From 2155420d71f75f6c6448f6bda5591335fea8459e Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Fri, 18 Jan 2019 11:13:29 +0100 Subject: [PATCH 001/262] implement custom fields for node monitor view Former-commit-id: d9dd515a726d1fa7cc5855b016270b9ef083cb6f --- .../agentes/status_monitor_custom_fields.php | 240 +++++ .../operation/agentes/status_monitor.php | 939 ++++++++++-------- pandora_console/pandoradb_data.sql | 1 + 3 files changed, 757 insertions(+), 423 deletions(-) create mode 100644 pandora_console/godmode/agentes/status_monitor_custom_fields.php diff --git a/pandora_console/godmode/agentes/status_monitor_custom_fields.php b/pandora_console/godmode/agentes/status_monitor_custom_fields.php new file mode 100644 index 0000000000..e01839c40a --- /dev/null +++ b/pandora_console/godmode/agentes/status_monitor_custom_fields.php @@ -0,0 +1,240 @@ + 'status_monitor_fields', + 'value' => $status_monitor_fields + ); + + //update 'status_monitor_fields' in tconfig table to keep the value at update. + $result = db_process_sql_update('tconfig', $values, + array ('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(); +$status_monitor_fields = ''; +$fields_selected = explode (',', $config['status_monitor_fields']); + +$result_selected = array(); + +//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 = __('Went to critical'); + break; + } + $result_selected[$field_selected] = $result; + } +} + +echo '

'.__('Show monitor detail fields').'

'; + +$table = new stdClass(); +$table->width = '100%'; +$table->class = 'databox filters'; + +$table->size = array(); +//~ $table->size[0] = '20%'; +$table->size[1] = '10px'; +//~ $table->size[2] = '20%'; + +$table->style[0] = 'text-align:center;'; +$table->style[2] = 'text-align:center;'; + +$table->data = array(); + +$fields_available = array(); + +$fields_available['policy'] = __('Policy'); +$fields_available['agent'] = __('Agent'); +$fields_available['data_type'] = __('Data type'); +$fields_available['module_name'] = __('Module name'); +$fields_available['server_type'] = __('Server type'); +$fields_available['interval'] = __('Interval'); +$fields_available['status'] = __('Status'); +$fields_available['graph'] = __('Graph'); +$fields_available['warn'] = __('Warn'); +$fields_available['data'] = __('Data'); +$fields_available['timestamp'] = __('Timestamp'); +$fields_available['to_critical'] = __('Went to critical'); + +//remove fields already selected +foreach ($fields_available as $key=>$available) { + foreach ($result_selected as $selected) { + if ($selected == $available) { + unset($fields_available[$key]); + } + } +} + +$table->data[0][0] = '' . __('Fields available').''; +$table->data[1][0] = html_print_select ($fields_available, 'fields_available[]', true, '', '', 0, true, true, false, '', false, 'width: 300px'); +$table->data[1][1] = '' . + html_print_image('images/darrowright.png', true, + array('id' => 'right', 'title' => __('Add fields to select'))) . + ''; +$table->data[1][1] .= '



' . + html_print_image('images/darrowleft.png', true, + array('id' => 'left', 'title' => __('Delete fields to select'))) . + ''; + +$table->data[0][1] = ''; +$table->data[0][2] = '' . __('Fields selected') . ''; +$table->data[1][2] = html_print_select($result_selected, + 'fields_selected[]', true, '', '', 0, true, true, false, '', false, 'width: 300px'); + +echo '
'; +html_print_table($table); + +echo '
'; + html_print_submit_button (__('Update'), 'upd_button', false, 'class="sub upd"'); +echo ''; +echo '
'; +?> + + diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 724feb4aea..dff51edd17 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -36,9 +36,38 @@ enterprise_include_once ('include/functions_metaconsole.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); if (! defined ('METACONSOLE')) { - //Header - ui_print_page_header (__('Monitor detail'), - 'images/brick.png', false); + + $section = (string) get_parameter ("section", "view"); + + + $buttons['fields'] = array('active' => false, + 'text' => '' . + html_print_image("images/custom_columns.png", true, array("title" => __('Custom fields'))) . '', + 'operation' => true); + + $buttons['view'] = array('active' => false, + 'text' => '' . + html_print_image("images/list.png", true, array("title" => __('View'))) . '', + 'operation' => true); + + + switch ($section) { + case 'fields': + $buttons['fields']['active'] = true; + $subpage = ' - ' . __('Custom fields'); + break; + default: + $buttons['view']['active'] = true; + break; + } + + ui_print_page_header (__("Monitor detail") . $subpage, "", false, "", true, $buttons); + + if ($section == 'fields') { + require_once($config["homedir"] . '/godmode/agentes/status_monitor_custom_fields.php'); + exit(); + } + } else { @@ -882,60 +911,90 @@ if (!empty($result)) { $table->size = array (); $table->align = array (); - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) - $table->head[0] = '' . __('P.') . ''; +$show_fields = explode (',', $config['status_monitor_fields']); - $table->head[1] = __('Agent'); - $table->head[1] .=' ' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . ''; - $table->head[2] = __('Data Type'); - $table->head[2] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectTypeDown, 'alt' => 'down')) . ''; - - $table->align[2] = 'left'; - - $table->head[3] = __('Module name'); - $table->head[3] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; - - $table->head[4] = __('Server type'); - $table->head[4] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; - - $table->head[5] = __('Interval'); - $table->head[5] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectIntervalUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectIntervalDown, 'alt' => 'down')) . ''; - $table->align[5] = 'left'; - - $table->head[6] = __('Status'); - $table->head[6] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; - - $table->align[6] = 'left'; - - $table->head[7] = __('Graph'); - $table->align[7] = 'left'; - - $table->head[8] = __('Warn'); - $table->align[8] = 'left'; - - $table->head[9] = __('Data'); - $table->align[9] = 'left'; - if ( is_metaconsole() ) { - $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; + if (in_array('policy', $show_fields)) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) + $table->head[0] = '' . __('P.') . ''; } - $table->head[10] = __('Timestamp'); - $table->head[10] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTimestampUp, 'alt' => 'up')) . '' . - '' . html_print_image('images/sort_down.png', true, array('style' => $selectTimestampDown, 'alt' => 'down')) . ''; - $table->align[10] = 'left'; + if (in_array('agent', $show_fields) || is_metaconsole()) { + $table->head[1] = __('Agent'); + $table->head[1] .=' ' . html_print_image('images/sort_up.png', true, array('style' => $selectAgentNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectAgentNameDown, 'alt' => 'down')) . ''; + } + + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $table->head[2] = __('Data Type'); + $table->head[2] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTypeUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectTypeDown, 'alt' => 'down')) . ''; + + $table->align[2] = 'left'; + } + + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $table->head[3] = __('Module name'); + $table->head[3] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; + } + + if (in_array('server_type', $show_fields) || is_metaconsole()) { + $table->head[4] = __('Server type'); + $table->head[4] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectModuleNameUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectModuleNameDown, 'alt' => 'down')) . ''; + } + + if (in_array('interval', $show_fields) || is_metaconsole()) { + $table->head[5] = __('Interval'); + $table->head[5] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectIntervalUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectIntervalDown, 'alt' => 'down')) . ''; + $table->align[5] = 'left'; + } + + if (in_array('status', $show_fields) || is_metaconsole()) { + $table->head[6] = __('Status'); + $table->head[6] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; + + $table->align[6] = 'left'; + } + + if (in_array('graph', $show_fields) || is_metaconsole()) { + $table->head[7] = __('Graph'); + $table->align[7] = 'left'; + } + + if (in_array('warn', $show_fields) || is_metaconsole()) { + $table->head[8] = __('Warn'); + $table->align[8] = 'left'; + } + + if (in_array('data', $show_fields) || is_metaconsole()) { + $table->head[9] = __('Data'); + $table->align[9] = 'left'; + if ( is_metaconsole() ) { + $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; + } + } + + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + $table->head[10] = __('Timestamp'); + $table->head[10] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectTimestampUp, 'alt' => 'up')) . '' . + '' . html_print_image('images/sort_down.png', true, array('style' => $selectTimestampDown, 'alt' => 'down')) . ''; + $table->align[10] = 'left'; + } + + if (in_array('to_critical', $show_fields)) { + $table->head[11] = __('Went to critical'); + } $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo', 'nombre', 'web_content_string'); foreach ($result as $row) { + //Avoid unset, null and false value if (empty($row['server_name'])) $row['server_name'] = ""; @@ -957,440 +1016,474 @@ if (!empty($result)) { } $data = array (); - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - if(is_metaconsole()){ - $node = metaconsole_get_connection_by_id($row['server_id']); - if (metaconsole_load_external_db($node) !== NOERR) { - // Restore the default connection. - metaconsole_restore_db(); - $errors++; - break; - } - } - $policyInfo = policies_info_module_policy($row['id_agente_modulo']); - - if ($policyInfo === false) - $data[0] = ''; - else { - $linked = policies_is_module_linked($row['id_agente_modulo']); - - $adopt = false; - if (policies_is_module_adopt($row['id_agente_modulo'])) { - $adopt = true; + if (in_array('policy', $show_fields) || is_metaconsole()) { + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + if(is_metaconsole()){ + $node = metaconsole_get_connection_by_id($row['server_id']); + if (metaconsole_load_external_db($node) !== NOERR) { + // Restore the default connection. + metaconsole_restore_db(); + $errors++; + break; + } } - if ($linked) { - if ($adopt) { - $img = 'images/policies_brick.png'; - $title = __('(Adopt) ') . $policyInfo['name_policy']; + $policyInfo = policies_info_module_policy($row['id_agente_modulo']); + + if ($policyInfo === false) + $data[0] = ''; + else { + $linked = policies_is_module_linked($row['id_agente_modulo']); + + $adopt = false; + if (policies_is_module_adopt($row['id_agente_modulo'])) { + $adopt = true; + } + + if ($linked) { + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ') . $policyInfo['name_policy']; + } + else { + $img = 'images/policies.png'; + $title = $policyInfo['name_policy']; + } } else { - $img = 'images/policies.png'; - $title = $policyInfo['name_policy']; + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Unlinked) (Adopt) ') . $policyInfo['name_policy']; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $policyInfo['name_policy']; + } } + if(is_metaconsole()){ + $data[0] = '' . + html_print_image($img,true, array('title' => $title)) . + ''; + } + else{ + $data[0] = '' . + html_print_image($img,true, array('title' => $title)) . + ''; + } + } + + if(is_metaconsole()){ + metaconsole_restore_db(); + } + } + } + + if (in_array('agent', $show_fields) || is_metaconsole()) { + $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; + + // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view + if (defined('METACONSOLE')) { + $agent_link = ''; + $agent_alias = ui_print_truncate_text($agent_alias, + 'agent_small', false, true, false, '[…]', + 'font-size:7.5pt;'); + if (can_user_access_node ()) { + $data[1] = $agent_link . '' . $agent_alias . ''; } else { - if ($adopt) { - $img = 'images/policies_not_brick.png'; - $title = __('(Unlinked) (Adopt) ') . $policyInfo['name_policy']; - } - else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ') . $policyInfo['name_policy']; - } + $data[1] = $agent_alias; } - if(is_metaconsole()){ - $data[0] = '' . - html_print_image($img,true, array('title' => $title)) . - ''; - } - else{ - $data[0] = '' . - html_print_image($img,true, array('title' => $title)) . - ''; - } - } - - if(is_metaconsole()){ - metaconsole_restore_db(); - } - } - - $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; - - // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view - if (defined('METACONSOLE')) { - $agent_link = ''; - $agent_alias = ui_print_truncate_text($agent_alias, - 'agent_small', false, true, false, '[…]', - 'font-size:7.5pt;'); - if (can_user_access_node ()) { - $data[1] = $agent_link . '' . $agent_alias . ''; } else { - $data[1] = $agent_alias; + $data[1] = ''; + $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); + $data[1] .= ''; } } - else { - $data[1] = ''; - $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); - $data[1] .= ''; - } - - $data[2] = html_print_image('images/' . modules_show_icon_type ($row['module_type']), true); - $agent_groups = is_metaconsole() - ? $row['groups_in_server'] - : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); - if (check_acl_one_of_groups ($config['id_user'], $agent_groups, 'AW')) { - $show_edit_icon = true; - if (defined('METACONSOLE')) { - if (!can_user_access_node ()) { - $show_edit_icon = false; + if (in_array('data_type', $show_fields) || is_metaconsole()) { + $data[2] = html_print_image('images/' . modules_show_icon_type ($row['module_type']), true); + $agent_groups = is_metaconsole() + ? $row['groups_in_server'] + : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); + if (check_acl_one_of_groups ($config['id_user'], $agent_groups, 'AW')) { + $show_edit_icon = true; + if (defined('METACONSOLE')) { + if (!can_user_access_node ()) { + $show_edit_icon = false; + } + + $url_edit_module = $row['server_url'] . 'index.php?' . + 'sec=gagente&' . + 'sec2=godmode/agentes/configurar_agente&' . + 'id_agente=' . $row['id_agent'] . '&' . + 'tab=module&' . + 'id_agent_module=' . $row['id_agente_modulo'] . '&' . + 'edit_module=1' . + '&loginhash=auto&loginhash_data=' . $row['hashdata'] . '&loginhash_user=' . str_rot13($row['user']); + } + else { + $url_edit_module = 'index.php?' . + 'sec=gagente&' . + 'sec2=godmode/agentes/configurar_agente&' . + 'id_agente=' . $row['id_agent'] . '&' . + 'tab=module&' . + 'id_agent_module=' . $row['id_agente_modulo'] . '&' . + 'edit_module=1'; } - $url_edit_module = $row['server_url'] . 'index.php?' . - 'sec=gagente&' . - 'sec2=godmode/agentes/configurar_agente&' . - 'id_agente=' . $row['id_agent'] . '&' . - 'tab=module&' . - 'id_agent_module=' . $row['id_agente_modulo'] . '&' . - 'edit_module=1' . - '&loginhash=auto&loginhash_data=' . $row['hashdata'] . '&loginhash_user=' . str_rot13($row['user']); - } - else { - $url_edit_module = 'index.php?' . - 'sec=gagente&' . - 'sec2=godmode/agentes/configurar_agente&' . - 'id_agente=' . $row['id_agent'] . '&' . - 'tab=module&' . - 'id_agent_module=' . $row['id_agente_modulo'] . '&' . - 'edit_module=1'; - } - - if ($show_edit_icon) { - $data[2] .= '' . - html_print_image('images/config.png', true, - array('alt' => '0', 'border' => '', 'title' => __('Edit'))) . - ''; + if ($show_edit_icon) { + $data[2] .= '' . + html_print_image('images/config.png', true, + array('alt' => '0', 'border' => '', 'title' => __('Edit'))) . + ''; + } } } - $data[3] = ui_print_truncate_text($row['module_name'], 'agent_small', false, true, true); - if ($row['extended_info'] != '') { - $data[3] .= ui_print_help_tip ($row['extended_info'], true, '/images/default_list.png'); + if (in_array('module_name', $show_fields) || is_metaconsole()) { + $data[3] = ui_print_truncate_text($row['module_name'], 'agent_small', false, true, true); + if ($row['extended_info'] != '') { + $data[3] .= ui_print_help_tip ($row['extended_info'], true, '/images/default_list.png'); + } + if ($row['tags'] != '') { + $data[3] .= html_print_image('/images/tag_red.png', true, + array( + 'title' => $row['tags'], + 'style' => 'width: 20px; margin-left: 3px;')); + } } - if ($row['tags'] != '') { - $data[3] .= html_print_image('/images/tag_red.png', true, - array( - 'title' => $row['tags'], - 'style' => 'width: 20px; margin-left: 3px;')); - } - $data[4] = servers_show_type ($row['id_modulo']); + + if (in_array('server_type', $show_fields) || is_metaconsole()) + $data[4] = servers_show_type ($row['id_modulo']); - $data[5] = ($row['module_interval'] == 0) ? - human_time_description_raw($row['agent_interval']) - : - human_time_description_raw($row['module_interval']); - if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 || - $row['module_type'] > 23) && $row['module_type'] != 100)) { - $data[6] = ui_print_status_image(STATUS_MODULE_NO_DATA, - __('NOT INIT'), true); + if (in_array('interval', $show_fields) || is_metaconsole()) { + $data[5] = ($row['module_interval'] == 0) ? + human_time_description_raw($row['agent_interval']) + : + human_time_description_raw($row['module_interval']); } - elseif ($row['estado'] == 0) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image(STATUS_MODULE_OK, - __('NORMAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + + if (in_array('status', $show_fields) || is_metaconsole()) { + if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 || + $row['module_type'] > 23) && $row['module_type'] != 100)) { + $data[6] = ui_print_status_image(STATUS_MODULE_NO_DATA, + __('NOT INIT'), true); + } + elseif ($row['estado'] == 0) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image(STATUS_MODULE_OK, + __('NORMAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + } + else { + $data[6] = ui_print_status_image(STATUS_MODULE_OK, + __('NORMAL') . ': ' . $row['datos'], true); + } + } + elseif ($row['estado'] == 1) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image(STATUS_MODULE_CRITICAL, + __('CRITICAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + } + else { + $data[6] = ui_print_status_image(STATUS_MODULE_CRITICAL, + __('CRITICAL') . ': ' . $row['datos'], true); + } + } + elseif ($row['estado'] == 2) { + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image(STATUS_MODULE_WARNING, + __('WARNING') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + } + else { + $data[6] = ui_print_status_image(STATUS_MODULE_WARNING, + __('WARNING') . ': ' . $row['datos'], true); + } } else { - $data[6] = ui_print_status_image(STATUS_MODULE_OK, - __('NORMAL') . ': ' . $row['datos'], true); + $last_status = modules_get_agentmodule_last_status( + $row['id_agente_modulo']); + switch($last_status) { + case 0: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . ' - ' . __('Last status') . " " . + __('NORMAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + } + else { + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . ' - ' . __('Last status') . " " . + __('NORMAL') . ': ' . $row['datos'], true); + } + break; + case 1: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . ' - ' . __('Last status') ." " . + __('CRITICAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + } + else { + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . ' - ' . __('Last status') ." " . + __('CRITICAL') . ': ' . $row['datos'], true); + } + break; + case 2: + if (is_numeric($row['datos'])) { + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . ' - ' . __('Last status') . " " . + __('WARNING') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + } + else { + $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, + __('UNKNOWN') . ' - ' . __('Last status') . " " . + __('WARNING') . ': ' . $row['datos'], true); + } + break; + } } } - elseif ($row['estado'] == 1) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image(STATUS_MODULE_CRITICAL, - __('CRITICAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); + + if (in_array('graph', $show_fields) || is_metaconsole()) { + $data[7] = ""; + + $acl_graphs = false; + + // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions + if (!is_metaconsole()) { + $acl_graphs = check_acl($config['id_user'], $row['id_group'], 'RR'); } else { - $data[6] = ui_print_status_image(STATUS_MODULE_CRITICAL, - __('CRITICAL') . ': ' . $row['datos'], true); - } - } - elseif ($row['estado'] == 2) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image(STATUS_MODULE_WARNING, - __('WARNING') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); - } - else { - $data[6] = ui_print_status_image(STATUS_MODULE_WARNING, - __('WARNING') . ': ' . $row['datos'], true); - } - } - else { - $last_status = modules_get_agentmodule_last_status( - $row['id_agente_modulo']); - switch($last_status) { - case 0: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, - __('UNKNOWN') . ' - ' . __('Last status') . " " . - __('NORMAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); - } - else { - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, - __('UNKNOWN') . ' - ' . __('Last status') . " " . - __('NORMAL') . ': ' . $row['datos'], true); - } - break; - case 1: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, - __('UNKNOWN') . ' - ' . __('Last status') ." " . - __('CRITICAL') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); - } - else { - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, - __('UNKNOWN') . ' - ' . __('Last status') ." " . - __('CRITICAL') . ': ' . $row['datos'], true); - } - break; - case 2: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, - __('UNKNOWN') . ' - ' . __('Last status') . " " . - __('WARNING') . ': ' . remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), true); - } - else { - $data[6] = ui_print_status_image(STATUS_MODULE_UNKNOWN, - __('UNKNOWN') . ' - ' . __('Last status') . " " . - __('WARNING') . ': ' . $row['datos'], true); - } - break; - } - } - - $data[7] = ""; - - $acl_graphs = false; - - // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions - if (!is_metaconsole()) { - $acl_graphs = check_acl($config['id_user'], $row['id_group'], 'RR'); - } - else { - $acl_graphs = true; - } - - if ($row['history_data'] == 1 && $acl_graphs) { - $graph_type = return_graphtype ($row['module_type']); - - $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); - $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); - $win_handle = 'day_'.$handle; - - $graph_params = array( - 'type' => $graph_type, - 'period' => SECONDS_1DAY, - 'id' => $row['id_agente_modulo'], - 'label' => base64_encode($row['module_name']), - 'refresh' => SECONDS_10MINUTES - ); - - if (is_metaconsole() && isset($row['server_id'])) { - // Set the server id - $graph_params['server'] = $row['server_id']; + $acl_graphs = true; } - $graph_params_str = http_build_query($graph_params); - - $link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')'; + if ($row['history_data'] == 1 && $acl_graphs) { + $graph_type = return_graphtype ($row['module_type']); + + $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); + $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); + $win_handle = 'day_'.$handle; + + $graph_params = array( + 'type' => $graph_type, + 'period' => SECONDS_1DAY, + 'id' => $row['id_agente_modulo'], + 'label' => base64_encode($row['module_name']), + 'refresh' => SECONDS_10MINUTES + ); + + if (is_metaconsole() && isset($row['server_id'])) { + // Set the server id + $graph_params['server'] = $row['server_id']; + } + + $graph_params_str = http_build_query($graph_params); + + $link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')'; - $data[7] = get_module_realtime_link_graph($row); + $data[7] = get_module_realtime_link_graph($row); - if(!is_snapshot_data($row['datos'])){ - $data[7] .= '' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) . ''; + if(!is_snapshot_data($row['datos'])){ + $data[7] .= '' . html_print_image('images/chart_curve.png', true, array('border' => '0', 'alt' => '')) . ''; + } + $data[7] .= '' . + html_print_image ('images/binary.png', true, + array ('border' => '0', 'alt' => '')) . ''; + + $data[7] .= '' . + $row['module_name'] . + ''; } - $data[7] .= '' . - html_print_image ('images/binary.png', true, - array ('border' => '0', 'alt' => '')) . ''; - - $data[7] .= '' . - $row['module_name'] . - ''; } - - $data[8] = ui_print_module_warn_value($row['max_warning'], - $row['min_warning'], $row['str_warning'], $row['max_critical'], - $row['min_critical'], $row['str_critical']); - if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { - if ( $config['render_proc'] ) { - switch($row['module_type']) { - case 2: - case 6: - case 9: - case 18: - case 21: - case 31: - if ( $row['datos'] >= 1 ) - $salida = $config['render_proc_ok']; - else - $salida = $config['render_proc_fail']; - break; - default: - switch($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') - $salida = human_milliseconds_to_string($row['datos']); - else + if (in_array('warn', $show_fields) || is_metaconsole()) { + + $data[8] = ui_print_module_warn_value($row['max_warning'], + $row['min_warning'], $row['str_warning'], $row['max_critical'], + $row['min_critical'], $row['str_critical']); + + if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { + if ( $config['render_proc'] ) { + switch($row['module_type']) { + case 2: + case 6: + case 9: + case 18: + case 21: + case 31: + if ( $row['datos'] >= 1 ) + $salida = $config['render_proc_ok']; + else + $salida = $config['render_proc_fail']; + break; + default: + switch($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $salida = human_milliseconds_to_string($row['datos']); + else + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + default: $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; - } + break; + } + break; + } + } + else { + switch($row['module_type']) { + case 15: + $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); + if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') + $salida = human_milliseconds_to_string($row['datos']); + else + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); + break; + default: + $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); break; } - } - else { - switch($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') - $salida = human_milliseconds_to_string($row['datos']); - else - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; } - } - - // Show units ONLY in numeric data types - if (isset($row['unit'])) { - $data_macro = modules_get_unit_macro($row['datos'],$row['unit']); - if($data_macro) { - $salida = $data_macro; - } else { - $salida .= ' ' . '' . io_safe_output($row['unit']) . ''; - if(strlen($salida) > $config['agent_size_text_small']) { - $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); - //clean tag - $text_aux = explode(' $row['id_agente_modulo'], - 'interval' => $row['current_interval'], - 'module_name' => $row['module_name'], - 'id_node' => $row['server_id'] - )); - $salida = ui_get_snapshot_image($link, $is_snapshot) . '  '; - } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); - if ($module_value == $sub_string) { - if ($module_value == 0 && !$sub_string) { - $salida = 0; - } - else { - $data_macro = modules_get_unit_macro($row['datos'],$row['unit']); - if($data_macro) { - $salida = $data_macro; + $salida .= ' ' . '' . io_safe_output($row['unit']) . ''; + if(strlen($salida) > $config['agent_size_text_small']) { + $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); + //clean tag + $text_aux = explode(' $row['id_agente_modulo'], + 'interval' => $row['current_interval'], + 'module_name' => $row['module_name'], + 'id_node' => $row['server_id'] + )); + $salida = ui_get_snapshot_image($link, $is_snapshot) . '  '; + } else { + $sub_string = substr(io_safe_output($row['datos']), 0, 12); + if ($module_value == $sub_string) { + if ($module_value == 0 && !$sub_string) { + $salida = 0; + } + else { + $data_macro = modules_get_unit_macro($row['datos'],$row['unit']); + if($data_macro) { + $salida = $data_macro; + } else { + $salida = $row['datos']; + } + } } else { - //Fixed the data from Selenium Plugin - if ($module_value != strip_tags($module_value)) { - $module_value = io_safe_input($module_value); + //Fixed the goliat sends the strings from web + //without HTML entities + if ($is_web_content_string) { $sub_string = substr($row['datos'], 0, 12); } else { - $sub_string = substr(io_safe_output($row['datos']),0, 12); + //Fixed the data from Selenium Plugin + if ($module_value != strip_tags($module_value)) { + $module_value = io_safe_input($module_value); + $sub_string = substr($row['datos'], 0, 12); + } + else { + $sub_string = substr(io_safe_output($row['datos']),0, 12); + } + } + + if ($module_value == $sub_string) { + $salida = $module_value; + } + else { + $salida = "" . + $module_value . + "" . + "" . + '' . + $sub_string . ' ' . + "" . + html_print_image('images/rosette.png', true) . ''; } - } - - if ($module_value == $sub_string) { - $salida = $module_value; - } - else { - $salida = "" . - $module_value . - "" . - "" . - '' . - $sub_string . ' ' . - "" . - html_print_image('images/rosette.png', true) . ''; } } } } + + if (in_array('data', $show_fields) || is_metaconsole()) + $data[9] = $salida; - $data[9] = $salida; - - if ($row['module_interval'] > 0) - $interval = $row['module_interval']; - else - $interval = $row['agent_interval']; - - if ($row['estado'] == 3) { - $option = array ('html_attr' => 'class="redb"','style' => 'font-size:7pt;'); + if (in_array('timestamp', $show_fields) || is_metaconsole()) { + if ($row['module_interval'] > 0) + $interval = $row['module_interval']; + else + $interval = $row['agent_interval']; + + if ($row['estado'] == 3) { + $option = array ('html_attr' => 'class="redb"','style' => 'font-size:7pt;'); + } + else { + $option = array ('style' => 'font-size:7pt;'); + } + $data[10] = ui_print_timestamp ($row['utimestamp'], true, $option); } - else { - $option = array ('style' => 'font-size:7pt;'); + + if (in_array('to_critical', $show_fields)) { + + if ($row['estado'] == 1) { + $to_critical_timestamp = db_get_sql ('SELECT utimestamp FROM tevento WHERE id_agentmodule=' . $row['id_agente_modulo'] . ' AND event_type LIKE "going_up_critical" ORDER BY utimestamp DESC'); + $data[11] = ui_print_timestamp ($to_critical_timestamp, true, $option); + } else { + $data[11] = '-'; + } + } - $data[10] = ui_print_timestamp ($row['utimestamp'], true, $option); array_push ($table->data, $data); } diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 53b7b79257..162c5ff45d 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -85,6 +85,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('netflow_nfdump', '/usr/bin/nfdump'), ('netflow_max_resolution', '50'), ('event_fields', 'evento,id_agente,estado,timestamp'), +('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'), ('list_ACL_IPs_for_API', '127.0.0.1'), ('enable_pass_policy', 0), ('pass_size', 4), From 902e8589f38357b1a3cdc6e04542d2169986da74 Mon Sep 17 00:00:00 2001 From: samucarc Date: Tue, 29 Jan 2019 15:30:04 +0100 Subject: [PATCH 002/262] Apply a policy into an agent with CLI Former-commit-id: 87037688b1dd3a551c0585319ec545c855484a97 --- pandora_server/util/pandora_manage.pl | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 05547a779f..2dd9ee14c4 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -196,7 +196,7 @@ sub help_screen{ print "\nINCIDENTS:\n\n" unless $param ne ''; help_screen_line('--create_incident', " <description> <origin> <status> <priority 0 for Informative, \n\t 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance>\n\t <group> [<owner>]", 'Create incidents'); print "\nPOLICIES:\n\n" unless $param ne ''; - help_screen_line('--apply_policy', '<policy_name>', 'Force apply a policy'); + help_screen_line('--apply_policy', '<id_policy> [<id_agent> <return> <name agent>]', 'Force apply a policy'); help_screen_line('--apply_all_policies', '', 'Force apply to all the policies'); help_screen_line('--add_agent_to_policy', '<agent_name> <policy_name>', 'Add an agent to a policy'); help_screen_line('--remove_agent_from_policy', '<policy_id> <agent_id>', 'Delete an agent to a policy'); @@ -3509,19 +3509,11 @@ sub cli_delete_data($) { ############################################################################## sub cli_apply_policy() { - my $policy_name = @ARGV[2]; - - my $policy_id = enterprise_hook('get_policy_id',[$dbh, safe_input($policy_name)]); - exist_check($policy_id,'policy',$policy_name); - - my $ret = enterprise_hook('pandora_add_policy_queue', [$dbh, $conf, $policy_id, 'apply']); - - if($ret == -1) { - print_log "[ERROR] Operation 'apply' cannot be added to policy '$policy_name' because is duplicated in queue or incompatible with others operations\n\n"; - exit; - } - - print_log "[INFO] Added operation 'apply' to policy '$policy_name'\n\n"; + my ($id_policy, $id_agent, $name, $return) = @ARGV[2..5]; + + # Call the API. + my $result = api_call(\%conf, 'set', 'apply_policy', $id_policy, $id_agent, "$name|$return"); + print "\n$result\n"; } ############################################################################## @@ -5918,7 +5910,7 @@ sub pandora_manage_main ($$$) { cli_delete_data($ltotal); } elsif ($param eq '--apply_policy') { - param_check($ltotal, 1); + param_check($ltotal, 4, 3); cli_apply_policy(); } elsif ($param eq '--disable_policy_alerts') { From dc3d7cc5e2669475a3a118e13dca27e0def65464 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Wed, 30 Jan 2019 11:56:21 +0100 Subject: [PATCH 003/262] notifications, first approach db schema Former-commit-id: 1142c65f175c13eaaff9b26a9887f4ef519e9612 --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 88 +++++++++++++++ pandora_console/pandoradb.sql | 101 +++++++++++++++--- pandora_console/pandoradb_data.sql | 12 +++ 3 files changed, 187 insertions(+), 14 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 5dc7cd70c4..e62e76efd5 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1868,3 +1868,91 @@ CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Table `tnotification_source` +-- ----------------------------------------------------- +CREATE TABLE `tnotification_source` ( + `id` serial, + `description` VARCHAR(255) DEFAULT NULL, + `icon` text, + `max_postpone_time` int(11) DEFAULT NULL, + `enabled` int(1) DEFAULT NULL, + `user_editable` int(1) DEFAULT NULL, + `also_mail` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `tnotification_source` +-- +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 0); + +-- ----------------------------------------------------- +-- Table `tmensajes` +-- ----------------------------------------------------- +ALTER TABLE `tmensajes` ADD COLUMN `url` TEXT; +ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0'; +ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL; +ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + + +-- ---------------------------------------------------------------------- +-- Table `tnotification_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_user` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_user` VARCHAR(60) NOT NULL, + `utimestamp_read` BIGINT(20), + `utimestamp_erased` BIGINT(20), + `postpone` INT, + PRIMARY KEY (`id_mensaje`,`id_user`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_group` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_group` mediumint(4) UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`,`id_group`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + PRIMARY KEY (`id_source`,`id_group`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7f8197540b..c70650c70b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -719,20 +719,6 @@ CREATE TABLE IF NOT EXISTS `tlink` ( PRIMARY KEY (`id_link`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- ----------------------------------------------------- --- Table `tmensajes` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tmensajes` ( - `id_mensaje` int(10) unsigned NOT NULL auto_increment, - `id_usuario_origen` varchar(60) NOT NULL default '', - `id_usuario_destino` varchar(60) NOT NULL default '', - `mensaje` text NOT NULL, - `timestamp` bigint (20) unsigned NOT NULL default '0', - `subject` varchar(255) NOT NULL default '', - `estado` int(4) unsigned NOT NULL default '0', - PRIMARY KEY (`id_mensaje`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- ---------------------------------------------------------------------- -- Table `tmodule_group` -- ---------------------------------------------------------------------- @@ -1177,6 +1163,93 @@ CREATE TABLE IF NOT EXISTS `treset_pass_history` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ----------------------------------------------------- +-- Table `tnotification_source` +-- ----------------------------------------------------- +CREATE TABLE `tnotification_source` ( + `id` serial, + `description` VARCHAR(255) DEFAULT NULL, + `icon` text, + `max_postpone_time` int(11) DEFAULT NULL, + `enabled` int(1) DEFAULT NULL, + `user_editable` int(1) DEFAULT NULL, + `also_mail` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Table `tmensajes` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tmensajes` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `id_usuario_origen` VARCHAR(60) NOT NULL DEFAULT '', + `mensaje` TEXT NOT NULL, + `timestamp` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', + `subject` VARCHAR(255) NOT NULL DEFAULT '', + `estado` INT(4) UNSIGNED NOT NULL DEFAULT '0', + `url` TEXT, + `response_mode` VARCHAR(200) DEFAULT NULL, + `citicity` INT(10) UNSIGNED DEFAULT '0', + `id_source` BIGINT(20) UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`), + UNIQUE KEY `id_mensaje` (`id_mensaje`), + KEY `tsource_fk` (`id_source`), + CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_user` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_user` VARCHAR(60) NOT NULL, + `utimestamp_read` BIGINT(20), + `utimestamp_erased` BIGINT(20), + `postpone` INT, + PRIMARY KEY (`id_mensaje`,`id_user`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_group` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_group` mediumint(4) UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`,`id_group`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_group` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + PRIMARY KEY (`id_source`,`id_group`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ---------------------------------------------------------------------- -- Table `tnews` -- ---------------------------------------------------------------------- diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 32adab0421..e803c83d82 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1267,3 +1267,15 @@ INSERT INTO `tcontainer` SET `name` = 'Default graph container'; INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', 'pagina, html_err_code, _tiempo_', 1); + +-- +-- Dumping data for table `tnotification_source` +-- +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 0); + From fa6c4d5bc9f32e75fa1f98109e602d11b30be8d8 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Wed, 30 Jan 2019 11:56:47 +0100 Subject: [PATCH 004/262] notifications, WIP: new lib defined Former-commit-id: 430ac2e090f91403fc074d2a9b37ab36de10d5a9 --- .../include/functions_messages.php | 652 +++++++++++------- .../include/functions_notifications.php | 53 ++ .../operation/messages/message_list.php | 470 +++++++------ 3 files changed, 698 insertions(+), 477 deletions(-) create mode 100644 pandora_console/include/functions_notifications.php diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index dec3dc2b62..675b9c2a38 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -1,321 +1,451 @@ <?php -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation; version 2 +require_once $config['homedir'].'/include/functions_users.php'; +require_once $config['homedir'].'/include/functions_groups.php'; +require_once $config['homedir'].'/include/functions_notifications.php'; -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. /** - * @package Include - * @subpackage Messages - */ - -require_once($config['homedir'] . "/include/functions_users.php"); -require_once ($config['homedir'].'/include/functions_groups.php'); - -/** * Creates a private message to be forwarded to other people - * - * @param string $usuario_origen The sender of the message - * @param string $usuario_destino The receiver of the message - * @param string $subject Subject of the message (much like E-Mail) - * @param string $mensaje The actual message. This message will be cleaned by io_safe_input - * (html is allowed but loose html chars will be translated) * - * @return bool true when delivered, false in case of error + * @param string $usuario_origen The sender of the message. + * @param string $usuario_destino The receiver of the message. + * @param string $subject Subject of the message (much like E-Mail). + * @param string $mensaje The actual message. This message will be + * cleaned by io_safe_input (html is allowed but + * loose html chars will be translated). + * + * @return boolean true when delivered, false in case of error */ -function messages_create_message ($usuario_origen, $usuario_destino, $subject, $mensaje) { - $users = users_get_info (); - - if (!array_key_exists ($usuario_origen, $users) || !array_key_exists ($usuario_destino, $users)) { - return false; //Users don't exist so don't send to them - } - - $values = array (); - $values["id_usuario_origen"] = $usuario_origen; - $values["id_usuario_destino"] = $usuario_destino; - $values["subject"] = $subject; - $values["mensaje"] = $mensaje; - $values["timestamp"] = get_system_time (); - - $return = db_process_sql_insert ("tmensajes", $values); - - if ($return === false) { - return false; - } - else { - return true; - } +function messages_create_message( + string $usuario_origen, + string $usuario_destino, + string $subject, + string $mensaje +) { + $users = users_get_info(); + + if (!array_key_exists($usuario_origen, $users) + || !array_key_exists($usuario_destino, $users) + ) { + return false; + // Users don't exist so don't send to them. + } + + // Create message. + $message_id = db_process_sql_insert( + 'tmensajes', + [ + 'id_usuario_origen' => $usuario_origen, + 'subject' => $subject, + 'mensaje' => $mensaje, + 'id_source' => get_notification_source_id('message'), + 'timestamp' => get_system_time(), + ] + ); + + // Update URL + // Update targets. + if ($message_id !== false) { + $return = db_process_sql_insert( + 'tnotification_user', + [ + 'id_mensaje' => $message_id, + 'id_user' => $usuario_destino, + ] + ); + } + + if ($return === false) { + return false; + } else { + return true; + } } -/** + +/** * Creates private messages to be forwarded to groups - * - * @param string The sender of the message - * @param string The receivers (group) of the message - * @param string Subject of the message (much like E-Mail) - * @param string The actual message. This message will be cleaned by io_safe_input - * (html is allowed but loose html chars will be translated) * - * @return bool true when delivered, false in case of error + * @param string $usuario_origen The sender of the message. + * @param string $dest_group The receivers (group) of the message. + * @param string $subject Subject of the message (much like E-Mail). + * @param string $mensaje The actual message. This message will be + * cleaned by io_safe_input (html is allowed but + * loose html chars will be translated). + * + * @return boolean true when delivered, false in case of error */ -function messages_create_group ($usuario_origen, $dest_group, $subject, $mensaje) { - $users = users_get_info (); - $group_users = groups_get_users ($dest_group); - - if (! array_key_exists ($usuario_origen, $users)) { - //Users don't exist in the system - return false; - } - elseif (empty ($group_users)) { - //There are no users in the group, so it hasn't failed although it hasn't done anything. - return true; - } - - // array unique - foreach ($group_users as $user) { - foreach ($user as $key=>$us) { - if ($key == 'id_user') { - $group_user[$us] = $us; - } - } - } - - foreach ($group_user as $user) { - $return = messages_create_message ($usuario_origen, get_user_id ($user), $subject, $mensaje); - if ($return === false) { - //Error sending message - return false; - } - } - - return true; +function messages_create_group( + string $usuario_origen, + string $dest_group, + string $subject, + string $mensaje +) { + $users = users_get_info(); + $group_users = groups_get_users($dest_group); + + if (! array_key_exists($usuario_origen, $users)) { + // Users don't exist in the system. + return false; + } else if (empty($group_users)) { + /* + There are no users in the group, so it hasn't failed + although it hasn't done anything. + */ + + return true; + } + + // Array unique. + foreach ($group_users as $user) { + foreach ($user as $key => $us) { + if ($key == 'id_user') { + $group_user[$us] = $us; + } + } + } + + foreach ($group_user as $user) { + $return = messages_create_message( + $usuario_origen, + get_user_id($user), + $subject, + $mensaje + ); + if ($return === false) { + // Error sending message. + return false; + } + } + + return true; } -/** + +/** * Deletes a private message - * - * @param int $id_message * - * @return bool true when deleted, false in case of error + * @param integer $id_message Message to be deleted. + * + * @return boolean true when deleted, false in case of error */ -function messages_delete_message ($id_message) { - global $config; - - $where = array( - //'id_usuario_destino' => $config["id_user"], - 'id_mensaje' => $id_message); - return (bool)db_process_sql_delete('tmensajes', $where); +function messages_delete_message(int $id_message) +{ + global $config; + // 'id_usuario_destino' => $config["id_user"], + $where = ['id_mensaje' => $id_message]; + return (bool) db_process_sql_delete('tmensajes', $where); } -/** + +/** * Marks a private message as read/unread - * - * @param int $message_id The message to modify - * @param bool $read To set unread pass 0, false or empty value * - * @return bool true when marked, false in case of error + * @param integer $message_id The message to modify. + * @param boolean $read To set unread pass 0, false or empty value. + * + * @return boolean true when marked, false in case of error */ -function messages_process_read ($message_id, $read = true) { - if (empty ($read)) { - $read = 0; - } - else { - $read = 1; - } - - return (bool) db_process_sql_update('tmensajes', array('estado' => $read), array('id_mensaje' => $message_id)); +function messages_process_read( + int $message_id, + bool $read=true +) { + if (empty($read)) { + $read = 0; + } else { + $read = 1; + } + + return (bool) db_process_sql_update( + 'tmensajes', + ['estado' => $read], + ['id_mensaje' => $message_id] + ); } -/** + +/** * Gets a private message * - * This function abstracts the database backend so it can simply be replaced with another system - * - * @param int $message_id + * This function abstracts the database backend so it can simply be + * replaced with another system + * + * @param integer $message_id Message to be retrieved. * * @return mixed False if it doesn't exist or a filled array otherwise */ -function messages_get_message ($message_id) { - global $config; - - $sql = sprintf("SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp - FROM tmensajes - WHERE id_usuario_destino='%s' AND id_mensaje=%d" , $config["id_user"], $message_id); - $row = db_get_row_sql ($sql); - - if (empty ($row)) { - return false; - } - - return $row; +function messages_get_message(int $message_id) +{ + global $config; + + $sql = sprintf( + "SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp + FROM tmensajes + WHERE id_usuario_destino='%s' AND id_mensaje=%d", + $config['id_user'], + $message_id + ); + $row = db_get_row_sql($sql); + + if (empty($row)) { + return false; + } + + return $row; } -/** + +/** * Gets a sent message * - * This function abstracts the database backend so it can simply be replaced with another system - * - * @param int $message_id + * This function abstracts the database backend so it can simply be + * replaced with another system + * + * @param integer $message_id Message to be retrieved. * * @return mixed False if it doesn't exist or a filled array otherwise */ -function messages_get_message_sent ($message_id) { - global $config; - - $sql = sprintf("SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp - FROM tmensajes - WHERE id_usuario_origen='%s' AND id_mensaje=%d" , $config["id_user"], $message_id); - $row = db_get_row_sql ($sql); - - if (empty ($row)) { - return false; - } - - return $row; +function messages_get_message_sent(int $message_id) +{ + global $config; + + $sql = sprintf( + "SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp + FROM tmensajes + WHERE id_usuario_origen='%s' AND id_mensaje=%d", + $config['id_user'], + $message_id + ); + $row = db_get_row_sql($sql); + + if (empty($row)) { + return false; + } + + return $row; } -/** +/** * Counts private messages * - * @param string $user - * @param bool $incl_read Whether or not to include read messages + * @param string $user Target user. + * @param boolean $incl_read Whether or not to include read messages. * - * @return int The number of messages this user has + * @return integer The number of messages this user has */ -function messages_get_count ($user = false, $incl_read = false) { - if (empty ($user)) { - global $config; - $user = $config["id_user"]; - } - - if (empty ($incl_read)) { - $filter = "AND estado = 0"; - } - else { - $filter = ""; - } - $sql = sprintf("SELECT COUNT(*) - FROM tmensajes WHERE id_usuario_destino='%s' %s", $user, $filter); - - return (int) db_get_sql ($sql); -} +function messages_get_count( + string $user='', + bool $incl_read=false +) { + if (empty($user)) { + global $config; + $user = $config['id_user']; + } -/** - * Counts sended messages - * - * @param string $user - * - * @return int The number of messages this user has sent - */ -function messages_get_count_sent ($user = false) { - if (empty ($user)) { - global $config; - $user = $config["id_user"]; - } - $sql = sprintf("SELECT COUNT(*) - FROM tmensajes WHERE id_usuario_origen='%s'", $user); - - return (int) db_get_sql ($sql); + if (!empty($incl_read)) { + // Retrieve only unread messages. + $filter = 'AND nu.uptimestap_read == NULL'; + } else { + // Do not filter. + $filter = ''; + } + + $sql = sprintf( + "SELECT count(*) FROM tmensajes tm + left join tnotification_user nu + ON tm.id_mensaje=nu.id_mensaje + left join tnotification_group ng + ON tm.id_mensaje=ng.id_mensaje + left join tusuario_perfil up + ON tm.id_mensaje=ng.id_mensaje + AND ng.id_group=up.id_grupo + WHERE (nu.id_user='%s' OR ng.id_group=0 OR up.id_grupo=ng.id_group) + %s", + $config['id_user'], + $filter + ); + + return (int) db_get_sql($sql); } -/** +/** + * Counts messages sent. + * + * @param string $user Target user. + * + * @return integer The number of messages this user has sent + */ +function messages_get_count_sent(string $user='') +{ + if (empty($user)) { + global $config; + $user = $config['id_user']; + } + + $sql = sprintf( + "SELECT COUNT(*) + FROM tmensajes WHERE id_usuario_origen='%s'", + $user + ); + + return (int) db_get_sql($sql); +} + + +/** * Get message overview in array * - * @param string $order How to order them valid: - * (status (default), subject, timestamp, sender) - * @param string $order_dir Direction of order (ASC = Ascending, DESC = Descending) + * @param string $order How to order them valid: + * (status (default), subject, timestamp, sender). + * @param string $order_dir Direction of order + * (ASC = Ascending, DESC = Descending). * - * @return int The number of messages this user has + * @return integer The number of messages this user has */ -function messages_get_overview ($order = "status", $order_dir = "ASC") { - global $config; - - switch ($order) { - case "timestamp": - case "sender": - case "subject": - break; - case "status": - default: - $order = "estado, timestamp"; - break; - } - - if ($order_dir != "ASC") { - $order .= " DESC"; - } - - $result = array (); - $return = db_get_all_rows_field_filter ('tmensajes', 'id_usuario_destino', $config["id_user"], $order); - - if ($return === false) { - return $result; - } - - foreach ($return as $message) { - $result[$message["id_mensaje"]]["sender"] = $message["id_usuario_origen"]; - $result[$message["id_mensaje"]]["subject"] = $message["subject"]; - $result[$message["id_mensaje"]]["timestamp"] = $message["timestamp"]; - $result[$message["id_mensaje"]]["status"] = $message["estado"]; - } - - return $result; +function messages_get_overview( + string $order='status', + string $order_dir='ASC' +) { + global $config; + + switch ($order) { + case 'timestamp':{ + } + case 'sender':{ + } + case 'subject':{ + } + break; + + case 'status': + default: + $order = 'estado, timestamp'; + break; + } + + if ($order_dir != 'ASC') { + $order .= ' DESC'; + } + + $sql = sprintf( + "SELECT * FROM tmensajes tm + left join tnotification_user nu + ON tm.id_mensaje=nu.id_mensaje + left join tnotification_group ng + ON tm.id_mensaje=ng.id_mensaje + left join tusuario_perfil up + ON tm.id_mensaje=ng.id_mensaje + AND ng.id_group=up.id_grupo + WHERE (nu.id_user='%s' OR ng.id_group=0 OR up.id_grupo=ng.id_group) + ORDER BY %s", + $config['id_user'], + $order + ); + + $result = []; + $return = db_get_all_rows_sql($sql); + + if ($return === false) { + return $result; + } + + foreach ($return as $message) { + $id_message = $message['id_mensaje']; + $result[$id_message]['sender'] = $message['id_usuario_origen']; + $result[$id_message]['subject'] = $message['subject']; + $result[$id_message]['timestamp'] = $message['timestamp']; + $result[$id_message]['status'] = $message['estado']; + } + + return $result; } -/** + +/** * Get sent message overview in array * - * @param string $order How to order them valid: - * (status (default), subject, timestamp, sender) - * @param string $order_dir Direction of order (ASC = Ascending, DESC = Descending) + * @param string $order How to order them valid: + * (status (default), subject, timestamp, sender). + * @param string $order_dir Direction of order + * (ASC = Ascending, DESC = Descending). * - * @return int The number of messages this user has + * @return integer The number of messages this user has */ -function messages_get_overview_sent ($order = "timestamp", $order_dir = "ASC") { - global $config; - - switch ($order) { - case "timestamp": - case "sender": - case "subject": - break; - case "status": - default: - $order = "estado, timestamp"; - break; - } - - if ($order_dir != "ASC") { - $order .= " DESC"; - } - - $result = array (); - $return = db_get_all_rows_field_filter ('tmensajes', 'id_usuario_origen', $config["id_user"], $order); - - if ($return === false) { - return $result; - } - - foreach ($return as $message) { - $result[$message["id_mensaje"]]["dest"] = $message["id_usuario_destino"]; - $result[$message["id_mensaje"]]["subject"] = $message["subject"]; - $result[$message["id_mensaje"]]["timestamp"] = $message["timestamp"]; - $result[$message["id_mensaje"]]["status"] = $message["estado"]; - } - - return $result; -} +function messages_get_overview_sent( + string $order='timestamp', + string $order_dir='ASC' +) { + global $config; -?> + switch ($order) { + case 'timestamp':{ + } + case 'sender':{ + } + case 'subject':{ + } + break; + + case 'status': + default: + $order = 'estado, timestamp'; + break; + } + + if ($order_dir != 'ASC') { + $order .= ' DESC'; + } + + $result = []; + $return = db_get_all_rows_field_filter( + 'tmensajes', + 'id_usuario_origen', + $config['id_user'], + $order + ); + + if ($return === false) { + return $result; + } + + foreach ($return as $message) { + $id_message = $message['id_mensaje']; + $result[$id_message]['dest'] = $message['id_usuario_destino']; + $result[$id_message]['subject'] = $message['subject']; + $result[$id_message]['timestamp'] = $message['timestamp']; + $result[$id_message]['status'] = $message['estado']; + } + + return $result; +} diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php new file mode 100644 index 0000000000..8372f54bf0 --- /dev/null +++ b/pandora_console/include/functions_notifications.php @@ -0,0 +1,53 @@ +<?php + +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + + +/** + * Retrieves source ID for given source. + * + * @param string $source Source. + * + * @return integer source's id. + */ +function get_notification_source_id(string $source) +{ + if (empty($source) === true) { + return false; + } + + return db_get_value_sql( + sprintf( + 'SELECT id + FROM `tnotification_source` + WHERE lower(`description`) = lower("%s")', + $source + ) + ); +} diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index 32e79a46de..d0ebb09cb3 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -1,257 +1,295 @@ <?php +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list +require_once 'include/functions_messages.php'; -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -include_once ('include/functions_messages.php'); - -$delete_msg = get_parameter('delete_message',0); -$multiple_delete = get_parameter('multiple_delete',0); +$delete_msg = get_parameter('delete_message', 0); +$multiple_delete = get_parameter('multiple_delete', 0); $show_sent = get_parameter('show_sent', 0); $mark_unread = get_parameter('mark_unread', 0); $active_list = true; $active_sent = false; -if ($show_sent) { - $active_list = false; - $active_sent = true; +if ($show_sent !== 0) { + $active_list = false; + $active_sent = true; } -$buttons['message_list'] = array('active' => $active_list, - 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">' . - html_print_image("images/email_inbox.png", true, array ("title" => __('Received messages'))) .'</a>'); +$buttons['message_list'] = [ + 'active' => $active_list, + 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">'.html_print_image('images/email_inbox.png', true, ['title' => __('Received messages')]).'</a>', +]; -$buttons['sent_messages'] = array('active' => $active_sent, - 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">' . - html_print_image("images/email_outbox.png", true, array ("title" => __('Sent messages'))) .'</a>'); +$buttons['sent_messages'] = [ + 'active' => $active_sent, + 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'.html_print_image('images/email_outbox.png', true, ['title' => __('Sent messages')]).'</a>', +]; -$buttons['create_message'] = array('active' => false, - 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">' . - html_print_image("images/new_message.png", true, array ("title" => __('Create message'))) .'</a>'); +$buttons['create_message'] = [ + 'active' => false, + 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">'.html_print_image( + 'images/new_message.png', + true, + ['title' => __('Create message')] + ).'</a>', +]; -if (!is_ajax ()) { - ui_print_page_header (__('Messages'), "images/email_mc.png", false, "", false, $buttons); +if (!is_ajax()) { + ui_print_page_header( + __('Messages'), + 'images/email_mc.png', + false, + '', + false, + $buttons + ); } if ($mark_unread) { - $message_id = get_parameter('id_message'); - messages_process_read ($message_id, false); + $message_id = get_parameter('id_message'); + messages_process_read($message_id, false); } if ($delete_msg) { - $id = (int) get_parameter ("id"); - $result = messages_delete_message ($id); //Delete message function will actually check the credentials - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Could not be deleted')); + $id = (int) get_parameter('id'); + $result = messages_delete_message($id); + // Delete message function will actually check the credentials. + ui_print_result_message( + $result, + __('Successfully deleted'), + __('Could not be deleted') + ); } if ($multiple_delete) { - $ids = (array)get_parameter('delete_multiple', array()); - - foreach ($ids as $id) { - $result = db_process_sql_delete ('tmensajes', - array ('id_mensaje' => $id)); - - if ($result === false) { - break; - } - } - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting messages')); + $ids = (array) get_parameter('delete_multiple', []); + + foreach ($ids as $id) { + $result = db_process_sql_delete( + 'tmensajes', + ['id_mensaje' => $id] + ); + + if ($result === false) { + break; + } + } + + ui_print_result_message( + $result, + __('Successfully deleted'), + __('Not deleted. Error deleting messages') + ); } -if ($show_sent) { //sent view - $num_messages = messages_get_count_sent($config['id_user']); - if ($num_messages > 0 && !is_ajax()) { - echo '<p>' . __('You have') . ' <b>' . $num_messages . '</b> ' . - ' ' . __('sent message(s)') . '.</p>'; - } - $messages = messages_get_overview_sent ('', 'DESC'); -} -else { //messages received - $num_messages = messages_get_count ($config["id_user"]); - if ($num_messages > 0 && !is_ajax()) { - echo '<p>' . __('You have') . ' <b>' . $num_messages . '</b> ' . - ' ' . __('unread message(s)') . '.</p>'; - } - $messages = messages_get_overview (); +if ($show_sent) { + // Sent view. + $num_messages = messages_get_count_sent($config['id_user']); + if ($num_messages > 0 && !is_ajax()) { + echo '<p>'.__('You have').' <b>'.$num_messages.'</b>'.__('sent message(s)').'.</p>'; + } + + $messages = messages_get_overview_sent('', 'DESC'); +} else { + // Messages received. + $num_messages = messages_get_count($config['id_user']); + if ($num_messages > 0 && !is_ajax()) { + echo '<p>'.__('You have').' <b>'.$num_messages.'</b>'.__('unread message(s)').'.</p>'; + } + + $messages = messages_get_overview(); } -if (empty ($messages)) { - ui_print_info_message ( - array('no_close'=>true, - 'message'=> __('There are no messages.') ) ); -} -else { - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox data'; - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->head = array (); - $table->data = array (); - $table->align = array (); - $table->size = array (); - - $table->align[0] = "left"; - $table->align[1] = "left"; - $table->align[2] = "left"; - $table->align[3] = "left"; - $table->align[4] = "right"; - - $table->size[0] = "20px"; - $table->size[1] = "100px"; - $table->size[3] = "80px"; - $table->size[4] = "60px"; - - $table->head[0] = __('Status'); - if ($show_sent) - $table->head[1] = __('Destination'); - else - $table->head[1] = __('Sender'); - $table->head[2] = __('Subject'); - $table->head[3] = __('Timestamp'); - $table->head[4] = __('Delete'). html_print_checkbox('all_delete_messages', 0, false, true, false); - - foreach ($messages as $message_id => $message) { - $data = array (); - $data[0] = ''; - if ($message["status"] == 1) { - if ($show_sent) { - $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; - $data[0] .= html_print_image ("images/email_open.png", true, array ("border" => 0, "title" => __('Click to read'))); - $data[0] .= '</a>'; - } - else { - $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&mark_unread=1&id_message='.$message_id.'">'; - $data[0] .= html_print_image ("images/email_open.png", true, array ("border" => 0, "title" => __('Mark as unread'))); - $data[0] .= '</a>'; - } - } - else { - if ($show_sent) { - $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; - $data[0] .= html_print_image ("images/email.png", true, array ("border" => 0, "title" => __('Message unread - click to read'))); - $data[0] .= '</a>'; - } - else { - $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">'; - $data[0] .= html_print_image ("images/email.png", true, array ("border" => 0, "title" => __('Message unread - click to read'))); - $data[0] .= '</a>'; - } - } - - if ($show_sent) { - $dest_user = get_user_fullname ($message["dest"]); - if (!$dest_user) { - $dest_user = $message["dest"]; - } - $data[1] = $dest_user; - } - else { - $orig_user = get_user_fullname ($message["sender"]); - if (!$orig_user) { - $orig_user = $message["sender"]; - } - $data[1] = $orig_user; - } - - if ($show_sent) { - $data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; - } - else { - $data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">'; - } - if ($message["subject"] == "") { - $data[2] .= __('No Subject'); - } - else { - $data[2] .= $message["subject"]; - } - $data[2] .= '</a>'; - - $data[3] = ui_print_timestamp( - $message["timestamp"], true, - array ("prominent" => "timestamp")); - - if ($show_sent) { - $data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'" - onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">' . - html_print_image ('images/cross.png', true, array("title" => __('Delete'))) . '</a>'. - html_print_checkbox_extended ('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); - } - else { - $data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&delete_message=1&id='.$message_id.'" - onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">' . - html_print_image ('images/cross.png', true, array("title" => __('Delete'))) . '</a>'. - html_print_checkbox_extended ('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); - } - array_push ($table->data, $data); - } - +if (empty($messages)) { + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('There are no messages.'), + ] + ); +} else { + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox data'; + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->head = []; + $table->data = []; + $table->align = []; + $table->size = []; + + $table->align[0] = 'left'; + $table->align[1] = 'left'; + $table->align[2] = 'left'; + $table->align[3] = 'left'; + $table->align[4] = 'right'; + + $table->size[0] = '20px'; + $table->size[1] = '100px'; + $table->size[3] = '80px'; + $table->size[4] = '60px'; + + $table->head[0] = __('Status'); + if ($show_sent) { + $table->head[1] = __('Destination'); + } else { + $table->head[1] = __('Sender'); + } + + $table->head[2] = __('Subject'); + $table->head[3] = __('Timestamp'); + $table->head[4] = __('Delete').html_print_checkbox('all_delete_messages', 0, false, true, false); + + foreach ($messages as $message_id => $message) { + $data = []; + $data[0] = ''; + if ($message['status'] == 1) { + if ($show_sent) { + $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; + $data[0] .= html_print_image('images/email_open.png', true, ['border' => 0, 'title' => __('Click to read')]); + $data[0] .= '</a>'; + } else { + $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&mark_unread=1&id_message='.$message_id.'">'; + $data[0] .= html_print_image('images/email_open.png', true, ['border' => 0, 'title' => __('Mark as unread')]); + $data[0] .= '</a>'; + } + } else { + if ($show_sent) { + $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; + $data[0] .= html_print_image('images/email.png', true, ['border' => 0, 'title' => __('Message unread - click to read')]); + $data[0] .= '</a>'; + } else { + $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">'; + $data[0] .= html_print_image('images/email.png', true, ['border' => 0, 'title' => __('Message unread - click to read')]); + $data[0] .= '</a>'; + } + } + + if ($show_sent) { + $dest_user = get_user_fullname($message['dest']); + if (!$dest_user) { + $dest_user = $message['dest']; + } + + $data[1] = $dest_user; + } else { + $orig_user = get_user_fullname($message['sender']); + if (!$orig_user) { + $orig_user = $message['sender']; + } + + $data[1] = $orig_user; + } + + if ($show_sent) { + $data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; + } else { + $data[2] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id.'">'; + } + + if ($message['subject'] == '') { + $data[2] .= __('No Subject'); + } else { + $data[2] .= $message['subject']; + } + + $data[2] .= '</a>'; + + $data[3] = ui_print_timestamp( + $message['timestamp'], + true, + ['prominent' => 'timestamp'] + ); + + if ($show_sent) { + $data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'" + onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); + } else { + $data[4] = '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&delete_message=1&id='.$message_id.'" + onClick="javascript:if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>'.html_print_checkbox_extended('delete_multiple_messages[]', $message_id, false, false, '', 'class="check_delete_messages"', true); + } + + array_push($table->data, $data); + } } if (!empty($messages)) { - if ($show_sent) { - echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'; - } - else { - echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list">'; - } - html_print_input_hidden('multiple_delete', 1); - html_print_table($table); - echo "<div style='float: right;'>"; - html_print_submit_button(__('Delete'), 'delete_btn', - false, 'class="sub delete"'); - echo "</div>"; - echo "</form>"; + if ($show_sent) { + echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'; + } else { + echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list">'; + } + + html_print_input_hidden('multiple_delete', 1); + html_print_table($table); + echo "<div style='float: right;'>"; + html_print_submit_button( + __('Delete'), + 'delete_btn', + false, + 'class="sub delete"' + ); + echo '</div>'; + echo '</form>'; } echo "<div style='float: right;'>"; - echo '<form method="post" style="float:right;" action="index.php?sec=message_list&sec2=operation/messages/message_edit">'; - html_print_submit_button (__('Create message'), 'create', false, 'class="sub next" style="margin-right:5px;"'); - echo "</form>"; -echo "</div>"; + echo '<form method="post" style="float:right;" action="index.php?sec=message_list&sec2=operation/messages/message_edit">'; + html_print_submit_button(__('Create message'), 'create', false, 'class="sub next" style="margin-right:5px;"'); + echo '</form>'; +echo '</div>'; ?> <script type="text/javascript"> - $( document ).ready(function() { + $( document ).ready(function() { - $('[id^=checkbox-delete_multiple_messages]').change(function(){ - if($(this).parent().parent().hasClass('checkselected')){ - $(this).parent().parent().removeClass('checkselected'); - } - else{ - $(this).parent().parent().addClass('checkselected'); - } - }); + $('[id^=checkbox-delete_multiple_messages]').change(function(){ + if($(this).parent().parent().hasClass('checkselected')){ + $(this).parent().parent().removeClass('checkselected'); + } + else{ + $(this).parent().parent().addClass('checkselected'); + } + }); - $('[id^=checkbox-all_delete_messages]').change(function(){ - if ($("#checkbox-all_delete_messages").prop("checked")) { - $('[id^=checkbox-delete_multiple_messages]').parent().parent().addClass('checkselected'); - $(".check_delete_messages").prop("checked", true); - } - else{ - $('[id^=checkbox-delete_multiple_messages]').parent().parent().removeClass('checkselected'); - $(".check_delete_messages").prop("checked", false); - } - }); + $('[id^=checkbox-all_delete_messages]').change(function(){ + if ($("#checkbox-all_delete_messages").prop("checked")) { + $('[id^=checkbox-delete_multiple_messages]').parent().parent().addClass('checkselected'); + $(".check_delete_messages").prop("checked", true); + } + else{ + $('[id^=checkbox-delete_multiple_messages]').parent().parent().removeClass('checkselected'); + $(".check_delete_messages").prop("checked", false); + } + }); - }); + }); </script> From 406c062a3c126e23f55a49413135a73ab2822bc1 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Wed, 30 Jan 2019 13:29:46 +0100 Subject: [PATCH 005/262] WIP messages, usable Former-commit-id: 79e0b38fe7499642480505aac088ef8b45b04714 --- .../include/functions_messages.php | 229 ++++----- .../include/functions_notifications.php | 57 ++- .../operation/messages/message_edit.php | 458 ++++++++++++------ .../operation/messages/message_list.php | 11 +- 4 files changed, 463 insertions(+), 292 deletions(-) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 675b9c2a38..3d163825c3 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -33,33 +33,88 @@ require_once $config['homedir'].'/include/functions_groups.php'; require_once $config['homedir'].'/include/functions_notifications.php'; +/** + * Set targets for given messaje + * + * @param integer $message_id Message id. + * @param array $users An array with all target users. + * @param array $groups An array with all target groups. + * + * @return boolean Task status. + */ +function message_set_targets( + int $message_id, + array $users=null, + array $groups=null +) { + if (empty($message_id)) { + return false; + } + + if (is_array($users)) { + $values = []; + foreach ($users as $user) { + if (empty($user)) { + continue; + } + + $values['id_mensaje'] = $message_id; + $values['id_user'] = $user; + } + + if (!empty($values)) { + $ret = db_process_sql_insert('tnotification_user', $values); + if ($ret === false) { + return false; + } + } + } + + if (is_array($groups)) { + $values = []; + foreach ($groups as $group) { + if (empty($group)) { + continue; + } + + $values['id_mensaje'] = $message_id; + $values['id_group'] = $group; + } + + if (!empty($values)) { + $ret = db_process_sql_insert('tnotification_group', $values); + if ($ret === false) { + return false; + } + } + } + + return true; +} + + /** * Creates a private message to be forwarded to other people * - * @param string $usuario_origen The sender of the message. - * @param string $usuario_destino The receiver of the message. - * @param string $subject Subject of the message (much like E-Mail). - * @param string $mensaje The actual message. This message will be - * cleaned by io_safe_input (html is allowed but - * loose html chars will be translated). + * @param string $usuario_origen The sender of the message. + * @param array $target_users The receiver of the message. + * @param array $target_groups Target groups to be delivered. + * @param string $subject Subject of the message (much like E-Mail). + * @param string $mensaje The actual message. This message will be + * cleaned by io_safe_input (html is allowed but + * loose html chars will be translated). * * @return boolean true when delivered, false in case of error */ function messages_create_message( string $usuario_origen, - string $usuario_destino, + array $target_users, + array $target_groups, string $subject, string $mensaje ) { $users = users_get_info(); - if (!array_key_exists($usuario_origen, $users) - || !array_key_exists($usuario_destino, $users) - ) { - return false; - // Users don't exist so don't send to them. - } - // Create message. $message_id = db_process_sql_insert( 'tmensajes', @@ -75,13 +130,19 @@ function messages_create_message( // Update URL // Update targets. if ($message_id !== false) { - $return = db_process_sql_insert( - 'tnotification_user', - [ - 'id_mensaje' => $message_id, - 'id_user' => $usuario_destino, - ] + $ret = message_set_targets( + $message_id, + $target_users, + $target_groups ); + if ($ret === false) { + // Failed to deliver messages. Erase message and show error. + db_process_sql_delete( + 'tmensajes', + ['id_mensaje' => $message_id] + ); + return false; + } } if ($return === false) { @@ -92,65 +153,6 @@ function messages_create_message( } -/** - * Creates private messages to be forwarded to groups - * - * @param string $usuario_origen The sender of the message. - * @param string $dest_group The receivers (group) of the message. - * @param string $subject Subject of the message (much like E-Mail). - * @param string $mensaje The actual message. This message will be - * cleaned by io_safe_input (html is allowed but - * loose html chars will be translated). - * - * @return boolean true when delivered, false in case of error - */ -function messages_create_group( - string $usuario_origen, - string $dest_group, - string $subject, - string $mensaje -) { - $users = users_get_info(); - $group_users = groups_get_users($dest_group); - - if (! array_key_exists($usuario_origen, $users)) { - // Users don't exist in the system. - return false; - } else if (empty($group_users)) { - /* - There are no users in the group, so it hasn't failed - although it hasn't done anything. - */ - - return true; - } - - // Array unique. - foreach ($group_users as $user) { - foreach ($user as $key => $us) { - if ($key == 'id_user') { - $group_user[$us] = $us; - } - } - } - - foreach ($group_user as $user) { - $return = messages_create_message( - $usuario_origen, - get_user_id($user), - $subject, - $mensaje - ); - if ($return === false) { - // Error sending message. - return false; - } - } - - return true; -} - - /** * Deletes a private message * @@ -160,8 +162,6 @@ function messages_create_group( */ function messages_delete_message(int $id_message) { - global $config; - // 'id_usuario_destino' => $config["id_user"], $where = ['id_mensaje' => $id_message]; return (bool) db_process_sql_delete('tmensajes', $where); } @@ -208,10 +208,9 @@ function messages_get_message(int $message_id) global $config; $sql = sprintf( - "SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp + 'SELECT * FROM tmensajes - WHERE id_usuario_destino='%s' AND id_mensaje=%d", - $config['id_user'], + WHERE id_mensaje=%d', $message_id ); $row = db_get_row_sql($sql); @@ -239,7 +238,7 @@ function messages_get_message_sent(int $message_id) global $config; $sql = sprintf( - "SELECT id_usuario_origen, id_usuario_destino, subject, mensaje, timestamp + "SELECT id_usuario_origen, subject, mensaje, timestamp FROM tmensajes WHERE id_usuario_origen='%s' AND id_mensaje=%d", $config['id_user'], @@ -251,6 +250,16 @@ function messages_get_message_sent(int $message_id) return false; } + $targets = get_notification_targets($message_id); + + $row['id_usuario_destino'] = implode( + ',', + $targets['users'] + ).implode( + ',', + $targets['groups'] + ); + return $row; } @@ -281,15 +290,15 @@ function messages_get_count( } $sql = sprintf( - "SELECT count(*) FROM tmensajes tm + "SELECT count(tm.id_mensaje) FROM tmensajes tm left join tnotification_user nu ON tm.id_mensaje=nu.id_mensaje + AND nu.id_user='%s' left join tnotification_group ng ON tm.id_mensaje=ng.id_mensaje left join tusuario_perfil up - ON tm.id_mensaje=ng.id_mensaje - AND ng.id_group=up.id_grupo - WHERE (nu.id_user='%s' OR ng.id_group=0 OR up.id_grupo=ng.id_group) + ON ng.id_group=up.id_grupo + AND (ng.id_group=0 OR up.id_grupo=ng.id_group) %s", $config['id_user'], $filter @@ -359,36 +368,21 @@ function messages_get_overview( } $sql = sprintf( - "SELECT * FROM tmensajes tm + "SELECT tm.* FROM tmensajes tm left join tnotification_user nu ON tm.id_mensaje=nu.id_mensaje + AND nu.id_user='%s' left join tnotification_group ng ON tm.id_mensaje=ng.id_mensaje left join tusuario_perfil up - ON tm.id_mensaje=ng.id_mensaje - AND ng.id_group=up.id_grupo - WHERE (nu.id_user='%s' OR ng.id_group=0 OR up.id_grupo=ng.id_group) + ON ng.id_group=up.id_grupo + AND (ng.id_group=0 OR up.id_grupo=ng.id_group) ORDER BY %s", $config['id_user'], $order ); - $result = []; - $return = db_get_all_rows_sql($sql); - - if ($return === false) { - return $result; - } - - foreach ($return as $message) { - $id_message = $message['id_mensaje']; - $result[$id_message]['sender'] = $message['id_usuario_origen']; - $result[$id_message]['subject'] = $message['subject']; - $result[$id_message]['timestamp'] = $message['timestamp']; - $result[$id_message]['status'] = $message['estado']; - } - - return $result; + return db_get_all_rows_sql($sql); } @@ -427,25 +421,10 @@ function messages_get_overview_sent( $order .= ' DESC'; } - $result = []; - $return = db_get_all_rows_field_filter( + return db_get_all_rows_field_filter( 'tmensajes', 'id_usuario_origen', $config['id_user'], $order ); - - if ($return === false) { - return $result; - } - - foreach ($return as $message) { - $id_message = $message['id_mensaje']; - $result[$id_message]['dest'] = $message['id_usuario_destino']; - $result[$id_message]['subject'] = $message['subject']; - $result[$id_message]['timestamp'] = $message['timestamp']; - $result[$id_message]['status'] = $message['estado']; - } - - return $result; } diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 8372f54bf0..03f0b07963 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -1,10 +1,9 @@ <?php /** - * Extension to manage a list of gateways and the node address where they should - * point to. + * Library. Notification system auxiliary functions. * - * @category Extensions + * @category Library * @package Pandora FMS * @subpackage Community * @version 1.0.0 @@ -51,3 +50,55 @@ function get_notification_source_id(string $source) ) ); } + + +/** + * Retrieve all targets for given message. + * + * @param integer $id_message Message id. + * + * @return array of users and groups target of this message. + */ +function get_notification_targets(int $id_message) +{ + $targets = [ + 'users' => [], + 'groups' => [], + ]; + + if (empty($id_message)) { + return $targets; + } + + $ret = db_get_all_rows_sql( + sprintf( + 'SELECT id_user + FROM tnotification_user nu + WHERE nu.id_mensaje = %d', + $id_message + ) + ); + + if (is_array($ret)) { + foreach ($ret as $row) { + array_push($targets['users'], $row['id_user']); + } + } + + $ret = $targets['groups'] = db_get_all_rows_sql( + sprintf( + 'SELECT id_group + FROM tnotification_group ng + WHERE ng.id_mensaje = %d', + $id_message + ) + ); + + if (is_array($ret)) { + foreach ($ret as $row) { + array_push($targets['groups'], $row['id_group']); + } + } + + return $targets; +} diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index 5df20ce9fe..a92abc19e8 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -1,26 +1,39 @@ <?php +/** + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Load global vars global $config; -require_once ('include/functions_users.php'); -require_once ('include/functions_groups.php'); -require_once ('include/functions_io.php'); +require_once 'include/functions_users.php'; +require_once 'include/functions_groups.php'; +require_once 'include/functions_io.php'; -//params +// Parse parameters. $new_msg = get_parameter('new_msg', 0); $dst_user = get_parameter('dst_user'); $dst_group = get_parameter('dst_group'); @@ -30,191 +43,320 @@ $read_message = get_parameter('read_message', 0); $reply = get_parameter('reply', 0); $show_sent = get_parameter('show_sent', 0); -$buttons['message_list'] = array('active' => false, - 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">' . - html_print_image("images/email_inbox.png", true, array ("title" => __('Received messages'))) .'</a>'); +$buttons['message_list'] = [ + 'active' => false, + 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list">'.html_print_image( + 'images/email_inbox.png', + true, + ['title' => __('Received messages')] + ).'</a>', +]; -$buttons['sent_messages'] = array('active' => false, - 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">' . - html_print_image("images/email_outbox.png", true, array ("title" => __('Sent messages'))) .'</a>'); +$buttons['sent_messages'] = [ + 'active' => false, + 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1">'.html_print_image( + 'images/email_outbox.png', + true, + ['title' => __('Sent messages')] + ).'</a>', +]; -$buttons['create_message'] = array('active' => true, - 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">' . - html_print_image("images/new_message.png", true, array ("title" => __('Create message'))) .'</a>'); +$buttons['create_message'] = [ + 'active' => true, + 'text' => '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit">'.html_print_image( + 'images/new_message.png', + true, + ['title' => __('Create message')] + ).'</a>', +]; -// Header -ui_print_page_header (__('Messages'), "images/email_mc.png", false, "", false, $buttons); +// Header. +ui_print_page_header( + __('Messages'), + 'images/email_mc.png', + false, + '', + false, + $buttons +); -//read a message +// Read a message. if ($read_message) { - $message_id = (int) get_parameter ("id_message"); - if ($show_sent) { - $message = messages_get_message_sent ($message_id); - } - else { - $message = messages_get_message ($message_id); - messages_process_read ($message_id); - } - - if ($message == false) { - echo '<div>'.__('This message does not exist in the system').'</div>'; - return; //Move out of this page and go processing other pages - } - - $user_name = get_user_fullname ($message["id_usuario_origen"]); - if (!$user_name) { - $user_name = $message["id_usuario_origen"]; - } - - $dst_name = get_user_fullname ($message["id_usuario_destino"]); - if (!$dst_name) { - $dst_name = $message["id_usuario_destino"]; - } - - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox filters'; - $table->data = array(); - - $table->data[0][0] = __('Sender'); - $table->data[0][1] = $user_name.' '.__('at').' ' . ui_print_timestamp ($message["timestamp"], true, array ("prominent" => "timestamp")); - - $table->data[1][0] = __('Destination'); - $table->data[1][1] = $dst_name; - - $table->data[2][0] = __('Subject'); - $table->data[2][1] = html_print_input_text_extended ("subject", $message["subject"], 'text-subject', '', 50, 70, true, false, '', 'readonly'); - - $order = array("\r\n", "\n", "\r"); - $replace = '<br />'; - $parsed_message = str_replace($order, $replace, $message["mensaje"]); - - $table->data[3][0] = __('Message'); - $table->data[3][1] = html_print_textarea ("message", 15, 255, $message["mensaje"], 'readonly', true); - - //Prevent RE: RE: RE: - if (strstr ($message["subject"], "RE:")) { - $new_subj = $message["subject"]; - } - else { - $new_subj = "RE: ".$message["subject"]; - } - - //Start the message much like an e-mail reply - $new_msg = "\n\n\nOn ".date ($config["date_format"], $message["timestamp"]).' '.$user_name.' '.__('wrote').":\n\n".$message["mensaje"]; - - echo '<form id="delete_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'">'; - html_print_table($table); - echo "</form>"; - - echo '<form id="reply_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1&reply=1">'; - html_print_input_hidden ("dst_user", $message["id_usuario_origen"]); - html_print_input_hidden ("subject", $new_subj); - html_print_input_hidden ("message", $new_msg); - html_print_input_hidden ("orig_user", $message["id_usuario_destino"]); - echo '</form>'; + $message_id = (int) get_parameter('id_message'); + if ($show_sent) { + $message = messages_get_message_sent($message_id); + } else { + $message = messages_get_message($message_id); + messages_process_read($message_id); + } - echo "<div class= 'action-buttons' style=' width:" . $table->width . "'>"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'form="delete_message" class="sub delete"'); - echo " "; - html_print_submit_button (__('Reply'), 'reply', false, 'form="reply_message" class="sub next"'); - echo "</div>"; - - return; + if ($message == false) { + echo '<div>'.__('This message does not exist in the system').'</div>'; + return; + // Move out of this page and go processing other pages. + } + + $user_name = get_user_fullname($message['id_usuario_origen']); + if (!$user_name) { + $user_name = $message['id_usuario_origen']; + } + + $dst_name = get_user_fullname($message['id_usuario_destino']); + if (!$dst_name) { + $dst_name = $message['id_usuario_destino']; + } + + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox filters'; + $table->data = []; + + $table->data[0][0] = __('Sender'); + $table->data[0][1] = $user_name.' '.__('at').' '.ui_print_timestamp( + $message['timestamp'], + true, + ['prominent' => 'timestamp'] + ); + + $table->data[1][0] = __('Destination'); + $table->data[1][1] = $dst_name; + + $table->data[2][0] = __('Subject'); + $table->data[2][1] = html_print_input_text_extended( + 'subject', + $message['subject'], + 'text-subject', + '', + 50, + 70, + true, + false, + '', + 'readonly' + ); + + $order = [ + "\r\n", + "\n", + "\r", + ]; + $replace = '<br />'; + $parsed_message = str_replace($order, $replace, $message['mensaje']); + + $table->data[3][0] = __('Message'); + $table->data[3][1] = html_print_textarea( + 'message', + 15, + 255, + $message['mensaje'], + 'readonly', + true + ); + + // Prevent RE: RE: RE:. + if (strstr($message['subject'], 'RE:')) { + $new_subj = $message['subject']; + } else { + $new_subj = 'RE: '.$message['subject']; + } + + // Start the message much like an e-mail reply. + $new_msg = "\n\n\nOn ".date( + $config['date_format'], + $message['timestamp'] + ).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje']; + + echo '<form id="delete_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'">'; + html_print_table($table); + echo '</form>'; + + echo '<form id="reply_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1&reply=1">'; + html_print_input_hidden('dst_user', $message['id_usuario_origen']); + html_print_input_hidden('subject', $new_subj); + html_print_input_hidden('message', $new_msg); + html_print_input_hidden('orig_user', $message['id_usuario_destino']); + echo '</form>'; + + echo "<div class= 'action-buttons' style=' width:".$table->width."'>"; + html_print_submit_button( + __('Delete'), + 'delete_btn', + false, + 'form="delete_message" class="sub delete"' + ); + echo ' '; + html_print_submit_button( + __('Reply'), + 'reply', + false, + 'form="reply_message" class="sub next"' + ); + echo '</div>'; + + return; } -// Create message (destination user) -if (($new_msg) && (!empty ($dst_user)) && (!$reply)) { - $return = messages_create_message ($config["id_user"], $dst_user, $subject, $message); - - $user_name = get_user_fullname ($dst_user); - if (!$user_name) { - $user_name = $dst_user; - } - - ui_print_result_message ($return, - __('Message successfully sent to user %s', $user_name), - __('Error sending message to user %s', $user_name)); +// Create message (destination user). +if (($new_msg) && (!empty($dst_user)) && (!$reply)) { + $return = messages_create_message( + $config['id_user'], + [$dst_user], + [], + $subject, + $message + ); + + $user_name = get_user_fullname($dst_user); + if (!$user_name) { + $user_name = $dst_user; + } + + ui_print_result_message( + $return, + __('Message successfully sent to user %s', $user_name), + __('Error sending message to user %s', $user_name) + ); } -// Create message (destination group) -if (($new_msg) && ($dst_group!='') && (!$reply)) { - $return = messages_create_group ($config["id_user"], $dst_group, $subject, $message); - - ui_print_result_message ($return, - __('Message successfully sent'), - __('Error sending message to group %s', groups_get_name ($dst_group))); +// Create message (destination group). +if (($new_msg) && ($dst_group != '') && (!$reply)) { + $return = messages_create_message( + $config['id_user'], + [], + [$dst_group], + $subject, + $message + ); + + ui_print_result_message( + $return, + __('Message successfully sent'), + __('Error sending message to group %s', groups_get_name($dst_group)) + ); } -//message creation form - -//user info -$own_info = get_user_info ($config['id_user']); +// Message creation form. +// User info. +$own_info = get_user_info($config['id_user']); $table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; -$table->data = array(); +$table->data = []; $table->data[0][0] = __('Sender'); if (!empty($own_info['fullname'])) { - $table->data[0][1] = $own_info['fullname']; -} -else { - $table->data[0][1] = $config['id_user']; + $table->data[0][1] = $own_info['fullname']; +} else { + $table->data[0][1] = $config['id_user']; } $table->data[1][0] = __('Destination'); -$is_admin = (bool)db_get_value('is_admin', 'tusuario', 'id_user', $config['id_user']); +$is_admin = (bool) db_get_value( + 'is_admin', + 'tusuario', + 'id_user', + $config['id_user'] +); if ($is_admin) { - $users_full = db_get_all_rows_filter('tusuario', array(), array('id_user', 'fullname')); -} -else { - $users_full = groups_get_users (array_keys(users_get_groups()), false, false); + $users_full = db_get_all_rows_filter( + 'tusuario', + [], + [ + 'id_user', + 'fullname', + ] + ); +} else { + $users_full = groups_get_users( + array_keys(users_get_groups()), + false, + false + ); } -$users = array(); +$users = []; foreach ($users_full as $user_id => $user_info) { - $users[$user_info['id_user']] = $user_info['fullname']; + $users[$user_info['id_user']] = $user_info['fullname']; } -//Check if the user to reply is in the list, if not add reply user +// Check if the user to reply is in the list, if not add reply user. if ($reply) { - if (!array_key_exists($dst_user, $users)) { - //Add the user to reply - $user_reply = db_get_row('tusuario', 'id_user', $dst_user); - $users[$user_reply['id_user']] = $user_reply['fullname']; - } + if (!array_key_exists($dst_user, $users)) { + // Add the user to reply. + $user_reply = db_get_row('tusuario', 'id_user', $dst_user); + $users[$user_reply['id_user']] = $user_reply['fullname']; + } } -if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $return_all_groups = true; -else - $return_all_groups = false; +if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { + $return_all_groups = true; +} else { + $return_all_groups = false; +} -$groups = users_get_groups ($config["id_user"], "AR"); //Get a list of all groups - -$table->data[1][1] = html_print_select ($users, "dst_user", $dst_user, '', __('Select user'), false, true, false, '', false); +$groups = users_get_groups($config['id_user'], 'AR'); +// Get a list of all groups. +$table->data[1][1] = html_print_select( + $users, + 'dst_user', + $dst_user, + '', + __('Select user'), + false, + true, + false, + '', + false +); $table->data[1][1] .= '  '.__('OR').'  '; -$table->data[1][1] .= html_print_select_groups($config['id_user'], "AR", $return_all_groups, 'dst_group', $dst_group, '', __('Select group'), '', true); +$table->data[1][1] .= html_print_select_groups( + $config['id_user'], + 'AR', + $return_all_groups, + 'dst_group', + $dst_group, + '', + __('Select group'), + '', + true +); $table->data[2][0] = __('Subject'); -$table->data[2][1] = html_print_input_text ("subject", $subject, '', 50, 70, true); +$table->data[2][1] = html_print_input_text( + 'subject', + $subject, + '', + 50, + 70, + true +); $table->data[3][0] = __('Message'); -$table->data[3][1] = html_print_textarea ("message", 15, 255, $message, '', true); +$table->data[3][1] = html_print_textarea( + 'message', + 15, + 255, + $message, + '', + true +); echo '<form method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1">'; html_print_table($table); echo '<div class="action-buttons" style="width: '.$table->width.'">'; - html_print_submit_button (__('Send message'), 'send_mes', false, 'class="sub wand"'); -echo '</form>'; -echo '</div>'; -?> + html_print_submit_button( + __('Send message'), + 'send_mes', + false, + 'class="sub wand"' + ); + echo '</form>'; + echo '</div>'; diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index d0ebb09cb3..49ecfe14dd 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -88,13 +88,10 @@ if ($delete_msg) { } if ($multiple_delete) { - $ids = (array) get_parameter('delete_multiple', []); + $ids = (array) get_parameter('delete_multiple_messages', []); foreach ($ids as $id) { - $result = db_process_sql_delete( - 'tmensajes', - ['id_mensaje' => $id] - ); + $result = messages_delete_message($id); if ($result === false) { break; @@ -166,7 +163,9 @@ if (empty($messages)) { $table->head[3] = __('Timestamp'); $table->head[4] = __('Delete').html_print_checkbox('all_delete_messages', 0, false, true, false); - foreach ($messages as $message_id => $message) { + + foreach ($messages as $message) { + $message_id = $message['id_mensaje']; $data = []; $data[0] = ''; if ($message['status'] == 1) { From 3f81e60df245f2e752f4d2c5fc3eaa973a6373be Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Wed, 30 Jan 2019 17:33:31 +0100 Subject: [PATCH 006/262] wip messages Former-commit-id: 7852ce90b3f2681a0134a651812341f7fac00c53 --- .../include/functions_messages.php | 184 +++++++++++++----- .../include/functions_notifications.php | 51 ++++- .../operation/messages/message_edit.php | 2 +- .../operation/messages/message_list.php | 14 +- 4 files changed, 195 insertions(+), 56 deletions(-) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 3d163825c3..7552dc74f2 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -73,7 +73,7 @@ function message_set_targets( if (is_array($groups)) { $values = []; foreach ($groups as $group) { - if (empty($group)) { + if ($group != 0 && empty($group)) { continue; } @@ -162,8 +162,43 @@ function messages_create_message( */ function messages_delete_message(int $id_message) { - $where = ['id_mensaje' => $id_message]; - return (bool) db_process_sql_delete('tmensajes', $where); + global $config; + + // Check if user has grants to access the message. + if (check_notification_readable($id_message) === false) { + return false; + } + + $utimestamp = time(); + + $ret = db_process_sql_update( + 'tnotification_user', + ['utimestamp_erased' => $utimestamp], + [ + 'id_mensaje' => $id_message, + 'id_user' => $config['id_user'], + ] + ); + + if ($ret === 0) { + // No previous updates. + // Message available to user due group assignment. + $ret = db_process_sql_insert( + 'tnotification_user', + [ + 'id_mensaje' => $id_message, + 'id_user' => $config['id_user'], + 'utimestamp_erased' => $utimestamp, + ] + ); + + // Quick fix. Insertions returns 0. + if ($ret !== false) { + $ret = 1; + } + } + + return (bool) $ret; } @@ -179,17 +214,45 @@ function messages_process_read( int $message_id, bool $read=true ) { - if (empty($read)) { - $read = 0; - } else { - $read = 1; + global $config; + + // Check if user has grants to read the message. + if (check_notification_readable($message_id) === false) { + return false; } - return (bool) db_process_sql_update( - 'tmensajes', - ['estado' => $read], - ['id_mensaje' => $message_id] + if (empty($read)) { + // Mark as unread. + $utimestamp = null; + } else { + // Mark as read. + $utimestamp = time(); + } + + $ret = db_process_sql_update( + 'tnotification_user', + ['utimestamp_read' => $utimestamp], + [ + 'id_mensaje' => $message_id, + 'id_user' => $config['id_user'], + 'utimestamp_read' => null, + ] ); + + if ($ret === 0) { + // No previous updates. + // Message available to user due group assignment. + $ret = db_process_sql_insert( + 'tnotification_user', + [ + 'id_mensaje' => $message_id, + 'id_user' => $config['id_user'], + 'utimestamp_read' => $utimestamp, + ] + ); + } + + return (bool) $ret; } @@ -207,10 +270,17 @@ function messages_get_message(int $message_id) { global $config; + // Check if user has grants to read the message. + if (check_notification_readable($message_id) === false) { + return false; + } + $sql = sprintf( - 'SELECT * - FROM tmensajes - WHERE id_mensaje=%d', + 'SELECT *, nu.utimestamp_read > 0 as "read" + FROM tmensajes tm + LEFT JOIN tnotification_user nu + ON nu.id_mensaje = tm.id_mensaje + WHERE tm.id_mensaje=%d', $message_id ); $row = db_get_row_sql($sql); @@ -219,6 +289,8 @@ function messages_get_message(int $message_id) return false; } + $row['id_usuario_destino'] = $config['id_user']; + return $row; } @@ -255,7 +327,7 @@ function messages_get_message_sent(int $message_id) $row['id_usuario_destino'] = implode( ',', $targets['users'] - ).implode( + ).','.implode( ',', $targets['groups'] ); @@ -282,26 +354,30 @@ function messages_get_count( } if (!empty($incl_read)) { - // Retrieve only unread messages. - $filter = 'AND nu.uptimestap_read == NULL'; - } else { // Do not filter. - $filter = ''; + $read = ''; + } else { + // Retrieve only unread messages. + $read = 'where t.read is null'; } $sql = sprintf( - "SELECT count(tm.id_mensaje) FROM tmensajes tm - left join tnotification_user nu - ON tm.id_mensaje=nu.id_mensaje - AND nu.id_user='%s' - left join tnotification_group ng - ON tm.id_mensaje=ng.id_mensaje - left join tusuario_perfil up - ON ng.id_group=up.id_grupo - AND (ng.id_group=0 OR up.id_grupo=ng.id_group) - %s", - $config['id_user'], - $filter + 'SELECT count(*) FROM ( + SELECT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + LEFT JOIN tnotification_user nu + ON tm.id_mensaje=nu.id_mensaje + LEFT JOIN (tnotification_group ng + INNER JOIN tusuario_perfil up + ON ng.id_group=up.id_grupo + AND up.id_grupo=ng.id_group + ) ON tm.id_mensaje=ng.id_mensaje + WHERE utimestamp_erased is null + AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0) + ) t + %s', + $user, + $user, + $read ); return (int) db_get_sql($sql); @@ -335,16 +411,18 @@ function messages_get_count_sent(string $user='') /** * Get message overview in array * - * @param string $order How to order them valid: - * (status (default), subject, timestamp, sender). - * @param string $order_dir Direction of order - * (ASC = Ascending, DESC = Descending). + * @param string $order How to order them valid: + * (status (default), subject, timestamp, sender). + * @param string $order_dir Direction of order + * (ASC = Ascending, DESC = Descending). + * @param boolean $incl_read Include read messages in return. * * @return integer The number of messages this user has */ function messages_get_overview( string $order='status', - string $order_dir='ASC' + string $order_dir='ASC', + bool $incl_read=true ) { global $config; @@ -367,18 +445,32 @@ function messages_get_overview( $order .= ' DESC'; } + if (!empty($incl_read)) { + // Do not filter. + $read = ''; + } else { + // Retrieve only unread messages. + $read = 'where t.read is null'; + } + $sql = sprintf( - "SELECT tm.* FROM tmensajes tm - left join tnotification_user nu - ON tm.id_mensaje=nu.id_mensaje - AND nu.id_user='%s' - left join tnotification_group ng - ON tm.id_mensaje=ng.id_mensaje - left join tusuario_perfil up - ON ng.id_group=up.id_grupo - AND (ng.id_group=0 OR up.id_grupo=ng.id_group) - ORDER BY %s", + 'SELECT * FROM ( + SELECT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + LEFT JOIN tnotification_user nu + ON tm.id_mensaje=nu.id_mensaje + LEFT JOIN (tnotification_group ng + INNER JOIN tusuario_perfil up + ON ng.id_group=up.id_grupo + AND up.id_grupo=ng.id_group + ) ON tm.id_mensaje=ng.id_mensaje + WHERE utimestamp_erased is null + AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0) + ) t + %s + ORDER BY %s', $config['id_user'], + $config['id_user'], + $read, $order ); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 03f0b07963..3005e9a47c 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -81,14 +81,19 @@ function get_notification_targets(int $id_message) if (is_array($ret)) { foreach ($ret as $row) { - array_push($targets['users'], $row['id_user']); + array_push( + $targets['users'], + get_user_fullname($row['id_user']) + ); } } - $ret = $targets['groups'] = db_get_all_rows_sql( + $ret = db_get_all_rows_sql( sprintf( - 'SELECT id_group + 'SELECT COALESCE(tg.nombre,ng.id_group) as "id_group" FROM tnotification_group ng + LEFT JOIN tgrupo tg + ON tg.id_grupo=ng.id_group WHERE ng.id_mensaje = %d', $id_message ) @@ -96,9 +101,49 @@ function get_notification_targets(int $id_message) if (is_array($ret)) { foreach ($ret as $row) { + if ($row['id_group'] == '0') { + $row['id_group'] = '<b>'.__('All').'</b>'; + } + array_push($targets['groups'], $row['id_group']); } } return $targets; } + + +/** + * Check if current user has grants to read this notification + * + * @param integer $id_message Target message. + * + * @return boolean true, read available. False if not. + */ +function check_notification_readable(int $id_message) +{ + global $config; + + if (empty($id_message)) { + return false; + } + + $sql = sprintf( + 'SELECT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + LEFT JOIN tnotification_user nu + ON tm.id_mensaje=nu.id_mensaje + AND tm.id_mensaje=%d + LEFT JOIN (tnotification_group ng + INNER JOIN tusuario_perfil up + ON ng.id_group=up.id_grupo + AND up.id_grupo=ng.id_group + ) ON tm.id_mensaje=ng.id_mensaje + WHERE utimestamp_erased is null + AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0)', + $id_message, + $config['id_user'], + $config['id_user'] + ); + + return (bool) db_get_value_sql($sql); +} diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index a92abc19e8..b284bc3d13 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -90,7 +90,7 @@ if ($read_message) { messages_process_read($message_id); } - if ($message == false) { + if ($message === false) { echo '<div>'.__('This message does not exist in the system').'</div>'; return; // Move out of this page and go processing other pages. diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index 49ecfe14dd..4a6d48a397 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -109,18 +109,20 @@ if ($show_sent) { // Sent view. $num_messages = messages_get_count_sent($config['id_user']); if ($num_messages > 0 && !is_ajax()) { - echo '<p>'.__('You have').' <b>'.$num_messages.'</b>'.__('sent message(s)').'.</p>'; + echo '<p>'.__('You have').' <b>'.$num_messages.'</b> '.__('sent message(s)').'.</p>'; } $messages = messages_get_overview_sent('', 'DESC'); } else { // Messages received. - $num_messages = messages_get_count($config['id_user']); + $num_messages = messages_get_count($config['id_user'], true); if ($num_messages > 0 && !is_ajax()) { - echo '<p>'.__('You have').' <b>'.$num_messages.'</b>'.__('unread message(s)').'.</p>'; + $unread_messages = messages_get_count($config['id_user']); + echo '<p>'.__('You have').' <b>'.$unread_messages.'</b> '.__('unread message(s)').'.</p>'; + $messages = messages_get_overview(); + } else { + $messages = messages_get_overview('status', 'ASC', false); } - - $messages = messages_get_overview(); } if (empty($messages)) { @@ -168,7 +170,7 @@ if (empty($messages)) { $message_id = $message['id_mensaje']; $data = []; $data[0] = ''; - if ($message['status'] == 1) { + if ($message['read'] == 1) { if ($show_sent) { $data[0] .= '<a href="index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&show_sent=1&id_message='.$message_id.'">'; $data[0] .= html_print_image('images/email_open.png', true, ['border' => 0, 'title' => __('Click to read')]); From 397f2964da997b91a7f36463f1eb8d7eec2c19cd Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 31 Jan 2019 15:16:56 +0100 Subject: [PATCH 007/262] Added messages notification ball Former-commit-id: c44a99cf63bc7451890389e4d234fd8aa7b62cbc --- pandora_console/general/header.php | 4 +++- .../include/functions_notifications.php | 16 ++++++++++++++++ pandora_console/include/styles/pandora.css | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index c26bed8762..1edcf76b77 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -16,6 +16,7 @@ require_once ("include/functions_messages.php"); require_once ('include/functions_servers.php'); +require_once ('include/functions_notifications.php'); // Check permissions @@ -65,6 +66,7 @@ config_check(); $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;'; @@ -360,7 +362,7 @@ config_check(); $table->data[0][9] .= '</a>'; } - + $table->data[0]['notifications'] = notifications_print_ball(); html_print_table($table); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 3005e9a47c..5c9bb71885 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -147,3 +147,19 @@ function check_notification_readable(int $id_message) return (bool) db_get_value_sql($sql); } + +/** + * Print the notification ball to see unread messages + * + * @return string with HTML code of notification ball + */ +function notifications_print_ball() { + $num_notifications = messages_get_count(); + $class_status = $num_notifications == 0 + ? 'notification-ball-no-messages' + : 'notification-ball-new-messages'; + return + "<div class='notification-ball $class_status' id='notification-ball-header'> + $num_notifications + </div>"; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index f42c64f70a..15d81dbbb5 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4912,6 +4912,23 @@ div#dialog_messages table th:last-child { text-align: right; } +.notification-ball { + border: white solid 2px; + border-radius: 50px; + width: 18px; + height: 18px; + display: flex; + justify-content: center; + align-items: center; +} + +.notification-ball-no-messages { + background-color: #82b92e; +} +.notification-ball-new-messages { + background-color: #fc4444; +} + /* --- JQUERY-UI --- */ .ui-button-text-only .ui-button-text { font-family: "nunito", sans-serif; From 95f3c063a51ef417ed3f98262396382751796cc5 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 31 Jan 2019 16:27:55 +0100 Subject: [PATCH 008/262] Added tnotification_source_group_user table Former-commit-id: e1b542a76ceb0e80f49904c16a98e44c14fff1ff --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 19 +++++++++++++++++++ pandora_console/pandoradb.sql | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index e62e76efd5..482fcb8f4e 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1953,6 +1953,25 @@ CREATE TABLE `tnotification_source_group` ( `id_source` BIGINT(20) UNSIGNED NOT NULL, `id_group` mediumint(4) unsigned NOT NULL, PRIMARY KEY (`id_source`,`id_group`), + INDEX (`id_group`), FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c70650c70b..daae31bf5d 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1246,10 +1246,29 @@ CREATE TABLE `tnotification_source_group` ( `id_source` BIGINT(20) UNSIGNED NOT NULL, `id_group` mediumint(4) unsigned NOT NULL, PRIMARY KEY (`id_source`,`id_group`), + INDEX (`id_group`), FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------------------------------------------------- +-- Table `tnotification_source_user` +-- ---------------------------------------------------------------------- +CREATE TABLE `tnotification_source_group_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ---------------------------------------------------------------------- -- Table `tnews` -- ---------------------------------------------------------------------- From b589826c8602f4c93096a3825af7453c8ef4b053 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 31 Jan 2019 19:11:59 +0100 Subject: [PATCH 009/262] Added HTML switch element Former-commit-id: 426557a47577fd9b5b2002ed02d70f1effb92162 --- pandora_console/include/functions.php | 11 +++++ pandora_console/include/functions_html.php | 19 ++++++++ pandora_console/include/styles/pandora.css | 56 ++++++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 6741f08bc1..bce19cadda 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3516,4 +3516,15 @@ function mask2cidr($mask){ return 32-log(($long ^ $base)+1,2); } +/** + * Convert the checkbox result to 1 or 0 + * + * @param string $value Param returned by swith fomulary. + * + * @return int 1 if value is "on". 0 otherwise. + */ +function switch_to_int(string $value) { + return $value === "on" ? 1 : 0; +} + ?> diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index a3e3358c82..8510b5e259 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2580,4 +2580,23 @@ function html_print_csrf_error () { ); return true; } + +/** + * Print an swith button + * + * @param array $atributes. Valid params: + * name: Usefull to handle in forms + * value: If is checked or not + * @return string with HTML of button + */ +function html_print_switch ($attributes = array()) { + + $name_html = isset($attributes['name']) ? "name = {$attributes['name']}" : ''; + $checked_html = (bool)$attributes['value'] ? 'checked' : ''; + return + "<label class='p-switch'> + <input type='checkbox' $name_html $checked_html> + <span class='p-slider'></span> + </label>"; +} ?> diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 15d81dbbb5..6256d1a7c0 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5175,3 +5175,59 @@ input[type="submit"].ui-button-dialog { width: 90px !important; } /* --- END - JQUERY-UI --- */ + +/* --- SWITCH --- */ +.p-switch { + position: relative; + display: inline-block; + width: 30px; + height: 17px; +} + +.p-switch input { + opacity: 0; + width: 0; + height: 0; +} + +.p-slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: 0.4s; + transition: 0.4s; + border-radius: 34px; +} + +.p-slider:before { + position: absolute; + content: ""; + height: 13px; + width: 13px; + left: 2px; + bottom: 2px; + background-color: white; + -webkit-transition: 0.4s; + transition: 0.4s; + border-radius: 50%; +} + +input:checked + .p-slider { + background-color: #82b92e; +} + +input:focus + .p-slider { + box-shadow: 0 0 1px #82b92e; +} + +input:checked + .p-slider:before { + -webkit-transform: translateX(13px); + -ms-transform: translateX(13px); + transform: translateX(13px); +} + +/* --- END SWITCH --- */ From 01bc0775bcaaef3140de22afc40b600c90ea83c6 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 31 Jan 2019 19:13:51 +0100 Subject: [PATCH 010/262] Added notification global configuration (only enable and disable) Former-commit-id: 850d4dd1d8e30fc66623308b8ab148eaeadb5015 --- pandora_console/godmode/menu.php | 5 +- pandora_console/godmode/setup/setup.php | 12 ++++ .../godmode/setup/setup_notifications.php | 66 +++++++++++++++++++ .../include/functions_notifications.php | 54 +++++++++++++-- pandora_console/include/styles/pandora.css | 10 +++ 5 files changed, 140 insertions(+), 7 deletions(-) create mode 100644 pandora_console/godmode/setup/setup_notifications.php diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 8ad895ff35..854a897349 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -271,7 +271,10 @@ if (check_acl ($config['id_user'], 0, "PM")) { $sub2["godmode/setup/setup&section=ehorus"]["text"] = __('eHorus'); $sub2["godmode/setup/setup&section=ehorus"]["refr"] = 0; - + + $sub2["godmode/setup/setup&section=notifications"]["text"] = __('Notifications'); + $sub2["godmode/setup/setup&section=notifications"]["refr"] = 0; + if ($config['activate_gis']) { $sub2["godmode/setup/gis"]["text"] = __('Map conections GIS'); } diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 1b4f2a208c..59652d6f1a 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -101,6 +101,11 @@ $buttons['ehorus'] = array('active' => false, 'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=ehorus">' . html_print_image("images/ehorus/ehorus.png", true, array ("title" => __('eHorus'))) . '</a>'); +// FIXME: Not definitive icon +$buttons['notifications'] = array('active' => false, + 'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=notifications">' . + html_print_image("images/alerts_template.png", true, array ("title" => __('Notifications'))) . '</a>'); + $help_header = ''; if (enterprise_installed()) { $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); @@ -132,6 +137,10 @@ switch ($section) { $buttons['ehorus']['active'] = true; $subpage = ' » ' . __('eHorus'); break; + case 'notifications': + $buttons['notifications']['active'] = true; + $subpage = ' » ' . __('Notifications'); + break; } // Header @@ -167,6 +176,9 @@ switch ($section) { case "ehorus": require_once($config['homedir'] . "/godmode/setup/setup_ehorus.php"); break; + case "notifications": + require_once($config['homedir'] . "/godmode/setup/setup_notifications.php"); + break; default: enterprise_hook('setup_enterprise_select_tab', array($section)); break; diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php new file mode 100644 index 0000000000..f598a00a9c --- /dev/null +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -0,0 +1,66 @@ +<?php + +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2019 Artica Soluciones Tecnologicas +// Please see http://pandorafms.org for full contribution list + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation for version 2. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Warning: This file may be required into the metaconsole's setup + +// Load global vars +global $config; + +check_login (); + +if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { + db_pandora_audit('ACL Violation', 'Trying to access Setup Management'); + require ('general/noaccess.php'); + return; +} + +// Actions +if (get_parameter('update_config', 0)) { + $res_global = array_reduce(notifications_get_all_sources(), function($carry, $source){ + $id = notifications_desc_to_id($source['description']); + if (empty($id)) return false; + $enable_value = switch_to_int(get_parameter("enable-$id")); + $res = mysql_db_process_sql_update( + 'tnotification_source', + array( + 'enabled' => $enable_value), + array('id' => $source['id']) + ); + return $res && $carry; + }, true); +} + +// Notification table. It is just a wrapper. +$table_content = new StdClass(); +$table_content->data = array(); +$table_content->width = '100%'; +$table_content->id = 'notifications-wrapper'; +$table_content->class = 'databox filters'; +$table_content->size['name'] = '30%'; +$table_remote->style['name'] = 'font-weight: bold'; + +// Print each source configuration +$table_content->data = array_map(function ($source) { + return notifications_print_global_source_configuration($source); +}, notifications_get_all_sources()); +$table_content->data[] = html_print_submit_button( + __('Update'), 'update_button', false, 'class="sub upd" style="display: flex; "', true +); + +echo '<form id="form_enable" method="post">'; +html_print_input_hidden('update_config', 1); +html_print_table($table_content); +echo '</form>'; + diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 5c9bb71885..c59b44f1fd 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -42,15 +42,24 @@ function get_notification_source_id(string $source) } return db_get_value_sql( - sprintf( - 'SELECT id - FROM `tnotification_source` - WHERE lower(`description`) = lower("%s")', - $source - ) + "SELECT id + FROM `tnotification_source` + WHERE `description` LIKE '{$source}%'" ); } +/** + * Converts description into a handable identifier + * + * @param string $desc Full description + * + * @return string First word in lowercase. Empty string if no word detected. + */ +function notifications_desc_to_id(string $desc) { + preg_match('/^[a-zA-Z]*/', $desc, $matches); + $match = $matches[0]; + return isset($match) ? $match : ''; +} /** * Retrieve all targets for given message. @@ -148,6 +157,15 @@ function check_notification_readable(int $id_message) return (bool) db_get_value_sql($sql); } +/** + * Return all info from tnotification_source + * + * @return array with sources info + */ +function notifications_get_all_sources() { + return mysql_db_get_all_rows_in_table('tnotification_source'); +} + /** * Print the notification ball to see unread messages * @@ -163,3 +181,27 @@ function notifications_print_ball() { $num_notifications </div>"; } + +/** + * Print notification configuration global + * + * @param array notification source data + * + * @return string with HTML of source configuration + */ +function notifications_print_global_source_configuration($source) { + + // Get some values to generate the title + $switch_values = array ( + 'name' => "enable-" . notifications_desc_to_id($source['description']), + 'value' => $source['enabled'] + ); + // Generate the title + $html_title = "<div class='global-config-notification-title'>"; + $html_title .= html_print_switch($switch_values); + $html_title .= "<h2>{$source['description']}</h2>"; + $html_title .= "</div>"; + + // Return all html + return $html_title; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 6256d1a7c0..924e147895 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4929,6 +4929,16 @@ div#dialog_messages table th:last-child { background-color: #fc4444; } +.global-config-notification-title { + display: flex; + flex-direction: row; + align-items: center; +} + +.global-config-notification-title h2 { + margin-left: 10px; +} + /* --- JQUERY-UI --- */ .ui-button-text-only .ui-button-text { font-family: "nunito", sans-serif; From 75eaa875c93847a7759f818e6da1ecca5bfc43d1 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 31 Jan 2019 19:43:13 +0100 Subject: [PATCH 011/262] Added checkboxes to notifications global configuration Former-commit-id: 79df159f003292dfef697773fe8daa25b77f04c2 --- .../godmode/setup/setup_notifications.php | 6 +++++- .../include/functions_notifications.php | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index f598a00a9c..40a4031dbb 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -32,10 +32,14 @@ if (get_parameter('update_config', 0)) { $id = notifications_desc_to_id($source['description']); if (empty($id)) return false; $enable_value = switch_to_int(get_parameter("enable-$id")); + $mail_value = (int)get_parameter("mail-{$id}", 0); + $user_value = (int)get_parameter("user-{$id}", 0); $res = mysql_db_process_sql_update( 'tnotification_source', array( - 'enabled' => $enable_value), + 'enabled' => $enable_value, + 'user_editable' => $user_value, + 'also_mail' => $mail_value), array('id' => $source['id']) ); return $res && $carry; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index c59b44f1fd..d7810417db 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -192,8 +192,9 @@ function notifications_print_ball() { function notifications_print_global_source_configuration($source) { // Get some values to generate the title + $id = notifications_desc_to_id($source['description']); $switch_values = array ( - 'name' => "enable-" . notifications_desc_to_id($source['description']), + 'name' => "enable-" . $id, 'value' => $source['enabled'] ); // Generate the title @@ -202,6 +203,17 @@ function notifications_print_global_source_configuration($source) { $html_title .= "<h2>{$source['description']}</h2>"; $html_title .= "</div>"; + // Generate the checkboxes and time select + $html_checkboxes = "<div class='global-config-notification-checkboxes'>"; + $html_checkboxes .= " <span>"; + $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true); + $html_checkboxes .= __('Also email users with notification content'); + $html_checkboxes .= " </span><br><span>"; + $html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true); + $html_checkboxes .= __('Users cannot modify notification preferences'); + $html_checkboxes .= " </span>"; + $html_checkboxes .= "</div>"; + // Return all html - return $html_title; + return $html_title . $html_checkboxes; } From 1c0a5ca247930bae3b6378b053d7876e16ad7d62 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 31 Jan 2019 20:11:43 +0100 Subject: [PATCH 012/262] Added pospone select (fixme) Former-commit-id: 428b4424a15ef54c4d95a2eb4af07a334366577a --- .../godmode/setup/setup_notifications.php | 5 +++- .../include/functions_notifications.php | 23 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 40a4031dbb..c105b89e62 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -34,12 +34,15 @@ if (get_parameter('update_config', 0)) { $enable_value = switch_to_int(get_parameter("enable-$id")); $mail_value = (int)get_parameter("mail-{$id}", 0); $user_value = (int)get_parameter("user-{$id}", 0); + $postpone_value = (int)get_parameter("postpone-{$id}", 0); $res = mysql_db_process_sql_update( 'tnotification_source', array( 'enabled' => $enable_value, 'user_editable' => $user_value, - 'also_mail' => $mail_value), + 'also_mail' => $mail_value, + 'max_postpone_time' => $postpone_value + ), array('id' => $source['id']) ); return $res && $carry; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index d7810417db..85bcf5caf3 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -27,6 +27,7 @@ * ============================================================================ */ +define('NOTIFICATIONS_POSTPONE_FOREVER', -1); /** * Retrieves source ID for given source. @@ -214,6 +215,26 @@ function notifications_print_global_source_configuration($source) { $html_checkboxes .= " </span>"; $html_checkboxes .= "</div>"; + // Generate the select with the time + $html_select_pospone = __('Users can postpone notifications up to'); + $html_select_pospone .= html_print_select ( + array( + SECONDS_5MINUTES => __('5 minutes'), + SECONDS_15MINUTES => __('15 minutes'), + SECONDS_12HOURS => __('12 hours'), + SECONDS_1DAY => __('1 day'), + SECONDS_1WEEK => __('1 week'), + SECONDS_15DAYS => __('15 days'), + SECONDS_1MONTH => __('1 month'), + NOTIFICATIONS_POSTPONE_FOREVER => __('forever')), + "postpone-{$id}", + $source['max_postpone_time'], + '', + '', + 0, + true + ); + // Return all html - return $html_title . $html_checkboxes; + return $html_title . $html_checkboxes . $html_select_pospone; } From 315a51c5e76a6e7cd6332f9796d1c05685d503e7 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Fri, 1 Feb 2019 13:46:58 +0100 Subject: [PATCH 013/262] Added only read selector global notification setup Former-commit-id: bd6262cda30c0bb5a63b106e6c3832efbcfc63b9 --- .../include/functions_notifications.php | 53 ++++++++++++++++++- pandora_console/include/styles/pandora.css | 27 ++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 85bcf5caf3..9dfca6bf99 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -167,6 +167,31 @@ function notifications_get_all_sources() { return mysql_db_get_all_rows_in_table('tnotification_source'); } +function notifications_get_user_sources_for_select($source_id) { + $users = db_get_all_rows_filter( + 'tnotification_source_user', + array('id_source' => $source_id), + 'id_user' + ); + // If fails or no one is selected, return empty array + if ($users === false) return array(); + + return index_array($users, 'id_user', 'id_user'); +} + +function notifications_get_group_sources_for_select($source_id) { + $users = db_get_all_rows_filter( + 'tnotification_source_group tnsg + INNER JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo', + array('id_source' => $source_id), + array ('tnsg.id_group', 'tg.nombre') + ); + // If fails or no one is selected, return empty array + if ($users === false) return array(); + + return index_array($users, 'id_group', 'nombre'); +} + /** * Print the notification ball to see unread messages * @@ -204,6 +229,12 @@ function notifications_print_global_source_configuration($source) { $html_title .= "<h2>{$source['description']}</h2>"; $html_title .= "</div>"; + // Generate the html for title + $html_selectors = "<div class='global-config-notification-selectors'>"; + $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users'); + $html_selectors .= notifications_print_source_select_box(notifications_get_group_sources_for_select($source['id']), 'groups'); + $html_selectors .= "</div>"; + // Generate the checkboxes and time select $html_checkboxes = "<div class='global-config-notification-checkboxes'>"; $html_checkboxes .= " <span>"; @@ -236,5 +267,25 @@ function notifications_print_global_source_configuration($source) { ); // Return all html - return $html_title . $html_checkboxes . $html_select_pospone; + return $html_title . $html_selectors . $html_checkboxes . $html_select_pospone; +} + +function notifications_print_source_select_box($info_selec, $id) { + + $title = $id == "users" ? __('Notified users') : __('Notified groups'); + $add_title = $id == "users" ? __('Add users') : __('Add groups'); + $delete_title = $id == "users" ? __('Delete users') : __('Delete groups'); + + // Generate the HTML + $html_select = "<div class='global-config-notification-single-selector'>"; + $html_select .= " <div>"; + $html_select .= " <h4>$title</h4>"; + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}[]", 0, false, '', '', true, true); + $html_select .= " </div>"; + $html_select .= " <div class='global-notifications-icons'>"; + $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title)); + $html_select .= html_print_image('images/input_delete.png', true, array('title' => $delete_title)); + $html_select .= " </div>"; + $html_select .= "</div>"; + return $html_select; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 924e147895..e1545c8d5d 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4939,6 +4939,33 @@ div#dialog_messages table th:last-child { margin-left: 10px; } +.global-config-notification-selectors { + display: flex; + flex-direction: row; + margin-bottom: 10px; +} + +.global-config-notification-selectors h4 { + margin: 0; +} + +.global-config-notification-single-selector { + display: flex; + width: 100%; + padding: 0 10px; +} + +.global-config-notification-single-selector :first-child, +.global-config-notification-single-selector :first-child select { + width: 99%; +} + +.global-config-notification-single-selector :last-child { + flex-direction: column; + display: flex; + justify-content: flex-end; +} + /* --- JQUERY-UI --- */ .ui-button-text-only .ui-button-text { font-family: "nunito", sans-serif; From a8b85d2593cb289b00a00a3e8f77a14532823cf6 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Fri, 1 Feb 2019 13:53:22 +0100 Subject: [PATCH 014/262] Added missing docs Former-commit-id: 807c7466b60e4c8ecb77fb8d94102300e9bcd780 --- .../include/functions_notifications.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 9dfca6bf99..d5cd4ac97f 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -167,6 +167,13 @@ function notifications_get_all_sources() { return mysql_db_get_all_rows_in_table('tnotification_source'); } +/** + * Return the user sources to be inserted into a select + * + * @param int $source_id Source database identificator + * + * @return array with the user id in keys and user id in value too + */ function notifications_get_user_sources_for_select($source_id) { $users = db_get_all_rows_filter( 'tnotification_source_user', @@ -179,6 +186,14 @@ function notifications_get_user_sources_for_select($source_id) { return index_array($users, 'id_user', 'id_user'); } + +/** + * Return the groups sources to be inserted into a select + * + * @param int $source_id Source database identificator + * + * @return array with the group id in keys and group name in value + */ function notifications_get_group_sources_for_select($source_id) { $users = db_get_all_rows_filter( 'tnotification_source_group tnsg @@ -270,6 +285,14 @@ function notifications_print_global_source_configuration($source) { return $html_title . $html_selectors . $html_checkboxes . $html_select_pospone; } +/** + * Print select boxes of notified users or groups + * + * @param array $info_selec All info required for build the selector + * @param string $id users|groups + * + * @return string HTML with the generated selector + */ function notifications_print_source_select_box($info_selec, $id) { $title = $id == "users" ? __('Notified users') : __('Notified groups'); @@ -280,6 +303,7 @@ function notifications_print_source_select_box($info_selec, $id) { $html_select = "<div class='global-config-notification-single-selector'>"; $html_select .= " <div>"; $html_select .= " <h4>$title</h4>"; + // Put a true if empty sources to avoid to sow the 'None' value $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}[]", 0, false, '', '', true, true); $html_select .= " </div>"; $html_select .= " <div class='global-notifications-icons'>"; From 50030b69332bd93a29957e9d213bd5aabfe7e80d Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Fri, 1 Feb 2019 14:48:52 +0100 Subject: [PATCH 015/262] Added notify all users and disable on first load Former-commit-id: d193a8375ce00f3f2cf2c1fc181d4eef47c92eb2 --- .../include/functions_notifications.php | 28 +++++++++++++------ pandora_console/include/styles/pandora.css | 4 +++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index d5cd4ac97f..3d62dc0429 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -195,16 +195,16 @@ function notifications_get_user_sources_for_select($source_id) { * @return array with the group id in keys and group name in value */ function notifications_get_group_sources_for_select($source_id) { - $users = db_get_all_rows_filter( + $groups = db_get_all_rows_filter( 'tnotification_source_group tnsg - INNER JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo', + LEFT JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo', array('id_source' => $source_id), - array ('tnsg.id_group', 'tg.nombre') + array ('tnsg.id_group', 'IFNULL(tg.nombre, "All") AS name') ); // If fails or no one is selected, return empty array - if ($users === false) return array(); + if ($groups === false) return array(); - return index_array($users, 'id_group', 'nombre'); + return index_array($groups, 'id_group', 'name'); } /** @@ -238,6 +238,12 @@ function notifications_print_global_source_configuration($source) { 'name' => "enable-" . $id, 'value' => $source['enabled'] ); + + // Search if group all is set and handle that situation + $source_groups = notifications_get_group_sources_for_select($source['id']); + $is_group_all = isset($source_groups["0"]); + if($is_group_all) unset($source_groups["0"]); + // Generate the title $html_title = "<div class='global-config-notification-title'>"; $html_title .= html_print_switch($switch_values); @@ -246,13 +252,16 @@ function notifications_print_global_source_configuration($source) { // Generate the html for title $html_selectors = "<div class='global-config-notification-selectors'>"; - $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users'); - $html_selectors .= notifications_print_source_select_box(notifications_get_group_sources_for_select($source['id']), 'groups'); + $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $is_group_all); + $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $is_group_all); $html_selectors .= "</div>"; // Generate the checkboxes and time select $html_checkboxes = "<div class='global-config-notification-checkboxes'>"; $html_checkboxes .= " <span>"; + $html_checkboxes .= html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)'); + $html_checkboxes .= __('Notify all users'); + $html_checkboxes .= " </span><br><span>"; $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true); $html_checkboxes .= __('Also email users with notification content'); $html_checkboxes .= " </span><br><span>"; @@ -290,10 +299,11 @@ function notifications_print_global_source_configuration($source) { * * @param array $info_selec All info required for build the selector * @param string $id users|groups + * @param bool $disabled Disable the selectors * * @return string HTML with the generated selector */ -function notifications_print_source_select_box($info_selec, $id) { +function notifications_print_source_select_box($info_selec, $id, $disabled) { $title = $id == "users" ? __('Notified users') : __('Notified groups'); $add_title = $id == "users" ? __('Add users') : __('Add groups'); @@ -304,7 +314,7 @@ function notifications_print_source_select_box($info_selec, $id) { $html_select .= " <div>"; $html_select .= " <h4>$title</h4>"; // Put a true if empty sources to avoid to sow the 'None' value - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}[]", 0, false, '', '', true, true); + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}[]", 0, false, '', '', true, true, true,'', $disabled); $html_select .= " </div>"; $html_select .= " <div class='global-notifications-icons'>"; $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title)); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index e1545c8d5d..aee1b9dc5d 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4939,6 +4939,10 @@ div#dialog_messages table th:last-child { margin-left: 10px; } +.global-config-notification-checkboxes :first-child { + font-weight: bold; +} + .global-config-notification-selectors { display: flex; flex-direction: row; From d2a3d3bbbcdb800df3463e07e79f63d1eaae865e Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Mon, 4 Feb 2019 10:41:35 +0100 Subject: [PATCH 016/262] Added all users in global notifications config Former-commit-id: d4bf0067f3ffe2e4fdef25158579716bdfd78d5d --- .../godmode/setup/setup_notifications.php | 8 +++- .../include/functions_notifications.php | 47 +++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index c105b89e62..d3c846aebf 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -35,7 +35,8 @@ if (get_parameter('update_config', 0)) { $mail_value = (int)get_parameter("mail-{$id}", 0); $user_value = (int)get_parameter("user-{$id}", 0); $postpone_value = (int)get_parameter("postpone-{$id}", 0); - $res = mysql_db_process_sql_update( + $all_users = (int)get_parameter("all-{$id}", 0); + $res = db_process_sql_update( 'tnotification_source', array( 'enabled' => $enable_value, @@ -45,7 +46,10 @@ if (get_parameter('update_config', 0)) { ), array('id' => $source['id']) ); - return $res && $carry; + $all_users_res = $all_users + ? notifications_add_group_to_source($source['id'], array(0)) + : notifications_remove_group_from_source($source['id'], array(0)); + return $all_users_res && $res && $carry; }, true); } diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 3d62dc0429..921b5c55e1 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -207,6 +207,53 @@ function notifications_get_group_sources_for_select($source_id) { return index_array($groups, 'id_group', 'name'); } +/** + * Delete a set of groups from notification source + * + * @param int Source id + * @param array Id of groups to be deleted + * + * @return bool True if success. False otherwise. + */ +function notifications_remove_group_from_source ($source_id, $groups) { + // Source id is mandatory + if (!isset($source_id)) return false; + + // Delete from database + return db_process_sql_delete ( + 'tnotification_source_group', + array( + 'id_group' => $groups, + 'id_source' => $source_id + ) + ) !== false; +} + +/** + * Insert a set of groups to notification source + * + * @param int Source id + * @param array Id of groups to be deleted + * + * @return bool True if success. False otherwise. + */ +function notifications_add_group_to_source ($source_id, $groups) { + // Source id is mandatory + if (!isset($source_id)) return false; + + // Insert into database all groups passed + $res = true; + foreach ($groups as $group) { + $res = db_process_sql_insert( + 'tnotification_source_group', + array( + 'id_group' => $group, + 'id_source' => $source_id) + ) !== false; + } + return $res; +} + /** * Print the notification ball to see unread messages * From 54f0bc1a038a5de061438f2b25b45011eef93cf6 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Mon, 4 Feb 2019 11:02:52 +0100 Subject: [PATCH 017/262] Disable selec boxes when click notify all users on notifications global config Former-commit-id: 93a3a0007a3a8dfabfec5d0b9ead7d185aeee81b --- .../godmode/setup/setup_notifications.php | 20 +++++++++++++++++++ .../include/functions_notifications.php | 9 +++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index d3c846aebf..06e6a85b63 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -75,3 +75,23 @@ html_print_input_hidden('update_config', 1); html_print_table($table_content); echo '</form>'; +?> +<script> + +// Get the source id +function notifications_get_source_id(id) { + var matched = id.match(/.*-(.*)/); + if (matched == null) return ''; + return matched[1]; +} + +// Disable or enable the select seeing the checked value of notify all users +function notifications_disable_source(event) { + var id = notifications_get_source_id(event.target.id); + var is_checked = document.getElementById(event.target.id).checked; + var selectors = ['groups', 'users']; + selectors.map(function (select) { + document.getElementById('multi-' + select + '-' + id).disabled = is_checked; + }); +} +</script> diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 921b5c55e1..24013b92fd 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -299,8 +299,8 @@ function notifications_print_global_source_configuration($source) { // Generate the html for title $html_selectors = "<div class='global-config-notification-selectors'>"; - $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $is_group_all); - $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $is_group_all); + $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all); + $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all); $html_selectors .= "</div>"; // Generate the checkboxes and time select @@ -346,11 +346,12 @@ function notifications_print_global_source_configuration($source) { * * @param array $info_selec All info required for build the selector * @param string $id users|groups + * @param string $source_id Id of source * @param bool $disabled Disable the selectors * * @return string HTML with the generated selector */ -function notifications_print_source_select_box($info_selec, $id, $disabled) { +function notifications_print_source_select_box($info_selec, $id, $source_id, $disabled) { $title = $id == "users" ? __('Notified users') : __('Notified groups'); $add_title = $id == "users" ? __('Add users') : __('Add groups'); @@ -361,7 +362,7 @@ function notifications_print_source_select_box($info_selec, $id, $disabled) { $html_select .= " <div>"; $html_select .= " <h4>$title</h4>"; // Put a true if empty sources to avoid to sow the 'None' value - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}[]", 0, false, '', '', true, true, true,'', $disabled); + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true,'', $disabled); $html_select .= " </div>"; $html_select .= " <div class='global-notifications-icons'>"; $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title)); From 53947de42a13f96717e33606c2eae87014b990b6 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 4 Feb 2019 19:14:02 +0100 Subject: [PATCH 018/262] minor changes - constants style Former-commit-id: 3482cb88dc0884ea3c1742eb8fef4ac7c603a849 --- pandora_console/include/constants.php | 955 +++++++++++++------------- 1 file changed, 485 insertions(+), 470 deletions(-) diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 22f46257dc..cd1b907c0a 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -1,552 +1,567 @@ <?php -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2012 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation; version 2 - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - /** - * @package Include - * @subpackage Constants + * Constants definitions. + * + * @category Library + * @package Pandora FMS + * @subpackage Opensource + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ */ -/* Enterprise hook constant */ -define ('ENTERPRISE_NOT_HOOK', -1); +// Enterprise hook constant. +define('ENTERPRISE_NOT_HOOK', -1); -/* Others */ +// Others. define('GROUP_ALL', 0); -/* Date and time formats */ -define('DATE_FORMAT', 'Y/m/d'); -define('DATE_FORMAT_JS', 'yy/mm/dd'); -define('TIME_FORMAT', 'H:i:s'); -define('TIME_FORMAT_JS', 'HH:mm:ss'); +// Date and time formats. +define('DATE_FORMAT', 'Y/m/d'); +define('DATE_FORMAT_JS', 'yy/mm/dd'); +define('TIME_FORMAT', 'H:i:s'); +define('TIME_FORMAT_JS', 'HH:mm:ss'); -/* Events state constants */ -define ('EVENT_NEW', 0); -define ('EVENT_VALIDATE', 1); -define ('EVENT_PROCESS', 2); +// Events state constants. +define('EVENT_NEW', 0); +define('EVENT_VALIDATE', 1); +define('EVENT_PROCESS', 2); -/* Agents disabled status */ -define ('AGENT_ENABLED', 0); -define ('AGENT_DISABLED', 1); +// Agents disabled status. +define('AGENT_ENABLED', 0); +define('AGENT_DISABLED', 1); -/* Error report codes */ -define ('NOERR', 11111); -define ('ERR_GENERIC', -10000); -define ('ERR_EXIST', -20000); -define ('ERR_INCOMPLETE', -30000); -define ('ERR_DB', -40000); -define ('ERR_DB_HOST', -40001); -define ('ERR_DB_DB', -40002); -define ('ERR_FILE', -50000); -define ('ERR_NOCHANGES', -60000); -define ('ERR_NODATA', -70000); -define ('ERR_CONNECTION', -80000); -define ('ERR_DISABLED', -90000); -define ('ERR_WRONG', -100000); -define ('ERR_WRONG_NAME', -100001); -define ('ERR_WRONG_PARAMETERS', -100002); -define ('ERR_ACL', -110000); -define ('ERR_AUTH', -120000); -define ('ERR_COULDNT_RESOLVE_HOST', -130000); +// Error report codes. +define('NOERR', 11111); +define('ERR_GENERIC', -10000); +define('ERR_EXIST', -20000); +define('ERR_INCOMPLETE', -30000); +define('ERR_DB', -40000); +define('ERR_DB_HOST', -40001); +define('ERR_DB_DB', -40002); +define('ERR_FILE', -50000); +define('ERR_NOCHANGES', -60000); +define('ERR_NODATA', -70000); +define('ERR_CONNECTION', -80000); +define('ERR_DISABLED', -90000); +define('ERR_WRONG', -100000); +define('ERR_WRONG_NAME', -100001); +define('ERR_WRONG_PARAMETERS', -100002); +define('ERR_ACL', -110000); +define('ERR_AUTH', -120000); +define('ERR_COULDNT_RESOLVE_HOST', -130000); -/* Event status code */ -define ('EVENT_STATUS_NEW', 0); -define ('EVENT_STATUS_INPROCESS', 2); -define ('EVENT_STATUS_VALIDATED', 1); +// Event status code. +define('EVENT_STATUS_NEW', 0); +define('EVENT_STATUS_INPROCESS', 2); +define('EVENT_STATUS_VALIDATED', 1); -/* Seconds in a time unit constants */ -define('SECONDS_1MINUTE', 60); -define('SECONDS_2MINUTES', 120); -define('SECONDS_5MINUTES', 300); -define('SECONDS_10MINUTES', 600); -define('SECONDS_15MINUTES', 900); -define('SECONDS_30MINUTES', 1800); -define('SECONDS_1HOUR', 3600); -define('SECONDS_2HOUR', 7200); -define('SECONDS_3HOUR', 10800); -define('SECONDS_5HOUR', 18000); -define('SECONDS_6HOURS', 21600); -define('SECONDS_12HOURS', 43200); -define('SECONDS_1DAY', 86400); -define('SECONDS_2DAY', 172800); -define('SECONDS_4DAY', 345600); -define('SECONDS_5DAY', 432000); -define('SECONDS_1WEEK', 604800); -define('SECONDS_10DAY', 864000); -define('SECONDS_2WEEK', 1209600); -define('SECONDS_15DAYS', 1296000); -define('SECONDS_1MONTH', 2592000); -define('SECONDS_2MONTHS', 5184000); -define('SECONDS_3MONTHS', 7776000); -define('SECONDS_6MONTHS', 15552000); -define('SECONDS_1YEAR', 31104000); -define('SECONDS_2YEARS', 62208000); -define('SECONDS_3YEARS', 93312000); +// Seconds in a time unit constants. +define('SECONDS_1MINUTE', 60); +define('SECONDS_2MINUTES', 120); +define('SECONDS_5MINUTES', 300); +define('SECONDS_10MINUTES', 600); +define('SECONDS_15MINUTES', 900); +define('SECONDS_30MINUTES', 1800); +define('SECONDS_1HOUR', 3600); +define('SECONDS_2HOUR', 7200); +define('SECONDS_3HOUR', 10800); +define('SECONDS_5HOUR', 18000); +define('SECONDS_6HOURS', 21600); +define('SECONDS_12HOURS', 43200); +define('SECONDS_1DAY', 86400); +define('SECONDS_2DAY', 172800); +define('SECONDS_4DAY', 345600); +define('SECONDS_5DAY', 432000); +define('SECONDS_1WEEK', 604800); +define('SECONDS_10DAY', 864000); +define('SECONDS_2WEEK', 1209600); +define('SECONDS_15DAYS', 1296000); +define('SECONDS_1MONTH', 2592000); +define('SECONDS_2MONTHS', 5184000); +define('SECONDS_3MONTHS', 7776000); +define('SECONDS_6MONTHS', 15552000); +define('SECONDS_1YEAR', 31104000); +define('SECONDS_2YEARS', 62208000); +define('SECONDS_3YEARS', 93312000); -/* Separator constats */ -define('SEPARATOR_COLUMN', ';'); -define('SEPARATOR_ROW', chr(10)); //chr(10) = '\n' -define('SEPARATOR_COLUMN_CSV', "#"); -define('SEPARATOR_ROW_CSV', "@\n"); +// Separator constats. +define('SEPARATOR_COLUMN', ';'); +define('SEPARATOR_ROW', chr(10)); +// Chr(10) is \n. +define('SEPARATOR_COLUMN_CSV', '#'); +define('SEPARATOR_ROW_CSV', "@\n"); -/* Backup paths */ -switch ($config["dbtype"]) { - case "mysql": - case "postgresql": - define ('BACKUP_DIR', 'attachment/backups'); - define ('BACKUP_FULLPATH', $config['homedir'] . '/' . BACKUP_DIR); - break; - case "oracle": - define ('BACKUP_DIR', 'DATA_PUMP_DIR'); - define ('BACKUP_FULLPATH', 'DATA_PUMP_DIR'); - break; +// Backup paths. +switch ($config['dbtype']) { + case 'mysql': + case 'postgresql': + define('BACKUP_DIR', 'attachment/backups'); + define('BACKUP_FULLPATH', $config['homedir'].'/'.BACKUP_DIR); + break; + + case 'oracle': + define('BACKUP_DIR', 'DATA_PUMP_DIR'); + define('BACKUP_FULLPATH', 'DATA_PUMP_DIR'); + break; + + default: + // Ignore. + break; } -/* Color constants */ -define('COL_CRITICAL', '#FC4444'); -define('COL_WARNING', '#FAD403'); -define('COL_WARNING_DARK', '#FFB900'); -define('COL_NORMAL', '#80BA27'); -define('COL_NOTINIT', '#3BA0FF'); -define('COL_UNKNOWN', '#B2B2B2'); -define('COL_DOWNTIME', '#976DB1'); -define('COL_IGNORED', '#DDD'); -define('COL_ALERTFIRED', '#FFA631'); -define('COL_MINOR', '#F099A2'); -define('COL_MAJOR', '#C97A4A'); -define('COL_INFORMATIONAL', '#E4E4E4'); -define('COL_MAINTENANCE', '#3BA0FF'); +// Color constants. +define('COL_CRITICAL', '#FC4444'); +define('COL_WARNING', '#FAD403'); +define('COL_WARNING_DARK', '#FFB900'); +define('COL_NORMAL', '#80BA27'); +define('COL_NOTINIT', '#3BA0FF'); +define('COL_UNKNOWN', '#B2B2B2'); +define('COL_DOWNTIME', '#976DB1'); +define('COL_IGNORED', '#DDD'); +define('COL_ALERTFIRED', '#FFA631'); +define('COL_MINOR', '#F099A2'); +define('COL_MAJOR', '#C97A4A'); +define('COL_INFORMATIONAL', '#E4E4E4'); +define('COL_MAINTENANCE', '#3BA0FF'); -define('COL_GRAPH1', '#C397F2'); -define('COL_GRAPH2', '#FFE66C'); -define('COL_GRAPH3', '#92CCA3'); -define('COL_GRAPH4', '#EA6D5B'); -define('COL_GRAPH5', '#6BD8DD'); -define('COL_GRAPH6', '#F49B31'); -define('COL_GRAPH7', '#999999'); -define('COL_GRAPH8', '#F2B8C1'); -define('COL_GRAPH9', '#C4E8C1'); -define('COL_GRAPH10', '#C1DBE5'); -define('COL_GRAPH11', '#C9C1e0'); -define('COL_GRAPH12', '#F45B95'); -define('COL_GRAPH13', '#E83128'); +define('COL_GRAPH1', '#C397F2'); +define('COL_GRAPH2', '#FFE66C'); +define('COL_GRAPH3', '#92CCA3'); +define('COL_GRAPH4', '#EA6D5B'); +define('COL_GRAPH5', '#6BD8DD'); +define('COL_GRAPH6', '#F49B31'); +define('COL_GRAPH7', '#999999'); +define('COL_GRAPH8', '#F2B8C1'); +define('COL_GRAPH9', '#C4E8C1'); +define('COL_GRAPH10', '#C1DBE5'); +define('COL_GRAPH11', '#C9C1e0'); +define('COL_GRAPH12', '#F45B95'); +define('COL_GRAPH13', '#E83128'); -/* The styles */ -/* Size of text in characters for truncate */ -define('GENERIC_SIZE_TEXT', 50); +// Styles. +// Size of text in characters for truncate. +define('GENERIC_SIZE_TEXT', 50); -/* Agent module status */ -define('AGENT_MODULE_STATUS_ALL', -1); -define('AGENT_MODULE_STATUS_CRITICAL_BAD', 1); -define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 100); -define('AGENT_MODULE_STATUS_NO_DATA', 4); -define('AGENT_MODULE_STATUS_NORMAL', 0); -define('AGENT_MODULE_STATUS_NORMAL_ALERT', 300); -define('AGENT_MODULE_STATUS_NOT_NORMAL', 6); -define('AGENT_MODULE_STATUS_WARNING', 2); -define('AGENT_MODULE_STATUS_WARNING_ALERT', 200); -define('AGENT_MODULE_STATUS_UNKNOWN', 3); -define('AGENT_MODULE_STATUS_NOT_INIT', 5); +// Agent module status. +define('AGENT_MODULE_STATUS_ALL', -1); +define('AGENT_MODULE_STATUS_CRITICAL_BAD', 1); +define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 100); +define('AGENT_MODULE_STATUS_NO_DATA', 4); +define('AGENT_MODULE_STATUS_NORMAL', 0); +define('AGENT_MODULE_STATUS_NORMAL_ALERT', 300); +define('AGENT_MODULE_STATUS_NOT_NORMAL', 6); +define('AGENT_MODULE_STATUS_WARNING', 2); +define('AGENT_MODULE_STATUS_WARNING_ALERT', 200); +define('AGENT_MODULE_STATUS_UNKNOWN', 3); +define('AGENT_MODULE_STATUS_NOT_INIT', 5); -/* Agent status */ -define('AGENT_STATUS_ALL', -1); -define('AGENT_STATUS_CRITICAL', 1); -define('AGENT_STATUS_NORMAL', 0); -define('AGENT_STATUS_NOT_INIT', 5); -define('AGENT_STATUS_NOT_NORMAL', 6); -define('AGENT_STATUS_UNKNOWN', 3); -define('AGENT_STATUS_ALERT_FIRED', 4); -define('AGENT_STATUS_WARNING', 2); +// Agent status. +define('AGENT_STATUS_ALL', -1); +define('AGENT_STATUS_CRITICAL', 1); +define('AGENT_STATUS_NORMAL', 0); +define('AGENT_STATUS_NOT_INIT', 5); +define('AGENT_STATUS_NOT_NORMAL', 6); +define('AGENT_STATUS_UNKNOWN', 3); +define('AGENT_STATUS_ALERT_FIRED', 4); +define('AGENT_STATUS_WARNING', 2); -/* Visual maps contants */ -//The items kind -define('STATIC_GRAPH', 0); -define('PERCENTILE_BAR', 3); -define('MODULE_GRAPH', 1); -define('AUTO_SLA_GRAPH', 14); -define('SIMPLE_VALUE', 2); -define('LABEL', 4); -define('ICON', 5); -define('SIMPLE_VALUE_MAX', 6); -define('SIMPLE_VALUE_MIN', 7); -define('SIMPLE_VALUE_AVG', 8); -define('PERCENTILE_BUBBLE', 9); -define('SERVICE', 10); //Enterprise Item. -define('GROUP_ITEM', 11); -define('BOX_ITEM', 12); -define('LINE_ITEM', 13); +// Visual maps contants. +// The items kind. +define('STATIC_GRAPH', 0); +define('PERCENTILE_BAR', 3); +define('MODULE_GRAPH', 1); +define('AUTO_SLA_GRAPH', 14); +define('SIMPLE_VALUE', 2); +define('LABEL', 4); +define('ICON', 5); +define('SIMPLE_VALUE_MAX', 6); +define('SIMPLE_VALUE_MIN', 7); +define('SIMPLE_VALUE_AVG', 8); +define('PERCENTILE_BUBBLE', 9); +define('SERVICE', 10); +// Enterprise Item. +define('GROUP_ITEM', 11); +define('BOX_ITEM', 12); +define('LINE_ITEM', 13); define('CIRCULAR_PROGRESS_BAR', 15); define('CIRCULAR_INTERIOR_PROGRESS_BAR', 16); -define('DONUT_GRAPH', 17); -define('BARS_GRAPH', 18); -define('CLOCK', 19); -define('COLOR_CLOUD', 20); -//Some styles -define('MIN_WIDTH', 300); -define('MIN_HEIGHT', 120); -define('MIN_WIDTH_CAPTION', 420); -//The process for simple value -define('PROCESS_VALUE_NONE', 0); -define('PROCESS_VALUE_MIN', 1); -define('PROCESS_VALUE_MAX', 2); -define('PROCESS_VALUE_AVG', 3); -//Status -define('VISUAL_MAP_STATUS_CRITICAL_BAD', 1); -define('VISUAL_MAP_STATUS_CRITICAL_ALERT', 4); -define('VISUAL_MAP_STATUS_NORMAL', 0); -define('VISUAL_MAP_STATUS_WARNING', 2); -define('VISUAL_MAP_STATUS_UNKNOWN', 3); -define('VISUAL_MAP_STATUS_WARNING_ALERT', 10); -//Wizard -define('VISUAL_MAP_WIZARD_PARENTS_NONE', 0); -define('VISUAL_MAP_WIZARD_PARENTS_ITEM_MAP', 1); -define('VISUAL_MAP_WIZARD_PARENTS_AGENT_RELANTIONSHIP', 2); +define('DONUT_GRAPH', 17); +define('BARS_GRAPH', 18); +define('CLOCK', 19); +define('COLOR_CLOUD', 20); +// Some styles. +define('MIN_WIDTH', 300); +define('MIN_HEIGHT', 120); +define('MIN_WIDTH_CAPTION', 420); +// The process for simple value. +define('PROCESS_VALUE_NONE', 0); +define('PROCESS_VALUE_MIN', 1); +define('PROCESS_VALUE_MAX', 2); +define('PROCESS_VALUE_AVG', 3); +// Status. +define('VISUAL_MAP_STATUS_CRITICAL_BAD', 1); +define('VISUAL_MAP_STATUS_CRITICAL_ALERT', 4); +define('VISUAL_MAP_STATUS_NORMAL', 0); +define('VISUAL_MAP_STATUS_WARNING', 2); +define('VISUAL_MAP_STATUS_UNKNOWN', 3); +define('VISUAL_MAP_STATUS_WARNING_ALERT', 10); +// Wizard. +define('VISUAL_MAP_WIZARD_PARENTS_NONE', 0); +define('VISUAL_MAP_WIZARD_PARENTS_ITEM_MAP', 1); +define('VISUAL_MAP_WIZARD_PARENTS_AGENT_RELANTIONSHIP', 2); -/* Service constants */ -//Status -define('SERVICE_STATUS_UNKNOWN', -1); -define('SERVICE_STATUS_NORMAL', 0); -define('SERVICE_STATUS_CRITICAL', 1); -define('SERVICE_STATUS_WARNING', 2); -define('SERVICE_STATUS_ALERT', 4); -//Default weights -define('SERVICE_WEIGHT_CRITICAL', 1); -define('SERVICE_WEIGHT_WARNING', 0.5); -define('SERVICE_ELEMENT_WEIGHT_CRITICAL', 1); -define('SERVICE_ELEMENT_WEIGHT_WARNING', 0.5); -define('SERVICE_ELEMENT_WEIGHT_OK', 0); -define('SERVICE_ELEMENT_WEIGHT_UNKNOWN', 0); -//Modes -define('SERVICE_MODE_MANUAL', 0); -define('SERVICE_MODE_AUTO', 1); -define('SERVICE_MODE_SIMPLE', 2); - - -/* Status images */ -//For modules -define ('STATUS_MODULE_OK', 'module_ok.png'); -define ('STATUS_MODULE_CRITICAL', 'module_critical.png'); -define ('STATUS_MODULE_WARNING', 'module_warning.png'); -define ('STATUS_MODULE_NO_DATA', 'module_no_data.png'); -define ('STATUS_MODULE_UNKNOWN', 'module_unknown.png'); -//For agents -define ('STATUS_AGENT_CRITICAL', 'agent_critical.png'); -define ('STATUS_AGENT_WARNING', 'agent_warning.png'); -define ('STATUS_AGENT_DOWN', 'agent_down.png'); -define ('STATUS_AGENT_UNKNOWN', 'agent_unknown.png'); -define ('STATUS_AGENT_OK', 'agent_ok.png'); -define ('STATUS_AGENT_NO_DATA', 'agent_no_data.png'); -define ('STATUS_AGENT_NO_MONITORS', 'agent_no_monitors.png'); -define ('STATUS_AGENT_NOT_INIT', 'agent_notinit.png'); -//For alerts -define ('STATUS_ALERT_FIRED', 'alert_fired.png'); -define ('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png'); -define ('STATUS_ALERT_DISABLED', 'alert_disabled.png'); -//For servers -define ('STATUS_SERVER_OK', 'server_ok.png'); -define ('STATUS_SERVER_DOWN', 'server_down.png'); - - -/* Status images (ball) */ -//For modules -define ('STATUS_MODULE_OK_BALL', 'module_ok_ball.png'); -define ('STATUS_MODULE_CRITICAL_BALL', 'module_critical_ball.png'); -define ('STATUS_MODULE_WARNING_BALL', 'module_warning_ball.png'); -define ('STATUS_MODULE_NO_DATA_BALL', 'module_no_data_ball.png'); -define ('STATUS_MODULE_UNKNOWN_BALL', 'module_unknown_ball.png'); -//For agents -define ('STATUS_AGENT_CRITICAL_BALL', 'agent_critical_ball.png'); -define ('STATUS_AGENT_WARNING_BALL', 'agent_warning_ball.png'); -define ('STATUS_AGENT_DOWN_BALL', 'agent_down_ball.png'); -define ('STATUS_AGENT_UNKNOWN_BALL', 'agent_unknown_ball.png'); -define ('STATUS_AGENT_OK_BALL', 'agent_ok_ball.png'); -define ('STATUS_AGENT_NO_DATA_BALL', 'agent_no_data_ball.png'); -define ('STATUS_AGENT_NO_MONITORS_BALL', 'agent_no_monitors_ball.png'); -define ('STATUS_AGENT_NOT_INIT_BALL', 'agent_notinit_ball.png'); -//For alerts -define ('STATUS_ALERT_FIRED_BALL', 'alert_fired_ball.png'); -define ('STATUS_ALERT_NOT_FIRED_BALL', 'alert_not_fired_ball.png'); -define ('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png'); -//For servers -define ('STATUS_SERVER_OK_BALL', 'server_ok_ball.png'); -define ('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png'); +// Service constants. +// Status. +define('SERVICE_STATUS_UNKNOWN', -1); +define('SERVICE_STATUS_NORMAL', 0); +define('SERVICE_STATUS_CRITICAL', 1); +define('SERVICE_STATUS_WARNING', 2); +define('SERVICE_STATUS_ALERT', 4); +// Default weights. +define('SERVICE_WEIGHT_CRITICAL', 1); +define('SERVICE_WEIGHT_WARNING', 0.5); +define('SERVICE_ELEMENT_WEIGHT_CRITICAL', 1); +define('SERVICE_ELEMENT_WEIGHT_WARNING', 0.5); +define('SERVICE_ELEMENT_WEIGHT_OK', 0); +define('SERVICE_ELEMENT_WEIGHT_UNKNOWN', 0); +// Modes. +define('SERVICE_MODE_MANUAL', 0); +define('SERVICE_MODE_AUTO', 1); +define('SERVICE_MODE_SIMPLE', 2); -/* Events criticity */ -define ('EVENT_CRIT_MAINTENANCE', 0); -define ('EVENT_CRIT_INFORMATIONAL', 1); -define ('EVENT_CRIT_NORMAL', 2); -define ('EVENT_CRIT_MINOR', 5); -define ('EVENT_CRIT_WARNING', 3); -define ('EVENT_CRIT_MAJOR', 6); -define ('EVENT_CRIT_CRITICAL', 4); -define ('EVENT_CRIT_WARNING_OR_CRITICAL', 34); -define ('EVENT_CRIT_NOT_NORMAL', 20); -define ('EVENT_CRIT_OR_NORMAL', 21); +// Status images. +// For modules. +define('STATUS_MODULE_OK', 'module_ok.png'); +define('STATUS_MODULE_CRITICAL', 'module_critical.png'); +define('STATUS_MODULE_WARNING', 'module_warning.png'); +define('STATUS_MODULE_NO_DATA', 'module_no_data.png'); +define('STATUS_MODULE_UNKNOWN', 'module_unknown.png'); +// For agents. +define('STATUS_AGENT_CRITICAL', 'agent_critical.png'); +define('STATUS_AGENT_WARNING', 'agent_warning.png'); +define('STATUS_AGENT_DOWN', 'agent_down.png'); +define('STATUS_AGENT_UNKNOWN', 'agent_unknown.png'); +define('STATUS_AGENT_OK', 'agent_ok.png'); +define('STATUS_AGENT_NO_DATA', 'agent_no_data.png'); +define('STATUS_AGENT_NO_MONITORS', 'agent_no_monitors.png'); +define('STATUS_AGENT_NOT_INIT', 'agent_notinit.png'); +// For alerts. +define('STATUS_ALERT_FIRED', 'alert_fired.png'); +define('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png'); +define('STATUS_ALERT_DISABLED', 'alert_disabled.png'); +// For servers. +define('STATUS_SERVER_OK', 'server_ok.png'); +define('STATUS_SERVER_DOWN', 'server_down.png'); -/* Id Module (more use in component)*/ -define ('MODULE_DATA', 1); -define ('MODULE_NETWORK', 2); -define ('MODULE_SNMP', 2); -define ('MODULE_PLUGIN', 4); -define ('MODULE_PREDICTION', 5); -define ('MODULE_WMI', 6); -define ('MODULE_WEB', 7); -define ('MODULE_WUX', 8); -/* Type of Modules of Prediction */ -define ('MODULE_PREDICTION_SERVICE', 2); -define ('MODULE_PREDICTION_SYNTHETIC', 3); -define ('MODULE_PREDICTION_NETFLOW', 4); -define ('MODULE_PREDICTION_CLUSTER', 5); -define ('MODULE_PREDICTION_CLUSTER_AA', 6); -define ('MODULE_PREDICTION_CLUSTER_AP', 7); -/* SNMP CONSTANTS */ -define('SNMP_DIR_MIBS', "attachment/mibs"); +// Status images (ball). +// For modules. +define('STATUS_MODULE_OK_BALL', 'module_ok_ball.png'); +define('STATUS_MODULE_CRITICAL_BALL', 'module_critical_ball.png'); +define('STATUS_MODULE_WARNING_BALL', 'module_warning_ball.png'); +define('STATUS_MODULE_NO_DATA_BALL', 'module_no_data_ball.png'); +define('STATUS_MODULE_UNKNOWN_BALL', 'module_unknown_ball.png'); +// For agents. +define('STATUS_AGENT_CRITICAL_BALL', 'agent_critical_ball.png'); +define('STATUS_AGENT_WARNING_BALL', 'agent_warning_ball.png'); +define('STATUS_AGENT_DOWN_BALL', 'agent_down_ball.png'); +define('STATUS_AGENT_UNKNOWN_BALL', 'agent_unknown_ball.png'); +define('STATUS_AGENT_OK_BALL', 'agent_ok_ball.png'); +define('STATUS_AGENT_NO_DATA_BALL', 'agent_no_data_ball.png'); +define('STATUS_AGENT_NO_MONITORS_BALL', 'agent_no_monitors_ball.png'); +define('STATUS_AGENT_NOT_INIT_BALL', 'agent_notinit_ball.png'); +// For alerts. +define('STATUS_ALERT_FIRED_BALL', 'alert_fired_ball.png'); +define('STATUS_ALERT_NOT_FIRED_BALL', 'alert_not_fired_ball.png'); +define('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png'); +// For servers. +define('STATUS_SERVER_OK_BALL', 'server_ok_ball.png'); +define('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png'); -define('SNMP_TRAP_TYPE_NONE', -1); -define('SNMP_TRAP_TYPE_COLD_START', 0); -define('SNMP_TRAP_TYPE_WARM_START', 1); -define('SNMP_TRAP_TYPE_LINK_DOWN', 2); -define('SNMP_TRAP_TYPE_LINK_UP', 3); -define('SNMP_TRAP_TYPE_AUTHENTICATION_FAILURE', 4); -define('SNMP_TRAP_TYPE_OTHER', 5); -/* PASSWORD POLICIES */ -define('PASSSWORD_POLICIES_OK', 0); -define('PASSSWORD_POLICIES_FIRST_CHANGE', 1); -define('PASSSWORD_POLICIES_EXPIRED', 2); -/* SERVER TYPES */ -define('SERVER_TYPE_DATA', 0); -define('SERVER_TYPE_NETWORK', 1); -define('SERVER_TYPE_SNMP', 2); -define('SERVER_TYPE_RECON', 3); -define('SERVER_TYPE_PLUGIN', 4); -define('SERVER_TYPE_PREDICTION', 5); -define('SERVER_TYPE_WMI', 6); -define('SERVER_TYPE_EXPORT', 7); -define('SERVER_TYPE_INVENTORY', 8); -define('SERVER_TYPE_WEB', 9); -define('SERVER_TYPE_EVENT', 10); -define('SERVER_TYPE_ENTERPRISE_ICMP', 11); -define('SERVER_TYPE_ENTERPRISE_SNMP', 12); -define('SERVER_TYPE_ENTERPRISE_SATELLITE', 13); -define('SERVER_TYPE_ENTERPRISE_TRANSACTIONAL', 14); -define('SERVER_TYPE_MAINFRAME', 15); -define('SERVER_TYPE_SYNC', 16); -define('SERVER_TYPE_WUX', 17); -define('SERVER_TYPE_SYSLOG', 18); -define('SERVER_TYPE_AUTOPROVISION', 19); -define('SERVER_TYPE_MIGRATION', 20); +// Events criticity. +define('EVENT_CRIT_MAINTENANCE', 0); +define('EVENT_CRIT_INFORMATIONAL', 1); +define('EVENT_CRIT_NORMAL', 2); +define('EVENT_CRIT_MINOR', 5); +define('EVENT_CRIT_WARNING', 3); +define('EVENT_CRIT_MAJOR', 6); +define('EVENT_CRIT_CRITICAL', 4); +define('EVENT_CRIT_WARNING_OR_CRITICAL', 34); +define('EVENT_CRIT_NOT_NORMAL', 20); +define('EVENT_CRIT_OR_NORMAL', 21); -/* REPORTS */ -define('REPORT_TOP_N_MAX', 1); -define('REPORT_TOP_N_MIN', 2); -define('REPORT_TOP_N_AVG', 0); +// Id Module (more use in component). +define('MODULE_DATA', 1); +define('MODULE_NETWORK', 2); +define('MODULE_SNMP', 2); +define('MODULE_PLUGIN', 4); +define('MODULE_PREDICTION', 5); +define('MODULE_WMI', 6); +define('MODULE_WEB', 7); +define('MODULE_WUX', 8); -define('REPORT_TOP_N_ONLY_GRAPHS', 2); -define('REPORT_TOP_N_SHOW_TABLE_GRAPS', 1); -define('REPORT_TOP_N_ONLY_TABLE', 0); +// Type of Modules of Prediction. +define('MODULE_PREDICTION_SERVICE', 2); +define('MODULE_PREDICTION_SYNTHETIC', 3); +define('MODULE_PREDICTION_NETFLOW', 4); +define('MODULE_PREDICTION_CLUSTER', 5); +define('MODULE_PREDICTION_CLUSTER_AA', 6); +define('MODULE_PREDICTION_CLUSTER_AP', 7); -define('REPORT_EXCEPTION_CONDITION_EVERYTHING', 0); -define('REPORT_EXCEPTION_CONDITION_GE', 1); -define('REPORT_EXCEPTION_CONDITION_LE', 5); -define('REPORT_EXCEPTION_CONDITION_L', 2); -define('REPORT_EXCEPTION_CONDITION_G', 6); -define('REPORT_EXCEPTION_CONDITION_E', 7); -define('REPORT_EXCEPTION_CONDITION_NE', 8); -define('REPORT_EXCEPTION_CONDITION_OK', 3); -define('REPORT_EXCEPTION_CONDITION_NOT_OK', 4); +// SNMP CONSTANTS. +define('SNMP_DIR_MIBS', 'attachment/mibs'); -define('REPORT_ITEM_ORDER_BY_AGENT_NAME', 3); -define('REPORT_ITEM_ORDER_BY_ASCENDING', 2); -define('REPORT_ITEM_ORDER_BY_DESCENDING', 1); -define('REPORT_ITEM_ORDER_BY_UNSORT', 0); +define('SNMP_TRAP_TYPE_NONE', -1); +define('SNMP_TRAP_TYPE_COLD_START', 0); +define('SNMP_TRAP_TYPE_WARM_START', 1); +define('SNMP_TRAP_TYPE_LINK_DOWN', 2); +define('SNMP_TRAP_TYPE_LINK_UP', 3); +define('SNMP_TRAP_TYPE_AUTHENTICATION_FAILURE', 4); +define('SNMP_TRAP_TYPE_OTHER', 5); -define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1); -define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2); -define('REPORT_OLD_TYPE_SLA', 3); -define('REPORT_OLD_TYPE_MONITOR_REPORT', 6); -define('REPORT_OLD_TYPE_AVG_VALUE', 7); -define('REPORT_OLD_TYPE_MAX_VALUE', 8); -define('REPORT_OLD_TYPE_MIN_VALUE', 9); -define('REPORT_OLD_TYPE_SUMATORY', 10); +// PASSWORD POLICIES. +define('PASSSWORD_POLICIES_OK', 0); +define('PASSSWORD_POLICIES_FIRST_CHANGE', 1); +define('PASSSWORD_POLICIES_EXPIRED', 2); -define('REPORT_GENERAL_NOT_GROUP_BY_AGENT', 0); -define('REPORT_GENERAL_GROUP_BY_AGENT', 1); +// SERVER TYPES. +define('SERVER_TYPE_DATA', 0); +define('SERVER_TYPE_NETWORK', 1); +define('SERVER_TYPE_SNMP', 2); +define('SERVER_TYPE_RECON', 3); +define('SERVER_TYPE_PLUGIN', 4); +define('SERVER_TYPE_PREDICTION', 5); +define('SERVER_TYPE_WMI', 6); +define('SERVER_TYPE_EXPORT', 7); +define('SERVER_TYPE_INVENTORY', 8); +define('SERVER_TYPE_WEB', 9); +define('SERVER_TYPE_EVENT', 10); +define('SERVER_TYPE_ENTERPRISE_ICMP', 11); +define('SERVER_TYPE_ENTERPRISE_SNMP', 12); +define('SERVER_TYPE_ENTERPRISE_SATELLITE', 13); +define('SERVER_TYPE_ENTERPRISE_TRANSACTIONAL', 14); +define('SERVER_TYPE_MAINFRAME', 15); +define('SERVER_TYPE_SYNC', 16); +define('SERVER_TYPE_WUX', 17); +define('SERVER_TYPE_SYSLOG', 18); +define('SERVER_TYPE_AUTOPROVISION', 19); +define('SERVER_TYPE_MIGRATION', 20); -define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15); +// REPORTS. +define('REPORT_TOP_N_MAX', 1); +define('REPORT_TOP_N_MIN', 2); +define('REPORT_TOP_N_AVG', 0); -/* POLICIES */ +define('REPORT_TOP_N_ONLY_GRAPHS', 2); +define('REPORT_TOP_N_SHOW_TABLE_GRAPS', 1); +define('REPORT_TOP_N_ONLY_TABLE', 0); -define("POLICY_UPDATED", 0); -define("POLICY_PENDING_DATABASE", 1); -define("POLICY_PENDING_ALL", 2); +define('REPORT_EXCEPTION_CONDITION_EVERYTHING', 0); +define('REPORT_EXCEPTION_CONDITION_GE', 1); +define('REPORT_EXCEPTION_CONDITION_LE', 5); +define('REPORT_EXCEPTION_CONDITION_L', 2); +define('REPORT_EXCEPTION_CONDITION_G', 6); +define('REPORT_EXCEPTION_CONDITION_E', 7); +define('REPORT_EXCEPTION_CONDITION_NE', 8); +define('REPORT_EXCEPTION_CONDITION_OK', 3); +define('REPORT_EXCEPTION_CONDITION_NOT_OK', 4); -define("STATUS_IN_QUEUE_OUT", 0); -define("STATUS_IN_QUEUE_IN", 1); -define("STATUS_IN_QUEUE_APPLYING", 2); +define('REPORT_ITEM_ORDER_BY_AGENT_NAME', 3); +define('REPORT_ITEM_ORDER_BY_ASCENDING', 2); +define('REPORT_ITEM_ORDER_BY_DESCENDING', 1); +define('REPORT_ITEM_ORDER_BY_UNSORT', 0); -define("MODULE_UNLINKED", 0); -define("MODULE_LINKED", 1); -define("MODULE_PENDING_UNLINK", 10); -define("MODULE_PENDING_LINK", 11); +define('REPORT_OLD_TYPE_SIMPLE_GRAPH', 1); +define('REPORT_OLD_TYPE_CUSTOM_GRAPH', 2); +define('REPORT_OLD_TYPE_SLA', 3); +define('REPORT_OLD_TYPE_MONITOR_REPORT', 6); +define('REPORT_OLD_TYPE_AVG_VALUE', 7); +define('REPORT_OLD_TYPE_MAX_VALUE', 8); +define('REPORT_OLD_TYPE_MIN_VALUE', 9); +define('REPORT_OLD_TYPE_SUMATORY', 10); -/* EVENTS */ -define("EVENTS_GOING_UNKNOWN" , 'going_unknown'); -define("EVENTS_UNKNOWN", 'unknown'); -define("EVENTS_ALERT_FIRED", 'alert_fired'); -define("EVENTS_ALERT_RECOVERED", 'alert_recovered'); -define("EVENTS_ALERT_CEASED", 'alert_ceased'); -define("EVENTS_ALERT_MANUAL_VALIDATION", 'alert_manual_validation'); -define("EVENTS_RECON_HOST_DETECTED", 'recon_host_detected'); -define("EVENTS_SYSTEM", 'system'); -define("EVENTS_ERROR", 'error'); -define("EVENTS_NEW_AGENT", 'new_agent'); -define("EVENTS_GOING_UP_WARNING", 'going_up_warning'); -define("EVENTS_GOING_UP_CRITICAL", 'going_up_critical'); -define("EVENTS_GOING_DOWN_WARNING", 'going_down_warning'); -define("EVENTS_GOING_DOWN_NORMAL", 'going_down_normal'); -define("EVENTS_GOING_DOWN_CRITICAL", 'going_down_critical'); -define("EVENTS_GOING_UP_NORMAL", 'going_up_normal'); -define("EVENTS_CONFIGURATION_CHANGE", 'configuration_change'); +define('REPORT_GENERAL_NOT_GROUP_BY_AGENT', 0); +define('REPORT_GENERAL_GROUP_BY_AGENT', 1); -/* CUSTOM GRAPHS */ -define("CUSTOM_GRAPH_AREA", 0); -define("CUSTOM_GRAPH_STACKED_AREA", 1); -define("CUSTOM_GRAPH_LINE", 2); -define("CUSTOM_GRAPH_STACKED_LINE", 3); -define("CUSTOM_GRAPH_BULLET_CHART", 4); -define("CUSTOM_GRAPH_GAUGE", 5); -define("CUSTOM_GRAPH_HBARS", 6); -define("CUSTOM_GRAPH_VBARS", 7); -define("CUSTOM_GRAPH_PIE", 8); -define("CUSTOM_GRAPH_BULLET_CHART_THRESHOLD", 9); +define('REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE', 15); -/* COLLECTIONS */ -define("COLLECTION_PENDING_APPLY", 0); -define("COLLECTION_CORRECT", 1); -define("COLLECTION_ERROR_LOST_DIRECTORY", 2); -define("COLLECTION_UNSAVED", 3); +// POLICIES. +define('POLICY_UPDATED', 0); +define('POLICY_PENDING_DATABASE', 1); +define('POLICY_PENDING_ALL', 2); -/* PAGINATION */ -define("PAGINATION_BLOCKS_LIMIT", 15); +define('STATUS_IN_QUEUE_OUT', 0); +define('STATUS_IN_QUEUE_IN', 1); +define('STATUS_IN_QUEUE_APPLYING', 2); -/* CHARTS */ -define("CHART_DEFAULT_WIDTH", 150); -define("CHART_DEFAULT_HEIGHT", 110); +define('MODULE_UNLINKED', 0); +define('MODULE_LINKED', 1); +define('MODULE_PENDING_UNLINK', 10); +define('MODULE_PENDING_LINK', 11); -define("CHART_DEFAULT_ALPHA", 50); +// EVENTS. +define('EVENTS_GOING_UNKNOWN', 'going_unknown'); +define('EVENTS_UNKNOWN', 'unknown'); +define('EVENTS_ALERT_FIRED', 'alert_fired'); +define('EVENTS_ALERT_RECOVERED', 'alert_recovered'); +define('EVENTS_ALERT_CEASED', 'alert_ceased'); +define('EVENTS_ALERT_MANUAL_VALIDATION', 'alert_manual_validation'); +define('EVENTS_RECON_HOST_DETECTED', 'recon_host_detected'); +define('EVENTS_SYSTEM', 'system'); +define('EVENTS_ERROR', 'error'); +define('EVENTS_NEW_AGENT', 'new_agent'); +define('EVENTS_GOING_UP_WARNING', 'going_up_warning'); +define('EVENTS_GOING_UP_CRITICAL', 'going_up_critical'); +define('EVENTS_GOING_DOWN_WARNING', 'going_down_warning'); +define('EVENTS_GOING_DOWN_NORMAL', 'going_down_normal'); +define('EVENTS_GOING_DOWN_CRITICAL', 'going_down_critical'); +define('EVENTS_GOING_UP_NORMAL', 'going_up_normal'); +define('EVENTS_CONFIGURATION_CHANGE', 'configuration_change'); -/* Statwin */ -define("STATWIN_DEFAULT_CHART_WIDTH", 555); -define("STATWIN_DEFAULT_CHART_HEIGHT", 245); +// CUSTOM GRAPHS. +define('CUSTOM_GRAPH_AREA', 0); +define('CUSTOM_GRAPH_STACKED_AREA', 1); +define('CUSTOM_GRAPH_LINE', 2); +define('CUSTOM_GRAPH_STACKED_LINE', 3); +define('CUSTOM_GRAPH_BULLET_CHART', 4); +define('CUSTOM_GRAPH_GAUGE', 5); +define('CUSTOM_GRAPH_HBARS', 6); +define('CUSTOM_GRAPH_VBARS', 7); +define('CUSTOM_GRAPH_PIE', 8); +define('CUSTOM_GRAPH_BULLET_CHART_THRESHOLD', 9); -/* Dashboard */ -define("DASHBOARD_DEFAULT_COUNT_CELLS", 1); +// COLLECTIONS. +define('COLLECTION_PENDING_APPLY', 0); +define('COLLECTION_CORRECT', 1); +define('COLLECTION_ERROR_LOST_DIRECTORY', 2); +define('COLLECTION_UNSAVED', 3); -define("OPTION_TEXT", 1); -define("OPTION_SINGLE_SELECT", 2); -define("OPTION_MULTIPLE_SELECT", 3); -define("OPTION_BOOLEAN", 4); -define("OPTION_TEXTAREA", 5); -define("OPTION_TREE_GROUP_SELECT", 6); -define("OPTION_SINGLE_SELECT_TIME", 7); -define("OPTION_CUSTOM_INPUT", 8); -define("OPTION_AGENT_AUTOCOMPLETE", 9); -define("OPTION_SELECT_MULTISELECTION", 10); -define("OPTION_COLOR_PICKER", 11); +// PAGINATION. +define('PAGINATION_BLOCKS_LIMIT', 15); -/* Transactional map constants */ -define("NODE_TYPE", 0); -define("ARROW_TYPE", 1); +// CHARTS. +define('CHART_DEFAULT_WIDTH', 150); +define('CHART_DEFAULT_HEIGHT', 110); -/* SAML attributes constants */ -define("SAML_ROLE_AND_TAG", "eduPersonEntitlement"); -define("SAML_USER_DESC", "commonName"); -define("SAML_ID_USER_IN_PANDORA", "eduPersonTargetedId"); -define("SAML_GROUP_IN_PANDORA", "schacHomeOrganization"); -define("SAML_MAIL_IN_PANDORA", "mail"); -define("SAML_DEFAULT_PROFILES_AND_TAGS_FORM", "urn:mace:rediris.es:entitlement:monitoring:"); +define('CHART_DEFAULT_ALPHA', 50); -/* Other constants */ -define("STATUS_OK", 0); -define("STATUS_ERROR", 1); +// Statwin. +define('STATWIN_DEFAULT_CHART_WIDTH', 555); +define('STATWIN_DEFAULT_CHART_HEIGHT', 245); -/* Maps (new networkmaps and new visualmaps) */ -define("MAP_TYPE_NETWORKMAP", 0); -define("MAP_TYPE_VISUALMAP", 1); +// Dashboard. +define('DASHBOARD_DEFAULT_COUNT_CELLS', 1); -define("MAP_REFRESH_TIME", SECONDS_5MINUTES); +define('OPTION_TEXT', 1); +define('OPTION_SINGLE_SELECT', 2); +define('OPTION_MULTIPLE_SELECT', 3); +define('OPTION_BOOLEAN', 4); +define('OPTION_TEXTAREA', 5); +define('OPTION_TREE_GROUP_SELECT', 6); +define('OPTION_SINGLE_SELECT_TIME', 7); +define('OPTION_CUSTOM_INPUT', 8); +define('OPTION_AGENT_AUTOCOMPLETE', 9); +define('OPTION_SELECT_MULTISELECTION', 10); +define('OPTION_COLOR_PICKER', 11); -define("MAP_SUBTYPE_TOPOLOGY", 0); -define("MAP_SUBTYPE_POLICIES", 1); -define("MAP_SUBTYPE_GROUPS", 2); -define("MAP_SUBTYPE_RADIAL_DYNAMIC", 3); +// Transactional map constants. +define('NODE_TYPE', 0); +define('ARROW_TYPE', 1); -define("MAP_GENERATION_CIRCULAR", 0); -define("MAP_GENERATION_PLANO", 1); -define("MAP_GENERATION_RADIAL", 2); -define("MAP_GENERATION_SPRING1", 3); -define("MAP_GENERATION_SPRING2", 4); +// SAML attributes constants. +define('SAML_ROLE_AND_TAG', 'eduPersonEntitlement'); +define('SAML_USER_DESC', 'commonName'); +define('SAML_ID_USER_IN_PANDORA', 'eduPersonTargetedId'); +define('SAML_GROUP_IN_PANDORA', 'schacHomeOrganization'); +define('SAML_MAIL_IN_PANDORA', 'mail'); +define('SAML_DEFAULT_PROFILES_AND_TAGS_FORM', 'urn:mace:rediris.es:entitlement:monitoring:'); -define("MAP_SOURCE_GROUP", 0); -define("MAP_SOURCE_IP_MASK", 1); +// Other constants. +define('STATUS_OK', 0); +define('STATUS_ERROR', 1); -define("NETWORKMAP_DEFAULT_WIDTH", 800); -define("NETWORKMAP_DEFAULT_HEIGHT", 800); +// Maps (new networkmaps and new visualmaps). +define('MAP_TYPE_NETWORKMAP', 0); +define('MAP_TYPE_VISUALMAP', 1); -/* Background options */ -define("CENTER", 0); -define("MOSAIC", 1); -define("STRECH", 2); -define("FIT_WIDTH", 3); -define("FIT_HEIGH", 4); +define('MAP_REFRESH_TIME', SECONDS_5MINUTES); -/* Items of maps */ -define("ITEM_TYPE_AGENT_NETWORKMAP", 0); -define("ITEM_TYPE_MODULE_NETWORKMAP", 1); -define("ITEM_TYPE_EDGE_NETWORKMAP", 2); -define("ITEM_TYPE_FICTIONAL_NODE", 3); -define("ITEM_TYPE_MODULEGROUP_NETWORKMAP", 4); -define("ITEM_TYPE_GROUP_NETWORKMAP", 5); -define("ITEM_TYPE_POLICY_NETWORKMAP", 6); +define('MAP_SUBTYPE_TOPOLOGY', 0); +define('MAP_SUBTYPE_POLICIES', 1); +define('MAP_SUBTYPE_GROUPS', 2); +define('MAP_SUBTYPE_RADIAL_DYNAMIC', 3); -/* Another constants new networkmap */ -define("DEFAULT_NODE_WIDTH", 30); -define("DEFAULT_NODE_HEIGHT", 30); -define("DEFAULT_NODE_SHAPE", "circle"); -define("DEFAULT_NODE_COLOR", COL_NOTINIT); -define("DEFAULT_NODE_IMAGE", "images/networkmap/unknown.png"); +define('MAP_GENERATION_CIRCULAR', 0); +define('MAP_GENERATION_PLANO', 1); +define('MAP_GENERATION_RADIAL', 2); +define('MAP_GENERATION_SPRING1', 3); +define('MAP_GENERATION_SPRING2', 4); -define("NODE_IMAGE_PADDING", 5); -?> +define('MAP_SOURCE_GROUP', 0); +define('MAP_SOURCE_IP_MASK', 1); + +define('NETWORKMAP_DEFAULT_WIDTH', 800); +define('NETWORKMAP_DEFAULT_HEIGHT', 800); + +// Background options. +define('CENTER', 0); +define('MOSAIC', 1); +define('STRECH', 2); +define('FIT_WIDTH', 3); +define('FIT_HEIGH', 4); + +// Items of maps. +define('ITEM_TYPE_AGENT_NETWORKMAP', 0); +define('ITEM_TYPE_MODULE_NETWORKMAP', 1); +define('ITEM_TYPE_EDGE_NETWORKMAP', 2); +define('ITEM_TYPE_FICTIONAL_NODE', 3); +define('ITEM_TYPE_MODULEGROUP_NETWORKMAP', 4); +define('ITEM_TYPE_GROUP_NETWORKMAP', 5); +define('ITEM_TYPE_POLICY_NETWORKMAP', 6); + +// Another constants new networkmap. +define('DEFAULT_NODE_WIDTH', 30); +define('DEFAULT_NODE_HEIGHT', 30); +define('DEFAULT_NODE_SHAPE', 'circle'); +define('DEFAULT_NODE_COLOR', COL_NOTINIT); +define('DEFAULT_NODE_IMAGE', 'images/networkmap/unknown.png'); + +define('NODE_IMAGE_PADDING', 5); From c15357dc03d235e0e0225b7527784831529b1ef7 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 4 Feb 2019 19:16:30 +0100 Subject: [PATCH 019/262] Servers get server string name Former-commit-id: 6988fc5972c72c23131704e9dcb45328755b0ee8 --- pandora_console/include/functions_servers.php | 1425 +++++++++-------- 1 file changed, 788 insertions(+), 637 deletions(-) diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 6bd255e88d..856864b4a3 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -1,24 +1,32 @@ <?php - -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation; version 2 - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - /** - * @package Include - * @subpackage Servers + * Auxiliary functions to manage servers. + * + * @category Library + * @package Pandora FMS + * @subpackage Opensource + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ */ + /** * Get a server. * @@ -28,62 +36,78 @@ * * @return Server with the given id. False if not available. */ -function servers_get_server ($id_server, $filter = false, $fields = false) { - if (empty ($id_server)) - return false; - if (! is_array ($filter)) - $filter = array (); - $filter['id_server'] = $id_server; - - return @db_get_row_filter ('tserver', $filter, $fields); +function servers_get_server($id_server, $filter=false, $fields=false) +{ + if (empty($id_server)) { + return false; + } + + if (! is_array($filter)) { + $filter = []; + } + + $filter['id_server'] = $id_server; + + return @db_get_row_filter('tserver', $filter, $fields); } + /** * Get all the server availables. * * @return All the servers available. */ -function servers_get_names () { - $all_servers = @db_get_all_rows_filter ('tserver', false, array ('DISTINCT(name) as name')); - if ($all_servers === false) - return array (); - - $servers = array (); - foreach ($all_servers as $server) { - $servers[$server['name']] = $server['name']; - } - return $servers; +function servers_get_names() +{ + $all_servers = @db_get_all_rows_filter('tserver', false, ['DISTINCT(name) as name']); + if ($all_servers === false) { + return []; + } + + $servers = []; + foreach ($all_servers as $server) { + $servers[$server['name']] = $server['name']; + } + + return $servers; } + /** * This function forces a recon task to be queued by the server asap */ -function servers_force_recon_task($id_recon_task) { - $values = array('utimestamp' => 0, 'status' => 1); - db_process_sql_update('trecon_task', $values, array('id_rt' => $id_recon_task)); +function servers_force_recon_task($id_recon_task) +{ + $values = [ + 'utimestamp' => 0, + 'status' => 1, + ]; + db_process_sql_update('trecon_task', $values, ['id_rt' => $id_recon_task]); } + /** * This function will get several metrics from the database to get info about server performance - * @return array with several data + * + * @return array with several data */ -function servers_get_performance () { - - global $config; - - $data = array(); - $data["total_modules"] = 0; - $data["total_remote_modules"] = 0; - $data["total_local_modules"] = 0; - $data["avg_interval_total_modules"] = array(); - $data["avg_interval_remote_modules"] = array(); - $data["avg_interval_local_modules"] = 0; - $data["local_modules_rate"] = 0; - $data["network_modules_rate"] = 0; - - if ($config["realtimestats"] == 1) { - - $counts = db_get_all_rows_sql (" +function servers_get_performance() +{ + global $config; + + $data = []; + $data['total_modules'] = 0; + $data['total_remote_modules'] = 0; + $data['total_local_modules'] = 0; + $data['avg_interval_total_modules'] = []; + $data['avg_interval_remote_modules'] = []; + $data['avg_interval_local_modules'] = 0; + $data['local_modules_rate'] = 0; + $data['network_modules_rate'] = 0; + + if ($config['realtimestats'] == 1) { + $counts = db_get_all_rows_sql( + ' SELECT tagente_modulo.id_modulo, COUNT(tagente_modulo.id_agente_modulo) modules FROM tagente_modulo, tagente_estado, tagente @@ -95,94 +119,108 @@ function servers_get_performance () { AND (utimestamp > 0 OR (id_tipo_modulo = 100 OR (id_tipo_modulo > 21 AND id_tipo_modulo < 23))) AND tagente.disabled = 0 - GROUP BY tagente_modulo.id_modulo"); - - if (empty($counts)) { - $counts = array(); - } - - foreach($counts as $c) { - switch($c['id_modulo']) { - case MODULE_DATA: - $data["total_local_modules"] = $c['modules']; - break; - case MODULE_NETWORK: - $data["total_network_modules"] = $c['modules']; - break; - case MODULE_PLUGIN: - $data["total_plugin_modules"] = $c['modules']; - break; - case MODULE_PREDICTION: - $data["total_prediction_modules"] = $c['modules']; - break; - case MODULE_WMI: - $data["total_wmi_modules"] = $c['modules']; - break; - case MODULE_WEB: - $data["total_web_modules"] = $c['modules']; - break; - } - - if($c['id_modulo'] != MODULE_DATA) { - $data["total_remote_modules"] += $c['modules']; - } - - $data["total_modules"] += $c['modules']; - } - } - else { - $counts = db_get_all_rows_sql (" + GROUP BY tagente_modulo.id_modulo' + ); + + if (empty($counts)) { + $counts = []; + } + + foreach ($counts as $c) { + switch ($c['id_modulo']) { + case MODULE_DATA: + $data['total_local_modules'] = $c['modules']; + break; + + case MODULE_NETWORK: + $data['total_network_modules'] = $c['modules']; + break; + + case MODULE_PLUGIN: + $data['total_plugin_modules'] = $c['modules']; + break; + + case MODULE_PREDICTION: + $data['total_prediction_modules'] = $c['modules']; + break; + + case MODULE_WMI: + $data['total_wmi_modules'] = $c['modules']; + break; + + case MODULE_WEB: + $data['total_web_modules'] = $c['modules']; + break; + } + + if ($c['id_modulo'] != MODULE_DATA) { + $data['total_remote_modules'] += $c['modules']; + } + + $data['total_modules'] += $c['modules']; + } + } else { + $counts = db_get_all_rows_sql( + ' SELECT server_type, my_modules modules FROM tserver - GROUP BY server_type"); - - if (empty($counts)) { - $counts = array(); - } - - foreach ($counts as $c) { - switch ($c['server_type']) { - case SERVER_TYPE_DATA: - $data["total_local_modules"] = $c['modules']; - break; - case SERVER_TYPE_NETWORK: - case SERVER_TYPE_SNMP: - case SERVER_TYPE_ENTERPRISE_ICMP: - case SERVER_TYPE_ENTERPRISE_SNMP: - $data["total_network_modules"] = $c['modules']; - break; - case SERVER_TYPE_PLUGIN: - $data["total_plugin_modules"] = $c['modules']; - break; - case SERVER_TYPE_PREDICTION: - $data["total_prediction_modules"] = $c['modules']; - break; - case SERVER_TYPE_WMI: - $data["total_wmi_modules"] = $c['modules']; - break; - case SERVER_TYPE_WEB: - $data["total_web_modules"] = $c['modules']; - break; - case SERVER_TYPE_EXPORT: - case SERVER_TYPE_INVENTORY: - case SERVER_TYPE_EVENT: - case SERVER_TYPE_RECON: - case SERVER_TYPE_SYSLOG: - break; - } - - if ($c['server_type'] != SERVER_TYPE_DATA) { - $data["total_remote_modules"] += $c['modules']; - } - - $data["total_modules"] += $c['modules']; - } - } - - $interval_avgs = array(); - - // Avg of modules interval when modules have module_interval > 0 - $interval_avgs_modules = db_get_all_rows_sql (" + GROUP BY server_type' + ); + + if (empty($counts)) { + $counts = []; + } + + foreach ($counts as $c) { + switch ($c['server_type']) { + case SERVER_TYPE_DATA: + $data['total_local_modules'] = $c['modules']; + break; + + case SERVER_TYPE_NETWORK: + case SERVER_TYPE_SNMP: + case SERVER_TYPE_ENTERPRISE_ICMP: + case SERVER_TYPE_ENTERPRISE_SNMP: + $data['total_network_modules'] = $c['modules']; + break; + + case SERVER_TYPE_PLUGIN: + $data['total_plugin_modules'] = $c['modules']; + break; + + case SERVER_TYPE_PREDICTION: + $data['total_prediction_modules'] = $c['modules']; + break; + + case SERVER_TYPE_WMI: + $data['total_wmi_modules'] = $c['modules']; + break; + + case SERVER_TYPE_WEB: + $data['total_web_modules'] = $c['modules']; + break; + + case SERVER_TYPE_EXPORT: + case SERVER_TYPE_INVENTORY: + case SERVER_TYPE_EVENT: + case SERVER_TYPE_RECON: + case SERVER_TYPE_SYSLOG: + break; + } + + if ($c['server_type'] != SERVER_TYPE_DATA) { + $data['total_remote_modules'] += $c['modules']; + } + + $data['total_modules'] += $c['modules']; + } + } + + $interval_avgs = []; + + // Avg of modules interval when modules have module_interval > 0 + $interval_avgs_modules = db_get_all_rows_sql( + ' SELECT count(tagente_modulo.id_modulo) modules , tagente_modulo.id_modulo, AVG(tagente_modulo.module_interval) avg_interval @@ -194,20 +232,22 @@ function servers_get_performance () { AND delete_pending = 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente - GROUP BY tagente_modulo.id_modulo"); - - if (empty($interval_avgs_modules)) { - $interval_avgs_modules = array(); - } - - // Transform into a easily format - foreach ($interval_avgs_modules as $iamodules) { - $interval_avgs[$iamodules['id_modulo']]['avg_interval'] = $iamodules['avg_interval']; - $interval_avgs[$iamodules['id_modulo']]['modules'] = $iamodules['modules']; - } - - // Avg of agents interval when modules have module_interval == 0 - $interval_avgs_agents = db_get_all_rows_sql (" + GROUP BY tagente_modulo.id_modulo' + ); + + if (empty($interval_avgs_modules)) { + $interval_avgs_modules = []; + } + + // Transform into a easily format + foreach ($interval_avgs_modules as $iamodules) { + $interval_avgs[$iamodules['id_modulo']]['avg_interval'] = $iamodules['avg_interval']; + $interval_avgs[$iamodules['id_modulo']]['modules'] = $iamodules['modules']; + } + + // Avg of agents interval when modules have module_interval == 0 + $interval_avgs_agents = db_get_all_rows_sql( + ' SELECT count(tagente_modulo.id_modulo) modules , tagente_modulo.id_modulo, AVG(tagente.intervalo) avg_interval FROM tagente_modulo, tagente_estado, tagente @@ -218,82 +258,86 @@ function servers_get_performance () { AND delete_pending = 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente - GROUP BY tagente_modulo.id_modulo"); - - if (empty($interval_avgs_agents)) { - $interval_avgs_agents = array(); - } - - // Merge with the previous calculated array - foreach ($interval_avgs_agents as $iaagents) { - if (!isset($interval_avgs[$iaagents['id_modulo']]['modules'])) { - $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = $iaagents['avg_interval']; - $interval_avgs[$iaagents['id_modulo']]['modules'] = $iaagents['modules']; - } - else { - $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = servers_get_avg_interval($interval_avgs[$iaagents['id_modulo']], $iaagents); - $interval_avgs[$iaagents['id_modulo']]['modules'] += $iaagents['modules']; - } - } - - foreach ($interval_avgs as $id_modulo => $ia) { - switch($id_modulo) { - case MODULE_DATA: - $data["avg_interval_local_modules"] = $ia['avg_interval']; - $data["local_modules_rate"] = - servers_get_rate($data["avg_interval_local_modules"], $data["total_local_modules"]); - break; - case MODULE_NETWORK: - $data["avg_interval_network_modules"] = $ia['avg_interval']; - $data["network_modules_rate"] = - servers_get_rate($data["avg_interval_network_modules"], - $data["total_network_modules"]); - break; - case MODULE_PLUGIN: - $data["avg_interval_plugin_modules"] = $ia['avg_interval']; - $data["plugin_modules_rate"] = servers_get_rate($data["avg_interval_plugin_modules"], $data["total_plugin_modules"]); - break; - case MODULE_PREDICTION: - $data["avg_interval_prediction_modules"] = $ia['avg_interval']; - $data["prediction_modules_rate"] = servers_get_rate($data["avg_interval_prediction_modules"], $data["total_prediction_modules"]); - break; - case MODULE_WMI: - $data["avg_interval_wmi_modules"] = $ia['avg_interval']; - $data["wmi_modules_rate"] = servers_get_rate($data["avg_interval_wmi_modules"], $data["total_wmi_modules"]); - break; - case MODULE_WEB: - $data["avg_interval_web_modules"] = $ia['avg_interval']; - $data["web_modules_rate"] = servers_get_rate($data["avg_interval_web_modules"], $data["total_web_modules"]); - break; - } - - if ($id_modulo != MODULE_DATA) { - $data["avg_interval_remote_modules"][] = $ia['avg_interval']; - } - - $data["avg_interval_total_modules"][] = $ia['avg_interval']; - } - - if (empty($data["avg_interval_remote_modules"])) { - $data["avg_interval_remote_modules"] = 0; - } - else { - $data["avg_interval_remote_modules"] = array_sum($data["avg_interval_remote_modules"]) / count($data["avg_interval_remote_modules"]); - } - - if (empty($data["avg_interval_total_modules"])) { - $data["avg_interval_total_modules"] = 0; - } - else { - $data["avg_interval_total_modules"] = array_sum($data["avg_interval_total_modules"]) / count($data["avg_interval_total_modules"]); - } - - $data["remote_modules_rate"] = servers_get_rate($data["avg_interval_remote_modules"], $data["total_remote_modules"]); - $data["total_modules_rate"] = servers_get_rate($data["avg_interval_total_modules"], $data["total_modules"]); - - return ($data); + GROUP BY tagente_modulo.id_modulo' + ); + + if (empty($interval_avgs_agents)) { + $interval_avgs_agents = []; + } + + // Merge with the previous calculated array + foreach ($interval_avgs_agents as $iaagents) { + if (!isset($interval_avgs[$iaagents['id_modulo']]['modules'])) { + $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = $iaagents['avg_interval']; + $interval_avgs[$iaagents['id_modulo']]['modules'] = $iaagents['modules']; + } else { + $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = servers_get_avg_interval($interval_avgs[$iaagents['id_modulo']], $iaagents); + $interval_avgs[$iaagents['id_modulo']]['modules'] += $iaagents['modules']; + } + } + + foreach ($interval_avgs as $id_modulo => $ia) { + switch ($id_modulo) { + case MODULE_DATA: + $data['avg_interval_local_modules'] = $ia['avg_interval']; + $data['local_modules_rate'] = servers_get_rate($data['avg_interval_local_modules'], $data['total_local_modules']); + break; + + case MODULE_NETWORK: + $data['avg_interval_network_modules'] = $ia['avg_interval']; + $data['network_modules_rate'] = servers_get_rate( + $data['avg_interval_network_modules'], + $data['total_network_modules'] + ); + break; + + case MODULE_PLUGIN: + $data['avg_interval_plugin_modules'] = $ia['avg_interval']; + $data['plugin_modules_rate'] = servers_get_rate($data['avg_interval_plugin_modules'], $data['total_plugin_modules']); + break; + + case MODULE_PREDICTION: + $data['avg_interval_prediction_modules'] = $ia['avg_interval']; + $data['prediction_modules_rate'] = servers_get_rate($data['avg_interval_prediction_modules'], $data['total_prediction_modules']); + break; + + case MODULE_WMI: + $data['avg_interval_wmi_modules'] = $ia['avg_interval']; + $data['wmi_modules_rate'] = servers_get_rate($data['avg_interval_wmi_modules'], $data['total_wmi_modules']); + break; + + case MODULE_WEB: + $data['avg_interval_web_modules'] = $ia['avg_interval']; + $data['web_modules_rate'] = servers_get_rate($data['avg_interval_web_modules'], $data['total_web_modules']); + break; + } + + if ($id_modulo != MODULE_DATA) { + $data['avg_interval_remote_modules'][] = $ia['avg_interval']; + } + + $data['avg_interval_total_modules'][] = $ia['avg_interval']; + } + + if (empty($data['avg_interval_remote_modules'])) { + $data['avg_interval_remote_modules'] = 0; + } else { + $data['avg_interval_remote_modules'] = (array_sum($data['avg_interval_remote_modules']) / count($data['avg_interval_remote_modules'])); + } + + if (empty($data['avg_interval_total_modules'])) { + $data['avg_interval_total_modules'] = 0; + } else { + $data['avg_interval_total_modules'] = (array_sum($data['avg_interval_total_modules']) / count($data['avg_interval_total_modules'])); + } + + $data['remote_modules_rate'] = servers_get_rate($data['avg_interval_remote_modules'], $data['total_remote_modules']); + $data['total_modules_rate'] = servers_get_rate($data['avg_interval_total_modules'], $data['total_modules']); + + return ($data); } + /** * Get avg interval * @@ -302,15 +346,19 @@ function servers_get_performance () { * * @return float number of avg modules between two parts */ - -function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2) { - $total_modules = $modules_avg_interval1['modules'] + $modules_avg_interval2['modules']; - - $parcial1 = $modules_avg_interval1['avg_interval'] * $modules_avg_interval1['modules']; - $parcial2 = $modules_avg_interval2['avg_interval'] * $modules_avg_interval2['modules']; - - return ($parcial1 + $parcial2) / $total_modules; + + +function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2) +{ + $total_modules = ($modules_avg_interval1['modules'] + $modules_avg_interval2['modules']); + + $parcial1 = ($modules_avg_interval1['avg_interval'] * $modules_avg_interval1['modules']); + $parcial2 = ($modules_avg_interval2['avg_interval'] * $modules_avg_interval2['modules']); + + return (($parcial1 + $parcial2) / $total_modules); } + + /** * Get server rate * @@ -319,13 +367,12 @@ function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2 * * @return float number of modules processed by second */ -function servers_get_rate($avg_interval, $num_modules) { - - return $avg_interval > 0 ? - ($num_modules / $avg_interval) : - 0; +function servers_get_rate($avg_interval, $num_modules) +{ + return $avg_interval > 0 ? ($num_modules / $avg_interval) : 0; } + /** * This function will get all the server information in an array or a specific server * @@ -333,300 +380,321 @@ function servers_get_rate($avg_interval, $num_modules) { * * @return mixed False in case the server doesn't exist or an array with info. */ -function servers_get_info ($id_server = -1) { - global $config; - - if (is_array ($id_server)) { - $select_id = " WHERE id_server IN (".implode (",", $id_server).")"; - } - elseif ($id_server > 0) { - $select_id = " WHERE id_server IN (".(int) $id_server.")"; - } - else { - $select_id = ""; - } - - $sql = " +function servers_get_info($id_server=-1) +{ + global $config; + + if (is_array($id_server)) { + $select_id = ' WHERE id_server IN ('.implode(',', $id_server).')'; + } else if ($id_server > 0) { + $select_id = ' WHERE id_server IN ('.(int) $id_server.')'; + } else { + $select_id = ''; + } + + $sql = ' SELECT * - FROM tserver " . $select_id . " - ORDER BY server_type"; - $result = db_get_all_rows_sql ($sql); - $time = get_system_time (); - - if (empty ($result)) { - return false; - } - - $return = array (); - foreach ($result as $server) { - switch ($server['server_type']) { - case SERVER_TYPE_DATA: - $server["img"] = html_print_image ("images/data.png", true, array ("title" => __('Data server'))); - $server["type"] = "data"; - $id_modulo = 1; - break; - case SERVER_TYPE_NETWORK: - $server["img"] = html_print_image ("images/network.png", true, array ("title" => __('Network server'))); - $server["type"] = "network"; - $id_modulo = 2; - break; - case SERVER_TYPE_SNMP: - $server["img"] = html_print_image ("images/snmp.png", true, array ("title" => __('SNMP Trap server'))); - $server["type"] = "snmp"; - $id_modulo = 0; - break; - case SERVER_TYPE_RECON: - $server["img"] = html_print_image ("images/recon.png", true, array ("title" => __('Recon server'))); - $server["type"] = "recon"; - $id_modulo = 0; - break; - case SERVER_TYPE_PLUGIN: - $server["img"] = html_print_image ("images/plugin.png", true, array ("title" => __('Plugin server'))); - $server["type"] = "plugin"; - $id_modulo = 4; - break; - case SERVER_TYPE_PREDICTION: - $server["img"] = html_print_image ("images/chart_bar.png", true, array ("title" => __('Prediction server'))); - $server["type"] = "prediction"; - $id_modulo = 5; - break; - case SERVER_TYPE_WMI: - $server["img"] = html_print_image ("images/wmi.png", true, array ("title" => __('WMI server'))); - $server["type"] = "wmi"; - $id_modulo = 6; - break; - case SERVER_TYPE_EXPORT: - $server["img"] = html_print_image ("images/server_export.png", true, array ("title" => __('Export server'))); - $server["type"] = "export"; - $id_modulo = 0; - break; - case SERVER_TYPE_INVENTORY: - $server["img"] = html_print_image ("images/page_white_text.png", true, array ("title" => __('Inventory server'))); - $server["type"] = "inventory"; - $id_modulo = 0; - break; - case SERVER_TYPE_WEB: - $server["img"] = html_print_image ("images/world.png", true, array ("title" => __('Web server'))); - $server["type"] = "web"; - $id_modulo = 0; - break; - case SERVER_TYPE_EVENT: - $server["img"] = html_print_image ("images/lightning_go.png", true, array ("title" => __('Event server'))); - $server["type"] = "event"; - $id_modulo = 2; - break; - case SERVER_TYPE_ENTERPRISE_ICMP: - $server["img"] = html_print_image ("images/network.png", true, array ("title" => __('Enterprise ICMP server'))); - $server["type"] = "enterprise icmp"; - $id_modulo = 2; - break; - case SERVER_TYPE_ENTERPRISE_SNMP: - $server["img"] = html_print_image ("images/network.png", true, array ("title" => __('Enterprise SNMP server'))); - $server["type"] = "enterprise snmp"; - $id_modulo = 2; - break; - case SERVER_TYPE_ENTERPRISE_SATELLITE: - $server["img"] = html_print_image ("images/satellite.png", true, array ("title" => __('Enterprise Satellite server'))); - $server["type"] = "enterprise satellite"; - $id_modulo = 0; - break; - case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: - $server["img"] = html_print_image ("images/transactional_map.png", true, array ("title" => __('Enterprise Transactional server'))); - $server["type"] = "enterprise transactional"; - $id_modulo = 0; - break; - case SERVER_TYPE_MAINFRAME: - $server["img"] = html_print_image ("images/mainframe.png", true, array ("title" => __('Mainframe server'))); - $server["type"] = "mainframe"; - $id_modulo = 0; - break; - case SERVER_TYPE_SYNC: - $server["img"] = html_print_image ("images/sync.png", true, array ("title" => __('Sync server'))); - $server["type"] = "sync"; - $id_modulo = 0; - break; - case SERVER_TYPE_WUX: - $server["img"] = html_print_image ("images/icono-wux.png", true, array ("title" => __('Wux server'))); - $server["type"] = "wux"; - $id_modulo = 0; - break; - case SERVER_TYPE_SYSLOG: - $server["img"] = html_print_image ("images/syslog.png", true, array ("title" => __('Syslog server'))); - $server["type"] = "syslog"; - $id_modulo = 0; - break; - case SERVER_TYPE_AUTOPROVISION: - $server["img"] = html_print_image ("images/autoprovision.png", true, array ("title" => __('Autoprovision server'))); - $server["type"] = "autoprovision"; - $id_modulo = 0; - break; - case SERVER_TYPE_MIGRATION: - $server["img"] = html_print_image ("images/migration.png", true, array ("title" => __('Migration server'))); - $server["type"] = "migration"; - $id_modulo = 0; - break; - default: - $server["img"] = ''; - $server["type"] = "unknown"; - $id_modulo = 0; - break; - } - - if ($config["realtimestats"] == 0) { - // --------------------------------------------------------------- - // Take data from database if not realtime stats - // --------------------------------------------------------------- - - $server["lag"] = db_get_sql ("SELECT lag_time FROM tserver WHERE id_server = ".$server["id_server"]); - $server["module_lag"] = db_get_sql ("SELECT lag_modules FROM tserver WHERE id_server = ".$server["id_server"]); - $server["modules"] = db_get_sql ("SELECT my_modules FROM tserver WHERE id_server = ".$server["id_server"]); - $server["modules_total"] = db_get_sql ("SELECT total_modules_running FROM tserver WHERE id_server = ".$server["id_server"]); - - } - else { - - // --------------------------------------------------------------- - // Take data in realtime - // --------------------------------------------------------------- - - - - $server["module_lag"] = 0; - $server["lag"] = 0; - - // Inventory server - if ($server["server_type"] == SERVER_TYPE_INVENTORY) { - - // Get modules exported by this server - $server["modules"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente AND tagente.server_name = '" . $server["name"] . "'"); - - // Get total exported modules - $server["modules_total"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente"); - - $interval_esc = db_escape_key_identifier ("interval"); - - // Get the module lag - $server["module_lag"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag + FROM tserver '.$select_id.' + ORDER BY server_type'; + $result = db_get_all_rows_sql($sql); + $time = get_system_time(); + + if (empty($result)) { + return false; + } + + $return = []; + foreach ($result as $server) { + switch ($server['server_type']) { + case SERVER_TYPE_DATA: + $server['img'] = html_print_image('images/data.png', true, ['title' => __('Data server')]); + $server['type'] = 'data'; + $id_modulo = 1; + break; + + case SERVER_TYPE_NETWORK: + $server['img'] = html_print_image('images/network.png', true, ['title' => __('Network server')]); + $server['type'] = 'network'; + $id_modulo = 2; + break; + + case SERVER_TYPE_SNMP: + $server['img'] = html_print_image('images/snmp.png', true, ['title' => __('SNMP Trap server')]); + $server['type'] = 'snmp'; + $id_modulo = 0; + break; + + case SERVER_TYPE_RECON: + $server['img'] = html_print_image('images/recon.png', true, ['title' => __('Recon server')]); + $server['type'] = 'recon'; + $id_modulo = 0; + break; + + case SERVER_TYPE_PLUGIN: + $server['img'] = html_print_image('images/plugin.png', true, ['title' => __('Plugin server')]); + $server['type'] = 'plugin'; + $id_modulo = 4; + break; + + case SERVER_TYPE_PREDICTION: + $server['img'] = html_print_image('images/chart_bar.png', true, ['title' => __('Prediction server')]); + $server['type'] = 'prediction'; + $id_modulo = 5; + break; + + case SERVER_TYPE_WMI: + $server['img'] = html_print_image('images/wmi.png', true, ['title' => __('WMI server')]); + $server['type'] = 'wmi'; + $id_modulo = 6; + break; + + case SERVER_TYPE_EXPORT: + $server['img'] = html_print_image('images/server_export.png', true, ['title' => __('Export server')]); + $server['type'] = 'export'; + $id_modulo = 0; + break; + + case SERVER_TYPE_INVENTORY: + $server['img'] = html_print_image('images/page_white_text.png', true, ['title' => __('Inventory server')]); + $server['type'] = 'inventory'; + $id_modulo = 0; + break; + + case SERVER_TYPE_WEB: + $server['img'] = html_print_image('images/world.png', true, ['title' => __('Web server')]); + $server['type'] = 'web'; + $id_modulo = 0; + break; + + case SERVER_TYPE_EVENT: + $server['img'] = html_print_image('images/lightning_go.png', true, ['title' => __('Event server')]); + $server['type'] = 'event'; + $id_modulo = 2; + break; + + case SERVER_TYPE_ENTERPRISE_ICMP: + $server['img'] = html_print_image('images/network.png', true, ['title' => __('Enterprise ICMP server')]); + $server['type'] = 'enterprise icmp'; + $id_modulo = 2; + break; + + case SERVER_TYPE_ENTERPRISE_SNMP: + $server['img'] = html_print_image('images/network.png', true, ['title' => __('Enterprise SNMP server')]); + $server['type'] = 'enterprise snmp'; + $id_modulo = 2; + break; + + case SERVER_TYPE_ENTERPRISE_SATELLITE: + $server['img'] = html_print_image('images/satellite.png', true, ['title' => __('Enterprise Satellite server')]); + $server['type'] = 'enterprise satellite'; + $id_modulo = 0; + break; + + case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: + $server['img'] = html_print_image('images/transactional_map.png', true, ['title' => __('Enterprise Transactional server')]); + $server['type'] = 'enterprise transactional'; + $id_modulo = 0; + break; + + case SERVER_TYPE_MAINFRAME: + $server['img'] = html_print_image('images/mainframe.png', true, ['title' => __('Mainframe server')]); + $server['type'] = 'mainframe'; + $id_modulo = 0; + break; + + case SERVER_TYPE_SYNC: + $server['img'] = html_print_image('images/sync.png', true, ['title' => __('Sync server')]); + $server['type'] = 'sync'; + $id_modulo = 0; + break; + + case SERVER_TYPE_WUX: + $server['img'] = html_print_image('images/icono-wux.png', true, ['title' => __('Wux server')]); + $server['type'] = 'wux'; + $id_modulo = 0; + break; + + case SERVER_TYPE_SYSLOG: + $server['img'] = html_print_image('images/syslog.png', true, ['title' => __('Syslog server')]); + $server['type'] = 'syslog'; + $id_modulo = 0; + break; + + case SERVER_TYPE_AUTOPROVISION: + $server['img'] = html_print_image('images/autoprovision.png', true, ['title' => __('Autoprovision server')]); + $server['type'] = 'autoprovision'; + $id_modulo = 0; + break; + + case SERVER_TYPE_MIGRATION: + $server['img'] = html_print_image('images/migration.png', true, ['title' => __('Migration server')]); + $server['type'] = 'migration'; + $id_modulo = 0; + break; + + default: + $server['img'] = ''; + $server['type'] = 'unknown'; + $id_modulo = 0; + break; + } + + if ($config['realtimestats'] == 0) { + // --------------------------------------------------------------- + // Take data from database if not realtime stats + // --------------------------------------------------------------- + $server['lag'] = db_get_sql('SELECT lag_time FROM tserver WHERE id_server = '.$server['id_server']); + $server['module_lag'] = db_get_sql('SELECT lag_modules FROM tserver WHERE id_server = '.$server['id_server']); + $server['modules'] = db_get_sql('SELECT my_modules FROM tserver WHERE id_server = '.$server['id_server']); + $server['modules_total'] = db_get_sql('SELECT total_modules_running FROM tserver WHERE id_server = '.$server['id_server']); + } else { + // --------------------------------------------------------------- + // Take data in realtime + // --------------------------------------------------------------- + $server['module_lag'] = 0; + $server['lag'] = 0; + + // Inventory server + if ($server['server_type'] == SERVER_TYPE_INVENTORY) { + // Get modules exported by this server + $server['modules'] = db_get_sql("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente AND tagente.server_name = '".$server['name']."'"); + + // Get total exported modules + $server['modules_total'] = db_get_sql('SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente'); + + $interval_esc = db_escape_key_identifier('interval'); + + // Get the module lag + $server['module_lag'] = db_get_sql( + 'SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag FROM tagente, tagent_module_inventory WHERE utimestamp > 0 AND tagent_module_inventory.id_agente = tagente.id_agente - AND tagent_module_inventory." . $interval_esc . " > 0 - AND tagente.server_name = '" . $server["name"] . "' - AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory." . $interval_esc . " * 10) - AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory." . $interval_esc); - - // Get the lag - $server["lag"] = db_get_sql ("SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory." . $interval_esc . ") + AND tagent_module_inventory.'.$interval_esc." > 0 + AND tagente.server_name = '".$server['name']."' + AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.".$interval_esc.' * 10) + AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.'.$interval_esc + ); + + // Get the lag + $server['lag'] = db_get_sql( + 'SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory.'.$interval_esc.') FROM tagente, tagent_module_inventory WHERE utimestamp > 0 AND tagent_module_inventory.id_agente = tagente.id_agente - AND tagent_module_inventory." . $interval_esc . " > 0 - AND tagente.server_name = '" . $server["name"] . "' - AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory." . $interval_esc . " * 10) - AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory." . $interval_esc); - // Export server - } - else if ($server["server_type"] == SERVER_TYPE_EXPORT) { - - // Get modules exported by this server - $server["modules"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tserver_export WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export = tserver_export.id AND tserver_export.id_export_server = " . $server["id_server"]); - - // Get total exported modules - $server["modules_total"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export != 0"); - - $server["lag"] = 0; - $server["module_lag"] = 0; - - } - // Recon server - else if ($server["server_type"] == SERVER_TYPE_RECON) { - - $server["name"] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view&server_id='.$server["id_server"].'">'.$server["name"].'</a>'; - - //Total jobs running on this recon server - $server["modules"] = db_get_sql ("SELECT COUNT(id_rt) + AND tagent_module_inventory.'.$interval_esc." > 0 + AND tagente.server_name = '".$server['name']."' + AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.".$interval_esc.' * 10) + AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.'.$interval_esc + ); + // Export server + } else if ($server['server_type'] == SERVER_TYPE_EXPORT) { + // Get modules exported by this server + $server['modules'] = db_get_sql('SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tserver_export WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export = tserver_export.id AND tserver_export.id_export_server = '.$server['id_server']); + + // Get total exported modules + $server['modules_total'] = db_get_sql('SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export != 0'); + + $server['lag'] = 0; + $server['module_lag'] = 0; + } + // Recon server + else if ($server['server_type'] == SERVER_TYPE_RECON) { + $server['name'] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view&server_id='.$server['id_server'].'">'.$server['name'].'</a>'; + + // Total jobs running on this recon server + $server['modules'] = db_get_sql( + 'SELECT COUNT(id_rt) FROM trecon_task - WHERE id_recon_server = ".$server["id_server"]); - - //Total recon jobs (all servers) - $server["modules_total"] = db_get_sql ("SELECT COUNT(status) FROM trecon_task"); - - //Lag (take average active time of all active tasks) - $server["module_lag"] = 0; - - switch ($config["dbtype"]) { - case "mysql": - $server["lag"] = db_get_sql ("SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - case "postgresql": - $server["lag"] = db_get_sql ("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - case "oracle": - $server["lag"] = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - } - } - else { - - // --------------------------------------------------------------- - // Data, Plugin, WMI, Network and Others - - $server["modules"] = db_get_sql ("SELECT count(tagente_estado.id_agente_modulo) FROM tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = ".$server["id_server"]); - - $server["modules_total"] = db_get_sql ("SELECT count(tagente_estado.id_agente_modulo) FROM tserver, tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = tserver.id_server AND tserver.server_type = ".$server["server_type"]); - - // Remote servers LAG Calculation (server_type != 0) - if ($server["server_type"] != 0) { - switch ($config["dbtype"]) { - case "mysql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + WHERE id_recon_server = '.$server['id_server'] + ); + + // Total recon jobs (all servers) + $server['modules_total'] = db_get_sql('SELECT COUNT(status) FROM trecon_task'); + + // Lag (take average active time of all active tasks) + $server['module_lag'] = 0; + + switch ($config['dbtype']) { + case 'mysql': + $server['lag'] = db_get_sql('SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + + $server['module_lag'] = db_get_sql('SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + break; + + case 'postgresql': + $server['lag'] = db_get_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server['id_server']); + + $server['module_lag'] = db_get_sql("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server['id_server']); + break; + + case 'oracle': + $server['lag'] = db_get_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + + $server['module_lag'] = db_get_sql("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + break; + } + } else { + // --------------------------------------------------------------- + // Data, Plugin, WMI, Network and Others + $server['modules'] = db_get_sql('SELECT count(tagente_estado.id_agente_modulo) FROM tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = '.$server['id_server']); + + $server['modules_total'] = db_get_sql('SELECT count(tagente_estado.id_agente_modulo) FROM tserver, tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = tserver.id_server AND tserver.server_type = '.$server['server_type']); + + // Remote servers LAG Calculation (server_type != 0) + if ($server['server_type'] != 0) { + switch ($config['dbtype']) { + case 'mysql': + $result = db_get_row_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND running_by = ".$server["id_server"]." + AND running_by = '.$server['id_server'].' AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) - AND (UNIX_TIMESTAMP() - utimestamp) > current_interval"); - break; - case "postgresql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND (UNIX_TIMESTAMP() - utimestamp) > current_interval' + ); + break; + + case 'postgresql': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND running_by = ".$server["id_server"]." + AND running_by = ".$server['id_server']." AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) < ( current_interval * 10) - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval"); - break; - case "oracle": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval" + ); + break; + + case 'oracle': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND running_by = ".$server["id_server"]." - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) < ( current_interval * 10) - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (" . SECONDS_1DAY . ")) > current_interval"); - break; - } - } - else { - // Local/Dataserver server LAG calculation: - switch ($config["dbtype"]) { - case "mysql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND running_by = '.$server['id_server']." + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp) < ( current_interval * 10) + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (".SECONDS_1DAY.')) > current_interval' + ); + break; + } + } else { + // Local/Dataserver server LAG calculation: + switch ($config['dbtype']) { + case 'mysql': + $result = db_get_row_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -635,11 +703,14 @@ function servers_get_info ($id_server = -1) { AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) - AND running_by = ".$server["id_server"]." - AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)"); - break; - case "postgresql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND running_by = '.$server['id_server'].' + AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)' + ); + break; + + case 'postgresql': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -648,11 +719,14 @@ function servers_get_info ($id_server = -1) { AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) < ( current_interval * 10) - AND running_by = ".$server["id_server"]." - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)"); - break; - case "oracle": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND running_by = ".$server['id_server']." + AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)" + ); + break; + + case 'oracle': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -660,52 +734,51 @@ function servers_get_info ($id_server = -1) { AND tagente_modulo.id_tipo_modulo < 5 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) < ( current_interval * 10) - AND running_by = ".$server["id_server"]." - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) > (current_interval * 1.1)"); - break; - } - } - - // Lag over current_interval * 2 is not lag, it's a timed out module - - if (!empty ($result["lag"])) { - $server["lag"] = $result["lag"]; - } - - if (!empty ($result["module_lag"])) { - $server["module_lag"] = $result["module_lag"]; - } - } - } // Take data for realtime mode - - if (isset($server["module_lag"])) - $server["lag_txt"] = - ($server["lag"] == 0 ? - '-' - : - human_time_description_raw($server["lag"])) . " / " . $server["module_lag"]; - else - $server["lag_txt"] = ""; - - if ($server["modules_total"] > 0) { - $server["load"] = round ($server["modules"] / $server["modules_total"] * 100); - } - else { - $server["load"] = 0; - } - - //Push the raw data on the return stack - $return[$server["id_server"]] = $server; - } // Main foreach - - return $return; + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp) < ( current_interval * 10) + AND running_by = '.$server['id_server']." + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp) > (current_interval * 1.1)' + ); + break; + } + } + + // Lag over current_interval * 2 is not lag, it's a timed out module + if (!empty($result['lag'])) { + $server['lag'] = $result['lag']; + } + + if (!empty($result['module_lag'])) { + $server['module_lag'] = $result['module_lag']; + } + } + } //end if + + if (isset($server['module_lag'])) { + $server['lag_txt'] = ($server['lag'] == 0 ? '-' : human_time_description_raw($server['lag'])).' / '.$server['module_lag']; + } else { + $server['lag_txt'] = ''; + } + + if ($server['modules_total'] > 0) { + $server['load'] = round(($server['modules'] / $server['modules_total'] * 100)); + } else { + $server['load'] = 0; + } + + // Push the raw data on the return stack + $return[$server['id_server']] = $server; + } //end foreach + + return $return; } -function servers_get_servers_type($type) { - return db_get_all_rows_filter('tserver', array('server_type' => $type)); + +function servers_get_servers_type($type) +{ + return db_get_all_rows_filter('tserver', ['server_type' => $type]); } + /** * Get the server name. * @@ -713,41 +786,46 @@ function servers_get_servers_type($type) { * * @return string Name of the given server */ -function servers_get_name ($id_server) { - return (string) db_get_value ('name', 'tserver', 'id_server', (int) $id_server); +function servers_get_name($id_server) +{ + return (string) db_get_value('name', 'tserver', 'id_server', (int) $id_server); } + /** * Get the presence of .conf and .md5 into remote_config dir - * + * * @param string Agent name - * + * * @return true if files exist and are writable */ -function servers_check_remote_config ($server_name) { - global $config; - - $server_md5 = md5 ($server_name, false); - - $filenames = array(); - $filenames['md5'] = io_safe_output($config["remote_config"]) - . "/md5/" . $server_md5 . ".srv.md5"; - $filenames['conf'] = io_safe_output($config["remote_config"]) - . "/conf/" . $server_md5 . ".srv.conf"; - - if (! isset ($filenames['conf'])) - return false; - if (! isset ($filenames['md5'])) - return false; - - return (file_exists ($filenames['conf']) - && is_writable ($filenames['conf']) - && file_exists ($filenames['md5']) - && is_writable ($filenames['md5'])); +function servers_check_remote_config($server_name) +{ + global $config; + + $server_md5 = md5($server_name, false); + + $filenames = []; + $filenames['md5'] = io_safe_output($config['remote_config']).'/md5/'.$server_md5.'.srv.md5'; + $filenames['conf'] = io_safe_output($config['remote_config']).'/conf/'.$server_md5.'.srv.conf'; + + if (! isset($filenames['conf'])) { + return false; + } + + if (! isset($filenames['md5'])) { + return false; + } + + return (file_exists($filenames['conf']) + && is_writable($filenames['conf']) + && file_exists($filenames['md5']) + && is_writable($filenames['md5'])); } + /** * Return a string containing image tag for a given target id (server) * TODO: Make this print_servertype_icon and move to functions_ui.php. Make XHTML compatible. Make string translatable @@ -758,72 +836,87 @@ function servers_check_remote_config ($server_name) { * * @return string Fully formatted IMG HTML tag with icon */ -function servers_show_type ($id) { - global $config; - - switch ($id) { - case 1: - return html_print_image("images/database.png", true, array("title" => get_product_name() . " Data server")); - break; - case 2: - return html_print_image("images/network.png", true, array("title" => get_product_name() . " Network server")); - break; - case 4: - return html_print_image("images/plugin.png", true, array("title" => get_product_name() . " Plugin server")); - break; - case 5: - return html_print_image("images/chart_bar.png", true, array("title" => get_product_name() . " Prediction server")); - break; - case 6: - return html_print_image("images/wmi.png", true, array("title" => get_product_name() . " WMI server")); - break; - case 7: - return html_print_image("images/server_web.png", true, array("title" => get_product_name() . " WEB server")); - break; - case 8: - return html_print_image("images/module-wux.png", true, array("title" => get_product_name() . " WUX server")); - break; - default: - return "--"; - break; - } +function servers_show_type($id) +{ + global $config; + + switch ($id) { + case 1: + return html_print_image('images/database.png', true, ['title' => get_product_name().' Data server']); + + break; + case 2: + return html_print_image('images/network.png', true, ['title' => get_product_name().' Network server']); + + break; + case 4: + return html_print_image('images/plugin.png', true, ['title' => get_product_name().' Plugin server']); + + break; + case 5: + return html_print_image('images/chart_bar.png', true, ['title' => get_product_name().' Prediction server']); + + break; + case 6: + return html_print_image('images/wmi.png', true, ['title' => get_product_name().' WMI server']); + + break; + case 7: + return html_print_image('images/server_web.png', true, ['title' => get_product_name().' WEB server']); + + break; + case 8: + return html_print_image('images/module-wux.png', true, ['title' => get_product_name().' WUX server']); + + break; + default: + return '--'; + break; + } } + /** * Get the numbers of servers up. * * This check assumes that server_keepalive should be at least 15 minutes. * - * @return int The number of servers alive. + * @return integer The number of servers alive. */ -function servers_check_status () { - global $config; - - switch ($config["dbtype"]) { - case "mysql": - $sql = "SELECT COUNT(id_server) +function servers_check_status() +{ + global $config; + + switch ($config['dbtype']) { + case 'mysql': + $sql = 'SELECT COUNT(id_server) FROM tserver WHERE status = 1 - AND keepalive > NOW() - INTERVAL server_keepalive*2 SECOND"; - break; - case "postgresql": - $sql = "SELECT COUNT(id_server) + AND keepalive > NOW() - INTERVAL server_keepalive*2 SECOND'; + break; + + case 'postgresql': + $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > NOW() - INTERVAL 'server_keepalive*2 SECOND'"; - break; - case "oracle": - $sql = "SELECT COUNT(id_server) + break; + + case 'oracle': + $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > systimestamp - INTERVAL 'server_keepalive*2' SECOND"; - break; - } - $status = (int) db_get_sql ($sql); //Cast as int will assure a number value - // This function should just ack of server down, not set it down. - return $status; + break; + } + + $status = (int) db_get_sql($sql); + // Cast as int will assure a number value + // This function should just ack of server down, not set it down. + return $status; } + /** * @deprecated use servers_get_info instead * Get statistical information for a given server @@ -832,8 +925,66 @@ function servers_check_status () { * * @return array Server info array */ -function servers_get_status ($id_server) { - $serverinfo = servers_get_info ($id_server); - return $serverinfo[$id_server]; +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 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_RECON: + return __('Discovery server'); + + case SERVER_TYPE_SYSLOG: + return __('Syslog server'); + + default: + return __('N/A'); + } } -?> From 89af077b52dcf2bc49fa8ca3cee437c6e2361e86 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 4 Feb 2019 19:16:30 +0100 Subject: [PATCH 020/262] Servers get server string name Former-commit-id: e67755e9a86872ba65c5768191cba80fbd879322 --- pandora_console/include/functions_servers.php | 1425 +++++++++-------- 1 file changed, 788 insertions(+), 637 deletions(-) diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 6bd255e88d..bc5fd590f3 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -1,24 +1,32 @@ <?php - -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation; version 2 - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - /** - * @package Include - * @subpackage Servers + * Auxiliary functions to manage servers. + * + * @category Library + * @package Pandora FMS + * @subpackage Opensource + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ */ + /** * Get a server. * @@ -28,62 +36,78 @@ * * @return Server with the given id. False if not available. */ -function servers_get_server ($id_server, $filter = false, $fields = false) { - if (empty ($id_server)) - return false; - if (! is_array ($filter)) - $filter = array (); - $filter['id_server'] = $id_server; - - return @db_get_row_filter ('tserver', $filter, $fields); +function servers_get_server($id_server, $filter=false, $fields=false) +{ + if (empty($id_server)) { + return false; + } + + if (! is_array($filter)) { + $filter = []; + } + + $filter['id_server'] = $id_server; + + return @db_get_row_filter('tserver', $filter, $fields); } + /** * Get all the server availables. * * @return All the servers available. */ -function servers_get_names () { - $all_servers = @db_get_all_rows_filter ('tserver', false, array ('DISTINCT(name) as name')); - if ($all_servers === false) - return array (); - - $servers = array (); - foreach ($all_servers as $server) { - $servers[$server['name']] = $server['name']; - } - return $servers; +function servers_get_names() +{ + $all_servers = @db_get_all_rows_filter('tserver', false, ['DISTINCT(name) as name']); + if ($all_servers === false) { + return []; + } + + $servers = []; + foreach ($all_servers as $server) { + $servers[$server['name']] = $server['name']; + } + + return $servers; } + /** * This function forces a recon task to be queued by the server asap */ -function servers_force_recon_task($id_recon_task) { - $values = array('utimestamp' => 0, 'status' => 1); - db_process_sql_update('trecon_task', $values, array('id_rt' => $id_recon_task)); +function servers_force_recon_task($id_recon_task) +{ + $values = [ + 'utimestamp' => 0, + 'status' => 1, + ]; + db_process_sql_update('trecon_task', $values, ['id_rt' => $id_recon_task]); } + /** * This function will get several metrics from the database to get info about server performance - * @return array with several data + * + * @return array with several data */ -function servers_get_performance () { - - global $config; - - $data = array(); - $data["total_modules"] = 0; - $data["total_remote_modules"] = 0; - $data["total_local_modules"] = 0; - $data["avg_interval_total_modules"] = array(); - $data["avg_interval_remote_modules"] = array(); - $data["avg_interval_local_modules"] = 0; - $data["local_modules_rate"] = 0; - $data["network_modules_rate"] = 0; - - if ($config["realtimestats"] == 1) { - - $counts = db_get_all_rows_sql (" +function servers_get_performance() +{ + global $config; + + $data = []; + $data['total_modules'] = 0; + $data['total_remote_modules'] = 0; + $data['total_local_modules'] = 0; + $data['avg_interval_total_modules'] = []; + $data['avg_interval_remote_modules'] = []; + $data['avg_interval_local_modules'] = 0; + $data['local_modules_rate'] = 0; + $data['network_modules_rate'] = 0; + + if ($config['realtimestats'] == 1) { + $counts = db_get_all_rows_sql( + ' SELECT tagente_modulo.id_modulo, COUNT(tagente_modulo.id_agente_modulo) modules FROM tagente_modulo, tagente_estado, tagente @@ -95,94 +119,108 @@ function servers_get_performance () { AND (utimestamp > 0 OR (id_tipo_modulo = 100 OR (id_tipo_modulo > 21 AND id_tipo_modulo < 23))) AND tagente.disabled = 0 - GROUP BY tagente_modulo.id_modulo"); - - if (empty($counts)) { - $counts = array(); - } - - foreach($counts as $c) { - switch($c['id_modulo']) { - case MODULE_DATA: - $data["total_local_modules"] = $c['modules']; - break; - case MODULE_NETWORK: - $data["total_network_modules"] = $c['modules']; - break; - case MODULE_PLUGIN: - $data["total_plugin_modules"] = $c['modules']; - break; - case MODULE_PREDICTION: - $data["total_prediction_modules"] = $c['modules']; - break; - case MODULE_WMI: - $data["total_wmi_modules"] = $c['modules']; - break; - case MODULE_WEB: - $data["total_web_modules"] = $c['modules']; - break; - } - - if($c['id_modulo'] != MODULE_DATA) { - $data["total_remote_modules"] += $c['modules']; - } - - $data["total_modules"] += $c['modules']; - } - } - else { - $counts = db_get_all_rows_sql (" + GROUP BY tagente_modulo.id_modulo' + ); + + if (empty($counts)) { + $counts = []; + } + + foreach ($counts as $c) { + switch ($c['id_modulo']) { + case MODULE_DATA: + $data['total_local_modules'] = $c['modules']; + break; + + case MODULE_NETWORK: + $data['total_network_modules'] = $c['modules']; + break; + + case MODULE_PLUGIN: + $data['total_plugin_modules'] = $c['modules']; + break; + + case MODULE_PREDICTION: + $data['total_prediction_modules'] = $c['modules']; + break; + + case MODULE_WMI: + $data['total_wmi_modules'] = $c['modules']; + break; + + case MODULE_WEB: + $data['total_web_modules'] = $c['modules']; + break; + } + + if ($c['id_modulo'] != MODULE_DATA) { + $data['total_remote_modules'] += $c['modules']; + } + + $data['total_modules'] += $c['modules']; + } + } else { + $counts = db_get_all_rows_sql( + ' SELECT server_type, my_modules modules FROM tserver - GROUP BY server_type"); - - if (empty($counts)) { - $counts = array(); - } - - foreach ($counts as $c) { - switch ($c['server_type']) { - case SERVER_TYPE_DATA: - $data["total_local_modules"] = $c['modules']; - break; - case SERVER_TYPE_NETWORK: - case SERVER_TYPE_SNMP: - case SERVER_TYPE_ENTERPRISE_ICMP: - case SERVER_TYPE_ENTERPRISE_SNMP: - $data["total_network_modules"] = $c['modules']; - break; - case SERVER_TYPE_PLUGIN: - $data["total_plugin_modules"] = $c['modules']; - break; - case SERVER_TYPE_PREDICTION: - $data["total_prediction_modules"] = $c['modules']; - break; - case SERVER_TYPE_WMI: - $data["total_wmi_modules"] = $c['modules']; - break; - case SERVER_TYPE_WEB: - $data["total_web_modules"] = $c['modules']; - break; - case SERVER_TYPE_EXPORT: - case SERVER_TYPE_INVENTORY: - case SERVER_TYPE_EVENT: - case SERVER_TYPE_RECON: - case SERVER_TYPE_SYSLOG: - break; - } - - if ($c['server_type'] != SERVER_TYPE_DATA) { - $data["total_remote_modules"] += $c['modules']; - } - - $data["total_modules"] += $c['modules']; - } - } - - $interval_avgs = array(); - - // Avg of modules interval when modules have module_interval > 0 - $interval_avgs_modules = db_get_all_rows_sql (" + GROUP BY server_type' + ); + + if (empty($counts)) { + $counts = []; + } + + foreach ($counts as $c) { + switch ($c['server_type']) { + case SERVER_TYPE_DATA: + $data['total_local_modules'] = $c['modules']; + break; + + case SERVER_TYPE_NETWORK: + case SERVER_TYPE_SNMP: + case SERVER_TYPE_ENTERPRISE_ICMP: + case SERVER_TYPE_ENTERPRISE_SNMP: + $data['total_network_modules'] = $c['modules']; + break; + + case SERVER_TYPE_PLUGIN: + $data['total_plugin_modules'] = $c['modules']; + break; + + case SERVER_TYPE_PREDICTION: + $data['total_prediction_modules'] = $c['modules']; + break; + + case SERVER_TYPE_WMI: + $data['total_wmi_modules'] = $c['modules']; + break; + + case SERVER_TYPE_WEB: + $data['total_web_modules'] = $c['modules']; + break; + + case SERVER_TYPE_EXPORT: + case SERVER_TYPE_INVENTORY: + case SERVER_TYPE_EVENT: + case SERVER_TYPE_RECON: + case SERVER_TYPE_SYSLOG: + break; + } + + if ($c['server_type'] != SERVER_TYPE_DATA) { + $data['total_remote_modules'] += $c['modules']; + } + + $data['total_modules'] += $c['modules']; + } + } + + $interval_avgs = []; + + // Avg of modules interval when modules have module_interval > 0 + $interval_avgs_modules = db_get_all_rows_sql( + ' SELECT count(tagente_modulo.id_modulo) modules , tagente_modulo.id_modulo, AVG(tagente_modulo.module_interval) avg_interval @@ -194,20 +232,22 @@ function servers_get_performance () { AND delete_pending = 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente - GROUP BY tagente_modulo.id_modulo"); - - if (empty($interval_avgs_modules)) { - $interval_avgs_modules = array(); - } - - // Transform into a easily format - foreach ($interval_avgs_modules as $iamodules) { - $interval_avgs[$iamodules['id_modulo']]['avg_interval'] = $iamodules['avg_interval']; - $interval_avgs[$iamodules['id_modulo']]['modules'] = $iamodules['modules']; - } - - // Avg of agents interval when modules have module_interval == 0 - $interval_avgs_agents = db_get_all_rows_sql (" + GROUP BY tagente_modulo.id_modulo' + ); + + if (empty($interval_avgs_modules)) { + $interval_avgs_modules = []; + } + + // Transform into a easily format + foreach ($interval_avgs_modules as $iamodules) { + $interval_avgs[$iamodules['id_modulo']]['avg_interval'] = $iamodules['avg_interval']; + $interval_avgs[$iamodules['id_modulo']]['modules'] = $iamodules['modules']; + } + + // Avg of agents interval when modules have module_interval == 0 + $interval_avgs_agents = db_get_all_rows_sql( + ' SELECT count(tagente_modulo.id_modulo) modules , tagente_modulo.id_modulo, AVG(tagente.intervalo) avg_interval FROM tagente_modulo, tagente_estado, tagente @@ -218,82 +258,86 @@ function servers_get_performance () { AND delete_pending = 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente - GROUP BY tagente_modulo.id_modulo"); - - if (empty($interval_avgs_agents)) { - $interval_avgs_agents = array(); - } - - // Merge with the previous calculated array - foreach ($interval_avgs_agents as $iaagents) { - if (!isset($interval_avgs[$iaagents['id_modulo']]['modules'])) { - $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = $iaagents['avg_interval']; - $interval_avgs[$iaagents['id_modulo']]['modules'] = $iaagents['modules']; - } - else { - $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = servers_get_avg_interval($interval_avgs[$iaagents['id_modulo']], $iaagents); - $interval_avgs[$iaagents['id_modulo']]['modules'] += $iaagents['modules']; - } - } - - foreach ($interval_avgs as $id_modulo => $ia) { - switch($id_modulo) { - case MODULE_DATA: - $data["avg_interval_local_modules"] = $ia['avg_interval']; - $data["local_modules_rate"] = - servers_get_rate($data["avg_interval_local_modules"], $data["total_local_modules"]); - break; - case MODULE_NETWORK: - $data["avg_interval_network_modules"] = $ia['avg_interval']; - $data["network_modules_rate"] = - servers_get_rate($data["avg_interval_network_modules"], - $data["total_network_modules"]); - break; - case MODULE_PLUGIN: - $data["avg_interval_plugin_modules"] = $ia['avg_interval']; - $data["plugin_modules_rate"] = servers_get_rate($data["avg_interval_plugin_modules"], $data["total_plugin_modules"]); - break; - case MODULE_PREDICTION: - $data["avg_interval_prediction_modules"] = $ia['avg_interval']; - $data["prediction_modules_rate"] = servers_get_rate($data["avg_interval_prediction_modules"], $data["total_prediction_modules"]); - break; - case MODULE_WMI: - $data["avg_interval_wmi_modules"] = $ia['avg_interval']; - $data["wmi_modules_rate"] = servers_get_rate($data["avg_interval_wmi_modules"], $data["total_wmi_modules"]); - break; - case MODULE_WEB: - $data["avg_interval_web_modules"] = $ia['avg_interval']; - $data["web_modules_rate"] = servers_get_rate($data["avg_interval_web_modules"], $data["total_web_modules"]); - break; - } - - if ($id_modulo != MODULE_DATA) { - $data["avg_interval_remote_modules"][] = $ia['avg_interval']; - } - - $data["avg_interval_total_modules"][] = $ia['avg_interval']; - } - - if (empty($data["avg_interval_remote_modules"])) { - $data["avg_interval_remote_modules"] = 0; - } - else { - $data["avg_interval_remote_modules"] = array_sum($data["avg_interval_remote_modules"]) / count($data["avg_interval_remote_modules"]); - } - - if (empty($data["avg_interval_total_modules"])) { - $data["avg_interval_total_modules"] = 0; - } - else { - $data["avg_interval_total_modules"] = array_sum($data["avg_interval_total_modules"]) / count($data["avg_interval_total_modules"]); - } - - $data["remote_modules_rate"] = servers_get_rate($data["avg_interval_remote_modules"], $data["total_remote_modules"]); - $data["total_modules_rate"] = servers_get_rate($data["avg_interval_total_modules"], $data["total_modules"]); - - return ($data); + GROUP BY tagente_modulo.id_modulo' + ); + + if (empty($interval_avgs_agents)) { + $interval_avgs_agents = []; + } + + // Merge with the previous calculated array + foreach ($interval_avgs_agents as $iaagents) { + if (!isset($interval_avgs[$iaagents['id_modulo']]['modules'])) { + $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = $iaagents['avg_interval']; + $interval_avgs[$iaagents['id_modulo']]['modules'] = $iaagents['modules']; + } else { + $interval_avgs[$iaagents['id_modulo']]['avg_interval'] = servers_get_avg_interval($interval_avgs[$iaagents['id_modulo']], $iaagents); + $interval_avgs[$iaagents['id_modulo']]['modules'] += $iaagents['modules']; + } + } + + foreach ($interval_avgs as $id_modulo => $ia) { + switch ($id_modulo) { + case MODULE_DATA: + $data['avg_interval_local_modules'] = $ia['avg_interval']; + $data['local_modules_rate'] = servers_get_rate($data['avg_interval_local_modules'], $data['total_local_modules']); + break; + + case MODULE_NETWORK: + $data['avg_interval_network_modules'] = $ia['avg_interval']; + $data['network_modules_rate'] = servers_get_rate( + $data['avg_interval_network_modules'], + $data['total_network_modules'] + ); + break; + + case MODULE_PLUGIN: + $data['avg_interval_plugin_modules'] = $ia['avg_interval']; + $data['plugin_modules_rate'] = servers_get_rate($data['avg_interval_plugin_modules'], $data['total_plugin_modules']); + break; + + case MODULE_PREDICTION: + $data['avg_interval_prediction_modules'] = $ia['avg_interval']; + $data['prediction_modules_rate'] = servers_get_rate($data['avg_interval_prediction_modules'], $data['total_prediction_modules']); + break; + + case MODULE_WMI: + $data['avg_interval_wmi_modules'] = $ia['avg_interval']; + $data['wmi_modules_rate'] = servers_get_rate($data['avg_interval_wmi_modules'], $data['total_wmi_modules']); + break; + + case MODULE_WEB: + $data['avg_interval_web_modules'] = $ia['avg_interval']; + $data['web_modules_rate'] = servers_get_rate($data['avg_interval_web_modules'], $data['total_web_modules']); + break; + } + + if ($id_modulo != MODULE_DATA) { + $data['avg_interval_remote_modules'][] = $ia['avg_interval']; + } + + $data['avg_interval_total_modules'][] = $ia['avg_interval']; + } + + if (empty($data['avg_interval_remote_modules'])) { + $data['avg_interval_remote_modules'] = 0; + } else { + $data['avg_interval_remote_modules'] = (array_sum($data['avg_interval_remote_modules']) / count($data['avg_interval_remote_modules'])); + } + + if (empty($data['avg_interval_total_modules'])) { + $data['avg_interval_total_modules'] = 0; + } else { + $data['avg_interval_total_modules'] = (array_sum($data['avg_interval_total_modules']) / count($data['avg_interval_total_modules'])); + } + + $data['remote_modules_rate'] = servers_get_rate($data['avg_interval_remote_modules'], $data['total_remote_modules']); + $data['total_modules_rate'] = servers_get_rate($data['avg_interval_total_modules'], $data['total_modules']); + + return ($data); } + /** * Get avg interval * @@ -302,15 +346,19 @@ function servers_get_performance () { * * @return float number of avg modules between two parts */ - -function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2) { - $total_modules = $modules_avg_interval1['modules'] + $modules_avg_interval2['modules']; - - $parcial1 = $modules_avg_interval1['avg_interval'] * $modules_avg_interval1['modules']; - $parcial2 = $modules_avg_interval2['avg_interval'] * $modules_avg_interval2['modules']; - - return ($parcial1 + $parcial2) / $total_modules; + + +function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2) +{ + $total_modules = ($modules_avg_interval1['modules'] + $modules_avg_interval2['modules']); + + $parcial1 = ($modules_avg_interval1['avg_interval'] * $modules_avg_interval1['modules']); + $parcial2 = ($modules_avg_interval2['avg_interval'] * $modules_avg_interval2['modules']); + + return (($parcial1 + $parcial2) / $total_modules); } + + /** * Get server rate * @@ -319,13 +367,12 @@ function servers_get_avg_interval($modules_avg_interval1, $modules_avg_interval2 * * @return float number of modules processed by second */ -function servers_get_rate($avg_interval, $num_modules) { - - return $avg_interval > 0 ? - ($num_modules / $avg_interval) : - 0; +function servers_get_rate($avg_interval, $num_modules) +{ + return $avg_interval > 0 ? ($num_modules / $avg_interval) : 0; } + /** * This function will get all the server information in an array or a specific server * @@ -333,300 +380,321 @@ function servers_get_rate($avg_interval, $num_modules) { * * @return mixed False in case the server doesn't exist or an array with info. */ -function servers_get_info ($id_server = -1) { - global $config; - - if (is_array ($id_server)) { - $select_id = " WHERE id_server IN (".implode (",", $id_server).")"; - } - elseif ($id_server > 0) { - $select_id = " WHERE id_server IN (".(int) $id_server.")"; - } - else { - $select_id = ""; - } - - $sql = " +function servers_get_info($id_server=-1) +{ + global $config; + + if (is_array($id_server)) { + $select_id = ' WHERE id_server IN ('.implode(',', $id_server).')'; + } else if ($id_server > 0) { + $select_id = ' WHERE id_server IN ('.(int) $id_server.')'; + } else { + $select_id = ''; + } + + $sql = ' SELECT * - FROM tserver " . $select_id . " - ORDER BY server_type"; - $result = db_get_all_rows_sql ($sql); - $time = get_system_time (); - - if (empty ($result)) { - return false; - } - - $return = array (); - foreach ($result as $server) { - switch ($server['server_type']) { - case SERVER_TYPE_DATA: - $server["img"] = html_print_image ("images/data.png", true, array ("title" => __('Data server'))); - $server["type"] = "data"; - $id_modulo = 1; - break; - case SERVER_TYPE_NETWORK: - $server["img"] = html_print_image ("images/network.png", true, array ("title" => __('Network server'))); - $server["type"] = "network"; - $id_modulo = 2; - break; - case SERVER_TYPE_SNMP: - $server["img"] = html_print_image ("images/snmp.png", true, array ("title" => __('SNMP Trap server'))); - $server["type"] = "snmp"; - $id_modulo = 0; - break; - case SERVER_TYPE_RECON: - $server["img"] = html_print_image ("images/recon.png", true, array ("title" => __('Recon server'))); - $server["type"] = "recon"; - $id_modulo = 0; - break; - case SERVER_TYPE_PLUGIN: - $server["img"] = html_print_image ("images/plugin.png", true, array ("title" => __('Plugin server'))); - $server["type"] = "plugin"; - $id_modulo = 4; - break; - case SERVER_TYPE_PREDICTION: - $server["img"] = html_print_image ("images/chart_bar.png", true, array ("title" => __('Prediction server'))); - $server["type"] = "prediction"; - $id_modulo = 5; - break; - case SERVER_TYPE_WMI: - $server["img"] = html_print_image ("images/wmi.png", true, array ("title" => __('WMI server'))); - $server["type"] = "wmi"; - $id_modulo = 6; - break; - case SERVER_TYPE_EXPORT: - $server["img"] = html_print_image ("images/server_export.png", true, array ("title" => __('Export server'))); - $server["type"] = "export"; - $id_modulo = 0; - break; - case SERVER_TYPE_INVENTORY: - $server["img"] = html_print_image ("images/page_white_text.png", true, array ("title" => __('Inventory server'))); - $server["type"] = "inventory"; - $id_modulo = 0; - break; - case SERVER_TYPE_WEB: - $server["img"] = html_print_image ("images/world.png", true, array ("title" => __('Web server'))); - $server["type"] = "web"; - $id_modulo = 0; - break; - case SERVER_TYPE_EVENT: - $server["img"] = html_print_image ("images/lightning_go.png", true, array ("title" => __('Event server'))); - $server["type"] = "event"; - $id_modulo = 2; - break; - case SERVER_TYPE_ENTERPRISE_ICMP: - $server["img"] = html_print_image ("images/network.png", true, array ("title" => __('Enterprise ICMP server'))); - $server["type"] = "enterprise icmp"; - $id_modulo = 2; - break; - case SERVER_TYPE_ENTERPRISE_SNMP: - $server["img"] = html_print_image ("images/network.png", true, array ("title" => __('Enterprise SNMP server'))); - $server["type"] = "enterprise snmp"; - $id_modulo = 2; - break; - case SERVER_TYPE_ENTERPRISE_SATELLITE: - $server["img"] = html_print_image ("images/satellite.png", true, array ("title" => __('Enterprise Satellite server'))); - $server["type"] = "enterprise satellite"; - $id_modulo = 0; - break; - case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: - $server["img"] = html_print_image ("images/transactional_map.png", true, array ("title" => __('Enterprise Transactional server'))); - $server["type"] = "enterprise transactional"; - $id_modulo = 0; - break; - case SERVER_TYPE_MAINFRAME: - $server["img"] = html_print_image ("images/mainframe.png", true, array ("title" => __('Mainframe server'))); - $server["type"] = "mainframe"; - $id_modulo = 0; - break; - case SERVER_TYPE_SYNC: - $server["img"] = html_print_image ("images/sync.png", true, array ("title" => __('Sync server'))); - $server["type"] = "sync"; - $id_modulo = 0; - break; - case SERVER_TYPE_WUX: - $server["img"] = html_print_image ("images/icono-wux.png", true, array ("title" => __('Wux server'))); - $server["type"] = "wux"; - $id_modulo = 0; - break; - case SERVER_TYPE_SYSLOG: - $server["img"] = html_print_image ("images/syslog.png", true, array ("title" => __('Syslog server'))); - $server["type"] = "syslog"; - $id_modulo = 0; - break; - case SERVER_TYPE_AUTOPROVISION: - $server["img"] = html_print_image ("images/autoprovision.png", true, array ("title" => __('Autoprovision server'))); - $server["type"] = "autoprovision"; - $id_modulo = 0; - break; - case SERVER_TYPE_MIGRATION: - $server["img"] = html_print_image ("images/migration.png", true, array ("title" => __('Migration server'))); - $server["type"] = "migration"; - $id_modulo = 0; - break; - default: - $server["img"] = ''; - $server["type"] = "unknown"; - $id_modulo = 0; - break; - } - - if ($config["realtimestats"] == 0) { - // --------------------------------------------------------------- - // Take data from database if not realtime stats - // --------------------------------------------------------------- - - $server["lag"] = db_get_sql ("SELECT lag_time FROM tserver WHERE id_server = ".$server["id_server"]); - $server["module_lag"] = db_get_sql ("SELECT lag_modules FROM tserver WHERE id_server = ".$server["id_server"]); - $server["modules"] = db_get_sql ("SELECT my_modules FROM tserver WHERE id_server = ".$server["id_server"]); - $server["modules_total"] = db_get_sql ("SELECT total_modules_running FROM tserver WHERE id_server = ".$server["id_server"]); - - } - else { - - // --------------------------------------------------------------- - // Take data in realtime - // --------------------------------------------------------------- - - - - $server["module_lag"] = 0; - $server["lag"] = 0; - - // Inventory server - if ($server["server_type"] == SERVER_TYPE_INVENTORY) { - - // Get modules exported by this server - $server["modules"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente AND tagente.server_name = '" . $server["name"] . "'"); - - // Get total exported modules - $server["modules_total"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente"); - - $interval_esc = db_escape_key_identifier ("interval"); - - // Get the module lag - $server["module_lag"] = db_get_sql ("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag + FROM tserver '.$select_id.' + ORDER BY server_type'; + $result = db_get_all_rows_sql($sql); + $time = get_system_time(); + + if (empty($result)) { + return false; + } + + $return = []; + foreach ($result as $server) { + switch ($server['server_type']) { + case SERVER_TYPE_DATA: + $server['img'] = html_print_image('images/data.png', true, ['title' => __('Data server')]); + $server['type'] = 'data'; + $id_modulo = 1; + break; + + case SERVER_TYPE_NETWORK: + $server['img'] = html_print_image('images/network.png', true, ['title' => __('Network server')]); + $server['type'] = 'network'; + $id_modulo = 2; + break; + + case SERVER_TYPE_SNMP: + $server['img'] = html_print_image('images/snmp.png', true, ['title' => __('SNMP Trap server')]); + $server['type'] = 'snmp'; + $id_modulo = 0; + break; + + case SERVER_TYPE_RECON: + $server['img'] = html_print_image('images/recon.png', true, ['title' => __('Recon server')]); + $server['type'] = 'recon'; + $id_modulo = 0; + break; + + case SERVER_TYPE_PLUGIN: + $server['img'] = html_print_image('images/plugin.png', true, ['title' => __('Plugin server')]); + $server['type'] = 'plugin'; + $id_modulo = 4; + break; + + case SERVER_TYPE_PREDICTION: + $server['img'] = html_print_image('images/chart_bar.png', true, ['title' => __('Prediction server')]); + $server['type'] = 'prediction'; + $id_modulo = 5; + break; + + case SERVER_TYPE_WMI: + $server['img'] = html_print_image('images/wmi.png', true, ['title' => __('WMI server')]); + $server['type'] = 'wmi'; + $id_modulo = 6; + break; + + case SERVER_TYPE_EXPORT: + $server['img'] = html_print_image('images/server_export.png', true, ['title' => __('Export server')]); + $server['type'] = 'export'; + $id_modulo = 0; + break; + + case SERVER_TYPE_INVENTORY: + $server['img'] = html_print_image('images/page_white_text.png', true, ['title' => __('Inventory server')]); + $server['type'] = 'inventory'; + $id_modulo = 0; + break; + + case SERVER_TYPE_WEB: + $server['img'] = html_print_image('images/world.png', true, ['title' => __('Web server')]); + $server['type'] = 'web'; + $id_modulo = 0; + break; + + case SERVER_TYPE_EVENT: + $server['img'] = html_print_image('images/lightning_go.png', true, ['title' => __('Event server')]); + $server['type'] = 'event'; + $id_modulo = 2; + break; + + case SERVER_TYPE_ENTERPRISE_ICMP: + $server['img'] = html_print_image('images/network.png', true, ['title' => __('Enterprise ICMP server')]); + $server['type'] = 'enterprise icmp'; + $id_modulo = 2; + break; + + case SERVER_TYPE_ENTERPRISE_SNMP: + $server['img'] = html_print_image('images/network.png', true, ['title' => __('Enterprise SNMP server')]); + $server['type'] = 'enterprise snmp'; + $id_modulo = 2; + break; + + case SERVER_TYPE_ENTERPRISE_SATELLITE: + $server['img'] = html_print_image('images/satellite.png', true, ['title' => __('Enterprise Satellite server')]); + $server['type'] = 'enterprise satellite'; + $id_modulo = 0; + break; + + case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: + $server['img'] = html_print_image('images/transactional_map.png', true, ['title' => __('Enterprise Transactional server')]); + $server['type'] = 'enterprise transactional'; + $id_modulo = 0; + break; + + case SERVER_TYPE_MAINFRAME: + $server['img'] = html_print_image('images/mainframe.png', true, ['title' => __('Mainframe server')]); + $server['type'] = 'mainframe'; + $id_modulo = 0; + break; + + case SERVER_TYPE_SYNC: + $server['img'] = html_print_image('images/sync.png', true, ['title' => __('Sync server')]); + $server['type'] = 'sync'; + $id_modulo = 0; + break; + + case SERVER_TYPE_WUX: + $server['img'] = html_print_image('images/icono-wux.png', true, ['title' => __('Wux server')]); + $server['type'] = 'wux'; + $id_modulo = 0; + break; + + case SERVER_TYPE_SYSLOG: + $server['img'] = html_print_image('images/syslog.png', true, ['title' => __('Syslog server')]); + $server['type'] = 'syslog'; + $id_modulo = 0; + break; + + case SERVER_TYPE_AUTOPROVISION: + $server['img'] = html_print_image('images/autoprovision.png', true, ['title' => __('Autoprovision server')]); + $server['type'] = 'autoprovision'; + $id_modulo = 0; + break; + + case SERVER_TYPE_MIGRATION: + $server['img'] = html_print_image('images/migration.png', true, ['title' => __('Migration server')]); + $server['type'] = 'migration'; + $id_modulo = 0; + break; + + default: + $server['img'] = ''; + $server['type'] = 'unknown'; + $id_modulo = 0; + break; + } + + if ($config['realtimestats'] == 0) { + // --------------------------------------------------------------- + // Take data from database if not realtime stats + // --------------------------------------------------------------- + $server['lag'] = db_get_sql('SELECT lag_time FROM tserver WHERE id_server = '.$server['id_server']); + $server['module_lag'] = db_get_sql('SELECT lag_modules FROM tserver WHERE id_server = '.$server['id_server']); + $server['modules'] = db_get_sql('SELECT my_modules FROM tserver WHERE id_server = '.$server['id_server']); + $server['modules_total'] = db_get_sql('SELECT total_modules_running FROM tserver WHERE id_server = '.$server['id_server']); + } else { + // --------------------------------------------------------------- + // Take data in realtime + // --------------------------------------------------------------- + $server['module_lag'] = 0; + $server['lag'] = 0; + + // Inventory server + if ($server['server_type'] == SERVER_TYPE_INVENTORY) { + // Get modules exported by this server + $server['modules'] = db_get_sql("SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente AND tagente.server_name = '".$server['name']."'"); + + // Get total exported modules + $server['modules_total'] = db_get_sql('SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) FROM tagente, tagent_module_inventory WHERE tagente.disabled=0 AND tagent_module_inventory.id_agente = tagente.id_agente'); + + $interval_esc = db_escape_key_identifier('interval'); + + // Get the module lag + $server['module_lag'] = db_get_sql( + 'SELECT COUNT(tagent_module_inventory.id_agent_module_inventory) AS module_lag FROM tagente, tagent_module_inventory WHERE utimestamp > 0 AND tagent_module_inventory.id_agente = tagente.id_agente - AND tagent_module_inventory." . $interval_esc . " > 0 - AND tagente.server_name = '" . $server["name"] . "' - AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory." . $interval_esc . " * 10) - AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory." . $interval_esc); - - // Get the lag - $server["lag"] = db_get_sql ("SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory." . $interval_esc . ") + AND tagent_module_inventory.'.$interval_esc." > 0 + AND tagente.server_name = '".$server['name']."' + AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.".$interval_esc.' * 10) + AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.'.$interval_esc + ); + + // Get the lag + $server['lag'] = db_get_sql( + 'SELECT AVG(UNIX_TIMESTAMP() - utimestamp - tagent_module_inventory.'.$interval_esc.') FROM tagente, tagent_module_inventory WHERE utimestamp > 0 AND tagent_module_inventory.id_agente = tagente.id_agente - AND tagent_module_inventory." . $interval_esc . " > 0 - AND tagente.server_name = '" . $server["name"] . "' - AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory." . $interval_esc . " * 10) - AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory." . $interval_esc); - // Export server - } - else if ($server["server_type"] == SERVER_TYPE_EXPORT) { - - // Get modules exported by this server - $server["modules"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tserver_export WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export = tserver_export.id AND tserver_export.id_export_server = " . $server["id_server"]); - - // Get total exported modules - $server["modules_total"] = db_get_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export != 0"); - - $server["lag"] = 0; - $server["module_lag"] = 0; - - } - // Recon server - else if ($server["server_type"] == SERVER_TYPE_RECON) { - - $server["name"] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view&server_id='.$server["id_server"].'">'.$server["name"].'</a>'; - - //Total jobs running on this recon server - $server["modules"] = db_get_sql ("SELECT COUNT(id_rt) + AND tagent_module_inventory.'.$interval_esc." > 0 + AND tagente.server_name = '".$server['name']."' + AND (UNIX_TIMESTAMP() - utimestamp) < (tagent_module_inventory.".$interval_esc.' * 10) + AND (UNIX_TIMESTAMP() - utimestamp) > tagent_module_inventory.'.$interval_esc + ); + // Export server + } else if ($server['server_type'] == SERVER_TYPE_EXPORT) { + // Get modules exported by this server + $server['modules'] = db_get_sql('SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tserver_export WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export = tserver_export.id AND tserver_export.id_export_server = '.$server['id_server']); + + // Get total exported modules + $server['modules_total'] = db_get_sql('SELECT COUNT(tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_export != 0'); + + $server['lag'] = 0; + $server['module_lag'] = 0; + } + // Recon server + else if ($server['server_type'] == SERVER_TYPE_RECON) { + $server['name'] = '<a href="index.php?sec=estado&sec2=operation/servers/recon_view&server_id='.$server['id_server'].'">'.$server['name'].'</a>'; + + // Total jobs running on this recon server + $server['modules'] = db_get_sql( + 'SELECT COUNT(id_rt) FROM trecon_task - WHERE id_recon_server = ".$server["id_server"]); - - //Total recon jobs (all servers) - $server["modules_total"] = db_get_sql ("SELECT COUNT(status) FROM trecon_task"); - - //Lag (take average active time of all active tasks) - $server["module_lag"] = 0; - - switch ($config["dbtype"]) { - case "mysql": - $server["lag"] = db_get_sql ("SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - case "postgresql": - $server["lag"] = db_get_sql ("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - case "oracle": - $server["lag"] = db_get_sql ("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - - $server["module_lag"] = db_get_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) > (utimestamp + interval_sweep) AND id_recon_server = ".$server["id_server"]); - break; - } - } - else { - - // --------------------------------------------------------------- - // Data, Plugin, WMI, Network and Others - - $server["modules"] = db_get_sql ("SELECT count(tagente_estado.id_agente_modulo) FROM tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = ".$server["id_server"]); - - $server["modules_total"] = db_get_sql ("SELECT count(tagente_estado.id_agente_modulo) FROM tserver, tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = tserver.id_server AND tserver.server_type = ".$server["server_type"]); - - // Remote servers LAG Calculation (server_type != 0) - if ($server["server_type"] != 0) { - switch ($config["dbtype"]) { - case "mysql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + WHERE id_recon_server = '.$server['id_server'] + ); + + // Total recon jobs (all servers) + $server['modules_total'] = db_get_sql('SELECT COUNT(status) FROM trecon_task'); + + // Lag (take average active time of all active tasks) + $server['module_lag'] = 0; + + switch ($config['dbtype']) { + case 'mysql': + $server['lag'] = db_get_sql('SELECT UNIX_TIMESTAMP() - utimestamp from trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + + $server['module_lag'] = db_get_sql('SELECT COUNT(id_rt) FROM trecon_task WHERE UNIX_TIMESTAMP() > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + break; + + case 'postgresql': + $server['lag'] = db_get_sql("SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp from trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server['id_server']); + + $server['module_lag'] = db_get_sql("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil(date_part('epoch', CURRENT_TIMESTAMP)) > (utimestamp + interval_sweep) AND id_recon_server = ".$server['id_server']); + break; + + case 'oracle': + $server['lag'] = db_get_sql("SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp from trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + + $server['module_lag'] = db_get_sql("SELECT COUNT(id_rt) FROM trecon_task WHERE ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) > (utimestamp + interval_sweep) AND id_recon_server = '.$server['id_server']); + break; + } + } else { + // --------------------------------------------------------------- + // Data, Plugin, WMI, Network and Others + $server['modules'] = db_get_sql('SELECT count(tagente_estado.id_agente_modulo) FROM tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = '.$server['id_server']); + + $server['modules_total'] = db_get_sql('SELECT count(tagente_estado.id_agente_modulo) FROM tserver, tagente_estado, tagente_modulo, tagente WHERE tagente.disabled=0 AND tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_estado.running_by = tserver.id_server AND tserver.server_type = '.$server['server_type']); + + // Remote servers LAG Calculation (server_type != 0) + if ($server['server_type'] != 0) { + switch ($config['dbtype']) { + case 'mysql': + $result = db_get_row_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND running_by = ".$server["id_server"]." + AND running_by = '.$server['id_server'].' AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) - AND (UNIX_TIMESTAMP() - utimestamp) > current_interval"); - break; - case "postgresql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND (UNIX_TIMESTAMP() - utimestamp) > current_interval' + ); + break; + + case 'postgresql': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND running_by = ".$server["id_server"]." + AND running_by = ".$server['id_server']." AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) < ( current_interval * 10) - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval"); - break; - case "oracle": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > current_interval" + ); + break; + + case 'oracle': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_modulo.disabled = 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND running_by = ".$server["id_server"]." - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) < ( current_interval * 10) - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (" . SECONDS_1DAY . ")) > current_interval"); - break; - } - } - else { - // Local/Dataserver server LAG calculation: - switch ($config["dbtype"]) { - case "mysql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND running_by = '.$server['id_server']." + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp) < ( current_interval * 10) + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) - utimestamp) * (".SECONDS_1DAY.')) > current_interval' + ); + break; + } + } else { + // Local/Dataserver server LAG calculation: + switch ($config['dbtype']) { + case 'mysql': + $result = db_get_row_sql( + 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -635,11 +703,14 @@ function servers_get_info ($id_server = -1) { AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) - AND running_by = ".$server["id_server"]." - AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)"); - break; - case "postgresql": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND running_by = '.$server['id_server'].' + AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)' + ); + break; + + case 'postgresql': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -648,11 +719,14 @@ function servers_get_info ($id_server = -1) { AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) < ( current_interval * 10) - AND running_by = ".$server["id_server"]." - AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)"); - break; - case "oracle": - $result = db_get_row_sql ("SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente + AND running_by = ".$server['id_server']." + AND (ceil(date_part('epoch', CURRENT_TIMESTAMP)) - utimestamp) > (current_interval * 1.1)" + ); + break; + + case 'oracle': + $result = db_get_row_sql( + "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.")) - utimestamp - current_interval) AS lag FROM tagente_estado, tagente_modulo, tagente WHERE utimestamp > 0 AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente @@ -660,52 +734,51 @@ function servers_get_info ($id_server = -1) { AND tagente_modulo.id_tipo_modulo < 5 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND current_interval > 0 - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) < ( current_interval * 10) - AND running_by = ".$server["id_server"]." - AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (" . SECONDS_1DAY . ")) - utimestamp) > (current_interval * 1.1)"); - break; - } - } - - // Lag over current_interval * 2 is not lag, it's a timed out module - - if (!empty ($result["lag"])) { - $server["lag"] = $result["lag"]; - } - - if (!empty ($result["module_lag"])) { - $server["module_lag"] = $result["module_lag"]; - } - } - } // Take data for realtime mode - - if (isset($server["module_lag"])) - $server["lag_txt"] = - ($server["lag"] == 0 ? - '-' - : - human_time_description_raw($server["lag"])) . " / " . $server["module_lag"]; - else - $server["lag_txt"] = ""; - - if ($server["modules_total"] > 0) { - $server["load"] = round ($server["modules"] / $server["modules_total"] * 100); - } - else { - $server["load"] = 0; - } - - //Push the raw data on the return stack - $return[$server["id_server"]] = $server; - } // Main foreach - - return $return; + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp) < ( current_interval * 10) + AND running_by = '.$server['id_server']." + AND (ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - utimestamp) > (current_interval * 1.1)' + ); + break; + } + } + + // Lag over current_interval * 2 is not lag, it's a timed out module + if (!empty($result['lag'])) { + $server['lag'] = $result['lag']; + } + + if (!empty($result['module_lag'])) { + $server['module_lag'] = $result['module_lag']; + } + } + } //end if + + if (isset($server['module_lag'])) { + $server['lag_txt'] = ($server['lag'] == 0 ? '-' : human_time_description_raw($server['lag'])).' / '.$server['module_lag']; + } else { + $server['lag_txt'] = ''; + } + + if ($server['modules_total'] > 0) { + $server['load'] = round(($server['modules'] / $server['modules_total'] * 100)); + } else { + $server['load'] = 0; + } + + // Push the raw data on the return stack + $return[$server['id_server']] = $server; + } //end foreach + + return $return; } -function servers_get_servers_type($type) { - return db_get_all_rows_filter('tserver', array('server_type' => $type)); + +function servers_get_servers_type($type) +{ + return db_get_all_rows_filter('tserver', ['server_type' => $type]); } + /** * Get the server name. * @@ -713,41 +786,46 @@ function servers_get_servers_type($type) { * * @return string Name of the given server */ -function servers_get_name ($id_server) { - return (string) db_get_value ('name', 'tserver', 'id_server', (int) $id_server); +function servers_get_name($id_server) +{ + return (string) db_get_value('name', 'tserver', 'id_server', (int) $id_server); } + /** * Get the presence of .conf and .md5 into remote_config dir - * + * * @param string Agent name - * + * * @return true if files exist and are writable */ -function servers_check_remote_config ($server_name) { - global $config; - - $server_md5 = md5 ($server_name, false); - - $filenames = array(); - $filenames['md5'] = io_safe_output($config["remote_config"]) - . "/md5/" . $server_md5 . ".srv.md5"; - $filenames['conf'] = io_safe_output($config["remote_config"]) - . "/conf/" . $server_md5 . ".srv.conf"; - - if (! isset ($filenames['conf'])) - return false; - if (! isset ($filenames['md5'])) - return false; - - return (file_exists ($filenames['conf']) - && is_writable ($filenames['conf']) - && file_exists ($filenames['md5']) - && is_writable ($filenames['md5'])); +function servers_check_remote_config($server_name) +{ + global $config; + + $server_md5 = md5($server_name, false); + + $filenames = []; + $filenames['md5'] = io_safe_output($config['remote_config']).'/md5/'.$server_md5.'.srv.md5'; + $filenames['conf'] = io_safe_output($config['remote_config']).'/conf/'.$server_md5.'.srv.conf'; + + if (! isset($filenames['conf'])) { + return false; + } + + if (! isset($filenames['md5'])) { + return false; + } + + return (file_exists($filenames['conf']) + && is_writable($filenames['conf']) + && file_exists($filenames['md5']) + && is_writable($filenames['md5'])); } + /** * Return a string containing image tag for a given target id (server) * TODO: Make this print_servertype_icon and move to functions_ui.php. Make XHTML compatible. Make string translatable @@ -758,72 +836,87 @@ function servers_check_remote_config ($server_name) { * * @return string Fully formatted IMG HTML tag with icon */ -function servers_show_type ($id) { - global $config; - - switch ($id) { - case 1: - return html_print_image("images/database.png", true, array("title" => get_product_name() . " Data server")); - break; - case 2: - return html_print_image("images/network.png", true, array("title" => get_product_name() . " Network server")); - break; - case 4: - return html_print_image("images/plugin.png", true, array("title" => get_product_name() . " Plugin server")); - break; - case 5: - return html_print_image("images/chart_bar.png", true, array("title" => get_product_name() . " Prediction server")); - break; - case 6: - return html_print_image("images/wmi.png", true, array("title" => get_product_name() . " WMI server")); - break; - case 7: - return html_print_image("images/server_web.png", true, array("title" => get_product_name() . " WEB server")); - break; - case 8: - return html_print_image("images/module-wux.png", true, array("title" => get_product_name() . " WUX server")); - break; - default: - return "--"; - break; - } +function servers_show_type($id) +{ + global $config; + + switch ($id) { + case 1: + return html_print_image('images/database.png', true, ['title' => get_product_name().' Data server']); + + break; + case 2: + return html_print_image('images/network.png', true, ['title' => get_product_name().' Network server']); + + break; + case 4: + return html_print_image('images/plugin.png', true, ['title' => get_product_name().' Plugin server']); + + break; + case 5: + return html_print_image('images/chart_bar.png', true, ['title' => get_product_name().' Prediction server']); + + break; + case 6: + return html_print_image('images/wmi.png', true, ['title' => get_product_name().' WMI server']); + + break; + case 7: + return html_print_image('images/server_web.png', true, ['title' => get_product_name().' WEB server']); + + break; + case 8: + return html_print_image('images/module-wux.png', true, ['title' => get_product_name().' WUX server']); + + break; + default: + return '--'; + break; + } } + /** * Get the numbers of servers up. * * This check assumes that server_keepalive should be at least 15 minutes. * - * @return int The number of servers alive. + * @return integer The number of servers alive. */ -function servers_check_status () { - global $config; - - switch ($config["dbtype"]) { - case "mysql": - $sql = "SELECT COUNT(id_server) +function servers_check_status() +{ + global $config; + + switch ($config['dbtype']) { + case 'mysql': + $sql = 'SELECT COUNT(id_server) FROM tserver WHERE status = 1 - AND keepalive > NOW() - INTERVAL server_keepalive*2 SECOND"; - break; - case "postgresql": - $sql = "SELECT COUNT(id_server) + AND keepalive > NOW() - INTERVAL server_keepalive*2 SECOND'; + break; + + case 'postgresql': + $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > NOW() - INTERVAL 'server_keepalive*2 SECOND'"; - break; - case "oracle": - $sql = "SELECT COUNT(id_server) + break; + + case 'oracle': + $sql = "SELECT COUNT(id_server) FROM tserver WHERE status = 1 AND keepalive > systimestamp - INTERVAL 'server_keepalive*2' SECOND"; - break; - } - $status = (int) db_get_sql ($sql); //Cast as int will assure a number value - // This function should just ack of server down, not set it down. - return $status; + break; + } + + $status = (int) db_get_sql($sql); + // Cast as int will assure a number value + // This function should just ack of server down, not set it down. + return $status; } + /** * @deprecated use servers_get_info instead * Get statistical information for a given server @@ -832,8 +925,66 @@ function servers_check_status () { * * @return array Server info array */ -function servers_get_status ($id_server) { - $serverinfo = servers_get_info ($id_server); - return $serverinfo[$id_server]; +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_RECON: + return __('Discovery server'); + + case SERVER_TYPE_SYSLOG: + return __('Syslog server'); + + default: + return __('N/A'); + } } -?> From 8d17c9e0d0d02a4ca8b543f1e38647f1772be009 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 4 Feb 2019 19:32:54 +0100 Subject: [PATCH 021/262] minor plugintools fix Former-commit-id: d7d43777b952b483a733c7ac92776f12b5c17e62 --- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 6b80d054d7..b4526ab68f 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -163,6 +163,8 @@ sub csv_to_obj { @hr_headers = map { $_ =~ s/\"//g; trim($_); } @hr_headers; foreach my $line (@lines) { + next if empty($line); + my $i = 0; my %hr = map { $_ =~ s/\"//g; $hr_headers[$i++] => trim($_) } split /,/, $line; From 0b72571c7cb47056711365750f9035012ab88af6 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Tue, 5 Feb 2019 12:53:57 +0100 Subject: [PATCH 022/262] Added NOT IN in format mysql filter Former-commit-id: f3a8cdd6923834443ed7223d1e6ad7776b861184 --- pandora_console/include/db/mysql.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 71fed08dd9..092b01af2d 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -616,6 +616,7 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix $i = 1; $max = count ($values); foreach ($values as $field => $value) { + $negative = false; if (is_numeric ($field)) { /* User provide the exact operation to do */ $query .= $value; @@ -626,7 +627,10 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix $i++; continue; } - + if ($field[0] == "!") { + $negative = true; + $field = substr($field, 1); + } if ($field[0] != "`") { //If the field is as <table>.<field>, don't scape. if (strstr($field, '.') === false) @@ -643,7 +647,8 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix $query .= sprintf ("%s = %f", $field, $value); } elseif (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 === "") { From 881125776273a58a661bf584064f90de063478bc Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Tue, 5 Feb 2019 13:36:16 +0100 Subject: [PATCH 023/262] Popup to add groups and sources to global notification configuration Former-commit-id: 481812290ea1d1446aa7378ab6a935139483c8a0 --- .../godmode/setup/setup_notifications.php | 70 ++++++++++++++++ .../include/functions_notifications.php | 81 +++++++++++++++++-- pandora_console/include/styles/pandora.css | 20 ++++- 3 files changed, 165 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 06e6a85b63..8cb4152366 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -18,6 +18,8 @@ // Load global vars global $config; +require_once ($config['homedir'] . '/include/functions_notifications.php'); + check_login (); if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { @@ -27,6 +29,22 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user } // Actions +// AJAX +if (get_parameter('get_selection_two_ways_form', 0)) { + $source_id = get_parameter('source_id', ''); + $users = get_parameter('users', ''); + $id = get_notification_source_id($source_id); + $info_selec = $users === "users" + ? notifications_get_user_source_not_configured($id) + : notifications_get_group_source_not_configured($id); + + echo notifications_print_two_ways_select( + $info_selec, + $users, + $source_id + ); + return; +} if (get_parameter('update_config', 0)) { $res_global = array_reduce(notifications_get_all_sources(), function($carry, $source){ $id = notifications_desc_to_id($source['description']); @@ -94,4 +112,56 @@ function notifications_disable_source(event) { document.getElementById('multi-' + select + '-' + id).disabled = is_checked; }); } + +// Open a dialog with selector of source elements. +function add_source_dialog(users, source_id) { + // Display the dialog + var dialog_id = 'global_config_notifications_dialog_add-' + users + '-' + source_id; + var not_dialog = document.createElement('div'); + not_dialog.setAttribute('class', 'global_config_notifications_dialog_add'); + not_dialog.setAttribute('id', dialog_id); + document.body.appendChild(not_dialog); + $("#" + dialog_id).dialog({ + resizable: false, + draggable: true, + modal: true, + dialogClass: "global_config_notifications_dialog_add_wrapper", + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: true, + modal: true + }); + + jQuery.post ("ajax.php", + {"page" : "godmode/setup/setup_notifications", + "get_selection_two_ways_form" : 1, + "users" : users, + "source_id" : source_id + }, + function (data, status) { + not_dialog.innerHTML = data + }, + "html" + ); +} + +// Move from selected and not selected source elements. +function notifications_modify_two_ways_element (id, source_id, operation) { + var index_sufix = 'multi-' + id + '-' + source_id; + var start_id = operation === 'add' ? 'all-' : 'selected-'; + var end_id = operation !== 'add' ? 'all-' : 'selected-'; + var select = document.getElementById( + start_id + index_sufix + ); + var select_end = document.getElementById( + end_id + index_sufix + ); + for (var i = 0; i < select.options.length; i++) { + if(select.options[i].selected ==true){ + select_end.appendChild(select.options[i]); + } + } +} </script> diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 24013b92fd..cd8d977053 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -195,16 +195,37 @@ function notifications_get_user_sources_for_select($source_id) { * @return array with the group id in keys and group name in value */ function notifications_get_group_sources_for_select($source_id) { + $groups = notifications_get_group_sources ( + array('id_source' => $source_id), + array('id_group') + ); + return index_array($groups, 'id_group', 'name'); +} + +/** + * Get the group sources + * + * @param array $filter Filter of sql query. + */ +function notifications_get_group_sources ($filter = array(), $fields = array()) { + // Get only the tnotifications_source_group fields in addition to group name. + if (empty($fields)) $fields[] = "tnsg.*"; + $fields = array_map(function($field) { + if (!preg_match("/^tnsg./", $field)) $field = "tnsg.{$field}"; + return $field; + }, $fields); + + // Get groups. $groups = db_get_all_rows_filter( 'tnotification_source_group tnsg LEFT JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo', - array('id_source' => $source_id), - array ('tnsg.id_group', 'IFNULL(tg.nombre, "All") AS name') + $filter, + array_merge ($fields, array('IFNULL(tg.nombre, "All") AS name')) ); + // If fails or no one is selected, return empty array if ($groups === false) return array(); - - return index_array($groups, 'id_group', 'name'); + return $groups; } /** @@ -254,6 +275,36 @@ function notifications_add_group_to_source ($source_id, $groups) { return $res; } +/** + * Get the groups that not own to a source and, for that reason, they can be + * added to the source. + * + * @param int $source_id Source id. + * @return array Indexed by id group all selectable groups. + */ +function notifications_get_group_source_not_configured ($source_id) { + $groups_selected = notifications_get_group_sources_for_select($source_id); + $all_groups = users_get_groups_for_select(false, "AR", false, true, $groups_selected); + return array_diff($all_groups, $groups_selected); +} + +/** + * Get the users that not own to a source and, for that reason, they can be + * added to the source. + * + * @param int $source_id + * @return array Indexed by id user, all selectable users. + */ +function notifications_get_user_source_not_configured ($source_id) { + $users_selected = array_keys(notifications_get_user_sources_for_select($source_id)); + $users = get_users( + 'id_user', + array('!id_user' => $users_selected), + array('id_user') + ); + return index_array($users, 'id_user', 'id_user'); +} + /** * Print the notification ball to see unread messages * @@ -365,9 +416,29 @@ function notifications_print_source_select_box($info_selec, $id, $source_id, $di $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true,'', $disabled); $html_select .= " </div>"; $html_select .= " <div class='global-notifications-icons'>"; - $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title)); + $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')")); $html_select .= html_print_image('images/input_delete.png', true, array('title' => $delete_title)); $html_select .= " </div>"; $html_select .= "</div>"; return $html_select; } + +/** + * Print the select with right and left arrows to select new sources + * (groups or users). + * + * @param array $info_selec Array with source info. + * @param string $users users|groups. + * @param source $source_id Source id. + * @return string HTML with the select code. + */ +function notifications_print_two_ways_select($info_selec, $users, $source_id) { + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true,''); + $html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>"; + $html_select .= html_print_image('images/darrowright.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')")); + $html_select .= html_print_image('images/darrowleft.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')")); + $html_select .= "</div>"; + $html_select .= html_print_select(true, "selected-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, ''); + + return $html_select; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index aee1b9dc5d..31ca3b865a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4953,7 +4953,8 @@ div#dialog_messages table th:last-child { margin: 0; } -.global-config-notification-single-selector { +.global-config-notification-single-selector, +.global_config_notifications_dialog_add select { display: flex; width: 100%; padding: 0 10px; @@ -4970,6 +4971,23 @@ div#dialog_messages table th:last-child { justify-content: flex-end; } +.global_config_notifications_dialog_add { + display: flex; + flex-direction: row; + margin: 8px; +} + +.global_config_notifications_two_ways_form_arrows { + display: flex; + flex-flow: column; + justify-content: center; + margin: 0 5px; +} + +.global_config_notifications_two_ways_form_arrows img { + margin: 15px 0; +} + /* --- JQUERY-UI --- */ .ui-button-text-only .ui-button-text { font-family: "nunito", sans-serif; From 68bdbd511c97cd7094c97fdd3a20e72325b0a05b Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Tue, 5 Feb 2019 13:46:16 +0100 Subject: [PATCH 024/262] Fixed add consecutive source elements Former-commit-id: 7763da94a48442953879538d42f36673fbdec752 --- pandora_console/godmode/setup/setup_notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 8cb4152366..e5700fedef 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -158,7 +158,7 @@ function notifications_modify_two_ways_element (id, source_id, operation) { var select_end = document.getElementById( end_id + index_sufix ); - for (var i = 0; i < select.options.length; i++) { + for (var i = select.options.length - 1; i >= 0; i--) { if(select.options[i].selected ==true){ select_end.appendChild(select.options[i]); } From b4f3e94b13e6405fd34884544af2770d38abcb7f Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Tue, 5 Feb 2019 15:31:08 +0100 Subject: [PATCH 025/262] Clean dialog box on creation Former-commit-id: 824f7a968b2e196d6df98b9f5dbd48f21a7c9859 --- pandora_console/godmode/setup/setup_notifications.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index e5700fedef..373e1a7322 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -117,6 +117,10 @@ function notifications_disable_source(event) { function add_source_dialog(users, source_id) { // Display the dialog var dialog_id = 'global_config_notifications_dialog_add-' + users + '-' + source_id; + // Clean id element. + var previous_dialog = document.getElementById(dialog_id); + if (previous_dialog !== null) previous_dialog.remove(); + // Create or recreate the content. var not_dialog = document.createElement('div'); not_dialog.setAttribute('class', 'global_config_notifications_dialog_add'); not_dialog.setAttribute('id', dialog_id); From 7df3fe2dac62a51520282454b65ceab66ec2ff7a Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Tue, 5 Feb 2019 17:40:44 +0100 Subject: [PATCH 026/262] Added functionallity to Add element on notification global config Former-commit-id: b51cf2d5079019a69fd7c4344dfcff2bf38147db --- .../godmode/setup/setup_notifications.php | 68 +++++++++++++++++-- .../include/functions_notifications.php | 32 ++++++++- pandora_console/include/styles/pandora.css | 3 +- 3 files changed, 95 insertions(+), 8 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 373e1a7322..8233b84028 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -28,8 +28,7 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user return; } -// Actions -// AJAX +// AJAX actions. if (get_parameter('get_selection_two_ways_form', 0)) { $source_id = get_parameter('source_id', ''); $users = get_parameter('users', ''); @@ -45,6 +44,22 @@ if (get_parameter('get_selection_two_ways_form', 0)) { ); return; } +if (get_parameter('add_source_to_database', 0)) { + $source_id = get_parameter('source_id', ''); + $users = get_parameter('users', ''); + $elements = get_parameter('elements', array()); + $id = get_notification_source_id($source_id); + $res = $users === "users" + ? notifications_add_users_to_source($id, $elements) + : notifications_add_group_to_source($id, $elements); + $result = array( + 'result' => $res + ); + echo json_encode($result); + return; +} + +// Form actions. if (get_parameter('update_config', 0)) { $res_global = array_reduce(notifications_get_all_sources(), function($carry, $source){ $id = notifications_desc_to_id($source['description']); @@ -113,23 +128,32 @@ function notifications_disable_source(event) { }); } +// Get index of two ways element dialog. +function notifications_two_ways_element_get_dialog (id, source_id) { + return 'global_config_notifications_dialog_add-' + id + '-' + source_id; +} +// Get index of two ways element form. +function notifications_two_ways_element_get_sufix (id, source_id) { + return 'multi-' + id + '-' + source_id; +} + // Open a dialog with selector of source elements. function add_source_dialog(users, source_id) { // Display the dialog - var dialog_id = 'global_config_notifications_dialog_add-' + users + '-' + source_id; + var dialog_id = notifications_two_ways_element_get_dialog(users, source_id); // Clean id element. var previous_dialog = document.getElementById(dialog_id); if (previous_dialog !== null) previous_dialog.remove(); // Create or recreate the content. var not_dialog = document.createElement('div'); - not_dialog.setAttribute('class', 'global_config_notifications_dialog_add'); + not_dialog.setAttribute('class', 'global_config_notifications_dialog_add_wrapper'); not_dialog.setAttribute('id', dialog_id); document.body.appendChild(not_dialog); $("#" + dialog_id).dialog({ resizable: false, draggable: true, modal: true, - dialogClass: "global_config_notifications_dialog_add_wrapper", + dialogClass: "global_config_notifications_dialog_add_full", overlay: { opacity: 0.5, background: "black" @@ -153,7 +177,7 @@ function add_source_dialog(users, source_id) { // Move from selected and not selected source elements. function notifications_modify_two_ways_element (id, source_id, operation) { - var index_sufix = 'multi-' + id + '-' + source_id; + var index_sufix = notifications_two_ways_element_get_sufix (id, source_id); var start_id = operation === 'add' ? 'all-' : 'selected-'; var end_id = operation !== 'add' ? 'all-' : 'selected-'; var select = document.getElementById( @@ -168,4 +192,36 @@ function notifications_modify_two_ways_element (id, source_id, operation) { } } } + +// Add elements to database and close dialog +function notifications_add_source_element_to_database(id, source_id) { + var index = 'selected-' + notifications_two_ways_element_get_sufix (id, source_id); + var select = document.getElementById(index); + var selected = []; + for (var i = select.options.length - 1; i >= 0; i--) { + selected.push(select.options[i].value); + } + jQuery.post ("ajax.php", + {"page" : "godmode/setup/setup_notifications", + "add_source_to_database" : 1, + "users" : id, + "source_id" : source_id, + "elements": selected + }, + function (data, status) { + if (data.result) { + // Append to other element + var out_select = document.getElementById('multi-' + id + '-' + source_id); + for (var i = select.options.length - 1; i >= 0; i--) { + out_select.appendChild(select.options[i]); + } + // Close the dialog + $("#" + notifications_two_ways_element_get_dialog(id, source_id)).dialog("close"); + } else { + console.log("Cannot update element."); + } + }, + "json" + ); +} </script> diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index cd8d977053..44bb0fb12e 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -265,7 +265,8 @@ function notifications_add_group_to_source ($source_id, $groups) { // Insert into database all groups passed $res = true; foreach ($groups as $group) { - $res = db_process_sql_insert( + if (empty($group)) continue; + $res = $res && db_process_sql_insert( 'tnotification_source_group', array( 'id_group' => $group, @@ -275,6 +276,32 @@ function notifications_add_group_to_source ($source_id, $groups) { return $res; } +/** + * Insert a set of users to notification source + * + * @param int Source id + * @param array Id of users to be deleted + * + * @return bool True if success. False otherwise. + */ + function notifications_add_users_to_source ($source_id, $users) { + // Source id is mandatory + if (!isset($source_id)) return false; + + // Insert into database all groups passed + $res = true; + foreach ($users as $user) { + if (empty($user)) continue; + $res = $res && db_process_sql_insert( + 'tnotification_source_user', + array( + 'id_user' => $user, + 'id_source' => $source_id) + ) !== false; + } + return $res; +} + /** * Get the groups that not own to a source and, for that reason, they can be * added to the source. @@ -433,12 +460,15 @@ function notifications_print_source_select_box($info_selec, $id, $source_id, $di * @return string HTML with the select code. */ function notifications_print_two_ways_select($info_selec, $users, $source_id) { + $html_select = "<div class='global_config_notifications_dialog_add'>"; $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true,''); $html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>"; $html_select .= html_print_image('images/darrowright.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')")); $html_select .= html_print_image('images/darrowleft.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')")); $html_select .= "</div>"; $html_select .= html_print_select(true, "selected-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, ''); + $html_select .= "</div>"; + $html_select .= html_print_button(__('Add'), 'Add', false, "notifications_add_source_element_to_database('$users', '$source_id')", "class='sub add'", true); return $html_select; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 31ca3b865a..1d4e4af4c0 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4965,7 +4965,8 @@ div#dialog_messages table th:last-child { width: 99%; } -.global-config-notification-single-selector :last-child { +.global-config-notification-single-selector :last-child, +.global_config_notifications_dialog_add_wrapper { flex-direction: column; display: flex; justify-content: flex-end; From ddcf0bbd16c6cdd3e15dd394111d75c9c17779be Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Tue, 5 Feb 2019 18:14:10 +0100 Subject: [PATCH 027/262] Added deletion on global notification config Former-commit-id: 2356bbe374e5decf929cfaaf2fc4776611b0652d --- .../godmode/setup/setup_notifications.php | 86 ++++++++++++++----- .../include/functions_notifications.php | 24 +++++- 2 files changed, 88 insertions(+), 22 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 8233b84028..bf842951aa 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -29,11 +29,13 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user } // AJAX actions. +$source_id = get_parameter('source_id', ''); +$users = get_parameter('users', ''); +$elements = get_parameter('elements', array()); +$id = empty($source_id) ? 0 : get_notification_source_id($source_id); +$is_users = $users === "users"; if (get_parameter('get_selection_two_ways_form', 0)) { - $source_id = get_parameter('source_id', ''); - $users = get_parameter('users', ''); - $id = get_notification_source_id($source_id); - $info_selec = $users === "users" + $info_selec = $is_users ? notifications_get_user_source_not_configured($id) : notifications_get_group_source_not_configured($id); @@ -45,11 +47,7 @@ if (get_parameter('get_selection_two_ways_form', 0)) { return; } if (get_parameter('add_source_to_database', 0)) { - $source_id = get_parameter('source_id', ''); - $users = get_parameter('users', ''); - $elements = get_parameter('elements', array()); - $id = get_notification_source_id($source_id); - $res = $users === "users" + $res = $is_users ? notifications_add_users_to_source($id, $elements) : notifications_add_group_to_source($id, $elements); $result = array( @@ -58,6 +56,16 @@ if (get_parameter('add_source_to_database', 0)) { echo json_encode($result); return; } +if (get_parameter('remove_source_on_database', 0)) { + $res = $is_users + ? notifications_remove_users_from_source($id, $elements) + : notifications_remove_group_from_source($id, $elements); + $result = array( + 'result' => $res + ); + echo json_encode($result); + return; +} // Form actions. if (get_parameter('update_config', 0)) { @@ -118,25 +126,26 @@ function notifications_get_source_id(id) { return matched[1]; } +// Get index of two ways element dialog. +function notifications_two_ways_element_get_dialog (id, source_id) { + return 'global_config_notifications_dialog_add-' + id + '-' + source_id; +} + +// Get index of two ways element form. +function notifications_two_ways_element_get_sufix (id, source_id) { + return 'multi-' + id + '-' + source_id; +} + // Disable or enable the select seeing the checked value of notify all users function notifications_disable_source(event) { var id = notifications_get_source_id(event.target.id); var is_checked = document.getElementById(event.target.id).checked; var selectors = ['groups', 'users']; selectors.map(function (select) { - document.getElementById('multi-' + select + '-' + id).disabled = is_checked; + document.getElementById(notifications_two_ways_element_get_sufix(select, id)).disabled = is_checked; }); } -// Get index of two ways element dialog. -function notifications_two_ways_element_get_dialog (id, source_id) { - return 'global_config_notifications_dialog_add-' + id + '-' + source_id; -} -// Get index of two ways element form. -function notifications_two_ways_element_get_sufix (id, source_id) { - return 'multi-' + id + '-' + source_id; -} - // Open a dialog with selector of source elements. function add_source_dialog(users, source_id) { // Display the dialog @@ -187,7 +196,7 @@ function notifications_modify_two_ways_element (id, source_id, operation) { end_id + index_sufix ); for (var i = select.options.length - 1; i >= 0; i--) { - if(select.options[i].selected ==true){ + if(select.options[i].selected){ select_end.appendChild(select.options[i]); } } @@ -211,7 +220,9 @@ function notifications_add_source_element_to_database(id, source_id) { function (data, status) { if (data.result) { // Append to other element - var out_select = document.getElementById('multi-' + id + '-' + source_id); + var out_select = document.getElementById( + notifications_two_ways_element_get_sufix(id, source_id) + ); for (var i = select.options.length - 1; i >= 0; i--) { out_select.appendChild(select.options[i]); } @@ -224,4 +235,37 @@ function notifications_add_source_element_to_database(id, source_id) { "json" ); } + +// Add elements to database and remove it form main select +function remove_source_elements(id, source_id) { + var index = notifications_two_ways_element_get_sufix(id, source_id); + var select = document.getElementById(index); + var selected = []; + var selected_index = []; + for (var i = select.options.length - 1; i >= 0; i--) { + if(select.options[i].selected){ + selected.push(select.options[i].value); + selected_index.push(i); + } + } + jQuery.post ("ajax.php", + {"page" : "godmode/setup/setup_notifications", + "remove_source_on_database" : 1, + "users" : id, + "source_id" : source_id, + "elements": selected + }, + function (data, status) { + if (data.result) { + // Append to other element + for (var i = selected_index.length - 1; i >= 0; i--) { + select.remove(selected_index[i]); + } + } else { + console.log("Cannot delete elements."); + } + }, + "json" + ); +} </script> diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 44bb0fb12e..9467c0ff92 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -250,6 +250,28 @@ function notifications_remove_group_from_source ($source_id, $groups) { ) !== false; } +/** + * Delete a set of users from notification source + * + * @param int Source id + * @param array Id of users to be deleted + * + * @return bool True if success. False otherwise. + */ +function notifications_remove_users_from_source ($source_id, $users) { + // Source id is mandatory + if (!isset($source_id)) return false; + + // Delete from database + return db_process_sql_delete ( + 'tnotification_source_user', + array( + 'id_user' => $users, + 'id_source' => $source_id + ) + ) !== false; +} + /** * Insert a set of groups to notification source * @@ -444,7 +466,7 @@ function notifications_print_source_select_box($info_selec, $id, $source_id, $di $html_select .= " </div>"; $html_select .= " <div class='global-notifications-icons'>"; $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')")); - $html_select .= html_print_image('images/input_delete.png', true, array('title' => $delete_title)); + $html_select .= html_print_image('images/input_delete.png', true, array('title' => $delete_title, 'onclick' => "remove_source_elements('$id', '$source_id')")); $html_select .= " </div>"; $html_select .= "</div>"; return $html_select; From 6f87b436d0c48a33fa5dd041a9fa005c350bff32 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Tue, 5 Feb 2019 18:47:41 +0100 Subject: [PATCH 028/262] minor fix Former-commit-id: 3fabf2561773365932c5d33e8bf9e42b7ed4e7f0 --- pandora_console/include/functions_servers.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index bc5fd590f3..249704fe13 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -984,6 +984,9 @@ function servers_get_server_string_name(int $server) case SERVER_TYPE_SYSLOG: return __('Syslog server'); + case SERVER_TYPE_WUX: + return __('WUX server'); + default: return __('N/A'); } From ac6b74dcdf857d01a6107cf7b9176cc90f20f04d Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Wed, 6 Feb 2019 11:36:28 +0100 Subject: [PATCH 029/262] Added new window to display user notifications config Former-commit-id: 57ba8fcd01365cedc92535d7cf71f70432a55a94 --- pandora_console/operation/menu.php | 5 + pandora_console/operation/users/user_edit.php | 51 +--------- .../operation/users/user_edit_header.php | 97 +++++++++++++++++++ .../users/user_edit_notifications.php | 24 +++++ 4 files changed, 129 insertions(+), 48 deletions(-) create mode 100644 pandora_console/operation/users/user_edit_header.php create mode 100644 pandora_console/operation/users/user_edit_notifications.php diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index d7a546a96a..42a70cf5e2 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -374,6 +374,11 @@ $sub["operation/users/user_edit"]["text"] = __('Edit my user'); $sub["operation/users/user_edit"]["id"] = 'Edit my user'; $sub["operation/users/user_edit"]["refr"] = 0; +// Users +$sub["operation/users/user_edit_notifications"]["text"] = __('Configure user notifications'); +$sub["operation/users/user_edit_notifications"]["id"] = 'Configure user notifications'; +$sub["operation/users/user_edit_notifications"]["refr"] = 0; + // ANY user can chat with other user and dogs. // Users $sub["operation/users/webchat"]["text"] = __('WebChat'); diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 1c2eb0ef2e..7613caa92e 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -13,56 +13,11 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // Load global vars global $config; -check_login (); - -enterprise_hook('open_meta_frame'); - -include_once($config['homedir'] . "/include/functions_profile.php"); -include_once($config['homedir'] . '/include/functions_users.php'); -include_once ($config['homedir'] . '/include/functions_groups.php'); -include_once ($config['homedir'] . '/include/functions_visual_map.php'); - -$meta = false; -if (enterprise_installed() && defined("METACONSOLE")) { - $meta = true; -} - -$id = get_parameter_get ("id", $config["id_user"]); // ID given as parameter -$status = get_parameter ("status", -1); // Flag to print action status message - -$user_info = get_user_info ($id); -$id = $user_info["id_user"]; //This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem) - -if ((!check_acl ($config["id_user"], users_get_groups ($id), "UM")) - AND ($id != $config["id_user"])) { - - db_pandora_audit("ACL Violation","Trying to view a user without privileges"); - require ("general/noaccess.php"); - exit; -} - -//If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info -if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) { - $view_mode = false; -} -else { - $view_mode = true; -} - -// Header -if ($meta) { - user_meta_print_header(); - $url = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit'; -} -else { - ui_print_page_header (__('User detail editor'), "images/op_workspace.png", false, "", false, ""); - $url = 'index.php?sec=workspace&sec2=operation/users/user_edit'; -} - +// Load the header +require($config['homedir'] . "/operation/users/user_edit_header.php"); // Update user info if (isset ($_GET["modified"]) && !$view_mode) { @@ -525,7 +480,7 @@ $table->rowclass[] = ''; $table->rowstyle[] = ''; $table->data[] = $data; -echo '<form name="user_mod" method="post" action="'.$url.'&modified=1&id='.$id.'&pure='.$config['pure'].'">'; +echo '<form name="user_mod" method="post" action="'.$urls['main'].'&modified=1&id='.$id.'&pure='.$config['pure'].'">'; html_print_table($table); diff --git a/pandora_console/operation/users/user_edit_header.php b/pandora_console/operation/users/user_edit_header.php new file mode 100644 index 0000000000..99e0567e57 --- /dev/null +++ b/pandora_console/operation/users/user_edit_header.php @@ -0,0 +1,97 @@ +<?php + +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas +// Please see http://pandorafms.org for full contribution list + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation for version 2. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + + +// Load global vars +global $config; + +check_login (); + +enterprise_hook('open_meta_frame'); + +include_once($config['homedir'] . "/include/functions_profile.php"); +include_once($config['homedir'] . '/include/functions_users.php'); +include_once ($config['homedir'] . '/include/functions_groups.php'); +include_once ($config['homedir'] . '/include/functions_visual_map.php'); + +$meta = false; +if (enterprise_installed() && defined("METACONSOLE")) { + $meta = true; +} + +$id = get_parameter_get ("id", $config["id_user"]); // ID given as parameter +$status = get_parameter ("status", -1); // Flag to print action status message + +$user_info = get_user_info ($id); +$id = $user_info["id_user"]; //This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem) + +if ((!check_acl ($config["id_user"], users_get_groups ($id), "UM")) + AND ($id != $config["id_user"])) { + + db_pandora_audit("ACL Violation","Trying to view a user without privileges"); + require ("general/noaccess.php"); + exit; +} + +//If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info +if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) { + $view_mode = false; +} +else { + $view_mode = true; +} + +$urls = array(); +if (is_metaconsole()) { + user_meta_print_header(); + $urls['main'] = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit'; +} +else { + $urls['main'] = "index.php?sec=workspace&sec2=operation/users/user_edit"; + $urls['notifications'] = "index.php?sec=workspace&sec2=operation/users/user_edit_notifications"; + $buttons = array( + 'main' => array( + 'active' => $_GET['sec2'] === 'operation/users/user_edit', + 'text' => + "<a href='{$urls['main']}'>". + html_print_image ( + "images/user_green.png", + true, + array ("title" => __('User management')) + ).'</a>' + ), + 'notifications' => array( + 'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications', + 'text' => + "<a href='{$urls['notifications']}'>". + html_print_image ( + "images/alerts_template.png", + true, + array ("title" => __('User notifications')) + ).'</a>' + ) + ); + + ui_print_page_header ( + __('User detail editor'), + "images/op_workspace.png", + false, + "", + false, + $buttons + ); +} + +?> \ No newline at end of file diff --git a/pandora_console/operation/users/user_edit_notifications.php b/pandora_console/operation/users/user_edit_notifications.php new file mode 100644 index 0000000000..edec0e2a6c --- /dev/null +++ b/pandora_console/operation/users/user_edit_notifications.php @@ -0,0 +1,24 @@ +<?php + +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas +// Please see http://pandorafms.org for full contribution list + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation for version 2. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Load global vars +global $config; + +// Load the header +require($config['homedir'] . "/operation/users/user_edit_header.php"); + +// TODO + +?> \ No newline at end of file From 6ddcfcbb19a07037d4503af914bd4a50ee98b0c5 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Wed, 6 Feb 2019 12:51:02 +0100 Subject: [PATCH 030/262] Fixed code style lintern Former-commit-id: d7757a56f8368761776f80f826600d601b56b6d9 --- .../godmode/setup/setup_notifications.php | 360 +++++++++--------- .../include/functions_notifications.php | 315 +++++++++------ .../operation/users/user_edit_header.php | 124 +++--- 3 files changed, 425 insertions(+), 374 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index bf842951aa..d315f14711 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -1,10 +1,9 @@ -<?php +<?php // Pandora FMS - http://pandorafms.com // ================================================== // Copyright (c) 2005-2019 Artica Soluciones Tecnologicas // Please see http://pandorafms.org for full contribution list - // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation for version 2. @@ -12,103 +11,104 @@ // 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. - // Warning: This file may be required into the metaconsole's setup - // Load global vars global $config; -require_once ($config['homedir'] . '/include/functions_notifications.php'); +require_once $config['homedir'].'/include/functions_notifications.php'; -check_login (); +check_login(); if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { db_pandora_audit('ACL Violation', 'Trying to access Setup Management'); - require ('general/noaccess.php'); + include 'general/noaccess.php'; return; } // AJAX actions. $source_id = get_parameter('source_id', ''); $users = get_parameter('users', ''); -$elements = get_parameter('elements', array()); +$elements = get_parameter('elements', []); $id = empty($source_id) ? 0 : get_notification_source_id($source_id); -$is_users = $users === "users"; +$is_users = $users === 'users'; if (get_parameter('get_selection_two_ways_form', 0)) { - $info_selec = $is_users - ? notifications_get_user_source_not_configured($id) - : notifications_get_group_source_not_configured($id); + $info_selec = $is_users ? notifications_get_user_source_not_configured($id) : notifications_get_group_source_not_configured($id); - echo notifications_print_two_ways_select( - $info_selec, - $users, - $source_id - ); - return; + echo notifications_print_two_ways_select( + $info_selec, + $users, + $source_id + ); + return; } + if (get_parameter('add_source_to_database', 0)) { - $res = $is_users - ? notifications_add_users_to_source($id, $elements) - : notifications_add_group_to_source($id, $elements); - $result = array( - 'result' => $res - ); - echo json_encode($result); - return; + $res = $is_users ? notifications_add_users_to_source($id, $elements) : notifications_add_group_to_source($id, $elements); + $result = ['result' => $res]; + echo json_encode($result); + return; } + if (get_parameter('remove_source_on_database', 0)) { - $res = $is_users - ? notifications_remove_users_from_source($id, $elements) - : notifications_remove_group_from_source($id, $elements); - $result = array( - 'result' => $res - ); - echo json_encode($result); - return; + $res = $is_users ? notifications_remove_users_from_source($id, $elements) : notifications_remove_group_from_source($id, $elements); + $result = ['result' => $res]; + echo json_encode($result); + return; } // Form actions. if (get_parameter('update_config', 0)) { - $res_global = array_reduce(notifications_get_all_sources(), function($carry, $source){ - $id = notifications_desc_to_id($source['description']); - if (empty($id)) return false; - $enable_value = switch_to_int(get_parameter("enable-$id")); - $mail_value = (int)get_parameter("mail-{$id}", 0); - $user_value = (int)get_parameter("user-{$id}", 0); - $postpone_value = (int)get_parameter("postpone-{$id}", 0); - $all_users = (int)get_parameter("all-{$id}", 0); - $res = db_process_sql_update( - 'tnotification_source', - array( - 'enabled' => $enable_value, - 'user_editable' => $user_value, - 'also_mail' => $mail_value, - 'max_postpone_time' => $postpone_value - ), - array('id' => $source['id']) - ); - $all_users_res = $all_users - ? notifications_add_group_to_source($source['id'], array(0)) - : notifications_remove_group_from_source($source['id'], array(0)); - return $all_users_res && $res && $carry; - }, true); + $res_global = array_reduce( + notifications_get_all_sources(), + function ($carry, $source) { + $id = notifications_desc_to_id($source['description']); + if (empty($id)) { + return false; + } + + $enable_value = switch_to_int(get_parameter("enable-$id")); + $mail_value = (int) get_parameter("mail-{$id}", 0); + $user_value = (int) get_parameter("user-{$id}", 0); + $postpone_value = (int) get_parameter("postpone-{$id}", 0); + $all_users = (int) get_parameter("all-{$id}", 0); + $res = db_process_sql_update( + 'tnotification_source', + [ + 'enabled' => $enable_value, + 'user_editable' => $user_value, + 'also_mail' => $mail_value, + 'max_postpone_time' => $postpone_value, + ], + ['id' => $source['id']] + ); + $all_users_res = $all_users ? notifications_add_group_to_source($source['id'], [0]) : notifications_remove_group_from_source($source['id'], [0]); + return $all_users_res && $res && $carry; + }, + true + ); } // Notification table. It is just a wrapper. $table_content = new StdClass(); -$table_content->data = array(); +$table_content->data = []; $table_content->width = '100%'; $table_content->id = 'notifications-wrapper'; $table_content->class = 'databox filters'; $table_content->size['name'] = '30%'; -$table_remote->style['name'] = 'font-weight: bold'; // Print each source configuration -$table_content->data = array_map(function ($source) { - return notifications_print_global_source_configuration($source); -}, notifications_get_all_sources()); +$table_content->data = array_map( + function ($source) { + return notifications_print_global_source_configuration($source); + }, + notifications_get_all_sources() +); $table_content->data[] = html_print_submit_button( - __('Update'), 'update_button', false, 'class="sub upd" style="display: flex; "', true + __('Update'), + 'update_button', + false, + 'class="sub upd" style="display: flex; "', + true ); echo '<form id="form_enable" method="post">'; @@ -121,151 +121,151 @@ echo '</form>'; // Get the source id function notifications_get_source_id(id) { - var matched = id.match(/.*-(.*)/); - if (matched == null) return ''; - return matched[1]; + var matched = id.match(/.*-(.*)/); + if (matched == null) return ''; + return matched[1]; } // Get index of two ways element dialog. function notifications_two_ways_element_get_dialog (id, source_id) { - return 'global_config_notifications_dialog_add-' + id + '-' + source_id; + return 'global_config_notifications_dialog_add-' + id + '-' + source_id; } // Get index of two ways element form. function notifications_two_ways_element_get_sufix (id, source_id) { - return 'multi-' + id + '-' + source_id; + return 'multi-' + id + '-' + source_id; } // Disable or enable the select seeing the checked value of notify all users function notifications_disable_source(event) { - var id = notifications_get_source_id(event.target.id); - var is_checked = document.getElementById(event.target.id).checked; - var selectors = ['groups', 'users']; - selectors.map(function (select) { - document.getElementById(notifications_two_ways_element_get_sufix(select, id)).disabled = is_checked; - }); + var id = notifications_get_source_id(event.target.id); + var is_checked = document.getElementById(event.target.id).checked; + var selectors = ['groups', 'users']; + selectors.map(function (select) { + document.getElementById(notifications_two_ways_element_get_sufix(select, id)).disabled = is_checked; + }); } // Open a dialog with selector of source elements. function add_source_dialog(users, source_id) { - // Display the dialog - var dialog_id = notifications_two_ways_element_get_dialog(users, source_id); - // Clean id element. - var previous_dialog = document.getElementById(dialog_id); - if (previous_dialog !== null) previous_dialog.remove(); - // Create or recreate the content. - var not_dialog = document.createElement('div'); - not_dialog.setAttribute('class', 'global_config_notifications_dialog_add_wrapper'); - not_dialog.setAttribute('id', dialog_id); - document.body.appendChild(not_dialog); - $("#" + dialog_id).dialog({ - resizable: false, - draggable: true, - modal: true, - dialogClass: "global_config_notifications_dialog_add_full", - overlay: { - opacity: 0.5, - background: "black" - }, - closeOnEscape: true, - modal: true - }); + // Display the dialog + var dialog_id = notifications_two_ways_element_get_dialog(users, source_id); + // Clean id element. + var previous_dialog = document.getElementById(dialog_id); + if (previous_dialog !== null) previous_dialog.remove(); + // Create or recreate the content. + var not_dialog = document.createElement('div'); + not_dialog.setAttribute('class', 'global_config_notifications_dialog_add_wrapper'); + not_dialog.setAttribute('id', dialog_id); + document.body.appendChild(not_dialog); + $("#" + dialog_id).dialog({ + resizable: false, + draggable: true, + modal: true, + dialogClass: "global_config_notifications_dialog_add_full", + overlay: { + opacity: 0.5, + background: "black" + }, + closeOnEscape: true, + modal: true + }); - jQuery.post ("ajax.php", - {"page" : "godmode/setup/setup_notifications", - "get_selection_two_ways_form" : 1, - "users" : users, - "source_id" : source_id - }, - function (data, status) { - not_dialog.innerHTML = data - }, - "html" - ); + jQuery.post ("ajax.php", + {"page" : "godmode/setup/setup_notifications", + "get_selection_two_ways_form" : 1, + "users" : users, + "source_id" : source_id + }, + function (data, status) { + not_dialog.innerHTML = data + }, + "html" + ); } // Move from selected and not selected source elements. function notifications_modify_two_ways_element (id, source_id, operation) { - var index_sufix = notifications_two_ways_element_get_sufix (id, source_id); - var start_id = operation === 'add' ? 'all-' : 'selected-'; - var end_id = operation !== 'add' ? 'all-' : 'selected-'; - var select = document.getElementById( - start_id + index_sufix - ); - var select_end = document.getElementById( - end_id + index_sufix - ); - for (var i = select.options.length - 1; i >= 0; i--) { - if(select.options[i].selected){ - select_end.appendChild(select.options[i]); - } - } + var index_sufix = notifications_two_ways_element_get_sufix (id, source_id); + var start_id = operation === 'add' ? 'all-' : 'selected-'; + var end_id = operation !== 'add' ? 'all-' : 'selected-'; + var select = document.getElementById( + start_id + index_sufix + ); + var select_end = document.getElementById( + end_id + index_sufix + ); + for (var i = select.options.length - 1; i >= 0; i--) { + if(select.options[i].selected){ + select_end.appendChild(select.options[i]); + } + } } // Add elements to database and close dialog function notifications_add_source_element_to_database(id, source_id) { - var index = 'selected-' + notifications_two_ways_element_get_sufix (id, source_id); - var select = document.getElementById(index); - var selected = []; - for (var i = select.options.length - 1; i >= 0; i--) { - selected.push(select.options[i].value); - } - jQuery.post ("ajax.php", - {"page" : "godmode/setup/setup_notifications", - "add_source_to_database" : 1, - "users" : id, - "source_id" : source_id, - "elements": selected - }, - function (data, status) { - if (data.result) { - // Append to other element - var out_select = document.getElementById( - notifications_two_ways_element_get_sufix(id, source_id) - ); - for (var i = select.options.length - 1; i >= 0; i--) { - out_select.appendChild(select.options[i]); - } - // Close the dialog - $("#" + notifications_two_ways_element_get_dialog(id, source_id)).dialog("close"); - } else { - console.log("Cannot update element."); - } - }, - "json" - ); + var index = 'selected-' + notifications_two_ways_element_get_sufix (id, source_id); + var select = document.getElementById(index); + var selected = []; + for (var i = select.options.length - 1; i >= 0; i--) { + selected.push(select.options[i].value); + } + jQuery.post ("ajax.php", + {"page" : "godmode/setup/setup_notifications", + "add_source_to_database" : 1, + "users" : id, + "source_id" : source_id, + "elements": selected + }, + function (data, status) { + if (data.result) { + // Append to other element + var out_select = document.getElementById( + notifications_two_ways_element_get_sufix(id, source_id) + ); + for (var i = select.options.length - 1; i >= 0; i--) { + out_select.appendChild(select.options[i]); + } + // Close the dialog + $("#" + notifications_two_ways_element_get_dialog(id, source_id)).dialog("close"); + } else { + console.log("Cannot update element."); + } + }, + "json" + ); } // Add elements to database and remove it form main select function remove_source_elements(id, source_id) { - var index = notifications_two_ways_element_get_sufix(id, source_id); - var select = document.getElementById(index); - var selected = []; - var selected_index = []; - for (var i = select.options.length - 1; i >= 0; i--) { - if(select.options[i].selected){ - selected.push(select.options[i].value); - selected_index.push(i); - } - } - jQuery.post ("ajax.php", - {"page" : "godmode/setup/setup_notifications", - "remove_source_on_database" : 1, - "users" : id, - "source_id" : source_id, - "elements": selected - }, - function (data, status) { - if (data.result) { - // Append to other element - for (var i = selected_index.length - 1; i >= 0; i--) { - select.remove(selected_index[i]); - } - } else { - console.log("Cannot delete elements."); - } - }, - "json" - ); + var index = notifications_two_ways_element_get_sufix(id, source_id); + var select = document.getElementById(index); + var selected = []; + var selected_index = []; + for (var i = select.options.length - 1; i >= 0; i--) { + if(select.options[i].selected){ + selected.push(select.options[i].value); + selected_index.push(i); + } + } + jQuery.post ("ajax.php", + {"page" : "godmode/setup/setup_notifications", + "remove_source_on_database" : 1, + "users" : id, + "source_id" : source_id, + "elements": selected + }, + function (data, status) { + if (data.result) { + // Append to other element + for (var i = selected_index.length - 1; i >= 0; i--) { + select.remove(selected_index[i]); + } + } else { + console.log("Cannot delete elements."); + } + }, + "json" + ); } </script> diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 9467c0ff92..ac030349ef 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -29,6 +29,7 @@ define('NOTIFICATIONS_POSTPONE_FOREVER', -1); + /** * Retrieves source ID for given source. * @@ -49,6 +50,7 @@ function get_notification_source_id(string $source) ); } + /** * Converts description into a handable identifier * @@ -56,12 +58,14 @@ function get_notification_source_id(string $source) * * @return string First word in lowercase. Empty string if no word detected. */ -function notifications_desc_to_id(string $desc) { +function notifications_desc_to_id(string $desc) +{ preg_match('/^[a-zA-Z]*/', $desc, $matches); $match = $matches[0]; return isset($match) ? $match : ''; } + /** * Retrieve all targets for given message. * @@ -158,30 +162,36 @@ function check_notification_readable(int $id_message) return (bool) db_get_value_sql($sql); } + /** * Return all info from tnotification_source * * @return array with sources info */ -function notifications_get_all_sources() { - return mysql_db_get_all_rows_in_table('tnotification_source'); +function notifications_get_all_sources() +{ + return db_get_all_rows_in_table('tnotification_source'); } + /** * Return the user sources to be inserted into a select * - * @param int $source_id Source database identificator + * @param integer $source_id Source database identificator * * @return array with the user id in keys and user id in value too */ -function notifications_get_user_sources_for_select($source_id) { +function notifications_get_user_sources_for_select($source_id) +{ $users = db_get_all_rows_filter( 'tnotification_source_user', - array('id_source' => $source_id), + ['id_source' => $source_id], 'id_user' ); // If fails or no one is selected, return empty array - if ($users === false) return array(); + if ($users === false) { + return []; + } return index_array($users, 'id_user', 'id_user'); } @@ -190,186 +200,231 @@ function notifications_get_user_sources_for_select($source_id) { /** * Return the groups sources to be inserted into a select * - * @param int $source_id Source database identificator + * @param integer $source_id Source database identificator * * @return array with the group id in keys and group name in value */ -function notifications_get_group_sources_for_select($source_id) { - $groups = notifications_get_group_sources ( - array('id_source' => $source_id), - array('id_group') +function notifications_get_group_sources_for_select($source_id) +{ + $groups = notifications_get_group_sources( + ['id_source' => $source_id], + ['id_group'] ); return index_array($groups, 'id_group', 'name'); } + /** * Get the group sources * * @param array $filter Filter of sql query. */ -function notifications_get_group_sources ($filter = array(), $fields = array()) { +function notifications_get_group_sources($filter=[], $fields=[]) +{ // Get only the tnotifications_source_group fields in addition to group name. - if (empty($fields)) $fields[] = "tnsg.*"; - $fields = array_map(function($field) { - if (!preg_match("/^tnsg./", $field)) $field = "tnsg.{$field}"; - return $field; - }, $fields); + if (empty($fields)) { + $fields[] = 'tnsg.*'; + } + + $fields = array_map( + function ($field) { + if (!preg_match('/^tnsg./', $field)) { + $field = "tnsg.{$field}"; + } + + return $field; + }, + $fields + ); // Get groups. $groups = db_get_all_rows_filter( 'tnotification_source_group tnsg LEFT JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo', $filter, - array_merge ($fields, array('IFNULL(tg.nombre, "All") AS name')) + array_merge($fields, ['IFNULL(tg.nombre, "All") AS name']) ); // If fails or no one is selected, return empty array - if ($groups === false) return array(); + if ($groups === false) { + return []; + } + return $groups; } + /** * Delete a set of groups from notification source * * @param int Source id * @param array Id of groups to be deleted * - * @return bool True if success. False otherwise. + * @return boolean True if success. False otherwise. */ -function notifications_remove_group_from_source ($source_id, $groups) { +function notifications_remove_group_from_source($source_id, $groups) +{ // Source id is mandatory - if (!isset($source_id)) return false; + if (!isset($source_id)) { + return false; + } // Delete from database - return db_process_sql_delete ( + return db_process_sql_delete( 'tnotification_source_group', - array( - 'id_group' => $groups, - 'id_source' => $source_id - ) + [ + 'id_group' => $groups, + 'id_source' => $source_id, + ] ) !== false; } + /** * Delete a set of users from notification source * * @param int Source id * @param array Id of users to be deleted * - * @return bool True if success. False otherwise. + * @return boolean True if success. False otherwise. */ -function notifications_remove_users_from_source ($source_id, $users) { +function notifications_remove_users_from_source($source_id, $users) +{ // Source id is mandatory - if (!isset($source_id)) return false; + if (!isset($source_id)) { + return false; + } // Delete from database - return db_process_sql_delete ( + return db_process_sql_delete( 'tnotification_source_user', - array( - 'id_user' => $users, - 'id_source' => $source_id - ) + [ + 'id_user' => $users, + 'id_source' => $source_id, + ] ) !== false; } + /** * Insert a set of groups to notification source * * @param int Source id * @param array Id of groups to be deleted * - * @return bool True if success. False otherwise. + * @return boolean True if success. False otherwise. */ -function notifications_add_group_to_source ($source_id, $groups) { +function notifications_add_group_to_source($source_id, $groups) +{ // Source id is mandatory - if (!isset($source_id)) return false; + if (!isset($source_id)) { + return false; + } // Insert into database all groups passed $res = true; foreach ($groups as $group) { - if (empty($group)) continue; + if (empty($group)) { + continue; + } + $res = $res && db_process_sql_insert( 'tnotification_source_group', - array( - 'id_group' => $group, - 'id_source' => $source_id) - ) !== false; + [ + 'id_group' => $group, + 'id_source' => $source_id, + ] + ) !== false; } + return $res; } + /** * Insert a set of users to notification source * * @param int Source id * @param array Id of users to be deleted * - * @return bool True if success. False otherwise. + * @return boolean True if success. False otherwise. */ - function notifications_add_users_to_source ($source_id, $users) { +function notifications_add_users_to_source($source_id, $users) +{ // Source id is mandatory - if (!isset($source_id)) return false; + if (!isset($source_id)) { + return false; + } // Insert into database all groups passed $res = true; foreach ($users as $user) { - if (empty($user)) continue; + if (empty($user)) { + continue; + } + $res = $res && db_process_sql_insert( 'tnotification_source_user', - array( - 'id_user' => $user, - 'id_source' => $source_id) - ) !== false; + [ + 'id_user' => $user, + 'id_source' => $source_id, + ] + ) !== false; } + return $res; } + /** * Get the groups that not own to a source and, for that reason, they can be * added to the source. * - * @param int $source_id Source id. + * @param integer $source_id Source id. * @return array Indexed by id group all selectable groups. */ -function notifications_get_group_source_not_configured ($source_id) { +function notifications_get_group_source_not_configured($source_id) +{ $groups_selected = notifications_get_group_sources_for_select($source_id); - $all_groups = users_get_groups_for_select(false, "AR", false, true, $groups_selected); + $all_groups = users_get_groups_for_select(false, 'AR', false, true, $groups_selected); return array_diff($all_groups, $groups_selected); } + /** * Get the users that not own to a source and, for that reason, they can be * added to the source. * - * @param int $source_id + * @param integer $source_id * @return array Indexed by id user, all selectable users. */ -function notifications_get_user_source_not_configured ($source_id) { +function notifications_get_user_source_not_configured($source_id) +{ $users_selected = array_keys(notifications_get_user_sources_for_select($source_id)); $users = get_users( 'id_user', - array('!id_user' => $users_selected), - array('id_user') + ['!id_user' => $users_selected], + ['id_user'] ); return index_array($users, 'id_user', 'id_user'); } + /** * Print the notification ball to see unread messages * * @return string with HTML code of notification ball */ -function notifications_print_ball() { +function notifications_print_ball() +{ $num_notifications = messages_get_count(); - $class_status = $num_notifications == 0 - ? 'notification-ball-no-messages' - : 'notification-ball-new-messages'; - return - "<div class='notification-ball $class_status' id='notification-ball-header'> + $class_status = $num_notifications == 0 ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; + return "<div class='notification-ball $class_status' id='notification-ball-header'> $num_notifications </div>"; } + /** * Print notification configuration global * @@ -377,58 +432,61 @@ function notifications_print_ball() { * * @return string with HTML of source configuration */ -function notifications_print_global_source_configuration($source) { - +function notifications_print_global_source_configuration($source) +{ // Get some values to generate the title $id = notifications_desc_to_id($source['description']); - $switch_values = array ( - 'name' => "enable-" . $id, - 'value' => $source['enabled'] - ); + $switch_values = [ + 'name' => 'enable-'.$id, + 'value' => $source['enabled'], + ]; // Search if group all is set and handle that situation $source_groups = notifications_get_group_sources_for_select($source['id']); - $is_group_all = isset($source_groups["0"]); - if($is_group_all) unset($source_groups["0"]); + $is_group_all = isset($source_groups['0']); + if ($is_group_all) { + unset($source_groups['0']); + } // Generate the title $html_title = "<div class='global-config-notification-title'>"; - $html_title .= html_print_switch($switch_values); - $html_title .= "<h2>{$source['description']}</h2>"; - $html_title .= "</div>"; + $html_title .= html_print_switch($switch_values); + $html_title .= "<h2>{$source['description']}</h2>"; + $html_title .= '</div>'; // Generate the html for title $html_selectors = "<div class='global-config-notification-selectors'>"; - $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all); - $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all); - $html_selectors .= "</div>"; + $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all); + $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all); + $html_selectors .= '</div>'; // Generate the checkboxes and time select $html_checkboxes = "<div class='global-config-notification-checkboxes'>"; - $html_checkboxes .= " <span>"; - $html_checkboxes .= html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)'); - $html_checkboxes .= __('Notify all users'); - $html_checkboxes .= " </span><br><span>"; - $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true); - $html_checkboxes .= __('Also email users with notification content'); - $html_checkboxes .= " </span><br><span>"; - $html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true); - $html_checkboxes .= __('Users cannot modify notification preferences'); - $html_checkboxes .= " </span>"; - $html_checkboxes .= "</div>"; + $html_checkboxes .= ' <span>'; + $html_checkboxes .= html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)'); + $html_checkboxes .= __('Notify all users'); + $html_checkboxes .= ' </span><br><span>'; + $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true); + $html_checkboxes .= __('Also email users with notification content'); + $html_checkboxes .= ' </span><br><span>'; + $html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true); + $html_checkboxes .= __('Users cannot modify notification preferences'); + $html_checkboxes .= ' </span>'; + $html_checkboxes .= '</div>'; // Generate the select with the time $html_select_pospone = __('Users can postpone notifications up to'); - $html_select_pospone .= html_print_select ( - array( - SECONDS_5MINUTES => __('5 minutes'), - SECONDS_15MINUTES => __('15 minutes'), - SECONDS_12HOURS => __('12 hours'), - SECONDS_1DAY => __('1 day'), - SECONDS_1WEEK => __('1 week'), - SECONDS_15DAYS => __('15 days'), - SECONDS_1MONTH => __('1 month'), - NOTIFICATIONS_POSTPONE_FOREVER => __('forever')), + $html_select_pospone .= html_print_select( + [ + SECONDS_5MINUTES => __('5 minutes'), + SECONDS_15MINUTES => __('15 minutes'), + SECONDS_12HOURS => __('12 hours'), + SECONDS_1DAY => __('1 day'), + SECONDS_1WEEK => __('1 week'), + SECONDS_15DAYS => __('15 days'), + SECONDS_1MONTH => __('1 month'), + NOTIFICATIONS_POSTPONE_FOREVER => __('forever'), + ], "postpone-{$id}", $source['max_postpone_time'], '', @@ -438,58 +496,61 @@ function notifications_print_global_source_configuration($source) { ); // Return all html - return $html_title . $html_selectors . $html_checkboxes . $html_select_pospone; + return $html_title.$html_selectors.$html_checkboxes.$html_select_pospone; } + /** * Print select boxes of notified users or groups * - * @param array $info_selec All info required for build the selector - * @param string $id users|groups - * @param string $source_id Id of source - * @param bool $disabled Disable the selectors + * @param array $info_selec All info required for build the selector + * @param string $id users|groups + * @param string $source_id Id of source + * @param boolean $disabled Disable the selectors * * @return string HTML with the generated selector */ -function notifications_print_source_select_box($info_selec, $id, $source_id, $disabled) { - - $title = $id == "users" ? __('Notified users') : __('Notified groups'); - $add_title = $id == "users" ? __('Add users') : __('Add groups'); - $delete_title = $id == "users" ? __('Delete users') : __('Delete groups'); +function notifications_print_source_select_box($info_selec, $id, $source_id, $disabled) +{ + $title = $id == 'users' ? __('Notified users') : __('Notified groups'); + $add_title = $id == 'users' ? __('Add users') : __('Add groups'); + $delete_title = $id == 'users' ? __('Delete users') : __('Delete groups'); // Generate the HTML $html_select = "<div class='global-config-notification-single-selector'>"; - $html_select .= " <div>"; + $html_select .= ' <div>'; $html_select .= " <h4>$title</h4>"; // Put a true if empty sources to avoid to sow the 'None' value - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true,'', $disabled); - $html_select .= " </div>"; + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true, '', $disabled); + $html_select .= ' </div>'; $html_select .= " <div class='global-notifications-icons'>"; - $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')")); - $html_select .= html_print_image('images/input_delete.png', true, array('title' => $delete_title, 'onclick' => "remove_source_elements('$id', '$source_id')")); - $html_select .= " </div>"; - $html_select .= "</div>"; + $html_select .= html_print_image('images/input_add.png', true, ['title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')"]); + $html_select .= html_print_image('images/input_delete.png', true, ['title' => $delete_title, 'onclick' => "remove_source_elements('$id', '$source_id')"]); + $html_select .= ' </div>'; + $html_select .= '</div>'; return $html_select; } + /** * Print the select with right and left arrows to select new sources * (groups or users). * - * @param array $info_selec Array with source info. - * @param string $users users|groups. - * @param source $source_id Source id. + * @param array $info_selec Array with source info. + * @param string $users users|groups. + * @param source $source_id Source id. * @return string HTML with the select code. */ -function notifications_print_two_ways_select($info_selec, $users, $source_id) { +function notifications_print_two_ways_select($info_selec, $users, $source_id) +{ $html_select = "<div class='global_config_notifications_dialog_add'>"; - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true,''); - $html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>"; - $html_select .= html_print_image('images/darrowright.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')")); - $html_select .= html_print_image('images/darrowleft.png', true, array('title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')")); - $html_select .= "</div>"; + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, ''); + $html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>"; + $html_select .= html_print_image('images/darrowright.png', true, ['title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')"]); + $html_select .= html_print_image('images/darrowleft.png', true, ['title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')"]); + $html_select .= '</div>'; $html_select .= html_print_select(true, "selected-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, ''); - $html_select .= "</div>"; + $html_select .= '</div>'; $html_select .= html_print_button(__('Add'), 'Add', false, "notifications_add_source_element_to_database('$users', '$source_id')", "class='sub add'", true); return $html_select; diff --git a/pandora_console/operation/users/user_edit_header.php b/pandora_console/operation/users/user_edit_header.php index 99e0567e57..4b329eee77 100644 --- a/pandora_console/operation/users/user_edit_header.php +++ b/pandora_console/operation/users/user_edit_header.php @@ -4,7 +4,6 @@ // ================================================== // Copyright (c) 2005-2010 Artica Soluciones Tecnologicas // Please see http://pandorafms.org for full contribution list - // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation for version 2. @@ -12,86 +11,77 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - - // Load global vars global $config; -check_login (); +check_login(); enterprise_hook('open_meta_frame'); -include_once($config['homedir'] . "/include/functions_profile.php"); -include_once($config['homedir'] . '/include/functions_users.php'); -include_once ($config['homedir'] . '/include/functions_groups.php'); -include_once ($config['homedir'] . '/include/functions_visual_map.php'); +require_once $config['homedir'].'/include/functions_profile.php'; +require_once $config['homedir'].'/include/functions_users.php'; +require_once $config['homedir'].'/include/functions_groups.php'; +require_once $config['homedir'].'/include/functions_visual_map.php'; $meta = false; -if (enterprise_installed() && defined("METACONSOLE")) { - $meta = true; +if (enterprise_installed() && defined('METACONSOLE')) { + $meta = true; } -$id = get_parameter_get ("id", $config["id_user"]); // ID given as parameter -$status = get_parameter ("status", -1); // Flag to print action status message - -$user_info = get_user_info ($id); -$id = $user_info["id_user"]; //This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem) - -if ((!check_acl ($config["id_user"], users_get_groups ($id), "UM")) - AND ($id != $config["id_user"])) { - - db_pandora_audit("ACL Violation","Trying to view a user without privileges"); - require ("general/noaccess.php"); - exit; +$id = get_parameter_get('id', $config['id_user']); +// ID given as parameter +$status = get_parameter('status', -1); +// Flag to print action status message +$user_info = get_user_info($id); +$id = $user_info['id_user']; +// This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem) +if ((!check_acl($config['id_user'], users_get_groups($id), 'UM')) + and ($id != $config['id_user']) +) { + db_pandora_audit('ACL Violation', 'Trying to view a user without privileges'); + include 'general/noaccess.php'; + exit; } -//If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info -if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) { - $view_mode = false; -} -else { - $view_mode = true; +// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info +if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) { + $view_mode = false; +} else { + $view_mode = true; } -$urls = array(); +$urls = []; if (is_metaconsole()) { - user_meta_print_header(); - $urls['main'] = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit'; -} -else { - $urls['main'] = "index.php?sec=workspace&sec2=operation/users/user_edit"; - $urls['notifications'] = "index.php?sec=workspace&sec2=operation/users/user_edit_notifications"; - $buttons = array( - 'main' => array( - 'active' => $_GET['sec2'] === 'operation/users/user_edit', - 'text' => - "<a href='{$urls['main']}'>". - html_print_image ( - "images/user_green.png", - true, - array ("title" => __('User management')) - ).'</a>' - ), - 'notifications' => array( - 'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications', - 'text' => - "<a href='{$urls['notifications']}'>". - html_print_image ( - "images/alerts_template.png", - true, - array ("title" => __('User notifications')) - ).'</a>' - ) - ); + user_meta_print_header(); + $urls['main'] = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit'; +} else { + $urls['main'] = 'index.php?sec=workspace&sec2=operation/users/user_edit'; + $urls['notifications'] = 'index.php?sec=workspace&sec2=operation/users/user_edit_notifications'; + $buttons = [ + 'main' => [ + 'active' => $_GET['sec2'] === 'operation/users/user_edit', + 'text' => "<a href='{$urls['main']}'>".html_print_image( + 'images/user_green.png', + true, + ['title' => __('User management')] + ).'</a>', + ], + 'notifications' => [ + 'active' => $_GET['sec2'] === 'operation/users/user_edit_notifications', + 'text' => "<a href='{$urls['notifications']}'>".html_print_image( + 'images/alerts_template.png', + true, + ['title' => __('User notifications')] + ).'</a>', + ], + ]; - ui_print_page_header ( - __('User detail editor'), - "images/op_workspace.png", - false, - "", - false, - $buttons - ); + ui_print_page_header( + __('User detail editor'), + 'images/op_workspace.png', + false, + '', + false, + $buttons + ); } - -?> \ No newline at end of file From 37d02ddf59fdf04119d4176476030f1a539cf00f Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Wed, 6 Feb 2019 18:18:48 +0100 Subject: [PATCH 031/262] Added disabled status to switches Former-commit-id: 7fee49f58e4be84bfb8bad08303b203d71dafe16 --- pandora_console/include/functions_html.php | 3 ++- pandora_console/include/styles/pandora.css | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 8510b5e259..22c392e726 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2593,9 +2593,10 @@ function html_print_switch ($attributes = array()) { $name_html = isset($attributes['name']) ? "name = {$attributes['name']}" : ''; $checked_html = (bool)$attributes['value'] ? 'checked' : ''; + $disabled_html = (bool)$attributes['disabled'] ? 'disabled' : ''; return "<label class='p-switch'> - <input type='checkbox' $name_html $checked_html> + <input type='checkbox' $name_html $checked_html $disabled_html> <span class='p-slider'></span> </label>"; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 1d4e4af4c0..cc6545fc87 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5290,4 +5290,8 @@ input:checked + .p-slider:before { transform: translateX(13px); } +input:disabled + .p-slider { + opacity: 0.4; +} + /* --- END SWITCH --- */ From 986dfcb74d04677281cb3a5712ff4f5e3062ff7a Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Wed, 6 Feb 2019 18:20:26 +0100 Subject: [PATCH 032/262] Added basic and dummy user edit notifications Former-commit-id: d0395c5b2cbc870812e54e15db523eeaac94557f --- .../include/functions_notifications.php | 92 ++++++++++++++++++- .../users/user_edit_notifications.php | 30 +++++- 2 files changed, 116 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index ac030349ef..0f26ed977c 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -182,18 +182,37 @@ function notifications_get_all_sources() * @return array with the user id in keys and user id in value too */ function notifications_get_user_sources_for_select($source_id) +{ + $users = notifications_get_user_sources( + ['id_source' => $source_id], + ['id_user'] + ); + + return index_array($users, 'id_user', 'id_user'); +} + + +/** + * Get the user sources + * + * @param array $filter Filter of sql query. + * @param array $fields Fields to get of query. + * + * @return array Array with user sources data. + */ +function notifications_get_user_sources($filter=[], $fields=[]) { $users = db_get_all_rows_filter( 'tnotification_source_user', - ['id_source' => $source_id], - 'id_user' + $filter, + $fields ); - // If fails or no one is selected, return empty array + // If fails or no one is selected, return empty array. if ($users === false) { return []; } - return index_array($users, 'id_user', 'id_user'); + return $users; } @@ -358,6 +377,12 @@ function notifications_add_users_to_source($source_id, $users) // Insert into database all groups passed $res = true; + $also_mail = db_get_value( + 'also_mail', + 'tnotification_source', + 'id', + $source_id + ); foreach ($users as $user) { if (empty($user)) { continue; @@ -368,6 +393,8 @@ function notifications_add_users_to_source($source_id, $users) [ 'id_user' => $user, 'id_source' => $source_id, + 'enabled' => 1, + 'also_mail' => (int) $also_mail, ] ) !== false; } @@ -410,6 +437,48 @@ function notifications_get_user_source_not_configured($source_id) } +function notifications_build_user_enable_return($status, $enabled) +{ + return [ + 'status' => ((bool) $status === true) ? 1 : 0, + 'enabled' => ((bool) $enabled === true) ? 1 : 0, + ]; +} + + +function notifications_get_user_label_status($source, $user, $label) +{ + // If not enabled, it cannot be modificable. + if (!$source['enabled'] || !$source[$label]) { + return notifications_build_user_enable_return(false, false); + } + + // See at first for direct reference. + $user_source = notifications_get_user_sources( + [ + 'id_source' => $source['id'], + 'id_user' => $user, + ] + ); + if (!empty($user_source)) { + return notifications_build_user_enable_return( + isset($user_source[0][$label]) ? $user_source[0][$label] : false, + $source['user_editable'] + ); + } + + $common_groups = array_intersect( + array_keys(users_get_groups($user)), + array_keys( + notifications_get_group_sources_for_select($source['id']) + ) + ); + // No group found, return no permissions. + $value = empty($common_groups) ? false : $source[$label]; + return notifications_build_user_enable_return($value, false); +} + + /** * Print the notification ball to see unread messages * @@ -470,7 +539,7 @@ function notifications_print_global_source_configuration($source) $html_checkboxes .= __('Also email users with notification content'); $html_checkboxes .= ' </span><br><span>'; $html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true); - $html_checkboxes .= __('Users cannot modify notification preferences'); + $html_checkboxes .= __('Users can modify notification preferences'); $html_checkboxes .= ' </span>'; $html_checkboxes .= '</div>'; @@ -555,3 +624,16 @@ function notifications_print_two_ways_select($info_selec, $users, $source_id) return $html_select; } + + +function notifications_print_user_switch($source, $user, $label) +{ + $status = notifications_get_user_label_status($source, $user, $label); + return html_print_switch( + [ + 'name' => $label, + 'value' => $status['status'], + 'disabled' => !$status['enabled'], + ] + ); +} diff --git a/pandora_console/operation/users/user_edit_notifications.php b/pandora_console/operation/users/user_edit_notifications.php index edec0e2a6c..d7a4f71194 100644 --- a/pandora_console/operation/users/user_edit_notifications.php +++ b/pandora_console/operation/users/user_edit_notifications.php @@ -16,9 +16,37 @@ // Load global vars global $config; +// Includes. +include_once ($config['homedir'] . '/include/functions_notifications.php'); + // Load the header require($config['homedir'] . "/operation/users/user_edit_header.php"); -// TODO +// User notification table. It is just a wrapper. +$table_content = new StdClass(); +$table_content->data = array(); +$table_content->width = '100%'; +$table_content->id = 'user-notifications-wrapper'; +$table_content->class = 'databox filters'; +$table_content->size[0] = '33%'; +$table_content->size[1] = '33%'; +$table_content->size[2] = '33%'; + +// Print the header. +$table_content->data[] = array ( + '', + __('Enable'), + __('Also receive an email') +); + +$sources = notifications_get_all_sources(); +foreach ($sources as $source) { + $table_content->data[] = array( + $source['description'], + notifications_print_user_switch($source, $id, 'enabled'), + notifications_print_user_switch($source, $id, 'also_mail'), + ); +} +html_print_table($table_content); ?> \ No newline at end of file From 9ea3980b2666554dabf350710e4ca62aeb8b48f1 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Wed, 6 Feb 2019 20:22:22 +0100 Subject: [PATCH 033/262] wip supervisor Former-commit-id: 991922a7dd18ace8fd831d02ada2cf20e81d27c2 --- .../include/functions_notifications.php | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index ac030349ef..c8f46d90ae 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -1,5 +1,4 @@ <?php - /** * Library. Notification system auxiliary functions. * @@ -46,7 +45,7 @@ function get_notification_source_id(string $source) return db_get_value_sql( "SELECT id FROM `tnotification_source` - WHERE `description` LIKE '{$source}%'" + WHERE `description` LIKE '".$source."%'" ); } @@ -54,7 +53,7 @@ function get_notification_source_id(string $source) /** * Converts description into a handable identifier * - * @param string $desc Full description + * @param string $desc Full description. * * @return string First word in lowercase. Empty string if no word detected. */ @@ -163,6 +162,65 @@ function check_notification_readable(int $id_message) } +/** + * Returns the target users and groups assigned to be notified on + * desired source. + * + * @param integer $id_source + * + * @return array [users] and [groups] with the targets. + */ +function get_notification_source_targets(int $id_source) +{ + $ret = []; + + $users = db_get_all_rows_sql( + sprintf( + 'SELECT + id_user, + IF(ns.user_editable = 1,nsu.also_mail,ns.also_mail) AS also_mail + FROM tnotification_source_user nsu + INNER JOIN tnotification_source ns + ON ns.id=nsu.id_source + WHERE ns.id = %d + AND ((ns.enabled is NULL OR ns.enabled != 0) + OR (nsu.enabled is NULL OR nsu.enabled != 0))', + $id_source + ) + ); + + if ($users !== false) { + $i = 0; + foreach ($users as $user) { + $ret['users'][$i]['id_user'] = $user['id_user']; + $ret['users'][$i++]['also_mail'] = $also_mail; + } + } + + $groups = db_get_all_rows_sql( + sprintf( + 'SELECT id_group,ns.also_mail + FROM tnotification_source_group nsg + INNER JOIN tnotification_source ns + ON ns.id=nsg.id_source + WHERE ns.id = %d + AND (ns.enabled is NULL OR ns.enabled != 0)', + $id_source + ) + ); + + if ($groups !== false) { + $i = 0; + foreach ($groups as $group) { + $ret['groups'][$i]['id_group'] = $group['id_group']; + $ret['groups'][$i++]['also_mail'] = $group['also_mail']; + } + } + + return $ret; +} + + /** * Return all info from tnotification_source * From 6dbeaf630707a68d9ca7fc411aec71bf871f8640 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 7 Feb 2019 12:20:34 +0100 Subject: [PATCH 034/262] Added more attributes to swith HTML element Former-commit-id: aa567ef6f16e1e89489b16f808b00e772866ef86 --- pandora_console/include/functions_html.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 22c392e726..0db0b371cb 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2587,16 +2587,27 @@ function html_print_csrf_error () { * @param array $atributes. Valid params: * name: Usefull to handle in forms * value: If is checked or not + * disabled: Disabled. Cannot be pressed. + * id: Optional id for the switch. + * class: Additional classes (string). * @return string with HTML of button */ function html_print_switch ($attributes = array()) { + $html_expand = ''; - $name_html = isset($attributes['name']) ? "name = {$attributes['name']}" : ''; - $checked_html = (bool)$attributes['value'] ? 'checked' : ''; - $disabled_html = (bool)$attributes['disabled'] ? 'disabled' : ''; + // Check the load values on status. + $html_expand .= (bool)$attributes['value'] ? ' checked' : ''; + $html_expand .= (bool)$attributes['disabled'] ? ' disabled' : ''; + + // Only load the valid attributes. + $valid_attrs = ['id', 'class', 'name']; + foreach ($valid_attrs as $va) { + if (!isset($attributes[$va])) continue; + $html_expand .= ' '.$va.'="'.$attributes[$va].'"'; + } return "<label class='p-switch'> - <input type='checkbox' $name_html $checked_html $disabled_html> + <input type='checkbox' $html_expand> <span class='p-slider'></span> </label>"; } From d5fb9f1051818a6a3edc389b2593f852882d60f7 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 7 Feb 2019 12:22:50 +0100 Subject: [PATCH 035/262] Added AJAX to user notification config window Former-commit-id: 9ca09ae777d699588a76dfb619156d800a95895b --- .../include/functions_notifications.php | 27 +++++- .../users/user_edit_notifications.php | 92 ++++++++++++++++--- 2 files changed, 106 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 0f26ed977c..9037e9790f 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -168,9 +168,9 @@ function check_notification_readable(int $id_message) * * @return array with sources info */ -function notifications_get_all_sources() +function notifications_get_all_sources($filter=[]) { - return db_get_all_rows_in_table('tnotification_source'); + return db_get_all_rows_filter('tnotification_source', $filter); } @@ -478,6 +478,27 @@ function notifications_get_user_label_status($source, $user, $label) return notifications_build_user_enable_return($value, false); } +function notifications_set_user_label_status($source, $user, $label, $value) { + $source_info = notifications_get_all_sources(['id' => $source]); + if (!isset($source_info[0]) + || !$source_info[0]['enabled'] + || !$source_info[0][$label] + || !$source_info[0]['user_editable'] + ) { + return false; + } + + return (bool) db_process_sql_update( + 'tnotification_source_user', + [$label => $value], + [ + 'id_user' => $user, + 'id_source' => $source, + ] + ); + +} + /** * Print the notification ball to see unread messages @@ -634,6 +655,8 @@ function notifications_print_user_switch($source, $user, $label) 'name' => $label, 'value' => $status['status'], 'disabled' => !$status['enabled'], + 'class' => 'notifications-user-label_individual', + 'id' => 'notifications-user-'.$source['id'].'-label-'.$label, ] ); } diff --git a/pandora_console/operation/users/user_edit_notifications.php b/pandora_console/operation/users/user_edit_notifications.php index d7a4f71194..6ffbf87976 100644 --- a/pandora_console/operation/users/user_edit_notifications.php +++ b/pandora_console/operation/users/user_edit_notifications.php @@ -4,7 +4,6 @@ // ================================================== // Copyright (c) 2005-2010 Artica Soluciones Tecnologicas // Please see http://pandorafms.org for full contribution list - // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation for version 2. @@ -12,19 +11,39 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - // Load global vars global $config; // Includes. -include_once ($config['homedir'] . '/include/functions_notifications.php'); +require_once $config['homedir'].'/include/functions_notifications.php'; // Load the header -require($config['homedir'] . "/operation/users/user_edit_header.php"); +require $config['homedir'].'/operation/users/user_edit_header.php'; + +if (get_parameter('change_label', 0)) { + $label = get_parameter('label', ''); + $source = get_parameter('source', 0); + $user = get_parameter('user', ''); + $value = get_parameter('value', 0) ? 1 : 0; + + // Update the label value. + ob_clean(); + echo json_encode( + [ + 'result' => notifications_set_user_label_status( + $source, + $user, + $label, + $value + ), + ] + ); + return; +} // User notification table. It is just a wrapper. $table_content = new StdClass(); -$table_content->data = array(); +$table_content->data = []; $table_content->width = '100%'; $table_content->id = 'user-notifications-wrapper'; $table_content->class = 'databox filters'; @@ -33,20 +52,71 @@ $table_content->size[1] = '33%'; $table_content->size[2] = '33%'; // Print the header. -$table_content->data[] = array ( +$table_content->data[] = [ '', __('Enable'), - __('Also receive an email') -); + __('Also receive an email'), +]; $sources = notifications_get_all_sources(); foreach ($sources as $source) { - $table_content->data[] = array( + $table_content->data[] = [ $source['description'], notifications_print_user_switch($source, $id, 'enabled'), notifications_print_user_switch($source, $id, 'also_mail'), - ); + ]; } + html_print_table($table_content); -?> \ No newline at end of file +// Print id user to handle it on js. +html_print_input_hidden('id_user', $id); + +?> +<script> +// Encapsulate the code +(function() { + function notifications_change_label(event) { + event.preventDefault(); + var check = document.getElementById(event.target.id); + if (check === null) return; + + var match = /notifications-user-([0-9]+)-label-(.*)/ + .exec(event.target.id); + + jQuery.post ("ajax.php", + { + "page" : "operation/users/user_edit_notifications", + "change_label" : 1, + "label" : match[2], + "source" : match[1], + "user" : document.getElementById('hidden-id_user').value, + "value": check.checked ? 1 : 0 + }, + function (data, status) { + if (!data.result) { + console.error("Error changing configuration in database."); + } else { + check.checked = !check.checked; + } + }, + "json" + ).done(function(m){}) + .fail(function(xhr, textStatus, errorThrown){ + console.error( + "Cannot change configuration in database. Server error.", + xhr.responseText + ); + }); + + } + var all_labels = document.getElementsByClassName( + 'notifications-user-label_individual' + ); + for (var i = 0; i < all_labels.length; i++) { + all_labels[i].addEventListener( + 'click', notifications_change_label, false + ); + } +}()); +</script> From cf5716e569d2f9c9637eb03ec5dde43c4ad63b48 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Thu, 7 Feb 2019 12:56:48 +0100 Subject: [PATCH 036/262] supervisor added subtype to tmensajes Former-commit-id: 650e7317a4fea4e44be850af1156024297396a16 --- .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 15 ++++++++------- pandora_console/pandoradb.sql | 1 + pandora_console/pandoradb_data.sql | 15 +++++++-------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 482fcb8f4e..ce015f9149 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1886,13 +1886,13 @@ CREATE TABLE `tnotification_source` ( -- -- Dumping data for table `tnotification_source` -- -INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `user_editable`, `also_mail`) VALUES - ("System status", "icono_info_mr.png", 86400, 1, 0), - ("Message", "icono_info_mr.png", 86400, 1, 0), - ("Pending task", "icono_info_mr.png", 86400, 1, 0), - ("Advertisement", "icono_info_mr.png", 86400, 1, 0), - ("Official communication", "icono_info_mr.png", 86400, 1, 0), - ("Sugerence", "icono_info_mr.png", 86400, 1, 0); +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); -- ----------------------------------------------------- -- Table `tmensajes` @@ -1901,6 +1901,7 @@ ALTER TABLE `tmensajes` ADD COLUMN `url` TEXT; ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL; ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0'; ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT ''; ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index daae31bf5d..5af9d38c55 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1191,6 +1191,7 @@ CREATE TABLE IF NOT EXISTS `tmensajes` ( `response_mode` VARCHAR(200) DEFAULT NULL, `citicity` INT(10) UNSIGNED DEFAULT '0', `id_source` BIGINT(20) UNSIGNED NOT NULL, + `subtype` VARCHAR(255) DEFAULT '', PRIMARY KEY (`id_mensaje`), UNIQUE KEY `id_mensaje` (`id_mensaje`), KEY `tsource_fk` (`id_source`), diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index e803c83d82..f73ab0af68 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1271,11 +1271,10 @@ INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', -- -- Dumping data for table `tnotification_source` -- -INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `user_editable`, `also_mail`) VALUES - ("System status", "icono_info_mr.png", 86400, 1, 0), - ("Message", "icono_info_mr.png", 86400, 1, 0), - ("Pending task", "icono_info_mr.png", 86400, 1, 0), - ("Advertisement", "icono_info_mr.png", 86400, 1, 0), - ("Official communication", "icono_info_mr.png", 86400, 1, 0), - ("Sugerence", "icono_info_mr.png", 86400, 1, 0); - +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); From fb814680db32f7bdd9257583fca070d677c3704d Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 7 Feb 2019 12:57:51 +0100 Subject: [PATCH 037/262] Added some well formatted docs Former-commit-id: 30aa9de2e1b3835f96adf2fbec24bfd5ab17e7c2 --- .../include/functions_notifications.php | 100 +++++++++++++----- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 9037e9790f..5c232709de 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -166,6 +166,8 @@ function check_notification_readable(int $id_message) /** * Return all info from tnotification_source * + * @param array $filter Filter to table tnotification_source. + * * @return array with sources info */ function notifications_get_all_sources($filter=[]) @@ -177,7 +179,7 @@ function notifications_get_all_sources($filter=[]) /** * Return the user sources to be inserted into a select * - * @param integer $source_id Source database identificator + * @param integer $source_id Source database identificator. * * @return array with the user id in keys and user id in value too */ @@ -219,7 +221,7 @@ function notifications_get_user_sources($filter=[], $fields=[]) /** * Return the groups sources to be inserted into a select * - * @param integer $source_id Source database identificator + * @param integer $source_id Source database identificator. * * @return array with the group id in keys and group name in value */ @@ -237,6 +239,9 @@ function notifications_get_group_sources_for_select($source_id) * Get the group sources * * @param array $filter Filter of sql query. + * @param array $fields Fields retrieved. + * + * @return array With the group info */ function notifications_get_group_sources($filter=[], $fields=[]) { @@ -276,8 +281,8 @@ function notifications_get_group_sources($filter=[], $fields=[]) /** * Delete a set of groups from notification source * - * @param int Source id - * @param array Id of groups to be deleted + * @param integer $source_id Source id. + * @param array $groups Id of groups to be deleted. * * @return boolean True if success. False otherwise. */ @@ -302,8 +307,8 @@ function notifications_remove_group_from_source($source_id, $groups) /** * Delete a set of users from notification source * - * @param int Source id - * @param array Id of users to be deleted + * @param integer $source_id Source id. + * @param array $users Id of users to be deleted. * * @return boolean True if success. False otherwise. */ @@ -328,8 +333,8 @@ function notifications_remove_users_from_source($source_id, $users) /** * Insert a set of groups to notification source * - * @param int Source id - * @param array Id of groups to be deleted + * @param integer $source_id Source id. + * @param array $groups Id of groups to be deleted. * * @return boolean True if success. False otherwise. */ @@ -363,8 +368,8 @@ function notifications_add_group_to_source($source_id, $groups) /** * Insert a set of users to notification source * - * @param int Source id - * @param array Id of users to be deleted + * @param integer $source_id Source id. + * @param array $users Id of users to be deleted. * * @return boolean True if success. False otherwise. */ @@ -407,7 +412,8 @@ function notifications_add_users_to_source($source_id, $users) * Get the groups that not own to a source and, for that reason, they can be * added to the source. * - * @param integer $source_id Source id. + * @param integer $source_id Source id. + * * @return array Indexed by id group all selectable groups. */ function notifications_get_group_source_not_configured($source_id) @@ -422,7 +428,8 @@ function notifications_get_group_source_not_configured($source_id) * Get the users that not own to a source and, for that reason, they can be * added to the source. * - * @param integer $source_id + * @param integer $source_id Source id. + * * @return array Indexed by id user, all selectable users. */ function notifications_get_user_source_not_configured($source_id) @@ -437,6 +444,14 @@ function notifications_get_user_source_not_configured($source_id) } +/** + * Build a data struct to handle the value of a label + * + * @param mixed $status Status value. + * @param mixed $enabled Enabled value. + * + * @return array with status (1|0) and enabled (1|0) + */ function notifications_build_user_enable_return($status, $enabled) { return [ @@ -446,6 +461,15 @@ function notifications_build_user_enable_return($status, $enabled) } +/** + * Get user label (enabled, also_mail...) status. + * + * @param integer $source Id of notification source. + * @param string $user User id. + * @param string $label Label id (enabled, also_email...). + * + * @return array Return of notifications_build_user_enable_return. + */ function notifications_get_user_label_status($source, $user, $label) { // If not enabled, it cannot be modificable. @@ -478,7 +502,19 @@ function notifications_get_user_label_status($source, $user, $label) return notifications_build_user_enable_return($value, false); } -function notifications_set_user_label_status($source, $user, $label, $value) { + +/** + * Set the status to a single label on config of users notifications. + * + * @param integer $source Id of notification source. + * @param string $user User id. + * @param string $label Label id (enabled, also_email...). + * @param mixed $value Numeric value: 1 or 0. + * + * @return boolean True if success. + */ +function notifications_set_user_label_status($source, $user, $label, $value) +{ $source_info = notifications_get_all_sources(['id' => $source]); if (!isset($source_info[0]) || !$source_info[0]['enabled'] @@ -501,9 +537,9 @@ function notifications_set_user_label_status($source, $user, $label, $value) { /** - * Print the notification ball to see unread messages + * Print the notification ball to see unread messages. * - * @return string with HTML code of notification ball + * @return string with HTML code of notification ball. */ function notifications_print_ball() { @@ -518,7 +554,7 @@ function notifications_print_ball() /** * Print notification configuration global * - * @param array notification source data + * @param array $source Notification source data. * * @return string with HTML of source configuration */ @@ -593,15 +629,19 @@ function notifications_print_global_source_configuration($source) /** * Print select boxes of notified users or groups * - * @param array $info_selec All info required for build the selector - * @param string $id users|groups - * @param string $source_id Id of source - * @param boolean $disabled Disable the selectors + * @param array $info_selec All info required for build the selector. + * @param string $id One of users|groups. + * @param string $source_id Id of source. + * @param boolean $disabled Disable the selectors. * * @return string HTML with the generated selector */ -function notifications_print_source_select_box($info_selec, $id, $source_id, $disabled) -{ +function notifications_print_source_select_box( + $info_selec, + $id, + $source_id, + $disabled +) { $title = $id == 'users' ? __('Notified users') : __('Notified groups'); $add_title = $id == 'users' ? __('Add users') : __('Add groups'); $delete_title = $id == 'users' ? __('Delete users') : __('Delete groups'); @@ -626,9 +666,10 @@ function notifications_print_source_select_box($info_selec, $id, $source_id, $di * Print the select with right and left arrows to select new sources * (groups or users). * - * @param array $info_selec Array with source info. - * @param string $users users|groups. - * @param source $source_id Source id. + * @param array $info_selec Array with source info. + * @param string $users One of users|groups. + * @param source $source_id Source id. + * * @return string HTML with the select code. */ function notifications_print_two_ways_select($info_selec, $users, $source_id) @@ -647,6 +688,15 @@ function notifications_print_two_ways_select($info_selec, $users, $source_id) } +/** + * Print a label status represented by a switch + * + * @param integer $source Source id. + * @param string $user User id. + * @param string $label Label (enabled, also_mail...). + * + * @return string With HTML code + */ function notifications_print_user_switch($source, $user, $label) { $status = notifications_get_user_label_status($source, $user, $label); From dc9decde422ad82a123e8b82b70530f4ab2b8d86 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Thu, 7 Feb 2019 16:24:49 +0100 Subject: [PATCH 038/262] ConsoleSupervisor Former-commit-id: 3c40e628883f032a449862d0161659586819e6df --- .../include/class/ConsoleSupervisor.php | 2013 +++++++ pandora_console/include/functions_config.php | 5013 +++++++++-------- 2 files changed, 4725 insertions(+), 2301 deletions(-) create mode 100644 pandora_console/include/class/ConsoleSupervisor.php diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php new file mode 100644 index 0000000000..3eaedcfcfb --- /dev/null +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -0,0 +1,2013 @@ +<?php +/** + * Extension to self monitor Pandora FMS Console + * + * @category Console Class + * @package Pandora FMS + * @subpackage Supervisor + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +global $config; + +require_once __DIR__.'/../functions.php'; +require_once $config['homedir'].'/include/functions_io.php'; +require_once $config['homedir'].'/include/functions_notifications.php'; +require_once $config['homedir'].'/include/functions_servers.php'; + +// Enterprise includes. +enterprise_include_once('include/functions_metaconsole.php'); +enterprise_include_once('include/functions_license.php'); + + +/** + * Base class to run scheduled tasks in cron extension + */ +class ConsoleSupervisor +{ + + /** + * Show if console supervisor is enabled or not. + * + * @var boolean + */ + public $enabled; + + /** + * Value of 'id' from tnotification_source + * where description is 'System status' + * + * @var integer + */ + public $sourceId; + + /** + * Target groups to be notified. + * + * @var array + */ + public $targetGroups; + + /** + * Target users to be notified. + * + * @var array + */ + public $targetUsers; + + /** + * Targets up to date. + * + * @var boolean + */ + public $targetUpdated; + + /** + * Show messages or not. + * + * @var boolean + */ + public $verbose; + + + /** + * Constructor. + * + * @param boolean $verbose Show output while executing or not. + * + * @return class This object + */ + public function __construct(bool $verbose=true) + { + $source = db_get_row( + 'tnotification_source', + 'description', + io_safe_input('System status') + ); + + $this->verbose = $verbose; + + if ($source === false) { + $this->enabled = false; + $this->sourceId = null; + + $this->targetGroups = null; + $this->targetUsers = null; + } else { + $this->enabled = (bool) $source['enabled']; + $this->sourceId = $source['id']; + + // Assign targets. + $targets = get_notification_source_targets($this->sourceId); + $this->targetGroups = $targets['groups']; + $this->targetUsers = $targets['users']; + $this->targetUpdated = true; + } + + return $this; + } + + + /** + * Warn a message. + * + * @param string $msg Message. + * + * @return void + */ + public function warn(string $msg) + { + if ($this->verbose === true) { + echo date('M j G:i:s').' ConsoleSupervisor: '.$msg."\n"; + } + } + + + /** + * Manage scheduled tasks. + * + * @return void + */ + public function run() + { + global $config; + + if ($this->enabled === false) { + // Feature not enabled. + return; + } + + if ($this->sourceId === null) { + // Source not detected. + return; + } + + if ($this->verbose === true) { + if (enterprise_hook('cron_supervisor_lock') === false) { + // Cannot continue. Locked. + exit; + } + } + + // Enterprise support. + if (file_exists($config['homedir'].'/'.ENTERPRISE_DIR.'/load_enterprise.php')) { + include_once $config['homedir'].'/'.ENTERPRISE_DIR.'/load_enterprise.php'; + } + + $time = get_system_time(); + $scheduled_tasks = db_get_all_rows_in_table('tuser_task_scheduled'); + if (!$scheduled_tasks) { + $scheduled_tasks = []; + } + + // Automatic checks launched by supervisor. + $this->warn('running.'); + + /* + * Check license. + * NOTIF.LICENSE.EXPIRATION + */ + + $this->checkLicense(); + + /* + * Check number of files in attachment: + * NOTIF.FILES.ATTACHMENT + */ + + $this->checkAttachment(); + + /* + * Files in data_in: + * NOTIF.FILES.DATAIN (>1000) + * NOTIF.FILES.DATAIN.BADXML (>150) + */ + + $this->checkDataIn(); + + /* + * Check module queues not growing: + * NOTIF.SERVER.QUEUE.ID_SERVER + */ + + $this->checkServers(); + + /* + * Check component statuses (servers down - frozen). + * NOTIF.SERVER.STATUS.ID_SERVER + */ + + $this->checkPandoraServers(); + + /* + * Check at least 1 server running in master mode. + * NOTIF.SERVER.MASTER + */ + + $this->checkPandoraServerMasterAvailable(); + + /* + * PHP configuration warnings: + * NOTIF.PHP.SAFE_MODE + * NOTIF.PHP.INPUT_TIME + * NOTIF.PHP.EXECUTION_TIME + * NOTIF.PHP.UPLOAD_MAX_FILESIZE + * NOTIF.PHP.MEMORY_LIMIT + * NOTIF.PHP.DISABLE_FUNCTIONS + * NOTIF.PHP.PHANTOMJS + * NOTIF.PHP.VERSION + */ + + $this->checkPHPSettings(); + + /* + * Check connection with historical DB (if enabled). + * NOTIF.HISTORYDB + */ + + $this->checkPandoraHistoryDB(); + + /* + * Check pandoradb running in main DB. + * Check pandoradb running in historical DB. + * NOTIF.PANDORADB + * NOTIF.PANDORADB.HISTORICAL + */ + + $this->checkPandoraDBMaintenance(); + + /* + * Check historical DB MR version. + * NOTIF.HISTORYDB.MR + */ + + $this->checkPandoraHistoryDBMR(); + + /* + * Check external components. + * NOTIF.EXT.ELASTICSEARCH + * NOTIF.EXT.LOGSTASH + * + */ + + $this->checkExternalComponents(); + + /* + * Check Metaconsole synchronization issues. + * NOTIF.METACONSOLE.DB_CONNECTION + */ + + $this->checkMetaconsole(); + + /* + * Check incoming scheduled downtimes (< 15d). + * NOTIF.DOWNTIME + */ + + $this->checkDowntimes(); + + /* + * Check if instance is registered. + * NOTIF.UPDATEMANAGER.REGISTRATION + */ + + $this->checkUpdateManagerRegistration(); + + /* + * Check if event storm protection is activated. + * NOTIF.MISC.EVENTSTORMPROTECTION + */ + + $this->checkEventStormProtection(); + + /* + * Check if develop_bypass is enabled. + * NOTIF.MISC.DEVELOPBYPASS + */ + + $this->checkDevelopBypass(); + + /* + * Check if fontpath exists. + * NOTIF.MISC.FONTPATH + */ + + $this->checkFont(); + + /* + * Check if default user and password exists. + * NOTIF.SECURITY.DEFAULT_PASSWORD + */ + + $this->checkDefaultPassword(); + + /* + * Check if there's an active subscription. + * NOTIF.NEWSLETTER.SUBSCRIPTION + */ + + $this->checkNewsletterSubscription(); + + /* + * Check if there're new updates. + * NOTIF.UPDATEMANAGER.OPENSETUP + * NOTIF.UPDATEMANAGER.UPDATE + */ + + $this->checkUpdates(); + + if ($this->verbose === true) { + // Release the lock. + enterprise_hook('cron_supervisor_release_lock'); + } + + } + + + /** + * Update targets for given notification using object targets. + * + * @param integer $notification_id Current notification. + * + * @return void + */ + public function updateTargets(int $notification_id) + { + if (is_array($this->targetUsers) === true + && count($this->targetUsers) > 0 + ) { + // Process user targets. + $insertion_string = ''; + $users_sql = 'INSERT INTO tnotification_user(id_mensaje,id_user)'; + foreach ($this->targetUsers as $user) { + $insertion_string .= sprintf( + '(%d,"%s")', + $notification_id, + $user['id_user'] + ); + $insertion_string .= ','; + + // Send mail. + if (isset($user['also_mail']) && $user['also_mail'] == 1) { + $this->warn('Mailing user: '.$user['id_user']."\n"); + // TODO: Add sendmail sequence. + } + } + + $insertion_string = substr($insertion_string, 0, -1); + + db_process_sql($users_sql.' VALUES '.$insertion_string); + } + + if (is_array($this->targetGroups) === true + && count($this->targetGroups) > 0 + ) { + // Process group targets. + $insertion_string = ''; + $groups_sql = 'INSERT INTO tnotification_group(id_mensaje,id_group)'; + foreach ($this->targetGroups as $group) { + $insertion_string .= sprintf( + '(%d,"%s")', + $notification_id, + $group['id_group'] + ); + $insertion_string .= ','; + + // Send mail. + if (isset($group['also_mail']) && $group['also_mail'] == 1) { + $this->warn('Mailing group: '.$group['id_group']."\n"); + // TODO: Add sendmail sequence. + } + } + + $insertion_string = substr($insertion_string, 0, -1); + + db_process_sql($groups_sql.' VALUES '.$insertion_string); + } + + } + + + /** + * Generates notifications for target users and groups. + * + * @param array $data Message to be delivered: + * - boolean status (false: notify, true: do not notify) + * - string title + * - string message + * - string url. + * @param integer $source_id Target source_id, by default $this->sourceId. + * @param integer $max_age Maximum age for generated notification. + * + * @return void + */ + public function notify( + array $data, + int $source_id=0, + int $max_age=86400 + ) { + // Uses 'check failed' logic. + if (is_array($data) === false) { + // Skip. + return; + } + + if ($this->targetUpdated === false) { + $targets = get_notification_source_targets($this->sourceId); + $this->targetGroups = $targets['groups']; + $this->targetUsers = $targets['users']; + $this->targetUpdated = false; + } + + if ($source_id === 0) { + $source_id = $this->sourceId; + // Assign targets. + $targets = get_notification_source_targets($source_id); + $this->targetGroups = $targets['groups']; + $this->targetUsers = $targets['users']; + $this->targetUpdated = false; + } + + switch ($data['type']) { + case 'NOTIF.LICENSE.EXPIRATION': + case 'NOTIF.FILES.ATTACHMENT': + case 'NOTIF.FILES.DATAIN': + case 'NOTIF.FILES.DATAIN.BADXML': + case 'NOTIF.PHP.SAFE_MODE': + case 'NOTIF.PHP.INPUT_TIME': + case 'NOTIF.PHP.EXECUTION_TIME': + case 'NOTIF.PHP.UPLOAD_MAX_FILESIZE': + case 'NOTIF.PHP.MEMORY_LIMIT': + case 'NOTIF.PHP.DISABLE_FUNCTIONS': + case 'NOTIF.PHP.PHANTOMJS': + case 'NOTIF.PHP.VERSION': + case 'NOTIF.HISTORYDB': + case 'NOTIF.PANDORADB': + case 'NOTIF.PANDORADB.HISTORICAL': + case 'NOTIF.HISTORYDB.MR': + case 'NOTIF.EXT.ELASTICSEARCH': + case 'NOTIF.EXT.LOGSTASH': + case 'NOTIF.METACONSOLE.DB_CONNECTION': + case 'NOTIF.DOWNTIME': + case 'NOTIF.UPDATEMANAGER.REGISTRATION': + case 'NOTIF.MISC.EVENTSTORMPROTECTION': + case 'NOTIF.MISC.DEVELOPBYPASS': + case 'NOTIF.MISC.FONTPATH': + case 'NOTIF.SECURITY.DEFAULT_PASSWORD': + case 'NOTIF.NEWSLETTER.SUBSCRIPTION': + case 'NOTIF.UPDATEMANAGER.OPENSETUP': + case 'NOTIF.UPDATEMANAGER.UPDATE': + + default: + // NOTIF.SERVER.STATUS. + // NOTIF.SERVER.STATUS.ID_SERVER. + // NOTIF.SERVER.QUEUE.ID_SERVER. + // NOTIF.SERVER.MASTER. + // NOTIF.SERVER.STATUS.ID_SERVER. + if (preg_match('/^NOTIF.SERVER/', $data['type']) === true) { + // Component notifications require be inmediate. + $max_age = 0; + } + + // Else ignored. + break; + } + + // Get previous notification. + $prev = db_get_row( + 'tmensajes', + 'subtype', + $data['type'] + ); + + if ($prev !== false + && (time() - $prev['timestamp']) > $max_age + ) { + // Clean previous notification. + $this->cleanNotifications($data['type']); + } else if ($prev !== false) { + // Avoid creation. Previous notification is still valid. + // Update message with latest information. + $r = db_process_sql_update( + 'tmensajes', + [ + 'mensaje' => io_safe_input($data['message']), + 'subject' => io_safe_input($data['title']), + ], + ['id_mensaje' => $prev['id_mensaje']] + ); + + $this->updateTargets($prev['id_mensaje']); + return; + } + + if (isset($data['type']) === false) { + $data['type'] = ''; + } + + // Create notification. + $notification = []; + $notification['timestamp'] = time(); + $notification['id_source'] = $source_id; + $notification['mensaje'] = io_safe_input($data['message']); + $notification['subject'] = io_safe_input($data['title']); + $notification['subtype'] = $data['type']; + $notification['url'] = io_safe_input($data['url']); + + $id = db_process_sql_insert('tmensajes', $notification); + + if ($id === false) { + // Failed to generate notification. + $this->warn('Failed to generate notification'); + return; + } + + $this->updateTargets($id); + + } + + + /** + * Deletes useless notifications. + * + * @param string $subtype Subtype to be deleted. + * + * @return mixed False in case of error or invalid values passed. + * Affected rows otherwise + */ + public function cleanNotifications(string $subtype) + { + $not_count = db_get_value_sql( + sprintf( + 'SELECT count(*) as n + FROM tmensajes + WHERE subtype like "%s"', + $subtype + ) + ); + + if ($not_count > 0) { + return db_process_sql_delete( + 'tmensajes', + sprintf('subtype like "%s"', $subtype) + ); + } + + return true; + } + + + /** + * Check license status and validity. + * + * @return boolean Return true if license is valid, false if not. + */ + public function checkLicense() + { + global $config; + + $license = enterprise_hook('license_get_info'); + if ($license === ENTERPRISE_NOT_HOOK) { + return false; + } + + $days_to_expiry = ((strtotime($license['expiry_date']) - time()) / (60 * 60 * 24)); + + if (($days_to_expiry <= 15) && ($days_to_expiry > 0)) { + // Warn user if license is going to expire in 15 days or less. + $this->notify( + [ + 'type' => 'NOTIF.LICENSE_EXPIRATION', + 'title' => __('License is going to expire.'), + 'message' => __( + 'Your license is going to expire in %d days. Please contact sales.', + $days_to_expiry + ), + 'url' => ui_get_full_url( + 'index.php?sec=gsetup&sec2=godmode/setup/license' + ), + ] + ); + } else if ($days_to_expiry < 0) { + // Warn user, license has expired. + $this->notify( + [ + 'type' => 'NOTIF.LICENSE.EXPIRATION', + 'title' => __('License is expired.'), + 'message' => __('Your license has expired. Please contact sales.'), + 'url' => ui_get_full_url( + 'index.php?sec=gsetup&sec2=godmode/setup/license' + ), + ] + ); + return false; + } else { + $this->cleanNotifications('NOTIF.LICENSE.EXPIRATION'); + } + + return true; + + } + + + /** + * Count files in target path. + * + * @param string $path Path to be checked. + * @param string $regex Regular expression to find files. + * @param integer $max_files Maximum number of files to find. + * + * @return integer Number of files in target path. + */ + public function countFiles( + string $path='', + string $regex='', + int $max_files=500 + ) { + if (empty($path) === true) { + return -1; + } + + $nitems = 0; + + // Count files up to max_files. + $dir = opendir($path); + + if ($dir !== false) { + // Used instead of glob to avoid check directories with + // more than 1M files. + while (false !== ($file = readdir($dir)) && $nitems <= $max_files) { + if ($file != '.' && $file != '..') { + if (empty($regex) === false) { + if (preg_match($regex, $file) !== 1) { + $nitems++; + continue; + } + } + + $nitems++; + } + } + + closedir($dir); + } + + return $nitems; + } + + + /** + * Check excesive files in attachment directory. + * + * @return void + */ + public function checkAttachment() + { + global $config; + + if (is_writable($config['attachment_store']) !== true) { + $this->notify( + [ + 'type' => 'NOTIF.WRITABLE.ATTACHMENT', + 'title' => __('Attachment directory is not writable.'), + 'message' => __( + 'Directory %s is not writable. Please configure proper permissions.', + $config['attachment_store'] + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' + ), + ] + ); + return; + } else { + $this->cleanNotifications('NOTIF.WRITABLE.ATTACHMENT'); + } + + $filecount = $this->countFiles( + $config['attachment_store'], + '', + $config['num_files_attachment'] + ); + if ($filecount > $config['num_files_attachment']) { + $this->notify( + [ + 'type' => 'NOTIF.FILES.ATTACHMENT', + 'title' => __('There are too much files in attachment directory.'), + 'message' => __( + 'There are more than %d files in attachment, you should consider cleaning up your attachment directory manually.', + $config['num_files_attachment'] + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.FILES.ATTACHMENT'); + } + + } + + + /** + * Check excesive files in data_in directory. + * + * @return void + */ + public function checkDataIn() + { + global $config; + + if (enterprise_installed() + && isset($config['license_nms']) + && $config['license_nms'] != 1 + ) { + if (is_readable($config['remote_config']) !== true) { + $this->notify( + [ + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG', + 'title' => __('Remote configuration directory is not readable.'), + 'message' => __( + 'Remote configuration directory %s is not readable. Please configure it.', + $config['remote_config'] + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' + ), + ] + ); + return; + } else { + $this->cleanNotifications( + 'NOTIF.PERMISSIONS.REMOTE_CONFIG' + ); + } + + if (is_writable($config['remote_config'].'/conf') !== true) { + $this->notify( + [ + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF', + 'title' => __('Remote configuration directory is not writable.'), + 'message' => __( + 'Remote configuration directory %s is not writable. Please configure it.', + $config['remote_config'].'/conf' + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' + ), + ] + ); + } else { + $this->cleanNotifications( + 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF' + ); + } + + if (is_writable($config['remote_config'].'/collections') !== true) { + $this->notify( + [ + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS', + 'title' => __('Remote collections directory is not writable.'), + 'message' => __( + 'Collections directory %s is not writable. Please configure it.', + $config['remote_config'].'/collections' + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' + ), + ] + ); + } else { + $this->cleanNotifications( + 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS' + ); + } + + if (is_writable($config['remote_config'].'/md5') !== true) { + $this->notify( + [ + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5', + 'title' => __('Remote md5 directory is not writable.'), + 'message' => __( + 'MD5 directory %s is not writable. Please configure it.', + $config['remote_config'].'/md5' + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' + ), + ] + ); + } else { + $this->cleanNotifications( + 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5' + ); + } + } else { + $this->cleanNotifications('NOTIF.PERMISSIONS.REMOTE_CONF%'); + } + + $MAX_FILES_DATA_IN = 1000; + $MAX_BADXML_FILES_DATA_IN = 150; + + $filecount = $this->countFiles( + $config['remote_config'], + '', + $MAX_FILES_DATA_IN + ); + // If cannot open directory, count is '-1', skip. + if ($filecount > $MAX_FILES_DATA_IN) { + $this->notify( + [ + 'type' => 'NOTIF.FILES.DATAIN', + 'title' => __('There are too much files in spool').'.', + 'message' => __( + 'There are more than %d files in %s, you should consider checking DataServer performance', + $MAX_FILES_DATA_IN, + $config['remote_config'] + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.FILES.DATAIN'); + } + + $filecount = $this->countFiles( + $config['remote_config'], + '/.*BADXML/', + $MAX_BADXML_FILES_DATA_IN + ); + // If cannot open directory, count is '-1', skip. + if ($filecount > $MAX_BADXML_FILES_DATA_IN) { + $this->notify( + [ + 'type' => 'NOTIF.FILES.DATAIN.BADXML', + 'title' => __('There are too much BADXML files in spool.'), + 'message' => __( + 'There are more than %d files in %s, you should consider checking software agents.', + $MAX_BADXML_FILES_DATA_IN, + $config['remote_config'] + ), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.FILES.DATAIN.BADXML'); + } + } + + + /** + * Check growing queues in servers. + * + * @return void + */ + public function checkServers() + { + global $config; + + $idx_file = $config['attachment_store'].'/.cron.supervisor.servers.idx'; + + $MAX_QUEUE = 1500; + $MAX_GROWN = 50; + + $queue_state = []; + $previous = []; + $new = []; + + if (file_exists($idx_file) === true) { + // Read previous values from file. + $previous = json_decode(file_get_contents($idx_file), true); + } + + // DataServer queue status. + $queue_state = db_get_all_rows_sql( + 'SELECT id_server,name,server_type,queued_modules,status + FROM tserver ORDER BY 1' + ); + + $time = time(); + foreach ($queue_state as $queue) { + $key = $queue['id_server']; + $type = $queue['server_type']; + $new_data[$key] = $queue['queued_modules']; + + // Compare queue increments in a not over 900 seconds. + if (empty($previous[$key]['modules']) + || ($time - $previous[$key]['utime']) > 900 + ) { + $previous[$key]['modules'] = 0; + } + + $modules_queued = ($queue['queued_modules'] - $previous[$key]['modules']); + + // 50 Modules queued since last check. Or more than 1500 queued. + if ($modules_queued > $MAX_GROWN + || $queue['queued_modules'] > $MAX_QUEUE + ) { + $msg = 'Queue has grown %d modules. Total %d'; + if ($modules_queued <= 0) { + $msg = 'Queue is decreasing in %d modules. But there are %d queued.'; + $modules_queued *= -1; + } + + $this->notify( + [ + 'type' => 'NOTIF.SERVER.QUEUE.'.$key, + 'title' => __( + '%s (%s) performance is being lacked.', + servers_get_server_string_name($type), + $queue['name'] + ), + 'message' => __( + $msg, + $modules_queued, + $queue['queued_modules'] + ), + 'url' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.SERVER.QUEUE.'.$key); + } + + $new[$key]['modules'] = $queue['queued_modules']; + $new[$key]['utime'] = $time; + } + + file_put_contents($idx_file, json_encode($new)); + } + + + /** + * Check Pandora component statuses. + * + * @return void + */ + public function checkPandoraServers() + { + $servers = db_get_all_rows_sql( + 'SELECT + id_server, + name, + server_type, + status, + unix_timestamp() - unix_timestamp(keepalive) as downtime + FROM tserver + WHERE + unix_timestamp() - unix_timestamp(keepalive) > server_keepalive + OR status = 0' + ); + + if ($servers === false) { + $nservers = db_get_value_sql( + 'SELECT count(*) as nservers + FROM tserver' + ); + if ($nservers == 0) { + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Configuration'; + if ($config['language'] == 'es') { + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Configuracion'; + } + + $this->notify( + [ + 'type' => 'NOTIF.SERVER.STATUS', + 'title' => __('No servers available.'), + 'message' => __('There are no servers registered in this console, please check installation guide.'), + 'url' => $url, + ] + ); + } + + // At this point there's no servers with issues. + $this->cleanNotifications('NOTIF.SERVER.STATUS%'); + return; + } + + foreach ($servers as $server) { + if ($server['status'] == 1) { + // Fatal error. Component has die. + $msg = __( + '%s (%s) crashed.', + servers_get_server_string_name($server['server_type']), + $server['name'] + ); + + $description = __( + '%s (%s) has died, please check log files', + servers_get_server_string_name($server['server_type']), + $server['name'] + ); + } else { + // Non-fatal error. Controlated exit. Component is not running. + $msg = __( + '%s (%s) is stopped.', + servers_get_server_string_name($server['server_type']), + $server['name'] + ); + $description = __( + '%s (%s) is stopped, please check configuration file or remove this server from server list.', + servers_get_server_string_name($server['server_type']), + $server['name'] + ); + } + + $this->notify( + [ + 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], + 'title' => $msg, + 'message' => $description, + 'url' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60' + ), + ] + ); + } + } + + + /** + * Checks if there's at last one server running in master mode. + * + * @return void + */ + public function checkPandoraServerMasterAvailable() + { + $n_masters = db_get_value_sql( + 'SELECT + count(*) as n + FROM tserver + WHERE + unix_timestamp() - unix_timestamp(keepalive) <= server_keepalive + AND master > 0 + AND status = 1' + ); + + if ($n_masters === false) { + // Failed to retrieve server list. + return; + } + + if ($n_masters <= 0) { + // No server running in master. + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Configuration#master'; + if ($config['language'] == 'es') { + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Configuracion#master'; + } + + $this->notify( + [ + 'type' => 'NOTIF.SERVER.MASTER', + 'title' => __('No master servers found.'), + 'message' => __('You should define at last one server to run as master, please check documentation.'), + 'url' => $url, + ] + ); + } else { + $this->cleanNotifications('NOTIF.SERVER.MASTER%'); + } + + } + + + /** + * Checks PHP settings to be correct. Generates system notifications if not. + * + * @return void + */ + public function checkPHPSettings() + { + global $config; + + $PHPupload_max_filesize = config_return_in_bytes( + ini_get('upload_max_filesize') + ); + + // PHP configuration. + $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'); + $PHPupload_max_filesize_min = config_return_in_bytes('800M'); + $PHPmemory_limit_min = config_return_in_bytes('500M'); + + // PhantomJS status. + $result_ejecution = exec($config['phantomjs_bin'].'/phantomjs --version'); + + // PHP version checks. + $php_version = phpversion(); + $php_version_array = explode('.', $php_version); + + if ($PHPsafe_mode === '1') { + $this->notify( + [ + 'type' => 'NOTIF.PHP.SAFE_MODE', + 'title' => __('PHP safe mode is enabled. Some features may not properly work.'), + 'message' => __('To disable, change it on your PHP configuration file (php.ini) and put safe_mode = Off (Dont forget restart apache process after changes)'), + 'url' => ui_get_full_url('index.php'), + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.SAFE_MODE'); + } + + if ($PHPmax_input_time !== '-1') { + $this->notify( + [ + 'type' => 'NOTIF.PHP.INPUT_TIME', + 'title' => sprintf( + __("Not recommended '%s' value in PHP configuration"), + 'max_input_time' + ), + 'message' => sprintf( + __('Recommended value is %s'), + '-1 ('.__('Unlimited').')' + ).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), + 'url' => ui_get_full_url('index.php'), + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.INPUT_TIME'); + } + + if ($PHPmax_execution_time !== '0') { + $this->notify( + [ + 'type' => 'NOTIF.PHP.EXECUTION_TIME', + 'title' => sprintf( + __("Not recommended '%s' value in PHP configuration"), + 'max_execution_time' + ), + 'message' => sprintf( + __('Recommended value is: %s'), + '0 ('.__('Unlimited').')' + ).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), + 'url' => ui_get_full_url('index.php'), + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.EXECUTION_TIME'); + } + + if ($PHPupload_max_filesize < $PHPupload_max_filesize_min) { + $this->notify( + [ + 'type' => 'NOTIF.PHP.UPLOAD_MAX_FILESIZE', + 'title' => sprintf( + __("Not recommended '%s' value in PHP configuration"), + 'upload_max_filesize' + ), + 'message' => sprintf( + __('Recommended value is: %s'), + sprintf(__('%s or greater'), '800M') + ).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), + 'url' => ui_get_full_url('index.php'), + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.UPLOAD_MAX_FILESIZE'); + } + + if ($PHPmemory_limit < $PHPmemory_limit_min && $PHPmemory_limit !== '-1') { + $this->notify( + [ + 'type' => 'NOTIF.PHP.MEMORY_LIMIT', + 'title' => sprintf( + __("Not recommended '%s' value in PHP configuration"), + 'memory_limit' + ), + 'message' => sprintf( + __('Recommended value is: %s'), + sprintf(__('%s or greater'), '500M') + ).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), + 'url' => ui_get_full_url('index.php'), + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.MEMORY_LIMIT'); + } + + if (preg_match('/system/', $PHPdisable_functions) || preg_match('/exec/', $PHPdisable_functions)) { + $this->notify( + [ + 'type' => 'NOTIF.PHP.DISABLE_FUNCTIONS', + 'title' => __('Problems with disable functions in PHP.INI'), + 'message' => __('Variable disable_functions containts functions system() or exec(), in PHP configuration file (php.ini)').'<br /><br />'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), + 'url' => ui_get_full_url('index.php'), + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.DISABLE_FUNCTIONS'); + } + + if (!isset($result_ejecution) || $result_ejecution == '') { + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Configuration#Phantomjs'; + if ($config['language'] == 'es') { + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Configuracion#Phantomjs'; + } + + $this->notify( + [ + 'type' => 'NOTIF.PHP.PHANTOMJS', + 'title' => __('phantomjs is not installed'), + 'message' => __('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:'), + 'url' => $url, + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.PHANTOMJS'); + } + + if ($php_version_array[0] < 7) { + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:_PHP_7'; + if ($config['language'] == 'es') { + $url = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Instalaci%C3%B3n_y_actualizaci%C3%B3n_PHP_7'; + } + + $this->notify( + [ + 'type' => 'NOTIF.PHP.VERSION', + 'title' => __('PHP UPDATE REQUIRED'), + 'message' => __('For a correct operation of PandoraFMS, PHP must be updated to version 7.0 or higher.').'<br>'.__('Otherwise, functionalities will be lost.').'<br>'."<ol><li style='color: #676767'>".__('Report download in PDF format').'</li>'."<li style='color: #676767'>".__('Emails Sending').'</li><li style="color: #676767">'.__('Metaconsole Collections').'</li><li style="color: #676767">...</li></ol>', + 'url' => $url, + ] + ); + } else { + $this->cleanNotifications('NOTIF.PHP.VERSION'); + } + } + + + /** + * Checks if history DB is available. + * + * @return void + */ + public function checkPandoraHistoryDB() + { + global $config; + + if (isset($config['history_db_enabled']) + && $config['history_db_enabled'] == 1 + ) { + if (! isset($config['history_db_connection']) + || $config['history_db_connection'] === false + ) { + ob_start(); + $config['history_db_connection'] = db_connect( + $config['history_db_host'], + $config['history_db_name'], + $config['history_db_user'], + io_output_password($config['history_db_pass']), + $config['history_db_port'], + false + ); + ob_get_clean(); + } + + if ($config['history_db_connection'] === false) { + $this->notify( + [ + 'type' => 'NOTIF.HISTORYDB', + 'title' => __('Historical database not available'), + 'message' => __('Historical database is enabled. But not available using given configuration. Please check it.'), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.HISTORYDB'); + } + } else { + $this->cleanNotifications('NOTIF.HISTORYDB'); + } + } + + + /** + * Check if pandora_db is running in all available DB instances. + * Generating notifications. + * + * @return void + */ + public function checkPandoraDBMaintenance() + { + global $config; + + // Main DB db_maintenance value. + $db_maintance = db_get_value( + '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); + + // Limit 48h. + if ($last_maintance > 172800) { + $this->notify( + [ + 'type' => 'NOTIF.PANDORADB', + 'title' => __('Database maintance problem'), + 'message' => __('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()), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.PANDORADB'); + } + + if (isset($config['history_db_enabled']) + && $config['history_db_enabled'] == 1 + ) { + // History DB db_maintenance value. + $db_maintenance = db_get_value( + 'value', + 'tconfig', + 'token', + 'db_maintenance', + true + ); + + // History db connection is supossed to be enabled since we use + // db_get_value, wich initializes target db connection. + if (empty($db_maintance)) { + $sql = sprintf( + 'UPDATE tconfig SET `value`=%d WHERE `token`="%s"', + date('U'), + 'db_maintenance' + ); + $affected_rows = db_process_sql( + $sql, + $rettype = 'affected_rows', + $dbconnection = $config['history_db_connection'] + ); + + if ($affected_rows == 0) { + // Failed to update. Maybe the row does not exist? + $sql = sprintf( + 'INSERT INTO tconfig(`token`,`value`) VALUES("%s",%d)', + 'db_maintenance', + date('U') + ); + + $affected_rows = db_process_sql( + $sql, + $rettype = 'affected_rows', + $dbconnection = $config['history_db_connection'] + ); + } + } + + $last_maintance = (date('U') - $db_maintance); + + // Limit 48h. + if ($last_maintance > 172800) { + $this->notify( + [ + 'type' => 'NOTIF.PANDORADB.HISTORY', + 'title' => __( + 'Historical database maintance problem.' + ), + 'message' => __('Your historical database is not being 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()), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' + ), + ] + ); + } else { + // Historical db working fine. + $this->cleanNotifications('NOTIF.PANDORADB.HISTORY'); + } + } else { + // Disabled historical db. + $this->cleanNotifications('NOTIF.PANDORADB.HISTORY'); + } + } + + + /** + * Check MR package applied in historical DB + * + * @return void + */ + public function checkPandoraHistoryDBMR() + { + global $config; + + if (isset($config['history_db_enabled']) + && $config['history_db_enabled'] == 1 + ) { + $mrh_version = db_get_value( + 'value', + 'tconfig', + 'token', + 'MR', + true + ); + if ($mrh_version != $config['MR']) { + $this->notify( + [ + 'type' => 'NOTIF.HISTORYDB.MR', + 'title' => __('Historical database MR missmatch'), + 'message' => __('Your historical database is not using the same schema of main DB. This could produce anomalyes while storing historical data.'), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db' + ), + ] + ); + } else { + // MR version OK. + $this->cleanNotifications('NOTIF.HISTORYDB.MR'); + } + } else { + // Disabled historical db. + $this->cleanNotifications('NOTIF.HISTORYDB.MR'); + } + } + + + /** + * Check if elasticsearch is available. + * + * @return void + */ + public function checkExternalComponents() + { + global $config; + + // Cannot check logstash, configuration is only available from server. + // Cannot check selenium, configuration is only available from server. + if (isset($config['log_collector']) + && $config['log_collector'] == 1 + ) { + $elasticsearch = @fsockopen( + $config['elasticsearch_ip'], + $config['elasticsearch_port'], + $errno, + $errstr, + 5 + ); + + if ($elasticsearch === false) { + $this->notify( + [ + 'type' => 'NOTIF.EXT.ELASTICSEARCH', + 'title' => __('Log collector cannot connect to ElasticSearch'), + 'message' => __('ElasticSearch is not available using current configuration. Please check it.'), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=log' + ), + ] + ); + } else { + fclose($elasticsearch); + $this->cleanNotifications('NOTIF.EXT.ELASTICSEARCH'); + } + } else { + $this->cleanNotifications('NOTIF.EXT.ELASTICSEARCH'); + } + + } + + + /** + * Checks if metaconsole DB connection is ready. + * + * @return void + */ + public function checkMetaconsole() + { + global $config; + + $check_ok = true; + + if (license_free() + && is_metaconsole() === false + && isset($config['node_metaconsole']) + && $config['node_metaconsole'] == 1 + ) { + // Check if node is successfully registered in MC. + $server_name = db_get_value( + 'distinct(name)', + 'tserver', + 'server_type', + 1 + ); + + $mc_db_conn = enterprise_hook( + 'metaconsole_load_external_db', + [ + [ + 'dbhost' => $config['replication_dbhost'], + 'dbuser' => $config['replication_dbuser'], + 'dbpass' => io_output_password( + $config['replication_dbpass'] + ), + 'dbname' => $config['replication_dbname'], + ], + ] + ); + + if ($mc_db_conn === NOERR) { + $check_ok = true; + } else { + $check_ok = false; + } + + // Restore the default connection. + enterprise_hook('metaconsole_restore_db'); + } + + if ($check_ok === true) { + $this->cleanNotifications('NOTIF.METACONSOLE.DB_CONNECTION'); + } else { + $this->notify( + [ + 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', + 'title' => __('Metaconsole DB is not available.'), + 'message' => __('Cannot connect with Metaconsole DB using stored configuration. Please check it.'), + 'url' => ui_get_full_url( + 'index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise' + ), + ] + ); + } + } + + + /** + * Check if there are any incoming scheduled downtime in less than 15d. + * + * @return void + */ + public function checkDowntimes() + { + // 15 Days. + $THRESHOLD_SECONDS = (15 * 3600 * 24); + + // Check first if any planned runtime is running. + $currently_running = (int) db_get_value_sql( + 'SELECT count(*) as "n" FROM tplanned_downtime + WHERE executed = 1' + ); + + if ($currently_running > 0) { + $this->notify( + [ + 'type' => 'NOTIF.DOWNTIME', + 'title' => __('Scheduled downtime running.'), + 'message' => __('A scheduled downtime is running. Some monitorization data won\'t be available while downtime is taking place.'), + 'url' => ui_get_full_url( + 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list' + ), + ] + ); + return; + } else { + // Retrieve downtimes. + $downtimes = db_get_all_rows_sql( + 'SELECT * FROM tplanned_downtime + WHERE + (type_execution="once" AND date_from > now()) + OR type_execution!="once" ORDER BY `id` DESC' + ); + + // Initialize searchers. + $next_downtime_begin = PHP_INT_MAX; + $now = time(); + + if ($downtimes === false) { + $this->cleanNotifications('NOTIF.DOWNTIME'); + return; + } + + $weekdays = [ + 'monday', + 'tuesday', + 'wednesday', + 'thursday', + 'friday', + 'saturday', + 'sunday', + ]; + + foreach ($downtimes as $dt) { + if ($dt['type_execution'] == 'once' + && ($dt['date_from'] - $now) < $THRESHOLD_SECONDS + ) { + if ($next_downtime_begin > $dt['date_from']) { + // Store datetime for next downtime. + $next_downtime_begin = $dt['date_from']; + $next_downtime_end = $dt['date_to']; + } + } else if ($dt['type_periodicity'] == 'monthly') { + $schd_time_begin = explode( + ':', + $dt['periodically_time_from'] + ); + $schd_time_end = explode( + ':', + $dt['periodically_time_to'] + ); + + $begin = mktime( + // Hour. + $schd_time_begin[0], + // Minute. + $schd_time_begin[1], + // Second. + $schd_time_begin[2], + // Month. + date('n', $now), + // Day. + $dt['periodically_day_from'], + // Year. + date('Y', $now) + ); + + $end = mktime( + // Hour. + $schd_time_end[0], + // Minute. + $schd_time_end[1], + // Second. + $schd_time_end[2], + // Month. + date('n', $now), + // Day. + $dt['periodically_day_to'], + // Year. + date('Y', $now) + ); + + if ($next_downtime_begin > $begin) { + $next_downtime_begin = $begin; + $next_downtime_end = $end; + } + } else if ($dt['type_periodicity'] == 'weekly') { + // Always applies. + $current_week_day = date('N', $now); + + $schd_time_begin = explode( + ':', + $dt['periodically_time_from'] + ); + $schd_time_end = explode( + ':', + $dt['periodically_time_to'] + ); + + $i = 0; + $max = 7; + while ($dt[$weekdays[(($current_week_day + $i) % 7)]] != 1 + && $max-- >= 0 + ) { + // Calculate day of the week matching downtime + // definition. + $i++; + } + + if ($max < 0) { + // No days set. + continue; + } + + // Calculate utimestamp. + $begin = mktime( + // Hour. + $schd_time_begin[0], + // Minute. + $schd_time_begin[1], + // Second. + $schd_time_begin[2], + // Month. + date('n', $now), + // Day. + (date('j', $now) + $i + 1), + // Year. + date('Y', $now) + ); + + $end = mktime( + // Hour. + $schd_time_end[0], + // Minute. + $schd_time_end[1], + // Second. + $schd_time_end[2], + // Month. + date('n', $now), + // Day. + (date('j', $now) + $i + 1), + // Year. + date('Y', $now) + ); + + if ($next_downtime_begin > $begin) { + $next_downtime_begin = $begin; + $next_downtime_end = $end; + } + } + } + + if ($next_downtime_begin != PHP_INT_MAX) { + $this->notify( + [ + 'type' => 'NOTIF.DOWNTIME', + 'title' => __('Downtime scheduled soon.'), + 'message' => __( + 'A scheduled downtime is going to be executed from %s to %s. Some monitorization data won\'t be available while downtime is taking place.', + date('M j, G:i:s ', $next_downtime_begin), + date('M j, G:i:s ', $next_downtime_end) + ), + 'url' => ui_get_full_url( + 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list' + ), + ] + ); + return; + } else { + $this->cleanNotifications('NOTIF.DOWNTIME'); + } + } + } + + + /** + * Check if current instance of Pandora FMS is registered in Update Manager. + * + * @return void + */ + public function checkUpdateManagerRegistration() + { + global $config; + $login = get_parameter('login', false); + + if (license_free() === true + && users_is_admin($config['id_user']) === true + ) { + $login = get_parameter('login', false); + // Registration advice. + if ((isset($config['instance_registered']) === true + || ($config['instance_registered'] != 1)) && ($login === false) + ) { + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', + 'title' => __('This instance is not registered in the Update manager'), + 'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'), + 'url' => 'javascript: force_run_register();', + ] + ); + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); + } + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.REGISTRATION'); + } + } + + + /** + * Check if instance is subscribed to newsletter. + * + * @return void + */ + public function checkNewsletterSubscription() + { + global $config; + $login = get_parameter('login', false); + + // Newsletter advice. + $newsletter = db_get_value( + 'middlename', + 'tusuario', + 'id_user', + $config['id_user'] + ); + if (license_free() === true + && $newsletter != 1 + && $login === false + ) { + $this->notify( + [ + 'type' => 'NOTIF.NEWSLETTER.SUBSCRIPTION', + 'title' => __('Not subscribed to the newsletter'), + 'message' => __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_newsletter();"> here</a> to start the newsletter subscription process'), + 'url' => 'javascript: force_run_newsletter();', + ] + ); + } else { + $this->cleanNotifications('NOTIF.NEWSLETTER.SUBSCRIPTION'); + } + } + + + /** + * Check if user 'admin' is enabled and using default password. + * + * @return void + */ + public function checkDefaultPassword() + { + global $config; + // Check default password for "admin". + $admin_with_default_pass = db_get_value_sql( + 'SELECT count(*) FROM tusuario + WHERE + id_user="admin" + AND password="1da7ee7d45b96d0e1f45ee4ee23da560" + AND is_admin=1 + and disabled!=1' + ); + + if ($admin_with_default_pass > 0) { + $this->notify( + [ + 'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD', + 'title' => __('Default password for "Admin" user has not been changed.'), + 'message' => __('Please change the default password because is a common vulnerability reported.'), + 'url' => ui_get_full_url( + 'index.php?sec=gusuarios&sec2=godmode/users/user_list' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.SECURITY.DEFAULT_PASSWORD'); + } + } + + + /** + * Undocumented function + * + * @return void + */ + public function checkFont() + { + global $config; + + if (($config['fontpath'] == '') + || (file_exists($config['fontpath']) === false) + ) { + $this->notify( + [ + 'type' => 'NOTIF.MISC.FONTPATH', + 'title' => __('Default font doesnt exist'), + 'message' => __('Your defined font doesnt exist or is not defined. Please check font parameters in your config'), + 'url' => ui_get_full_url( + 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=vis' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.MISC.FONTPATH'); + } + } + + + /** + * Checks if develop_bypass is enabbled. + * + * @return void + */ + public function checkDevelopBypass() + { + global $develop_bypass; + + if ($develop_bypass == 1) { + $this->notify( + [ + 'type' => 'NOTIF.MISC.DEVELOPBYPASS', + 'title' => __('Developer mode is enabled'), + 'message' => __( + '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() + ), + 'url' => ui_get_full_url('index.php'), + ] + ); + } else { + $this->cleanNotifications('NOTIF.MISC.DEVELOPBYPASS'); + } + } + + + /** + * Check if event storm protection is enabled. + * + * @return void + */ + public function checkEventStormProtection() + { + global $config; + if ($config['event_storm_protection']) { + $this->notify( + [ + 'type' => 'NOTIF.MISC.EVENTSTORMPROTECTION', + 'title' => __('Event storm protection is activated.'), + 'message' => __('You need to restart server after altering this configuration setting. No events will be generated during this mode.'), + 'url' => ui_get_full_url( + 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.MISC.EVENTSTORMPROTECTION'); + } + } + + + /** + * Check if there're new updates available. + * + * @return void + */ + public function checkUpdates() + { + global $config; + + 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) { + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', + 'title' => __('Error, first setup "Open update".'), + 'message' => $message, + 'url' => ui_get_full_url( + 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general' + ), + ] + ); + } + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.OPENSETUP'); + } + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.OPENSETUP'); + } + + if ($_SESSION['new_update'] == 'new') { + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.UPDATE', + 'title' => __( + 'New %s Console update', + get_product_name() + ), + 'message' => __('There is a new update available. Please<a style="font-weight:bold;" href="index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online"> go to Administration:Setup:Update Manager</a> for more details.'), + 'url' => ui_get_full_url( + 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.UPDATE'); + } + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.OPENSETUP'); + $this->cleanNotifications('NOTIF.UPDATEMANAGER.UPDATE'); + } + } + + +} diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 2fd79d6d43..3af3db3f69 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1,2364 +1,2775 @@ <?php -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation; version 2 - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - /** - * @package Include + * Extension to self monitor Pandora FMS Console + * + * @category Config + * @package Pandora FMS * @subpackage Config + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ */ + // Config functions. + + /** * Creates a single config value in the database. - * - * @param string Config token to create. - * @param string Value to set. * - * @return bool Config id if success. False on failure. + * @param string $token Config token to create. + * @param string $value Value to set. + * + * @return boolean Config id if success. False on failure. */ -function config_create_value ($token, $value) { - return db_process_sql_insert ('tconfig', - array ('value' => $value, - 'token' => $token)); +function config_create_value($token, $value) +{ + return db_process_sql_insert( + 'tconfig', + [ + 'value' => $value, + 'token' => $token, + ] + ); } + /** * Update a single config value in the database. - * - * If the config token doesn't exists, it's created. - * - * @param string Config token to update. - * @param string New value to set. * - * @return bool True if success. False on failure. + * If the config token doesn't exists, it's created. + * + * @param string $token Config token to update. + * @param string $value New value to set. + * + * @return boolean True if success. False on failure. */ -function config_update_value ($token, $value) { - global $config; - // Include functions_io to can call __() function - include_once($config['homedir'] . '/include/functions_io.php'); - - if ($token == 'list_ACL_IPs_for_API') { - $value = str_replace(array("\r\n", "\r", "\n"), ";", - io_safe_output($value)); - } - - if ($token == 'default_assign_tags') { - $value = ($value); - } - - if (!isset ($config[$token])) { - $config[$token] = $value; - return (bool) config_create_value ($token, io_safe_input($value)); - } - - /* If it has not changed */ - if ($config[$token] == $value) - return true; - - $config[$token] = $value; - $value = io_safe_output($value); - - $result = db_process_sql_update ('tconfig', - array ('value' => io_safe_input($value)), - array ('token' => $token)); - - if ($result === 0) - return true; - else - return (bool) $result; +function config_update_value($token, $value) +{ + global $config; + // Include functions_io to can call __() function. + include_once $config['homedir'].'/include/functions_io.php'; + + if ($token == 'list_ACL_IPs_for_API') { + $value = str_replace( + [ + "\r\n", + "\r", + "\n", + ], + ';', + io_safe_output($value) + ); + } + + if ($token == 'default_assign_tags') { + $value = ($value); + } + + if (!isset($config[$token])) { + $config[$token] = $value; + return (bool) config_create_value($token, io_safe_input($value)); + } + + // If it has not changed. + if ($config[$token] == $value) { + return true; + } + + $config[$token] = $value; + $value = io_safe_output($value); + + $result = db_process_sql_update( + 'tconfig', + ['value' => io_safe_input($value)], + ['token' => $token] + ); + + if ($result === 0) { + return true; + } else { + return (bool) $result; + } } + /** - * Updates all config values in case setup page was invoked + * Updates all config values in case setup page was invoked + * + * @return boolean */ -function config_update_config () { - global $config; - - // Include functions_io to can call __() function - include_once($config['homedir'] . '/include/functions_io.php'); - - /* If user is not even log it, don't try this */ - if (! isset ($config['id_user'])) { - $config['error_config_update_config'] = array(); - $config['error_config_update_config']['correct'] = false; - $config['error_config_update_config']['message'] = __('Failed updated: User did not login.'); - - return false; - } - - if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) { - $config['error_config_update_config'] = array(); - $config['error_config_update_config']['correct'] = false; - $config['error_config_update_config']['message'] = __('Failed updated: User is not admin.'); - - return false; - } - - $update_config = (bool) get_parameter ('update_config'); - - if ($update_config) { - db_pandora_audit("Setup", "Setup has changed"); - } - else { - //Do none - - return false; - } - - $error_update = array(); - - $sec2 = get_parameter_get('sec2'); - switch ($sec2) { - case 'godmode/setup/setup': - $section_setup = get_parameter ('section'); - //////// MAIN SETUP - // Setup now is divided in different tabs - switch ($section_setup) { - case 'general': - if (!config_update_value ('language', (string) get_parameter ('language'))) - $error_update[] = __('Language settings'); - if (!config_update_value ('remote_config', (string) get_parameter ('remote_config'))) - $error_update[] = __('Remote config directory'); - if (!config_update_value ('phantomjs_bin', (string) get_parameter ('phantomjs_bin'))) - $error_update[] = __('phantomjs config directory'); - if (!config_update_value ('loginhash_pwd', io_input_password((string) get_parameter ('loginhash_pwd')))) - $error_update[] = __('Auto login (hash) password'); - if (!config_update_value ('timesource', (string) get_parameter ('timesource'))) - $error_update[] = __('Time source'); - if (!config_update_value ('autoupdate', (bool) get_parameter ('autoupdate'))) - $error_update[] = __('Automatic check for updates'); - if (!config_update_value ('cert_path', (bool) get_parameter ('cert_path'))) - $error_update[] = __('SSL cert path'); - if (!config_update_value ('https', (bool) get_parameter ('https'))) - $error_update[] = __('Enforce https'); - if (!config_update_value ('use_cert', (bool) get_parameter ('use_cert'))) - $error_update[] = __('Use cert.'); - if (!config_update_value ('attachment_store', (string) get_parameter ('attachment_store'))) - $error_update[] = __('Attachment store'); - if (!config_update_value ('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API'))) - $error_update[] = __('IP list with API access'); - if (!config_update_value ('api_password', io_input_password(get_parameter('api_password')))) - $error_update[] = __('API password'); - if (!config_update_value ('activate_gis', (bool) get_parameter ('activate_gis'))) - $error_update[] = __('Enable GIS features'); - if (!config_update_value ('integria_inventory', get_parameter ('integria_inventory'))) - $error_update[] = __('Integria inventory'); - if (!config_update_value ('integria_api_password', io_input_password(get_parameter ('integria_api_password')))) - $error_update[] = __('Integria API password'); - if (!config_update_value ('integria_url', get_parameter ('integria_url'))) - $error_update[] = __('Integria URL'); - if (!config_update_value ('activate_netflow', (bool) get_parameter ('activate_netflow'))) - $error_update[] = __('Enable Netflow'); - $timezone = (string) get_parameter ('timezone'); - if ($timezone != "") { - if (!config_update_value ('timezone', $timezone)) - $error_update[] = __('Timezone setup'); - } - if (!config_update_value ('sound_alert', get_parameter('sound_alert'))) - $error_update[] = __('Sound for Alert fired'); - if (!config_update_value ('sound_critical', get_parameter('sound_critical'))) - $error_update[] = __('Sound for Monitor critical'); - if (!config_update_value ('sound_warning', get_parameter('sound_warning'))) - $error_update[] = __('Sound for Monitor warning'); - # Update of Pandora FMS license - $update_manager_installed = db_get_value('value', 'tconfig', 'token', 'update_manager_installed'); - - if ($update_manager_installed == 1) { - $license_info_key = get_parameter('license_info_key', ''); - if (!empty($license_info_key)) { - $values = array(db_escape_key_identifier('value') => $license_info_key); - $where = array(db_escape_key_identifier('key') => 'customer_key'); - $update_manage_settings_result = db_process_sql_update('tupdate_settings', $values, $where); - if ($update_manage_settings_result === false) - $error_update[] = __('License information'); - } - } - if (!config_update_value ('public_url', get_parameter('public_url'))) - $error_update[] = __('Public URL'); - if (!config_update_value ('referer_security', get_parameter('referer_security'))) - $error_update[] = __('Referer security'); - if (!config_update_value ('event_storm_protection', get_parameter('event_storm_protection'))) - $error_update[] = __('Event storm protection'); - if (!config_update_value ('command_snapshot', get_parameter('command_snapshot'))) - $error_update[] = __('Command Snapshot'); - if (!config_update_value ('server_log_dir', get_parameter('server_log_dir'))) - $error_update[] = __('Server logs directory'); - if (!config_update_value ('max_log_size', get_parameter('max_log_size'))) - $error_update[] = __('Log size limit in system logs viewer extension'); - if (!config_update_value ('tutorial_mode', get_parameter('tutorial_mode'))) - $error_update[] = __('Tutorial mode'); - if (!config_update_value ('past_planned_downtimes', get_parameter('past_planned_downtimes'))) - $error_update[] = __('Allow create planned downtimes in the past'); - if (!config_update_value ('limit_parameters_massive', get_parameter('limit_parameters_massive'))) - $error_update[] = __('Limit parameters bulk'); - if (!config_update_value ('identification_reminder', get_parameter('identification_reminder'))) - $error_update[] = __('Identification_reminder'); - if (!config_update_value ('include_agents', (bool)get_parameter('include_agents'))) - $error_update[] = __('Include_agents'); - if (!config_update_value ('alias_as_name', get_parameter('alias_as_name'))) - $error_update[] = __('alias_as_name'); - if (!config_update_value ('auditdir', get_parameter('auditdir'))) - $error_update[] = __('Audit log directory'); - break; - case 'enterprise': - if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { - if (!config_update_value ('trap2agent', (string) get_parameter ('trap2agent'))) - $error_update[] = __('Forward SNMP traps to agent (if exist)'); - if (!config_update_value ('acl_enterprise', get_parameter ('acl_enterprise'))) - $error_update[] = __('Use Enterprise ACL System'); - if (!config_update_value ('metaconsole', get_parameter ('metaconsole'))) - $error_update[] = __('Activate Metaconsole'); - if (!config_update_value ('collection_max_size', get_parameter('collection_max_size'))) - $error_update[] = __('Size of collection'); - if (!config_update_value ('event_replication', (int)get_parameter('event_replication'))) - $error_update[] = __('Events replication'); - if ((int)get_parameter('event_replication') == 1) { - if (!config_update_value ('replication_interval', (int)get_parameter('replication_interval'))) - $error_update[] = __('Replication interval'); - if (!config_update_value ('replication_limit', (int)get_parameter('replication_limit'))) - $error_update[] = __('Replication limit'); - if (!config_update_value ('replication_mode', (string)get_parameter('replication_mode'))) - $error_update[] = __('Replication mode'); - if (!config_update_value ('show_events_in_local', (string)get_parameter('show_events_in_local'))) - $error_update[] = __('Show events list in local console (read only)'); - } - if (!config_update_value ('replication_dbengine', (string)get_parameter('replication_dbengine'))) - $error_update[] = __('Replication DB engine'); - if (!config_update_value ('replication_dbhost', (string)get_parameter('replication_dbhost'))) - $error_update[] = __('Replication DB host'); - if (!config_update_value ('replication_dbname', (string)get_parameter('replication_dbname'))) - $error_update[] = __('Replication DB database'); - if (!config_update_value ('replication_dbuser', (string)get_parameter('replication_dbuser'))) - $error_update[] = __('Replication DB user'); - if (!config_update_value ('replication_dbpass', io_input_password((string)get_parameter('replication_dbpass')))) - $error_update[] = __('Replication DB password'); - if (!config_update_value ('replication_dbport', (string)get_parameter('replication_dbport'))) - $error_update[] = __('Replication DB port'); - if (!config_update_value ('metaconsole_agent_cache', (int)get_parameter('metaconsole_agent_cache'))) - $error_update[] = __('Metaconsole agent cache'); - if (!config_update_value ('log_collector', (bool)get_parameter('log_collector'))) - $error_update[] = __('Activate Log Collector'); - if (!config_update_value ('enable_update_manager', get_parameter('enable_update_manager'))) - $error_update[] = __('Enable Update Manager'); - if (!config_update_value ('ipam_ocuppied_critical_treshold', get_parameter('ipam_ocuppied_critical_treshold'))) - $error_update[] = __('Ipam Ocuppied Manager Critical'); - if (!config_update_value ('ipam_ocuppied_warning_treshold', get_parameter('ipam_ocuppied_warning_treshold'))) - $error_update[] = __('Ipam Ocuppied Manager Warning'); +function config_update_config() +{ + global $config; - $inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', array()); - if (!config_update_value ('inventory_changes_blacklist', implode(',',$inventory_changes_blacklist))) - $error_update[] = __('Inventory changes blacklist'); + // Include functions_io to can call __() function. + include_once $config['homedir'].'/include/functions_io.php'; - if (!config_update_value ('email_from_dir', get_parameter('email_from_dir'))) - $error_update[] = __('From dir'); - if (!config_update_value ('email_from_name', get_parameter('email_from_name'))) - $error_update[] = __('From name'); - if (!config_update_value ('email_smtpServer', get_parameter('email_smtpServer'))) - $error_update[] = __('Server SMTP'); - if (!config_update_value ('email_smtpPort', (int)get_parameter('email_smtpPort'))) - $error_update[] = __('Port SMTP'); - if (!config_update_value ('email_encryption', get_parameter('email_encryption'))) - $error_update[] = __('Encryption'); - if (!config_update_value ('email_username', get_parameter('email_username'))) - $error_update[] = __('Email user'); - if (!config_update_value ('email_password', get_parameter('email_password'))) - $error_update[] = __('Email password'); - - } - break; - case 'pass': - if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { - if (!config_update_value ('enable_pass_policy', get_parameter('enable_pass_policy'))) - $error_update[] = __('Enable password policy'); - - if (!config_update_value ('pass_size', get_parameter('pass_size'))) - $error_update[] = __('Min. size password'); - if (!config_update_value ('pass_expire', get_parameter('pass_expire'))) - $error_update[] = __('Password expiration'); - if (!config_update_value ('first_login', get_parameter('first_login'))) - $error_update[] = __('Force change password on first login'); - if (!config_update_value ('mins_fail_pass', get_parameter('mins_fail_pass'))) - $error_update[] = __('User blocked if login fails'); - if (!config_update_value ('number_attempts', get_parameter('number_attempts'))) - $error_update[] = __('Number of failed login attempts'); - if (!config_update_value ('pass_needs_numbers', get_parameter('pass_needs_numbers'))) - $error_update[] = __('Password must have numbers'); - if (!config_update_value ('pass_needs_symbols', get_parameter('pass_needs_symbols'))) - $error_update[] = __('Password must have symbols'); - if (!config_update_value ('enable_pass_policy_admin', get_parameter('enable_pass_policy_admin'))) - $error_update[] = __('Apply password policy to admin users'); - if (!config_update_value ('enable_pass_history', get_parameter('enable_pass_history'))) - $error_update[] = __('Enable password history'); - if (!config_update_value ('compare_pass', get_parameter('compare_pass'))) - $error_update[] = __('Compare previous password'); - if (!config_update_value ('reset_pass_option', (bool)get_parameter('reset_pass_option'))) - $error_update[] = __('Activate reset password'); - } - break; - case 'auth': - //////// AUTHENTICATION SETUP - if (!config_update_value ('auth', get_parameter ('auth'))) - $error_update[] = __('Authentication method'); - if (!config_update_value ('autocreate_remote_users', get_parameter ('autocreate_remote_users'))) - $error_update[] = __('Autocreate remote users'); - if (!config_update_value ('default_remote_profile', get_parameter ('default_remote_profile'))) - $error_update[] = __('Autocreate profile'); - if (!config_update_value ('default_remote_group', get_parameter ('default_remote_group'))) - $error_update[] = __('Autocreate profile group'); - if (!config_update_value ('default_assign_tags', implode(",",get_parameter ('default_assign_tags')))) - $error_update[] = __('Autocreate profile tags'); - if (!config_update_value ('default_no_hierarchy', (int)get_parameter ('default_no_hierarchy'))) - $error_update[] = __('Automatically assigned no hierarchy'); - if (!config_update_value ('autocreate_blacklist', get_parameter ('autocreate_blacklist'))) - $error_update[] = __('Autocreate blacklist'); - - if (!config_update_value ('ad_server', get_parameter ('ad_server'))) - $error_update[] = __('Active directory server'); - if (!config_update_value ('ad_port', get_parameter ('ad_port'))) - $error_update[] = __('Active directory port'); - if (!config_update_value ('ad_start_tls', get_parameter ('ad_start_tls'))) - $error_update[] = __('Start TLS'); - if (!config_update_value ('ad_advanced_config', get_parameter ('ad_advanced_config'))) - $error_update[] = __('Advanced Config AD'); - if (!config_update_value ('ldap_advanced_config', get_parameter ('ldap_advanced_config'))) - $error_update[] = __('Advanced Config LDAP'); - if (!config_update_value ('ad_domain', get_parameter ('ad_domain'))) - $error_update[] = __('Domain'); - if (!config_update_value ('ad_adv_perms', get_parameter ('ad_adv_perms'))) - $error_update[] = __('Advanced Permisions AD'); - if (!config_update_value ('ldap_adv_perms', get_parameter ('ldap_adv_perms'))) - $error_update[] = __('Advanced Permissions LDAP'); - if (!config_update_value ('ldap_server', get_parameter ('ldap_server'))) - $error_update[] = __('LDAP server'); - if (!config_update_value ('ldap_port', get_parameter ('ldap_port'))) - $error_update[] = __('LDAP port'); - if (!config_update_value ('ldap_version', get_parameter ('ldap_version'))) - $error_update[] = __('LDAP version'); - if (!config_update_value ('ldap_start_tls', get_parameter ('ldap_start_tls'))) - $error_update[] = __('Start TLS'); - if (!config_update_value ('ldap_base_dn', get_parameter ('ldap_base_dn'))) - $error_update[] = __('Base DN'); - if (!config_update_value ('ldap_login_attr', get_parameter ('ldap_login_attr'))) - $error_update[] = __('Login attribute'); - if (!config_update_value ('ldap_admin_login', get_parameter ('ldap_admin_login'))) - $error_update[] = __('Admin LDAP login'); - if (!config_update_value ('ldap_admin_pass', get_parameter ('ldap_admin_pass'))) - $error_update[] = __('Admin LDAP password'); - if (!config_update_value ('fallback_local_auth', get_parameter ('fallback_local_auth'))) - $error_update[] = __('Fallback to local authentication'); - if (!config_update_value ('ldap_login_user_attr', get_parameter ('ldap_login_user_attr'))) - $error_update[] = __('Login user attribute'); - if (!config_update_value ('ldap_function', get_parameter ('ldap_function'))) - $error_update[] = __('LDAP function'); - - if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 0) { - if (!config_update_value ('ldap_save_password', get_parameter ('ldap_save_password'))) - $error_update[] = __('Save Password'); - } - else if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 1) { - config_update_value ('ldap_save_password', 1); - } + // If user is not even log it, don't try this. + if (! isset($config['id_user'])) { + $config['error_config_update_config'] = []; + $config['error_config_update_config']['correct'] = false; + $config['error_config_update_config']['message'] = __('Failed updated: User did not login.'); - if (!config_update_value ('rpandora_server', get_parameter ('rpandora_server'))) - $error_update[] = __('MySQL host'); - if (!config_update_value ('rpandora_port', get_parameter ('rpandora_port'))) - $error_update[] = __('MySQL port'); - if (!config_update_value ('rpandora_dbname', get_parameter ('rpandora_dbname'))) - $error_update[] = __('Database name'); - if (!config_update_value ('rpandora_user', get_parameter ('rpandora_user'))) - $error_update[] = __('User'); - if (!config_update_value ('rpandora_pass', io_input_password(get_parameter ('rpandora_pass')))) - $error_update[] = __('Password'); - - if (!config_update_value ('rintegria_server', get_parameter ('rintegria_server'))) - $error_update[] = __('Integria host'); - if (!config_update_value ('rintegria_port', get_parameter ('rintegria_port'))) - $error_update[] = __('MySQL port'); - if (!config_update_value ('rintegria_dbname', get_parameter ('rintegria_dbname'))) - $error_update[] = __('Database name'); - if (!config_update_value ('rintegria_user', get_parameter ('rintegria_user'))) - $error_update[] = __('User'); - if (!config_update_value ('rintegria_pass', io_input_password(get_parameter ('rintegria_pass')))) - $error_update[] = __('Password'); - if (!config_update_value ('saml_path', get_parameter ('saml_path'))) - $error_update[] = __('Saml path'); - if (!config_update_value ('double_auth_enabled', get_parameter ('double_auth_enabled'))) - $error_update[] = __('Double authentication'); - if (!config_update_value ('session_timeout', get_parameter ('session_timeout'))) - $error_update[] = __('Session timeout'); - ///////////// - break; - case 'perf': - //////// PERFORMANCE SETUP - if (!config_update_value ('event_purge', get_parameter ('event_purge'))) - $error_update[] = - $check_metaconsole_events_history = get_parameter ('metaconsole_events_history', -1); - if ($check_metaconsole_events_history != -1) - if (!config_update_value ('metaconsole_events_history', get_parameter ('metaconsole_events_history'))) - $error_update[] = __('Max. days before delete events'); - if (!config_update_value ('trap_purge', get_parameter ('trap_purge'))) - $error_update[] = __('Max. days before delete traps'); - if (!config_update_value ('string_purge', get_parameter ('string_purge'))) - $error_update[] = __('Max. days before delete string data'); - if (!config_update_value ('audit_purge', get_parameter ('audit_purge'))) - $error_update[] = __('Max. days before delete audit events'); - if (!config_update_value ('gis_purge', get_parameter ('gis_purge'))) - $error_update[] = __('Max. days before delete GIS data'); - if (!config_update_value ('days_purge', (int) get_parameter ('days_purge'))) - $error_update[] = __('Max. days before purge'); - if (!config_update_value ('days_delete_unknown', (int) get_parameter ('days_delete_unknown'))) - $error_update[] = __('Max. days before delete unknown modules'); - if (!config_update_value ('days_compact', (int) get_parameter ('days_compact'))) - $error_update[] = __('Max. days before compact data'); - if (!config_update_value ('days_autodisable_deletion', (int) get_parameter ('days_autodisable_deletion'))) - $error_update[] = __('Max. days before autodisable deletion'); - if (!config_update_value ('report_limit', (int) get_parameter ('report_limit'))) - $error_update[] = __('Item limit for realtime reports)'); - if (!config_update_value ('step_compact', (int) get_parameter ('step_compact'))) - $error_update[] = __('Compact interpolation in hours (1 Fine-20 bad)'); - if (!config_update_value ('event_view_hr', (int) get_parameter ('event_view_hr'))) - $error_update[] = __('Default hours for event view'); - if (!config_update_value ('realtimestats', get_parameter ('realtimestats'))) - $error_update[] = __('Use realtime statistics'); - if (!config_update_value ('stats_interval', get_parameter ('stats_interval'))) - $error_update[] = __('Batch statistics period (secs)'); - if (!config_update_value ('agentaccess', (int) get_parameter ('agentaccess'))) - $error_update[] = __('Use agent access graph'); - if (!config_update_value ('num_files_attachment', (int) get_parameter ('num_files_attachment'))) - $error_update[] = __('Max. recommended number of files in attachment directory'); - if (!config_update_value ('delete_notinit', get_parameter ('delete_notinit'))) - $error_update[] = __('Delete not init modules'); - if (!config_update_value ('big_operation_step_datos_purge', get_parameter ('big_operation_step_datos_purge'))) - $error_update[] = __('Big Operatiopn Step to purge old data'); - if (!config_update_value ('small_operation_step_datos_purge', get_parameter ('small_operation_step_datos_purge'))) - $error_update[] = __('Small Operation Step to purge old data'); - if (!config_update_value ('num_past_special_days', get_parameter ('num_past_special_days'))) - $error_update[] = __('Retention period of past special days'); - if (!config_update_value ('max_macro_fields', get_parameter ('max_macro_fields'))) - $error_update[] = __('Max. macro data fields'); - if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { - if (!config_update_value ('inventory_purge', get_parameter ('inventory_purge'))) - $error_update[] = __('Max. days before delete inventory data'); - } - if (!config_update_value ('max_graph_container', get_parameter ('max_graph_container'))) - $error_update[] = __('Graph container - Max. Items'); - ///////////// - break; - - case 'vis': - //////// VISUAL STYLES SETUP - if (!config_update_value ('date_format', (string) get_parameter ('date_format'))) - $error_update[] = __('Date format string'); - if (!config_update_value ('prominent_time', (string) get_parameter ('prominent_time'))) - $error_update[] = __('Timestamp or time comparation'); - if (!config_update_value ('graph_color1', (string) get_parameter ('graph_color1'))) - $error_update[] = __('Graph color #1'); - if (!config_update_value ('graph_color2', (string) get_parameter ('graph_color2'))) - $error_update[] = __('Graph color #2'); - if (!config_update_value ('graph_color3', (string) get_parameter ('graph_color3'))) - $error_update[] = __('Graph color #3'); - if (!config_update_value ('graph_color4', (string) get_parameter ('graph_color4'))) - $error_update[] = __('Graph color #4'); - if (!config_update_value ('graph_color5', (string) get_parameter ('graph_color5'))) - $error_update[] = __('Graph color #5'); - if (!config_update_value ('graph_color6', (string) get_parameter ('graph_color6'))) - $error_update[] = __('Graph color #6'); - if (!config_update_value ('graph_color7', (string) get_parameter ('graph_color7'))) - $error_update[] = __('Graph color #7'); - if (!config_update_value ('graph_color8', (string) get_parameter ('graph_color8'))) - $error_update[] = __('Graph color #8'); - if (!config_update_value ('graph_color9', (string) get_parameter ('graph_color9'))) - $error_update[] = __('Graph color #9'); - if (!config_update_value ('graph_color10', (string) get_parameter ('graph_color10'))) - $error_update[] = __('Graph color #10'); - if (!config_update_value ('interface_unit', (string) get_parameter ('interface_unit', __('Bytes') ))) - $error_update[] = __('Value to interface graphics'); - if (!config_update_value ('graph_precision', (string) get_parameter ('graph_precision', 1))) - $error_update[] = __('Data precision for reports'); - $style = (string) get_parameter ('style'); - if ($style != $config['style']) - $style = substr ($style, 0, strlen ($style) - 4); - if (!config_update_value ('style', $style)) - $error_update[] = __('Style template'); - if (!config_update_value ('block_size', (int) get_parameter ('block_size'))) - $error_update[] = __('Block size for pagination'); - if (!config_update_value ('round_corner', (bool) get_parameter ('round_corner'))) - $error_update[] = __('Use round corners'); - if (!config_update_value ('show_qr_code_header', (bool) get_parameter ('show_qr_code_header'))) - $error_update[] = __('Show QR code header'); - if (!config_update_value ('status_images_set', (string) get_parameter ('status_images_set'))) - $error_update[] = __('Status icon set'); - if (!config_update_value ('fontpath', (string) get_parameter ('fontpath'))) - $error_update[] = __('Font path'); - if (!config_update_value ('font_size', get_parameter('font_size'))) - $error_update[] = __('Font size'); + return false; + } - if (!config_update_value ('custom_favicon', (string) get_parameter ('custom_favicon'))) - $error_update[] = __('Custom favicon'); - if (!config_update_value ('custom_logo', (string) get_parameter ('custom_logo'))) - $error_update[] = __('Custom logo'); - if (!config_update_value ('custom_logo_white_bg', (string) get_parameter ('custom_logo_white_bg'))) - $error_update[] = __('Custom logo white background'); - if (!config_update_value ('custom_logo_login', (string) get_parameter ('custom_logo_login'))) - $error_update[] = __('Custom logo login'); - if (!config_update_value ('custom_splash_login', (string) get_parameter ('custom_splash_login'))) - $error_update[] = __('Custom splash login'); - if (!config_update_value ('custom_docs_logo', (string) get_parameter ('custom_docs_logo'))) - $error_update[] = __('Custom documentation logo'); - if (!config_update_value ('custom_support_logo', (string) get_parameter ('custom_support_logo'))) - $error_update[] = __('Custom support logo'); - if (!config_update_value ('custom_network_center_logo', (string) get_parameter ('custom_network_center_logo'))) - $error_update[] = __('Custom networkmap center logo'); - if (!config_update_value ('custom_mobile_console_logo', (string) get_parameter ('custom_mobile_console_logo'))) - $error_update[] = __('Custom networkmap center logo'); - if (!config_update_value ('custom_title1_login', (string) get_parameter ('custom_title1_login'))) - $error_update[] = __('Custom title1 login'); - if (!config_update_value ('custom_title2_login', (string) get_parameter ('custom_title2_login'))) - $error_update[] = __('Custom title2 login'); - if (!config_update_value ('login_background', (string) get_parameter ('login_background'))) - $error_update[] = __('Login background'); - - if (!config_update_value ('custom_docs_url', (string) get_parameter ('custom_docs_url'))) - $error_update[] = __('Custom Docs url'); - if (!config_update_value ('custom_support_url', (string) get_parameter ('custom_support_url'))) - $error_update[] = __('Custom support url'); - if (!config_update_value ('rb_product_name', (string) get_parameter ('rb_product_name'))) - $error_update[] = __('Product name'); - if (!config_update_value ('rb_copyright_notice', (string) get_parameter ('rb_copyright_notice'))) - $error_update[] = __('Copyright notice'); + if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { + $config['error_config_update_config'] = []; + $config['error_config_update_config']['correct'] = false; + $config['error_config_update_config']['message'] = __('Failed updated: User is not admin.'); - if (!config_update_value ('meta_custom_logo', (string) get_parameter ('meta_custom_logo'))) - $error_update[] = __('Custom logo metaconsole'); - if (!config_update_value ('meta_custom_logo_white_bg', (string) get_parameter ('meta_custom_logo_white_bg'))) - $error_update[] = __('Custom logo metaconsole (white background)'); - if (!config_update_value ('meta_custom_logo_login', (string) get_parameter ('meta_custom_logo_login'))) - $error_update[] = __('Custom logo login metaconsole'); - if (!config_update_value ('meta_custom_splash_login', (string) get_parameter ('meta_custom_splash_login'))) - $error_update[] = __('Custom splash login metaconsole'); - if (!config_update_value ('meta_custom_title1_login', (string) get_parameter ('meta_custom_title1_login'))) - $error_update[] = __('Custom title1 login metaconsole'); - if (!config_update_value ('meta_custom_title2_login', (string) get_parameter ('meta_custom_title2_login'))) - $error_update[] = __('Custom title2 login metaconsole'); - if (!config_update_value ('meta_login_background', (string) get_parameter ('meta_login_background'))) - $error_update[] = __('Login background metaconsole'); + return false; + } - if (!config_update_value ('meta_custom_docs_url', (string) get_parameter ('meta_custom_docs_url'))) - $error_update[] = __('Custom Docs url'); - if (!config_update_value ('meta_custom_support_url', (string) get_parameter ('meta_custom_support_url'))) - $error_update[] = __('Custom support url'); + $update_config = (bool) get_parameter('update_config'); - if (!config_update_value ('vc_refr', get_parameter('vc_refr'))) - $error_update[] = __('Default interval for refresh on Visual Console'); - if (!config_update_value ('vc_favourite_view', (int) get_parameter('vc_favourite_view', 0))) - $error_update[] = __('Default line favourite_view for the Visual Console'); - if (!config_update_value ('vc_menu_items', (int) get_parameter('vc_menu_items', 10))) - $error_update[] = __('Default line menu items for the Visual Console'); - if (!config_update_value ('vc_line_thickness', (int) get_parameter('vc_line_thickness'))) - $error_update[] = __('Default line thickness for the Visual Console'); + if ($update_config) { + db_pandora_audit('Setup', 'Setup has changed'); + } else { + // Do nothing. + return false; + } - if (!config_update_value ('ser_menu_items', (int) get_parameter('ser_menu_items', 10))) - $error_update[] = __('Default line menu items for the Services'); + $error_update = []; - if (!config_update_value ('agent_size_text_small', get_parameter('agent_size_text_small'))) - $error_update[] = __('Agent size text'); - if (!config_update_value ('agent_size_text_medium', get_parameter('agent_size_text_medium'))) - $error_update[] = __('Agent size text'); - if (!config_update_value ('module_size_text_small', get_parameter('module_size_text_small'))) - $error_update[] = __('Module size text'); - if (!config_update_value ('module_size_text_medium', get_parameter('module_size_text_medium'))) - $error_update[] = __('Description size text'); - if (!config_update_value ('description_size_text', get_parameter('description_size_text'))) - $error_update[] = __('Description size text'); - if (!config_update_value ('item_title_size_text', get_parameter('item_title_size_text'))) - $error_update[] = __('Item title size text'); - if (!config_update_value ('gis_label', get_parameter ('gis_label'))) - $error_update[] = __('GIS Labels'); - if (!config_update_value ('simple_module_value', get_parameter ('simple_module_value'))) - $error_update[] = __('Show units in values report'); - if (!config_update_value ('gis_default_icon', get_parameter ('gis_default_icon'))) - $error_update[] = __('Default icon in GIS'); - if (!config_update_value ('autohidden_menu', get_parameter('autohidden_menu'))) - $error_update[] = __('Autohidden menu'); - if (!config_update_value ('visual_animation', get_parameter('visual_animation'))) - $error_update[] = __('visual_animation'); - if (!config_update_value ('disable_help', get_parameter('disable_help'))) - $error_update[] = __('Disable help'); - if (!config_update_value ('fixed_graph', get_parameter('fixed_graph'))) - $error_update[] = __('Fixed graph'); - if (!config_update_value ('fixed_header', get_parameter('fixed_header'))) - $error_update[] = __('Fixed header'); - if (!config_update_value ('fixed_menu', get_parameter('fixed_menu'))) - $error_update[] = __('Fixed menu'); - if (!config_update_value ('paginate_module', get_parameter('paginate_module'))) - $error_update[] = __('Paginate module'); - if (!config_update_value ('graphviz_bin_dir', get_parameter('graphviz_bin_dir'))) - $error_update[] = __('Custom graphviz directory'); - if (!config_update_value ('networkmap_max_width', get_parameter('networkmap_max_width'))) - $error_update[] = __('Networkmap max width'); - if (!config_update_value ('short_module_graph_data', get_parameter('short_module_graph_data'))) - $error_update[] = __('Shortened module graph data'); - if (!config_update_value ('show_group_name', get_parameter('show_group_name'))) - $error_update[] = __('Show the group name instead the group icon.'); - if (!config_update_value ('custom_graph_width', (int) get_parameter('custom_graph_width', 1))) - $error_update[] = __('Default line thickness for the Custom Graph.'); - if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area'))) - $error_update[] = __('Default type of module charts.'); - if (!config_update_value ('type_interface_charts', (string) get_parameter('type_interface_charts', 'line'))) - $error_update[] = __('Default type of interface charts.'); - if (!config_update_value ('render_proc', (bool) get_parameter('render_proc', false))) - $error_update[] = __('Display data of proc modules in other format'); - if (!config_update_value ('render_proc_ok', (string) get_parameter('render_proc_ok', __('Ok') ))) - $error_update[] = __('Display text proc modules have state is ok'); - if (!config_update_value ('render_proc_fail', (string) get_parameter('render_proc_fail', __('Fail') ))) - $error_update[] = __('Display text when proc modules have state critical'); - //Daniel maya 02/06/2016 Display menu with click --INI - if (!config_update_value ('click_display', (bool) get_parameter('click_display', false))) - $error_update[] = __('Display lateral menus with left click'); - //Daniel maya 02/06/2016 Display menu with click --END - if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { - if (!config_update_value ('service_label_font_size', get_parameter('service_label_font_size', false))) - $error_update[] = __('Service label font size'); - if (!config_update_value ('service_item_padding_size', get_parameter('service_item_padding_size', false))) - $error_update[] = __('Service item padding size'); - } - if (!config_update_value ('percentil', (int) get_parameter('percentil', 0))) - $error_update[] = __('Default percentil'); + $sec2 = get_parameter_get('sec2'); + switch ($sec2) { + case 'godmode/setup/setup': + $section_setup = get_parameter('section'); + // MAIN SETUP. + // Setup now is divided in different tabs. + switch ($section_setup) { + case 'general': + if (!config_update_value('language', (string) get_parameter('language'))) { + $error_update[] = __('Language settings'); + } - if (!config_update_value ('full_scale_option', (int) get_parameter('full_scale_option', 0))) - $error_update[] = __('Default full scale (TIP)'); + if (!config_update_value('remote_config', (string) get_parameter('remote_config'))) { + $error_update[] = __('Remote config directory'); + } - if (!config_update_value ('type_mode_graph', (int) get_parameter('type_mode_graph', 0))) - $error_update[] = __('Default soft graphs'); + if (!config_update_value('phantomjs_bin', (string) get_parameter('phantomjs_bin'))) { + $error_update[] = __('phantomjs config directory'); + } - if (!config_update_value ('zoom_graph', (int) get_parameter('zoom_graph', 1))) - $error_update[] = __('Default zoom graphs'); + if (!config_update_value('loginhash_pwd', io_input_password((string) get_parameter('loginhash_pwd')))) { + $error_update[] = __('Auto login (hash) password'); + } - if (!config_update_value ('graph_image_height', (int) get_parameter('graph_image_height', 280))) - $error_update[] = __('Default height of the chart image'); + if (!config_update_value('timesource', (string) get_parameter('timesource'))) { + $error_update[] = __('Time source'); + } - if (!config_update_value ('classic_menu', (bool) get_parameter('classic_menu', false))) - $error_update[] = __('Classic menu mode'); + if (!config_update_value('autoupdate', (bool) get_parameter('autoupdate'))) { + $error_update[] = __('Automatic check for updates'); + } + if (!config_update_value('cert_path', (bool) get_parameter('cert_path'))) { + $error_update[] = __('SSL cert path'); + } - //-------------------------------------------------- - // CUSTOM VALUES POST PROCESS - //-------------------------------------------------- - $custom_value = get_parameter('custom_value'); - $custom_text = get_parameter('custom_text'); - $custom_value_add = (bool)get_parameter('custom_value_add', 0); - $custom_value_to_delete = get_parameter('custom_value_to_delete', 0); - - $custom_value = str_replace(',', '.', $custom_value); - - if ($custom_value_add) { - require_once("include/functions_post_process.php"); - - if (!post_process_add_custom_value( - $custom_text, (string)$custom_value)) - $error_update[] = __('Add the custom post process'); - } - - if ($custom_value_to_delete > 0) { - require_once("include/functions_post_process.php"); - - if (!post_process_delete_custom_value($custom_value_to_delete)) { - $error_update[] = __('Delete the custom post process'); - } - } - //-------------------------------------------------- + if (!config_update_value('https', (bool) get_parameter('https'))) { + $error_update[] = __('Enforce https'); + } - //-------------------------------------------------- - // CUSTOM INTERVAL VALUES - //-------------------------------------------------- - $interval_values = get_parameter ('interval_values'); - - // Add new interval value if is provided - $interval_value = (float) get_parameter ('interval_value', 0); - - if ($interval_value > 0) { - $interval_unit = (int) get_parameter ('interval_unit'); - $new_interval = $interval_value * $interval_unit; - - if ($interval_values === '') { - $interval_values = $new_interval; - } - else { - $interval_values_array = explode(',',$interval_values); - if(!in_array($new_interval, $interval_values_array)) { - $interval_values_array[] = $new_interval; - $interval_values = implode(',',$interval_values_array); - } - } - } - - // 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); - foreach ($interval_values_array as $k => $iva) { - if ($interval_to_delete == $iva) { - unset($interval_values_array[$k]); - } - } - $interval_values = implode(',',$interval_values_array); - } - - if (!config_update_value ('interval_values', $interval_values)) - $error_update[] = __('Delete interval'); - //-------------------------------------------------- - - if (!config_update_value ('custom_report_info', get_parameter('custom_report_info'))) - $error_update[] = __('Custom report info'); - - - // 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'); - - if (!config_update_value ('custom_report_front_font', get_parameter('custom_report_front_font'))) - $error_update[] = __('Custom report front') . ' - ' . __('Font family'); - - if (!config_update_value ('custom_report_front_logo', get_parameter('custom_report_front_logo'))) - $error_update[] = __('Custom report front') . ' - ' . __('Custom logo'); - - if (!config_update_value ('custom_report_front_header', get_parameter('custom_report_front_header'))) - $error_update[] = __('Custom report front') . ' - ' . __('Header'); - - if (!config_update_value ('custom_report_front_firstpage', get_parameter('custom_report_front_firstpage'))) - $error_update[] = __('Custom report front') . ' - ' . __('First page'); - - if (!config_update_value ('custom_report_front_footer', get_parameter('custom_report_front_footer'))) - $error_update[] = __('Custom report front') . ' - ' . __('Footer'); + if (!config_update_value('use_cert', (bool) get_parameter('use_cert'))) { + $error_update[] = __('Use cert.'); + } - if (!config_update_value ('csv_divider', (string) get_parameter('csv_divider', ';'))) - $error_update[] = __('CSV divider'); - - break; - case 'net': - if (!config_update_value ('netflow_path', get_parameter ('netflow_path'))) - $error_update[] = __('Data storage path'); - if (!config_update_value ('netflow_interval', (int)get_parameter ('netflow_interval'))) - $error_update[] = __('Daemon interval'); - if (!config_update_value ('netflow_daemon', get_parameter ('netflow_daemon'))) - $error_update[] = __('Daemon binary path'); - if (!config_update_value ('netflow_nfdump', get_parameter ('netflow_nfdump'))) - $error_update[] = __('Nfdump binary path'); - if (!config_update_value ('netflow_nfexpire', get_parameter ('netflow_nfexpire'))) - $error_update[] = __('Nfexpire binary path'); - if (!config_update_value ('netflow_max_resolution', (int)get_parameter ('netflow_max_resolution'))) - $error_update[] = __('Maximum chart resolution'); - if (!config_update_value ('netflow_disable_custom_lvfilters', get_parameter ('netflow_disable_custom_lvfilters'))) - $error_update[] = __('Disable custom live view filters'); - if (!config_update_value ('netflow_max_lifetime', (int) get_parameter ('netflow_max_lifetime'))) - $error_update[] = __('Netflow max lifetime'); - if (!config_update_value ('netflow_get_ip_hostname', (int) get_parameter ('netflow_get_ip_hostname'))) - $error_update[] = __('Name resolution for IP address'); - break; - case 'log': - if (!config_update_value ('elasticsearch_ip', get_parameter('elasticsearch_ip'))) - $error_update[] = __('IP ElasticSearch server'); - if (!config_update_value ('elasticsearch_port', get_parameter('elasticsearch_port'))) - $error_update[] = __('Port ElasticSearch server'); - if (!config_update_value ('number_logs_viewed', (int)get_parameter('number_logs_viewed'))) - $error_update[] = __('Number of logs viewed'); - if (!config_update_value ('Days_purge_old_information', (int)get_parameter('Days_purge_old_information'))) - $error_update[] = __('Days to purge old information'); - break; - case 'hist_db': - if (!config_update_value ('history_db_enabled', get_parameter ('history_db_enabled'))) - $error_update[] = __('Enable history database'); - if (!config_update_value ('history_event_enabled', get_parameter ('history_event_enabled'))) - $error_update[] = __('Enable history event'); - if (!config_update_value ('history_db_host', get_parameter ('history_db_host'))) - $error_update[] = __('Host'); - if (!config_update_value ('history_db_port', get_parameter ('history_db_port'))) - $error_update[] = __('Port'); - if (!config_update_value ('history_db_name', get_parameter ('history_db_name'))) - $error_update[] = __('Database name'); - if (!config_update_value ('history_db_user', get_parameter ('history_db_user'))) - $error_update[] = __('Database user'); - if (!config_update_value ('history_db_pass', io_input_password(get_parameter ('history_db_pass')))) - $error_update[] = __('Database password'); - if (!config_update_value ('history_db_days', get_parameter ('history_db_days'))) - $error_update[] = __('Days'); - if (!config_update_value ('history_event_days', get_parameter ('history_event_days'))) - $error_update[] = __('Event Days'); - if (!config_update_value ('history_db_step', get_parameter ('history_db_step'))) - $error_update[] = __('Step'); - if (!config_update_value ('history_db_delay', get_parameter ('history_db_delay'))) - $error_update[] = __('Delay'); - break; - case 'ehorus': - if (!config_update_value('ehorus_enabled', (int) get_parameter('ehorus_enabled', $config['ehorus_enabled']))) - $error_update[] = __('Enable eHorus'); - if (!config_update_value('ehorus_user', (string) get_parameter('ehorus_user', $config['ehorus_user']))) - $error_update[] = __('eHorus user'); - if (!config_update_value('ehorus_pass', io_input_password((string) get_parameter('ehorus_pass', $config['ehorus_pass'])))) - $error_update[] = __('eHorus password'); - if (!config_update_value('ehorus_hostname', (string) get_parameter('ehorus_hostname', $config['ehorus_hostname']))) - $error_update[] = __('eHorus API hostname'); - if (!config_update_value('ehorus_port', (int) get_parameter('ehorus_port', $config['ehorus_port']))) - $error_update[] = __('eHorus API port'); - if (!config_update_value('ehorus_req_timeout', (int) get_parameter('ehorus_req_timeout', $config['ehorus_req_timeout']))) - $error_update[] = __('eHorus request timeout'); - if (!config_update_value('ehorus_custom_field', (string) get_parameter('ehorus_custom_field', $config['ehorus_custom_field']))) - $error_update[] = __('eHorus id custom field'); - break; - } - } + if (!config_update_value('attachment_store', (string) get_parameter('attachment_store'))) { + $error_update[] = __('Attachment store'); + } - if (count($error_update) > 0) { - $config['error_config_update_config'] = array(); - $config['error_config_update_config']['correct'] = false; - $values = implode(', ', $error_update); - $config['error_config_update_config']['message'] = sprintf(__('Failed updated: the next values cannot update: %s'), $values); - } - else { - $config['error_config_update_config'] = array(); - $config['error_config_update_config']['correct'] = true; - } + if (!config_update_value('list_ACL_IPs_for_API', (string) get_parameter('list_ACL_IPs_for_API'))) { + $error_update[] = __('IP list with API access'); + } - enterprise_include_once('include/functions_policies.php'); - $enterprise = enterprise_include_once ('include/functions_skins.php'); - if ($enterprise !== ENTERPRISE_NOT_HOOK) { - $config['relative_path'] = get_parameter('relative_path', $config['relative_path']); - } + if (!config_update_value('api_password', io_input_password(get_parameter('api_password')))) { + $error_update[] = __('API password'); + } + + if (!config_update_value('activate_gis', (bool) get_parameter('activate_gis'))) { + $error_update[] = __('Enable GIS features'); + } + + if (!config_update_value('integria_inventory', get_parameter('integria_inventory'))) { + $error_update[] = __('Integria inventory'); + } + + if (!config_update_value('integria_api_password', io_input_password(get_parameter('integria_api_password')))) { + $error_update[] = __('Integria API password'); + } + + if (!config_update_value('integria_url', get_parameter('integria_url'))) { + $error_update[] = __('Integria URL'); + } + + if (!config_update_value('activate_netflow', (bool) get_parameter('activate_netflow'))) { + $error_update[] = __('Enable Netflow'); + } + + $timezone = (string) get_parameter('timezone'); + if ($timezone != '') { + if (!config_update_value('timezone', $timezone)) { + $error_update[] = __('Timezone setup'); + } + } + + if (!config_update_value('sound_alert', get_parameter('sound_alert'))) { + $error_update[] = __('Sound for Alert fired'); + } + + if (!config_update_value('sound_critical', get_parameter('sound_critical'))) { + $error_update[] = __('Sound for Monitor critical'); + } + + if (!config_update_value('sound_warning', get_parameter('sound_warning'))) { + $error_update[] = __('Sound for Monitor warning'); + } + + // Update of Pandora FMS license. + $update_manager_installed = db_get_value('value', 'tconfig', 'token', 'update_manager_installed'); + + if ($update_manager_installed == 1) { + $license_info_key = get_parameter('license_info_key', ''); + if (!empty($license_info_key)) { + $values = [db_escape_key_identifier('value') => $license_info_key]; + $where = [db_escape_key_identifier('key') => 'customer_key']; + $update_manage_settings_result = db_process_sql_update('tupdate_settings', $values, $where); + if ($update_manage_settings_result === false) { + $error_update[] = __('License information'); + } + } + } + + if (!config_update_value('public_url', get_parameter('public_url'))) { + $error_update[] = __('Public URL'); + } + + if (!config_update_value('referer_security', get_parameter('referer_security'))) { + $error_update[] = __('Referer security'); + } + + if (!config_update_value('event_storm_protection', get_parameter('event_storm_protection'))) { + $error_update[] = __('Event storm protection'); + } + + if (!config_update_value('command_snapshot', get_parameter('command_snapshot'))) { + $error_update[] = __('Command Snapshot'); + } + + if (!config_update_value('server_log_dir', get_parameter('server_log_dir'))) { + $error_update[] = __('Server logs directory'); + } + + if (!config_update_value('max_log_size', get_parameter('max_log_size'))) { + $error_update[] = __('Log size limit in system logs viewer extension'); + } + + if (!config_update_value('tutorial_mode', get_parameter('tutorial_mode'))) { + $error_update[] = __('Tutorial mode'); + } + + if (!config_update_value('past_planned_downtimes', get_parameter('past_planned_downtimes'))) { + $error_update[] = __('Allow create planned downtimes in the past'); + } + + if (!config_update_value('limit_parameters_massive', get_parameter('limit_parameters_massive'))) { + $error_update[] = __('Limit parameters bulk'); + } + + if (!config_update_value('identification_reminder', get_parameter('identification_reminder'))) { + $error_update[] = __('Identification_reminder'); + } + + if (!config_update_value('include_agents', (bool) get_parameter('include_agents'))) { + $error_update[] = __('Include_agents'); + } + + if (!config_update_value('alias_as_name', get_parameter('alias_as_name'))) { + $error_update[] = __('alias_as_name'); + } + + if (!config_update_value('auditdir', get_parameter('auditdir'))) { + $error_update[] = __('Audit log directory'); + } + break; + + case 'enterprise': + if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { + if (!config_update_value('trap2agent', (string) get_parameter('trap2agent'))) { + $error_update[] = __('Forward SNMP traps to agent (if exist)'); + } + + if (!config_update_value('acl_enterprise', get_parameter('acl_enterprise'))) { + $error_update[] = __('Use Enterprise ACL System'); + } + + if (!config_update_value('metaconsole', get_parameter('metaconsole'))) { + $error_update[] = __('Activate Metaconsole'); + } + + if (!config_update_value('collection_max_size', get_parameter('collection_max_size'))) { + $error_update[] = __('Size of collection'); + } + + if (!config_update_value('event_replication', (int) get_parameter('event_replication'))) { + $error_update[] = __('Events replication'); + } + + if ((int) get_parameter('event_replication') == 1) { + if (!config_update_value('replication_interval', (int) get_parameter('replication_interval'))) { + $error_update[] = __('Replication interval'); + } + + if (!config_update_value('replication_limit', (int) get_parameter('replication_limit'))) { + $error_update[] = __('Replication limit'); + } + + if (!config_update_value('replication_mode', (string) get_parameter('replication_mode'))) { + $error_update[] = __('Replication mode'); + } + + if (!config_update_value('show_events_in_local', (string) get_parameter('show_events_in_local'))) { + $error_update[] = __('Show events list in local console (read only)'); + } + } + + if (!config_update_value('replication_dbengine', (string) get_parameter('replication_dbengine'))) { + $error_update[] = __('Replication DB engine'); + } + + if (!config_update_value('replication_dbhost', (string) get_parameter('replication_dbhost'))) { + $error_update[] = __('Replication DB host'); + } + + if (!config_update_value('replication_dbname', (string) get_parameter('replication_dbname'))) { + $error_update[] = __('Replication DB database'); + } + + if (!config_update_value('replication_dbuser', (string) get_parameter('replication_dbuser'))) { + $error_update[] = __('Replication DB user'); + } + + if (!config_update_value('replication_dbpass', io_input_password((string) get_parameter('replication_dbpass')))) { + $error_update[] = __('Replication DB password'); + } + + if (!config_update_value('replication_dbport', (string) get_parameter('replication_dbport'))) { + $error_update[] = __('Replication DB port'); + } + + if (!config_update_value('metaconsole_agent_cache', (int) get_parameter('metaconsole_agent_cache'))) { + $error_update[] = __('Metaconsole agent cache'); + } + + if (!config_update_value('log_collector', (bool) get_parameter('log_collector'))) { + $error_update[] = __('Activate Log Collector'); + } + + if (!config_update_value('enable_update_manager', get_parameter('enable_update_manager'))) { + $error_update[] = __('Enable Update Manager'); + } + + if (!config_update_value('ipam_ocuppied_critical_treshold', get_parameter('ipam_ocuppied_critical_treshold'))) { + $error_update[] = __('Ipam Ocuppied Manager Critical'); + } + + if (!config_update_value('ipam_ocuppied_warning_treshold', get_parameter('ipam_ocuppied_warning_treshold'))) { + $error_update[] = __('Ipam Ocuppied Manager Warning'); + } + + $inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', []); + if (!config_update_value('inventory_changes_blacklist', implode(',', $inventory_changes_blacklist))) { + $error_update[] = __('Inventory changes blacklist'); + } + + if (!config_update_value('email_from_dir', get_parameter('email_from_dir'))) { + $error_update[] = __('From dir'); + } + + if (!config_update_value('email_from_name', get_parameter('email_from_name'))) { + $error_update[] = __('From name'); + } + + if (!config_update_value('email_smtpServer', get_parameter('email_smtpServer'))) { + $error_update[] = __('Server SMTP'); + } + + if (!config_update_value('email_smtpPort', (int) get_parameter('email_smtpPort'))) { + $error_update[] = __('Port SMTP'); + } + + if (!config_update_value('email_encryption', get_parameter('email_encryption'))) { + $error_update[] = __('Encryption'); + } + + if (!config_update_value('email_username', get_parameter('email_username'))) { + $error_update[] = __('Email user'); + } + + if (!config_update_value('email_password', get_parameter('email_password'))) { + $error_update[] = __('Email password'); + } + } + break; + + case 'pass': + if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { + if (!config_update_value('enable_pass_policy', get_parameter('enable_pass_policy'))) { + $error_update[] = __('Enable password policy'); + } + + if (!config_update_value('pass_size', get_parameter('pass_size'))) { + $error_update[] = __('Min. size password'); + } + + if (!config_update_value('pass_expire', get_parameter('pass_expire'))) { + $error_update[] = __('Password expiration'); + } + + if (!config_update_value('first_login', get_parameter('first_login'))) { + $error_update[] = __('Force change password on first login'); + } + + if (!config_update_value('mins_fail_pass', get_parameter('mins_fail_pass'))) { + $error_update[] = __('User blocked if login fails'); + } + + if (!config_update_value('number_attempts', get_parameter('number_attempts'))) { + $error_update[] = __('Number of failed login attempts'); + } + + if (!config_update_value('pass_needs_numbers', get_parameter('pass_needs_numbers'))) { + $error_update[] = __('Password must have numbers'); + } + + if (!config_update_value('pass_needs_symbols', get_parameter('pass_needs_symbols'))) { + $error_update[] = __('Password must have symbols'); + } + + if (!config_update_value('enable_pass_policy_admin', get_parameter('enable_pass_policy_admin'))) { + $error_update[] = __('Apply password policy to admin users'); + } + + if (!config_update_value('enable_pass_history', get_parameter('enable_pass_history'))) { + $error_update[] = __('Enable password history'); + } + + if (!config_update_value('compare_pass', get_parameter('compare_pass'))) { + $error_update[] = __('Compare previous password'); + } + + if (!config_update_value('reset_pass_option', (bool) get_parameter('reset_pass_option'))) { + $error_update[] = __('Activate reset password'); + } + } + break; + + case 'auth': + // AUTHENTICATION SETUP. + if (!config_update_value('auth', get_parameter('auth'))) { + $error_update[] = __('Authentication method'); + } + + if (!config_update_value('autocreate_remote_users', get_parameter('autocreate_remote_users'))) { + $error_update[] = __('Autocreate remote users'); + } + + if (!config_update_value('default_remote_profile', get_parameter('default_remote_profile'))) { + $error_update[] = __('Autocreate profile'); + } + + if (!config_update_value('default_remote_group', get_parameter('default_remote_group'))) { + $error_update[] = __('Autocreate profile group'); + } + + if (!config_update_value('default_assign_tags', implode(',', get_parameter('default_assign_tags')))) { + $error_update[] = __('Autocreate profile tags'); + } + + if (!config_update_value('default_no_hierarchy', (int) get_parameter('default_no_hierarchy'))) { + $error_update[] = __('Automatically assigned no hierarchy'); + } + + if (!config_update_value('autocreate_blacklist', get_parameter('autocreate_blacklist'))) { + $error_update[] = __('Autocreate blacklist'); + } + + if (!config_update_value('ad_server', get_parameter('ad_server'))) { + $error_update[] = __('Active directory server'); + } + + if (!config_update_value('ad_port', get_parameter('ad_port'))) { + $error_update[] = __('Active directory port'); + } + + if (!config_update_value('ad_start_tls', get_parameter('ad_start_tls'))) { + $error_update[] = __('Start TLS'); + } + + if (!config_update_value('ad_advanced_config', get_parameter('ad_advanced_config'))) { + $error_update[] = __('Advanced Config AD'); + } + + if (!config_update_value('ldap_advanced_config', get_parameter('ldap_advanced_config'))) { + $error_update[] = __('Advanced Config LDAP'); + } + + if (!config_update_value('ad_domain', get_parameter('ad_domain'))) { + $error_update[] = __('Domain'); + } + + if (!config_update_value('ad_adv_perms', get_parameter('ad_adv_perms'))) { + $error_update[] = __('Advanced Permisions AD'); + } + + if (!config_update_value('ldap_adv_perms', get_parameter('ldap_adv_perms'))) { + $error_update[] = __('Advanced Permissions LDAP'); + } + + if (!config_update_value('ldap_server', get_parameter('ldap_server'))) { + $error_update[] = __('LDAP server'); + } + + if (!config_update_value('ldap_port', get_parameter('ldap_port'))) { + $error_update[] = __('LDAP port'); + } + + if (!config_update_value('ldap_version', get_parameter('ldap_version'))) { + $error_update[] = __('LDAP version'); + } + + if (!config_update_value('ldap_start_tls', get_parameter('ldap_start_tls'))) { + $error_update[] = __('Start TLS'); + } + + if (!config_update_value('ldap_base_dn', get_parameter('ldap_base_dn'))) { + $error_update[] = __('Base DN'); + } + + if (!config_update_value('ldap_login_attr', get_parameter('ldap_login_attr'))) { + $error_update[] = __('Login attribute'); + } + + if (!config_update_value('ldap_admin_login', get_parameter('ldap_admin_login'))) { + $error_update[] = __('Admin LDAP login'); + } + + if (!config_update_value('ldap_admin_pass', get_parameter('ldap_admin_pass'))) { + $error_update[] = __('Admin LDAP password'); + } + + if (!config_update_value('fallback_local_auth', get_parameter('fallback_local_auth'))) { + $error_update[] = __('Fallback to local authentication'); + } + + if (!config_update_value('ldap_login_user_attr', get_parameter('ldap_login_user_attr'))) { + $error_update[] = __('Login user attribute'); + } + + if (!config_update_value('ldap_function', get_parameter('ldap_function'))) { + $error_update[] = __('LDAP function'); + } + + if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 0) { + if (!config_update_value('ldap_save_password', get_parameter('ldap_save_password'))) { + $error_update[] = __('Save Password'); + } + } else if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 1) { + config_update_value('ldap_save_password', 1); + } + + if (!config_update_value('rpandora_server', get_parameter('rpandora_server'))) { + $error_update[] = __('MySQL host'); + } + + if (!config_update_value('rpandora_port', get_parameter('rpandora_port'))) { + $error_update[] = __('MySQL port'); + } + + if (!config_update_value('rpandora_dbname', get_parameter('rpandora_dbname'))) { + $error_update[] = __('Database name'); + } + + if (!config_update_value('rpandora_user', get_parameter('rpandora_user'))) { + $error_update[] = __('User'); + } + + if (!config_update_value('rpandora_pass', io_input_password(get_parameter('rpandora_pass')))) { + $error_update[] = __('Password'); + } + + if (!config_update_value('rintegria_server', get_parameter('rintegria_server'))) { + $error_update[] = __('Integria host'); + } + + if (!config_update_value('rintegria_port', get_parameter('rintegria_port'))) { + $error_update[] = __('MySQL port'); + } + + if (!config_update_value('rintegria_dbname', get_parameter('rintegria_dbname'))) { + $error_update[] = __('Database name'); + } + + if (!config_update_value('rintegria_user', get_parameter('rintegria_user'))) { + $error_update[] = __('User'); + } + + if (!config_update_value('rintegria_pass', io_input_password(get_parameter('rintegria_pass')))) { + $error_update[] = __('Password'); + } + + if (!config_update_value('saml_path', get_parameter('saml_path'))) { + $error_update[] = __('Saml path'); + } + + if (!config_update_value('double_auth_enabled', get_parameter('double_auth_enabled'))) { + $error_update[] = __('Double authentication'); + } + + if (!config_update_value('session_timeout', get_parameter('session_timeout'))) { + $error_update[] = __('Session timeout'); + } + break; + + case 'perf': + // PERFORMANCE SETUP. + if (!config_update_value('event_purge', get_parameter('event_purge'))) { + $check_metaconsole_events_history = get_parameter('metaconsole_events_history', -1); + $error_update[] = $check_metaconsole_events_history; + } + + if ($check_metaconsole_events_history != -1) { + if (!config_update_value('metaconsole_events_history', get_parameter('metaconsole_events_history'))) { + $error_update[] = __('Max. days before delete events'); + } + } + + if (!config_update_value('trap_purge', get_parameter('trap_purge'))) { + $error_update[] = __('Max. days before delete traps'); + } + + if (!config_update_value('string_purge', get_parameter('string_purge'))) { + $error_update[] = __('Max. days before delete string data'); + } + + if (!config_update_value('audit_purge', get_parameter('audit_purge'))) { + $error_update[] = __('Max. days before delete audit events'); + } + + if (!config_update_value('gis_purge', get_parameter('gis_purge'))) { + $error_update[] = __('Max. days before delete GIS data'); + } + + if (!config_update_value('days_purge', (int) get_parameter('days_purge'))) { + $error_update[] = __('Max. days before purge'); + } + + if (!config_update_value('days_delete_unknown', (int) get_parameter('days_delete_unknown'))) { + $error_update[] = __('Max. days before delete unknown modules'); + } + + if (!config_update_value('days_compact', (int) get_parameter('days_compact'))) { + $error_update[] = __('Max. days before compact data'); + } + + if (!config_update_value('days_autodisable_deletion', (int) get_parameter('days_autodisable_deletion'))) { + $error_update[] = __('Max. days before autodisable deletion'); + } + + if (!config_update_value('report_limit', (int) get_parameter('report_limit'))) { + $error_update[] = __('Item limit for realtime reports)'); + } + + if (!config_update_value('step_compact', (int) get_parameter('step_compact'))) { + $error_update[] = __('Compact interpolation in hours (1 Fine-20 bad)'); + } + + if (!config_update_value('event_view_hr', (int) get_parameter('event_view_hr'))) { + $error_update[] = __('Default hours for event view'); + } + + if (!config_update_value('realtimestats', get_parameter('realtimestats'))) { + $error_update[] = __('Use realtime statistics'); + } + + if (!config_update_value('stats_interval', get_parameter('stats_interval'))) { + $error_update[] = __('Batch statistics period (secs)'); + } + + if (!config_update_value('agentaccess', (int) get_parameter('agentaccess'))) { + $error_update[] = __('Use agent access graph'); + } + + if (!config_update_value('num_files_attachment', (int) get_parameter('num_files_attachment'))) { + $error_update[] = __('Max. recommended number of files in attachment directory'); + } + + if (!config_update_value('delete_notinit', get_parameter('delete_notinit'))) { + $error_update[] = __('Delete not init modules'); + } + + if (!config_update_value('big_operation_step_datos_purge', get_parameter('big_operation_step_datos_purge'))) { + $error_update[] = __('Big Operatiopn Step to purge old data'); + } + + if (!config_update_value('small_operation_step_datos_purge', get_parameter('small_operation_step_datos_purge'))) { + $error_update[] = __('Small Operation Step to purge old data'); + } + + if (!config_update_value('num_past_special_days', get_parameter('num_past_special_days'))) { + $error_update[] = __('Retention period of past special days'); + } + + if (!config_update_value('max_macro_fields', get_parameter('max_macro_fields'))) { + $error_update[] = __('Max. macro data fields'); + } + + if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { + if (!config_update_value('inventory_purge', get_parameter('inventory_purge'))) { + $error_update[] = __('Max. days before delete inventory data'); + } + } + + if (!config_update_value('max_graph_container', get_parameter('max_graph_container'))) { + $error_update[] = __('Graph container - Max. Items'); + } + break; + + case 'vis': + // VISUAL STYLES SETUP. + if (!config_update_value('date_format', (string) get_parameter('date_format'))) { + $error_update[] = __('Date format string'); + } + + if (!config_update_value('prominent_time', (string) get_parameter('prominent_time'))) { + $error_update[] = __('Timestamp or time comparation'); + } + + if (!config_update_value('graph_color1', (string) get_parameter('graph_color1'))) { + $error_update[] = __('Graph color #1'); + } + + if (!config_update_value('graph_color2', (string) get_parameter('graph_color2'))) { + $error_update[] = __('Graph color #2'); + } + + if (!config_update_value('graph_color3', (string) get_parameter('graph_color3'))) { + $error_update[] = __('Graph color #3'); + } + + if (!config_update_value('graph_color4', (string) get_parameter('graph_color4'))) { + $error_update[] = __('Graph color #4'); + } + + if (!config_update_value('graph_color5', (string) get_parameter('graph_color5'))) { + $error_update[] = __('Graph color #5'); + } + + if (!config_update_value('graph_color6', (string) get_parameter('graph_color6'))) { + $error_update[] = __('Graph color #6'); + } + + if (!config_update_value('graph_color7', (string) get_parameter('graph_color7'))) { + $error_update[] = __('Graph color #7'); + } + + if (!config_update_value('graph_color8', (string) get_parameter('graph_color8'))) { + $error_update[] = __('Graph color #8'); + } + + if (!config_update_value('graph_color9', (string) get_parameter('graph_color9'))) { + $error_update[] = __('Graph color #9'); + } + + if (!config_update_value('graph_color10', (string) get_parameter('graph_color10'))) { + $error_update[] = __('Graph color #10'); + } + + if (!config_update_value('interface_unit', (string) get_parameter('interface_unit', __('Bytes')))) { + $error_update[] = __('Value to interface graphics'); + } + + if (!config_update_value('graph_precision', (string) get_parameter('graph_precision', 1))) { + $error_update[] = __('Data precision for reports'); + } + + $style = (string) get_parameter('style'); + if ($style != $config['style']) { + $style = substr($style, 0, (strlen($style) - 4)); + } + + if (!config_update_value('style', $style)) { + $error_update[] = __('Style template'); + } + + if (!config_update_value('block_size', (int) get_parameter('block_size'))) { + $error_update[] = __('Block size for pagination'); + } + + if (!config_update_value('round_corner', (bool) get_parameter('round_corner'))) { + $error_update[] = __('Use round corners'); + } + + if (!config_update_value('show_qr_code_header', (bool) get_parameter('show_qr_code_header'))) { + $error_update[] = __('Show QR code header'); + } + + if (!config_update_value('status_images_set', (string) get_parameter('status_images_set'))) { + $error_update[] = __('Status icon set'); + } + + if (!config_update_value('fontpath', (string) get_parameter('fontpath'))) { + $error_update[] = __('Font path'); + } + + if (!config_update_value('font_size', get_parameter('font_size'))) { + $error_update[] = __('Font size'); + } + + if (!config_update_value('custom_favicon', (string) get_parameter('custom_favicon'))) { + $error_update[] = __('Custom favicon'); + } + + if (!config_update_value('custom_logo', (string) get_parameter('custom_logo'))) { + $error_update[] = __('Custom logo'); + } + + if (!config_update_value('custom_logo_white_bg', (string) get_parameter('custom_logo_white_bg'))) { + $error_update[] = __('Custom logo white background'); + } + + if (!config_update_value('custom_logo_login', (string) get_parameter('custom_logo_login'))) { + $error_update[] = __('Custom logo login'); + } + + if (!config_update_value('custom_splash_login', (string) get_parameter('custom_splash_login'))) { + $error_update[] = __('Custom splash login'); + } + + if (!config_update_value('custom_docs_logo', (string) get_parameter('custom_docs_logo'))) { + $error_update[] = __('Custom documentation logo'); + } + + if (!config_update_value('custom_support_logo', (string) get_parameter('custom_support_logo'))) { + $error_update[] = __('Custom support logo'); + } + + if (!config_update_value('custom_network_center_logo', (string) get_parameter('custom_network_center_logo'))) { + $error_update[] = __('Custom networkmap center logo'); + } + + if (!config_update_value('custom_mobile_console_logo', (string) get_parameter('custom_mobile_console_logo'))) { + $error_update[] = __('Custom networkmap center logo'); + } + + if (!config_update_value('custom_title1_login', (string) get_parameter('custom_title1_login'))) { + $error_update[] = __('Custom title1 login'); + } + + if (!config_update_value('custom_title2_login', (string) get_parameter('custom_title2_login'))) { + $error_update[] = __('Custom title2 login'); + } + + if (!config_update_value('login_background', (string) get_parameter('login_background'))) { + $error_update[] = __('Login background'); + } + + if (!config_update_value('custom_docs_url', (string) get_parameter('custom_docs_url'))) { + $error_update[] = __('Custom Docs url'); + } + + if (!config_update_value('custom_support_url', (string) get_parameter('custom_support_url'))) { + $error_update[] = __('Custom support url'); + } + + if (!config_update_value('rb_product_name', (string) get_parameter('rb_product_name'))) { + $error_update[] = __('Product name'); + } + + if (!config_update_value('rb_copyright_notice', (string) get_parameter('rb_copyright_notice'))) { + $error_update[] = __('Copyright notice'); + } + + if (!config_update_value('meta_custom_logo', (string) get_parameter('meta_custom_logo'))) { + $error_update[] = __('Custom logo metaconsole'); + } + + if (!config_update_value('meta_custom_logo_white_bg', (string) get_parameter('meta_custom_logo_white_bg'))) { + $error_update[] = __('Custom logo metaconsole (white background)'); + } + + if (!config_update_value('meta_custom_logo_login', (string) get_parameter('meta_custom_logo_login'))) { + $error_update[] = __('Custom logo login metaconsole'); + } + + if (!config_update_value('meta_custom_splash_login', (string) get_parameter('meta_custom_splash_login'))) { + $error_update[] = __('Custom splash login metaconsole'); + } + + if (!config_update_value('meta_custom_title1_login', (string) get_parameter('meta_custom_title1_login'))) { + $error_update[] = __('Custom title1 login metaconsole'); + } + + if (!config_update_value('meta_custom_title2_login', (string) get_parameter('meta_custom_title2_login'))) { + $error_update[] = __('Custom title2 login metaconsole'); + } + + if (!config_update_value('meta_login_background', (string) get_parameter('meta_login_background'))) { + $error_update[] = __('Login background metaconsole'); + } + + if (!config_update_value('meta_custom_docs_url', (string) get_parameter('meta_custom_docs_url'))) { + $error_update[] = __('Custom Docs url'); + } + + if (!config_update_value('meta_custom_support_url', (string) get_parameter('meta_custom_support_url'))) { + $error_update[] = __('Custom support url'); + } + + if (!config_update_value('vc_refr', get_parameter('vc_refr'))) { + $error_update[] = __('Default interval for refresh on Visual Console'); + } + + if (!config_update_value('vc_favourite_view', (int) get_parameter('vc_favourite_view', 0))) { + $error_update[] = __('Default line favourite_view for the Visual Console'); + } + + if (!config_update_value('vc_menu_items', (int) get_parameter('vc_menu_items', 10))) { + $error_update[] = __('Default line menu items for the Visual Console'); + } + + if (!config_update_value('vc_line_thickness', (int) get_parameter('vc_line_thickness'))) { + $error_update[] = __('Default line thickness for the Visual Console'); + } + + if (!config_update_value('ser_menu_items', (int) get_parameter('ser_menu_items', 10))) { + $error_update[] = __('Default line menu items for the Services'); + } + + if (!config_update_value('agent_size_text_small', get_parameter('agent_size_text_small'))) { + $error_update[] = __('Agent size text'); + } + + if (!config_update_value('agent_size_text_medium', get_parameter('agent_size_text_medium'))) { + $error_update[] = __('Agent size text'); + } + + if (!config_update_value('module_size_text_small', get_parameter('module_size_text_small'))) { + $error_update[] = __('Module size text'); + } + + if (!config_update_value('module_size_text_medium', get_parameter('module_size_text_medium'))) { + $error_update[] = __('Description size text'); + } + + if (!config_update_value('description_size_text', get_parameter('description_size_text'))) { + $error_update[] = __('Description size text'); + } + + if (!config_update_value('item_title_size_text', get_parameter('item_title_size_text'))) { + $error_update[] = __('Item title size text'); + } + + if (!config_update_value('gis_label', get_parameter('gis_label'))) { + $error_update[] = __('GIS Labels'); + } + + if (!config_update_value('simple_module_value', get_parameter('simple_module_value'))) { + $error_update[] = __('Show units in values report'); + } + + if (!config_update_value('gis_default_icon', get_parameter('gis_default_icon'))) { + $error_update[] = __('Default icon in GIS'); + } + + if (!config_update_value('autohidden_menu', get_parameter('autohidden_menu'))) { + $error_update[] = __('Autohidden menu'); + } + + if (!config_update_value('visual_animation', get_parameter('visual_animation'))) { + $error_update[] = __('visual_animation'); + } + + if (!config_update_value('disable_help', get_parameter('disable_help'))) { + $error_update[] = __('Disable help'); + } + + if (!config_update_value('fixed_graph', get_parameter('fixed_graph'))) { + $error_update[] = __('Fixed graph'); + } + + if (!config_update_value('fixed_header', get_parameter('fixed_header'))) { + $error_update[] = __('Fixed header'); + } + + if (!config_update_value('fixed_menu', get_parameter('fixed_menu'))) { + $error_update[] = __('Fixed menu'); + } + + if (!config_update_value('paginate_module', get_parameter('paginate_module'))) { + $error_update[] = __('Paginate module'); + } + + if (!config_update_value('graphviz_bin_dir', get_parameter('graphviz_bin_dir'))) { + $error_update[] = __('Custom graphviz directory'); + } + + if (!config_update_value('networkmap_max_width', get_parameter('networkmap_max_width'))) { + $error_update[] = __('Networkmap max width'); + } + + if (!config_update_value('short_module_graph_data', get_parameter('short_module_graph_data'))) { + $error_update[] = __('Shortened module graph data'); + } + + if (!config_update_value('show_group_name', get_parameter('show_group_name'))) { + $error_update[] = __('Show the group name instead the group icon.'); + } + + if (!config_update_value('custom_graph_width', (int) get_parameter('custom_graph_width', 1))) { + $error_update[] = __('Default line thickness for the Custom Graph.'); + } + + if (!config_update_value('type_module_charts', (string) get_parameter('type_module_charts', 'area'))) { + $error_update[] = __('Default type of module charts.'); + } + + if (!config_update_value('type_interface_charts', (string) get_parameter('type_interface_charts', 'line'))) { + $error_update[] = __('Default type of interface charts.'); + } + + if (!config_update_value('render_proc', (bool) get_parameter('render_proc', false))) { + $error_update[] = __('Display data of proc modules in other format'); + } + + if (!config_update_value('render_proc_ok', (string) get_parameter('render_proc_ok', __('Ok')))) { + $error_update[] = __('Display text proc modules have state is ok'); + } + + if (!config_update_value('render_proc_fail', (string) get_parameter('render_proc_fail', __('Fail')))) { + $error_update[] = __('Display text when proc modules have state critical'); + } + + // Daniel maya 02/06/2016 Display menu with click --INI. + if (!config_update_value('click_display', (bool) get_parameter('click_display', false))) { + $error_update[] = __('Display lateral menus with left click'); + } + + // Daniel maya 02/06/2016 Display menu with click --END. + if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { + if (!config_update_value('service_label_font_size', get_parameter('service_label_font_size', false))) { + $error_update[] = __('Service label font size'); + } + + if (!config_update_value('service_item_padding_size', get_parameter('service_item_padding_size', false))) { + $error_update[] = __('Service item padding size'); + } + } + + if (!config_update_value('percentil', (int) get_parameter('percentil', 0))) { + $error_update[] = __('Default percentil'); + } + + if (!config_update_value('full_scale_option', (int) get_parameter('full_scale_option', 0))) { + $error_update[] = __('Default full scale (TIP)'); + } + + if (!config_update_value('type_mode_graph', (int) get_parameter('type_mode_graph', 0))) { + $error_update[] = __('Default soft graphs'); + } + + if (!config_update_value('zoom_graph', (int) get_parameter('zoom_graph', 1))) { + $error_update[] = __('Default zoom graphs'); + } + + if (!config_update_value('graph_image_height', (int) get_parameter('graph_image_height', 280))) { + $error_update[] = __('Default height of the chart image'); + } + + if (!config_update_value('classic_menu', (bool) get_parameter('classic_menu', false))) { + $error_update[] = __('Classic menu mode'); + } + + // -------------------------------------------------- + // CUSTOM VALUES POST PROCESS + // -------------------------------------------------- + $custom_value = get_parameter('custom_value'); + $custom_text = get_parameter('custom_text'); + $custom_value_add = (bool) get_parameter('custom_value_add', 0); + $custom_value_to_delete = get_parameter('custom_value_to_delete', 0); + + $custom_value = str_replace(',', '.', $custom_value); + + if ($custom_value_add) { + include_once 'include/functions_post_process.php'; + + if (!post_process_add_custom_value( + $custom_text, + (string) $custom_value + ) + ) { + $error_update[] = __('Add the custom post process'); + } + } + + if ($custom_value_to_delete > 0) { + include_once 'include/functions_post_process.php'; + + if (!post_process_delete_custom_value($custom_value_to_delete)) { + $error_update[] = __('Delete the custom post process'); + } + } + + // -------------------------------------------------- + // -------------------------------------------------- + // CUSTOM INTERVAL VALUES + // -------------------------------------------------- + $interval_values = get_parameter('interval_values'); + + // Add new interval value if is provided. + $interval_value = (float) get_parameter('interval_value', 0); + + if ($interval_value > 0) { + $interval_unit = (int) get_parameter('interval_unit'); + $new_interval = ($interval_value * $interval_unit); + + if ($interval_values === '') { + $interval_values = $new_interval; + } else { + $interval_values_array = explode(',', $interval_values); + if (!in_array($new_interval, $interval_values_array)) { + $interval_values_array[] = $new_interval; + $interval_values = implode(',', $interval_values_array); + } + } + } + + // 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); + foreach ($interval_values_array as $k => $iva) { + if ($interval_to_delete == $iva) { + unset($interval_values_array[$k]); + } + } + + $interval_values = implode(',', $interval_values_array); + } + + if (!config_update_value('interval_values', $interval_values)) { + $error_update[] = __('Delete interval'); + } + + // -------------------------------------------------- + if (!config_update_value('custom_report_info', get_parameter('custom_report_info'))) { + $error_update[] = __('Custom report info'); + } + + // 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'); + } + + if (!config_update_value('custom_report_front_font', get_parameter('custom_report_front_font'))) { + $error_update[] = __('Custom report front').' - '.__('Font family'); + } + + if (!config_update_value('custom_report_front_logo', get_parameter('custom_report_front_logo'))) { + $error_update[] = __('Custom report front').' - '.__('Custom logo'); + } + + if (!config_update_value('custom_report_front_header', get_parameter('custom_report_front_header'))) { + $error_update[] = __('Custom report front').' - '.__('Header'); + } + + if (!config_update_value('custom_report_front_firstpage', get_parameter('custom_report_front_firstpage'))) { + $error_update[] = __('Custom report front').' - '.__('First page'); + } + + if (!config_update_value('custom_report_front_footer', get_parameter('custom_report_front_footer'))) { + $error_update[] = __('Custom report front').' - '.__('Footer'); + } + + if (!config_update_value('csv_divider', (string) get_parameter('csv_divider', ';'))) { + $error_update[] = __('CSV divider'); + } + break; + + case 'net': + if (!config_update_value('netflow_path', get_parameter('netflow_path'))) { + $error_update[] = __('Data storage path'); + } + + if (!config_update_value('netflow_interval', (int) get_parameter('netflow_interval'))) { + $error_update[] = __('Daemon interval'); + } + + if (!config_update_value('netflow_daemon', get_parameter('netflow_daemon'))) { + $error_update[] = __('Daemon binary path'); + } + + if (!config_update_value('netflow_nfdump', get_parameter('netflow_nfdump'))) { + $error_update[] = __('Nfdump binary path'); + } + + if (!config_update_value('netflow_nfexpire', get_parameter('netflow_nfexpire'))) { + $error_update[] = __('Nfexpire binary path'); + } + + if (!config_update_value('netflow_max_resolution', (int) get_parameter('netflow_max_resolution'))) { + $error_update[] = __('Maximum chart resolution'); + } + + if (!config_update_value('netflow_disable_custom_lvfilters', get_parameter('netflow_disable_custom_lvfilters'))) { + $error_update[] = __('Disable custom live view filters'); + } + + if (!config_update_value('netflow_max_lifetime', (int) get_parameter('netflow_max_lifetime'))) { + $error_update[] = __('Netflow max lifetime'); + } + + if (!config_update_value('netflow_get_ip_hostname', (int) get_parameter('netflow_get_ip_hostname'))) { + $error_update[] = __('Name resolution for IP address'); + } + break; + + case 'log': + if (!config_update_value('elasticsearch_ip', get_parameter('elasticsearch_ip'))) { + $error_update[] = __('IP ElasticSearch server'); + } + + if (!config_update_value('elasticsearch_port', get_parameter('elasticsearch_port'))) { + $error_update[] = __('Port ElasticSearch server'); + } + + if (!config_update_value('number_logs_viewed', (int) get_parameter('number_logs_viewed'))) { + $error_update[] = __('Number of logs viewed'); + } + + if (!config_update_value('Days_purge_old_information', (int) get_parameter('Days_purge_old_information'))) { + $error_update[] = __('Days to purge old information'); + } + break; + + case 'hist_db': + if (!config_update_value('history_db_enabled', get_parameter('history_db_enabled'))) { + $error_update[] = __('Enable history database'); + } + + if (!config_update_value('history_event_enabled', get_parameter('history_event_enabled'))) { + $error_update[] = __('Enable history event'); + } + + if (!config_update_value('history_db_host', get_parameter('history_db_host'))) { + $error_update[] = __('Host'); + } + + if (!config_update_value('history_db_port', get_parameter('history_db_port'))) { + $error_update[] = __('Port'); + } + + if (!config_update_value('history_db_name', get_parameter('history_db_name'))) { + $error_update[] = __('Database name'); + } + + if (!config_update_value('history_db_user', get_parameter('history_db_user'))) { + $error_update[] = __('Database user'); + } + + if (!config_update_value('history_db_pass', io_input_password(get_parameter('history_db_pass')))) { + $error_update[] = __('Database password'); + } + + if (!config_update_value('history_db_days', get_parameter('history_db_days'))) { + $error_update[] = __('Days'); + } + + if (!config_update_value('history_event_days', get_parameter('history_event_days'))) { + $error_update[] = __('Event Days'); + } + + if (!config_update_value('history_db_step', get_parameter('history_db_step'))) { + $error_update[] = __('Step'); + } + + if (!config_update_value('history_db_delay', get_parameter('history_db_delay'))) { + $error_update[] = __('Delay'); + } + break; + + case 'ehorus': + if (!config_update_value('ehorus_enabled', (int) get_parameter('ehorus_enabled', $config['ehorus_enabled']))) { + $error_update[] = __('Enable eHorus'); + } + + if (!config_update_value('ehorus_user', (string) get_parameter('ehorus_user', $config['ehorus_user']))) { + $error_update[] = __('eHorus user'); + } + + if (!config_update_value('ehorus_pass', io_input_password((string) get_parameter('ehorus_pass', $config['ehorus_pass'])))) { + $error_update[] = __('eHorus password'); + } + + if (!config_update_value('ehorus_hostname', (string) get_parameter('ehorus_hostname', $config['ehorus_hostname']))) { + $error_update[] = __('eHorus API hostname'); + } + + if (!config_update_value('ehorus_port', (int) get_parameter('ehorus_port', $config['ehorus_port']))) { + $error_update[] = __('eHorus API port'); + } + + if (!config_update_value('ehorus_req_timeout', (int) get_parameter('ehorus_req_timeout', $config['ehorus_req_timeout']))) { + $error_update[] = __('eHorus request timeout'); + } + + if (!config_update_value('ehorus_custom_field', (string) get_parameter('ehorus_custom_field', $config['ehorus_custom_field']))) { + $error_update[] = __('eHorus id custom field'); + } + break; + + default: + // Ignore. + break; + } + + default: + // Ignore. + break; + } + + if (count($error_update) > 0) { + $config['error_config_update_config'] = []; + $config['error_config_update_config']['correct'] = false; + $values = implode(', ', $error_update); + $config['error_config_update_config']['message'] = sprintf(__('Failed updated: the next values cannot update: %s'), $values); + } else { + $config['error_config_update_config'] = []; + $config['error_config_update_config']['correct'] = true; + } + + enterprise_include_once('include/functions_policies.php'); + $enterprise = enterprise_include_once('include/functions_skins.php'); + if ($enterprise !== ENTERPRISE_NOT_HOOK) { + $config['relative_path'] = get_parameter('relative_path', $config['relative_path']); + } } + /** - * Process config variables + * Process config variables. + * + * @return void */ -function config_process_config () { - global $config; - - $configs = db_get_all_rows_in_table ('tconfig'); - - if (empty ($configs)) { - include ($config["homedir"]."/general/error_emptyconfig.php"); - exit; - } - - $is_windows = false; - if (substr(strtolower(PHP_OS), 0, 3) === 'win') { - $is_windows = true; - } - - /* Compatibility fix */ - foreach ($configs as $c) { - $config[$c['token']] = $c['value']; - } - - if (!isset ($config['language'])) { - config_update_value ('language', 'en'); - } - - if (isset ($config['homeurl']) && (strlen($config['homeurl']) > 0)) { - if ($config['homeurl'][0] != '/') { - $config['homeurl'] = '/'.$config['homeurl']; - } - } - - if (!isset ($config['remote_config'])) { - if ($is_windows) - $default = 'C:\\PandoraFMS\\Pandora_Server\\data_in'; - else - $default = '/var/spool/pandora/data_in'; - - config_update_value ('remote_config', $default); - } - - if (!isset ($config['phantomjs_bin'])) { - if ($is_windows){ - $default = 'C:\\PandoraFMS\\phantomjs'; - } - else{ - $default = '/usr/bin'; - } - config_update_value ('phantomjs_bin', $default); - } - - if (!isset ($config['date_format'])) { - config_update_value ('date_format', 'F j, Y, g:i a'); - } - - if (!isset ($config['event_view_hr'])) { - config_update_value ('event_view_hr', 8); - } - - if (!isset ($config['report_limit'])) { - config_update_value ('report_limit', 100); - } - - if (!isset ($config['loginhash_pwd'])) { - config_update_value ('loginhash_pwd', io_input_password(rand (0, 1000) * rand (0, 1000)."pandorahash")); - } - - if (!isset ($config["trap2agent"])) { - config_update_value ('trap2agent', 0); - } - - 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) - config_update_value ('prominent_time', 'comparation'); - } - - if (!isset ($config["timesource"])) { - // 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 - config_update_value ('https', false); - } - if (!isset ($config["use_cert"])) { - config_update_value ('use_cert', false); - } - - if (!isset ($config['cert_path'])) { - // Sets name and path of ssl path for use in application - config_update_value ('cert_path', '/etc/ssl/certs/pandorafms.pem'); - } - - if (!isset ($config["num_files_attachment"])) { - config_update_value ('num_files_attachment', 100); - } - - if (!isset ($config['status_images_set'])) { - config_update_value ('status_images_set', 'default'); - } - - // Load user session - if (isset ($_SESSION['id_usuario'])) - $config["id_user"] = $_SESSION["id_usuario"]; - - if (!isset ($config["round_corner"])) { - config_update_value ('round_corner', false); - } - - if (!isset ($config["show_qr_code_header"])) { - config_update_value ('show_qr_code_header', false); - } - - if (!isset ($config["agentaccess"])) { - config_update_value ('agentaccess', true); - } - - if (!isset ($config["timezone"])) { - config_update_value ('timezone', "Europe/Berlin"); - } - - if (!isset ($config["stats_interval"])) { - config_update_value ('stats_interval', SECONDS_5MINUTES); - } - - if (!isset ($config["realtimestats"])) { - config_update_value ('realtimestats', 1); - } - - if (!isset ($config["delete_notinit"])) { - config_update_value ('delete_notinit', 0); - } - - if (!isset ($config["big_operation_step_datos_purge"])) { - config_update_value ('big_operation_step_datos_purge', 100); - } - - if (!isset ($config["small_operation_step_datos_purge"])) { - config_update_value ('small_operation_step_datos_purge', 1000); - } - - if (!isset ($config["num_past_special_days"])) { - config_update_value ('num_past_special_days', 0); - } - - if (isset($config['enterprise_installed'])) { - if (!isset($config['inventory_purge'])) { - config_update_value ('inventory_purge', 21); - } - } - - if (!isset($config['max_graph_container'])) { - config_update_value ('max_graph_container', 10); - } - - if (!isset($config['max_macro_fields'])) { - config_update_value ('max_macro_fields', 10); - } - - if (!isset ($config["event_purge"])) { - config_update_value ('event_purge', 15); - } - - if (!isset ($config["metaconsole_events_history"])) { - config_update_value ('metaconsole_events_history', 0); - } - - if (!isset ($config["trap_purge"])) { - config_update_value ('trap_purge', 7); - } - - if (!isset ($config["string_purge"])) { - config_update_value ('string_purge', 14); - } - - if (!isset ($config["audit_purge"])) { - config_update_value ('audit_purge', 30); - } - - if (!isset ($config["acl_enterprise"])) { - config_update_value ('acl_enterprise', 0); - } - - if (!isset ($config["metaconsole"])) { - config_update_value ('metaconsole', 0); - } - - if (!isset ($config["gis_purge"])) { - config_update_value ('gis_purge', 7); - } - - if (!isset ($config["collection_max_size"])) { - config_update_value ('collection_max_size', 1000000); - } - - if (!isset ($config["event_replication"])) { - config_update_value ('event_replication', 0); - } - - if (!isset ($config["replication_interval"])) { - config_update_value ('replication_interval', 10); - } - - if (!isset ($config["replication_limit"])) { - config_update_value ('replication_limit', 50); - } - - if (!isset ($config["replication_dbengine"])) { - config_update_value ('replication_dbengine', 'mysql'); - } - - if (!isset ($config["replication_dbhost"])) { - config_update_value ('replication_dbhost', ""); - } - - if (!isset ($config["replication_dbname"])) { - config_update_value ('replication_dbname', ""); - } - - if (!isset ($config["replication_dbuser"])) { - config_update_value ('replication_dbuser', ""); - } - - if (!isset ($config["replication_dbpass"])) { - config_update_value ('replication_dbpass', ""); - } - - if (!isset ($config["replication_dbport"])) { - config_update_value ('replication_dbport', ""); - } - - if (!isset ($config["replication_mode"])) { - config_update_value ('replication_mode', "only_validated"); - } - - if (!isset ($config["metaconsole_agent_cache"])) { - config_update_value ('metaconsole_agent_cache', 0); - } - - if (!isset ($config["show_events_in_local"])) { - config_update_value ('show_events_in_local', 0); - } - - if (!isset ($config["log_collector"])) { - config_update_value ('log_collector', 0); - } - - if (!isset ($config["enable_update_manager"])) { - config_update_value ('enable_update_manager', 1); - } - - if (!isset ($config["ipam_ocuppied_critical_treshold"])) { - config_update_value ('ipam_ocuppied_critical_treshold', 90); - } - - if (!isset ($config["ipam_ocuppied_warning_treshold"])) { - config_update_value ('ipam_ocuppied_warning_treshold', 80); - } - - if (!isset ($config["reset_pass_option"])) { - config_update_value ('reset_pass_option', 0); - } - - if (!isset ($config["include_agents"])) { - config_update_value ('include_agents', 0); - } - - if (!isset ($config["alias_as_name"])) { - config_update_value ('alias_as_name', 0); - } - - if (!isset ($config["auditdir"])) { - config_update_value ('auditdir',"/var/www/html/pandora_console"); - } - - if (!isset ($config["elasticsearch_ip"])) { - config_update_value ('elasticsearch_ip', ""); - } - - if (!isset ($config["elasticsearch_port"])) { - config_update_value ('elasticsearch_port', 9200); - } - - if (!isset ($config["number_logs_viewed"])) { - config_update_value ('number_logs_viewed', 50); - } - - if (!isset ($config["Days_purge_old_information"])) { - config_update_value ('Days_purge_old_information', 90); - } - - if (!isset ($config["font_size"])) { - config_update_value ('font_size', 6); - } - - if (!isset ($config["limit_parameters_massive"])) { - config_update_value ('limit_parameters_massive', ini_get("max_input_vars") / 2); - } - - /* - *Parse the ACL IP list for access API - */ - $temp_list_ACL_IPs_for_API = array(); - if (isset($config['list_ACL_IPs_for_API'])) { - if (!empty($config['list_ACL_IPs_for_API'])) { - $temp_list_ACL_IPs_for_API = explode(';', $config['list_ACL_IPs_for_API']); - } - } - $config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API; - $keysConfig = array_keys($config); - - - // This is not set here. The first time, when no - // setup is done, update_manager extension manage it - // the first time make a conenction and disable itself - // Not Managed here ! - - // if (!isset ($config["autoupdate"])) { - // config_update_value ('autoupdate', true); - // } - - require_once ($config["homedir"] . "/include/auth/mysql.php"); - require_once ($config["homedir"] . "/include/functions_io.php"); - - - // Next is the directory where "/attachment" directory is placed, - // to upload files stores. This MUST be writtable by http server - // user, and should be in pandora root. By default, Pandora adds - // /attachment to this, so by default is the pandora console home - // dir. - if (!isset ($config['attachment_store'])) { - config_update_value('attachment_store', - io_safe_input($config['homedir']) . '/attachment'); - } - else { - //Fixed when the user moves the pandora console to another dir - //after the first uses. - if (!is_dir($config['attachment_store'])) { - config_update_value('attachment_store', - $config['homedir'] . '/attachment'); - } - } - - - if (!isset ($config['fontpath'])) { - $home = str_replace('\\', '/', $config['homedir'] ); - config_update_value('fontpath', - $home . '/include/fonts/smallfont.ttf'); - } - - if (!isset ($config['style'])) { - config_update_value ( 'style', 'pandora'); - } - - if (!isset ($config["login_background"])) { - config_update_value ('login_background', ''); - } - - if (!isset ($config["login_background_meta"])) { - config_update_value ('login_background_meta', 'background_metaconsole.png'); - } - - if (!isset ($config["paginate_module"])) { - config_update_value ('paginate_module', false); - } - - if (!isset ($config["graphviz_bin_dir"])) { - config_update_value ('graphviz_bin_dir', ""); - } - - if (!isset ($config["disable_help"])) { - config_update_value ('disable_help', false); - } - - if (!isset ($config["fixed_header"])) { - config_update_value ('fixed_header', false); - } - - if (!isset ($config["fixed_graph"])) { - config_update_value ('fixed_graph', false); - } - - if (!isset ($config["fixed_menu"])) { - config_update_value ('fixed_menu', false); - } - - if (!isset ($config["custom_favicon"])) { - config_update_value ('custom_favicon', ''); - } - - if (!isset ($config["custom_logo"])) { - config_update_value ('custom_logo', 'pandora_logo_head_4.png'); - } - - if (!isset ($config["custom_logo_white_bg"])) { - config_update_value ('custom_logo_white_bg', 'pandora_logo_head_white_bg.png'); - } - - if (!isset ($config["custom_logo_login"])) { - config_update_value ('custom_logo_login', 'login_logo_v7.png'); - } - - if (!isset ($config["custom_splash_login"])) { - config_update_value ('custom_splash_login', 'splash_image_default.png'); - } - - if (!isset ($config["custom_docs_logo"])) { - config_update_value ('custom_docs_logo', ''); - } - - if (!isset ($config["custom_support_logo"])) { - config_update_value ('custom_support_logo', ''); - } - - if (!isset ($config["custom_network_center_logo"])) { - config_update_value ('custom_network_center_logo', ''); - } - - if (!isset ($config["custom_mobile_console_logo"])) { - config_update_value ('custom_mobile_console_logo', ''); - } - - if (!isset ($config["custom_title1_login"])) { - config_update_value ('custom_title1_login', __('WELCOME TO PANDORA FMS')); - } - - if (!isset ($config["custom_title2_login"])) { - config_update_value ('custom_title2_login', __('NEXT GENERATION')); - } - - if (!isset ($config["custom_docs_url"])) { - config_update_value ('custom_docs_url', 'http://wiki.pandorafms.com/'); - } - - if (!isset ($config["custom_support_url"])) { - config_update_value ('custom_support_url', 'https://support.artica.es'); - } - - if (!isset ($config['rb_product_name'])) { - config_update_value('rb_product_name', get_product_name()); - } - - if (!isset ($config['rb_copyright_notice'])) { - config_update_value('rb_copyright_notice', get_copyright_notice()); - } - - if (!isset ($config["meta_custom_docs_url"])) { - config_update_value ('meta_custom_docs_url', 'http://wiki.pandorafms.com/index.php?title=Main_Page'); - } - - if (!isset ($config["meta_custom_support_url"])) { - config_update_value ('meta_custom_support_url', 'https://support.artica.es'); - } - - if (!isset ($config["meta_custom_logo"])) { - config_update_value ('meta_custom_logo', 'logo_pandora_metaconsola.png'); - } - - if (!isset ($config["meta_custom_logo_white_bg"])) { - config_update_value ('pandora_logo_head_white_bg', 'pandora_logo_head_white_bg.png'); - } - - if (!isset ($config["meta_custom_logo_login"])) { - config_update_value ('meta_custom_logo_login', 'pandora_logo.png'); - } - - if (!isset ($config["meta_custom_splash_login"])) { - config_update_value ('meta_custom_splash_login', 'splash_image_metaconsola.png'); - } - - if (!isset ($config["meta_custom_title1_login"])) { - config_update_value ('meta_custom_title1_login', __('PANDORA FMS NEXT GENERATION')); - } - - if (!isset ($config["meta_custom_title2_login"])) { - config_update_value ('meta_custom_title2_login', __('METACONSOLE')); - } - - if (!isset($config['vc_favourite_view'])) { - config_update_value('vc_favourite_view', 0); - } - if (!isset($config['vc_menu_items'])) { - config_update_value('vc_menu_items', 10); - } - if (!isset($config['ser_menu_items'])) { - config_update_value('ser_menu_items', 10); - } - - if (!isset ($config['history_db_enabled'])) { - config_update_value ( 'history_db_enabled', false); - } - - if (!isset ($config['history_event_enabled'])) { - config_update_value ( 'history_event_enabled', false); - } - - if (!isset ($config['history_db_host'])) { - config_update_value ( 'history_db_host', ''); - } - - if (!isset ($config['history_db_port'])) { - config_update_value ( 'history_db_port', 3306); - } - - if (!isset ($config['history_db_name'])) { - config_update_value ( 'history_db_name', 'pandora'); - } - - if (!isset ($config['history_db_user'])) { - config_update_value ( 'history_db_user', 'pandora'); - } - - if (!isset ($config['history_db_pass'])) { - config_update_value ( 'history_db_pass', ''); - } - - if (!isset ($config['history_db_days'])) { - config_update_value ( 'history_db_days', 0); - } - - if (!isset ($config['history_event_days'])) { - config_update_value ('history_event_days', 90); - } - - if (!isset ($config['history_db_step'])) { - config_update_value ( 'history_db_step', 0); - } - - if (!isset ($config['history_db_delay'])) { - config_update_value ( 'history_db_delay', 0); - } - - if (!isset ($config['email_from_dir'])) { - config_update_value ( 'email_from_dir', "pandora@pandorafms.org"); - } - - if (!isset ($config['email_from_name'])) { - config_update_value ( 'email_from_name', "Pandora FMS"); - } - - if (!isset ($config['email_smtpServer'])) { - config_update_value ( 'email_smtpServer', "127.0.0.1"); - } - - if (!isset ($config['email_smtpPort'])) { - config_update_value ( 'email_smtpPort', 25); - } - - if (!isset ($config['email_encryption'])) { - config_update_value ( 'email_encryption', 0); - } - - if (!isset ($config['email_username'])) { - config_update_value ( 'email_username', ""); - } - - if (!isset ($config['email_password'])) { - config_update_value ( 'email_password', ""); - } - - if (!isset ($config['activate_gis'])) { - config_update_value ( 'activate_gis', 0); - } - - if (!isset ($config['activate_netflow'])) { - config_update_value ( 'activate_netflow', 0); - } - - if (!isset ($config['netflow_path'])) { - if ($is_windows) - $default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\netflow'; - else - $default = '/var/spool/pandora/data_in/netflow'; - - config_update_value ( 'netflow_path', $default); - } - - if (!isset ($config['netflow_interval'])) { - config_update_value ( 'netflow_interval', SECONDS_10MINUTES); - } - - if (!isset ($config['netflow_daemon'])) { - config_update_value ( 'netflow_daemon', '/usr/bin/nfcapd'); - } - - if (!isset ($config['netflow_nfdump'])) { - config_update_value ( 'netflow_nfdump', '/usr/bin/nfdump'); - } - - if (!isset ($config['netflow_nfexpire'])) { - config_update_value ( 'netflow_nfexpire', '/usr/bin/nfexpire'); - } - - if (!isset ($config['netflow_max_resolution'])) { - config_update_value ( 'netflow_max_resolution', '50'); - } - - if (!isset ($config['netflow_disable_custom_lvfilters'])) { - config_update_value ( 'netflow_disable_custom_lvfilters', 0); - } - - if (!isset ($config['netflow_max_lifetime'])) { - config_update_value ( 'netflow_max_lifetime', '5'); - } - - if (!isset ($config['auth'])) { - config_update_value ( 'auth', 'mysql'); - } - - if (!isset ($config['autocreate_remote_users'])) { - config_update_value ('autocreate_remote_users', 0); - } - - if (!isset ($config['autocreate_blacklist'])) { - config_update_value ('autocreate_blacklist', ''); - } - - if (!isset ($config['default_remote_profile'])) { - config_update_value ('default_remote_profile', 0); - } - - if (!isset ($config['default_remote_group'])) { - config_update_value ('default_remote_group', 0); - } - - if (!isset ($config['default_assign_tags'])) { - config_update_value ( 'default_assign_tags', ''); - } - if (!isset ($config['default_no_hierarchy'])) { - config_update_value ('default_no_hierarchy', 0); - } - - if (!isset ($config['ldap_server'])) { - config_update_value ( 'ldap_server', 'localhost'); - } - - if (!isset ($config['ldap_port'])) { - config_update_value ( 'ldap_port', 389); - } - - if (!isset ($config['ldap_version'])) { - config_update_value ( 'ldap_version', '3'); - } - - if (!isset ($config['ldap_start_tls'])) { - config_update_value ( 'ldap_start_tls', 0); - } - - if (!isset ($config['ldap_base_dn'])) { - config_update_value('ldap_base_dn', - 'ou=People,dc=edu,dc=example,dc=org'); - } - - if (!isset ($config['ldap_login_attr'])) { - config_update_value ( 'ldap_login_attr', 'uid'); - } - - if (!isset ($config['ldap_admin_login'])) { - config_update_value ( 'ldap_admin_login', ''); - } - - if (!isset ($config['ldap_admin_pass'])) { - config_update_value ( 'ldap_admin_pass', ''); - } - - if (!isset ($config['ldap_function'])) { - config_update_value ( 'ldap_function', 'local'); - } - - if (!isset ($config['fallback_local_auth'])) { - config_update_value ( 'fallback_local_auth', '0'); - } - - if (!isset ($config['ad_server'])) { - config_update_value ( 'ad_server', 'localhost'); - } - - if (!isset ($config['ad_port'])) { - config_update_value ( 'ad_port', 389); - } - - if (!isset ($config['ad_start_tls'])) { - config_update_value ( 'ad_start_tls', 0); - } - - if (!isset ($config['ad_advanced_config'])) { - config_update_value ( 'ad_advanced_config', 0); - } - - if (!isset ($config['ldap_advanced_config'])) { - config_update_value ( 'ldap_advanced_config', 0); - } - - if (!isset ($config['ad_adv_user_node'])) { - config_update_value ( 'ad_adv_user_node', 1); - } - - if (!isset ($config['ldap_adv_user_node'])) { - config_update_value ( 'ldap_adv_user_node', 1); - } - - if (!isset ($config['ad_domain'])) { - config_update_value ( 'ad_domain', ''); - } - - if (!isset ($config['ad_adv_perms'])) { - config_update_value ('ad_adv_perms', ''); - } - else { - if (!json_decode(io_safe_output($config['ad_adv_perms']))) { - $temp_ad_adv_perms = array(); - if (!isset($config['ad_adv_perms']) && $config['ad_adv_perms'] != '') { - $perms = explode(';', io_safe_output($config['ad_adv_perms'])); - foreach ($perms as $ad_adv_perm) { - if (preg_match('/[\[\]]/',$ad_adv_perm)) { - $all_data = explode (",", io_safe_output($ad_adv_perm)); - $profile = $all_data[0]; - $group_pnd = $all_data[1]; - $groups_ad = str_replace(array("[","]"), "", $all_data[2]); - $tags = str_replace(array("[","]"), "", $all_data[3]); - $groups_ad = explode('|', $groups_ad); - $tags_name = explode('|', $tags); - $tags_ids = array(); - foreach ($tags_name as $tag) { - $tags_ids[] = tags_get_id($tag); - } - $profile = profile_get_profiles( - array( - "name" => io_safe_input($profile))); - if (!$profile) - continue; - $profile_id = array_keys($profile); - $id_grupo = groups_get_id (io_safe_input($group_pnd), false); - $new_ad_adv_perms[] = - array('profile' => $profile_id[0], - 'group' => array($id_grupo), - 'tags' => $tags_ids, - 'groups_ad' => $groups_ad); - } - else { - $all_data = explode (",", io_safe_output($ad_adv_perm)); - $profile = $all_data[0]; - $group_pnd = $all_data[1]; - $groups_ad = $all_data[2]; - $tags = $all_data[3]; - $profile = profile_get_profiles( - array( - "name" => io_safe_input($profile))); - if (!$profile) - continue; - $profile_id = array_keys($profile); - $id_grupo = groups_get_id (io_safe_input($group_pnd), false); - - $new_ad_adv_perms[] = - array('profile' => $profile_id[0], - 'group' => array($id_grupo), - 'tags' => array($tags), - 'groups_ad' => array($groups_ad)); - } - } - - if (!empty($new_ad_adv_perms)) { - $temp_ad_adv_perms = json_encode($new_ad_adv_perms); - } - } - config_update_value ('ad_adv_perms', $temp_ad_adv_perms); - } - } - - if (!isset ($config['ldap_adv_perms'])) { - config_update_value ('ldap_adv_perms', ''); - } - else { - if (!json_decode(io_safe_output($config['ldap_adv_perms']))) { - $temp_ldap_adv_perms = array(); - if (!isset($config['ad_adv_perms']) && $config['ldap_adv_perms'] != '') { - $perms = explode(';', io_safe_output($config['ldap_adv_perms'])); - foreach ($perms as $ad_adv_perm) { - if (preg_match('/[\[\]]/',$ad_adv_perm)) { - $all_data = explode (",", io_safe_output($ad_adv_perm)); - $profile = $all_data[0]; - $group_pnd = $all_data[1]; - $groups_ad = str_replace(array("[","]"), "", $all_data[2]); - $tags = str_replace(array("[","]"), "", $all_data[3]); - $groups_ad = explode('|', $groups_ad); - $tags_name = explode('|', $tags); - $tags_ids = array(); - foreach ($tags_name as $tag) { - $tags_ids[] = tags_get_id($tag); - } - $profile = profile_get_profiles( - array( - "name" => io_safe_input($profile))); - if (!$profile) - continue; - $profile_id = array_keys($profile); - $id_grupo = groups_get_id (io_safe_input($group_pnd), false); - $new_ldap_adv_perms[] = - array('profile' => $profile_id[0], - 'group' => array($id_grupo), - 'tags' => $tags_ids, - 'groups_ldap' => $groups_ldap); - } - else { - $all_data = explode (",", io_safe_output($ad_adv_perm)); - $profile = $all_data[0]; - $group_pnd = $all_data[1]; - $groups_ad = $all_data[2]; - $tags = $all_data[3]; - $profile = profile_get_profiles( - array( - "name" => io_safe_input($profile))); - if (!$profile) - continue; - $profile_id = array_keys($profile); - $id_grupo = groups_get_id (io_safe_input($group_pnd), false); - - $new_ldap_adv_perms[] = - array('profile' => $profile_id[0], - 'group' => array($id_grupo), - 'tags' => array($tags), - 'groups_ldap' => array($groups_ldap)); - } - } - - if (!empty($new_ldap_adv_perms)) { - $temp_ldap_adv_perms = json_encode($new_ldap_adv_perms); - } - } - config_update_value ('ldap_adv_perms', $temp_ldap_adv_perms); - } - } - - if (!isset ($config['rpandora_server'])) { - config_update_value ( 'rpandora_server', 'localhost'); - } - - if (!isset ($config['rpandora_port'])) { - config_update_value ( 'rpandora_port', 3306); - } - - if (!isset ($config['rpandora_dbname'])) { - config_update_value ( 'rpandora_dbname', 'pandora'); - } - - if (!isset ($config['rpandora_user'])) { - config_update_value ( 'rpandora_user', 'pandora'); - } - - if (!isset ($config['rpandora_pass'])) { - config_update_value ( 'rpandora_pass', ''); - } - - if (!isset ($config['rintegria_server'])) { - config_update_value ( 'rintegria_server', 'localhost'); - } - - if (!isset ($config['rintegria_port'])) { - config_update_value ( 'rintegria_port', 3306); - } - - if (!isset ($config['rintegria_dbname'])) { - config_update_value ( 'rintegria_dbname', 'integria'); - } - - if (!isset ($config['rintegria_user'])) { - config_update_value ( 'rintegria_user', 'integria'); - } - - if (!isset ($config['rintegria_pass'])) { - config_update_value ( 'rintegria_pass', ''); - } - - if (!isset ($config['saml_path'])) { - config_update_value ('saml_path', '/opt/'); - } - - if (!isset ($config['autoupdate'])) { - config_update_value ( 'autoupdate', 1); - } - - if (!isset ($config['api_password'])) { - config_update_value( 'api_password', ''); - } - - if (defined('METACONSOLE')) { - // Customizable sections (Metaconsole) - enterprise_include_once ('include/functions_enterprise.php'); - $customizable_sections = enterprise_hook('enterprise_get_customizable_sections'); - - if($customizable_sections != ENTERPRISE_NOT_HOOK) { - foreach($customizable_sections as $k => $v) { - if (!isset ($config[$k])) { - config_update_value($k, $v['default']); - } - } - } - - if (!isset ($config['meta_num_elements'])) { - config_update_value('meta_num_elements', 100); - } - } - - if (!isset ($config['relative_path']) && (isset ($_POST['nick']) - || isset ($config['id_user'])) && isset($config['enterprise_installed'])) { - - $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); - if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { - - // 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 - $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 (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_groups ($id), "UM")) && $config["user_can_update_info"]) { - $view_mode = false; - } - else { - $view_mode = true; - } - - if (isset ($_GET["modified"]) && !$view_mode) { - $upd_info["id_skin"] = get_parameter ("skin", $user_info["id_skin"]); - $return_update_skin = update_user ($id, $upd_info); - } - } - - if(!is_metaconsole()) { - // Skins are available only in console mode - - if (isset($config['id_user'])){ - $relative_path = enterprise_hook('skins_set_image_skin_path',array($config['id_user'])); - } - else{ - $relative_path = enterprise_hook('skins_set_image_skin_path',array(get_parameter('nick'))); - } - } - else { - $relative_path = ''; - } - $config['relative_path'] = $relative_path; - } - } - - if (!isset ($config['dbtype'])) { - config_update_value ('dbtype', 'mysql'); - } - - if (!isset ($config['vc_refr'])) { - config_update_value ('vc_refr', 300); - } - - if (!isset($config['agent_size_text_small'])) { - config_update_value ('agent_size_text_small', 18); - } - - if (!isset($config['agent_size_text_medium'])) { - config_update_value ('agent_size_text_medium', 50); - } - - if (!isset($config['module_size_text_small'])) { - config_update_value ('module_size_text_small', 25); - } - - if (!isset($config['module_size_text_medium'])) { - config_update_value ('module_size_text_medium', 50); - } - - if (!isset($config['description_size_text'])) { - config_update_value ('description_size_text', 60); - } - - if (!isset($config['item_title_size_text'])) { - config_update_value ('item_title_size_text', 45); - } - - if (!isset($config['simple_module_value'])) { - config_update_value ('simple_module_value', 1); - } - - if (!isset($config['gis_label'])) { - config_update_value ('gis_label', 0); - } - - if (!isset($config['interface_unit'])) { - config_update_value ('interface_unit', __('Bytes')); - } - - if (!isset($config['graph_precision'])) { - config_update_value ('graph_precision', 1); - } - else { - if (!isset($config['enterprise_installed'])) { - config_update_value ('graph_precision', 1); - } - } - - if (!isset($config['gis_default_icon'])) { - config_update_value ('gis_default_icon', "marker"); - } - - if (!isset($config['interval_values'])) { - config_update_value ('interval_values', ""); - } - - if (!isset($config['public_url'])) { - config_update_value ('public_url', ""); - } - - if (!isset($config['referer_security'])) { - config_update_value ('referer_security', 0); - } - - if (!isset($config['event_storm_protection'])) { - config_update_value ('event_storm_protection', 0); - } - - if (!isset($config['server_log_dir'])) { - config_update_value ('server_log_dir', ""); - } - - if (!isset($config['max_log_size'])) { - config_update_value ('max_log_size', 512); - } - - if (!isset($config['show_group_name'])) { - config_update_value ('show_group_name', 0); - } - - if (!isset($config['custom_graph_width'])) { - config_update_value ('custom_graph_width', 1); - } - - if (!isset($config['type_module_charts'])) { - config_update_value ('type_module_charts', 'area'); - } - - if (!isset($config['type_interface_charts'])) { - config_update_value ('type_interface_charts', 'line'); - } - - if (!isset($config['render_proc'])) { - config_update_value ('render_proc', 0); - } - - if (!isset($config['graph_image_height'])) { - config_update_value ('graph_image_height', 280); - } - - if (!isset($config['zoom_graph'])) { - config_update_value ('zoom_graph', 1); - } - - if (!isset($config["render_proc_ok"])) { - config_update_value ('render_proc_ok', __('Ok') ); - } - if (!isset($config["render_proc_fail"])) { - config_update_value ('render_proc_fail', __('Fail') ); - } - //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 - if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { - if (!isset($config["service_label_font_size"])) { - config_update_value ('service_label_font_size', 20); - } - - if (!isset($config["service_item_padding_size"])) { - config_update_value ('service_item_padding_size', 80); - } - } - if (!isset($config["classic_menu"])) { - config_update_value ('classic_menu', 0); - } - - if (!isset($config["csv_divider"])) { - config_update_value ('csv_divider', ";"); - } - - if (!isset($config['command_snapshot'])) { - config_update_value ('command_snapshot', 1); - } - - if (!isset($config['custom_report_info'])) { - config_update_value ('custom_report_info', 1); - } - - // Juanma (06/05/2014) New feature: Custom front page for reports - if (!isset($config['custom_report_front'])) { - config_update_value ('custom_report_front', 0); - } - - if (!isset($config['custom_report_front_font'])) { - config_update_value ('custom_report_front_font', 'FreeSans.ttf'); - } - - if (!isset($config['custom_report_front_logo'])) { - config_update_value ('custom_report_front_logo', - 'images/pandora_logo_white.jpg'); - } - - if (!isset($config['custom_report_front_header'])) { - config_update_value ('custom_report_front_header', ''); - } - - if (!isset($config['custom_report_front_firstpage'])) { - config_update_value ('custom_report_front_firstpage', - "<p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><img src="(_URLIMAGE_)/images/pandora_report_logo.png" alt="" width="800" /></p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p> <p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>"); - } - - if (!isset($config['custom_report_front_footer'])) { - config_update_value ('custom_report_front_footer', ''); - } - - if (!isset($config['autohidden_menu'])) { - config_update_value ('autohidden_menu', 0); - } - - if (!isset($config['visual_animation'])) { - config_update_value ('visual_animation', 1); - } - - if (!isset($config['networkmap_max_width'])) { - config_update_value ('networkmap_max_width', 900); - } - - if (!isset($config['short_module_graph_data'])) { - config_update_value ('short_module_graph_data', ''); - } - - if (!isset($config['tutorial_mode'])) { - config_update_value ('tutorial_mode', 'full'); - } - - if (!isset($config['post_process_custom_values'])) { - config_update_value ('post_process_custom_values', - json_encode(array())); - } - - if (!isset($config['update_manager_proxy_server'])) { - config_update_value ('update_manager_proxy_server', - ""); - } - if (!isset($config['update_manager_proxy_port'])) { - config_update_value ('update_manager_proxy_port', - ""); - } - if (!isset($config['update_manager_proxy_user'])) { - config_update_value ('update_manager_proxy_user', - ""); - } - if (!isset($config['update_manager_proxy_password'])) { - config_update_value ('update_manager_proxy_password', - ""); - } - - if (!isset ($config["session_timeout"])) { - config_update_value ('session_timeout', 90); - } - - if (!isset ($config["max_file_size"])) { - config_update_value ('max_file_size', "2M"); - } - - if (!isset ($config["initial_wizard"])) { - config_update_value ('initial_wizard', 0); - } - - if (!isset ($config["identification_reminder"])) { - config_update_value ('identification_reminder', 1); - } - - if (!isset ($config["identification_reminder_timestamp"])) { - config_update_value ('identification_reminder_timestamp', 0); - } - - if (!isset ($config["instance_registered"])) { - config_update_value ('instance_registered', 0); - } - - // eHorus - if (!isset($config['ehorus_enabled'])) { - config_update_value('ehorus_enabled', 0); - } - if (!isset($config['ehorus_custom_field'])) { - config_update_value('ehorus_custom_field', 'eHorusID'); - } - if (!isset($config['ehorus_hostname'])) { - config_update_value('ehorus_hostname', 'portal.ehorus.com'); - } - if (!isset($config['ehorus_port'])) { - config_update_value('ehorus_port', 18080); - } - if (!isset($config['ehorus_req_timeout'])) { - config_update_value('ehorus_req_timeout', 5); - } - - if (is_metaconsole()) { - if (!isset($config["metaconsole_deploy_collection"])) { - config_update_value('metaconsole_deploy_collection', 0); - } - - if (!isset($config["metaconsole_deploy_inventory_plugin"])) { - config_update_value('metaconsole_deploy_inventory_plugin', 0); - } - - if (!isset($config["metaconsole_deploy_plugin_server"])) { - config_update_value('metaconsole_deploy_plugin_server', 0); - } - } - - /* Finally, check if any value was overwritten in a form */ - config_update_config(); +function config_process_config() +{ + global $config; + + $configs = db_get_all_rows_in_table('tconfig'); + + if (empty($configs)) { + include $config['homedir'].'/general/error_emptyconfig.php'; + exit; + } + + $is_windows = false; + if (substr(strtolower(PHP_OS), 0, 3) === 'win') { + $is_windows = true; + } + + // Compatibility fix. + foreach ($configs as $c) { + $config[$c['token']] = $c['value']; + } + + if (!isset($config['language'])) { + config_update_value('language', 'en'); + } + + if (isset($config['homeurl']) && (strlen($config['homeurl']) > 0)) { + if ($config['homeurl'][0] != '/') { + $config['homeurl'] = '/'.$config['homeurl']; + } + } + + if (!isset($config['remote_config'])) { + if ($is_windows) { + $default = 'C:\\PandoraFMS\\Pandora_Server\\data_in'; + } else { + $default = '/var/spool/pandora/data_in'; + } + + config_update_value('remote_config', $default); + } + + if (!isset($config['phantomjs_bin'])) { + if ($is_windows) { + $default = 'C:\\PandoraFMS\\phantomjs'; + } else { + $default = '/usr/bin'; + } + + config_update_value('phantomjs_bin', $default); + } + + if (!isset($config['date_format'])) { + config_update_value('date_format', 'F j, Y, g:i a'); + } + + if (!isset($config['event_view_hr'])) { + config_update_value('event_view_hr', 8); + } + + if (!isset($config['report_limit'])) { + config_update_value('report_limit', 100); + } + + if (!isset($config['loginhash_pwd'])) { + config_update_value('loginhash_pwd', io_input_password((rand(0, 1000) * rand(0, 1000)).'pandorahash')); + } + + if (!isset($config['trap2agent'])) { + config_update_value('trap2agent', 0); + } + + 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). + config_update_value('prominent_time', 'comparation'); + } + + if (!isset($config['timesource'])) { + // 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. + config_update_value('https', false); + } + + if (!isset($config['use_cert'])) { + config_update_value('use_cert', false); + } + + if (!isset($config['cert_path'])) { + // Sets name and path of ssl path for use in application. + config_update_value('cert_path', '/etc/ssl/certs/pandorafms.pem'); + } + + if (!isset($config['num_files_attachment'])) { + config_update_value('num_files_attachment', 100); + } + + if (!isset($config['status_images_set'])) { + config_update_value('status_images_set', 'default'); + } + + // Load user session. + if (isset($_SESSION['id_usuario'])) { + $config['id_user'] = $_SESSION['id_usuario']; + } + + if (!isset($config['round_corner'])) { + config_update_value('round_corner', false); + } + + if (!isset($config['show_qr_code_header'])) { + config_update_value('show_qr_code_header', false); + } + + if (!isset($config['agentaccess'])) { + config_update_value('agentaccess', true); + } + + if (!isset($config['timezone'])) { + config_update_value('timezone', 'Europe/Berlin'); + } + + if (!isset($config['stats_interval'])) { + config_update_value('stats_interval', SECONDS_5MINUTES); + } + + if (!isset($config['realtimestats'])) { + config_update_value('realtimestats', 1); + } + + if (!isset($config['delete_notinit'])) { + config_update_value('delete_notinit', 0); + } + + if (!isset($config['big_operation_step_datos_purge'])) { + config_update_value('big_operation_step_datos_purge', 100); + } + + if (!isset($config['small_operation_step_datos_purge'])) { + config_update_value('small_operation_step_datos_purge', 1000); + } + + if (!isset($config['num_past_special_days'])) { + config_update_value('num_past_special_days', 0); + } + + if (isset($config['enterprise_installed'])) { + if (!isset($config['inventory_purge'])) { + config_update_value('inventory_purge', 21); + } + } + + if (!isset($config['max_graph_container'])) { + config_update_value('max_graph_container', 10); + } + + if (!isset($config['max_macro_fields'])) { + config_update_value('max_macro_fields', 10); + } + + if (!isset($config['event_purge'])) { + config_update_value('event_purge', 15); + } + + if (!isset($config['metaconsole_events_history'])) { + config_update_value('metaconsole_events_history', 0); + } + + if (!isset($config['trap_purge'])) { + config_update_value('trap_purge', 7); + } + + if (!isset($config['string_purge'])) { + config_update_value('string_purge', 14); + } + + if (!isset($config['audit_purge'])) { + config_update_value('audit_purge', 30); + } + + if (!isset($config['acl_enterprise'])) { + config_update_value('acl_enterprise', 0); + } + + if (!isset($config['metaconsole'])) { + config_update_value('metaconsole', 0); + } + + if (!isset($config['gis_purge'])) { + config_update_value('gis_purge', 7); + } + + if (!isset($config['collection_max_size'])) { + config_update_value('collection_max_size', 1000000); + } + + if (!isset($config['event_replication'])) { + config_update_value('event_replication', 0); + } + + if (!isset($config['replication_interval'])) { + config_update_value('replication_interval', 10); + } + + if (!isset($config['replication_limit'])) { + config_update_value('replication_limit', 50); + } + + if (!isset($config['replication_dbengine'])) { + config_update_value('replication_dbengine', 'mysql'); + } + + if (!isset($config['replication_dbhost'])) { + config_update_value('replication_dbhost', ''); + } + + if (!isset($config['replication_dbname'])) { + config_update_value('replication_dbname', ''); + } + + if (!isset($config['replication_dbuser'])) { + config_update_value('replication_dbuser', ''); + } + + if (!isset($config['replication_dbpass'])) { + config_update_value('replication_dbpass', ''); + } + + if (!isset($config['replication_dbport'])) { + config_update_value('replication_dbport', ''); + } + + if (!isset($config['replication_mode'])) { + config_update_value('replication_mode', 'only_validated'); + } + + if (!isset($config['metaconsole_agent_cache'])) { + config_update_value('metaconsole_agent_cache', 0); + } + + if (!isset($config['show_events_in_local'])) { + config_update_value('show_events_in_local', 0); + } + + if (!isset($config['log_collector'])) { + config_update_value('log_collector', 0); + } + + if (!isset($config['enable_update_manager'])) { + config_update_value('enable_update_manager', 1); + } + + if (!isset($config['ipam_ocuppied_critical_treshold'])) { + config_update_value('ipam_ocuppied_critical_treshold', 90); + } + + if (!isset($config['ipam_ocuppied_warning_treshold'])) { + config_update_value('ipam_ocuppied_warning_treshold', 80); + } + + if (!isset($config['reset_pass_option'])) { + config_update_value('reset_pass_option', 0); + } + + if (!isset($config['include_agents'])) { + config_update_value('include_agents', 0); + } + + if (!isset($config['alias_as_name'])) { + config_update_value('alias_as_name', 0); + } + + if (!isset($config['auditdir'])) { + config_update_value('auditdir', '/var/www/html/pandora_console'); + } + + if (!isset($config['elasticsearch_ip'])) { + config_update_value('elasticsearch_ip', ''); + } + + if (!isset($config['elasticsearch_port'])) { + config_update_value('elasticsearch_port', 9200); + } + + if (!isset($config['number_logs_viewed'])) { + config_update_value('number_logs_viewed', 50); + } + + if (!isset($config['Days_purge_old_information'])) { + config_update_value('Days_purge_old_information', 90); + } + + if (!isset($config['font_size'])) { + config_update_value('font_size', 6); + } + + if (!isset($config['limit_parameters_massive'])) { + config_update_value('limit_parameters_massive', (ini_get('max_input_vars') / 2)); + } + + /* + * 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'])) { + $temp_list_ACL_IPs_for_API = explode(';', $config['list_ACL_IPs_for_API']); + } + } + + $config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API; + $keysConfig = array_keys($config); + + // This is not set here. The first time, when no + // setup is done, update_manager extension manage it + // the first time make a conenction and disable itself + // Not Managed here ! + // if (!isset ($config["autoupdate"])) { + // config_update_value ('autoupdate', true);. + include_once $config['homedir'].'/include/auth/mysql.php'; + include_once $config['homedir'].'/include/functions_io.php'; + + // Next is the directory where "/attachment" directory is placed, + // to upload files stores. This MUST be writtable by http server + // user, and should be in pandora root. By default, Pandora adds + // /attachment to this, so by default is the pandora console home + // dir. + if (!isset($config['attachment_store'])) { + config_update_value( + 'attachment_store', + io_safe_input($config['homedir']).'/attachment' + ); + } else { + // Fixed when the user moves the pandora console to another dir + // after the first uses. + if (!is_dir($config['attachment_store'])) { + config_update_value( + 'attachment_store', + $config['homedir'].'/attachment' + ); + } + } + + if (!isset($config['fontpath'])) { + $home = str_replace('\\', '/', $config['homedir']); + config_update_value( + 'fontpath', + $home.'/include/fonts/smallfont.ttf' + ); + } + + if (!isset($config['style'])) { + config_update_value('style', 'pandora'); + } + + if (!isset($config['login_background'])) { + config_update_value('login_background', ''); + } + + if (!isset($config['login_background_meta'])) { + config_update_value('login_background_meta', 'background_metaconsole.png'); + } + + if (!isset($config['paginate_module'])) { + config_update_value('paginate_module', false); + } + + if (!isset($config['graphviz_bin_dir'])) { + config_update_value('graphviz_bin_dir', ''); + } + + if (!isset($config['disable_help'])) { + config_update_value('disable_help', false); + } + + if (!isset($config['fixed_header'])) { + config_update_value('fixed_header', false); + } + + if (!isset($config['fixed_graph'])) { + config_update_value('fixed_graph', false); + } + + if (!isset($config['fixed_menu'])) { + config_update_value('fixed_menu', false); + } + + if (!isset($config['custom_favicon'])) { + config_update_value('custom_favicon', ''); + } + + if (!isset($config['custom_logo'])) { + config_update_value('custom_logo', 'pandora_logo_head_4.png'); + } + + if (!isset($config['custom_logo_white_bg'])) { + config_update_value('custom_logo_white_bg', 'pandora_logo_head_white_bg.png'); + } + + if (!isset($config['custom_logo_login'])) { + config_update_value('custom_logo_login', 'login_logo_v7.png'); + } + + if (!isset($config['custom_splash_login'])) { + config_update_value('custom_splash_login', 'splash_image_default.png'); + } + + if (!isset($config['custom_docs_logo'])) { + config_update_value('custom_docs_logo', ''); + } + + if (!isset($config['custom_support_logo'])) { + config_update_value('custom_support_logo', ''); + } + + if (!isset($config['custom_network_center_logo'])) { + config_update_value('custom_network_center_logo', ''); + } + + if (!isset($config['custom_mobile_console_logo'])) { + config_update_value('custom_mobile_console_logo', ''); + } + + if (!isset($config['custom_title1_login'])) { + config_update_value('custom_title1_login', __('WELCOME TO PANDORA FMS')); + } + + if (!isset($config['custom_title2_login'])) { + config_update_value('custom_title2_login', __('NEXT GENERATION')); + } + + if (!isset($config['custom_docs_url'])) { + config_update_value('custom_docs_url', 'http://wiki.pandorafms.com/'); + } + + if (!isset($config['custom_support_url'])) { + config_update_value('custom_support_url', 'https://support.artica.es'); + } + + if (!isset($config['rb_product_name'])) { + config_update_value('rb_product_name', get_product_name()); + } + + if (!isset($config['rb_copyright_notice'])) { + config_update_value('rb_copyright_notice', get_copyright_notice()); + } + + if (!isset($config['meta_custom_docs_url'])) { + config_update_value('meta_custom_docs_url', 'http://wiki.pandorafms.com/index.php?title=Main_Page'); + } + + if (!isset($config['meta_custom_support_url'])) { + config_update_value('meta_custom_support_url', 'https://support.artica.es'); + } + + if (!isset($config['meta_custom_logo'])) { + config_update_value('meta_custom_logo', 'logo_pandora_metaconsola.png'); + } + + if (!isset($config['meta_custom_logo_white_bg'])) { + config_update_value('pandora_logo_head_white_bg', 'pandora_logo_head_white_bg.png'); + } + + if (!isset($config['meta_custom_logo_login'])) { + config_update_value('meta_custom_logo_login', 'pandora_logo.png'); + } + + if (!isset($config['meta_custom_splash_login'])) { + config_update_value('meta_custom_splash_login', 'splash_image_metaconsola.png'); + } + + if (!isset($config['meta_custom_title1_login'])) { + config_update_value('meta_custom_title1_login', __('PANDORA FMS NEXT GENERATION')); + } + + if (!isset($config['meta_custom_title2_login'])) { + config_update_value('meta_custom_title2_login', __('METACONSOLE')); + } + + if (!isset($config['vc_favourite_view'])) { + config_update_value('vc_favourite_view', 0); + } + + if (!isset($config['vc_menu_items'])) { + config_update_value('vc_menu_items', 10); + } + + if (!isset($config['ser_menu_items'])) { + config_update_value('ser_menu_items', 10); + } + + if (!isset($config['history_db_enabled'])) { + config_update_value('history_db_enabled', false); + } + + if (!isset($config['history_event_enabled'])) { + config_update_value('history_event_enabled', false); + } + + if (!isset($config['history_db_host'])) { + config_update_value('history_db_host', ''); + } + + if (!isset($config['history_db_port'])) { + config_update_value('history_db_port', 3306); + } + + if (!isset($config['history_db_name'])) { + config_update_value('history_db_name', 'pandora'); + } + + if (!isset($config['history_db_user'])) { + config_update_value('history_db_user', 'pandora'); + } + + if (!isset($config['history_db_pass'])) { + config_update_value('history_db_pass', ''); + } + + if (!isset($config['history_db_days'])) { + config_update_value('history_db_days', 0); + } + + if (!isset($config['history_event_days'])) { + config_update_value('history_event_days', 90); + } + + if (!isset($config['history_db_step'])) { + config_update_value('history_db_step', 0); + } + + if (!isset($config['history_db_delay'])) { + config_update_value('history_db_delay', 0); + } + + if (!isset($config['email_from_dir'])) { + config_update_value('email_from_dir', 'pandora@pandorafms.org'); + } + + if (!isset($config['email_from_name'])) { + config_update_value('email_from_name', 'Pandora FMS'); + } + + if (!isset($config['email_smtpServer'])) { + config_update_value('email_smtpServer', '127.0.0.1'); + } + + if (!isset($config['email_smtpPort'])) { + config_update_value('email_smtpPort', 25); + } + + if (!isset($config['email_encryption'])) { + config_update_value('email_encryption', 0); + } + + if (!isset($config['email_username'])) { + config_update_value('email_username', ''); + } + + if (!isset($config['email_password'])) { + config_update_value('email_password', ''); + } + + if (!isset($config['activate_gis'])) { + config_update_value('activate_gis', 0); + } + + if (!isset($config['activate_netflow'])) { + config_update_value('activate_netflow', 0); + } + + if (!isset($config['netflow_path'])) { + if ($is_windows) { + $default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\netflow'; + } else { + $default = '/var/spool/pandora/data_in/netflow'; + } + + config_update_value('netflow_path', $default); + } + + if (!isset($config['netflow_interval'])) { + config_update_value('netflow_interval', SECONDS_10MINUTES); + } + + if (!isset($config['netflow_daemon'])) { + config_update_value('netflow_daemon', '/usr/bin/nfcapd'); + } + + if (!isset($config['netflow_nfdump'])) { + config_update_value('netflow_nfdump', '/usr/bin/nfdump'); + } + + if (!isset($config['netflow_nfexpire'])) { + config_update_value('netflow_nfexpire', '/usr/bin/nfexpire'); + } + + if (!isset($config['netflow_max_resolution'])) { + config_update_value('netflow_max_resolution', '50'); + } + + if (!isset($config['netflow_disable_custom_lvfilters'])) { + config_update_value('netflow_disable_custom_lvfilters', 0); + } + + if (!isset($config['netflow_max_lifetime'])) { + config_update_value('netflow_max_lifetime', '5'); + } + + if (!isset($config['auth'])) { + config_update_value('auth', 'mysql'); + } + + if (!isset($config['autocreate_remote_users'])) { + config_update_value('autocreate_remote_users', 0); + } + + if (!isset($config['autocreate_blacklist'])) { + config_update_value('autocreate_blacklist', ''); + } + + if (!isset($config['default_remote_profile'])) { + config_update_value('default_remote_profile', 0); + } + + if (!isset($config['default_remote_group'])) { + config_update_value('default_remote_group', 0); + } + + if (!isset($config['default_assign_tags'])) { + config_update_value('default_assign_tags', ''); + } + + if (!isset($config['default_no_hierarchy'])) { + config_update_value('default_no_hierarchy', 0); + } + + if (!isset($config['ldap_server'])) { + config_update_value('ldap_server', 'localhost'); + } + + if (!isset($config['ldap_port'])) { + config_update_value('ldap_port', 389); + } + + if (!isset($config['ldap_version'])) { + config_update_value('ldap_version', '3'); + } + + if (!isset($config['ldap_start_tls'])) { + config_update_value('ldap_start_tls', 0); + } + + if (!isset($config['ldap_base_dn'])) { + config_update_value( + 'ldap_base_dn', + 'ou=People,dc=edu,dc=example,dc=org' + ); + } + + if (!isset($config['ldap_login_attr'])) { + config_update_value('ldap_login_attr', 'uid'); + } + + if (!isset($config['ldap_admin_login'])) { + config_update_value('ldap_admin_login', ''); + } + + if (!isset($config['ldap_admin_pass'])) { + config_update_value('ldap_admin_pass', ''); + } + + if (!isset($config['ldap_function'])) { + config_update_value('ldap_function', 'local'); + } + + if (!isset($config['fallback_local_auth'])) { + config_update_value('fallback_local_auth', '0'); + } + + if (!isset($config['ad_server'])) { + config_update_value('ad_server', 'localhost'); + } + + if (!isset($config['ad_port'])) { + config_update_value('ad_port', 389); + } + + if (!isset($config['ad_start_tls'])) { + config_update_value('ad_start_tls', 0); + } + + if (!isset($config['ad_advanced_config'])) { + config_update_value('ad_advanced_config', 0); + } + + if (!isset($config['ldap_advanced_config'])) { + config_update_value('ldap_advanced_config', 0); + } + + if (!isset($config['ad_adv_user_node'])) { + config_update_value('ad_adv_user_node', 1); + } + + if (!isset($config['ldap_adv_user_node'])) { + config_update_value('ldap_adv_user_node', 1); + } + + if (!isset($config['ad_domain'])) { + config_update_value('ad_domain', ''); + } + + if (!isset($config['ad_adv_perms'])) { + config_update_value('ad_adv_perms', ''); + } else { + if (!json_decode(io_safe_output($config['ad_adv_perms']))) { + $temp_ad_adv_perms = []; + if (!isset($config['ad_adv_perms']) && $config['ad_adv_perms'] != '') { + $perms = explode(';', io_safe_output($config['ad_adv_perms'])); + foreach ($perms as $ad_adv_perm) { + if (preg_match('/[\[\]]/', $ad_adv_perm)) { + $all_data = explode(',', io_safe_output($ad_adv_perm)); + $profile = $all_data[0]; + $group_pnd = $all_data[1]; + $groups_ad = str_replace(['[', ']'], '', $all_data[2]); + $tags = str_replace(['[', ']'], '', $all_data[3]); + $groups_ad = explode('|', $groups_ad); + $tags_name = explode('|', $tags); + $tags_ids = []; + foreach ($tags_name as $tag) { + $tags_ids[] = tags_get_id($tag); + } + + $profile = profile_get_profiles( + [ + 'name' => io_safe_input($profile), + ] + ); + if (!$profile) { + continue; + } + + $profile_id = array_keys($profile); + $id_grupo = groups_get_id(io_safe_input($group_pnd), false); + $new_ad_adv_perms[] = [ + 'profile' => $profile_id[0], + 'group' => [$id_grupo], + 'tags' => $tags_ids, + 'groups_ad' => $groups_ad, + ]; + } else { + $all_data = explode(',', io_safe_output($ad_adv_perm)); + $profile = $all_data[0]; + $group_pnd = $all_data[1]; + $groups_ad = $all_data[2]; + $tags = $all_data[3]; + $profile = profile_get_profiles( + [ + 'name' => io_safe_input($profile), + ] + ); + if (!$profile) { + continue; + } + + $profile_id = array_keys($profile); + $id_grupo = groups_get_id(io_safe_input($group_pnd), false); + + $new_ad_adv_perms[] = [ + 'profile' => $profile_id[0], + 'group' => [$id_grupo], + 'tags' => [$tags], + 'groups_ad' => [$groups_ad], + ]; + } + } + + if (!empty($new_ad_adv_perms)) { + $temp_ad_adv_perms = json_encode($new_ad_adv_perms); + } + } + + config_update_value('ad_adv_perms', $temp_ad_adv_perms); + } + } + + if (!isset($config['ldap_adv_perms'])) { + config_update_value('ldap_adv_perms', ''); + } else { + if (!json_decode(io_safe_output($config['ldap_adv_perms']))) { + $temp_ldap_adv_perms = []; + if (!isset($config['ad_adv_perms']) && $config['ldap_adv_perms'] != '') { + $perms = explode(';', io_safe_output($config['ldap_adv_perms'])); + foreach ($perms as $ad_adv_perm) { + if (preg_match('/[\[\]]/', $ad_adv_perm)) { + $all_data = explode(',', io_safe_output($ad_adv_perm)); + $profile = $all_data[0]; + $group_pnd = $all_data[1]; + $groups_ad = str_replace(['[', ']'], '', $all_data[2]); + $tags = str_replace(['[', ']'], '', $all_data[3]); + $groups_ad = explode('|', $groups_ad); + $tags_name = explode('|', $tags); + $tags_ids = []; + foreach ($tags_name as $tag) { + $tags_ids[] = tags_get_id($tag); + } + + $profile = profile_get_profiles( + [ + 'name' => io_safe_input($profile), + ] + ); + if (!$profile) { + continue; + } + + $profile_id = array_keys($profile); + $id_grupo = groups_get_id(io_safe_input($group_pnd), false); + $new_ldap_adv_perms[] = [ + 'profile' => $profile_id[0], + 'group' => [$id_grupo], + 'tags' => $tags_ids, + 'groups_ldap' => $groups_ldap, + ]; + } else { + $all_data = explode(',', io_safe_output($ad_adv_perm)); + $profile = $all_data[0]; + $group_pnd = $all_data[1]; + $groups_ad = $all_data[2]; + $tags = $all_data[3]; + $profile = profile_get_profiles( + [ + 'name' => io_safe_input($profile), + ] + ); + if (!$profile) { + continue; + } + + $profile_id = array_keys($profile); + $id_grupo = groups_get_id(io_safe_input($group_pnd), false); + + $new_ldap_adv_perms[] = [ + 'profile' => $profile_id[0], + 'group' => [$id_grupo], + 'tags' => [$tags], + 'groups_ldap' => [$groups_ldap], + ]; + } + } + + if (!empty($new_ldap_adv_perms)) { + $temp_ldap_adv_perms = json_encode($new_ldap_adv_perms); + } + } + + config_update_value('ldap_adv_perms', $temp_ldap_adv_perms); + } + } + + if (!isset($config['rpandora_server'])) { + config_update_value('rpandora_server', 'localhost'); + } + + if (!isset($config['rpandora_port'])) { + config_update_value('rpandora_port', 3306); + } + + if (!isset($config['rpandora_dbname'])) { + config_update_value('rpandora_dbname', 'pandora'); + } + + if (!isset($config['rpandora_user'])) { + config_update_value('rpandora_user', 'pandora'); + } + + if (!isset($config['rpandora_pass'])) { + config_update_value('rpandora_pass', ''); + } + + if (!isset($config['rintegria_server'])) { + config_update_value('rintegria_server', 'localhost'); + } + + if (!isset($config['rintegria_port'])) { + config_update_value('rintegria_port', 3306); + } + + if (!isset($config['rintegria_dbname'])) { + config_update_value('rintegria_dbname', 'integria'); + } + + if (!isset($config['rintegria_user'])) { + config_update_value('rintegria_user', 'integria'); + } + + if (!isset($config['rintegria_pass'])) { + config_update_value('rintegria_pass', ''); + } + + if (!isset($config['saml_path'])) { + config_update_value('saml_path', '/opt/'); + } + + if (!isset($config['autoupdate'])) { + config_update_value('autoupdate', 1); + } + + if (!isset($config['api_password'])) { + config_update_value('api_password', ''); + } + + if (defined('METACONSOLE')) { + // Customizable sections (Metaconsole). + enterprise_include_once('include/functions_enterprise.php'); + $customizable_sections = enterprise_hook('enterprise_get_customizable_sections'); + + if ($customizable_sections != ENTERPRISE_NOT_HOOK) { + foreach ($customizable_sections as $k => $v) { + if (!isset($config[$k])) { + config_update_value($k, $v['default']); + } + } + } + + if (!isset($config['meta_num_elements'])) { + config_update_value('meta_num_elements', 100); + } + } + + if (!isset($config['relative_path']) && (isset($_POST['nick']) + || isset($config['id_user'])) && isset($config['enterprise_installed']) + ) { + $isFunctionSkins = enterprise_include_once('include/functions_skins.php'); + if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { + // 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. + $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 (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) { + $view_mode = false; + } else { + $view_mode = true; + } + + if (isset($_GET['modified']) && !$view_mode) { + $upd_info['id_skin'] = get_parameter('skin', $user_info['id_skin']); + $return_update_skin = update_user($id, $upd_info); + } + } + + if (!is_metaconsole()) { + // 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 { + $relative_path = enterprise_hook('skins_set_image_skin_path', [get_parameter('nick')]); + } + } else { + $relative_path = ''; + } + + $config['relative_path'] = $relative_path; + } + } + + if (!isset($config['dbtype'])) { + config_update_value('dbtype', 'mysql'); + } + + if (!isset($config['vc_refr'])) { + config_update_value('vc_refr', 300); + } + + if (!isset($config['agent_size_text_small'])) { + config_update_value('agent_size_text_small', 18); + } + + if (!isset($config['agent_size_text_medium'])) { + config_update_value('agent_size_text_medium', 50); + } + + if (!isset($config['module_size_text_small'])) { + config_update_value('module_size_text_small', 25); + } + + if (!isset($config['module_size_text_medium'])) { + config_update_value('module_size_text_medium', 50); + } + + if (!isset($config['description_size_text'])) { + config_update_value('description_size_text', 60); + } + + if (!isset($config['item_title_size_text'])) { + config_update_value('item_title_size_text', 45); + } + + if (!isset($config['simple_module_value'])) { + config_update_value('simple_module_value', 1); + } + + if (!isset($config['gis_label'])) { + config_update_value('gis_label', 0); + } + + if (!isset($config['interface_unit'])) { + config_update_value('interface_unit', __('Bytes')); + } + + if (!isset($config['graph_precision'])) { + config_update_value('graph_precision', 1); + } else { + if (!isset($config['enterprise_installed'])) { + config_update_value('graph_precision', 1); + } + } + + if (!isset($config['gis_default_icon'])) { + config_update_value('gis_default_icon', 'marker'); + } + + if (!isset($config['interval_values'])) { + config_update_value('interval_values', ''); + } + + if (!isset($config['public_url'])) { + config_update_value('public_url', ''); + } + + if (!isset($config['referer_security'])) { + config_update_value('referer_security', 0); + } + + if (!isset($config['event_storm_protection'])) { + config_update_value('event_storm_protection', 0); + } + + if (!isset($config['server_log_dir'])) { + config_update_value('server_log_dir', ''); + } + + if (!isset($config['max_log_size'])) { + config_update_value('max_log_size', 512); + } + + if (!isset($config['show_group_name'])) { + config_update_value('show_group_name', 0); + } + + if (!isset($config['custom_graph_width'])) { + config_update_value('custom_graph_width', 1); + } + + if (!isset($config['type_module_charts'])) { + config_update_value('type_module_charts', 'area'); + } + + if (!isset($config['type_interface_charts'])) { + config_update_value('type_interface_charts', 'line'); + } + + if (!isset($config['render_proc'])) { + config_update_value('render_proc', 0); + } + + if (!isset($config['graph_image_height'])) { + config_update_value('graph_image_height', 280); + } + + if (!isset($config['zoom_graph'])) { + config_update_value('zoom_graph', 1); + } + + if (!isset($config['render_proc_ok'])) { + config_update_value('render_proc_ok', __('Ok')); + } + + if (!isset($config['render_proc_fail'])) { + config_update_value('render_proc_fail', __('Fail')); + } + + // 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. + if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) { + if (!isset($config['service_label_font_size'])) { + config_update_value('service_label_font_size', 20); + } + + if (!isset($config['service_item_padding_size'])) { + config_update_value('service_item_padding_size', 80); + } + } + + if (!isset($config['classic_menu'])) { + config_update_value('classic_menu', 0); + } + + if (!isset($config['csv_divider'])) { + config_update_value('csv_divider', ';'); + } + + if (!isset($config['command_snapshot'])) { + config_update_value('command_snapshot', 1); + } + + if (!isset($config['custom_report_info'])) { + config_update_value('custom_report_info', 1); + } + + // Juanma (06/05/2014) New feature: Custom front page for reports. + if (!isset($config['custom_report_front'])) { + config_update_value('custom_report_front', 0); + } + + if (!isset($config['custom_report_front_font'])) { + config_update_value('custom_report_front_font', 'FreeSans.ttf'); + } + + if (!isset($config['custom_report_front_logo'])) { + config_update_value( + 'custom_report_front_logo', + 'images/pandora_logo_white.jpg' + ); + } + + if (!isset($config['custom_report_front_header'])) { + config_update_value('custom_report_front_header', ''); + } + + if (!isset($config['custom_report_front_firstpage'])) { + config_update_value( + 'custom_report_front_firstpage', + '<p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><img src="(_URLIMAGE_)/images/pandora_report_logo.png" alt="" width="800" /></p> <p style="text-align: center;">&nbsp;</p> <p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p> <p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>' + ); + } + + if (!isset($config['custom_report_front_footer'])) { + config_update_value('custom_report_front_footer', ''); + } + + if (!isset($config['autohidden_menu'])) { + config_update_value('autohidden_menu', 0); + } + + if (!isset($config['visual_animation'])) { + config_update_value('visual_animation', 1); + } + + if (!isset($config['networkmap_max_width'])) { + config_update_value('networkmap_max_width', 900); + } + + if (!isset($config['short_module_graph_data'])) { + config_update_value('short_module_graph_data', ''); + } + + if (!isset($config['tutorial_mode'])) { + config_update_value('tutorial_mode', 'full'); + } + + if (!isset($config['post_process_custom_values'])) { + config_update_value( + 'post_process_custom_values', + json_encode([]) + ); + } + + if (!isset($config['update_manager_proxy_server'])) { + config_update_value( + 'update_manager_proxy_server', + '' + ); + } + + if (!isset($config['update_manager_proxy_port'])) { + config_update_value( + 'update_manager_proxy_port', + '' + ); + } + + if (!isset($config['update_manager_proxy_user'])) { + config_update_value( + 'update_manager_proxy_user', + '' + ); + } + + if (!isset($config['update_manager_proxy_password'])) { + config_update_value( + 'update_manager_proxy_password', + '' + ); + } + + if (!isset($config['session_timeout'])) { + config_update_value('session_timeout', 90); + } + + if (!isset($config['max_file_size'])) { + config_update_value('max_file_size', '2M'); + } + + if (!isset($config['initial_wizard'])) { + config_update_value('initial_wizard', 0); + } + + if (!isset($config['identification_reminder'])) { + config_update_value('identification_reminder', 1); + } + + if (!isset($config['identification_reminder_timestamp'])) { + config_update_value('identification_reminder_timestamp', 0); + } + + if (!isset($config['instance_registered'])) { + config_update_value('instance_registered', 0); + } + + // Ehorus. + if (!isset($config['ehorus_enabled'])) { + config_update_value('ehorus_enabled', 0); + } + + if (!isset($config['ehorus_custom_field'])) { + config_update_value('ehorus_custom_field', 'eHorusID'); + } + + if (!isset($config['ehorus_hostname'])) { + config_update_value('ehorus_hostname', 'portal.ehorus.com'); + } + + if (!isset($config['ehorus_port'])) { + config_update_value('ehorus_port', 18080); + } + + if (!isset($config['ehorus_req_timeout'])) { + config_update_value('ehorus_req_timeout', 5); + } + + if (is_metaconsole()) { + if (!isset($config['metaconsole_deploy_collection'])) { + config_update_value('metaconsole_deploy_collection', 0); + } + + if (!isset($config['metaconsole_deploy_inventory_plugin'])) { + config_update_value('metaconsole_deploy_inventory_plugin', 0); + } + + if (!isset($config['metaconsole_deploy_plugin_server'])) { + config_update_value('metaconsole_deploy_plugin_server', 0); + } + } + + // Finally, check if any value was overwritten in a form. + config_update_config(); } -function config_check () { - global $config; - - // At this first version I'm passing errors using session variables, because the error management - // is done by an AJAX request. Better solutions could be implemented in the future :-) - - if (license_free() && users_is_admin($config['id_user'])) { - - $login = get_parameter ('login', false); - //Registration advice - if ((!isset ($config['instance_registered']) || ($config['instance_registered'] != 1)) && ($login === false)) { - set_pandora_error_for_header( - __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_register();"> here</a> to start the registration process'), - __("This instance is not registered in the Update manager")); - } - - //Newsletter advice - $newsletter = db_get_value ('middlename', 'tusuario', 'id_user', $config['id_user']); - if ($newsletter != 1 && $login === false) { - set_pandora_error_for_header( - __('Click <a style="font-weight:bold; text-decoration:underline" href="javascript: force_run_newsletter();"> here</a> to start the newsletter subscription process'), - __("Not subscribed to the newsletter")); - } - } - - // 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', array('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', - array('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', array('token' => 'fontpath'))); - if (($fontpath == "") OR (!file_exists ($fontpath))) { - set_pandora_error_for_header( - __('Your defined font doesnt exist or is not defined. Please check font parameters in your config'), - __("Default font doesnt exist")); - } - - if ($config['event_storm_protection']) { - set_pandora_error_for_header( - __('You need to restart server after altering this configuration setting.'), - __('Event storm protection is activated. No events will be generated during this mode.')); - } - - global $develop_bypass; - - if ($develop_bypass == 1) { - set_pandora_error_for_header( - __('Your %s has the "develop_bypass" mode enabled. This is a developer mode and should be disabled in a production system. This value is written in the main index.php file', get_product_name()), - __("Developer mode is enabled")); - } - - if (isset($_SESSION['new_update'])) { - if (!empty($_SESSION['return_installation_open'])) { - if (!$_SESSION['return_installation_open']['return']) { - foreach ($_SESSION['return_installation_open']['text'] as $message) { - set_pandora_error_for_header( - $message, - __("Error first setup Open update")); - } - } - } - if ($_SESSION['new_update'] == 'new') { - set_pandora_error_for_header( - __('There is a new update available. Please<a style="font-weight:bold;" href="index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online"> go to Administration:Setup:Update Manager</a> for more details.'), - __("New %s Console update", get_product_name())); - } - } - - // PHP configuration values - $PHPupload_max_filesize = config_return_in_bytes(ini_get('upload_max_filesize')); - $PHPmax_input_time = ini_get('max_input_time'); - $PHPmemory_limit = config_return_in_bytes(ini_get('memory_limit')); - $PHPmax_execution_time = ini_get('max_execution_time'); - $PHPsafe_mode = ini_get('safe_mode'); - $PHPdisable_functions = ini_get('disable_functions'); - - if ($PHPsafe_mode === '1') { - set_pandora_error_for_header( - __('To disable, change it on your PHP configuration file (php.ini) and put safe_mode = Off (Dont forget restart apache process after changes)'), - sprintf(__("PHP safe mode is enabled. Some features may not properly work."))); - } - - if ($PHPmax_input_time !== '-1') { - set_pandora_error_for_header( - sprintf(__('Recommended value is %s'), '-1 (' . __('Unlimited') . ')') . '<br><br>' . __('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), - sprintf(__("Not recommended '%s' value in PHP configuration"), 'max_input_time')); - } - - if ($PHPmax_execution_time !== '0') { - set_pandora_error_for_header( - sprintf(__('Recommended value is: %s'), '0 (' . __('Unlimited') . ')') . '<br><br>' . __('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), - sprintf(__("Not recommended '%s' value in PHP configuration"), 'max_execution_time')); - } - - $PHPupload_max_filesize_min = config_return_in_bytes('800M'); - - if ($PHPupload_max_filesize < $PHPupload_max_filesize_min) { - set_pandora_error_for_header( - sprintf(__('Recommended value is: %s'), sprintf(__('%s or greater'), '800M')) . '<br><br>' . __('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), - sprintf(__("Not recommended '%s' value in PHP configuration"), 'upload_max_filesize')); - } +/** + * Start supervisor. + * + * @return void + */ +function config_check() +{ + global $config; - $PHPmemory_limit_min = config_return_in_bytes('500M'); + include_once __DIR__.'/class/ConsoleSupervisor.php'; - if ($PHPmemory_limit < $PHPmemory_limit_min && $PHPmemory_limit !== '-1') { - set_pandora_error_for_header( - sprintf(__('Recommended value is: %s'), sprintf(__('%s or greater'), '500M')) . '<br><br>' . __('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), - sprintf(__("Not recommended '%s' value in PHP configuration"), 'memory_limit')); - } + // Enterprise controlles supervisor using discovery cron task. + if (!license_free()) { + $supervisor = new ConsoleSupervisor(false); + $supervisor->run(); + } - if (preg_match("/system/", $PHPdisable_functions) or preg_match("/exec/", $PHPdisable_functions)) { - set_pandora_error_for_header( - __("Variable disable_functions containts functions system() or exec(), in PHP configuration file (php.ini)"). '<br /><br />' . - __('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Dont forget restart apache process after changes)'), __("Problems with disable functions in PHP.INI")); - } - - $result_ejecution = exec($config['phantomjs_bin'] . '/phantomjs --version'); - if(!isset($result_ejecution) || $result_ejecution == '') { - if ($config['language'] == 'es') { - set_pandora_error_for_header( - __('To be able to create images of the graphs for PDFs, please install the phantom.js extension. For that, it is necessary to follow these steps:') . - '<a target="blank" href="https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Configuracion#Phantomjs">Click here</a>', - __("phantomjs is not installed")); - } else { - set_pandora_error_for_header( - __('To be able to create images of the graphs for PDFs, please install the phantom.js extension. For that, it is necessary to follow these steps:') . - '<a target="blank" href="https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Configuration#Phantomjs">Click here</a>', - __("phantomjs is not installed")); - } - } - - - $php_version = phpversion(); - $php_version_array = explode('.', $php_version); - if($php_version_array[0] < 7){ - if ($config['language'] == 'es') { - $url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Instalaci%C3%B3n_y_actualizaci%C3%B3n_PHP_7'; - } - else{ - $url_help = 'https://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:_PHP_7'; - } - - set_pandora_error_for_header( - __('For a correct operation of PandoraFMS, PHP must be updated to version 7.0 or higher.') . "<br>" . - __('Otherwise, functionalities will be lost.') . "<br>" . - "<ol><li style='color: #676767'>" . __('Report download in PDF format') . "</li>" . - "<li style='color: #676767'>" . __('Emails Sending') . "</li>" . - "<li style='color: #676767'>" . __('Metaconsole Collections') . "</li>" . - "<li style='color: #676767'>" . '...' . "</li>" . - "</ol>" . - '<a target="blank" href="' . $url_help . '">'.__('Access Help').'</a>', - __("PHP UPDATE REQUIRED")); - } } -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 - case 'g': - $val *= 1024; - case 'm': - $val *= 1024; - case 'k': - $val *= 1024; - } - - return $val; + +/** + * 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. + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + default: + // Ignore. + break; + } + + return $val; } -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 - if ($userinfo['last_connect'] < (time()-SECONDS_1MINUTE)) { - update_user($config['id_user'], array('last_connect' => time())); - } - if (!empty($userinfo["block_size"]) && ($userinfo["block_size"] != 0)) - $config["block_size"] = $userinfo["block_size"]; +/** + * Undocumented function + * + * @return void + */ +function config_user_set_custom_config() +{ + global $config; - // Each user could have it's own timezone) - if (isset($userinfo["timezone"])) { - if ($userinfo["timezone"] != "") { - date_default_timezone_set($userinfo["timezone"]); - } - } - - if (defined('METACONSOLE')) { - $config['metaconsole_access'] = $userinfo["metaconsole_access"]; - } + $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. + if ($userinfo['last_connect'] < (time() - SECONDS_1MINUTE)) { + update_user($config['id_user'], ['last_connect' => time()]); + } + + if (!empty($userinfo['block_size']) && ($userinfo['block_size'] != 0)) { + $config['block_size'] = $userinfo['block_size']; + } + + // Each user could have it's own timezone). + if (isset($userinfo['timezone'])) { + if ($userinfo['timezone'] != '') { + date_default_timezone_set($userinfo['timezone']); + } + } + + if (defined('METACONSOLE')) { + $config['metaconsole_access'] = $userinfo['metaconsole_access']; + } } -function config_prepare_session() { - global $config; - if(isset($config["id_user"])){ - $user = users_get_user_by_id($config["id_user"]); - $user_sesion_time = $user['session_time']; - } - else{ - $user_sesion_time = null; - } +/** + * Undocumented function + * + * @return void + */ +function config_prepare_session() +{ + global $config; - if ($user_sesion_time == 0) { - // 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 - $sessionCookieExpireTime = $user_sesion_time; - } + if (isset($config['id_user'])) { + $user = users_get_user_by_id($config['id_user']); + $user_sesion_time = $user['session_time']; + } else { + $user_sesion_time = null; + } - if ($sessionCookieExpireTime <= 0) - $sessionCookieExpireTime = 10 * 365 * 24 * 60 * 60; - else - $sessionCookieExpireTime *= 60; + if ($user_sesion_time == 0) { + // 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. + $sessionCookieExpireTime = $user_sesion_time; + } - // 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, "/"); + if ($sessionCookieExpireTime <= 0) { + $sessionCookieExpireTime = (10 * 365 * 24 * 60 * 60); + } else { + $sessionCookieExpireTime *= 60; + } - ini_set("post_max_size", $config["max_file_size"]); - ini_set("upload_max_filesize", $config["max_file_size"]); + // 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), '/'); + } + + ini_set('post_max_size', $config['max_file_size']); + ini_set('upload_max_filesize', $config['max_file_size']); } -?> From 7fa344c2a4e8dd90d869dc6cd37a8ab9de85b22c Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 7 Feb 2019 17:53:09 +0100 Subject: [PATCH 039/262] Change the global configuration notification to AJAX Former-commit-id: a9017377c8ed6780170c0f418ec3e9bc39f7782c --- .../godmode/setup/setup_notifications.php | 146 +++++++++++++----- .../include/functions_notifications.php | 26 ++-- 2 files changed, 123 insertions(+), 49 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index d315f14711..f8ce35c9f8 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -56,36 +56,31 @@ if (get_parameter('remove_source_on_database', 0)) { return; } -// Form actions. if (get_parameter('update_config', 0)) { - $res_global = array_reduce( - notifications_get_all_sources(), - function ($carry, $source) { - $id = notifications_desc_to_id($source['description']); - if (empty($id)) { - return false; - } + $source = (int) get_parameter('source', 0); + $element = (string) get_parameter('element', ''); + $value = (int) get_parameter('value', 0); - $enable_value = switch_to_int(get_parameter("enable-$id")); - $mail_value = (int) get_parameter("mail-{$id}", 0); - $user_value = (int) get_parameter("user-{$id}", 0); - $postpone_value = (int) get_parameter("postpone-{$id}", 0); - $all_users = (int) get_parameter("all-{$id}", 0); - $res = db_process_sql_update( + // Update the label value. + ob_clean(); + $res = false; + switch ($element) { + // All users has other action. + case 'all_users': + $res = $value ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]); + break; + + default: + $res = (bool) db_process_sql_update( 'tnotification_source', - [ - 'enabled' => $enable_value, - 'user_editable' => $user_value, - 'also_mail' => $mail_value, - 'max_postpone_time' => $postpone_value, - ], - ['id' => $source['id']] + [$element => $value], + ['id' => $source] ); - $all_users_res = $all_users ? notifications_add_group_to_source($source['id'], [0]) : notifications_remove_group_from_source($source['id'], [0]); - return $all_users_res && $res && $carry; - }, - true - ); + break; + } + + echo json_encode(['result' => $res]); + return; } // Notification table. It is just a wrapper. @@ -103,22 +98,11 @@ $table_content->data = array_map( }, notifications_get_all_sources() ); -$table_content->data[] = html_print_submit_button( - __('Update'), - 'update_button', - false, - 'class="sub upd" style="display: flex; "', - true -); -echo '<form id="form_enable" method="post">'; -html_print_input_hidden('update_config', 1); html_print_table($table_content); -echo '</form>'; ?> <script> - // Get the source id function notifications_get_source_id(id) { var matched = id.match(/.*-(.*)/); @@ -268,4 +252,92 @@ function remove_source_elements(id, source_id) { "json" ); } + +function notifications_handle_change_element(event) { + event.preventDefault(); + var match = /nt-([0-9]+)-(.*)/.exec(event.target.id); + if (!match) { + console.error( + "Cannot handle change element. Id not valid: ", event.target.id + ); + return; + } + var action = {source: match[1], bit: match[2]}; + var element = document.getElementById(event.target.id); + if (element === null) { + console.error( + "Cannot get element. Id: ", event.target.id + ); + return; + } + + var value; + switch (action.bit) { + case 'enabled': + case 'also_mail': + case 'user_editable': + case 'all_users': + value = element.checked ? 1 : 0; + break; + case 'max_postpone_time': + value = element.value; + break; + default: + console.error("Unregonized action", action.bit, '.'); + return; + + } + jQuery.post ("ajax.php", + { + "page" : "godmode/setup/setup_notifications", + "update_config" : 1, + "source" : match[1], + "element" : match[2], + "value": value + }, + function (data, status) { + if (!data.result) { + console.error("Error changing configuration in database."); + } else { + switch (action.bit) { + case 'enabled': + case 'also_mail': + case 'user_editable': + case 'all_users': + element.checked = !element.checked; + break; + case 'max_postpone_time': + value = element.value; + break; + default: + console.error("Unregonized action (insert on db)", action.bit, '.'); + return; + } + } + }, + "json" + ) + .done(function(m){}) + .fail(function(xhr, textStatus, errorThrown){ + console.error( + "Cannot change configuration in database. Server error.", + xhr.responseText + ); + }); +} +(function(){ + // Add listener to all componentes marked + var all_clickables = document.getElementsByClassName('elem-clickable'); + for (var i = 0; i < all_clickables.length; i++) { + all_clickables[i].addEventListener( + 'click', notifications_handle_change_element, false + ); + } + var all_changes = document.getElementsByClassName('elem-changeable'); + for (var i = 0; i < all_changes.length; i++) { + all_changes[i].addEventListener( + 'change', notifications_handle_change_element, false + ); + } +})(); </script> diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 5c232709de..1142f19ebe 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -340,17 +340,15 @@ function notifications_remove_users_from_source($source_id, $users) */ function notifications_add_group_to_source($source_id, $groups) { - // Source id is mandatory + // Source id is mandatory. if (!isset($source_id)) { return false; } - // Insert into database all groups passed + // Insert into database all groups passed. $res = true; foreach ($groups as $group) { - if (empty($group)) { - continue; - } + if (!isset($group)) continue; $res = $res && db_process_sql_insert( 'tnotification_source_group', @@ -560,11 +558,13 @@ function notifications_print_ball() */ function notifications_print_global_source_configuration($source) { - // Get some values to generate the title + // Get some values to generate the title. $id = notifications_desc_to_id($source['description']); $switch_values = [ 'name' => 'enable-'.$id, 'value' => $source['enabled'], + 'id' => 'nt-'.$source['id'].'-enabled', + 'class' => 'elem-clickable', ]; // Search if group all is set and handle that situation @@ -585,17 +585,16 @@ function notifications_print_global_source_configuration($source) $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all); $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all); $html_selectors .= '</div>'; - // Generate the checkboxes and time select $html_checkboxes = "<div class='global-config-notification-checkboxes'>"; $html_checkboxes .= ' <span>'; - $html_checkboxes .= html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)'); + $html_checkboxes .= html_print_checkbox_extended("all-$id", 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"'); $html_checkboxes .= __('Notify all users'); $html_checkboxes .= ' </span><br><span>'; - $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true); + $html_checkboxes .= html_print_checkbox_extended("mail-$id", 1, $source['also_mail'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-also_mail"'); $html_checkboxes .= __('Also email users with notification content'); $html_checkboxes .= ' </span><br><span>'; - $html_checkboxes .= html_print_checkbox("user-$id", 1, $source['user_editable'], true); + $html_checkboxes .= html_print_checkbox_extended("user-$id", 1, $source['user_editable'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-user_editable"'); $html_checkboxes .= __('Users can modify notification preferences'); $html_checkboxes .= ' </span>'; $html_checkboxes .= '</div>'; @@ -613,12 +612,15 @@ function notifications_print_global_source_configuration($source) SECONDS_1MONTH => __('1 month'), NOTIFICATIONS_POSTPONE_FOREVER => __('forever'), ], - "postpone-{$id}", + 'nt-'.$source['id'].'-max_postpone_time', $source['max_postpone_time'], '', '', 0, - true + true, + false, + true, + 'elem-changeable' ); // Return all html From 681ad670288a75f728fc69225e5b1d189891f007 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Thu, 7 Feb 2019 18:00:51 +0100 Subject: [PATCH 040/262] ConsoleSuperviso - mailing support and minor fixes Former-commit-id: 86db19d675aa2b7ea37af2839764245fde9ee3c4 --- pandora_console/general/header.php | 930 +++++++++--------- .../include/class/ConsoleSupervisor.php | 105 +- pandora_console/include/functions_config.php | 4 +- .../include/functions_notifications.php | 2 +- pandora_console/pandoradb_data.sql | 8 + 5 files changed, 546 insertions(+), 503 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 1edcf76b77..80191de038 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -4,509 +4,487 @@ // ================================================== // 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. - -require_once ("include/functions_messages.php"); -require_once ('include/functions_servers.php'); -require_once ('include/functions_notifications.php'); +require_once 'include/functions_messages.php'; +require_once 'include/functions_servers.php'; +require_once 'include/functions_notifications.php'; // Check permissions - // Global errors/warnings checking. config_check(); ?> <table width="100%" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px; margin-top: 0px; height: 100%" border="0"> - <tr> - <td style="width:90%;"> - <a href="index.php?sec=main"> - <?php - $custom_logo = 'images/custom_logo/' . $config['custom_logo']; - - if (!defined ('PANDORA_ENTERPRISE')) { - $logo_title = get_product_name() . ' Opensource'; - $custom_logo = 'images/custom_logo/pandora_logo_head_3.png'; - } - else { - if (file_exists(ENTERPRISE_DIR . '/' . $custom_logo)) { - $custom_logo = ENTERPRISE_DIR . '/' . $custom_logo; - } - $logo_title = get_product_name() . ' Enterprise'; - } - - echo html_print_image($custom_logo, true, - array("alt" => $logo_title, "border" => '0')); - ?> - </a> - </td> - <td style="min-width:200px;"> - <?php - $table = new stdClass(); - $table->id = "header_table"; - $table->class = "none"; - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->head = array (); - $table->data = array (); - $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'] = - $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;'; - $table->width = "100%"; - $table->styleTable = 'margin: auto; margin-top: 0px;'; - $table->rowclass[0] = ''; - - $acl_head_search = true; - if ($config["acl_enterprise"] == 1 && !users_is_admin()) { - $acl_head_search = db_get_sql("SELECT sec FROM tusuario + <tr> + <td style="width:90%;"> + <a href="index.php?sec=main"> + <?php + $custom_logo = 'images/custom_logo/'.$config['custom_logo']; + + if (!defined('PANDORA_ENTERPRISE')) { + $logo_title = get_product_name().' Opensource'; + $custom_logo = 'images/custom_logo/pandora_logo_head_3.png'; + } else { + if (file_exists(ENTERPRISE_DIR.'/'.$custom_logo)) { + $custom_logo = ENTERPRISE_DIR.'/'.$custom_logo; + } + + $logo_title = get_product_name().' Enterprise'; + } + + echo html_print_image( + $custom_logo, + true, + [ + 'alt' => $logo_title, + 'border' => '0', + ] + ); + ?> + </a> + </td> + <td style="min-width:200px;"> + <?php + $table = new stdClass(); + $table->id = 'header_table'; + $table->class = 'none'; + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->head = []; + $table->data = []; + $table->style[0] = $table->style['clippy'] = $table->style[1] = $table->style[3] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = $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;'; + $table->width = '100%'; + $table->styleTable = 'margin: auto; margin-top: 0px;'; + $table->rowclass[0] = ''; + + $acl_head_search = true; + if ($config['acl_enterprise'] == 1 && !users_is_admin()) { + $acl_head_search = db_get_sql( + "SELECT sec FROM tusuario INNER JOIN tusuario_perfil ON tusuario.id_user = tusuario_perfil.id_usuario INNER JOIN tprofile_view ON tprofile_view.id_profile = tusuario_perfil.id_perfil - WHERE tusuario.id_user = '".$config['id_user']."' AND (sec = '*' OR sec = 'head_search')"); - } - if ($acl_head_search) { - $table->data[0][11] = ui_print_help_tip (__("Blank characters are used as AND conditions"), true); - - // Search bar - $search_bar = '<form method="get" style="display: inline;" name="quicksearch" action="">'; - if (!isset($config['search_keywords'])) { - $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; - } - else { - if (strlen($config['search_keywords']) == 0) - $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; - else - $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = false; </script>'; - } - - $search_bar .= '<input type="text" id="keywords" name="keywords"'; - if (!isset($config['search_keywords'])) - $search_bar .= "value='" . __("Enter keywords to search") . "'"; - else if (strlen($config['search_keywords']) == 0) - $search_bar .= "value='" . __("Enter keywords to search") . "'"; - else - $search_bar .= "value='" . $config['search_keywords'] . "'"; - - $search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" + WHERE tusuario.id_user = '".$config['id_user']."' AND (sec = '*' OR sec = 'head_search')" + ); + } + + if ($acl_head_search) { + $table->data[0][11] = ui_print_help_tip(__('Blank characters are used as AND conditions'), true); + + // Search bar + $search_bar = '<form method="get" style="display: inline;" name="quicksearch" action="">'; + if (!isset($config['search_keywords'])) { + $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; + } else { + if (strlen($config['search_keywords']) == 0) { + $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; + } else { + $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = false; </script>'; + } + } + + $search_bar .= '<input type="text" id="keywords" name="keywords"'; + if (!isset($config['search_keywords'])) { + $search_bar .= "value='".__('Enter keywords to search')."'"; + } else if (strlen($config['search_keywords']) == 0) { + $search_bar .= "value='".__('Enter keywords to search')."'"; + } else { + $search_bar .= "value='".$config['search_keywords']."'"; + } + + $search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" onkeyup="javascript: fieldKeyWordEmpty = false;" style="margin-top:5px;" class="search_input" />'; - - //$search_bar .= 'onClick="javascript: document.quicksearch.submit()"'; - - $search_bar .= "<input type='hidden' name='head_search_keywords' value='abc' />"; - $search_bar .= '</form>'; - - $table->data[0]['searchbar'] = $search_bar; - } - - // Servers check - $servers = array(); - $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, array("alt" => 'cross', "class" => 'bot', 'title' => __('All systems').': '.__('Down'))); - } - elseif ($servers["down"] != 0) { - //Some servers down - $servers_check_img = html_print_image("images/header_warning.png", true, array("alt" => 'error', "class" => 'bot', 'title' => $servers["down"].' '.__('servers down'))); - } - else { - //All servers up - $servers_check_img = html_print_image("images/header_ready.png", true, array("alt" => 'ok', "class" => 'bot', 'title' => __('All systems').': '.__('Ready'))); - } - unset ($servers); // Since this is the header, we don't like to trickle down variables. - - $servers_link_open = '<a class="white" href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60">'; - $servers_link_close = '</a>'; - - if ($config['show_qr_code_header'] == 0){ - $show_qr_code_header = 'display: none;'; - } - else { - $show_qr_code_header = 'display: inline;'; - } - - $table->data[0]['qr'] = - '<div style="' . $show_qr_code_header . '" id="qr_code_container" style="">' . - '<a href="javascript: show_dialog_qrcode();">' . - html_print_image( - "images/qrcode_icon.png", - true, - array("alt" => __('QR Code of the page'), - 'title' => __('QR Code of the page'))) . - '</a>' . - '</div>'; - - echo "<div style='display: none;' id='qrcode_container' title='" . __('QR code of the page') . "'>"; - echo "<div id='qrcode_container_image'></div>"; - echo "</div>"; - ?> - <script type='text/javascript'> - $(document).ready(function() { - $( "#qrcode_container" ).dialog({ - autoOpen: false, - modal: true - }); - }); - </script> - <?php - - if ($config['tutorial_mode'] !== 'expert' && !$config['disable_help']) { - $table->data[0]['clippy'] = - '<a href="javascript: show_clippy();">' . - html_print_image( - "images/clippy_icon.png", - true, - array("id" => 'clippy', - "class" => 'clippy', - "alt" => __('%s assistant', get_product_name()), - 'title' => __('%s assistant', get_product_name()))) . - '</a>'; - } - - - $table->data[0][0] = $servers_link_open . - $servers_check_img . $servers_link_close; - - - - - //======= Autorefresh code ============================= - $autorefresh_txt = ''; - $autorefresh_additional = ''; - - $ignored_params = array ('agent_config' => false, 'code' => false); - - if (!isset($_GET['sec2'])) { - $_GET['sec2'] = ''; - } - if (!isset($_GET['refr'])) { - $_GET['refr'] = null; - } - - $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '" . $config['id_user'] . "'"); - $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); - - if ($autorefresh_list !== null && array_search($_GET['sec2'], $autorefresh_list) !== false) { - $do_refresh = true; - if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { - if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { - $do_refresh = false; - } - } - if ($do_refresh) { - $autorefresh_img = html_print_image("images/header_refresh.png", true, array("class" => 'bot', "alt" => 'lightning', 'title' => __('Configure autorefresh'))); - - if ($_GET['refr']) { - $autorefresh_txt .= ' (<span id="refrcounter">'.date ("i:s", $config["refr"]).'</span>)'; - } - - $ignored_params['refr'] = ''; - $values = get_refresh_time_array(); - $autorefresh_additional = '<span id="combo_refr" style="display: none;">'; - $autorefresh_additional .= html_print_select ($values, 'ref', '', '', __('Select'), '0', true, false, false); - $autorefresh_additional .= '</span>'; - unset ($values); - - $autorefresh_link_open_img = - '<a class="white autorefresh" href="' . ui_get_url_refresh ($ignored_params) . '">'; - - if ($_GET['refr']) { - $autorefresh_link_open_txt = - '<a class="white autorefresh autorefresh_txt" href="' . ui_get_url_refresh ($ignored_params) . '">'; - } - else { - $autorefresh_link_open_txt = '<a>'; - } - - $autorefresh_link_close = '</a>'; - } - else { - $autorefresh_img = html_print_image("images/header_refresh_disabled.png", true, array("class" => 'bot autorefresh_disabled', "alt" => 'lightning', 'title' => __('Disabled autorefresh'))); - - $ignored_params['refr'] = false; - - $autorefresh_link_open_img = ''; - $autorefresh_link_open_txt = ''; - $autorefresh_link_close = ''; - } - } - else { - $autorefresh_img = html_print_image("images/header_refresh_disabled.png", true, array("class" => 'bot autorefresh_disabled', "alt" => 'lightning', 'title' => __('Disabled autorefresh'))); - - $ignored_params['refr'] = false; - - $autorefresh_link_open_img = ''; - $autorefresh_link_open_txt = ''; - $autorefresh_link_close = ''; - } - - $table->data[0][1] = $autorefresh_link_open_img . $autorefresh_img . $autorefresh_link_close; - $table->data[0][2] = $autorefresh_link_open_txt . $autorefresh_txt . $autorefresh_link_close . $autorefresh_additional; - //====================================================== - - - $check_minor_release_available = false; - $pandora_management = check_acl($config['id_user'], 0, "PM"); - - $check_minor_release_available = db_check_minor_relase_available (); - - if ($check_minor_release_available) { - if (users_is_admin($config['id_user'])) { - - if($config['language'] == 'es'){ - set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Actualizacion#Versi.C3.B3n_7.0NG_.28_Rolling_Release_.29">'.__('Sobre actualización de revisión menor').'</a>', 'Revisión/es menor/es disponible/s'); - } - else{ - set_pandora_error_for_header('There are one or more minor releases waiting for update. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Anexo_Upgrade#Version_7.0NG_.28_Rolling_Release_.29">'.__('About minor release update').'</a>', 'minor release/s available'); - } - } - } - echo '<div id="alert_messages" style="display: none"></div>'; + // $search_bar .= 'onClick="javascript: document.quicksearch.submit()"'; + $search_bar .= "<input type='hidden' name='head_search_keywords' value='abc' />"; + $search_bar .= '</form>'; - if ($config["alert_cnt"] > 0) { - $maintenance_link = 'javascript:'; - $maintenance_title = __("System alerts detected - Please fix as soon as possible"); - $maintenance_class = $maintenance_id = 'show_systemalert_dialog white'; - - $maintenance_link_open_txt = - '<a href="' . $maintenance_link . '" title="' . $maintenance_title . '" class="' . $maintenance_class . '" id="show_systemalert_dialog">'; - $maintenance_link_open_img = - '<a href="' . $maintenance_link . '" title="' . $maintenance_title . '" class="' . $maintenance_class . '">'; - $maintenance_link_close = '</a>'; - if (!$pandora_management) { - $maintenance_img = ''; - } - else { - $maintenance_img = $maintenance_link_open_img . - html_print_image("images/header_yellow.png", - true, array( - "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, array ("title" => __('There are not warnings'), "id" => "yougotalert", "class" => "bot")); - } - } - - $table->data[0][3] = $maintenance_img; - - // Main help icon - if (!$config['disable_help']) { - $table->data[0][4] = - '<a href="#" class="modalpopup" id="helpmodal">' . - html_print_image("images/header_help.png", true, array( - "title" => __('Main help'), - "id" => "helpmodal", - "class" => "modalpopup")) . - '</a>'; - } - - // Logout - $table->data[0][5] = '<a class="white" href="' . ui_get_full_url('index.php?bye=bye') . '">'; - $table->data[0][5] .= html_print_image("images/header_logout.png", true, array("alt" => __('Logout'), "class" => 'bot', "title" => __('Logout'))); - $table->data[0][5] .= '</a>'; - - // User - if (is_user_admin ($config["id_user"]) == 1) - $table->data[0][6] = html_print_image("images/header_user_admin.png" , true, array("title" => __('Edit my user'), "class" => 'bot', "alt" => 'user')); - else - $table->data[0][6] = html_print_image("images/header_user.png" , true, array("title" => __('Edit my user'), "class" => 'bot', "alt" => 'user')); - - $table->data[0][6] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit">' . $table->data[0][6] . '</a>'; - - $table->data[0][7] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit" class="white_bold"> (' . $config["id_user"] . ')</a>'; - - // Chat messages - $table->data[0][8] = "<span id='icon_new_messages_chat' style='display: none;'>"; - $table->data[0][8] .= "<a href='index.php?sec=workspace&sec2=operation/users/webchat'>"; - $table->data[0][8] .= html_print_image('images/header_chat.png', true, array("title" => __('New chat message'))); - $table->data[0][8] .= "</a>"; - $table->data[0][8] .= "</span>"; - - // Messages - $msg_cnt = messages_get_count ($config["id_user"]); - if ($msg_cnt > 0) { - echo '<div id="dialog_messages" style="display: none"></div>'; - - $table->data[0][9] = '<a href="ajax.php?page=operation/messages/message_list" title="' . __("Message overview") . '" id="show_messages_dialog">'; - $table->data[0][9] .= html_print_image ("images/header_email.png", true, array ("title" => __('You have %d unread message(s)', $msg_cnt), "id" => "yougotmail", "class" => "bot", 'style' => 'width:24px;')); - $table->data[0][9] .= '</a>'; - } + $table->data[0]['searchbar'] = $search_bar; + } - $table->data[0]['notifications'] = notifications_print_ball(); + // 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')]); + } - html_print_table($table); - - unset($table); - ?> - </td> - <!-- - <td style="text-align:center"> - <?php - echo "<a href='index.php?sec=main'>"; - if (isset($config["custom_logo"])) { - echo html_print_image("images/custom_logo/" . $config["custom_logo"], true, array("height" => '60', "width" => '139', "alt" => 'Logo')); - } - echo "</a>"; - ?> - </td> - --> - </tr> + unset($servers); + // Since this is the header, we don't like to trickle down variables. + $servers_link_open = '<a class="white" href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60">'; + $servers_link_close = '</a>'; + + if ($config['show_qr_code_header'] == 0) { + $show_qr_code_header = 'display: none;'; + } else { + $show_qr_code_header = 'display: inline;'; + } + + $table->data[0]['qr'] = '<div style="'.$show_qr_code_header.'" id="qr_code_container" style="">'.'<a href="javascript: show_dialog_qrcode();">'.html_print_image( + 'images/qrcode_icon.png', + true, + [ + 'alt' => __('QR Code of the page'), + 'title' => __('QR Code of the page'), + ] + ).'</a>'.'</div>'; + + echo "<div style='display: none;' id='qrcode_container' title='".__('QR code of the page')."'>"; + echo "<div id='qrcode_container_image'></div>"; + echo '</div>'; + ?> + <script type='text/javascript'> + $(document).ready(function() { + $( "#qrcode_container" ).dialog({ + autoOpen: false, + modal: true + }); + }); + </script> + <?php + if ($config['tutorial_mode'] !== 'expert' && !$config['disable_help']) { + $table->data[0]['clippy'] = '<a href="javascript: show_clippy();">'.html_print_image( + 'images/clippy_icon.png', + true, + [ + 'id' => 'clippy', + 'class' => 'clippy', + 'alt' => __('%s assistant', get_product_name()), + 'title' => __( + '%s assistant', + get_product_name() + ), + ] + ).'</a>'; + } + + + $table->data[0][0] = $servers_link_open.$servers_check_img.$servers_link_close; + + + + + // ======= Autorefresh code ============================= + $autorefresh_txt = ''; + $autorefresh_additional = ''; + + $ignored_params = [ + 'agent_config' => false, + 'code' => false, + ]; + + if (!isset($_GET['sec2'])) { + $_GET['sec2'] = ''; + } + + if (!isset($_GET['refr'])) { + $_GET['refr'] = null; + } + + $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '".$config['id_user']."'"); + $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); + + if ($autorefresh_list !== null && array_search($_GET['sec2'], $autorefresh_list) !== false) { + $do_refresh = true; + if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { + if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { + $do_refresh = false; + } + } + + if ($do_refresh) { + $autorefresh_img = html_print_image('images/header_refresh.png', true, ['class' => 'bot', 'alt' => 'lightning', 'title' => __('Configure autorefresh')]); + + if ($_GET['refr']) { + $autorefresh_txt .= ' (<span id="refrcounter">'.date('i:s', $config['refr']).'</span>)'; + } + + $ignored_params['refr'] = ''; + $values = get_refresh_time_array(); + $autorefresh_additional = '<span id="combo_refr" style="display: none;">'; + $autorefresh_additional .= html_print_select($values, 'ref', '', '', __('Select'), '0', true, false, false); + $autorefresh_additional .= '</span>'; + unset($values); + + $autorefresh_link_open_img = '<a class="white autorefresh" href="'.ui_get_url_refresh($ignored_params).'">'; + + if ($_GET['refr']) { + $autorefresh_link_open_txt = '<a class="white autorefresh autorefresh_txt" href="'.ui_get_url_refresh($ignored_params).'">'; + } else { + $autorefresh_link_open_txt = '<a>'; + } + + $autorefresh_link_close = '</a>'; + } else { + $autorefresh_img = html_print_image('images/header_refresh_disabled.png', true, ['class' => 'bot autorefresh_disabled', 'alt' => 'lightning', 'title' => __('Disabled autorefresh')]); + + $ignored_params['refr'] = false; + + $autorefresh_link_open_img = ''; + $autorefresh_link_open_txt = ''; + $autorefresh_link_close = ''; + } + } else { + $autorefresh_img = html_print_image('images/header_refresh_disabled.png', true, ['class' => 'bot autorefresh_disabled', 'alt' => 'lightning', 'title' => __('Disabled autorefresh')]); + + $ignored_params['refr'] = false; + + $autorefresh_link_open_img = ''; + $autorefresh_link_open_txt = ''; + $autorefresh_link_close = ''; + } + + $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; + // ====================================================== + $pandora_management = check_acl($config['id_user'], 0, 'PM'); + + echo '<div id="alert_messages" style="display: none"></div>'; + + if ($config['alert_cnt'] > 0) { + $maintenance_link = 'javascript:'; + $maintenance_title = __('System alerts detected - Please fix as soon as possible'); + $maintenance_class = $maintenance_id = 'show_systemalert_dialog white'; + + $maintenance_link_open_txt = '<a href="'.$maintenance_link.'" title="'.$maintenance_title.'" class="'.$maintenance_class.'" id="show_systemalert_dialog">'; + $maintenance_link_open_img = '<a href="'.$maintenance_link.'" title="'.$maintenance_title.'" class="'.$maintenance_class.'">'; + $maintenance_link_close = '</a>'; + if (!$pandora_management) { + $maintenance_img = ''; + } else { + $maintenance_img = $maintenance_link_open_img.html_print_image( + 'images/header_yellow.png', + true, + [ + 'title' => __( + 'You have %d warning(s)', + $config['alert_cnt'] + ), + 'id' => 'yougotalert', + 'class' => 'bot', + ] + ).$maintenance_link_close; + } + } else { + if (!$pandora_management) { + $maintenance_img = ''; + } else { + $maintenance_img = html_print_image('images/header_ready.png', true, ['title' => __('There are not warnings'), 'id' => 'yougotalert', 'class' => 'bot']); + } + } + + $table->data[0][3] = $maintenance_img; + + // Main help icon + if (!$config['disable_help']) { + $table->data[0][4] = '<a href="#" class="modalpopup" id="helpmodal">'.html_print_image( + 'images/header_help.png', + true, + [ + 'title' => __('Main help'), + 'id' => 'helpmodal', + 'class' => 'modalpopup', + ] + ).'</a>'; + } + + // Logout + $table->data[0][5] = '<a class="white" href="'.ui_get_full_url('index.php?bye=bye').'">'; + $table->data[0][5] .= html_print_image('images/header_logout.png', true, ['alt' => __('Logout'), 'class' => 'bot', 'title' => __('Logout')]); + $table->data[0][5] .= '</a>'; + + // User + if (is_user_admin($config['id_user']) == 1) { + $table->data[0][6] = html_print_image('images/header_user_admin.png', true, ['title' => __('Edit my user'), 'class' => 'bot', 'alt' => 'user']); + } else { + $table->data[0][6] = html_print_image('images/header_user.png', true, ['title' => __('Edit my user'), 'class' => 'bot', 'alt' => 'user']); + } + + $table->data[0][6] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit">'.$table->data[0][6].'</a>'; + + $table->data[0][7] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit" class="white_bold"> ('.$config['id_user'].')</a>'; + + // Chat messages + $table->data[0][8] = "<span id='icon_new_messages_chat' style='display: none;'>"; + $table->data[0][8] .= "<a href='index.php?sec=workspace&sec2=operation/users/webchat'>"; + $table->data[0][8] .= html_print_image('images/header_chat.png', true, ['title' => __('New chat message')]); + $table->data[0][8] .= '</a>'; + $table->data[0][8] .= '</span>'; + + // Messages + $msg_cnt = messages_get_count($config['id_user']); + if ($msg_cnt > 0) { + echo '<div id="dialog_messages" style="display: none"></div>'; + + $table->data[0][9] = '<a href="ajax.php?page=operation/messages/message_list" title="'.__('Message overview').'" id="show_messages_dialog">'; + $table->data[0][9] .= html_print_image('images/header_email.png', true, ['title' => __('You have %d unread message(s)', $msg_cnt), 'id' => 'yougotmail', 'class' => 'bot', 'style' => 'width:24px;']); + $table->data[0][9] .= '</a>'; + } + + $table->data[0]['notifications'] = notifications_print_ball(); + + html_print_table($table); + + unset($table); + ?> + </td> + <!-- + <td style="text-align:center"> + <?php + echo "<a href='index.php?sec=main'>"; + if (isset($config['custom_logo'])) { + echo html_print_image('images/custom_logo/'.$config['custom_logo'], true, ['height' => '60', 'width' => '139', 'alt' => 'Logo']); + } + + echo '</a>'; + ?> + </td> + --> + </tr> </table> <script type="text/javascript"> - /* <![CDATA[ */ - - <?php - $config_fixed_header = false; - if (isset($config['fixed_header'])) { - $config_fixed_header = $config['fixed_header']; - } - ?> - - var fixed_header = <?php echo json_encode((bool)$config_fixed_header); ?>; - - var new_chat = <?php echo (int)$_SESSION['new_chat'];?>; - $(document).ready (function () { - <?php - if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET["refr"]))) { - $do_refresh = true; - if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { - if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { - $do_refresh = false; - } - } - - $new_dashboard = get_parameter('new_dashboard',0); - - if ($_GET['sec2'] == 'enterprise/dashboard/main_dashboard' && $new_dashboard) { - $do_refresh = false; - } + /* <![CDATA[ */ + + <?php + $config_fixed_header = false; + if (isset($config['fixed_header'])) { + $config_fixed_header = $config['fixed_header']; + } + ?> + + var fixed_header = <?php echo json_encode((bool) $config_fixed_header); ?>; + + var new_chat = <?php echo (int) $_SESSION['new_chat']; ?>; + $(document).ready (function () { + <?php + if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET['refr']))) { + $do_refresh = true; + if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { + if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { + $do_refresh = false; + } + } - if ($do_refresh) { - ?> - $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); - $("#combo_refr").css('padding-right', '9px'); - href = $("a.autorefresh").attr ("href"); - <?php - if($select[0]['time_autorefresh']){ - ?> - var refresh = '<?php echo $select[0]["time_autorefresh"] ?>'; - $(document).attr ("location", href + refresh); - <?php - } - ?> - - <?php - } - } - ?> + $new_dashboard = get_parameter('new_dashboard', 0); - if (fixed_header) { - $('div#head').addClass('fixed_header'); - $('div#page') - .css('padding-top', $('div#head').innerHeight() + 'px') - .css('position', 'relative'); - } - - check_new_chats_icon('icon_new_messages_chat'); - - /* Temporal fix to hide graphics when ui_dialog are displayed */ - $("#yougotalert").click(function () { - $("#agent_access").css("display", "none"); - }); - $("#ui_close_dialog_titlebar").click(function () { - $("#agent_access").css("display",""); - }); - - function blinkmail(){ - $("#yougotmail").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkmail); - } - function blinkalert(){ - $("#yougotalert").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkalert); - } - function blinkpubli(){ - $(".publienterprise").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkpubli); - } - <?php - if ($msg_cnt > 0) { - ?> - blinkmail(); - <?php - } - ?> - - - <?php - if ($config["alert_cnt"] > 0) { - ?> - blinkalert(); - <?php - } - ?> - blinkpubli(); + if ($_GET['sec2'] == 'enterprise/dashboard/main_dashboard' && $new_dashboard) { + $do_refresh = false; + } - <?php - if ($_GET["refr"]) { - ?> - var refr_time = <?php echo (int) get_parameter("refr", 0); ?>; - var t = new Date(); - t.setTime (t.getTime () + - parseInt(<?php echo $config["refr"] * 1000; ?>)); - $("#refrcounter").countdown ({until: t, - layout: '%M%nn%M:%S%nn%S', - labels: ['', '', '', '', '', '', ''], - onExpiry: function () { - href = $("a.autorefresh").attr ("href"); - href = href + refr_time; - $(document).attr ("location", href); - } - }); - <?php - } - ?> - - $("a.autorefresh").click (function () { - $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); - $("#combo_refr").css('padding-right', '9px'); - $("select#ref").change (function () { - href = $("a.autorefresh").attr ("href"); - $(document).attr ("location", href + this.value); - }); - - return false; - }); - }); + if ($do_refresh) { + ?> + $("a.autorefresh_txt").toggle (); + $("#combo_refr").toggle (); + $("#combo_refr").css('padding-right', '9px'); + href = $("a.autorefresh").attr ("href"); + <?php + if ($select[0]['time_autorefresh']) { + ?> + var refresh = '<?php echo $select[0]['time_autorefresh']; ?>'; + $(document).attr ("location", href + refresh); + <?php + } + ?> + + <?php + } + } + ?> + + if (fixed_header) { + $('div#head').addClass('fixed_header'); + $('div#page') + .css('padding-top', $('div#head').innerHeight() + 'px') + .css('position', 'relative'); + } + + check_new_chats_icon('icon_new_messages_chat'); + + /* Temporal fix to hide graphics when ui_dialog are displayed */ + $("#yougotalert").click(function () { + $("#agent_access").css("display", "none"); + }); + $("#ui_close_dialog_titlebar").click(function () { + $("#agent_access").css("display",""); + }); + + function blinkmail(){ + $("#yougotmail").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkmail); + } + function blinkalert(){ + $("#yougotalert").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkalert); + } + function blinkpubli(){ + $(".publienterprise").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkpubli); + } + <?php + if ($msg_cnt > 0) { + ?> + blinkmail(); + <?php + } + ?> + + + <?php + if ($config['alert_cnt'] > 0) { + ?> + blinkalert(); + <?php + } + ?> + blinkpubli(); + + <?php + if ($_GET['refr']) { + ?> + var refr_time = <?php echo (int) get_parameter('refr', 0); ?>; + var t = new Date(); + t.setTime (t.getTime () + + parseInt(<?php echo ($config['refr'] * 1000); ?>)); + $("#refrcounter").countdown ({until: t, + layout: '%M%nn%M:%S%nn%S', + labels: ['', '', '', '', '', '', ''], + onExpiry: function () { + href = $("a.autorefresh").attr ("href"); + href = href + refr_time; + $(document).attr ("location", href); + } + }); + <?php + } + ?> + + $("a.autorefresh").click (function () { + $("a.autorefresh_txt").toggle (); + $("#combo_refr").toggle (); + $("#combo_refr").css('padding-right', '9px'); + $("select#ref").change (function () { + href = $("a.autorefresh").attr ("href"); + $(document).attr ("location", href + this.value); + }); + + return false; + }); + }); /* ]]> */ </script> diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 3eaedcfcfb..fb9ca0fff7 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -28,7 +28,7 @@ global $config; -require_once __DIR__.'/../functions.php'; +require_once $config['homedir'].'/include/functions_db.php'; require_once $config['homedir'].'/include/functions_io.php'; require_once $config['homedir'].'/include/functions_notifications.php'; require_once $config['homedir'].'/include/functions_servers.php'; @@ -36,7 +36,7 @@ require_once $config['homedir'].'/include/functions_servers.php'; // Enterprise includes. enterprise_include_once('include/functions_metaconsole.php'); enterprise_include_once('include/functions_license.php'); - +enterprise_include_once('extensions/cron/functions.php'); /** * Base class to run scheduled tasks in cron extension @@ -172,12 +172,6 @@ class ConsoleSupervisor include_once $config['homedir'].'/'.ENTERPRISE_DIR.'/load_enterprise.php'; } - $time = get_system_time(); - $scheduled_tasks = db_get_all_rows_in_table('tuser_task_scheduled'); - if (!$scheduled_tasks) { - $scheduled_tasks = []; - } - // Automatic checks launched by supervisor. $this->warn('running.'); @@ -334,6 +328,13 @@ class ConsoleSupervisor $this->checkUpdates(); + /* + * Check if there're new minor updates available. + * NOTIF.UPDATEMANAGER.MINOR + */ + + $this->checkMinorRelease(); + if ($this->verbose === true) { // Release the lock. enterprise_hook('cron_supervisor_release_lock'); @@ -345,12 +346,17 @@ class ConsoleSupervisor /** * Update targets for given notification using object targets. * - * @param integer $notification_id Current notification. + * @param array $notification Current notification. + * @param boolean $update Only update db targets, no email. * * @return void */ - public function updateTargets(int $notification_id) - { + public function updateTargets( + array $notification, + bool $update=false + ) { + $notification_id = $notification['id_mensaje']; + if (is_array($this->targetUsers) === true && count($this->targetUsers) > 0 ) { @@ -365,10 +371,18 @@ class ConsoleSupervisor ); $insertion_string .= ','; - // Send mail. - if (isset($user['also_mail']) && $user['also_mail'] == 1) { - $this->warn('Mailing user: '.$user['id_user']."\n"); - // TODO: Add sendmail sequence. + if ($update === false) { + // Send mail. + if (isset($user['also_mail']) && $user['also_mail'] == 1) { + enterprise_hook( + 'send_email_user', + [ + $user['id_user'], + io_safe_output($notification['mensaje']).'<br><hl><br>'.$notification['url'], + io_safe_output($notification['subject']), + ] + ); + } } } @@ -391,10 +405,19 @@ class ConsoleSupervisor ); $insertion_string .= ','; - // Send mail. - if (isset($group['also_mail']) && $group['also_mail'] == 1) { - $this->warn('Mailing group: '.$group['id_group']."\n"); - // TODO: Add sendmail sequence. + if ($update === false) { + // Send mail. + if (isset($group['also_mail']) && $group['also_mail'] == 1) { + $this->warn('Mailing group: '.$group['id_group']."\n"); + enterprise_hook( + 'send_email_group', + [ + $group['id_group'], + io_safe_output($notification['mensaje']).'<br><hl><br>'.$notification['url'], + io_safe_output($notification['subject']), + ] + ); + } } } @@ -422,7 +445,7 @@ class ConsoleSupervisor public function notify( array $data, int $source_id=0, - int $max_age=86400 + int $max_age=0 ) { // Uses 'check failed' logic. if (is_array($data) === false) { @@ -475,7 +498,7 @@ class ConsoleSupervisor case 'NOTIF.NEWSLETTER.SUBSCRIPTION': case 'NOTIF.UPDATEMANAGER.OPENSETUP': case 'NOTIF.UPDATEMANAGER.UPDATE': - + case 'NOTIF.UPDATEMANAGER.MINOR': default: // NOTIF.SERVER.STATUS. // NOTIF.SERVER.STATUS.ID_SERVER. @@ -514,8 +537,7 @@ class ConsoleSupervisor ], ['id_mensaje' => $prev['id_mensaje']] ); - - $this->updateTargets($prev['id_mensaje']); + $this->updateTargets($prev, true); return; } @@ -540,7 +562,7 @@ class ConsoleSupervisor return; } - $this->updateTargets($id); + $this->updateTargets($notification); } @@ -2010,4 +2032,39 @@ class ConsoleSupervisor } + /** + * Check if there're minor updates available. + * + * @return void + */ + public function checkMinorRelease() + { + global $config; + + $check_minor_release_available = db_check_minor_relase_available(); + + if ($check_minor_release_available) { + $url = 'http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Anexo_Upgrade#Version_7.0NG_.28_Rolling_Release_.29'; + if ($config['language'] == 'es') { + $url = 'http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Actualizacion#Versi.C3.B3n_7.0NG_.28_Rolling_Release_.29'; + } + + $this->notify( + [ + 'type' => 'NOTIF.UPDATEMANAGER.MINOR', + 'title' => __('Minor release/s available'), + 'message' => __( + 'There are one or more minor releases waiting for update. <a style="font-size:8pt;font-style:italic;" target="blank" href="%s">.About minor release update</a>.', + $url + ), + 'url' => $url, + ] + ); + } else { + $this->cleanNotifications('NOTIF.UPDATEMANAGER.MINOR'); + } + + } + + } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 3af3db3f69..e532deea15 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2664,8 +2664,8 @@ function config_check() include_once __DIR__.'/class/ConsoleSupervisor.php'; - // Enterprise controlles supervisor using discovery cron task. - if (!license_free()) { + // Enterprise customers launch supervisor using discovery task. + if (license_free()) { $supervisor = new ConsoleSupervisor(false); $supervisor->run(); } diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index c8f46d90ae..2ac5eb1227 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -193,7 +193,7 @@ function get_notification_source_targets(int $id_source) $i = 0; foreach ($users as $user) { $ret['users'][$i]['id_user'] = $user['id_user']; - $ret['users'][$i++]['also_mail'] = $also_mail; + $ret['users'][$i++]['also_mail'] = $user['also_mail']; } } diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index f73ab0af68..e97f7e6a5b 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1278,3 +1278,11 @@ INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, ` ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); + +-- +-- Dumping data for table `tnotification_source_user` +-- +INSERT INTO `tnotification_source_user`(`id_source`,`id_user`,`enabled`,`also_mail`) VALUES + ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin",1,0); + + \ No newline at end of file From 04b2cb8665ebda46cf93b5df7a420703a187e79a Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Thu, 7 Feb 2019 18:04:14 +0100 Subject: [PATCH 041/262] Use real ids instead fake ids Former-commit-id: 2360a14d1865f918247d23b2f3181626052cad60 --- .../godmode/setup/setup_notifications.php | 20 ++++++------ .../include/functions_notifications.php | 32 ++++++------------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index f8ce35c9f8..956571aa1f 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -26,38 +26,36 @@ if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user } // AJAX actions. -$source_id = get_parameter('source_id', ''); +$source = get_parameter('source', ''); $users = get_parameter('users', ''); $elements = get_parameter('elements', []); -$id = empty($source_id) ? 0 : get_notification_source_id($source_id); $is_users = $users === 'users'; if (get_parameter('get_selection_two_ways_form', 0)) { - $info_selec = $is_users ? notifications_get_user_source_not_configured($id) : notifications_get_group_source_not_configured($id); + $info_selec = $is_users ? notifications_get_user_source_not_configured($source) : notifications_get_group_source_not_configured($source); echo notifications_print_two_ways_select( $info_selec, $users, - $source_id + $source ); return; } if (get_parameter('add_source_to_database', 0)) { - $res = $is_users ? notifications_add_users_to_source($id, $elements) : notifications_add_group_to_source($id, $elements); + $res = $is_users ? notifications_add_users_to_source($source, $elements) : notifications_add_group_to_source($source, $elements); $result = ['result' => $res]; echo json_encode($result); return; } if (get_parameter('remove_source_on_database', 0)) { - $res = $is_users ? notifications_remove_users_from_source($id, $elements) : notifications_remove_group_from_source($id, $elements); + $res = $is_users ? notifications_remove_users_from_source($source, $elements) : notifications_remove_group_from_source($source, $elements); $result = ['result' => $res]; echo json_encode($result); return; } if (get_parameter('update_config', 0)) { - $source = (int) get_parameter('source', 0); $element = (string) get_parameter('element', ''); $value = (int) get_parameter('value', 0); @@ -159,7 +157,7 @@ function add_source_dialog(users, source_id) { {"page" : "godmode/setup/setup_notifications", "get_selection_two_ways_form" : 1, "users" : users, - "source_id" : source_id + "source" : source_id }, function (data, status) { not_dialog.innerHTML = data @@ -198,7 +196,7 @@ function notifications_add_source_element_to_database(id, source_id) { {"page" : "godmode/setup/setup_notifications", "add_source_to_database" : 1, "users" : id, - "source_id" : source_id, + "source" : source_id, "elements": selected }, function (data, status) { @@ -236,13 +234,13 @@ function remove_source_elements(id, source_id) { {"page" : "godmode/setup/setup_notifications", "remove_source_on_database" : 1, "users" : id, - "source_id" : source_id, + "source" : source_id, "elements": selected }, function (data, status) { if (data.result) { // Append to other element - for (var i = selected_index.length - 1; i >= 0; i--) { + for (var i = 0; i < selected_index.length; i++) { select.remove(selected_index[i]); } } else { diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 1142f19ebe..768bd67b97 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -51,21 +51,6 @@ function get_notification_source_id(string $source) } -/** - * Converts description into a handable identifier - * - * @param string $desc Full description - * - * @return string First word in lowercase. Empty string if no word detected. - */ -function notifications_desc_to_id(string $desc) -{ - preg_match('/^[a-zA-Z]*/', $desc, $matches); - $match = $matches[0]; - return isset($match) ? $match : ''; -} - - /** * Retrieve all targets for given message. * @@ -348,7 +333,9 @@ function notifications_add_group_to_source($source_id, $groups) // Insert into database all groups passed. $res = true; foreach ($groups as $group) { - if (!isset($group)) continue; + if (!isset($group)) { + continue; + } $res = $res && db_process_sql_insert( 'tnotification_source_group', @@ -559,9 +546,8 @@ function notifications_print_ball() function notifications_print_global_source_configuration($source) { // Get some values to generate the title. - $id = notifications_desc_to_id($source['description']); $switch_values = [ - 'name' => 'enable-'.$id, + 'name' => 'enable-'.$source['id'], 'value' => $source['enabled'], 'id' => 'nt-'.$source['id'].'-enabled', 'class' => 'elem-clickable', @@ -582,19 +568,19 @@ function notifications_print_global_source_configuration($source) // Generate the html for title $html_selectors = "<div class='global-config-notification-selectors'>"; - $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $id, $is_group_all); - $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $id, $is_group_all); + $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $source['id'], $is_group_all); + $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $source['id'], $is_group_all); $html_selectors .= '</div>'; // Generate the checkboxes and time select $html_checkboxes = "<div class='global-config-notification-checkboxes'>"; $html_checkboxes .= ' <span>'; - $html_checkboxes .= html_print_checkbox_extended("all-$id", 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"'); + $html_checkboxes .= html_print_checkbox_extended('all-'.$source['id'], 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"'); $html_checkboxes .= __('Notify all users'); $html_checkboxes .= ' </span><br><span>'; - $html_checkboxes .= html_print_checkbox_extended("mail-$id", 1, $source['also_mail'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-also_mail"'); + $html_checkboxes .= html_print_checkbox_extended('mail-'.$source['id'], 1, $source['also_mail'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-also_mail"'); $html_checkboxes .= __('Also email users with notification content'); $html_checkboxes .= ' </span><br><span>'; - $html_checkboxes .= html_print_checkbox_extended("user-$id", 1, $source['user_editable'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-user_editable"'); + $html_checkboxes .= html_print_checkbox_extended('user-'.$source['id'], 1, $source['user_editable'], false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-user_editable"'); $html_checkboxes .= __('Users can modify notification preferences'); $html_checkboxes .= ' </span>'; $html_checkboxes .= '</div>'; From 42b0afb884592da50ed09b85d192b2ba478ae6ed Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Thu, 7 Feb 2019 18:07:52 +0100 Subject: [PATCH 042/262] Supervisor minor fixes Former-commit-id: 84171e197df0a016a9a4b7d0e49f0412b65ee864 --- pandora_console/include/class/ConsoleSupervisor.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index fb9ca0fff7..517ed8acd3 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -387,7 +387,6 @@ class ConsoleSupervisor } $insertion_string = substr($insertion_string, 0, -1); - db_process_sql($users_sql.' VALUES '.$insertion_string); } @@ -445,7 +444,7 @@ class ConsoleSupervisor public function notify( array $data, int $source_id=0, - int $max_age=0 + int $max_age=86400 ) { // Uses 'check failed' logic. if (is_array($data) === false) { @@ -562,6 +561,9 @@ class ConsoleSupervisor return; } + // Update reference to update targets. + $notification['id_mensaje'] = $id; + $this->updateTargets($notification); } From e90d4b7256945e5364738844e676cb321383dcb7 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Thu, 7 Feb 2019 18:29:20 +0100 Subject: [PATCH 043/262] Supervisor added blacklist to avoid mail twice Former-commit-id: e2f03306076d90f9abe312694ea1fa2298ee7c62 --- pandora_console/include/class/ConsoleSupervisor.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 517ed8acd3..ad21b44345 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -356,6 +356,7 @@ class ConsoleSupervisor bool $update=false ) { $notification_id = $notification['id_mensaje']; + $blacklist = []; if (is_array($this->targetUsers) === true && count($this->targetUsers) > 0 @@ -382,6 +383,7 @@ class ConsoleSupervisor io_safe_output($notification['subject']), ] ); + array_push($blacklist, $user['id_user']); } } } @@ -407,13 +409,14 @@ class ConsoleSupervisor if ($update === false) { // Send mail. if (isset($group['also_mail']) && $group['also_mail'] == 1) { - $this->warn('Mailing group: '.$group['id_group']."\n"); enterprise_hook( 'send_email_group', [ $group['id_group'], io_safe_output($notification['mensaje']).'<br><hl><br>'.$notification['url'], io_safe_output($notification['subject']), + null, + $blacklist, ] ); } From 80a5d0b0b926753f0a9f9344a7baa6c250736105 Mon Sep 17 00:00:00 2001 From: Fermin <fermin.hernandez@artica.es> Date: Fri, 8 Feb 2019 10:32:04 +0100 Subject: [PATCH 044/262] Removed unused code and format some files Former-commit-id: 5f8da31efc5241dd16002565fdb89d774072b7b3 --- .../godmode/setup/setup_notifications.php | 66 +++++++-------- .../include/functions_notifications.php | 80 ++++++++++--------- 2 files changed, 74 insertions(+), 72 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 956571aa1f..d6ce67ab90 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -1,18 +1,31 @@ <?php +/** + * Library. Notification system auxiliary functions. + * + * @category UI file + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2019 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// Warning: This file may be required into the metaconsole's setup -// Load global vars global $config; require_once $config['homedir'].'/include/functions_notifications.php'; @@ -31,7 +44,7 @@ $users = get_parameter('users', ''); $elements = get_parameter('elements', []); $is_users = $users === 'users'; if (get_parameter('get_selection_two_ways_form', 0)) { - $info_selec = $is_users ? notifications_get_user_source_not_configured($source) : notifications_get_group_source_not_configured($source); + $info_selec = ($is_users) ? notifications_get_user_source_not_configured($source) : notifications_get_group_source_not_configured($source); echo notifications_print_two_ways_select( $info_selec, @@ -42,14 +55,14 @@ if (get_parameter('get_selection_two_ways_form', 0)) { } if (get_parameter('add_source_to_database', 0)) { - $res = $is_users ? notifications_add_users_to_source($source, $elements) : notifications_add_group_to_source($source, $elements); + $res = ($is_users) ? notifications_add_users_to_source($source, $elements) : notifications_add_group_to_source($source, $elements); $result = ['result' => $res]; echo json_encode($result); return; } if (get_parameter('remove_source_on_database', 0)) { - $res = $is_users ? notifications_remove_users_from_source($source, $elements) : notifications_remove_group_from_source($source, $elements); + $res = ($is_users) ? notifications_remove_users_from_source($source, $elements) : notifications_remove_group_from_source($source, $elements); $result = ['result' => $res]; echo json_encode($result); return; @@ -65,7 +78,7 @@ if (get_parameter('update_config', 0)) { switch ($element) { // All users has other action. case 'all_users': - $res = $value ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]); + $res = ($value) ? notifications_add_group_to_source($source, [0]) : notifications_remove_group_from_source($source, [0]); break; default: @@ -89,7 +102,7 @@ $table_content->id = 'notifications-wrapper'; $table_content->class = 'databox filters'; $table_content->size['name'] = '30%'; -// Print each source configuration +// Print each source configuration. $table_content->data = array_map( function ($source) { return notifications_print_global_source_configuration($source); @@ -101,13 +114,6 @@ html_print_table($table_content); ?> <script> -// Get the source id -function notifications_get_source_id(id) { - var matched = id.match(/.*-(.*)/); - if (matched == null) return ''; - return matched[1]; -} - // Get index of two ways element dialog. function notifications_two_ways_element_get_dialog (id, source_id) { return 'global_config_notifications_dialog_add-' + id + '-' + source_id; @@ -118,16 +124,6 @@ function notifications_two_ways_element_get_sufix (id, source_id) { return 'multi-' + id + '-' + source_id; } -// Disable or enable the select seeing the checked value of notify all users -function notifications_disable_source(event) { - var id = notifications_get_source_id(event.target.id); - var is_checked = document.getElementById(event.target.id).checked; - var selectors = ['groups', 'users']; - selectors.map(function (select) { - document.getElementById(notifications_two_ways_element_get_sufix(select, id)).disabled = is_checked; - }); -} - // Open a dialog with selector of source elements. function add_source_dialog(users, source_id) { // Display the dialog diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 768bd67b97..85f34cc2c7 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -1,5 +1,4 @@ <?php - /** * Library. Notification system auxiliary functions. * @@ -44,9 +43,12 @@ function get_notification_source_id(string $source) } return db_get_value_sql( - "SELECT id - FROM `tnotification_source` - WHERE `description` LIKE '{$source}%'" + sprintf( + 'SELECT id + FROM `tnotification_source` + WHERE lower(`description`) = lower("%s")', + $source + ) ); } @@ -238,7 +240,7 @@ function notifications_get_group_sources($filter=[], $fields=[]) $fields = array_map( function ($field) { if (!preg_match('/^tnsg./', $field)) { - $field = "tnsg.{$field}"; + $field = 'tnsg.'.$field; } return $field; @@ -254,7 +256,7 @@ function notifications_get_group_sources($filter=[], $fields=[]) array_merge($fields, ['IFNULL(tg.nombre, "All") AS name']) ); - // If fails or no one is selected, return empty array + // If fails or no one is selected, return empty array. if ($groups === false) { return []; } @@ -273,12 +275,12 @@ function notifications_get_group_sources($filter=[], $fields=[]) */ function notifications_remove_group_from_source($source_id, $groups) { - // Source id is mandatory + // Source id is mandatory. if (!isset($source_id)) { return false; } - // Delete from database + // Delete from database. return db_process_sql_delete( 'tnotification_source_group', [ @@ -299,12 +301,12 @@ function notifications_remove_group_from_source($source_id, $groups) */ function notifications_remove_users_from_source($source_id, $users) { - // Source id is mandatory + // Source id is mandatory. if (!isset($source_id)) { return false; } - // Delete from database + // Delete from database. return db_process_sql_delete( 'tnotification_source_user', [ @@ -360,12 +362,12 @@ function notifications_add_group_to_source($source_id, $groups) */ function notifications_add_users_to_source($source_id, $users) { - // Source id is mandatory + // Source id is mandatory. if (!isset($source_id)) { return false; } - // Insert into database all groups passed + // Insert into database all groups passed. $res = true; $also_mail = db_get_value( 'also_mail', @@ -529,10 +531,14 @@ function notifications_set_user_label_status($source, $user, $label, $value) function notifications_print_ball() { $num_notifications = messages_get_count(); - $class_status = $num_notifications == 0 ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; - return "<div class='notification-ball $class_status' id='notification-ball-header'> - $num_notifications - </div>"; + $class_status = ($num_notifications == 0) ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; + return sprintf( + '<div class="notification-ball %s" id="notification-ball-header"> + %s + </div>', + $class_status, + $num_notifications + ); } @@ -553,25 +559,25 @@ function notifications_print_global_source_configuration($source) 'class' => 'elem-clickable', ]; - // Search if group all is set and handle that situation + // Search if group all is set and handle that situation. $source_groups = notifications_get_group_sources_for_select($source['id']); $is_group_all = isset($source_groups['0']); if ($is_group_all) { unset($source_groups['0']); } - // Generate the title + // Generate the title. $html_title = "<div class='global-config-notification-title'>"; $html_title .= html_print_switch($switch_values); - $html_title .= "<h2>{$source['description']}</h2>"; + $html_title .= '<h2>'.$source['description'].'</h2>'; $html_title .= '</div>'; - // Generate the html for title + // Generate the html for title. $html_selectors = "<div class='global-config-notification-selectors'>"; $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $source['id'], $is_group_all); $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $source['id'], $is_group_all); $html_selectors .= '</div>'; - // Generate the checkboxes and time select + // Generate the checkboxes and time select. $html_checkboxes = "<div class='global-config-notification-checkboxes'>"; $html_checkboxes .= ' <span>'; $html_checkboxes .= html_print_checkbox_extended('all-'.$source['id'], 1, $is_group_all, false, '', 'class= "elem-clickable"', true, 'id="nt-'.$source['id'].'-all_users"'); @@ -585,7 +591,7 @@ function notifications_print_global_source_configuration($source) $html_checkboxes .= ' </span>'; $html_checkboxes .= '</div>'; - // Generate the select with the time + // Generate the select with the time. $html_select_pospone = __('Users can postpone notifications up to'); $html_select_pospone .= html_print_select( [ @@ -609,7 +615,7 @@ function notifications_print_global_source_configuration($source) 'elem-changeable' ); - // Return all html + // Return all html. return $html_title.$html_selectors.$html_checkboxes.$html_select_pospone; } @@ -630,20 +636,20 @@ function notifications_print_source_select_box( $source_id, $disabled ) { - $title = $id == 'users' ? __('Notified users') : __('Notified groups'); - $add_title = $id == 'users' ? __('Add users') : __('Add groups'); - $delete_title = $id == 'users' ? __('Delete users') : __('Delete groups'); + $title = ($id === 'users') ? __('Notified users') : __('Notified groups'); + $add_title = ($id === 'users') ? __('Add users') : __('Add groups'); + $delete_title = ($id === 'users') ? __('Delete users') : __('Delete groups'); - // Generate the HTML + // Generate the HTML. $html_select = "<div class='global-config-notification-single-selector'>"; $html_select .= ' <div>'; - $html_select .= " <h4>$title</h4>"; - // Put a true if empty sources to avoid to sow the 'None' value - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}-{$source_id}[]", 0, false, '', '', true, true, true, '', $disabled); + $html_select .= ' <h4>'.$title.'</h4>'; + // Put a true if empty sources to avoid to sow the 'None' value. + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, 'multi-'.$id.'-'.$source_id.'[]', 0, false, '', '', true, true, true, '', $disabled); $html_select .= ' </div>'; $html_select .= " <div class='global-notifications-icons'>"; - $html_select .= html_print_image('images/input_add.png', true, ['title' => $add_title, 'onclick' => "add_source_dialog('$id', '$source_id')"]); - $html_select .= html_print_image('images/input_delete.png', true, ['title' => $delete_title, 'onclick' => "remove_source_elements('$id', '$source_id')"]); + $html_select .= html_print_image('images/input_add.png', true, ['title' => $add_title, 'onclick' => 'add_source_dialog("'.$id.', "'.$source_id.'")"']); + $html_select .= html_print_image('images/input_delete.png', true, ['title' => $delete_title, 'onclick' => 'remove_source_elements("'.$id.'", "'.$source_id.'")"']); $html_select .= ' </div>'; $html_select .= '</div>'; return $html_select; @@ -663,14 +669,14 @@ function notifications_print_source_select_box( function notifications_print_two_ways_select($info_selec, $users, $source_id) { $html_select = "<div class='global_config_notifications_dialog_add'>"; - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "all-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, ''); + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, 'all-multi-'.$users.'-'.$source_id.'[]', 0, false, '', '', true, true, true, ''); $html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>"; - $html_select .= html_print_image('images/darrowright.png', true, ['title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'add')"]); - $html_select .= html_print_image('images/darrowleft.png', true, ['title' => $add_title, 'onclick' => "notifications_modify_two_ways_element('$users', '$source_id', 'remove')"]); + $html_select .= html_print_image('images/darrowright.png', true, ['title' => $add_title, 'onclick' => 'notifications_modify_two_ways_element("'.$users.'", "'.$source_id.'", "add")']); + $html_select .= html_print_image('images/darrowleft.png', true, ['title' => $add_title, 'onclick' => 'notifications_modify_two_ways_element("'.$users.'", "'.$source_id.'", "remove")']); $html_select .= '</div>'; - $html_select .= html_print_select(true, "selected-multi-{$users}-{$source_id}[]", 0, false, '', '', true, true, true, ''); + $html_select .= html_print_select(true, 'selected-multi-'.$users.'-'.$source_id.'[]', 0, false, '', '', true, true, true, ''); $html_select .= '</div>'; - $html_select .= html_print_button(__('Add'), 'Add', false, "notifications_add_source_element_to_database('$users', '$source_id')", "class='sub add'", true); + $html_select .= html_print_button(__('Add'), 'Add', false, 'notifications_add_source_element_to_database("'.$users.'", "'.$source_id.'")', "class='sub add'", true); return $html_select; } From 63d589c9188d24618ae364f9e330c36c796bd610 Mon Sep 17 00:00:00 2001 From: Daniel Maya <daniel.maya@artica.es> Date: Fri, 8 Feb 2019 11:34:47 +0100 Subject: [PATCH 045/262] Parameter changes deprecated in LDAP Former-commit-id: 2accf38ffe089c19475b1956cf04da7769dca2e9 --- pandora_console/include/auth/mysql.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 69e848d805..8003275fbf 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -1369,8 +1369,7 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $tls = ' -ZZ '; } - $ldap_host = ' -h '.$ldap_host; - $ldap_port = ' -p '.$ldap_port; + $ldap_host = ' -H '.$ldap_host.':'.$ldap_port; $ldap_version = ' -P '.$ldap_version; if (!empty($ldap_admin_user)) { $ldap_admin_user = " -D '".$ldap_admin_user."'"; @@ -1382,7 +1381,7 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $dn = " -b '".$dn."'"; - $shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_port.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"')); + $shell_ldap_search = explode("\n", shell_exec('ldapsearch -LLL -o ldif-wrap=no -x'.$ldap_host.$ldap_version.' -E pr=10000/noprompt '.$ldap_admin_user.$ldap_admin_pass.$dn.$filter.$tls.' | grep -v "^#\|^$" | sed "s/:\+ /=>/g"')); foreach ($shell_ldap_search as $line) { $values = explode('=>', $line); if (!empty($values[0]) && !empty($values[1])) { From 4b86683d230541c82eba2f28143192e642f36a6f Mon Sep 17 00:00:00 2001 From: Fermin <fermin.hernandez@artica.es> Date: Fri, 8 Feb 2019 11:39:17 +0100 Subject: [PATCH 046/262] Fixed style Former-commit-id: bd4c0370bb3c63eddb9a7b36b0e8f6938c48b4ae --- .../godmode/setup/setup_notifications.php | 20 ++- .../include/functions_notifications.php | 149 +++++++++++++++--- 2 files changed, 141 insertions(+), 28 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index d6ce67ab90..d207f72d76 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -44,7 +44,7 @@ $users = get_parameter('users', ''); $elements = get_parameter('elements', []); $is_users = $users === 'users'; if (get_parameter('get_selection_two_ways_form', 0)) { - $info_selec = ($is_users) ? notifications_get_user_source_not_configured($source) : notifications_get_group_source_not_configured($source); + $info_selec = ($is_users === true) ? notifications_get_user_source_not_configured($source) : notifications_get_group_source_not_configured($source); echo notifications_print_two_ways_select( $info_selec, @@ -133,7 +133,10 @@ function add_source_dialog(users, source_id) { if (previous_dialog !== null) previous_dialog.remove(); // Create or recreate the content. var not_dialog = document.createElement('div'); - not_dialog.setAttribute('class', 'global_config_notifications_dialog_add_wrapper'); + not_dialog.setAttribute( + 'class', + 'global_config_notifications_dialog_add_wrapper' + ); not_dialog.setAttribute('id', dialog_id); document.body.appendChild(not_dialog); $("#" + dialog_id).dialog({ @@ -182,7 +185,8 @@ function notifications_modify_two_ways_element (id, source_id, operation) { // Add elements to database and close dialog function notifications_add_source_element_to_database(id, source_id) { - var index = 'selected-' + notifications_two_ways_element_get_sufix (id, source_id); + var index = 'selected-' + + notifications_two_ways_element_get_sufix (id, source_id); var select = document.getElementById(index); var selected = []; for (var i = select.options.length - 1; i >= 0; i--) { @@ -205,7 +209,11 @@ function notifications_add_source_element_to_database(id, source_id) { out_select.appendChild(select.options[i]); } // Close the dialog - $("#" + notifications_two_ways_element_get_dialog(id, source_id)).dialog("close"); + $("#" + notifications_two_ways_element_get_dialog( + id, + source_id + )) + .dialog("close"); } else { console.log("Cannot update element."); } @@ -304,7 +312,9 @@ function notifications_handle_change_element(event) { value = element.value; break; default: - console.error("Unregonized action (insert on db)", action.bit, '.'); + console.error( + "Unregonized action (insert on db)", action.bit, '.' + ); return; } } diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 85f34cc2c7..7f82908aab 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -641,18 +641,59 @@ function notifications_print_source_select_box( $delete_title = ($id === 'users') ? __('Delete users') : __('Delete groups'); // Generate the HTML. - $html_select = "<div class='global-config-notification-single-selector'>"; - $html_select .= ' <div>'; - $html_select .= ' <h4>'.$title.'</h4>'; - // Put a true if empty sources to avoid to sow the 'None' value. - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, 'multi-'.$id.'-'.$source_id.'[]', 0, false, '', '', true, true, true, '', $disabled); - $html_select .= ' </div>'; - $html_select .= " <div class='global-notifications-icons'>"; - $html_select .= html_print_image('images/input_add.png', true, ['title' => $add_title, 'onclick' => 'add_source_dialog("'.$id.', "'.$source_id.'")"']); - $html_select .= html_print_image('images/input_delete.png', true, ['title' => $delete_title, 'onclick' => 'remove_source_elements("'.$id.'", "'.$source_id.'")"']); - $html_select .= ' </div>'; - $html_select .= '</div>'; - return $html_select; + return sprintf( + " + <div class='global-config-notification-single-selector'> + <div> + <h4>%s</h4> + %s + </div> + <div class='global-notifications-icons'> + %s + %s + </div> + </div> + ", + $title, + // Put a true if empty sources to avoid to sow the 'None' value. + html_print_select( + empty($info_selec) ? true : $info_selec, + 'multi-'.$id.'-'.$source_id.'[]', + 0, + false, + '', + '', + true, + true, + true, + '', + $disabled + ), + html_print_image( + 'images/input_add.png', + true, + [ + 'title' => $add_title, + 'onclick' => sprintf( + "add_source_dialog('%s', '%s')", + $id, + $source_id + ), + ] + ), + html_print_image( + 'images/input_delete.png', + true, + [ + 'title' => $delete_title, + 'onclick' => sprintf( + "remove_source_elements('%s', '%s')", + $id, + $source_id + ), + ] + ) + ); } @@ -668,17 +709,79 @@ function notifications_print_source_select_box( */ function notifications_print_two_ways_select($info_selec, $users, $source_id) { - $html_select = "<div class='global_config_notifications_dialog_add'>"; - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, 'all-multi-'.$users.'-'.$source_id.'[]', 0, false, '', '', true, true, true, ''); - $html_select .= "<div class='global_config_notifications_two_ways_form_arrows'>"; - $html_select .= html_print_image('images/darrowright.png', true, ['title' => $add_title, 'onclick' => 'notifications_modify_two_ways_element("'.$users.'", "'.$source_id.'", "add")']); - $html_select .= html_print_image('images/darrowleft.png', true, ['title' => $add_title, 'onclick' => 'notifications_modify_two_ways_element("'.$users.'", "'.$source_id.'", "remove")']); - $html_select .= '</div>'; - $html_select .= html_print_select(true, 'selected-multi-'.$users.'-'.$source_id.'[]', 0, false, '', '', true, true, true, ''); - $html_select .= '</div>'; - $html_select .= html_print_button(__('Add'), 'Add', false, 'notifications_add_source_element_to_database("'.$users.'", "'.$source_id.'")', "class='sub add'", true); - - return $html_select; + return sprintf( + " + <div class='global_config_notifications_dialog_add'> + %s + <div class='global_config_notifications_two_ways_form_arrows'> + %s + %s + </div> + %s + </div> + %s + ", + html_print_select( + empty($info_selec) ? true : $info_selec, + 'all-multi-'.$users.'-'.$source_id.'[]', + 0, + false, + '', + '', + true, + true, + true, + '' + ), + html_print_image( + 'images/darrowright.png', + true, + [ + 'title' => __('Add elements'), + 'onclick' => sprintf( + "notifications_modify_two_ways_element('%s', '%s', 'add')", + $users, + $source_id + ), + ] + ), + html_print_image( + 'images/darrowleft.png', + true, + [ + 'title' => __('Remove elements'), + 'onclick' => sprintf( + "notifications_modify_two_ways_element('%s', '%s', 'remove')", + $users, + $source_id + ), + ] + ), + html_print_select( + true, + 'selected-multi-'.$users.'-'.$source_id.'[]', + 0, + false, + '', + '', + true, + true, + true, + '' + ), + html_print_button( + __('Add'), + 'Add', + false, + sprintf( + "notifications_add_source_element_to_database('%s', '%s')", + $users, + $source_id + ), + "class='sub add'", + true + ) + ); } From 348a10cfe42a694c54ed5212e173839fcae7130c Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Fri, 8 Feb 2019 13:59:48 +0100 Subject: [PATCH 047/262] Added tevent_extended to db scripts Former-commit-id: 5391b8dc0da2bc30bf92735f8604fe84456e992e --- .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 13 +++++++++++++ pandora_console/pandoradb.sql | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 5dc7cd70c4..e34d4dee90 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1856,6 +1856,19 @@ ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; +-- --------------------------------------------------------------------- +-- Table `tevent_extended` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tevent_extended` ( + `id` serial PRIMARY KEY, + `id_evento` bigint(20) unsigned NOT NULL, + `external_id` bigint(20) unsigned, + `utimestamp` bigint(20) NOT NULL default '0', + `description` text, + FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- ----------------------------------------------------- -- Table `tgis_map_layer_groups` -- ----------------------------------------------------- diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7f8197540b..874f8b0bb6 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -655,6 +655,19 @@ CREATE TABLE IF NOT EXISTS `tevento` ( -- Criticity: 3 - Warning (yellow) (status 2) -- Criticity: 4 - Critical (red) (status 1) +-- --------------------------------------------------------------------- +-- Table `tevent_extended` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tevent_extended` ( + `id` serial PRIMARY KEY, + `id_evento` bigint(20) unsigned NOT NULL, + `external_id` bigint(20) unsigned, + `utimestamp` bigint(20) NOT NULL default '0', + `description` text, + FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- --------------------------------------------------------------------- -- Table `tgrupo` -- --------------------------------------------------------------------- From 0124bd0a17ee165a9d201c9bc5fc17d8abacfc6b Mon Sep 17 00:00:00 2001 From: Fermin <fermin.hernandez@artica.es> Date: Fri, 8 Feb 2019 14:23:05 +0100 Subject: [PATCH 048/262] Added real notifications (not AJAX jet) Former-commit-id: 5d0dee32c4fb96ad8dcb4f3f70049e1d1c4936fc --- pandora_console/general/header.php | 972 +++++++++--------- .../include/functions_messages.php | 29 +- .../include/functions_notifications.php | 66 +- pandora_console/include/styles/pandora.css | 53 + 4 files changed, 635 insertions(+), 485 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 1edcf76b77..7e84247c50 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -4,509 +4,529 @@ // ================================================== // 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. - -require_once ("include/functions_messages.php"); -require_once ('include/functions_servers.php'); -require_once ('include/functions_notifications.php'); +require_once 'include/functions_messages.php'; +require_once 'include/functions_servers.php'; +require_once 'include/functions_notifications.php'; // Check permissions - // Global errors/warnings checking. config_check(); ?> <table width="100%" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px; margin-top: 0px; height: 100%" border="0"> - <tr> - <td style="width:90%;"> - <a href="index.php?sec=main"> - <?php - $custom_logo = 'images/custom_logo/' . $config['custom_logo']; - - if (!defined ('PANDORA_ENTERPRISE')) { - $logo_title = get_product_name() . ' Opensource'; - $custom_logo = 'images/custom_logo/pandora_logo_head_3.png'; - } - else { - if (file_exists(ENTERPRISE_DIR . '/' . $custom_logo)) { - $custom_logo = ENTERPRISE_DIR . '/' . $custom_logo; - } - $logo_title = get_product_name() . ' Enterprise'; - } - - echo html_print_image($custom_logo, true, - array("alt" => $logo_title, "border" => '0')); - ?> - </a> - </td> - <td style="min-width:200px;"> - <?php - $table = new stdClass(); - $table->id = "header_table"; - $table->class = "none"; - $table->cellpadding = 0; - $table->cellspacing = 0; - $table->head = array (); - $table->data = array (); - $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'] = - $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;'; - $table->width = "100%"; - $table->styleTable = 'margin: auto; margin-top: 0px;'; - $table->rowclass[0] = ''; - - $acl_head_search = true; - if ($config["acl_enterprise"] == 1 && !users_is_admin()) { - $acl_head_search = db_get_sql("SELECT sec FROM tusuario + <tr> + <td style="width:90%;"> + <a href="index.php?sec=main"> + <?php + $custom_logo = 'images/custom_logo/'.$config['custom_logo']; + + if (!defined('PANDORA_ENTERPRISE')) { + $logo_title = get_product_name().' Opensource'; + $custom_logo = 'images/custom_logo/pandora_logo_head_3.png'; + } else { + if (file_exists(ENTERPRISE_DIR.'/'.$custom_logo)) { + $custom_logo = ENTERPRISE_DIR.'/'.$custom_logo; + } + + $logo_title = get_product_name().' Enterprise'; + } + + echo html_print_image( + $custom_logo, + true, + [ + 'alt' => $logo_title, + 'border' => '0', + ] + ); + ?> + </a> + </td> + <td style="min-width:200px;"> + <?php + $table = new stdClass(); + $table->id = 'header_table'; + $table->class = 'none'; + $table->cellpadding = 0; + $table->cellspacing = 0; + $table->head = []; + $table->data = []; + $table->style[0] = $table->style['clippy'] = $table->style[1] = $table->style[3] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = $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;'; + $table->width = '100%'; + $table->styleTable = 'margin: auto; margin-top: 0px;'; + $table->rowclass[0] = ''; + + $acl_head_search = true; + if ($config['acl_enterprise'] == 1 && !users_is_admin()) { + $acl_head_search = db_get_sql( + "SELECT sec FROM tusuario INNER JOIN tusuario_perfil ON tusuario.id_user = tusuario_perfil.id_usuario INNER JOIN tprofile_view ON tprofile_view.id_profile = tusuario_perfil.id_perfil - WHERE tusuario.id_user = '".$config['id_user']."' AND (sec = '*' OR sec = 'head_search')"); - } - if ($acl_head_search) { - $table->data[0][11] = ui_print_help_tip (__("Blank characters are used as AND conditions"), true); - - // Search bar - $search_bar = '<form method="get" style="display: inline;" name="quicksearch" action="">'; - if (!isset($config['search_keywords'])) { - $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; - } - else { - if (strlen($config['search_keywords']) == 0) - $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; - else - $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = false; </script>'; - } - - $search_bar .= '<input type="text" id="keywords" name="keywords"'; - if (!isset($config['search_keywords'])) - $search_bar .= "value='" . __("Enter keywords to search") . "'"; - else if (strlen($config['search_keywords']) == 0) - $search_bar .= "value='" . __("Enter keywords to search") . "'"; - else - $search_bar .= "value='" . $config['search_keywords'] . "'"; - - $search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" + WHERE tusuario.id_user = '".$config['id_user']."' AND (sec = '*' OR sec = 'head_search')" + ); + } + + if ($acl_head_search) { + $table->data[0][11] = ui_print_help_tip(__('Blank characters are used as AND conditions'), true); + + // Search bar + $search_bar = '<form method="get" style="display: inline;" name="quicksearch" action="">'; + if (!isset($config['search_keywords'])) { + $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; + } else { + if (strlen($config['search_keywords']) == 0) { + $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = true; </script>'; + } else { + $search_bar .= '<script type="text/javascript"> var fieldKeyWordEmpty = false; </script>'; + } + } + + $search_bar .= '<input type="text" id="keywords" name="keywords"'; + if (!isset($config['search_keywords'])) { + $search_bar .= "value='".__('Enter keywords to search')."'"; + } else if (strlen($config['search_keywords']) == 0) { + $search_bar .= "value='".__('Enter keywords to search')."'"; + } else { + $search_bar .= "value='".$config['search_keywords']."'"; + } + + $search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" onkeyup="javascript: fieldKeyWordEmpty = false;" style="margin-top:5px;" class="search_input" />'; - - //$search_bar .= 'onClick="javascript: document.quicksearch.submit()"'; - - $search_bar .= "<input type='hidden' name='head_search_keywords' value='abc' />"; - $search_bar .= '</form>'; - - $table->data[0]['searchbar'] = $search_bar; - } - - // Servers check - $servers = array(); - $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, array("alt" => 'cross', "class" => 'bot', 'title' => __('All systems').': '.__('Down'))); - } - elseif ($servers["down"] != 0) { - //Some servers down - $servers_check_img = html_print_image("images/header_warning.png", true, array("alt" => 'error', "class" => 'bot', 'title' => $servers["down"].' '.__('servers down'))); - } - else { - //All servers up - $servers_check_img = html_print_image("images/header_ready.png", true, array("alt" => 'ok', "class" => 'bot', 'title' => __('All systems').': '.__('Ready'))); - } - unset ($servers); // Since this is the header, we don't like to trickle down variables. - - $servers_link_open = '<a class="white" href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60">'; - $servers_link_close = '</a>'; - - if ($config['show_qr_code_header'] == 0){ - $show_qr_code_header = 'display: none;'; - } - else { - $show_qr_code_header = 'display: inline;'; - } - - $table->data[0]['qr'] = - '<div style="' . $show_qr_code_header . '" id="qr_code_container" style="">' . - '<a href="javascript: show_dialog_qrcode();">' . - html_print_image( - "images/qrcode_icon.png", - true, - array("alt" => __('QR Code of the page'), - 'title' => __('QR Code of the page'))) . - '</a>' . - '</div>'; - - echo "<div style='display: none;' id='qrcode_container' title='" . __('QR code of the page') . "'>"; - echo "<div id='qrcode_container_image'></div>"; - echo "</div>"; - ?> - <script type='text/javascript'> - $(document).ready(function() { - $( "#qrcode_container" ).dialog({ - autoOpen: false, - modal: true - }); - }); - </script> - <?php - - if ($config['tutorial_mode'] !== 'expert' && !$config['disable_help']) { - $table->data[0]['clippy'] = - '<a href="javascript: show_clippy();">' . - html_print_image( - "images/clippy_icon.png", - true, - array("id" => 'clippy', - "class" => 'clippy', - "alt" => __('%s assistant', get_product_name()), - 'title' => __('%s assistant', get_product_name()))) . - '</a>'; - } - - - $table->data[0][0] = $servers_link_open . - $servers_check_img . $servers_link_close; - - - - - //======= Autorefresh code ============================= - $autorefresh_txt = ''; - $autorefresh_additional = ''; - - $ignored_params = array ('agent_config' => false, 'code' => false); - - if (!isset($_GET['sec2'])) { - $_GET['sec2'] = ''; - } - if (!isset($_GET['refr'])) { - $_GET['refr'] = null; - } - - $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '" . $config['id_user'] . "'"); - $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); - - if ($autorefresh_list !== null && array_search($_GET['sec2'], $autorefresh_list) !== false) { - $do_refresh = true; - if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { - if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { - $do_refresh = false; - } - } - if ($do_refresh) { - $autorefresh_img = html_print_image("images/header_refresh.png", true, array("class" => 'bot', "alt" => 'lightning', 'title' => __('Configure autorefresh'))); - - if ($_GET['refr']) { - $autorefresh_txt .= ' (<span id="refrcounter">'.date ("i:s", $config["refr"]).'</span>)'; - } - - $ignored_params['refr'] = ''; - $values = get_refresh_time_array(); - $autorefresh_additional = '<span id="combo_refr" style="display: none;">'; - $autorefresh_additional .= html_print_select ($values, 'ref', '', '', __('Select'), '0', true, false, false); - $autorefresh_additional .= '</span>'; - unset ($values); - - $autorefresh_link_open_img = - '<a class="white autorefresh" href="' . ui_get_url_refresh ($ignored_params) . '">'; - - if ($_GET['refr']) { - $autorefresh_link_open_txt = - '<a class="white autorefresh autorefresh_txt" href="' . ui_get_url_refresh ($ignored_params) . '">'; - } - else { - $autorefresh_link_open_txt = '<a>'; - } - - $autorefresh_link_close = '</a>'; - } - else { - $autorefresh_img = html_print_image("images/header_refresh_disabled.png", true, array("class" => 'bot autorefresh_disabled', "alt" => 'lightning', 'title' => __('Disabled autorefresh'))); - - $ignored_params['refr'] = false; - - $autorefresh_link_open_img = ''; - $autorefresh_link_open_txt = ''; - $autorefresh_link_close = ''; - } - } - else { - $autorefresh_img = html_print_image("images/header_refresh_disabled.png", true, array("class" => 'bot autorefresh_disabled', "alt" => 'lightning', 'title' => __('Disabled autorefresh'))); - - $ignored_params['refr'] = false; - - $autorefresh_link_open_img = ''; - $autorefresh_link_open_txt = ''; - $autorefresh_link_close = ''; - } - - $table->data[0][1] = $autorefresh_link_open_img . $autorefresh_img . $autorefresh_link_close; - $table->data[0][2] = $autorefresh_link_open_txt . $autorefresh_txt . $autorefresh_link_close . $autorefresh_additional; - //====================================================== - - - $check_minor_release_available = false; - $pandora_management = check_acl($config['id_user'], 0, "PM"); - - $check_minor_release_available = db_check_minor_relase_available (); - - if ($check_minor_release_available) { - if (users_is_admin($config['id_user'])) { - - if($config['language'] == 'es'){ - set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Actualizacion#Versi.C3.B3n_7.0NG_.28_Rolling_Release_.29">'.__('Sobre actualización de revisión menor').'</a>', 'Revisión/es menor/es disponible/s'); - } - else{ - set_pandora_error_for_header('There are one or more minor releases waiting for update. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Anexo_Upgrade#Version_7.0NG_.28_Rolling_Release_.29">'.__('About minor release update').'</a>', 'minor release/s available'); - } - } - } - echo '<div id="alert_messages" style="display: none"></div>'; + // $search_bar .= 'onClick="javascript: document.quicksearch.submit()"'; + $search_bar .= "<input type='hidden' name='head_search_keywords' value='abc' />"; + $search_bar .= '</form>'; - if ($config["alert_cnt"] > 0) { - $maintenance_link = 'javascript:'; - $maintenance_title = __("System alerts detected - Please fix as soon as possible"); - $maintenance_class = $maintenance_id = 'show_systemalert_dialog white'; - - $maintenance_link_open_txt = - '<a href="' . $maintenance_link . '" title="' . $maintenance_title . '" class="' . $maintenance_class . '" id="show_systemalert_dialog">'; - $maintenance_link_open_img = - '<a href="' . $maintenance_link . '" title="' . $maintenance_title . '" class="' . $maintenance_class . '">'; - $maintenance_link_close = '</a>'; - if (!$pandora_management) { - $maintenance_img = ''; - } - else { - $maintenance_img = $maintenance_link_open_img . - html_print_image("images/header_yellow.png", - true, array( - "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, array ("title" => __('There are not warnings'), "id" => "yougotalert", "class" => "bot")); - } - } - - $table->data[0][3] = $maintenance_img; - - // Main help icon - if (!$config['disable_help']) { - $table->data[0][4] = - '<a href="#" class="modalpopup" id="helpmodal">' . - html_print_image("images/header_help.png", true, array( - "title" => __('Main help'), - "id" => "helpmodal", - "class" => "modalpopup")) . - '</a>'; - } - - // Logout - $table->data[0][5] = '<a class="white" href="' . ui_get_full_url('index.php?bye=bye') . '">'; - $table->data[0][5] .= html_print_image("images/header_logout.png", true, array("alt" => __('Logout'), "class" => 'bot', "title" => __('Logout'))); - $table->data[0][5] .= '</a>'; - - // User - if (is_user_admin ($config["id_user"]) == 1) - $table->data[0][6] = html_print_image("images/header_user_admin.png" , true, array("title" => __('Edit my user'), "class" => 'bot', "alt" => 'user')); - else - $table->data[0][6] = html_print_image("images/header_user.png" , true, array("title" => __('Edit my user'), "class" => 'bot', "alt" => 'user')); - - $table->data[0][6] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit">' . $table->data[0][6] . '</a>'; - - $table->data[0][7] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit" class="white_bold"> (' . $config["id_user"] . ')</a>'; - - // Chat messages - $table->data[0][8] = "<span id='icon_new_messages_chat' style='display: none;'>"; - $table->data[0][8] .= "<a href='index.php?sec=workspace&sec2=operation/users/webchat'>"; - $table->data[0][8] .= html_print_image('images/header_chat.png', true, array("title" => __('New chat message'))); - $table->data[0][8] .= "</a>"; - $table->data[0][8] .= "</span>"; - - // Messages - $msg_cnt = messages_get_count ($config["id_user"]); - if ($msg_cnt > 0) { - echo '<div id="dialog_messages" style="display: none"></div>'; - - $table->data[0][9] = '<a href="ajax.php?page=operation/messages/message_list" title="' . __("Message overview") . '" id="show_messages_dialog">'; - $table->data[0][9] .= html_print_image ("images/header_email.png", true, array ("title" => __('You have %d unread message(s)', $msg_cnt), "id" => "yougotmail", "class" => "bot", 'style' => 'width:24px;')); - $table->data[0][9] .= '</a>'; - } + $table->data[0]['searchbar'] = $search_bar; + } - $table->data[0]['notifications'] = notifications_print_ball(); + // 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')]); + } - html_print_table($table); - - unset($table); - ?> - </td> - <!-- - <td style="text-align:center"> - <?php - echo "<a href='index.php?sec=main'>"; - if (isset($config["custom_logo"])) { - echo html_print_image("images/custom_logo/" . $config["custom_logo"], true, array("height" => '60', "width" => '139', "alt" => 'Logo')); - } - echo "</a>"; - ?> - </td> - --> - </tr> + unset($servers); + // Since this is the header, we don't like to trickle down variables. + $servers_link_open = '<a class="white" href="index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60">'; + $servers_link_close = '</a>'; + + if ($config['show_qr_code_header'] == 0) { + $show_qr_code_header = 'display: none;'; + } else { + $show_qr_code_header = 'display: inline;'; + } + + $table->data[0]['qr'] = '<div style="'.$show_qr_code_header.'" id="qr_code_container" style="">'.'<a href="javascript: show_dialog_qrcode();">'.html_print_image( + 'images/qrcode_icon.png', + true, + [ + 'alt' => __('QR Code of the page'), + 'title' => __('QR Code of the page'), + ] + ).'</a>'.'</div>'; + + echo "<div style='display: none;' id='qrcode_container' title='".__('QR code of the page')."'>"; + echo "<div id='qrcode_container_image'></div>"; + echo '</div>'; + ?> + <script type='text/javascript'> + $(document).ready(function() { + $( "#qrcode_container" ).dialog({ + autoOpen: false, + modal: true + }); + }); + </script> + <?php + if ($config['tutorial_mode'] !== 'expert' && !$config['disable_help']) { + $table->data[0]['clippy'] = '<a href="javascript: show_clippy();">'.html_print_image( + 'images/clippy_icon.png', + true, + [ + 'id' => 'clippy', + 'class' => 'clippy', + 'alt' => __('%s assistant', get_product_name()), + 'title' => __( + '%s assistant', + get_product_name() + ), + ] + ).'</a>'; + } + + + $table->data[0][0] = $servers_link_open.$servers_check_img.$servers_link_close; + + + + + // ======= Autorefresh code ============================= + $autorefresh_txt = ''; + $autorefresh_additional = ''; + + $ignored_params = [ + 'agent_config' => false, + 'code' => false, + ]; + + if (!isset($_GET['sec2'])) { + $_GET['sec2'] = ''; + } + + if (!isset($_GET['refr'])) { + $_GET['refr'] = null; + } + + $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '".$config['id_user']."'"); + $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); + + if ($autorefresh_list !== null && array_search($_GET['sec2'], $autorefresh_list) !== false) { + $do_refresh = true; + if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { + if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { + $do_refresh = false; + } + } + + if ($do_refresh) { + $autorefresh_img = html_print_image('images/header_refresh.png', true, ['class' => 'bot', 'alt' => 'lightning', 'title' => __('Configure autorefresh')]); + + if ($_GET['refr']) { + $autorefresh_txt .= ' (<span id="refrcounter">'.date('i:s', $config['refr']).'</span>)'; + } + + $ignored_params['refr'] = ''; + $values = get_refresh_time_array(); + $autorefresh_additional = '<span id="combo_refr" style="display: none;">'; + $autorefresh_additional .= html_print_select($values, 'ref', '', '', __('Select'), '0', true, false, false); + $autorefresh_additional .= '</span>'; + unset($values); + + $autorefresh_link_open_img = '<a class="white autorefresh" href="'.ui_get_url_refresh($ignored_params).'">'; + + if ($_GET['refr']) { + $autorefresh_link_open_txt = '<a class="white autorefresh autorefresh_txt" href="'.ui_get_url_refresh($ignored_params).'">'; + } else { + $autorefresh_link_open_txt = '<a>'; + } + + $autorefresh_link_close = '</a>'; + } else { + $autorefresh_img = html_print_image('images/header_refresh_disabled.png', true, ['class' => 'bot autorefresh_disabled', 'alt' => 'lightning', 'title' => __('Disabled autorefresh')]); + + $ignored_params['refr'] = false; + + $autorefresh_link_open_img = ''; + $autorefresh_link_open_txt = ''; + $autorefresh_link_close = ''; + } + } else { + $autorefresh_img = html_print_image('images/header_refresh_disabled.png', true, ['class' => 'bot autorefresh_disabled', 'alt' => 'lightning', 'title' => __('Disabled autorefresh')]); + + $ignored_params['refr'] = false; + + $autorefresh_link_open_img = ''; + $autorefresh_link_open_txt = ''; + $autorefresh_link_close = ''; + } + + $table->data[0][1] = $autorefresh_link_open_img.$autorefresh_img.$autorefresh_link_close; + $table->data[0][2] = $autorefresh_link_open_txt.$autorefresh_txt.$autorefresh_link_close.$autorefresh_additional; + // ====================================================== + $check_minor_release_available = false; + $pandora_management = check_acl($config['id_user'], 0, 'PM'); + + $check_minor_release_available = db_check_minor_relase_available(); + + if ($check_minor_release_available) { + if (users_is_admin($config['id_user'])) { + if ($config['language'] == 'es') { + set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Actualizacion#Versi.C3.B3n_7.0NG_.28_Rolling_Release_.29">'.__('Sobre actualización de revisión menor').'</a>', 'Revisión/es menor/es disponible/s'); + } else { + set_pandora_error_for_header('There are one or more minor releases waiting for update. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Anexo_Upgrade#Version_7.0NG_.28_Rolling_Release_.29">'.__('About minor release update').'</a>', 'minor release/s available'); + } + } + } + + echo '<div id="alert_messages" style="display: none"></div>'; + + if ($config['alert_cnt'] > 0) { + $maintenance_link = 'javascript:'; + $maintenance_title = __('System alerts detected - Please fix as soon as possible'); + $maintenance_class = $maintenance_id = 'show_systemalert_dialog white'; + + $maintenance_link_open_txt = '<a href="'.$maintenance_link.'" title="'.$maintenance_title.'" class="'.$maintenance_class.'" id="show_systemalert_dialog">'; + $maintenance_link_open_img = '<a href="'.$maintenance_link.'" title="'.$maintenance_title.'" class="'.$maintenance_class.'">'; + $maintenance_link_close = '</a>'; + if (!$pandora_management) { + $maintenance_img = ''; + } else { + $maintenance_img = $maintenance_link_open_img.html_print_image( + 'images/header_yellow.png', + true, + [ + 'title' => __( + 'You have %d warning(s)', + $config['alert_cnt'] + ), + 'id' => 'yougotalert', + 'class' => 'bot', + ] + ).$maintenance_link_close; + } + } else { + if (!$pandora_management) { + $maintenance_img = ''; + } else { + $maintenance_img = html_print_image('images/header_ready.png', true, ['title' => __('There are not warnings'), 'id' => 'yougotalert', 'class' => 'bot']); + } + } + + $table->data[0][3] = $maintenance_img; + + // Main help icon + if (!$config['disable_help']) { + $table->data[0][4] = '<a href="#" class="modalpopup" id="helpmodal">'.html_print_image( + 'images/header_help.png', + true, + [ + 'title' => __('Main help'), + 'id' => 'helpmodal', + 'class' => 'modalpopup', + ] + ).'</a>'; + } + + $table->data[0]['notifications'] = notifications_print_ball(); + + // Logout + $table->data[0][5] = '<a class="white" href="'.ui_get_full_url('index.php?bye=bye').'">'; + $table->data[0][5] .= html_print_image('images/header_logout.png', true, ['alt' => __('Logout'), 'class' => 'bot', 'title' => __('Logout')]); + $table->data[0][5] .= '</a>'; + + // User + if (is_user_admin($config['id_user']) == 1) { + $table->data[0][6] = html_print_image('images/header_user_admin.png', true, ['title' => __('Edit my user'), 'class' => 'bot', 'alt' => 'user']); + } else { + $table->data[0][6] = html_print_image('images/header_user.png', true, ['title' => __('Edit my user'), 'class' => 'bot', 'alt' => 'user']); + } + + $table->data[0][6] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit">'.$table->data[0][6].'</a>'; + + $table->data[0][7] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit" class="white_bold"> ('.$config['id_user'].')</a>'; + + // Chat messages + $table->data[0][8] = "<span id='icon_new_messages_chat' style='display: none;'>"; + $table->data[0][8] .= "<a href='index.php?sec=workspace&sec2=operation/users/webchat'>"; + $table->data[0][8] .= html_print_image('images/header_chat.png', true, ['title' => __('New chat message')]); + $table->data[0][8] .= '</a>'; + $table->data[0][8] .= '</span>'; + + // Messages + $msg_cnt = messages_get_count($config['id_user']); + if ($msg_cnt > 0) { + echo '<div id="dialog_messages" style="display: none"></div>'; + + $table->data[0][9] = '<a href="ajax.php?page=operation/messages/message_list" title="'.__('Message overview').'" id="show_messages_dialog">'; + $table->data[0][9] .= html_print_image('images/header_email.png', true, ['title' => __('You have %d unread message(s)', $msg_cnt), 'id' => 'yougotmail', 'class' => 'bot', 'style' => 'width:24px;']); + $table->data[0][9] .= '</a>'; + } + + html_print_table($table); + + unset($table); + ?> + </td> + <!-- + <td style="text-align:center"> + <?php + echo "<a href='index.php?sec=main'>"; + if (isset($config['custom_logo'])) { + echo html_print_image('images/custom_logo/'.$config['custom_logo'], true, ['height' => '60', 'width' => '139', 'alt' => 'Logo']); + } + + echo '</a>'; + ?> + </td> + --> + </tr> </table> <script type="text/javascript"> - /* <![CDATA[ */ - - <?php - $config_fixed_header = false; - if (isset($config['fixed_header'])) { - $config_fixed_header = $config['fixed_header']; - } - ?> - - var fixed_header = <?php echo json_encode((bool)$config_fixed_header); ?>; - - var new_chat = <?php echo (int)$_SESSION['new_chat'];?>; - $(document).ready (function () { - <?php - if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET["refr"]))) { - $do_refresh = true; - if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { - if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { - $do_refresh = false; - } - } - - $new_dashboard = get_parameter('new_dashboard',0); - - if ($_GET['sec2'] == 'enterprise/dashboard/main_dashboard' && $new_dashboard) { - $do_refresh = false; - } + /* <![CDATA[ */ + + <?php + $config_fixed_header = false; + if (isset($config['fixed_header'])) { + $config_fixed_header = $config['fixed_header']; + } - if ($do_refresh) { - ?> - $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); - $("#combo_refr").css('padding-right', '9px'); - href = $("a.autorefresh").attr ("href"); - <?php - if($select[0]['time_autorefresh']){ - ?> - var refresh = '<?php echo $select[0]["time_autorefresh"] ?>'; - $(document).attr ("location", href + refresh); - <?php - } - ?> - - <?php - } - } - ?> + ?> - if (fixed_header) { - $('div#head').addClass('fixed_header'); - $('div#page') - .css('padding-top', $('div#head').innerHeight() + 'px') - .css('position', 'relative'); - } - - check_new_chats_icon('icon_new_messages_chat'); - - /* Temporal fix to hide graphics when ui_dialog are displayed */ - $("#yougotalert").click(function () { - $("#agent_access").css("display", "none"); - }); - $("#ui_close_dialog_titlebar").click(function () { - $("#agent_access").css("display",""); - }); - - function blinkmail(){ - $("#yougotmail").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkmail); - } - function blinkalert(){ - $("#yougotalert").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkalert); - } - function blinkpubli(){ - $(".publienterprise").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkpubli); - } - <?php - if ($msg_cnt > 0) { - ?> - blinkmail(); - <?php - } - ?> - - - <?php - if ($config["alert_cnt"] > 0) { - ?> - blinkalert(); - <?php - } - ?> - blinkpubli(); + function addNotifications(event) { + var elements = document.getElementsByClassName("notification-wrapper"); + if (!elements) return; + Array.prototype.forEach.call(elements, function(elem) { + toggle_element(elem); + }); + attatch_to_image(); + } - <?php - if ($_GET["refr"]) { - ?> - var refr_time = <?php echo (int) get_parameter("refr", 0); ?>; - var t = new Date(); - t.setTime (t.getTime () + - parseInt(<?php echo $config["refr"] * 1000; ?>)); - $("#refrcounter").countdown ({until: t, - layout: '%M%nn%M:%S%nn%S', - labels: ['', '', '', '', '', '', ''], - onExpiry: function () { - href = $("a.autorefresh").attr ("href"); - href = href + refr_time; - $(document).attr ("location", href); - } - }); - <?php - } - ?> - - $("a.autorefresh").click (function () { - $("a.autorefresh_txt").toggle (); - $("#combo_refr").toggle (); - $("#combo_refr").css('padding-right', '9px'); - $("select#ref").change (function () { - href = $("a.autorefresh").attr ("href"); - $(document).attr ("location", href + this.value); - }); - - return false; - }); - }); + function attatch_to_image() { + var notification_elems = document.getElementsByClassName("notification-wrapper"); + var image_attached = document.getElementById("notification-ball-header").getBoundingClientRect().left; + Array.prototype.forEach.call(notification_elems, function(elem) { + elem.style.left = image_attached - 300 + "px"; + }); + } + function toggle_element(elem) { + elem.style.display = elem.style.display === "none" ? "block" : "none"; + } + + // Resize event + window.addEventListener("resize", function() { + attatch_to_image(); + }); + + var fixed_header = <?php echo json_encode((bool) $config_fixed_header); ?>; + + var new_chat = <?php echo (int) $_SESSION['new_chat']; ?>; + $(document).ready (function () { + <?php + if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET['refr']))) { + $do_refresh = true; + if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { + if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { + $do_refresh = false; + } + } + + $new_dashboard = get_parameter('new_dashboard', 0); + + if ($_GET['sec2'] == 'enterprise/dashboard/main_dashboard' && $new_dashboard) { + $do_refresh = false; + } + + if ($do_refresh) { + ?> + $("a.autorefresh_txt").toggle (); + $("#combo_refr").toggle (); + $("#combo_refr").css('padding-right', '9px'); + href = $("a.autorefresh").attr ("href"); + <?php + if ($select[0]['time_autorefresh']) { + ?> + var refresh = '<?php echo $select[0]['time_autorefresh']; ?>'; + $(document).attr ("location", href + refresh); + <?php + } + ?> + + <?php + } + } + ?> + + if (fixed_header) { + $('div#head').addClass('fixed_header'); + $('div#page') + .css('padding-top', $('div#head').innerHeight() + 'px') + .css('position', 'relative'); + } + + check_new_chats_icon('icon_new_messages_chat'); + + /* Temporal fix to hide graphics when ui_dialog are displayed */ + $("#yougotalert").click(function () { + $("#agent_access").css("display", "none"); + }); + $("#ui_close_dialog_titlebar").click(function () { + $("#agent_access").css("display",""); + }); + + function blinkmail(){ + $("#yougotmail").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkmail); + } + function blinkalert(){ + $("#yougotalert").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkalert); + } + function blinkpubli(){ + $(".publienterprise").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkpubli); + } + <?php + if ($msg_cnt > 0) { + ?> + blinkmail(); + <?php + } + ?> + + + <?php + if ($config['alert_cnt'] > 0) { + ?> + blinkalert(); + <?php + } + ?> + blinkpubli(); + + <?php + if ($_GET['refr']) { + ?> + var refr_time = <?php echo (int) get_parameter('refr', 0); ?>; + var t = new Date(); + t.setTime (t.getTime () + + parseInt(<?php echo ($config['refr'] * 1000); ?>)); + $("#refrcounter").countdown ({until: t, + layout: '%M%nn%M:%S%nn%S', + labels: ['', '', '', '', '', '', ''], + onExpiry: function () { + href = $("a.autorefresh").attr ("href"); + href = href + refr_time; + $(document).attr ("location", href); + } + }); + <?php + } + ?> + + $("a.autorefresh").click (function () { + $("a.autorefresh_txt").toggle (); + $("#combo_refr").toggle (); + $("#combo_refr").css('padding-right', '9px'); + $("select#ref").change (function () { + href = $("a.autorefresh").attr ("href"); + $(document).attr ("location", href + this.value); + }); + + return false; + }); + }); /* ]]> */ </script> + +<?php +echo notifications_print_dropdown(); diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 7552dc74f2..1062b8fa48 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -411,18 +411,20 @@ function messages_get_count_sent(string $user='') /** * Get message overview in array * - * @param string $order How to order them valid: - * (status (default), subject, timestamp, sender). - * @param string $order_dir Direction of order - * (ASC = Ascending, DESC = Descending). - * @param boolean $incl_read Include read messages in return. + * @param string $order How to order them valid: + * (status (default), subject, timestamp, sender). + * @param string $order_dir Direction of order + * (ASC = Ascending, DESC = Descending). + * @param boolean $incl_read Include read messages in return. + * @param boolean $incl_source_info Include source info. * * @return integer The number of messages this user has */ function messages_get_overview( string $order='status', string $order_dir='ASC', - bool $incl_read=true + bool $incl_read=true, + bool $incl_source_info=false ) { global $config; @@ -453,21 +455,32 @@ function messages_get_overview( $read = 'where t.read is null'; } + $source_fields = ''; + $source_join = ''; + if ($incl_source_info) { + $source_fields = ', tns.*'; + $source_join = 'INNER JOIN tnotification_source tns + ON tns.id=tm.id_source'; + } + $sql = sprintf( 'SELECT * FROM ( - SELECT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + SELECT tm.*, utimestamp_read > 0 as "read" %s FROM tmensajes tm LEFT JOIN tnotification_user nu ON tm.id_mensaje=nu.id_mensaje LEFT JOIN (tnotification_group ng INNER JOIN tusuario_perfil up ON ng.id_group=up.id_grupo AND up.id_grupo=ng.id_group - ) ON tm.id_mensaje=ng.id_mensaje + ) ON tm.id_mensaje=ng.id_mensaje + %s WHERE utimestamp_erased is null AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0) ) t %s ORDER BY %s', + $source_fields, + $source_join, $config['id_user'], $config['id_user'], $read, diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 7f82908aab..ad3e8953ad 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -523,6 +523,11 @@ function notifications_set_user_label_status($source, $user, $label, $value) } +// ///////////////////////////////////////////////////////////////////////////// +// UI FUNCTIONS +// ///////////////////////////////////////////////////////////////////////////// + + /** * Print the notification ball to see unread messages. * @@ -533,7 +538,11 @@ function notifications_print_ball() $num_notifications = messages_get_count(); $class_status = ($num_notifications == 0) ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; return sprintf( - '<div class="notification-ball %s" id="notification-ball-header"> + '<div + onclick="addNotifications(event)" + class="notification-ball %s" + id="notification-ball-header" + > %s </div>', $class_status, @@ -807,3 +816,58 @@ function notifications_print_user_switch($source, $user, $label) ] ); } + + +/** + * Generates the dropdown notifications menu. + * + * @return string HTML with dropdown menu. + */ +function notifications_print_dropdown() +{ + $mess = messages_get_overview('status', 'DESC', false, true); + if ($mess === false) { + $mess = []; + } + + return sprintf( + "<div class='notification-wrapper' style='display:none;'> + %s + </div>", + array_reduce( + $mess, + function ($carry, $message) { + return $carry.notifications_print_dropdown_element($message); + }, + '' + ) + ); +} + + +/** + * Print a single notification box + * + * @param array $message_info Info of printed message. + * + * @return string HTML code of single message + */ +function notifications_print_dropdown_element($message_info) +{ + return sprintf( + "<div class='notification-item'> + <img src='%s'> + <div class='notification-info'> + <h4 class='notification-title'> + %s + </h4> + <p class='notification-subtitle'> + %s + </p> + </div> + </div>", + html_print_image('images/'.$message_info['icon'], true), + $message_info['description'], + $message_info['mensaje'] + ); +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index cc6545fc87..00ac3161fb 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4929,6 +4929,59 @@ div#dialog_messages table th:last-child { background-color: #fc4444; } +.notification-wrapper { + background: white; + border: #a5a5a5 solid 1px; + z-index: 900000; + position: absolute; + width: 400px; + margin-top: -5px; +} +.notification-wrapper::before { + content: ""; + display: block; + position: absolute; + width: 0px; + height: 0; + border-color: transparent; + border-width: 12px; + border-style: solid; + bottom: 100%; + left: 78%; + left: calc(78% - 2px); + margin-left: -12px; + border-bottom-color: white; +} +.notification-item { + background: whitesmoke; + height: 100px; + margin: 7px; + border: #cccccc solid 1px; + display: flex; + flex-flow: row nowrap; + align-items: center; +} +.notification-item > * { + padding-left: 15px; +} + +.notification-info { + width: 87%; + display: flex; + flex-flow: column nowrap; +} +.notification-item img { + max-width: 100%; + max-height: 100%; +} +.notification-title { + margin: 0; +} +.notification-subtitle { + margin: 0; + color: #373737; +} + .global-config-notification-title { display: flex; flex-direction: row; From a3a1bbb778904923de620079009100e1e389a0bd Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Fri, 8 Feb 2019 17:30:13 +0100 Subject: [PATCH 049/262] added missed new field extended_info for events Former-commit-id: 8edb7cb854364259ffca27585e423464d213137a --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 ++ pandora_console/pandoradb.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index f1d1d4dd23..d02beda560 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1856,6 +1856,8 @@ ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; +ALTER TABLE `tevento` ADD COLUMN `extended_info` tinyint(1) NOT NULL default '0'; + -- --------------------------------------------------------------------- -- Table `tevent_extended` -- --------------------------------------------------------------------- diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 874f8b0bb6..b596dd4411 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -644,6 +644,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `custom_data` TEXT NOT NULL, `data` double(22,5) default NULL, `module_status` int(4) NOT NULL default '0', + `extended_info` tinyint(1) NOT NULL default '0' PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`), From 091f6ace96302cf25688d69845733cbaeb8cf42d Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Fri, 8 Feb 2019 17:30:47 +0100 Subject: [PATCH 050/262] minor fixes and revised code style Former-commit-id: aad587c578de99432dd759d6c82b622f6cd6c6e7 --- pandora_console/include/ajax/events.php | 130 +- pandora_console/include/functions_events.php | 1765 +++++++++++------- 2 files changed, 1207 insertions(+), 688 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 5f6f62568b..77930e3e50 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -1,16 +1,31 @@ <?php +/** + * Manage AJAX response for event pages. + * + * @category Ajax + * @package Pandora FMS + * @subpackage Events + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation for version 2. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. require_once 'include/functions_events.php'; require_once 'include/functions_agents.php'; require_once 'include/functions_ui.php'; @@ -210,11 +225,14 @@ if ($dialogue_event_response) { $prompt = '<br>> '; switch ($event_response['type']) { case 'command': - - if ($massive) { echo "<div style='text-align:left'>"; - echo $prompt.sprintf("(Event #$event_id) ".__('Executing command: %s', $command)); + echo $prompt.sprintf( + '(Event #'.$event_id.') '.__( + 'Executing command: %s', + $command + ) + ); echo '</div><br>'; echo "<div id='response_loading_command_".$out_iterator."' style='display:none'>".html_print_image('images/spinner.gif', true).'</div>'; @@ -242,7 +260,11 @@ if ($dialogue_event_response) { case 'url': $command = str_replace('localhost', $_SERVER['SERVER_NAME'], $command); - echo "<iframe src='$command' id='divframe' style='width:100%;height:90%;'></iframe>"; + echo "<iframe src='".$command."' id='divframe' style='width:100%;height:90%;'></iframe>"; + break; + + default: + // Ignore. break; } } @@ -319,10 +341,10 @@ if ($get_extended_event) { $readonly = true; } - // Clean url from events and store in array + // Clean url from events and store in array. $event['clean_tags'] = events_clean_tags($event['tags']); - // If the event is not found, we abort + // If the event is not found, we abort. if (empty($event)) { ui_print_error_message('Event not found'); return false; @@ -341,34 +363,38 @@ if ($get_extended_event) { $event['timestamp_last'] = $timestamp_last; $event['event_rep'] = $event_rep; - // Check ACLs + // Check ACLs. if (is_user_admin($config['id_user'])) { - // Do nothing if you're admin, you get full access + // Do nothing if you're admin, you get full access. + $__ignored_line = 0; } else if ($config['id_user'] == $event['owner_user']) { - // Do nothing if you're the owner user, you get access + // Do nothing if you're the owner user, you get access. + $__ignored_line = 0; } else if ($event['id_grupo'] == 0) { - // If the event has access to all groups, you get access + // If the event has access to all groups, you get access. + $__ignored_line = 0; } else { - // Get your groups + // Get your groups. $groups = users_get_groups($config['id_user'], 'ER'); if (in_array($event['id_grupo'], array_keys($groups))) { - // If the event group is among the groups of the user, you get access + // If event group is among the groups of the user, you get access. + $__ignored_line = 0; } else { - // If all the access types fail, abort + // If all the access types fail, abort. echo 'Access denied'; return false; } } - // Print group_rep in a hidden field to recover it from javascript + // Print group_rep in a hidden field to recover it from javascript. html_print_input_hidden('group_rep', (int) $group_rep); if ($event === false) { return; } - // Tabs + // Tabs. $tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>"; $tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>'; $tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Details').'</span></a></li>'; @@ -376,7 +402,19 @@ if ($get_extended_event) { $tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Comments').'</span></a></li>'; if (!$readonly - && ((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids))) + && ((tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EM', + $event['clean_tags'], + $childrens_ids + )) || (tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EW', + $event['clean_tags'], + $childrens_ids + ))) ) { $tabs .= "<li><a href='#extended_event_responses_page' id='link_responses'>".html_print_image('images/event_responses_col.png', true)."<span style='position:relative;top:-6px;left:3px;margin-right:10px;'>".__('Responses').'</span></a></li>'; } @@ -387,7 +425,7 @@ if ($get_extended_event) { $tabs .= '</ul>'; - // Get criticity image + // Get criticity image. switch ($event['criticity']) { default: case 0: @@ -419,7 +457,19 @@ if ($get_extended_event) { } if (!$readonly - && ((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids))) + && ((tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EM', + $event['clean_tags'], + $childrens_ids + )) || (tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EW', + $event['clean_tags'], + $childrens_ids + ))) ) { $responses = events_page_responses($event, $childrens_ids); } else { @@ -427,7 +477,7 @@ if ($get_extended_event) { } $console_url = ''; - // If metaconsole switch to node to get details and custom fields + // If metaconsole switch to node to get details and custom fields. if ($meta) { $server = metaconsole_get_connection_by_id($server_id); metaconsole_connect($server); @@ -437,7 +487,8 @@ if ($get_extended_event) { $details = events_page_details($event, $server); - // Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct node connection was lost + // Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct + // node connection was lost. if ($meta) { $server = metaconsole_get_connection_by_id($server_id); metaconsole_connect($server); @@ -472,7 +523,7 @@ if ($get_extended_event) { }); '; - // Load the required tab + // Load the required tab. switch ($dialog_page) { case 'general': $js .= '$tabs.tabs( "option", "active", 0);'; @@ -497,6 +548,10 @@ if ($get_extended_event) { case 'custom_data': $js .= '$tabs.tabs( "option", "active", 5);'; break; + + default: + // Ignore. + break; } $js .= ' @@ -543,6 +598,10 @@ if ($get_events_details) { $img = ui_get_full_url('images/hourglass.png', false, false, false); $title = __('Event in process'); break; + + default: + // Ignore. + break; } $out .= '<tr class="'.get_priority_class($event['criticity']).'" style="height: 25px;">'; @@ -594,7 +653,8 @@ if ($table_events) { $id_agente = (int) get_parameter('id_agente', 0); $all_events_24h = (int) get_parameter('all_events_24h', 0); - // Fix: for tag functionality groups have to be all user_groups (propagate ACL funct!) + // Fix: for tag functionality groups have to be all user_groups + // (propagate ACL funct!). $groups = users_get_groups($config['id_user']); $tags_condition = tags_get_acl_tags( @@ -612,7 +672,7 @@ if ($table_events) { if ($all_events_24h) { events_print_event_table( - "utimestamp > $date_subtract_day", + 'utimestamp > '.$date_subtract_day, 200, '100%', false, @@ -621,7 +681,7 @@ if ($table_events) { ); } else { events_print_event_table( - "estado <> 1 $tags_condition", + 'estado <> 1 '.$tags_condition, 200, '100%', false, diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f3f3d2b0fa..8ff58d8d8b 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1,17 +1,32 @@ <?php +/** + * Events library. + * + * @category Library + * @package Pandora FMS + * @subpackage Events + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-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 Lesser General Public License -// as published by the Free Software Foundation; version 2 -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -require_once $config['homedir'].'/include/functions_ui.php'; + require_once $config['homedir'].'/include/functions_ui.php'; require_once $config['homedir'].'/include/functions_tags.php'; require_once $config['homedir'].'/include/functions.php'; enterprise_include_once('meta/include/functions_events_meta.php'); @@ -20,11 +35,10 @@ enterprise_include_once('meta/include/functions_modules_meta.php'); /** - * @package Include - * @subpackage Events + * Return all header string for each event field. + * + * @return array */ - - function events_get_all_fields() { $columns = []; @@ -59,23 +73,36 @@ function events_get_all_fields() * Get all rows of events from the database, that * pass the filter, and can get only some fields. * - * @param mixed 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: - * <code> - * 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: + * <code> + * 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' + * ); + * </code>. + * @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'); - * </code> - * @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, @@ -166,101 +225,39 @@ function events_get_events_grouped( $groupby_extra = ''; } - switch ($config['dbtype']) { - case 'mysql': - db_process_sql('SET group_concat_max_len = 9999999'); - $event_lj = events_get_secondary_groups_left_join($table); - if ($total) { - $sql = "SELECT COUNT(*) FROM (SELECT * - FROM $table te $event_lj - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra.') AS t'; - } else { - $sql = "SELECT *, MAX(id_evento) AS id_evento, - GROUP_CONCAT(DISTINCT user_comment SEPARATOR '<br>') AS user_comment, - GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, - COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, - MIN(utimestamp) AS timestamp_rep_min, - (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, - (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, - (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, - (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, - (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp, - (SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name - FROM $table te $event_lj - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra; - $sql .= ' '.events_get_sql_order($sort_field, $order, 2); - $sql .= ' LIMIT '.$offset.','.$pagination; - } - break; - - case 'postgresql': - if ($total) { - $sql = "SELECT COUNT(*) - FROM $table te - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra'.$groupby_extra; - } else { - $sql = "SELECT *, MAX(id_evento) AS id_evento, array_to_string(array_agg(DISTINCT user_comment), '<br>') AS user_comment, - array_to_string(array_agg(DISTINCT id_evento), ',') AS similar_ids, - COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, - MIN(utimestamp) AS timestamp_rep_min, - (SELECT owner_user FROM $table WHERE id_evento = MAX(te.id_evento)) owner_user, - (SELECT id_usuario FROM $table WHERE id_evento = MAX(te.id_evento)) id_usuario, - (SELECT id_agente FROM $table WHERE id_evento = MAX(te.id_evento)) id_agente, - (SELECT criticity FROM $table WHERE id_evento = MAX(te.id_evento)) AS criticity, - (SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp - FROM $table te - WHERE 1=1 ".$sql_post.' - GROUP BY estado, evento, id_agentmodule, id_evento, - id_agente, id_usuario, id_grupo, estado, - timestamp, utimestamp, event_type, id_alert_am, - criticity, user_comment, tags, source, id_extra, - te.critical_instructions, - te.warning_instructions, - te.unknown_instructions, - te.owner_user, - te.ack_utimestamp, - te.custom_data '.$groupby_extra.' - ORDER BY timestamp_rep ASC LIMIT '.$pagination.' OFFSET '.$offset; - } - break; - - case 'oracle': - if ($total) { - $sql = "SELECT COUNT(*) - FROM $table te - WHERE 1=1 $sql_post - GROUP BY estado, to_char(evento), id_agentmodule".$groupby_extra.') b '; - } else { - $set = []; - $set['limit'] = $pagination; - $set['offset'] = $offset; - - $sql = "SELECT ta.*, tb.event_rep, tb.timestamp_rep, tb.timestamp_rep_min, tb.user_comments, tb.similar_ids - FROM $table ta - INNER JOIN (SELECT MAX(id_evento) AS id_evento, COUNT(id_evento) AS event_rep, - MAX(utimestamp) AS timestamp_rep, MIN(utimestamp) AS timestamp_rep_min, - TAB_TO_STRING(CAST(COLLECT(TO_CHAR(user_comment) ORDER BY id_evento ASC) AS t_varchar2_tab), '<br>') AS user_comments, - TAB_TO_STRING(CAST(COLLECT(CAST(id_evento AS VARCHAR2(4000)) ORDER BY id_evento ASC) AS t_varchar2_tab)) AS similar_ids - FROM $table te - WHERE 1=1 $sql_post - GROUP BY estado, to_char(evento), id_agentmodule$groupby_extra) tb - ON ta.id_evento = tb.id_evento - ORDER BY tb.timestamp_rep ASC"; - $sql = oracle_recode_query($sql, $set); - } - break; + db_process_sql('SET group_concat_max_len = 9999999'); + $event_lj = events_get_secondary_groups_left_join($table); + if ($total) { + $sql = 'SELECT COUNT(*) FROM (SELECT * + FROM '.$table.' te '.$event_lj.' + WHERE 1=1 '.$sql_post.' + GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra.') AS t'; + } else { + $sql = "SELECT *, MAX(id_evento) AS id_evento, + GROUP_CONCAT(DISTINCT user_comment SEPARATOR '<br>') AS user_comment, + GROUP_CONCAT(DISTINCT id_evento SEPARATOR ',') AS similar_ids, + COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep, + MIN(utimestamp) AS timestamp_rep_min, + (SELECT owner_user FROM ".$table.' WHERE id_evento = MAX(te.id_evento)) owner_user, + (SELECT id_usuario FROM '.$table.' WHERE id_evento = MAX(te.id_evento)) id_usuario, + (SELECT id_agente FROM '.$table.' WHERE id_evento = MAX(te.id_evento)) id_agente, + (SELECT criticity FROM '.$table.' WHERE id_evento = MAX(te.id_evento)) AS criticity, + (SELECT ack_utimestamp FROM '.$table.' WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp, + (SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = te.id_agentmodule) AS module_name + FROM '.$table.' te '.$event_lj.' + WHERE 1=1 '.$sql_post.' + GROUP BY estado, evento, id_agente, id_agentmodule'.$groupby_extra; + $sql .= ' '.events_get_sql_order($sort_field, $order, 2); + $sql .= ' LIMIT '.$offset.','.$pagination; } - // Extract the events by filter (or not) from db + // Extract the events by filter (or not) from db. $events = db_get_all_rows_sql($sql, $history_db); if ($total) { return reset($events[0]); } else { - // Override the column 'user_comment' with the column 'user_comments' when oracle + // Override the column 'user_comment' with the column 'user_comments' when oracle. if (!empty($events) && $config['dbtype'] == 'oracle') { array_walk( $events, @@ -275,6 +272,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); @@ -287,9 +293,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. */ @@ -299,7 +305,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']); } @@ -331,26 +344,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); @@ -366,7 +386,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 { @@ -376,7 +396,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; } } @@ -393,25 +413,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']; @@ -481,14 +505,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: @@ -499,6 +529,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; } } @@ -511,23 +545,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) { @@ -548,20 +590,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'] = ''; } @@ -582,6 +631,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) { @@ -601,21 +658,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) { @@ -636,25 +702,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'; @@ -672,12 +743,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"], '<br>', $comment); if ($comment != '') { @@ -686,30 +762,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 = '<b>-- '.$action.' by '.$config['id_user'].' '.'['.date($config['date_format']).'] --</b><br>'.$commentbox.'<br>'; + // Don't translate 'by' word because if multiple users with + // different languages make comments in the same console + // will be a mess. + $comment = '<b>-- '.$action.' by '.$config['id_user'].' ['.date($config['date_format']).'] --</b><br>'.$commentbox.'<br>'; - // 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; } @@ -724,13 +796,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 + ); } @@ -743,24 +820,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, @@ -791,206 +881,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'); @@ -998,24 +946,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 == '') { @@ -1063,7 +1019,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;'; } @@ -1098,7 +1056,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')) { @@ -1107,7 +1065,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'; @@ -1123,6 +1081,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( @@ -1167,20 +1129,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] = "<a class='$myclass' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event['id_agente']."'>".agents_get_alias($event['id_agente']).'</A>'; - // for System or SNMP generated alerts + $data[4] = "<a class='".$myclass."' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event['id_agente']."'>".agents_get_alias($event['id_agente']).'</A>'; + // For System or SNMP generated alerts. } else if ($event['event_type'] == 'system') { $data[4] = __('System'); } else { @@ -1188,13 +1155,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); } @@ -1234,16 +1209,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 = ''; @@ -1261,13 +1239,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; @@ -1307,7 +1285,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, @@ -1327,8 +1305,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 */ @@ -1355,13 +1333,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; @@ -1416,9 +1394,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. */ @@ -1438,7 +1422,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; } @@ -1492,9 +1476,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. */ @@ -1528,7 +1523,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; } } @@ -1557,6 +1552,7 @@ function events_get_agent( break; default: + // Ignore. break; } } @@ -1577,12 +1573,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 + ).')'; } } @@ -1591,10 +1591,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') { @@ -1607,7 +1607,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) { @@ -1801,6 +1801,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) @@ -1853,6 +1855,10 @@ function events_get_status($status_id) case 3: $status_desc = __('Only not validated'); break; + + default: + // Ignore. + break; } return $status_desc; @@ -1872,10 +1878,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; } @@ -1896,9 +1902,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. */ @@ -1920,7 +1926,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) @@ -1967,13 +1975,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; @@ -1986,26 +2001,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) { @@ -2015,24 +2047,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'), @@ -2041,7 +2101,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'), @@ -2049,48 +2110,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] = '<form method="post">'; - $data[1] .= html_print_button(__('Delete event'), 'delete_button', false, 'if(!confirm(\''.__('Are you sure?').'\')) { return false; } this.form.submit();', 'class="sub cancel"', true); + $data[1] .= html_print_button( + __('Delete event'), + 'delete_button', + false, + 'if(!confirm(\''.__('Are you sure?').'\')) { return false; } this.form.submit();', + 'class="sub cancel"', + true + ); $data[1] .= html_print_input_hidden('delete', 1, true); - $data[1] .= html_print_input_hidden('validate_ids', $event['id_evento'], true); + $data[1] .= html_print_input_hidden( + 'validate_ids', + $event['id_evento'], + true + ); $data[1] .= '</form>'; $table_responses->data[] = $data; } - // Custom responses + // Custom responses. $data = []; $data[0] = __('Custom responses'); @@ -2126,7 +2238,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; @@ -2161,10 +2280,23 @@ function events_page_responses($event, $childrens_ids=[]) } -// Replace macros in the target of a response and return it -// If server_id > 0, is a metaconsole query -function events_get_response_target($event_id, $response_id, $server_id, $history=false) -{ +/** + * Replace macros in the target of a response and return it. + * If server_id > 0, is a metaconsole query. + * + * @param integer $event_id Event_id. + * @param integer $response_id Response_id. + * @param integer $server_id Server_id. + * @param boolean $history History. + * + * @return string Target. + */ +function events_get_response_target( + $event_id, + $response_id, + $server_id, + $history=false +) { global $config; $event_response = db_get_row('tevent_response', 'id', $response_id); @@ -2181,7 +2313,7 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor $target = io_safe_output($event_response['target']); - // Substitute each macro + // Substitute each macro. if (strpos($target, '_agent_address_') !== false) { if ($meta) { $agente_table_name = 'tmetaconsole_agent'; @@ -2195,7 +2327,7 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor } $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'); } @@ -2266,7 +2398,11 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor } 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) { @@ -2355,12 +2491,17 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor } 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); } - // Parse the event custom data + // Parse the event custom data. if (!empty($event['custom_data'])) { $custom_data = json_decode(base64_decode($event['custom_data'])); foreach ($custom_data as $key => $value) { @@ -2372,12 +2513,19 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor } +/** + * 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; @@ -2418,7 +2566,7 @@ function events_page_custom_fields($event) } foreach ($fields as $field) { - // Owner + // Owner. $data = []; $data[0] = $field['name']; @@ -2443,15 +2591,62 @@ 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', + $id_evento + ) + ); + +} + + +/** + * Generates the 'extended' 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_extended($event, $server='') +{ + $html = ''; + + $data = []; + $data[0] = __('Extended events'); + $data[1] = ''; + + 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) { @@ -2463,7 +2658,7 @@ function events_page_details($event, $server='') } // - // Details + // Details. // $table_details->width = '100%'; $table_details->data = []; @@ -2474,15 +2669,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']); @@ -2490,7 +2690,6 @@ function events_page_details($event, $server='') $agent = []; } - $data = []; $data[0] = __('Agent details'); $data[1] = empty($agent) ? '<i>'.__('N/A').'</i>' : ''; $table_details->data[] = $data; @@ -2499,9 +2698,24 @@ function events_page_details($event, $server='') $data = []; $data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>'; if (can_user_access_node()) { - $data[1] = ui_print_agent_name($event['id_agente'], true, 'agent_medium', '', false, $serverstring, $hashstring, $agent['alias']); + $data[1] = ui_print_agent_name( + $event['id_agente'], + true, + 'agent_medium', + '', + false, + $serverstring, + $hashstring, + $agent['alias'] + ); } else { - $data[1] = ui_print_truncate_text($agent['alias'], 'agent_medium', true, true, true); + $data[1] = ui_print_truncate_text( + $agent['alias'], + 'agent_medium', + true, + true, + true + ); } $table_details->data[] = $data; @@ -2522,22 +2736,35 @@ function events_page_details($event, $server='') $data = []; $data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Last contact').'</div>'; - $data[1] = $agent['ultimo_contacto'] == '1970-01-01 00:00:00' ? '<i>'.__('N/A').'</i>' : date_w_fixed_tz($agent['ultimo_contacto']); + $data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : date_w_fixed_tz($agent['ultimo_contacto']); $table_details->data[] = $data; $data = []; $data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Last remote contact').'</div>'; - $data[1] = $agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00' ? '<i>'.__('N/A').'</i>' : date_w_fixed_tz($agent['ultimo_contacto_remoto']); + $data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : date_w_fixed_tz($agent['ultimo_contacto_remoto']); $table_details->data[] = $data; $data = []; $data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Custom fields').'</div>'; - $data[1] = html_print_button(__('View custom fields'), 'custom_button', false, '$(\'#link_custom_fields\').trigger(\'click\');', 'class="sub next"', true); + $data[1] = html_print_button( + __('View custom fields'), + 'custom_button', + false, + '$(\'#link_custom_fields\').trigger(\'click\');', + 'class="sub next"', + true + ); $table_details->data[] = $data; } if ($event['id_agentmodule'] != 0) { - $module = db_get_row_filter('tagente_modulo', ['id_agente_modulo' => $event['id_agentmodule'], 'delete_pending' => 0]); + $module = db_get_row_filter( + 'tagente_modulo', + [ + 'id_agente_modulo' => $event['id_agentmodule'], + 'delete_pending' => 0, + ] + ); } else { $module = []; } @@ -2548,20 +2775,25 @@ function events_page_details($event, $server='') $table_details->data[] = $data; if (!empty($module)) { - // Module name + // Module name. $data = []; $data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Name').'</div>'; $data[1] = $module['nombre']; $table_details->data[] = $data; - // Module group + // Module group. $data = []; $data[0] = '<div style="font-weight:normal; margin-left: 20px;">'.__('Module group').'</div>'; $id_module_group = $module['id_module_group']; if ($id_module_group == 0) { $data[1] = __('No assigned'); } else { - $module_group = db_get_value('name', 'tmodule_group', 'id_mg', $id_module_group); + $module_group = db_get_value( + 'name', + 'tmodule_group', + 'id_mg', + $id_module_group + ); $data[1] = '<a href="'.$serverstring.'index.php?sec=view&sec2=operation/agentes/status_monitor&status=-1&modulegroup='.$id_module_group.$hashstring.'">'; $data[1] .= $module_group; $data[1] .= '</a>'; @@ -2569,12 +2801,21 @@ function events_page_details($event, $server='') $table_details->data[] = $data; - // ACL + // ACL. $acl_graph = false; - $strict_user = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']); + $strict_user = (bool) db_get_value( + 'strict_acl', + 'tusuario', + 'id_user', + $config['id_user'] + ); if (!empty($agent['id_grupo'])) { - $acl_graph = check_acl($config['id_user'], $agent['id_grupo'], 'RR'); + $acl_graph = check_acl( + $config['id_user'], + $agent['id_grupo'], + 'RR' + ); } if ($acl_graph) { @@ -2587,9 +2828,16 @@ function events_page_details($event, $server='') } $graph_type = return_graphtype($module_type); - $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); - $handle = dechex(crc32($module['id_agente_modulo'].$module['nombre'])); - $win_handle = "day_$handle"; + $url = ui_get_full_url( + 'operation/agentes/stat_win.php', + false, + false, + false + ); + $handle = dechex( + crc32($module['id_agente_modulo'].$module['nombre']) + ); + $win_handle = 'day_'.$handle; $graph_params = [ 'type' => $graph_type, @@ -2600,13 +2848,13 @@ function events_page_details($event, $server='') ]; if (defined('METACONSOLE')) { - // Set the server id + // Set the server id. $graph_params['server'] = $server['id']; } $graph_params_str = http_build_query($graph_params); - $link = "winopeng('$url?$graph_params_str','$win_handle')"; + $link = "winopeng('".$url.'?'.$graph_params_str."','".$win_handle."')"; $data[1] = '<a href="javascript:'.$link.'">'; $data[1] .= html_print_image('images/chart_curve.png', true); @@ -2617,7 +2865,7 @@ function events_page_details($event, $server='') $data = []; $data[0] = __('Alert details'); - $data[1] = $event['id_alert_am'] == 0 ? '<i>'.__('N/A').'</i>' : ''; + $data[1] = ($event['id_alert_am'] == 0) ? '<i>'.__('N/A').'</i>' : ''; $table_details->data[] = $data; if ($event['id_alert_am'] != 0) { @@ -2708,12 +2956,19 @@ function events_page_details($event, $server='') } +/** + * Generates content for 'custom data' page in event viewer. + * + * @param array $event Event. + * + * @return string HTML. + */ function events_page_custom_data($event) { global $config; // - // Custom data + // Custom data. // if ($event['custom_data'] == '') { return ''; @@ -2745,14 +3000,26 @@ function events_page_custom_data($event) } -// Get the event name from tevento and display it in console +/** + * Get the event name from tevento and display it in console. + * + * @param string $db_name Target event name. + * + * @return string Event name. + */ function events_display_name($db_name='') { return io_safe_output(str_replace(' ', '<br>', $db_name)); } -// Get the image and status value of event +/** + * Get the image and status value of event. + * + * @param integer $status Status. + * + * @return string Image path. + */ function events_display_status($status) { switch ($status) { @@ -2773,15 +3040,26 @@ function events_display_status($status) 'img' => 'images/hourglass.png', 'title' => __('Event in process'), ]; + + default: + // Ignore. + break; } } -// Get the instruction of an event -// $event_type: Type of event -// $inst: Array with unknown warning and critical instructions -// $italic: Display N/A between italic html marks if instruction is not found -function events_display_instructions($event_type='', $inst, $italic=true) +/** + * Get the instruction of an event. + * + * @param string $event_type Type of event. + * @param array $inst Array with unknown warning and critical + * instructions. + * @param boolean $italic Display N/A between italic html marks if + * instruction is not found. + * + * @return string Safe output. + */ +function events_display_instructions($event_type='', $inst=[], $italic=true) { switch ($event_type) { case 'going_unknown': @@ -2818,23 +3096,39 @@ function events_display_instructions($event_type='', $inst, $italic=true) return str_replace("\n", '<br>', io_safe_output($inst['unknown_instructions'])); } break; + + default: + // Ignore. + break; } - $na_return = $italic ? '<i>'.__('N/A').'</i>' : __('N/A'); + $na_return = ($italic === true) ? '<i>'.__('N/A').'</i>' : __('N/A'); + return $na_return; } +/** + * Generates 'general' page for events viewer. + * + * @param array $event Event. + * + * @return string HTML. + */ function events_page_general($event) { global $img_sev; global $config; - // $group_rep = $event['similar_ids'] == -1 ? 1 : count(explode(',',$event['similar_ids'])); + /* + Commented out (old) + // $group_rep = $event['similar_ids'] == -1 ? 1 : count(explode(',',$event['similar_ids'])); + */ + global $group_rep; // - // General + // General. // $table_general->cellspacing = 2; $table_general->cellpadding = 2; @@ -2885,7 +3179,10 @@ function events_page_general($event) $data = []; $data[0] = __('Type'); - $data[1] = events_print_type_img($event['event_type'], true).' '.events_print_type_description($event['event_type'], true); + $data[1] = events_print_type_img( + $event['event_type'], + true + ).' '.events_print_type_description($event['event_type'], true); $table_general->data[] = $data; $data = []; @@ -2919,7 +3216,7 @@ function events_page_general($event) $data[1] .= ' '.$event_criticity; $table_general->data[] = $data; - // Get Status + // Get Status. $event_st = events_display_status($event['estado']); $data = []; @@ -2927,7 +3224,7 @@ function events_page_general($event) $data[1] = html_print_image($event_st['img'], true).' '.$event_st['title']; $table_general->data[] = $data; - // If event is validated, show who and when acknowleded it + // If event is validated, show who and when acknowleded it. $data = []; $data[0] = __('Acknowledged by'); @@ -2984,10 +3281,18 @@ function events_page_general($event) } +/** + * Generate 'comments' page for event viewer. + * + * @param array $event Event. + * @param array $childrens_ids Children ids. + * + * @return string HTML. + */ function events_page_comments($event, $childrens_ids=[]) { // - // Comments + // Comments. // global $config; @@ -3001,13 +3306,13 @@ function events_page_comments($event, $childrens_ids=[]) $event_comments = $event['user_comment']; $event_comments = str_replace(["\n", ' '], '<br>', $event_comments); - // 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, true); - // Show the comments more recent first + // Show the comments more recent first. $event_comments_array = array_reverse($event_comments_array); - if (is_null($event_comments_array)) { + if (empty($event_comments_array)) { $comments_format = 'old'; } else { $comments_format = 'new'; @@ -3034,7 +3339,7 @@ function events_page_comments($event, $childrens_ids=[]) case 'old': $comments_array = explode('<br>', $event_comments); - // Split comments and put in table + // Split comments and put in table. $col = 0; $data = []; @@ -3050,6 +3355,10 @@ function events_page_comments($event, $childrens_ids=[]) case 1: $row_text = preg_replace("/[\r\n|\r|\n]/", '<br>', io_safe_output(strip_tags($c))); break; + + default: + // Ignore. + break; } $data[$col] = $row_text; @@ -3071,14 +3380,33 @@ function events_page_comments($event, $childrens_ids=[]) $table_comments->data[] = $data; } break; + + default: + // Ignore. + break; } - if (((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids)) || (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids))) && $config['show_events_in_local'] == false || $config['event_replication'] == false) { + if (((tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EM', + $event['clean_tags'], + $childrens_ids + )) || (tags_checks_event_acl( + $config['id_user'], + $event['id_grupo'], + 'EW', + $event['clean_tags'], + $childrens_ids + ))) && $config['show_events_in_local'] == false || $config['event_replication'] == false + ) { $comments_form = '<br><div id="comments_form" style="width:98%;">'.html_print_textarea('comment', 3, 10, '', 'style="min-height: 15px; width: 100%; disabled"', true); $comments_form .= '<br><div style="text-align:right;">'.html_print_button(__('Add comment'), 'comment_button', false, 'event_comment();', 'class="sub next"', true).'</div><br></div>'; } else { - $comments_form = ui_print_message(__('If event replication is ongoing, it won\'t be possible to enter comments here. This option is only to allow local pandora users to see comments, but not to operate with them. The operation, when event replication is enabled, must be done only in the Metaconsole.')); + $comments_form = ui_print_message( + __('If event replication is ongoing, it won\'t be possible to enter comments here. This option is only to allow local pandora users to see comments, but not to operate with them. The operation, when event replication is enabled, must be done only in the Metaconsole.') + ); } $comments = '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>'; @@ -3087,6 +3415,13 @@ function events_page_comments($event, $childrens_ids=[]) } +/** + * Retrieve event tags (cleaned). + * + * @param string $tags Tags. + * + * @return array of Tags. + */ function events_clean_tags($tags) { if (empty($tags)) { @@ -3103,9 +3438,14 @@ function events_clean_tags($tags) * * 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 $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_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 $dbmeta Dbmeta. * * @return array An array with all the events happened. */ @@ -3121,7 +3461,7 @@ function events_get_count_events_by_agent( ) { global $config; - // date + // Date. if (!is_numeric($date)) { $date = time_w_fixed_tz($date); } @@ -3130,11 +3470,11 @@ function events_get_count_events_by_agent( $date = get_system_time(); } - // group + // Group. $id_group = groups_safe_acl($config['id_user'], $id_group, 'AR'); if (empty($id_group)) { - // An empty array means the user doesn't have access + // An empty array means the user doesn't have access. return false; } @@ -3162,6 +3502,7 @@ function events_get_count_events_by_agent( break; default: + // Ignore. break; } } @@ -3182,6 +3523,7 @@ function events_get_count_events_by_agent( case 3: $filter_event_status[$key] = ('0, 2'); default: + // Ignore. break; } } @@ -3196,10 +3538,10 @@ function events_get_count_events_by_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') { @@ -3212,7 +3554,7 @@ function events_get_count_events_by_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).'%")'; } $tagente = 'tagente'; @@ -3265,9 +3607,14 @@ function events_get_count_events_by_agent( * * 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 array $filter Use target filter. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @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 $dbmeta Dbmeta. * * @return array An array with all the events happened. */ @@ -3282,13 +3629,13 @@ function events_get_count_events_validated_by_user( $dbmeta=false ) { global $config; - // group + // Group. $sql_filter = ' AND 1=1 '; if (isset($filter['id_group'])) { $id_group = groups_safe_acl($config['id_user'], $filter['id_group'], 'AR'); if (empty($id_group)) { - // An empty array means the user doesn't have access + // An empty array means the user doesn't have access. return false; } @@ -3303,7 +3650,7 @@ function events_get_count_events_validated_by_user( $sql_filter .= sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']); } - // date + // Date. if (!is_numeric($date)) { $date = time_w_fixed_tz($date); } @@ -3336,6 +3683,7 @@ function events_get_count_events_validated_by_user( break; default: + // Ignore. break; } } @@ -3356,6 +3704,7 @@ function events_get_count_events_validated_by_user( case 3: $filter_event_status[$key] = ('0, 2'); default: + // Ignore. break; } } @@ -3370,10 +3719,10 @@ function events_get_count_events_validated_by_user( $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') { @@ -3386,7 +3735,7 @@ function events_get_count_events_validated_by_user( } 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).'%")'; } $tevento = 'tevento'; @@ -3435,9 +3784,14 @@ function events_get_count_events_validated_by_user( * * 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 $filter Target filter. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @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 $dbmeta Dbmeta. * * @return array An array with all the events happened. */ @@ -3458,7 +3812,7 @@ function events_get_count_events_by_criticity( $id_group = groups_safe_acl($config['id_user'], $filter['id_group'], 'AR'); if (empty($id_group)) { - // An empty array means the user doesn't have access + // An empty array means the user doesn't have access. return false; } @@ -3505,6 +3859,7 @@ function events_get_count_events_by_criticity( break; default: + // Ignore. break; } } @@ -3524,7 +3879,10 @@ function events_get_count_events_by_criticity( case 3: $filter_event_status[$key] = ('0, 2'); + break; + default: + // Ignored. break; } } @@ -3539,10 +3897,10 @@ function events_get_count_events_by_criticity( $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') { @@ -3555,7 +3913,7 @@ function events_get_count_events_by_criticity( } 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).'%")'; } $tevento = 'tevento'; @@ -3597,9 +3955,14 @@ function events_get_count_events_by_criticity( * * 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 $filter Target filter. + * @param integer $period Period in seconds to get events. + * @param integer $date Beginning date to get events. + * @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 $dbmeta Dbmeta. * * @return array An array with all the events happened. */ @@ -3615,30 +3978,43 @@ function events_get_count_events_validated( ) { global $config; - // group + // Group. $sql_filter = ' 1=1 '; if (isset($filter['id_group'])) { - $id_group = groups_safe_acl($config['id_user'], $filter['id_group'], 'AR'); + $id_group = groups_safe_acl( + $config['id_user'], + $filter['id_group'], + 'AR' + ); if (empty($id_group)) { - // An empty array means the user doesn't have access + // An empty array means the user doesn't have access. return false; } - $sql_filter .= sprintf(' AND id_grupo IN (%s) ', implode(',', $id_group)); + $sql_filter .= sprintf( + ' AND id_grupo IN (%s) ', + implode(',', $id_group) + ); } - // agent + // Agent. if (!empty($filter['id_agent'])) { - $sql_filter .= sprintf(' AND id_agente = %d ', $filter['id_agent']); + $sql_filter .= sprintf( + ' AND id_agente = %d ', + $filter['id_agent'] + ); } - // module + // Module. if (!empty($filter['id_agentmodule'])) { - $sql_filter .= sprintf(' AND id_agentmodule = %d ', $filter['id_agentmodule']); + $sql_filter .= sprintf( + ' AND id_agentmodule = %d ', + $filter['id_agentmodule'] + ); } - // date + // Date. if (!is_numeric($date)) { $date = time_w_fixed_tz($date); } @@ -3691,6 +4067,7 @@ function events_get_count_events_validated( break; default: + // Ingore. break; } } @@ -3710,7 +4087,10 @@ function events_get_count_events_validated( case 3: $filter_event_status[$key] = ('0, 2'); + break; + default: + // Ignore. break; } } @@ -3725,10 +4105,10 @@ function events_get_count_events_validated( $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') { @@ -3741,7 +4121,7 @@ function events_get_count_events_validated( } 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).'%")'; } $tevento = 'tevento'; @@ -3781,6 +4161,14 @@ function events_get_count_events_validated( } +/** + * Check event tags. + * + * @param array $event_data Event. + * @param array $acltags Acl tags. + * + * @return boolean True or false. + */ function events_checks_event_tags($event_data, $acltags) { global $config; @@ -3809,6 +4197,18 @@ function events_checks_event_tags($event_data, $acltags) } +/** + * Retrieves events grouped by agent. + * + * @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. + * + * @return array Data. + */ function events_get_events_grouped_by_agent( $sql_post, $offset=0, @@ -3831,23 +4231,23 @@ function events_get_events_grouped_by_agent( $event_lj = events_get_secondary_groups_left_join($table); if ($total) { - $sql = "SELECT COUNT(*) FROM (select id_agente from $table $event_lj WHERE 1=1 - $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t"; + $sql = 'SELECT COUNT(*) FROM (select id_agente from '.$table.' '.$event_lj.' WHERE 1=1 + '.$sql_post.' GROUP BY id_agente, event_type'.$groupby_extra.' ORDER BY id_agente ) AS t'; } else { - $sql = "select id_agente, count(*) as total$fields_extra from $table te $event_lj - WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination"; + $sql = 'select id_agente, count(*) as total'.$fields_extra.' from '.$table.' te '.$event_lj.' + WHERE id_agente > 0 '.$sql_post.' GROUP BY id_agente'.$groupby_extra.' ORDER BY id_agente LIMIT '.$offset.','.$pagination; } $result = []; - // Extract the events by filter (or not) from db + // Extract the events by filter (or not) from db. $events = db_get_all_rows_sql($sql); $result = []; if ($events) { foreach ($events as $event) { if ($meta) { - $sql = "select event_type from $table te $event_lj - WHERE agent_name = '".$event['agent_name']."' $sql_post ORDER BY utimestamp DESC "; + $sql = 'SELECT event_type FROM '.$table.' te '.$event_lj." + WHERE agent_name = '".$event['agent_name']."' ".$sql_post.' ORDER BY utimestamp DESC '; $resultado = db_get_row_sql($sql); $id_agente = $event['agent_name']; @@ -3858,8 +4258,8 @@ function events_get_events_grouped_by_agent( 'event_type' => $resultado['event_type'], ]; } else { - $sql = "SELECT event_type FROM $table te $event_lj - WHERE id_agente = ".$event['id_agente']." $sql_post ORDER BY utimestamp DESC "; + $sql = 'SELECT event_type FROM '.$table.' te '.$event_lj.' + WHERE id_agente = '.$event['id_agente'].' '.$sql_post.' ORDER BY utimestamp DESC '; $resultado = db_get_row_sql($sql); $id_agente = $event['id_agente']; @@ -3876,6 +4276,28 @@ function events_get_events_grouped_by_agent( } +/** + * Return SQL query to group events by agents. + * + * @param mixed $id_agent Id_agent. + * @param integer $server_id Server_id. + * @param string $event_type Event_type. + * @param integer $severity Severity. + * @param integer $status Status. + * @param string $search Search. + * @param integer $id_agent_module Id_agent_module. + * @param integer $event_view_hr Event_view_hr. + * @param boolean $id_user_ack Id_user_ack. + * @param array $tag_with Tag_with. + * @param array $tag_without Tag_without. + * @param boolean $filter_only_alert Filter_only_alert. + * @param string $date_from Date_from. + * @param string $date_to Date_to. + * @param boolean $id_user Id_user. + * @param boolean $server_id_search Server_id_search. + * + * @return string SQL. + */ function events_sql_events_grouped_agents( $id_agent, $server_id=-1, @@ -3913,17 +4335,21 @@ function events_sql_events_grouped_agents( case 3: $sql_post .= ' AND (estado = 0 OR estado = 2)'; break; + + default: + // Ignore. + break; } if ($search != '') { - $sql_post .= " AND (evento LIKE '%".io_safe_input($search)."%' OR id_evento LIKE '%$search%')"; + $sql_post .= " AND (evento LIKE '%".io_safe_input($search)."%' OR id_evento LIKE '%".$search."%')"; } 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" + // Shown to user only "warning, critical and normal". if ($event_type == 'warning' || $event_type == 'critical' || $event_type == 'normal') { - $sql_post .= " AND event_type LIKE '%$event_type%' "; + $sql_post .= " AND event_type LIKE '%".$event_type."%' "; } else if ($event_type == 'not_normal') { $sql_post .= " AND (event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%') "; } else if ($event_type != 'all') { @@ -3950,23 +4376,25 @@ function events_sql_events_grouped_agents( break; default: - $sql_post .= " AND criticity = $severity"; + $sql_post .= ' AND criticity = '.$severity; break; } } - // In metaconsole mode the agent search is performed by name + // In metaconsole mode the agent search is performed by name. if ($meta) { if ($id_agent != __('All')) { - $sql_post .= " AND agent_name LIKE '%$id_agent%'"; + $sql_post .= " AND agent_name LIKE '%".$id_agent."%'"; } } else { switch ($id_agent) { case 0: + // Ignore. + $__invalid_value = 1; break; case -1: - // Agent doesnt exist. No results will returned + // Agent doesnt exist. No results will returned. $sql_post .= ' AND 1 = 0'; break; @@ -3976,14 +4404,13 @@ function events_sql_events_grouped_agents( } } - if ($meta) { - // There is another filter. - } else { + // There is another filter for if ($meta). + if (!$meta) { if (!empty($text_module)) { $sql_post .= " AND id_agentmodule IN ( SELECT id_agente_modulo FROM tagente_modulo - WHERE nombre = '$text_module' + WHERE nombre = '".$text_module."' )"; } } @@ -4017,7 +4444,7 @@ function events_sql_events_grouped_agents( } } - // Search by tag + // Search by tag. if (!empty($tag_with) && (io_safe_output($tag_with) != '[]') && (io_safe_output($tag_with) != '["0"]')) { $sql_post .= ' AND ( '; $first = true; @@ -4050,7 +4477,7 @@ function events_sql_events_grouped_agents( $sql_post .= ' ) '; } - // Filter/Only alerts + // Filter/Only alerts. if (isset($filter_only_alert)) { if ($filter_only_alert == 0) { $sql_post .= " AND event_type NOT LIKE '%alert%'"; @@ -4059,7 +4486,7 @@ function events_sql_events_grouped_agents( } } - // Tags ACLS + // Tags ACLS. if ($id_group > 0 && in_array($id_group, array_keys($groups))) { $group_array = (array) $id_group; } else { @@ -4077,12 +4504,12 @@ function events_sql_events_grouped_agents( [], true ); - // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)" + // FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)". if (($tags_acls_condition != ERR_WRONG_PARAMETERS) && ($tags_acls_condition != ERR_ACL) && ($tags_acls_condition != -110000)) { $sql_post .= $tags_acls_condition; } - // Metaconsole fitlers + // Metaconsole filters. if ($meta) { if ($server_id_search) { $sql_post .= ' AND server_id = '.$server_id_search; @@ -4116,29 +4543,40 @@ function events_sql_events_grouped_agents( } +/** + * Retrieve list of events grouped by agents. + * + * @param string $sql SQL. + * + * @return string HTML. + */ function events_list_events_grouped_agents($sql) { global $config; $table = events_get_events_table(is_metaconsole(), $history); - $sql = "select * from $table - LEFT JOIN tagent_secondary_group - ON tagent_secondary_group.id_agent = tevento.id_agente - WHERE $sql"; + $sql = sprintf( + 'SELECT * FROM %s + LEFT JOIN tagent_secondary_group + ON tagent_secondary_group.id_agent = tevento.id_agente + WHERE %s', + $table, + $sql + ); $result = db_get_all_rows_sql($sql); $group_rep = 0; $meta = is_metaconsole(); - // fields that the user has selected to show + // Fields that the user has selected to show. if ($meta) { $show_fields = events_meta_get_custom_fields_user(); } else { $show_fields = explode(',', $config['event_fields']); } - // headers + // Headers. $i = 0; $table = new stdClass(); if (!isset($table->width)) { @@ -4299,7 +4737,7 @@ function events_list_events_grouped_agents($sql) } if ($meta) { - // Get info of the all servers to use it on hash auth + // Get info of the all servers to use it on hash auth. $servers_url_hash = metaconsole_get_servers_url_hash(); $servers = metaconsole_get_servers(); } @@ -4308,7 +4746,7 @@ function events_list_events_grouped_agents($sql) $show_validate_button = false; $idx = 0; - // Arrange data. We already did ACL's in the query + // Arrange data. We already did ACL's in the query. foreach ($result as $event) { $data = []; @@ -4318,16 +4756,16 @@ function events_list_events_grouped_agents($sql) $event['server_name'] = $servers[$event['server_id']]['server_name']; } - // Clean url from events and store in array + // Clean url from events and store in array. $event['clean_tags'] = events_clean_tags($event['tags']); - // First pass along the class of this row + // First pass along the class of this row. $myclass = get_priority_class($event['criticity']); - // print status + // Print status. $estado = $event['estado']; - // Colored box + // Colored box. switch ($estado) { case EVENT_NEW: $img_st = 'images/star.png'; @@ -4343,6 +4781,10 @@ function events_list_events_grouped_agents($sql) $img_st = 'images/hourglass.png'; $title_st = __('Event in process'); break; + + default: + // Ignore. + break; } $i = 0; @@ -4350,7 +4792,7 @@ function events_list_events_grouped_agents($sql) $data[$i] = '#'.$event['id_evento']; $table->cellstyle[count($table->data)][$i] = 'background: #F3F3F3; color: #111 !important;'; - // Pass grouped values in hidden fields to use it from modal window + // Pass grouped values in hidden fields to use it from modal window. if ($group_rep) { $similar_ids = $event['similar_ids']; $timestamp_first = $event['timestamp_rep_min']; @@ -4361,17 +4803,17 @@ function events_list_events_grouped_agents($sql) $timestamp_last = $event['utimestamp']; } - // Store group data to show in extended view + // Store group data to show in extended view. $data[$i] .= html_print_input_hidden('similar_ids_'.$event['id_evento'], $similar_ids, true); $data[$i] .= html_print_input_hidden('timestamp_first_'.$event['id_evento'], $timestamp_first, true); $data[$i] .= html_print_input_hidden('timestamp_last_'.$event['id_evento'], $timestamp_last, true); $data[$i] .= html_print_input_hidden('childrens_ids', json_encode($childrens_ids), true); - // Store server id if is metaconsole. 0 otherwise + // Store server id if is metaconsole. 0 otherwise. if ($meta) { $server_id = $event['server_id']; - // If meta activated, propagate the id of the event on node (source id) + // If meta activated, propagate the id of the event on node (source id). $data[$i] .= html_print_input_hidden('source_id_'.$event['id_evento'], $event['id_source_event'], true); $table->cellclass[count($table->data)][$i] = $myclass; } else { @@ -4385,7 +4827,7 @@ function events_list_events_grouped_agents($sql) } $data[$i] .= html_print_input_hidden('event_rep_'.$event['id_evento'], $event['event_rep'], true); - // Store concat comments to show in extended view + // Store concat comments to show in extended view. $data[$i] .= html_print_input_hidden('user_comment_'.$event['id_evento'], base64_encode($event['user_comment']), true); $i++; @@ -4456,7 +4898,7 @@ function events_list_events_grouped_agents($sql) } if (in_array('evento', $show_fields)) { - // Event description + // Event description. $data[$i] = '<span title="'.$event['evento'].'" class="f9">'; if ($allow_action) { $data[$i] .= '<a href="javascript:" onclick="show_event_dialog('.$event['id_evento'].', '.$group_rep.');">'; @@ -4476,7 +4918,7 @@ function events_list_events_grouped_agents($sql) $data[$i] = '<span class="'.$myclass.'">'; if ($event['id_agente'] > 0) { - // Agent name + // Agent name. if ($meta) { $agent_link = '<a href="'.$event['server_url'].'/index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event['id_agente'].$event['server_url_hash'].'">'; if (can_user_access_node()) { @@ -4497,7 +4939,7 @@ function events_list_events_grouped_agents($sql) } if (in_array('timestamp', $show_fields)) { - // Time + // Time. $data[$i] = '<span class="'.$myclass.'">'; if ($group_rep == 1) { $data[$i] .= ui_print_timestamp($event['timestamp_rep'], true); @@ -4700,6 +5142,10 @@ function events_list_events_grouped_agents($sql) $data[$i] = html_print_image('images/page_white_text.png', true, ['title' => str_replace("\n", '<br>', io_safe_output($event['unknown_instructions']))]); } break; + + default: + // Ignore. + break; } if (!isset($data[$i])) { @@ -4729,11 +5175,11 @@ function events_list_events_grouped_agents($sql) } if ($i != 0 && $allow_action) { - // Actions + // Actions. $data[$i] = ''; if (!$readonly) { - // Validate event + // Validate event. if (($event['estado'] != 1) && (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids))) { $show_validate_button = true; $data[$i] .= '<a href="javascript:validate_event_advanced('.$event['id_evento'].', 1)" id="validate-'.$event['id_evento'].'">'; @@ -4745,7 +5191,7 @@ function events_list_events_grouped_agents($sql) $data[$i] .= '</a>'; } - // Delete event + // Delete event. if ((tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids) == 1)) { if ($event['estado'] != 2) { $show_delete_button = true; @@ -4784,11 +5230,11 @@ function events_list_events_grouped_agents($sql) if (!$readonly) { if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EM', $event['clean_tags'], $childrens_ids) == 1) { - // Checkbox - // Class 'candeleted' must be the fist class to be parsed from javascript. Dont change + // Checkbox. + // Class 'candeleted' must be the fist class to be parsed from javascript. Dont change. $data[$i] = html_print_checkbox_extended('validate_ids[]', $event['id_evento'], false, false, false, 'class="candeleted chk_val"', true); } else if (tags_checks_event_acl($config['id_user'], $event['id_grupo'], 'EW', $event['clean_tags'], $childrens_ids) == 1) { - // Checkbox + // Checkbox. $data[$i] = html_print_checkbox_extended('validate_ids[]', $event['id_evento'], false, false, false, 'class="chk_val"', true); } else if (isset($table->header[$i]) || true) { $data[$i] = ''; @@ -4807,6 +5253,15 @@ function events_list_events_grouped_agents($sql) } +/** + * Retrieves SQL for custom order. + * + * @param string $sort_field Field. + * @param string $sort Order. + * @param integer $group_rep Group field. + * + * @return string SQL. + */ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=0) { $sort_field_translated = $sort_field; @@ -4854,18 +5309,22 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep= case 'extra_id': $sort_field_translated = 'id_extra'; break; + + default: + // Ignore. + break; } $dir = ($sort == 'up') ? 'ASC' : 'DESC'; - return "ORDER BY $sort_field_translated $dir"; + return 'ORDER BY '.$sort_field_translated.' '.$dir; } /** - * SQL left join of event queries to handle secondary groups + * SQL left join of event queries to handle secondary groups. * - * @param string Table to see if is metaconsole or not + * @param string $table Table to use based on environment. * * @return string With the query. */ From d5d58e5b2bb195d0c9f6d25fd9729d35bb63ed0e Mon Sep 17 00:00:00 2001 From: Fermin <fermin.hernandez@artica.es> Date: Fri, 8 Feb 2019 18:53:28 +0100 Subject: [PATCH 051/262] Added outter shadow to notifications messages box Former-commit-id: 1eed4b4f2ef7d58dbab73ccb2628bb0ef9ffc7ca --- pandora_console/general/header.php | 26 ++++++++++--------- .../include/functions_notifications.php | 11 ++++++-- pandora_console/include/styles/pandora.css | 13 ++++++++-- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 7e84247c50..1413cc12e1 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -386,23 +386,25 @@ config_check(); ?> function addNotifications(event) { - var elements = document.getElementsByClassName("notification-wrapper"); - if (!elements) return; - Array.prototype.forEach.call(elements, function(elem) { - toggle_element(elem); - }); + var element = document.getElementById("notification-content"); + if (!element) return; + element.style.display = "block"; attatch_to_image(); } function attatch_to_image() { - var notification_elems = document.getElementsByClassName("notification-wrapper"); - var image_attached = document.getElementById("notification-ball-header").getBoundingClientRect().left; - Array.prototype.forEach.call(notification_elems, function(elem) { - elem.style.left = image_attached - 300 + "px"; - }); + var notification_elem = document.getElementById("notification-wrapper"); + var image_attached = + document.getElementById("notification-ball-header") + .getBoundingClientRect() + .left + ; + notification_elem.style.left = image_attached - 300 + "px"; } - function toggle_element(elem) { - elem.style.display = elem.style.display === "none" ? "block" : "none"; + + function notifications_hide() { + var element = document.getElementById("notification-content"); + element.style.display = "none" } // Resize event diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index ad3e8953ad..be11a4df72 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -831,8 +831,15 @@ function notifications_print_dropdown() } return sprintf( - "<div class='notification-wrapper' style='display:none;'> - %s + "<div id='notification-content' style='display:none;'> + <div id='notification-wrapper'> + %s + </div> + <div + id='notification-wrapper-shadow' + onclick='notifications_hide()' + > + </div> </div>", array_reduce( $mess, diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 00ac3161fb..499b1f93ec 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4929,7 +4929,7 @@ div#dialog_messages table th:last-child { background-color: #fc4444; } -.notification-wrapper { +#notification-wrapper { background: white; border: #a5a5a5 solid 1px; z-index: 900000; @@ -4937,7 +4937,7 @@ div#dialog_messages table th:last-child { width: 400px; margin-top: -5px; } -.notification-wrapper::before { +#notification-wrapper::before { content: ""; display: block; position: absolute; @@ -4952,6 +4952,15 @@ div#dialog_messages table th:last-child { margin-left: -12px; border-bottom-color: white; } +#notification-wrapper-shadow { + height: 100%; + width: 100%; + background: #111; + position: fixed; + z-index: 9009; + top: 0; + opacity: 0.3; +} .notification-item { background: whitesmoke; height: 100px; From 49cf9d5db0bde721d7c24c730e68ed6ff50bdad2 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Fri, 8 Feb 2019 19:07:49 +0100 Subject: [PATCH 052/262] Extended events Former-commit-id: f2e0925ce58042dc9c9505a0d0fcf1a424c8a0bb --- pandora_console/include/ajax/events.php | 47 ++++++-- .../include/ajax/events_extended.php | 104 ++++++++++++++++++ pandora_console/include/functions_events.php | 13 +-- 3 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 pandora_console/include/ajax/events_extended.php diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 77930e3e50..d52220cd1a 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -397,6 +397,10 @@ if ($get_extended_event) { // Tabs. $tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>"; $tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>'; + if ($event['extended_info'] == 1) { + $tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Related').'</span></a></li>'; + } + $tabs .= "<li><a href='#extended_event_details_page' id='link_details'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Details').'</span></a></li>'; $tabs .= "<li><a href='#extended_event_custom_fields_page' id='link_custom_fields'>".html_print_image('images/custom_field_col.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Agent fields').'</span></a></li>'; $tabs .= "<li><a href='#extended_event_comments_page' id='link_comments'>".html_print_image('images/pencil.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Comments').'</span></a></li>'; @@ -487,6 +491,10 @@ if ($get_extended_event) { $details = events_page_details($event, $server); + if ($event['extended_info'] == 1) { + $related = events_page_related($event, $server); + } + // Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct // node connection was lost. if ($meta) { @@ -515,7 +523,7 @@ if ($get_extended_event) { $loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>'; - $out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$loading.$general.$details.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>'; + $out = '<div id="tabs" style="height:95%; overflow: auto">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>'; $js = '<script> $(function() { @@ -533,30 +541,53 @@ if ($get_extended_event) { $js .= '$tabs.tabs( "option", "active", 1);'; break; - case 'custom_fields': + case 'related': $js .= '$tabs.tabs( "option", "active", 2);'; break; - case 'comments': + case 'custom_fields': $js .= '$tabs.tabs( "option", "active", 3);'; break; - case 'responses': + case 'comments': $js .= '$tabs.tabs( "option", "active", 4);'; break; - case 'custom_data': + case 'responses': $js .= '$tabs.tabs( "option", "active", 5);'; break; + case 'custom_data': + $js .= '$tabs.tabs( "option", "active", 6);'; + break; + default: // Ignore. break; } - $js .= ' - }); - </script>'; + $js .= '});'; + + if ($event['extended_info'] == 1) { + $js .= ' + $("#link_related").click(function (){ + $.post ({ + url : "ajax.php", + data : { + page: "include/ajax/events_extended", + get_extended_info: 1, + id_event: '.$event['id_evento'].' + }, + dataType : "html", + success: function (data) { + $("#related_data").html(data); + console.log("vamos puta"); + } + }); + });'; + } + + $js .= '</script>'; echo $out.$js; } diff --git a/pandora_console/include/ajax/events_extended.php b/pandora_console/include/ajax/events_extended.php new file mode 100644 index 0000000000..1543215c40 --- /dev/null +++ b/pandora_console/include/ajax/events_extended.php @@ -0,0 +1,104 @@ +<?php +/** + * Manage AJAX response for event pages. + * + * @category Ajax + * @package Pandora FMS + * @subpackage Events extended + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ + +require_once 'include/functions_events.php'; + + +enterprise_include_once('meta/include/functions_events_meta.php'); +enterprise_include_once('include/functions_metaconsole.php'); + + +global $config; + +// Check ACLs. +if (is_user_admin($config['id_user']) === true) { + // Do nothing if you're admin, you get full access. + $allowed = true; +} else if ($config['id_user'] == $event['owner_user']) { + // Do nothing if you're the owner user, you get access. + $allowed = true; +} else if ($event['id_grupo'] == 0) { + // If the event has access to all groups, you get access. + $allowed = true; +} else { + // Get your groups. + $groups = users_get_groups($config['id_user'], 'ER'); + + if (in_array($event['id_grupo'], array_keys($groups))) { + // If event group is among the groups of the user, you get access. + $__ignored_line = true; + } else { + // If all the access types fail, abort. + $allowed = false; + } +} + +if ($allowed === false) { + echo 'Access denied'; + exit; +} + +$id_event = get_parameter('id_event', null); +$get_extended_info = get_parameter('get_extended_info', 0); + + +if ($get_extended_info == 1) { + if (isset($id_event) === falsse) { + echo 'Internal error. Invalid event.'; + exit; + } + + $extended_info = events_get_extended_events($id_event); + + $table = new StdClass(); + // + // Details. + // + $table->width = '100%'; + $table->data = []; + $table->head = []; + $table->style[0] = 'min-width:120px; text-align: left;'; + $table->style[1] = 'text-align: left;'; + $table->cellspacing = 2; + $table->cellpadding = 2; + $table->class = 'alternate rounded_cells'; + + $output = []; + $output[] = '<b>'.__('Timestamp').'</b>'; + $output[] = '<b>'.__('Description').'</b>'; + $table->data[] = $output; + + foreach ($extended_info as $data) { + $output = []; + $output[] = date('Y/m/d H:i:s', $data['utimestamp']); + $output[] = io_safe_output($data['description']); + $table->data[] = $output; + } + + html_print_table($table); +} diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 8ff58d8d8b..600f6b6169 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2611,20 +2611,19 @@ function events_get_extended_events(int $id_evento) /** - * Generates the 'extended' page in event view. + * 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_extended($event, $server='') +function events_page_related($event, $server='') { - $html = ''; - - $data = []; - $data[0] = __('Extended events'); - $data[1] = ''; + $html = '<div id="extended_event_related_page" class="extended_event_pages">'; + $html .= '<h4>'.__('Extended information').'</h4>'; + $html .= '<div id="related_data"><p>'.__('Loading').'...</p></div>'; + $html .= '</div>'; return $html; } From e1d87ce0c8e5f3ed0b9e68e7d952632d3197276f Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Fri, 8 Feb 2019 19:09:36 +0100 Subject: [PATCH 053/262] minor fix falsse => false Former-commit-id: 938e161b179736a3b72cad3f35db90a02e5d632c --- pandora_console/include/ajax/events_extended.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/ajax/events_extended.php b/pandora_console/include/ajax/events_extended.php index 1543215c40..4993014ddf 100644 --- a/pandora_console/include/ajax/events_extended.php +++ b/pandora_console/include/ajax/events_extended.php @@ -68,7 +68,7 @@ $get_extended_info = get_parameter('get_extended_info', 0); if ($get_extended_info == 1) { - if (isset($id_event) === falsse) { + if (isset($id_event) === false) { echo 'Internal error. Invalid event.'; exit; } From e6dc69e3be9d29d35ab49d655c168eb1eaafa337 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Mon, 11 Feb 2019 13:05:31 +0100 Subject: [PATCH 054/262] Added last_id to notification ball Former-commit-id: f7095e633ce5799cf79bd20393e13e5b6233bf4c --- pandora_console/general/header.php | 6 ++- .../include/functions_messages.php | 10 +++-- .../include/functions_notifications.php | 40 ++++++++++++++++++- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 1413cc12e1..86935f9506 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -319,7 +319,11 @@ config_check(); ).'</a>'; } - $table->data[0]['notifications'] = notifications_print_ball(); + $notifications_numbers = notifications_get_counters(); + $table->data[0]['notifications'] = notifications_print_ball( + $notifications_numbers['notifications'], + $notifications_numbers['last_id'] + ); // Logout $table->data[0][5] = '<a class="white" href="'.ui_get_full_url('index.php?bye=bye').'">'; diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 1062b8fa48..2c195bd19f 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -417,6 +417,7 @@ function messages_get_count_sent(string $user='') * (ASC = Ascending, DESC = Descending). * @param boolean $incl_read Include read messages in return. * @param boolean $incl_source_info Include source info. + * @param integer $limit Maximum number of result in the query. * * @return integer The number of messages this user has */ @@ -424,7 +425,8 @@ function messages_get_overview( string $order='status', string $order_dir='ASC', bool $incl_read=true, - bool $incl_source_info=false + bool $incl_source_info=false, + int $limit=0 ) { global $config; @@ -478,13 +480,15 @@ function messages_get_overview( AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0) ) t %s - ORDER BY %s', + ORDER BY %s + %s', $source_fields, $source_join, $config['id_user'], $config['id_user'], $read, - $order + $order, + ($limit !== 0) ? ' LIMIT '.$limit : '' ); return db_get_all_rows_sql($sql); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index be11a4df72..59e553145f 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -519,7 +519,37 @@ function notifications_set_user_label_status($source, $user, $label, $value) 'id_source' => $source, ] ); +} + +/** + * Get the counters of notification. Usefull to print the header notification + * ball. + * + * @return array With the fields: + * 'notifications' => Total new notifications, + * 'last_id' => Id of last read value. Usefull to make comparisons. + */ +function notifications_get_counters() +{ + $num_notifications = 0; + $last_id = 0; + $last_message = messages_get_overview( + 'timestamp', + 'DESC', + false, + false, + 1 + ); + if (!empty($last_message)) { + $num_notifications = messages_get_count(); + $last_id = $last_message[0]['id_mensaje']; + } + + return [ + 'notifications' => $num_notifications, + 'last_id' => $last_id, + ]; } @@ -531,21 +561,27 @@ function notifications_set_user_label_status($source, $user, $label, $value) /** * Print the notification ball to see unread messages. * + * @param integer $num_notifications Number of messages shown + * in notification ball. + * @param integer $last_id Id of last message shown + * in the notification ball. + * * @return string with HTML code of notification ball. */ -function notifications_print_ball() +function notifications_print_ball($num_notifications, $last_id) { - $num_notifications = messages_get_count(); $class_status = ($num_notifications == 0) ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; return sprintf( '<div onclick="addNotifications(event)" class="notification-ball %s" id="notification-ball-header" + last_id="%s" > %s </div>', $class_status, + $last_id, $num_notifications ); } From a50a251b002e494e15395415198011668963bb38 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Mon, 11 Feb 2019 13:35:36 +0100 Subject: [PATCH 055/262] Added filter to get last messages by notification ball Former-commit-id: 57619fe6cd46f3f723c5b2c3bdbe3aa9ba155a0c --- pandora_console/general/header.php | 30 +++++++++++++++++++ .../godmode/setup/setup_notifications.php | 26 ++++++++++++++++ .../include/functions_messages.php | 5 +++- .../include/functions_notifications.php | 2 ++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 86935f9506..4975f3c81b 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -411,6 +411,32 @@ config_check(); element.style.display = "none" } + function check_new_notifications() { + var last_id = document.getElementById('notification-ball-header') + .getAttribute('last_id'); + if (last_id === null) { + console.error('Cannot retrieve notifications ball last_id.'); + return; + } + + jQuery.post ("ajax.php", + {"page" : "godmode/setup/setup_notifications", + "check_new_notifications" : 1, + "last_id": last_id + }, + function (data, status) { + // TODO + }, + "json" + ) + .fail(function(xhr, textStatus, errorThrown){ + console.error( + "Cannot get new notifications. Error: ", + xhr.responseText + ); + }); + } + // Resize event window.addEventListener("resize", function() { attatch_to_image(); @@ -420,6 +446,10 @@ config_check(); var new_chat = <?php echo (int) $_SESSION['new_chat']; ?>; $(document).ready (function () { + + // Check new notifications on a periodic way + setInterval(check_new_notifications, 10000); + <?php if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET['refr']))) { $do_refresh = true; diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index d207f72d76..b31e7389c2 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -94,6 +94,32 @@ if (get_parameter('update_config', 0)) { return; } +if (get_parameter('check_new_notifications', 0)) { + $last_id_ui = (int) get_parameter('last_id', 0); + $counters = notifications_get_counters(); + if ((int) $last_id_ui === (int) $counters['last_id']) { + echo json_encode(['new_notifications' => []]); + return; + } + + // If there is new messages, get the info. + echo json_encode( + [ + 'notifications' => $counters['notifications'], + 'last_id' => $counters['last_id'], + 'new_notifications' => messages_get_overview( + 'timestamp', + 'ASC', + false, + true, + 0, + ['id_mensaje' => '>'.$last_id_ui] + ), + ] + ); + return; +} + // Notification table. It is just a wrapper. $table_content = new StdClass(); $table_content->data = []; diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 2c195bd19f..f16801a448 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -426,7 +426,8 @@ function messages_get_overview( string $order_dir='ASC', bool $incl_read=true, bool $incl_source_info=false, - int $limit=0 + int $limit=0, + array $other_filter=[] ) { global $config; @@ -480,6 +481,7 @@ function messages_get_overview( AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0) ) t %s + %s ORDER BY %s %s', $source_fields, @@ -487,6 +489,7 @@ function messages_get_overview( $config['id_user'], $config['id_user'], $read, + db_format_array_where_clause_sql($other_filter, 'AND', ' AND '), $order, ($limit !== 0) ? ' LIMIT '.$limit : '' ); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 59e553145f..5058f50591 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -26,6 +26,8 @@ * ============================================================================ */ +require_once $config['homedir'].'/include/functions_messages.php'; + define('NOTIFICATIONS_POSTPONE_FOREVER', -1); From 1223ce69da0c58ecd7b937865e74ebf0c4b76474 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Mon, 11 Feb 2019 13:49:03 +0100 Subject: [PATCH 056/262] Added missing docs Former-commit-id: d0477e479f4ba4d138112de73746ca8173c9d563 --- pandora_console/include/functions_messages.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index f16801a448..63c810d684 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -418,6 +418,7 @@ function messages_get_count_sent(string $user='') * @param boolean $incl_read Include read messages in return. * @param boolean $incl_source_info Include source info. * @param integer $limit Maximum number of result in the query. + * @param array $other_filter Add a filter on main query. * * @return integer The number of messages this user has */ From 17c012cd83a42b974f87c50514463a23dbc718ae Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Mon, 11 Feb 2019 14:44:14 +0100 Subject: [PATCH 057/262] Added update ball notifications Former-commit-id: 60c253a1b64d1084ae732e88e0a6fb1f98cf8a12 --- pandora_console/general/header.php | 17 ++++++++++++++++- .../godmode/setup/setup_notifications.php | 13 +++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 4975f3c81b..cf001942f0 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -425,7 +425,22 @@ config_check(); "last_id": last_id }, function (data, status) { - // TODO + if(!data.has_new_notifications) return; + // Substitute the ball + var new_ball = atob(data.new_ball); + var ball_wrapper = document + .getElementById('notification-ball-header') + .parentElement; + if (ball_wrapper === null) { + console.error('Cannot update notification ball'); + return; + } + ball_wrapper.innerHTML = new_ball; + + // Show the toasts + //TODO + + }, "json" ) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index b31e7389c2..ad40926220 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -98,16 +98,21 @@ if (get_parameter('check_new_notifications', 0)) { $last_id_ui = (int) get_parameter('last_id', 0); $counters = notifications_get_counters(); if ((int) $last_id_ui === (int) $counters['last_id']) { - echo json_encode(['new_notifications' => []]); + echo json_encode(['has_new_notifications' => false]); return; } // If there is new messages, get the info. echo json_encode( [ - 'notifications' => $counters['notifications'], - 'last_id' => $counters['last_id'], - 'new_notifications' => messages_get_overview( + 'has_new_notifications' => true, + 'new_ball' => base64_encode( + notifications_print_ball( + $counters['notifications'], + $counters['last_id'] + ) + ), + 'new_notifications' => messages_get_overview( 'timestamp', 'ASC', false, From 7893827652076386d9b5b8d2f56e0d080a19b40f Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 11 Feb 2019 14:51:59 +0100 Subject: [PATCH 058/262] fixed query notifications pending Former-commit-id: ac8c5b5cb1276c16b9339e2e86c88d856540be0d --- pandora_console/include/functions_messages.php | 4 ++-- pandora_console/include/functions_notifications.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 63c810d684..4b9c66c1c1 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -372,7 +372,7 @@ function messages_get_count( AND up.id_grupo=ng.id_group ) ON tm.id_mensaje=ng.id_mensaje WHERE utimestamp_erased is null - AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0) + AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0)) ) t %s', $user, @@ -479,7 +479,7 @@ function messages_get_overview( ) ON tm.id_mensaje=ng.id_mensaje %s WHERE utimestamp_erased is null - AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0) + AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0)) ) t %s %s diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 5058f50591..1901e47e7b 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -142,7 +142,7 @@ function check_notification_readable(int $id_message) AND up.id_grupo=ng.id_group ) ON tm.id_mensaje=ng.id_mensaje WHERE utimestamp_erased is null - AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0)', + AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))', $id_message, $config['id_user'], $config['id_user'] From d2649bb51c3aaadbd331d40a20f3bd7ecd4a804d Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 11 Feb 2019 15:28:38 +0100 Subject: [PATCH 059/262] fixed double count in read messages Former-commit-id: e3661ad675c7dcd70fbea3bc5a41b3f103a376a0 --- pandora_console/include/functions_messages.php | 11 +++++++++-- pandora_console/include/functions_notifications.php | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 4b9c66c1c1..4cee825ecc 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -363,9 +363,11 @@ function messages_get_count( $sql = sprintf( 'SELECT count(*) FROM ( - SELECT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + SELECT DISTINCT tm.*, utimestamp_read > 0 as "read" + FROM tmensajes tm LEFT JOIN tnotification_user nu ON tm.id_mensaje=nu.id_mensaje + AND nu.id_user="%s" LEFT JOIN (tnotification_group ng INNER JOIN tusuario_perfil up ON ng.id_group=up.id_grupo @@ -377,6 +379,7 @@ function messages_get_count( %s', $user, $user, + $user, $read ); @@ -467,11 +470,14 @@ function messages_get_overview( ON tns.id=tm.id_source'; } + // Using distinct because could be double assignment due group/user. $sql = sprintf( 'SELECT * FROM ( - SELECT tm.*, utimestamp_read > 0 as "read" %s FROM tmensajes tm + SELECT DISTINCT tm.*, utimestamp_read > 0 as "read" %s + FROM tmensajes tm LEFT JOIN tnotification_user nu ON tm.id_mensaje=nu.id_mensaje + AND nu.id_user="%s" LEFT JOIN (tnotification_group ng INNER JOIN tusuario_perfil up ON ng.id_group=up.id_grupo @@ -486,6 +492,7 @@ function messages_get_overview( ORDER BY %s %s', $source_fields, + $config['id_user'], $source_join, $config['id_user'], $config['id_user'], diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 1901e47e7b..cebbc1f5b5 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -131,10 +131,13 @@ function check_notification_readable(int $id_message) return false; } + // Using distinct to avoid double response on group messages read by user. $sql = sprintf( - 'SELECT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + 'SELECT DISTINCT tm.*, utimestamp_read > 0 as "read" + FROM tmensajes tm LEFT JOIN tnotification_user nu ON tm.id_mensaje=nu.id_mensaje + AND nu.id_user="%s" AND tm.id_mensaje=%d LEFT JOIN (tnotification_group ng INNER JOIN tusuario_perfil up @@ -143,6 +146,7 @@ function check_notification_readable(int $id_message) ) ON tm.id_mensaje=ng.id_mensaje WHERE utimestamp_erased is null AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))', + $config['id_user'], $id_message, $config['id_user'], $config['id_user'] From c355a581ff1ac4ccdc0de60f0643ac0f4809fff8 Mon Sep 17 00:00:00 2001 From: fermin831 <fermin.hernandez@artica.es> Date: Mon, 11 Feb 2019 17:53:37 +0100 Subject: [PATCH 060/262] Added toasts to notifications Former-commit-id: 7429bf8d9c4f4e8bb16549172a59c33d22185821 --- pandora_console/general/header.php | 73 ++++++++++++++++-- pandora_console/include/styles/pandora.css | 87 ++++++++++++++++++++++ 2 files changed, 155 insertions(+), 5 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index cf001942f0..e9743dd99c 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -411,6 +411,38 @@ config_check(); element.style.display = "none" } + function click_on_notification_toast(event) { + // TODO action. + document.getElementById(event.target.id).remove(); + } + + function print_toast(title, subtitle, severity, id, onclick) { + // TODO severity. + severity = ''; + + // Start the toast. + var toast = document.createElement('div'); + toast.className = 'snackbar ' + severity; + toast.setAttribute('onclick', onclick); + toast.id = id; + + // Fill toast. + var toast_title = document.createElement('h3'); + var toast_text = document.createElement('p'); + toast_title.innerHTML = title; + toast_text.innerHTML = subtitle; + toast.appendChild(toast_title); + toast.appendChild(toast_text); + + // Show and program the hide event. + toast.className = toast.className + ' show'; + setTimeout(function(){ + toast.className = toast.className.replace("show", ""); + }, 8000); + + return toast; + } + function check_new_notifications() { var last_id = document.getElementById('notification-ball-header') .getAttribute('last_id'); @@ -420,12 +452,27 @@ config_check(); } jQuery.post ("ajax.php", - {"page" : "godmode/setup/setup_notifications", + { + "page" : "godmode/setup/setup_notifications", "check_new_notifications" : 1, "last_id": last_id }, function (data, status) { + // Clean the toasts wrapper at first. + var toast_wrapper = document.getElementById( + 'notifications-toasts-wrapper' + ); + if (toast_wrapper === null) { + console.error('Cannot place toast notifications.'); + return; + } + while (toast_wrapper.firstChild) { + toast_wrapper.removeChild(toast_wrapper.firstChild); + } + + // Return if no new notification. if(!data.has_new_notifications) return; + // Substitute the ball var new_ball = atob(data.new_ball); var ball_wrapper = document @@ -437,10 +484,18 @@ config_check(); } ball_wrapper.innerHTML = new_ball; - // Show the toasts - //TODO - - + // Add the new toasts. + data.new_notifications.forEach(function(ele) { + toast_wrapper.appendChild( + print_toast( + ele.description, + ele.mensaje, + ele.criticity, + 'notification-toast-id-' + ele.id_mensaje, + 'click_on_notification_toast(event)' + ) + ); + }); }, "json" ) @@ -465,6 +520,14 @@ config_check(); // Check new notifications on a periodic way setInterval(check_new_notifications, 10000); + // Print the wrapper for notifications + var notifications_toasts_wrapper = document.createElement('div'); + notifications_toasts_wrapper.id = 'notifications-toasts-wrapper'; + document.body.insertBefore( + notifications_toasts_wrapper, + document.body.firstChild + ); + <?php if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET['refr']))) { $do_refresh = true; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 499b1f93ec..df67b5e797 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -5357,3 +5357,90 @@ input:disabled + .p-slider { } /* --- END SWITCH --- */ + +/* --- TOAST --- */ +#notifications-toasts-wrapper { + position: fixed; + right: 20px; + top: 70px; + width: 270px; + height: 100%; + z-index: 6; + pointer-events: none; +} + +.snackbar { + max-width: 270px; + background-color: #333; + color: #fff; + text-align: center; + /* border-radius: 2px; */ + padding: 16px; + margin: 10px; + border-radius: 4px; + visibility: hidden; + pointer-events: all; +} + +.snackbar.show { + visibility: visible; + -webkit-animation: fadein 0.5s, fadeout 0.5s 7.5s; + animation: fadein 0.5s, fadeout 0.5s 7.5s; +} + +.snackbar p, +.snackbar h3 { + text-align: left; + margin: 0; + pointer-events: none; +} +.snackbar h3 { + color: white; + margin-bottom: 10px; +} + +@-webkit-keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + to { + bottom: 30px; + opacity: 1; + } +} + +@keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + to { + bottom: 30px; + opacity: 1; + } +} + +@-webkit-keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + to { + bottom: 0; + opacity: 0; + } +} + +@keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + to { + bottom: 0; + opacity: 0; + } +} + +/* --- END TOAST --- */ From 0dbabd3ba3274576e1f5095c978351697693c1fe Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 11 Feb 2019 18:28:00 +0100 Subject: [PATCH 061/262] Improved conversation view (messages) some filters and fixes in functions_messages Former-commit-id: 13597c6556939bbe772d5ed749930e30e5377c47 --- .../include/functions_messages.php | 18 +++- .../operation/messages/message_edit.php | 99 ++++++++++++------- .../operation/messages/message_list.php | 6 +- 3 files changed, 80 insertions(+), 43 deletions(-) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 4cee825ecc..1ecb6dd186 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -339,14 +339,16 @@ function messages_get_message_sent(int $message_id) /** * Counts private messages * - * @param string $user Target user. - * @param boolean $incl_read Whether or not to include read messages. + * @param string $user Target user. + * @param boolean $incl_read Whether or not to include read messages. + * @param boolean $ignore_source Ignore source. * * @return integer The number of messages this user has */ function messages_get_count( string $user='', - bool $incl_read=false + bool $incl_read=false, + bool $ignore_source=false ) { if (empty($user)) { global $config; @@ -361,10 +363,19 @@ function messages_get_count( $read = 'where t.read is null'; } + if ($ignore_source === true) { + $source_sql = ''; + } else { + $source_sql = 'INNER JOIN tnotification_source ns + ON tm.id_source = ns.id + AND ns.enabled = 1'; + } + $sql = sprintf( 'SELECT count(*) FROM ( SELECT DISTINCT tm.*, utimestamp_read > 0 as "read" FROM tmensajes tm + %s LEFT JOIN tnotification_user nu ON tm.id_mensaje=nu.id_mensaje AND nu.id_user="%s" @@ -377,6 +388,7 @@ function messages_get_count( AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0)) ) t %s', + $source_sql, $user, $user, $user, diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index b284bc3d13..8e6173ca24 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -106,34 +106,69 @@ if ($read_message) { $dst_name = $message['id_usuario_destino']; } - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox filters'; - $table->data = []; + // Parse message chain. + ?> - $table->data[0][0] = __('Sender'); - $table->data[0][1] = $user_name.' '.__('at').' '.ui_print_timestamp( - $message['timestamp'], - true, - ['prominent' => 'timestamp'] - ); +<h1>Conversation with <?php echo $user_name; ?></h1> +<h2>Subject: <?php echo $message['subject']; ?></h2> - $table->data[1][0] = __('Destination'); - $table->data[1][1] = $dst_name; + <?php + $conversation = []; + $target_str = $message['mensaje']; + + while (preg_match_all( + '/(.*)On(.*)wrote:(.*)/', + $target_str, + $decoded, + PREG_PATTERN_ORDER + ) !== false && empty($target_str) !== true) { + if (empty($decoded[2]) !== true) { + array_push( + $conversation, + [ + 'message' => array_pop($decoded)[0], + 'date' => array_pop($decoded)[0], + ] + ); + } else { + array_push( + $conversation, + ['message' => $target_str] + ); + } + + $target_str = $decoded[1][0]; + } + + ui_require_css_file('message_edit'); + foreach ($conversation as $row) { + $date = $row['date']; + + if ($date === null) { + $date = date( + $config['date_format'], + $message['timestamp'] + ).' '.$user_name; + } + + $order = [ + "\r\n", + "\n", + "\r", + ]; + $replace = '<br />'; + $parsed_message = str_replace( + $order, + $replace, + io_safe_output($row['message']) + ); + + echo '<div class="container">'; + echo ' <p>'.$parsed_message.'</p>'; + echo '<span class="time-left">'.$date.'</span>'; + echo '</div>'; + } - $table->data[2][0] = __('Subject'); - $table->data[2][1] = html_print_input_text_extended( - 'subject', - $message['subject'], - 'text-subject', - '', - 50, - 70, - true, - false, - '', - 'readonly' - ); $order = [ "\r\n", @@ -143,16 +178,6 @@ if ($read_message) { $replace = '<br />'; $parsed_message = str_replace($order, $replace, $message['mensaje']); - $table->data[3][0] = __('Message'); - $table->data[3][1] = html_print_textarea( - 'message', - 15, - 255, - $message['mensaje'], - 'readonly', - true - ); - // Prevent RE: RE: RE:. if (strstr($message['subject'], 'RE:')) { $new_subj = $message['subject']; @@ -166,8 +191,8 @@ if ($read_message) { $message['timestamp'] ).' '.$user_name.' '.__('wrote').":\n\n".$message['mensaje']; + echo '<form id="delete_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_list&show_sent=1&delete_message=1&id='.$message_id.'">'; - html_print_table($table); echo '</form>'; echo '<form id="reply_message" method="post" action="index.php?sec=message_list&sec2=operation/messages/message_edit&new_msg=1&reply=1">'; @@ -179,7 +204,7 @@ if ($read_message) { echo "<div class= 'action-buttons' style=' width:".$table->width."'>"; html_print_submit_button( - __('Delete'), + __('Delete conversation'), 'delete_btn', false, 'form="delete_message" class="sub delete"' diff --git a/pandora_console/operation/messages/message_list.php b/pandora_console/operation/messages/message_list.php index 4a6d48a397..9427159432 100644 --- a/pandora_console/operation/messages/message_list.php +++ b/pandora_console/operation/messages/message_list.php @@ -115,13 +115,13 @@ if ($show_sent) { $messages = messages_get_overview_sent('', 'DESC'); } else { // Messages received. - $num_messages = messages_get_count($config['id_user'], true); + $num_messages = messages_get_count($config['id_user'], true, true); if ($num_messages > 0 && !is_ajax()) { - $unread_messages = messages_get_count($config['id_user']); + $unread_messages = messages_get_count($config['id_user'], false, true); echo '<p>'.__('You have').' <b>'.$unread_messages.'</b> '.__('unread message(s)').'.</p>'; $messages = messages_get_overview(); } else { - $messages = messages_get_overview('status', 'ASC', false); + $messages = messages_get_overview('status', 'ASC'); } } From 72a57bfbec54de973f7c83f371425ac80f76822e Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 11 Feb 2019 19:27:21 +0100 Subject: [PATCH 062/262] minor changes in message edit Former-commit-id: a36fe911f191c3a187c8c70032f3b1aaa0977fea --- pandora_console/operation/messages/message_edit.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index 8e6173ca24..6c100d7c00 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -106,13 +106,9 @@ if ($read_message) { $dst_name = $message['id_usuario_destino']; } - // Parse message chain. - ?> + echo '<h1>Conversation with '.$user_name.'</h1>'; + echo '<h2>Subject: '.$message['subject'].'</h2>'; -<h1>Conversation with <?php echo $user_name; ?></h1> -<h2>Subject: <?php echo $message['subject']; ?></h2> - - <?php $conversation = []; $target_str = $message['mensaje']; @@ -160,7 +156,7 @@ if ($read_message) { $parsed_message = str_replace( $order, $replace, - io_safe_output($row['message']) + trim(io_safe_output($row['message'])) ); echo '<div class="container">'; @@ -319,7 +315,6 @@ if ($reply) { } - if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { $return_all_groups = true; } else { From 332c53b0982eb4bfaae89cb558afd780541ba7ca Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 11 Feb 2019 19:46:46 +0100 Subject: [PATCH 063/262] change behaviour to avoid mr slow updates. Event extended Former-commit-id: c5a6d5448a14b10b6851f59c5f688f360d747606 --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 -- pandora_console/include/ajax/events.php | 6 ++--- pandora_console/include/functions_events.php | 24 ++++++++++++++++++- pandora_console/pandoradb.sql | 3 +-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index d02beda560..f1d1d4dd23 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1856,8 +1856,6 @@ ALTER TABLE `tevento` ADD COLUMN `data` double(22,5) default NULL; ALTER TABLE `tevento` ADD COLUMN `module_status` int(4) NOT NULL default '0'; -ALTER TABLE `tevento` ADD COLUMN `extended_info` tinyint(1) NOT NULL default '0'; - -- --------------------------------------------------------------------- -- Table `tevent_extended` -- --------------------------------------------------------------------- diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index d52220cd1a..711743d735 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -397,7 +397,7 @@ if ($get_extended_event) { // Tabs. $tabs = "<ul style='background:#ffffff !important; border-top: 0px; border-left: 0px; border-right: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-color: #D3D3D3;'>"; $tabs .= "<li><a href='#extended_event_general_page' id='link_general'>".html_print_image('images/lightning_go.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('General').'</span></a></li>'; - if ($event['extended_info'] == 1) { + if (events_has_extended_info($event['id_evento']) === true) { $tabs .= "<li><a href='#extended_event_related_page' id='link_related'>".html_print_image('images/zoom.png', true)."<span style='position:relative;top:-6px;left:5px;margin-right:10px;'>".__('Related').'</span></a></li>'; } @@ -491,7 +491,7 @@ if ($get_extended_event) { $details = events_page_details($event, $server); - if ($event['extended_info'] == 1) { + if (events_has_extended_info($event['id_evento']) === true) { $related = events_page_related($event, $server); } @@ -568,7 +568,7 @@ if ($get_extended_event) { $js .= '});'; - if ($event['extended_info'] == 1) { + if (events_has_extended_info($event['id_evento']) === true) { $js .= ' $("#link_related").click(function (){ $.post ({ diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 600f6b6169..71780ed4e5 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2602,7 +2602,8 @@ function events_get_extended_events(int $id_evento) { return db_get_all_rows_sql( sprintf( - 'SELECT * FROM tevent_extended WHERE id_evento=%d', + 'SELECT * FROM tevent_extended + WHERE id_evento=%d ORDER BY utimestamp DESC', $id_evento ) ); @@ -2610,6 +2611,27 @@ function events_get_extended_events(int $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 tevent_extended WHERE id_evento=%d + ', + $id_event + ) + ); +} + + /** * Generates the 'related' page in event view. * diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index b596dd4411..7e408462ed 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -643,8 +643,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `custom_data` TEXT NOT NULL, `data` double(22,5) default NULL, - `module_status` int(4) NOT NULL default '0', - `extended_info` tinyint(1) NOT NULL default '0' + `module_status` int(4) NOT NULL default '0' PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`), From 851050f04e22acda2e4b73af9a5248bbd1d3caa7 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 11 Feb 2019 19:48:20 +0100 Subject: [PATCH 064/262] message_edit.css added Former-commit-id: f4e88b813dc1b39e50b0f997ace3768a10f406f1 --- .../include/styles/message_edit.css | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 pandora_console/include/styles/message_edit.css diff --git a/pandora_console/include/styles/message_edit.css b/pandora_console/include/styles/message_edit.css new file mode 100644 index 0000000000..f4b2294580 --- /dev/null +++ b/pandora_console/include/styles/message_edit.css @@ -0,0 +1,49 @@ +/* Chat containers */ +.container { + border: 2px solid #dedede; + background-color: #f1f1f1; + border-radius: 5px; + padding: 10px; + margin: 10px 0; +} + +/* Darker chat container */ +.darker { + border-color: #ccc; + background-color: #ddd; +} + +/* Clear floats */ +.container::after { + content: ""; + clear: both; + display: table; +} + +/* Style images */ +.container img { + float: left; + max-width: 60px; + width: 100%; + margin-right: 20px; + border-radius: 50%; +} + +/* Style the right image */ +.container img.right { + float: right; + margin-left: 20px; + margin-right: 0; +} + +/* Style time text */ +.time-right { + float: right; + color: #aaa; +} + +/* Style time text */ +.time-left { + float: left; + color: #999; +} From 738443445c0dbac5bc28eb3d1d41655201458261 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Mon, 11 Feb 2019 20:20:23 +0100 Subject: [PATCH 065/262] minor fix in tevento db script Former-commit-id: cb75a25c47f8025c4d9482ec0f8ebd64365073a7 --- pandora_console/pandoradb.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7e408462ed..874f8b0bb6 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -643,7 +643,7 @@ CREATE TABLE IF NOT EXISTS `tevento` ( `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', `custom_data` TEXT NOT NULL, `data` double(22,5) default NULL, - `module_status` int(4) NOT NULL default '0' + `module_status` int(4) NOT NULL default '0', PRIMARY KEY (`id_evento`), KEY `idx_agente` (`id_agente`), KEY `idx_agentmodule` (`id_agentmodule`), From d40ced2043ad13a0a843528f0f4a08848e17b5fe Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Tue, 12 Feb 2019 11:16:34 +0100 Subject: [PATCH 066/262] alert_command send notification Former-commit-id: ff0eb13b51cdab9c2d188362da0c8b2c4191b2cf --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 7 +- pandora_console/pandoradb_data.sql | 6 +- pandora_server/lib/PandoraFMS/Core.pm | 86 +++++++++++++++++++ 3 files changed, 94 insertions(+), 5 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 482fcb8f4e..61fac7ae74 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1974,4 +1974,9 @@ CREATE TABLE `tnotification_source_group_user` ( ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Add alert command 'Generate notification' +-- ---------------------------------------------------------------------- +INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index e803c83d82..ab1630e489 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -23,7 +23,8 @@ INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (9,'SMS','sendsms _field1_ _field2_','Send SMS using the standard SMS device, using smstools. Uses field2 as text message, field1 as destination phone (include international prefix!)',0,'[\"Destination number\",\"Message\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (10,'Validate Event','Internal type','This alert validate the events matched with a module given the agent name (_field1_) and module name (_field2_)',1,'[\"Agent name\",\"Module name\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (11,'Integria IMS Ticket','Internal type','This alert create a ticket into your Integria IMS.',1,'[\"Integria IMS API path\",\"Integria IMS API pass\",\"Integria IMS user\",\"Integria IMS user pass\",\"Ticket title\",\"Ticket group ID\",\"Ticket priority\",\"Email copy\",\"Ticket owner\",\"Ticket description\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"10,Maintenance;0,Informative;1,Low;2,Medium;3,Serious;4,Very Serious\",\"\",\"\",\"\"]'); - +INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (12,'Remote agent control','/usr/share/pandora_server/util/udp_client.pl _address_ 41122 "_field1_"','This command is used to send commands to the agents with the UDP server enabled. The UDP server is used to order agents (Windows and UNIX) to "refresh" the agent execution: that means, to force the agent to execute and send data',0,'[\"Command\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); +INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (13,'Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); -- -- Dumping data for table `tconfig` -- @@ -1104,10 +1105,7 @@ INSERT INTO `tgis_map_layer` VALUES (1,'Group All',1,0,1,0); -- example alert template -INSERT INTO `talert_commands` (`id`, `name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES (12,'Remote agent control','/usr/share/pandora_server/util/udp_client.pl _address_ 41122 "_field1_"','This command is used to send commands to the agents with the UDP server enabled. The UDP server is used to order agents (Windows and UNIX) to "refresh" the agent execution: that means, to force the agent to execute and send data',0,'[\"Command\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); - -- alert actions (default) - INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES (1,'Mail to Admin',1,'yourmail@domain.es','[PANDORA] Alert from agent _agent_ on module _module_','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','',0,0,'','','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://wiki.pandorafms.com">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','text/html','','','','','',''); INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `id_group`, `action_threshold`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`) VALUES diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3bfd1e1a7d..20af9e9747 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -249,6 +249,7 @@ our @EXPORT = qw( pandora_delete_graph_source pandora_delete_custom_graph pandora_edit_custom_graph + notification_set_targets ); # Some global variables @@ -1459,6 +1460,35 @@ sub pandora_execute_action ($$$$$$$$$;$) { pandora_create_integria_ticket($pa_config, $api_path, $api_pass, $integria_user, $integria_user_pass, $ticket_name, $ticket_group_id, $ticket_priority, $ticket_email, $ticket_owner, $ticket_description); + + # Generate notification + } elsif ($clean_name eq "Generate Notification") { + + # Translate macros + $field3 = subst_alert_macros($field3, \%macros, $pa_config, $dbh, $agent, $module); + $field4 = subst_alert_macros($field4, \%macros, $pa_config, $dbh, $agent, $module); + + # If no targets ignore notification + if (defined($field1) && defined($field2) && ($field1 ne "" || $field2 ne "")) { + my @user_list = map {clean_blank($_)} split /,/, $field1; + my @group_list = map {clean_blank($_)} split /,/, $field2; + + my $notification = {}; + $notification->{'subject'} = safe_input($field3); + $notification->{'mensaje'} = safe_input($field4); + $notification->{'id_source'} = get_db_value($dbh, 'SELECT id FROM tnotification_source WHERE description = ?', safe_input('System status')); + + # Create message + my $notification_id = db_process_insert($dbh,'id_mensaje','tmensajes',$notification); + if (!$notification_id) { + logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3); + } else { + notification_set_targets($pa_config, $dbh, $notification_id, \@user_list, \@group_list); + } + } else { + logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "' Empty targets. Ignored.", 3); + } + # Unknown } else { logger($pa_config, "Unknown action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined ($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3); @@ -5746,6 +5776,62 @@ sub pandora_safe_mode_modules_update { } } +########################################################################## + +=head2 C<< message_set_targets (I<$dbh>, I<$pa_config>, I<$notification_id>, I<$users>, I<$groups>) >> +Set targets for given messaje (users and groups in hash ref) +=cut + +########################################################################## +sub notification_set_targets { + my ($pa_config, $dbh, $notification_id, $users, $groups) = @_; + my $ret = undef; + + if (!defined($pa_config)) { + return undef; + } + + if (!defined($notification_id)) { + return undef; + } + + if (ref($users) eq "ARRAY") { + my $values = {}; + foreach my $user (@{$users}) { + if (defined($user) && $user eq "") { + next; + } + + $values->{'id_mensaje'} = $notification_id; + $values->{'id_user'} = $user; + } + + $ret = db_process_insert($dbh, '', 'tnotification_user', $values); + if (!$ret) { + return undef; + } + } + + if (ref($groups) eq "ARRAY") { + my $values = {}; + foreach my $group (@{$groups}) { + if ($group != 0 && empty($group)) { + next; + } + + $values->{'id_mensaje'} = $notification_id; + $values->{'id_group'} = $group; + } + + $ret = db_process_insert($dbh, '', 'tnotification_group', $values); + if (!$ret) { + return undef; + } + } + + return 1; +} + # End of function declaration # End of defined Code From 9a3140baf295dc6d907186ac222046ece14dcfc3 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Tue, 12 Feb 2019 12:27:32 +0100 Subject: [PATCH 067/262] notifications. Up to date Former-commit-id: 80b94d79e7ad393fcaea63cbbd7f734a805da751 --- pandora_console/general/header.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e9743dd99c..c80630185f 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -255,21 +255,8 @@ config_check(); $table->data[0][1] = $autorefresh_link_open_img.$autorefresh_img.$autorefresh_link_close; $table->data[0][2] = $autorefresh_link_open_txt.$autorefresh_txt.$autorefresh_link_close.$autorefresh_additional; // ====================================================== - $check_minor_release_available = false; $pandora_management = check_acl($config['id_user'], 0, 'PM'); - $check_minor_release_available = db_check_minor_relase_available(); - - if ($check_minor_release_available) { - if (users_is_admin($config['id_user'])) { - if ($config['language'] == 'es') { - set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_es:Actualizacion#Versi.C3.B3n_7.0NG_.28_Rolling_Release_.29">'.__('Sobre actualización de revisión menor').'</a>', 'Revisión/es menor/es disponible/s'); - } else { - set_pandora_error_for_header('There are one or more minor releases waiting for update. <a style="font-size:8pt;font-style:italic;" target="blank" href="http://wiki.pandorafms.com/index.php?title=Pandora:Documentation_en:Anexo_Upgrade#Version_7.0NG_.28_Rolling_Release_.29">'.__('About minor release update').'</a>', 'minor release/s available'); - } - } - } - echo '<div id="alert_messages" style="display: none"></div>'; if ($config['alert_cnt'] > 0) { From e744dd50ebec8dfc7a2250dfad764371b855fcc8 Mon Sep 17 00:00:00 2001 From: fbsanchez <fborja.sanchez@artica.es> Date: Tue, 12 Feb 2019 13:14:22 +0100 Subject: [PATCH 068/262] Merged from discovery and validated Former-commit-id: af2047a38913f2763b68a8ec15b8f0cd58b8e676 --- pandora_console/godmode/menu.php | 3 + pandora_console/godmode/setup/setup.php | 15 + .../include/functions_notifications.php | 59 + pandora_console/install.php | 1090 ----------------- 4 files changed, 77 insertions(+), 1090 deletions(-) delete mode 100644 pandora_console/install.php diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 69ec49cfce..107cf7febd 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -269,6 +269,9 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); + $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; + if ($config['activate_gis']) { $sub2['godmode/setup/gis']['text'] = __('Map conections GIS'); } diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index f5f229ddd5..ebfc11493f 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -107,6 +107,12 @@ $buttons['ehorus'] = [ 'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=ehorus">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>', ]; +// FIXME: Not definitive icon +$buttons['notifications'] = [ + 'active' => false, + 'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=notifications">'.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'</a>', +]; + $help_header = ''; if (enterprise_installed()) { $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); @@ -143,6 +149,11 @@ switch ($section) { $buttons['ehorus']['active'] = true; $subpage = ' » '.__('eHorus'); break; + + case 'notifications': + $buttons['notifications']['active'] = true; + $subpage = ' » '.__('Notifications'); + break; } // Header @@ -183,6 +194,10 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; + case 'notifications': + include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; + break; + default: enterprise_hook('setup_enterprise_select_tab', [$section]); break; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index cebbc1f5b5..9af36f4c00 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -156,6 +156,65 @@ function check_notification_readable(int $id_message) } +/** + * Returns the target users and groups assigned to be notified on + * desired source. + * + * @param integer $id_source + * + * @return array [users] and [groups] with the targets. + */ +function get_notification_source_targets(int $id_source) +{ + $ret = []; + + $users = db_get_all_rows_sql( + sprintf( + 'SELECT + id_user, + IF(ns.user_editable = 1,nsu.also_mail,ns.also_mail) AS also_mail + FROM tnotification_source_user nsu + INNER JOIN tnotification_source ns + ON ns.id=nsu.id_source + WHERE ns.id = %d + AND ((ns.enabled is NULL OR ns.enabled != 0) + OR (nsu.enabled is NULL OR nsu.enabled != 0))', + $id_source + ) + ); + + if ($users !== false) { + $i = 0; + foreach ($users as $user) { + $ret['users'][$i]['id_user'] = $user['id_user']; + $ret['users'][$i++]['also_mail'] = $user['also_mail']; + } + } + + $groups = db_get_all_rows_sql( + sprintf( + 'SELECT id_group,ns.also_mail + FROM tnotification_source_group nsg + INNER JOIN tnotification_source ns + ON ns.id=nsg.id_source + WHERE ns.id = %d + AND (ns.enabled is NULL OR ns.enabled != 0)', + $id_source + ) + ); + + if ($groups !== false) { + $i = 0; + foreach ($groups as $group) { + $ret['groups'][$i]['id_group'] = $group['id_group']; + $ret['groups'][$i++]['also_mail'] = $group['also_mail']; + } + } + + return $ret; +} + + /** * Return all info from tnotification_source * diff --git a/pandora_console/install.php b/pandora_console/install.php deleted file mode 100644 index 69e11b10bd..0000000000 --- a/pandora_console/install.php +++ /dev/null @@ -1,1090 +0,0 @@ -<?php - -// Pandora FMS - http://pandorafms.com -// ================================================== -// Copyright (c) 2005-2012 Artica Soluciones Tecnologicas -// Please see http://pandorafms.org for full contribution list -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation; version 2 -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>Pandora FMS - Installation Wizard - - - - - - - - - - - - - - - -
- -
- - - -'; - echo " $label "; - echo ''; - if (!extension_loaded($ext)) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - -function check_include($ext, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!include $ext) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - - -function check_exists($file, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!file_exists($file)) { - echo " "; - return 1; - } else { - echo " "; - return 0; - } - - echo ''; -} - - -function check_generic($ok, $label) -{ - echo ""; - if ($ok == 0) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } -} - - -function check_writable($fullpath, $label) -{ - echo ""; - if (file_exists($fullpath)) { - if (is_writable($fullpath)) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } -} - - -function check_variable($var, $value, $label, $mode) -{ - echo ''; - echo " $label "; - echo ''; - if ($mode == 1) { - if ($var >= $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - } else if ($var == $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - - echo ''; -} - - -function parse_mysql_dump($url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysql_query($query)) { - echo mysql_error(); - // Uncomment for debug - echo "
$query
"; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function parse_mysqli_dump($connection, $url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysqli_query($connection, $query)) { - echo mysqli_error(); - // Uncomment for debug - echo "
$query
"; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function random_name($size) -{ - $temp = ''; - for ($a = 0; $a < $size; $a++) { - $temp = $temp.chr(rand(122, 97)); - } - - return $temp; -} - - -function print_logo_status($step, $step_total) -{ - global $banner; - - $header = " -
-
-
- $banner -
-
"; - $header .= " -
- Install step $step of $step_total -
"; - - 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. -
"; - - echo '
'; - - if ($writable == 0) { - echo "
"; - echo ""; - echo '
'; - } else { - echo "
ERROR:You need to setup permissions to be able to write in ./include directory
"; - } - - echo '
'; - - echo "
"; - echo " -
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - - -function install_step1_licence() -{ - echo " -
-
- ".print_logo_status(2, 6)." -
-

GPL2 Licence terms agreement

-

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 "'; - echo '

'; - echo "

"; - } - - echo '
'; - - echo "
-
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - - -function install_step2() -{ - echo " -
-
- ".print_logo_status(3, 6)." -
"; - echo '

Checking software dependencies

'; - echo ''; - $res = 0; - $res += check_variable(phpversion(), '5.2', 'PHP version >= 5.2', 1); - $res += check_extension('gd', 'PHP GD extension'); - $res += check_extension('ldap', 'PHP LDAP extension'); - $res += check_extension('snmp', 'PHP SNMP extension'); - $res += check_extension('session', 'PHP session extension'); - $res += check_extension('gettext', 'PHP gettext extension'); - $res += check_extension('mbstring', 'PHP Multibyte String'); - $res += check_extension('zip', 'PHP Zip'); - $res += check_extension('zlib', 'PHP Zlib extension'); - $res += check_extension('json', 'PHP json extension'); - $res += check_extension('curl', 'CURL (Client URL Library)'); - $res += check_extension('filter', 'PHP filter extension'); - $res += check_extension('calendar', 'PHP calendar extension'); - if (PHP_OS == 'FreeBSD') { - $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); - } else if (PHP_OS == 'NetBSD') { - $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); - } else if (substr(PHP_OS, 0, 3) == 'WIN') { - $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); - } else { - $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); - } - - echo ''; - check_extension('mysql', 'PHP MySQL extension'); - check_extension('mysqli', 'PHP MySQL(mysqli) extension'); - echo '
'; - echo "DB Engines"; - echo ''; - echo '
'; - - if ($res > 0) { - echo " -
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. -
-
- Ignore it. -
"; - } else { - echo "
"; - echo " - "; - echo '
'; - } - - echo '
'; - echo "
"; - echo " -
-
-
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
- "; -} - - -function install_step3() -{ - $options = ''; - if (extension_loaded('mysql')) { - $options .= ""; - } - - if (extension_loaded('mysqli')) { - $options .= ""; - } - - $error = false; - if (empty($options)) { - $error = true; - } - - echo " -
-
- ".print_logo_status(4, 6)." -
-

Environment and database setup

-

- 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.
"; - } - - if (!$error) { - echo ""; - } - - echo ""; - echo '"; - - // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost - echo " - - "; - - echo " "; - - echo ""; - echo '
'; - echo 'DB Engine
'; - - if ($error) { - echo " -
- Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. -
"; - } else { - echo "'; - - echo '
'; - echo ' Installation in
'; - echo "'; - } - - echo "
DB User with privileges
- - -
DB Password for this user
- - -
DB Hostname
- - -
DB Name (pandora by default)
- - -
Drop Database if exists
- -
Full path to HTTP publication directory
- For example /var/www/pandora_console/ -
- - -
'; - echo "URL path to Pandora FMS Console
- For example '/pandora_console' -
- -
- "; - - if (!$error) { - echo "
"; - echo " - "; - echo '
'; - ?> - - '; - - echo ''; - - echo "
"; - echo "
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} - - -function install_step4() -{ - $pandora_config = 'include/config.php'; - - if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) - || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) - ) { - $dbpassword = ''; - $dbuser = ''; - $dbhost = ''; - $dbname = ''; - $engine = ''; - $dbaction = ''; - $dbgrant = ''; - } else { - $engine = $_POST['engine']; - $dbpassword = $_POST['pass']; - $dbuser = $_POST['user']; - $dbhost = $_POST['host']; - $dbaction = $_POST['db_action']; - if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { - $dbgrant = $_POST['dbgrant']; - } else { - $dbgrant = $_SERVER['SERVER_ADDR']; - } - - if (isset($_POST['drop'])) { - $dbdrop = $_POST['drop']; - } else { - $dbdrop = 0; - } - - $dbname = $_POST['dbname']; - if (isset($_POST['url'])) { - $url = $_POST['url']; - } else { - $url = 'http://localhost'; - } - - if (isset($_POST['path'])) { - $path = $_POST['path']; - $path = str_replace('\\', '/', $path); - // Windows compatibility - } else { - $path = '/var/www'; - } - } - - $everything_ok = 0; - $step1 = 0; - $step2 = 0; - $step3 = 0; - $step4 = 0; - $step5 = 0; - $step6 = 0; - $step7 = 0; - - echo " -
-
- ".print_logo_status(5, 6)." -
-

Creating database and default configuration file

- "; - switch ($engine) { - case 'mysql': - if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysql_query("DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysql_query("CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysql_select_db($dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysql_dump('pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysql_dump('pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysql_query( - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysql_query('FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - - case 'mysqli': - $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); - if (mysqli_connect_error() > 0) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysqli_select_db($connection, $dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine, $connection); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysqli_query( - $connection, - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysqli_query($connection, 'FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - } - - echo '
'; - - if ($everything_ok == 1) { - echo "
"; - echo " - "; - echo '
'; - } else { - $info = "
There were some problems. - Installation was not completed. -

Please correct failures before trying again. - All database "; - if ($engine == 'oracle') { - $info .= 'objects '; - } else { - $info .= 'schemes '; - } - - $info .= 'created in this step have been dropped.

-
'; - echo $info; - - switch ($engine) { - case 'mysql': - if (mysql_error() != '') { - echo "
ERROR: ".mysql_error().'.
'; - } - - if ($step1 == 1) { - mysql_query("DROP DATABASE $dbname"); - } - break; - - case 'mysqli': - if (mysqli_error($connection) != '') { - echo "
ERROR: ".mysqli_error($connection).'.
'; - } - - if ($step1 == 1) { - mysqli_query($connection, "DROP DATABASE $dbname"); - } - break; - } - - echo '
'; - } - - echo '
'; - echo "
"; - echo " -
-
- Pandora FMS is an Open Source Software project registered at - SourceForge -
-
"; -} - - -function install_step5() -{ - echo " -
-
- ".print_logo_status(6, 6)." -
-

Installation complete

-

For security, you now must manually delete this installer - ('install.php') file before trying to access to your Pandora FMS console. -

You should also install Pandora FMS Servers before trying to monitor anything; - please read documentation on how to install it.

-

Default user is 'admin' with password 'pandora', - please change it both as soon as possible.

-

Don't forget to check http://pandorafms.com - for updates. -

Select if you want to rename 'install.php'.

-
- - -
-


. -

-
"; - - echo "
-
- Pandora FMS is an OpenSource Software project registered at - SourceForge -
-
"; -} From af907344360b2dc89a0cf5898e1702eff4162083 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 13:29:04 +0100 Subject: [PATCH 069/262] Revert "Merged from discovery and validated" This reverts commit e744dd50ebec8dfc7a2250dfad764371b855fcc8 [formerly af2047a38913f2763b68a8ec15b8f0cd58b8e676]. Former-commit-id: b32e3295f770a72ee587754b0d63ac8df1fd70f8 --- pandora_console/godmode/menu.php | 3 - pandora_console/godmode/setup/setup.php | 15 - .../include/functions_notifications.php | 59 - pandora_console/install.php | 1090 +++++++++++++++++ 4 files changed, 1090 insertions(+), 77 deletions(-) create mode 100644 pandora_console/install.php diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 107cf7febd..69ec49cfce 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -269,9 +269,6 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; - $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); - $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; - if ($config['activate_gis']) { $sub2['godmode/setup/gis']['text'] = __('Map conections GIS'); } diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index ebfc11493f..f5f229ddd5 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -107,12 +107,6 @@ $buttons['ehorus'] = [ 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', ]; -// FIXME: Not definitive icon -$buttons['notifications'] = [ - 'active' => false, - 'text' => ''.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'', -]; - $help_header = ''; if (enterprise_installed()) { $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); @@ -149,11 +143,6 @@ switch ($section) { $buttons['ehorus']['active'] = true; $subpage = ' » '.__('eHorus'); break; - - case 'notifications': - $buttons['notifications']['active'] = true; - $subpage = ' » '.__('Notifications'); - break; } // Header @@ -194,10 +183,6 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; - case 'notifications': - include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; - break; - default: enterprise_hook('setup_enterprise_select_tab', [$section]); break; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 9af36f4c00..cebbc1f5b5 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -156,65 +156,6 @@ function check_notification_readable(int $id_message) } -/** - * Returns the target users and groups assigned to be notified on - * desired source. - * - * @param integer $id_source - * - * @return array [users] and [groups] with the targets. - */ -function get_notification_source_targets(int $id_source) -{ - $ret = []; - - $users = db_get_all_rows_sql( - sprintf( - 'SELECT - id_user, - IF(ns.user_editable = 1,nsu.also_mail,ns.also_mail) AS also_mail - FROM tnotification_source_user nsu - INNER JOIN tnotification_source ns - ON ns.id=nsu.id_source - WHERE ns.id = %d - AND ((ns.enabled is NULL OR ns.enabled != 0) - OR (nsu.enabled is NULL OR nsu.enabled != 0))', - $id_source - ) - ); - - if ($users !== false) { - $i = 0; - foreach ($users as $user) { - $ret['users'][$i]['id_user'] = $user['id_user']; - $ret['users'][$i++]['also_mail'] = $user['also_mail']; - } - } - - $groups = db_get_all_rows_sql( - sprintf( - 'SELECT id_group,ns.also_mail - FROM tnotification_source_group nsg - INNER JOIN tnotification_source ns - ON ns.id=nsg.id_source - WHERE ns.id = %d - AND (ns.enabled is NULL OR ns.enabled != 0)', - $id_source - ) - ); - - if ($groups !== false) { - $i = 0; - foreach ($groups as $group) { - $ret['groups'][$i]['id_group'] = $group['id_group']; - $ret['groups'][$i++]['also_mail'] = $group['also_mail']; - } - } - - return $ret; -} - - /** * Return all info from tnotification_source * diff --git a/pandora_console/install.php b/pandora_console/install.php new file mode 100644 index 0000000000..69e11b10bd --- /dev/null +++ b/pandora_console/install.php @@ -0,0 +1,1090 @@ + + + + + Pandora FMS - Installation Wizard + + + + + + + + + + + + + + + +
+ +
+ + + +'; + echo " $label "; + echo ''; + if (!extension_loaded($ext)) { + echo ""; + return 1; + } else { + echo ""; + return 0; + } + + echo ''; +} + +function check_include($ext, $label) +{ + echo ''; + echo " $label "; + echo ''; + if (!include $ext) { + echo ""; + return 1; + } else { + echo ""; + return 0; + } + + echo ''; +} + + +function check_exists($file, $label) +{ + echo ''; + echo " $label "; + echo ''; + if (!file_exists($file)) { + echo " "; + return 1; + } else { + echo " "; + return 0; + } + + echo ''; +} + + +function check_generic($ok, $label) +{ + echo ""; + if ($ok == 0) { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 0; + } +} + + +function check_writable($fullpath, $label) +{ + echo ""; + if (file_exists($fullpath)) { + if (is_writable($fullpath)) { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 0; + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } +} + + +function check_variable($var, $value, $label, $mode) +{ + echo ''; + echo " $label "; + echo ''; + if ($mode == 1) { + if ($var >= $value) { + echo " "; + return 0; + } else { + echo " "; + return 1; + } + } else if ($var == $value) { + echo " "; + return 0; + } else { + echo " "; + return 1; + } + + echo ''; +} + + +function parse_mysql_dump($url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysql_query($query)) { + echo mysql_error(); + // Uncomment for debug + echo "
$query
"; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +function parse_mysqli_dump($connection, $url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysqli_query($connection, $query)) { + echo mysqli_error(); + // Uncomment for debug + echo "
$query
"; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +function random_name($size) +{ + $temp = ''; + for ($a = 0; $a < $size; $a++) { + $temp = $temp.chr(rand(122, 97)); + } + + return $temp; +} + + +function print_logo_status($step, $step_total) +{ + global $banner; + + $header = " +
+
+
+ $banner +
+
"; + $header .= " +
+ Install step $step of $step_total +
"; + + 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. +
"; + + echo '
'; + + if ($writable == 0) { + echo "
"; + echo ""; + echo '
'; + } else { + echo "
ERROR:You need to setup permissions to be able to write in ./include directory
"; + } + + echo '
'; + + echo "
"; + echo " +
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} + + +function install_step1_licence() +{ + echo " +
+
+ ".print_logo_status(2, 6)." +
+

GPL2 Licence terms agreement

+

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 "'; + echo '

'; + echo "

"; + } + + echo '
'; + + echo "
+
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} + + +function install_step2() +{ + echo " +
+
+ ".print_logo_status(3, 6)." +
"; + echo '

Checking software dependencies

'; + echo ''; + $res = 0; + $res += check_variable(phpversion(), '5.2', 'PHP version >= 5.2', 1); + $res += check_extension('gd', 'PHP GD extension'); + $res += check_extension('ldap', 'PHP LDAP extension'); + $res += check_extension('snmp', 'PHP SNMP extension'); + $res += check_extension('session', 'PHP session extension'); + $res += check_extension('gettext', 'PHP gettext extension'); + $res += check_extension('mbstring', 'PHP Multibyte String'); + $res += check_extension('zip', 'PHP Zip'); + $res += check_extension('zlib', 'PHP Zlib extension'); + $res += check_extension('json', 'PHP json extension'); + $res += check_extension('curl', 'CURL (Client URL Library)'); + $res += check_extension('filter', 'PHP filter extension'); + $res += check_extension('calendar', 'PHP calendar extension'); + if (PHP_OS == 'FreeBSD') { + $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); + } else if (PHP_OS == 'NetBSD') { + $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); + } else if (substr(PHP_OS, 0, 3) == 'WIN') { + $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); + } else { + $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); + } + + echo ''; + check_extension('mysql', 'PHP MySQL extension'); + check_extension('mysqli', 'PHP MySQL(mysqli) extension'); + echo '
'; + echo "DB Engines"; + echo ''; + echo '
'; + + if ($res > 0) { + echo " +
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. +
+
+ Ignore it. +
"; + } else { + echo "
"; + echo " + "; + echo '
'; + } + + echo '
'; + echo "
"; + echo " +
+
+
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+ "; +} + + +function install_step3() +{ + $options = ''; + if (extension_loaded('mysql')) { + $options .= ""; + } + + if (extension_loaded('mysqli')) { + $options .= ""; + } + + $error = false; + if (empty($options)) { + $error = true; + } + + echo " +
+
+ ".print_logo_status(4, 6)." +
+

Environment and database setup

+

+ 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.
"; + } + + if (!$error) { + echo ""; + } + + echo ""; + echo '"; + + // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost + echo " + + "; + + echo " "; + + echo ""; + echo '
'; + echo 'DB Engine
'; + + if ($error) { + echo " +
+ Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. +
"; + } else { + echo "'; + + echo '
'; + echo ' Installation in
'; + echo "'; + } + + echo "
DB User with privileges
+ + +
DB Password for this user
+ + +
DB Hostname
+ + +
DB Name (pandora by default)
+ + +
Drop Database if exists
+ +
Full path to HTTP publication directory
+ For example /var/www/pandora_console/ +
+ + +
'; + echo "URL path to Pandora FMS Console
+ For example '/pandora_console' +
+ +
+ "; + + if (!$error) { + echo "
"; + echo " + "; + echo '
'; + ?> + + '; + + echo ''; + + echo "
"; + echo "
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} + + +function install_step4() +{ + $pandora_config = 'include/config.php'; + + if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) + || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) + ) { + $dbpassword = ''; + $dbuser = ''; + $dbhost = ''; + $dbname = ''; + $engine = ''; + $dbaction = ''; + $dbgrant = ''; + } else { + $engine = $_POST['engine']; + $dbpassword = $_POST['pass']; + $dbuser = $_POST['user']; + $dbhost = $_POST['host']; + $dbaction = $_POST['db_action']; + if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { + $dbgrant = $_POST['dbgrant']; + } else { + $dbgrant = $_SERVER['SERVER_ADDR']; + } + + if (isset($_POST['drop'])) { + $dbdrop = $_POST['drop']; + } else { + $dbdrop = 0; + } + + $dbname = $_POST['dbname']; + if (isset($_POST['url'])) { + $url = $_POST['url']; + } else { + $url = 'http://localhost'; + } + + if (isset($_POST['path'])) { + $path = $_POST['path']; + $path = str_replace('\\', '/', $path); + // Windows compatibility + } else { + $path = '/var/www'; + } + } + + $everything_ok = 0; + $step1 = 0; + $step2 = 0; + $step3 = 0; + $step4 = 0; + $step5 = 0; + $step6 = 0; + $step7 = 0; + + echo " +
+
+ ".print_logo_status(5, 6)." +
+

Creating database and default configuration file

+ "; + switch ($engine) { + case 'mysql': + if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysql_query("DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysql_query("CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysql_select_db($dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysql_dump('pandoradb.sql'); + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysql_dump('pandoradb_data.sql'); + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysql_query( + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysql_query('FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + + case 'mysqli': + $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); + if (mysqli_connect_error() > 0) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysqli_select_db($connection, $dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine, $connection); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysqli_query( + $connection, + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysqli_query($connection, 'FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + } + + echo '
'; + + if ($everything_ok == 1) { + echo "
"; + echo " + "; + echo '
'; + } else { + $info = "
There were some problems. + Installation was not completed. +

Please correct failures before trying again. + All database "; + if ($engine == 'oracle') { + $info .= 'objects '; + } else { + $info .= 'schemes '; + } + + $info .= 'created in this step have been dropped.

+
'; + echo $info; + + switch ($engine) { + case 'mysql': + if (mysql_error() != '') { + echo "
ERROR: ".mysql_error().'.
'; + } + + if ($step1 == 1) { + mysql_query("DROP DATABASE $dbname"); + } + break; + + case 'mysqli': + if (mysqli_error($connection) != '') { + echo "
ERROR: ".mysqli_error($connection).'.
'; + } + + if ($step1 == 1) { + mysqli_query($connection, "DROP DATABASE $dbname"); + } + break; + } + + echo '
'; + } + + echo '
'; + echo "
"; + echo " +
+
+ Pandora FMS is an Open Source Software project registered at + SourceForge +
+
"; +} + + +function install_step5() +{ + echo " +
+
+ ".print_logo_status(6, 6)." +
+

Installation complete

+

For security, you now must manually delete this installer + ('install.php') file before trying to access to your Pandora FMS console. +

You should also install Pandora FMS Servers before trying to monitor anything; + please read documentation on how to install it.

+

Default user is 'admin' with password 'pandora', + please change it both as soon as possible.

+

Don't forget to check http://pandorafms.com + for updates. +

Select if you want to rename 'install.php'.

+
+ + +
+


. +

+
"; + + echo "
+
+ Pandora FMS is an OpenSource Software project registered at + SourceForge +
+
"; +} From 36dd59b2502182c58e96a4095860f3cec12fae9a Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 13:29:43 +0100 Subject: [PATCH 070/262] Added changes without delete install.php Former-commit-id: 686b0dc8e519283508f8f83ff663f6d3b79e7b80 --- pandora_console/godmode/menu.php | 3 + pandora_console/godmode/setup/setup.php | 15 +++++ .../include/functions_notifications.php | 59 +++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 69ec49cfce..107cf7febd 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -269,6 +269,9 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); + $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; + if ($config['activate_gis']) { $sub2['godmode/setup/gis']['text'] = __('Map conections GIS'); } diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index f5f229ddd5..ebfc11493f 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -107,6 +107,12 @@ $buttons['ehorus'] = [ 'text' => ''.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'', ]; +// FIXME: Not definitive icon +$buttons['notifications'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'', +]; + $help_header = ''; if (enterprise_installed()) { $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); @@ -143,6 +149,11 @@ switch ($section) { $buttons['ehorus']['active'] = true; $subpage = ' » '.__('eHorus'); break; + + case 'notifications': + $buttons['notifications']['active'] = true; + $subpage = ' » '.__('Notifications'); + break; } // Header @@ -183,6 +194,10 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_ehorus.php'; break; + case 'notifications': + include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; + break; + default: enterprise_hook('setup_enterprise_select_tab', [$section]); break; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index cebbc1f5b5..9af36f4c00 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -156,6 +156,65 @@ function check_notification_readable(int $id_message) } +/** + * Returns the target users and groups assigned to be notified on + * desired source. + * + * @param integer $id_source + * + * @return array [users] and [groups] with the targets. + */ +function get_notification_source_targets(int $id_source) +{ + $ret = []; + + $users = db_get_all_rows_sql( + sprintf( + 'SELECT + id_user, + IF(ns.user_editable = 1,nsu.also_mail,ns.also_mail) AS also_mail + FROM tnotification_source_user nsu + INNER JOIN tnotification_source ns + ON ns.id=nsu.id_source + WHERE ns.id = %d + AND ((ns.enabled is NULL OR ns.enabled != 0) + OR (nsu.enabled is NULL OR nsu.enabled != 0))', + $id_source + ) + ); + + if ($users !== false) { + $i = 0; + foreach ($users as $user) { + $ret['users'][$i]['id_user'] = $user['id_user']; + $ret['users'][$i++]['also_mail'] = $user['also_mail']; + } + } + + $groups = db_get_all_rows_sql( + sprintf( + 'SELECT id_group,ns.also_mail + FROM tnotification_source_group nsg + INNER JOIN tnotification_source ns + ON ns.id=nsg.id_source + WHERE ns.id = %d + AND (ns.enabled is NULL OR ns.enabled != 0)', + $id_source + ) + ); + + if ($groups !== false) { + $i = 0; + foreach ($groups as $group) { + $ret['groups'][$i]['id_group'] = $group['id_group']; + $ret['groups'][$i++]['also_mail'] = $group['also_mail']; + } + } + + return $ret; +} + + /** * Return all info from tnotification_source * From 27da41c7dabc362652b832bd895d7f5dcbca27dc Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 12 Feb 2019 14:39:01 +0100 Subject: [PATCH 071/262] WIP Host&devices Former-commit-id: cc18e55a30f72c606bb5b5736a5fa771987e0a45 --- pandora_console/godmode/menu.php | 7 + pandora_console/godmode/servers/discovery.php | 67 ++ .../godmode/wizards/HostDevices.class.php | 835 ++++++++++++++++++ .../godmode/wizards/Wizard.interface.php | 16 + .../godmode/wizards/hostDevices.png | Bin 0 -> 5251 bytes pandora_console/godmode/wizards/index.php | 7 + 6 files changed, 932 insertions(+) create mode 100755 pandora_console/godmode/servers/discovery.php create mode 100755 pandora_console/godmode/wizards/HostDevices.class.php create mode 100755 pandora_console/godmode/wizards/Wizard.interface.php create mode 100755 pandora_console/godmode/wizards/hostDevices.png create mode 100755 pandora_console/godmode/wizards/index.php diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 69ec49cfce..7722463c65 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -200,11 +200,18 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, ' $menu_godmode['gservers']['id'] = 'god-servers'; $sub = []; + if (check_acl($config['id_user'], 0, 'PM')) { + $sub['godmode/servers/discovery']['text'] = __('Discover'); + $sub['godmode/servers/discovery']['id'] = 'Discover'; + } + if (check_acl($config['id_user'], 0, 'AW')) { $sub['godmode/servers/modificar_server']['text'] = __('Manage servers'); $sub['godmode/servers/modificar_server']['id'] = 'Manage servers'; } + + // This subtabs are only for Pandora Admin if (check_acl($config['id_user'], 0, 'PM')) { enterprise_hook('ha_cluster'); diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php new file mode 100755 index 0000000000..557b7bf5b3 --- /dev/null +++ b/pandora_console/godmode/servers/discovery.php @@ -0,0 +1,67 @@ +run(); + // TODO: Here we'll controlle if return is a valid recon task id. + exit(); +} + +if ($classname_selected === null) { + // Load classes and print selector. + echo '
    '; + foreach ($classes as $classpath) { + $classname = basename($classpath, '.class.php'); + $obj = new $classname(); + $wiz_data = $obj->load(); + + hd($wiz_data); + ?> +
  • + + <?php echo $classname; ?> +
    +
    +
  • + + '; +} diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php new file mode 100755 index 0000000000..b41788f344 --- /dev/null +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -0,0 +1,835 @@ +id = null; + $this->msg = $msg; + $this->icon = $icon; + $this->label = $label; + $this->page = $page; + $this->url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd' + ); + + return $this; + } + + + /** + * Undocumented function + * + * @return void + */ + public function run() + { + global $config; + $mode = get_parameter('mode', null); + + if ($mode === null) { + echo 'Importar csv'; + echo 'Escanear red'; + return; + } + + if ($mode == 'importcsv') { + return $this->runCSV(); + } + + if ($mode == 'netscan') { + return $this->runNetScan(); + } + + return null; + } + + + /** + * Checks if environment is ready, + * returns array + * icon: icon to be displayed + * label: label to be displayed + * + * @return array With data. + **/ + public function load() + { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + ]; + } + + + // extra methods + + + /** + * Undocumented function + * + * @return void + */ + public function runCSV() + { + global $config; + echo 'formulario csv'; + if (isset($this->page) === false || $this->page === 0) { + $this->page = 0; + + $test = get_parameter('test', null); + + // Check user answers. + if ($test !== null) { + // $this->process_page_0($respuestas_usuario) + $this->page++; + header( + 'Location: '.$this->url.'&page='.$this->page + ); + } else { + // Mostrar pagina 0. + echo 'Aqui vamos a empezar a construir el formulario.'; + ?> +
    + +
    + page == 1) { + // Code... + $this->page++; + return; + header('Location: index.php?class=HostDevices&page='.$this->page); + } else if ($this->page == 2) { + // Code... + $this->page++; + header('Location: index.php?class=HostDevices&page='.$this->page); + } else if ($this->page == 3) { + // Code... + $this->page++; + header('Location: /XXX/discovery/index.php?class=HostDevices&page='.$this->page); + } + + // Page 4, last. + return [ + 'result' => $this->result, + 'id' => $this->id, + 'msg' => $this->msg, + ]; + + } + + + /** + * Undocumented function + * + * @return void + */ + public function runNetScan() + { + global $config; + + echo 'formulario netscan'; + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access Agent Management' + ); + include 'general/noaccess.php'; + return; + } + + include_once $config['homedir'].'/include/functions_users.php'; + + $user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); + $user_groups = array_keys($user_groups); + + if (is_ajax()) { + $get_explanation = (bool) get_parameter('get_explanation', 0); + + if ($get_explanation) { + $id = (int) get_parameter('id', 0); + + $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id); + + echo io_safe_output($explanation); + + return; + } + + $get_recon_script_macros = get_parameter('get_recon_script_macros'); + if ($get_recon_script_macros) { + $id_recon_script = (int) get_parameter('id'); + $id_recon_task = (int) get_parameter('id_rt'); + + if (!empty($id_recon_task) && empty($id_recon_script)) { + $recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task); + } else if (!empty($id_recon_task)) { + $recon_task_id_rs = (int) db_get_value('id_recon_script', 'trecon_task', 'id_rt', $id_recon_task); + + if ($id_recon_script == $recon_task_id_rs) { + $recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task); + } else { + $recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script); + } + } else if (!empty($id_recon_script)) { + $recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script); + } else { + $recon_script_macros = []; + } + + $macros = []; + $macros['base64'] = base64_encode($recon_script_macros); + $macros['array'] = json_decode($recon_script_macros, true); + + echo io_json_mb_encode($macros); + return; + } + + return; + } + + // Edit mode. + if (isset($_GET['update']) || (isset($_GET['upd']))) { + $update_recon = true; + if (isset($_GET['upd'])) { + if ($_GET['upd'] != 'update') { + $update_recon = false; + } else { + $id_rt = get_parameter('upd'); + } + } + + if ($update_recon) { + if (!isset($id_rt)) { + $id_rt = (int) get_parameter_get('update'); + } + + $row = db_get_row('trecon_task', 'id_rt', $id_rt); + $name = $row['name']; + $network = $row['subnet']; + $id_recon_server = $row['id_recon_server']; + $description = $row['description']; + $interval = $row['interval_sweep']; + $id_group = $row['id_group']; + $create_incident = $row['create_incident']; + $id_network_profile = $row['id_network_profile']; + $id_os = $row['id_os']; + $recon_ports = $row['recon_ports']; + $snmp_community = $row['snmp_community']; + $snmp_version = $row['snmp_version']; + $snmp3_auth_user = $row['snmp_auth_user']; + $snmp3_auth_pass = $row['snmp_auth_pass']; + $snmp3_privacy_method = $row['snmp_privacy_method']; + $snmp3_privacy_pass = $row['snmp_privacy_pass']; + $snmp3_auth_method = $row['snmp_auth_method']; + $snmp3_security_level = $row['snmp_security_level']; + $id_recon_script = $row['id_recon_script']; + $field1 = $row['field1']; + $field2 = $row['field2']; + $field3 = $row['field3']; + $field4 = $row['field4']; + if ($id_recon_script == 0) { + $mode = 'network_sweep'; + } else { + $mode = 'recon_script'; + } + + $os_detect = $row['os_detect']; + $resolve_names = $row['resolve_names']; + $os_detect = $row['os_detect']; + $parent_detection = $row['parent_detection']; + $parent_recursion = $row['parent_recursion']; + $macros = $row['macros']; + $alias_as_name = $row['alias_as_name']; + $snmp_enabled = $row['snmp_enabled']; + $vlan_enabled = $row['vlan_enabled']; + + $name_script = db_get_value( + 'name', + 'trecon_script', + 'id_recon_script', + $id_recon_script + ); + + if (! in_array($id_group, $user_groups)) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access Recon Task Management' + ); + include 'general/noaccess.php'; + return; + } + } + } else if (isset($_GET['create']) || isset($_GET['crt'])) { + $create_recon = true; + if (isset($_GET['crt'])) { + if ($_GET['crt'] != 'Create') { + $create_recon = false; + } + } + + if ($create_recon) { + $id_rt = -1; + $name = get_parameter('name'); + $network = get_parameter('network'); + $description = get_parameter('description'); + $id_recon_server = 0; + $interval = 0; + $id_group = 0; + $create_incident = 1; + $snmp_community = 'public'; + $snmp3_auth_user = ''; + $snmp3_auth_pass = ''; + $snmp_version = 1; + $snmp3_privacy_method = ''; + $snmp3_privacy_pass = ''; + $snmp3_auth_method = ''; + $snmp3_security_level = ''; + $id_network_profile = 0; + $id_os = -1; + // Any + $recon_ports = ''; + // Any + $field1 = ''; + $field2 = ''; + $field3 = ''; + $field4 = ''; + $id_recon_script = 0; + $mode = 'network_sweep'; + $os_detect = 0; + $resolve_names = 0; + $parent_detection = 1; + $parent_recursion = 5; + $macros = ''; + $alias_as_name = 0; + $snmp_enabled = 0; + $vlan_enabled = 0; + } + + $modify = false; + if (($name != '') || ($network != '')) { + $modify = true; + } + } + + $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; + if ($is_windows) { + echo '
    '; + echo __('Warning').': '.__('By default, in Windows, %s only support Standard network sweep, not custom scripts', get_product_name()); + echo '
    '; + } + + $table = new stdClass(); + $table->id = 'table_recon'; + $table->width = '100%'; + $table->cellspacing = 4; + $table->cellpadding = 4; + $table->class = 'databox filters'; + + $table->rowclass[3] = 'network_sweep'; + $table->rowclass[5] = 'network_sweep'; + $table->rowclass[7] = 'network_sweep'; + $table->rowclass[8] = 'network_sweep'; + $table->rowclass[11] = 'network_sweep'; + $table->rowclass[12] = 'network_sweep'; + $table->rowclass[18] = 'network_sweep'; + $table->rowclass[19] = 'network_sweep'; + $table->rowclass[20] = 'network_sweep'; + $table->rowclass[21] = 'network_sweep'; + $table->rowclass[22] = 'network_sweep'; + $table->rowclass[23] = 'network_sweep'; + $table->rowclass[24] = 'network_sweep'; + $table->rowclass[25] = 'network_sweep recon_v3'; + $table->rowclass[26] = 'network_sweep recon_v3'; + $table->rowclass[27] = 'network_sweep recon_v3'; + $table->rowclass[28] = 'network_sweep recon_v3'; + $table->rowclass[29] = 'network_sweep recon_v3'; + $table->rowclass[30] = 'network_sweep recon_v3'; + + $table->rowclass[6] = 'recon_script'; + $table->rowclass[13] = 'recon_script'; + $table->rowclass[14] = 'recon_script'; + $table->rowclass[15] = 'recon_script'; + $table->rowclass[16] = 'recon_script'; + $table->rowclass[17] = 'recon_script'; + // Name. + $table->data[0][0] = ''.__('Task name').''; + $table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); + + // Recon server. + $table->data[1][0] = ''.__('Recon server').ui_print_help_tip( + __('You must select a Recon Server for the Task, otherwise the Recon Task will never run'), + true + ); + + $sql = 'SELECT id_server, name + FROM tserver + WHERE server_type = 3 + ORDER BY name'; + $table->data[1][1] = html_print_select_from_sql($sql, 'id_recon_server', $id_recon_server, '', '', '', true); + + $fields['network_sweep'] = __('Network sweep'); + if (!$is_windows) { + $fields['recon_script'] = __('Custom script'); + } + + $table->data[2][0] = ''.__('Mode').''; + $table->data[2][1] = html_print_select($fields, 'mode', $mode, '', '', 0, true); + + // Network. + $table->data[3][0] = ''.__('Network').''; + $table->data[3][0] .= ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true); + $table->data[3][1] = html_print_input_text('network', $network, '', 25, 0, true); + + // Interval. + $interv_manual = 0; + if ((int) $interval == 0) { + $interv_manual = 1; + } + + $table->data[4][0] = ''.__('Interval'); + $table->data[4][0] .= ui_print_help_tip(__('Manual interval means that it will be executed only On-demand'), true); + + $values = [ + 0 => __('Defined'), + 1 => __('Manual'), + ]; + $table->data[4][1] = html_print_select($values, 'interval_manual_defined', $interv_manual, '', '', '', true); + + $table->data[4][1] .= ''; + $table->data[4][1] .= html_print_extended_select_for_time('interval', $interval, '', '', '0', false, true, false, false); + $table->data[4][1] .= ui_print_help_tip(__('The minimum recomended interval for Recon Task is 5 minutes'), true); + $table->data[4][1] .= ''; + + // Module template. + $table->data[5][0] = ''.__('Module template').''; + + $sql = 'SELECT id_np, name + FROM tnetwork_profile + ORDER BY name'; + $table->data[5][1] = html_print_select_from_sql($sql, 'id_network_profile', $id_network_profile, '', __('None'), 0, true); + + // Recon script. + $data[1] = ''; + $table->data[6][0] = ''.__('Recon script').''; + + $sql = "SELECT id_recon_script, name + FROM trecon_script + WHERE name <> 'IPAM Recon' + ORDER BY name"; + if ($name_script != 'IPAM Recon') { + $table->data[6][1] = html_print_select_from_sql($sql, 'id_recon_script', $id_recon_script, '', '', '', true); + $table->data[6][1] .= "'; + $table->data[6][1] .= $data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); + } else { + $table->data[6][1] = 'IPAM Recon'; + } + + // OS. + $table->data[7][0] = ''.__('OS').''; + + $sql = 'SELECT id_os, name + FROM tconfig_os + ORDER BY name'; + $table->data[7][1] = html_print_select_from_sql($sql, 'id_os', $id_os, '', __('Any'), -1, true); + + // Recon ports. + $table->data[8][0] = ''.__('Ports').''; + $table->data[8][1] = html_print_input_text('recon_ports', $recon_ports, '', 25, 0, true); + $table->data[8][1] .= ui_print_help_tip( + __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), + true + ); + + // Group. + $table->data[9][0] = ''.__('Group'); + $groups = users_get_groups(false, 'PM', false); + $table->data[9][1] = html_print_select_groups(false, 'PM', false, 'id_group', $id_group, '', '', 0, true); + + // Incident. + $values = [ + 0 => __('No'), + 1 => __('Yes'), + ]; + $table->data[10][0] = ''.__('Incident'); + $table->data[10][1] = html_print_select( + $values, + 'create_incident', + $create_incident, + '', + '', + '', + true + ).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true); + + // snmp_enabled. + $table->data[11][0] = ''.__('SNMP enabled'); + $table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true); + + // SNMP default community. + $table->data[12][0] = ''.__('SNMP Default community'); + $table->data[12][0] .= ui_print_help_tip(__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true); + $table->data[12][1] = html_print_input_text('snmp_community', $snmp_community, '', 35, 0, true); + + // SNMP version. + $snmp_versions['1'] = 'v. 1'; + $snmp_versions['2'] = 'v. 2'; + $snmp_versions['2c'] = 'v. 2c'; + $snmp_versions['3'] = 'v. 3'; + $table->data[24][0] = ''._('SNMP version'); + $table->data[24][1] = html_print_select($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true); + + $table->data[25][0] = ''.__('Auth user'); + $table->data[25][1] = html_print_input_text( + 'snmp_auth_user', + $snmp3_auth_user, + '', + 15, + 60, + true, + '', + false, + '', + '' + ); + $table->data[26][0] = ''.__('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); + $table->data[26][1] = html_print_input_password( + 'snmp_auth_pass', + $snmp3_auth_pass, + '', + 15, + 60, + true, + '', + false, + '' + ); + $table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true); + + $table->data[27][0] = ''.__('Privacy method'); + $table->data[27][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', ''); + $table->data[28][0] = ''.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); + $table->data[28][1] = html_print_input_password( + 'snmp_privacy_pass', + $snmp3_privacy_pass, + '', + 15, + 60, + true, + '', + false, + '' + ); + $table->data[29][0] = ''.__('Auth method'); + $table->data[29][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', ''); + $table->data[30][0] = ''.__('Security level'); + $table->data[30][1] = html_print_select( + [ + 'noAuthNoPriv' => __('Not auth and not privacy method'), + 'authNoPriv' => __('Auth and not privacy method'), + 'authPriv' => __('Auth and privacy method'), + ], + 'snmp_security_level', + $snmp3_security_level, + '', + '', + '', + true, + false, + false, + '', + '' + ); + + // Explanation. + $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); + + $table->data[13][0] = ''.__('Explanation').''; + $table->data[13][1] = "'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); + + // A hidden "model row" to clone it from javascript to add fields dynamicaly. + $data = []; + $data[0] = 'macro_desc'; + $data[0] .= ui_print_help_tip('macro_help', true); + $data[1] = html_print_input_text('macro_name', 'macro_value', '', 100, 255, true); + $table->colspan['macro_field'][1] = 3; + $table->rowstyle['macro_field'] = 'display:none'; + $table->data['macro_field'] = $data; + + // If there are $macros, we create the form fields. + if (!empty($macros)) { + $macros = json_decode($macros, true); + + foreach ($macros as $k => $m) { + $data = []; + $data[0] = ''.$m['desc'].''; + if (!empty($m['help'])) { + $data[0] .= ui_print_help_tip($m['help'], true); + } + + if ($m['hide']) { + $data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true); + } else { + $data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true); + } + + $table->colspan['macro'.$m['macro']][1] = 3; + $table->rowclass['macro'.$m['macro']] = 'macro_field'; + + $table->data['macro'.$m['macro']] = $data; + } + } + + // Comments. + $table->data[18][0] = ''.__('Comments'); + $table->data[18][1] = html_print_input_text('description', $description, '', 45, 0, true); + + // OS detection. + $table->data[19][0] = ''.__('OS detection'); + $table->data[19][1] = html_print_checkbox('os_detect', 1, $os_detect, true); + + // Name resolution. + $table->data[20][0] = ''.__('Name resolution'); + $table->data[20][1] = html_print_checkbox('resolve_names', 1, $resolve_names, true); + + // Parent detection. + $table->data[21][0] = ''.__('Parent detection'); + $table->data[21][1] = html_print_checkbox('parent_detection', 1, $parent_detection, true); + + // Parent recursion. + $table->data[22][0] = ''.__('Parent recursion'); + $table->data[22][1] = html_print_input_text('parent_recursion', $parent_recursion, '', 5, 0, true).ui_print_help_tip(__('Maximum number of parent hosts that will be created if parent detection is enabled.'), true); + + // Is vlan_enabled. + $table->data[23][0] = ''.__('Vlan enabled'); + $table->data[23][1] = html_print_checkbox('vlan_enabled', 1, $vlan_enabled, true); + + // Alias as name + // NOTE: The 7.0NG Recon Server will not generate random names, since IP + // address collisions could have other consequences. + // $table->data[22][0] = "".__('Alias as Name'); + // $table->data[22][1] = html_print_checkbox ('alias_as_name', 1, $alias_as_name, true); + // Different Form url if it's a create or if it's a update form. + echo '
    '; + html_print_table($table); + echo '
    '; + + if ($id_rt != -1) { + if ($name_script != 'IPAM Recon') { + html_print_submit_button(__('Update'), 'crt', false, 'class="sub upd"'); + } + } else { + html_print_submit_button(__('Add'), 'crt', false, 'class="sub wand"'); + } + + echo '
    '; + + echo '
    '; + + ui_require_javascript_file('pandora_modules'); + ?> + + $this->result, + 'id' => $this->id, + 'msg' => $this->msg, + ]; + */ + + } + + +} diff --git a/pandora_console/godmode/wizards/Wizard.interface.php b/pandora_console/godmode/wizards/Wizard.interface.php new file mode 100755 index 0000000000..6d1ac73783 --- /dev/null +++ b/pandora_console/godmode/wizards/Wizard.interface.php @@ -0,0 +1,16 @@ +cv-ny18iMfovj7YD0gdX7qp$L z$L6I*IRF66s`^+_-}}>gn*D3=Xxfii3d+Z&C)3d;r(YKNAcVx)JbzgN5gOTamEKKL z+6_TW@Ktekb{=*~sHw*AcNnf4YL4=>Mn$58%kOeCy|2YXV-%Kw<|?A~(Xoqt>?teh z8-A|xpjOB;;I@j(K%-Wl*5LVr)B4%tM!(Wog$Q^|ET~n@NMR8YMaiSA&Id~zK*V9w0|fvW0e_ZthaX7{V;fbp;2AcfxxDl$#Ecqu63Tl9IP@Q!1(&sJM0L8yac_6o{( zcH+WgPQf^_+k?R65_|#Ops~QT)=) zEPW`M`Tv{Ze}zOSi?=%a)C9GIGV(m(%bEqwtx~KpdUk%nqV!;_9Cc$__!3G+O6p?R z#M%(f5O3G<8&6H4s;eILZ5@{a6+AtwJPxwv-uP|PngJCBT6!7WDs%N8ii(JonAN#! z4F)n@rVZW>Cvs_ntt-aor!8BzpKCu%7#|R<7Yl$5;uma9Z(-Yy)fN}P7N zaNV4*P*PJos^0$1#sUZliRC??h5wj&!R~ct zGUN_1HTH@K6{rXdR`$=G8-&as6g+P?4C2JM%+Z;hJ<e;Xo>m7V^<=R4U4D0u-K^ddqpDz)a-;v`tX5`;T_ADv6rt*6-q~ohgY#zZvbOs zVwg7jH(IzRsbf`Mxh+OA{XO(0l|jyxAd}P!3kzv!X+fObOQ4-jBq!7I+S=~%DZe?9 zXdEbT3Dv#h+dvl=Zqg8XER(6dyxgBn8*DXPWbjA>6%pKIiNoQrSm_Qol36ER1@(?; zpu*>p63txQHsM{|_VH=I-R^f~p(IMA_zW*Uzq+R8;u|Y(?}GgNB`a5fI4DQUp!BxcT1-p~tlZ;@IxpjX5X4#ed>vQXs}=jN*EKgkUpRd>#lMod zu{OFp*i()zCC?dgrv;YblCS}ZGNEmO)z#HyR6*1~!BTs!zE^7AF$F7ITU)cRvX%^q zGYi~-s=ADoL1bmkFK(Ecb8>RlCu^2||5ov0X@7y|42irWzA;gyp55OnZRm?ersS!s zsR0!WN=i01HvCS$BO$NMG(LwkSM-!ePd#pUJYJ4@u6%F6EUZkcpKC6XYU25^2l`;g}lyi^hX7@TqOG~Rl;FxV}z@chq)~kV`XJU7LGb)`R zYxA=@2k)e=_J5a?p0Q?L8Ck?5ncJ^8+_=EptuzhUDCRS!_l9J(rHQD}1UdrlMf!+vx9bUBknH)N=y(iqbLzbuP%dLjFz!x_p z4k#Jt4OTz+OZtWmS_oO&S7*EzZZ@`SZJf=ZC*#FxMtZHln1hDX#Z&5;w|*(#(0vm>R>GY5LEV)ApY_B7~Azwf#-hw-g&YWt6NBBc;n{CNwgveqNo5^ z92K521=544+F!yXJQiCIsVPe}61y>+AvqpN7z*|@J$U2s=uLeYca zfxs*GLDMJ7A(I?+CP7ViA2i|+uZ^xlL7>F?GHxOMp%~t7%_z*?G^hiH4|wTO-Tmd6 z>DM?O_zm2Gk~yxoAcP74Y|ELbK(BS8)93iB9;BuTZ9A9?+LK>2LNt_S(a%TZDfMy< z$Bwf?z2qhx^Vo%#X(ZV@%82!>+m;cnW8J@1&VRfPVNpp@t;(yoLRo-4;gXjYonvR; zf1AaIQYb?Iy)riDq^?dFF6aZ=-Ia+{>dEw!J=Q+h!N+`;#yfm^dGMzcAi;&2gI3^J#5yi7u%lXr;T z;RUY@<)D|rY?H%k&|NLQ3T(U^{xZUsSzPXD0UP-(eYg8ra7yjS#62`4wv|Wi9kl=gRWS z%#+T2zuTT``S1U2N3wwPK8;d@JiB|^;*1EmIW!AL%|EY(t#za7Jf_yHBr#Z?$HcDF zB(^GlxT06(M`;;&ZLGe(fU~KmeFG5^T`yJg$Rgw6Ox-z!Y`|vMH0-k|uUUWHnhMaG zb=JH1E-}#ZaO0GSV4?6?eOX#PKl%6IeX;t^_c}3QX<}XDdVB2y`JNn3#UbhEvlB!I zQcaldkl&K82H*zQbQ1ZK)9s?EgTFT)j@ogKS{(OhE*MF5jhLuZ@rks?E4-$}yz=iLA1~zh;>`cUSN5FmyVKCqjAbc&Qhi$La~c(xRvWsG^RhWJih3 zuoefA$0swqz?}Z)$?<3JuO#t&ufIPy2OIVB@RY16=|u1~)m9MEYIWzET^^Sm=5Rvr zM}z$n@8S&&z6fiGtw8V;FBvkFrBJW(-a+4R3BB{i5%jJk<>NahJLW-j#jq#guIMB} zAqXr9`F((GkehH)>k-7QRLLmxGnD5XR^~jwJ-2?42Mn*^bzx_@t$>$vFD0&-xm# zmg?_l-7T>nwjtp9b0}rtFp9+sM`Z*kFpa0iRNLm%oy7qVKu%ZDYL0hkIkQmO)f) zWNG53^x0=K-c?UJgMDDa(W2aqhq%>uVPL?^X`{)!lfkvUYCVtSOcem&MlHRetsyn% zR^j1&irUe{1jSFj?_=V})Ff*%KW}fDL*kI5Y>J?|ML#nOOO2>^fKvPs|K1)11OR}- z*{?+oA$92>P?aEnF&Jiee`(Es{ke#+1bYFdPP#~}U#V~fO+qij`b0C2HF z4rxUaoT|02Fz_dB>m}qM?col?Ky&@y%QC}~67U4-F?Eg8wm+rTPzT8O({_mq5c>!X zEJ3NAf~{f?-)M=04i0Me#j9*2A}CXc>S26y!z}Efrx{?=rOl zp|cuOk!yFlxNP=1hxq68KwieJUXm2&v&jRxVhLZx%z(DYB^F5zA~E!BEm}j%*^JHof^bVM_$kdn}Mj>^WuE&CJ+ZR;0HiK2b_gQCv$-- zEuO-Qeh-}t4BPxUp^2nPr-N!-XX4J$dS+^5B{=<4xur?fX!E%7v{dQo9X0ngM9T}z zcHy<1&m*5nrlx&v+bNSbk!+R`NWJ)Aq3Es@>mjB~>yb~%=GHVwLVrrUKvdSruDnof=5!GS}PQjh9T4lQ5oL=Myq@9ufJqfmh4?>})t} z)+dfwWoBw-dpdRMX)Y8&g^xk-m^!gq%^xlQ&Iy3w0qCao1&&X3Q>1MWav;WzELMOE z_OvZQz-cHWW8DY89X~WBe@uXjBVaNsEZ5uFuym$p$9w)bid}Jg%%@Z!?XgeCH#7(U zqPp|fOlI3{!P6)?740cDDppO#(3;+8!ZpuZTEV!})Iy|D33Y)im@;aIy z-+{S$Dwi){5~*M}G2-S@B=274Xc!y!a#5yb`2DQoZPtwOdU2jMhOdspk}&kUwl{Bn5m*7212Nj!Xh<9sX4 z%hh}OUeoT{&Bo;T0z-cMB8gE$Hom>}G0hS|8nc|=DEFz>Pu;{NB?$i^$TB!Pzn5Kp zRBESt2m6r3&Y%j=*}7&?OqBajF^6uu#b?8~>{wLSCz`1RYtN&bId5@I%@cbuc3>7O ztIU|in6G)QyDZcun<=?KYL__MXyhndEYJ(9e=gK;xIY(otJkhCJESzX`e=*prdqn6 z%VfL3!&TuL{59Kf#@?A_F9-MVQ7I9z8a>VKr>8=rOwK=z^;Y{F4SXDJOfpfm-}cEI z{$}V*zN}7PzjGsuj81`GQJkoVk%>XtUVapNvDBM-jO7zv|3!7Im&;dZfl8G{Xi(&y zZ7Q~7T{%@Wp7lssrTEdl*?S=o_uYkS(P=U!*p-Lz-jpY!M_xk+!>IC8&pP(=a zIqky*q{%46<5Op1DH77dSwTeq83Yp$m+w6JtMwPF?MCy zMMbL~IMLYW`>S3r_{cRPm)l=eE#=-xb7t&_x-08e?UGpLcPKrJtSi{iN`FLLW-Jq`j;%SskT-z=H~RSsN+-n4EaK+%0K9G?^s!JE>IuP`*Sn(E zEMkd<0fNWt<{D1*A44GRU%v!EvUT}Y+|T+G*ihNload(); From 325f5e87755b6e8f69817acd3b054aa369ef1960 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 15:27:14 +0100 Subject: [PATCH 072/262] Added onclik con notification toasts Former-commit-id: 7d0c7a7cc9dacc0e52c7f362a3301ed87a7205d3 --- pandora_console/general/header.php | 58 ++++++++++++++----- .../godmode/setup/setup_notifications.php | 24 ++++++++ .../include/functions_messages.php | 26 ++++++++- 3 files changed, 93 insertions(+), 15 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 03ccfc4dfc..a6c1630ceb 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -197,7 +197,6 @@ config_check(); if (!isset($_GET['refr'])) { $_GET['refr'] = null; } - $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '".$config['id_user']."'"); $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); @@ -398,8 +397,37 @@ config_check(); } function click_on_notification_toast(event) { - // TODO action. - document.getElementById(event.target.id).remove(); + var match = /notification-toast-id-([0-9]+)/.exec(event.target.id); + if (!match) { + console.error( + "Cannot handle toast click event. Id not valid: ", + event.target.id + ); + return; + } + jQuery.post ("ajax.php", + { + "page" : "godmode/setup/setup_notifications", + "mark_notification_as_read" : 1, + "message": match[1] + }, + function (data, status) { + console.log(data.url) + if (!data.result) { + console.error("Cannot redirect to URL."); + return; + } + window.location.replace(data.url); + document.getElementById(event.target.id).remove(); + }, + "json" + ) + .fail(function(xhr, textStatus, errorThrown){ + console.error( + "Failed onclik event on toast. Error: ", + xhr.responseText + ); + }); } function print_toast(title, subtitle, severity, id, onclick) { @@ -471,17 +499,19 @@ config_check(); ball_wrapper.innerHTML = new_ball; // Add the new toasts. - data.new_notifications.forEach(function(ele) { - toast_wrapper.appendChild( - print_toast( - ele.description, - ele.mensaje, - ele.criticity, - 'notification-toast-id-' + ele.id_mensaje, - 'click_on_notification_toast(event)' - ) - ); - }); + if (Array.isArray(data.new_notifications)) { + data.new_notifications.forEach(function(ele) { + toast_wrapper.appendChild( + print_toast( + ele.description, + ele.mensaje, + ele.criticity, + 'notification-toast-id-' + ele.id_mensaje, + 'click_on_notification_toast(event)' + ) + ); + }); + } }, "json" ) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index ad40926220..3d7c04fb44 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -125,6 +125,30 @@ if (get_parameter('check_new_notifications', 0)) { return; } +if (get_parameter('mark_notification_as_read', 0)) { + hd("asdfe", true); + $message = (int) get_parameter('message', 0); + messages_process_read($message); + // TODO check read. + $url = messages_get_url($message); + hd("asdfe 2" . $url, true); + // Return false if cannot get the URL. + if ($url === false) { + echo json_encode(['result' => false]); + return; + } + hd("asdfe 03", true); + + // If there is new messages, get the info. + echo json_encode( + [ + 'result' => true, + 'url' => $url, + ] + ); + return; +} + // Notification table. It is just a wrapper. $table_content = new StdClass(); $table_content->data = []; diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 1ecb6dd186..f633866f65 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -215,7 +215,6 @@ function messages_process_read( bool $read=true ) { global $config; - // Check if user has grants to read the message. if (check_notification_readable($message_id) === false) { return false; @@ -560,3 +559,28 @@ function messages_get_overview_sent( $order ); } + + +/** + * Get the URL of a message. If field in db is null, it returs a link to + * messages view. + * + * @param integer $message_id Message id to get URL. + * + * @return mixed False if fails. A string with URL otherwise. + */ +function messages_get_url($message_id) +{ + $messages = messages_get_message($message_id); + if ($messages === false) { + return false; + } + + // Return URL stored if is set in database. + if (isset($messages['url'])) { + return $messages['url']; + } + + // Return the message direction. + return ui_get_full_url('index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$message_id); +} From 3c3d9daa0967114738f9c992d61b75908d0e206e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 15:29:28 +0100 Subject: [PATCH 073/262] Removed unwanted traces Former-commit-id: 23e41d90e1ee5d94758c050de942b6f8fb779613 --- pandora_console/general/header.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index a6c1630ceb..e9b1133bfe 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -412,7 +412,6 @@ config_check(); "message": match[1] }, function (data, status) { - console.log(data.url) if (!data.result) { console.error("Cannot redirect to URL."); return; From 35ea03ddf62f31183e90b5d3a18cf1669d9f6201 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 15:36:41 +0100 Subject: [PATCH 074/262] Fixed notifications global configuration. Do not disable the multiple selects. Former-commit-id: c5148e3adad63300c2b938a78eb46974cceff761 --- .../include/functions_notifications.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 9af36f4c00..3135fbfa16 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -684,8 +684,16 @@ function notifications_print_global_source_configuration($source) // Generate the html for title. $html_selectors = "
    "; - $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $source['id'], $is_group_all); - $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $source['id'], $is_group_all); + $html_selectors .= notifications_print_source_select_box( + notifications_get_user_sources_for_select($source['id']), + 'users', + $source['id'] + ); + $html_selectors .= notifications_print_source_select_box( + $source_groups, + 'groups', + $source['id'] + ); $html_selectors .= '
    '; // Generate the checkboxes and time select. $html_checkboxes = "
    "; @@ -733,18 +741,16 @@ function notifications_print_global_source_configuration($source) /** * Print select boxes of notified users or groups * - * @param array $info_selec All info required for build the selector. - * @param string $id One of users|groups. - * @param string $source_id Id of source. - * @param boolean $disabled Disable the selectors. + * @param array $info_selec All info required for build the selector. + * @param string $id One of users|groups. + * @param string $source_id Id of source. * * @return string HTML with the generated selector */ function notifications_print_source_select_box( $info_selec, $id, - $source_id, - $disabled + $source_id ) { $title = ($id === 'users') ? __('Notified users') : __('Notified groups'); $add_title = ($id === 'users') ? __('Add users') : __('Add groups'); @@ -774,10 +780,7 @@ function notifications_print_source_select_box( '', '', true, - true, - true, - '', - $disabled + true ), html_print_image( 'images/input_add.png', From 105341e5539ca3002f549bf1e7d41e2234c9b671 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 16:01:24 +0100 Subject: [PATCH 075/262] Removed unwanted traces (again) Former-commit-id: c6453610177b1894bc9d65c8297cd4f8ee01092d --- pandora_console/godmode/setup/setup_notifications.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 3d7c04fb44..489c5666d3 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -126,18 +126,15 @@ if (get_parameter('check_new_notifications', 0)) { } if (get_parameter('mark_notification_as_read', 0)) { - hd("asdfe", true); $message = (int) get_parameter('message', 0); messages_process_read($message); // TODO check read. $url = messages_get_url($message); - hd("asdfe 2" . $url, true); // Return false if cannot get the URL. if ($url === false) { echo json_encode(['result' => false]); return; } - hd("asdfe 03", true); // If there is new messages, get the info. echo json_encode( From cc2b2709f9f10b024ee8738e38ea4641a037c0ed Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 16:25:59 +0100 Subject: [PATCH 076/262] Show the notifications with AJAX Former-commit-id: 73f407d13d3805dce879c1431311a4aaec00c152 --- pandora_console/general/header.php | 43 ++++++++++++++++--- .../godmode/setup/setup_notifications.php | 5 +++ .../include/functions_notifications.php | 17 ++++---- pandora_console/include/styles/pandora.css | 2 + 4 files changed, 52 insertions(+), 15 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e9b1133bfe..e82f7da221 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -363,6 +363,9 @@ config_check(); + + + - - \ No newline at end of file diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 489c5666d3..c6b6ef7d47 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -146,6 +146,11 @@ if (get_parameter('mark_notification_as_read', 0)) { return; } +if (get_parameter('get_notifications_dropdown', 0)) { + echo notifications_print_dropdown(); + return; +} + // Notification table. It is just a wrapper. $table_content = new StdClass(); $table_content->data = []; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 3135fbfa16..de0dc46fe9 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -160,7 +160,7 @@ function check_notification_readable(int $id_message) * Returns the target users and groups assigned to be notified on * desired source. * - * @param integer $id_source + * @param integer $id_source Source identificator. * * @return array [users] and [groups] with the targets. */ @@ -635,16 +635,18 @@ function notifications_get_counters() */ function notifications_print_ball($num_notifications, $last_id) { - $class_status = ($num_notifications == 0) ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; + $no_notifications = (int) $num_notifications === 0; + $class_status = ($no_notifications) ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; return sprintf( '
    %s
    ', + ($no_notifications) ? '' : 'onclick="addNotifications(event)"', $class_status, $last_id, $num_notifications @@ -935,16 +937,15 @@ function notifications_print_dropdown() } return sprintf( - " + ", array_reduce( $mess, function ($carry, $message) { diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 0c2fb2e3fe..d479d53268 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4287,10 +4287,12 @@ div#dialog_messages table th:last-child { display: flex; justify-content: center; align-items: center; + cursor: pointer; } .notification-ball-no-messages { background-color: #82b92e; + cursor: inherit; } .notification-ball-new-messages { background-color: #fc4444; From 48724fe033abd191bc27c3c0f92d5a16ed71ebb0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 12 Feb 2019 16:46:21 +0100 Subject: [PATCH 077/262] Added onclick to notification-item's Former-commit-id: 2e4833686b08b104b11ba9023f6eca38e0ed6bd9 --- pandora_console/general/header.php | 2 +- pandora_console/include/functions_notifications.php | 7 ++++++- pandora_console/include/styles/pandora.css | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e82f7da221..2fd30a73c6 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -423,7 +423,7 @@ config_check(); } function click_on_notification_toast(event) { - var match = /notification-toast-id-([0-9]+)/.exec(event.target.id); + var match = /notification-.*-id-([0-9]+)/.exec(event.target.id); if (!match) { console.error( "Cannot handle toast click event. Id not valid: ", diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index de0dc46fe9..746a3c7ed7 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -967,7 +967,11 @@ function notifications_print_dropdown() function notifications_print_dropdown_element($message_info) { return sprintf( - "
    + "

    @@ -978,6 +982,7 @@ function notifications_print_dropdown_element($message_info)

    ", + $message_info['id_mensaje'], html_print_image('images/'.$message_info['icon'], true), $message_info['description'], $message_info['mensaje'] diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d479d53268..477fbced3b 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4305,6 +4305,8 @@ div#dialog_messages table th:last-child { position: absolute; width: 400px; margin-top: -5px; + max-height: 78%; + overflow: auto; } #notification-wrapper::before { content: ""; @@ -4341,6 +4343,7 @@ div#dialog_messages table th:last-child { } .notification-item > * { padding-left: 15px; + pointer-events: none; } .notification-info { From fe50d6caff48b01a14f5556bb61746c87ed3dd10 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 13 Feb 2019 11:09:15 +0100 Subject: [PATCH 078/262] Open toasts and messages into new window Former-commit-id: ff3d565247225032219d4bbb5fa903bdae7730e8 --- pandora_console/general/header.php | 44 +++++++++++++------ .../godmode/setup/setup_notifications.php | 25 ++++++++--- .../include/functions_notifications.php | 7 ++- pandora_console/include/styles/pandora.css | 4 ++ 4 files changed, 58 insertions(+), 22 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 2fd30a73c6..a60118e9a8 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -417,13 +417,26 @@ config_check(); notification_elem.style.left = image_attached - 300 + "px"; } + function notifications_clean_ui(action, self_id) { + switch(action) { + case 'item': + // Recalculate the notification ball. + check_new_notifications(); + break; + case 'toast': + // Only remove the toast element. + document.getElementById(self_id).remove(); + break; + } + } + function notifications_hide() { var element = document.getElementById("notification-content"); element.style.display = "none" } function click_on_notification_toast(event) { - var match = /notification-.*-id-([0-9]+)/.exec(event.target.id); + var match = /notification-(.*)-id-([0-9]+)/.exec(event.target.id); if (!match) { console.error( "Cannot handle toast click event. Id not valid: ", @@ -435,15 +448,14 @@ config_check(); { "page" : "godmode/setup/setup_notifications", "mark_notification_as_read" : 1, - "message": match[1] + "message": match[2] }, function (data, status) { if (!data.result) { console.error("Cannot redirect to URL."); return; } - window.location.replace(data.url); - document.getElementById(event.target.id).remove(); + notifications_clean_ui(match[1], event.target.id); }, "json" ) @@ -455,28 +467,34 @@ config_check(); }); } - function print_toast(title, subtitle, severity, id, onclick) { + function print_toast(title, subtitle, severity, url, id, onclick) { // TODO severity. severity = ''; // Start the toast. - var toast = document.createElement('div'); - toast.className = 'snackbar ' + severity; + var toast = document.createElement('a'); toast.setAttribute('onclick', onclick); - toast.id = id; + toast.setAttribute('href', url); + toast.setAttribute('target', '_blank'); // Fill toast. + var toast_div = document.createElement('div'); + toast_div.className = 'snackbar ' + severity; + toast_div.id = id; var toast_title = document.createElement('h3'); var toast_text = document.createElement('p'); toast_title.innerHTML = title; toast_text.innerHTML = subtitle; - toast.appendChild(toast_title); - toast.appendChild(toast_text); + toast_div.appendChild(toast_title); + toast_div.appendChild(toast_text); + toast.appendChild(toast_div); + + console.log(toast); // Show and program the hide event. - toast.className = toast.className + ' show'; + toast_div.className = toast_div.className + ' show'; setTimeout(function(){ - toast.className = toast.className.replace("show", ""); + toast_div.className = toast_div.className.replace("show", ""); }, 8000); return toast; @@ -528,7 +546,6 @@ config_check(); not_drop.removeChild(not_drop.firstChild); } - // Add the new toasts. if (Array.isArray(data.new_notifications)) { data.new_notifications.forEach(function(ele) { @@ -537,6 +554,7 @@ config_check(); ele.description, ele.mensaje, ele.criticity, + ele.full_url, 'notification-toast-id-' + ele.id_mensaje, 'click_on_notification_toast(event)' ) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index c6b6ef7d47..14a29c4bb2 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -102,6 +102,18 @@ if (get_parameter('check_new_notifications', 0)) { return; } + $messages = messages_get_overview( + 'timestamp', + 'ASC', + false, + true, + 0, + ['id_mensaje' => '>'.$last_id_ui] + ); + if ($messages === false) { + $messages = []; + } + // If there is new messages, get the info. echo json_encode( [ @@ -112,13 +124,12 @@ if (get_parameter('check_new_notifications', 0)) { $counters['last_id'] ) ), - 'new_notifications' => messages_get_overview( - 'timestamp', - 'ASC', - false, - true, - 0, - ['id_mensaje' => '>'.$last_id_ui] + 'new_notifications' => array_map( + function ($elem) { + $elem['full_url'] = messages_get_url($elem['id_mensaje']); + return $elem; + }, + $messages ), ] ); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 746a3c7ed7..6dfcc0615e 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -967,10 +967,12 @@ function notifications_print_dropdown() function notifications_print_dropdown_element($message_info) { return sprintf( - "
    @@ -981,8 +983,9 @@ function notifications_print_dropdown_element($message_info) %s

    -
    ", + ", $message_info['id_mensaje'], + messages_get_url($message_info['id_mensaje']), html_print_image('images/'.$message_info['icon'], true), $message_info['description'], $message_info['mensaje'] diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 477fbced3b..3e6bac9543 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4346,6 +4346,10 @@ div#dialog_messages table th:last-child { pointer-events: none; } +.notification-item:hover { + text-decoration: none; +} + .notification-info { width: 87%; display: flex; From 8be28b5fedd7245f1590a63f52f45d1bf9877e62 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 13 Feb 2019 11:47:33 +0100 Subject: [PATCH 079/262] Removed some header icons (it will be substituted by notifications) Former-commit-id: 29929ee6f9785cf892b3a0afe7779531d5615e6c --- pandora_console/general/header.php | 102 ++--------------------------- 1 file changed, 4 insertions(+), 98 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index a60118e9a8..5cf10bc749 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -57,7 +57,7 @@ config_check(); $table->cellspacing = 0; $table->head = []; $table->data = []; - $table->style[0] = $table->style['clippy'] = $table->style[1] = $table->style[3] = $table->style[4] = $table->style[5] = $table->style[6] = $table->style[8] = $table->style[9] = $table->style['qr'] = $table->style['notifications'] = '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 = ''; @@ -255,42 +228,6 @@ config_check(); // ====================================================== $pandora_management = check_acl($config['id_user'], 0, 'PM'); - 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( @@ -333,16 +270,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); @@ -644,33 +571,12 @@ config_check(); $("#ui_close_dialog_titlebar").click(function () { $("#agent_access").css("display",""); }); - - function blinkmail(){ - $("#yougotmail").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkmail); - } - function blinkalert(){ - $("#yougotalert").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkalert); - } + function blinkpubli(){ $(".publienterprise").delay(100).fadeTo(300,0.2).delay(100).fadeTo(300,1, blinkpubli); } - 0) { - ?> - blinkmail(); - - - - 0) { - ?> - blinkalert(); - - blinkpubli(); + + blinkpubli(); Date: Wed, 13 Feb 2019 12:44:30 +0100 Subject: [PATCH 080/262] Fixed arrow on notifications area Former-commit-id: 6771d282bf7a6b5b9ddd0baec8a0a887f741d931 --- pandora_console/include/functions_notifications.php | 12 +++++++----- pandora_console/include/styles/pandora.css | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 6dfcc0615e..cb23c3cdfd 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -938,12 +938,14 @@ function notifications_print_dropdown() return sprintf( "
    - %s +
    + %s
    -
    +
    +
    ", array_reduce( diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 3e6bac9543..14ddf74326 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4305,8 +4305,6 @@ div#dialog_messages table th:last-child { position: absolute; width: 400px; margin-top: -5px; - max-height: 78%; - overflow: auto; } #notification-wrapper::before { content: ""; @@ -4323,6 +4321,10 @@ div#dialog_messages table th:last-child { margin-left: -12px; border-bottom-color: white; } +#notification-wrapper-inner { + max-height: 400px; + overflow: auto; +} #notification-wrapper-shadow { height: 100%; width: 100%; From 0ecf2bb9c46157089758400746917751bc0d95fd Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 13 Feb 2019 14:43:55 +0100 Subject: [PATCH 081/262] Added pandora db messages purgue Former-commit-id: 23d1f55ac6b7d6d5470fa25860b9bbb1575875df --- pandora_console/godmode/setup/performance.php | 12 ++++++++++++ pandora_console/include/functions_config.php | 8 ++++++++ pandora_server/util/pandora_db.pl | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index b8a397531e..a426c44cc2 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -82,6 +82,18 @@ if (enterprise_installed()) { $table->data[12][1] = html_print_input_text('inventory_purge', $config['inventory_purge'], '', 5, 5, true); } +$table->data[] = [ + __('Max. days before delete old messages'), + html_print_input_text( + 'delete_old_messages', + $config['delete_old_messages'], + '', + 5, + 5, + true + ), +]; + $table_other = new stdClass(); $table_other->width = '100%'; $table_other->class = 'databox filters'; diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index e532deea15..d55eda62e5 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -748,6 +748,10 @@ function config_update_config() } } + if (!config_update_value('delete_old_messages', get_parameter('delete_old_messages'))) { + $error_update[] = __('Max. days before delete old messages'); + } + if (!config_update_value('max_graph_container', get_parameter('max_graph_container'))) { $error_update[] = __('Graph container - Max. Items'); } @@ -1535,6 +1539,10 @@ function config_process_config() } } + if (!isset($config['delete_old_messages'])) { + config_update_value('delete_old_messages', 21); + } + if (!isset($config['max_graph_container'])) { config_update_value('max_graph_container', 10); } diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index d1ff8d455f..ee3ab0d1fa 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -437,6 +437,13 @@ sub pandora_purgedb ($$) { # Delete old tgraph_source data db_do ($dbh,"DELETE FROM tgraph_source WHERE id_graph NOT IN (SELECT id_graph FROM tgraph)"); + + # Delete old messages + log_message ('PURGE', "Deleting old messages."); + if ($conf->{'_delete_old_messages'} > 0) { + my $message_limit = time() - 86400 * $conf->{'_delete_old_messages'}; + db_do ($dbh, "DELETE FROM tmensajes WHERE timestamp < ?", $message_limit); + } } ############################################################################### @@ -656,6 +663,7 @@ sub pandora_load_config_pdb ($) { $conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'"); $conf->{'_days_delete_unknown'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'days_delete_unknown'"); $conf->{'_inventory_purge'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'inventory_purge'"); + $conf->{'_delete_old_messages'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'delete_old_messages'"); $conf->{'_enterprise_installed'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'enterprise_installed'"); $conf->{'_metaconsole'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole'"); $conf->{'_metaconsole_events_history'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'metaconsole_events_history'"); From ed63ef47fa69bc55d32f2820d56337d0d9acff34 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 Feb 2019 14:56:10 +0100 Subject: [PATCH 082/262] Moved ReconServer to DiscoveryServer Former-commit-id: 5e18aa75d669f6b45d3b4e2648f31473fd206091 --- .../general/firts_task/recon_view.php | 2 +- .../godmode/servers/manage_recontask_form.php | 6 +- .../godmode/wizards/HostDevices.class.php | 10 +- .../include/class/ConsoleSupervisor.php | 99 +++++----- pandora_console/include/constants.php | 2 +- pandora_console/include/functions_events.php | 2 +- pandora_console/include/functions_servers.php | 16 +- .../help/en/help_reconscript_definition.php | 2 +- .../include/help/en/help_recontask.php | 4 +- .../include/help/ja/help_recontask.php | 2 +- .../operation/servers/recon_view.php | 2 +- pandora_server/bin/pandora_server | 4 +- pandora_server/lib/PandoraFMS/Core.pm | 2 +- .../{ReconServer.pm => DiscoveryServer.pm} | 65 ++++-- pandora_server/lib/PandoraFMS/Recon/Base.pm | 187 ++++++++++++++++++ pandora_server/lib/PandoraFMS/Tools.pm | 4 +- 16 files changed, 320 insertions(+), 89 deletions(-) rename pandora_server/lib/PandoraFMS/{ReconServer.pm => DiscoveryServer.pm} (92%) diff --git a/pandora_console/general/firts_task/recon_view.php b/pandora_console/general/firts_task/recon_view.php index 026d0f5673..1d81c13e98 100755 --- a/pandora_console/general/firts_task/recon_view.php +++ b/pandora_console/general/firts_task/recon_view.php @@ -19,7 +19,7 @@ ui_require_css_file('firts_task');
    - __('Recon server')]); ?> + __('Discovery server')]); ?>

    diff --git a/pandora_console/godmode/servers/manage_recontask_form.php b/pandora_console/godmode/servers/manage_recontask_form.php index c47416afd7..cbbcde8ec7 100644 --- a/pandora_console/godmode/servers/manage_recontask_form.php +++ b/pandora_console/godmode/servers/manage_recontask_form.php @@ -248,9 +248,9 @@ $table->rowclass[17] = 'recon_script'; $table->data[0][0] = ''.__('Task name').''; $table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); -// Recon server -$table->data[1][0] = ''.__('Recon server').ui_print_help_tip( - __('You must select a Recon Server for the Task, otherwise the Recon Task will never run'), +// Discovery server +$table->data[1][0] = ''.__('Discovery server').ui_print_help_tip( + __('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), true ); diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index b41788f344..3921eac025 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -402,9 +402,9 @@ class HostDevices implements Wizard $table->data[0][0] = ''.__('Task name').''; $table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); - // Recon server. - $table->data[1][0] = ''.__('Recon server').ui_print_help_tip( - __('You must select a Recon Server for the Task, otherwise the Recon Task will never run'), + // Discovery server. + $table->data[1][0] = ''.__('Discovery server').ui_print_help_tip( + __('You must select a Discovery Server for the Task, otherwise the Recon Task will never run'), true ); @@ -818,8 +818,8 @@ function get_explanation_recon_script (id) { } - 900 - ) { - $previous[$key]['modules'] = 0; - } - - $modules_queued = ($queue['queued_modules'] - $previous[$key]['modules']); - - // 50 Modules queued since last check. Or more than 1500 queued. - if ($modules_queued > $MAX_GROWN - || $queue['queued_modules'] > $MAX_QUEUE - ) { - $msg = 'Queue has grown %d modules. Total %d'; - if ($modules_queued <= 0) { - $msg = 'Queue is decreasing in %d modules. But there are %d queued.'; - $modules_queued *= -1; + // Compare queue increments in a not over 900 seconds. + if (empty($previous[$key]['modules']) + || ($time - $previous[$key]['utime']) > 900 + ) { + $previous[$key]['modules'] = 0; } - $this->notify( - [ - 'type' => 'NOTIF.SERVER.QUEUE.'.$key, - 'title' => __( - '%s (%s) performance is being lacked.', - servers_get_server_string_name($type), - $queue['name'] - ), - 'message' => __( - $msg, - $modules_queued, - $queue['queued_modules'] - ), - 'url' => ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60' - ), - ] - ); - } else { - $this->cleanNotifications('NOTIF.SERVER.QUEUE.'.$key); + $modules_queued = ($queue['queued_modules'] - $previous[$key]['modules']); + + // 50 Modules queued since last check. Or more than 1500 queued. + if ($modules_queued > $MAX_GROWN + || $queue['queued_modules'] > $MAX_QUEUE + ) { + $msg = 'Queue has grown %d modules. Total %d'; + if ($modules_queued <= 0) { + $msg = 'Queue is decreasing in %d modules. But there are %d queued.'; + $modules_queued *= -1; + } + + $this->notify( + [ + 'type' => 'NOTIF.SERVER.QUEUE.'.$key, + 'title' => __( + '%s (%s) performance is being lacked.', + servers_get_server_string_name($type), + $queue['name'] + ), + 'message' => __( + $msg, + $modules_queued, + $queue['queued_modules'] + ), + 'url' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60' + ), + ] + ); + } else { + $this->cleanNotifications('NOTIF.SERVER.QUEUE.'.$key); + } + + $new[$key]['modules'] = $queue['queued_modules']; + $new[$key]['utime'] = $time; } - $new[$key]['modules'] = $queue['queued_modules']; - $new[$key]['utime'] = $time; - } + // Update file content. + file_put_contents($idx_file, json_encode($new)); + } else { + // No queue data, ignore. + unlink($idx_file); - file_put_contents($idx_file, json_encode($new)); + // Clean notifications. + $this->cleanNotifications('NOTIF.SERVER.QUEUE.%'); + } } diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index cd1b907c0a..b472f98ad8 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -366,7 +366,7 @@ define('PASSSWORD_POLICIES_EXPIRED', 2); define('SERVER_TYPE_DATA', 0); define('SERVER_TYPE_NETWORK', 1); define('SERVER_TYPE_SNMP', 2); -define('SERVER_TYPE_RECON', 3); +define('SERVER_TYPE_DISCOVERY', 3); define('SERVER_TYPE_PLUGIN', 4); define('SERVER_TYPE_PREDICTION', 5); define('SERVER_TYPE_WMI', 6); diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index f3f3d2b0fa..a2ca914b37 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -1378,7 +1378,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'; diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 249704fe13..ba6659ddc1 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -26,6 +26,8 @@ * ============================================================================ */ +require_once __DIR__.'/constants.php'; + /** * Get a server. @@ -203,7 +205,7 @@ function servers_get_performance() case SERVER_TYPE_EXPORT: case SERVER_TYPE_INVENTORY: case SERVER_TYPE_EVENT: - case SERVER_TYPE_RECON: + case SERVER_TYPE_DISCOVERY: case SERVER_TYPE_SYSLOG: break; } @@ -424,8 +426,8 @@ function servers_get_info($id_server=-1) $id_modulo = 0; break; - case SERVER_TYPE_RECON: - $server['img'] = html_print_image('images/recon.png', true, ['title' => __('Recon server')]); + case SERVER_TYPE_DISCOVERY: + $server['img'] = html_print_image('images/recon.png', true, ['title' => __('Discovery server')]); $server['type'] = 'recon'; $id_modulo = 0; break; @@ -598,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 @@ -978,7 +980,7 @@ function servers_get_server_string_name(int $server) case SERVER_TYPE_EVENT: return __('Event server'); - case SERVER_TYPE_RECON: + case SERVER_TYPE_DISCOVERY: return __('Discovery server'); case SERVER_TYPE_SYSLOG: 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.

    Mode
    diff --git a/pandora_console/include/help/ja/help_recontask.php b/pandora_console/include/help/ja/help_recontask.php index 790c2cdb48..182b249653 100644 --- a/pandora_console/include/help/ja/help_recontask.php +++ b/pandora_console/include/help/ja/help_recontask.php @@ -12,7 +12,7 @@ 検出タスクの名前です。フィルターやテンプレートとは異なり、タスクを区別しやすい説明を入れるだけです。

    -自動検出サーバ(Recon server)
    +自動検出サーバ(Discovery server)
    タスクを割り当てる自動検出サーバです。複数の自動検出サーバがある場合は、自動検出タスクをどのサーバで実行するかを選択します。

    diff --git a/pandora_console/operation/servers/recon_view.php b/pandora_console/operation/servers/recon_view.php index d91b838e8b..84a057d69c 100644 --- a/pandora_console/operation/servers/recon_view.php +++ b/pandora_console/operation/servers/recon_view.php @@ -30,7 +30,7 @@ $servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3'); if ($servers === false) { $servers = []; ui_print_page_header(__('Recon View'), 'images/op_recon.png', false, '', false); - ui_print_error_message(__('Recon Server is disabled')); + ui_print_error_message(__('Discovery Server is disabled')); return; } else { $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index a5e8be893d..53265cb0a0 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -33,7 +33,7 @@ use PandoraFMS::Core; use PandoraFMS::DataServer; use PandoraFMS::NetworkServer; use PandoraFMS::SNMPServer; -use PandoraFMS::ReconServer; +use PandoraFMS::DiscoveryServer; use PandoraFMS::WMIServer; use PandoraFMS::PluginServer; use PandoraFMS::PredictionServer; @@ -123,7 +123,7 @@ sub pandora_startup () { pandora_reset_server (\%Config, $DBH); push (@Servers, new PandoraFMS::DataServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::NetworkServer (\%Config, $DBH)); - push (@Servers, new PandoraFMS::ReconServer (\%Config, $DBH)); + push (@Servers, new PandoraFMS::DiscoveryServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::SNMPServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH)); diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3bfd1e1a7d..ff82d69c53 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4514,7 +4514,7 @@ sub pandora_server_statistics ($$) { $server->{"lag"} = 0; $server->{"module_lag"} = 0; # Recon server - } elsif ($server->{"server_type"} == RECONSERVER) { + } elsif ($server->{"server_type"} == DISCOVERYSERVER) { # Total jobs running on this recon server $server->{"modules"} = get_db_value ($dbh, "SELECT COUNT(id_rt) FROM trecon_task WHERE id_recon_server = ?", $server->{"id_server"}); diff --git a/pandora_server/lib/PandoraFMS/ReconServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm similarity index 92% rename from pandora_server/lib/PandoraFMS/ReconServer.pm rename to pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 277e3a3ec8..7b6fa7c0ea 100644 --- a/pandora_server/lib/PandoraFMS/ReconServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -1,6 +1,6 @@ -package PandoraFMS::ReconServer; +package PandoraFMS::DiscoveryServer; ########################################################################## -# Pandora FMS Recon Server. +# Pandora FMS Discovery Server. # Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org ########################################################################## # Copyright (c) 2005-2009 Artica Soluciones Tecnologicas S.L @@ -57,16 +57,16 @@ use constant OS_ROUTER => 17; use constant OS_SWITCH => 18; ######################################################################################## -# Recon Server class constructor. +# Discovery Server class constructor. ######################################################################################## sub new ($$$$$$) { my ($class, $config, $dbh) = @_; - return undef unless $config->{'reconserver'} == 1; + return undef unless $config->{'reconserver'} == 1 || $config->{'discoveryserver'} == 1; if (! -e $config->{'nmap'}) { - logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1); - print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Recon Server not found.", 1); + logger ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1); + print_message ($config, ' [E] ' . $config->{'nmap'} . " needed by " . $config->{'rb_product_name'} . " Discovery Server not found.", 1); return undef; } @@ -78,14 +78,14 @@ sub new ($$$$$$) { # Restart automatic recon tasks. db_do ($dbh, 'UPDATE trecon_task SET utimestamp = 0 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep > 0', - get_server_id ($dbh, $config->{'servername'}, RECONSERVER)); + get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER)); # Reset (but do not restart) manual recon tasks. db_do ($dbh, 'UPDATE trecon_task SET status = -1 WHERE id_recon_server = ? AND status <> -1 AND interval_sweep = 0', - get_server_id ($dbh, $config->{'servername'}, RECONSERVER)); + get_server_id ($dbh, $config->{'servername'}, DISCOVERYSERVER)); # Call the constructor of the parent class - my $self = $class->SUPER::new($config, RECONSERVER, \&PandoraFMS::ReconServer::data_producer, \&PandoraFMS::ReconServer::data_consumer, $dbh); + my $self = $class->SUPER::new($config, DISCOVERYSERVER, \&PandoraFMS::DiscoveryServer::data_producer, \&PandoraFMS::DiscoveryServer::data_consumer, $dbh); bless $self, $class; return $self; @@ -98,7 +98,7 @@ sub run ($) { my $self = shift; my $pa_config = $self->getConfig (); - print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Recon Server.", 1); + print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Discovery Server.", 1); $self->setNumThreads ($pa_config->{'recon_threads'}); $self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem); } @@ -121,9 +121,10 @@ sub data_producer ($) { # Status -1 means "done". my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task - WHERE id_recon_server = ? - AND disabled = 0 - AND utimestamp = 0 OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP())', $server_id); + WHERE id_recon_server = ? + AND disabled = 0 + AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1) + OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id); foreach my $row (@rows) { # Update task status @@ -154,12 +155,13 @@ sub data_consumer ($$) { logger($pa_config, 'Starting recon task for net ' . $task->{'subnet'} . '.', 10); } - # Call nmap - my $nmap_args = '-nsP -PE --max-retries '.$pa_config->{'icmp_checks'}.' --host-timeout '.$pa_config->{'networktimeout'}.'s -T'.$pa_config->{'recon_timing_template'}; - my $np = new PandoraFMS::NmapParser; eval { my @subnets = split(/,/, safe_output($task->{'subnet'})); my @communities = split(/,/, safe_output($task->{'snmp_community'})); + my @auth_strings = (); + if(defined($task->{'auth_strings'})) { + @auth_strings = split(/,/, safe_output($task->{'auth_strings'})); + } my $recon = new PandoraFMS::Recon::Base( communities => \@communities, @@ -186,6 +188,8 @@ sub data_consumer ($$) { subnets => \@subnets, task_id => $task->{'id_rt'}, vlan_cache_enabled => $task->{'vlan_enabled'}, + wmi_enabled => $task->{'wmi_enabled'}, + auth_strings_array => \@auth_strings, %{$pa_config} ); @@ -748,6 +752,35 @@ sub PandoraFMS::Recon::Base::set_parent($$$) { db_do($self->{'dbh'}, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $agent_parent->{'id_agente'}, $agent->{'id_agente'}); } +########################################################################## +# Create a WMI module for the given agent. +########################################################################## +sub PandoraFMS::Recon::Base::wmi_module { + my ($self, $agent_id, $target, $wmi_query, $wmi_auth, $column, + $module_name, $module_description, $module_type, $unit) = @_; + + # Check whether the module already exists. + my $module_id = get_agent_module_id($self->{'dbh'}, $module_name, $agent_id); + return if ($module_id > 0); + + my ($user, $pass) = ($wmi_auth ne '') ? split('%', $wmi_auth) : (undef, undef); + my %module = ( + 'descripcion' => safe_input($module_description), + 'id_agente' => $agent_id, + 'id_modulo' => 6, + 'id_tipo_modulo' => get_module_id($self->{'dbh'}, $module_type), + 'ip_target' => $target, + 'nombre' => safe_input($module_name), + 'plugin_pass' => defined($pass) ? $pass : '', + 'plugin_user' => defined($user) ? $user : '', + 'snmp_oid' => $wmi_query, + 'tcp_port' => $column, + 'unit' => defined($unit) ? $unit : '' + ); + + pandora_create_module_from_hash($self->{'pa_config'}, \%module, $self->{'dbh'}); +} + ########################################################################## # Update recon task status. ########################################################################## diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index a214d6ba4b..8d24ebf311 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -123,6 +123,12 @@ sub new { # Globally enable/disable SNMP scans. snmp_enabled => 1, + # Globally enable/disable WMI scans. + wmi_enabled => 0, + auth_strings_array => [], + wmi_timeout => 3, + timeout_cmd => '', + # Switch to switch connections. Used to properly connect hosts # that are connected to a switch wich is in turn connected to another switch, # since the hosts will show up in the latter's switch AFT too. @@ -217,6 +223,19 @@ sub new { } } + # Prepare auth array. + # WMI could be launched with '-N' - no pass - argument. + if ($self->{'wmi_enabled'} == 1){ + if (defined($self->{'auth_strings_str'})) { + @{$self->{'auth_strings_array'}} = split(',', $self->{'auth_strings_str'}); + } + + # Timeout available only in linux environments. + if ($^O =~ /lin/i && defined($self->{'plugin_exec'}) && defined($self->{'wmi_timeout'})) { + $self->{'timeout_cmd'} = $self->{'plugin_exec'}.' '.$self->{'wmi_timeout'}.' '; + } + } + # Remove all snmp related values if disabled if (!$self->{'snmp_enabled'}) { $self->{'communities'} = []; @@ -1312,6 +1331,9 @@ sub scan_subnet($) { $progress += $step; $self->snmp_discovery($host); + + # Add wmi scan if enabled. + $self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1); } } # ping scan. @@ -1330,6 +1352,9 @@ sub scan_subnet($) { next if ($self->ping($host) == 0); $self->snmp_discovery($host); + + # Add wmi scan if enabled. + $self->wmi_scan($host) if ($self->{'wmi_enabled'} == 1); } } } @@ -1579,6 +1604,168 @@ sub traceroute_connectivity($$) { } } +########################################################################## +# Returns the credentials with which the host responds to WMI queries or +# undef if it does not respond to WMI. +########################################################################## +sub responds_to_wmi { + my ($self, $target) = @_; + + foreach my $auth (@{$self->{'auth_strings_array'}}) { + my @output; + if ($auth ne '') { + @output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -U $auth //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`; + } else { + @output = `$self->{'timeout_cmd'}$self->{'wmi_client'} -N //$target "SELECT * FROM Win32_ComputerSystem" 2>&1`; + } + + foreach my $line (@output) { + chomp($line); + return $auth if ($line =~ m/^CLASS: Win32_ComputerSystem$/); + } + } + + return undef; +} + +########################################################################## +# Add wmi modules to the given host. +########################################################################## +sub wmi_scan { + my ($self, $target) = @_; + + $self->call('message', "[".$target."] Checking WMI.", 5); + + my $auth = $self->responds_to_wmi($target); + return unless defined($auth); + + $self->call('message', "[".$target."] WMI available.", 10); + # Create the agent if it does not exist. + my $agent_id = $self->call('create_agent', $target); + next unless defined($agent_id); + + # CPU. + my @cpus = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceId FROM Win32_Processor', 0); + foreach my $cpu (@cpus) { + $self->call( + 'wmi_module', + ( + $agent_id, + $target, + "SELECT LoadPercentage FROM Win32_Processor WHERE DeviceId='$cpu'", + $auth, + 1, + "CPU Load $cpu", + "Load for $cpu (%)", + 'generic_data' + ) + ); + } + + # Memory. + my $mem = $self->wmi_get_value($target, $auth, 'SELECT FreePhysicalMemory FROM Win32_OperatingSystem', 0); + if (defined($mem)) { + $self->call('wmi_module', + ( + $agent_id, + $target, + "SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem", + $auth, + 0, + 'FreeMemory', + 'Free memory', + 'generic_data', + 'KB' + ) + ); + } + + # Disk. + my @units = $self->wmi_get_value_array($target, $auth, 'SELECT DeviceID FROM Win32_LogicalDisk', 0); + foreach my $unit (@units) { + $self->call( + 'wmi_module', + ( + $agent_id, + $target, + "SELECT FreeSpace FROM Win32_LogicalDisk WHERE DeviceID='$unit'", + $auth, + 1, + "FreeDisk $unit", + 'Available disk space in kilobytes', + 'generic_data', + 'KB' + ) + ); + } +} + +########################################################################## +# Extra: WMI imported methods. DO NOT EXPORT TO AVOID DOUBLE DEF. +########################################################################## + +########################################################################## +# Performs a wmi get requests and returns the response as an array. +########################################################################## +sub wmi_get { + my ($self, $target, $auth, $query) = @_; + + my @output; + if (defined($auth) && $auth ne '') { + @output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -U $auth //$target "$query" 2>&1`; + }else { + @output = `$self->{'timeout_cmd'}"$self->{'wmi_client'}" -N //$target "$query" 2>&1`; + } + + # Something went wrong. + return () if ($? != 0); + + return @output; +} + +########################################################################## +# Performs a WMI request and returns the requested column of the first row. +# Returns undef on error. +########################################################################## +sub wmi_get_value { + my ($self, $target, $auth, $query, $column) = @_; + my @result; + + my @output = $self->wmi_get($target, $auth, $query); + return undef unless defined($output[2]); + + my $line = $output[2]; + chomp($line); + my @columns = split(/\|/, $line); + return undef unless defined($columns[$column]); + + return $columns[$column]; +} + +########################################################################## +# Performs a WMI request and returns row values for the requested column +# in an array. +########################################################################## +sub wmi_get_value_array { + my ($self, $target, $auth, $query, $column) = @_; + my @result; + + my @output = $self->wmi_get($target, $auth, $query); + foreach (my $i = 2; defined($output[$i]); $i++) { + my $line = $output[$i]; + chomp($line); + my @columns = split(/\|/, $line); + next unless defined($columns[$column]); + push(@result, $columns[$column]); + } + + return @result; +} + +########################################################################## +# END: WMI imported methods. +########################################################################## + 1; __END__ diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 1146e8ce92..aababebd69 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -51,7 +51,7 @@ our @EXPORT = qw( DATASERVER NETWORKSERVER SNMPCONSOLE - RECONSERVER + DISCOVERYSERVER PLUGINSERVER PREDICTIONSERVER WMISERVER @@ -134,7 +134,7 @@ our @EXPORT = qw( use constant DATASERVER => 0; use constant NETWORKSERVER => 1; use constant SNMPCONSOLE => 2; -use constant RECONSERVER => 3; +use constant DISCOVERYSERVER => 3; use constant PLUGINSERVER => 4; use constant PREDICTIONSERVER => 5; use constant WMISERVER => 6; From 74e16b656b19947224edd700963c2bb612b92477 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 13 Feb 2019 15:03:59 +0100 Subject: [PATCH 083/262] Disable max postpone select Former-commit-id: 43460b3304b70d6d0248ace672d51c2b48c3d22c --- pandora_console/include/functions_notifications.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index cb23c3cdfd..16a82898c4 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -713,6 +713,7 @@ function notifications_print_global_source_configuration($source) // Generate the select with the time. $html_select_pospone = __('Users can postpone notifications up to'); + // FIXMEit should not be disabled. $html_select_pospone .= html_print_select( [ SECONDS_5MINUTES => __('5 minutes'), @@ -732,7 +733,8 @@ function notifications_print_global_source_configuration($source) true, false, true, - 'elem-changeable' + 'elem-changeable', + true, ); // Return all html. From 9951aadab34471321da98891f4d228d3ad12b451 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 13 Feb 2019 15:04:53 +0100 Subject: [PATCH 084/262] Fixed typo Former-commit-id: 469f46c34caefcb6b810e99f88a9223434959182 --- pandora_console/include/functions_notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 16a82898c4..7f4b40c98b 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -734,7 +734,7 @@ function notifications_print_global_source_configuration($source) false, true, 'elem-changeable', - true, + true ); // Return all html. From 10a37c313c4f31b72e319bebfcc3b9f705e696dc Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 Feb 2019 15:05:21 +0100 Subject: [PATCH 085/262] DB schema update native WMI scan Former-commit-id: 995fce571f2f37c5cbe891f726fa979cbb8ef183 --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 ++ pandora_console/pandoradb.sql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 58bb5d8e5e..c9784987fd 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1406,6 +1406,8 @@ ALTER TABLE twidget_dashboard MODIFY options LONGTEXT NOT NULL default ""; ALTER TABLE trecon_task ADD `alias_as_name` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; +ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; +ALTER TABLE trecon_task ADD `auth_strings` text; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5af9d38c55..a8d9b5c129 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -769,6 +769,8 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `snmp_privacy_method` varchar(25) NOT NULL default '', `snmp_privacy_pass` varchar(255) NOT NULL default '', `snmp_security_level` varchar(25) NOT NULL default '', + `wmi_enabled` tinyint(1) unsigned DEFAULT '0', + `auth_strings` text, PRIMARY KEY (`id_rt`), KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 453c639c53c6c49a0225d3cf5cc61f27db22609a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 Feb 2019 15:54:40 +0100 Subject: [PATCH 086/262] optimized. events_has_extended_info Former-commit-id: 805b80f1a9e09425b0e5710906886ae39e791753 --- pandora_console/include/functions_events.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 71780ed4e5..8ffabc5ad4 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2622,10 +2622,9 @@ function events_has_extended_info(int $id_event) { return (bool) db_get_value_sql( sprintf( - ' - SELECT count(*) as "n" - FROM tevent_extended WHERE id_evento=%d - ', + 'SELECT count(*) FROM ( + SELECT * as "n" + FROM tevent_extended WHERE id_evento=%d LIMIT 1) t', $id_event ) ); From 7f4353c4bc3d5b03d43b2a28d793ca51b929c6fc Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 Feb 2019 15:55:03 +0100 Subject: [PATCH 087/262] optimized. events_has_extended_info Former-commit-id: 2435badcea24fd5777bde358658409bf947a2d4b --- pandora_console/include/functions_events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 8ffabc5ad4..dcdd4a6bf3 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2622,8 +2622,8 @@ function events_has_extended_info(int $id_event) { return (bool) db_get_value_sql( sprintf( - 'SELECT count(*) FROM ( - SELECT * as "n" + 'SELECT count(*) as "n" FROM ( + SELECT * FROM tevent_extended WHERE id_evento=%d LIMIT 1) t', $id_event ) From f75a292b34c9a15114de3b43861ca8a63041ea51 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 Feb 2019 16:40:37 +0100 Subject: [PATCH 088/262] minor fixes/updates in notifications UI Former-commit-id: d4f5b7db1b5a6f0a023e33c4b8cd55db7765b11a --- pandora_console/general/header.php | 5 ++--- pandora_console/include/functions_notifications.php | 6 +++--- pandora_console/include/styles/pandora.css | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 5cf10bc749..e35d401502 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -170,6 +170,7 @@ config_check(); if (!isset($_GET['refr'])) { $_GET['refr'] = null; } + $select = db_process_sql("SELECT autorefresh_white_list,time_autorefresh FROM tusuario WHERE id_user = '".$config['id_user']."'"); $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); @@ -416,8 +417,6 @@ config_check(); toast_div.appendChild(toast_text); toast.appendChild(toast_div); - console.log(toast); - // Show and program the hide event. toast_div.className = toast_div.className + ' show'; setTimeout(function(){ @@ -478,7 +477,7 @@ config_check(); data.new_notifications.forEach(function(ele) { toast_wrapper.appendChild( print_toast( - ele.description, + ele.subject, ele.mensaje, ele.criticity, ele.full_url, diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 7f4b40c98b..0e35b7ea37 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -978,7 +978,7 @@ function notifications_print_dropdown_element($message_info) href='%s' target='_blank' > - + %s

    %s @@ -991,7 +991,7 @@ function notifications_print_dropdown_element($message_info) $message_info['id_mensaje'], messages_get_url($message_info['id_mensaje']), html_print_image('images/'.$message_info['icon'], true), - $message_info['description'], - $message_info['mensaje'] + $message_info['subject'], + str_replace([io_safe_input('
    ')], ' ', $message_info['mensaje']) ); } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 14ddf74326..d915d19508 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4292,7 +4292,7 @@ div#dialog_messages table th:last-child { .notification-ball-no-messages { background-color: #82b92e; - cursor: inherit; + cursor: pointer; } .notification-ball-new-messages { background-color: #fc4444; @@ -4342,6 +4342,7 @@ div#dialog_messages table th:last-child { display: flex; flex-flow: row nowrap; align-items: center; + padding: 5px; } .notification-item > * { padding-left: 15px; @@ -4754,6 +4755,7 @@ input:checked + .p-slider:before { border-radius: 4px; visibility: hidden; pointer-events: all; + transition: visibility 0s 1s; } .snackbar.show { From 5b4cadf1382dc98558f70386d9d218f3867170f0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 13 Feb 2019 17:16:12 +0100 Subject: [PATCH 089/262] minor style fix Former-commit-id: ca2dcf89672832b7796c9b9cc555d36d9db503ec --- pandora_console/include/styles/pandora.css | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index d915d19508..f3fdca5874 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4755,7 +4755,6 @@ input:checked + .p-slider:before { border-radius: 4px; visibility: hidden; pointer-events: all; - transition: visibility 0s 1s; } .snackbar.show { From 57991495e4441395943cfd8df9619a35c884b65b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Feb 2019 10:30:01 +0100 Subject: [PATCH 090/262] Use the CSV extension to import CSV on host and devices Former-commit-id: ed95b09992ee681e35e7f934b8a8ac70c83bc8be --- pandora_console/godmode/servers/discovery.php | 13 +++- .../godmode/wizards/HostDevices.class.php | 66 +++++++------------ .../include/functions_extensions.php | 3 +- 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 557b7bf5b3..0e52d0dc1f 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -1,8 +1,19 @@ url.'&mode=importcsv" alt="importcsv">Importar csv'; + if (extensions_is_enabled_extension('csv_import')) { + echo 'Importar csv'; + } + echo 'Escanear red'; return; } @@ -116,50 +119,27 @@ class HostDevices implements Wizard public function runCSV() { global $config; - echo 'formulario csv'; - if (isset($this->page) === false || $this->page === 0) { - $this->page = 0; - - $test = get_parameter('test', null); - - // Check user answers. - if ($test !== null) { - // $this->process_page_0($respuestas_usuario) - $this->page++; - header( - 'Location: '.$this->url.'&page='.$this->page - ); - } else { - // Mostrar pagina 0. - echo 'Aqui vamos a empezar a construir el formulario.'; - ?> -
    - -
    - page == 1) { - // Code... - $this->page++; + if (!check_acl($config['id_user'], 0, 'AW') + ) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access db status' + ); + include 'general/noaccess.php'; return; - header('Location: index.php?class=HostDevices&page='.$this->page); - } else if ($this->page == 2) { - // Code... - $this->page++; - header('Location: index.php?class=HostDevices&page='.$this->page); - } else if ($this->page == 3) { - // Code... - $this->page++; - header('Location: /XXX/discovery/index.php?class=HostDevices&page='.$this->page); } - // Page 4, last. - return [ - 'result' => $this->result, - 'id' => $this->id, - 'msg' => $this->msg, - ]; + if (!extensions_is_enabled_extension('csv_import')) { + ui_print_error_message( + [ + 'message' => __('Extension CSV Import is not enabled.'), + 'no_close' => true, + ] + ); + return; + } + include_once $config['homedir'].'/enterprise/extensions/csv_import/main.php'; } @@ -818,8 +798,8 @@ function get_explanation_recon_script (id) { } - Date: Thu, 14 Feb 2019 10:56:25 +0100 Subject: [PATCH 091/262] WIP H&D Former-commit-id: c3b0b6f56ff0591f8c5839d61144bbb72ddd7033 --- .../godmode/wizards/HostDevices.class.php | 174 ++++++++------- .../godmode/wizards/Wizard.interface.php | 16 -- .../godmode/wizards/Wizard.main.php | 198 ++++++++++++++++++ .../godmode/wizards/hostDevices.png | Bin 5251 -> 0 bytes 4 files changed, 300 insertions(+), 88 deletions(-) delete mode 100755 pandora_console/godmode/wizards/Wizard.interface.php create mode 100644 pandora_console/godmode/wizards/Wizard.main.php delete mode 100755 pandora_console/godmode/wizards/hostDevices.png diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 3921eac025..20bd304014 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -1,11 +1,11 @@ data[11][0] = ''.__('SNMP enabled'); $table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true); @@ -673,99 +708,99 @@ class HostDevices implements Wizard echo ''; ui_require_javascript_file('pandora_modules'); - ?> - - `; + echo $a; + return [ 'result' => $this->result, 'id' => $this->id, 'msg' => $this->msg, - ]; - */ - + ]; } diff --git a/pandora_console/godmode/wizards/Wizard.interface.php b/pandora_console/godmode/wizards/Wizard.interface.php deleted file mode 100755 index 6d1ac73783..0000000000 --- a/pandora_console/godmode/wizards/Wizard.interface.php +++ /dev/null @@ -1,16 +0,0 @@ -'; + + $ouput .= '
      '; + + foreach ($inputs as $input) { + $output .= '
    • '; + $output .= '
    • '; + } + + $output .= '
    '; + $output .= ''; + $output .= $js; + + return $output; + + } + + +} diff --git a/pandora_console/godmode/wizards/hostDevices.png b/pandora_console/godmode/wizards/hostDevices.png deleted file mode 100755 index bccf7ba092cc19b100a33675437046561258f65d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5251 zcmb`L=Tj3vyTtcv-ny18iMfovj7YD0gdX7qp$L z$L6I*IRF66s`^+_-}}>gn*D3=Xxfii3d+Z&C)3d;r(YKNAcVx)JbzgN5gOTamEKKL z+6_TW@Ktekb{=*~sHw*AcNnf4YL4=>Mn$58%kOeCy|2YXV-%Kw<|?A~(Xoqt>?teh z8-A|xpjOB;;I@j(K%-Wl*5LVr)B4%tM!(Wog$Q^|ET~n@NMR8YMaiSA&Id~zK*V9w0|fvW0e_ZthaX7{V;fbp;2AcfxxDl$#Ecqu63Tl9IP@Q!1(&sJM0L8yac_6o{( zcH+WgPQf^_+k?R65_|#Ops~QT)=) zEPW`M`Tv{Ze}zOSi?=%a)C9GIGV(m(%bEqwtx~KpdUk%nqV!;_9Cc$__!3G+O6p?R z#M%(f5O3G<8&6H4s;eILZ5@{a6+AtwJPxwv-uP|PngJCBT6!7WDs%N8ii(JonAN#! z4F)n@rVZW>Cvs_ntt-aor!8BzpKCu%7#|R<7Yl$5;uma9Z(-Yy)fN}P7N zaNV4*P*PJos^0$1#sUZliRC??h5wj&!R~ct zGUN_1HTH@K6{rXdR`$=G8-&as6g+P?4C2JM%+Z;hJ<e;Xo>m7V^<=R4U4D0u-K^ddqpDz)a-;v`tX5`;T_ADv6rt*6-q~ohgY#zZvbOs zVwg7jH(IzRsbf`Mxh+OA{XO(0l|jyxAd}P!3kzv!X+fObOQ4-jBq!7I+S=~%DZe?9 zXdEbT3Dv#h+dvl=Zqg8XER(6dyxgBn8*DXPWbjA>6%pKIiNoQrSm_Qol36ER1@(?; zpu*>p63txQHsM{|_VH=I-R^f~p(IMA_zW*Uzq+R8;u|Y(?}GgNB`a5fI4DQUp!BxcT1-p~tlZ;@IxpjX5X4#ed>vQXs}=jN*EKgkUpRd>#lMod zu{OFp*i()zCC?dgrv;YblCS}ZGNEmO)z#HyR6*1~!BTs!zE^7AF$F7ITU)cRvX%^q zGYi~-s=ADoL1bmkFK(Ecb8>RlCu^2||5ov0X@7y|42irWzA;gyp55OnZRm?ersS!s zsR0!WN=i01HvCS$BO$NMG(LwkSM-!ePd#pUJYJ4@u6%F6EUZkcpKC6XYU25^2l`;g}lyi^hX7@TqOG~Rl;FxV}z@chq)~kV`XJU7LGb)`R zYxA=@2k)e=_J5a?p0Q?L8Ck?5ncJ^8+_=EptuzhUDCRS!_l9J(rHQD}1UdrlMf!+vx9bUBknH)N=y(iqbLzbuP%dLjFz!x_p z4k#Jt4OTz+OZtWmS_oO&S7*EzZZ@`SZJf=ZC*#FxMtZHln1hDX#Z&5;w|*(#(0vm>R>GY5LEV)ApY_B7~Azwf#-hw-g&YWt6NBBc;n{CNwgveqNo5^ z92K521=544+F!yXJQiCIsVPe}61y>+AvqpN7z*|@J$U2s=uLeYca zfxs*GLDMJ7A(I?+CP7ViA2i|+uZ^xlL7>F?GHxOMp%~t7%_z*?G^hiH4|wTO-Tmd6 z>DM?O_zm2Gk~yxoAcP74Y|ELbK(BS8)93iB9;BuTZ9A9?+LK>2LNt_S(a%TZDfMy< z$Bwf?z2qhx^Vo%#X(ZV@%82!>+m;cnW8J@1&VRfPVNpp@t;(yoLRo-4;gXjYonvR; zf1AaIQYb?Iy)riDq^?dFF6aZ=-Ia+{>dEw!J=Q+h!N+`;#yfm^dGMzcAi;&2gI3^J#5yi7u%lXr;T z;RUY@<)D|rY?H%k&|NLQ3T(U^{xZUsSzPXD0UP-(eYg8ra7yjS#62`4wv|Wi9kl=gRWS z%#+T2zuTT``S1U2N3wwPK8;d@JiB|^;*1EmIW!AL%|EY(t#za7Jf_yHBr#Z?$HcDF zB(^GlxT06(M`;;&ZLGe(fU~KmeFG5^T`yJg$Rgw6Ox-z!Y`|vMH0-k|uUUWHnhMaG zb=JH1E-}#ZaO0GSV4?6?eOX#PKl%6IeX;t^_c}3QX<}XDdVB2y`JNn3#UbhEvlB!I zQcaldkl&K82H*zQbQ1ZK)9s?EgTFT)j@ogKS{(OhE*MF5jhLuZ@rks?E4-$}yz=iLA1~zh;>`cUSN5FmyVKCqjAbc&Qhi$La~c(xRvWsG^RhWJih3 zuoefA$0swqz?}Z)$?<3JuO#t&ufIPy2OIVB@RY16=|u1~)m9MEYIWzET^^Sm=5Rvr zM}z$n@8S&&z6fiGtw8V;FBvkFrBJW(-a+4R3BB{i5%jJk<>NahJLW-j#jq#guIMB} zAqXr9`F((GkehH)>k-7QRLLmxGnD5XR^~jwJ-2?42Mn*^bzx_@t$>$vFD0&-xm# zmg?_l-7T>nwjtp9b0}rtFp9+sM`Z*kFpa0iRNLm%oy7qVKu%ZDYL0hkIkQmO)f) zWNG53^x0=K-c?UJgMDDa(W2aqhq%>uVPL?^X`{)!lfkvUYCVtSOcem&MlHRetsyn% zR^j1&irUe{1jSFj?_=V})Ff*%KW}fDL*kI5Y>J?|ML#nOOO2>^fKvPs|K1)11OR}- z*{?+oA$92>P?aEnF&Jiee`(Es{ke#+1bYFdPP#~}U#V~fO+qij`b0C2HF z4rxUaoT|02Fz_dB>m}qM?col?Ky&@y%QC}~67U4-F?Eg8wm+rTPzT8O({_mq5c>!X zEJ3NAf~{f?-)M=04i0Me#j9*2A}CXc>S26y!z}Efrx{?=rOl zp|cuOk!yFlxNP=1hxq68KwieJUXm2&v&jRxVhLZx%z(DYB^F5zA~E!BEm}j%*^JHof^bVM_$kdn}Mj>^WuE&CJ+ZR;0HiK2b_gQCv$-- zEuO-Qeh-}t4BPxUp^2nPr-N!-XX4J$dS+^5B{=<4xur?fX!E%7v{dQo9X0ngM9T}z zcHy<1&m*5nrlx&v+bNSbk!+R`NWJ)Aq3Es@>mjB~>yb~%=GHVwLVrrUKvdSruDnof=5!GS}PQjh9T4lQ5oL=Myq@9ufJqfmh4?>})t} z)+dfwWoBw-dpdRMX)Y8&g^xk-m^!gq%^xlQ&Iy3w0qCao1&&X3Q>1MWav;WzELMOE z_OvZQz-cHWW8DY89X~WBe@uXjBVaNsEZ5uFuym$p$9w)bid}Jg%%@Z!?XgeCH#7(U zqPp|fOlI3{!P6)?740cDDppO#(3;+8!ZpuZTEV!})Iy|D33Y)im@;aIy z-+{S$Dwi){5~*M}G2-S@B=274Xc!y!a#5yb`2DQoZPtwOdU2jMhOdspk}&kUwl{Bn5m*7212Nj!Xh<9sX4 z%hh}OUeoT{&Bo;T0z-cMB8gE$Hom>}G0hS|8nc|=DEFz>Pu;{NB?$i^$TB!Pzn5Kp zRBESt2m6r3&Y%j=*}7&?OqBajF^6uu#b?8~>{wLSCz`1RYtN&bId5@I%@cbuc3>7O ztIU|in6G)QyDZcun<=?KYL__MXyhndEYJ(9e=gK;xIY(otJkhCJESzX`e=*prdqn6 z%VfL3!&TuL{59Kf#@?A_F9-MVQ7I9z8a>VKr>8=rOwK=z^;Y{F4SXDJOfpfm-}cEI z{$}V*zN}7PzjGsuj81`GQJkoVk%>XtUVapNvDBM-jO7zv|3!7Im&;dZfl8G{Xi(&y zZ7Q~7T{%@Wp7lssrTEdl*?S=o_uYkS(P=U!*p-Lz-jpY!M_xk+!>IC8&pP(=a zIqky*q{%46<5Op1DH77dSwTeq83Yp$m+w6JtMwPF?MCy zMMbL~IMLYW`>S3r_{cRPm)l=eE#=-xb7t&_x-08e?UGpLcPKrJtSi{iN`FLLW-Jq`j;%SskT-z=H~RSsN+-n4EaK+%0K9G?^s!JE>IuP`*Sn(E zEMkd<0fNWt<{D1*A44GRU%v!EvUT}Y+|T+G*ihN Date: Thu, 14 Feb 2019 11:32:07 +0100 Subject: [PATCH 092/262] WIP H&D base structure Former-commit-id: dace1164c5a568adbb98c187106838d25334f934 --- .../godmode/wizards/HostDevices.class.php | 178 +++--------------- .../godmode/wizards/Wizard.main.php | 62 +++++- 2 files changed, 86 insertions(+), 154 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 6612e0e088..330ae72865 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -68,7 +68,7 @@ class HostDevices extends Wizard /** * Undocumented function. * - * @param integer $page Mensajito. + * @param integer $page Start page, by default 0. * @param string $msg Mensajito. * @param string $icon Mensajito. * @param string $label Mensajito. @@ -81,6 +81,8 @@ class HostDevices extends Wizard string $icon='hostDevices.png', string $label='Host & Devices' ) { + $this->setBreadcrum([]); + $this->id = null; $this->msg = $msg; $this->icon = $icon; @@ -105,6 +107,8 @@ class HostDevices extends Wizard $mode = get_parameter('mode', null); if ($mode === null) { + $this->setBreadcrum(['Host&devices']); + $this->printHeader(); if (extensions_is_enabled_extension('csv_import')) { echo 'Importar csv'; } @@ -114,10 +118,24 @@ class HostDevices extends Wizard } if ($mode == 'importcsv') { + $this->setBreadcrum( + [ + 'Host&devices', + 'Import CSV', + ] + ); + $this->printHeader(); return $this->runCSV(); } if ($mode == 'netscan') { + $this->setBreadcrum( + [ + 'Host&devices', + 'Net scan', + ] + ); + $this->printHeader(); return $this->runNetScan(); } @@ -154,6 +172,7 @@ class HostDevices extends Wizard public function runCSV() { global $config; + if (!check_acl($config['id_user'], 0, 'AW') ) { db_pandora_audit( @@ -187,7 +206,6 @@ class HostDevices extends Wizard { global $config; - echo 'formulario netscan'; check_login(); if (! check_acl($config['id_user'], 0, 'PM')) { @@ -688,158 +706,12 @@ class HostDevices extends Wizard echo ''; ui_require_javascript_file('pandora_modules'); - $javascript = ` - `; - echo $javascript; - - return [ - 'result' => $this->result, - 'id' => $this->id, - 'msg' => $this->msg, - ]; + return [ + 'result' => $this->result, + 'id' => $this->id, + 'msg' => $this->msg, + ]; } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 9a827d73da..6a97cf73a3 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -6,6 +6,37 @@ class Wizard { + /** + * Breadcrum + * + * @var array. + */ + public $breadcrum; + + + /** + * Setter for breadcrum + * + * @param array $str Breadcrum. + * + * @return void + */ + public function setBreadcrum(array $str) + { + $this->breadcrum = $str; + } + + + /** + * Getter for breadcrum + * + * @return array Breadcrum. + */ + public function getBreadcrum() + { + return $this->breadcrum; + } + /** * To be overwritten. @@ -27,6 +58,35 @@ class Wizard } + /** + * Print breadcrum to follow flow. + * + * @return string Breadcrum HTML code. + */ + public function printBreadcrum() + { + return '

    '.implode(' > ', $this->breadcrum).'

    '; + } + + + /** + * Prints a header for current wizard. + * + * @param boolean $return Return HTML or print it. + * + * @return string HTML code for header. + */ + public function printHeader(bool $return=false) + { + $output = $this->printBreadcrum(); + if ($return === false) { + echo $output; + } + + return $output; + } + + /** * Print input using functions html lib. * @@ -168,7 +228,7 @@ class Wizard * * @param array $data Definition of target form to be printed. * - * @return void + * @return string HTML code. */ public function printForm(array $data) { From 070db506b8de05a8d5c3e1a6b5dfb1ce54a30e0a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 14 Feb 2019 11:53:06 +0100 Subject: [PATCH 093/262] WIP: H&D Former-commit-id: 8f66bccf64b219df20d19d72eb41bec8acdd9bbc --- .../godmode/wizards/HostDevices.class.php | 512 +----------------- .../godmode/wizards/Wizard.main.php | 14 +- 2 files changed, 36 insertions(+), 490 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 330ae72865..2b12530453 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -222,496 +222,38 @@ class HostDevices extends Wizard $user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); $user_groups = array_keys($user_groups); - if (is_ajax()) { - $get_explanation = (bool) get_parameter('get_explanation', 0); + if (isset($this->page) === false + || $this->page == 0 + ) { + $form = []; - if ($get_explanation) { - $id = (int) get_parameter('id', 0); + // Input task name. + // Input Discovery Server. + // Input Network. + // Input interval. + // Input group. + $form['inputs'] = [ + [ + 'label' => __('Task name'), + 'arguments' => [ + 'name' => 'name', + 'value' => '', + 'type' => 'text', + 'size' => 25, + ], + ], + ]; - $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id); - - echo io_safe_output($explanation); - - return; - } - - $get_recon_script_macros = get_parameter('get_recon_script_macros'); - if ($get_recon_script_macros) { - $id_recon_script = (int) get_parameter('id'); - $id_recon_task = (int) get_parameter('id_rt'); - - if (!empty($id_recon_task) && empty($id_recon_script)) { - $recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task); - } else if (!empty($id_recon_task)) { - $recon_task_id_rs = (int) db_get_value('id_recon_script', 'trecon_task', 'id_rt', $id_recon_task); - - if ($id_recon_script == $recon_task_id_rs) { - $recon_script_macros = db_get_value('macros', 'trecon_task', 'id_rt', $id_recon_task); - } else { - $recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script); - } - } else if (!empty($id_recon_script)) { - $recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script', $id_recon_script); - } else { - $recon_script_macros = []; - } - - $macros = []; - $macros['base64'] = base64_encode($recon_script_macros); - $macros['array'] = json_decode($recon_script_macros, true); - - echo io_json_mb_encode($macros); - return; - } - - return; + $this->printForm($form); } - // Edit mode. - if (isset($_GET['update']) || (isset($_GET['upd']))) { - $update_recon = true; - if (isset($_GET['upd'])) { - if ($_GET['upd'] != 'update') { - $update_recon = false; - } else { - $id_rt = get_parameter('upd'); - } - } - - if ($update_recon) { - if (!isset($id_rt)) { - $id_rt = (int) get_parameter_get('update'); - } - - $row = db_get_row('trecon_task', 'id_rt', $id_rt); - $name = $row['name']; - $network = $row['subnet']; - $id_recon_server = $row['id_recon_server']; - $description = $row['description']; - $interval = $row['interval_sweep']; - $id_group = $row['id_group']; - $create_incident = $row['create_incident']; - $id_network_profile = $row['id_network_profile']; - $id_os = $row['id_os']; - $recon_ports = $row['recon_ports']; - $snmp_community = $row['snmp_community']; - $snmp_version = $row['snmp_version']; - $snmp3_auth_user = $row['snmp_auth_user']; - $snmp3_auth_pass = $row['snmp_auth_pass']; - $snmp3_privacy_method = $row['snmp_privacy_method']; - $snmp3_privacy_pass = $row['snmp_privacy_pass']; - $snmp3_auth_method = $row['snmp_auth_method']; - $snmp3_security_level = $row['snmp_security_level']; - $id_recon_script = $row['id_recon_script']; - $field1 = $row['field1']; - $field2 = $row['field2']; - $field3 = $row['field3']; - $field4 = $row['field4']; - if ($id_recon_script == 0) { - $mode = 'network_sweep'; - } else { - $mode = 'recon_script'; - } - - $os_detect = $row['os_detect']; - $resolve_names = $row['resolve_names']; - $os_detect = $row['os_detect']; - $parent_detection = $row['parent_detection']; - $parent_recursion = $row['parent_recursion']; - $macros = $row['macros']; - $alias_as_name = $row['alias_as_name']; - $snmp_enabled = $row['snmp_enabled']; - $vlan_enabled = $row['vlan_enabled']; - - $name_script = db_get_value( - 'name', - 'trecon_script', - 'id_recon_script', - $id_recon_script - ); - - if (! in_array($id_group, $user_groups)) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access Recon Task Management' - ); - include 'general/noaccess.php'; - return; - } - } - } else if (isset($_GET['create']) || isset($_GET['crt'])) { - $create_recon = true; - if (isset($_GET['crt'])) { - if ($_GET['crt'] != 'Create') { - $create_recon = false; - } - } - - if ($create_recon) { - $id_rt = -1; - $name = get_parameter('name'); - $network = get_parameter('network'); - $description = get_parameter('description'); - $id_recon_server = 0; - $interval = 0; - $id_group = 0; - $create_incident = 1; - $snmp_community = 'public'; - $snmp3_auth_user = ''; - $snmp3_auth_pass = ''; - $snmp_version = 1; - $snmp3_privacy_method = ''; - $snmp3_privacy_pass = ''; - $snmp3_auth_method = ''; - $snmp3_security_level = ''; - $id_network_profile = 0; - $id_os = -1; - // Any. - $recon_ports = ''; - // Any. - $field1 = ''; - $field2 = ''; - $field3 = ''; - $field4 = ''; - $id_recon_script = 0; - $mode = 'network_sweep'; - $os_detect = 0; - $resolve_names = 0; - $parent_detection = 1; - $parent_recursion = 5; - $macros = ''; - $alias_as_name = 0; - $snmp_enabled = 0; - $vlan_enabled = 0; - } - - $modify = false; - if (($name != '') || ($network != '')) { - $modify = true; - } + if ($this->page == 100) { + return [ + 'result' => $this->result, + 'id' => $this->id, + 'msg' => $this->msg, + ]; } - - $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; - if ($is_windows) { - echo '
    '; - echo __('Warning').': '.__('By default, in Windows, %s only support Standard network sweep, not custom scripts', get_product_name()); - echo '
    '; - } - - $table = new stdClass(); - $table->id = 'table_recon'; - $table->width = '100%'; - $table->cellspacing = 4; - $table->cellpadding = 4; - $table->class = 'databox filters'; - - $table->rowclass[3] = 'network_sweep'; - $table->rowclass[5] = 'network_sweep'; - $table->rowclass[7] = 'network_sweep'; - $table->rowclass[8] = 'network_sweep'; - $table->rowclass[11] = 'network_sweep'; - $table->rowclass[12] = 'network_sweep'; - $table->rowclass[18] = 'network_sweep'; - $table->rowclass[19] = 'network_sweep'; - $table->rowclass[20] = 'network_sweep'; - $table->rowclass[21] = 'network_sweep'; - $table->rowclass[22] = 'network_sweep'; - $table->rowclass[23] = 'network_sweep'; - $table->rowclass[24] = 'network_sweep'; - $table->rowclass[25] = 'network_sweep recon_v3'; - $table->rowclass[26] = 'network_sweep recon_v3'; - $table->rowclass[27] = 'network_sweep recon_v3'; - $table->rowclass[28] = 'network_sweep recon_v3'; - $table->rowclass[29] = 'network_sweep recon_v3'; - $table->rowclass[30] = 'network_sweep recon_v3'; - - $table->rowclass[6] = 'recon_script'; - $table->rowclass[13] = 'recon_script'; - $table->rowclass[14] = 'recon_script'; - $table->rowclass[15] = 'recon_script'; - $table->rowclass[16] = 'recon_script'; - $table->rowclass[17] = 'recon_script'; - // Name. - $table->data[0][0] = ''.__('Task name').''; - $table->data[0][1] = html_print_input_text('name', $name, '', 25, 0, true); - - // Discovery server. - $table->data[1][0] = ''.__('Discovery server').ui_print_help_tip( - __('You must select a Discovery Server for the Task, otherwise the Recon Task will never run'), - true - ); - - $sql = 'SELECT id_server, name - FROM tserver - WHERE server_type = 3 - ORDER BY name'; - $table->data[1][1] = html_print_select_from_sql($sql, 'id_recon_server', $id_recon_server, '', '', '', true); - - $fields['network_sweep'] = __('Network sweep'); - if (!$is_windows) { - $fields['recon_script'] = __('Custom script'); - } - - $table->data[2][0] = ''.__('Mode').''; - $table->data[2][1] = html_print_select($fields, 'mode', $mode, '', '', 0, true); - - // Network. - $table->data[3][0] = ''.__('Network').''; - $table->data[3][0] .= ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true); - $table->data[3][1] = html_print_input_text('network', $network, '', 25, 0, true); - - // Interval. - $interv_manual = 0; - if ((int) $interval == 0) { - $interv_manual = 1; - } - - $table->data[4][0] = ''.__('Interval'); - $table->data[4][0] .= ui_print_help_tip(__('Manual interval means that it will be executed only On-demand'), true); - - $values = [ - 0 => __('Defined'), - 1 => __('Manual'), - ]; - $table->data[4][1] = html_print_select($values, 'interval_manual_defined', $interv_manual, '', '', '', true); - - $table->data[4][1] .= ''; - $table->data[4][1] .= html_print_extended_select_for_time('interval', $interval, '', '', '0', false, true, false, false); - $table->data[4][1] .= ui_print_help_tip(__('The minimum recomended interval for Recon Task is 5 minutes'), true); - $table->data[4][1] .= ''; - - // Module template. - $table->data[5][0] = ''.__('Module template').''; - - $sql = 'SELECT id_np, name - FROM tnetwork_profile - ORDER BY name'; - $table->data[5][1] = html_print_select_from_sql($sql, 'id_network_profile', $id_network_profile, '', __('None'), 0, true); - - // Recon script. - $data[1] = ''; - $table->data[6][0] = ''.__('Recon script').''; - - $sql = "SELECT id_recon_script, name - FROM trecon_script - WHERE name <> 'IPAM Recon' - ORDER BY name"; - if ($name_script != 'IPAM Recon') { - $table->data[6][1] = html_print_select_from_sql($sql, 'id_recon_script', $id_recon_script, '', '', '', true); - $table->data[6][1] .= "'; - $table->data[6][1] .= $data[1] .= html_print_input_hidden('macros', base64_encode($macros), true); - } else { - $table->data[6][1] = 'IPAM Recon'; - } - - // OS. - $table->data[7][0] = ''.__('OS').''; - - $sql = 'SELECT id_os, name - FROM tconfig_os - ORDER BY name'; - $table->data[7][1] = html_print_select_from_sql($sql, 'id_os', $id_os, '', __('Any'), -1, true); - - // Recon ports. - $table->data[8][0] = ''.__('Ports').''; - $table->data[8][1] = html_print_input_text('recon_ports', $recon_ports, '', 25, 0, true); - $table->data[8][1] .= ui_print_help_tip( - __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), - true - ); - - // Group. - $table->data[9][0] = ''.__('Group'); - $groups = users_get_groups(false, 'PM', false); - $table->data[9][1] = html_print_select_groups(false, 'PM', false, 'id_group', $id_group, '', '', 0, true); - - // Incident. - $values = [ - 0 => __('No'), - 1 => __('Yes'), - ]; - $table->data[10][0] = ''.__('Incident'); - $table->data[10][1] = html_print_select( - $values, - 'create_incident', - $create_incident, - '', - '', - '', - true - ).' '.ui_print_help_tip(__('Choose if the discovery of a new system creates an incident or not.'), true); - - // Snmp_enabled. - $table->data[11][0] = ''.__('SNMP enabled'); - $table->data[11][1] = html_print_checkbox('snmp_enabled', 1, $snmp_enabled, true); - - // SNMP default community. - $table->data[12][0] = ''.__('SNMP Default community'); - $table->data[12][0] .= ui_print_help_tip(__('You can specify several values, separated by commas, for example: public,mysecret,1234'), true); - $table->data[12][1] = html_print_input_text('snmp_community', $snmp_community, '', 35, 0, true); - - // SNMP version. - $snmp_versions['1'] = 'v. 1'; - $snmp_versions['2'] = 'v. 2'; - $snmp_versions['2c'] = 'v. 2c'; - $snmp_versions['3'] = 'v. 3'; - $table->data[24][0] = ''._('SNMP version'); - $table->data[24][1] = html_print_select($snmp_versions, 'snmp_version', $snmp_version, '', '', 0, true); - - $table->data[25][0] = ''.__('Auth user'); - $table->data[25][1] = html_print_input_text( - 'snmp_auth_user', - $snmp3_auth_user, - '', - 15, - 60, - true, - '', - false, - '', - '' - ); - $table->data[26][0] = ''.__('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); - $table->data[26][1] = html_print_input_password( - 'snmp_auth_pass', - $snmp3_auth_pass, - '', - 15, - 60, - true, - '', - false, - '' - ); - $table->data[26][1] .= html_print_input_hidden_extended('active_snmp_v3', 0, 'active_snmp_v3_mmen', true); - - $table->data[27][0] = ''.__('Privacy method'); - $table->data[27][1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp_privacy_method', $snmp3_privacy_method, '', '', '', true, false, false, '', ''); - $table->data[28][0] = ''.__('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true); - $table->data[28][1] = html_print_input_password( - 'snmp_privacy_pass', - $snmp3_privacy_pass, - '', - 15, - 60, - true, - '', - false, - '' - ); - $table->data[29][0] = ''.__('Auth method'); - $table->data[29][1] = html_print_select(['MD5' => __('MD5'), 'SHA' => __('SHA')], 'snmp_auth_method', $snmp3_auth_method, '', '', '', true, false, false, '', ''); - $table->data[30][0] = ''.__('Security level'); - $table->data[30][1] = html_print_select( - [ - 'noAuthNoPriv' => __('Not auth and not privacy method'), - 'authNoPriv' => __('Auth and not privacy method'), - 'authPriv' => __('Auth and privacy method'), - ], - 'snmp_security_level', - $snmp3_security_level, - '', - '', - '', - true, - false, - false, - '', - '' - ); - - // Explanation. - $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script); - - $table->data[13][0] = ''.__('Explanation').''; - $table->data[13][1] = "'.html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true); - - // A hidden "model row" to clone it from javascript to add fields dynamicaly. - $data = []; - $data[0] = 'macro_desc'; - $data[0] .= ui_print_help_tip('macro_help', true); - $data[1] = html_print_input_text('macro_name', 'macro_value', '', 100, 255, true); - $table->colspan['macro_field'][1] = 3; - $table->rowstyle['macro_field'] = 'display:none'; - $table->data['macro_field'] = $data; - - // If there are $macros, we create the form fields. - if (!empty($macros)) { - $macros = json_decode($macros, true); - - foreach ($macros as $k => $m) { - $data = []; - $data[0] = ''.$m['desc'].''; - if (!empty($m['help'])) { - $data[0] .= ui_print_help_tip($m['help'], true); - } - - if ($m['hide']) { - $data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true); - } else { - $data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true); - } - - $table->colspan['macro'.$m['macro']][1] = 3; - $table->rowclass['macro'.$m['macro']] = 'macro_field'; - - $table->data['macro'.$m['macro']] = $data; - } - } - - // Comments. - $table->data[18][0] = ''.__('Comments'); - $table->data[18][1] = html_print_input_text('description', $description, '', 45, 0, true); - - // OS detection. - $table->data[19][0] = ''.__('OS detection'); - $table->data[19][1] = html_print_checkbox('os_detect', 1, $os_detect, true); - - // Name resolution. - $table->data[20][0] = ''.__('Name resolution'); - $table->data[20][1] = html_print_checkbox('resolve_names', 1, $resolve_names, true); - - // Parent detection. - $table->data[21][0] = ''.__('Parent detection'); - $table->data[21][1] = html_print_checkbox('parent_detection', 1, $parent_detection, true); - - // Parent recursion. - $table->data[22][0] = ''.__('Parent recursion'); - $table->data[22][1] = html_print_input_text('parent_recursion', $parent_recursion, '', 5, 0, true).ui_print_help_tip(__('Maximum number of parent hosts that will be created if parent detection is enabled.'), true); - - // Is vlan_enabled. - $table->data[23][0] = ''.__('Vlan enabled'); - $table->data[23][1] = html_print_checkbox('vlan_enabled', 1, $vlan_enabled, true); - - // Alias as name - // NOTE: The 7.0NG Recon Server will not generate random names, since IP - // address collisions could have other consequences. - // $table->data[22][0] = "".__('Alias as Name'); - // $table->data[22][1] = html_print_checkbox ('alias_as_name', 1, $alias_as_name, true); - // Different Form url if it's a create or if it's a update form. - echo '
    '; - html_print_table($table); - echo '
    '; - - if ($id_rt != -1) { - if ($name_script != 'IPAM Recon') { - html_print_submit_button(__('Update'), 'crt', false, 'class="sub upd"'); - } - } else { - html_print_submit_button(__('Add'), 'crt', false, 'class="sub wand"'); - } - - echo '
    '; - - echo '
    '; - - ui_require_javascript_file('pandora_modules'); - - return [ - 'result' => $this->result, - 'id' => $this->id, - 'msg' => $this->msg, - ]; } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 6a97cf73a3..743d82dd11 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -105,9 +105,9 @@ class Wizard return html_print_input_text( $data['name'], $data['value'], - $data['alt'] = '', - $data['size'] = 50, - $data['maxlength'] = 255, + ((isset($data['alt']) === true) ? $data['alt'] : ''), + ((isset($data['size']) === true) ? $data['size'] : 50), + ((isset($data['maxlength']) === true) ? $data['maxlength'] : 255), ((isset($data['return']) === true) ? $data['return'] : true), ((isset($data['disabled']) === true) ? $data['disabled'] : false), ((isset($data['required']) === true) ? $data['required'] : false), @@ -230,7 +230,7 @@ class Wizard * * @return string HTML code. */ - public function printForm(array $data) + public function printForm(array $data, bool $return=false) { $form = $data['form']; $inputs = $data['inputs']; @@ -243,13 +243,17 @@ class Wizard foreach ($inputs as $input) { $output .= '
  • '; - $output .= '
  • '; + $output .= $this->printInput($input['arguments']).''; } $output .= '

'; $output .= ''; $output .= $js; + if ($return === false) { + echo $output; + } + return $output; } From 8acb658266ac79153027f01c62647c325c52099e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 14 Feb 2019 13:27:49 +0100 Subject: [PATCH 094/262] WIP: H&D Former-commit-id: 7e74f1330b7e5cfdab3757ec62523942a1b4fe9f --- pandora_console/godmode/servers/discovery.php | 1 - .../godmode/wizards/HostDevices.class.php | 182 ++++++++++++++++-- .../godmode/wizards/Wizard.main.php | 81 +++++++- pandora_console/include/styles/wizard.css | 11 ++ 4 files changed, 254 insertions(+), 21 deletions(-) create mode 100644 pandora_console/include/styles/wizard.css diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index e02d62783e..39c31b9465 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -52,7 +52,6 @@ if ($classname_selected !== null) { $wiz = new $classname_selected($page); $wiz->run(); // TODO: Here we'll controlle if return is a valid recon task id. - exit(); } if ($classname_selected === null) { diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 2b12530453..421ea07484 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -1,6 +1,7 @@ page) === false - || $this->page == 0 - ) { - $form = []; + if (isset($this->page) && $this->page == 1) { + // Parse page 0 responses. + $this->parseNetScan(); + } - // Input task name. - // Input Discovery Server. - // Input Network. - // Input interval. - // Input group. - $form['inputs'] = [ - [ - 'label' => __('Task name'), + if (!isset($this->page) || $this->page == 0) { + // Interval. + $interv_manual = 0; + if ((int) $interval == 0) { + $interv_manual = 1; + } + + if (isset($this->page) === false + || $this->page == 0 + ) { + $form = []; + + // Input task name. + $form['inputs'][] = [ + 'label' => ''.__('Task name').'', + 'arguments' => [ + 'name' => 'taskname', + 'value' => '', + 'type' => 'text', + 'size' => 25, + ], + ]; + + // Input Discovery Server. + $form['inputs'][] = [ + 'label' => ''.__('Discovery server').''.ui_print_help_tip( + __('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), + true + ), + 'arguments' => [ + 'type' => 'select_from_sql', + 'sql' => sprintf( + 'SELECT id_server, name + FROM tserver + WHERE server_type = %d + ORDER BY name', + SERVER_TYPE_DISCOVERY + ), + 'name' => 'id_recon_server', + 'selected' => 0, + 'return' => true, + ], + ]; + + // Input Network. + $form['inputs'][] = [ + + 'label' => ''.__('Network').''.ui_print_help_tip( + __('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), + true + ), 'arguments' => [ 'name' => 'name', 'value' => '', 'type' => 'text', 'size' => 25, ], - ], - ]; + ]; - $this->printForm($form); + // Input interval. + $form['inputs'][] = [ + 'label' => ''.__('Interval').''.ui_print_help_tip( + __('Manual interval means that it will be executed only On-demand'), + true + ), + 'arguments' => [ + 'type' => 'select', + 'selected' => $interv_manual, + 'fields' => [ + 0 => __('Defined'), + 1 => __('Manual'), + ], + 'name' => 'interval_manual_defined', + 'return' => true, + ], + 'extra' => ''.html_print_extended_select_for_time( + 'interval', + $interval, + '', + '', + '0', + false, + true, + false, + false + ).ui_print_help_tip( + __('The minimum recomended interval for Recon Task is 5 minutes'), + true + ).'', + ]; + + // Input Group. + $form['inputs'][] = [ + 'label' => ''.__('Group').'', + 'arguments' => [ + 'name' => 'id_group', + 'privilege' => 'PM', + 'type' => 'select_groups', + 'return' => true, + ], + ]; + + // Hidden, page. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'page', + 'value' => ($this->page + 1), + 'type' => 'hidden', + 'return' => true, + ], + ]; + + // Submit button. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Next'), + 'type' => 'submit', + 'attributes' => 'class="sub next"', + 'return' => true, + ], + ]; + + $form['form'] = [ + 'method' => 'POST', + 'action' => '#', + ]; + + $form['js'] = ' + $("select#interval_manual_defined").change(function() { + if ($("#interval_manual_defined").val() == 1) { + $("#interval_manual_container").hide(); + $("#text-interval_text").val(0); + $("#hidden-interval").val(0); + } + else { + $("#interval_manual_container").show(); + $("#text-interval_text").val(10); + $("#hidden-interval").val(600); + $("#interval_units").val(60); + } + }).change();'; + + // Print NetScan page 0. + $this->printForm($form); + } + } + + if ($this->page == 1) { + // Page 1. + echo 'page 1!'; } if ($this->page == 100) { diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 743d82dd11..e8722ea8e8 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -45,6 +45,7 @@ class Wizard */ public function run() { + ui_require_css_file('wizard'); } @@ -214,6 +215,77 @@ class Wizard ((isset($data['options']) === true) ? $data['options'] : false) ); + case 'select': + return html_print_select( + $data['fields'], + $data['name'], + ((isset($data['selected']) === true) ? $data['selected'] : ''), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['multiple']) === true) ? $data['multiple'] : false), + ((isset($data['sort']) === true) ? $data['sort'] : true), + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['style']) === true) ? $data['style'] : false), + ((isset($data['option_style']) === true) ? $data['option_style'] : false), + ((isset($data['size']) === true) ? $data['size'] : false), + ((isset($data['modal']) === true) ? $data['modal'] : false), + ((isset($data['message']) === true) ? $data['message'] : ''), + ((isset($data['select_all']) === true) ? $data['select_all'] : false) + ); + + case 'select_from_sql': + return html_print_select_from_sql( + $data['sql'], + $data['name'], + ((isset($data['selected']) === true) ? $data['selected'] : ''), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['multiple']) === true) ? $data['multiple'] : false), + ((isset($data['sort']) === true) ? $data['sort'] : true), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['style']) === true) ? $data['style'] : false), + ((isset($data['size']) === true) ? $data['size'] : false), + ((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT) + ); + + case 'select_groups': + return html_print_select_groups( + ((isset($data['id_user']) === true) ? $data['id_user'] : false), + ((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'), + ((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true), + $data['name'], + ((isset($data['selected']) === true) ? $data['selected'] : ''), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['multiple']) === true) ? $data['multiple'] : false), + ((isset($data['sort']) === true) ? $data['sort'] : true), + ((isset($data['class']) === true) ? $data['class'] : ''), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['style']) === true) ? $data['style'] : false), + ((isset($data['option_style']) === true) ? $data['option_style'] : false), + ((isset($data['id_group']) === true) ? $data['id_group'] : false), + ((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'), + ((isset($data['strict_user']) === true) ? $data['strict_user'] : false), + ((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false), + ((isset($data['include_groups']) === true) ? $data['include_groups'] : false) + ); + + case 'submit': + return html_print_submit_button( + ((isset($data['label']) === true) ? $data['label'] : 'OK'), + ((isset($data['name']) === true) ? $data['name'] : ''), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['attributes']) === true) ? $data['attributes'] : ''), + ((isset($data['return']) === true) ? $data['return'] : false) + ); + default: // Ignore. break; @@ -239,16 +311,19 @@ class Wizard $output = '
'; - $ouput .= '
    '; + $output .= '
      '; foreach ($inputs as $input) { $output .= '
    • '; - $output .= $this->printInput($input['arguments']).'
    • '; + $output .= $this->printInput($input['arguments']); + // Allow dynamic content. + $output .= $input['extra']; + $output .= ''; } $output .= '
    '; $output .= ''; - $output .= $js; + $output .= ''; if ($return === false) { echo $output; diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css new file mode 100644 index 0000000000..26f4ac0385 --- /dev/null +++ b/pandora_console/include/styles/wizard.css @@ -0,0 +1,11 @@ +ul.wizard { +} + +ul.wizard li { + padding: 10px; +} + +ul.wizard li > label { + width: 250px; + display: inline-block; +} From 0d7ea0d056030ffd5d2300a23ab6c122f72133d5 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Feb 2019 16:56:03 +0100 Subject: [PATCH 095/262] Added CSV report and copy a lot of not revisted code Former-commit-id: 005362b157450862501963770df3fd0419bc573a --- .../godmode/wizards/HostDevices.class.php | 200 ++++++++++++++++-- .../godmode/wizards/Wizard.main.php | 2 +- 2 files changed, 189 insertions(+), 13 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 421ea07484..8a6a14f892 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -8,6 +8,10 @@ require_once $config['homedir'].'/include/functions_users.php'; */ class HostDevices extends Wizard { + // CSV constants. + const HDW_CSV_NOT_DATA = 0; + const HDW_CSV_DUPLICATED = 0; + const HDW_CSV_GROUP_EXISTS = 0; /** * Undocumented variable @@ -114,11 +118,10 @@ class HostDevices extends Wizard if ($mode === null) { $this->setBreadcrum(['Host&devices']); $this->printHeader(); - if (extensions_is_enabled_extension('csv_import')) { - echo 'Importar csv'; - } + echo 'Importar csv'; echo 'Escanear red'; + return; } @@ -126,7 +129,7 @@ class HostDevices extends Wizard $this->setBreadcrum( [ 'Host&devices', - 'Import CSV', + 'Import CSV', ] ); $this->printHeader(); @@ -178,8 +181,7 @@ class HostDevices extends Wizard { global $config; - if (!check_acl($config['id_user'], 0, 'AW') - ) { + if (!check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( 'ACL Violation', 'Trying to access db status' @@ -188,17 +190,133 @@ class HostDevices extends Wizard return; } - if (!extensions_is_enabled_extension('csv_import')) { - ui_print_error_message( + if (!isset($this->page) || $this->page == 0) { + $this->printForm( [ - 'message' => __('Extension CSV Import is not enabled.'), - 'no_close' => true, + 'form' => [ + 'action' => '#', + 'method' => 'POST', + 'enctype' => 'multipart/form-data', + ], + 'inputs' => [ + [ + 'arguments' => [ + 'type' => 'hidden', + 'name' => 'import_file', + 'value' => 1, + 'return' => true, + ], + ], + [ + 'label' => __('Upload file'), + 'arguments' => [ + 'type' => 'file', + 'name' => 'file', + 'return' => true, + ], + ], + [ + 'label' => __('Server'), + 'arguments' => [ + 'type' => 'select', + 'fields' => servers_get_names(), + 'name' => 'server', + 'return' => true, + ], + ], + [ + 'label' => __('Separator'), + 'arguments' => [ + 'type' => 'select', + 'fields' => [ + ',' => ',', + ';' => ';', + ':' => ':', + '.' => '.', + '#' => '#', + ], + 'name' => 'separator', + 'return' => true, + ], + ], + [ + 'arguments' => [ + 'name' => 'page', + 'value' => 1, + 'type' => 'hidden', + 'return' => true, + ], + ], + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go'), + 'type' => 'submit', + 'attributes' => 'class="sub next"', + 'return' => true, + ], + ], + ], ] ); - return; } - include_once $config['homedir'].'/enterprise/extensions/csv_import/main.php'; + if (isset($this->page) && $this->page == 1) { + $server = get_parameter('server'); + $separator = get_parameter('separator'); + + if (isset($_FILES['file'])) { + $file_status_code = get_file_upload_status('file'); + $file_status = translate_file_upload_status($file_status_code); + + if ($file_status === true) { + $error_message = []; + $line = -1; + $file = fopen($_FILES['file']['tmp_name'], 'r'); + if (! empty($file)) { + while (($data = fgetcsv($file, 1000, $separator)) !== false) { + $result = $this->processCsvData($data, $server); + $line++; + if ($result === HDW_CSV_NOT_DATA || $result === HDW_CSV_DUPLICATED || $result === HDW_CSV_GROUP_EXISTS) { + if ($result === HDW_CSV_NOT_DATA) { + $error_message[] = __('No data or wrong separator in line ').$line.'
    '; + } else if ($result === HDW_CSV_DUPLICATED) { + $error_message[] = __('Agent ').io_safe_input($data[0]).__(' duplicated').'
    '; + } else { + $error_message[] = __("Id group %s in line %s doesn't exist in %s", $data[4], $line, get_product_name()).'
    '; + } + + continue; + } + + ui_print_result_message( + $result !== false, + __('Created agent %s', $result['agent_name']), + __('Could not create agent %s', $result['agent_name']) + ); + } + } + + fclose($file); + + if (empty($error_message)) { + ui_print_success_message(__('File processed')); + } else { + foreach ($error_message as $msg) { + ui_print_error_message($msg); + } + } + } else { + ui_print_error_message($file_status); + } + + @unlink($_FILES['file']['tmp_name']); + } else { + ui_print_error_message(__('No input file detected')); + } + + echo $this->breadcrum[0]; + } } @@ -405,4 +523,62 @@ class HostDevices extends Wizard } + /** + * Process the csv of agent. + * + * @param array $data Data of agent. + * @param string $server Name of server. + * + * @return array with data porcessed. + */ + private static function processCsvData($data, $server='') + { + if (empty($data) || count($data) < 5) { + return HDW_CSV_NOT_DATA; + } + + $data['network_components'] = array_slice($data, 6); + $data['agent_name'] = io_safe_input($data[0]); + $data['alias'] = io_safe_input($data[0]); + $data['ip_address'] = $data[1]; + $data['id_os'] = $data[2]; + $data['interval'] = $data[3]; + $data['id_group'] = $data[4]; + $data['comentarios'] = io_safe_input($data[5]); + + $exists = (bool) agents_get_agent_id($data['agent_name']); + if ($exists) { + return HDW_CSV_DUPLICATED; + } + + $group_exists_in_pandora = (bool) groups_get_group_by_id($data['id_group']); + if (!$group_exists_in_pandora) { + return HDW_CSV_GROUP_EXISTS; + } + + $data['id_agent'] = agents_create_agent( + $data['agent_name'], + $data['id_group'], + $data['interval'], + $data['ip_address'], + [ + 'id_os' => $data['id_os'], + 'server_name' => $server, + 'modo' => 1, + 'alias' => $data['alias'], + 'comentarios' => $data['comentarios'], + ] + ); + + foreach ($data['network_components'] as $id_network_component) { + network_components_create_module_from_network_component( + (int) $id_network_component, + $data['id_agent'] + ); + } + + return $data; + } + + } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index e8722ea8e8..3298a2e0e7 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -308,7 +308,7 @@ class Wizard $inputs = $data['inputs']; $js = $data['js']; - $output = '
    '; $output .= '
      '; From 7df9d4f78b09cd35157457f2177e7e526ec871f6 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 14 Feb 2019 17:14:01 +0100 Subject: [PATCH 096/262] WIP: H&D merge Former-commit-id: d53f7d5abed5cfc8d45e6a42bfd52089ff463ff3 --- .../godmode/wizards/HostDevices.class.php | 295 ++++++++++++++++-- .../godmode/wizards/Wizard.main.php | 74 ++++- pandora_console/include/functions_html.php | 1 + pandora_console/include/styles/wizard.css | 6 +- 4 files changed, 344 insertions(+), 32 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 8a6a14f892..e6117afa4a 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -27,13 +27,6 @@ class HostDevices extends Wizard */ public $result; - /** - * Undocumented variable - * - * @var [type] - */ - public $id; - /** * Undocumented variable * @@ -69,6 +62,13 @@ class HostDevices extends Wizard */ public $page; + /** + * Stores all needed parameters to create a recon task. + * + * @var array + */ + public $task; + /** * Undocumented function. @@ -88,7 +88,7 @@ class HostDevices extends Wizard ) { $this->setBreadcrum([]); - $this->id = null; + $this->task = []; $this->msg = $msg; $this->icon = $icon; $this->label = $label; @@ -488,21 +488,7 @@ class HostDevices extends Wizard 'action' => '#', ]; - $form['js'] = ' - $("select#interval_manual_defined").change(function() { - if ($("#interval_manual_defined").val() == 1) { - $("#interval_manual_container").hide(); - $("#text-interval_text").val(0); - $("#hidden-interval").val(0); - } - else { - $("#interval_manual_container").show(); - $("#text-interval_text").val(10); - $("#hidden-interval").val(600); - $("#interval_units").val(60); - } - }).change();'; - + // XXX: Could be improved validating inputs before continue (JS) // Print NetScan page 0. $this->printForm($form); } @@ -510,7 +496,268 @@ class HostDevices extends Wizard if ($this->page == 1) { // Page 1. - echo 'page 1!'; + $form = []; + // Hidden, id_rt. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'task', + 'value' => $this->task['id_rt'], + 'type' => 'hidden', + 'return' => true, + ], + ]; + + // Hidden, page. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'page', + 'value' => ($this->page + 1), + 'type' => 'hidden', + 'return' => true, + ], + ]; + + $form['inputs'][] = [ + 'extra' => '

      Please, configure task '.io_safe_output($this->task['name']).'

      ', + ]; + + // Input: Module template. + $form['inputs'][] = [ + 'label' => __('Module template'), + 'arguments' => [ + 'name' => 'id_network_profile', + 'type' => 'select_from_sql', + 'sql' => 'SELECT id_np, name + FROM tnetwork_profile + ORDER BY name', + 'return' => true, + + ], + ]; + + // Feature configuration. + // Input: Module template. + $form['inputs'][] = [ + 'label' => __('SNMP enabled'), + 'arguments' => [ + 'name' => 'snmp_enabled', + 'type' => 'switch', + 'return' => true, + 'onclick' => "\$('#snmp_extra').toggle();", + + ], + ]; + + // SNMP CONFIGURATION. + $form['inputs'][] = [ + 'hidden' => 1, + 'block_id' => 'snmp_extra', + 'block_content' => [ + 'label' => __('SNMP version'), + 'arguments' => [ + 'name' => 'auth_strings', + 'fields' => [ + '1' => 'v. 1', + '2c' => 'v. 2c', + '3' => 'v. 3', + ], + 'type' => 'select', + 'script' => "\$('#snmp_options_v'+this.value).toggle()", + 'return' => true, + ], + ], + ]; + + $form['inputs'][] = [ + 'hidden' => 1, + 'block_id' => 'snmp_options_v1', + 'block_content' => [ + 'label' => __('Community'), + 'arguments' => [ + 'name' => 'community', + 'type' => 'text', + 'size' => 25, + 'return' => true, + + ], + ], + ]; + + // Input: WMI enabled. + $form['inputs'][] = [ + 'label' => __('WMI enabled'), + 'arguments' => [ + 'name' => 'wmi_enabled', + 'type' => 'switch', + 'return' => true, + 'onclick' => "\$('#wmi_extra').toggle();", + + ], + ]; + + // WMI CONFIGURATION. + $form['inputs'][] = [ + 'label' => __('WMI Auth. strings'), + 'hidden' => 1, + 'id' => 'wmi_extra', + 'arguments' => [ + 'name' => 'auth_strings', + 'type' => 'text', + 'return' => true, + + ], + ]; + + // Input: Module template. + $form['inputs'][] = [ + 'label' => __('OS detection'), + 'arguments' => [ + 'name' => 'os_detect', + 'type' => 'switch', + 'return' => true, + + ], + ]; + + // Input: Name resolution. + $form['inputs'][] = [ + 'label' => __('Name resolution'), + 'arguments' => [ + 'name' => 'resolve_names', + 'type' => 'switch', + 'return' => true, + ], + ]; + + // Input: Parent detection. + $form['inputs'][] = [ + 'label' => __('Parent detection'), + 'arguments' => [ + 'name' => 'parent_detection', + 'type' => 'switch', + 'return' => true, + ], + ]; + + // Input: VLAN enabled. + $form['inputs'][] = [ + 'label' => __('VLAN enabled'), + 'arguments' => [ + 'name' => 'os_detect', + 'type' => 'switch', + 'return' => true, + ], + ]; + + // Submit button. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Next'), + 'type' => 'submit', + 'attributes' => 'class="sub next"', + 'return' => true, + ], + ]; + + $form['form'] = [ + 'method' => 'POST', + 'action' => '#', + ]; + + $this->printForm($form); + } + + if ($this->page == 2) { + // Interval and schedules. + $interv_manual = 0; + if ((int) $interval == 0) { + $interv_manual = 1; + } + + $form['inputs'][] = [ + 'label' => ''.__('Interval').''.ui_print_help_tip( + __('Manual interval means that it will be executed only On-demand'), + true + ), + 'arguments' => [ + 'type' => 'select', + 'selected' => $interv_manual, + 'fields' => [ + 0 => __('Defined'), + 1 => __('Manual'), + ], + 'name' => 'interval_manual_defined', + 'return' => true, + ], + 'extra' => ''.html_print_extended_select_for_time( + 'interval', + $interval, + '', + '', + '0', + false, + true, + false, + false + ).ui_print_help_tip( + __('The minimum recomended interval for Recon Task is 5 minutes'), + true + ).'', + ]; + + // Hidden, id_rt. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'task', + 'value' => $this->task['id_rt'], + 'type' => 'hidden', + 'return' => true, + ], + ]; + + // Hidden, page. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'page', + 'value' => ($this->page + 1), + 'type' => 'hidden', + 'return' => true, + ], + ]; + + // Submit button. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Next'), + 'type' => 'submit', + 'attributes' => 'class="sub next"', + 'return' => true, + ], + ]; + + $form['form'] = [ + 'method' => 'POST', + 'action' => '#', + ]; + + $form['js'] = ' +$("select#interval_manual_defined").change(function() { + if ($("#interval_manual_defined").val() == 1) { + $("#interval_manual_container").hide(); + $("#text-interval_text").val(0); + $("#hidden-interval").val(0); + } + else { + $("#interval_manual_container").show(); + $("#text-interval_text").val(10); + $("#hidden-interval").val(600); + $("#interval_units").val(60); + } +}).change();'; + + $this->printForm($form); } if ($this->page == 100) { diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 3298a2e0e7..c164b287b7 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -95,7 +95,7 @@ class Wizard * * @return string HTML code for desired input. */ - public function printInput(array $data) + public function printInput($data) { if (is_array($data) === false) { return ''; @@ -286,6 +286,20 @@ class Wizard ((isset($data['return']) === true) ? $data['return'] : false) ); + case 'checkbox': + return html_print_checkbox( + $data['name'], + $data['value'], + ((isset($data['checked']) === true) ? $data['checked'] : false), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['disabled']) === true) ? $data['disabled'] : false), + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false) + ); + + case 'switch': + return html_print_switch($data); + default: // Ignore. break; @@ -295,10 +309,60 @@ class Wizard } + /** + * Print a block of inputs. + * + * @param array $input Definition of target block to be printed. + * @param boolean $return Return as string or direct output. + * + * @return string HTML content. + */ + public function printBlock(array $input, bool $return=false) + { + $output = ''; + if ($input['hidden'] == 1) { + $class = ' class="hidden"'; + } else { + $class = ''; + } + + if (is_array($input['block_content']) === true) { + // Print independent block of inputs. + $output .= '
    • '; + $output .= '
        '; + foreach ($input['block_content'] as $input) { + $output .= $this->printBlock($input, $return); + } + + $output .= '
    • '; + } else { + if ($input['arguments']['type'] != 'hidden') { + $output .= '
    • '; + $output .= ''; + $output .= $this->printInput($input['arguments']); + // Allow dynamic content. + $output .= $input['extra']; + $output .= '
    • '; + } else { + $output .= $this->printInput($input['arguments']); + // Allow dynamic content. + $output .= $input['extra']; + } + } + + if ($return === false) { + echo $output; + } + + return $output; + } + + /** * Print a form. * - * @param array $data Definition of target form to be printed. + * @param array $data Definition of target form to be printed. + * @param boolean $return Return as string or direct output. * * @return string HTML code. */ @@ -314,11 +378,7 @@ class Wizard $output .= '
        '; foreach ($inputs as $input) { - $output .= '
      • '; - $output .= $this->printInput($input['arguments']); - // Allow dynamic content. - $output .= $input['extra']; - $output .= '
      • '; + $output .= $this->printBlock($input, true); } $output .= '
      '; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 8985655745..ca23d3b029 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -3016,6 +3016,7 @@ function html_print_switch($attributes=[]) 'id', 'class', 'name', + 'onclick', ]; foreach ($valid_attrs as $va) { if (!isset($attributes[$va])) { diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css index 26f4ac0385..fdaf5afa4b 100644 --- a/pandora_console/include/styles/wizard.css +++ b/pandora_console/include/styles/wizard.css @@ -5,7 +5,11 @@ ul.wizard li { padding: 10px; } -ul.wizard li > label { +ul.wizard li > label:not(.p-switch) { width: 250px; display: inline-block; } + +.hidden { + display: none; +} From 39958741763fb23de8f75fca6e7d675312461fa2 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 14 Feb 2019 17:19:20 +0100 Subject: [PATCH 097/262] WIP: H&D: merge Former-commit-id: c1e04b80a49fb0a9870676dc8f59732cd595fbc0 --- .../godmode/wizards/HostDevices.class.php | 249 +++- pandora_console/install.php | 1090 ----------------- 2 files changed, 192 insertions(+), 1147 deletions(-) delete mode 100644 pandora_console/install.php diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index e6117afa4a..23250995db 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -327,6 +327,93 @@ class HostDevices extends Wizard */ public function parseNetScan() { + if ($this->page == 0) { + // Error. Must not be here. + return true; + } + + // Validate response from page 0. No, not a bug, we're always 1 page + // from 'validation' page. + if ($this->page == 1) { + $taskname = get_parameter('taskname', ''); + $comment = get_parameter('comment', ''); + $server_id = get_parameter('id_recon_server', ''); + $network = get_parameter('name', ''); + $id_group = get_parameter('id_group', ''); + + if ($taskname == '') { + $this->msg = __('You must provide a task name.'); + return false; + } + + if ($server_id == '') { + $this->msg = __('You must select a Discovery Server.'); + return false; + } + + if ($network == '') { + // XXX: Could be improved validating provided network. + $this->msg = __('You must provide a valid network.'); + return false; + } + + if ($id_group == '') { + $this->msg = __('You must select a valid group.'); + return false; + } + + // Assign fields. + $this->task['name'] = $taskname; + $this->task['description'] = $comment; + $this->task['subnet'] = $network; + $this->task['id_recon_server'] = $server_id; + // Disabled 2 Implies wizard non finished. + $this->task['disabled'] = 2; + + $this->task['id_rt'] = 5; + + if (!isset($this->task['id_rt'])) { + // Create. + $this->task['id_rt'] = db_process_sql_insert( + 'trecon_task', + $this->task + ); + } else { + // Update. + db_process_sql_update( + 'trecon_task', + $this->task, + ['id_rt' => $this->task['id_rt']] + ); + } + + return true; + } + + // Validate response from page 1. + if ($this->page == 2) { + $id_rt = get_parameter('task', -1); + + $this->task = db_get_row( + 'trecon_task', + 'id_rt', + $id_rt + ); + + hd($this->task); + + return false; + } + + if ($this->page == 3) { + // Interval and schedules. + // By default manual if not defined. + $interval = get_parameter('interval', 0); + + $this->task['interval_sweep'] = $interval; + return false; + } + return false; } @@ -355,18 +442,83 @@ class HostDevices extends Wizard $user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); $user_groups = array_keys($user_groups); - if (isset($this->page) && $this->page == 1) { - // Parse page 0 responses. - $this->parseNetScan(); + if ($this->parseNetScan() === false) { + // Error. + ui_print_error_message( + $this->msg + ); + + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => '#', + ], + 'inputs' => [ + [ + 'arguments' => [ + 'type' => 'hidden', + 'name' => 'page', + 'value' => ($this->page - 1), + ], + ], + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + $this->printForm($form); + return null; } - if (!isset($this->page) || $this->page == 0) { - // Interval. - $interv_manual = 0; - if ((int) $interval == 0) { - $interv_manual = 1; - } + if (isset($this->page) + && $this->page != 0 + && isset($this->task['id_rt']) === false + ) { + // Error. + ui_print_error_message( + __('Internal error, please re-run this wizard.') + ); + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => '#', + ], + 'inputs' => [ + [ + 'arguments' => [ + 'type' => 'hidden', + 'name' => 'page', + 'value' => 0, + ], + ], + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + $this->printForm($form); + return null; + } + + // -------------------------------. + // Page 0. wizard starts HERE. + // -------------------------------. + if (!isset($this->page) || $this->page == 0) { if (isset($this->page) === false || $this->page == 0 ) { @@ -383,6 +535,17 @@ class HostDevices extends Wizard ], ]; + // Input task name. + $form['inputs'][] = [ + 'label' => ''.__('Comment').'', + 'arguments' => [ + 'name' => 'comment', + 'value' => '', + 'type' => 'text', + 'size' => 25, + ], + ]; + // Input Discovery Server. $form['inputs'][] = [ 'label' => ''.__('Discovery server').''.ui_print_help_tip( @@ -419,38 +582,6 @@ class HostDevices extends Wizard ], ]; - // Input interval. - $form['inputs'][] = [ - 'label' => ''.__('Interval').''.ui_print_help_tip( - __('Manual interval means that it will be executed only On-demand'), - true - ), - 'arguments' => [ - 'type' => 'select', - 'selected' => $interv_manual, - 'fields' => [ - 0 => __('Defined'), - 1 => __('Manual'), - ], - 'name' => 'interval_manual_defined', - 'return' => true, - ], - 'extra' => ''.html_print_extended_select_for_time( - 'interval', - $interval, - '', - '', - '0', - false, - true, - false, - false - ).ui_print_help_tip( - __('The minimum recomended interval for Recon Task is 5 minutes'), - true - ).'', - ]; - // Input Group. $form['inputs'][] = [ 'label' => ''.__('Group').'', @@ -553,17 +684,19 @@ class HostDevices extends Wizard 'hidden' => 1, 'block_id' => 'snmp_extra', 'block_content' => [ - 'label' => __('SNMP version'), - 'arguments' => [ - 'name' => 'auth_strings', - 'fields' => [ - '1' => 'v. 1', - '2c' => 'v. 2c', - '3' => 'v. 3', + [ + 'label' => __('SNMP version'), + 'arguments' => [ + 'name' => 'auth_strings', + 'fields' => [ + '1' => 'v. 1', + '2c' => 'v. 2c', + '3' => 'v. 3', + ], + 'type' => 'select', + 'script' => "\$('#snmp_options_v'+this.value).toggle()", + 'return' => true, ], - 'type' => 'select', - 'script' => "\$('#snmp_options_v'+this.value).toggle()", - 'return' => true, ], ], ]; @@ -572,13 +705,15 @@ class HostDevices extends Wizard 'hidden' => 1, 'block_id' => 'snmp_options_v1', 'block_content' => [ - 'label' => __('Community'), - 'arguments' => [ - 'name' => 'community', - 'type' => 'text', - 'size' => 25, - 'return' => true, + [ + 'label' => __('Community'), + 'arguments' => [ + 'name' => 'community', + 'type' => 'text', + 'size' => 25, + 'return' => true, + ], ], ], ]; diff --git a/pandora_console/install.php b/pandora_console/install.php deleted file mode 100644 index 69e11b10bd..0000000000 --- a/pandora_console/install.php +++ /dev/null @@ -1,1090 +0,0 @@ - - - - - Pandora FMS - Installation Wizard - - - - - - - - - - - - - - - -
      - -
      - - - -'; - echo " $label "; - echo ''; - if (!extension_loaded($ext)) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - -function check_include($ext, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!include $ext) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - - -function check_exists($file, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!file_exists($file)) { - echo " "; - return 1; - } else { - echo " "; - return 0; - } - - echo ''; -} - - -function check_generic($ok, $label) -{ - echo ""; - if ($ok == 0) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } -} - - -function check_writable($fullpath, $label) -{ - echo ""; - if (file_exists($fullpath)) { - if (is_writable($fullpath)) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } -} - - -function check_variable($var, $value, $label, $mode) -{ - echo ''; - echo " $label "; - echo ''; - if ($mode == 1) { - if ($var >= $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - } else if ($var == $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - - echo ''; -} - - -function parse_mysql_dump($url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysql_query($query)) { - echo mysql_error(); - // Uncomment for debug - echo "
      $query
      "; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function parse_mysqli_dump($connection, $url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysqli_query($connection, $query)) { - echo mysqli_error(); - // Uncomment for debug - echo "
      $query
      "; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function random_name($size) -{ - $temp = ''; - for ($a = 0; $a < $size; $a++) { - $temp = $temp.chr(rand(122, 97)); - } - - return $temp; -} - - -function print_logo_status($step, $step_total) -{ - global $banner; - - $header = " -
      -
      -
      - $banner -
      -
      "; - $header .= " -
      - Install step $step of $step_total -
      "; - - 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. -
      "; - - echo '
      '; - - if ($writable == 0) { - echo "
      "; - echo ""; - echo '
      '; - } else { - echo "
      ERROR:You need to setup permissions to be able to write in ./include directory
      "; - } - - echo '
      '; - - echo "
      "; - echo " -
      -
      - Pandora FMS is an OpenSource Software project registered at - SourceForge -
      -
      "; -} - - -function install_step1_licence() -{ - echo " -
      -
      - ".print_logo_status(2, 6)." -
      -

      GPL2 Licence terms agreement

      -

      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 "'; - echo '

      '; - echo "

      "; - } - - echo '
      '; - - echo "
      -
      -
      - Pandora FMS is an OpenSource Software project registered at - SourceForge -
      -
      "; -} - - -function install_step2() -{ - echo " -
      -
      - ".print_logo_status(3, 6)." -
      "; - echo '

      Checking software dependencies

      '; - echo ''; - $res = 0; - $res += check_variable(phpversion(), '5.2', 'PHP version >= 5.2', 1); - $res += check_extension('gd', 'PHP GD extension'); - $res += check_extension('ldap', 'PHP LDAP extension'); - $res += check_extension('snmp', 'PHP SNMP extension'); - $res += check_extension('session', 'PHP session extension'); - $res += check_extension('gettext', 'PHP gettext extension'); - $res += check_extension('mbstring', 'PHP Multibyte String'); - $res += check_extension('zip', 'PHP Zip'); - $res += check_extension('zlib', 'PHP Zlib extension'); - $res += check_extension('json', 'PHP json extension'); - $res += check_extension('curl', 'CURL (Client URL Library)'); - $res += check_extension('filter', 'PHP filter extension'); - $res += check_extension('calendar', 'PHP calendar extension'); - if (PHP_OS == 'FreeBSD') { - $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); - } else if (PHP_OS == 'NetBSD') { - $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); - } else if (substr(PHP_OS, 0, 3) == 'WIN') { - $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); - } else { - $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); - } - - echo ''; - check_extension('mysql', 'PHP MySQL extension'); - check_extension('mysqli', 'PHP MySQL(mysqli) extension'); - echo '
      '; - echo "DB Engines"; - echo ''; - echo '
      '; - - if ($res > 0) { - echo " -
      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. -
      -
      - Ignore it. -
      "; - } else { - echo "
      "; - echo " - "; - echo '
      '; - } - - echo '
      '; - echo "
      "; - echo " -
      -
      -
      -
      - Pandora FMS is an OpenSource Software project registered at - SourceForge -
      - "; -} - - -function install_step3() -{ - $options = ''; - if (extension_loaded('mysql')) { - $options .= ""; - } - - if (extension_loaded('mysqli')) { - $options .= ""; - } - - $error = false; - if (empty($options)) { - $error = true; - } - - echo " -
      -
      - ".print_logo_status(4, 6)." -
      -

      Environment and database setup

      -

      - 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.
      "; - } - - if (!$error) { - echo ""; - } - - echo ""; - echo '"; - - // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost - echo " - - "; - - echo " "; - - echo ""; - echo '
      '; - echo 'DB Engine
      '; - - if ($error) { - echo " -
      - Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. -
      "; - } else { - echo "'; - - echo '
      '; - echo ' Installation in
      '; - echo "'; - } - - echo "
      DB User with privileges
      - - -
      DB Password for this user
      - - -
      DB Hostname
      - - -
      DB Name (pandora by default)
      - - -
      Drop Database if exists
      - -
      Full path to HTTP publication directory
      - For example /var/www/pandora_console/ -
      - - -
      '; - echo "URL path to Pandora FMS Console
      - For example '/pandora_console' -
      - -
      - "; - - if (!$error) { - echo "
      "; - echo " - "; - echo '
      '; - ?> - - '; - - echo ''; - - echo "
      "; - echo "
      -
      - Pandora FMS is an OpenSource Software project registered at - SourceForge -
      -
      "; -} - - -function install_step4() -{ - $pandora_config = 'include/config.php'; - - if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) - || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) - ) { - $dbpassword = ''; - $dbuser = ''; - $dbhost = ''; - $dbname = ''; - $engine = ''; - $dbaction = ''; - $dbgrant = ''; - } else { - $engine = $_POST['engine']; - $dbpassword = $_POST['pass']; - $dbuser = $_POST['user']; - $dbhost = $_POST['host']; - $dbaction = $_POST['db_action']; - if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { - $dbgrant = $_POST['dbgrant']; - } else { - $dbgrant = $_SERVER['SERVER_ADDR']; - } - - if (isset($_POST['drop'])) { - $dbdrop = $_POST['drop']; - } else { - $dbdrop = 0; - } - - $dbname = $_POST['dbname']; - if (isset($_POST['url'])) { - $url = $_POST['url']; - } else { - $url = 'http://localhost'; - } - - if (isset($_POST['path'])) { - $path = $_POST['path']; - $path = str_replace('\\', '/', $path); - // Windows compatibility - } else { - $path = '/var/www'; - } - } - - $everything_ok = 0; - $step1 = 0; - $step2 = 0; - $step3 = 0; - $step4 = 0; - $step5 = 0; - $step6 = 0; - $step7 = 0; - - echo " -
      -
      - ".print_logo_status(5, 6)." -
      -

      Creating database and default configuration file

      - "; - switch ($engine) { - case 'mysql': - if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysql_query("DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysql_query("CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysql_select_db($dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysql_dump('pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysql_dump('pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysql_query( - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysql_query('FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
      Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
      "); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - - case 'mysqli': - $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); - if (mysqli_connect_error() > 0) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysqli_select_db($connection, $dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine, $connection); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysqli_query( - $connection, - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysqli_query($connection, 'FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
      Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
      "); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - } - - echo '
      '; - - if ($everything_ok == 1) { - echo "
      "; - echo " - "; - echo '
      '; - } else { - $info = "
      There were some problems. - Installation was not completed. -

      Please correct failures before trying again. - All database "; - if ($engine == 'oracle') { - $info .= 'objects '; - } else { - $info .= 'schemes '; - } - - $info .= 'created in this step have been dropped.

      -
      '; - echo $info; - - switch ($engine) { - case 'mysql': - if (mysql_error() != '') { - echo "
      ERROR: ".mysql_error().'.
      '; - } - - if ($step1 == 1) { - mysql_query("DROP DATABASE $dbname"); - } - break; - - case 'mysqli': - if (mysqli_error($connection) != '') { - echo "
      ERROR: ".mysqli_error($connection).'.
      '; - } - - if ($step1 == 1) { - mysqli_query($connection, "DROP DATABASE $dbname"); - } - break; - } - - echo '
      '; - } - - echo '
      '; - echo "
      "; - echo " -
      -
      - Pandora FMS is an Open Source Software project registered at - SourceForge -
      -
      "; -} - - -function install_step5() -{ - echo " -
      -
      - ".print_logo_status(6, 6)." -
      -

      Installation complete

      -

      For security, you now must manually delete this installer - ('install.php') file before trying to access to your Pandora FMS console. -

      You should also install Pandora FMS Servers before trying to monitor anything; - please read documentation on how to install it.

      -

      Default user is 'admin' with password 'pandora', - please change it both as soon as possible.

      -

      Don't forget to check http://pandorafms.com - for updates. -

      Select if you want to rename 'install.php'.

      -
      - - -
      -


      . -

      -
      "; - - echo "
      -
      - Pandora FMS is an OpenSource Software project registered at - SourceForge -
      -
      "; -} From 2059614ba231115ffa46e388301b28f68b90253f Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 14 Feb 2019 17:20:00 +0100 Subject: [PATCH 098/262] missed install... Former-commit-id: a2e1bc42354612afde7e1a28845348f41eab7509 --- pandora_console/install.php | 1106 +++++++++++++++++++++++++++++++++++ 1 file changed, 1106 insertions(+) create mode 100644 pandora_console/install.php diff --git a/pandora_console/install.php b/pandora_console/install.php new file mode 100644 index 0000000000..2a190ff74e --- /dev/null +++ b/pandora_console/install.php @@ -0,0 +1,1106 @@ + + + + + Pandora FMS - Installation Wizard + + + + + + + + + + + + + + + +
      + +
      + + + +'; + echo " $label "; + echo ''; + if (!extension_loaded($ext)) { + echo ""; + return 1; + } else { + echo ""; + return 0; + } + + echo ''; +} + +function check_include($ext, $label) +{ + echo ''; + echo " $label "; + echo ''; + if (!include $ext) { + echo ""; + return 1; + } else { + echo ""; + return 0; + } + + echo ''; +} + + +function check_exists($file, $label) +{ + echo ''; + echo " $label "; + echo ''; + if (!file_exists($file)) { + echo " "; + return 1; + } else { + echo " "; + return 0; + } + + echo ''; +} + + +function check_generic($ok, $label) +{ + echo ""; + if ($ok == 0) { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 0; + } +} + + +function check_writable($fullpath, $label) +{ + echo ""; + if (file_exists($fullpath)) { + if (is_writable($fullpath)) { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 0; + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } + } else { + echo " "; + echo ''; + echo " $label "; + echo ''; + echo ''; + return 1; + } +} + + +function check_variable($var, $value, $label, $mode) +{ + echo ''; + echo " $label "; + echo ''; + if ($mode == 1) { + if ($var >= $value) { + echo " "; + return 0; + } else { + echo " "; + return 1; + } + } else if ($var == $value) { + echo " "; + return 0; + } else { + echo " "; + return 1; + } + + echo ''; +} + + +function parse_mysql_dump($url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysql_query($query)) { + echo mysql_error(); + // Uncomment for debug + echo "
      $query
      "; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +function parse_mysqli_dump($connection, $url) +{ + if (file_exists($url)) { + $file_content = file($url); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { + $query .= $sql_line; + if (preg_match("/;[\040]*\$/", $sql_line)) { + if (!$result = mysqli_query($connection, $query)) { + echo mysqli_error(); + // Uncomment for debug + echo "
      $query
      "; + return 0; + } + + $query = ''; + } + } + } + + return 1; + } else { + return 0; + } +} + + +function random_name($size) +{ + $temp = ''; + for ($a = 0; $a < $size; $a++) { + $temp = $temp.chr(rand(122, 97)); + } + + return $temp; +} + + +function print_logo_status($step, $step_total) +{ + global $banner; + + $header = " +
      +
      +
      + $banner +
      +
      "; + $header .= " +
      + Install step $step of $step_total +
      "; + + 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. +
      "; + + echo '
      '; + + if ($writable == 0) { + echo "
      "; + echo ""; + echo '
      '; + } else { + echo "
      ERROR:You need to setup permissions to be able to write in ./include directory
      "; + } + + echo '
      '; + + echo "
      "; + echo " +
      +
      + Pandora FMS is an OpenSource Software project registered at + SourceForge +
      +
      "; +} + + +function install_step1_licence() +{ + echo " +
      +
      + ".print_logo_status(2, 6)." +
      +

      GPL2 Licence terms agreement

      +

      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 "'; + echo '

      '; + echo "

      "; + } + + echo '
      '; + + echo "
      +
      +
      + Pandora FMS is an OpenSource Software project registered at + SourceForge +
      +
      "; +} + + +function install_step2() +{ + echo " +
      +
      + ".print_logo_status(3, 6)." +
      "; + echo '

      Checking software dependencies

      '; + echo ''; + $res = 0; + $res += check_variable(phpversion(), '5.2', 'PHP version >= 5.2', 1); + $res += check_extension('gd', 'PHP GD extension'); + $res += check_extension('ldap', 'PHP LDAP extension'); + $res += check_extension('snmp', 'PHP SNMP extension'); + $res += check_extension('session', 'PHP session extension'); + $res += check_extension('gettext', 'PHP gettext extension'); + $res += check_extension('mbstring', 'PHP Multibyte String'); + $res += check_extension('zip', 'PHP Zip'); + $res += check_extension('zlib', 'PHP Zlib extension'); + $res += check_extension('json', 'PHP json extension'); + $res += check_extension('curl', 'CURL (Client URL Library)'); + $res += check_extension('filter', 'PHP filter extension'); + $res += check_extension('calendar', 'PHP calendar extension'); + if (PHP_OS == 'FreeBSD') { + $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); + } else if (PHP_OS == 'NetBSD') { + $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); + } else if (substr(PHP_OS, 0, 3) == 'WIN') { + $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); + } else { + $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); + } + + echo ''; + check_extension('mysql', 'PHP MySQL extension'); + check_extension('mysqli', 'PHP MySQL(mysqli) extension'); + echo '
      '; + echo "DB Engines"; + echo ''; + echo '
      '; + + if ($res > 0) { + echo " +
      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. +
      +
      + Ignore it. +
      "; + } else { + echo "
      "; + echo " + "; + echo '
      '; + } + + echo '
      '; + echo "
      "; + echo " +
      +
      +
      +
      + Pandora FMS is an OpenSource Software project registered at + SourceForge +
      + "; +} + + +function install_step3() +{ + $options = ''; + if (extension_loaded('mysql')) { + $options .= ""; + } + + if (extension_loaded('mysqli')) { + $options .= ""; + } + + $error = false; + if (empty($options)) { + $error = true; + } + + echo " +
      +
      + ".print_logo_status(4, 6)." +
      +

      Environment and database setup

      +

      + 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.
      "; + } + + if (!$error) { + echo ""; + } + + echo ""; + echo '"; + + // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost + echo " + + "; + + echo " "; + + echo ""; + echo '
      '; + echo 'DB Engine
      '; + + if ($error) { + echo " +
      + Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. +
      "; + } else { + echo "'; + + echo '
      '; + echo ' Installation in
      '; + echo "'; + } + + echo "
      DB User with privileges
      + + +
      DB Password for this user
      + + +
      DB Hostname
      + + +
      DB Name (pandora by default)
      + + +
      Drop Database if exists
      + +
      Full path to HTTP publication directory
      + For example /var/www/pandora_console/ +
      + + +
      '; + echo "URL path to Pandora FMS Console
      + For example '/pandora_console' +
      + +
      + "; + + if (!$error) { + echo "
      "; + echo " + "; + echo '
      '; + ?> + + '; + + echo ''; + + echo "
      "; + echo "
      +
      + Pandora FMS is an OpenSource Software project registered at + SourceForge +
      +
      "; +} + + +function install_step4() +{ + $pandora_config = 'include/config.php'; + + if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) + || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) + ) { + $dbpassword = ''; + $dbuser = ''; + $dbhost = ''; + $dbname = ''; + $engine = ''; + $dbaction = ''; + $dbgrant = ''; + } else { + $engine = $_POST['engine']; + $dbpassword = $_POST['pass']; + $dbuser = $_POST['user']; + $dbhost = $_POST['host']; + $dbaction = $_POST['db_action']; + if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { + $dbgrant = $_POST['dbgrant']; + } else { + $dbgrant = $_SERVER['SERVER_ADDR']; + } + + if (isset($_POST['drop'])) { + $dbdrop = $_POST['drop']; + } else { + $dbdrop = 0; + } + + $dbname = $_POST['dbname']; + if (isset($_POST['url'])) { + $url = $_POST['url']; + } else { + $url = 'http://localhost'; + } + + if (isset($_POST['path'])) { + $path = $_POST['path']; + $path = str_replace('\\', '/', $path); + // Windows compatibility + } else { + $path = '/var/www'; + } + } + + $everything_ok = 0; + $step1 = 0; + $step2 = 0; + $step3 = 0; + $step4 = 0; + $step5 = 0; + $step6 = 0; + $step7 = 0; + + echo " +
      +
      + ".print_logo_status(5, 6)." +
      +

      Creating database and default configuration file

      + "; + switch ($engine) { + case 'mysql': + if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysql_query("DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysql_query("CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysql_select_db($dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysql_dump('pandoradb.sql'); + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysql_dump('pandoradb_data.sql'); + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysql_query( + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysql_query('FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
      Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
      "); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + + case 'mysqli': + $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); + if (mysqli_connect_error() > 0) { + check_generic(0, 'Connection with Database'); + } else { + check_generic(1, 'Connection with Database'); + + // Drop database if needed and don't want to install over an existing DB + if ($dbdrop == 1) { + mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); + } + + // Create schema + if ($dbaction == 'db_new' || $dbdrop == 1) { + $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); + check_generic($step1, "Creating database '$dbname'"); + } else { + $step1 = 1; + } + + if ($step1 == 1) { + $step2 = mysqli_select_db($connection, $dbname); + check_generic($step2, "Opening database '$dbname'"); + + $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); + check_generic($step3, 'Creating schema'); + + $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); + check_generic($step4, 'Populating database'); + if (PHP_OS == 'FreeBSD') { + $step_freebsd = adjust_paths_for_freebsd($engine, $connection); + check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); + } + + $random_password = random_name(8); + $host = $dbhost; + // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { + $host = $dbgrant; + // if the granted origin is different from local machine, set the valid origin + } + + $step5 = mysqli_query( + $connection, + "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host + IDENTIFIED BY '".$random_password."'" + ); + mysqli_query($connection, 'FLUSH PRIVILEGES'); + check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
      Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
      "); + + $step6 = is_writable('include'); + check_generic($step6, "Write permissions to save config file in './include'"); + + $cfgin = fopen('include/config.inc.php', 'r'); + $cfgout = fopen($pandora_config, 'w'); + $config_contents = fread($cfgin, filesize('include/config.inc.php')); + $dbtype = 'mysql'; + $config_new = ''; + $step7 = fputs($cfgout, $config_new); + $step7 = ($step7 + fputs($cfgout, $config_contents)); + if ($step7 > 0) { + $step7 = 1; + } + + fclose($cfgin); + fclose($cfgout); + chmod($pandora_config, 0600); + check_generic($step7, "Created new config file at '".$pandora_config."'"); + } + } + + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + break; + } + + echo '
      '; + + if ($everything_ok == 1) { + echo "
      "; + echo " + "; + echo '
      '; + } else { + $info = "
      There were some problems. + Installation was not completed. +

      Please correct failures before trying again. + All database "; + if ($engine == 'oracle') { + $info .= 'objects '; + } else { + $info .= 'schemes '; + } + + $info .= 'created in this step have been dropped.

      +
      '; + echo $info; + + switch ($engine) { + case 'mysql': + if (mysql_error() != '') { + echo "
      ERROR: ".mysql_error().'.
      '; + } + + if ($step1 == 1) { + mysql_query("DROP DATABASE $dbname"); + } + break; + + case 'mysqli': + if (mysqli_error($connection) != '') { + echo "
      ERROR: ".mysqli_error($connection).'.
      '; + } + + if ($step1 == 1) { + mysqli_query($connection, "DROP DATABASE $dbname"); + } + break; + } + + echo '
      '; + } + + echo '
      '; + echo "
      "; + echo " +
      +
      + Pandora FMS is an Open Source Software project registered at + SourceForge +
      +
      "; +} + + +function install_step5() +{ + echo " +
      +
      + ".print_logo_status(6, 6)." +
      +

      Installation complete

      +

      For security, you now must manually delete this installer + ('install.php') file before trying to access to your Pandora FMS console. +

      You should also install Pandora FMS Servers before trying to monitor anything; + please read documentation on how to install it.

      +

      Default user is 'admin' with password 'pandora', + please change it both as soon as possible.

      +

      Don't forget to check http://pandorafms.com + for updates. +

      Select if you want to rename 'install.php'.

      +
      + + +
      +


      . +

      +
      "; + + echo "
      +
      + Pandora FMS is an OpenSource Software project registered at + SourceForge +
      +
      "; +} From 96fccc578c2349207482b4daf1a25e411f04c8b7 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 14 Feb 2019 17:56:10 +0100 Subject: [PATCH 099/262] WIP: H&D Former-commit-id: 82a6c84a2c896a08f420a89dc3fe6cd79d8ff3bb --- .../godmode/wizards/HostDevices.class.php | 298 +++++------------- .../godmode/wizards/Wizard.main.php | 7 + 2 files changed, 83 insertions(+), 222 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 23250995db..758f8e653b 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -1,7 +1,34 @@ setBreadcrum( - [ - 'Host&devices', - 'Import CSV', - ] - ); - $this->printHeader(); - return $this->runCSV(); + if (enterprise_installed()) { + if ($mode == 'importcsv') { + $this->setBreadcrum( + [ + 'Host&devices', + 'Import CSV', + ] + ); + $this->printHeader(); + $csv_importer = new CSVImportAgents($this->page, $this->breadcrum); + return $csv_importer->runCSV(); + } } if ($mode == 'netscan') { @@ -172,154 +195,6 @@ class HostDevices extends Wizard // Extra methods. - /** - * Undocumented function - * - * @return void - */ - public function runCSV() - { - global $config; - - if (!check_acl($config['id_user'], 0, 'AW')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access db status' - ); - include 'general/noaccess.php'; - return; - } - - if (!isset($this->page) || $this->page == 0) { - $this->printForm( - [ - 'form' => [ - 'action' => '#', - 'method' => 'POST', - 'enctype' => 'multipart/form-data', - ], - 'inputs' => [ - [ - 'arguments' => [ - 'type' => 'hidden', - 'name' => 'import_file', - 'value' => 1, - 'return' => true, - ], - ], - [ - 'label' => __('Upload file'), - 'arguments' => [ - 'type' => 'file', - 'name' => 'file', - 'return' => true, - ], - ], - [ - 'label' => __('Server'), - 'arguments' => [ - 'type' => 'select', - 'fields' => servers_get_names(), - 'name' => 'server', - 'return' => true, - ], - ], - [ - 'label' => __('Separator'), - 'arguments' => [ - 'type' => 'select', - 'fields' => [ - ',' => ',', - ';' => ';', - ':' => ':', - '.' => '.', - '#' => '#', - ], - 'name' => 'separator', - 'return' => true, - ], - ], - [ - 'arguments' => [ - 'name' => 'page', - 'value' => 1, - 'type' => 'hidden', - 'return' => true, - ], - ], - [ - 'arguments' => [ - 'name' => 'submit', - 'label' => __('Go'), - 'type' => 'submit', - 'attributes' => 'class="sub next"', - 'return' => true, - ], - ], - ], - ] - ); - } - - if (isset($this->page) && $this->page == 1) { - $server = get_parameter('server'); - $separator = get_parameter('separator'); - - if (isset($_FILES['file'])) { - $file_status_code = get_file_upload_status('file'); - $file_status = translate_file_upload_status($file_status_code); - - if ($file_status === true) { - $error_message = []; - $line = -1; - $file = fopen($_FILES['file']['tmp_name'], 'r'); - if (! empty($file)) { - while (($data = fgetcsv($file, 1000, $separator)) !== false) { - $result = $this->processCsvData($data, $server); - $line++; - if ($result === HDW_CSV_NOT_DATA || $result === HDW_CSV_DUPLICATED || $result === HDW_CSV_GROUP_EXISTS) { - if ($result === HDW_CSV_NOT_DATA) { - $error_message[] = __('No data or wrong separator in line ').$line.'
      '; - } else if ($result === HDW_CSV_DUPLICATED) { - $error_message[] = __('Agent ').io_safe_input($data[0]).__(' duplicated').'
      '; - } else { - $error_message[] = __("Id group %s in line %s doesn't exist in %s", $data[4], $line, get_product_name()).'
      '; - } - - continue; - } - - ui_print_result_message( - $result !== false, - __('Created agent %s', $result['agent_name']), - __('Could not create agent %s', $result['agent_name']) - ); - } - } - - fclose($file); - - if (empty($error_message)) { - ui_print_success_message(__('File processed')); - } else { - foreach ($error_message as $msg) { - ui_print_error_message($msg); - } - } - } else { - ui_print_error_message($file_status); - } - - @unlink($_FILES['file']['tmp_name']); - } else { - ui_print_error_message(__('No input file detected')); - } - - echo $this->breadcrum[0]; - } - } - - /** * Retrieves and validates information given by user in NetScan wizard. * @@ -701,6 +576,7 @@ class HostDevices extends Wizard ], ]; + // SNMP Options pack v1. $form['inputs'][] = [ 'hidden' => 1, 'block_id' => 'snmp_options_v1', @@ -718,6 +594,42 @@ class HostDevices extends Wizard ], ]; + // SNMP Options pack v2c. + $form['inputs'][] = [ + 'hidden' => 1, + 'block_id' => 'snmp_options_v2c', + 'block_content' => [ + [ + 'label' => __('Community'), + 'arguments' => [ + 'name' => 'community', + 'type' => 'text', + 'size' => 25, + 'return' => true, + + ], + ], + ], + ]; + + // SNMP Options pack v3. + $form['inputs'][] = [ + 'hidden' => 1, + 'block_id' => 'snmp_options_v3', + 'block_content' => [ + [ + 'label' => __(''), + 'arguments' => [ + 'name' => 'community', + 'type' => 'text', + 'size' => 25, + 'return' => true, + + ], + ], + ], + ]; + // Input: WMI enabled. $form['inputs'][] = [ 'label' => __('WMI enabled'), @@ -905,62 +817,4 @@ $("select#interval_manual_defined").change(function() { } - /** - * Process the csv of agent. - * - * @param array $data Data of agent. - * @param string $server Name of server. - * - * @return array with data porcessed. - */ - private static function processCsvData($data, $server='') - { - if (empty($data) || count($data) < 5) { - return HDW_CSV_NOT_DATA; - } - - $data['network_components'] = array_slice($data, 6); - $data['agent_name'] = io_safe_input($data[0]); - $data['alias'] = io_safe_input($data[0]); - $data['ip_address'] = $data[1]; - $data['id_os'] = $data[2]; - $data['interval'] = $data[3]; - $data['id_group'] = $data[4]; - $data['comentarios'] = io_safe_input($data[5]); - - $exists = (bool) agents_get_agent_id($data['agent_name']); - if ($exists) { - return HDW_CSV_DUPLICATED; - } - - $group_exists_in_pandora = (bool) groups_get_group_by_id($data['id_group']); - if (!$group_exists_in_pandora) { - return HDW_CSV_GROUP_EXISTS; - } - - $data['id_agent'] = agents_create_agent( - $data['agent_name'], - $data['id_group'], - $data['interval'], - $data['ip_address'], - [ - 'id_os' => $data['id_os'], - 'server_name' => $server, - 'modo' => 1, - 'alias' => $data['alias'], - 'comentarios' => $data['comentarios'], - ] - ); - - foreach ($data['network_components'] as $id_network_component) { - network_components_create_module_from_network_component( - (int) $id_network_component, - $data['id_agent'] - ); - } - - return $data; - } - - } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index c164b287b7..1a70bae362 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -13,6 +13,13 @@ class Wizard */ public $breadcrum; + /** + * Undocumented variable + * + * @var [type] + */ + public $page; + /** * Setter for breadcrum From ffe8bba3f784ef392fdb6cd78be685e99e828ab4 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 15 Feb 2019 09:10:21 +0100 Subject: [PATCH 100/262] added exception in ldapsearch Former-commit-id: 4ab1637c30cac2bb4c827b1e08017f6b08fae1b9 --- pandora_console/include/auth/mysql.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 8003275fbf..aab0b4c9e4 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -1369,7 +1369,12 @@ function local_ldap_search($ldap_host, $ldap_port=389, $ldap_version=3, $dn, $ac $tls = ' -ZZ '; } - $ldap_host = ' -H '.$ldap_host.':'.$ldap_port; + if (stripos($ldap_host, 'ldap') !== false) { + $ldap_host = ' -H '.$ldap_host.':'.$ldap_port; + } else { + $ldap_host = ' -h '.$ldap_host.' -p '.$ldap_port; + } + $ldap_version = ' -P '.$ldap_version; if (!empty($ldap_admin_user)) { $ldap_admin_user = " -D '".$ldap_admin_user."'"; From f777c59a8374025b1c2d3950c4b0df9ad6500df7 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 10:00:23 +0100 Subject: [PATCH 101/262] WIP: H&D skel files css wiz&discov Former-commit-id: e57758a9e77b19868262557d9e11a0ff7b38f02c --- pandora_console/godmode/servers/discovery.php | 2 ++ pandora_console/include/styles/discovery.css | 3 +++ pandora_console/include/styles/wizard.css | 4 ++++ 3 files changed, 9 insertions(+) create mode 100644 pandora_console/include/styles/discovery.css diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 39c31b9465..25619fbc7a 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -13,6 +13,8 @@ if (! check_acl($config['id_user'], 0, 'AW')) { exit; } +ui_require_css_file('discovery'); + ui_print_page_header(__('Discover'), 'wizards/hostDevices.png', false, '', true); diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css new file mode 100644 index 0000000000..62be6c7c98 --- /dev/null +++ b/pandora_console/include/styles/discovery.css @@ -0,0 +1,3 @@ +/* + * Discovery css global + */ diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css index fdaf5afa4b..912f5d5a4f 100644 --- a/pandora_console/include/styles/wizard.css +++ b/pandora_console/include/styles/wizard.css @@ -1,3 +1,7 @@ +/* + * Discovery > Wizard css global style + */ + ul.wizard { } From efdc17b801579c1f69d095ea8e251f61f5c43522 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 13:08:44 +0100 Subject: [PATCH 102/262] WIP: H&D Former-commit-id: 605aa350c6d8d9bcebadbb941bba2a6fc399cb7c --- pandora_console/godmode/servers/discovery.php | 3 +- .../godmode/wizards/HostDevices.class.php | 417 +++++++++++++++--- pandora_console/include/functions.php | 20 + 3 files changed, 374 insertions(+), 66 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 25619fbc7a..70da2939e7 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -52,8 +52,9 @@ $classname_selected = get_wiz_class($wiz_in_use); // Else: class not found pseudo exception. if ($classname_selected !== null) { $wiz = new $classname_selected($page); - $wiz->run(); + $result = $wiz->run(); // TODO: Here we'll controlle if return is a valid recon task id. + hd($result); } if ($classname_selected === null) { diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 758f8e653b..7e2772d6e1 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -102,7 +102,7 @@ class HostDevices extends Wizard */ public function __construct( int $page=0, - string $msg='hola', + string $msg='Default message. Not set.', string $icon='hostDevices.png', string $label='Host & Devices' ) { @@ -203,19 +203,68 @@ class HostDevices extends Wizard public function parseNetScan() { if ($this->page == 0) { - // Error. Must not be here. + // Check if we're updating a task. + $task_id = get_parameter('task', null); + + if (isset($task_id) === true) { + // We're updating this task. + $task = db_get_row( + 'trecon_task', + 'id_rt', + $task_id + ); + + if ($task !== false) { + $this->task = $task; + } + } + return true; } // Validate response from page 0. No, not a bug, we're always 1 page // from 'validation' page. if ($this->page == 1) { + $task_id = get_parameter('task', null); $taskname = get_parameter('taskname', ''); $comment = get_parameter('comment', ''); $server_id = get_parameter('id_recon_server', ''); - $network = get_parameter('name', ''); + $network = get_parameter('network', ''); $id_group = get_parameter('id_group', ''); + if (isset($task_id) === true) { + // We're updating this task. + $task = db_get_row( + 'trecon_task', + 'id_rt', + $task_id + ); + + if ($task !== false) { + $this->task = $task; + } + } else if (isset($taskname) === true + && isset($network) === true + ) { + // Avoid double creation. + $task = db_get_row_filter( + 'trecon_task', + [ + 'name' => $taskname, + 'subnet' => $network, + ] + ); + + if ($task !== false) { + $this->task = $task; + } + } + + if (isset($this->task['id_rt']) === false) { + // Disabled 2 Implies wizard non finished. + $this->task['disabled'] = 2; + } + if ($taskname == '') { $this->msg = __('You must provide a task name.'); return false; @@ -242,12 +291,9 @@ class HostDevices extends Wizard $this->task['description'] = $comment; $this->task['subnet'] = $network; $this->task['id_recon_server'] = $server_id; - // Disabled 2 Implies wizard non finished. - $this->task['disabled'] = 2; + $this->task['id_group'] = $id_group; - $this->task['id_rt'] = 5; - - if (!isset($this->task['id_rt'])) { + if (isset($this->task['id_rt']) === false) { // Create. $this->task['id_rt'] = db_process_sql_insert( 'trecon_task', @@ -269,24 +315,121 @@ class HostDevices extends Wizard if ($this->page == 2) { $id_rt = get_parameter('task', -1); - $this->task = db_get_row( + $task = db_get_row( 'trecon_task', 'id_rt', $id_rt ); - hd($this->task); + if ($task !== false) { + $this->task = $task; + } else { + $this->msg = __('Failed to find network scan task.'); + return false; + } - return false; + $id_network_profile = get_parameter('id_network_profile', null); + $snmp_enabled = get_parameter_switch('snmp_enabled'); + $os_detect = get_parameter_switch('os_detect'); + $parent_detection = get_parameter_switch('parent_detection'); + $parent_recursion = get_parameter_switch('parent_recursion'); + $vlan_enabled = get_parameter_switch('vlan_enabled'); + $snmp_version = get_parameter('snmp_version', null); + $community = get_parameter('community', null); + $snmp_context = get_parameter('snmp_context', null); + $snmp_auth_user = get_parameter('snmp_auth_user', null); + $snmp_auth_pass = get_parameter('snmp_auth_pass', null); + $snmp_privacy_method = get_parameter('snmp_privacy_method', null); + $snmp_privacy_pass = get_parameter('snmp_privacy_pass', null); + $snmp_auth_method = get_parameter('snmp_auth_method', null); + $snmp_security_level = get_parameter('snmp_security_level', null); + $auth_strings = get_parameter('auth_strings', null); + + if ($snmp_version == 3) { + $this->task['snmp_community'] = $snmp_context; + } else { + $this->task['snmp_community'] = $community; + } + + $this->task['id_network_profile'] = $id_network_profile; + $this->task['snmp_enabled'] = $snmp_enabled; + $this->task['os_detect'] = $os_detect; + $this->task['parent_detection'] = $parent_detection; + $this->task['parent_recursion'] = $parent_recursion; + $this->task['vlan_enabled'] = $vlan_enabled; + $this->task['snmp_version'] = $snmp_version; + $this->task['snmp_auth_user'] = $snmp_auth_user; + $this->task['snmp_auth_pass'] = $snmp_auth_pass; + $this->task['snmp_privacy_method'] = $snmp_privacy_method; + $this->task['snmp_privacy_pass'] = $snmp_privacy_pass; + $this->task['snmp_auth_method'] = $snmp_auth_method; + $this->task['snmp_security_level'] = $snmp_security_level; + $this->task['auth_strings'] = $auth_strings; + + // Update. + $res = db_process_sql_update( + 'trecon_task', + $this->task, + ['id_rt' => $this->task['id_rt']] + ); + + return true; } if ($this->page == 3) { // Interval and schedules. // By default manual if not defined. - $interval = get_parameter('interval', 0); + $id_rt = get_parameter('task', -1); + $task = db_get_row( + 'trecon_task', + 'id_rt', + $id_rt + ); + + if ($task !== false) { + $this->task = $task; + } else { + $this->msg = __('Failed to find network scan task.'); + return false; + } + + $interval = get_parameter('interval', 0); $this->task['interval_sweep'] = $interval; - return false; + + if ($this->task['disabled'] == 2) { + // Wizard finished. + $this->task['disabled'] = 0; + } + + // Update. + $res = db_process_sql_update( + 'trecon_task', + $this->task, + ['id_rt' => $this->task['id_rt']] + ); + + return true; + } + + if ($this->page == 4) { + // Wizard ended. Load data and return control to Discovery. + $id_rt = get_parameter('task', -1); + + $task = db_get_row( + 'trecon_task', + 'id_rt', + $id_rt + ); + + if ($task !== false) { + $this->task = $task; + } else { + $this->msg = __('Failed to find network scan task.'); + return false; + } + + return true; } return false; @@ -326,14 +469,14 @@ class HostDevices extends Wizard $form = [ 'form' => [ 'method' => 'POST', - 'action' => '#', + 'action' => $this->url.'&mode=netscan&page='.($this->page - 1).'&task='.$this->task['id_rt'], ], 'inputs' => [ [ 'arguments' => [ 'type' => 'hidden', - 'name' => 'page', - 'value' => ($this->page - 1), + 'name' => 'task', + 'value' => $this->task['id_rt'], ], ], [ @@ -364,7 +507,7 @@ class HostDevices extends Wizard $form = [ 'form' => [ 'method' => 'POST', - 'action' => '#', + 'action' => $this->url.'&mode=netscan&page=0', ], 'inputs' => [ [ @@ -404,18 +547,29 @@ class HostDevices extends Wizard 'label' => ''.__('Task name').'', 'arguments' => [ 'name' => 'taskname', - 'value' => '', + 'value' => $this->task['name'], 'type' => 'text', 'size' => 25, ], ]; + if (isset($this->task['id_rt']) === true) { + // Propagate id. + $form['inputs'][] = [ + 'arguments' => [ + 'name' => 'task', + 'value' => $this->task['id_rt'], + 'type' => 'hidden', + ], + ]; + } + // Input task name. $form['inputs'][] = [ 'label' => ''.__('Comment').'', 'arguments' => [ 'name' => 'comment', - 'value' => '', + 'value' => $this->task['description'], 'type' => 'text', 'size' => 25, ], @@ -437,7 +591,7 @@ class HostDevices extends Wizard SERVER_TYPE_DISCOVERY ), 'name' => 'id_recon_server', - 'selected' => 0, + 'selected' => $this->task['id_recon_server'], 'return' => true, ], ]; @@ -450,8 +604,8 @@ class HostDevices extends Wizard true ), 'arguments' => [ - 'name' => 'name', - 'value' => '', + 'name' => 'network', + 'value' => $this->task['subnet'], 'type' => 'text', 'size' => 25, ], @@ -464,25 +618,22 @@ class HostDevices extends Wizard 'name' => 'id_group', 'privilege' => 'PM', 'type' => 'select_groups', + 'selected' => $this->task['id_group'], 'return' => true, ], ]; - // Hidden, page. - $form['inputs'][] = [ - 'arguments' => [ - 'name' => 'page', - 'value' => ($this->page + 1), - 'type' => 'hidden', - 'return' => true, - ], - ]; + $str = __('Next'); + + if (isset($this->task['id_rt']) === true) { + $str = __('Update and continue'); + } // Submit button. $form['inputs'][] = [ 'arguments' => [ 'name' => 'submit', - 'label' => __('Next'), + 'label' => $str, 'type' => 'submit', 'attributes' => 'class="sub next"', 'return' => true, @@ -491,7 +642,7 @@ class HostDevices extends Wizard $form['form'] = [ 'method' => 'POST', - 'action' => '#', + 'action' => $this->url.'&mode=netscan&page='.($this->page + 1), ]; // XXX: Could be improved validating inputs before continue (JS) @@ -549,27 +700,28 @@ class HostDevices extends Wizard 'name' => 'snmp_enabled', 'type' => 'switch', 'return' => true, - 'onclick' => "\$('#snmp_extra').toggle();", + 'value' => 1, + 'onclick' => 'extraSNMP();', ], ]; // SNMP CONFIGURATION. $form['inputs'][] = [ - 'hidden' => 1, + 'hidden' => 0, 'block_id' => 'snmp_extra', 'block_content' => [ [ 'label' => __('SNMP version'), 'arguments' => [ - 'name' => 'auth_strings', + 'name' => 'snmp_version', 'fields' => [ '1' => 'v. 1', '2c' => 'v. 2c', '3' => 'v. 3', ], 'type' => 'select', - 'script' => "\$('#snmp_options_v'+this.value).toggle()", + 'script' => 'SNMPExtraShow(this.value)', 'return' => true, ], ], @@ -579,28 +731,15 @@ class HostDevices extends Wizard // SNMP Options pack v1. $form['inputs'][] = [ 'hidden' => 1, - 'block_id' => 'snmp_options_v1', + 'block_id' => 'snmp_options_basic', 'block_content' => [ [ - 'label' => __('Community'), - 'arguments' => [ - 'name' => 'community', - 'type' => 'text', - 'size' => 25, - 'return' => true, - - ], - ], - ], - ]; - - // SNMP Options pack v2c. - $form['inputs'][] = [ - 'hidden' => 1, - 'block_id' => 'snmp_options_v2c', - 'block_content' => [ - [ - 'label' => __('Community'), + 'label' => ''.__('SNMP Default community').''.ui_print_help_tip( + __( + 'You can specify several values, separated by commas, for example: public,mysecret,1234' + ), + true + ), 'arguments' => [ 'name' => 'community', 'type' => 'text', @@ -618,15 +757,99 @@ class HostDevices extends Wizard 'block_id' => 'snmp_options_v3', 'block_content' => [ [ - 'label' => __(''), + 'label' => ''.__('Context').'', 'arguments' => [ - 'name' => 'community', + 'name' => 'snmp_context', 'type' => 'text', - 'size' => 25, + 'size' => 15, 'return' => true, ], ], + [ + 'label' => ''.__('Auth user').'', + 'arguments' => [ + 'name' => 'snmp_auth_user', + 'type' => 'text', + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Auth password').''.ui_print_help_tip( + __( + 'The pass length must be eight character minimum.' + ), + true + ), + 'arguments' => [ + 'name' => 'snmp_auth_pass', + 'type' => 'password', + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Privacy method').'', + 'arguments' => [ + 'name' => 'snmp_privacy_method', + 'type' => 'select', + 'fields' => [ + 'DES' => __('DES'), + 'AES' => __('AES'), + ], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Privacy pass').''.ui_print_help_tip( + __( + 'The pass length must be eight character minimum.' + ), + true + ), + 'arguments' => [ + 'name' => 'snmp_privacy_pass', + 'type' => 'password', + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Auth method').'', + 'arguments' => [ + 'name' => 'snmp_auth_method', + 'type' => 'select', + 'fields' => [ + 'MD5' => __('MD5'), + 'SHA' => __('SHA'), + ], + 'size' => 15, + 'return' => true, + + ], + ], + [ + 'label' => ''.__('Security level').'', + 'arguments' => [ + 'name' => 'snmp_security_level', + 'type' => 'select', + 'fields' => [ + 'noAuthNoPriv' => __('Not auth and not privacy method'), + 'authNoPriv' => __('Auth and not privacy method'), + 'authPriv' => __('Auth and privacy method'), + ], + 'size' => 15, + 'return' => true, + + ], + ], + ], ]; @@ -662,6 +885,7 @@ class HostDevices extends Wizard 'name' => 'os_detect', 'type' => 'switch', 'return' => true, + 'value' => 1, ], ]; @@ -683,6 +907,18 @@ class HostDevices extends Wizard 'name' => 'parent_detection', 'type' => 'switch', 'return' => true, + 'value' => 1, + ], + ]; + + // Input: Parent recursion. + $form['inputs'][] = [ + 'label' => __('Parent recursion'), + 'arguments' => [ + 'name' => 'parent_recursion', + 'type' => 'switch', + 'return' => true, + 'value' => 1, ], ]; @@ -690,9 +926,10 @@ class HostDevices extends Wizard $form['inputs'][] = [ 'label' => __('VLAN enabled'), 'arguments' => [ - 'name' => 'os_detect', + 'name' => 'vlan_enabled', 'type' => 'switch', 'return' => true, + 'value' => 1, ], ]; @@ -707,9 +944,49 @@ class HostDevices extends Wizard ], ]; + $form['js'] = ' +function SNMPExtraShow(target) { + $("#snmp_options_basic").hide(); + $("#snmp_options_v3").hide(); + if (target == 3) { + $("#snmp_options_v3").show(); + } else { + $("#snmp_options_basic").show(); + } + +} + +function extraSNMP() { + if (document.getElementsByName("snmp_enabled")[0].checked) { + SNMPExtraShow($("#snmp_version").val()); + $("#snmp_extra").show(); + } else { + // Hide unusable sections + $("#snmp_extra").hide(); + $("#snmp_options_basic").hide(); + $("#snmp_options_v3").hide(); + + // Disable snmp dependant checks + if (document.getElementsByName("parent_recursion")[0].checked) + $("input[name=parent_recursion]").click(); + + if (document.getElementsByName("parent_detection")[0].checked) + $("input[name=parent_detection]").click(); + + if (document.getElementsByName("vlan_enabled")[0].checked) + $("input[name=vlan_enabled]").click(); + + } +} + +$(function() { + SNMPExtraShow($("#snmp_version").val()) +}); + '; + $form['form'] = [ 'method' => 'POST', - 'action' => '#', + 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'], ]; $this->printForm($form); @@ -786,7 +1063,7 @@ class HostDevices extends Wizard $form['form'] = [ 'method' => 'POST', - 'action' => '#', + 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'], ]; $form['js'] = ' @@ -807,10 +1084,20 @@ $("select#interval_manual_defined").change(function() { $this->printForm($form); } - if ($this->page == 100) { + if ($this->page == 3) { + if ($this->task['id_rt']) { + // 0 - Is OK. + $this->result = 0; + $this->msg = __('Task configured.'); + } else { + // 1 - Is NOT OK. + $this->result = 1; + $this->msg = __('Wizard failed. Cannot configure task.'); + } + return [ 'result' => $this->result, - 'id' => $this->id, + 'id' => $this->task['id_rt'], 'msg' => $this->msg, ]; } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 6f13388fc0..58120c4616 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -852,6 +852,26 @@ 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, 0); + + if ($data == 'on') { + return 1; + } + + return 0; +} + + function get_cookie($name, $default='') { if (isset($_COOKIE[$name])) { From c9c855da9ace314aecfa1abbc79a6613467a6fd2 Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 15 Feb 2019 13:47:11 +0100 Subject: [PATCH 103/262] Added new Cloud Wizard class Former-commit-id: 789af2b6cba344bac44b34c4c90228801f2468a0 --- pandora_console/godmode/servers/discovery.php | 3 + .../godmode/wizards/Cloud.class.php | 267 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100755 pandora_console/godmode/wizards/Cloud.class.php diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 25619fbc7a..974dadc82b 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -30,6 +30,9 @@ function get_wiz_class($str) case 'hd': return 'HostDevices'; + case 'cloud': + return 'Cloud'; + default: // Ignore. return null; diff --git a/pandora_console/godmode/wizards/Cloud.class.php b/pandora_console/godmode/wizards/Cloud.class.php new file mode 100755 index 0000000000..1de88c2ca7 --- /dev/null +++ b/pandora_console/godmode/wizards/Cloud.class.php @@ -0,0 +1,267 @@ +setBreadcrum([]); + + $this->task = []; + $this->msg = $msg; + $this->icon = $icon; + $this->label = $label; + $this->page = $page; + $this->url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=cloud' + ); + + return $this; + } + + + /** + * Run AmazonWS class. Entry point. + * + * @return void + */ + public function run() + { + global $config; + + // Load styles. + parent::run(); + + $mode = get_parameter('mode', null); + + if ($mode === null) { + $this->setBreadcrum(['Cloud']); + $this->printHeader(); + + echo 'Amazon WS'; + + return; + } + + if ($mode == 'amazonws') { + $this->setBreadcrum( + [ + 'Cloud', + 'Amazon AWS', + ] + ); + $this->printHeader(); + return $this->runAmazonAWS(); + } + + return null; + } + + + /** + * Checks if environment is ready, + * returns array + * icon: icon to be displayed + * label: label to be displayed + * + * @return array With data. + **/ + public function load() + { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + ]; + } + + + // ///////////////////////////////////////////////////////////////////////// + // Extra methods. + // ///////////////////////////////////////////////////////////////////////// + + + /** + * Amazon AWS pages manager. + * + * @return void + */ + public function runAmazonAWS() + { + global $config; + + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access Agent Management' + ); + include 'general/noaccess.php'; + return; + } + + // -------------------------------. + // Page 0. wizard starts HERE. + // -------------------------------. + if (!isset($this->page) || $this->page == 0) { + if (isset($this->page) === false + || $this->page == 0 + ) { + $this->printForm( + [ + 'form' => [ + 'action' => '#', + 'method' => 'POST', + ], + 'inputs' => [ + [ + 'label' => __('AWS access key ID'), + 'arguments' => [ + 'name' => 'aws_id', + 'value' => '', + 'type' => 'text', + ], + ], + [ + 'label' => __('AWS secret access key'), + 'arguments' => [ + 'name' => 'aws_id', + 'value' => '', + 'type' => 'text', + ], + ], + [ + 'arguments' => [ + 'name' => 'page', + 'value' => ($this->page + 1), + 'type' => 'hidden', + 'return' => true, + ], + ], + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Validate'), + 'type' => 'submit', + 'attributes' => 'class="sub wand"', + 'return' => true, + ], + ], + ], + ] + ); + } + } + + if ($this->page == 1) { + echo 'TODO'; + // TODOS. + } + + if ($this->page == 100) { + return [ + 'result' => $this->result, + 'id' => $this->id, + 'msg' => $this->msg, + ]; + } + } + + +} From ec672d6bfbb7a0c133d372e772d4fd5ed4df34c1 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 13:57:33 +0100 Subject: [PATCH 104/262] H&D network scan Former-commit-id: dcd22994d6addf69ab5d68a6724d12e26e994d15 --- pandora_console/godmode/servers/discovery.php | 14 +- .../godmode/wizards/HostDevices.class.php | 135 ++++++++++++------ 2 files changed, 100 insertions(+), 49 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 70da2939e7..2afbbb0f24 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -53,8 +53,18 @@ $classname_selected = get_wiz_class($wiz_in_use); if ($classname_selected !== null) { $wiz = new $classname_selected($page); $result = $wiz->run(); - // TODO: Here we'll controlle if return is a valid recon task id. - hd($result); + if (is_array($result) === true) { + if ($result['result'] === 0) { + // Success. + ui_print_success_message($result['msg']); + // TODO: Show task progress before redirect to main discovery menu. + } else { + // Failed. + ui_print_error_message($result['msg']); + } + + $classname_selected = null; + } } if ($classname_selected === null) { diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 7e2772d6e1..f31d16618b 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -160,13 +160,17 @@ class HostDevices extends Wizard } if ($mode == 'netscan') { - $this->setBreadcrum( - [ - 'Host&devices', - 'Net scan', - ] - ); - $this->printHeader(); + if ($this->page != 3) { + // Do not paint breadcrum in last page. Redirected. + $this->setBreadcrum( + [ + 'Host&devices', + 'Net scan', + ] + ); + $this->printHeader(); + } + return $this->runNetScan(); } @@ -258,6 +262,9 @@ class HostDevices extends Wizard if ($task !== false) { $this->task = $task; } + + $this->msg = __('This network scan task has been already defined. Please edit it or create a new one.'); + return false; } if (isset($this->task['id_rt']) === false) { @@ -334,6 +341,8 @@ class HostDevices extends Wizard $parent_detection = get_parameter_switch('parent_detection'); $parent_recursion = get_parameter_switch('parent_recursion'); $vlan_enabled = get_parameter_switch('vlan_enabled'); + $wmi_enabled = get_parameter_switch('wmi_enabled'); + $resolve_names = get_parameter_switch('resolve_names'); $snmp_version = get_parameter('snmp_version', null); $community = get_parameter('community', null); $snmp_context = get_parameter('snmp_context', null); @@ -357,6 +366,8 @@ class HostDevices extends Wizard $this->task['parent_detection'] = $parent_detection; $this->task['parent_recursion'] = $parent_recursion; $this->task['vlan_enabled'] = $vlan_enabled; + $this->task['wmi_enabled'] = $wmi_enabled; + $this->task['resolve_names'] = $resolve_names; $this->task['snmp_version'] = $snmp_version; $this->task['snmp_auth_user'] = $snmp_auth_user; $this->task['snmp_auth_pass'] = $snmp_auth_pass; @@ -640,9 +651,14 @@ class HostDevices extends Wizard ], ]; + $task_url = ''; + if (isset($this->task['id_rt'])) { + $task_url = '&task='.$this->task['id_rt']; + } + $form['form'] = [ 'method' => 'POST', - 'action' => $this->url.'&mode=netscan&page='.($this->page + 1), + 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url, ]; // XXX: Could be improved validating inputs before continue (JS) @@ -682,12 +698,13 @@ class HostDevices extends Wizard $form['inputs'][] = [ 'label' => __('Module template'), 'arguments' => [ - 'name' => 'id_network_profile', - 'type' => 'select_from_sql', - 'sql' => 'SELECT id_np, name + 'name' => 'id_network_profile', + 'type' => 'select_from_sql', + 'sql' => 'SELECT id_np, name FROM tnetwork_profile ORDER BY name', - 'return' => true, + 'return' => true, + 'selected' => $this->task['id_network_profile'], ], ]; @@ -700,7 +717,7 @@ class HostDevices extends Wizard 'name' => 'snmp_enabled', 'type' => 'switch', 'return' => true, - 'value' => 1, + 'value' => (isset($this->task['snmp_enabled'])) ? $this->task['snmp_enabled'] : 1, 'onclick' => 'extraSNMP();', ], @@ -714,15 +731,16 @@ class HostDevices extends Wizard [ 'label' => __('SNMP version'), 'arguments' => [ - 'name' => 'snmp_version', - 'fields' => [ + 'name' => 'snmp_version', + 'fields' => [ '1' => 'v. 1', '2c' => 'v. 2c', '3' => 'v. 3', ], - 'type' => 'select', - 'script' => 'SNMPExtraShow(this.value)', - 'return' => true, + 'type' => 'select', + 'script' => 'SNMPExtraShow(this.value)', + 'selected' => $this->task['snmp_version'], + 'return' => true, ], ], ], @@ -743,6 +761,7 @@ class HostDevices extends Wizard 'arguments' => [ 'name' => 'community', 'type' => 'text', + 'value' => $this->task['snmp_community'], 'size' => 25, 'return' => true, @@ -761,6 +780,7 @@ class HostDevices extends Wizard 'arguments' => [ 'name' => 'snmp_context', 'type' => 'text', + 'value' => $this->task['snmp_community'], 'size' => 15, 'return' => true, @@ -771,6 +791,7 @@ class HostDevices extends Wizard 'arguments' => [ 'name' => 'snmp_auth_user', 'type' => 'text', + 'value' => $this->task['snmp_auth_user'], 'size' => 15, 'return' => true, @@ -786,6 +807,7 @@ class HostDevices extends Wizard 'arguments' => [ 'name' => 'snmp_auth_pass', 'type' => 'password', + 'value' => $this->task['snmp_auth_pass'], 'size' => 15, 'return' => true, @@ -794,14 +816,15 @@ class HostDevices extends Wizard [ 'label' => ''.__('Privacy method').'', 'arguments' => [ - 'name' => 'snmp_privacy_method', - 'type' => 'select', - 'fields' => [ + 'name' => 'snmp_privacy_method', + 'type' => 'select', + 'fields' => [ 'DES' => __('DES'), 'AES' => __('AES'), ], - 'size' => 15, - 'return' => true, + 'selected' => $this->task['snmp_privacy_method'], + 'size' => 15, + 'return' => true, ], ], @@ -815,6 +838,7 @@ class HostDevices extends Wizard 'arguments' => [ 'name' => 'snmp_privacy_pass', 'type' => 'password', + 'value' => $this->task['snmp_privacy_pass'], 'size' => 15, 'return' => true, @@ -823,29 +847,31 @@ class HostDevices extends Wizard [ 'label' => ''.__('Auth method').'', 'arguments' => [ - 'name' => 'snmp_auth_method', - 'type' => 'select', - 'fields' => [ + 'name' => 'snmp_auth_method', + 'type' => 'select', + 'fields' => [ 'MD5' => __('MD5'), 'SHA' => __('SHA'), ], - 'size' => 15, - 'return' => true, + 'selected' => $this->task['snmp_auth_method'], + 'size' => 15, + 'return' => true, ], ], [ 'label' => ''.__('Security level').'', 'arguments' => [ - 'name' => 'snmp_security_level', - 'type' => 'select', - 'fields' => [ + 'name' => 'snmp_security_level', + 'type' => 'select', + 'fields' => [ 'noAuthNoPriv' => __('Not auth and not privacy method'), 'authNoPriv' => __('Auth and not privacy method'), 'authPriv' => __('Auth and privacy method'), ], - 'size' => 15, - 'return' => true, + 'selected' => $this->task['snmp_security_level'], + 'size' => 15, + 'return' => true, ], ], @@ -859,22 +885,27 @@ class HostDevices extends Wizard 'arguments' => [ 'name' => 'wmi_enabled', 'type' => 'switch', + 'value' => (isset($this->task['wmi_enabled'])) ? $this->task['wmi_enabled'] : 0, 'return' => true, - 'onclick' => "\$('#wmi_extra').toggle();", + 'onclick' => 'toggleWMI();', ], ]; // WMI CONFIGURATION. $form['inputs'][] = [ - 'label' => __('WMI Auth. strings'), - 'hidden' => 1, - 'id' => 'wmi_extra', - 'arguments' => [ - 'name' => 'auth_strings', - 'type' => 'text', - 'return' => true, - + 'block_id' => 'wmi_extra', + 'hidden' => 1, + 'block_content' => [ + [ + 'label' => __('WMI Auth. strings'), + 'arguments' => [ + 'name' => 'auth_strings', + 'type' => 'text', + 'value' => $this->task['auth_strings'], + 'return' => true, + ], + ], ], ]; @@ -885,7 +916,7 @@ class HostDevices extends Wizard 'name' => 'os_detect', 'type' => 'switch', 'return' => true, - 'value' => 1, + 'value' => (isset($this->task['os_detect'])) ? $this->task['os_detect'] : 1, ], ]; @@ -897,6 +928,7 @@ class HostDevices extends Wizard 'name' => 'resolve_names', 'type' => 'switch', 'return' => true, + 'value' => (isset($this->task['resolve_names'])) ? $this->task['resolve_names'] : 0, ], ]; @@ -907,7 +939,7 @@ class HostDevices extends Wizard 'name' => 'parent_detection', 'type' => 'switch', 'return' => true, - 'value' => 1, + 'value' => (isset($this->task['parent_detection'])) ? $this->task['parent_detection'] : 1, ], ]; @@ -918,7 +950,7 @@ class HostDevices extends Wizard 'name' => 'parent_recursion', 'type' => 'switch', 'return' => true, - 'value' => 1, + 'value' => (isset($this->task['parent_recursion'])) ? $this->task['parent_recursion'] : 1, ], ]; @@ -929,7 +961,7 @@ class HostDevices extends Wizard 'name' => 'vlan_enabled', 'type' => 'switch', 'return' => true, - 'value' => 1, + 'value' => (isset($this->task['vlan_enabled'])) ? $this->task['vlan_enabled'] : 1, ], ]; @@ -979,8 +1011,16 @@ function extraSNMP() { } } +function toggleWMI() { + if (document.getElementsByName("wmi_enabled")[0].checked) + $("#wmi_extra").show(); + else + $("#wmi_extra").hide(); +} + $(function() { - SNMPExtraShow($("#snmp_version").val()) + SNMPExtraShow($("#snmp_version").val()); + toggleWMI(); }); '; @@ -1082,6 +1122,7 @@ $("select#interval_manual_defined").change(function() { }).change();'; $this->printForm($form); + return null; } if ($this->page == 3) { From 32d34cd09b9ff6fbfed2e6d9a77d3aaf7232a3b0 Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 15 Feb 2019 14:02:32 +0100 Subject: [PATCH 105/262] Changed styles in host and devices Former-commit-id: 743f203466e8e3745a33837054e5bc4faa69337c --- pandora_console/godmode/servers/discovery.php | 9 +++--- .../godmode/wizards/HostDevices.class.php | 21 +++++++++++-- pandora_console/images/wizard/csv_image.svg | 4 +++ pandora_console/include/styles/discovery.css | 30 +++++++++++++++++++ 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 pandora_console/images/wizard/csv_image.svg diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 70da2939e7..39cc86675c 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -15,7 +15,7 @@ if (! check_acl($config['id_user'], 0, 'AW')) { ui_require_css_file('discovery'); -ui_print_page_header(__('Discover'), 'wizards/hostDevices.png', false, '', true); +ui_print_page_header(__('Discover'), '', false, '', true); /** @@ -64,13 +64,12 @@ if ($classname_selected === null) { $classname = basename($classpath, '.class.php'); $obj = new $classname(); $wiz_data = $obj->load(); - - hd($wiz_data); ?> +
    • - <?php echo $classname; ?> -
      + <?php echo $classname; ?> +
    • diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 7e2772d6e1..157657d237 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -138,9 +138,24 @@ class HostDevices extends Wizard if ($mode === null) { $this->setBreadcrum(['Host&devices']); $this->printHeader(); - - echo 'Importar csv'; - echo 'Escanear red'; + echo '
      '; + echo '
      '; + echo '
      '; + echo 'importcsv'; + echo '
      '; + echo '
      '; + echo ''.__('Import CSV').''; + echo '
      '; + echo '
      '; + echo '
      '; + echo '
      '; + echo 'importcsv'; + echo '
      '; + echo '
      '; + echo ''.__('Escanear red').''; + echo '
      '; + echo '
      '; + echo '
      '; return; } diff --git a/pandora_console/images/wizard/csv_image.svg b/pandora_console/images/wizard/csv_image.svg new file mode 100644 index 0000000000..1e82511472 --- /dev/null +++ b/pandora_console/images/wizard/csv_image.svg @@ -0,0 +1,4 @@ + + + + diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 62be6c7c98..5f2cc45b68 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -1,3 +1,33 @@ /* * Discovery css global */ + +#contenedor_principal { + height: auto; + position: relative; + margin: auto; +} +#contenedor_imagen_texto { + width: 11%; + height: auto; + position: relative; + display: inline-block; + vertical-align: top; + overflow: hidden; + margin-right: 5%; +} +#imagen { + width: 15%; + height: auto; + position: relative; + display: inline; +} +.texto { + height: auto; + text-align: center; +} +#text_wizard { + font-weight: bolder; + text-decoration: none; + font-size: 24px; +} From e397353f71b2cb60bab75a65ad788cb5d91f814f Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 14:03:16 +0100 Subject: [PATCH 106/262] minor fix get_parameter_switch Former-commit-id: c8e430e1cbd789a99058217e7dffb4098aab821a --- pandora_console/include/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 58120c4616..e1861e70a3 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -862,9 +862,11 @@ function get_parameter_checkbox($name, $default='') */ function get_parameter_switch($name, $default='') { - $data = get_parameter($name, 0); + $data = get_parameter($name, null); - if ($data == 'on') { + if ($data === null) { + return 0; + } else if ($data == 'on') { return 1; } From c62c01c4a0cc26759b1dcc68dbc69720b96a8ea0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 14:14:56 +0100 Subject: [PATCH 107/262] H&D minor fix - visual Former-commit-id: 57d1e3c62192d9568bfa4db11658e31a8d811a3a --- .../godmode/wizards/HostDevices.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index c7eddc84f4..adbc13180e 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -740,7 +740,7 @@ class HostDevices extends Wizard // SNMP CONFIGURATION. $form['inputs'][] = [ - 'hidden' => 0, + 'hidden' => 1, 'block_id' => 'snmp_extra', 'block_content' => [ [ @@ -995,10 +995,12 @@ class HostDevices extends Wizard function SNMPExtraShow(target) { $("#snmp_options_basic").hide(); $("#snmp_options_v3").hide(); - if (target == 3) { - $("#snmp_options_v3").show(); - } else { - $("#snmp_options_basic").show(); + if (document.getElementsByName("snmp_enabled")[0].checked) { + if (target == 3) { + $("#snmp_options_v3").show(); + } else { + $("#snmp_options_basic").show(); + } } } From 45fd528e3880bea244a350425fbb4003013e0c7f Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 16:02:55 +0100 Subject: [PATCH 108/262] minor fixes H&D Former-commit-id: c3236b91b4b6a0f37af2d4da4955c711dd4ace43 --- pandora_console/godmode/wizards/HostDevices.class.php | 5 ++--- pandora_server/lib/PandoraFMS/Recon/Base.pm | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index adbc13180e..12fcaaa39e 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -276,10 +276,9 @@ class HostDevices extends Wizard if ($task !== false) { $this->task = $task; + $this->msg = __('This network scan task has been already defined. Please edit it or create a new one.'); + return false; } - - $this->msg = __('This network scan task has been already defined. Please edit it or create a new one.'); - return false; } if (isset($this->task['id_rt']) === false) { diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index 8d24ebf311..116bcd75e6 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -1500,6 +1500,9 @@ sub snmp_get_command { my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe "; if ($self->{'snmp_version'} eq "3") { + if ($self->{'community'}) { # Context + $command .= " -N $self->{'community} "; + } $command .= " -l$self->{'snmp_security_level'} "; if ($self->{'snmp_security_level'} ne "noAuthNoPriv") { $command .= " -u$self->{'snmp_auth_user'} -a$self->{'snmp_auth_method'} -A$self->{'snmp_auth_pass'} "; From 7a1b66755deea0a35d5f3ba83fb455726b54db93 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 16:06:28 +0100 Subject: [PATCH 109/262] minor fixes H&D Former-commit-id: a4ffc2e761dc0a4d06209fb1c448bc17d5d45022 --- pandora_server/lib/PandoraFMS/Recon/Base.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index 116bcd75e6..e819b06476 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -1501,7 +1501,7 @@ sub snmp_get_command { my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe "; if ($self->{'snmp_version'} eq "3") { if ($self->{'community'}) { # Context - $command .= " -N $self->{'community} "; + $command .= " -N $self->{'community'} "; } $command .= " -l$self->{'snmp_security_level'} "; if ($self->{'snmp_security_level'} ne "noAuthNoPriv") { From 0f375d6a766e5118f999c9337b8368c4d1abedd5 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 16:37:48 +0100 Subject: [PATCH 110/262] H&D minor fix group cannot be All Former-commit-id: 2feb42ce06bd379bbb3804a30fab744a4b01b1e1 --- .../godmode/wizards/HostDevices.class.php | 54 +++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 12fcaaa39e..f619d2d706 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -420,7 +420,12 @@ class HostDevices extends Wizard } $interval = get_parameter('interval', 0); + $id_os = get_parameter('id_os', 0); + $recon_ports = get_parameter('recon_ports', ''); + + $this->task['id_os'] = $id_os; $this->task['interval_sweep'] = $interval; + $this->task['recon_ports'] = $recon_ports; if ($this->task['disabled'] == 2) { // Wizard finished. @@ -640,11 +645,12 @@ class HostDevices extends Wizard $form['inputs'][] = [ 'label' => ''.__('Group').'', 'arguments' => [ - 'name' => 'id_group', - 'privilege' => 'PM', - 'type' => 'select_groups', - 'selected' => $this->task['id_group'], - 'return' => true, + 'name' => 'id_group', + 'returnAllGroup' => false, + 'privilege' => 'PM', + 'type' => 'select_groups', + 'selected' => $this->task['id_group'], + 'return' => true, ], ]; @@ -724,7 +730,7 @@ class HostDevices extends Wizard ]; // Feature configuration. - // Input: Module template. + // Input: SNMP enabled. $form['inputs'][] = [ 'label' => __('SNMP enabled'), 'arguments' => [ @@ -923,7 +929,7 @@ class HostDevices extends Wizard ], ]; - // Input: Module template. + // Input: Enforce os detection. $form['inputs'][] = [ 'label' => __('OS detection'), 'arguments' => [ @@ -1051,10 +1057,40 @@ $(function() { if ($this->page == 2) { // Interval and schedules. $interv_manual = 0; - if ((int) $interval == 0) { + if ((int) $this->task['interval_sweep'] == 0) { $interv_manual = 1; } + // Filter: OS. + $form['inputs'][] = [ + 'label' => ''.__('Filter by OS').'', + 'arguments' => [ + 'type' => 'select_from_sql', + 'sql' => 'SELECT id_os, name + FROM tconfig_os + ORDER BY name', + 'name' => 'id_os', + 'return' => 'true', + 'nothing' => __('Any'), + 'selected' => $this->task['id_os'], + ], + ]; + + // Filter: Ports. + $form['inputs'][] = [ + 'label' => ''.__('Filter by ports').''.ui_print_help_tip( + __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), + true + ), + 'arguments' => [ + 'type' => 'text', + 'name' => 'recon_ports', + 'return' => 'true', + 'recon_ports' => $this->task['recon_ports'], + ], + ]; + + // Schedule. $form['inputs'][] = [ 'label' => ''.__('Interval').''.ui_print_help_tip( __('Manual interval means that it will be executed only On-demand'), @@ -1072,7 +1108,7 @@ $(function() { ], 'extra' => ''.html_print_extended_select_for_time( 'interval', - $interval, + $this->task['interval_sweep'], '', '', '0', From 5093094d7d20bc4e1e1b6fc5f3b9e75ce98ed32b Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 18:05:59 +0100 Subject: [PATCH 111/262] H&D tasklist and some visual changes Former-commit-id: d9130ec520b0c23a9cf42ce62aae6c3d2432649b --- pandora_console/godmode/servers/discovery.php | 15 +- .../wizards/DiscoveryTaskList.class.php | 297 ++++++++++++++++++ .../godmode/wizards/HostDevices.class.php | 59 +--- .../godmode/wizards/Wizard.main.php | 70 ++++- pandora_console/images/wizard/hostdevices.svg | 4 + pandora_console/images/wizard/tasklist.svg | 4 + pandora_console/include/styles/discovery.css | 37 +++ 7 files changed, 430 insertions(+), 56 deletions(-) create mode 100644 pandora_console/godmode/wizards/DiscoveryTaskList.class.php create mode 100644 pandora_console/images/wizard/hostdevices.svg create mode 100644 pandora_console/images/wizard/tasklist.svg diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 456bf05c01..024eb39e30 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -30,6 +30,9 @@ function get_wiz_class($str) case 'hd': return 'HostDevices'; + case 'tasklist': + return 'DiscoveryTaskList'; + default: // Ignore. return null; @@ -37,6 +40,10 @@ function get_wiz_class($str) } +/* + * CLASS LOADER. + */ + // Dynamic class loader. $classes = glob($config['homedir'].'/godmode/wizards/*.class.php'); foreach ($classes as $classpath) { @@ -76,10 +83,12 @@ if ($classname_selected === null) { $wiz_data = $obj->load(); ?> -
    • +
    • - <?php echo $classname; ?> -
      +
      + +
      +
    • diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php new file mode 100644 index 0000000000..0ad4af9683 --- /dev/null +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -0,0 +1,297 @@ +setBreadcrum([]); + + $this->task = []; + $this->msg = $msg; + $this->icon = $icon; + $this->label = __($label); + $this->page = $page; + $this->url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist' + ); + + return $this; + } + + + /** + * Implements run method. + * + * @return mixed Returns null if wizard is ongoing. Result if done. + */ + public function run() + { + // Load styles. + parent::run(); + return $this->showList(); + } + + + /** + * Implements load method. + * + * @return mixed Skeleton for button. + */ + public function load() + { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + + ]; + + } + + + /** + * Show complete list of running tasks. + * + * @return boolean Success or not. + */ + public function showList() + { + global $config; + + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + // Get all recon servers + $servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3'); + if ($servers === false) { + $servers = []; + ui_print_error_message(__('Discovery Server is disabled')); + return; + } else { + $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); + if ($recon_task === false) { + ui_print_page_header(__('Recon View'), 'images/op_recon.png', false, '', false); + include_once $config['homedir'].'/general/firts_task/recon_view.php'; + return; + } else { + include_once $config['homedir'].'/include/functions_graph.php'; + include_once $config['homedir'].'/include/functions_servers.php'; + include_once $config['homedir'].'/include/functions_network_profiles.php'; + + $modules_server = 0; + $total_modules = 0; + $total_modules_data = 0; + + // -------------------------------- + // FORCE A RECON TASK + // -------------------------------- + if (check_acl($config['id_user'], 0, 'PM')) { + if (isset($_GET['force'])) { + $id = (int) get_parameter_get('force', 0); + servers_force_recon_task($id); + } + } + + foreach ($servers as $serverItem) { + $id_server = $serverItem['id_server']; + $server_name = servers_get_name($id_server); + $recon_tasks = db_get_all_rows_field_filter('trecon_task', 'id_recon_server', $id_server); + + // Show network tasks for Recon Server + if ($recon_tasks === false) { + $recon_tasks = []; + } + + $table = new StdClass(); + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->width = '100%'; + $table->class = 'databox data'; + $table->head = []; + $table->data = []; + $table->align = []; + $table->headstyle = []; + for ($i = 0; $i < 9; $i++) { + $table->headstyle[$i] = 'text-align: left;'; + } + + $table->head[0] = __('Force'); + $table->align[0] = 'left'; + + $table->head[1] = __('Task name'); + $table->align[1] = 'left'; + + $table->head[2] = __('Interval'); + $table->align[2] = 'left'; + + $table->head[3] = __('Network'); + $table->align[3] = 'left'; + + $table->head[4] = __('Status'); + $table->align[4] = 'left'; + + $table->head[5] = __('Template'); + $table->align[5] = 'left'; + + $table->head[6] = __('Progress'); + $table->align[6] = 'left'; + + $table->head[7] = __('Updated at'); + $table->align[7] = 'left'; + + $table->head[8] = __('Edit'); + $table->align[8] = 'left'; + + foreach ($recon_tasks as $task) { + $data = []; + + if ($task['disabled'] == 0) { + $data[0] = ''; + $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]); + $data[0] .= ''; + } else { + $data[0] = ''; + } + + $data[1] = ''.$task['name'].''; + + $data[2] = human_time_description_raw($task['interval_sweep']); + + if ($task['id_recon_script'] == 0) { + $data[3] = $task['subnet']; + } else { + $data[3] = '-'; + } + + if ($task['status'] <= 0) { + $data[4] = __('Done'); + } else { + $data[4] = __('Pending'); + } + + if ($task['id_recon_script'] == 0) { + // Network recon task + $data[5] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'  '; + $data[5] .= network_profiles_get_name($task['id_network_profile']); + } else { + // APP recon task + $data[5] = html_print_image('images/plugin.png', true).'  '; + $data[5] .= db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $task['id_recon_script'])); + } + + if ($task['status'] <= 0 || $task['status'] > 100) { + $data[6] = '-'; + } else { + $data[6] = progress_bar($task['status'], 100, 20, __('Progress').':'.$task['status'].'%', 1); + } + + $data[7] = ui_print_timestamp($task['utimestamp'], true); + + if (check_acl($config['id_user'], $task['id_group'], 'PM')) { + $data[8] = ''.html_print_image( + 'images/wrench_orange.png', + true + ).''; + } else { + $data[8] = ''; + } + + array_push($table->data, $data); + } + + if (empty($table->data)) { + echo '
      '.__('Server').' '.$server_name.' '.__('has no recon tasks assigned').'
      '; + } else { + html_print_table($table); + } + + unset($table); + } + } + } + + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery' + ), + ], + 'inputs' => [ + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + $this->printForm($form); + + return true; + } + + +} diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index f619d2d706..633fbfe19f 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -31,56 +31,12 @@ require_once $config['homedir'].'/include/functions_users.php'; enterprise_include('include/class/CSVImportAgents.class.php'); /** - * Undocumented class + * Wizard section Host&devices. + * Provides classic recon task creation. + * In enterprise environments, provides also CSV agent import features. */ class HostDevices extends Wizard { - // CSV constants. - const HDW_CSV_NOT_DATA = 0; - const HDW_CSV_DUPLICATED = 0; - const HDW_CSV_GROUP_EXISTS = 0; - - /** - * Undocumented variable - * - * @var array - */ - public $values = []; - - /** - * Undocumented variable - * - * @var [type] - */ - public $result; - - /** - * Undocumented variable - * - * @var [type] - */ - public $msg; - - /** - * Undocumented variable - * - * @var [type] - */ - public $icon; - - /** - * Undocumented variable - * - * @var [type] - */ - public $label; - - /** - * Undocumented variable - * - * @var [type] - */ - public $url; /** * Stores all needed parameters to create a recon task. @@ -91,7 +47,7 @@ class HostDevices extends Wizard /** - * Undocumented function. + * Constructor. * * @param integer $page Start page, by default 0. * @param string $msg Mensajito. @@ -103,7 +59,7 @@ class HostDevices extends Wizard public function __construct( int $page=0, string $msg='Default message. Not set.', - string $icon='hostDevices.png', + string $icon='images/wizard/hostdevices.svg', string $label='Host & Devices' ) { $this->setBreadcrum([]); @@ -122,9 +78,9 @@ class HostDevices extends Wizard /** - * Undocumented function + * Run wizard manager. * - * @return void + * @return mixed Returns null if wizard is ongoing. Result if done. */ public function run() { @@ -684,6 +640,7 @@ class HostDevices extends Wizard // XXX: Could be improved validating inputs before continue (JS) // Print NetScan page 0. $this->printForm($form); + $this->printGoBackButton(); } } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 1a70bae362..ecc253ad04 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -20,6 +20,41 @@ class Wizard */ public $page; + /** + * Target icon to be shown in discovery wizard list. + * + * @var string + */ + public $icon; + + /** + * Target label to be shown in discovery wizard list. + * + * @var string + */ + public $label; + + /** + * This wizard's url. + * + * @var string + */ + public $url; + + /** + * Result of wizard execution (0 - ok, 1 - not ok). + * + * @var integer + */ + public $result; + + /** + * Message to be delivered to user. + * + * @var string + */ + public $msg; + /** * Setter for breadcrum @@ -285,13 +320,13 @@ class Wizard ); case 'submit': - return html_print_submit_button( + return '
      '.html_print_submit_button( ((isset($data['label']) === true) ? $data['label'] : 'OK'), ((isset($data['name']) === true) ? $data['name'] : ''), ((isset($data['disabled']) === true) ? $data['disabled'] : false), ((isset($data['attributes']) === true) ? $data['attributes'] : ''), ((isset($data['return']) === true) ? $data['return'] : false) - ); + ).'
      '; case 'checkbox': return html_print_checkbox( @@ -316,6 +351,37 @@ class Wizard } + /** + * Prints a go back button redirecting to main page. + * + * @return void + */ + public function printGoBackButton() + { + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery' + ), + ], + 'inputs' => [ + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; + + $this->printForm($form); + } + + /** * Print a block of inputs. * diff --git a/pandora_console/images/wizard/hostdevices.svg b/pandora_console/images/wizard/hostdevices.svg new file mode 100644 index 0000000000..1e82511472 --- /dev/null +++ b/pandora_console/images/wizard/hostdevices.svg @@ -0,0 +1,4 @@ + + + + diff --git a/pandora_console/images/wizard/tasklist.svg b/pandora_console/images/wizard/tasklist.svg new file mode 100644 index 0000000000..1e82511472 --- /dev/null +++ b/pandora_console/images/wizard/tasklist.svg @@ -0,0 +1,4 @@ + + + + diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 5f2cc45b68..df393fdf3e 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -2,6 +2,43 @@ * Discovery css global */ +li.discovery { + display: inline-block; + float: left; + width: 250px; + height: 120px; + margin: 15px; +} + +li.discovery > a { + text-decoration: none; +} + +li.discovery > a:hover { + color: #000; +} + +li.discovery img { + height: 90px; +} + +li.discovery > a label { + cursor: pointer; +} + +div.data_container { + width: 100%; + height: 100%; + text-align: center; + border: 1px solid #ddd; + padding-top: 30px; + padding-bottom: 30px; +} + +div.data_container:hover { + box-shadow: 2px 2px 10px #ddd; +} + #contenedor_principal { height: auto; position: relative; From a5ad61f340ac851ca5dc5226132a29e50c1c2ed7 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 18:35:35 +0100 Subject: [PATCH 112/262] discovery delete task Former-commit-id: 8809067053aa6bebfa61498afb2108aea352f3d7 --- .../wizards/DiscoveryTaskList.class.php | 73 ++++++++++++++++--- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 0ad4af9683..5488b675b9 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -76,6 +76,13 @@ class DiscoveryTaskList extends Wizard { // Load styles. parent::run(); + + $delete = (bool) get_parameter('delete', false); + + if ($delete) { + return $this->deleteTask(); + } + return $this->showList(); } @@ -97,6 +104,41 @@ class DiscoveryTaskList extends Wizard } + /** + * Delete a recon task. + * + * @return void + */ + public function deleteTask() + { + global $config; + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + $task = get_parameter('task', null); + + if ($task !== null) { + db_process_sql_delete( + 'trecon_task', + ['id_rt' => $task] + ); + } + + return [ + 'result' => 0, + 'msg' => __('Task successfully deleted'), + 'id' => false, + ]; + } + + /** * Show complete list of running tasks. * @@ -114,21 +156,21 @@ class DiscoveryTaskList extends Wizard 'Trying to access recon task viewer' ); include 'general/noaccess.php'; - return; + return false; } - // Get all recon servers + // Get all recon servers. $servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3'); if ($servers === false) { $servers = []; ui_print_error_message(__('Discovery Server is disabled')); - return; + return false; } else { $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); if ($recon_task === false) { ui_print_page_header(__('Recon View'), 'images/op_recon.png', false, '', false); include_once $config['homedir'].'/general/firts_task/recon_view.php'; - return; + return false; } else { include_once $config['homedir'].'/include/functions_graph.php'; include_once $config['homedir'].'/include/functions_servers.php'; @@ -145,6 +187,11 @@ class DiscoveryTaskList extends Wizard if (isset($_GET['force'])) { $id = (int) get_parameter_get('force', 0); servers_force_recon_task($id); + header( + 'Location: '.ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist' + ) + ); } } @@ -153,7 +200,7 @@ class DiscoveryTaskList extends Wizard $server_name = servers_get_name($id_server); $recon_tasks = db_get_all_rows_field_filter('trecon_task', 'id_recon_server', $id_server); - // Show network tasks for Recon Server + // Show network tasks for Recon Server. if ($recon_tasks === false) { $recon_tasks = []; } @@ -195,14 +242,16 @@ class DiscoveryTaskList extends Wizard $table->head[7] = __('Updated at'); $table->align[7] = 'left'; - $table->head[8] = __('Edit'); + $table->head[8] = __('Operations'); $table->align[8] = 'left'; foreach ($recon_tasks as $task) { $data = []; if ($task['disabled'] == 0) { - $data[0] = ''; + $data[0] = ''; $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]); $data[0] .= ''; } else { @@ -226,11 +275,11 @@ class DiscoveryTaskList extends Wizard } if ($task['id_recon_script'] == 0) { - // Network recon task + // Network recon task. $data[5] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'  '; $data[5] .= network_profiles_get_name($task['id_network_profile']); } else { - // APP recon task + // APP recon task. $data[5] = html_print_image('images/plugin.png', true).'  '; $data[5] .= db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $task['id_recon_script'])); } @@ -250,6 +299,12 @@ class DiscoveryTaskList extends Wizard 'images/wrench_orange.png', true ).''; + $data[8] .= ''.html_print_image( + 'images/cross.png', + true + ).''; } else { $data[8] = ''; } From 912f0baace3b3917fdf76dd7703078901f86de48 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 18:42:44 +0100 Subject: [PATCH 113/262] Discovery Tasks first tasks and some minor fixes Former-commit-id: 4a37dc99f1b1a95217e9be207526d750133a14a6 --- pandora_console/general/firts_task/recon_view.php | 10 +++++----- .../godmode/wizards/DiscoveryTaskList.class.php | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pandora_console/general/firts_task/recon_view.php b/pandora_console/general/firts_task/recon_view.php index 1d81c13e98..2377ce7c20 100755 --- a/pandora_console/general/firts_task/recon_view.php +++ b/pandora_console/general/firts_task/recon_view.php @@ -15,17 +15,17 @@ global $config; check_login(); ui_require_css_file('firts_task'); ?> - true, 'message' => __('There are no recon task defined yet.') ]); ?> + true, 'message' => __('There are no discovery tasks defined yet.') ]); ?>
      __('Discovery server')]); ?>
      -

      +

      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/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 5488b675b9..d0c5da17fb 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -168,7 +168,6 @@ class DiscoveryTaskList extends Wizard } else { $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); if ($recon_task === false) { - ui_print_page_header(__('Recon View'), 'images/op_recon.png', false, '', false); include_once $config['homedir'].'/general/firts_task/recon_view.php'; return false; } else { From c49c8bc0b5d84ab2b61c05ee629fe15764d27a76 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 15 Feb 2019 18:44:59 +0100 Subject: [PATCH 114/262] discovery minor style changes Former-commit-id: ea572c9d797214cbfc6f1b9ff2025f0c4819b4ed --- pandora_console/include/styles/discovery.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index df393fdf3e..930dbd047d 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -30,7 +30,6 @@ div.data_container { width: 100%; height: 100%; text-align: center; - border: 1px solid #ddd; padding-top: 30px; padding-bottom: 30px; } @@ -39,6 +38,9 @@ div.data_container:hover { box-shadow: 2px 2px 10px #ddd; } +/* + * TODO: This may be at hostdevices.css + */ #contenedor_principal { height: auto; position: relative; From a9caebbbf41f4dfcc6a38e7fc2a7e5093caf7f78 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 18 Feb 2019 10:24:19 +0100 Subject: [PATCH 115/262] Put the list into a function Former-commit-id: 11e4d0faa3512e46582530f48bab2cfa1031e89f --- pandora_console/godmode/servers/discovery.php | 18 ++------- .../godmode/wizards/Wizard.main.php | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 024eb39e30..97b9b8a884 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -76,24 +76,12 @@ if ($classname_selected !== null) { if ($classname_selected === null) { // Load classes and print selector. - echo '
        '; + $wiz_data = []; foreach ($classes as $classpath) { $classname = basename($classpath, '.class.php'); $obj = new $classname(); - $wiz_data = $obj->load(); - ?> - -
      • - -
        - -
        -
        -
        -
      • - - load(); } - echo '
      '; + Wizard::printBigButtonsList($wiz_data); } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index ecc253ad04..709e601fa5 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -467,4 +467,44 @@ class Wizard } + /** + * Print a big button element (huge image, big text and link). + * + * @param array $data Element data (link, image...). + * + * @return void Only prints the element. + */ + public static function printBigButtonElement($data) + { + if (isset($data['url']) === false) { + $data['url'] = '#'; + } + + ?> +
    • + +
      + +
      +
      +
      +
    • + '; + array_map('self::printBigButtonElement', $list_data); + echo '
    '; + } } From 29206eb3bbd2b9bd10e0dc9570cf1dabde797923 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 18 Feb 2019 11:42:55 +0100 Subject: [PATCH 116/262] Added visual changes Former-commit-id: 33ac4873763e6b0e2cf3d2ad2b25492fe5b33583 --- .../godmode/wizards/HostDevices.class.php | 32 ++++++++----------- pandora_console/images/wizard/hostdevices.svg | 4 +-- pandora_console/images/wizard/tasklist.svg | 5 ++- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 633fbfe19f..54fdeb0716 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -94,24 +94,20 @@ class HostDevices extends Wizard if ($mode === null) { $this->setBreadcrum(['Host&devices']); $this->printHeader(); - echo '
    '; - echo '
    '; - echo '
    '; - echo 'importcsv'; - echo '
    '; - echo '
    '; - echo ''.__('Import CSV').''; - echo '
    '; - echo '
    '; - echo '
    '; - echo '
    '; - echo 'importcsv'; - echo '
    '; - echo '
    '; - echo ''.__('Escanear red').''; - echo '
    '; - echo '
    '; - echo '
    '; + $this->printBigButtonsList( + [ + [ + 'url' => $this->url.'&mode=importcsv', + 'icon' => 'images/wizard/csv_image.svg', + 'label' => __('Import CSV'), + ], + [ + 'url' => $this->url.'&mode=netscan', + 'icon' => 'images/wizard/csv_image.svg', + 'label' => __('Net Scan'), + ], + ] + ); return; } diff --git a/pandora_console/images/wizard/hostdevices.svg b/pandora_console/images/wizard/hostdevices.svg index 1e82511472..3add7ea833 100644 --- a/pandora_console/images/wizard/hostdevices.svg +++ b/pandora_console/images/wizard/hostdevices.svg @@ -1,4 +1,4 @@ - - + + diff --git a/pandora_console/images/wizard/tasklist.svg b/pandora_console/images/wizard/tasklist.svg index 1e82511472..bac9f75f6f 100644 --- a/pandora_console/images/wizard/tasklist.svg +++ b/pandora_console/images/wizard/tasklist.svg @@ -1,4 +1,3 @@ - - - + + From a1a429aa5275081ba230fb027f508641ef5be098 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 12:14:03 +0100 Subject: [PATCH 117/262] H&D minor fixes and acl checks Former-commit-id: cec9ec899e648ab6e76716333c8ee09ca875023a --- .../godmode/wizards/HostDevices.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 54fdeb0716..07f8e1ee7b 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -439,9 +439,6 @@ class HostDevices extends Wizard return; } - $user_groups = users_get_groups(false, 'AW', true, false, null, 'id_grupo'); - $user_groups = array_keys($user_groups); - if ($this->parseNetScan() === false) { // Error. ui_print_error_message( @@ -473,6 +470,17 @@ class HostDevices extends Wizard ], ]; + // Check ACL. If user is not able to manage target task, + // redirect him to main page. + if (users_is_admin() || check_acl( + $config['id_usuario'], + $this->task['id_group'], + 'PM' + ) !== true + ) { + $form['form']['action'] = $this->url.'&mode=netscan&page='.($this->page - 1); + } + $this->printForm($form); return null; } @@ -954,6 +962,7 @@ function SNMPExtraShow(target) { $("#snmp_options_basic").hide(); $("#snmp_options_v3").hide(); if (document.getElementsByName("snmp_enabled")[0].checked) { + $("#snmp_extra").show(); if (target == 3) { $("#snmp_options_v3").show(); } else { From 5816320effe68eb3ba1ccdeb7913439e712da461 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 14:00:38 +0100 Subject: [PATCH 118/262] new token. autoconfiguration_enabled. discovery tasks Former-commit-id: d19c86696b73335b6977d11d5ea683131780097e --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + pandora_console/pandoradb.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 6140297ef8..c86c9bf7d6 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1408,6 +1408,7 @@ ALTER TABLE trecon_task ADD `snmp_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; ALTER TABLE trecon_task ADD `auth_strings` text; +ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 4271269fd7..ae780a5470 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -784,6 +784,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `snmp_security_level` varchar(25) NOT NULL default '', `wmi_enabled` tinyint(1) unsigned DEFAULT '0', `auth_strings` text, + `autoconfiguration_enabled` tinyint(1) unsigned default '0', PRIMARY KEY (`id_rt`), KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 46af41a2cc3663e26258fb867a993c5ad058de7a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 14:00:55 +0100 Subject: [PATCH 119/262] support for autoconfiguration Former-commit-id: 034ed513ed9cf7efbe22720b61e8ff431ebbbc84 --- .../godmode/wizards/HostDevices.class.php | 263 +++++++----------- .../lib/PandoraFMS/DiscoveryServer.pm | 9 + pandora_server/lib/PandoraFMS/Recon/Base.pm | 1 + 3 files changed, 103 insertions(+), 170 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 07f8e1ee7b..c537ae3c8d 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -109,6 +109,7 @@ class HostDevices extends Wizard ] ); + $this->printGoBackButton(); return; } @@ -202,6 +203,7 @@ class HostDevices extends Wizard $server_id = get_parameter('id_recon_server', ''); $network = get_parameter('network', ''); $id_group = get_parameter('id_group', ''); + $interval = get_parameter('interval', 0); if (isset($task_id) === true) { // We're updating this task. @@ -265,6 +267,7 @@ class HostDevices extends Wizard $this->task['subnet'] = $network; $this->task['id_recon_server'] = $server_id; $this->task['id_group'] = $id_group; + $this->task['interval_sweep'] = $interval; if (isset($this->task['id_rt']) === false) { // Create. @@ -343,42 +346,6 @@ class HostDevices extends Wizard $this->task['snmp_security_level'] = $snmp_security_level; $this->task['auth_strings'] = $auth_strings; - // Update. - $res = db_process_sql_update( - 'trecon_task', - $this->task, - ['id_rt' => $this->task['id_rt']] - ); - - return true; - } - - if ($this->page == 3) { - // Interval and schedules. - // By default manual if not defined. - $id_rt = get_parameter('task', -1); - - $task = db_get_row( - 'trecon_task', - 'id_rt', - $id_rt - ); - - if ($task !== false) { - $this->task = $task; - } else { - $this->msg = __('Failed to find network scan task.'); - return false; - } - - $interval = get_parameter('interval', 0); - $id_os = get_parameter('id_os', 0); - $recon_ports = get_parameter('recon_ports', ''); - - $this->task['id_os'] = $id_os; - $this->task['interval_sweep'] = $interval; - $this->task['recon_ports'] = $recon_ports; - if ($this->task['disabled'] == 2) { // Wizard finished. $this->task['disabled'] = 0; @@ -394,7 +361,7 @@ class HostDevices extends Wizard return true; } - if ($this->page == 4) { + if ($this->page == 3) { // Wizard ended. Load data and return control to Discovery. $id_rt = get_parameter('task', -1); @@ -472,7 +439,7 @@ class HostDevices extends Wizard // Check ACL. If user is not able to manage target task, // redirect him to main page. - if (users_is_admin() || check_acl( + if (users_is_admin() !== true && check_acl( $config['id_usuario'], $this->task['id_group'], 'PM' @@ -485,7 +452,7 @@ class HostDevices extends Wizard return null; } - if (isset($this->page) + if (isset($this->page) === true && $this->page != 0 && isset($this->task['id_rt']) === false ) { @@ -526,7 +493,7 @@ class HostDevices extends Wizard // -------------------------------. // Page 0. wizard starts HERE. // -------------------------------. - if (!isset($this->page) || $this->page == 0) { + if (isset($this->page) === true || $this->page == 0) { if (isset($this->page) === false || $this->page == 0 ) { @@ -614,6 +581,44 @@ class HostDevices extends Wizard ], ]; + // Interval and schedules. + $interv_manual = 0; + if ((int) $this->task['interval_sweep'] == 0) { + $interv_manual = 1; + } + + // Schedule. + $form['inputs'][] = [ + 'label' => ''.__('Interval').''.ui_print_help_tip( + __('Manual interval means that it will be executed only On-demand'), + true + ), + 'arguments' => [ + 'type' => 'select', + 'selected' => $interv_manual, + 'fields' => [ + 0 => __('Defined'), + 1 => __('Manual'), + ], + 'name' => 'interval_manual_defined', + 'return' => true, + ], + 'extra' => ''.html_print_extended_select_for_time( + 'interval', + $this->task['interval_sweep'], + '', + '', + '0', + false, + true, + false, + false + ).ui_print_help_tip( + __('The minimum recomended interval for Recon Task is 5 minutes'), + true + ).'', + ]; + $str = __('Next'); if (isset($this->task['id_rt']) === true) { @@ -641,6 +646,21 @@ class HostDevices extends Wizard 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url, ]; + $form['js'] = ' +$("select#interval_manual_defined").change(function() { + if ($("#interval_manual_defined").val() == 1) { + $("#interval_manual_container").hide(); + $("#text-interval_text").val(0); + $("#hidden-interval").val(0); + } + else { + $("#interval_manual_container").show(); + $("#text-interval_text").val(10); + $("#hidden-interval").val(600); + $("#interval_units").val(60); + } +}).change();'; + // XXX: Could be improved validating inputs before continue (JS) // Print NetScan page 0. $this->printForm($form); @@ -679,17 +699,38 @@ class HostDevices extends Wizard $form['inputs'][] = [ 'label' => __('Module template'), 'arguments' => [ - 'name' => 'id_network_profile', - 'type' => 'select_from_sql', - 'sql' => 'SELECT id_np, name + 'name' => 'id_network_profile', + 'type' => 'select_from_sql', + 'sql' => 'SELECT id_np, name FROM tnetwork_profile ORDER BY name', - 'return' => true, - 'selected' => $this->task['id_network_profile'], + 'return' => true, + 'selected' => $this->task['id_network_profile'], + 'nothing_value' => 0, + 'nothing' => __('None'), ], ]; + if (enterprise_installed() === true) { + // Input: Enable auto configuration. + $form['inputs'][] = [ + 'label' => __('Apply autoconfiguration rules').ui_print_help_tip( + __( + 'System is able to auto configure detected host & devices by applying your defined configuration rules.' + ), + true + ), + 'arguments' => [ + 'name' => 'autoconfiguration_enabled', + 'type' => 'switch', + 'return' => true, + 'value' => (isset($this->task['autoconfiguration_enabled'])) ? $this->task['autoconfiguration_enabled'] : 0, + + ], + ]; + } + // Feature configuration. // Input: SNMP enabled. $form['inputs'][] = [ @@ -879,7 +920,12 @@ class HostDevices extends Wizard 'hidden' => 1, 'block_content' => [ [ - 'label' => __('WMI Auth. strings'), + 'label' => ''.__('WMI Auth. strings').''.ui_print_help_tip( + __( + 'Auth strings must be defined as user%pass, comma separated as many you need.' + ), + true + ), 'arguments' => [ 'name' => 'auth_strings', 'type' => 'text', @@ -950,7 +996,7 @@ class HostDevices extends Wizard $form['inputs'][] = [ 'arguments' => [ 'name' => 'submit', - 'label' => __('Next'), + 'label' => __('Finish'), 'type' => 'submit', 'attributes' => 'class="sub next"', 'return' => true, @@ -1017,129 +1063,6 @@ $(function() { } if ($this->page == 2) { - // Interval and schedules. - $interv_manual = 0; - if ((int) $this->task['interval_sweep'] == 0) { - $interv_manual = 1; - } - - // Filter: OS. - $form['inputs'][] = [ - 'label' => ''.__('Filter by OS').'', - 'arguments' => [ - 'type' => 'select_from_sql', - 'sql' => 'SELECT id_os, name - FROM tconfig_os - ORDER BY name', - 'name' => 'id_os', - 'return' => 'true', - 'nothing' => __('Any'), - 'selected' => $this->task['id_os'], - ], - ]; - - // Filter: Ports. - $form['inputs'][] = [ - 'label' => ''.__('Filter by ports').''.ui_print_help_tip( - __('Ports defined like: 80 or 80,443,512 or even 0-1024 (Like Nmap command line format). If dont want to do a sweep using portscan, left it in blank'), - true - ), - 'arguments' => [ - 'type' => 'text', - 'name' => 'recon_ports', - 'return' => 'true', - 'recon_ports' => $this->task['recon_ports'], - ], - ]; - - // Schedule. - $form['inputs'][] = [ - 'label' => ''.__('Interval').''.ui_print_help_tip( - __('Manual interval means that it will be executed only On-demand'), - true - ), - 'arguments' => [ - 'type' => 'select', - 'selected' => $interv_manual, - 'fields' => [ - 0 => __('Defined'), - 1 => __('Manual'), - ], - 'name' => 'interval_manual_defined', - 'return' => true, - ], - 'extra' => ''.html_print_extended_select_for_time( - 'interval', - $this->task['interval_sweep'], - '', - '', - '0', - false, - true, - false, - false - ).ui_print_help_tip( - __('The minimum recomended interval for Recon Task is 5 minutes'), - true - ).'', - ]; - - // Hidden, id_rt. - $form['inputs'][] = [ - 'arguments' => [ - 'name' => 'task', - 'value' => $this->task['id_rt'], - 'type' => 'hidden', - 'return' => true, - ], - ]; - - // Hidden, page. - $form['inputs'][] = [ - 'arguments' => [ - 'name' => 'page', - 'value' => ($this->page + 1), - 'type' => 'hidden', - 'return' => true, - ], - ]; - - // Submit button. - $form['inputs'][] = [ - 'arguments' => [ - 'name' => 'submit', - 'label' => __('Next'), - 'type' => 'submit', - 'attributes' => 'class="sub next"', - 'return' => true, - ], - ]; - - $form['form'] = [ - 'method' => 'POST', - 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'], - ]; - - $form['js'] = ' -$("select#interval_manual_defined").change(function() { - if ($("#interval_manual_defined").val() == 1) { - $("#interval_manual_container").hide(); - $("#text-interval_text").val(0); - $("#hidden-interval").val(0); - } - else { - $("#interval_manual_container").show(); - $("#text-interval_text").val(10); - $("#hidden-interval").val(600); - $("#interval_units").val(60); - } -}).change();'; - - $this->printForm($form); - return null; - } - - if ($this->page == 3) { if ($this->task['id_rt']) { // 0 - Is OK. $this->result = 0; diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 7b6fa7c0ea..b6423a8506 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -190,6 +190,7 @@ sub data_consumer ($$) { vlan_cache_enabled => $task->{'vlan_enabled'}, wmi_enabled => $task->{'wmi_enabled'}, auth_strings_array => \@auth_strings, + autoconfigure_agent => $task->{'autoconfiguration_enabled'} %{$pa_config} ); @@ -445,6 +446,14 @@ sub PandoraFMS::Recon::Base::create_agent($$) { $location->{'longitude'}, $location->{'latitude'} ); return undef unless defined ($agent_id) and ($agent_id > 0); + + # Autoconfigure agent + if (defined($self->{'autoconfiguration_enabled'}) && $self->{'autoconfiguration_enabled'} == 1) { + my $agent_data = PandoraFMS::DB::get_db_single_row($self->{'dbh'}, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id); + # Update agent configuration once, after create agent. + enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}]); + } + pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); $agent_learning = 1; diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm index e819b06476..ec3eb0d853 100644 --- a/pandora_server/lib/PandoraFMS/Recon/Base.pm +++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm @@ -166,6 +166,7 @@ sub new { snmp_timeout => 2, snmp_version => 1, subnets => [], + autoconfiguration_enabled => 0, @_, }; From 34cf0bd837e3e1758a0cfc467de4be1827262ccf Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 14:01:17 +0100 Subject: [PATCH 120/262] minor fix acl check in notifications Former-commit-id: 3ee0004f0c8ab507ed2301b77117ca945fb4e826 --- pandora_console/godmode/setup/setup_notifications.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 14a29c4bb2..28c336aa92 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -32,12 +32,6 @@ require_once $config['homedir'].'/include/functions_notifications.php'; check_login(); -if (! check_acl($config['id_user'], 0, 'PM') && ! is_user_admin($config['id_user'])) { - db_pandora_audit('ACL Violation', 'Trying to access Setup Management'); - include 'general/noaccess.php'; - return; -} - // AJAX actions. $source = get_parameter('source', ''); $users = get_parameter('users', ''); From 7b2e0342c1c8a95e79bedd092d1737ef17dab92c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 14:18:58 +0100 Subject: [PATCH 121/262] Fix. notification did not reach ALL target Former-commit-id: 237e5dac34bcbe50453e0b56f0964a9d74aa7c04 --- pandora_console/include/functions_messages.php | 4 ++-- pandora_console/include/functions_notifications.php | 2 +- pandora_console/operation/messages/message_edit.php | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index f633866f65..a67bcb56e1 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -384,7 +384,7 @@ function messages_get_count( AND up.id_grupo=ng.id_group ) ON tm.id_mensaje=ng.id_mensaje WHERE utimestamp_erased is null - AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0)) + AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0) ) t %s', $source_sql, @@ -496,7 +496,7 @@ function messages_get_overview( ) ON tm.id_mensaje=ng.id_mensaje %s WHERE utimestamp_erased is null - AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0)) + AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0) ) t %s %s diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 0e35b7ea37..23b1a90e70 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -145,7 +145,7 @@ function check_notification_readable(int $id_message) AND up.id_grupo=ng.id_group ) ON tm.id_mensaje=ng.id_mensaje WHERE utimestamp_erased is null - AND (nu.id_user="%s" OR (up.id_usuario="%s" AND ng.id_group=0))', + AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)', $config['id_user'], $id_message, $config['id_user'], diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index 6c100d7c00..f116e6609d 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -106,7 +106,12 @@ if ($read_message) { $dst_name = $message['id_usuario_destino']; } - echo '

    Conversation with '.$user_name.'

    '; + if (isset($user_name) !== true || empty($user_name) === true) { + echo '

    Notification

    '; + } else { + echo '

    Conversation with '.$user_name.'

    '; + } + echo '

    Subject: '.$message['subject'].'

    '; $conversation = []; From cb94692491b1d0100ce3dbe6e89170a08955d142 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 18 Feb 2019 14:30:03 +0100 Subject: [PATCH 122/262] Added function addBreadcrum in Wizard main Former-commit-id: ac40c2fd49ff02a84dc6752c4ea99309a3d4440f --- pandora_console/godmode/servers/discovery.php | 10 + .../godmode/wizards/Cloud.class.php | 267 ------------------ .../godmode/wizards/Wizard.main.php | 18 ++ 3 files changed, 28 insertions(+), 267 deletions(-) delete mode 100755 pandora_console/godmode/wizards/Cloud.class.php diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 235ae01e78..489293c862 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -49,6 +49,16 @@ function get_wiz_class($str) // Dynamic class loader. $classes = glob($config['homedir'].'/godmode/wizards/*.class.php'); +if (enterprise_installed()) { + $ent_classes = glob( + $config['homedir'].'/enterprise/godmode/wizards/*.class.php' + ); + if ($ent_classes === false) { + $ent_classes = []; + } + $classes = array_merge($classes, $ent_classes); +} + foreach ($classes as $classpath) { include_once $classpath; } diff --git a/pandora_console/godmode/wizards/Cloud.class.php b/pandora_console/godmode/wizards/Cloud.class.php deleted file mode 100755 index 1de88c2ca7..0000000000 --- a/pandora_console/godmode/wizards/Cloud.class.php +++ /dev/null @@ -1,267 +0,0 @@ -setBreadcrum([]); - - $this->task = []; - $this->msg = $msg; - $this->icon = $icon; - $this->label = $label; - $this->page = $page; - $this->url = ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=cloud' - ); - - return $this; - } - - - /** - * Run AmazonWS class. Entry point. - * - * @return void - */ - public function run() - { - global $config; - - // Load styles. - parent::run(); - - $mode = get_parameter('mode', null); - - if ($mode === null) { - $this->setBreadcrum(['Cloud']); - $this->printHeader(); - - echo 'Amazon WS'; - - return; - } - - if ($mode == 'amazonws') { - $this->setBreadcrum( - [ - 'Cloud', - 'Amazon AWS', - ] - ); - $this->printHeader(); - return $this->runAmazonAWS(); - } - - return null; - } - - - /** - * Checks if environment is ready, - * returns array - * icon: icon to be displayed - * label: label to be displayed - * - * @return array With data. - **/ - public function load() - { - return [ - 'icon' => $this->icon, - 'label' => $this->label, - 'url' => $this->url, - ]; - } - - - // ///////////////////////////////////////////////////////////////////////// - // Extra methods. - // ///////////////////////////////////////////////////////////////////////// - - - /** - * Amazon AWS pages manager. - * - * @return void - */ - public function runAmazonAWS() - { - global $config; - - check_login(); - - if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access Agent Management' - ); - include 'general/noaccess.php'; - return; - } - - // -------------------------------. - // Page 0. wizard starts HERE. - // -------------------------------. - if (!isset($this->page) || $this->page == 0) { - if (isset($this->page) === false - || $this->page == 0 - ) { - $this->printForm( - [ - 'form' => [ - 'action' => '#', - 'method' => 'POST', - ], - 'inputs' => [ - [ - 'label' => __('AWS access key ID'), - 'arguments' => [ - 'name' => 'aws_id', - 'value' => '', - 'type' => 'text', - ], - ], - [ - 'label' => __('AWS secret access key'), - 'arguments' => [ - 'name' => 'aws_id', - 'value' => '', - 'type' => 'text', - ], - ], - [ - 'arguments' => [ - 'name' => 'page', - 'value' => ($this->page + 1), - 'type' => 'hidden', - 'return' => true, - ], - ], - [ - 'arguments' => [ - 'name' => 'submit', - 'label' => __('Validate'), - 'type' => 'submit', - 'attributes' => 'class="sub wand"', - 'return' => true, - ], - ], - ], - ] - ); - } - } - - if ($this->page == 1) { - echo 'TODO'; - // TODOS. - } - - if ($this->page == 100) { - return [ - 'result' => $this->result, - 'id' => $this->id, - 'msg' => $this->msg, - ]; - } - } - - -} diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 709e601fa5..288a32fc47 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -78,6 +78,22 @@ class Wizard { return $this->breadcrum; } + + + /** + * Add an element to breadcrum array. + * + * @param string $string Element to add to breadcrum. + * + * @return void + */ + protected function addBreadcrum($string) { + if (empty($string)) { + return; + } + + array_push($this->breadcrum, $string); + } /** @@ -507,4 +523,6 @@ class Wizard array_map('self::printBigButtonElement', $list_data); echo '
'; } + + } From 27602d8e49500cd7694f43c6be5b5775073dc61e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 15:14:24 +0100 Subject: [PATCH 123/262] Recovered notification editor for user Former-commit-id: a4fbf05912c974ab388cde9e9237022f2bcc3277 --- pandora_console/operation/users/user_edit.php | 49 ++----------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 1552f2f57c..0449902172 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -14,51 +14,8 @@ // Load global vars global $config; -check_login(); - -enterprise_hook('open_meta_frame'); - -require_once $config['homedir'].'/include/functions_profile.php'; -require_once $config['homedir'].'/include/functions_users.php'; -require_once $config['homedir'].'/include/functions_groups.php'; -require_once $config['homedir'].'/include/functions_visual_map.php'; - -$meta = false; -if (enterprise_installed() && defined('METACONSOLE')) { - $meta = true; -} - -$id = get_parameter_get('id', $config['id_user']); -// ID given as parameter -$status = get_parameter('status', -1); -// Flag to print action status message -$user_info = get_user_info($id); -$id = $user_info['id_user']; -// This is done in case there are problems with uppercase/lowercase (MySQL auth has that problem) -if ((!check_acl($config['id_user'], users_get_groups($id), 'UM')) - and ($id != $config['id_user']) -) { - db_pandora_audit('ACL Violation', 'Trying to view a user without privileges'); - include 'general/noaccess.php'; - exit; -} - -// If current user is editing himself or if the user has UM (User Management) rights on any groups the user is part of AND the authorization scheme allows for users/admins to update info -if (($config['id_user'] == $id || check_acl($config['id_user'], users_get_groups($id), 'UM')) && $config['user_can_update_info']) { - $view_mode = false; -} else { - $view_mode = true; -} - -// Header -if ($meta) { - user_meta_print_header(); - $url = 'index.php?sec=advanced&sec2=advanced/users_setup&tab=user_edit'; -} else { - ui_print_page_header(__('User detail editor'), 'images/op_workspace.png', false, '', false, ''); - $url = 'index.php?sec=workspace&sec2=operation/users/user_edit'; -} - +// Load the header +require $config['homedir'].'/operation/users/user_edit_header.php'; // Update user info if (isset($_GET['modified']) && !$view_mode) { @@ -535,7 +492,7 @@ $table->rowclass[] = ''; $table->rowstyle[] = ''; $table->data[] = $data; -echo '
'; +echo ''; html_print_table($table); From 37f6da9aa8df93525b87bd37968a30eb6f9a6dba Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 15:36:51 +0100 Subject: [PATCH 124/262] recovered. changes from 0b72571c7cb47056711365750f9035012ab88af6 [formerly f3a8cdd6923834443ed7223d1e6ad7776b861184] Former-commit-id: 591e002043d2bae2382c8a91c437057fd2b809c7 --- pandora_console/include/db/mysql.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 49ffb2d101..66366c1289 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -706,6 +706,7 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa $i = 1; $max = count($values); foreach ($values as $field => $value) { + $negative = false; if (is_numeric($field)) { // User provide the exact operation to do $query .= $value; @@ -718,6 +719,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa continue; } + if ($field[0] == '!') { + $negative = true; + $field = substr($field, 1); + } + if ($field[0] != '`') { // If the field is as ., 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 From bb83f4ba4a316ff113d38d0d6b90108db2ebf9f1 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 17:08:23 +0100 Subject: [PATCH 125/262] avoid to show notification if disabled by user Former-commit-id: d00b09c9e608c51223f7192ad85408976fac5baa --- .../godmode/setup/setup_notifications.php | 4 ++++ .../include/functions_messages.php | 19 +++++++++++++++---- .../include/functions_notifications.php | 8 +++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 28c336aa92..9ee95f78cc 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -96,6 +96,10 @@ if (get_parameter('check_new_notifications', 0)) { return; } + if (messages_get_count() == 0) { + return; + } + $messages = messages_get_overview( 'timestamp', 'ASC', diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index a67bcb56e1..9266733a68 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -365,9 +365,16 @@ function messages_get_count( if ($ignore_source === true) { $source_sql = ''; } else { - $source_sql = 'INNER JOIN tnotification_source ns - ON tm.id_source = ns.id - AND ns.enabled = 1'; + $source_sql = sprintf( + 'INNER JOIN tnotification_source ns + ON tm.id_source = ns.id + AND ns.enabled = 1 + INNER JOIN tnotification_source_user nsu + ON nsu.id_source=ns.id + AND nsu.enabled = 1 + AND nsu.id_user = "%s"', + $user + ); } $sql = sprintf( @@ -478,7 +485,11 @@ function messages_get_overview( if ($incl_source_info) { $source_fields = ', tns.*'; $source_join = 'INNER JOIN tnotification_source tns - ON tns.id=tm.id_source'; + ON tns.id=tm.id_source + INNER JOIN tnotification_source_user nsu + ON nsu.id_source=tns.id + AND nsu.enabled = 1 + OR tns.enabled = 1'; } // Using distinct because could be double assignment due group/user. diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 23b1a90e70..26dcc248c5 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -525,7 +525,7 @@ function notifications_build_user_enable_return($status, $enabled) function notifications_get_user_label_status($source, $user, $label) { // If not enabled, it cannot be modificable. - if (!$source['enabled'] || !$source[$label]) { + if (!$source['enabled']) { return notifications_build_user_enable_return(false, false); } @@ -551,7 +551,10 @@ function notifications_get_user_label_status($source, $user, $label) ); // No group found, return no permissions. $value = empty($common_groups) ? false : $source[$label]; - return notifications_build_user_enable_return($value, false); + return notifications_build_user_enable_return( + $value, + false + ); } @@ -570,7 +573,6 @@ function notifications_set_user_label_status($source, $user, $label, $value) $source_info = notifications_get_all_sources(['id' => $source]); if (!isset($source_info[0]) || !$source_info[0]['enabled'] - || !$source_info[0][$label] || !$source_info[0]['user_editable'] ) { return false; From af110f4820bbb0ac04ffe2262948c6b99b55bf49 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 18:13:22 +0100 Subject: [PATCH 126/262] minor fix notification direct assignment Former-commit-id: 59ffb2338377ac2c3270681e6905f5d853add16b --- .../include/functions_messages.php | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 9266733a68..3fb907ab06 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -356,49 +356,59 @@ function messages_get_count( if (!empty($incl_read)) { // Do not filter. - $read = ''; + $read = ' 1=1 '; } else { // Retrieve only unread messages. - $read = 'where t.read is null'; + $read = ' t.read is null'; } if ($ignore_source === true) { + $source_select = ''; $source_sql = ''; + $source_extra = ''; } else { + $source_select = ',IF(ns.user_editable,nsu.enabled,ns.enabled) as enabled'; + + // Row in tnotification_source_user could exist or not. $source_sql = sprintf( - 'INNER JOIN tnotification_source ns - ON tm.id_source = ns.id - AND ns.enabled = 1 - INNER JOIN tnotification_source_user nsu - ON nsu.id_source=ns.id - AND nsu.enabled = 1 - AND nsu.id_user = "%s"', + 'INNER JOIN ( + tnotification_source ns + LEFT JOIN tnotification_source_user nsu + ON ns.id=nsu.id_source + AND nsu.id_user="test") + ON tm.id_source=ns.id', $user ); + $source_extra = 'AND (t.enabled=1 OR t.enabled is null)'; } $sql = sprintf( - 'SELECT count(*) FROM ( - SELECT DISTINCT tm.*, utimestamp_read > 0 as "read" - FROM tmensajes tm - %s - LEFT JOIN tnotification_user nu - ON tm.id_mensaje=nu.id_mensaje - AND nu.id_user="%s" - LEFT JOIN (tnotification_group ng - INNER JOIN tusuario_perfil up - ON ng.id_group=up.id_grupo - AND up.id_grupo=ng.id_group - ) ON tm.id_mensaje=ng.id_mensaje + 'SELECT count(*) as "n" FROM ( + SELECT + tm.*, + utimestamp_read > 0 as "read" + %s + FROM tmensajes tm + %s + LEFT JOIN tnotification_user nu + ON tm.id_mensaje=nu.id_mensaje + AND nu.id_user="%s" + LEFT JOIN (tnotification_group ng + INNER JOIN tusuario_perfil up + ON ng.id_group=up.id_grupo + AND up.id_grupo=ng.id_group) + ON tm.id_mensaje=ng.id_mensaje WHERE utimestamp_erased is null AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0) - ) t - %s', + ) t + WHERE %s %s', + $source_select, $source_sql, $user, $user, $user, - $read + $read, + $source_extra ); return (int) db_get_sql($sql); From 7f0b676e0f03e91c6a51d5e5ce017f62f7f003fb Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 18 Feb 2019 19:50:13 +0100 Subject: [PATCH 127/262] Discovery tasks. Extended events. Autoconfigure detected agents. Former-commit-id: da2282082606c970dbace453193eb0a7e4089731 --- .../godmode/wizards/HostDevices.class.php | 4 +++ pandora_server/lib/PandoraFMS/Core.pm | 32 ++++++++++++++++--- .../lib/PandoraFMS/DiscoveryServer.pm | 17 ++++++++-- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index c537ae3c8d..bf4eb8f73d 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -305,6 +305,9 @@ class HostDevices extends Wizard } $id_network_profile = get_parameter('id_network_profile', null); + $autoconf_enabled = get_parameter_switch( + 'autoconfiguration_enabled' + ); $snmp_enabled = get_parameter_switch('snmp_enabled'); $os_detect = get_parameter_switch('os_detect'); $parent_detection = get_parameter_switch('parent_detection'); @@ -329,6 +332,7 @@ class HostDevices extends Wizard $this->task['snmp_community'] = $community; } + $this->task['autoconfiguration_enabled'] = $autoconf_enabled; $this->task['id_network_profile'] = $id_network_profile; $this->task['snmp_enabled'] = $snmp_enabled; $this->task['os_detect'] = $os_detect; diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index ba9ddbeae8..84f16b5362 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -179,6 +179,7 @@ our @EXPORT = qw( pandora_evaluate_alert pandora_evaluate_snmp_alerts pandora_event + pandora_extended_event pandora_execute_alert pandora_execute_action pandora_exec_forced_alerts @@ -3270,11 +3271,11 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { # Create the event logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); - db_do ($dbh, 'INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) + my $event_id = db_insert ($dbh, 'id_evento','INSERT INTO ' . $event_table . ' (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $module_data, $module_status); - + # Do not write to the event file - return if ($pa_config->{'event_file'} eq ''); + return $event_id if ($pa_config->{'event_file'} eq ''); # Add a header when the event file is created my $header = undef; @@ -3285,7 +3286,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { # Open the event file for writing if (! open (EVENT_FILE, '>>' . $pa_config->{'event_file'})) { logger($pa_config, "Error opening event file " . $pa_config->{'event_file'} . ": $!", 10); - return; + return $event_id; } # Resolve ids @@ -3308,6 +3309,29 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) { print EVENT_FILE "$agent_name,".safe_output($group_name)."," . safe_output ($evento) . ",$timestamp,$event_status,$utimestamp,$event_type,".safe_output($module_name).",".safe_output($alert_name).",$severity,".safe_output($comment).",".safe_output($module_tags).",$source,$id_extra,$user_name,".safe_output($critical_instructions).",".safe_output($warning_instructions).",".safe_output($unknown_instructions).",$ack_utimestamp\n"; close (EVENT_FILE); + + return $event_id; +} + +########################################################################## +=head2 C<< pandora_extended_event (I<$pa_config>, I<$dbh>, I<$event_id>, I<$description>) >> + +Creates an extended event linked to an existing main event id. + +=cut +########################################################################## +sub pandora_extended_event($$$$) { + my ($pa_config, $dbh, $event_id, $description) = @_; + + return unless defined($event_id) && "$event_id" ne "" && $event_id > 0; + + return db_do( + $dbh, + 'INSERT INTO tevent_extended (id_evento, utimestamp, description) VALUES (?,?,?)', + $event_id, + time(), + safe_input($description) + ); } ########################################################################## diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index b6423a8506..8911d353e3 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -163,6 +163,8 @@ sub data_consumer ($$) { @auth_strings = split(/,/, safe_output($task->{'auth_strings'})); } + my $main_event = pandora_event($pa_config, "[Discovery] Execution summary",$task->{'id_group'}, 0, 0, 0, 0, 'system', 0, $dbh); + my $recon = new PandoraFMS::Recon::Base( communities => \@communities, dbh => $dbh, @@ -190,7 +192,8 @@ sub data_consumer ($$) { vlan_cache_enabled => $task->{'vlan_enabled'}, wmi_enabled => $task->{'wmi_enabled'}, auth_strings_array => \@auth_strings, - autoconfigure_agent => $task->{'autoconfiguration_enabled'} + autoconfiguration_enabled => $task->{'autoconfiguration_enabled'}, + main_event_id => $main_event, %{$pa_config} ); @@ -451,10 +454,18 @@ sub PandoraFMS::Recon::Base::create_agent($$) { if (defined($self->{'autoconfiguration_enabled'}) && $self->{'autoconfiguration_enabled'} == 1) { my $agent_data = PandoraFMS::DB::get_db_single_row($self->{'dbh'}, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id); # Update agent configuration once, after create agent. - enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}]); + enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}, $agent_id]); + } + + if (defined($self->{'main_event_id'})) { + my $addresses_str = join(',', safe_output($self->get_addresses($device))); + pandora_extended_event( + $self->{'pa_config'}, $self->{'dbh'}, $self->{'main_event_id'}, + "[Discovery] New " . safe_output($self->get_device_type($device)) . " found " . $host_name . " (" . $addresses_str . ") Agent $agent_id." + ); + } - pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); $agent_learning = 1; # Create network profile modules for the agent From 938408ada909387a37054cf4b57de43640663956 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 19 Feb 2019 08:58:30 +0100 Subject: [PATCH 128/262] Added wizard Former-commit-id: d47389f000b9295c21d9a56ed0138913d0045b76 --- .../godmode/wizards/HostDevices.class.php | 20 +++++-- .../godmode/wizards/Wizard.main.php | 7 ++- pandora_console/include/styles/discovery.css | 59 ++++++++++++------- 3 files changed, 59 insertions(+), 27 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index c537ae3c8d..2dd29d923c 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -92,7 +92,7 @@ class HostDevices extends Wizard $mode = get_parameter('mode', null); if ($mode === null) { - $this->setBreadcrum(['Host&devices']); + $this->setBreadcrum(['']); $this->printHeader(); $this->printBigButtonsList( [ @@ -117,8 +117,8 @@ class HostDevices extends Wizard if ($mode == 'importcsv') { $this->setBreadcrum( [ - 'Host&devices', - 'Import CSV', + '', + '', ] ); $this->printHeader(); @@ -132,10 +132,20 @@ class HostDevices extends Wizard // Do not paint breadcrum in last page. Redirected. $this->setBreadcrum( [ - 'Host&devices', - 'Net scan', + '', + '', ] ); + if ($this->page == 1) { + $this->setBreadcrum( + [ + '', + '', + '', + ] + ); + } + $this->printHeader(); } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 709e601fa5..2f58bea91e 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -108,7 +108,7 @@ class Wizard */ public function printBreadcrum() { - return '

'.implode(' > ', $this->breadcrum).'

'; + return '

'.implode('', $this->breadcrum).'

'; } @@ -502,9 +502,12 @@ class Wizard * * @return void Print the full list. */ - public static function printBigButtonsList($list_data) { + public static function printBigButtonsList($list_data) + { echo '
    '; array_map('self::printBigButtonElement', $list_data); echo '
'; } + + } diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 930dbd047d..ad85fd606c 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -41,26 +41,6 @@ div.data_container:hover { /* * TODO: This may be at hostdevices.css */ -#contenedor_principal { - height: auto; - position: relative; - margin: auto; -} -#contenedor_imagen_texto { - width: 11%; - height: auto; - position: relative; - display: inline-block; - vertical-align: top; - overflow: hidden; - margin-right: 5%; -} -#imagen { - width: 15%; - height: auto; - position: relative; - display: inline; -} .texto { height: auto; text-align: center; @@ -70,3 +50,42 @@ div.data_container:hover { text-decoration: none; font-size: 24px; } +.text_color { + color: white; + margin-left: 25px; +} +.text_color:hover { + text-decoration: none; +} +.arrow_box { + display: inline-block; + position: relative; + background: #82b92e; + width: 15%; + padding: 1%; + margin-left: 20px; + margin-bottom: 10px; +} +.arrow_box:after, +.arrow_box:before { + top: 50%; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; +} + +.arrow_box:after { + left: 0%; + border-left-color: white; + border-width: 20px; + margin-top: -20px; +} +.arrow_box:before { + left: 100%; + border-left-color: #82b92e; + border-width: 20px; + margin-top: -20px; +} From 906ba091e1135bae6ffa4b33faf5625730ed2e5b Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 10:37:09 +0100 Subject: [PATCH 129/262] minor fixes/changes DiscoveryServer Former-commit-id: 8273727109628f99fc86c125c9b6f62a416c07f1 --- pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 8911d353e3..527dbe5054 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -454,7 +454,7 @@ sub PandoraFMS::Recon::Base::create_agent($$) { if (defined($self->{'autoconfiguration_enabled'}) && $self->{'autoconfiguration_enabled'} == 1) { my $agent_data = PandoraFMS::DB::get_db_single_row($self->{'dbh'}, 'SELECT * FROM tagente WHERE id_agente = ?', $agent_id); # Update agent configuration once, after create agent. - enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}, $agent_id]); + enterprise_hook('autoconfigure_agent', [$self->{'pa_config'}, $host_name, $agent_id, $agent_data, $self->{'dbh'}, 1]); } if (defined($self->{'main_event_id'})) { From 85371424eed81f5a37b4a8187bb34937fb97485e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 11:13:07 +0100 Subject: [PATCH 130/262] Minor fixes and status check Former-commit-id: 47a7e75579927c0ac109f303b77ebcc273334581 --- .../include/class/ConsoleSupervisor.php | 56 ++++++++++++++++++- pandora_console/include/functions_config.php | 5 ++ pandora_console/include/styles/pandora.css | 9 ++- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 60b5b6083c..88dbf0f11f 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -501,6 +501,7 @@ class ConsoleSupervisor case 'NOTIF.UPDATEMANAGER.OPENSETUP': case 'NOTIF.UPDATEMANAGER.UPDATE': case 'NOTIF.UPDATEMANAGER.MINOR': + case 'NOTIF.CRON.CONFIGURED': default: // NOTIF.SERVER.STATUS. // NOTIF.SERVER.STATUS.ID_SERVER. @@ -1379,7 +1380,10 @@ class ConsoleSupervisor [ 'type' => 'NOTIF.PANDORADB', 'title' => __('Database maintance problem'), - 'message' => __('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()), + 'message' => __( + '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.', + io_safe_output(get_product_name()) + ), 'url' => ui_get_full_url( 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' ), @@ -2081,4 +2085,54 @@ class ConsoleSupervisor } + /** + * Check if CRON utility has been configured. + * + * @return void + */ + public function checkCronRunning() + { + global $config; + + // Check if DiscoveryCronTasks is running. Warn user if not. + if ($config['cron_last_run'] == 0 + || (get_system_time() - $config['cron_last_run']) > 3600 + ) { + $message_conf_cron = __('DiscoveryConsoleTasks is not running properly'); + if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { + $message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service'); + $message_conf_cron .= ' '.__('Please, add the following line to your crontab file:'); + $message_conf_cron .= '
* * * * * <user> wget -q -O - --no-check-certificate ';
+                $message_conf_cron .= str_replace(
+                    ENTERPRISE_DIR.'/meta/',
+                    '',
+                    ui_get_full_url(false)
+                );
+                $message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
+                $message_conf_cron .= '/cron/cron.php >> ';
+                $message_conf_cron .= $config['homedir'].'/pandora_console.log
'; + } + + 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']); + } + + $this->notify( + [ + 'type' => 'NOTIF.CRON.CONFIGURED', + 'title' => __('DiscoveryConsoleTasks is not configured.'), + 'message' => __($message_conf_cron), + 'url' => ui_get_full_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/functions_config.php b/pandora_console/include/functions_config.php index d55eda62e5..8875f7ade9 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2676,6 +2676,11 @@ function config_check() if (license_free()) { $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->checkCronRunning(); } } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index f3fdca5874..03fb56489a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4305,6 +4305,7 @@ div#dialog_messages table th:last-child { position: absolute; width: 400px; margin-top: -5px; + border-radius: 5px; } #notification-wrapper::before { content: ""; @@ -4338,12 +4339,15 @@ div#dialog_messages table th:last-child { background: whitesmoke; height: 100px; margin: 7px; - border: #cccccc solid 1px; + border: #e4e4e4 solid 1px; display: flex; flex-flow: row nowrap; align-items: center; padding: 5px; } +.notification-item:hover { + border: #ccc solid 1px; +} .notification-item > * { padding-left: 15px; pointer-events: none; @@ -4357,6 +4361,9 @@ div#dialog_messages table th:last-child { width: 87%; display: flex; flex-flow: column nowrap; + overflow: hidden; + max-height: 83px; + line-height: 1.4em; } .notification-item img { max-width: 100%; From 8c09b945c776688d2f91b1429b13a582d8c0ed9b Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 11:14:48 +0100 Subject: [PATCH 131/262] minor fix changed customer check Former-commit-id: f2659c9e7780dcddaa9528b1aa13a4d61026c154 --- pandora_console/include/functions_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 8875f7ade9..2a301affd9 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -2673,7 +2673,7 @@ function config_check() include_once __DIR__.'/class/ConsoleSupervisor.php'; // Enterprise customers launch supervisor using discovery task. - if (license_free()) { + if (enterprise_installed() === false) { $supervisor = new ConsoleSupervisor(false); $supervisor->run(); } else if ($config['cron_last_run'] == 0 From 1b82a970b1a55b6e7eb5d9101ebdbd94023e34e0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 14:36:16 +0100 Subject: [PATCH 132/262] WIP: App wiz Former-commit-id: aa969dc2fead693977959374c747f046676c5fed --- pandora_console/godmode/servers/discovery.php | 16 ++++++++++++++++ .../godmode/wizards/HostDevices.class.php | 18 ------------------ .../godmode/wizards/Wizard.main.php | 14 +++++++++++--- .../include/class/ConsoleSupervisor.php | 8 ++++++++ pandora_console/include/functions_messages.php | 2 +- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 97b9b8a884..e7922c881a 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -33,6 +33,9 @@ function get_wiz_class($str) case 'tasklist': return 'DiscoveryTaskList'; + case 'app': + return 'Applications'; + default: // Ignore. return null; @@ -50,6 +53,19 @@ foreach ($classes as $classpath) { include_once $classpath; } +// Load enterprise wizards. +if (enterprise_installed() === true) { + $enterprise_classes = glob( + $config['homedir'].'/'.ENTERPRISE_DIR.'/wizards/*.class.php' + ); + foreach ($enterprise_classes as $classpath) { + $r = enterprise_include_once( + 'wizards/'.basename($classpath) + ); + } +} + +$classes = array_merge($classes, $enterprise_classes); $wiz_in_use = get_parameter('wiz', null); $page = get_parameter('page', 0); diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 8dcf6d9a1e..88b9a2fa7e 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -156,24 +156,6 @@ class HostDevices extends Wizard } - /** - * Checks if environment is ready, - * returns array - * icon: icon to be displayed - * label: label to be displayed - * - * @return array With data. - **/ - public function load() - { - return [ - 'icon' => $this->icon, - 'label' => $this->label, - 'url' => $this->url, - ]; - } - - // Extra methods. diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 2f58bea91e..3a7fea7cf0 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -92,12 +92,20 @@ class Wizard /** - * To be overwritten. + * Checks if environment is ready, + * returns array + * icon: icon to be displayed + * label: label to be displayed * - * @return void - */ + * @return array With data. + **/ public function load() { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + ]; } diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 88dbf0f11f..95a5ff1086 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -340,6 +340,14 @@ class ConsoleSupervisor enterprise_hook('cron_supervisor_release_lock'); } + /* + * Check if CRON is running. + * NOTIF.CRON.CONFIGURED + */ + if (enterprise_installed()) { + $this->checkCronRunning(); + } + } diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index 3fb907ab06..5374fb7b1e 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -375,7 +375,7 @@ function messages_get_count( tnotification_source ns LEFT JOIN tnotification_source_user nsu ON ns.id=nsu.id_source - AND nsu.id_user="test") + AND nsu.id_user="%s") ON tm.id_source=ns.id', $user ); From 2c3357ac64fb6f02c37411c863df0d73524df23e Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 19 Feb 2019 16:06:41 +0100 Subject: [PATCH 133/262] Added interval input to Wizards Former-commit-id: ad64615eed06f025654d7875a3b572b865364d37 --- pandora_console/godmode/wizards/Wizard.main.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 3afd31d332..d23f533626 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -358,6 +358,19 @@ class Wizard case 'switch': return html_print_switch($data); + case 'interval': + return html_print_extended_select_for_time( + $data['name'], + $data['value'], + ((isset($data['script']) === true) ? $data['script'] : ''), + ((isset($data['nothing']) === true) ? $data['nothing'] : ''), + ((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0), + ((isset($data['size']) === true) ? $data['size'] : false), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['style']) === true) ? $data['selected'] : false), + ((isset($data['unique']) === true) ? $data['unique'] : false) + ); + default: // Ignore. break; @@ -518,8 +531,7 @@ class Wizard * * @return void Print the full list. */ - public static function printBigButtonsList($list_data) - { + public static function printBigButtonsList($list_data){ echo '
    '; array_map('self::printBigButtonElement', $list_data); echo '
'; From ea70c0846c82281607016e69d369e62dc8275bdc Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 19 Feb 2019 16:34:11 +0100 Subject: [PATCH 134/262] Added href in wizard Former-commit-id: 9b6b9e66d14257163f14bc904d5b13c6de9f9912 --- .../godmode/wizards/HostDevices.class.php | 18 +++++++++--------- pandora_console/include/styles/discovery.css | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 8dcf6d9a1e..f7a9b22e21 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -92,7 +92,7 @@ class HostDevices extends Wizard $mode = get_parameter('mode', null); if ($mode === null) { - $this->setBreadcrum(['']); + $this->setBreadcrum(['
    Host & devices
']); $this->printHeader(); $this->printBigButtonsList( [ @@ -117,8 +117,8 @@ class HostDevices extends Wizard if ($mode == 'importcsv') { $this->setBreadcrum( [ - '', - '', + '
    Host & devices
', + '
      Import CSV
', ] ); $this->printHeader(); @@ -128,20 +128,20 @@ class HostDevices extends Wizard } if ($mode == 'netscan') { - if ($this->page != 3) { + if ($this->page != 2) { // Do not paint breadcrum in last page. Redirected. $this->setBreadcrum( [ - '', - '', + '
    Host & devices
', + '
    Net scan definition
', ] ); if ($this->page == 1) { $this->setBreadcrum( [ - '', - '', - '', + '
    Host & devices
', + '
    Net scan definition
', + '
    Net scan features
', ] ); } diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index ad85fd606c..7c5933aba9 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -61,8 +61,7 @@ div.data_container:hover { display: inline-block; position: relative; background: #82b92e; - width: 15%; - padding: 1%; + padding: 14px; margin-left: 20px; margin-bottom: 10px; } From e7abe4ad4372158206e47b628c9f17f8cfea2ac4 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 17:59:02 +0100 Subject: [PATCH 135/262] Wiz.Applications SQL updates Former-commit-id: e0f547a0f35b338705a14df6477bf3a5461d8e49 --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + pandora_console/pandoradb.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index c86c9bf7d6..2352cf2a66 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1409,6 +1409,7 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; ALTER TABLE trecon_task ADD `auth_strings` text; ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; +ALTER TABLE trecon_task ADD `task_type` tinyint(2) NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index ae780a5470..34d843bb44 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -785,6 +785,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `wmi_enabled` tinyint(1) unsigned DEFAULT '0', `auth_strings` text, `autoconfiguration_enabled` tinyint(1) unsigned default '0', + `task_type` tinyint(2) NOT NULL default '0', PRIMARY KEY (`id_rt`), KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 86d57f26540d287b884da9ea1bed7f11ba402fe2 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 19 Feb 2019 18:23:20 +0100 Subject: [PATCH 136/262] Added callback to print forms Former-commit-id: e8f113710158278cb61f494a6c0111e1615ab877 --- pandora_console/godmode/wizards/Wizard.main.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index d23f533626..78ea5d7be3 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -473,6 +473,8 @@ class Wizard $form = $data['form']; $inputs = $data['inputs']; $js = $data['js']; + $cb_function = $data['cb_function']; + $cb_args = $data['cb_args']; $output = ''; @@ -483,6 +485,17 @@ class Wizard $output .= $this->printBlock($input, true); } + try { + if (isset($cb_function) === true) { + call_user_func( + $cb_function, + (isset($cb_args) === true) ? $cb_args : [] + ); + } + } catch (Exception $e) { + error_log('Error executing wizard callback: ', $e->getMessage()); + } + $output .= ''; $output .= ''; $output .= ''; From 819910923f4c5c4070411f381d801a486a924d57 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 19 Feb 2019 18:29:59 +0100 Subject: [PATCH 137/262] Added callback to print forms Former-commit-id: 8e95ba3ae518a750d421fcce41238ca7f47b46c2 --- .../godmode/wizards/Wizard.main.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 78ea5d7be3..5c7fbb60a5 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -476,13 +476,11 @@ class Wizard $cb_function = $data['cb_function']; $cb_args = $data['cb_args']; - $output = '
'; + $output_head = ''; - $output .= '
    '; - - foreach ($inputs as $input) { - $output .= $this->printBlock($input, true); + if ($return === false) { + echo $output_head; } try { @@ -496,6 +494,12 @@ class Wizard error_log('Error executing wizard callback: ', $e->getMessage()); } + $output = '
      '; + + foreach ($inputs as $input) { + $output .= $this->printBlock($input, true); + } + $output .= '
    '; $output .= ''; $output .= ''; @@ -504,7 +508,7 @@ class Wizard echo $output; } - return $output; + return $output_head.$output; } From 422708c04a59af4bcf118dab6a9b42f02239d54a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 18:33:17 +0100 Subject: [PATCH 138/262] Revert "Wiz.Applications SQL updates" Identification using recon_script This reverts commit e7abe4ad4372158206e47b628c9f17f8cfea2ac4 [formerly e0f547a0f35b338705a14df6477bf3a5461d8e49]. Former-commit-id: 5b112c7d889d98c2040514556849ce4e408ab444 --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 - pandora_console/pandoradb.sql | 1 - 2 files changed, 2 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 2352cf2a66..c86c9bf7d6 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1409,7 +1409,6 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; ALTER TABLE trecon_task ADD `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; ALTER TABLE trecon_task ADD `auth_strings` text; ALTER TABLE trecon_task ADD `autoconfiguration_enabled` tinyint(1) unsigned default '0'; -ALTER TABLE trecon_task ADD `task_type` tinyint(2) NOT NULL default '0'; -- --------------------------------------------------------------------- -- Table `twidget` AND Table `twidget_dashboard` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 34d843bb44..ae780a5470 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -785,7 +785,6 @@ CREATE TABLE IF NOT EXISTS `trecon_task` ( `wmi_enabled` tinyint(1) unsigned DEFAULT '0', `auth_strings` text, `autoconfiguration_enabled` tinyint(1) unsigned default '0', - `task_type` tinyint(2) NOT NULL default '0', PRIMARY KEY (`id_rt`), KEY `recon_task_daemon` (`id_recon_server`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From 55af128cd599cc49274e9a4873b2a61fd848a6b7 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 19 Feb 2019 20:14:14 +0100 Subject: [PATCH 139/262] Modified snmp browser to work with wizard Former-commit-id: c8d37e06967ed43867320ae89fd3dc2bede7b0ce --- pandora_console/godmode/wizards/Wizard.main.php | 2 +- pandora_console/include/functions_snmp_browser.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 5c7fbb60a5..b191223770 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -485,7 +485,7 @@ class Wizard try { if (isset($cb_function) === true) { - call_user_func( + call_user_func_array( $cb_function, (isset($cb_args) === true) ? $cb_args : [] ); diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 57bc416c76..714d394b4a 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) { static $url = false; @@ -106,7 +106,9 @@ 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) ? '' : '_'.$level; + $checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix; + echo html_print_checkbox($checkbox_name, 0, false, true, false, '').' '.$level.''; if (isset($sub_level['__VALUE__'])) { echo ''; } @@ -114,7 +116,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] echo ''; // Recursively print sub levels - snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array); + snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix); $count++; } @@ -838,7 +840,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 +853,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; From fa3f548cdd35b607e1605d7ee5c6107449258404 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 19 Feb 2019 20:27:05 +0100 Subject: [PATCH 140/262] Several changes for Wiz.App support Former-commit-id: 7c86d2e601771686a69d3f1b846638a427a25d6e --- .../wizards/DiscoveryTaskList.class.php | 27 ++++++++++- .../godmode/wizards/Wizard.main.php | 46 +++++++++++++++++++ .../include/class/ConsoleSupervisor.php | 3 +- 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index d0c5da17fb..e135c80672 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -292,8 +292,13 @@ class DiscoveryTaskList extends Wizard $data[7] = ui_print_timestamp($task['utimestamp'], true); if (check_acl($config['id_user'], $task['id_group'], 'PM')) { + // Check if is a H&D, Cloud or Application. $data[8] = ''.html_print_image( 'images/wrench_orange.png', true @@ -348,4 +353,24 @@ class DiscoveryTaskList extends Wizard } + /** + * Return target url sub-string to edit target task. + * + * @param array $task With all data. + * + * @return string + */ + public function getTargetWiz($task) + { + // TODO: Do not use description. Use recon_script ID instead. + switch ($task['description']) { + case 'Discovery.Application.VMware': + return 'wiz=app&mode=vmware'; + + default: + return 'wiz=hd&mode=netscan'; + } + } + + } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 2f58bea91e..31e494a737 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -80,6 +80,52 @@ class Wizard } + /** + * Setter for label + * + * @param string $str Label. + * + * @return void + */ + public function setLabel(string $str) + { + $this->label = $str; + } + + + /** + * Getter for label + * + * @return array Breadcrum. + */ + public function getLabel() + { + return $this->label; + } + + + /** + * Builder for breadcrum + * + * @param array $urls Array of urls to be stored in breadcrum. + * + * @return void + */ + public function prepareBreadcrum(array $urls) + { + $bc = []; + $i = 0; + foreach ($urls as $url) { + $bc[$i] = ''; + $bc[$i] .= '
    '.$url['label'].'
    '; + $bc[$i++] .= '
    '; + } + + $this->setBreadcrum($bc); + + } + + /** * To be overwritten. * diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 88dbf0f11f..fa40994962 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -2101,7 +2101,7 @@ class ConsoleSupervisor $message_conf_cron = __('DiscoveryConsoleTasks is not running properly'); if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { $message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service'); - $message_conf_cron .= ' '.__('Please, add the following line to your crontab file:'); + $message_conf_cron .= '. '.__('Please, add the following line to your crontab file:'); $message_conf_cron .= '
    * * * * * <user> wget -q -O - --no-check-certificate ';
                     $message_conf_cron .= str_replace(
                         ENTERPRISE_DIR.'/meta/',
    @@ -2116,6 +2116,7 @@ class ConsoleSupervisor
                 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(
    
    From 3d2ae475431b63b87bd42bec933af670a86ce1b0 Mon Sep 17 00:00:00 2001
    From: manuel 
    Date: Wed, 20 Feb 2019 08:41:15 +0100
    Subject: [PATCH 141/262] Added prepareBreadcrum function
    
    Former-commit-id: caf781a20bdd16bed7347bf755e2bf0da6ae7e99
    ---
     .../godmode/wizards/HostDevices.class.php     | 74 ++++++++++++++++---
     1 file changed, 63 insertions(+), 11 deletions(-)
    
    diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php
    index f7a9b22e21..83f5d21b4c 100755
    --- a/pandora_console/godmode/wizards/HostDevices.class.php
    +++ b/pandora_console/godmode/wizards/HostDevices.class.php
    @@ -92,7 +92,15 @@ class HostDevices extends Wizard
             $mode = get_parameter('mode', null);
     
             if ($mode === null) {
    -            $this->setBreadcrum(['
        Host & devices
    ']); + $this->prepareBreadcrum( + [ + [ + 'link' => $this->url.'&wiz=hd', + 'label' => __('    Host & devices'), + ], + ] + ); + $this->printHeader(); $this->printBigButtonsList( [ @@ -115,10 +123,16 @@ class HostDevices extends Wizard if (enterprise_installed()) { if ($mode == 'importcsv') { - $this->setBreadcrum( + $this->prepareBreadcrum( [ - '
        Host & devices
    ', - '
          Import CSV
    ', + [ + 'link' => $this->url.'&wiz=hd', + 'label' => __('    Host & devices'), + ], + [ + 'link' => $this->url.'&wiz=hd&mode=importcsv', + 'label' => __('      Import CSV'), + ], ] ); $this->printHeader(); @@ -130,18 +144,34 @@ class HostDevices extends Wizard if ($mode == 'netscan') { if ($this->page != 2) { // Do not paint breadcrum in last page. Redirected. - $this->setBreadcrum( + $this->prepareBreadcrum( [ - '
        Host & devices
    ', - '
        Net scan definition
    ', + [ + 'link' => $this->url.'&wiz=hd', + 'label' => __('    Host & devices'), + ], + [ + 'link' => $this->url.'&wiz=hd&mode=netscan', + 'label' => __('      Net scan definition'), + ], ] ); + if ($this->page == 1) { - $this->setBreadcrum( + $this->prepareBreadcrum( [ - '
        Host & devices
    ', - '
        Net scan definition
    ', - '
        Net scan features
    ', + [ + 'link' => $this->url.'&wiz=hd', + 'label' => __('    Host & devices'), + ], + [ + 'link' => $this->url.'&wiz=hd&mode=netscan', + 'label' => __('      Net scan definition'), + ], + [ + 'link' => $this->url.'&wiz=hd&mode=netscan&page=1', + 'label' => __('      Net scan features'), + ], ] ); } @@ -1096,4 +1126,26 @@ $(function() { } + /** + * Builder for breadcrum + * + * @param array $urls Array of urls to be stored in breadcrum. + * + * @return void + */ + public function prepareBreadcrum(array $urls) + { + $bc = []; + $i = 0; + foreach ($urls as $url) { + $bc[$i] = ''; + $bc[$i] .= '
    '.$url['label'].'
    '; + $bc[$i++] .= '
    '; + } + + $this->setBreadcrum($bc); + + } + + } From ca243c46fbdfc35198d2561e8709288e3d0a6feb Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 20 Feb 2019 08:52:29 +0100 Subject: [PATCH 142/262] Minor fix Former-commit-id: f3c550c07a38df24b5de84200190583437586720 --- pandora_console/include/functions_snmp_browser.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 714d394b4a..9354d4adfd 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -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,7 +106,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] echo ''; } - $checkbox_name_sufix = ($sufix) ? '' : '_'.$level; + $checkbox_name_sufix = ($sufix === true) ? '_'.$level : ''; $checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix; echo html_print_checkbox($checkbox_name, 0, false, true, false, '').' '.$level.''; if (isset($sub_level['__VALUE__'])) { @@ -115,7 +115,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] echo '
  • '; - // Recursively print sub levels + // Recursively print sub levels. snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix); $count++; From e9d97e8010d1eb73a43d487e6503e78a725ce70d Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 10:53:54 +0100 Subject: [PATCH 143/262] Wiz. Added option url to printGoBackButton Former-commit-id: 31c9c56da3475f9b1510904ad7237f993c0a6ccf --- pandora_console/godmode/wizards/Wizard.main.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 31e494a737..ebee7c9c03 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -402,13 +402,17 @@ class Wizard * * @return void */ - public function printGoBackButton() + public function printGoBackButton($url) { + if (isset($url) === false) { + $url = 'index.php?sec=gservers&sec2=godmode/servers/discovery'; + } + $form = [ 'form' => [ 'method' => 'POST', 'action' => ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/discovery' + $url ), ], 'inputs' => [ From 65db8482c1645191f16b1d730b7b4ed75ef2dd80 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 10:58:56 +0100 Subject: [PATCH 144/262] Wiz. Added option url to printGoBackButton Former-commit-id: fd0c76ce5efef9902cbda2817b13e59e6672c972 --- pandora_console/godmode/wizards/Wizard.main.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index ebee7c9c03..d2ee440a67 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -405,15 +405,15 @@ class Wizard public function printGoBackButton($url) { if (isset($url) === false) { - $url = 'index.php?sec=gservers&sec2=godmode/servers/discovery'; + $url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery' + ); } $form = [ 'form' => [ 'method' => 'POST', - 'action' => ui_get_full_url( - $url - ), + 'action' => $url, ], 'inputs' => [ [ From a63e497497e60fc5ed91872832a88de1a043bb1c Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 11:11:26 +0100 Subject: [PATCH 145/262] Wiz. Added textarea input Former-commit-id: 319ab37377e6649c1cd6c6adea1e956e934f2e23 --- pandora_console/godmode/wizards/Wizard.main.php | 11 +++++++++++ pandora_console/include/styles/wizard.css | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index d2ee440a67..21731a4bf8 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -388,6 +388,17 @@ class Wizard case 'switch': return html_print_switch($data); + case 'textarea': + return html_print_textarea( + $data['name'], + $data['rows'], + $data['columns'], + ((isset($data['value']) === true) ? $data['value'] : ''), + ((isset($data['attributes']) === true) ? $data['attributes'] : ''), + ((isset($data['return']) === true) ? $data['return'] : false), + ((isset($data['class']) === true) ? $data['class'] : '') + ); + default: // Ignore. break; diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css index 912f5d5a4f..869ea85f2c 100644 --- a/pandora_console/include/styles/wizard.css +++ b/pandora_console/include/styles/wizard.css @@ -10,6 +10,12 @@ ul.wizard li { } ul.wizard li > label:not(.p-switch) { + width: 250px; + vertical-align: top; + display: inline-block; +} + +ul.wizard li > textarea { width: 250px; display: inline-block; } From f19bdf956e800c31ceaf12790ae0e1e4da502d02 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 12:32:12 +0100 Subject: [PATCH 146/262] Wiz. minor fix default value url in goback button Former-commit-id: 434b2acb09290f11c8804024adb8834b86eeda73 --- pandora_console/godmode/wizards/Wizard.main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 21731a4bf8..65a526cc58 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -413,7 +413,7 @@ class Wizard * * @return void */ - public function printGoBackButton($url) + public function printGoBackButton($url=null) { if (isset($url) === false) { $url = ui_get_full_url( From e088b412cd831bd669850c690984f1ae6ffc2f9a Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 20 Feb 2019 13:55:21 +0100 Subject: [PATCH 147/262] Added preload schecked values into snmp browser treeview Former-commit-id: d8a3317d849263ff732cbf3a7a7714f4b41917d5 --- pandora_console/include/functions_snmp_browser.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 9354d4adfd..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=[], $sufix=false) +function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[], $sufix=false, $checked=[]) { static $url = false; @@ -108,7 +108,8 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] $checkbox_name_sufix = ($sufix === true) ? '_'.$level : ''; $checkbox_name = 'create_'.$sub_id.$checkbox_name_sufix; - echo html_print_checkbox($checkbox_name, 0, false, true, false, '').' '.$level.''; + $status = (!empty($checked) && isset($checked[$level])); + echo html_print_checkbox($checkbox_name, 0, $status, true, false, '').' '.$level.''; if (isset($sub_level['__VALUE__'])) { echo ''; } @@ -116,7 +117,7 @@ function snmp_browser_print_tree($tree, $id=0, $depth=0, $last=0, $last_array=[] echo ''; // Recursively print sub levels. - snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix); + snmp_browser_print_tree($sub_level, $sub_id, ($depth + 1), ($count == $total ? 1 : 0), $last_array, $sufix, $checked); $count++; } From 4834561e873d6117197ef697eaa7c683f30a2359 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 14:38:00 +0100 Subject: [PATCH 148/262] Wiz. minor fixes Former-commit-id: b3963bf5994a8f9829922e0a1b0be3a20fc54fba --- .../godmode/wizards/HostDevices.class.php | 12 ++++- .../godmode/wizards/Wizard.main.php | 44 ++++++++++++++++++- pandora_console/include/styles/discovery.css | 10 ++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 83f5d21b4c..b5f635eb40 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -690,6 +690,14 @@ class HostDevices extends Wizard 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url, ]; + // Default. + $interval = 600; + $unit = 60; + if (isset($this->task['interval_sweep']) === true) { + $interval = $this->task['interval_sweep']; + $unit = $this->getTimeUnit($interval); + } + $form['js'] = ' $("select#interval_manual_defined").change(function() { if ($("#interval_manual_defined").val() == 1) { @@ -700,8 +708,8 @@ $("select#interval_manual_defined").change(function() { else { $("#interval_manual_container").show(); $("#text-interval_text").val(10); - $("#hidden-interval").val(600); - $("#interval_units").val(60); + $("#hidden-interval").val('.$interval.'); + $("#interval_units").val('.$unit.'); } }).change();'; diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 65a526cc58..638228c365 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -104,6 +104,40 @@ class Wizard } + /** + * Return units associated to target interval (in seconds). + * + * @param integer $interval Target interval. + * + * @return integer Unit. + */ + public function getTimeUnit($interval) + { + $units = [ + 1, + 60, + 3600, + 86400, + 604800, + 2592000, + 31104000, + ]; + + $size = count($units); + for ($i = 0; $i < $size; $i++) { + if ($interval < $units[$i]) { + if (($i - 1) < 0) { + return 1; + } + + return $units[($i - 1)]; + } + } + + return $units[-1]; + } + + /** * Builder for breadcrum * @@ -116,9 +150,15 @@ class Wizard $bc = []; $i = 0; foreach ($urls as $url) { + if ($url['selected'] == 1) { + $class = 'selected'; + } else { + $class = ''; + } + $bc[$i] = ''; - $bc[$i] .= '
    '.$url['label'].'
    '; - $bc[$i++] .= '
    '; + $bc[$i] .= '
    '.$url['label']; + $bc[$i++] .= '
    '; } $this->setBreadcrum($bc); diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 7c5933aba9..aebb0a3d0d 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -60,7 +60,7 @@ div.data_container:hover { .arrow_box { display: inline-block; position: relative; - background: #82b92e; + background: #ccc; padding: 14px; margin-left: 20px; margin-bottom: 10px; @@ -75,6 +75,9 @@ div.data_container:hover { position: absolute; pointer-events: none; } +.arrow_box.selected { + background: #82b92e; +} .arrow_box:after { left: 0%; @@ -84,7 +87,10 @@ div.data_container:hover { } .arrow_box:before { left: 100%; - border-left-color: #82b92e; + border-left-color: #ccc; border-width: 20px; margin-top: -20px; } +.arrow_box.selected:before { + border-left-color: #82b92e; +} From f49b26692e796b3d6859c0f73f50953cafd9b5bb Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 20 Feb 2019 16:47:29 +0100 Subject: [PATCH 149/262] Fixes on wizards Former-commit-id: 98804bde49e19a7ecb3e2749a8955ac656da54a8 --- .../godmode/wizards/HostDevices.class.php | 22 ------------------ .../godmode/wizards/Wizard.main.php | 23 ++++++++++++------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 83f5d21b4c..538969e6ef 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -1126,26 +1126,4 @@ $(function() { } - /** - * Builder for breadcrum - * - * @param array $urls Array of urls to be stored in breadcrum. - * - * @return void - */ - public function prepareBreadcrum(array $urls) - { - $bc = []; - $i = 0; - foreach ($urls as $url) { - $bc[$i] = ''; - $bc[$i] .= '
    '.$url['label'].'
    '; - $bc[$i++] .= '
    '; - } - - $this->setBreadcrum($bc); - - } - - } diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index c0ae95504c..de6ed6b525 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -83,17 +83,17 @@ class Wizard /** * Add an element to breadcrum array. * - * @param string $string Element to add to breadcrum. + * @param string $breads Elements to add to breadcrum. * * @return void */ - protected function addBreadcrum($string) + protected function addBreadcrum($breads) { - if (empty($string)) { + if (empty($breads)) { return; } - array_push($this->breadcrum, $string); + $this->breadcrum = array_merge($this->breadcrum, $breads); } @@ -124,21 +124,28 @@ class Wizard /** * Builder for breadcrum * - * @param array $urls Array of urls to be stored in breadcrum. + * @param array $urls Array of urls to be stored in breadcrum. + * @param boolean $add True if breadcrum should be added instead of + * overwrite it. * * @return void */ - public function prepareBreadcrum(array $urls) + public function prepareBreadcrum(array $urls, bool $add=false) { $bc = []; $i = 0; foreach ($urls as $url) { - $bc[$i] = ''; + $href = (isset($url['link']) === true) ? 'href="'.$url['link'].'"' : ''; + $bc[$i] = ''; $bc[$i] .= '
    '.$url['label'].'
    '; $bc[$i++] .= '
    '; } - $this->setBreadcrum($bc); + if ($add === true) { + $this->addBreadcrum($bc); + } else { + $this->setBreadcrum($bc); + } } From eb3adfb6fb016e5e7fedd5385aa789efb9dfc9ae Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 17:17:24 +0100 Subject: [PATCH 150/262] Data update. added recon scripts app.vmware and cloud Former-commit-id: 1fa41a16848794846fee6b5da510bd49aa7b51b1 --- .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 6 ++++++ pandora_console/pandoradb_data.sql | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index c86c9bf7d6..6827938b42 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1997,3 +1997,9 @@ CREATE TABLE `tnotification_source_group_user` ( -- Add alert command 'Generate notification' -- ---------------------------------------------------------------------- INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); + +-- ---------------------------------------------------------------------- +-- Add custom internal recon scripts +-- ---------------------------------------------------------------------- +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware_plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index a8e378042c..8fa08b7074 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1130,9 +1130,11 @@ INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (2, 'Monitoring&#x INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (3, 'Monitoring Report Alerts', 'select t1.alias as agent_name, t2.nombre as module_name, (select talert_templates.name from talert_templates where talert_templates.id = t3.id_alert_template) as template, (select group_concat(t02.name) from talert_template_module_actions as t01 inner join talert_actions as t02 on t01.id_alert_action = t02.id where t01.id_alert_template_module = t3.id group by t01.id_alert_template_module) as actions from tagente as t1 inner join tagente_modulo as t2 on t1.id_agente = t2.id_agente inner join talert_template_modules as t3 on t2.id_agente_modulo = t3.id_agent_module order by agent_name, module_name;'); INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group view', 'select t1.nombre, (select count(t3.id_agente) from tagente as t3 where t1.id_grupo = t3.id_grupo) as agents, (SELECT COUNT(t4.id_agente) FROM tagente as t4 WHERE t4.id_grupo = t1.id_grupo AND t4.disabled = 0 AND t4.ultimo_contacto < NOW() - (intervalo / (1/2))) as agent_unknown, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100) AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval / (1/2))) as monitor_unknow, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24) AND utimestamp = 0) as monitor_no_init, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 0 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24)))) as monitor_ok, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0) as monitor_critical, (SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente WHERE tagente.id_grupo = t1.id_grupo AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND times_fired > 0) as monitor_alert_fired from tgrupo as t1 where 0 < (select count(t2.id_agente) from tagente as t2 where t1.id_grupo = t2.id_grupo)'); +-- trecon scripts INSERT INTO `trecon_script` VALUES (2,'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es> Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4> * custom_field1 = Network i.e.: 192.168.100.0/24 * custom_field2 = Username * custom_field3 = Password * custom_field4 = Additional parameters i.e.: -D LAN_2_0','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5. These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'); - INSERT INTO `trecon_script` VALUES (5,'WMI Recon Script','This script is used to automatically gather host information via WMI. Available parameters: * Network = network to scan (e.g. 192.168.100.0/24). * WMI auth = comma separated list of WMI authentication tokens in the format username%password (e.g. Administrador%pass). See the documentation for more information.','/usr/share/pandora_server/util/recon_scripts/wmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"WMI auth\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware_plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"true\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_'); From 08c6d782a4bfc1b463ebf31ce4daa5e3ac4e9639 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 18:24:32 +0100 Subject: [PATCH 151/262] Add menuentry discovery Former-commit-id: bc40f0bda89947a88a912484642aa3c89ded64f8 --- pandora_console/godmode/menu.php | 21 +++++++++++++----- pandora_console/images/discovery-100.png | Bin 0 -> 1403 bytes .../images/discovery_green-100.png | Bin 0 -> 1493 bytes pandora_console/images/gm_discovery.menu.png | Bin 0 -> 311 bytes .../images/gm_discovery_green.menu.png | Bin 0 -> 381 bytes pandora_console/include/styles/menu.css | 3 +++ .../lib/PandoraFMS/DiscoveryServer.pm | 14 +++++++++++- 7 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 pandora_console/images/discovery-100.png create mode 100644 pandora_console/images/discovery_green-100.png create mode 100644 pandora_console/images/gm_discovery.menu.png create mode 100644 pandora_console/images/gm_discovery_green.menu.png diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 1c369db688..0ed041d680 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -21,6 +21,21 @@ require_once 'include/functions_menu.php'; $menu_godmode = []; $menu_godmode['class'] = 'godmode'; + +if (check_acl($config['id_user'], 0, 'PM')) { + $sub = []; + $sub['godmode/servers/discovery']['text'] = __('Discover'); + $sub['godmode/servers/discovery']['id'] = 'Discover'; + $sub['godmode/servers/discovery']['subsecs'] = ['godmode/servers/discovery']; + + // Add to menu. + $menu_godmode['discover']['text'] = __('Discovery'); + $menu_godmode['discover']['sec2'] = 'godmode/servers/discovery'; + $menu_godmode['discover']['id'] = 'god-discovery'; + $menu_godmode['discover']['sub'] = $sub; +} + + $sub = []; if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'AD')) { $sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents'); @@ -200,18 +215,12 @@ if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, ' $menu_godmode['gservers']['id'] = 'god-servers'; $sub = []; - if (check_acl($config['id_user'], 0, 'PM')) { - $sub['godmode/servers/discovery']['text'] = __('Discover'); - $sub['godmode/servers/discovery']['id'] = 'Discover'; - } if (check_acl($config['id_user'], 0, 'AW')) { $sub['godmode/servers/modificar_server']['text'] = __('Manage servers'); $sub['godmode/servers/modificar_server']['id'] = 'Manage servers'; } - - // This subtabs are only for Pandora Admin if (check_acl($config['id_user'], 0, 'PM')) { enterprise_hook('ha_cluster'); diff --git a/pandora_console/images/discovery-100.png b/pandora_console/images/discovery-100.png new file mode 100644 index 0000000000000000000000000000000000000000..7ec755e7eb6e72b7367a0e04122f49cc7248cffb GIT binary patch literal 1403 zcmV->1%&#EP)#DY#GL>-L7WMw)XH~`gRy@5y=Q%QK3@{Y!us^RUzS81 z5ybI$Ot60Tm>?Mwc6w#!VHD6g8AEow9slDo^ho!FY>yu?3%$}E8QJkO-Z1+U?1b!( zr|}$|x_>g3?9`+LuAD^}vK~X+iX(3V8q-BVA!~NDg}6g;T|ftp{2V5s*W42Fsz}H_ zm@Ic>@Ejvm{I^5|009m&a#etK@K_bHXmR94i-W%l!`iPp))GodfiDhLR8IH(siN;Ss~XN|5GQV@YF7C zLPVmbGgALpaPXZvcc=={wdHk%yc+})fsjh5JF!H_!SjG1sgQ|ksOx}`q^tTCL_)Mj z=ZW_qhb}$`8A8OU)E$|H1VO4w?Y%-wMrAHblx*hS#Z1Q-kUEBjqq0yWN(NVbR)~o+ z=XjBH^x(}F6oou$&O%(bl{>iU5zF0lW;;&$NJgSa!dADVG|1WZk&uOC=U7|rEC#_| zW&re&kXJ>8EOm(yL~MiEvSY5aiP0pYe`ZU;T%99k($dD#w2eN6y{7LUKD~G6kyq`S zk!c&gYFlyF=E|T{ax(c7OQ07H?EZBh6k@B>-YeODIjL@4@h>kH+Q|Aqh^$W??FBZ`D%hzZGD zPNefrhzLWI2sbiH3ZYQS9#JA>M1T-d3dsl%l9C`ql(0$cIPGd3NgUJx>sfpg0?B{y z?0y&N&)XUWg_wgEA#d4nIT#GSv4fXEF8R;w*g)|k-tv!QcX*bu`FvfY;(b%h3h6=} z+#HRC5_WADvuhp{m4cd(@1Dt6adV_vnPu1CM)EJTtoxBK1Qo)a_0+ILK4r&VB1A{6 z5Fbu(Cmgm38Rc#eQ?e$@(_;LM@D+uPn+Z}^zMm~7qK>(+{Z_&5xs2Ku{G=EOxp3$& zeu(JE8QDIA70e1LL)zTs2N(B0XSx!MNuh0c{aQS+n|9+`5>yItFxxK|$|!shBHEgt zdBzlz$x1MjQH#2EuAk8dAsKcuBpf^{giEE+!YqViqApWf!A2N($LHE}^@`Pn%BN_2}96VIPso zb7s&L(w4#IOd0bCKkjX*q)U^?yH literal 0 HcmV?d00001 diff --git a/pandora_console/images/discovery_green-100.png b/pandora_console/images/discovery_green-100.png new file mode 100644 index 0000000000000000000000000000000000000000..bcda80e4dd59f97c041d7377194ace1635ab5c08 GIT binary patch literal 1493 zcmV;`1uFW9P)tf;+&Ec`~lRN*aJv5ZpoT#&#; zyL)?kG9eM#_n%)ftmoc~5XO{l-srZUfcS^OApD>&u}wfc+ls?rHl={(*e>8KB6Z|+ z^HTZqk-o0Jef@n%3UP0zTogLj)r&+O4|G$PS>^Qo+vKv`rnqmV*m26xxULu!vTA`L zT-Pco#7`h^vKdv$HYvoeI&AKrfGDVgjWLFbAIo?GkX)995&2#scAyLJSQTRVOGFafcv4%tjg*i8bWHtv`! zd_*T}3T9k_K_R-6OR8XQ5)hbCd0m#Jqmq6C(()q_#R4K7gBubNI)i;v}cx0|h2Mh;suUH;&wyxwX02nInN*jzO2D88;ye$7i}~Q!oYOCf;ZmHd|Z>0 zpsw*qa2;E7cLRCe52XFkP@of5y-3utfQG@9@<7@b{D5AYDAuSVsvh7rLK0saxQ%j(Ah zqml+6ZDd+jffzIbh>C59FzQs&$D$A&7-Izgm9wgn90QPC6Gjm@455W;*1OVb_#SG~Pa1@Q)z6d^05Y%>Ja+aSy)5K;YHhW0

    sO>r literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_discovery.menu.png b/pandora_console/images/gm_discovery.menu.png new file mode 100644 index 0000000000000000000000000000000000000000..0f396c08c688a8b396bd2f6817ed999fa71774dc GIT binary patch literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^q9Dw{1|(OCFP#RYBuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrH1%-Sl*E45_%4l%OE==l}nDTLEc<0B#1};vf8s&sS!?`1_yZ zf&(wJ@V~`P-yL)ubi;#=Z_QYjqZA?>Clm#>#Hovg#Y+4)fs#he|H*gVLa==%*0pWpOffQ zVx93L literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_discovery_green.menu.png b/pandora_console/images/gm_discovery_green.menu.png new file mode 100644 index 0000000000000000000000000000000000000000..f4a387c201e5a8b4bdba6ee670bf1a5df143496d GIT binary patch literal 381 zcmV-@0fPRCP)Ixn)RBi~Vu?8?cEZ)r!rAPEN`UtT5`}n9*;_IFKS`W#o zz4)tE!iKsxDJ(Jy75P*W(pI%?O1I=W2ULKJ5Np^t>f5KKvg0zxts!vX5%t@12P!_53d^a7i0_@vjLr*?kmceM=NL-AQm2i~Wq^9a~ zN=VwQcEmeLrGv1vgYZJhxul78{"value"} . '"'; } } + + my $args = "$task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters"; + + # Depending of the recon_script type (name) should be invoked + # in different ways: + if ($script->{'name'} =~ /Discovery.App/i) { + # Discovery Application recon script. Imported from heavy server plugins. + # Instantiate configuration file. + + + } if (-x $command) { - `$command $task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters`; + `$command $args`; } else { logger ($pa_config, "Cannot execute recon task command $command."); } From 6a43536b3363f79406eb3afab4e148ffc8ad4b14 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 20 Feb 2019 19:30:25 +0100 Subject: [PATCH 152/262] Discovery. Added App.VMw Former-commit-id: 18a9300f37163048bd99109c08c1228231426a59 --- .../lib/PandoraFMS/DiscoveryServer.pm | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 89f1c6919a..e43f1ca05a 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -234,7 +234,13 @@ sub exec_recon_script ($$$) { # \r and \n should be escaped for decode_json(). $macros =~ s/\n/\\n/g; $macros =~ s/\r/\\r/g; - my $decoded_macros = decode_json (encode_utf8($macros)); + my $decoded_macros; + + if ($macros) { + eval { + $decoded_macros = decode_json(encode_utf8($macros)); + }; + } my $macros_parameters = ''; @@ -254,15 +260,12 @@ sub exec_recon_script ($$$) { } } - my $args = "$task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters"; - - # Depending of the recon_script type (name) should be invoked - # in different ways: - if ($script->{'name'} =~ /Discovery.App/i) { - # Discovery Application recon script. Imported from heavy server plugins. - # Instantiate configuration file. - - + my $ent_script = 0; + my $args = enterprise_hook('discovery_custom_recon_scripts',[$pa_config, $dbh, $task, $script]); + if (!$args) { + $args = "$task->{'id_rt'} $task->{'id_group'} $task->{'create_incident'} $macros_parameters"; + } else { + $ent_script = 1; } if (-x $command) { @@ -273,6 +276,10 @@ sub exec_recon_script ($$$) { # Only update the timestamp in case something went wrong. The script should set the status. db_do ($dbh, 'UPDATE trecon_task SET utimestamp = ? WHERE id_rt = ?', time (), $task->{'id_rt'}); + + if ($ent_script == 1) { + enterprise_hook('discovery_clean_custom_recon',[$pa_config, $dbh, $task, $script]); + } logger($pa_config, 'Done executing recon script ' . safe_output($script->{'name'}), 10); return 0; From ad3e2b88bf7d5ead87f43e2d741fbae7126f48e0 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 21 Feb 2019 11:19:38 +0100 Subject: [PATCH 153/262] Minor fixes Wiz.Discovery Former-commit-id: 750cd3ab1902ed3eda9806aa9b505d5e4a1175be --- pandora_console/godmode/servers/discovery.php | 48 +++- .../godmode/wizards/ConsoleTasks.class.php | 133 +++++++++++ .../godmode/wizards/HostDevices.class.php | 218 +++++++++--------- pandora_console/include/styles/discovery.css | 8 + .../include/styles/hostdevices.css | 3 + 5 files changed, 298 insertions(+), 112 deletions(-) create mode 100644 pandora_console/godmode/wizards/ConsoleTasks.class.php create mode 100644 pandora_console/include/styles/hostdevices.css diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 1ac048a9ed..261cdd0696 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -19,10 +19,11 @@ ui_print_page_header(__('Discover'), '', false, '', true); /** - * Undocumented function + * Mask class names. * - * @param [type] $str - * @return void + * @param string $str Wiz parameter. + * + * @return string Classname. */ function get_wiz_class($str) { @@ -39,6 +40,9 @@ function get_wiz_class($str) case 'app': return 'Applications'; + case 'ctask': + return 'ConsoleTasks'; + default: // Ignore. return null; @@ -46,6 +50,31 @@ function get_wiz_class($str) } +/** + * Aux. function to compare classpath names. + * + * @param string $a Classpath A. + * @param string $b Classpath B. + * + * @return string Matching one. + */ +function cl_load_cmp($a, $b) +{ + $str_a = basename($a, '.class.php'); + $str_b = basename($b, '.class.php'); + if ($str_a == $str_b) { + return 0; + } + + if ($str_a < $str_b) { + return -1; + } + + return 1; + +} + + /* * CLASS LOADER. */ @@ -79,8 +108,13 @@ if (enterprise_installed() === true) { } } +// Combine class paths. $classes = array_merge($classes, $enterprise_classes); +// Sort output. +uasort($classes, 'cl_load_cmp'); + +// Check user action. $wiz_in_use = get_parameter('wiz', null); $page = get_parameter('page', 0); @@ -110,7 +144,13 @@ if ($classname_selected === null) { foreach ($classes as $classpath) { $classname = basename($classpath, '.class.php'); $obj = new $classname(); - $wiz_data[] = $obj->load(); + + // DiscoveryTaskList must be first button. + if ($classname == 'DiscoveryTaskList') { + array_unshift($wiz_data, $obj->load()); + } else { + $wiz_data[] = $obj->load(); + } } Wizard::printBigButtonsList($wiz_data); diff --git a/pandora_console/godmode/wizards/ConsoleTasks.class.php b/pandora_console/godmode/wizards/ConsoleTasks.class.php new file mode 100644 index 0000000000..9c9e060fdf --- /dev/null +++ b/pandora_console/godmode/wizards/ConsoleTasks.class.php @@ -0,0 +1,133 @@ +setBreadcrum([]); + + $this->task = []; + $this->msg = $msg; + $this->icon = $icon; + $this->label = __($label); + $this->page = $page; + $this->url = ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=ctask' + ); + + return $this; + } + + + /** + * Implements run method. + * + * @return mixed Returns null if wizard is ongoing. Result if done. + */ + public function run() + { + global $config; + + // Load styles. + parent::run(); + echo 'hola'; + + for ($i = 0; $i < $this->MAXPAGES; $i++) { + $breadcrum[] = [ + 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=app&mode=vmware&page='.$i.'&task='.$this->task['id_rt'], + 'label' => $this->label.' '.$this->pageLabels[$i], + 'selected' => (($i == $this->page) ? 1 : 0), + ]; + } + + if ($this->page < $this->MAXPAGES) { + // Avoid to print header out of wizard. + $this->prepareBreadcrum($breadcrum); + $this->printHeader(); + } + + $this->printGoBackButton(); + return null; + + } + + + /** + * Implements load method. + * + * @return mixed Skeleton for button. + */ + public function load() + { + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + + ]; + } + + +} diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index d9765cf5c2..b7a41afa58 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -38,6 +38,24 @@ enterprise_include('include/class/CSVImportAgents.class.php'); class HostDevices extends Wizard { + /** + * Number of pages to control breadcrum. + * + * @var integer + */ + public $maxPagesNetScan = 2; + + /** + * Labels for breadcrum. + * + * @var array + */ + public $pageLabelsNetScan = [ + 'NetScan definition', + 'NetScan features', + + ]; + /** * Stores all needed parameters to create a recon task. * @@ -92,16 +110,6 @@ class HostDevices extends Wizard $mode = get_parameter('mode', null); if ($mode === null) { - $this->prepareBreadcrum( - [ - [ - 'link' => $this->url.'&wiz=hd', - 'label' => __('    Host & devices'), - ], - ] - ); - - $this->printHeader(); $this->printBigButtonsList( [ [ @@ -123,62 +131,12 @@ class HostDevices extends Wizard if (enterprise_installed()) { if ($mode == 'importcsv') { - $this->prepareBreadcrum( - [ - [ - 'link' => $this->url.'&wiz=hd', - 'label' => __('    Host & devices'), - ], - [ - 'link' => $this->url.'&wiz=hd&mode=importcsv', - 'label' => __('      Import CSV'), - ], - ] - ); - $this->printHeader(); $csv_importer = new CSVImportAgents($this->page, $this->breadcrum); return $csv_importer->runCSV(); } } if ($mode == 'netscan') { - if ($this->page != 2) { - // Do not paint breadcrum in last page. Redirected. - $this->prepareBreadcrum( - [ - [ - 'link' => $this->url.'&wiz=hd', - 'label' => __('    Host & devices'), - ], - [ - 'link' => $this->url.'&wiz=hd&mode=netscan', - 'label' => __('      Net scan definition'), - ], - ] - ); - - if ($this->page == 1) { - $this->prepareBreadcrum( - [ - [ - 'link' => $this->url.'&wiz=hd', - 'label' => __('    Host & devices'), - ], - [ - 'link' => $this->url.'&wiz=hd&mode=netscan', - 'label' => __('      Net scan definition'), - ], - [ - 'link' => $this->url.'&wiz=hd&mode=netscan&page=1', - 'label' => __('      Net scan features'), - ], - ] - ); - } - - $this->printHeader(); - } - return $this->runNetScan(); } @@ -257,53 +215,77 @@ class HostDevices extends Wizard } } - if (isset($this->task['id_rt']) === false) { - // Disabled 2 Implies wizard non finished. - $this->task['disabled'] = 2; - } - - if ($taskname == '') { - $this->msg = __('You must provide a task name.'); - return false; - } - - if ($server_id == '') { - $this->msg = __('You must select a Discovery Server.'); - return false; - } - - if ($network == '') { - // XXX: Could be improved validating provided network. - $this->msg = __('You must provide a valid network.'); - return false; - } - - if ($id_group == '') { - $this->msg = __('You must select a valid group.'); - return false; - } - - // Assign fields. - $this->task['name'] = $taskname; - $this->task['description'] = $comment; - $this->task['subnet'] = $network; - $this->task['id_recon_server'] = $server_id; - $this->task['id_group'] = $id_group; - $this->task['interval_sweep'] = $interval; - - if (isset($this->task['id_rt']) === false) { - // Create. - $this->task['id_rt'] = db_process_sql_insert( - 'trecon_task', - $this->task - ); + if ($task_id !== null + && $taskname == null + && $server_id == null + && $id_group == null + && $server == null + && $datacenter == '' + && $user == '' + && $pass == '' + && $encrypt == null + && $interval == 0 + ) { + // Default values, no data received. + // User is accesing directly to this page. + if (users_is_admin() !== true && check_acl( + $config['id_usuario'], + $this->task['id_group'], + 'PM' + ) !== true + ) { + $this->msg = __('You have no access to edit this task.'); + return false; + } } else { - // Update. - db_process_sql_update( - 'trecon_task', - $this->task, - ['id_rt' => $this->task['id_rt']] - ); + if (isset($this->task['id_rt']) === false) { + // Disabled 2 Implies wizard non finished. + $this->task['disabled'] = 2; + } + + if ($taskname == '') { + $this->msg = __('You must provide a task name.'); + return false; + } + + if ($server_id == '') { + $this->msg = __('You must select a Discovery Server.'); + return false; + } + + if ($network == '') { + // XXX: Could be improved validating provided network. + $this->msg = __('You must provide a valid network.'); + return false; + } + + if ($id_group == '') { + $this->msg = __('You must select a valid group.'); + return false; + } + + // Assign fields. + $this->task['name'] = $taskname; + $this->task['description'] = $comment; + $this->task['subnet'] = $network; + $this->task['id_recon_server'] = $server_id; + $this->task['id_group'] = $id_group; + $this->task['interval_sweep'] = $interval; + + if (isset($this->task['id_rt']) === false) { + // Create. + $this->task['id_rt'] = db_process_sql_insert( + 'trecon_task', + $this->task + ); + } else { + // Update. + db_process_sql_update( + 'trecon_task', + $this->task, + ['id_rt' => $this->task['id_rt']] + ); + } } return true; @@ -408,7 +390,6 @@ class HostDevices extends Wizard } return false; - } @@ -478,6 +459,25 @@ class HostDevices extends Wizard return null; } + $task_url = ''; + if (isset($this->task['id_rt'])) { + $task_url = '&task='.$this->task['id_rt']; + } + + for ($i = 0; $i < $this->maxPagesNetScan; $i++) { + $breadcrum[] = [ + 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page='.$i.$task_url, + 'label' => $this->pageLabelsNetScan[$i], + 'selected' => (($i == $this->page) ? 1 : 0), + ]; + } + + if ($this->page < $this->maxPagesNetScan) { + // Avoid to print header out of wizard. + $this->prepareBreadcrum($breadcrum); + $this->printHeader(); + } + if (isset($this->page) === true && $this->page != 0 && isset($this->task['id_rt']) === false @@ -698,7 +698,9 @@ $("select#interval_manual_defined").change(function() { // XXX: Could be improved validating inputs before continue (JS) // Print NetScan page 0. $this->printForm($form); - $this->printGoBackButton(); + $this->printGoBackButton( + $this->url.'&page='.($this->page - 1).$task_url + ); } } diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index aebb0a3d0d..2bc41163b6 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -94,3 +94,11 @@ div.data_container:hover { .arrow_box.selected:before { border-left-color: #82b92e; } +.arrow_box { + display: inline-block; + position: relative; + padding: 14px; + margin-left: 20px; + margin-bottom: 10px; + padding-left: 3em; +} diff --git a/pandora_console/include/styles/hostdevices.css b/pandora_console/include/styles/hostdevices.css new file mode 100644 index 0000000000..461327705e --- /dev/null +++ b/pandora_console/include/styles/hostdevices.css @@ -0,0 +1,3 @@ +/* + * TODO: This may be at hostdevices.css + */ From c385a3191f5ff71ccece04a8f8cbf68902f6ef55 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 21 Feb 2019 11:21:56 +0100 Subject: [PATCH 154/262] minor fixes Former-commit-id: ffb62390a5edaa158507f253cf7fb23c690f8fcf --- .../godmode/wizards/ConsoleTasks.class.php | 133 ------------------ 1 file changed, 133 deletions(-) delete mode 100644 pandora_console/godmode/wizards/ConsoleTasks.class.php diff --git a/pandora_console/godmode/wizards/ConsoleTasks.class.php b/pandora_console/godmode/wizards/ConsoleTasks.class.php deleted file mode 100644 index 9c9e060fdf..0000000000 --- a/pandora_console/godmode/wizards/ConsoleTasks.class.php +++ /dev/null @@ -1,133 +0,0 @@ -setBreadcrum([]); - - $this->task = []; - $this->msg = $msg; - $this->icon = $icon; - $this->label = __($label); - $this->page = $page; - $this->url = ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=ctask' - ); - - return $this; - } - - - /** - * Implements run method. - * - * @return mixed Returns null if wizard is ongoing. Result if done. - */ - public function run() - { - global $config; - - // Load styles. - parent::run(); - echo 'hola'; - - for ($i = 0; $i < $this->MAXPAGES; $i++) { - $breadcrum[] = [ - 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=app&mode=vmware&page='.$i.'&task='.$this->task['id_rt'], - 'label' => $this->label.' '.$this->pageLabels[$i], - 'selected' => (($i == $this->page) ? 1 : 0), - ]; - } - - if ($this->page < $this->MAXPAGES) { - // Avoid to print header out of wizard. - $this->prepareBreadcrum($breadcrum); - $this->printHeader(); - } - - $this->printGoBackButton(); - return null; - - } - - - /** - * Implements load method. - * - * @return mixed Skeleton for button. - */ - public function load() - { - return [ - 'icon' => $this->icon, - 'label' => $this->label, - 'url' => $this->url, - - ]; - } - - -} From 4148387c506a19ac2ff0d1afacf440b5ed669dac Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 13:05:48 +0100 Subject: [PATCH 155/262] Updates discovery Former-commit-id: e99072a2b7a1ddd528698e12bdfe75b0b56ba25b --- .../wizards/DiscoveryTaskList.class.php | 2 +- .../godmode/wizards/HostDevices.class.php | 30 +++++++++--------- pandora_console/images/wizard/csv_image.svg | 4 --- pandora_console/images/wizard/hostdevices.png | Bin 0 -> 1152 bytes pandora_console/images/wizard/hostdevices.svg | 4 --- pandora_console/images/wizard/netscan.png | Bin 0 -> 9083 bytes pandora_console/images/wizard/tasklist.png | Bin 0 -> 855 bytes pandora_console/images/wizard/tasklist.svg | 3 -- .../images/wizard/verde/hostdevices.png | Bin 0 -> 8256 bytes .../images/wizard/verde/tasklist.png | Bin 0 -> 1038 bytes pandora_console/include/styles/discovery.css | 1 + 11 files changed, 17 insertions(+), 27 deletions(-) delete mode 100644 pandora_console/images/wizard/csv_image.svg create mode 100644 pandora_console/images/wizard/hostdevices.png delete mode 100644 pandora_console/images/wizard/hostdevices.svg create mode 100644 pandora_console/images/wizard/netscan.png create mode 100644 pandora_console/images/wizard/tasklist.png delete mode 100644 pandora_console/images/wizard/tasklist.svg create mode 100644 pandora_console/images/wizard/verde/hostdevices.png create mode 100644 pandora_console/images/wizard/verde/tasklist.png diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e135c80672..0a7fa9b8e5 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -49,7 +49,7 @@ class DiscoveryTaskList extends Wizard public function __construct( int $page=0, string $msg='Default message. Not set.', - string $icon='images/wizard/tasklist.svg', + string $icon='images/wizard/tasklist.png', string $label='Task list' ) { $this->setBreadcrum([]); diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index b7a41afa58..ef98b09d3a 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -77,7 +77,7 @@ class HostDevices extends Wizard public function __construct( int $page=0, string $msg='Default message. Not set.', - string $icon='images/wizard/hostdevices.svg', + string $icon='images/wizard/hostdevices.png', string $label='Host & Devices' ) { $this->setBreadcrum([]); @@ -110,21 +110,21 @@ class HostDevices extends Wizard $mode = get_parameter('mode', null); if ($mode === null) { - $this->printBigButtonsList( - [ - [ - 'url' => $this->url.'&mode=importcsv', - 'icon' => 'images/wizard/csv_image.svg', - 'label' => __('Import CSV'), - ], - [ - 'url' => $this->url.'&mode=netscan', - 'icon' => 'images/wizard/csv_image.svg', - 'label' => __('Net Scan'), - ], - ] - ); + $buttons = []; + $buttons[] = [ + 'url' => $this->url.'&mode=netscan', + 'icon' => 'images/wizard/netscan.png', + 'label' => __('Net Scan'), + ]; + if (enterprise_installed()) { + $buttons[] = [ + 'url' => $this->url.'&mode=importcsv', + 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png', + 'label' => __('Import CSV'), + ]; + } + $this->printBigButtonsList($buttons); $this->printGoBackButton(); return; } diff --git a/pandora_console/images/wizard/csv_image.svg b/pandora_console/images/wizard/csv_image.svg deleted file mode 100644 index 1e82511472..0000000000 --- a/pandora_console/images/wizard/csv_image.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/pandora_console/images/wizard/hostdevices.png b/pandora_console/images/wizard/hostdevices.png new file mode 100644 index 0000000000000000000000000000000000000000..bc60d6125c71058f0691fef3a4382fe649848f2d GIT binary patch literal 1152 zcmV-`1b_R9P)B_~< zyBEz)TK*ke$MM9M*?>&J%gL1Gj~;Y!nA<+QGiCX(cMYuHs4QG(patM7)?8nDFJn!Q zkr~>7Ox7b2#;M+f>zdL9)gJ#M3t?*Vj!R63M;HRO@k|e&Zg>3hepgCgZ%1x&lKB84JBS1wzQCr7GtfH767`%2w3L&snH^?#UpnV z?p*1~bd5CaC1}?#;<84=-oZx$GytW)P01!w`7vblq2ca+plEca69TIj5WKSj4o(9nXId(lVIvons9jy(HA z(TY@jd9EH!kc)d=CQ@DCm#(H+-0^|*R$jL@Q4+p)9RB80N2*&gunjt4(1~P)uDtVI z6<2%mwaGn=yyJc=%dZ7`+R`5@+MwhQ_tkAQt}5CFoqLGRK+8IqN|p$qElY=d0veQb zxCA<^XaU+%tSef8wiK~s^JI-q2E>epA5&pz@13!zq-wG+y&eQ?$%ku|OHsZ1KPlO9 zhFcYT0ey2W=}_&QYV%x&ys8QLZ@EF|Zs4}1L$-N+kdC?1Y4VcqsM6Ru=#Xn2vaMV9 z)ZU$(>xpk2Il$gI8n%11YUi}8cU;3Zs+qVr>zHlOeu+lw*t^KWc1&CYjjP~21zl$A z>Sj=bEwkE|j#IX-c)v1}656_G=zq7~+v(y4-=o8d7SaKG*Dufs>ujvNPR0(}sz$Sa zT}ZE8o6+D!dfJy9zG;L|(hoY_3Xn%4#&A*WY8c2(Mbx90BC>)Xaqn5Gy - - - diff --git a/pandora_console/images/wizard/netscan.png b/pandora_console/images/wizard/netscan.png new file mode 100644 index 0000000000000000000000000000000000000000..c90f4ddc5da30015144d716d5611d9bf2be96c69 GIT binary patch literal 9083 zcmch7cTkhh*Ka_Oj_{=;2sV1Jp@Rqrk{}=*DIyX;AP^8j2T@eoS5b)}(tB43JyZda zlF+3$Nk9lKKI{QIN7OzC0AuT@e0_yP@V11TolAK>MzrC>FB8{0b-vjjbF6Zaxf3c?ZVC-Aj`}Y14Y(W09%U~@m zdQ({iXla`q`z=$S1MsspvsQ1)DbGigb}h2}h2n(N)=JxkS|ngJOXT<#?P`{F`{zp} z*K9uS=+L(d;c_Ve3=~>`n=zFQ9;w}^2Rwicy@A}MU9H+(=*P;{y@hGFhLblR?QBd| zFP+J@0uurK8)WBjbH}FVL`|K>Oz+GT38q2Kyx)sb=zj9nJWuCh)gi%5hpUqlSs8UY zWKOqm=LS&cXm6x*Lei!JRd~>#?M;{S`Gw+3JVpTNaePF`Oqi&27JBvDOk9pCODavq zSw{QpcWS5b*)0rM{8i-)>b9l_;~*z;NU7=hIN9J{OZbsR`9IMw4_9+j-a2GPSkKh^ z=hg?V4cpDPWOl+znGOyfrTzs%fAZ7nmRrs*EFfMPv|0JeSj@xqW^L~z(s{k?T_fRa2Hn&M@@#N? zu3oooub^8Y)1c$D=02UF}NC58gkQrg+icaE5 zz*dbtfv$Q~W!bev#2zqp%ii4W?JrNs_l09Xo1U}1dF3H$+#QbH^5AdrM9+3Oxh69a ziI2N`IlB8T_ZS0Tu*Wkf{vq+pfu+2s2B2o_B2j3%LA|&e?&U**!sR5t0C2nZ1m0G! zinE2gJ}_cU=4)kTs;q&W_rUCi1LyXm#jh6);mMpCy*9y{D36!E0E8IQj_}UP+`Ktx zecaRe_^@U{)5X^O!pN zCWpw89XAR9WsT(kJl%E$Y4;dT9SE=j2HC0)%NPc8Y4zy_=>Q^XK;WwEu_B~|7SPTB zpvcmQ0_ed2HWVOwf#(0+#l5L-0ND19I^6Ax3|(6x275a2k;iK}r?bJiDe#PFvZ}R>$=GSnT5ok}35f^jwI*ujxD28D>H9@! zECMY;5!xiuj4K0W3QtJI3T{JrBR9n>Q!+Vcfu=}8scyK>`bF^dj&rNcA8`vbV$yQU za6Boe@w$k+{orB){s+Yei#v+31wgMq&r+oq#eq~m*^~!rwRt!*DDSC24}@e)`W^Xd zkGkH2Quk9rR%FcM<(BJ_@v4L#91V+qI;tS_9Fk^)^=C%`6yu-9{jjDBj<`)cDNxj< zC`foAG0B@J5pJ5aqHR*>0s16#GEe6xMLo)x#q>sFhKNHugB-|5(F^&?U7#WTXKo=c zjcD5~GFN-6l;o9m2B@`q9#FV7O%KO5k# zEwY%8jU}&-DF^a;i>!}1sR>#8g;8fcz%?Y9U$l+EidKJg%C`_8fFkqcWeRq0-9xw8 zE?WfTR?^}9OOW{g=n?=e%8{N_{rJvCjkzWZrvmCo#3s3QaU0tdXUKI z^@Sd+n^etd#$98k!CFcQ`Tft!sytjSO@A8@$0SAUb~XK_cq=Hi(m+Q?-;<44j_66E zICVQi+uo=;ttdcoRg%)c-6|;1hf)(QcA0^FYh<#0y)(tm&Y!Hc2DHBjtmTx6JI~%n zUF3{c)|{p-&>$*x!jD$0xs(S>(!EDc%B`!MAO8LuFk!iquAyODtDw0zyS+s) zp+ygzH9zBv<$!p)w16&VB)D}76z-6$>=r*qZCRUdn#j5?^#6m>ZMsx#lbcd&VHkp+ zx3MCTm^^IJfvnU&8T;r{RzabyMZqb<<{=eP7kg`S0tZc*P8l{2MwsQv<+R^uMRBoh ziLCO$l8haZm#PLwW;niRaB*A-L9^*uO(6z&vIJ6JZ{|3JHE;*akXig@2f~4nZ%EgilLly+MQA*1l_GB*U0`{0zq<8j}Ms1g7gC6w# zTCE9ARDG3933ubigRMxOOEoWhf@(gDH!VS0evN&))<_T1H=_}iDWe|s*Q&F0VBJ+b zjF)D5kSz`@UV9mI+ZlQ+IK6Kk-A$TKs@?xiG;vA(4OXlhiS*+ht9WVm$;dNP#W9;k zbic7mhQQR1N#-$_k!vXUJ=PDwpvu;8=YDDpb1f*4W-F`HXTuM3f!WqLqng!aCrdFOL?ht}EW~ z9nW8Wu&LH4B8Rm)N%Y8^Hi)ne<>T(=Vgh?zMf$({W$_Q;pG8ir)&vhc#(QnpDW486 zPQ~wvz6RQ1YNmRVUe!Zw3ALEV%}8ltQSrRB!==X!g>6#Gx~ec~rJpLul|F$BHDuZ1 zS6X_?>ah-#cPw?1DDzc5lox*FV$GjpPMVf+g*X4g4!sY)6r~-@kv(bU{goSHw>UZ6 zHY3AdwH*-2+Gr_owIkrM-oZSGeq{EPAKja6pTBSyVi6F6XA0Ex^BxQI2hsN{c02^J zw~H$kTZYsIO80luiO>&j#^Lp|?cgDsnI78aF$}S(UGYz83f4#^!LlFEbP5FRaUE?l z*q9?*mm5G&3rM%YFW^Aen{0_rV{GScjbE?>HzFk=mrK)>J$@n2JbO|y**eDMYeu1) z|JjrB()`B?c%O$yy3DhGrzlDJg97yx@AwK%Q#)+fXCi(tq=Z~wLycDsg5upbc98_gz zYN&r=9zIA}g520R+`^;^f&&!yieRATNJjxJ)lpbT%aZN)JX(#n)HELH-s#>3)uBU% zx`rwJ?KPzazl8;VUud?NbeXW?G+t(W=V9rm6OpBBpL~gP^u6Z;t5F(pBuEXkU!Bf% zyYE+C@`jP(QX;Gpf8Bf%a3t_!U0hc+pkan9>#t#=-s!>Kr|fkjwdVVPqtnRr;_z!L zQ-{cE1DDu^yg~FpCvrYVc2G?>_cA}$(kv_>RZZ=?TZuvdn0l*MoJ(!5)4# zlp`*u@YnR_13SOqQ`<|imQW`gIISSC@1${L$c=@5aQrYNX6r2H#mZSu?qB)xudCPp zc~t$M!ByGS2y!D(^Trm*sV7-k82I@`OavVpD(Tz8BE!Whbm$^Cw?}}|uKSU&TGhFt zy|F4!M3N#FSGTTqsPr^vp1%1vK4RvwzALz3?P7VN+@NrM<@^vOG1(Y3hdV{M|P1pS119 z7;jXrJpsc#p|UkrR;vc?htz!359~uV3Iq9;PYTU$0(rE$w<52mGm*5F%MAsU2hlZ{ zpP+_xWPl!Y*Fi(M-qsIYYR|0QR zZFnxG`4UfS;F7G)iBVADr16;6DjxFiG!0=K_n{h~2KOYQbwJufg2(7oQ19#M)1&$FEV>J`zwa9~)R?)?Xvd zzKO<;&|32$&X$Un@6Uf$ATRTS=7!>~-kKIi{8=HI$ipL-U8m+&CNTU` zS6(mNnoytcIz3vt!J)`v0M$0;Nv4#xh+vwhx2<;%G^s8H6vJpQ|s9l_rR(&f4hp;pJ|=vWI>)JOf~W}pfJ}Q zTnE*|EAL!qQi}&YA>*SgE@7_4ukE1VsC4B+-bjOsJDbgk}wgnyu~| z@|29Z@l@W3Up*I}FV#1xP8?@RDwr{s?93{NfmdEu&5U39=-_^h9)}+;tyNoWcqA2> zy$*NMJr-5To^(V%QdQDv4Nvv{9OT)sx&nyseixt&{#ob5yWs3`a>UEBo76@yAZPR) z1l*ey3gVUI#(hYC5ms6hEc(r=)u>xal7&> z4_&0zhFH&{=RST^UNO`qR5|&&@EIIEJGLy*0ig#tl@WC>MW!2nVS9d;rDq(r&`%h_ zUk}XYpcdJJxMS4F1v4{LVj^U}9RQ~{YwtyMDk9HnKYs6cmJ(J0A6!;5oqoFcAh0^OM}-<% z(p5)N2=H+VvkDpi;DH*rg53`fp0nZq$p7I;Kw{!C9egPvgf+BobK zLp0bEfn9WL?=pvJd!hQxl}MlIs@1~`46q0i?o-jEli3BI!z?$jvZF|x46ksVlWbI0 zc@FY(Xg6lynOG|FGz+ojK&tY{+iC@iP5lsjd!s&BAbGIfFWbNU%{C{JM`KQ-N1f9E zwuxKx#7JW`Xhl0LAx@_Vqxc-727Pm-6AYdn@;zp%|kkKc$@j2-R!9A~PC-p(Kv8lT}GNeV4y?LAB!VrD2nRvd?!plXE@KLj|SYy0*NT%D_qNR8Gu1X+-+nE0wBr>R-`V zgxvsshDk4nX57*^|J8I{_C&{7SV&DWazuToD@cDi{1-y`bwJAc;b$W4DJa5eb=yh} z3v7yrNlaKCOFm!h(st%TddxowdNPZ{glj*;F8Y=HG`?qD_$Zd8z4ufm@ucVSK=5^4 zqnL)dysw{?)oi93eOFzLis4_bG#C{A+}_Zj1TCRKjMd>TBmiN3{lDh^611 z=RbK%9d`E8g1>x>O+BW8jKqs?5F*$RD_>+^Ts9-AN|`tk6yga)#`9O!N)y)i3Bui% zA^uA1511`&CC@P-(3@WDo?+Q_uK9$%9aaT@_7s@NtNWuzu}-0|h*QD*-Ph1aC%y6! zDOWGl=xR=V#AAk1^>K;IN7V+z-CCSuNU6bWdO%$%^7oA^B=Hl>c>k@uZsQ2=>|9sI z9iu6;>7-NpeFP4(H2-3RPW^cF0QJUA=^mlaaA)glb`Y=5sSDNCgzOGkmJlEaT&L8` z7-7Q)#NR$j^x?Oi1u8g=K!K#j2Y2roLN0DP^B&N+-^8XB!IO~zMsE6HOou=XE1j+6 ztFLS3J9E-GOz6P~sH*_#c~80wZ_lN@GPzmVWRRbTu)}nKd}!pgMLsNcLgJKOmb+%% zjB(@lY(&y;5EwV;Zl}QfiRj}6UYPn^%UHz#bmR2 z#CbIG^P~|4C$Vrsg|Q!-I76vFRTB4Asg;85(j8{x!*h2((vt|mfD^CHz=6`&N)9kaHrbsKs5uTcFz7+?3%dMqE zqu^@=J!^WID(4GIL<+|F&}9`V4&nd))EjW1V1^IZH@u*CIfyq4DYz~of1D5Wu}-6Y zz4MMGnu7g#glq;$-DUOTE{nbaq>}k3W7;5iJZnZy|6hu*QAkCwu;v5_L>clz_lS?tFgb_>srL=2^9|_tO zi!Yd~W^vI1XZb9`f6W|GD&1y^_sb2A%PAUC$r&Cc?j`=zQkuF#D^rB$Af3ljEYBZ7 zC|#rF2MrlsnO6dcu=2}7lCd*Sh!kvjoJw7jJ1ZC#Z9N&MVV@Z0;6gE>fEL2+FnRBK zBhqOruiW|Z>uv>zEVC?S3;WOyeGzzOz&I4iio5FR(4hM->)Tw{+f7I0n?NdizML0J zzt}!;=3(}R(-rP66AoBzQ`x*jB( zq;Z}6rDsyKk5^SME+|x#Bu3L8h^TJ45k1~;9hg$K!UFIrA1;`p5IB&M)q@Mwu2~2i8Rm7O!0{%5=6^k^J^#4y$tE7S2sP7XhYy`gEC&j_zGipJ=NF z^(KWW>5u4fD|EXQt&VuGERcNe|E>5rp=PVafBDrgP1cw;a^_f#mj@*aKG`&fNds!E zYATXTePpDizc?+MI=|*8oO|j7tyg0|NC3)}vx9=5r#j$uD~;NQgJD$IFKS)EyQN+f zm7S%sh4Anxvqz1A#fKZ?()mof>!;@lvfUA$I(6O2R|fZ3!bD5+Zw@)G+lc~vN`1hP zf-{ihMm+;t_qcj%Bg{zr5{}>F_tcBxSVf!rWbnz9XlA%VF@YVRWcb_e_f-89erK-6 zV+`2YT`wDcwm*S=*daX#kn7bGM4wFvQyxyPVvcs zCwidT3zb`=73AmVU;Eq{UcPa=GQ&{iajmv>&0CQ5Dc%`iYO@&=m38oc4P9Q-(oX-;J@nZRW2< zs}yc7{e<5WAXgfa#~Y*8b?;x^SUAjrgV^7$c0VMUdXKV!x|$Yo?=EF24BfgK0|)jT zA39a{una#BL*h_sKo1t|_U3F;Cw|(tDim=}R1*V`IMKbf(dyKSB8mwAj2PbM-?aO# zNPQvbl8Z zG7f77*ghaC;2omgPkhcuzd|@OP63V7y}J{5n+{UO#(!}j#TorAR)IP|Rl=Xd+Gp{C zboccpSI_u|O^ieK9|p1PLLHfy8Q-=PS8 zTH#tibUh|GWE;Oo@;#j^Ai=Htg@NMIN+W%x^=>x&HFr@X*pUWIz8K^L1hAt}lE9lvCxsC{ z!NFuXrEE``M=g%wqyg2gkCJYLp*E*SFQ>&94{)lJz-I+G!1*3BU z*-#&XVyFnpv8iB~eeiO}6Fm&KfSn|C$+M zcc2QXe{VuOHYL2CFJuCjDNup92wQREsjk`=i**x*25q+}>E3(I-Fs%D^<=YYiIVZf z#Q1L_Jz9_dlvewmj$1-~C8cRZ2`pIK>+T!6+X&;;sOQ0=14j%@JSn`a-k&ogREps$ z%odQjhmYyOGXJ31kzZv9pGQ&*Ublpi2XAeUc3)tg6XlddrG%cN49eJ1{nDBfZy7+f zIBIsJswLzPC}H7lNG$G&(_V@DaZ_3D;6D>gBmWM`422z(;O;^#tV1?ew!{D38qO|0 z2#_Wn9{?mFa*bVX3^a%ALH35c=Mh$gTO(_`r^y?HHE+28A9 j+^POw_fd)}FJ#*Qy#aZ7?Ra4NUnye)@ZE|#F0ua$3gD^8 literal 0 HcmV?d00001 diff --git a/pandora_console/images/wizard/tasklist.png b/pandora_console/images/wizard/tasklist.png new file mode 100644 index 0000000000000000000000000000000000000000..3250311b69cd02e87ea89b967c4579c3635a3c77 GIT binary patch literal 855 zcmV-d1E~CoP)4Z;B|L3iDS72Em-?YuG;7P8F@p0ODGeUgQQ6wG`K z&u`=(6QuwE0Kh-v@pvQ$CJub?EI82*Z~7=Cr&*TG(5%#_fRcsLU@-W#+wFe$UG&F* zk_(2+XQe&|mYnP3)up!UhaVC9l<_Wfx!hQb)`OOrI4#xM?HQ6MRe#rjyjBwVJj+*?}Yrt1A$_v~KUT$nQ0^Qp&(Y zA1?tU7w5i<*|Hw{%0+b3jBUCQw36J*1&firwrtOk+-7BHYVyko+1@1U^WE!*$B6v> z)Z>0_EjsXpuj*WXBJ4bFY+BfpD?|Mvxw!ytIw%*(wU!R6C3s2ps@#19sL6}iS~~GHE9;gvdwBUGqEh6!~aFh}_4CY|2N!pE2N8l6%+Qm9lm@k~>%# zny<0VFQvRlHb1L)ipZbWeDo>V-ez*7`RFfIt*`US&_r|V%82iB5#vSBYH?+oj~3at z>JUbkE9)dcO^z)eo$|XK00000000000002+gWP0|eg8V&gx)`TlV#a0n#1oO{gr(5 zo-Xpy3G?|f^U=={`;_s{UGvd$F?&>p&8N3#NS@e)OG-RPK5@l|ghNxS(osq$$rhF} z%evY>x_34DzT%VWV*lvH6*!$+w|5P-QY1c@uLm>PM<1nA3ZglP7MG4NxCq}M=x88?z+3s=lUDrWQ}tF=zcH3OR|ebd=*IY%zPzdSp~9x hGynhqTp0fZ7yvEOZlM7Km}CF|002ovPDHLkV1hJ7m8Spz literal 0 HcmV?d00001 diff --git a/pandora_console/images/wizard/tasklist.svg b/pandora_console/images/wizard/tasklist.svg deleted file mode 100644 index bac9f75f6f..0000000000 --- a/pandora_console/images/wizard/tasklist.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/pandora_console/images/wizard/verde/hostdevices.png b/pandora_console/images/wizard/verde/hostdevices.png new file mode 100644 index 0000000000000000000000000000000000000000..8b8fa022ecc04430bae4c1a71e1644de599fc660 GIT binary patch literal 8256 zcmd6NcT`i`*KNQ^2MZz!A~uRhQ9wX26j2m`fb@=tA@nLBAYHMbq9P?Efb(AG}zYz>#CqGsWQT^piWLPYm4cpZM8&As}jx-5(*&X}a1X5&8(*$NrwJ zh?@|I;JD^(HN&Sv^CN0+1$>ePm*lxGx(Lb14PA>%>Uyv6JriL^`xO_F#&PZCb&+l8 zJ+qguPqDsc_gJ=Ex_@O_TA6|OQidAeZ7z=N>F3nYrhMa;5)(TSjalU{KDs?8Ct5?l zmVWh9!>-ahZ{i%cd`$YW^vXOk^f-@dsj2Cz@(L>SLpZ{P*jVs5rFn)88^C9|52VZ${g1 zp6NKo(d|R|1NGI(MwP|g`EeQe)pH7SpCx{jU{dpB&+j)im^`k*4@n8qOje9$#Gx$sL~LhXsROkz zc_zuCQ1)~YM#eHOi-i_*COn}%*ycuBb%07VO}vKLd9uZ=xDy$A{xPX z-wf6A>HKYB+VBo>4>naIF2e{#a@sGd=x=#TyCk%|?EJX0AH~)`gRf1EkXDax}p&# zbo7i`?5y41FMmQLlUaVTFRsux7-GPSp}R`#Ggjubs-=tX;C5bg;9a*d3aTE)4{*yZ zM+@~S}OU`z&FdW77e-_9qYt&pZtoZP?{`xrulvDa@G2nomA;R=1r2aWBC|7;;5hB};PgP>j&)LpYu`1IchC~! zwV~zh)yc9QCRGn#a@a`p8rK2aZH#flZKQ6L!R|icq!W=dt1Yq{5+0+WbU^0rm&sV4 z_WbAWWUt}pNV)gMF94B@wbHk^Lw1%;=?NWQxszF`-t5TjSW!rLsgYOR@?@iw3Ew9H zA=MPX-F@pnN_7EhYplgw?GN}a$=Ia?O^&>doW5UiWNU{`k*bm44;_6xE^V3Eb%xsI z(*1@$)2Ol#q5@&T|BAGaM4~TIqL-jYF}Dn!f*a%7YC5tar`wi>^8*XPGZsx*+xMz_ zBc8gg*O&m1rjl>2&PEn2Ctjc+Yi%I;6T>GQ6+dK(_}uFam-Qy_b;K@OaaBEg$5A@) zSDDw_XB5HUtWgXq36>UyeYY^cC+)5(tc|l_r_SyDV(l~*luHn zkEGuCkV?)QyR5)a-})Qj>l_=1KAl*gBx@3hjP1;qF~nYG1cR}}k>>j$@VJD>ral;a zXG+1hcfa?nUhe9Ht2R33#p;X(FAZo5%W@}YhMcvC2DkQX?XoALa!x1LtP`7FKMO&` z;W+yGe}DvDqT#WKJz*d71d+QlSULs>csdHjMnA+WV(7|cY0+O&^eWJz$C+2v10Lqt znNc88B`udE$ zhQT3_jNgummxp9(%7fMWBrK3@H1HT6FfA22iaBm1JfdBhITA*TrDbm4X+7@%sn~nduXWwP9O?{jB9Uc@hB`Vb^O(Cj5d;j0ujp$&$@3>1tootbn&(+y?+(?hq$Yw z>LG2++L>oG^cS%=R+yGA(ryJ;-to#L)GW=F@7_9qHE5%CE>>AeXZ(QNuCd7XE2|&n zwd7L-Eg^=)DsEK|ee+0#yTmVwJdYT^wZU4|Ak zSThGP>&C6TS`O4nN2J!<4AHD`K%v`M{Bx>kDS|tgwZ0nh2`-n4-w!eidTo3X#A>_z0)X$vIw$8&DzW0HezrXgn7Ki%%n3XLw5QDy8L<%&q zanf0f6T8tb3<>w{eeAFXlA-bQ9fDNd!&fI&J=|(Liecql^Gn*9xkLsa8E=PaF5}w$ zh6$`X^y@$qCo*PTdSE~QX6tFk&dXp0@{jAgTWyVHQM5XW=lKO;wok!CayGcxfQ9&I z_aWRN@g75lhvsI@#H+aqA-;d1_7n*d%y1L8A`^}9t>GPALlj6CHB6k$Jz_<( z$*4PwGDcZCx!{J#NiveGA9i*q@X_Q#lQaif6@Ser0SsQ@ahR{$zvq6Sc-yNPRz-XZ z^x~S*zABuh6<5Fzh=}a_k;W^=J|Vi0JQ?iC|7BJFwJ87TUj8o~dfR+5J5-WXx~obH zTPUqbBCW6E+=ygSsoj8P7$>0qw;kUa`pm)$@;H(=(66p?A%g{8IX_B{sR6MYAVU|N zc`2la?PUC;k&r3|JYfei-kZPVydhKEHUCpfyYxoUcfZXJC7ya`oNSf1{Cw+bAaSo`g? z>}>Iy;Kaq&o$!g$?1Le(wxkXxUJOJ}&wenCQ0Gkq2@j{ zvnMc+zPvfB7vMx$TMb_FW%elai|@9{LUE6f?_FD`$Icm);ba<3h9%$Xvb|ERtn4Wx zF+5O(!y@1Mhx=t}t_)H!ETZRR?C!dblBZB*kxnz!F11%=Q@`)jY@m-}w7+t6Gfs6- z6lj-N;933S)OZY3bVjhYasm7g+~$9}OxFM1c>bRp>f!@>Idw4oo2}LLTeNxR{jYv* zV=lDmq&avCn+1juGLWxWS2peq2u z3G0V;PrB13_e1v3-4emUx%TuDUP~nUZ1B@A zG6YO*S<>2iFh_YXs{D*Hwy5$Q`Ivb2SQs;$em3Y&MG?9}*E^IA{^hH_ZSu1XL>Tc) zRKjzl&GGlb(#o{UV4o-+R{58u}c8A;9Z*8+nq6yBHm;+WfuX<0b7Kc z_j|+x8T58|;Ltpg>t643@$<7=(mXuK2z8m5OC|PB2nUTwb!ndJ7S7GsX0zP}S(d(M z!%-*ELIij9ZvvGpiQz(G;iaj`TfHXo)ixh^(a`aLC!GwE2E3unKa9_qRtYqM=MAxg7*sY4O(IC9}tXMu-CH^tJ-VL*~x%`R!cs)^?75}aNPc^!Gf<8j(+2-GF7cu<(q#mOnlWQf@2oi6iCY$0=nApN;@E z7y?OG3l{uavBOy?+MC{P0apeBmty$A2i&H&QO3q#iVaLKR}&pofVC`2vTmS*Qtrk3 zm8fu-D=;(fKHCl`26SY#27XK~N4)f5$cn|QapFpvT?TyYajuaD-bcP^M-y#f?%wlI ztaTYg3=co`ZJ?d>@b&$;}B36x#V0AQ^*&fIL)n99|q!T-re=~`E-|c*C6P`7M|Byn?FJ|bV$#}hwH7-&`V!6EUPn|ta6K9$p|xg7)`CN8BF&eF zhR;P`S@Aiz_T$m*rIm~VPA?oJ>%xfcrr9A_5pUBk2xVO_?*meAQusn{8Bfw?nm zz>*^P#EnK9+zE8_nS9GMeO$B4+5I6YsdcVJrA?oxn))sm)W2V*PGcpoxwfpZ)Fqmz zMj*we#0ZJsfd6||AQ9khMN?oUq=9+$Jmn5-R@rJo0hTHOOD zHxgukT0QYTf~Lg9-VD@|P4J?6CBkBtfd$TI0M^_^)R&42f(rvfa=l;~0;L*WA-#PF z7W-Y|#eCntSNjK(_+3Yb!>Fs`(vQ)ZqK)C}ZEF<`rHEcp>nXPU>JMjeVLyKyA{{wl ztt$z<_i94W){?ILGs^)RE{oj-HclQbvTR4xQFCTAuf5c;$cem+c76(VnWiV z+^rtw;8JI2uUVK7EJAII&in7SICla+)E(095dS7d=URTVOY&#`D?@g;LIBVmv3|?9 ze*P!4nurfs+n$fio-K8JuV-I?v;uIvnO#0y@usvs)$DFG@dC`9yWzC8SrGt646lL3 zHoGwTrcYdYB|rNQNxs#BNquWl2cY(mc2O;Z=t!amfH2}s%QS*b5-Rb?jYyKnmVqy#BVWzEmu7_eBmy@wIwpJltm^70J ze@o)@@(%|ui|I{T9VKOQaKJ(`_q|NuKJhL&DUqZRUK+*(vyZx`OM0NJ{DJG%kI9S% zZI#(V*>jqq!Z+9Q5WRimCvfsIt8ICptu&c$Yrx)d9R9azrtTN3*=Ss#~a zfn?>qcX`rbsC`16Zf^~%LpU&(ez<-_Flc$~n|hS^>;8xc)P3e0gdm4!Twa%rRHQA}S!hc!B4$+CTZ(XMGfAs#zeQm_{)7DA~EXNCXL{|_dsc77Xn z{!+q!-#M0fBsNmiW_V;LxR{=WEGS?;j5LsN>*{-0ppsvfv8jf#O|7yado8Ehmf$NL zM80~q6=0qyHt4xt%nTPFvXkqdDK1n&@bPCnsBYr{u{{9%zTO{C$9Q=chjMKK$$Le` zvj>>%DlGmRiNCDbr8~JiPbc)z@Pte8aJse>G5>3aMcms^_Du$%AI@@%|c~(0J$((^fMEy+1p)wk+mo+hWDZQ z={#2t2d+6I(viM!m^~md`l>|F-{I}xvz8#?g>n4N!~%K}rUP0$Rv{JS^+&87Y0a$@ z;%-bwF$IRW_^D#oH*IbjVZ6DdWnW3CQP8=*eR$1# zGSj#y=VJ_>)Gl&N4BAZBk^0GaXV8Z6zgqZLyfz|fJDH{0B(^InwP7zM;GJEG0#B8#j}+FO%hiY zJo(M>vz{Se6V?(C#W}Ot<>PyCP;qhuS%QR4oemk#IK+bYHA!-}dS*X)wv-jW*5K`N zre9d~n)%}On>U$Z_R-2u^HfN_dUu4cMy<0f&@*b32bF?HpMBJT$Dr@6D-OHM+eA4amXP~iC=*?D>MJCc?2Zw^fX$~rWeMQ+D{syPp&&dEyv zv^Qc(mWjUpK4kOH$K*1Ex zaR6T+&&;*$flNU+g=+I}R9B)z3nVLcN|f^mL0m@DJ3Lm)ux&j-=V|TwU^G4cEXRP{ zG{p;ZMaw&&A9TIkPCZ#Qt0|Nbi12kI4Wg^I^iu;9B9hCmkU+23Pmmm{8|B-SjCHA0lZUs<}Co)`o?_pKu|}_OX~#{H`u?_x?(hL z&NE)z=53mtTEE+Iq0PmB38=?s(EYs+-09fxKk94bNHh)sHshBe2EoDqrW1MrOiPWm zI{WAbE9l=iMG2vgaaervDp>WDjb}cJk@!3fy~AH9B0D$~B@?;3ooKtenb{EZx3gLy z_s452Ub6sL)Z!~PQxs+ZawA660GRy>ZN{jo+rtHTE|t2SG>Ik%TaQ=K*cj?;X~bGW z1h7z?1TJ>MO=V|wW-a()us_ysVMQyTzsCs`ws`VTc#M0iGAeyB_Qok(e|(&zW-~Sm zij;)E_&y4C_?9Ms6Rw9=&5WJ>cN^oNu>7K<%@ux9D`H>Vqz$e>cO{uT<-eio(O}rR z)g<2Zd)_P)v3)*b6e=uf>;G(hwQFHg_%i49=OW?U4*5WK=TXzn* z9b$ny*kxXp&0e9CGc=AQ7_k?8&{Po-46g82iH9q(z#odgC+y{XqzndG(BH3a+6?nx zSnvbZo$4_uDKb@D^2>qkyX6lOOrMXsbt} zF)h=dM2sV9A0^UH9?;uvjI83HSL2P49f2u<^BDYb}7Xh;ibvEdi^@3H;ZeY#Uj#L zr%(C38=IP=-FSVyo&1Gp8Yodwgo(bWa5tDC$?*rHopJRklbjMavYFSox#_X&aZDEC za?FOAeBu*?KG?K~({=BR-@_0`qW$G$Tf*4tjyN-tR;tV;=;K*aj14WXMqM)A&cp{D z>x?0LxO!W^Y9~+3FLxRAB5zOA?E6}Ua}~1@8^vueg3S0ke4U{z(1w25qmkDA(@5nn7WYu&cjeNC}jg((D!~jaNOq z^q?iU*NVzp2|Z8JDU!nu%gikc&H#riucF|b^HBQ!XVe#0qi?KR8H+Q*3ZNWr8@%Yq z+WyV8LxUkENA6%tr=D2Ji+&@O;r~cy-07`*yN69|aK8Vs*=0tWVXsbI2%49w=)2TH zakXfaAyCrF1BH3SDvk!NfAk9s*`)5L(|1AwLLPO>F0c6bRr4kc`vU*&GlyhA z<)Y1*?V=;|Ho^Op%8f=u&N^=r>s25L6gWZxjv zyiM9)b8}{Vvb}uA4;A&Yoh-mY=kE>A<&=0z z3T^qwX2eDJfgYNS$*0YT1RPwX%<7#~-6#_J5bPP6+e;z;l(4f?vBt9^d*4yq#O3n8 z4qE;T;r2^sKm#V@EBB_f8@T0y|N`sbDR`p7kArzS$iZU~%!rH4v zckDMc&6{J&=4?@7W8~v9T6DP~-DpOG>cnG-l(<=o*h3Ta5yvgtm2hXJB;WR+ zPEAe*M(rRE4cgcNs# z@FAlNmI#euGyaLN`Po0xx38nFqa|LyWdtc*s2@r0d3`$+zTPm^)?*nG&&?wY{Mnf= zj<#`e_7NJizAJP|syjwrn~McscyBExwXs_0cJC3{AhmK}pIdXE!Q;1VE51LoeWY*_ zv;>ZHqy450??Ma~tN#Dnfc_sh$xqPt51)cyJ(~)>)7KA!p9DZO@4#;t-g+4RUxtnZ AN&o-= literal 0 HcmV?d00001 diff --git a/pandora_console/images/wizard/verde/tasklist.png b/pandora_console/images/wizard/verde/tasklist.png new file mode 100644 index 0000000000000000000000000000000000000000..4c6669e89de9d2c125b9c16940ab3dc54c54d808 GIT binary patch literal 1038 zcmeAS@N?(olHy`uVBq!ia0vp^Q6S901SGegx)utgBuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFmLd5aSW-r^=6KJhE$-;@#GB)npd7oXm-+{@K7cwNAZ&3 zgoS;6iryIq{cc*_T&g+6r!Z@|LmS_tOBeI>ruk$VI7iEzQxs_LIxEn_$93|;{Msiw zem$>wZ*yPr{cmZPhwtuI&;S1W^SkfW{^#2dO}0ES_Y5;*0RuY{I{xMn$FIZZr_O!a zP*q=8@iwbNV^2^0w@T(Oe^2+DPd&Y;dh6j6O)05`clX}9c(`fF#g)9fXXq(6PqIJf zw)@-WY1?_(d6mUHFR7b)`Oe<3fZK2N&cwGW*S}r8uuR$b|MI0*qeZI=a_oOE`D4sD z>voRj(Oa@7l;ZChAO4kaP}BKArOEpD0q^cG^3GG-aG+_)0@P0$f>YGHi^c049nx^%)HoSjvXWNO?38i1wZ)%CS@V4_sv}N+^ zJ0>fWuYB%gxz*_6^0g^KLnvG|>xHy`&DI?}$u1?UHzp|ee#@VEs@}GS)nuCX+lf<` zTGYnHOx3xseLTWt@rj%MnlJ#ldzR;e6iVGldjt$THHYpt-@Gvg0? zX9=JBa$EI^_B<__^<@D|F1VjNRoKrI7$|n8&G_icyT1;umW@CCzGt(Si_V4_b5A%q zr<$rK>t15wp84C_;(JL%j}CKZ$E(&Se`T-OF3gSmyom3lgvGM^Zof)zK1-EQJ|wbl zL8{AP7G2L5(-zn(H6A@0>Ukx?#^O(_c@$a*0J-IlKU6Yvn*RNFbbWZUQQEsh2RFUa z;asG%&N|3*qpMm_tMT=|cMthrrq6rj+p8Y@bn9GJ+p8++7o*DcLEC zbH&@^a;?@rr#og`EgRiok8MA5?_Z#?$o?H3%=N0pLo0ab@ zpPLu8%U!{D;rvrUcbuNS{PAZ)QRJMc`v+%Rg*nf@?QcJ8LwUGp-!hZ3SmW zx^?3M*%LMvTEF&7t~m6tSInY;83n!T{Ue&daA!4BbF<|xSzrcd@O1TaS?83{1OQP5 B?Mwgw literal 0 HcmV?d00001 diff --git a/pandora_console/include/styles/discovery.css b/pandora_console/include/styles/discovery.css index 2bc41163b6..33b1d3c0a9 100644 --- a/pandora_console/include/styles/discovery.css +++ b/pandora_console/include/styles/discovery.css @@ -8,6 +8,7 @@ li.discovery { width: 250px; height: 120px; margin: 15px; + padding-bottom: 50px; } li.discovery > a { From acf3c94642f70f0b890a01692313b96f60f2a2c6 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Thu, 21 Feb 2019 13:16:32 +0100 Subject: [PATCH 156/262] fix bad solved conflict and added changes in bd to migrate and mr Former-commit-id: d52e91d0f2b886620aa9fc07dda48bfeb27ffe0c --- pandora_console/extras/mr/25.sql | 5 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + .../operation/agentes/status_monitor.php | 521 +----------------- 3 files changed, 8 insertions(+), 519 deletions(-) create mode 100644 pandora_console/extras/mr/25.sql diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql new file mode 100644 index 0000000000..b8a1eca9ae --- /dev/null +++ b/pandora_console/extras/mr/25.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index bedb9927cd..99a5dae2be 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1206,6 +1206,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '731'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); -- --------------------------------------------------------------------- -- Table `tconfig_os` diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 0d34b416a4..fd4d9d050f 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1068,7 +1068,7 @@ if (!empty($result)) { $table->size = array (); $table->align = array (); -$show_fields = explode (',', $config['status_monitor_fields']); + $show_fields = explode (',', $config['status_monitor_fields']); if (in_array('policy', $show_fields)) { @@ -1131,7 +1131,7 @@ $show_fields = explode (',', $config['status_monitor_fields']); $table->head[9] = __('Data'); $table->align[9] = 'left'; if ( is_metaconsole() ) { - $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . + $table->head[9] .= ' ' . html_print_image('images/sort_up.png', true, array('style' => $selectStatusUp, 'alt' => 'up')) . '' . '' . html_print_image('images/sort_down.png', true, array('style' => $selectStatusDown, 'alt' => 'down')) . ''; } } @@ -1644,523 +1644,6 @@ $show_fields = explode (',', $config['status_monitor_fields']); array_push ($table->data, $data); } - - html_print_table ($table); - - $table->head[2] = __('Data Type'); - $table->head[2] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectTypeUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectTypeDown, 'alt' => 'down']).''; - - $table->align[2] = 'left'; - - $table->head[3] = __('Module name'); - $table->head[3] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectModuleNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectModuleNameDown, 'alt' => 'down']).''; - - $table->head[4] = __('Server type'); - $table->head[4] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectModuleNameUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectModuleNameDown, 'alt' => 'down']).''; - - $table->head[5] = __('Interval'); - $table->head[5] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectIntervalUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectIntervalDown, 'alt' => 'down']).''; - $table->align[5] = 'left'; - - $table->head[6] = __('Status'); - $table->head[6] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectStatusDown, 'alt' => 'down']).''; - - $table->align[6] = 'left'; - - $table->head[7] = __('Graph'); - $table->align[7] = 'left'; - - $table->head[8] = __('Warn'); - $table->align[8] = 'left'; - - $table->head[9] = __('Data'); - $table->align[9] = 'left'; - if (is_metaconsole()) { - $table->head[9] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectStatusUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectStatusDown, 'alt' => 'down']).''; - } - - $table->head[10] = __('Timestamp'); - $table->head[10] .= ' '.html_print_image('images/sort_up.png', true, ['style' => $selectTimestampUp, 'alt' => 'up']).''.''.html_print_image('images/sort_down.png', true, ['style' => $selectTimestampDown, 'alt' => 'down']).''; - $table->align[10] = 'left'; - - $id_type_web_content_string = db_get_value( - 'id_tipo', - 'ttipo_modulo', - 'nombre', - 'web_content_string' - ); - - foreach ($result as $row) { - // Avoid unset, null and false value - if (empty($row['server_name'])) { - $row['server_name'] = ''; - } - - $is_web_content_string = (bool) db_get_value_filter( - 'id_agente_modulo', - 'tagente_modulo', - [ - 'id_agente_modulo' => $row['id_agente_modulo'], - 'id_tipo_modulo' => $id_type_web_content_string, - ] - ); - - // Fixed the goliat sends the strings from web - // without HTML entities - if ($is_web_content_string) { - $row['datos'] = io_safe_input($row['datos']); - } - - // Fixed the data from Selenium Plugin - if ($row['datos'] != strip_tags($row['datos'])) { - $row['datos'] = io_safe_input($row['datos']); - } - - $data = []; - if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - if (is_metaconsole()) { - $node = metaconsole_get_connection_by_id($row['server_id']); - if (metaconsole_load_external_db($node) !== NOERR) { - // Restore the default connection. - metaconsole_restore_db(); - $errors++; - break; - } - } - - $policyInfo = policies_info_module_policy($row['id_agente_modulo']); - - if ($policyInfo === false) { - $data[0] = ''; - } else { - $linked = policies_is_module_linked($row['id_agente_modulo']); - - $adopt = false; - if (policies_is_module_adopt($row['id_agente_modulo'])) { - $adopt = true; - } - - if ($linked) { - if ($adopt) { - $img = 'images/policies_brick.png'; - $title = __('(Adopt) ').$policyInfo['name_policy']; - } else { - $img = 'images/policies.png'; - $title = $policyInfo['name_policy']; - } - } else { - if ($adopt) { - $img = 'images/policies_not_brick.png'; - $title = __('(Unlinked) (Adopt) ').$policyInfo['name_policy']; - } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ').$policyInfo['name_policy']; - } - } - - if (is_metaconsole()) { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; - } else { - $data[0] = ''.html_print_image($img, true, ['title' => $title]).''; - } - } - - if (is_metaconsole()) { - metaconsole_restore_db(); - } - } - - $agent_alias = !empty($row['agent_alias']) ? $row['agent_alias'] : $row['agent_name']; - - // TODO: Calculate hash access before to use it more simply like other sections. I.E. Events view - if (defined('METACONSOLE')) { - $agent_link = ''; - $agent_alias = ui_print_truncate_text( - $agent_alias, - 'agent_small', - false, - true, - false, - '[…]', - 'font-size:7.5pt;' - ); - if (can_user_access_node()) { - $data[1] = $agent_link.''.$agent_alias.''; - } else { - $data[1] = $agent_alias; - } - } else { - $data[1] = ''; - $data[1] .= ui_print_truncate_text($agent_alias, 'agent_medium', false, true, false, '[…]', 'font-size:7.5pt;'); - $data[1] .= ''; - } - - - $data[2] = html_print_image('images/'.modules_show_icon_type($row['module_type']), true); - $agent_groups = is_metaconsole() ? $row['groups_in_server'] : agents_get_all_groups_agent($row['id_agent'], $row['id_group']); - if (check_acl_one_of_groups($config['id_user'], $agent_groups, 'AW')) { - $show_edit_icon = true; - if (defined('METACONSOLE')) { - if (!can_user_access_node()) { - $show_edit_icon = false; - } - - $url_edit_module = $row['server_url'].'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'.'&loginhash=auto&loginhash_data='.$row['hashdata'].'&loginhash_user='.str_rot13($row['user']); - } else { - $url_edit_module = 'index.php?'.'sec=gagente&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$row['id_agent'].'&'.'tab=module&'.'id_agent_module='.$row['id_agente_modulo'].'&'.'edit_module=1'; - } - - if ($show_edit_icon) { - $data[2] .= ''.html_print_image( - 'images/config.png', - true, - [ - 'alt' => '0', - 'border' => '', - 'title' => __('Edit'), - ] - ).''; - } - } - - $data[3] = ui_print_truncate_text($row['module_name'], 'agent_small', false, true, true); - if ($row['extended_info'] != '') { - $data[3] .= ui_print_help_tip($row['extended_info'], true, '/images/default_list.png'); - } - - if ($row['tags'] != '') { - $data[3] .= html_print_image( - '/images/tag_red.png', - true, - [ - 'title' => $row['tags'], - 'style' => 'width: 20px; margin-left: 3px;', - ] - ); - } - - $data[4] = servers_show_type($row['id_modulo']); - - $data[5] = ($row['module_interval'] == 0) ? human_time_description_raw($row['agent_interval']) : human_time_description_raw($row['module_interval']); - - if ($row['utimestamp'] == 0 && (($row['module_type'] < 21 - || $row['module_type'] > 23) && $row['module_type'] != 100) - ) { - $data[6] = ui_print_status_image( - STATUS_MODULE_NO_DATA, - __('NOT INIT'), - true - ); - } else if ($row['estado'] == 0) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_OK, - __('NORMAL').': '.$row['datos'], - true - ); - } - } else if ($row['estado'] == 1) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_CRITICAL, - __('CRITICAL').': '.$row['datos'], - true - ); - } - } else if ($row['estado'] == 2) { - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_WARNING, - __('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_WARNING, - __('WARNING').': '.$row['datos'], - true - ); - } - } else { - $last_status = modules_get_agentmodule_last_status( - $row['id_agente_modulo'] - ); - switch ($last_status) { - case 0: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('NORMAL').': '.$row['datos'], - true - ); - } - break; - - case 1: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('CRITICAL').': '.$row['datos'], - true - ); - } - break; - - case 2: - if (is_numeric($row['datos'])) { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.remove_right_zeros(number_format($row['datos'], $config['graph_precision'])), - true - ); - } else { - $data[6] = ui_print_status_image( - STATUS_MODULE_UNKNOWN, - __('UNKNOWN').' - '.__('Last status').' '.__('WARNING').': '.$row['datos'], - true - ); - } - break; - } - } - - $data[7] = ''; - - $acl_graphs = false; - - // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions - if (!is_metaconsole()) { - $acl_graphs = check_acl($config['id_user'], $row['id_group'], 'RR'); - } else { - $acl_graphs = true; - } - - if ($row['history_data'] == 1 && $acl_graphs) { - $graph_type = return_graphtype($row['module_type']); - - $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); - $handle = dechex(crc32($row['id_agente_modulo'].$row['module_name'])); - $win_handle = 'day_'.$handle; - - $graph_params = [ - 'type' => $graph_type, - 'period' => SECONDS_1DAY, - 'id' => $row['id_agente_modulo'], - 'label' => base64_encode($row['module_name']), - 'refresh' => SECONDS_10MINUTES, - ]; - - if (is_metaconsole() && isset($row['server_id'])) { - // Set the server id - $graph_params['server'] = $row['server_id']; - } - - $graph_params_str = http_build_query($graph_params); - - $link = 'winopeng(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\')'; - - $data[7] = get_module_realtime_link_graph($row); - - if (!is_snapshot_data($row['datos'])) { - $data[7] .= ''.html_print_image('images/chart_curve.png', true, ['border' => '0', 'alt' => '']).''; - } - - $data[7] .= ''.html_print_image( - 'images/binary.png', - true, - [ - 'border' => '0', - 'alt' => '', - ] - ).''; - - $data[7] .= ''.$row['module_name'].''; - } - - $data[8] = ui_print_module_warn_value( - $row['max_warning'], - $row['min_warning'], - $row['str_warning'], - $row['max_critical'], - $row['min_critical'], - $row['str_critical'] - ); - - if (is_numeric($row['datos']) && !modules_is_string_type($row['module_type'])) { - if ($config['render_proc']) { - switch ($row['module_type']) { - case 2: - case 6: - case 9: - case 18: - case 21: - case 31: - if ($row['datos'] >= 1) { - $salida = $config['render_proc_ok']; - } else { - $salida = $config['render_proc_fail']; - } - break; - - default: - switch ($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - $salida = human_milliseconds_to_string($row['datos']); - } else { - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - } - break; - - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; - } - break; - } - } else { - switch ($row['module_type']) { - case 15: - $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $row['id_agente_modulo']); - if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') { - $salida = human_milliseconds_to_string($row['datos']); - } else { - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - } - break; - - default: - $salida = remove_right_zeros(number_format($row['datos'], $config['graph_precision'])); - break; - } - } - - // Show units ONLY in numeric data types - if (isset($row['unit'])) { - $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); - if ($data_macro) { - $salida = $data_macro; - } else { - $salida .= ' '.''.io_safe_output($row['unit']).''; - if (strlen($salida) > $config['agent_size_text_small']) { - $salida = ui_print_truncate_text($salida, 'agent_small', true, true, false, '[…]', 'font-size:7.5pt;'); - // clean tag - $text_aux = explode(' $row['id_agente_modulo'], - 'interval' => $row['current_interval'], - 'module_name' => $row['module_name'], - 'id_node' => $row['server_id'], - ] - ); - $salida = ui_get_snapshot_image($link, $is_snapshot).'  '; - } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); - if ($module_value == $sub_string) { - if ($module_value == 0 && !$sub_string) { - $salida = 0; - } else { - $data_macro = modules_get_unit_macro($row['datos'], $row['unit']); - if ($data_macro) { - $salida = $data_macro; - } else { - $salida = $row['datos']; - } - } - } else { - // Fixed the goliat sends the strings from web - // without HTML entities - if ($is_web_content_string) { - $sub_string = substr($row['datos'], 0, 12); - } else { - // Fixed the data from Selenium Plugin - if ($module_value != strip_tags($module_value)) { - $module_value = io_safe_input($module_value); - $sub_string = substr($row['datos'], 0, 12); - } else { - $sub_string = substr(io_safe_output($row['datos']), 0, 12); - } - } - - if ($module_value == $sub_string) { - $salida = $module_value; - } else { - $salida = '".$module_value.''.'".''.$sub_string.' '."".html_print_image('images/rosette.png', true).''; - } - } - } - } - - $data[9] = $salida; - - if ($row['module_interval'] > 0) { - $interval = $row['module_interval']; - } else { - $interval = $row['agent_interval']; - } - - if ($row['estado'] == 3) { - $option = [ - 'html_attr' => 'class="redb"', - 'style' => 'font-size:7pt;', - ]; - } else { - $option = ['style' => 'font-size:7pt;']; - } - - $data[10] = ui_print_timestamp($row['utimestamp'], true, $option); - - array_push($table->data, $data); - } html_print_table($table); } else { From 698451ee98db45e1245b939cf20ab42ae6c567c7 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 13:38:58 +0100 Subject: [PATCH 157/262] MR25 Discovery Former-commit-id: 2685a72781173e3d87363fe0bc2b5dd72961cdce --- pandora_console/extras/mr/25.sql | 115 ++++++++++++++++++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 pandora_console/extras/mr/25.sql diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql new file mode 100644 index 0000000000..d6742561eb --- /dev/null +++ b/pandora_console/extras/mr/25.sql @@ -0,0 +1,115 @@ +START TRANSACTION; + +ALTER TABLE `trecon_task` ADD COLUMN `wmi_enabled` tinyint(1) unsigned DEFAULT '0'; +ALTER TABLE `trecon_task` ADD COLUMN `auth_strings` text; +ALTER TABLE `trecon_task` ADD COLUMN `autoconfiguration_enabled` tinyint(1) unsigned default '0'; + + +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware_plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); + +CREATE TABLE IF NOT EXISTS `tevent_extended` ( + `id` serial PRIMARY KEY, + `id_evento` bigint(20) unsigned NOT NULL, + `external_id` bigint(20) unsigned, + `utimestamp` bigint(20) NOT NULL default '0', + `description` text, + FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tnotification_source` ( + `id` serial, + `description` VARCHAR(255) DEFAULT NULL, + `icon` text, + `max_postpone_time` int(11) DEFAULT NULL, + `enabled` int(1) DEFAULT NULL, + `user_editable` int(1) DEFAULT NULL, + `also_mail` int(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `tnotification_source` +-- +INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, `enabled`, `user_editable`, `also_mail`) VALUES + ("System status", "icono_info_mr.png", 86400, 1, 1, 0), + ("Message", "icono_info_mr.png", 86400, 1, 1, 0), + ("Pending task", "icono_info_mr.png", 86400, 1, 1, 0), + ("Advertisement", "icono_info_mr.png", 86400, 1, 1, 0), + ("Official communication", "icono_info_mr.png", 86400, 1, 1, 0), + ("Sugerence", "icono_info_mr.png", 86400, 1, 1, 0); + +-- ----------------------------------------------------- +-- Table `tmensajes` +-- ----------------------------------------------------- +ALTER TABLE `tmensajes` ADD COLUMN `url` TEXT; +ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0'; +ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL; +ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT ''; +ALTER TABLE `tmensajes` ADD INDEX (`id_source`); +UPDATE `tmensajes` SET `id_source`=(SELECT `id` FROM `tnotification_source` WHERE `description` = "Message"); +ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +CREATE TABLE `tnotification_user` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_user` VARCHAR(60) NOT NULL, + `utimestamp_read` BIGINT(20), + `utimestamp_erased` BIGINT(20), + `postpone` INT, + PRIMARY KEY (`id_mensaje`,`id_user`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tnotification_group` ( + `id_mensaje` INT(10) UNSIGNED NOT NULL, + `id_group` mediumint(4) UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`,`id_group`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tnotification_source_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tnotification_source_group` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + PRIMARY KEY (`id_source`,`id_group`), + INDEX (`id_group`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `tnotification_source_group_user` ( + `id_source` BIGINT(20) UNSIGNED NOT NULL, + `id_group` mediumint(4) unsigned NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT(1) DEFAULT NULL, + `also_mail` INT(1) DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 6827938b42..7c1f8e2281 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1918,7 +1918,7 @@ ALTER TABLE `tmensajes` ADD COLUMN `response_mode` VARCHAR(200) DEFAULT NULL; ALTER TABLE `tmensajes` ADD COLUMN `citicity` INT(10) UNSIGNED DEFAULT '0'; ALTER TABLE `tmensajes` ADD COLUMN `id_source` BIGINT(20) UNSIGNED NOT NULL; ALTER TABLE `tmensajes` ADD COLUMN `subtype` VARCHAR(255) DEFAULT ''; -ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- ---------------------------------------------------------------------- From c12ba3b12e92f82081c5a02476fddc97b9d6be14 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 13:58:29 +0100 Subject: [PATCH 158/262] Minor MR and sql updates - presets Former-commit-id: edf310a362b58c68dcadbb078b899948430f23e3 --- pandora_console/extras/mr/25.sql | 4 ++++ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 6 ++++++ pandora_console/pandoradb_data.sql | 2 ++ 3 files changed, 12 insertions(+) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index d6742561eb..05c5978fed 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -112,4 +112,8 @@ CREATE TABLE `tnotification_source_group_user` ( INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); +INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); + +INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); + COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 7c1f8e2281..c9ae871185 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1998,6 +1998,12 @@ CREATE TABLE `tnotification_source_group_user` ( -- ---------------------------------------------------------------------- INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); +-- ---------------------------------------------------------------------- +-- Update message references and pre-configure notifications +-- ---------------------------------------------------------------------- +INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); +INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); + -- ---------------------------------------------------------------------- -- Add custom internal recon scripts -- ---------------------------------------------------------------------- diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 8fa08b7074..bce6c85d1d 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1285,4 +1285,6 @@ INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, ` INSERT INTO `tnotification_source_user`(`id_source`,`id_user`,`enabled`,`also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin",1,0); +INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); + \ No newline at end of file From fd77b94f96c7955fd1612d28c1e9859e3c7b6f20 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 14:16:17 +0100 Subject: [PATCH 159/262] Fix regexp Supervisor Former-commit-id: 7dc32dd119ae78a3158e7c5d20bc5f73a8c94d2f --- pandora_console/include/class/ConsoleSupervisor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 29ed623d6e..fa65cd5d1f 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -693,7 +693,7 @@ class ConsoleSupervisor while (false !== ($file = readdir($dir)) && $nitems <= $max_files) { if ($file != '.' && $file != '..') { if (empty($regex) === false) { - if (preg_match($regex, $file) !== 1) { + if (preg_match($regex, $file) === 1) { $nitems++; continue; } @@ -891,7 +891,7 @@ class ConsoleSupervisor $filecount = $this->countFiles( $config['remote_config'], - '/.*BADXML/', + '/^.*BADXML$/', $MAX_BADXML_FILES_DATA_IN ); // If cannot open directory, count is '-1', skip. From e32c4025a4dd1ea2015e1cd3b0f39410654899d5 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 14:18:33 +0100 Subject: [PATCH 160/262] Supervisor. minor fixes Former-commit-id: 036bc6a871db86d7a8925c7d5e2531d9f62ca839 --- pandora_console/include/class/ConsoleSupervisor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index fa65cd5d1f..4873186d62 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -697,9 +697,9 @@ class ConsoleSupervisor $nitems++; continue; } + } else { + $nitems++; } - - $nitems++; } } From 1167cfcafc4ed17fb9ce25342d4c01b080614843 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 14:27:09 +0100 Subject: [PATCH 161/262] Minor SQL fixes discovery Former-commit-id: 8d27ac99269f228b7fbb0c46b722bc5ea54c86ab --- pandora_console/extras/mr/25.sql | 12 ++++++------ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 05c5978fed..7e562b188d 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -53,7 +53,7 @@ UPDATE `tmensajes` SET `id_source`=(SELECT `id` FROM `tnotification_source` WHER ALTER TABLE `tmensajes` ADD CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -CREATE TABLE `tnotification_user` ( +CREATE TABLE IF NOT EXISTS `tnotification_user` ( `id_mensaje` INT(10) UNSIGNED NOT NULL, `id_user` VARCHAR(60) NOT NULL, `utimestamp_read` BIGINT(20), @@ -66,7 +66,7 @@ CREATE TABLE `tnotification_user` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `tnotification_group` ( +CREATE TABLE IF NOT EXISTS `tnotification_group` ( `id_mensaje` INT(10) UNSIGNED NOT NULL, `id_group` mediumint(4) UNSIGNED NOT NULL, PRIMARY KEY (`id_mensaje`,`id_group`), @@ -74,7 +74,7 @@ CREATE TABLE `tnotification_group` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `tnotification_source_user` ( +CREATE TABLE IF NOT EXISTS `tnotification_source_user` ( `id_source` BIGINT(20) UNSIGNED NOT NULL, `id_user` VARCHAR(60), `enabled` INT(1) DEFAULT NULL, @@ -86,7 +86,7 @@ CREATE TABLE `tnotification_source_user` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `tnotification_source_group` ( +CREATE TABLE IF NOT EXISTS `tnotification_source_group` ( `id_source` BIGINT(20) UNSIGNED NOT NULL, `id_group` mediumint(4) unsigned NOT NULL, PRIMARY KEY (`id_source`,`id_group`), @@ -95,7 +95,7 @@ CREATE TABLE `tnotification_source_group` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `tnotification_source_group_user` ( +CREATE TABLE IF NOT EXISTS `tnotification_source_group_user`( `id_source` BIGINT(20) UNSIGNED NOT NULL, `id_group` mediumint(4) unsigned NOT NULL, `id_user` VARCHAR(60), @@ -113,7 +113,7 @@ CREATE TABLE `tnotification_source_group_user` ( INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); - INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); +INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index c9ae871185..f2634417fb 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -2003,7 +2003,7 @@ INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fi -- ---------------------------------------------------------------------- INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); - +INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; -- ---------------------------------------------------------------------- -- Add custom internal recon scripts -- ---------------------------------------------------------------------- From 8fb84e910af5e9a626b97290fa935b4e9dabc357 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 14:29:59 +0100 Subject: [PATCH 162/262] Minor SQL fixes discovery Former-commit-id: e2513e61ea6038f0bdb8f009619dcb92f07b992e --- pandora_console/extras/mr/25.sql | 2 +- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- pandora_console/pandoradb_data.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 7e562b188d..87a37b3b48 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -113,7 +113,7 @@ CREATE TABLE IF NOT EXISTS `tnotification_source_group_user`( INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); -INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Messages"; INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index f2634417fb..e0e92f0a11 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -2002,7 +2002,7 @@ INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fi -- Update message references and pre-configure notifications -- ---------------------------------------------------------------------- INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); -INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Messages"; INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; -- ---------------------------------------------------------------------- -- Add custom internal recon scripts diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index bce6c85d1d..1ceeab65d8 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1285,6 +1285,6 @@ INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, ` INSERT INTO `tnotification_source_user`(`id_source`,`id_user`,`enabled`,`also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin",1,0); -INSERT INTO `tnotification_source_group` ((SELECT `id` FROM `tnotification_source` WHERE `description`="Messages"),0); +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Messages"; \ No newline at end of file From 6409fc2dddae52a1af7c6d4d3b7efda849ae6804 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 15:07:51 +0100 Subject: [PATCH 163/262] Added discovery name convention to server files Former-commit-id: d432ac2c5526cc05b7cbb29df66aef60a35ab0e7 --- pandora_server/lib/PandoraFMS/Config.pm | 10 +++++++--- pandora_server/lib/PandoraFMS/DiscoveryServer.pm | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 096903d6f4..0c959a5cb1 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -226,7 +226,7 @@ sub pandora_load_config { $pa_config->{"dataserver"} = 1; # default $pa_config->{"networkserver"} = 1; # default $pa_config->{"snmpconsole"} = 1; # default - $pa_config->{"reconserver"} = 1; # default + $pa_config->{"discoveryserver"} = 1; # default $pa_config->{"wmiserver"} = 1; # default $pa_config->{"pluginserver"} = 1; # default $pa_config->{"predictionserver"} = 1; # default @@ -254,6 +254,7 @@ sub pandora_load_config { $pa_config->{"plugin_threads"} = 2; # Introduced on 2.0 $pa_config->{"plugin_exec"} = '/usr/bin/timeout'; # 3.0 $pa_config->{"recon_threads"} = 2; # Introduced on 2.0 + $pa_config->{"discovery_threads"} = 2; # Introduced on 732 $pa_config->{"prediction_threads"} = 1; # Introduced on 2.0 $pa_config->{"plugin_timeout"} = 5; # Introduced on 2.0 $pa_config->{"wmi_threads"} = 2; # Introduced on 2.0 @@ -659,8 +660,8 @@ sub pandora_load_config { elsif ($parametro =~ m/^predictionserver\s+([0-9]*)/i){ $pa_config->{'predictionserver'}= clean_blank($1); } - elsif ($parametro =~ m/^reconserver\s+([0-9]*)/i) { - $pa_config->{'reconserver'}= clean_blank($1); + elsif ($parametro =~ m/^discoveryserver\s+([0-9]*)/i) { + $pa_config->{'discoveryserver'}= clean_blank($1); } elsif ($parametro =~ m/^reconserver\s+([0-9]*)/i) { $pa_config->{'reconserver'}= clean_blank($1); @@ -809,6 +810,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^autocreate_group\s+([0-9*]*)/i) { $pa_config->{'autocreate_group'}= clean_blank($1); } + elsif ($parametro =~ m/^discovery_threads\s+([0-9]*)/i) { + $pa_config->{'discovery_threads'}= clean_blank($1); + } elsif ($parametro =~ m/^recon_threads\s+([0-9]*)/i) { $pa_config->{'recon_threads'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index e43f1ca05a..137dffd822 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -100,7 +100,13 @@ sub run ($) { my $pa_config = $self->getConfig (); print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Discovery Server.", 1); - $self->setNumThreads ($pa_config->{'recon_threads'}); + my $threads = $pa_config->{'recon_threads'}; + + # Use hightest value + if ($pa_config->{'discovery_threads'} > $pa_config->{'recon_threads'}) { + $threads = $pa_config->{'discovery_threads'}; + } + $self->setNumThreads($threads); $self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem); } From e856969a59dd3fe02d934447d633ad7996553067 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 21 Feb 2019 15:13:27 +0100 Subject: [PATCH 164/262] Minor fix changed vmware_plugin reference to vmware-plugin Former-commit-id: 20e80bfffaf80583c320aa62d35e54f79e6ab03e --- pandora_console/extras/mr/25.sql | 2 +- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- pandora_console/pandoradb_data.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 87a37b3b48..7b3093497c 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -5,7 +5,7 @@ ALTER TABLE `trecon_task` ADD COLUMN `auth_strings` text; ALTER TABLE `trecon_task` ADD COLUMN `autoconfiguration_enabled` tinyint(1) unsigned default '0'; -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware_plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); CREATE TABLE IF NOT EXISTS `tevent_extended` ( diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index e0e92f0a11..ce92813d05 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -2007,5 +2007,5 @@ INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, -- ---------------------------------------------------------------------- -- Add custom internal recon scripts -- ---------------------------------------------------------------------- -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware_plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 1ceeab65d8..8dd4d3011e 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1133,7 +1133,7 @@ INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group vi -- trecon scripts INSERT INTO `trecon_script` VALUES (2,'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es> Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4> * custom_field1 = Network i.e.: 192.168.100.0/24 * custom_field2 = Username * custom_field3 = Password * custom_field4 = Additional parameters i.e.: -D LAN_2_0','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5. These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'); INSERT INTO `trecon_script` VALUES (5,'WMI Recon Script','This script is used to automatically gather host information via WMI. Available parameters: * Network = network to scan (e.g. 192.168.100.0/24). * WMI auth = comma separated list of WMI authentication tokens in the format username%password (e.g. Administrador%pass). See the documentation for more information.','/usr/share/pandora_server/util/recon_scripts/wmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"WMI auth\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}'); -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware_plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"true\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_'); From 9e9d915609b6500b8b52aa3b38019d895caeef0a Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 21 Feb 2019 15:35:44 +0100 Subject: [PATCH 165/262] Modified redirection Former-commit-id: 77dd6fee3a71064e790bd020afbcc91edbdfe20c --- .../godmode/wizards/DiscoveryTaskList.class.php | 7 +++++-- pandora_console/godmode/wizards/Wizard.main.php | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 0a7fa9b8e5..e075bb4f9e 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -295,7 +295,7 @@ class DiscoveryTaskList extends Wizard // Check if is a H&D, Cloud or Application. $data[8] = ' Date: Thu, 21 Feb 2019 18:00:50 +0100 Subject: [PATCH 167/262] discovery minor fixes Former-commit-id: 6d7a1a75bcb6844c839f34a2a2bfaf3f96734db8 --- pandora_console/godmode/servers/discovery.php | 5 ++++- .../wizards/DiscoveryTaskList.class.php | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 261cdd0696..d7ee26de86 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -134,7 +134,10 @@ if ($classname_selected !== null) { ui_print_error_message($result['msg']); } - $classname_selected = null; + // Redirect to Tasklist. + $classname_selected = 'DiscoveryTaskList'; + $wiz = new $classname_selected($page); + $result = $wiz->run(); } } diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index e075bb4f9e..179d87b2a6 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -125,17 +125,23 @@ class DiscoveryTaskList extends Wizard $task = get_parameter('task', null); if ($task !== null) { - db_process_sql_delete( + $result = db_process_sql_delete( 'trecon_task', ['id_rt' => $task] ); + + if ($result == 1) { + return [ + 'result' => 0, + 'msg' => __('Task successfully deleted'), + 'id' => false, + ]; + } + + // Trick to avoid double execution. + header('Location: '.$this->url); } - return [ - 'result' => 0, - 'msg' => __('Task successfully deleted'), - 'id' => false, - ]; } From 42448cf0d812cfad32c94f84e47eb74c0135319a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 22 Feb 2019 10:41:54 +0100 Subject: [PATCH 168/262] Updated path for discovery plugins Former-commit-id: 222373efee3c768619d5f301f3ae291009901e64 --- pandora_console/extras/mr/25.sql | 4 ++-- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 4 ++-- pandora_console/pandoradb_data.sql | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 7b3093497c..2a3eb9a297 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -5,8 +5,8 @@ ALTER TABLE `trecon_task` ADD COLUMN `auth_strings` text; ALTER TABLE `trecon_task` ADD COLUMN `autoconfiguration_enabled` tinyint(1) unsigned default '0'; -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); CREATE TABLE IF NOT EXISTS `tevent_extended` ( `id` serial PRIMARY KEY, diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index ce92813d05..c4f2325bb6 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -2007,5 +2007,5 @@ INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, -- ---------------------------------------------------------------------- -- Add custom internal recon scripts -- ---------------------------------------------------------------------- -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 8dd4d3011e..2b8245d849 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1133,8 +1133,8 @@ INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group vi -- trecon scripts INSERT INTO `trecon_script` VALUES (2,'IPMI Recon','Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es> Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> <custom_field4> * custom_field1 = Network i.e.: 192.168.100.0/24 * custom_field2 = Username * custom_field3 = Password * custom_field4 = Additional parameters i.e.: -D LAN_2_0','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Additional parameters\",\"help\":\"Optional additional parameters such as -D LAN_2_0 to use IPMI ver 2.0 instead of 1.5. These options will also be passed to the IPMI plugin when the current values are read.\",\"value\":\"\",\"hide\":\"\"}}'); INSERT INTO `trecon_script` VALUES (5,'WMI Recon Script','This script is used to automatically gather host information via WMI. Available parameters: * Network = network to scan (e.g. 192.168.100.0/24). * WMI auth = comma separated list of WMI authentication tokens in the format username%password (e.g. Administrador%pass). See the documentation for more information.','/usr/share/pandora_server/util/recon_scripts/wmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"WMI auth\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}'); -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/plugin/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); -INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/plugin/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Application.VMware', 'Discovery Application script to monitor VMware technologies (ESXi, VCenter, VSphere)', '/usr/share/pandora_server/util/recon_scripts/vmware-plugin.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); +INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Discovery.Cloud', 'Discovery Cloud script to monitor Cloud technologies (AWS.EC2, AWS.S3, AWS.RDS, RDS,ȊWS.EKS)', '/usr/share/pandora_server/util/recon_scripts/pcm_client.pl', '{"1":{"macro":"_field1_","desc":"Configuration file","help":"","value":"","hide":""}}'); INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"true\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Sensor\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Additional Options\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_'); From e65d128b25e1cf8a03f4736995d1e7159bd757d7 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 22 Feb 2019 12:40:02 +0100 Subject: [PATCH 169/262] minor fix db schema Former-commit-id: a4f87c1c7fd9da0f16a37f75cb5029ac6694baef --- pandora_console/extras/mr/25.sql | 2 +- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- pandora_console/pandoradb_data.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 2a3eb9a297..bcf6d041d7 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -113,7 +113,7 @@ CREATE TABLE IF NOT EXISTS `tnotification_source_group_user`( INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fields_descriptions`, `fields_values`) VALUES ('Generate Notification','Internal type','This command allows you to send an internal notification to any user or group.',1,'[\"Destination user\",\"Destination group\",\"Title\",\"Message\",\"Link\",\"Criticity\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); -INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Messages"; +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index c4f2325bb6..aa71ce277a 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -2002,7 +2002,7 @@ INSERT INTO `talert_commands` (`name`, `command`, `description`, `internal`, `fi -- Update message references and pre-configure notifications -- ---------------------------------------------------------------------- INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin", 1, 0); -INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Messages"; +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; -- ---------------------------------------------------------------------- -- Add custom internal recon scripts diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 2b8245d849..a9b0b25778 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1285,6 +1285,6 @@ INSERT INTO `tnotification_source`(`description`, `icon`, `max_postpone_time`, ` INSERT INTO `tnotification_source_user`(`id_source`,`id_user`,`enabled`,`also_mail`) VALUES ((SELECT `id` FROM `tnotification_source` WHERE `description`="System status"), "admin",1,0); -INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Messages"; +INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; \ No newline at end of file From 3d2bfa95b5f5af70b830338c8c8446d5b7103366 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 22 Feb 2019 12:53:35 +0100 Subject: [PATCH 170/262] add table console task in discovery Former-commit-id: b13571167c063188102a8473fb57fa63c18bece3 --- .../wizards/DiscoveryTaskList.class.php | 542 +++++++++++++++++- pandora_console/include/functions_cron.php | 458 +++++++++++++-- 2 files changed, 942 insertions(+), 58 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 179d87b2a6..af6c371b67 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -28,6 +28,8 @@ require_once __DIR__.'/Wizard.main.php'; require_once $config['homedir'].'/include/functions_users.php'; +require_once $config['homedir'].'/include/functions_reports.php'; +require_once $config['homedir'].'/include/functions_cron.php'; /** * Defined as wizard to guide user to explore running tasks. @@ -77,13 +79,22 @@ class DiscoveryTaskList extends Wizard // Load styles. parent::run(); - $delete = (bool) get_parameter('delete', false); + $force_run = (bool) get_parameter('force_run'); + if ($force_run === true) { + return $this->forceConsoleTask(); + } - if ($delete) { + $delete_console_task = (bool) get_parameter('delete_console_task'); + if ($delete_console_task === true) { + return $this->deleteConsoleTask(); + } + + $delete = (bool) get_parameter('delete', false); + if ($delete === true) { return $this->deleteTask(); } - return $this->showList(); + return $this->showListConsoleTask().''.$this->showList(); } @@ -145,6 +156,76 @@ class DiscoveryTaskList extends Wizard } + /** + * Force console task. + * + * @return void + */ + public function forceConsoleTask() + { + global $config; + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + $id_console_task = (int) get_parameter('id_console_task'); + + if ($id_console_task !== null) { + cron_task_run($id_console_task, true); + // Trick to avoid double execution. + header('Location: '.$this->url); + } + + } + + + /** + * Delete a Console task. + * + * @return void + */ + public function deleteConsoleTask() + { + global $config; + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return; + } + + $id_console_task = (int) get_parameter('id_console_task'); + + if ($id_console_task !== null) { + $result = db_process_sql_delete( + 'tuser_task_scheduled', + ['id' => $id_console_task] + ); + + if ($result == 1) { + return [ + 'result' => 0, + 'msg' => __('Console Task successfully deleted'), + 'id' => false, + ]; + } + + // Trick to avoid double execution. + header('Location: '.$this->url); + } + + } + + /** * Show complete list of running tasks. * @@ -203,7 +284,30 @@ class DiscoveryTaskList extends Wizard foreach ($servers as $serverItem) { $id_server = $serverItem['id_server']; $server_name = servers_get_name($id_server); - $recon_tasks = db_get_all_rows_field_filter('trecon_task', 'id_recon_server', $id_server); + $recon_tasks = db_get_all_rows_field_filter( + 'trecon_task', + 'id_recon_server', + $id_server + ); + + $user_groups = implode(',', array_keys(users_get_groups())); + $defined_tasks = db_get_all_rows_filter( + 'tuser_task_scheduled', + 'id_grupo IN ('.$user_groups.')' + ); + + if (isset($tasks_console) === true + && is_array($tasks_console) === true + ) { + foreach ($tasks_console as $key => $value) { + $value['parameters'] = unserialize( + $value['parameters'] + ); + + $value['type'] = 'Cron'; + array_push($recon_tasks, $value); + } + } // Show network tasks for Recon Server. if ($recon_tasks === false) { @@ -265,7 +369,9 @@ class DiscoveryTaskList extends Wizard $data[1] = ''.$task['name'].''; - $data[2] = human_time_description_raw($task['interval_sweep']); + $data[2] = human_time_description_raw( + $task['interval_sweep'] + ); if ($task['id_recon_script'] == 0) { $data[3] = $task['subnet']; @@ -281,23 +387,51 @@ class DiscoveryTaskList extends Wizard if ($task['id_recon_script'] == 0) { // Network recon task. - $data[5] = html_print_image('images/network.png', true, ['title' => __('Network recon task')]).'  '; - $data[5] .= network_profiles_get_name($task['id_network_profile']); + $data[5] = html_print_image( + 'images/network.png', + true, + ['title' => __('Network recon task')] + ).'  '; + $data[5] .= network_profiles_get_name( + $task['id_network_profile'] + ); } else { // APP recon task. - $data[5] = html_print_image('images/plugin.png', true).'  '; - $data[5] .= db_get_sql(sprintf('SELECT name FROM trecon_script WHERE id_recon_script = %d', $task['id_recon_script'])); + $data[5] = html_print_image( + 'images/plugin.png', + true + ).'  '; + $data[5] .= db_get_sql( + sprintf( + 'SELECT name FROM trecon_script WHERE id_recon_script = %d', + $task['id_recon_script'] + ) + ); } if ($task['status'] <= 0 || $task['status'] > 100) { $data[6] = '-'; } else { - $data[6] = progress_bar($task['status'], 100, 20, __('Progress').':'.$task['status'].'%', 1); + $data[6] = progress_bar( + $task['status'], + 100, + 20, + __('Progress').':'.$task['status'].'%', + 1 + ); } - $data[7] = ui_print_timestamp($task['utimestamp'], true); + $data[7] = ui_print_timestamp( + $task['utimestamp'], + true + ); - if (check_acl($config['id_user'], $task['id_group'], 'PM')) { + if (check_acl( + $config['id_user'], + $task['id_group'], + 'PM' + ) + ) { // Check if is a H&D, Cloud or Application. $data[8] = ''.html_print_image( - 'images/wrench_orange.png', + 'images/config.png', true ).''; $data[8] .= ''.html_print_image( + ).'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">'.html_print_image( 'images/cross.png', true ).''; @@ -325,6 +459,7 @@ class DiscoveryTaskList extends Wizard if (empty($table->data)) { echo '

    '.__('Server').' '.$server_name.' '.__('has no recon tasks assigned').'
    '; } else { + echo '

    '.__('Server task').'

    '; html_print_table($table); } @@ -359,6 +494,385 @@ class DiscoveryTaskList extends Wizard } + /** + * Show complete list of running tasks. + * + * @return boolean Success or not. + */ + public function showListConsoleTask() + { + global $config; + + check_login(); + + if (! check_acl($config['id_user'], 0, 'PM')) { + db_pandora_audit( + 'ACL Violation', + 'Trying to access recon task viewer' + ); + include 'general/noaccess.php'; + return false; + } + + $read_perms = check_acl( + $config['id_user'], + 0, + 'RR' + ); + $write_perms = check_acl( + $config['id_user'], + 0, + 'RW' + ); + $manage_perms = check_acl( + $config['id_user'], + 0, + 'RM' + ); + $manage_pandora = check_acl( + $config['id_user'], + 0, + 'PM' + ); + + $url = 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&'; + + $user_groups = implode( + ',', + array_keys(users_get_groups()) + ); + + $defined_tasks = db_get_all_rows_filter( + 'tuser_task_scheduled', + 'id_grupo IN ('.$user_groups.')' + ); + + if (!check_acl($config['id_user'], 0, 'PM')) { + $read_tasks = []; + foreach ($defined_tasks as $task) { + $function_name = db_get_value( + 'function_name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + + if (($function_name != 'cron_task_execute_custom_script') + && ($function_name != 'cron_task_do_backup') + ) { + $read_tasks[] = $task; + } + } + + $defined_tasks = $read_tasks; + + if (empty($defined_tasks)) { + $defined_tasks = false; + } + } + + if ($defined_tasks !== false) { + echo '

    '.__('Console task').'

    '; + + $table = new stdClass(); + $table->class = 'databox data'; + $table->width = '100%'; + $table->data = []; + $table->head = []; + $table->head[0] = ''; + $table->head[1] = __('User'); + $table->head[2] = __('Task'); + $table->head[3] = __('Scheduled'); + $table->head[4] = __('Next execution'); + $table->head[5] = __('Last run'); + $table->head[6] = __('Group'); + $table->head[7] = __('Operations'); + $table->align[7] = 'left'; + + foreach ($defined_tasks as $task) { + $data = []; + + $function_name = db_get_value( + 'function_name', + 'tuser_task', + 'id', + $task['id_user_task'] + ); + + switch ($function_name) { + case 'cron_task_generate_report': + if ($write_perms || $manage_pandora) { + $data[0] = ''; + $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); + } + + return true; + } + + /** * Return target url sub-string to edit target task. * 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); + } } From eb56fd566c41afa2ec2b517fae4230102892ccfb Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Fri, 22 Feb 2019 13:07:47 +0100 Subject: [PATCH 171/262] implemented services treeview Former-commit-id: d5d71442d0c6122ba91b160647559cdf03f55625 --- pandora_console/images/tree_events.png | Bin 0 -> 329 bytes pandora_console/images/tree_service_map.png | Bin 0 -> 401 bytes pandora_console/include/ajax/tree.ajax.php | 300 ++- pandora_console/include/class/Tree.class.php | 1819 ++++++++-------- .../include/class/TreeGroup.class.php | 786 ++++--- .../include/class/TreeGroupEdition.class.php | 184 +- .../include/class/TreeService.class.php | 342 +++ .../include/javascript/tree/TreeController.js | 1880 +++++++++-------- pandora_console/include/styles/pandora.css | 4 +- pandora_console/operation/events/events.php | 1 + pandora_console/operation/tree.php | 444 ++-- 11 files changed, 2973 insertions(+), 2787 deletions(-) create mode 100644 pandora_console/images/tree_events.png create mode 100644 pandora_console/images/tree_service_map.png create mode 100644 pandora_console/include/class/TreeService.class.php diff --git a/pandora_console/images/tree_events.png b/pandora_console/images/tree_events.png new file mode 100644 index 0000000000000000000000000000000000000000..7628d6a80d852ba73d65176446ae08840da77f7f GIT binary patch literal 329 zcmV-P0k-~$P)q$gGRCwB~mC+4@AP|PpIDjK`1e@?q zSLh}>LF)wC4IBmEd0>M&f_?D4KM85bg(?D_X0SbKep7s{(LZPy@X;JH=p?`oQQeRS_ zH1+jJWe8NzT0-TT3Z?0{sPo&Ni1Sb^yx>uLKAHJX6x43U6@K^Bbqwt&AJ}x5hH7{E zbyU~#WGgNJK2ta9)S-`oYN(uYL%YzxP^g4T8FQaD?)Bx`wr#!rLj*O73mtOa{F3E0 b`4wOQT9iM?aWo@)00000NkvXXu0mjfMuUuS literal 0 HcmV?d00001 diff --git a/pandora_console/images/tree_service_map.png b/pandora_console/images/tree_service_map.png new file mode 100644 index 0000000000000000000000000000000000000000..16005f1c984dead9ac88069241b40d76c7501466 GIT binary patch literal 401 zcmV;C0dD?@P)Ug!OY$R9aJUg32_zw>?E=;}_>=v@ZuGlr7ffX(;SHhU3Jr_^t5e?c`xW z%a!9*MxJFvld!|=hpy|cXq}7Et-Y+}OnMw;scaF47IcYhEtcyl6Q{I9BlgIH^a; vPFvncDbp70;dyjK9}YJAdf@j&-vt-|K80iT031UL00000NkvXXu0mjf?0~A# literal 0 HcmV?d00001 diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 6c8365a924..21df029b0a 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -3,173 +3,163 @@ // ================================================== // Copyright (c) 2005-2012 Artica Soluciones Tecnologicas // Please see http://pandorafms.org for full contribution list + // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; version 2 + // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. + // Only accesible by ajax -if (is_ajax()) { - global $config; +if (is_ajax ()) { + global $config; + + enterprise_include_once("include/functions_dashboard.php"); - enterprise_include_once('include/functions_dashboard.php'); + $public_hash = get_parameter('hash', 0); - $public_hash = get_parameter('hash', 0); + // Try to authenticate by hash on public dashboards + if ($public_hash == 0) { + // Login check + check_login(); + } else { + $validate_hash = enterprise_hook( + 'dasboard_validate_public_hash', + array($public_hash, 'tree_view') + ); + if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { + db_pandora_audit("Invalid public hash", "Trying to access report builder"); + require ("general/noaccess.php"); + exit; + } + } + + require_once($config['homedir'] . "/include/class/Tree.class.php"); + require_once($config['homedir'] . "/include/class/TreeOS.class.php"); + require_once($config['homedir'] . "/include/class/TreeModuleGroup.class.php"); + require_once($config['homedir'] . "/include/class/TreeModule.class.php"); + require_once($config['homedir'] . "/include/class/TreeTag.class.php"); + require_once($config['homedir'] . "/include/class/TreeGroup.class.php"); + require_once($config['homedir'] . "/include/class/TreeService.class.php"); + require_once($config['homedir'] . "/include/class/TreeGroupEdition.class.php"); + enterprise_include_once("include/class/TreePolicies.class.php"); + enterprise_include_once("include/class/TreeGroupMeta.class.php"); + require_once($config['homedir'] . "/include/functions_reporting.php"); + require_once($config['homedir'] . "/include/functions_os.php"); + + $getChildren = (bool) get_parameter('getChildren', 0); + $getGroupStatus = (bool) get_parameter('getGroupStatus', 0); + $getDetail = (bool) get_parameter('getDetail'); + + if ($getChildren) { + $type = get_parameter('type', 'group'); + $rootType = get_parameter('rootType', ''); + $id = get_parameter('id', -1); + $rootID = get_parameter('rootID', -1); + $serverID = get_parameter('serverID', false); + $childrenMethod = get_parameter('childrenMethod', 'on_demand'); + $hash = get_parameter('hash', false); + if ($hash !== false) { + enterprise_hook('dasboard_validate_public_hash', array($hash, 'tree_view')); + } - // Try to authenticate by hash on public dashboards - if ($public_hash == 0) { - // Login check - check_login(); - } else { - $validate_hash = enterprise_hook( - 'dasboard_validate_public_hash', - [ - $public_hash, - 'tree_view', - ] - ); - if ($validate_hash === false || $validate_hash === ENTERPRISE_NOT_HOOK) { - db_pandora_audit('Invalid public hash', 'Trying to access report builder'); - include 'general/noaccess.php'; - exit; - } - } + $default_filters = array( + 'searchAgent' => '', + 'statusAgent' => AGENT_STATUS_ALL, + 'searchModule' => '', + 'statusModule' => -1, + 'groupID' => 0, + 'tagID' => 0, + ); + $filter = get_parameter('filter', $default_filters); - include_once $config['homedir'].'/include/class/Tree.class.php'; - include_once $config['homedir'].'/include/class/TreeOS.class.php'; - include_once $config['homedir'].'/include/class/TreeModuleGroup.class.php'; - include_once $config['homedir'].'/include/class/TreeModule.class.php'; - include_once $config['homedir'].'/include/class/TreeTag.class.php'; - include_once $config['homedir'].'/include/class/TreeGroup.class.php'; - include_once $config['homedir'].'/include/class/TreeGroupEdition.class.php'; - enterprise_include_once('include/class/TreePolicies.class.php'); - enterprise_include_once('include/class/TreeGroupMeta.class.php'); - include_once $config['homedir'].'/include/functions_reporting.php'; - include_once $config['homedir'].'/include/functions_os.php'; + $agent_a = check_acl ($config['id_user'], 0, "AR"); + $agent_w = check_acl ($config['id_user'], 0, "AW"); + $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); + $switch_type = !empty($rootType) ? $rootType : $type; + switch ($switch_type) { + case 'os': + $tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + case 'module_group': + $tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + case 'module': + $tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + case 'tag': + $tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + case 'group': + if(is_metaconsole()){ + if (!class_exists('TreeGroupMeta')) break; + $tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + } + else{ + $tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + } + break; + case 'policies': + if (!class_exists('TreePolicies')) break; + $tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + case 'group_edition': + $tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + case 'services': + $tree = new TreeService($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + break; + default: + // FIXME. No error handler + return; + } - $getChildren = (bool) get_parameter('getChildren', 0); - $getGroupStatus = (bool) get_parameter('getGroupStatus', 0); - $getDetail = (bool) get_parameter('getDetail'); + $tree->setFilter($filter); + ob_clean(); - if ($getChildren) { - $type = get_parameter('type', 'group'); - $rootType = get_parameter('rootType', ''); - $id = get_parameter('id', -1); - $rootID = get_parameter('rootID', -1); - $serverID = get_parameter('serverID', false); - $childrenMethod = get_parameter('childrenMethod', 'on_demand'); - $hash = get_parameter('hash', false); - if ($hash !== false) { - enterprise_hook('dasboard_validate_public_hash', [$hash, 'tree_view']); - } - - $default_filters = [ - 'searchAgent' => '', - 'statusAgent' => AGENT_STATUS_ALL, - 'searchModule' => '', - 'statusModule' => -1, - 'groupID' => 0, - 'tagID' => 0, - ]; - $filter = get_parameter('filter', $default_filters); - - $agent_a = check_acl($config['id_user'], 0, 'AR'); - $agent_w = check_acl($config['id_user'], 0, 'AW'); - $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); - $switch_type = !empty($rootType) ? $rootType : $type; - switch ($switch_type) { - case 'os': - $tree = new TreeOS($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - break; - - case 'module_group': - $tree = new TreeModuleGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - break; - - case 'module': - $tree = new TreeModule($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - break; - - case 'tag': - $tree = new TreeTag($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - break; - - case 'group': - if (is_metaconsole()) { - if (!class_exists('TreeGroupMeta')) { - break; - } - - $tree = new TreeGroupMeta($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - } else { - $tree = new TreeGroup($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - } - break; - - case 'policies': - if (!class_exists('TreePolicies')) { - break; - } - - $tree = new TreePolicies($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - break; - - case 'group_edition': - $tree = new TreeGroupEdition($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - break; - - default: - // FIXME. No error handler - return; - } - - $tree->setFilter($filter); - ob_clean(); - echo json_encode(['success' => 1, 'tree' => $tree->getArray()]); - return; - } - - if ($getDetail) { - include_once $config['homedir'].'/include/functions_treeview.php'; - - $id = (int) get_parameter('id'); - $type = (string) get_parameter('type'); - - $server = []; - if (is_metaconsole()) { - $server_id = (int) get_parameter('serverID'); - $server = metaconsole_get_servers($server_id); - } - - ob_clean(); - - echo '
    '; - if (!empty($id) && !empty($type)) { - switch ($type) { - case 'agent': - treeview_printTable($id, $server, true); - break; - - case 'module': - treeview_printModuleTable($id, $server, true); - break; - - case 'alert': - treeview_printAlertsTable($id, $server, true); - break; - - default: - // Nothing - break; - } - } - - echo '
    '; - - return; - } - - return; + echo json_encode(array('success' => 1, 'tree' => $tree->getArray())); + return; + } + + if ($getDetail) { + require_once($config['homedir']."/include/functions_treeview.php"); + + $id = (int) get_parameter('id'); + $type = (string) get_parameter('type'); + + $server = array(); + if (is_metaconsole()) { + $server_id = (int) get_parameter('serverID'); + $server = metaconsole_get_servers($server_id); + } + + ob_clean(); + + echo '
    '; + if (!empty($id) && !empty($type)) { + switch ($type) { + case 'agent': + treeview_printTable($id, $server, true); + break; + case 'module': + treeview_printModuleTable($id, $server, true); + break; + case 'alert': + treeview_printAlertsTable($id, $server, true); + break; + default: + // Nothing + break; + } + } + echo '
    '; + + return; + } + + return; } +?> \ No newline at end of file diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index eda92b48b5..da0380f4ea 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -1,904 +1,762 @@ type = $type; + $this->rootType = !empty($rootType) ? $rootType : $type; + $this->id = $id; + $this->rootID = !empty($rootID) ? $rootID : $id; + $this->serverID = $serverID; + if (is_metaconsole()) { + $this->serverName = metaconsole_get_server_by_id($serverID); + } + $this->childrenMethod = $childrenMethod; + $this->access = $access; - protected $userGroupsACL; + $userGroupsACL = users_get_groups(false, $this->access); - protected $userGroups; + $this->userGroupsACL = empty($userGroupsACL) ? false : $userGroupsACL; + $this->userGroups = $this->userGroupsACL; + $this->userGroupsArray = array_keys($this->userGroups); - protected $userGroupsArray; + global $config; + include_once($config['homedir']."/include/functions_servers.php"); + include_once($config['homedir']."/include/functions_modules.php"); + require_once($config['homedir']."/include/functions_tags.php"); + enterprise_include_once("include/functions_agents.php"); - protected $access = false; + if (is_metaconsole()) enterprise_include_once("meta/include/functions_ui_meta.php"); + } - protected $L1fieldName = ''; + public function setFilter($filter) { + // There is not module filter in metaconsole. + if (is_metaconsole()) { + $filter['searchModule'] = ""; + $filter['statusModule'] = self::TV_DEFAULT_AGENT_STATUS; + } + $this->filter = $filter; + } - protected $L1fieldNameSql = ''; + protected function getEmptyModuleFilterStatus() { + return ( + !isset($this->filter['statusModule']) || + $this->filter['statusModule'] == -1 + ); + } - protected $L1extraFields = []; + protected function getModuleSearchFilter() { + if (empty($this->filter['searchModule'])) { + return ""; + } + return " AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' "; + } - protected $L1inner = ''; - - protected $L1innerInside = ''; - - protected $L1orderByFinal = ''; - - protected $L2condition = ''; - - protected $L2conditionInside = ''; - - protected $L2inner = ''; - - protected $L3forceTagCondition = false; - - const TV_DEFAULT_AGENT_STATUS = -1; + protected function getAgentSearchFilter() { + if (empty($this->filter['searchAgent'])) return ""; + return " AND LOWER(ta.alias) LIKE LOWER('%%".$this->filter['searchAgent']."%%')"; + } - public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR') - { - $this->type = $type; - $this->rootType = !empty($rootType) ? $rootType : $type; - $this->id = $id; - $this->rootID = !empty($rootID) ? $rootID : $id; - $this->serverID = $serverID; - if (is_metaconsole()) { - $this->serverName = metaconsole_get_server_by_id($serverID); - } + protected function getAgentStatusFilter ($status = self::TV_DEFAULT_AGENT_STATUS) { + if ($status == self::TV_DEFAULT_AGENT_STATUS) + $status = $this->filter['statusAgent']; - $this->childrenMethod = $childrenMethod; - $this->access = $access; - - $userGroupsACL = users_get_groups(false, $this->access); - $this->userGroupsACL = empty($userGroupsACL) ? false : $userGroupsACL; - $this->userGroups = $this->userGroupsACL; - $this->userGroupsArray = array_keys($this->userGroups); - - global $config; - include_once $config['homedir'].'/include/functions_servers.php'; - include_once $config['homedir'].'/include/functions_modules.php'; - include_once $config['homedir'].'/include/functions_tags.php'; - enterprise_include_once('include/functions_agents.php'); - - if (is_metaconsole()) { - enterprise_include_once('meta/include/functions_ui_meta.php'); - } - } - - - public function setFilter($filter) - { - // There is not module filter in metaconsole. - if (is_metaconsole()) { - $filter['searchModule'] = ''; - $filter['statusModule'] = self::TV_DEFAULT_AGENT_STATUS; - } - - $this->filter = $filter; - } - - - protected function getEmptyModuleFilterStatus() - { - return ( - !isset($this->filter['statusModule']) || - $this->filter['statusModule'] == -1 - ); - } - - - protected function getModuleSearchFilter() - { - if (empty($this->filter['searchModule'])) { - return ''; - } - - return " AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' "; - } - - - protected function getAgentSearchFilter() - { - if (empty($this->filter['searchAgent'])) { - return ''; - } - - return " AND LOWER(ta.alias) LIKE LOWER('%%".$this->filter['searchAgent']."%%')"; - } - - - protected function getAgentStatusFilter($status=self::TV_DEFAULT_AGENT_STATUS) - { - if ($status == self::TV_DEFAULT_AGENT_STATUS) { - $status = $this->filter['statusAgent']; - } - - $agent_status_filter = ''; - switch ($status) { - case AGENT_STATUS_ALL: - break; - - case AGENT_STATUS_NOT_INIT: - $agent_status_filter = ' AND (ta.total_count = 0 - OR ta.total_count = ta.notinit_count) '; - break; - - case AGENT_STATUS_CRITICAL: - $agent_status_filter = ' AND ta.critical_count > 0 '; - break; - - case AGENT_STATUS_WARNING: - $agent_status_filter = ' AND (ta.critical_count = 0 - AND ta.warning_count > 0) '; - break; - - case AGENT_STATUS_UNKNOWN: - $agent_status_filter = ' AND (ta.critical_count = 0 + $agent_status_filter = ""; + switch ($status) { + case AGENT_STATUS_ALL: + break; + case AGENT_STATUS_NOT_INIT: + $agent_status_filter = " AND (ta.total_count = 0 + OR ta.total_count = ta.notinit_count) "; + break; + case AGENT_STATUS_CRITICAL: + $agent_status_filter = " AND ta.critical_count > 0 "; + break; + case AGENT_STATUS_WARNING: + $agent_status_filter = " AND (ta.critical_count = 0 + AND ta.warning_count > 0) "; + break; + case AGENT_STATUS_UNKNOWN: + $agent_status_filter = " AND (ta.critical_count = 0 AND ta.warning_count = 0 - AND ta.unknown_count > 0) '; - break; - - case AGENT_STATUS_NORMAL: - $agent_status_filter = ' AND (ta.critical_count = 0 + AND ta.unknown_count > 0) "; + break; + case AGENT_STATUS_NORMAL: + $agent_status_filter = " AND (ta.critical_count = 0 AND ta.warning_count = 0 AND ta.unknown_count = 0 - AND ta.normal_count > 0) '; - break; - } + AND ta.normal_count > 0) "; + break; + } - return $agent_status_filter; - } + return $agent_status_filter; + } + protected function getFirstLevelFields() { + $fields = array ( + "g AS " . $this->L1fieldName, + "SUM(x_critical) AS total_critical_count", + "SUM(x_warning) AS total_warning_count", + "SUM(x_normal) AS total_normal_count", + "SUM(x_unknown) AS total_unknown_count", + "SUM(x_not_init) AS total_not_init_count", + "SUM(x_alerts) AS total_alerts_count", + "SUM(x_total) AS total_count" + ); + return implode(",", array_merge($fields, $this->L1extraFields)); + } - protected function getFirstLevelFields() - { - $fields = [ - 'g AS '.$this->L1fieldName, - 'SUM(x_critical) AS total_critical_count', - 'SUM(x_warning) AS total_warning_count', - 'SUM(x_normal) AS total_normal_count', - 'SUM(x_unknown) AS total_unknown_count', - 'SUM(x_not_init) AS total_not_init_count', - 'SUM(x_alerts) AS total_alerts_count', - 'SUM(x_total) AS total_count', - ]; - return implode(',', array_merge($fields, $this->L1extraFields)); - } + protected function getFirstLevelFieldsInside() { + return array( + 'warning' => array( + 'header' => "0 AS x_critical, SUM(total) AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_WARNING, $this->filter['show_not_init_agents']) + ), + 'critical' => array( + 'header' => "SUM(total) AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_CRITICAL, $this->filter['show_not_init_agents']) + ), + 'normal' => array( + 'header' => "0 AS x_critical, 0 AS x_warning, SUM(total) AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_NORMAL, $this->filter['show_not_init_agents']) + ), + 'unknown' => array( + 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, SUM(total) AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_UNKNOWN, $this->filter['show_not_init_agents']) + ), + 'not_init' => array( + 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, SUM(total) AS x_not_init, 0 AS x_alerts, 0 AS x_total, g", + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_NOT_INIT, $this->filter['show_not_init_agents']) + ), + 'alerts' => array( + 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, SUM(total) AS x_alerts, 0 AS x_total, g", + 'condition' => "AND ta.fired_count > 0" + ), + 'total' => array( + 'header' => "0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, SUM(total) AS x_total, g", + 'condition' => "AND " . agents_get_status_clause(AGENT_STATUS_ALL, $this->filter['show_not_init_agents']) + ) + ); + } + protected function getInnerOrLeftJoin () { + return $this->filter['show_not_init_agents'] + ? "LEFT" + : "INNER"; + } - protected function getFirstLevelFieldsInside() - { - return [ - 'warning' => [ - 'header' => '0 AS x_critical, SUM(total) AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g', - 'condition' => 'AND '.agents_get_status_clause(AGENT_STATUS_WARNING, $this->filter['show_not_init_agents']), - ], - 'critical' => [ - 'header' => 'SUM(total) AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g', - 'condition' => 'AND '.agents_get_status_clause(AGENT_STATUS_CRITICAL, $this->filter['show_not_init_agents']), - ], - 'normal' => [ - 'header' => '0 AS x_critical, 0 AS x_warning, SUM(total) AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g', - 'condition' => 'AND '.agents_get_status_clause(AGENT_STATUS_NORMAL, $this->filter['show_not_init_agents']), - ], - 'unknown' => [ - 'header' => '0 AS x_critical, 0 AS x_warning, 0 AS x_normal, SUM(total) AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, 0 AS x_total, g', - 'condition' => 'AND '.agents_get_status_clause(AGENT_STATUS_UNKNOWN, $this->filter['show_not_init_agents']), - ], - 'not_init' => [ - 'header' => '0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, SUM(total) AS x_not_init, 0 AS x_alerts, 0 AS x_total, g', - 'condition' => 'AND '.agents_get_status_clause(AGENT_STATUS_NOT_INIT, $this->filter['show_not_init_agents']), - ], - 'alerts' => [ - 'header' => '0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, SUM(total) AS x_alerts, 0 AS x_total, g', - 'condition' => 'AND ta.fired_count > 0', - ], - 'total' => [ - 'header' => '0 AS x_critical, 0 AS x_warning, 0 AS x_normal, 0 AS x_unknown, 0 AS x_not_init, 0 AS x_alerts, SUM(total) AS x_total, g', - 'condition' => 'AND '.agents_get_status_clause(AGENT_STATUS_ALL, $this->filter['show_not_init_agents']), - ], - ]; - } + protected function getModuleStatusFilter () { + $show_init_condition = ($this->filter['show_not_init_agents']) + ? "" + : " AND ta.notinit_count <> ta.total_count"; + if ($this->getEmptyModuleFilterStatus()) { + return $show_init_condition; + } - protected function getInnerOrLeftJoin() - { - return $this->filter['show_not_init_agents'] ? 'LEFT' : 'INNER'; - } + $field_filter = modules_get_counter_by_states($this->filter['statusModule']); + if ($field_filter === false) return " AND 1=0"; + return "AND ta.$field_filter > 0" . $show_init_condition; + } - protected function getModuleStatusFilter() - { - $show_init_condition = ($this->filter['show_not_init_agents']) ? '' : ' AND ta.notinit_count <> ta.total_count'; - - if ($this->getEmptyModuleFilterStatus()) { - return $show_init_condition; - } - - $field_filter = modules_get_counter_by_states($this->filter['statusModule']); - if ($field_filter === false) { - return ' AND 1=0'; - } - - return "AND ta.$field_filter > 0".$show_init_condition; - } - - - protected function getTagJoin() - { - return 'INNER JOIN ttag_module ttm + protected function getTagJoin () { + return 'INNER JOIN ttag_module ttm ON tam.id_agente_modulo = ttm.id_agente_modulo'; - } + } + protected function getTagCondition () { + $tags = tags_get_user_applied_agent_tags($this->id, "AR"); + // All tags permision, returns no condition + if ($tags === true) return ""; + // No permision, do not show anything + if ($tags === false) return " AND 1=0"; + $tags_sql = implode(',', $tags); + return "AND ttm.id_tag IN ($tags_sql)";; + } - protected function getTagCondition() - { - $tags = tags_get_user_applied_agent_tags($this->id, 'AR'); - // All tags permision, returns no condition - if ($tags === true) { - return ''; - } + protected function getModuleStatusFilterFromTestado ($state = false, $without_ands = false) { + $selected_status = ($state !== false && $state !== self::TV_DEFAULT_AGENT_STATUS) + ? $state + : $this->filter['statusModule']; - // No permision, do not show anything - if ($tags === false) { - return ' AND 1=0'; - } + $filter = array( + modules_get_state_condition($selected_status) + ); + if (!$this->filter['show_not_init_modules'] && $state === false) { + if (!empty($filter)) + $filter[] = "( + tae.estado <> ".AGENT_MODULE_STATUS_NO_DATA." + AND tae.estado <> ".AGENT_MODULE_STATUS_NOT_INIT." + )"; + } + $filter = implode(" AND ", $filter); + return ($without_ands) + ? $filter + : " AND $filter "; + } - $tags_sql = implode(',', $tags); - return "AND ttm.id_tag IN ($tags_sql)"; - ; - } + public function getGroupAclCondition() { + if (users_can_manage_group_all("AR")) return ""; - - protected function getModuleStatusFilterFromTestado($state=false, $without_ands=false) - { - $selected_status = ($state !== false && $state !== self::TV_DEFAULT_AGENT_STATUS) ? $state : $this->filter['statusModule']; - - $filter = [modules_get_state_condition($selected_status)]; - if (!$this->filter['show_not_init_modules'] && $state === false) { - if (!empty($filter)) { - $filter[] = '( - tae.estado <> '.AGENT_MODULE_STATUS_NO_DATA.' - AND tae.estado <> '.AGENT_MODULE_STATUS_NOT_INIT.' - )'; - } - } - - $filter = implode(' AND ', $filter); - return ($without_ands) ? $filter : " AND $filter "; - } - - - public function getGroupAclCondition() - { - if (users_can_manage_group_all('AR')) { - return ''; - } - - $groups_str = implode(',', $this->userGroupsArray); - return " AND ( + $groups_str= implode(",", $this->userGroupsArray); + return " AND ( ta.id_grupo IN ($groups_str) OR tasg.id_group IN ($groups_str) )"; - } + } - - protected function getGroupSearchInner() - { - if (empty($this->filter['searchGroup'])) { - return ''; - } - - return 'INNER JOIN tgrupo tg + protected function getGroupSearchInner() { + if (empty($this->filter['searchGroup'])) return ""; + return "INNER JOIN tgrupo tg ON ta.id_grupo = tg.id_grupo - OR tasg.id_group = tg.id_grupo'; - } - - - protected function getGroupSearchFilter() - { - if (empty($this->filter['searchGroup'])) { - return ''; - } - - return " AND tg.nombre LIKE '%%".$this->filter['searchGroup']."%%'"; - } - - - static function cmpSortNames($a, $b) - { - return strcmp($a['name'], $b['name']); - } - - - protected function getProcessedItem($item, $server=false) - { - if (isset($processed_item['is_processed']) && $processed_item['is_processed']) { - return $item; - } - - $processed_item = []; - $processed_item['id'] = $item['id']; - $processed_item['name'] = $item['name']; - $processed_item['rootID'] = $item['id']; - $processed_item['rootType'] = $this->rootType; - $processed_item['searchChildren'] = 1; - - if (isset($item['type'])) { - $processed_item['type'] = $item['type']; - } else { - $processed_item['type'] = $this->type; - } - - if (isset($item['rootType'])) { - $processed_item['rootType'] = $item['rootType']; - } else { - $processed_item['rootType'] = $this->rootType; - } - - if ($processed_item['type'] == 'group') { - $processed_item['parent'] = $item['parent']; - - $processed_item['icon'] = empty($item['icon']) ? 'without_group.png' : $item['icon'].'.png'; - } - - if (isset($item['iconHTML'])) { - $processed_item['icon'] = $item['iconHTML']; - } - - if (is_metaconsole() && !empty($server)) { - $processed_item['serverID'] = $server['id']; - } - - $counters = []; - if (isset($item['total_unknown_count'])) { - $counters['unknown'] = $item['total_unknown_count']; - } - - if (isset($item['total_critical_count'])) { - $counters['critical'] = $item['total_critical_count']; - } - - if (isset($item['total_warning_count'])) { - $counters['warning'] = $item['total_warning_count']; - } - - if (isset($item['total_not_init_count'])) { - $counters['not_init'] = $item['total_not_init_count']; - } - - if (isset($item['total_normal_count'])) { - $counters['ok'] = $item['total_normal_count']; - } - - if (isset($item['total_count'])) { - $counters['total'] = $item['total_count']; - } - - if (isset($item['total_fired_count'])) { - $counters['alerts'] = $item['total_fired_count']; - } - - if (!empty($counters)) { - $processed_item['counters'] = $counters; - } - - if (!empty($processed_item)) { - $processed_item['is_processed'] = true; - } - - return $processed_item; - } - - - // This function should be used only when retrieving the data of the metaconsole's nodes - protected function getMergedItems($items) - { - // This variable holds the result - $mergedItems = []; - - foreach ($items as $key => $item) { - // Avoid the deleted items - if (!isset($items[$key]) || empty($item)) { - continue; - } - - // Store the item in a temporary element - $resultItem = $item; - - // The 'id' parameter will be stored as 'server_id' => 'id' - $resultItem['id'] = []; - $resultItem['id'][$item['serverID']] = $item['id']; - $resultItem['rootID'] = []; - $resultItem['rootID'][$item['serverID']] = $item['rootID']; - $resultItem['serverID'] = []; - $resultItem['serverID'][$item['serverID']] = $item['rootID']; - - // Initialize counters if any of it don't exist - if (!isset($resultItem['counters'])) { - $resultItem['counters'] = []; - } - - if (!isset($resultItem['counters']['unknown'])) { - $resultItem['counters']['unknown'] = 0; - } - - if (!isset($resultItem['counters']['critical'])) { - $resultItem['counters']['critical'] = 0; - } - - if (!isset($resultItem['counters']['warning'])) { - $resultItem['counters']['warning'] = 0; - } - - if (!isset($resultItem['counters']['not_init'])) { - $resultItem['counters']['not_init'] = 0; - } - - if (!isset($resultItem['counters']['ok'])) { - $resultItem['counters']['ok'] = 0; - } - - if (!isset($resultItem['counters']['total'])) { - $resultItem['counters']['total'] = 0; - } - - if (!isset($resultItem['counters']['alerts'])) { - $resultItem['counters']['alerts'] = 0; - } - - if ($item['type'] == 'group') { - // Add the children - if (!isset($resultItem['children'])) { - $resultItem['children'] = []; - } - } - - // Iterate over the list to search items that match the actual item - foreach ($items as $key2 => $item2) { - // Skip the actual or empty items - if ($key == $key2 || !isset($items[$key2])) { - continue; - } - - // Match with the name and type - if ($item['name'] == $item2['name'] && $item['type'] == $item2['type']) { - // Add the matched ids - $resultItem['id'][$item2['serverID']] = $item2['id']; - $resultItem['rootID'][$item2['serverID']] = $item2['rootID']; - $resultItem['serverID'][$item2['serverID']] = $item2['rootID']; - - // Add the matched counters - if (isset($item2['counters']) && !empty($item2['counters'])) { - foreach ($item2['counters'] as $type => $value) { - if (isset($resultItem['counters'][$type])) { - $resultItem['counters'][$type] += $value; - } - } - } - - if ($item['type'] == 'group') { - // Add the matched children - if (isset($item2['children'])) { - $resultItem['children'] = array_merge($resultItem['children'], $item2['children']); - } - } - - // Remove the item - unset($items[$key2]); - } - } - - if ($item['type'] == 'group') { - // Get the merged children (recursion) - if (!empty($resultItem['children'])) { - $resultItem['children'] = $this->getMergedItems($resultItem['children']); - } - } - - // Add the resulting item - if (!empty($resultItem) && !empty($resultItem['counters']['total'])) { - $mergedItems[] = $resultItem; - } - - // Remove the item - unset($items[$key]); - } - - usort($mergedItems, ['Tree', 'cmpSortNames']); - - return $mergedItems; - } - - - protected function processModule(&$module, $server=false, $all_groups) - { - global $config; - - if (isset($module['children'])) { - foreach ($module['children'] as $i => $children) { - $this->processModule($module['children'][$i], $server, $all_groups); - } - } - - $module['type'] = 'module'; - $module['id'] = (int) $module['id']; - $module['name'] = io_safe_output($module['name']); - $module['id_module_type'] = (int) $module['id_tipo_modulo']; - $module['server_type'] = (int) $module['id_modulo']; - $module['status'] = $module['estado']; - $module['value'] = $module['datos']; - - if (is_metaconsole()) { - $module['serverID'] = $this->serverID; - $module['serverName'] = $this->serverName; - } else { - $module['serverName'] = false; - $module['serverID'] = false; - } - - if (!isset($module['value'])) { - $module['value'] = modules_get_last_value($module['id']); - } - - // Status - switch ($module['status']) { - case AGENT_MODULE_STATUS_CRITICAL_ALERT: - $module['alert'] = 1; - case AGENT_MODULE_STATUS_CRITICAL_BAD: - $statusType = STATUS_MODULE_CRITICAL_BALL; - $statusTitle = __('CRITICAL'); - $module['statusText'] = 'critical'; - break; - - case AGENT_MODULE_STATUS_WARNING_ALERT: - $module['alert'] = 1; - case AGENT_MODULE_STATUS_WARNING: - $statusType = STATUS_MODULE_WARNING_BALL; - $statusTitle = __('WARNING'); - $module['statusText'] = 'warning'; - break; - - case AGENT_MODULE_STATUS_UNKNOWN: - $statusType = STATUS_MODULE_UNKNOWN_BALL; - $statusTitle = __('UNKNOWN'); - $module['statusText'] = 'unknown'; - break; - - case AGENT_MODULE_STATUS_NO_DATA: - case AGENT_MODULE_STATUS_NOT_INIT: - $statusType = STATUS_MODULE_NO_DATA_BALL; - $statusTitle = __('NO DATA'); - $module['statusText'] = 'not_init'; - break; - - case AGENT_MODULE_STATUS_NORMAL_ALERT: - $module['alert'] = 1; - case AGENT_MODULE_STATUS_NORMAL: - default: - $statusType = STATUS_MODULE_OK_BALL; - $statusTitle = __('NORMAL'); - $module['statusText'] = 'ok'; - break; - } - - if ($statusType !== STATUS_MODULE_UNKNOWN_BALL - && $statusType !== STATUS_MODULE_NO_DATA_BALL - ) { - if (is_numeric($module['value'])) { - $statusTitle .= ' : '.format_for_graph($module['value']); - } else { - $statusTitle .= ' : '.substr(io_safe_output($module['value']), 0, 42); - } - } - - $module['statusImageHTML'] = ui_print_status_image($statusType, $statusTitle, true); - - // HTML of the server type image - $module['serverTypeHTML'] = servers_show_type($module['server_type']); - - // Link to the Module graph - // ACL - $acl_graphs = false; - $module['showGraphs'] = 0; - - // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions - if (!empty($group_id) && !is_metaconsole()) { - $acl_graphs = check_acl_one_of_groups($config['id_user'], $all_groups, 'RR'); - } else if (!empty($all_groups)) { - $acl_graphs = true; - } - - if ($acl_graphs) { - $module['showGraphs'] = 1; - } - - if ($module['showGraphs']) { - $graphType = return_graphtype($module['id_module_type']); - $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); - $winHandle = dechex(crc32($module['id'].$module['name'])); - - $graph_params = [ - 'type' => $graphType, - 'period' => SECONDS_1DAY, - 'id' => $module['id'], - 'label' => base64_encode($module['name']), - 'refresh' => SECONDS_10MINUTES, - ]; - - if (is_metaconsole()) { - // Set the server id - $graph_params['server'] = $module['serverID']; - } - - $graph_params_str = http_build_query($graph_params); - $moduleGraphURL = "$url?$graph_params_str"; - - $module['moduleGraph'] = [ - 'url' => $moduleGraphURL, - 'handle' => $winHandle, - ]; - - // Info to be able to open the snapshot image new page - $module['snapshot'] = ui_get_snapshot_link( - [ - 'id_module' => $module['id'], - 'interval' => $module['current_interval'], - 'module_name' => $module['name'], - 'id_node' => $module['serverID'] ? $module['serverID'] : 0, - ], - true - ); - } - - // Alerts fired image - if ((bool) $module['alerts']) { - $module['alertsImageHTML'] = html_print_image('images/bell.png', true, ['title' => __('Module alerts')]); - } - } - - - protected function processModules(&$modules, $server=false) - { - if (!empty($modules)) { - $all_groups = modules_get_agent_groups($modules[0]['id']); - } - - foreach ($modules as $iterator => $module) { - $this->processModule($modules[$iterator], $server, $all_groups); - } - } - - - protected function processAgent(&$agent, $server=false) - { - global $config; - - $agent['type'] = 'agent'; - $agent['id'] = (int) $agent['id']; - $agent['name'] = $agent['name']; - - $agent['rootID'] = $this->rootID; - $agent['rootType'] = $this->rootType; - - if (is_metaconsole()) { - if (isset($agent['server_id'])) { - $agent['serverID'] = $agent['server_id']; - } else if (!empty($server)) { - $agent['serverID'] = $server['id']; - } - } - - // Counters - if (empty($agent['counters'])) { - $agent['counters'] = []; - - $agent['counters']['unknown'] = isset($agent['unknown_count']) ? $agent['unknown_count'] : 0; - $agent['counters']['critical'] = isset($agent['critical_count']) ? $agent['critical_count'] : 0; - $agent['counters']['warning'] = isset($agent['warning_count']) ? $agent['warning_count'] : 0; - $agent['counters']['not_init'] = isset($agent['notinit_count']) ? $agent['notinit_count'] : 0; - $agent['counters']['ok'] = isset($agent['normal_count']) ? $agent['normal_count'] : 0; - $agent['counters']['total'] = isset($agent['total_count']) ? $agent['total_count'] : 0; - $agent['counters']['alerts'] = isset($agent['fired_count']) ? $agent['fired_count'] : 0; - } - - // Status image - $agent['statusImageHTML'] = agents_tree_view_status_img_ball( - $agent['counters']['critical'], - $agent['counters']['warning'], - $agent['counters']['unknown'], - $agent['counters']['total'], - $agent['counters']['not_init'] - ); - - // Alerts fired image - $agent['alertImageHTML'] = agents_tree_view_alert_img_ball($agent['counters']['alerts']); - - // search module recalculate counters - if (array_key_exists('state_normal', $agent)) { - $agent['counters']['unknown'] = $agent['state_unknown']; - $agent['counters']['critical'] = $agent['state_critical']; - $agent['counters']['warning'] = $agent['state_warning']; - $agent['counters']['not_init'] = $agent['state_notinit']; - $agent['counters']['ok'] = $agent['state_normal']; - $agent['counters']['total'] = $agent['state_total']; - - $agent['critical_count'] = $agent['counters']['critical']; - $agent['warning_count'] = $agent['counters']['warning']; - $agent['unknown_count'] = $agent['counters']['unknown']; - $agent['notinit_count'] = $agent['counters']['not_init']; - $agent['normal_count'] = $agent['counters']['ok']; - $agent['total_count'] = $agent['counters']['total']; - } - - if (!$this->getEmptyModuleFilterStatus()) { - $agent['counters']['unknown'] = 0; - $agent['counters']['critical'] = 0; - $agent['counters']['warning'] = 0; - $agent['counters']['not_init'] = 0; - $agent['counters']['ok'] = 0; - $agent['counters']['total'] = 0; - switch ($this->filter['statusModule']) { - case AGENT_MODULE_STATUS_CRITICAL_ALERT: - case AGENT_MODULE_STATUS_CRITICAL_BAD: - $agent['counters']['critical'] = $agent['critical_count']; - $agent['counters']['total'] = $agent['critical_count']; - break; - - case AGENT_MODULE_STATUS_WARNING_ALERT: - case AGENT_MODULE_STATUS_WARNING: - $agent['counters']['warning'] = $agent['warning_count']; - $agent['counters']['total'] = $agent['warning_count']; - break; - - case AGENT_MODULE_STATUS_UNKNOWN: - $agent['counters']['unknown'] = $agent['unknown_count']; - $agent['counters']['total'] = $agent['unknown_count']; - break; - - case AGENT_MODULE_STATUS_NO_DATA: - case AGENT_MODULE_STATUS_NOT_INIT: - $agent['counters']['not_init'] = $agent['notinit_count']; - $agent['counters']['total'] = $agent['notinit_count']; - break; - - case AGENT_MODULE_STATUS_NORMAL_ALERT: - case AGENT_MODULE_STATUS_NORMAL: - $agent['counters']['ok'] = $agent['normal_count']; - $agent['counters']['total'] = $agent['normal_count']; - break; - } - } - - if (!$this->filter['show_not_init_modules']) { - $agent['counters']['total'] -= $agent['counters']['not_init']; - $agent['counters']['not_init'] = 0; - } - - // Quiet image - if (isset($agent['quiet']) && $agent['quiet']) { - $agent['quietImageHTML'] = html_print_image('/images/dot_blue.png', true, ['title' => __('Quiet')]); - } - - // Children - if (empty($agent['children'])) { - $agent['children'] = []; - if ($agent['counters']['total'] > 0) { - switch ($this->childrenMethod) { - case 'on_demand': - $agent['searchChildren'] = 1; - break; - - case 'live': - $agent['searchChildren'] = 0; - break; - } - } else { - switch ($this->childrenMethod) { - case 'on_demand': - $agent['searchChildren'] = 0; - break; - - case 'live': - $agent['searchChildren'] = 0; - break; - } - } - } - } - - - protected function processAgents(&$agents, $server=false) - { - if (!empty($agents)) { - foreach ($agents as $iterator => $agent) { - $this->processAgent($agents[$iterator], $server); - } - } - } - - - protected function getData() - { - - } - - - protected function getFirstLevel() - { - $sql = $this->getFirstLevelSql(); - $items = db_get_all_rows_sql($sql); - if ($items === false) { - $items = []; - } - - $this->tree = $this->getProcessedItemsFirstLevel($items); - } - - - protected function getProcessedItemsFirstLevel($items) - { - $processed_items = []; - foreach ($items as $key => $item) { - $processed_item = $this->getProcessedItem($item); - $processed_items[] = $processed_item; - } - - return $processed_items; - } - - - protected function getFirstLevelSql() - { - $fields = $this->getFirstLevelFields(); - $field_name_sql = $this->L1fieldNameSql; - $inside_fields = $this->getFirstLevelFieldsInside(); - $inner = $this->L1inner; - $inner_inside = $this->L1innerInside; - $order_by_final = $this->L1orderByFinal; - - $group_inner = $this->getGroupSearchInner(); - $group_acl = $this->getGroupAclCondition(); - $group_search_filter = $this->getGroupSearchFilter(); - $agent_search_filter = $this->getAgentSearchFilter(); - $agent_status_filter = $this->getAgentStatusFilter(); - $module_search_filter = $this->getModuleSearchFilter(); - $module_status_inner = ''; - $module_status_filter = $this->getModuleStatusFilterFromTestado(); - if (!empty($module_status_filter)) { - $module_status_inner = ' + OR tasg.id_group = tg.id_grupo" + ; + } + + protected function getGroupSearchFilter() { + if (empty($this->filter['searchGroup'])) return ""; + return " AND tg.nombre LIKE '%%" . $this->filter['searchGroup'] . "%%'"; + } + + static function cmpSortNames($a, $b) { + return strcmp($a["name"], $b["name"]); + } + + protected function getProcessedItem ($item, $server = false) { + + if (isset($processed_item['is_processed']) && $processed_item['is_processed']) + return $item; + + $processed_item = array(); + $processed_item['id'] = $item['id']; + $processed_item['name'] = $item['name']; + $processed_item['rootID'] = $item['id']; + $processed_item['rootType'] = $this->rootType; + $processed_item['searchChildren'] = 1; + + if (isset($item['type'])) + $processed_item['type'] = $item['type']; + else + $processed_item['type'] = $this->type; + + if (isset($item['rootType'])) + $processed_item['rootType'] = $item['rootType']; + else + $processed_item['rootType'] = $this->rootType; + + if ($processed_item['type'] == 'group') { + $processed_item['parent'] = $item['parent']; + + $processed_item['icon'] = empty($item['icon']) + ? "without_group.png" + : $item['icon'].".png"; + } + if (isset($item['iconHTML'])) { + $processed_item['icon'] = $item['iconHTML']; + } + + if (is_metaconsole() && !empty($server)) { + $processed_item['serverID'] = $server['id']; + } + + $counters = array(); + if (isset($item['total_unknown_count'])) + $counters['unknown'] = $item['total_unknown_count']; + if (isset($item['total_critical_count'])) + $counters['critical'] = $item['total_critical_count']; + if (isset($item['total_warning_count'])) + $counters['warning'] = $item['total_warning_count']; + if (isset($item['total_not_init_count'])) + $counters['not_init'] = $item['total_not_init_count']; + if (isset($item['total_normal_count'])) + $counters['ok'] = $item['total_normal_count']; + if (isset($item['total_count'])) + $counters['total'] = $item['total_count']; + if (isset($item['total_fired_count'])) + $counters['alerts'] = $item['total_fired_count']; + + if (!empty($counters)) + $processed_item['counters'] = $counters; + + if (!empty($processed_item)) + $processed_item['is_processed'] = true; + + return $processed_item; + } + + // This function should be used only when retrieving the data of the metaconsole's nodes + protected function getMergedItems ($items) { + // This variable holds the result + $mergedItems = array(); + + foreach ($items as $key => $item) { + // Avoid the deleted items + if (!isset($items[$key]) || empty($item)) + continue; + + // Store the item in a temporary element + $resultItem = $item; + + // The 'id' parameter will be stored as 'server_id' => 'id' + $resultItem['id'] = array(); + $resultItem['id'][$item['serverID']] = $item['id']; + $resultItem['rootID'] = array(); + $resultItem['rootID'][$item['serverID']] = $item['rootID']; + $resultItem['serverID'] = array(); + $resultItem['serverID'][$item['serverID']] = $item['rootID']; + + // Initialize counters if any of it don't exist + if (!isset($resultItem['counters'])) + $resultItem['counters'] = array(); + if (!isset($resultItem['counters']['unknown'])) + $resultItem['counters']['unknown'] = 0; + if (!isset($resultItem['counters']['critical'])) + $resultItem['counters']['critical'] = 0; + if (!isset($resultItem['counters']['warning'])) + $resultItem['counters']['warning'] = 0; + if (!isset($resultItem['counters']['not_init'])) + $resultItem['counters']['not_init'] = 0; + if (!isset($resultItem['counters']['ok'])) + $resultItem['counters']['ok'] = 0; + if (!isset($resultItem['counters']['total'])) + $resultItem['counters']['total'] = 0; + if (!isset($resultItem['counters']['alerts'])) + $resultItem['counters']['alerts'] = 0; + + if ($item['type'] == 'group') { + // Add the children + if (!isset($resultItem['children'])) + $resultItem['children'] = array(); + } + + // Iterate over the list to search items that match the actual item + foreach ($items as $key2 => $item2) { + // Skip the actual or empty items + if ($key == $key2 || !isset($items[$key2])) + continue; + + // Match with the name and type + if ($item['name'] == $item2['name'] && $item['type'] == $item2['type']) { + // Add the matched ids + $resultItem['id'][$item2['serverID']] = $item2['id']; + $resultItem['rootID'][$item2['serverID']] = $item2['rootID']; + $resultItem['serverID'][$item2['serverID']] = $item2['rootID']; + + // Add the matched counters + if (isset($item2['counters']) && !empty($item2['counters'])) { + foreach ($item2['counters'] as $type => $value) { + if (isset($resultItem['counters'][$type])) + $resultItem['counters'][$type] += $value; + } + } + + if ($item['type'] == 'group') { + // Add the matched children + if (isset($item2['children'])) + $resultItem['children'] = array_merge($resultItem['children'], $item2['children']); + } + + // Remove the item + unset($items[$key2]); + } + } + + if ($item['type'] == 'group') { + // Get the merged children (recursion) + if (!empty($resultItem['children'])) + $resultItem['children'] = $this->getMergedItems($resultItem['children']); + + } + + // Add the resulting item + if (!empty($resultItem) && !empty($resultItem['counters']['total'])) + $mergedItems[] = $resultItem; + + // Remove the item + unset($items[$key]); + } + + usort($mergedItems, array("Tree", "cmpSortNames")); + + return $mergedItems; + } + + protected function processModule (&$module, $server = false, $all_groups) { + global $config; + + if (isset($module['children'])) { + foreach ($module['children'] as $i => $children) { + $this->processModule($module['children'][$i], $server, $all_groups); + } + } + + $module['type'] = 'module'; + $module['id'] = (int) $module['id']; + $module['name'] = io_safe_output($module['name']); + $module['id_module_type'] = (int) $module['id_tipo_modulo']; + $module['server_type'] = (int) $module['id_modulo']; + $module['status'] = $module['estado']; + $module['value'] = $module['datos']; + + if (is_metaconsole()) { + $module['serverID'] = $this->serverID; + $module['serverName'] = $this->serverName; + } + else { + $module['serverName'] = false; + $module['serverID'] = false; + } + + if (!isset($module['value'])) + $module['value'] = modules_get_last_value($module['id']); + + // Status + switch ($module['status']) { + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + $module['alert'] = 1; + case AGENT_MODULE_STATUS_CRITICAL_BAD: + $statusType = STATUS_MODULE_CRITICAL_BALL; + $statusTitle = __('CRITICAL'); + $module['statusText'] = "critical"; + break; + case AGENT_MODULE_STATUS_WARNING_ALERT: + $module['alert'] = 1; + case AGENT_MODULE_STATUS_WARNING: + $statusType = STATUS_MODULE_WARNING_BALL; + $statusTitle = __('WARNING'); + $module['statusText'] = "warning"; + break; + case AGENT_MODULE_STATUS_UNKNOWN: + $statusType = STATUS_MODULE_UNKNOWN_BALL; + $statusTitle = __('UNKNOWN'); + $module['statusText'] = "unknown"; + break; + case AGENT_MODULE_STATUS_NO_DATA: + case AGENT_MODULE_STATUS_NOT_INIT: + $statusType = STATUS_MODULE_NO_DATA_BALL; + $statusTitle = __('NO DATA'); + $module['statusText'] = "not_init"; + break; + case AGENT_MODULE_STATUS_NORMAL_ALERT: + $module['alert'] = 1; + case AGENT_MODULE_STATUS_NORMAL: + default: + $statusType = STATUS_MODULE_OK_BALL; + $statusTitle = __('NORMAL'); + $module['statusText'] = "ok"; + break; + } + + if ($statusType !== STATUS_MODULE_UNKNOWN_BALL + && $statusType !== STATUS_MODULE_NO_DATA_BALL) { + if (is_numeric($module["value"])) { + $statusTitle .= " : " . format_for_graph($module["value"]); + } + else { + $statusTitle .= " : " . substr(io_safe_output($module["value"]),0,42); + } + } + + $module['statusImageHTML'] = ui_print_status_image($statusType, $statusTitle, true); + + // HTML of the server type image + $module['serverTypeHTML'] = servers_show_type($module['server_type']); + + // Link to the Module graph + + // ACL + $acl_graphs = false; + $module["showGraphs"] = 0; + + // Avoid the check on the metaconsole. Too slow to show/hide an icon depending on the permissions + if (!empty($group_id) && !is_metaconsole()) { + $acl_graphs = check_acl_one_of_groups($config['id_user'], $all_groups, "RR"); + } + else if (!empty($all_groups)) { + $acl_graphs = true; + } + + if ($acl_graphs) { + $module["showGraphs"] = 1; + } + + if ($module["showGraphs"]) { + $graphType = return_graphtype($module['id_module_type']); + $url = ui_get_full_url("operation/agentes/stat_win.php", false, false, false); + $winHandle = dechex(crc32($module['id'].$module['name'])); + + $graph_params = array( + "type" => $graphType, + "period" => SECONDS_1DAY, + "id" => $module['id'], + "label" => base64_encode($module['name']), + "refresh" => SECONDS_10MINUTES + ); + + if (is_metaconsole()) { + // Set the server id + $graph_params["server"] = $module['serverID']; + } + + $graph_params_str = http_build_query($graph_params); + $moduleGraphURL = "$url?$graph_params_str"; + + $module['moduleGraph'] = array( + 'url' => $moduleGraphURL, + 'handle' => $winHandle + ); + + // Info to be able to open the snapshot image new page + $module['snapshot'] = ui_get_snapshot_link(array( + 'id_module' => $module['id'], + 'interval' => $module['current_interval'], + 'module_name' => $module['name'], + 'id_node' => $module['serverID'] ? $module['serverID'] : 0, + ), true); + } + + // Alerts fired image + if ((bool)$module['alerts']) { + $module['alertsImageHTML'] = html_print_image("images/bell.png", true, array("title" => __('Module alerts'))); + } + } + + protected function processModules (&$modules, $server = false) { + if (!empty($modules)) { + $all_groups = modules_get_agent_groups($modules[0]['id']); + } + foreach ($modules as $iterator => $module) { + $this->processModule($modules[$iterator], $server, $all_groups); + } + } + + protected function processAgent (&$agent, $server = false) { + global $config; + + $agent['type'] = 'agent'; + $agent['id'] = (int) $agent['id']; + $agent['name'] = $agent['name']; + + $agent['rootID'] = $this->rootID; + $agent['rootType'] = $this->rootType; + + if (is_metaconsole()) { + if (isset($agent['server_id'])) + $agent['serverID'] = $agent['server_id']; + else if (!empty($server)) + $agent['serverID'] = $server['id']; + } + // Counters + if (empty($agent['counters'])) { + $agent['counters'] = array(); + + $agent['counters']['unknown'] = isset($agent['unknown_count']) ? $agent['unknown_count'] : 0; + $agent['counters']['critical'] = isset($agent['critical_count']) ? $agent['critical_count'] : 0; + $agent['counters']['warning'] = isset($agent['warning_count']) ? $agent['warning_count'] : 0; + $agent['counters']['not_init'] = isset($agent['notinit_count']) ? $agent['notinit_count'] : 0; + $agent['counters']['ok'] = isset($agent['normal_count']) ? $agent['normal_count'] : 0; + $agent['counters']['total'] = isset($agent['total_count']) ? $agent['total_count'] : 0; + $agent['counters']['alerts'] = isset($agent['fired_count']) ? $agent['fired_count'] : 0; + } + + // Status image + $agent['statusImageHTML'] = agents_tree_view_status_img_ball( + $agent['counters']['critical'], + $agent['counters']['warning'], + $agent['counters']['unknown'], + $agent['counters']['total'], + $agent['counters']['not_init']); + + // Alerts fired image + $agent["alertImageHTML"] = agents_tree_view_alert_img_ball($agent['counters']['alerts']); + + // search module recalculate counters + if(array_key_exists('state_normal', $agent)){ + $agent['counters']['unknown'] = $agent['state_unknown']; + $agent['counters']['critical'] = $agent['state_critical']; + $agent['counters']['warning'] = $agent['state_warning']; + $agent['counters']['not_init'] = $agent['state_notinit']; + $agent['counters']['ok'] = $agent['state_normal']; + $agent['counters']['total'] = $agent['state_total']; + + $agent['critical_count'] = $agent['counters']['critical']; + $agent['warning_count'] = $agent['counters']['warning']; + $agent['unknown_count'] = $agent['counters']['unknown']; + $agent['notinit_count'] = $agent['counters']['not_init']; + $agent['normal_count'] = $agent['counters']['ok']; + $agent['total_count'] = $agent['counters']['total']; + } + + if (!$this->getEmptyModuleFilterStatus()) { + $agent['counters']['unknown'] = 0; + $agent['counters']['critical'] = 0; + $agent['counters']['warning'] = 0; + $agent['counters']['not_init'] = 0; + $agent['counters']['ok'] = 0; + $agent['counters']['total'] = 0; + switch($this->filter['statusModule']) { + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + case AGENT_MODULE_STATUS_CRITICAL_BAD: + $agent['counters']['critical'] = $agent['critical_count']; + $agent['counters']['total'] = $agent['critical_count']; + break; + case AGENT_MODULE_STATUS_WARNING_ALERT: + case AGENT_MODULE_STATUS_WARNING: + $agent['counters']['warning'] = $agent['warning_count']; + $agent['counters']['total'] = $agent['warning_count']; + break; + case AGENT_MODULE_STATUS_UNKNOWN: + $agent['counters']['unknown'] = $agent['unknown_count']; + $agent['counters']['total'] = $agent['unknown_count']; + break; + case AGENT_MODULE_STATUS_NO_DATA: + case AGENT_MODULE_STATUS_NOT_INIT: + $agent['counters']['not_init'] = $agent['notinit_count']; + $agent['counters']['total'] = $agent['notinit_count']; + break; + case AGENT_MODULE_STATUS_NORMAL_ALERT: + case AGENT_MODULE_STATUS_NORMAL: + $agent['counters']['ok'] = $agent['normal_count']; + $agent['counters']['total'] = $agent['normal_count']; + break; + } + } + + if (!$this->filter['show_not_init_modules']) { + $agent['counters']['total'] -= $agent['counters']['not_init']; + $agent['counters']['not_init'] = 0; + } + + // Quiet image + if (isset($agent['quiet']) && $agent['quiet']) + $agent['quietImageHTML'] = html_print_image("/images/dot_blue.png", true, array("title" => __('Quiet'))); + + // Children + if (empty($agent['children'])) { + $agent['children'] = array(); + if ($agent['counters']['total'] > 0) { + switch ($this->childrenMethod) { + case 'on_demand': + $agent['searchChildren'] = 1; + break; + case 'live': + $agent['searchChildren'] = 0; + break; + } + } + else { + switch ($this->childrenMethod) { + case 'on_demand': + $agent['searchChildren'] = 0; + break; + case 'live': + $agent['searchChildren'] = 0; + break; + } + } + } + } + + protected function processAgents (&$agents, $server = false) { + if (!empty($agents)) { + foreach ($agents as $iterator => $agent) { + $this->processAgent($agents[$iterator], $server); + } + } + } + + protected function getData() { + + } + + protected function getFirstLevel() { + $sql = $this->getFirstLevelSql(); + $items = db_get_all_rows_sql($sql); + if ($items === false) $items = array(); + + $this->tree = $this->getProcessedItemsFirstLevel($items); + } + + protected function getProcessedItemsFirstLevel($items){ + $processed_items = array(); + foreach ($items as $key => $item) { + $processed_item = $this->getProcessedItem($item); + $processed_items[] = $processed_item; + } + return $processed_items; + } + + protected function getFirstLevelSql() { + + $fields = $this->getFirstLevelFields(); + $field_name_sql = $this->L1fieldNameSql; + $inside_fields = $this->getFirstLevelFieldsInside(); + $inner = $this->L1inner; + $inner_inside = $this->L1innerInside; + $order_by_final = $this->L1orderByFinal; + + $group_inner = $this->getGroupSearchInner(); + $group_acl = $this->getGroupAclCondition(); + $group_search_filter = $this->getGroupSearchFilter(); + $agent_search_filter = $this->getAgentSearchFilter(); + $agent_status_filter = $this->getAgentStatusFilter(); + $module_search_filter = $this->getModuleSearchFilter(); + $module_status_inner = ""; + $module_status_filter = $this->getModuleStatusFilterFromTestado(); + if (!empty($module_status_filter)) { + $module_status_inner = " INNER JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo'; - } + ON tae.id_agente_modulo = tam.id_agente_modulo"; + } - $sql_model = "SELECT %s FROM + $sql_model = "SELECT %s FROM ( SELECT COUNT(DISTINCT(ta.id_agente)) AS total, $field_name_sql AS g FROM tagente ta @@ -920,42 +778,34 @@ class Tree $group_acl GROUP BY $field_name_sql ) x GROUP BY g"; - $sql_array = []; - foreach ($inside_fields as $inside_field) { - $sql_array[] = sprintf( - $sql_model, - $inside_field['header'], - $inside_field['condition'] - ); - } - - $sql = "SELECT $fields FROM (".implode(' UNION ALL ', $sql_array).") x2 + $sql_array = array(); + foreach ($inside_fields as $inside_field) { + $sql_array[] = sprintf( + $sql_model, + $inside_field['header'], + $inside_field['condition'] + ); + } + $sql = "SELECT $fields FROM (" . implode(" UNION ALL ", $sql_array) . ") x2 $inner GROUP BY g ORDER BY $order_by_final"; - return $sql; - } + return $sql; + } + protected function getSecondLevel() { + $sql = $this->getSecondLevelSql(); + $data = db_process_sql($sql); + if (empty($data)) { + $this->tree = array(); + return; + } + $this->processAgents($data); + $this->tree = $data; + } - protected function getSecondLevel() - { - $sql = $this->getSecondLevelSql(); - $data = db_process_sql($sql); - if (empty($data)) { - $this->tree = []; - return; - } - - $this->processAgents($data); - - $this->tree = $data; - } - - - protected function getSecondLevelSql() - { - $columns = sprintf( - 'ta.id_agente AS id, ta.nombre AS name, ta.alias, + protected function getSecondLevelSql() { + $columns = sprintf("ta.id_agente AS id, ta.nombre AS name, ta.alias, ta.fired_count, ta.normal_count, ta.warning_count, ta.critical_count, ta.unknown_count, ta.notinit_count, ta.total_count, ta.quiet, @@ -965,29 +815,29 @@ class Tree SUM(if(%s, 1, 0)) as state_notinit, SUM(if(%s, 1, 0)) as state_normal, SUM(if(%s AND tae.estado IS NOT NULL, 1, 0)) as state_total - ', - $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_CRITICAL_ALERT, true), - $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_WARNING_ALERT, true), - $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_UNKNOWN, true), - $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_NO_DATA, true), - $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_NORMAL, true), - $this->getModuleStatusFilterFromTestado(self::TV_DEFAULT_AGENT_STATUS, true) - ); + ", + $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_CRITICAL_ALERT, true), + $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_WARNING_ALERT, true), + $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_UNKNOWN, true), + $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_NO_DATA, true), + $this->getModuleStatusFilterFromTestado(AGENT_MODULE_STATUS_NORMAL, true), + $this->getModuleStatusFilterFromTestado(self::TV_DEFAULT_AGENT_STATUS, true) + ); - $inner_or_left = $this->getInnerOrLeftJoin(); - $group_inner = $this->getGroupSearchInner(); - $group_acl = $this->getGroupAclCondition(); - $group_search_filter = $this->getGroupSearchFilter(); - $agent_search_filter = $this->getAgentSearchFilter(); - $agent_status_filter = $this->getAgentStatusFilter(); - $module_search_filter = $this->getModuleSearchFilter(); - $module_status_filter = $this->getModuleStatusFilter(); + $inner_or_left = $this->getInnerOrLeftJoin(); + $group_inner = $this->getGroupSearchInner(); + $group_acl = $this->getGroupAclCondition(); + $group_search_filter = $this->getGroupSearchFilter(); + $agent_search_filter = $this->getAgentSearchFilter(); + $agent_status_filter = $this->getAgentStatusFilter(); + $module_search_filter = $this->getModuleSearchFilter(); + $module_status_filter = $this->getModuleStatusFilter(); - $condition = $this->L2condition; - $condition_inside = $this->L2conditionInside; - $inner = $this->L2inner; + $condition = $this->L2condition; + $condition_inside = $this->L2conditionInside; + $inner = $this->L2inner; - $sql = "SELECT $columns + $sql = "SELECT $columns FROM tagente ta $inner_or_left JOIN tagente_modulo tam ON ta.id_agente = tam.id_agente @@ -1017,48 +867,51 @@ class Tree ORDER BY ta.alias ASC, ta.id_agente ASC "; - return $sql; - } + return $sql; + } + protected function getThirdLevel() { + $sql = $this->getThirdLevelSql(); + $data = db_process_sql($sql); + if (empty($data)) { + $this->tree = array(); + return; + } + $data = $this->getProcessedModules($data); + $this->processModules($data); +hd("MODULES: ", true); +hd($data, true); + $this->tree = $data; + } - protected function getThirdLevel() - { - $sql = $this->getThirdLevelSql(); - $data = db_process_sql($sql); - if (empty($data)) { - $this->tree = []; - return; - } + protected function getThirdLevelSql() { + // Get the server id + $serverID = $this->serverID; - $data = $this->getProcessedModules($data); - $this->processModules($data); + $group_acl = $this->getGroupAclCondition(); + $agent_search_filter = $this->getAgentSearchFilter(); + $agent_status_filter = $this->getAgentStatusFilter(); + $module_search_filter = $this->getModuleSearchFilter(); + $module_status_filter = $this->getModuleStatusFilterFromTestado(); + $agent_filter = "AND ta.id_agente = " . $this->id; + $tag_condition = $this->getTagCondition(); + $tag_join = empty($tag_condition) && (!$this->L3forceTagCondition) + ? '' + : $this->getTagJoin(); - $this->tree = $data; - } + if ($this->avoid_condition === true) { + $condition = ''; + $inner = ''; + } else { + $condition = $this->L2condition; + $inner = $this->L2inner; + } - - protected function getThirdLevelSql() - { - // Get the server id - $serverID = $this->serverID; - - $group_acl = $this->getGroupAclCondition(); - $agent_search_filter = $this->getAgentSearchFilter(); - $agent_status_filter = $this->getAgentStatusFilter(); - $module_search_filter = $this->getModuleSearchFilter(); - $module_status_filter = $this->getModuleStatusFilterFromTestado(); - $agent_filter = 'AND ta.id_agente = '.$this->id; - $tag_condition = $this->getTagCondition(); - $tag_join = empty($tag_condition) && (!$this->L3forceTagCondition) ? '' : $this->getTagJoin(); - - $condition = $this->L2condition; - $inner = $this->L2inner; - - $columns = 'DISTINCT(tam.id_agente_modulo) AS id, tam.nombre AS name, + $columns = 'DISTINCT(tam.id_agente_modulo) AS id, tam.nombre AS name, tam.id_tipo_modulo, tam.id_modulo, tae.estado, tae.datos, tam.parent_module_id AS parent, tatm.id AS alerts'; - $sql = "SELECT $columns + $sql = "SELECT $columns FROM tagente_modulo tam $tag_join INNER JOIN tagente_estado tae @@ -1076,81 +929,57 @@ class Tree $group_acl $agent_search_filter $agent_status_filter - $module_status_filter $module_search_filter $tag_condition ORDER BY tam.nombre ASC, tam.id_agente_modulo ASC"; - return $sql; - } + return $sql; + } - public function getJSON() - { - $this->getData(); + public function getJSON() { + $this->getData(); - return json_encode($this->tree); - } + return json_encode($this->tree); + } + public function getArray() { + $this->getData(); - public function getArray() - { - $this->getData(); + return $this->tree; + } - return $this->tree; - } + static function name2symbol($name) { + return str_replace( + array(' ','#','/','.','(',')','¿','?','¡','!'), + array( + '_articapandora_'.ord(' ').'_pandoraartica_', + '_articapandora_'.ord('#').'_pandoraartica_', + '_articapandora_'.ord('/').'_pandoraartica_', + '_articapandora_'.ord('.').'_pandoraartica_', + '_articapandora_'.ord('(').'_pandoraartica_', + '_articapandora_'.ord(')').'_pandoraartica_', + '_articapandora_'.ord('¿').'_pandoraartica_', + '_articapandora_'.ord('?').'_pandoraartica_', + '_articapandora_'.ord('¡').'_pandoraartica_', + '_articapandora_'.ord('!').'_pandoraartica_' + ), + io_safe_output($name) + ); + } + static function symbol2name($name) { + $symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~'; + for ($i = 0; $i < strlen($symbols); $i++) { + $name = str_replace('_articapandora_' . + ord(substr($symbols, $i, 1)) .'_pandoraartica_', + substr($symbols, $i, 1), $name); + } + return io_safe_input($name); + } - static function name2symbol($name) - { - return str_replace( - [ - ' ', - '#', - '/', - '.', - '(', - ')', - '¿', - '?', - '¡', - '!', - ], - [ - '_articapandora_'.ord(' ').'_pandoraartica_', - '_articapandora_'.ord('#').'_pandoraartica_', - '_articapandora_'.ord('/').'_pandoraartica_', - '_articapandora_'.ord('.').'_pandoraartica_', - '_articapandora_'.ord('(').'_pandoraartica_', - '_articapandora_'.ord(')').'_pandoraartica_', - '_articapandora_'.ord('¿').'_pandoraartica_', - '_articapandora_'.ord('?').'_pandoraartica_', - '_articapandora_'.ord('¡').'_pandoraartica_', - '_articapandora_'.ord('!').'_pandoraartica_', - ], - io_safe_output($name) - ); - } - - - static function symbol2name($name) - { - $symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~'; - for ($i = 0; $i < strlen($symbols); $i++) { - $name = str_replace( - '_articapandora_'.ord(substr($symbols, $i, 1)).'_pandoraartica_', - substr($symbols, $i, 1), - $name - ); - } - - return io_safe_input($name); - } - - - protected function getProcessedModules($modules_tree) - { - return $modules_tree; - } - + protected function getProcessedModules($modules_tree) { + return $modules_tree; + } } +?> diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php index bef4287c7d..fd38794d1c 100644 --- a/pandora_console/include/class/TreeGroup.class.php +++ b/pandora_console/include/class/TreeGroup.class.php @@ -1,215 +1,193 @@ L1fieldName = "id_group"; + $this->L1extraFields = array( + "tg.nombre AS `name`", + "tg.icon", + "tg.id_grupo AS gid" + ); - $this->L1fieldName = 'id_group'; - $this->L1extraFields = [ - 'tg.nombre AS `name`', - 'tg.icon', - 'tg.id_grupo AS gid', - ]; + $this->L2conditionInside = "AND ( + ta.id_grupo = " . $this->id . " + OR tasg.id_group = " . $this->id . " + )"; + } - $this->L2conditionInside = 'AND ( - ta.id_grupo = '.$this->id.' - OR tasg.id_group = '.$this->id.' - )'; - } + public function setPropagateCounters($value) { + $this->propagateCounters = (bool)$value; + } + public function setDisplayAllGroups($value) { + $this->displayAllGroups = (bool)$value; + } - public function setPropagateCounters($value) - { - $this->propagateCounters = (bool) $value; - } + protected function getData() { + if ($this->id == -1) { + $this->getFirstLevel(); - public function setDisplayAllGroups($value) - { - $this->displayAllGroups = (bool) $value; - } + } elseif ($this->type == 'group') { + $this->getSecondLevel(); + } elseif ($this->type == 'agent') { + $this->getThirdLevel(); + } + } + protected function getGroupSearchFilter() { + return ""; + } - protected function getData() - { - if ($this->id == -1) { - $this->getFirstLevel(); - } else if ($this->type == 'group') { - $this->getSecondLevel(); - } else if ($this->type == 'agent') { - $this->getThirdLevel(); - } - } + protected function getFirstLevel() { + $processed_items = $this->getProcessedGroups(); + if (!empty($processed_items)) { + // Filter by group name. This should be done after rerieving the items cause we need the possible items descendants + if (!empty($this->filter['searchGroup'])) { + // Save the groups which intersect with the user groups + $groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%')); + if ($groups == false) $groups = array(); + $userGroupsACL = $this->userGroupsACL; + $ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) { + $group_id = $group['id_grupo']; + if (isset($userGroupsACL[$group_id])) { + $userGroups[$group_id] = $userGroupsACL[$group_id]; + } - protected function getGroupSearchFilter() - { - return ''; - } + return $userGroups; + }, array()); + $result = self::extractGroupsWithIDs($processed_items, $ids_hash); - protected function getFirstLevel() - { - $processed_items = $this->getProcessedGroups(); + $processed_items = ($result === false) ? array() : $result; + } - if (!empty($processed_items)) { - // Filter by group name. This should be done after rerieving the items cause we need the possible items descendants - if (!empty($this->filter['searchGroup'])) { - // Save the groups which intersect with the user groups - $groups = db_get_all_rows_filter('tgrupo', ['nombre' => '%'.$this->filter['searchGroup'].'%']); - if ($groups == false) { - $groups = []; - } + // groupID filter. To access the view from tactical views f.e. + if (!empty($this->filter['groupID'])) { + $result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL); - $userGroupsACL = $this->userGroupsACL; - $ids_hash = array_reduce( - $groups, - function ($userGroups, $group) use ($userGroupsACL) { - $group_id = $group['id_grupo']; - if (isset($userGroupsACL[$group_id])) { - $userGroups[$group_id] = $userGroupsACL[$group_id]; - } + $processed_items = ($result === false) ? array() : array($result); + } + } + hd("G-GETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVEL", true); +hd($processed_items, true); + $this->tree = $processed_items; + } - return $userGroups; - }, - [] - ); + protected function getProcessedGroups () { + $processed_groups = array(); + // Index and process the groups + $groups = $this->getGroupCounters(); - $result = self::extractGroupsWithIDs($processed_items, $ids_hash); + // If user have not permissions in parent, set parent node to 0 (all) + // Avoid to do foreach for admins + if (!users_can_manage_group_all("AR")) { + foreach ($groups as $id => $group) { + if (!isset($this->userGroups[$groups[$id]['parent']])) { + $groups[$id]['parent'] = 0; + } + } + } + // Build the group hierarchy + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + $parent = $groups[$id]['parent']; + // Parent exists + if (!isset($groups[$parent]['children'])) { + $groups[$parent]['children'] = array(); + } + // Store a reference to the group into the parent + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent + $groups[$id]['have_parent'] = true; + } + } + // Sort the children groups + foreach ($groups as $id => $group) { + if (isset($groups[$id]['children'])) { + usort($groups[$id]['children'], array("Tree", "cmpSortNames")); + } + } + //Filter groups and eliminates the reference to children groups out of her parent + $groups = array_filter($groups, function ($group) { + return !$group['have_parent']; + }); + // Propagate child counters to her parents - $processed_items = ($result === false) ? [] : $result; - } + if ($this->propagateCounters) { + TreeGroup::processCounters($groups); + // Filter groups and eliminates the reference to empty groups + $groups = $this->deleteEmptyGroups($groups); + } else { + $groups = $this->deleteEmptyGroupsNotPropagate($groups); + } - // groupID filter. To access the view from tactical views f.e. - if (!empty($this->filter['groupID'])) { - $result = self::extractItemWithID($processed_items, $this->filter['groupID'], 'group', $this->strictACL); + usort($groups, array("Tree", "cmpSortNames")); - $processed_items = ($result === false) ? [] : [$result]; - } - } + return $groups; + } - $this->tree = $processed_items; - } + protected function getGroupCounters() { + $fields = $this->getFirstLevelFields(); + $inside_fields = $this->getFirstLevelFieldsInside(); + $group_acl = ""; + $secondary_group_acl = ""; + if (!users_can_manage_group_all("AR")) { + $user_groups_str = implode(",", $this->userGroupsArray); + $group_acl = " AND ta.id_grupo IN ($user_groups_str)"; + $secondary_group_acl = " AND tasg.id_group IN ($user_groups_str)"; + } + $agent_search_filter = $this->getAgentSearchFilter(); + $agent_search_filter = preg_replace("/%/", "%%", $agent_search_filter); + $agent_status_filter = $this->getAgentStatusFilter(); + $module_status_filter = $this->getModuleStatusFilter(); - protected function getProcessedGroups() - { - $processed_groups = []; - // Index and process the groups - $groups = $this->getGroupCounters(); - - // If user have not permissions in parent, set parent node to 0 (all) - // Avoid to do foreach for admins - if (!users_can_manage_group_all('AR')) { - foreach ($groups as $id => $group) { - if (!isset($this->userGroups[$groups[$id]['parent']])) { - $groups[$id]['parent'] = 0; - } - } - } - - // Build the group hierarchy - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { - $parent = $groups[$id]['parent']; - // Parent exists - if (!isset($groups[$parent]['children'])) { - $groups[$parent]['children'] = []; - } - - // Store a reference to the group into the parent - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent - $groups[$id]['have_parent'] = true; - } - } - - // Sort the children groups - foreach ($groups as $id => $group) { - if (isset($groups[$id]['children'])) { - usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); - } - } - - // Filter groups and eliminates the reference to children groups out of her parent - $groups = array_filter( - $groups, - function ($group) { - return !$group['have_parent']; - } - ); - // Propagate child counters to her parents - if ($this->propagateCounters) { - self::processCounters($groups); - // Filter groups and eliminates the reference to empty groups - $groups = $this->deleteEmptyGroups($groups); - } else { - $groups = $this->deleteEmptyGroupsNotPropagate($groups); - } - - usort($groups, ['Tree', 'cmpSortNames']); - return $groups; - } - - - protected function getGroupCounters() - { - $fields = $this->getFirstLevelFields(); - $inside_fields = $this->getFirstLevelFieldsInside(); - - $group_acl = ''; - $secondary_group_acl = ''; - if (!users_can_manage_group_all('AR')) { - $user_groups_str = implode(',', $this->userGroupsArray); - $group_acl = " AND ta.id_grupo IN ($user_groups_str)"; - $secondary_group_acl = " AND tasg.id_group IN ($user_groups_str)"; - } - - $agent_search_filter = $this->getAgentSearchFilter(); - $agent_search_filter = preg_replace('/%/', '%%', $agent_search_filter); - $agent_status_filter = $this->getAgentStatusFilter(); - $module_status_filter = $this->getModuleStatusFilter(); - - $module_search_inner = ''; - $module_search_filter = ''; - if (!empty($this->filter['searchModule'])) { - $module_search_inner = ' + $module_search_inner = ""; + $module_search_filter = ""; + if (!empty($this->filter['searchModule'])) { + $module_search_inner = " INNER JOIN tagente_modulo tam ON ta.id_agente = tam.id_agente INNER JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo'; - $module_search_filter = "AND tam.disabled = 0 - AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' ".$this->getModuleStatusFilterFromTestado(); - } + ON tae.id_agente_modulo = tam.id_agente_modulo"; + $module_search_filter = "AND tam.disabled = 0 + AND tam.nombre LIKE '%%" . $this->filter['searchModule'] . "%%' " . + $this->getModuleStatusFilterFromTestado() + ; + } - $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; - $table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' : 'tagent_secondary_group'; + $table = is_metaconsole() ? "tmetaconsole_agent" : "tagente"; + $table_sec = is_metaconsole() ? "tmetaconsole_agent_secondary_group" : "tagent_secondary_group"; - $sql_model = "SELECT %s FROM + $sql_model = "SELECT %s FROM ( SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g FROM $table ta @@ -236,294 +214,254 @@ class TreeGroup extends Tree $secondary_group_acl GROUP BY id_group ) x GROUP BY g"; - $sql_array = []; - foreach ($inside_fields as $inside_field) { - $sql_array[] = sprintf( - $sql_model, - $inside_field['header'], - $inside_field['condition'], - $inside_field['condition'] - ); - } - - $sql = "SELECT $fields FROM (".implode(' UNION ALL ', $sql_array).') x2 + $sql_array = array(); + foreach ($inside_fields as $inside_field) { + $sql_array[] = sprintf( + $sql_model, + $inside_field['header'], + $inside_field['condition'], + $inside_field['condition'] + ); + } + $sql = "SELECT $fields FROM (" . implode(" UNION ALL ", $sql_array) . ") x2 RIGHT JOIN tgrupo tg ON x2.g = tg.id_grupo - GROUP BY tg.id_grupo'; - $stats = db_get_all_rows_sql($sql); + GROUP BY tg.id_grupo"; + $stats = db_get_all_rows_sql($sql); - $group_stats = []; - foreach ($stats as $group) { - $group_stats[$group['gid']]['total_count'] = (int) $group['total_count']; - $group_stats[$group['gid']]['total_critical_count'] = (int) $group['total_critical_count']; - $group_stats[$group['gid']]['total_unknown_count'] = (int) $group['total_unknown_count']; - $group_stats[$group['gid']]['total_warning_count'] = (int) $group['total_warning_count']; - $group_stats[$group['gid']]['total_not_init_count'] = (int) $group['total_not_init_count']; - $group_stats[$group['gid']]['total_normal_count'] = (int) $group['total_normal_count']; - $group_stats[$group['gid']]['total_fired_count'] = (int) $group['total_alerts_count']; - $group_stats[$group['gid']]['name'] = $group['name']; - $group_stats[$group['gid']]['parent'] = $group['parent']; - $group_stats[$group['gid']]['icon'] = $group['icon']; - $group_stats[$group['gid']]['id'] = $group['gid']; - $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); - } + $group_stats = array(); - return $group_stats; - } + hd("STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS ", true); + hd($stats, true); + foreach ($stats as $group) { + $group_stats[$group['gid']]['total_count'] = (int)$group['total_count']; + $group_stats[$group['gid']]['total_critical_count'] = (int)$group['total_critical_count']; + $group_stats[$group['gid']]['total_unknown_count'] = (int)$group['total_unknown_count']; + $group_stats[$group['gid']]['total_warning_count'] = (int)$group['total_warning_count']; + $group_stats[$group['gid']]['total_not_init_count'] = (int)$group['total_not_init_count']; + $group_stats[$group['gid']]['total_normal_count'] = (int)$group['total_normal_count']; + $group_stats[$group['gid']]['total_fired_count'] = (int)$group['total_alerts_count']; + $group_stats[$group['gid']]['name'] = $group['name']; + $group_stats[$group['gid']]['parent'] = $group['parent']; + $group_stats[$group['gid']]['icon'] = $group['icon']; + $group_stats[$group['gid']]['id'] = $group['gid']; + $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); + + } - protected function getFirstLevelFields() - { - $fields = parent::getFirstLevelFields(); - $parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent'; - return "$fields, $parent"; - } + return $group_stats; + } - protected function getProcessedModules($modules_tree) - { - $groups = []; - foreach ($modules_tree as $group) { - $groups[$group['id']] = $group; - } + protected function getFirstLevelFields() { + $fields = parent::getFirstLevelFields(); + $parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent'; + return "$fields, $parent"; + } - // Build the module hierarchy - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { - $parent = $groups[$id]['parent']; - // Parent exists - if (!isset($groups[$parent]['children'])) { - $groups[$parent]['children'] = []; - } + protected function getProcessedModules($modules_tree) { - // Store a reference to the group into the parent - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent - $groups[$id]['have_parent'] = true; - } - } + $groups = array(); + foreach ($modules_tree as $group) { + $groups[$group["id"]] = $group; + } - // Sort the children groups - foreach ($groups as $id => $group) { - if (isset($groups[$id]['children'])) { - usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); - } - } + // Build the module hierarchy + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + $parent = $groups[$id]['parent']; + // Parent exists + if (!isset($groups[$parent]['children'])) { + $groups[$parent]['children'] = array(); + } + // Store a reference to the group into the parent + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent + $groups[$id]['have_parent'] = true; + } + } - // Filter groups and eliminates the reference to children groups out of her parent - $groups = array_filter( - $groups, - function ($group) { - return !$group['have_parent']; - } - ); + // Sort the children groups + foreach ($groups as $id => $group) { + if (isset($groups[$id]['children'])) { + usort($groups[$id]['children'], array("Tree", "cmpSortNames")); + } + } + //Filter groups and eliminates the reference to children groups out of her parent + $groups = array_filter($groups, function ($group) { + return !$group['have_parent']; + }); - return array_values($groups); - } + return array_values($groups); + } + // FIXME: Hierarchy lops is broken + protected function getProcessedModules_old($modules_tree) { - // FIXME: Hierarchy lops is broken - protected function getProcessedModules_old($modules_tree) - { - $tree_modules = []; - $new_modules_root = array_filter( - $modules_tree, - function ($module) { - return (isset($module['parent']) && ($module['parent'] == 0)); - } - ); + $tree_modules = array(); + $new_modules_root = array_filter($modules_tree, function ($module) { + return (isset($module['parent']) && ($module['parent'] == 0)); + }); - $new_modules_child = array_filter( - $modules_tree, - function ($module) { - return (isset($module['parent']) && ($module['parent'] != 0)); - } - ); + $new_modules_child = array_filter($modules_tree, function ($module) { + return (isset($module['parent']) && ($module['parent'] != 0)); + }); - $i = 0; - while (!empty($new_modules_child)) { - foreach ($new_modules_child as $i => $child) { - self::recursive_modules_tree_view($new_modules_root, $new_modules_child, $i, $child); - } - } + $i = 0; + while (!empty($new_modules_child)) { + foreach ($new_modules_child as $i => $child) { + TreeGroup::recursive_modules_tree_view($new_modules_root, $new_modules_child, $i, $child); + } + } - foreach ($new_modules_root as $m) { - $tree_modules[] = $m; - } + foreach ($new_modules_root as $m) { + $tree_modules[] = $m; + } + return $tree_modules; + } - return $tree_modules; - } + // FIXME with getProcessedModules_old + static function recursive_modules_tree_view (&$new_modules, &$new_modules_child, $i, $child) { + foreach ($new_modules as $index => $module) { + if ($module['id'] == $child['parent']) { + $new_modules[$index]['children'][] = $child; + unset($new_modules_child[$i]); + break; + } + else if (isset($new_modules[$index]['children'])) { + TreeGroup::recursive_modules_tree_view ($new_modules[$index]['children'], $new_modules_child, $i, $child); + } + } + } + static function processCounters(&$groups) { + $all_counters = array(); + foreach ($groups as $id => $group) { + $child_counters = array(); + if (!empty($groups[$id]['children'])) { + $child_counters = TreeGroup::processCounters($groups[$id]['children']); + } + if (!empty($child_counters)) { + foreach($child_counters as $type => $value) { + $groups[$id]['counters'][$type] += $value; + } + } + foreach($groups[$id]['counters'] as $type => $value) { + $all_counters[$type] += $value; + } + } + return $all_counters; + } - // FIXME with getProcessedModules_old - static function recursive_modules_tree_view(&$new_modules, &$new_modules_child, $i, $child) - { - foreach ($new_modules as $index => $module) { - if ($module['id'] == $child['parent']) { - $new_modules[$index]['children'][] = $child; - unset($new_modules_child[$i]); - break; - } else if (isset($new_modules[$index]['children'])) { - self::recursive_modules_tree_view($new_modules[$index]['children'], $new_modules_child, $i, $child); - } - } - } + /** + * @brief Recursive function to remove the empty groups + * + * @param groups All groups structure + * + * @return new_groups A new groups structure without empty groups + */ + protected function deleteEmptyGroups ($groups) { + if($this->displayAllGroups) return $groups; + $new_groups = array(); + foreach ($groups as $group) { + // If a group is empty, do not add to new_groups. + if (!isset($group['counters']['total']) || $group['counters']['total'] == 0) { + continue; + } + // Tray to remove the children groups + if (!empty($group['children'])) { + $children = $this->deleteEmptyGroups ($group['children']); + if (empty($children)) unset($group['children']); + else $group['children'] = $children; + } + $new_groups[] = $group; + } + return $new_groups; + } + protected function deleteEmptyGroupsNotPropagate ($groups) { + if($this->displayAllGroups) return $groups; + $new_groups = array(); + foreach ($groups as $group) { + // Tray to remove the children groups + if (!empty($group['children'])) { + $children = $this->deleteEmptyGroupsNotPropagate ($group['children']); + if (empty($children)) { + unset($group['children']); + // If a group is empty, do not add to new_groups. + if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { + $new_groups[] = $group; + } + } else { + $group['children'] = $children; + $new_groups[] = $group; + } + } else { + // If a group is empty, do not add to new_groups. + if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { + $new_groups[] = $group; + } + } + } + return $new_groups; + } - static function processCounters(&$groups) - { - $all_counters = []; - foreach ($groups as $id => $group) { - $child_counters = []; - if (!empty($groups[$id]['children'])) { - $child_counters = self::processCounters($groups[$id]['children']); - } + private static function extractGroupsWithIDs ($groups, $ids_hash) { + $result_groups = array(); + foreach ($groups as $group) { + if (isset($ids_hash[$group['id']])) { + $result_groups[] = $group; + } + else if (!empty($group['children'])) { + $result = self::extractGroupsWithIDs($group['children'], $ids_hash); - if (!empty($child_counters)) { - foreach ($child_counters as $type => $value) { - $groups[$id]['counters'][$type] += $value; - } - } + // Item found on children + if (!empty($result)) { + $result_groups = array_merge($result_groups, $result); + } + } + } - foreach ($groups[$id]['counters'] as $type => $value) { - $all_counters[$type] += $value; - } - } + return $result_groups; + } - return $all_counters; - } + private static function extractItemWithID ($items, $item_id, $item_type = "group", $strictACL = false) { + foreach ($items as $item) { + if ($item["type"] != $item_type) + continue; + // Item found + if ($strictACL && is_metaconsole()) { + foreach ($item["id"] as $server_id => $id) { + if ($id == $item_id) + return $item; + } + } + else { + if ($item["id"] == $item_id) + return $item; + } - /** - * @brief Recursive function to remove the empty groups - * - * @param groups All groups structure - * - * @return new_groups A new groups structure without empty groups - */ - protected function deleteEmptyGroups($groups) - { - if ($this->displayAllGroups) { - return $groups; - } + if ($item["type"] == "group" && !empty($item["children"])) { + $result = self::extractItemWithID($item["children"], $item_id, $item_type, $strictACL); - $new_groups = []; - foreach ($groups as $group) { - // If a group is empty, do not add to new_groups. - if (!isset($group['counters']['total']) || $group['counters']['total'] == 0) { - continue; - } + // Item found on children + if ($result !== false) + return $result; + } + } - // Tray to remove the children groups - if (!empty($group['children'])) { - $children = $this->deleteEmptyGroups($group['children']); - if (empty($children)) { - unset($group['children']); - } else { - $group['children'] = $children; - } - } - - $new_groups[] = $group; - } - - return $new_groups; - } - - - protected function deleteEmptyGroupsNotPropagate($groups) - { - if ($this->displayAllGroups) { - return $groups; - } - - $new_groups = []; - foreach ($groups as $group) { - // Tray to remove the children groups - if (!empty($group['children'])) { - $children = $this->deleteEmptyGroupsNotPropagate($group['children']); - if (empty($children)) { - unset($group['children']); - // If a group is empty, do not add to new_groups. - if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { - $new_groups[] = $group; - } - } else { - $group['children'] = $children; - $new_groups[] = $group; - } - } else { - // If a group is empty, do not add to new_groups. - if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { - $new_groups[] = $group; - } - } - } - - return $new_groups; - } - - - private static function extractGroupsWithIDs($groups, $ids_hash) - { - $result_groups = []; - foreach ($groups as $group) { - if (isset($ids_hash[$group['id']])) { - $result_groups[] = $group; - } else if (!empty($group['children'])) { - $result = self::extractGroupsWithIDs($group['children'], $ids_hash); - - // Item found on children - if (!empty($result)) { - $result_groups = array_merge($result_groups, $result); - } - } - } - - return $result_groups; - } - - - private static function extractItemWithID($items, $item_id, $item_type='group', $strictACL=false) - { - foreach ($items as $item) { - if ($item['type'] != $item_type) { - continue; - } - - // Item found - if ($strictACL && is_metaconsole()) { - foreach ($item['id'] as $server_id => $id) { - if ($id == $item_id) { - return $item; - } - } - } else { - if ($item['id'] == $item_id) { - return $item; - } - } - - if ($item['type'] == 'group' && !empty($item['children'])) { - $result = self::extractItemWithID($item['children'], $item_id, $item_type, $strictACL); - - // Item found on children - if ($result !== false) { - return $result; - } - } - } - - // Item not found - return false; - } - - - protected function getDisplayHierarchy() - { - return $this->filter['searchHirearchy'] || - (empty($this->filter['searchAgent']) && empty($this->filter['searchModule'])); - } + // Item not found + return false; + } + protected function getDisplayHierarchy() { + return $this->filter['searchHirearchy'] || + (empty($this->filter['searchAgent']) && empty($this->filter['searchModule'])); + } } + +?> + diff --git a/pandora_console/include/class/TreeGroupEdition.class.php b/pandora_console/include/class/TreeGroupEdition.class.php index 55efebe976..dea62da238 100644 --- a/pandora_console/include/class/TreeGroupEdition.class.php +++ b/pandora_console/include/class/TreeGroupEdition.class.php @@ -1,120 +1,108 @@ id == -1) { + $this->getFirstLevel(); + } + } + + protected function getProcessedGroups () { + $processed_groups = array(); + // Index and process the groups + $groups = $this->getGroupCounters(); + + // If user have not permissions in parent, set parent node to 0 (all) + // Avoid to do foreach for admins + if (!users_can_manage_group_all("AR")) { + foreach ($groups as $id => $group) { + if (!isset($this->userGroups[$groups[$id]['parent']])) { + $groups[$id]['parent'] = 0; + } + } + } + // Build the group hierarchy + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + $parent = $groups[$id]['parent']; + // Parent exists + if (!isset($groups[$parent]['children'])) { + $groups[$parent]['children'] = array(); + } + // Store a reference to the group into the parent + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent + $groups[$id]['have_parent'] = true; + } + } + + // Sort the children groups + foreach ($groups as $id => $group) { + if (isset($groups[$id]['children'])) { + usort($groups[$id]['children'], array("Tree", "cmpSortNames")); + } + } + //Filter groups and eliminates the reference to children groups out of her parent + $groups = array_filter($groups, function ($group) { + return !$group['have_parent']; + }); + + usort($groups, array("Tree", "cmpSortNames")); + return $groups; + } - public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR') - { - global $config; - - parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - } - - - protected function getData() - { - if ($this->id == -1) { - $this->getFirstLevel(); - } - } - - - protected function getProcessedGroups() - { - $processed_groups = []; - // Index and process the groups - $groups = $this->getGroupCounters(); - - // If user have not permissions in parent, set parent node to 0 (all) - // Avoid to do foreach for admins - if (!users_can_manage_group_all('AR')) { - foreach ($groups as $id => $group) { - if (!isset($this->userGroups[$groups[$id]['parent']])) { - $groups[$id]['parent'] = 0; - } - } - } - - // Build the group hierarchy - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { - $parent = $groups[$id]['parent']; - // Parent exists - if (!isset($groups[$parent]['children'])) { - $groups[$parent]['children'] = []; - } - - // Store a reference to the group into the parent - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent - $groups[$id]['have_parent'] = true; - } - } - - // Sort the children groups - foreach ($groups as $id => $group) { - if (isset($groups[$id]['children'])) { - usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); - } - } - - // Filter groups and eliminates the reference to children groups out of her parent - $groups = array_filter( - $groups, - function ($group) { - return !$group['have_parent']; - } - ); - - usort($groups, ['Tree', 'cmpSortNames']); - return $groups; - } - - - protected function getGroupCounters() - { - $messages = [ - 'confirm' => __('Confirm'), - 'cancel' => __('Cancel'), - 'messg' => __('Are you sure?'), - ]; - $sql = 'SELECT id_grupo AS gid, + protected function getGroupCounters() { + $messages = array( + 'confirm' => __('Confirm'), + 'cancel' => __('Cancel'), + 'messg' => __('Are you sure?') + ); + $sql = "SELECT id_grupo AS gid, nombre as name, parent, icon FROM tgrupo - '; + "; - $stats = db_get_all_rows_sql($sql); - $group_stats = []; - foreach ($stats as $group) { - $group_stats[$group['gid']]['name'] = $group['name']; - $group_stats[$group['gid']]['parent'] = $group['parent']; - $group_stats[$group['gid']]['icon'] = $group['icon']; - $group_stats[$group['gid']]['id'] = $group['gid']; - $group_stats[$group['gid']]['type'] = 'group'; - - $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); - $group_stats[$group['gid']]['delete']['messages'] = $messages; - $group_stats[$group['gid']]['edit'] = 1; - $group_stats[$group['gid']]['alerts'] = ''; - } - - return $group_stats; - } + $stats = db_get_all_rows_sql($sql); + $group_stats = array(); + foreach ($stats as $group) { + $group_stats[$group['gid']]['name'] = $group['name']; + $group_stats[$group['gid']]['parent'] = $group['parent']; + $group_stats[$group['gid']]['icon'] = $group['icon']; + $group_stats[$group['gid']]['id'] = $group['gid']; + $group_stats[$group['gid']]['type'] = 'group'; + $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); + $group_stats[$group['gid']]['delete']['messages'] = $messages; + $group_stats[$group['gid']]['edit'] = 1; + $group_stats[$group['gid']]['alerts'] = ''; + } + return $group_stats; + } } + +?> + diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php new file mode 100644 index 0000000000..46f9139427 --- /dev/null +++ b/pandora_console/include/class/TreeService.class.php @@ -0,0 +1,342 @@ +L1fieldName = "id_group"; + $this->L1extraFields = array( + "ts.name AS `name`", + "ts.id AS `sid`" + ); + + $this->filter['statusAgent'] = AGENT_STATUS_ALL; + + $this->avoid_condition = true; + + $this->L2inner = 'LEFT JOIN tservice_element tse + ON tse.id_agent = ta.id_agente'; + + $this->L2condition = 'AND tse.id_service='.$this->id; + + } + + public function setPropagateCounters($value) { + $this->propagateCounters = (bool)$value; + } + + public function setDisplayAllGroups($value) { + $this->displayAllGroups = (bool)$value; + } + + protected function getData() { + if ($this->id == -1) { + $this->getFirstLevel(); + } elseif ($this->type == 'services') { + $this->getSecondLevel(); + } elseif ($this->type == 'agent') { + $this->getThirdLevel(); + } + } + + protected function getFirstLevel() { + $processed_items = $this->getProcessedServices(); + $ids = array_keys($processed_items); + + + + $filter=array('id'=>$ids); + + $own_info = get_user_info($config['id_user']); + + if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { + $display_all_services = true; + } else { + $display_all_services = false; + } + + $this->tree = []; + + $services = services_get_services($filter, false, $display_all_services); + + foreach ($services as $row) { + + + + $status = services_get_status($row, true); + + switch ($status) { + + case SERVICE_STATUS_NORMAL: + $processed_items[$row['id']]['statusImageHTML']='NORMAL status.'; + break; + + case SERVICE_STATUS_CRITICAL: + $processed_items[$row['id']]['statusImageHTML']='CRITICAL status.'; + break; + + case SERVICE_STATUS_WARNING: + $processed_items[$row['id']][$key]['statusImageHTML']='WARNING status.'; + break; + + case SERVICE_STATUS_UNKNOWN: + default: + $processed_items[$row['id']]['statusImageHTML']='UNKNOWN status.'; + break; + } + } + + $this->tree = $processed_items; + } + + protected function getProcessedServices () { + $fields = $this->getFirstLevelFields(); + + //hd($this->userGroupsArray, true); + + if (users_can_manage_group_all("AR")){ + $groups_acl = ""; + } + else{ + $groups_acl = "AND ts.id_group IN (".implode(',', $this->userGroupsArray).")"; + } + + $sql = sprintf("SELECT t1.* + FROM tservice_element tss + RIGHT JOIN + (SELECT ts.id, ts.id_agent_module, ts.name, ts.name AS `alias`, ts.id AS `rootID`, + 'services' AS rootType, 'services' AS type, + 0 AS quiet, + SUM(if((tse.id_agent<>0), 1, 0)) AS `total_agents`, + SUM(if((tse.id_agente_modulo<>0), 1, 0)) AS `total_modules`, + SUM(if((tse.id_service_child<>0), 1, 0)) AS `total_services` + FROM tservice ts + LEFT JOIN tservice_element tse + ON ts.id=tse.id_service + GROUP BY id + ) as t1 + ON tss.id_service_child = t1.id + WHERE tss.id_service_child IS NULL + %s + ", + $groups_acl + ); + + + $stats = db_get_all_rows_sql($sql); + + + + + $services = array(); + + foreach ($stats as $service) { + $services[$service['id']] = $this->getProcessedItem($services[$service['id']]); + if ($service['total_services']+$service['total_agents']+$service['total_modules'] > 0) + $services[$service['id']]['searchChildren'] = 1; + else + $services[$service['id']]['searchChildren'] = 0; + + $services[$service['id']]['counters'] = array('total_services'=>$service['total_services'], 'total_agents'=>$service['total_agents'], 'total_modules'=>$service['total_modules']); + $services[$service['id']]['name'] = $service['name']; + $services[$service['id']]['id'] = $service['id']; + $services[$service['id']]['serviceDetail']='http://localhost/pandora_console/index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id']; + } + + hd("STATS:::::::::::::::::::::::::::::: ", true); +hd($services, true); + + return $services; + } + + protected function getFirstLevelFields() { + $fields = array(); + + return implode(",", array_merge($fields, $this->L1extraFields)); + } + + protected function getSecondLevel() { + $data = array(); + $data_agents = array(); + $data_modules = array(); + $data_services = array(); + + $sql = $this->getSecondLevelSql(); + $data_agents = db_process_sql($sql); + + if (empty($data_agents)) + $data_agents = array(); + + $this->processAgents($data_agents); + + foreach ($data_agents as $key => $agent) { + $data_agents[$key]['showEventsBtn'] = 1; + $data_agents[$key]['eventAgent'] = $agent['id']; + } + + $sql = $this->getSecondLevelModulesSql(); + $data_modules = db_process_sql($sql); + + if (empty($data_modules)) + $data_modules = array(); + else { + foreach ($data_modules as $key => $module) { + switch ($module['estado']) { + case '0': + $data_modules[$key]['statusImageHTML'] = 'NORMAL status.'; + break; + case '1': + $data_modules[$key]['statusImageHTML'] = 'CRITICAL status.'; + break; + case '2': + $data_modules[$key]['statusImageHTML'] = 'WARNING status.'; + break; + case '4': + $data_modules[$key]['statusImageHTML'] = 'UNKNOWN status.'; + break; + default: + # code... + break; + } + + $data_modules[$key]['showEventsBtn'] = 1; + $data_modules[$key]['eventModule'] = $module['id_agente_modulo']; + } + } + + hd("MODULESSSS::", true); +hd($data_modules, true); + + $sql = $this->getSecondLevelServicesSql(); + $data_services = db_process_sql($sql); + + + $service_stats = array(); + + foreach ($data_services as $service) { + $service_stats[$service['id']]['id'] = (int)$service['id']; + $service_stats[$service['id']]['name'] = $service['name']; + $service_stats[$service['id']]['alias'] = $service['name']; + if ($service['total_services']+$service['total_agents']+$service['total_modules'] > 0) + $service_stats[$service['id']]['searchChildren'] = 1; + else + $services[$service['id']]['searchChildren'] = 0; + + $service_stats[$service['id']]['rootID'] = $service['rootID']; + $service_stats[$service['id']]['rootType'] = $service['rootType']; + $service_stats[$service['id']]['type'] = 'services'; + $service_stats[$service['id']]['children']=array(); + $service_stats[$service['id']]['serviceDetail']='http://localhost/pandora_console/index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id']; + $service_stats[$service['id']]['counters']=array('total_services'=>$service['total_services'], 'total_agents'=>$service['total_agents'], 'total_modules'=>$service['total_modules']); + + } + + $own_info = get_user_info($config['id_user']); + + if ($own_info['is_admin'] || check_acl($config['id_user'], 0, 'PM')) { + $display_all_services = true; + } else { + $display_all_services = false; + } + + $services = services_get_services($filter, false, $display_all_services); + + foreach ($services as $row) { + + if (!array_key_exists($row['id'], $service_stats)) + continue; + + $status = services_get_status($row, true); + + + switch ($status) { + + case SERVICE_STATUS_NORMAL: + $service_stats[$row['id']]['statusImageHTML']='NORMAL status.'; + break; + + case SERVICE_STATUS_CRITICAL: + $service_stats[$row['id']]['statusImageHTML']='CRITICAL status.'; + break; + + case SERVICE_STATUS_WARNING: + $service_stats[$row['id']][$key]['statusImageHTML']='WARNING status.'; + break; + + case SERVICE_STATUS_UNKNOWN: + default: + $service_stats[$row['id']]['statusImageHTML']='UNKNOWN status.'; + break; + } + } + + $data_services = array_values($service_stats); + + $data = array_merge($data_services, $data_agents, $data_modules); + + if (empty($data)) { + $this->tree = array(); + return; + } + + $this->tree = $data; + } + + protected function getSecondLevelServicesSql() { + $group_acl = $this->getGroupAclCondition(); + + $sql = "SELECT ts.id, ts.name, tse1.id_service AS `rootID`, 'services' AS rootType, 'services' AS type, 0 AS quiet, SUM(if((tse2.id_agent<>0), 1, 0)) AS `total_agents`, SUM(if((tse2.id_agente_modulo<>0), 1, 0)) AS `total_modules`, SUM(if((tse2.id_service_child<>0), 1, 0)) AS `total_services`, 0 AS fired_count, 0 AS normal_count, 0 AS warning_count, 0 AS critical_count, 0 AS unknown_count, 0 AS notinit_count, 0 AS state_critical, 0 AS state_warning, 0 AS state_unknown, 0 AS state_notinit, 0 AS state_normal, 0 AS state_total, '' AS statusImageHTML, '' AS alertImageHTML + FROM tservice_element tse1 + LEFT JOIN tservice_element tse2 ON tse1.id_service_child=tse2.id_service + LEFT JOIN tservice ts ON tse1.id_service_child=ts.id + WHERE tse1.id_service=$this->id AND tse1.id_service_child<>0 + GROUP BY tse1.id_service_child + "; + + return $sql; + } + + + protected function getSecondLevelModulesSql() { + + $sql = "SELECT tse.id_agente_modulo, nombre AS `name`, nombre AS `alias`, tse.id_service AS `rootID`, 'services' AS `rootType`, 'modules' AS `type`, estado + FROM tservice_element tse + INNER JOIN tagente_modulo tam ON tse.id_agente_modulo=tam.id_agente_modulo + INNER JOIN tagente_estado tae ON tam.id_agente_modulo=tae.id_agente_estado + WHERE tse.id_service=$this->id AND tse.id_agente_modulo<>0 + "; + + return $sql; + } + + protected function getAgentStatusFilter ($status = self::TV_DEFAULT_AGENT_STATUS) { + return ''; + } + +} + +?> + diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index e3f7260de4..e22a17ced9 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -13,895 +13,991 @@ // GNU General Public License for more details. var TreeController = { - controllers: [], - getController: function() { - var controller = { - index: -1, - recipient: "", - tree: [], - emptyMessage: "No data found.", - foundMessage: "Found groups", - errorMessage: "Error", - baseURL: "", - ajaxURL: "ajax.php", - ajaxPage: "include/ajax/tree.ajax", - detailRecipient: "", - filter: {}, - counterTitles: {}, - shouldHaveCounters: true, - reload: function() { - // Bad recipient - if ( - typeof this.recipient == "undefined" || - this.recipient.length == 0 - ) { - return; - } - - // Load branch - function _processGroup(container, elements, rootGroup) { - var $group = $("
      "); - - // First group - if (typeof rootGroup != "undefinded" && rootGroup == true) { - $group - .addClass("tree-root") - .hide() - .prepend( - '' - ); - } - // Normal group - else { - $group.addClass("tree-group").hide(); - } - - container.append($group); - - _.each(elements, function(element) { - element.jqObject = _processNode($group, element); - }); - - return $group; - } - - // Load leaf counters - function _processNodeCounters(container, counters, type) { - var hasCounters = false; - - if (typeof counters != "undefined") { - function _processNodeCounterTitle( - container, - elementType, - counterType - ) { - var defaultCounterTitles = { - total: { - agents: "Total agents", - modules: "Total modules", - none: "Total" - }, - alerts: { - agents: "Alerts fired", - modules: "Alerts fired", - none: "Alerts fired" - }, - critical: { - agents: "Critical agents", - modules: "Critical modules", - none: "Critical" - }, - warning: { - agents: "Warning agents", - modules: "Warning modules", - none: "Warning" - }, - unknown: { - agents: "Unknown agents", - modules: "Unknown modules", - none: "Unknown" - }, - not_init: { - agents: "Not init agents", - modules: "Not init modules", - none: "Not init" - }, - ok: { - agents: "Normal agents", - modules: "Normal modules", - none: "Normal" - } - }; - - try { - var title = ""; - switch (elementType) { - case "group": - if ( - typeof controller.counterTitles != "undefined" && - typeof controller.counterTitles[counterType] != - "undefined" && - typeof controller.counterTitles[counterType].agents != - "undefined" - ) { - title = controller.counterTitles[counterType].agents; - } else { - title = defaultCounterTitles[counterType].agents; - } - break; - case "agent": - if ( - typeof controller.counterTitles != "undefined" && - typeof controller.counterTitles[counterType] != - "undefined" && - typeof controller.counterTitles[counterType].modules != - "undefined" - ) { - title = controller.counterTitles[counterType].modules; - } else { - title = defaultCounterTitles[counterType].modules; - } - break; - default: - if ( - typeof controller.counterTitles != "undefined" && - typeof controller.counterTitles[counterType] != - "undefined" && - typeof controller.counterTitles[counterType].none != - "undefined" - ) { - title = controller.counterTitles[counterType].none; - } else { - title = defaultCounterTitles[counterType].none; - } - break; - } - if (title.length > 0) { - container - .data("title", title) - .addClass("forced_title") - .data("use_title_for_force_title", 1); // Trick to make easier the 'force title' output - } - } catch (error) { - // console.log(error); - } - } - - var $counters = $("
      "); - $counters.addClass("tree-node-counters"); - - if (typeof counters.total != "undefined" && counters.total >= 0) { - var $totalCounter = $("
      "); - $totalCounter - .addClass("tree-node-counter") - .addClass("total") - .html(counters.total); - - _processNodeCounterTitle($totalCounter, type, "total"); - - // Open the parentheses - $counters.append(" ("); - - $counters.append($totalCounter); - - if ( - typeof counters.alerts != "undefined" && - counters.alerts > 0 - ) { - var $firedCounter = $("
      "); - $firedCounter - .addClass("tree-node-counter") - .addClass("alerts") - .addClass("orange") - .html(counters.alerts); - - _processNodeCounterTitle($firedCounter, type, "alerts"); - - $counters.append(" : ").append($firedCounter); - } - if ( - typeof counters.critical != "undefined" && - counters.critical > 0 - ) { - var $criticalCounter = $("
      "); - $criticalCounter - .addClass("tree-node-counter") - .addClass("critical") - .addClass("red") - .html(counters.critical); - - _processNodeCounterTitle($criticalCounter, type, "critical"); - - $counters.append(" : ").append($criticalCounter); - } - if ( - typeof counters.warning != "undefined" && - counters.warning > 0 - ) { - var $warningCounter = $("
      "); - $warningCounter - .addClass("tree-node-counter") - .addClass("warning") - .addClass("yellow") - .html(counters.warning); - - _processNodeCounterTitle($warningCounter, type, "warning"); - - $counters.append(" : ").append($warningCounter); - } - if ( - typeof counters.unknown != "undefined" && - counters.unknown > 0 - ) { - var $unknownCounter = $("
      "); - $unknownCounter - .addClass("tree-node-counter") - .addClass("unknown") - .addClass("grey") - .html(counters.unknown); - - _processNodeCounterTitle($unknownCounter, type, "unknown"); - - $counters.append(" : ").append($unknownCounter); - } - if ( - typeof counters.not_init != "undefined" && - counters.not_init > 0 - ) { - var $notInitCounter = $("
      "); - $notInitCounter - .addClass("tree-node-counter") - .addClass("not_init") - .addClass("blue") - .html(counters.not_init); - - _processNodeCounterTitle($notInitCounter, type, "not_init"); - - $counters.append(" : ").append($notInitCounter); - } - if (typeof counters.ok != "undefined" && counters.ok > 0) { - var $okCounter = $("
      "); - $okCounter - .addClass("tree-node-counter") - .addClass("ok") - .addClass("green") - .html(counters.ok); - - _processNodeCounterTitle($okCounter, type, "ok"); - - $counters.append(" : ").append($okCounter); - } - - // Close the parentheses - $counters.append(")"); - - hasCounters = true; - } - - // Add the counters html to the container - container.append($counters); - } - - return hasCounters; - } - - // Load leaf - function _processNode(container, element) { - // type, [id], [serverID], callback - function _getTreeDetailData(type, id, serverID, callback) { - var lastParam = arguments[arguments.length - 1]; - var callback; - if (typeof lastParam === "function") callback = lastParam; - - var serverID; - if (arguments.length >= 4) serverID = arguments[2]; - var id; - if (arguments.length >= 3) id = arguments[1]; - var type; - if (arguments.length >= 2) type = arguments[0]; - - if (typeof type === "undefined") - throw new TypeError("Type required"); - if (typeof callback === "undefined") - throw new TypeError("Callback required"); - - var postData = { - page: controller.ajaxPage, - getDetail: 1, - type: type - }; - - if (typeof id !== "undefined") postData.id = id; - if (typeof serverID !== "undefined") postData.serverID = serverID; - - $.ajax({ - url: controller.ajaxURL, - type: "POST", - dataType: "html", - data: postData, - success: function(data, textStatus, xhr) { - callback(null, data); - }, - error: function(xhr, textStatus, errorThrown) { - callback(errorThrown); - } - }); - } - - var $node = $("
    • "); - var $leafIcon = $("
      "); - var $content = $("
      "); - - // Leaf icon - $leafIcon.addClass("leaf-icon"); - - // Content - $content.addClass("node-content"); - switch (element.type) { - case "group": - if ( - typeof element.icon != "undefined" && - element.icon.length > 0 - ) { - $content.append( - ' ' - ); - } else if ( - typeof element.iconHTML != "undefined" && - element.iconHTML.length > 0 - ) { - $content.append(element.iconHTML + " "); - } - $content.append(element.name); - - if (typeof element.edit != "undefined") { - var url_edit = - controller.baseURL + - "index.php?sec=gagente&sec2=godmode/groups/configure_group&tab=tree&id_group=" + - element.id; - var $updateicon = $( - '' - ); - var $updatebtn = $('').append( - $updateicon - ); - $content.append($updatebtn); - } - - if (typeof element.delete != "undefined") { - var url_delete = - controller.baseURL + - "index.php?sec=gagente&sec2=godmode/groups/group_list&tab=tree&delete_group=1&id_group=" + - element.id; - var $deleteBtn = $( - '' - ); - $deleteBtn.click(function(event) { - var ok_function = function() { - window.location.replace(url_delete); - }; - display_confirm_dialog( - element.delete.messages.messg, - element.delete.messages.confirm, - element.delete.messages.cancel, - ok_function - ); - }); - $content.append($deleteBtn); - } - - if (typeof element.alerts != "undefined") { - $content.append(element.alerts); - } - - break; - case "agent": - // Is quiet - if ( - typeof element.quietImageHTML != "undefined" && - element.quietImageHTML.length > 0 - ) { - var $quietImage = $(element.quietImageHTML); - $quietImage.addClass("agent-quiet"); - - $content.append($quietImage); - } - // Status image - if ( - typeof element.statusImageHTML != "undefined" && - element.statusImageHTML.length > 0 - ) { - var $statusImage = $(element.statusImageHTML); - $statusImage.addClass("agent-status"); - - $content.append($statusImage); - } - // Alerts fired image - if ( - typeof element.alertImageHTML != "undefined" && - element.alertImageHTML.length > 0 - ) { - var $alertImage = $(element.alertImageHTML); - $alertImage.addClass("agent-alerts-fired"); - - $content.append($alertImage); - } - $content.append(element.alias); - break; - case "module": - // Status image - if ( - typeof element.statusImageHTML != "undefined" && - element.statusImageHTML.length > 0 - ) { - var $statusImage = $(element.statusImageHTML); - $statusImage.addClass("module-status"); - - $content.append($statusImage); - } - // Server type - if ( - typeof element.serverTypeHTML != "undefined" && - element.serverTypeHTML.length > 0 && - element.serverTypeHTML != "--" - ) { - var $serverTypeImage = $(element.serverTypeHTML); - $serverTypeImage.addClass("module-server-type"); - - $content.append($serverTypeImage); - } - - if ( - typeof element.showGraphs != "undefined" && - element.showGraphs != 0 - ) { - // Graph pop-up - if (typeof element.moduleGraph != "undefined") { - if (element.statusImageHTML.indexOf("data:image") != -1) { - var $graphImage = $( - ' ' - ); - } else { - var $graphImage = $( - ' ' - ); - } - - $graphImage.addClass("module-graph").click(function(e) { - e.preventDefault(); - if (element.statusImageHTML.indexOf("data:image") != -1) { - try { - winopeng_var( - decodeURI(element.snapshot[0]), - element.snapshot[1], - element.snapshot[2], - element.snapshot[3] - ); - } catch (error) { - // console.log(error); - } - } else { - try { - winopeng( - element.moduleGraph.url, - element.moduleGraph.handle - ); - } catch (error) { - // console.log(error); - } - } - }); - - $content.append($graphImage); - } - - // Data pop-up - if (typeof element.id != "undefined" && !isNaN(element.id)) { - var $dataImage = $( - ' ' - ); - $dataImage.addClass("module-data").click(function(e) { - e.preventDefault(); - - try { - var serverName = - element.serverName.length > 0 ? element.serverName : ""; - if ($("#module_details_window").length > 0) - show_module_detail_dialog( - element.id, - "", - serverName, - 0, - 86400, - element.name.replace(/ /g, " ") - ); - } catch (error) { - // console.log(error); - } - }); - - $content.append($dataImage); - } - } - - // Alerts - if ( - typeof element.alertsImageHTML != "undefined" && - element.alertsImageHTML.length > 0 - ) { - var $alertsImage = $(element.alertsImageHTML); - - $alertsImage - .addClass("module-alerts") - .click(function(e) { - _getTreeDetailData( - "alert", - element.id, - element.serverID, - function(error, data) { - if (error) { - // console.error(error); - } else { - controller.detailRecipient - .render(element.name, data) - .open(); - } - } - ); - - // Avoid the execution of the module detail event - e.stopPropagation(); - }) - .css("cursor", "pointer"); - - $content.append($alertsImage); - } - - $content.append(element.name); - break; - case "os": - if ( - typeof element.icon != "undefined" && - element.icon.length > 0 - ) { - $content.append( - ' ' - ); - } - $content.append(element.name); - break; - case "tag": - if ( - typeof element.icon != "undefined" && - element.icon.length > 0 - ) { - $content.append( - ' ' - ); - } else { - $content.append( - ' ' - ); - } - $content.append(element.name); - break; - default: - $content.append(element.name); - break; - } - - // Load the status counters - var hasCounters = _processNodeCounters( - $content, - element.counters, - element.type - ); - //Don't show empty groups - if (element.type == "agent") { - if (!hasCounters) { - return; - } - } - // If exist the detail container, show the data - if (typeof controller.detailRecipient !== "undefined") { - if (element.type == "agent" || element.type == "module") { - $content - .click(function(e) { - _getTreeDetailData( - element.type, - element.id, - element.serverID, - function(error, data) { - if (error) { - // console.error(error); - } else { - controller.detailRecipient - .render(element.name, data) - .open(); - } - } - ); - }) - .css("cursor", "pointer"); - } - } - - $node - .addClass("tree-node") - .append($leafIcon) - .append($content); - - container.append($node); - - $node.addClass("leaf-empty"); - - if ( - typeof element.children != "undefined" && - element.children.length > 0 - ) { - $node.removeClass("leaf-empty").addClass("leaf-closed"); - - // Add children - var $children = _processGroup($node, element.children); - $node.data("children", $children); - - if ( - typeof element.searchChildren == "undefined" || - !element.searchChildren - ) { - $leafIcon.click(function(e) { - e.preventDefault(); - - if ($node.hasClass("leaf-open")) { - $node - .removeClass("leaf-open") - .addClass("leaf-closed") - .data("children") - .slideUp(); - } else { - $node - .removeClass("leaf-closed") - .addClass("leaf-open") - .data("children") - .slideDown(); - } - }); - } - } - // Get hash and user. - var public_hash = $("#hidden-publi_dash_tree_view_hash").val(); - if (typeof public_hash === "undefined") public_hash = 0; - var public_user = $("#hidden-publi_dash_tree_view_id_user").val(); - if (typeof public_user === "undefined") public_user = 0; - - if ( - typeof element.searchChildren != "undefined" && - element.searchChildren - ) { - if ( - element.rootType == "group_edition" && - typeof element.children == "undefined" - ) { - $node.addClass("leaf-empty"); - } else { - $node.removeClass("leaf-empty").addClass("leaf-closed"); - $leafIcon.click(function(e) { - e.preventDefault(); - - if ( - !$node.hasClass("leaf-loading") && - !$node.hasClass("children-loaded") && - !$node.hasClass("leaf-empty") - ) { - $node - .removeClass("leaf-closed") - .removeClass("leaf-error") - .addClass("leaf-loading"); - - $.ajax({ - url: controller.ajaxURL, - type: "POST", - dataType: "json", - data: { - page: controller.ajaxPage, - getChildren: 1, - id: element.id, - type: element.type, - rootID: element.rootID, - serverID: element.serverID, - rootType: element.rootType, - filter: controller.filter, - hash: public_hash, - id_user: public_user - }, - complete: function(xhr, textStatus) { - $node.removeClass("leaf-loading"); - $node.addClass("children-loaded"); - }, - success: function(data, textStatus, xhr) { - if (data.success) { - var $group = $node.children("ul.tree-group"); - if ( - (typeof data.tree != "undefined" && - data.tree.length > 0) || - $group.length > 0 - ) { - $node.addClass("leaf-open"); - - if ($group.length <= 0) { - $group = $("
        "); - $group.addClass("tree-group").hide(); - $node.append($group); - } - - _.each(data.tree, function(element) { - element.jqObject = _processNode($group, element); - }); - - $group.slideDown(); - - $node.data("children", $group); - - // Add again the hover event to the 'force_callback' elements - forced_title_callback(); - } else { - $node.addClass("leaf-empty"); - } - } else { - $node.addClass("leaf-error"); - } - }, - error: function(xhr, textStatus, errorThrown) { - $node.addClass("leaf-error"); - } - }); - } else if (!$node.hasClass("leaf-empty")) { - if ($node.hasClass("leaf-open")) { - $node - .removeClass("leaf-open") - .addClass("leaf-closed") - .data("children") - .slideUp(); - } else { - $node - .removeClass("leaf-closed") - .addClass("leaf-open") - .data("children") - .slideDown(); - } - } - }); - } - } - - return $node; - } - - if (controller.recipient.length == 0) { - return; - } else if (controller.tree.length == 0) { - controller.recipient.empty(); - controller.recipient.html( - "
        " + controller.emptyMessage + "
        " - ); - return; - } - - controller.recipient.empty(); - controller.recipient.html( - "
        " + - controller.foundMessage + - ": " + - controller.tree.length + - "
        " + - "
        " - ); - - var $children = _processGroup(this.recipient, this.tree, true); - $children.show(); - - controller.recipient.data("children", $children); - - // Add again the hover event to the 'force_callback' elements - forced_title_callback(); - }, - load: function() { - this.reload(); - }, - changeTree: function(tree) { - this.tree = tree; - this.reload(); - }, - init: function(data) { - if ( - typeof data.recipient !== "undefined" && - data.recipient.length > 0 - ) { - this.recipient = data.recipient; - } - if (typeof data.detailRecipient !== "undefined") { - this.detailRecipient = data.detailRecipient; - } - if (typeof data.tree !== "undefined") { - this.tree = data.tree; - } - if ( - typeof data.emptyMessage !== "undefined" && - data.emptyMessage.length > 0 - ) { - this.emptyMessage = data.emptyMessage; - } - if ( - typeof data.foundMessage !== "undefined" && - data.foundMessage.length > 0 - ) { - this.foundMessage = data.foundMessage; - } - if ( - typeof data.errorMessage !== "undefined" && - data.errorMessage.length > 0 - ) { - this.errorMessage = data.errorMessage; - } - if (typeof data.baseURL !== "undefined" && data.baseURL.length > 0) { - this.baseURL = data.baseURL; - } - if (typeof data.ajaxURL !== "undefined" && data.ajaxURL.length > 0) { - this.ajaxURL = data.ajaxURL; - } - if (typeof data.ajaxPage !== "undefined" && data.ajaxPage.length > 0) { - this.ajaxPage = data.ajaxPage; - } - if (typeof data.filter !== "undefined") { - this.filter = data.filter; - } - - this.load(); - }, - remove: function() { - if (typeof this.recipient != "undefined" && this.recipient.length > 0) { - this.recipient.empty(); - } - - if (this.index > -1) { - TreeController.controllers.splice(this.index, 1); - } - } - }; - controller.index = TreeController.controllers.push(controller) - 1; - - return controller; - } -}; + controllers: [], + getController: function () { + var controller = { + index: -1, + recipient: '', + tree: [], + emptyMessage: "No data found.", + foundMessage: "Found groups", + errorMessage: "Error", + baseURL: "", + ajaxURL: "ajax.php", + ajaxPage: "include/ajax/tree.ajax", + detailRecipient: '', + filter: {}, + counterTitles: {}, + shouldHaveCounters: true, + reload: function () { + // Bad recipient + if (typeof this.recipient == 'undefined' || this.recipient.length == 0) { + return; + } + + // Load branch + function _processGroup (container, elements, rootGroup) { + + var $group = $("
          "); + + // First group + if (typeof rootGroup != 'undefinded' && rootGroup == true) { + $group + .addClass("tree-root") + .hide() + .prepend(''); + } + // Normal group + else { + $group + .addClass("tree-group") + .hide(); + } + + container.append($group); + + _.each(elements, function(element) { + element.jqObject = _processNode($group, element); + }); + + return $group; + } + + // Load leaf counters + function _processNodeCounters (container, counters, type) { + var hasCounters = false; + + if (typeof counters != 'undefined') { + + function _processNodeCounterTitle (container, elementType, counterType) { + + var defaultCounterTitles = { + total: { + agents: "Total agents", + modules: "Total modules", + none: "Total" + }, + alerts: { + agents: "Alerts fired", + modules: "Alerts fired", + none: "Alerts fired" + }, + critical: { + agents: "Critical agents", + modules: "Critical modules", + none: "Critical" + }, + warning: { + agents: "Warning agents", + modules: "Warning modules", + none: "Warning" + }, + unknown: { + agents: "Unknown agents", + modules: "Unknown modules", + none: "Unknown" + }, + not_init: { + agents: "Not init agents", + modules: "Not init modules", + none: "Not init" + }, + ok: { + agents: "Normal agents", + modules: "Normal modules", + none: "Normal" + } + } + + var serviceCounterTitles = { + total_services: { + totals: "Services" + }, + total_agents: { + totals: "Agents" + }, + total_modules: { + totals: "Modules" + } + } + + try { + + var title = ''; + + switch (elementType) { + case "group": + if (typeof controller.counterTitles != 'undefined' + && typeof controller.counterTitles[counterType] != 'undefined' + && typeof controller.counterTitles[counterType].agents != 'undefined') { + title = controller.counterTitles[counterType].agents; + } + else { + title = defaultCounterTitles[counterType].agents; + } + break; + case "agent": + if (typeof controller.counterTitles != 'undefined' + && typeof controller.counterTitles[counterType] != 'undefined' + && typeof controller.counterTitles[counterType].modules != 'undefined') { + title = controller.counterTitles[counterType].modules; + } + else { + title = defaultCounterTitles[counterType].modules; + } + break; + case "services": + title = serviceCounterTitles[counterType].totals; + break; + default: + if (typeof controller.counterTitles != 'undefined' + && typeof controller.counterTitles[counterType] != 'undefined' + && typeof controller.counterTitles[counterType].none != 'undefined') { + title = controller.counterTitles[counterType].none; + } + else { + title = defaultCounterTitles[counterType].none; + } + break; + } + if (title.length > 0) { + container + .data("title", title) + .addClass("forced_title") + .data("use_title_for_force_title", 1); // Trick to make easier the 'force title' output + } + } + catch (error) { + // console.log(error); + } + } + + + if (type=="services") { + + var $counters = $("
          "); + $counters.addClass('tree-node-counters'); + + if (counters.total_services+counters.total_agents+counters.total_modules > 0) { + + // Open the parentheses + $counters.append(" ("); + + if (typeof counters.total_services != 'undefined' + && counters.total_services >= 0) { + + var $servicesCounter = $("
          "); + $servicesCounter + .addClass('tree-node-counter') + .addClass('total') + .html(counters.total_services); + + _processNodeCounterTitle($servicesCounter, type, "total_services"); + + $counters + .append($servicesCounter); + } else { + var $servicesCounter = $("
          "); + $servicesCounter + .addClass('tree-node-counter') + .addClass('total') + .html('0'); + + _processNodeCounterTitle($servicesCounter, type, "total_services"); + + $counters + .append($servicesCounter); + } + + if (typeof counters.total_agents != 'undefined' + && counters.total_agents > 0) { + var $agentsCounter = $("
          "); + $agentsCounter + .addClass('tree-node-counter') + .html(counters.total_agents); + + _processNodeCounterTitle($agentsCounter, type, "total_agents"); + + $counters + .append(" : ") + .append($agentsCounter); + } else { + var $agentsCounter = $("
          "); + $agentsCounter + .addClass('tree-node-counter') + .addClass('total') + .html('0'); + + _processNodeCounterTitle($agentsCounter, type, "total_agents"); + + $counters + .append(" : ") + .append($agentsCounter); + } + + if (typeof counters.total_modules != 'undefined' + && counters.total_modules > 0) { + var $modulesCounter = $("
          "); + $modulesCounter + .addClass('tree-node-counter') + .addClass('total') + .html(counters.total_modules); + + _processNodeCounterTitle($modulesCounter, type, "total_modules"); + + $counters + .append(" : ") + .append($modulesCounter); + } else { + var $modulesCounter = $("
          "); + $modulesCounter + .addClass('tree-node-counter') + .addClass('total') + .html('0'); + + _processNodeCounterTitle($modulesCounter, type, "total_modules"); + + $counters + .append(" : ") + .append($modulesCounter); + } + + // Close the parentheses + $counters.append(")"); + + hasCounters = true; + } + } else { + + var $counters = $("
          "); + $counters.addClass('tree-node-counters'); + + if (typeof counters.total != 'undefined' + && counters.total >= 0) { + + var $totalCounter = $("
          "); + $totalCounter + .addClass('tree-node-counter') + .addClass('total') + .html(counters.total); + + _processNodeCounterTitle($totalCounter, type, "total"); + + // Open the parentheses + $counters.append(" ("); + + $counters.append($totalCounter); + + if (typeof counters.alerts != 'undefined' + && counters.alerts > 0) { + var $firedCounter = $("
          "); + $firedCounter + .addClass('tree-node-counter') + .addClass('alerts') + .addClass('orange') + .html(counters.alerts); + + _processNodeCounterTitle($firedCounter, type, "alerts"); + + $counters + .append(" : ") + .append($firedCounter); + } + if (typeof counters.critical != 'undefined' + && counters.critical > 0) { + var $criticalCounter = $("
          "); + $criticalCounter + .addClass('tree-node-counter') + .addClass('critical') + .addClass('red') + .html(counters.critical); + + _processNodeCounterTitle($criticalCounter, type, "critical"); + + $counters + .append(" : ") + .append($criticalCounter); + } + if (typeof counters.warning != 'undefined' + && counters.warning > 0) { + var $warningCounter = $("
          "); + $warningCounter + .addClass('tree-node-counter') + .addClass('warning') + .addClass('yellow') + .html(counters.warning); + + _processNodeCounterTitle($warningCounter, type, "warning"); + + $counters + .append(" : ") + .append($warningCounter); + } + if (typeof counters.unknown != 'undefined' + && counters.unknown > 0) { + var $unknownCounter = $("
          "); + $unknownCounter + .addClass('tree-node-counter') + .addClass('unknown') + .addClass('grey') + .html(counters.unknown); + + _processNodeCounterTitle($unknownCounter, type, "unknown"); + + $counters + .append(" : ") + .append($unknownCounter); + } + if (typeof counters.not_init != 'undefined' + && counters.not_init > 0) { + var $notInitCounter = $("
          "); + $notInitCounter + .addClass('tree-node-counter') + .addClass('not_init') + .addClass('blue') + .html(counters.not_init); + + _processNodeCounterTitle($notInitCounter, type, "not_init"); + + $counters + .append(" : ") + .append($notInitCounter); + } + if (typeof counters.ok != 'undefined' + && counters.ok > 0) { + var $okCounter = $("
          "); + $okCounter + .addClass('tree-node-counter') + .addClass('ok') + .addClass('green') + .html(counters.ok); + + _processNodeCounterTitle($okCounter, type, "ok"); + + $counters + .append(" : ") + .append($okCounter); + } + } + + // Close the parentheses + $counters.append(")"); + + hasCounters = true; + } + + // Add the counters html to the container + container.append($counters); + } + + return hasCounters; + } + + // Load leaf + function _processNode (container, element) { + // type, [id], [serverID], callback + function _getTreeDetailData (type, id, serverID, callback) { + var lastParam = arguments[arguments.length - 1]; + var callback; + if (typeof lastParam === 'function') + callback = lastParam; + + var serverID; + if (arguments.length >= 4) + serverID = arguments[2]; + var id; + if (arguments.length >= 3) + id = arguments[1]; + var type; + if (arguments.length >= 2) + type = arguments[0]; + + if (typeof type === 'undefined') + throw new TypeError('Type required'); + if (typeof callback === 'undefined') + throw new TypeError('Callback required'); + + var postData = { + page: controller.ajaxPage, + getDetail: 1, + type: type + } + + if (typeof id !== 'undefined') + postData.id = id; + if (typeof serverID !== 'undefined') + postData.serverID = serverID; + + $.ajax({ + url: controller.ajaxURL, + type: 'POST', + dataType: 'html', + data: postData, + success: function(data, textStatus, xhr) { + callback(null, data); + }, + error: function(xhr, textStatus, errorThrown) { + callback(errorThrown); + } + }); + } + + var $node = $("
        • "); + var $leafIcon = $("
          "); + var $content = $("
          "); + + // Leaf icon + $leafIcon.addClass("leaf-icon"); + + // Content + $content.addClass("node-content"); + switch (element.type) { + case 'group': + if (typeof element.icon != 'undefined' && element.icon.length > 0) { + $content.append(' '); + } + else if (typeof element.iconHTML != 'undefined' && element.iconHTML.length > 0) { + $content.append(element.iconHTML + " "); + } + $content.append(element.name); + + if(typeof element.edit != 'undefined'){ + var url_edit = controller.baseURL + "index.php?sec=gagente&sec2=godmode/groups/configure_group&tab=tree&id_group=" + element.id; + var $updateicon = $('') + var $updatebtn = $('') + .append($updateicon); + $content.append($updatebtn); + } + + if(typeof element.delete != 'undefined'){ + var url_delete = controller.baseURL + "index.php?sec=gagente&sec2=godmode/groups/group_list&tab=tree&delete_group=1&id_group=" + element.id; + var $deleteBtn = $(''); + $deleteBtn.click(function (event){ + var ok_function = function(){ + window.location.replace(url_delete); + }; + display_confirm_dialog( + element.delete.messages.messg, + element.delete.messages.confirm, + element.delete.messages.cancel, + ok_function + ) + }); + $content.append($deleteBtn); + } + + if(typeof element.alerts != 'undefined'){ + $content.append(element.alerts); + } + + break; + case 'agent': + // Is quiet + if (typeof element.quietImageHTML != 'undefined' + && element.quietImageHTML.length > 0) { + var $quietImage = $(element.quietImageHTML); + $quietImage.addClass("agent-quiet"); + + $content.append($quietImage); + } + // Status image + if (typeof element.statusImageHTML != 'undefined' + && element.statusImageHTML.length > 0) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("agent-status"); + + $content.append($statusImage); + } + // Alerts fired image + if (typeof element.alertImageHTML != 'undefined' + && element.alertImageHTML.length > 0) { + var $alertImage = $(element.alertImageHTML); + $alertImage.addClass("agent-alerts-fired"); + + $content.append($alertImage); + } + + // Events by agent + if (element.showEventsBtn == 1) { + if (typeof element.eventAgent != 'undefined') { + + $content.append(''); + var $eventImage = $(''); + $eventImage.addClass("agent-alerts-fired"); + $eventImage + .click(function (e) { + e.preventDefault(); + + document.getElementById('hiddenAgentsEventsForm-'+element.eventAgent).submit(); + }) + .css('cursor', 'pointer'); + + $content.append($eventImage); + } + } + + $content.append(' '+element.alias); + break; + case 'services': + + if (typeof element.statusImageHTML != 'undefined' + && element.statusImageHTML.length > 0) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("agent-status"); + + $content.append($statusImage); + } + + + var $serviceDetailImage = $(''); + + if (typeof element.serviceDetail != 'undefined') { + + $serviceDetailImage + .click(function (e) { + e.preventDefault(); + + window.location.href = element.serviceDetail; + }) + .css('cursor', 'pointer'); + + $content.append($serviceDetailImage); + } + + $content.append(' '+element.name); + + + + + break; + case 'modules': + if (typeof element.statusImageHTML != 'undefined' + && element.statusImageHTML.length > 0) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("agent-status"); + + $content.append($statusImage); + } + + // Events by module + if (element.showEventsBtn == 1) { + if (typeof element.eventModule != 'undefined') { + + $content.append(''); + var $moduleImage = $(''); + $moduleImage + .click(function (e) { + e.preventDefault(); + + document.getElementById('hiddenModulesEventsForm-'+element.eventModule).submit(); + }) + .css('cursor', 'pointer'); + + $content.append($moduleImage); + } + } + + $content.append(' '+element.name); + break; + case 'module': + // Status image + if (typeof element.statusImageHTML != 'undefined' + && element.statusImageHTML.length > 0) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("module-status"); + + $content.append($statusImage); + } + // Server type + if (typeof element.serverTypeHTML != 'undefined' + && element.serverTypeHTML.length > 0 + && element.serverTypeHTML != '--') { + var $serverTypeImage = $(element.serverTypeHTML); + $serverTypeImage.addClass("module-server-type"); + + $content.append($serverTypeImage); + } + + if (typeof element.showGraphs != 'undefined' && element.showGraphs != 0) { + // Graph pop-up + if (typeof element.moduleGraph != 'undefined') { + + if(element.statusImageHTML.indexOf('data:image')!=-1){ + var $graphImage = $(' '); + } + else{ + + var $graphImage = $(' '); + } + + $graphImage + .addClass('module-graph') + .click(function (e) { + e.preventDefault(); + if(element.statusImageHTML.indexOf('data:image')!=-1){ + try { + winopeng_var( + decodeURI(element.snapshot[0]), + element.snapshot[1], + element.snapshot[2], + element.snapshot[3] + ); + } + catch (error) { + // console.log(error); + } + } + else{ + try { + winopeng(element.moduleGraph.url, element.moduleGraph.handle); + } + catch (error) { + // console.log(error); + } + } + }); + + $content.append($graphImage); + } + + // Data pop-up + if (typeof element.id != 'undefined' && !isNaN(element.id)) { + + var $dataImage = $(' '); + $dataImage + .addClass('module-data') + .click(function (e) { + e.preventDefault(); + + try { + var serverName = element.serverName.length > 0 ? element.serverName : ''; + if ($("#module_details_window").length > 0) + show_module_detail_dialog(element.id, '', serverName, 0, 86400, element.name.replace(/ /g , " ") ); + } + catch (error) { + // console.log(error); + } + }); + + $content.append($dataImage); + } + } + + // Alerts + if (typeof element.alertsImageHTML != 'undefined' + && element.alertsImageHTML.length > 0) { + + var $alertsImage = $(element.alertsImageHTML); + + $alertsImage + .addClass("module-alerts") + .click(function (e) { + _getTreeDetailData('alert', element.id, element.serverID, function (error, data) { + if (error) { + // console.error(error); + } + else { + controller.detailRecipient.render(element.name, data).open(); + } + }); + + // Avoid the execution of the module detail event + e.stopPropagation(); + }) + .css('cursor', 'pointer'); + + $content.append($alertsImage); + } + + $content.append(element.name); + break; + case 'os': + if (typeof element.icon != 'undefined' && element.icon.length > 0) { + $content.append(' '); + } + $content.append(element.name); + break; + case 'tag': + if (typeof element.icon != 'undefined' && element.icon.length > 0) { + $content.append(' '); + } + else { + $content.append(' '); + } + $content.append(element.name); + break; + case 'services': + // Status image + if (typeof element.statusImageHTML != 'undefined' + && element.statusImageHTML.length > 0) { + var $statusImage = $(element.statusImageHTML); + $statusImage.addClass("agent-status"); + + $content.append($statusImage); + } + $content.append(element.name); + break; + default: + $content.append(element.name); + break; + } + + // Load the status counters + console.log(element.counters); + var hasCounters = _processNodeCounters($content, element.counters, element.type); + //Don't show empty groups + if (element.type == 'agent') { + if (!hasCounters) { + return; + } + } + // If exist the detail container, show the data + if (typeof controller.detailRecipient !== 'undefined') { + if (element.type == 'agent' || element.type == 'module') { + $content.click(function (e) { + _getTreeDetailData(element.type, element.id, element.serverID, function (error, data) { + if (error) { + // console.error(error); + } + else { + controller.detailRecipient.render(element.name, data).open(); + } + }); + }) + .css('cursor', 'pointer'); + } + } + + $node + .addClass("tree-node") + .append($leafIcon) + .append($content); + + container.append($node); + + $node.addClass("leaf-empty"); + + if (typeof element.children != 'undefined' && element.children.length > 0) { + $node + .removeClass("leaf-empty") + .addClass("leaf-closed"); + + // Add children + var $children = _processGroup($node, element.children); + $node.data('children', $children); + + if (typeof element.searchChildren == 'undefined' || !element.searchChildren) { + $leafIcon.click(function (e) { + e.preventDefault(); + + if ($node.hasClass("leaf-open")) { + $node + .removeClass("leaf-open") + .addClass("leaf-closed") + .data('children') + .slideUp(); + } + else { + $node + .removeClass("leaf-closed") + .addClass("leaf-open") + .data('children') + .slideDown(); + } + }); + } + } + // Get hash and user. + var public_hash = $("#hidden-publi_dash_tree_view_hash" ).val(); + if (typeof(public_hash) === 'undefined') public_hash = 0; + var public_user = $("#hidden-publi_dash_tree_view_id_user" ).val(); + if (typeof(public_user) === 'undefined') public_user = 0; + + if (typeof element.searchChildren != 'undefined' && element.searchChildren) { + if(element.rootType == "group_edition" + && typeof element.children == 'undefined'){ + $node.addClass("leaf-empty"); + } + else{ + $node + .removeClass("leaf-empty") + .addClass("leaf-closed"); + $leafIcon.click(function (e) { + e.preventDefault(); + + if (!$node.hasClass("leaf-loading") && !$node.hasClass("children-loaded") && !$node.hasClass("leaf-empty")) { + $node + .removeClass("leaf-closed") + .removeClass("leaf-error") + .addClass("leaf-loading"); + + $.ajax({ + url: controller.ajaxURL, + type: 'POST', + dataType: 'json', + data: { + page: controller.ajaxPage, + getChildren: 1, + id: element.id, + type: element.type, + rootID: element.rootID, + serverID: element.serverID, + rootType: element.rootType, + filter: controller.filter, + hash: public_hash, + id_user: public_user + }, + complete: function(xhr, textStatus) { + $node.removeClass("leaf-loading"); + $node.addClass("children-loaded"); + }, + success: function(data, textStatus, xhr) { + if (data.success) { + var $group = $node.children("ul.tree-group"); + if ((typeof data.tree != 'undefined' && data.tree.length > 0) || $group.length > 0) { + $node.addClass("leaf-open"); + + if ($group.length <= 0) { + $group = $("
            "); + $group + .addClass("tree-group") + .hide(); + $node.append($group); + } + //console.log(data.tree); + + _.each(data.tree, function(element) { + element.jqObject = _processNode($group, element); + }); + + $group.slideDown(); + + $node.data('children', $group); + + // Add again the hover event to the 'force_callback' elements + forced_title_callback(); + } + else { + $node.addClass("leaf-empty"); + } + } + else { + $node.addClass("leaf-error"); + } + }, + error: function(xhr, textStatus, errorThrown) { + $node.addClass("leaf-error"); + } + }); + } + else if (! $node.hasClass("leaf-empty")) { + if ($node.hasClass("leaf-open")) { + $node + .removeClass("leaf-open") + .addClass("leaf-closed") + .data('children') + .slideUp(); + } + else { + $node + .removeClass("leaf-closed") + .addClass("leaf-open") + .data('children') + .slideDown(); + } + } + }); + } + } + + return $node; + } + + if (controller.recipient.length == 0) { + return; + } + else if (controller.tree.length == 0) { + controller.recipient.empty(); + controller.recipient.html("
            " + controller.emptyMessage + "
            "); + return; + } + + controller.recipient.empty(); + controller.recipient.html( + "
            " + + controller.foundMessage + ": " + controller.tree.length + + "
            " + + "
            " + ); + + var $children = _processGroup(this.recipient, this.tree, true); + $children.show(); + + controller.recipient.data('children', $children); + + // Add again the hover event to the 'force_callback' elements + forced_title_callback(); + }, + load: function () { + this.reload(); + }, + changeTree: function (tree) { + this.tree = tree; + this.reload(); + }, + init: function (data) { + if (typeof data.recipient !== 'undefined' && data.recipient.length > 0) { + this.recipient = data.recipient; + } + if (typeof data.detailRecipient !== 'undefined') { + this.detailRecipient = data.detailRecipient; + } + if (typeof data.tree !== 'undefined') { + this.tree = data.tree; + } + if (typeof data.emptyMessage !== 'undefined' && data.emptyMessage.length > 0) { + this.emptyMessage = data.emptyMessage; + } + if (typeof data.foundMessage !== 'undefined' && data.foundMessage.length > 0) { + this.foundMessage = data.foundMessage; + } + if (typeof data.errorMessage !== 'undefined' && data.errorMessage.length > 0) { + this.errorMessage = data.errorMessage; + } + if (typeof data.baseURL !== 'undefined' && data.baseURL.length > 0) { + this.baseURL = data.baseURL; + } + if (typeof data.ajaxURL !== 'undefined' && data.ajaxURL.length > 0) { + this.ajaxURL = data.ajaxURL; + } + if (typeof data.ajaxPage !== 'undefined' && data.ajaxPage.length > 0) { + this.ajaxPage = data.ajaxPage; + } + if (typeof data.filter !== 'undefined') { + this.filter = data.filter; + } + + this.load(); + }, + remove: function () { + if (typeof this.recipient != 'undefined' && this.recipient.length > 0) { + this.recipient.empty(); + } + + if (this.index > -1) { + TreeController.controllers.splice(this.index, 1); + } + } + } + controller.index = TreeController.controllers.push(controller) - 1; + + return controller; + } +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 70a9c4920e..180c187db0 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -21,8 +21,8 @@ Description: The default Pandora FMS theme layout */ /* Tree view styles */ -/*@import url(tree.css); -@import url(fixed-bottom-box.css);*/ +@import url(tree.css); +@import url(fixed-bottom-box.css); /* * --------------------------------------------------------------------- diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 18e1e77ffc..5dc7caea1b 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -314,6 +314,7 @@ if ($id_agent != 0) { $text_module = (string) get_parameter('module_search', ''); $id_agent_module = get_parameter('module_search_hidden', get_parameter('id_agent_module', 0)); +hd("------------------------------------>>>>>>> ".$id_agent_module." y id_agent: ".$id_agent, true); if ($id_agent_module != 0) { $text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); if ($text_module == false) { diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index fde9586325..3491f71458 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -278,226 +278,228 @@ enterprise_hook('close_meta_frame'); From 1feebae56497953b994017ab4684ce7ec610e8a7 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 22 Feb 2019 13:33:46 +0100 Subject: [PATCH 172/262] removed fullurl supervisor Former-commit-id: 74cc731977477c444150d49aff9ab062ddac065a --- .../include/class/ConsoleSupervisor.php | 118 +++++------------- 1 file changed, 33 insertions(+), 85 deletions(-) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 4873186d62..c0a91480cc 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -637,9 +637,7 @@ class ConsoleSupervisor 'Your license is going to expire in %d days. Please contact sales.', $days_to_expiry ), - 'url' => ui_get_full_url( - 'index.php?sec=gsetup&sec2=godmode/setup/license' - ), + 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license', ] ); } else if ($days_to_expiry < 0) { @@ -649,9 +647,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.LICENSE.EXPIRATION', 'title' => __('License is expired.'), 'message' => __('Your license has expired. Please contact sales.'), - 'url' => ui_get_full_url( - 'index.php?sec=gsetup&sec2=godmode/setup/license' - ), + 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/license', ] ); return false; @@ -728,9 +724,7 @@ class ConsoleSupervisor 'Directory %s is not writable. Please configure proper permissions.', $config['attachment_store'] ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); return; @@ -752,9 +746,7 @@ class ConsoleSupervisor 'There are more than %d files in attachment, you should consider cleaning up your attachment directory manually.', $config['num_files_attachment'] ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -786,9 +778,7 @@ class ConsoleSupervisor 'Remote configuration directory %s is not readable. Please configure it.', $config['remote_config'] ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); return; @@ -807,9 +797,7 @@ class ConsoleSupervisor 'Remote configuration directory %s is not writable. Please configure it.', $config['remote_config'].'/conf' ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -827,9 +815,7 @@ class ConsoleSupervisor 'Collections directory %s is not writable. Please configure it.', $config['remote_config'].'/collections' ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -847,9 +833,7 @@ class ConsoleSupervisor 'MD5 directory %s is not writable. Please configure it.', $config['remote_config'].'/md5' ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -880,9 +864,7 @@ class ConsoleSupervisor $MAX_FILES_DATA_IN, $config['remote_config'] ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -905,9 +887,7 @@ class ConsoleSupervisor $MAX_BADXML_FILES_DATA_IN, $config['remote_config'] ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -984,9 +964,7 @@ class ConsoleSupervisor $modules_queued, $queue['queued_modules'] ), - 'url' => ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60' - ), + 'url' => 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', ] ); } else { @@ -1088,9 +1066,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], 'title' => $msg, 'message' => $description, - 'url' => ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60' - ), + 'url' => 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', ] ); } @@ -1176,7 +1152,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.PHP.SAFE_MODE', 'title' => __('PHP safe mode is enabled. Some features may not properly work.'), 'message' => __('To disable, change it on your PHP configuration file (php.ini) and put safe_mode = Off (Dont forget restart apache process after changes)'), - 'url' => ui_get_full_url('index.php'), + 'url' => 'index.php', ] ); } else { @@ -1195,7 +1171,7 @@ class ConsoleSupervisor __('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)'), - 'url' => ui_get_full_url('index.php'), + 'url' => 'index.php', ] ); } else { @@ -1214,7 +1190,7 @@ class ConsoleSupervisor __('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)'), - 'url' => ui_get_full_url('index.php'), + 'url' => 'index.php', ] ); } else { @@ -1233,7 +1209,7 @@ class ConsoleSupervisor __('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)'), - 'url' => ui_get_full_url('index.php'), + 'url' => 'index.php', ] ); } else { @@ -1252,7 +1228,7 @@ class ConsoleSupervisor __('Recommended value is: %s'), sprintf(__('%s or greater'), '500M') ).'

            '.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), - 'url' => ui_get_full_url('index.php'), + 'url' => 'index.php', ] ); } else { @@ -1265,7 +1241,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.PHP.DISABLE_FUNCTIONS', 'title' => __('Problems with disable functions in PHP.INI'), 'message' => __('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)'), - 'url' => ui_get_full_url('index.php'), + 'url' => 'index.php', ] ); } else { @@ -1343,9 +1319,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.HISTORYDB', 'title' => __('Historical database not available'), 'message' => __('Historical database is enabled. But not available using given configuration. Please check it.'), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', ] ); } else { @@ -1392,9 +1366,7 @@ class ConsoleSupervisor '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.', io_safe_output(get_product_name()) ), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -1454,9 +1426,7 @@ class ConsoleSupervisor 'Historical database maintance problem.' ), 'message' => __('Your historical database is not being 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()), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=perf', ] ); } else { @@ -1495,9 +1465,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.HISTORYDB.MR', 'title' => __('Historical database MR missmatch'), 'message' => __('Your historical database is not using the same schema of main DB. This could produce anomalyes while storing historical data.'), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', ] ); } else { @@ -1539,9 +1507,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.EXT.ELASTICSEARCH', 'title' => __('Log collector cannot connect to ElasticSearch'), 'message' => __('ElasticSearch is not available using current configuration. Please check it.'), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=log' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=log', ] ); } else { @@ -1611,9 +1577,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', 'title' => __('Metaconsole DB is not available.'), 'message' => __('Cannot connect with Metaconsole DB using stored configuration. Please check it.'), - 'url' => ui_get_full_url( - 'index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise' - ), + 'url' => 'index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise', ] ); } @@ -1642,9 +1606,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.DOWNTIME', 'title' => __('Scheduled downtime running.'), 'message' => __('A scheduled downtime is running. Some monitorization data won\'t be available while downtime is taking place.'), - 'url' => ui_get_full_url( - 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list' - ), + 'url' => 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list', ] ); return; @@ -1805,9 +1767,7 @@ class ConsoleSupervisor date('M j, G:i:s ', $next_downtime_begin), date('M j, G:i:s ', $next_downtime_end) ), - 'url' => ui_get_full_url( - 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list' - ), + 'url' => 'index.php?sec=gagente&sec2=godmode/agentes/planned_downtime.list', ] ); return; @@ -1912,9 +1872,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD', 'title' => __('Default password for "Admin" user has not been changed.'), 'message' => __('Please change the default password because is a common vulnerability reported.'), - 'url' => ui_get_full_url( - 'index.php?sec=gusuarios&sec2=godmode/users/user_list' - ), + 'url' => 'index.php?sec=gusuarios&sec2=godmode/users/user_list', ] ); } else { @@ -1940,9 +1898,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.MISC.FONTPATH', 'title' => __('Default font doesnt exist'), 'message' => __('Your defined font doesnt exist or is not defined. Please check font parameters in your config'), - 'url' => ui_get_full_url( - 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=vis' - ), + 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=vis', ] ); } else { @@ -1969,7 +1925,7 @@ class ConsoleSupervisor '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() ), - 'url' => ui_get_full_url('index.php'), + 'url' => 'index.php', ] ); } else { @@ -1992,9 +1948,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.MISC.EVENTSTORMPROTECTION', 'title' => __('Event storm protection is activated.'), 'message' => __('You need to restart server after altering this configuration setting. No events will be generated during this mode.'), - 'url' => ui_get_full_url( - 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general' - ), + 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', ] ); } else { @@ -2021,9 +1975,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', 'title' => __('Error, first setup "Open update".'), 'message' => $message, - 'url' => ui_get_full_url( - 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general' - ), + 'url' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', ] ); } @@ -2043,9 +1995,7 @@ class ConsoleSupervisor get_product_name() ), 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), - 'url' => ui_get_full_url( - 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online' - ), + 'url' => 'index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online', ] ); } else { @@ -2132,9 +2082,7 @@ class ConsoleSupervisor 'type' => 'NOTIF.CRON.CONFIGURED', 'title' => __('DiscoveryConsoleTasks is not configured.'), 'message' => __($message_conf_cron), - 'url' => ui_get_full_url( - 'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron' - ), + 'url' => 'index.php?extension_in_menu=gservers&sec=extensions&sec2=enterprise/extensions/cron', ] ); } else { From f0c9d1631835b630f25465ec654493d10ed8e2b1 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 22 Feb 2019 13:45:59 +0100 Subject: [PATCH 173/262] fixed errors view discovery task list Former-commit-id: 7e3160cde5c0fa46ee3d918789ffec4091f42c31 --- .../wizards/DiscoveryTaskList.class.php | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index af6c371b67..c9ecaa8ec9 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -76,6 +76,7 @@ class DiscoveryTaskList extends Wizard */ public function run() { + global $config; // Load styles. parent::run(); @@ -94,7 +95,14 @@ class DiscoveryTaskList extends Wizard return $this->deleteTask(); } - return $this->showListConsoleTask().''.$this->showList(); + $ret = $this->showListConsoleTask(); + $ret2 = $this->showList(); + + if ($ret === false && $ret2 === false) { + include_once $config['homedir'].'/general/firts_task/recon_view.php'; + } + + return $ret; } @@ -255,7 +263,6 @@ class DiscoveryTaskList extends Wizard } else { $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); if ($recon_task === false) { - include_once $config['homedir'].'/general/firts_task/recon_view.php'; return false; } else { include_once $config['homedir'].'/include/functions_graph.php'; @@ -819,14 +826,18 @@ class DiscoveryTaskList extends Wizard if ($function_name == 'cron_task_do_backup' || $function_name == 'cron_task_execute_custom_script') { if ($manage_pandora) { - $data[7] = ''; + $data[7] = ''; $data[7] .= html_print_image( 'images/config.png', true, ['title' => __('Edit')] - ); - $data[7] .= ''; + ).''; } if ($manage_pandora) { @@ -841,14 +852,18 @@ class DiscoveryTaskList extends Wizard } } else { if ($write_perms || $manage_pandora) { - $data[7] = ''; + $data[7] = ''; $data[7] .= html_print_image( 'images/config.png', true, ['title' => __('Edit')] - ); - $data[7] .= ''; + ).''; } if ($manage_perms || $manage_pandora) { @@ -867,6 +882,8 @@ class DiscoveryTaskList extends Wizard } html_print_table($table); + } else { + return false; } return true; @@ -890,6 +907,9 @@ class DiscoveryTaskList extends Wizard case CLOUDWIZARD_AWS_DESCRIPTION: return 'wiz=cloud&mode=amazonws&page=1'; + case 'console_task': + return 'wiz=ctask'; + default: return 'wiz=hd&mode=netscan'; } From faae9c58b34fbababffd4f5c746156c6a3f9a5ba Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Fri, 22 Feb 2019 14:09:27 +0100 Subject: [PATCH 174/262] implement services tree view Former-commit-id: a081515f62ab210f96687577bfde60d5f6d23f23 --- pandora_console/include/class/Tree.class.php | 2 - .../include/class/TreeGroup.class.php | 906 ++++++++++-------- .../include/class/TreeGroupEdition.class.php | 184 ++-- .../include/class/TreeService.class.php | 8 - .../include/javascript/tree/TreeController.js | 2 - pandora_console/operation/events/events.php | 1 - 6 files changed, 582 insertions(+), 521 deletions(-) diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index da0380f4ea..4ad71f9ce1 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -879,8 +879,6 @@ class Tree { } $data = $this->getProcessedModules($data); $this->processModules($data); -hd("MODULES: ", true); -hd($data, true); $this->tree = $data; } diff --git a/pandora_console/include/class/TreeGroup.class.php b/pandora_console/include/class/TreeGroup.class.php index fd38794d1c..05ba271e24 100644 --- a/pandora_console/include/class/TreeGroup.class.php +++ b/pandora_console/include/class/TreeGroup.class.php @@ -1,467 +1,529 @@ L1fieldName = "id_group"; - $this->L1extraFields = array( - "tg.nombre AS `name`", - "tg.icon", - "tg.id_grupo AS gid" - ); - - $this->L2conditionInside = "AND ( - ta.id_grupo = " . $this->id . " - OR tasg.id_group = " . $this->id . " - )"; - } - - public function setPropagateCounters($value) { - $this->propagateCounters = (bool)$value; - } - - public function setDisplayAllGroups($value) { - $this->displayAllGroups = (bool)$value; - } - - protected function getData() { - if ($this->id == -1) { - - $this->getFirstLevel(); - - } elseif ($this->type == 'group') { - $this->getSecondLevel(); - } elseif ($this->type == 'agent') { - $this->getThirdLevel(); - } - } - - protected function getGroupSearchFilter() { - return ""; - } - - protected function getFirstLevel() { - $processed_items = $this->getProcessedGroups(); - - if (!empty($processed_items)) { - // Filter by group name. This should be done after rerieving the items cause we need the possible items descendants - if (!empty($this->filter['searchGroup'])) { - // Save the groups which intersect with the user groups - $groups = db_get_all_rows_filter('tgrupo', array('nombre' => '%' . $this->filter['searchGroup'] . '%')); - if ($groups == false) $groups = array(); - $userGroupsACL = $this->userGroupsACL; - $ids_hash = array_reduce($groups, function ($userGroups, $group) use ($userGroupsACL) { - $group_id = $group['id_grupo']; - if (isset($userGroupsACL[$group_id])) { - $userGroups[$group_id] = $userGroupsACL[$group_id]; - } - - return $userGroups; - }, array()); - - $result = self::extractGroupsWithIDs($processed_items, $ids_hash); - - $processed_items = ($result === false) ? array() : $result; - } - - // groupID filter. To access the view from tactical views f.e. - if (!empty($this->filter['groupID'])) { - $result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL); - - $processed_items = ($result === false) ? array() : array($result); - } - } - hd("G-GETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVELGETFIRSTLEVEL", true); -hd($processed_items, true); - $this->tree = $processed_items; - } - - protected function getProcessedGroups () { - $processed_groups = array(); - // Index and process the groups - $groups = $this->getGroupCounters(); - - // If user have not permissions in parent, set parent node to 0 (all) - // Avoid to do foreach for admins - if (!users_can_manage_group_all("AR")) { - foreach ($groups as $id => $group) { - if (!isset($this->userGroups[$groups[$id]['parent']])) { - $groups[$id]['parent'] = 0; - } - } - } - // Build the group hierarchy - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { - $parent = $groups[$id]['parent']; - // Parent exists - if (!isset($groups[$parent]['children'])) { - $groups[$parent]['children'] = array(); - } - // Store a reference to the group into the parent - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent - $groups[$id]['have_parent'] = true; - } - } - // Sort the children groups - foreach ($groups as $id => $group) { - if (isset($groups[$id]['children'])) { - usort($groups[$id]['children'], array("Tree", "cmpSortNames")); - } - } - //Filter groups and eliminates the reference to children groups out of her parent - $groups = array_filter($groups, function ($group) { - return !$group['have_parent']; - }); - // Propagate child counters to her parents - - if ($this->propagateCounters) { - TreeGroup::processCounters($groups); - // Filter groups and eliminates the reference to empty groups - $groups = $this->deleteEmptyGroups($groups); - } else { - $groups = $this->deleteEmptyGroupsNotPropagate($groups); - } - - usort($groups, array("Tree", "cmpSortNames")); - - return $groups; - } - - protected function getGroupCounters() { - $fields = $this->getFirstLevelFields(); - $inside_fields = $this->getFirstLevelFieldsInside(); - - $group_acl = ""; - $secondary_group_acl = ""; - if (!users_can_manage_group_all("AR")) { - $user_groups_str = implode(",", $this->userGroupsArray); - $group_acl = " AND ta.id_grupo IN ($user_groups_str)"; - $secondary_group_acl = " AND tasg.id_group IN ($user_groups_str)"; - } - $agent_search_filter = $this->getAgentSearchFilter(); - $agent_search_filter = preg_replace("/%/", "%%", $agent_search_filter); - $agent_status_filter = $this->getAgentStatusFilter(); - $module_status_filter = $this->getModuleStatusFilter(); - - $module_search_inner = ""; - $module_search_filter = ""; - if (!empty($this->filter['searchModule'])) { - $module_search_inner = " - INNER JOIN tagente_modulo tam - ON ta.id_agente = tam.id_agente - INNER JOIN tagente_estado tae - ON tae.id_agente_modulo = tam.id_agente_modulo"; - $module_search_filter = "AND tam.disabled = 0 - AND tam.nombre LIKE '%%" . $this->filter['searchModule'] . "%%' " . - $this->getModuleStatusFilterFromTestado() - ; - } - - $table = is_metaconsole() ? "tmetaconsole_agent" : "tagente"; - $table_sec = is_metaconsole() ? "tmetaconsole_agent_secondary_group" : "tagent_secondary_group"; - - $sql_model = "SELECT %s FROM - ( - SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g - FROM $table ta - $module_search_inner - WHERE ta.disabled = 0 - %s - $agent_search_filter - $agent_status_filter - $module_status_filter - $module_search_filter - $group_acl - GROUP BY id_grupo - UNION ALL - SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_group AS g - FROM $table ta INNER JOIN $table_sec tasg - ON ta.id_agente = tasg.id_agent - $module_search_inner - WHERE ta.disabled = 0 - %s - $agent_search_filter - $agent_status_filter - $module_status_filter - $module_search_filter - $secondary_group_acl - GROUP BY id_group - ) x GROUP BY g"; - $sql_array = array(); - foreach ($inside_fields as $inside_field) { - $sql_array[] = sprintf( - $sql_model, - $inside_field['header'], - $inside_field['condition'], - $inside_field['condition'] - ); - } - $sql = "SELECT $fields FROM (" . implode(" UNION ALL ", $sql_array) . ") x2 - RIGHT JOIN tgrupo tg - ON x2.g = tg.id_grupo - GROUP BY tg.id_grupo"; - $stats = db_get_all_rows_sql($sql); - - $group_stats = array(); - - hd("STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS STATS ", true); - hd($stats, true); - foreach ($stats as $group) { - $group_stats[$group['gid']]['total_count'] = (int)$group['total_count']; - $group_stats[$group['gid']]['total_critical_count'] = (int)$group['total_critical_count']; - $group_stats[$group['gid']]['total_unknown_count'] = (int)$group['total_unknown_count']; - $group_stats[$group['gid']]['total_warning_count'] = (int)$group['total_warning_count']; - $group_stats[$group['gid']]['total_not_init_count'] = (int)$group['total_not_init_count']; - $group_stats[$group['gid']]['total_normal_count'] = (int)$group['total_normal_count']; - $group_stats[$group['gid']]['total_fired_count'] = (int)$group['total_alerts_count']; - $group_stats[$group['gid']]['name'] = $group['name']; - $group_stats[$group['gid']]['parent'] = $group['parent']; - $group_stats[$group['gid']]['icon'] = $group['icon']; - $group_stats[$group['gid']]['id'] = $group['gid']; - $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); - - } + protected $displayAllGroups = false; + public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR') + { + global $config; - return $group_stats; - } + parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); - protected function getFirstLevelFields() { - $fields = parent::getFirstLevelFields(); - $parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent'; - return "$fields, $parent"; - } + $this->L1fieldName = 'id_group'; + $this->L1extraFields = [ + 'tg.nombre AS `name`', + 'tg.icon', + 'tg.id_grupo AS gid', + ]; - protected function getProcessedModules($modules_tree) { + $this->L2conditionInside = 'AND ( + ta.id_grupo = '.$this->id.' + OR tasg.id_group = '.$this->id.' + )'; + } - $groups = array(); - foreach ($modules_tree as $group) { - $groups[$group["id"]] = $group; - } - // Build the module hierarchy - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { - $parent = $groups[$id]['parent']; - // Parent exists - if (!isset($groups[$parent]['children'])) { - $groups[$parent]['children'] = array(); - } - // Store a reference to the group into the parent - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent - $groups[$id]['have_parent'] = true; - } - } + public function setPropagateCounters($value) + { + $this->propagateCounters = (bool) $value; + } - // Sort the children groups - foreach ($groups as $id => $group) { - if (isset($groups[$id]['children'])) { - usort($groups[$id]['children'], array("Tree", "cmpSortNames")); - } - } - //Filter groups and eliminates the reference to children groups out of her parent - $groups = array_filter($groups, function ($group) { - return !$group['have_parent']; - }); - return array_values($groups); - } + public function setDisplayAllGroups($value) + { + $this->displayAllGroups = (bool) $value; + } - // FIXME: Hierarchy lops is broken - protected function getProcessedModules_old($modules_tree) { - $tree_modules = array(); - $new_modules_root = array_filter($modules_tree, function ($module) { - return (isset($module['parent']) && ($module['parent'] == 0)); - }); + protected function getData() + { + if ($this->id == -1) { + $this->getFirstLevel(); + } else if ($this->type == 'group') { + $this->getSecondLevel(); + } else if ($this->type == 'agent') { + $this->getThirdLevel(); + } + } - $new_modules_child = array_filter($modules_tree, function ($module) { - return (isset($module['parent']) && ($module['parent'] != 0)); - }); - $i = 0; - while (!empty($new_modules_child)) { - foreach ($new_modules_child as $i => $child) { - TreeGroup::recursive_modules_tree_view($new_modules_root, $new_modules_child, $i, $child); - } - } + protected function getGroupSearchFilter() + { + return ''; + } - foreach ($new_modules_root as $m) { - $tree_modules[] = $m; - } - return $tree_modules; - } - // FIXME with getProcessedModules_old - static function recursive_modules_tree_view (&$new_modules, &$new_modules_child, $i, $child) { - foreach ($new_modules as $index => $module) { - if ($module['id'] == $child['parent']) { - $new_modules[$index]['children'][] = $child; - unset($new_modules_child[$i]); - break; - } - else if (isset($new_modules[$index]['children'])) { - TreeGroup::recursive_modules_tree_view ($new_modules[$index]['children'], $new_modules_child, $i, $child); - } - } - } + protected function getFirstLevel() + { + $processed_items = $this->getProcessedGroups(); - static function processCounters(&$groups) { - $all_counters = array(); - foreach ($groups as $id => $group) { - $child_counters = array(); - if (!empty($groups[$id]['children'])) { - $child_counters = TreeGroup::processCounters($groups[$id]['children']); - } - if (!empty($child_counters)) { - foreach($child_counters as $type => $value) { - $groups[$id]['counters'][$type] += $value; - } - } - foreach($groups[$id]['counters'] as $type => $value) { - $all_counters[$type] += $value; - } - } - return $all_counters; - } + if (!empty($processed_items)) { + // Filter by group name. This should be done after rerieving the items cause we need the possible items descendants + if (!empty($this->filter['searchGroup'])) { + // Save the groups which intersect with the user groups + $groups = db_get_all_rows_filter('tgrupo', ['nombre' => '%'.$this->filter['searchGroup'].'%']); + if ($groups == false) { + $groups = []; + } - /** - * @brief Recursive function to remove the empty groups - * - * @param groups All groups structure - * - * @return new_groups A new groups structure without empty groups - */ - protected function deleteEmptyGroups ($groups) { - if($this->displayAllGroups) return $groups; - $new_groups = array(); - foreach ($groups as $group) { - // If a group is empty, do not add to new_groups. - if (!isset($group['counters']['total']) || $group['counters']['total'] == 0) { - continue; - } - // Tray to remove the children groups - if (!empty($group['children'])) { - $children = $this->deleteEmptyGroups ($group['children']); - if (empty($children)) unset($group['children']); - else $group['children'] = $children; - } - $new_groups[] = $group; - } - return $new_groups; - } + $userGroupsACL = $this->userGroupsACL; + $ids_hash = array_reduce( + $groups, + function ($userGroups, $group) use ($userGroupsACL) { + $group_id = $group['id_grupo']; + if (isset($userGroupsACL[$group_id])) { + $userGroups[$group_id] = $userGroupsACL[$group_id]; + } - protected function deleteEmptyGroupsNotPropagate ($groups) { - if($this->displayAllGroups) return $groups; - $new_groups = array(); - foreach ($groups as $group) { - // Tray to remove the children groups - if (!empty($group['children'])) { - $children = $this->deleteEmptyGroupsNotPropagate ($group['children']); - if (empty($children)) { - unset($group['children']); - // If a group is empty, do not add to new_groups. - if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { - $new_groups[] = $group; - } - } else { - $group['children'] = $children; - $new_groups[] = $group; - } - } else { - // If a group is empty, do not add to new_groups. - if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { - $new_groups[] = $group; - } - } - } - return $new_groups; - } + return $userGroups; + }, + [] + ); - private static function extractGroupsWithIDs ($groups, $ids_hash) { - $result_groups = array(); - foreach ($groups as $group) { - if (isset($ids_hash[$group['id']])) { - $result_groups[] = $group; - } - else if (!empty($group['children'])) { - $result = self::extractGroupsWithIDs($group['children'], $ids_hash); + $result = self::extractGroupsWithIDs($processed_items, $ids_hash); - // Item found on children - if (!empty($result)) { - $result_groups = array_merge($result_groups, $result); - } - } - } + $processed_items = ($result === false) ? [] : $result; + } - return $result_groups; - } + // groupID filter. To access the view from tactical views f.e. + if (!empty($this->filter['groupID'])) { + $result = self::extractItemWithID($processed_items, $this->filter['groupID'], 'group', $this->strictACL); - private static function extractItemWithID ($items, $item_id, $item_type = "group", $strictACL = false) { - foreach ($items as $item) { - if ($item["type"] != $item_type) - continue; + $processed_items = ($result === false) ? [] : [$result]; + } + } - // Item found - if ($strictACL && is_metaconsole()) { - foreach ($item["id"] as $server_id => $id) { - if ($id == $item_id) - return $item; - } - } - else { - if ($item["id"] == $item_id) - return $item; - } + $this->tree = $processed_items; + } - if ($item["type"] == "group" && !empty($item["children"])) { - $result = self::extractItemWithID($item["children"], $item_id, $item_type, $strictACL); - // Item found on children - if ($result !== false) - return $result; - } - } + protected function getProcessedGroups() + { + $processed_groups = []; + // Index and process the groups + $groups = $this->getGroupCounters(); - // Item not found - return false; - } + // If user have not permissions in parent, set parent node to 0 (all) + // Avoid to do foreach for admins + if (!users_can_manage_group_all('AR')) { + foreach ($groups as $id => $group) { + if (!isset($this->userGroups[$groups[$id]['parent']])) { + $groups[$id]['parent'] = 0; + } + } + } + + // Build the group hierarchy + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + $parent = $groups[$id]['parent']; + // Parent exists + if (!isset($groups[$parent]['children'])) { + $groups[$parent]['children'] = []; + } + + // Store a reference to the group into the parent + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent + $groups[$id]['have_parent'] = true; + } + } + + // Sort the children groups + foreach ($groups as $id => $group) { + if (isset($groups[$id]['children'])) { + usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); + } + } + + // Filter groups and eliminates the reference to children groups out of her parent + $groups = array_filter( + $groups, + function ($group) { + return !$group['have_parent']; + } + ); + // Propagate child counters to her parents + if ($this->propagateCounters) { + self::processCounters($groups); + // Filter groups and eliminates the reference to empty groups + $groups = $this->deleteEmptyGroups($groups); + } else { + $groups = $this->deleteEmptyGroupsNotPropagate($groups); + } + + usort($groups, ['Tree', 'cmpSortNames']); + return $groups; + } + + + protected function getGroupCounters() + { + $fields = $this->getFirstLevelFields(); + $inside_fields = $this->getFirstLevelFieldsInside(); + + $group_acl = ''; + $secondary_group_acl = ''; + if (!users_can_manage_group_all('AR')) { + $user_groups_str = implode(',', $this->userGroupsArray); + $group_acl = " AND ta.id_grupo IN ($user_groups_str)"; + $secondary_group_acl = " AND tasg.id_group IN ($user_groups_str)"; + } + + $agent_search_filter = $this->getAgentSearchFilter(); + $agent_search_filter = preg_replace('/%/', '%%', $agent_search_filter); + $agent_status_filter = $this->getAgentStatusFilter(); + $module_status_filter = $this->getModuleStatusFilter(); + + $module_search_inner = ''; + $module_search_filter = ''; + if (!empty($this->filter['searchModule'])) { + $module_search_inner = ' + INNER JOIN tagente_modulo tam + ON ta.id_agente = tam.id_agente + INNER JOIN tagente_estado tae + ON tae.id_agente_modulo = tam.id_agente_modulo'; + $module_search_filter = "AND tam.disabled = 0 + AND tam.nombre LIKE '%%".$this->filter['searchModule']."%%' ".$this->getModuleStatusFilterFromTestado(); + } + + $table = is_metaconsole() ? 'tmetaconsole_agent' : 'tagente'; + $table_sec = is_metaconsole() ? 'tmetaconsole_agent_secondary_group' : 'tagent_secondary_group'; + + $sql_model = "SELECT %s FROM + ( + SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_grupo AS g + FROM $table ta + $module_search_inner + WHERE ta.disabled = 0 + %s + $agent_search_filter + $agent_status_filter + $module_status_filter + $module_search_filter + $group_acl + GROUP BY id_grupo + UNION ALL + SELECT COUNT(DISTINCT(ta.id_agente)) AS total, id_group AS g + FROM $table ta INNER JOIN $table_sec tasg + ON ta.id_agente = tasg.id_agent + $module_search_inner + WHERE ta.disabled = 0 + %s + $agent_search_filter + $agent_status_filter + $module_status_filter + $module_search_filter + $secondary_group_acl + GROUP BY id_group + ) x GROUP BY g"; + $sql_array = []; + foreach ($inside_fields as $inside_field) { + $sql_array[] = sprintf( + $sql_model, + $inside_field['header'], + $inside_field['condition'], + $inside_field['condition'] + ); + } + + $sql = "SELECT $fields FROM (".implode(' UNION ALL ', $sql_array).') x2 + RIGHT JOIN tgrupo tg + ON x2.g = tg.id_grupo + GROUP BY tg.id_grupo'; + $stats = db_get_all_rows_sql($sql); + + $group_stats = []; + foreach ($stats as $group) { + $group_stats[$group['gid']]['total_count'] = (int) $group['total_count']; + $group_stats[$group['gid']]['total_critical_count'] = (int) $group['total_critical_count']; + $group_stats[$group['gid']]['total_unknown_count'] = (int) $group['total_unknown_count']; + $group_stats[$group['gid']]['total_warning_count'] = (int) $group['total_warning_count']; + $group_stats[$group['gid']]['total_not_init_count'] = (int) $group['total_not_init_count']; + $group_stats[$group['gid']]['total_normal_count'] = (int) $group['total_normal_count']; + $group_stats[$group['gid']]['total_fired_count'] = (int) $group['total_alerts_count']; + $group_stats[$group['gid']]['name'] = $group['name']; + $group_stats[$group['gid']]['parent'] = $group['parent']; + $group_stats[$group['gid']]['icon'] = $group['icon']; + $group_stats[$group['gid']]['id'] = $group['gid']; + $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); + } + + return $group_stats; + } + + + protected function getFirstLevelFields() + { + $fields = parent::getFirstLevelFields(); + $parent = $this->getDisplayHierarchy() ? 'tg.parent' : '0 as parent'; + return "$fields, $parent"; + } + + + protected function getProcessedModules($modules_tree) + { + $groups = []; + foreach ($modules_tree as $group) { + $groups[$group['id']] = $group; + } + + // Build the module hierarchy + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + $parent = $groups[$id]['parent']; + // Parent exists + if (!isset($groups[$parent]['children'])) { + $groups[$parent]['children'] = []; + } + + // Store a reference to the group into the parent + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent + $groups[$id]['have_parent'] = true; + } + } + + // Sort the children groups + foreach ($groups as $id => $group) { + if (isset($groups[$id]['children'])) { + usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); + } + } + + // Filter groups and eliminates the reference to children groups out of her parent + $groups = array_filter( + $groups, + function ($group) { + return !$group['have_parent']; + } + ); + + return array_values($groups); + } + + + // FIXME: Hierarchy lops is broken + protected function getProcessedModules_old($modules_tree) + { + $tree_modules = []; + $new_modules_root = array_filter( + $modules_tree, + function ($module) { + return (isset($module['parent']) && ($module['parent'] == 0)); + } + ); + + $new_modules_child = array_filter( + $modules_tree, + function ($module) { + return (isset($module['parent']) && ($module['parent'] != 0)); + } + ); + + $i = 0; + while (!empty($new_modules_child)) { + foreach ($new_modules_child as $i => $child) { + self::recursive_modules_tree_view($new_modules_root, $new_modules_child, $i, $child); + } + } + + foreach ($new_modules_root as $m) { + $tree_modules[] = $m; + } + + return $tree_modules; + } + + + // FIXME with getProcessedModules_old + static function recursive_modules_tree_view(&$new_modules, &$new_modules_child, $i, $child) + { + foreach ($new_modules as $index => $module) { + if ($module['id'] == $child['parent']) { + $new_modules[$index]['children'][] = $child; + unset($new_modules_child[$i]); + break; + } else if (isset($new_modules[$index]['children'])) { + self::recursive_modules_tree_view($new_modules[$index]['children'], $new_modules_child, $i, $child); + } + } + } + + + static function processCounters(&$groups) + { + $all_counters = []; + foreach ($groups as $id => $group) { + $child_counters = []; + if (!empty($groups[$id]['children'])) { + $child_counters = self::processCounters($groups[$id]['children']); + } + + if (!empty($child_counters)) { + foreach ($child_counters as $type => $value) { + $groups[$id]['counters'][$type] += $value; + } + } + + foreach ($groups[$id]['counters'] as $type => $value) { + $all_counters[$type] += $value; + } + } + + return $all_counters; + } + + + /** + * @brief Recursive function to remove the empty groups + * + * @param groups All groups structure + * + * @return new_groups A new groups structure without empty groups + */ + protected function deleteEmptyGroups($groups) + { + if ($this->displayAllGroups) { + return $groups; + } + + $new_groups = []; + foreach ($groups as $group) { + // If a group is empty, do not add to new_groups. + if (!isset($group['counters']['total']) || $group['counters']['total'] == 0) { + continue; + } + + // Tray to remove the children groups + if (!empty($group['children'])) { + $children = $this->deleteEmptyGroups($group['children']); + if (empty($children)) { + unset($group['children']); + } else { + $group['children'] = $children; + } + } + + $new_groups[] = $group; + } + + return $new_groups; + } + + + protected function deleteEmptyGroupsNotPropagate($groups) + { + if ($this->displayAllGroups) { + return $groups; + } + + $new_groups = []; + foreach ($groups as $group) { + // Tray to remove the children groups + if (!empty($group['children'])) { + $children = $this->deleteEmptyGroupsNotPropagate($group['children']); + if (empty($children)) { + unset($group['children']); + // If a group is empty, do not add to new_groups. + if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { + $new_groups[] = $group; + } + } else { + $group['children'] = $children; + $new_groups[] = $group; + } + } else { + // If a group is empty, do not add to new_groups. + if (isset($group['counters']['total']) && $group['counters']['total'] != 0) { + $new_groups[] = $group; + } + } + } + + return $new_groups; + } + + + private static function extractGroupsWithIDs($groups, $ids_hash) + { + $result_groups = []; + foreach ($groups as $group) { + if (isset($ids_hash[$group['id']])) { + $result_groups[] = $group; + } else if (!empty($group['children'])) { + $result = self::extractGroupsWithIDs($group['children'], $ids_hash); + + // Item found on children + if (!empty($result)) { + $result_groups = array_merge($result_groups, $result); + } + } + } + + return $result_groups; + } + + + private static function extractItemWithID($items, $item_id, $item_type='group', $strictACL=false) + { + foreach ($items as $item) { + if ($item['type'] != $item_type) { + continue; + } + + // Item found + if ($strictACL && is_metaconsole()) { + foreach ($item['id'] as $server_id => $id) { + if ($id == $item_id) { + return $item; + } + } + } else { + if ($item['id'] == $item_id) { + return $item; + } + } + + if ($item['type'] == 'group' && !empty($item['children'])) { + $result = self::extractItemWithID($item['children'], $item_id, $item_type, $strictACL); + + // Item found on children + if ($result !== false) { + return $result; + } + } + } + + // Item not found + return false; + } + + + protected function getDisplayHierarchy() + { + return $this->filter['searchHirearchy'] || + (empty($this->filter['searchAgent']) && empty($this->filter['searchModule'])); + } - protected function getDisplayHierarchy() { - return $this->filter['searchHirearchy'] || - (empty($this->filter['searchAgent']) && empty($this->filter['searchModule'])); - } } - -?> - diff --git a/pandora_console/include/class/TreeGroupEdition.class.php b/pandora_console/include/class/TreeGroupEdition.class.php index dea62da238..55efebe976 100644 --- a/pandora_console/include/class/TreeGroupEdition.class.php +++ b/pandora_console/include/class/TreeGroupEdition.class.php @@ -1,108 +1,120 @@ id == -1) { - $this->getFirstLevel(); - } - } - - protected function getProcessedGroups () { - $processed_groups = array(); - // Index and process the groups - $groups = $this->getGroupCounters(); - - // If user have not permissions in parent, set parent node to 0 (all) - // Avoid to do foreach for admins - if (!users_can_manage_group_all("AR")) { - foreach ($groups as $id => $group) { - if (!isset($this->userGroups[$groups[$id]['parent']])) { - $groups[$id]['parent'] = 0; - } - } - } - // Build the group hierarchy - foreach ($groups as $id => $group) { - if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { - $parent = $groups[$id]['parent']; - // Parent exists - if (!isset($groups[$parent]['children'])) { - $groups[$parent]['children'] = array(); - } - // Store a reference to the group into the parent - $groups[$parent]['children'][] = &$groups[$id]; - // This group was introduced into a parent - $groups[$id]['have_parent'] = true; - } - } - - // Sort the children groups - foreach ($groups as $id => $group) { - if (isset($groups[$id]['children'])) { - usort($groups[$id]['children'], array("Tree", "cmpSortNames")); - } - } - //Filter groups and eliminates the reference to children groups out of her parent - $groups = array_filter($groups, function ($group) { - return !$group['have_parent']; - }); - - usort($groups, array("Tree", "cmpSortNames")); - return $groups; - } +class TreeGroupEdition extends TreeGroup +{ - protected function getGroupCounters() { - $messages = array( - 'confirm' => __('Confirm'), - 'cancel' => __('Cancel'), - 'messg' => __('Are you sure?') - ); - $sql = "SELECT id_grupo AS gid, + public function __construct($type, $rootType='', $id=-1, $rootID=-1, $serverID=false, $childrenMethod='on_demand', $access='AR') + { + global $config; + + parent::__construct($type, $rootType, $id, $rootID, $serverID, $childrenMethod, $access); + } + + + protected function getData() + { + if ($this->id == -1) { + $this->getFirstLevel(); + } + } + + + protected function getProcessedGroups() + { + $processed_groups = []; + // Index and process the groups + $groups = $this->getGroupCounters(); + + // If user have not permissions in parent, set parent node to 0 (all) + // Avoid to do foreach for admins + if (!users_can_manage_group_all('AR')) { + foreach ($groups as $id => $group) { + if (!isset($this->userGroups[$groups[$id]['parent']])) { + $groups[$id]['parent'] = 0; + } + } + } + + // Build the group hierarchy + foreach ($groups as $id => $group) { + if (isset($groups[$id]['parent']) && ($groups[$id]['parent'] != 0)) { + $parent = $groups[$id]['parent']; + // Parent exists + if (!isset($groups[$parent]['children'])) { + $groups[$parent]['children'] = []; + } + + // Store a reference to the group into the parent + $groups[$parent]['children'][] = &$groups[$id]; + // This group was introduced into a parent + $groups[$id]['have_parent'] = true; + } + } + + // Sort the children groups + foreach ($groups as $id => $group) { + if (isset($groups[$id]['children'])) { + usort($groups[$id]['children'], ['Tree', 'cmpSortNames']); + } + } + + // Filter groups and eliminates the reference to children groups out of her parent + $groups = array_filter( + $groups, + function ($group) { + return !$group['have_parent']; + } + ); + + usort($groups, ['Tree', 'cmpSortNames']); + return $groups; + } + + + protected function getGroupCounters() + { + $messages = [ + 'confirm' => __('Confirm'), + 'cancel' => __('Cancel'), + 'messg' => __('Are you sure?'), + ]; + $sql = 'SELECT id_grupo AS gid, nombre as name, parent, icon FROM tgrupo - "; + '; - $stats = db_get_all_rows_sql($sql); - $group_stats = array(); - foreach ($stats as $group) { - $group_stats[$group['gid']]['name'] = $group['name']; - $group_stats[$group['gid']]['parent'] = $group['parent']; - $group_stats[$group['gid']]['icon'] = $group['icon']; - $group_stats[$group['gid']]['id'] = $group['gid']; - $group_stats[$group['gid']]['type'] = 'group'; + $stats = db_get_all_rows_sql($sql); + $group_stats = []; + foreach ($stats as $group) { + $group_stats[$group['gid']]['name'] = $group['name']; + $group_stats[$group['gid']]['parent'] = $group['parent']; + $group_stats[$group['gid']]['icon'] = $group['icon']; + $group_stats[$group['gid']]['id'] = $group['gid']; + $group_stats[$group['gid']]['type'] = 'group'; + + $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); + $group_stats[$group['gid']]['delete']['messages'] = $messages; + $group_stats[$group['gid']]['edit'] = 1; + $group_stats[$group['gid']]['alerts'] = ''; + } + + return $group_stats; + } - $group_stats[$group['gid']] = $this->getProcessedItem($group_stats[$group['gid']]); - $group_stats[$group['gid']]['delete']['messages'] = $messages; - $group_stats[$group['gid']]['edit'] = 1; - $group_stats[$group['gid']]['alerts'] = ''; - } - return $group_stats; - } } - -?> - diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index 46f9139427..bbddc8dc2a 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -114,8 +114,6 @@ class TreeService extends Tree { protected function getProcessedServices () { $fields = $this->getFirstLevelFields(); - - //hd($this->userGroupsArray, true); if (users_can_manage_group_all("AR")){ $groups_acl = ""; @@ -166,9 +164,6 @@ class TreeService extends Tree { $services[$service['id']]['serviceDetail']='http://localhost/pandora_console/index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id']; } - hd("STATS:::::::::::::::::::::::::::::: ", true); -hd($services, true); - return $services; } @@ -227,9 +222,6 @@ hd($services, true); } } - hd("MODULESSSS::", true); -hd($data_modules, true); - $sql = $this->getSecondLevelServicesSql(); $data_services = db_process_sql($sql); diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index e22a17ced9..3fab4f6dab 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -750,7 +750,6 @@ var TreeController = { } // Load the status counters - console.log(element.counters); var hasCounters = _processNodeCounters($content, element.counters, element.type); //Don't show empty groups if (element.type == 'agent') { @@ -871,7 +870,6 @@ var TreeController = { .hide(); $node.append($group); } - //console.log(data.tree); _.each(data.tree, function(element) { element.jqObject = _processNode($group, element); diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 5dc7caea1b..18e1e77ffc 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -314,7 +314,6 @@ if ($id_agent != 0) { $text_module = (string) get_parameter('module_search', ''); $id_agent_module = get_parameter('module_search_hidden', get_parameter('id_agent_module', 0)); -hd("------------------------------------>>>>>>> ".$id_agent_module." y id_agent: ".$id_agent, true); if ($id_agent_module != 0) { $text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); if ($text_module == false) { From 2c1eb0fe03292e54ab7ffe48dd6cbd677858c8d4 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 22 Feb 2019 14:16:39 +0100 Subject: [PATCH 175/262] Added aws view menu Former-commit-id: a64079eb5e773d3fe36031bac856aa801728f79d --- pandora_console/operation/menu.php | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 7c7099580e..bf81ae5110 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -105,6 +105,7 @@ if (!empty($sub2)) { } enterprise_hook('cluster_menu'); +enterprise_hook('aws_menu'); if (!empty($sub)) { $menu_operation['estado']['text'] = __('Monitoring'); From 12b8042c5317d61f826e2f4695beff1b4106a95c Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 22 Feb 2019 14:26:58 +0100 Subject: [PATCH 176/262] Added server plugins in meta Former-commit-id: 7f69f55c3fad06c7b15408d755d088d5ac89b111 --- pandora_console/godmode/servers/plugin.php | 294 ++++++++++++++++++--- 1 file changed, 257 insertions(+), 37 deletions(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index ff370a5c48..fcb34363f0 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -112,6 +112,7 @@ $edit_file = get_parameter('edit_file', false); $update_file = get_parameter('update_file', false); $plugin_command = get_parameter('plugin_command', ''); $tab = get_parameter('tab', ''); +$deploy_plugin = get_parameter('deploy_plugin', 0); if ($view != '') { $form_id = $view; @@ -192,9 +193,8 @@ if ($filemanager) { // If is win compatible and the compatibility must be unix if ($is_win_compatible !== false && $compatibility == 'unix') { $contentFile = str_replace("\r\n", "\n", $contentFile); - } - // If is unix compatible and the compatibility must be win - else if ($is_win_compatible === false && $compatibility == 'windows') { + } else if ($is_win_compatible === false && $compatibility == 'windows') { + // If is unix compatible and the compatibility must be win $contentFile = str_replace("\n", "\r\n", $contentFile); } @@ -268,12 +268,16 @@ if ($filemanager) { // ===================================================================== $sec = 'gservers'; -if (($create != '') or ($view != '')) { +if (($create != '') || ($view != '')) { enterprise_hook('open_meta_frame'); if (defined('METACONSOLE')) { components_meta_print_header(); $sec = 'advanced'; + $management_allowed = is_management_allowed(); + if (!$management_allowed) { + ui_print_warning_message(__('To manage plugin you must activate centralized management')); + } } else { if ($create != '') { ui_print_page_header( @@ -292,6 +296,16 @@ if (($create != '') or ($view != '')) { true ); } + + $management_allowed = !is_central_policies_on_node(); + if (!$management_allowed) { + ui_print_warning_message( + __( + 'This console is not manager of this environment, + please manage this feature from centralized manager console (Metaconsole).' + ) + ); + } } @@ -564,9 +578,53 @@ if (($create != '') or ($view != '')) { if (defined('METACONSOLE')) { components_meta_print_header(); $sec = 'advanced'; + $management_allowed = is_management_allowed(); + if (!$management_allowed) { + ui_print_warning_message(__('To manage plugin you must activate centralized management')); + } + + if (!$config['metaconsole_deploy_plugin_server'] && $management_allowed) { + $deploy_plugin_server = true; + + echo ''; + ?> + + '; @@ -709,12 +767,15 @@ if (($create != '') or ($view != '')) { $result = db_process_sql_delete('tplugin', ['id' => $plugin_id]); - if (! $result) { - ui_print_error_message(__('Problem deleting plugin')); - } else { - ui_print_success_message(__('Plugin deleted successfully')); + if (!is_metaconsole()) { + if (!$result) { + ui_print_error_message(__('Problem deleting plugin')); + } else { + ui_print_success_message(__('Plugin deleted successfully')); + } } + if ($plugin_id != 0) { // Delete all the modules with this plugin $plugin_modules = db_get_all_rows_filter( @@ -737,6 +798,153 @@ if (($create != '') or ($view != '')) { policies_change_delete_pending_module($policies_id['id']); } } + + if (is_metaconsole()) { + enterprise_include_once('include/functions_plugins.php'); + $result = plugins_delete_plugin($plugin_id); + if (!$result) { + ui_print_error_message(__('Problem deleting plugin')); + } else { + ui_print_success_message(__('Plugin deleted successfully')); + } + } + } + } + + if ($deploy_plugin) { + if (is_metaconsole()) { + enterprise_include_once('include/functions_plugins.php'); + $result = plugins_deploy_plugin($deploy_plugin); + if (!$result) { + ui_print_error_message(__('Problem deploying plugin')); + } else { + ui_print_success_message(__('Plugin deployed successfully')); + } + } + } + + if ($deploy_plugin_server) { + $setup = db_get_all_rows_in_table('tmetaconsole_setup'); + // recorremos todos los nodos. + foreach ($setup as $key => $value) { + // Obtenemos los plugins de la meta. + $all_plugin_meta = db_get_all_rows_in_table('tplugin'); + // Conectamos con el nodo. + if (metaconsole_connect($value) == NOERR) { + $values = []; + // Obtenemos los plugin del nodo. + $node_plugin_server = db_get_all_rows_in_table('tplugin'); + foreach ($node_plugin_server as $key2 => $plugin) { + // Comprobamos si el id esta meta y nodo al mismo tiempo. + $key_exists = array_search($plugin['id'], array_column($all_plugin_meta, 'id')); + if ($key_exists !== false) { + // Si el plugin tiene el mismo id pero diferentes datos. + if ($all_plugin_meta[$key_exists] != $plugin) { + $old_id = $plugin['id']; + $new_id = ($plugin['id'] + (1000 * $value['id'])); + + // El plugin del nodo pasa a tener otro id y otro nombre. + $plugin['id'] = $new_id; + $plugin['name'] = $plugin['name'].'_'.$value['server_name']; + $result_update = db_process_sql_update( + 'tplugin', + [ + 'id' => $new_id, + 'name' => $plugin['name'], + ], + ['id' => $old_id] + ); + + if ($result_update) { + db_process_sql_update( + 'tagente_modulo', + ['id_plugin' => $new_id], + ['id_plugin' => $old_id] + ); + + db_process_sql_update( + 'tnetwork_component', + ['id_plugin' => $new_id], + ['id_plugin' => $old_id] + ); + + db_process_sql_update( + 'tpolicy_modules', + ['id_plugin' => $new_id], + ['id_plugin' => $old_id] + ); + } + + // New plugins to insert in the metaconsole. + $values[$plugin['id']] = $plugin; + } + } else { + // Exists in the node, but does not exist in the metaconsole. + $values[$plugin['id']] = $plugin; + } + } + + // Restore to metaconsole. + metaconsole_restore_db(); + + // Insert in metaconsole. + if (!empty($values)) { + foreach ($values as $key2 => $val) { + // Insert into metaconsole. + $result_insert = db_process_sql_insert('tplugin', $val); + } + } + } + } + + $all_plugin_meta = db_get_all_rows_in_table('tplugin'); + + foreach ($setup as $key => $value) { + if (metaconsole_connect($value) == NOERR) { + $all_plugin_node = db_get_all_rows_in_table('tplugin'); + + $array_diff = array_diff(array_column($all_plugin_meta, 'id'), array_column($all_plugin_node, 'id')); + foreach ($array_diff as $key2 => $pluginid) { + $other = []; + $plugin_meta = $all_plugin_meta[$key2]; + + unset($plugin_meta['id']); + $other['name'] = urlencode($plugin_meta['name']); + $other['description'] = urlencode($plugin_meta['description']); + $other['max_timeout'] = $plugin_meta['max_timeout']; + $other['max_retries'] = $plugin_meta['max_retries']; + $other['execute'] = urlencode($plugin_meta['execute']); + $other['net_dst_opt'] = $plugin_meta['net_dst_opt']; + $other['net_port_opt'] = $plugin_meta['net_port_opt']; + $other['user_opt'] = $plugin_meta['user_opt']; + $other['pass_opt'] = $plugin_meta['pass_opt']; + $other['plugin_type'] = $plugin_meta['plugin_type']; + $other['macros'] = urlencode($plugin_meta['macros']); + $other['parameters'] = urlencode($plugin_meta['parameters']); + $other = implode('%7C', $other); + + $auth_token = json_decode($value['auth_token']); + $url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7C&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password"; + $file_path = realpath($plugin_meta['execute']); + $post = ''; + if (file_exists($file_path)) { + $post = ['file' => curl_file_create($file_path)]; + } + + $curlObj = curl_init(); + curl_setopt($curlObj, CURLOPT_URL, $url); + curl_setopt($curlObj, CURLOPT_POST, 1); + curl_setopt($curlObj, CURLOPT_POSTFIELDS, $post); + curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, false); + + $api_result = curl_exec($curlObj); + curl_close($curlObj); + } + } + + // restore to metaconsole + metaconsole_restore_db(); } } @@ -753,7 +961,10 @@ if (($create != '') or ($view != '')) { echo '
          '; echo ''; echo ''; - echo "'; + if ($management_allowed) { + echo "'; + } + $color = 0; foreach ($rows as $row) { @@ -780,31 +991,38 @@ if (($create != '') or ($view != '')) { echo "'; - echo "'; } - echo "".html_print_image('images/config.png', true, ['title' => __('Edit')]).'  '; - echo "".html_print_image('images/cross.png', true, ['border' => '0']).''; - echo ''; echo ''; } @@ -813,12 +1031,15 @@ if (($create != '') or ($view != '')) { ui_print_info_message(['no_close' => true, 'message' => __('There are no plugins in the system') ]); } - echo "
          '.__('Name').''.__('Type').''.__('Command').'".''.__('Op.').''.'".''.__('Op.').''.'"; echo $row['execute']; echo '"; + if ($management_allowed) { + echo ""; - // Show it is locket - $modules_using_plugin = db_get_value_filter( - 'count(*)', - 'tagente_modulo', - [ - 'delete_pending' => 0, - 'id_plugin' => $row['id'], - ] - ); - $components_using_plugin = db_get_value_filter( - 'count(*)', - 'tnetwork_component', - ['id_plugin' => $row['id']] - ); - if (($components_using_plugin + $modules_using_plugin) > 0) { - echo ''; - html_print_image('images/lock.png'); - echo ''; + // Show it is locket + $modules_using_plugin = db_get_value_filter( + 'count(*)', + 'tagente_modulo', + [ + 'delete_pending' => 0, + 'id_plugin' => $row['id'], + ] + ); + $components_using_plugin = db_get_value_filter( + 'count(*)', + 'tnetwork_component', + ['id_plugin' => $row['id']] + ); + if (($components_using_plugin + $modules_using_plugin) > 0) { + echo ''; + html_print_image('images/lock.png'); + echo ''; + } + + echo "".html_print_image('images/config.png', true, ['title' => __('Edit')]).'  '; + echo "".html_print_image('images/cross.png', true, ['border' => '0']).''; + if (is_metaconsole()) { + echo "   ".html_print_image('images/deploy.png', true, ['title' => __('Deploy'), 'width' => '21 px']).'  '; + } + + echo '
          "; + if ($management_allowed) { + echo "
          "; - echo '
          '; - echo "
          "; - echo ""; - echo '
          '; + echo ''; + echo ""; + echo ""; + echo ''; + echo ' + +'; +echo ''; // menu_container @@ -64,6 +178,66 @@ if (isset($config['fixed_header'])) { @@ -348,7 +486,7 @@ $(document).ready( function() { opened = new Date().getTime() - openTime; if(opened > 3000 && handsIn == 0) { openTime = 4000; - $("ul#sub"+table_hover[0].id).hide(); + $("ul#sub"+table_noHover[0].id).hide(); //table_hover } }, 2500); }); @@ -371,7 +509,7 @@ $(document).ready( function() { opened = new Date().getTime() - openTime; if(opened > 5000 && handsIn == 0) { openTime = 6000; - $("ul#sub"+table_hover[0].id).hide(); + $("ul#sub"+table_noHover[0].id).hide(); //table_hover } }, 5500); }); @@ -389,7 +527,7 @@ $(document).ready( function() { }); } -- $('.has_submenu').mouseenter(function() { + $('.has_submenu').mouseenter(function() { table_hover2 = $(this); handsIn2 = 1; openTime2 = new Date().getTime(); @@ -410,7 +548,9 @@ $(document).ready( function() { }); $(document).ready(function() { - if (!classic_menu) { + + + // if (!classic_menu) { //Daniel maya 02/06/2016 Display menu with click --INI if(!click_display){ $('#container').click(function() { @@ -419,10 +559,11 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass( " no_hidden_menu"); - $('ul.submenu').css('left', '44px'); - $('div#title_menu').hide(); + /* $('#menu').css('width', '45px'); + $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); + $('ul.submenu').css('left', '44px');*/ + //$('div#title_menu').hide(); + console.log('m (collapsed)'); }); }else{ $('#main').click(function() { @@ -431,14 +572,15 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass( " no_hidden_menu"); - $('ul.submenu').css('left', '44px'); - $('div#title_menu').hide(); + /*$('#menu').css('width', '45px'); + $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); + $('ul.submenu').css('left', '44px');*/ + // $('div#title_menu').hide(); + console.log('n (collapsed)'); }); } //Daniel maya 02/06/2016 Display menu with click --END - } + /* } else { if(!click_display){ $('#container').click(function() { @@ -447,8 +589,13 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('#menu').css('width', '145px'); - $('ul.submenu').css('left', '144px'); + /*$('#menu').css('width', '145px');*/ + /* $('ul.submenu').css('left', '214px'); + $('#menu_full').css('width','215px'); + $('.button_collapse').css('width','215px'); + $('div#page').addClass('page_classic'); + $('#header_table').addClass('header_table_classic'); */ + /* console.log('o (es clasico)'); }); }else{ $('#main').click(function() { @@ -457,20 +604,26 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('#menu').css('width', '145px'); - $('ul.submenu').css('left', '144px'); + /*$('#menu').css('width', '145px');*/ + /* $('ul.submenu').css('left', '214px'); + $('#menu_full').css('width','215px'); + $('.button_collapse').css('width','215px'); + $('div#page').addClass('page_classic'); + $('#header_table').addClass('header_table_classic'); */ + /* console.log('p (es clasico)'); }); } - } + }*/ - if (classic_menu) { + // if (classic_menu) { $('div.menu>ul>li>ul>li>a').click(function() { openTime = 4000; if( typeof(table_hover) != 'undefined') $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('ul.submenu').css('left', '144px'); + /* $('ul.submenu').css('left', '214px');*/ + console.log('q (es clasico)'); }); $('div.menu>ul>li>ul>li>ul>li>a').click(function() { @@ -479,9 +632,10 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('ul.submenu').css('left', '144px'); + /*$('ul.submenu').css('left', '214px');*/ + console.log('r (es clasico)'); }); - } + /* } else { $('div.menu>ul>li>ul>li>a').click(function() { openTime = 4000; @@ -489,10 +643,11 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass( " no_hidden_menu"); - $('ul.submenu').css('left', '44px'); - $('div#title_menu').hide(); + /*$('#menu').css('width', '45px'); + $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); + $('ul.submenu').css('left', '44px');*/ + //$('div#title_menu').hide(); + /* console.log('s (no es clasico)'); }); $('div.menu>ul>li>ul>li>ul>li>a').click(function() { @@ -501,12 +656,13 @@ $(document).ready( function() { $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass( " no_hidden_menu"); - $('ul.submenu').css('left', '44px'); - $('div#title_menu').hide(); + /* $('#menu').css('width', '45px'); + $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); + $('ul.submenu').css('left', '44px');*/ + // $('div#title_menu').hide(); + /* console.log('t (no es clasico)'); }); - } + }*/ }); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 69ec49cfce..47d298cc84 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -54,6 +54,7 @@ if (check_acl($config['id_user'], 0, 'AW')) { } } +$menu_godmode['nuevo_texto']['text'] = __('nuevo_texto'); if (!empty($sub)) { $menu_godmode['gagente']['text'] = __('Resources'); $menu_godmode['gagente']['sec2'] = 'godmode/agentes/modificar_agente'; diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 36d1db123e..b2f5f91c5f 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -227,45 +227,65 @@ $table_styles->data[$row][1] = html_print_select( $table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'login_background_preview', false, '', 'class="sub camera logo_preview"', true); $row++; -$table_styles->data[$row][0] = __('Custom logo (header)').ui_print_help_icon('custom_logo', true); -if (enterprise_installed()) { - $ent_files = list_files('enterprise/images/custom_logo', 'png', 1, 0); - $open_files = list_files('images/custom_logo', 'png', 1, 0); - $table_styles->data[$row][1] = html_print_select( - array_merge($ent_files, $open_files), - 'custom_logo', - $config['custom_logo'], - '', - '', - '', - true, - false, - true, - '', - $open, - 'width:240px' - ); -} else { - $table_styles->data[$row][1] = html_print_select( - list_files('images/custom_logo', 'png', 1, 0), - 'custom_logo', - $config['custom_logo'], - '', - '', - '', - true, - false, - true, - '', - $open, - 'width:240px' - ); +/** + * Print a select for the custom logos. + * + * @param string $name This is the name for the select + * @param string $logo This is the option in $config (path) + * @return string Print the select + */ +function logo_custom_enterprise($name, $logo) +{ + if (enterprise_installed()) { + $ent_files = list_files('enterprise/images/custom_logo', 'png', 1, 0); + $open_files = list_files('images/custom_logo', 'png', 1, 0); + + $select = html_print_select( + array_merge($ent_files, $open_files), + $name, + $logo, + '', + '', + '', + true, + false, + true, + '', + $open, + 'width:240px' + ); + return $select; + } else { + $select = html_print_select( + list_files('images/custom_logo', 'png', 1, 0), + $name, + $logo, + '', + '', + '', + true, + false, + true, + '', + $open, + 'width:240px' + ); + return $select; + } } + +$table_styles->data[$row][0] = __('Custom logo (header)').ui_print_help_icon('custom_logo', true); +$table_styles->data[$row][1] = logo_custom_enterprise('custom_logo', $config['custom_logo']); $table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'custom_logo_preview', $open, '', 'class="sub camera logo_preview"', true, false, $open, 'visualmodal'); $row++; +$table_styles->data[$row][0] = __('Custom logo collapsed (header)').ui_print_help_icon('custom_logo_collapsed', true); +$table_styles->data[$row][1] = logo_custom_enterprise('custom_logo_collapsed', $config['custom_logo_collapsed']); +$table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'custom_logo_collapsed_preview', $open, '', 'class="sub camera logo_preview"', true, false, $open, 'visualmodal'); +$row++; + $table_styles->data[$row][0] = __('Custom logo (header white background)'); if (enterprise_installed()) { $ent_files = list_files('enterprise/images/custom_logo', 'png', 1, 0); @@ -1234,7 +1254,7 @@ html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"' echo ''; echo ''; -ui_require_css_file('color-picker','include/styles/js/'); +ui_require_css_file('color-picker', 'include/styles/js/'); ui_require_jquery_file('colorpicker'); @@ -1470,6 +1490,11 @@ $(".logo_preview").click (function(e) { icon_path = homeUrlEnt + "images/custom_logo/" + icon_name; options.grayed = true; break; + case 'button-custom_logo_collapsed_preview': + icon_name = $("select#custom_logo_collapsed option:selected").val(); + icon_path = homeUrlEnt + "images/custom_logo/" + icon_name; + options.grayed = true; + break; case 'button-custom_logo_white_bg_preview': icon_name = $("select#custom_logo_white_bg option:selected").val(); icon_path = homeUrlEnt + "images/custom_logo/" + icon_name; diff --git a/pandora_console/images/builder.menu_gray.png b/pandora_console/images/builder.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..9c3b0b6ff3ac42c9a5aa5e755ee2c0530a81ad85 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1GZ#-QbLn>}1r8qDNi|dv%1pQukhua~Bu+QK?nt(^5 zvPkosw;gKx1ytBX&0DJYpBS-;rGz@LDl|)Vd=%H%(6}zM46OS}ZIc^subVG!3medo5uX4;gFY=$x-oT)KdjWTVPD6^qMFxcf Z4DOZA>o0rNN&x-M;OXk;vd$@?2>`Y+ZzTW# literal 0 HcmV?d00001 diff --git a/pandora_console/images/builder.menu_white.png b/pandora_console/images/builder.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..f08ba661e9b3b11b696ea142b9cfc73256b1d62a GIT binary patch literal 294 zcmV+>0oneEP){?ic{p(Atz zMsWm2aD(auj({7$2yUQGP#?*?_)u;Eb%^J){(sE~?+#+Lujq)3F~^UN5KH28 zznbc@=LtyO%jQ{0prbiVp;6;a(d3jGlEY>ZS7XSDcE+%KT$H#{d8T07*qoM6N<$f-8D@U;qFB literal 0 HcmV?d00001 diff --git a/pandora_console/images/button_classic_menu.png b/pandora_console/images/button_classic_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..edbe81cd69727b27b095c669dc874fc01ed1784a GIT binary patch literal 745 zcmV50000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!i%CR5RCwCFSlw;HKnx}~LAn7%2Yi&ZRLal!YbNP=eD6U zqQky>(jCeW_ct_n`jQ-cOCt~v_t!P-V9V<^x4M9M!?US!1tz4Kl>i!gu#=dE8|)M- zk|go?Hf{_IJ5FLTZfGSpEIjQ7fF!rZ1c#(fFlh8{K=2s)opTHh&l2T57?J*tM%4P# z9f3%H2RgMsS>iq1>NiaQ5tD-LaUH6r6;rC zVD~HpJL?;j^^7Ax9Uw6d=X`!DTm$);?b_ap1`W@@GS{wr$PS#baHTls#{UGQKz}VK z7^Hl_0a*iz9Ma^-*^z6x=0+*+Pc-)~qya_w&croWf1?zJwvLmR-?j6S@93^Qbc_pG z*@hy;?&f%Vh!xXXTJbbuSzR{qK10`uk>}~2W6RhCzt2?Ulcm3lY$f50000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!nMp)JRCwCFn9*^43wwo+V3`ohE^;-|r9M z!+|`3+>>ytNIpRJhr?kXGIweOK!p>K5l9{|e+{w%Sprzy2?iig@f2j<(1k6*O* z6ac;b2?jvW6{VUSC*6X)lN;)W1r#99WJ%dhAY&MJGQ-fmSSyz-tmal=bF!{n(7*?j zHh`4Y)fk~1EzY$8rJg}MVUZ2UEW{dDtW=T<8K?(ySHEDW^HJ=P4RjnQksIjQ37`|` z=<$D<=rPjC zcr6cw*%AcjhaDXwFQrKKz$fVLb>(I?8fUqO14^hAcd zYgY~9_^v(llnXCSIVd%(?u~8_xuIGsTAoJGs>>MfGkl$RwVdwi$z(-EShx3?mi>h0 pec4S literal 0 HcmV?d00001 diff --git a/pandora_console/images/clippy_icon_gray.png b/pandora_console/images/clippy_icon_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..e7ac2b967adfbc7dc57b9aca3b8ce9c8614a9a56 GIT binary patch literal 462 zcmV;<0WtoGP)Q>nTT#h5vNP)G0U<|vv%YG2XHNd6M%A2NJr3uj%u?V;4h*JM9eYlPNFaMH`Z|j zGr|CRX5?!%x75MlD6M1kW6=^I86ScpKVJyQWe3-6-`IwP&-cJzIgFf>EU;WvP2;Ey z-%yeDsG^XL0I0AtnOliw3Vy}koXYf6MO?9uN_tSor{Ty~ZjX!_Tb~k8spCSzW9gm~ z9J5TPT=Hp-gm1UruJZ%y5lB4pg)`#CJ02A)$4MG*|L;wH)07*qoM6N<$ Ef>j;O2><{9 literal 0 HcmV?d00001 diff --git a/pandora_console/images/custom_logo/pandora_logo_green_collapsed.png b/pandora_console/images/custom_logo/pandora_logo_green_collapsed.png new file mode 100644 index 0000000000000000000000000000000000000000..73f77dec8f7a6839e9ee0c97f8c1eccc23595c29 GIT binary patch literal 2468 zcmaJ@dpy(YA9snADV0>CT9ZUn4{{31w2|=(klm=a0_s`}%&r&+~jv=u{@|H7t?11xkFuNJ$(+1Za@hAQOOj@EK8n55Qo@$J_x_ z2u?yCO@s&7(QWBM zGQi=wCx`&w1W!L!LNv>P4R>~eIZ6pC0zM#Nz@&VhKunMl;a_YQvCHh7gHD*s4>ScBIq)zbl{r!&@xz z0shhZQ)01SybwV80Ag^9h@~oAq?tODkU$mz3<)Um13}*OE_!o72`J`(LKxW>2U|^N zu($%X!SXADPA7N>#1e*p1$a=1a1{rF%ViUAcsC5*-hqTB+mlczHwSw>hD4%ZU8!Ug zii#!Urm+-|wS^A|B-2>-KUmlQ#HyQtFH}XQ03vQIz@~~oKJ07K1ny6?Q1NIC#tlzZ z@!@~2F_hTRSZ+s&VkrM8qf_qqOAgu&OL%}AaD2}2ww%Z%D|!V zA>#Pj=MJf+HqY1>o7={o%a`On`xxTL!;e~Tx#-}__KAW65< zsS{)7&?h#@I55xm=tUm+*Vv$=1W9^MvE5yZigp?y(d+gir;qna+t1gB9XwuLx2t2= zy}u#4d6_jKDxz;ms$sLy0&;tAX!UC>d64-_Je6mSq z7M0^Gl*=gvVLkgjKJOJQ+5_}99eCc8!)4)K1^e?z34O08FJQZuXipxJ*5q_6Noh?} zIZd?NJLg{2-#mfT9?HqxA6c{J(*qdk;K%64x5GvjoLF=)K;E)yD{vECpok3#-x!g- zzBF*oYSU2r`I4Ol-t;Sw=dL7WSJRFI0pnrt1=zM*8OfOei`%eUM-v+EzYapx>OX06{U-XwbMnKRHy?7wFFk%2f2LyH;m2<`$ouaWk1kvyy=lGs zbL^M77numx)zuHC$lNANBNX;T_V4HBSapd0^gZ@8Jj|*Dx-isb!^%&!nOD48G8Xzp z&Y?Lrb}_u#&9-adb*?bm0&B08W|t+_Lt)M9?6U_%73-gFY{nXJsX$E{I_Fla{tJ){7D#B+^UZUm6i2H^_ zi^O#|7={({L@7V3q()Zmmasj=kb`*q%lKPa>ty4}>nIkiT$8zp2_LM+jObMjZ)X%3 zJ&3;ZGF#)Q2cA5vG|yZwuWi^f-bZgDU7ZIpfZ?=0>ob5Eaf8Xq+eWn69T5B7!KdrH zSTb~22^r$!xEeG}Tcw+-TOv1kPkY`anOpei*%M4BrnxPsnpdaQ3#VN(g=u2XTG-I? zMsV)odeoh_&_XDEyX0NgZVv!H-{runwZ?wt51_qOzg6B3k3~@j!B>I#9~+yeg2I#o z5`1s#F=F64}*7hNpF zF#_H=5dvzLFVC$AM@@{-g5D&vJI_)n>hm0aG;r}GLSqXyTi^zsf@4+fu3(eW<=IHz?!P(^?_q|Oh&$)wZrL3 z`95r+WrHh{X+Lmc&R#Pd1Y4AG>ZqxEuDi9|^Y+fHsl|Q@+p2o(xuZ@I`J}8PipmvS z@wOoOP9BHf%p6r%C<|W7LP{+Hg33yVlw-WlPQ6y0jfWF7hn}`RusL;*@+CBD`EIA$ z37_-t$GAt7uKmZ>7&f&MlitAbs ZjR*UV)OCG&_^bNf=F_{u$Z`n1Xz$=L>Mdr62{*WLSQk7xCBH*lKroX6K~BG zVFNKxR{hHs{te1$hrzf&Kp;;~PoSqL5bbIU0zY{0;EF>;L6r5fDO^b5-Ynkv12J(WrfWScEt111hsIC3K zt2#UXTiXp|fc%fY|0A)Rk+%yHWPo%-ySu{ifwQ@HWy%GjH%66}21Ft|PHYJmSwgtj(B1LcN+q2NdjWhf_}188rLfT&7}h>EI6DvKyd zNrJ&D52PeT6%>@k6jhbLU{x_CiNCSRXt=vG5{3C2i}(*#8jQx2%kGwf8_G zR9(@|?0-%gV*k&+DE=egUs%LH`=a!ZSP(Pkt;mJL?G7;byx$83%l&zQIDU5jbZ>8eD4kTTYfwSbfM^_U9C>H0T$QK=w=D{m7Q%|K0@ z`AS!L>^4Ko$1c5etCo5#Prp8y9@R{kg9&3n159Od1lG)tns%?PKUv&mU~U|!R8!FLE;8cMuh4KB8yZGX%~uB zeYkB6N~0v@BAN|VW97TRt)@n56NKCmv`9b8cOy;jho?-+%FcS_;PiqW+lp@9J*5*l z7*5Q#QJIQNiBupbqQGxv|ib(TEQ z<5g#h^p3`00T2M8zU88p@vf@zT=NYgph0hzu3&2X@FISQn{$J%M7Cg`a39NFr6IC^#o)c9H!tAcu?R(ccT@r0?&d z99pd8s&D0~Mwj7E2u}u(grcX*Zs^I&YjMmSU8zw z7VVO{>~2qf5k+TXF|f0aXj*J588-+nfBXQTaJ13%<^0!_(h`K%=hsxK`?Z<)I!g4g zmDH04R?P(;XO3l8B;YTntfxJhp$<7rJ`wf zye+x6fON$$$5^ETcd~fLc595ObT!`(eMq5J8ax}&#PVv@;G_X)cZ?2ylfa%SP##kO zc+0I|IqF&z2DFSnNz98-a}e3;^@gvcZ9xW@qN`mzMxidM9&#s*^S@|~TOt%_D(OA! z0{Z+LXL^y&pLD+dWMlyc1MiPyHE=9Y1ZY^Ps6Seo{yp{5{igR=g}xe3(r4?Mi3xp2 z7uL5i*|!@YEf+!-i>wdZ$b=$#+_Ra9gy>PmCl&4Ih0?W0WTHjWG3Lq{&vJh#nQ3uT z1~Rq!bhy8jSn2)-;C1x02E2xdoWqx?iDMU*mEKosW%YS#499}=r?hxq%YggnPNM_9 zeX~SZ;)WT2{hZogfgM&d+NcE_xGWiVpVk`jBUQofr)|pA; zAhn*X`zTpHFE-I@k~gY7*LyOGHfBNrIpupU#Yk(BcJyLOHbXUqkq3K8sNEn#JM~}+ zvT-rD8K<8vSU&S0G%Rsd?+shhYO>!tw}MF`PWQvFh9I;m1Tn%EyiuEFlRu;w%_ z@7hU%KT~nZus&FQKj9pg|2l*KK&nl?&UF(MtPoZiVtxu zPR)sZk+emB&ga>^7tj-D)4{!x6!r6-n!SkgIW+lT7UV>uN9FvHe}3m+qN2lpZY=mc zkt7fj;~iF=Hwra4vG7F;T>|BhCQkBS^5Lalnopkn<}-e#O9rT29wuWxYC6Vqs#sGB zuWt8l*0sIXHm5M$plHc${EDPxgn#F@D3^u_fnIuajm(X{eZ?wirXah+yhZE^fI@2L z1?<$)i4qj5Tr2kjEanWpd)K8@zYnx`%G^Bo>ioygH@<9Xmv`SvYY~2y@8mY>yzi~~ z@VjgS(DIM>onJ|tJz;J?#s+Q{cS_rQ2uy;4OLntp&!L}JI*={x>B|d+xs;mN--A>2 zH;paUda|eDo;~NCSK+;Efzay}ZYFxR6+LJh^InZTo{*igFW4 z5!WhDW^o=b(Mjim?l#W?%AEeIXZ8qXjr?$zLp7n1ekW(JNnB)|V5l*~?9fl4qd9HF zb@BR2SV=-FQ6F7lc%M$o8qV{JoWq@##x_NTrri0c^h*xDYKN0YYIONxmPySA4rsud za6TkEY#RjpGWgLHTXh;Rkh5v9p+8Df^hzn?Mb22++GUjukx$S!7n%Sj&moPVa?*s; zoeo=b%{eaj;M#|Rj;U76OvW`t&8Y@@Kx0)mgH!~QlI2W){gSfwG%X1NwF<1cf1+t7 zyL3zMWkz$qc{#^$yS_uRTk{xi$rFwz)HDzDZbu&uM1A;fzFG0oF}c8L!mtvyD`@0v zsp%!L9xYeqXR1f=E}DI}79_`A^`kh$6MG)W{W;YuN5MW#6qoOr{O+?X--L+RFi~~C zE}^#K4C{wu^3m(v)B&bc$I{oFy8G;BbCp7qw^_w3Zl~S7Nbe)I(io2gkWt1D5_QeJ zqLo@{;{3(`t*HFsmQDdugLUP3=3Mqz1!-pLh)ioPe#6hXJ^G#Mu}A+>?2EYQ2Sb;& z!WS^F*pQU0YyR^;+`9$NI6Ok5*fm&&LO`5?Tp|g*0ta{>YUb?dF{{H%+CUHT4x+u8 z=~?3Mt=zcshPwq?LISLUJ99~vtRHHwpXu9TEu(Xv3roqml)Dd&Z-P#O=4ObNe=4lb zo&AQukx%-w(HbXUoH9g!KCizSw+LRyrxLc&>8-7r&3t^$%wSXZ)Y*ilAepPx2LmXa z6#fy2N!9NgZv*Bd_-k0|p1i|^B?9x~0}SGfJh=Zkq@>BsTmuCKkthq!90X&z-k zJHN-3u}l2%oD>Y&QKT{qCZDP8u4fQgeqSlxl68JLu zONZhK9n#(V(3COGIpelktSk_lTV5LYLB^oby<_U*Q%cpXxdJdVGQQ6Qay#@cYrU4)G5tj+N;FR z>MqdZNyWK>bx3oMQD(L8hA|yvXim&=c|tEggr!NpI`WVW9AUU4AKK8+o;ABxT|RUH zgH}ATUMAu(%dtK2J`LJWmsKEG)boXn_)6e9}JgUR2^(&*OBSG)cgQPSF173)ri zLlkZht_#%h0N#+Wyc3{L#VV8S1Hb=Vj7Z6X&K`SGr)>DKdHWx3yvtl_nF?^l4ut~B z*?=++F{K+`2c^c9Vfe~;9C025lJvy-wNBHZ=8DBpK6C^wMqC& zo5|wKB>3{XnCAP49*(_^^Wn&Q^!Yl2AS{w^!Yq*aUJ1)B5?M>m_(AK!Ar2`dZ~Cj~ zj|;)0I{{I83kJ8|FSi8{Q`G(TjqvR~Q|;DTS_&mF`9<2m99>yZMCYuBJAcR38X(O? zk_N&Ekh}R>37LN6t2l`4Ud=V&Z6Xx@p4`tEsrJ|k>Mx?smLC(6P+IhpI5}(IipCYZ97?QRc83# zC~B1(H|+ZDPi%G$as$6TAfRMnJ-aKsc9Tf;j{$M=y2g!hd7ra}xMxn{UQ&KivxUK( z9w|(WWgsry|8;bS9qTv^6MSgij3Na!?8P+l&W8j?^x{ zWZZP!KWRKJxt0)<2#p~7%-lxuEdw(kg78bbKeB9uv6h#IyQA6O zCKQj}%9u9MLL!~U<$0$i&Qo@R_GF8X0f|zK$y7D$Q|QJPkty>{A}o>iAcC)W@D+QE zh(SUFWDhx0ClZ-;7Ua{5-1^6|%o3Beb1kb^QfOHD%R<#)P( z9zCB`vM`lWJ)Afq`sVfQ=(x@h(@mow1_pH|OB^D8i90fpC>&7EG8fompzd$sEd?ok zbR(l5U+}BZqd%Be^8{3tR<50UgO3zs^H_Tg>sczMWc#tV&c%c<{GU^-F26Q(dy+99 zPWWH<@`g`^PsAS${=C;eu{)3*-^>wMR8ov2>_-#<6 zfkV30E!=kPVPgHh1zl!iW!LU#kzL~C%wy4~RIvFn{tWeWk|4{(<#1hrCm1@6;am0d z-#-pP4O8X>lQtO@wOy=CAbN5CKq^uN5~rZOJ)`7qb${UxR-_Hn>jat$g-7~~}Y zG!rEY0nV{qvuXDZv?uGUzu!g5eD#?sEnLJHpE3ZUb@lYvPOkUOZ7xDLsPldvYmrOP z-lJXvk0i-#yqU;fT%ZA^K_Kj8c; zu3jEK(xJ**8sB<#r+TJi2SqN3%=7?WSU52`6|FwQK4G!6W*Oe8Hs#EdusL~u*7f@x zWncY7OSZs1rRTW$?XtQ1%&$>Y=|Pz;^zOkIED4{x$0{BDd5x)5WQ|_|^m$n;&V(N6 z;0sm#Yu1Oub#Ox|$MS&FwULs?*Nybc{fGv{&9ap%EI@KlCw?d=_qr_K)lN-fD$>yy zD^?q*jLYGH#i@I5GM@|ntsP)=`d~(vVV@i5d!7+Dst04e$I0n+3aAIjByz+9Q2-h5YwnY+I)VXK1BML&D*)U8^opNVT^E7$M&!Rg0PkPD; zyY4XEyoACo7|w^|d|M`NUi>g_c{K7Y>RboVA=#}Mtm?mmKSCi}Cc3t@tKt|{DoL?F zkI0w`<~(76$XEaI3S+ME2(y&AR7uNb&wO* zl-R4BR`zJURO<(?4(34xH@Gu$Qa%g_UqO?goeOUo?ewVXK9|Q8HENUFsSu@tUtE3+ z!nw7_!Cv)#5<<;)&94Yu4lgIZ4zIiNQxLQ{GE`Pt>S}1r5s>Z(~G*tzl5uy!m%zUMagb!PX&)BL(u1m zEnExP>J&~XEMR1F$g&mCP6*^TQW40w!MKNwk(V*kj{gW#MGd3T8K4kzildr|>sJ<@ z#D-JfAD0MTFjZiEFWJG~bmC#_8zpA8OAX9=>nCPSVAN}7k1Fl#zO+LW7!7)XuX<}+bf{fEk7A`pl!(E9L#sBMd4)r?RmiFk~${caT qY=ZFLMh_`@hr^GU^o}wx0=>T5QY4{z(Ji3A7(8A5T-G@yGywoUW@2vu literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_alerts.menu_white.png b/pandora_console/images/gm_alerts.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..6eae2f3b317a6b50b0039edba14cc58d310fb5ee GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1Gt36#DLn>}1B^+S>_y7O>|ME=Fj3;n6%o6^$xQR(YOyMX4 zv%Up1jGptUwqUJa074yMqmX0BY%^o0a`Bk103AnuiRBdR@|SjGcH@GgR0Yh z_l*K0cAlkBLr18FaT#i)+ysinsD=`zGLU_|L?|qvqe-Bs6+i2nL+I9opdg75B~I}= z)TrY&oZeh zNoNGaB!k{GljjtR_j3bjk3dQyO_R(bYupB?xgY2u>q*v55_!n%F4u-kg$&!sv5DM< z#34ownTZX@W|+S?^mLDy3FV6SKNT&Ek!=nOEH<*ta?)L7rv3s90ONja(4?%5Z~y=R M07*qoM6N<$f(pQvzyJUM literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_configuration.menu_white.png b/pandora_console/images/gm_configuration.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..a82ece6578589b10638973881e1512b0fb469cb8 GIT binary patch literal 276 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1G+dN$yLn>}1B{(qs|Nmc~;n80Q8~F}di4&|2XW1P7{Ih2| zvwT@1R>Gap9Hn`_dQt|_>=9piR5CD>u_(CV;mLi;BDpv5H$x|RusIkqN@&Af~p1`OG2 WK80pQlq~@IfWgz%&t;ucLK6V@q+vh+ literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_events.menu_gray.png b/pandora_console/images/gm_events.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..aee937f912409d601bd62a3f7fc618d9dbe38221 GIT binary patch literal 321 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1Gk3C%+Ln>}1r8qDPi|d9n1buG2!O+2aVTttT$4b%?8yLiN zk`$O_BsMg&S{#v_v7zJUVAo4>3h~oWzqIzU&@`v$!1? z^EgUlZ3N<39&tM~^FQ#u8F98PZF<#;#03f;+{mdKI;Vst0H#ZB)&Kwi literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_events.menu_white.png b/pandora_console/images/gm_events.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..43e8c157c86bf713a8734cb810fb1904109e3263 GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1GyFFbTLn>}1B{(qu|NlRn;n81*KmY92G7=QT7)06s9Oo4& zc$s`iDXri6Et8wuG4>@pGVE8bJD4h9W-vd*S!RR8r+E_B7qm}g6f+g}Kg}z9T7uB>@~fv-vX~{%E*ju**N^lH!v^PFWHq3@?`QUNKlPaY_uM bKmx}1B`gq1a1o!eBV#A?gjxJYxLCf#F(e)Tv*QH6 z1REo-CPUEQfOm{GZ5#|688;>NWa!=GKcXNl)Hq4{gC+Y4xhJn!W+eJ#_~o|T+Rzv< zgW;+Q(@NHW>1WefX035>sW@OFf8f!k{|gcl8rjw`8?rH)S|%Cuu*_H?`gbv#Alrh7 z*&IjMJ45OlU+i(?Vo+;m$@s*$Tsful>je{5FMaV26P7cnj+5&d&QAE<$ff?suwA}` zdqGaYzLX=AB|8}voW&mSC@)B43z+_pnZKdUrlF95iHG6Fc8^=U-fsVao@DTJ^>bP0 Hl+XkKZU$`{ literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_resources.menu_white.png b/pandora_console/images/gm_resources.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..130b63ce3d7dd0680693de4a3da73f447d83982a GIT binary patch literal 285 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1G`#oJ8Ln>}1B`gsA@&EsRW`XV-Ncy2BjD~`Pru(gqR%eFdSi1VPQVA;cJhB6Qjm5 zhaR^D;(Q5)Z|p538ovDde}tJmhpq8U!lJO8ekm7;4GbS$6zn{f{NmnnYC7kJ7w*#| z_|Gb_sYoy}G3sP|;$I*sG{r;xkzu=h2ls+EE(u-t8}$DRFbi!EQ}$?+bck)^w_(`z fgt3QNAc3L(7<=Tk=JbA`R~S59{an^LB{Ts55`}Zw8Eu6P(x87 zYe<}!X-!A0y+BLEoY>kv6A;WR35hvfUi%YZ0RL+Q#!w*dhX4Qo07*qo IM6N<$g1GK_kpKVy literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_setup.menu_gray.png b/pandora_console/images/gm_setup.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..339fb5684f4c80a6ab414f091469192113dddf61 GIT binary patch literal 426 zcmV;b0agBqP)7eEQn0ja=H zLCiCs5LaNkg4B=-?8zt3*cF5hOe%nMKnYoSRvG0ugRPkz#QC(WPJ51AAl}|TUht@a z9LP4$PXpKGJ;(dOuZdkamOud{z?LME?*+&^AhiXHD?~pg-=Jto(wu8TGK`2QIfdjS z^V;l5sLsYw+tr9j)OlY?+;qsk5@hWk5f66n?hher+3qgp1P&7gE#XIE2J(2B8pzht zcVP1xzdZ;fpOP1QU-+lQ`h|Jp?df?|)q?)mn$g}9JxCf=bOv4nigFG@-M$LgAf=GY z)IRZCO?*|`DXyskDly~<_~v3wKiMc|+LQf7`3f>1Y`pe-;I9{(0u$#fX(2 zvYe4z7hjRc>^w6Ll&>u}C@gRJ8|hU#%~;NvaYTe7@kPeMomp=uqb_pEe(mpceac#_8$03w=;g<`pw6MoNUrWYl6qc7I# zbH!ryrD8)*p;Z*hm0hGg97<%$lUOJEjeCnh61QhM2FG~R*ng14KxWijjR^YFekyN3 zz}(4vS14#EpqDy^dpq*krH*ka=FNFLt+fw5F*j#mv3IBMikW#S&Vq}I3%6SPe08F9j UjorF>N&o-=07*qoM6N<$f*G}fHUIzs literal 0 HcmV?d00001 diff --git a/pandora_console/images/gm_users.menu_gray.png b/pandora_console/images/gm_users.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..a0bd6a2d21f71735e1107674abf4d182e51cf144 GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1Gmpok@Ln>}1r7$#gc284hSXsgL>A;~sJ5I3r1n`{@U^e10 zY_M!#_58qeA;mq&hw)d6eb3n=4yp&5j+-$mgz_KZ3|PqOaEGJhEBhoKrlvX-XNLt0 z9gc14Nx?nmvpHS50?m6qNR~8s7~WxXWUf*Yuy+t*+o;a;RHVa*Ba1_$_6++Y2Zgeh zM-D4))UA+e+8EX_<<$9RA*~>-w1#6b_Em2ZjWy)F%^cYIj}1B{DSq|Nmc|VPyr|rvpxIZpT=C0{Bh{FdOk0 zHdr>WdVXNKkm4TX!}u%3zUS-_2h{^D$ITcO-myRW9>9~t{UGRk)A31l3Vsfc#2E}v zEO40=(~`zvXK2+bC?KN{#IxP;g2P;nBm5Iu9N%<0Sh6l+lFs7LsBJK@aAKBVv2!?T z&u~?O>GBL%P^d5t!tDnm{r-UW|Rv>3C literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_alert_gray.png b/pandora_console/images/header_alert_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..13a2172a920f6bdb95d523ac8577a5c79adc39f1 GIT binary patch literal 458 zcmV;*0X6=KP)>k=V}*WTmHt_1l?!pV>8&z^Lmw z#ZiNTLG zZ%_H~;(I(IwUF^0k(955;Ox3b?xFBR+3(shn23rGgvU(i_)B(lO$ z@C0XrR|5050A|^Rf9h7;>aEc6WU=g+cw&)w$fJ4eKbf>l)^3tZNgEV5e-dKZ~SVWl48ZE*{60v@aFaC-m% literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_down_gray.png b/pandora_console/images/header_down_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..0cfebc477a6a175c6fd68c08a5210f4b9239642c GIT binary patch literal 364 zcmV-y0h9iTP)I}0P+Gci))@u~+1<#@4uORC7|16;UDug0rp0<#p_K|w?^aN(Um^hwTp|H2oGXD8I7b4sKv!CL zL~^y-RV-CeQN+HV)KrO8IT+`~HQzJ2rQI!N) literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_email.png b/pandora_console/images/header_email.png index 0d45c72d468f3d3bb72b2b08b9068a5b36849994..c5d41054a28cd528dc885974bcdf5390c2be345e 100644 GIT binary patch delta 444 zcmV;t0Ym=Z3fBW6iBL{Q4GJ0x0000DNk~Le0000O0000O2nGNE0N{5$_>mzee*t+( zL_t(|+U!)zZG%7%1>^$UL6Q#a3SugV-2qe(IB`sJJj12}E)laRauzE>i@ z0V1FffqSNOLN*2BPsG(Vtk^Fle|`dDmiriJ&FDq-9WO>#kV_S6-~dS3Tk%2fy^vxh zHY5wkyMrl*HdySJ02UnF9uQw(V>yF7;gC3zJGk&94!MT&g)Gl}z6lM=()ed%MM-4Y}BXf7vY;;Knn_ zVq$Ba_nOU^NH9WPlQ2dZUImEngqY8c!=NJ3EP)|%)04(dN>8L55(zGldwSBTdtgM` zA(4ItU*ZA=?w9Dk0M0v#_MGuzz8IF6a1z`a3-y|na7TWph+G(fg)M#Is&!UgVScLx+c zU~3$fNiz1q_>yQq7c)O-rin2bBx7!g%sDqr7NaJzY!TuxtIITuL8(_pnIFVUF8BQZ z`Tc(X*XKrqEiV+A_m}|yMSh>BRsTMvzoq#m0HB&5zZ=nwr!{X#Ym*|{0Hbig#Y&wV z>=&3Wu9aih!Q)prI{=0Qe0xX>1rAYRNkEwl28{}`&IZ8ljLJ;7htuFru8S8PNOI}| z0`sf`Ibsdq0ol!U^S&X4Ya4254-fT(Z7kw!gzZsE7Z5m&fulmNs8Ue}vaU<%=ZqUe z;B|=B<3JuK6$%7lx1?~e6~$}A_(1|bSdS9*xUJq+1Cuy`V+4ue4YdSLSsN&vfHxjQ zkEXB@s@2oH5lgomNVlfR6ow5944?ybsHAjZgw1Bda1tZQS{+fV4vHERtrgYEtb&JA z!wN5Jyd=UIMW$2g(;SGN>EjXvc~e$YH`=5(42v={Mxc16q%1HH_rYD1CM*FW( zXI=XKWR9DQs~elE&x!iJEBa#h)7DS)yY;=_<7$uo+_{=gI}L@n>-Us%c=h4+M2*2h z%f-He@stywITji>H4&C`u|x^|XL8O7!I6h+si{gDOun7yT^K&wzq=p22pJdBYpHFK z>A?pP=hZKzxnl6rJRs+nl5-tnHxI?YSI;GiX6%KnWwH5u%gZH~lkt|hlD1j!*VRYP zSJrC4azUa2{8UIcIHF7U-kVujN><#1ls&QYwE5hz>gwuWfQ3FVb-LB*ycw;-tKt_eoL?WOc+9{dGFPw(G7zQWx9I_9ltyfo+j?U8F=aGyaf zt9t*Usq@-m@Uz^pv9Vo~7opNSdACo|^M;A29Y0pqadhWvaZ|Zv#}1W^&p#`#8i=#g zKBM`j;doB4^7GtTmyzs%ZcMyEpD#bN>mySyjK{4_!pC{f)U&y>BNK6BRSHTNCf^y2 f-@P(28vh0Ws%(FAqy5g#%rDRHZSj2C)bZ*+t|r?f diff --git a/pandora_console/images/header_email_old.png b/pandora_console/images/header_email_old.png new file mode 100644 index 0000000000000000000000000000000000000000..0d45c72d468f3d3bb72b2b08b9068a5b36849994 GIT binary patch literal 1375 zcmaJ>ZA=?w9Dk0M0v#_MGuzz8IF6a1z`a3-y|na7TWph+G(fg)M#Is&!UgVScLx+c zU~3$fNiz1q_>yQq7c)O-rin2bBx7!g%sDqr7NaJzY!TuxtIITuL8(_pnIFVUF8BQZ z`Tc(X*XKrqEiV+A_m}|yMSh>BRsTMvzoq#m0HB&5zZ=nwr!{X#Ym*|{0Hbig#Y&wV z>=&3Wu9aih!Q)prI{=0Qe0xX>1rAYRNkEwl28{}`&IZ8ljLJ;7htuFru8S8PNOI}| z0`sf`Ibsdq0ol!U^S&X4Ya4254-fT(Z7kw!gzZsE7Z5m&fulmNs8Ue}vaU<%=ZqUe z;B|=B<3JuK6$%7lx1?~e6~$}A_(1|bSdS9*xUJq+1Cuy`V+4ue4YdSLSsN&vfHxjQ zkEXB@s@2oH5lgomNVlfR6ow5944?ybsHAjZgw1Bda1tZQS{+fV4vHERtrgYEtb&JA z!wN5Jyd=UIMW$2g(;SGN>EjXvc~e$YH`=5(42v={Mxc16q%1HH_rYD1CM*FW( zXI=XKWR9DQs~elE&x!iJEBa#h)7DS)yY;=_<7$uo+_{=gI}L@n>-Us%c=h4+M2*2h z%f-He@stywITji>H4&C`u|x^|XL8O7!I6h+si{gDOun7yT^K&wzq=p22pJdBYpHFK z>A?pP=hZKzxnl6rJRs+nl5-tnHxI?YSI;GiX6%KnWwH5u%gZH~lkt|hlD1j!*VRYP zSJrC4azUa2{8UIcIHF7U-kVujN><#1ls&QYwE5hz>gwuWfQ3FVb-LB*ycw;-tKt_eoL?WOc+9{dGFPw(G7zQWx9I_9ltyfo+j?U8F=aGyaf zt9t*Usq@-m@Uz^pv9Vo~7opNSdACo|^M;A29Y0pqadhWvaZ|Zv#}1W^&p#`#8i=#g zKBM`j;doB4^7GtTmyzs%ZcMyEpD#bN>mySyjK{4_!pC{f)U&y>BNK6BRSHTNCf^y2 f-@P(28vh0Ws%(FAqy5g#%rDRHZSj2C)bZ*+t|r?f literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_help_gray.png b/pandora_console/images/header_help_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..faa7815a3218b3d92270ff2017c6b318c6d10771 GIT binary patch literal 498 zcmVqr!KX94C z67T~`I_wuDu3QpISCAKAs8gBTsE_OUCnOALgJgW>pSC6mZc8EP@35zu)zBlzI|M9;k;QF&bsfF oso4aFxiW8Z=@0$49>b01Gt?0j9$BKuQ6K9f9%qffhd42u+3ip-G;)7ClM#2mBOzN&&AAfL<;nBQ=3a1P7=uz$uDqaR4=ZK9b=Vs20h% z45wx)ipOR+)p9Zr1VZEO15JtwYzEVK&wJl)8Qt4lSR{FRq tpbh9Lg`fpUmh=O00JI9FO0xwZzyMMsSZD|w>v#YF002ovPDHLkV1h5Wd8z;a literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_ready_gray.png b/pandora_console/images/header_ready_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..9aadb340d5eb710fa94188b3205ba9a20ea3de15 GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XHha1_hE&{2N|0b>W;}KJw5Wr`k+emP4>=uP*$K>FzKb>B z@N?yE!;2?A@H@QWNHVx|>chEn=eR>QGR%J{676uJpi4*LSivS;g=+;nSRHuZFZ|=Q z;1KH-BN^M7Tn#2pybHP>o)8mJ>P+0)B6HZWLDEIWw(3h$Z|_-W1!D#+Ifh5gM>Gv( zlqYRW`RX!b{Ru;vY^_6K^Co0l*mO)_oc2KJcEK94gpDmZhdozWxG|n(aA;s;NZV4O UtI~G=7SQ<&p00i_>zopr0NX2Oo&W#< literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_refresh_disabled_gray.png b/pandora_console/images/header_refresh_disabled_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..abe7de6bea740fe624a4ef70fb02847b77cda588 GIT binary patch literal 485 zcmV@&3krW=v&FpAopKez==`M-_Sy`5A z;LZFVpIDS(xCL?`Gky<157bpvjTjT+o6Q`7#jyca{4_GyE9Vy^O*!9jTmzRRwC{kb z_f*pXTPzqHLWE?)z{*kzIwsJ9i`^h_=Q+NdyLe*I)aDl($D)EST&gvb+}v66GFo#0 zf`$vc%71G!2AA!bzh4_oMg$bPa$nOIr%cK=$abu>ORCH@zn)jI_FVuQL9fo7idy1N b_9?&sQ6P)B9xYC>00000NkvXXu0mjfESbt> literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_refresh_gray.png b/pandora_console/images/header_refresh_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..35c8893b01b4f38ec603fec0a62d7e680080985a GIT binary patch literal 490 zcmV3PgmK3Mhd?UDp}+rk2iGybj_ymK2zAOUMe~1WZUYH;lalZ}J0!aqkU4 zzQH0_ZGat+;ZW70Cmt`Tn{&J94G|7~VA;~+WgD>}3Bw{G+H@%eR=hQN4Dx2+UAHu# zthc#-177#Yy~h#cqb0DeyLL%##{L^Psym3!@JQP29XT5Te@u1d8^!VC$mxpVz8L7t zfLp|VLtoubCbogdv4PXs0IpQ9Ex5`^-J_aI9l*$gL(f-cU-BH+lkNx=oPO?|2S$A; zhH;FfOwnEIJOF7zC0pVlBSxFwLwDIV4`#-<5FVtvjv!Cj&!iKt$JT*l!&6@Y%8l8> z5;}C%=Dn5~oYRYyF&0bWm;Wz(pQ)aFApYtdIA-oL3u0+phM~mLD;dJ9uf+!~jjGXx ga8P@Gv-}G%0Hphl5kmO=9{>OV07*qoM6N<$f{=jLf&c&j literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_user_admin_green.png b/pandora_console/images/header_user_admin_green.png new file mode 100644 index 0000000000000000000000000000000000000000..82a225f790faa0c7a0426007e588afaddd722bad GIT binary patch literal 665 zcmV;K0%rY*P)e0qiV8d`Mz-fG3FsP5-U@!?p?-k>+m^m@Y zXa^~qf+Yb@1!HMz=w+FSqcD6y-`1Gtm{pjO_Lo{FH|WbmRPg#Sr{-&icVM_>)gO%E z@jXIJ(RT*^&q|~SNhbJG{bAKIiZK>tvLiUfhGlOm0-kNpE%l4wrU@+d9Vr0rbq(v3 zg-Zbv=$${Z50i!%}h+=B6@(bp%RS z&d}(otFwqE;ua4#$$|hXYqR?|hwG0p9iM~Eg)Ej56$UQa(qUoRq~jf5{Gr zB?f@i**$2!)gUpM><8+6wBfzihTdlv?wjZIyT$V-;Bj4&mmgCu)MM>xDkDXbZ_O~! z#8@0AVsUuwHlgu+l~TsKr&gBGs^)~{8rXGE7zC2+$)$~B5UnTjQ9k;TkxMLP7Sr+h zz9bZgq$Bo^?OO^M{i7f9wXP)F}N^d2XID@7l3x8CxB@n{?5(|(ixnsB}cIUz5;kdTG6Jj zfG9VJlBUQhOxb=}2OO z;V0?bVqSukPdN9r70H40mWe8?ZxC8%ZC*sMeRjBv^n4z(Mr zmMH=(j%1+_;>lr~2H?4DUb$Zsnr3j+caQ_J&4qQ2B4-B)>G_ZBeQDzEj+Dn{n1JUz zKLz%Qz<}550PwX`AUbUdOf$#k-57JT$%GX53Kdj%%B}ISA8Ej!PG*1{RU=93SU(G$ zZ&o1pSF6CX*R3r`;#wyl*Eha;dh;&g8*zrqO|wXFeIGn&csKVLmtCpT7h5+cM={4F zd-SlE%Cthk95HxmY2a)T-X+qA183q42$~JPp`XG@9ta#h^gX{VnRO;Xzb)Sa3;^BP VyAS;NNc8{!002ovPDHLkV1mpd?C$^o literal 0 HcmV?d00001 diff --git a/pandora_console/images/header_warning_gray.png b/pandora_console/images/header_warning_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..ca9954d54f66e5df51f0781d6ef2a1e47b7f40ff GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XT0C7GLn>}1B`7dXnLb^cVI!kv)eH#_=I4$Q8J)~)bp#Xw zZBL3B^h6nC9bCb>SWJLTe8Csywm=8n10GJfY^zQ(Ex5xvckW#N6={qsR<&G9+ragl zSwLDSnRDYx4aT)*!VaH!Lv;>3yTpHGO9FF{9K&<=gbz9ks=64qs(EAvHZV9eFfz#K W%Wn4&-*^q^9tKZWKbLh*2~7agqe&$I literal 0 HcmV?d00001 diff --git a/pandora_console/images/input_zoom_gray.png b/pandora_console/images/input_zoom_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..002e397e8a9f54b4ee2f4a5526d9c41475fba7c5 GIT binary patch literal 416 zcmV;R0bl-!P)I@>bmy=PmKH@(n+{k-5MlX+&FOm3oaftsEbk;D$&EkBr5!GpUXVR3p=*uvOBd0N zQ6=?_=>f|=!=${KE_1@etz?3OwHZKFRb?2468sbPf$zWOETFK0of(H8W|U}W!0tS> zCPQF3qNAgBPa?-|yn;K|7Lif&G8R*=wI-4@=Q_<1Sg_1e6J^}*$1t$V5;XP2PN`AC zOG6|wYv24lwusn;W(d!?e1N&0Os=Xqb>Cb2;?z1`%GsSMHHp-FlfCG(Y^K|KQJs2I zepVvEi9}aEsVA8o&?92x+8`>>COon{c$bLUESu-@FTeoQPIx}(h_w>{0000< KMNUMnLSTZFrL`#l literal 0 HcmV?d00001 diff --git a/pandora_console/images/links.menu_gray.png b/pandora_console/images/links.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..c390e9a268e0e03d8968a3bc1040eb9b735aa10e GIT binary patch literal 387 zcmV-}0et?6P)tM-p+q09_zBj%n8*D`G?`?U{B6r-=aj0Z;*ZX4_7LOBt+O+<>482iQw#v+!ui z$kXv7eUjCx%xGy}7qY!DThDzfQB9}Sm-CQGbaD;^GO0VCXV!6B#&5|$s<;6K0yi%r zk_m~F*HfbWwLF71oOasZXD?nlQ<8ap>{cSJvs(49;cupNR^=+4 hO-T?0`6PY_FaYIpZcR1-;q zNHk%vQ`CTq{2!tYM0&1}(1I+LkYsB+gN)-UA-eFF0kv(2Ck|{O=B#i|-yF!DG{rqDOa(Nx3rYvJv_k zYU8;v2GLM^u9*(7Sj!eZl9Y*F9pN8m$oGhi0t^6s6&eS0Nnh^(0000}1r5s>X(~FX0SaR+0gt9aJ-8Kz62aYsI|9C90 zzafu9v00{|Lp(`1<;X)_Muo3(-B%bFWXo)PnW%Kpw0Fmx{?iJ~GV3fIRylrKvV$#N z;_q>>Xoo+HQrQxW=bDZRFbnPJzMicRE#7dbWeP+3k#z10rN1vG6)<0jZd}4*#;n;n zF{D|HA@*}aP_x~GVqQ%)UzT0Zn3u9O^2~7X5Hw^H6)NIQ{I3&r&tXke0|PU|wjP6> Ux)x95f$nGUboFyt=akR{0Eru6ivR!s literal 0 HcmV?d00001 diff --git a/pandora_console/images/op_events.menu_white.png b/pandora_console/images/op_events.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..b2cadf90ea5baeaa8cc4c088f9670b01270f4027 GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1G^E_P~Ln>}1B^+S<_y52A2YK^?1O+h$(euX>PgJr6F$5g0 z&D!C{(60E~v(%Si<+{W}ig^vLZy1!7A2SBUZkc~&L*kLd3-vmO#2bDvcd+eRBM>`@ zwOf%*r9yoDc98{{8TLmn_N%YCHd!irhl8RiPZR^s6Ly{_3@YpQvM(*G$?7b<=&~T& y&R_!f0zIV{Qc1BP9uu<{=w&H{={htpGDIw3KHh!s`dXk%89ZJ6T-G@yGywnvC|TwJ literal 0 HcmV?d00001 diff --git a/pandora_console/images/op_monitoring.menu_gray.png b/pandora_console/images/op_monitoring.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..3d1bc0e007ff5c9ea0c991c89a200719b517ec64 GIT binary patch literal 387 zcmV-}0et?6P)KR1i}EPywU^N?^sT;7}yt2RE}LjjY>SuTDx6Pt2FA62lP4 z0nOzL&;Z-X=lI9XNgV={SOeW89%rBc;lVB_N5!v)ciZagoB({xN00+6b15BCJr7s!BTuL{F((sDET*=N?tgyGo$jX1f#A(2@ zASsz+<{ws(jIWrX981sIB4uZvTHLRTxWG?sg6{8Gv#aEF=)ih$zan64T9WUlI%5!vR%LqyfUS2yoSVwNd!E= z8q_4n!FZt+Z#N1a%OV9?cKV_&U>9kxyX|$2KW9~w_Nz*1TWUfU@ oph}z86*ui)pOIf5wzmKS03!Av5#0#xeE~#nD6YV{3J4Y0R1n~Y&$t7e3hWZxLEHh%pgC!=?ktOwR+sE!c6V;q$<;s4>&NFB zR|m-;^-78_DYoU)W4jP5R}9ZSm4ZUR+lAH8?`TwQBEv~Q1iV94J#?AL*h4p}`e#HdwmUO z652xVlyGl&8hmSZ06RE;kkx2O)kG04S`^@Dl9}#_D3V+5uDn z5pL*rfXw9F+$Kd-cq)Pw2ZzwE{BM% z%;dRBDc7w)Dg#uc95J9<2I#&AXidbr1ZUDqgMDjbjV{qSFrI*?1&Iwg#GHmZ2=fh{ z7)e%g5YH2psPxG%VsnISc*geIijY;(1Xu}%9P|Ofr}t)mVq4a?ngT5e7B9S+xIz$X zv>ShC^@5{4N)-EkLR**N)hhn@p^aEgFtLXK0|3+f+&A+qi*x`0002ovPDHLkV1na0 BlG*?O literal 0 HcmV?d00001 diff --git a/pandora_console/images/op_reporting.menu_gray.png b/pandora_console/images/op_reporting.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..b568d4c1b287b3705eeb29787815e4b8cd418c15 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1GlRaG=Ln>}1r7$#gc28qxSXsmN=|KCR9VZ;bG>$WL$VzB1 z=w#HmFL=q`ah2!G$+{WL5gR_7kcn!vHCZHYxxR7JaYva)KX{wcqGBY!Gi=nm#ov?H mwWo}6er^kwnE<0e0>hbnwZCgNmG1^RkHOQ`&t;ucLK6U|vsK3c literal 0 HcmV?d00001 diff --git a/pandora_console/images/op_reporting.menu_white.png b/pandora_console/images/op_reporting.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..a764bc3a7ab6f63662aabc7a2ee16b20883d053a GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1G{hlt4Ar-fhQW%>4|Nqa-Gmqd{xZ&R6DyhAcrSz@h%4Y7^MYUOPj+yy2sKpLi>Oa{ZMv#eu$JdnKf~|L zXG&sBpS~%)Uiju%qRfpFLyqVKd55ItO~)N&9{u2DdbXB1V^%?A)Aa>^J8r0*&ldl1 i(``ipvmgT_8$)5R*5CXGYL!5zF?hQAxvXM&tvnj-gB+uEufQH%J;Ux>vc^R>+uZS6Iuo_&9 z%1E)6zSgoxpj@Jw#H}1B^+S>_y7NVh9lqqJ2Q0TB`An8n2P>6&iBjH z^u^!$I}VJow!(bQG7VE0XX60#i`WK?aRGJR4S~A53D< z$ob~Hv(MoT1Mg&ZhdqoP&z%onm^g9bM<%=JXWYNBndn+F6f(>zKQH`=Pg8**d=2Xa z3H5I~c!U%#Dlj{}?1=clFx`>e!{mk1K8F4NDGvMF)kNp8SqfwZFd442YH)aW+@M9U vKT#pQ+2n^Zr##Ce)&nAc8Dec68W{v*Ix((`i#NT)z4*}Q$iB}F9Kg-jU}kD1)Hn{$GqC$K#P=$PI>y@AJWDOo%M3@h1A1qiYwK9PL##S3YZLh*%VK*xmOUL9mr zXwm?6HPYu5u_nl#N+g$qTEq4X=UZ|I1p@odu9DcZd4dd%C~`Q*r( l21?~6?9{9H8>b%u1^|EX$&#sJ3DN)n002ovPDHLkV1n?L1ib(N literal 0 HcmV?d00001 diff --git a/pandora_console/images/to_top_menu.png b/pandora_console/images/to_top_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..79e82d11f3be8461a9491637a7104ef58e64765d GIT binary patch literal 323 zcmeAS@N?(olHy`uVBq!ia0vp^x**KK1|+Sd9?b$$k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xo_e}ChE&{obK@;)!;&Mslu-I;eq z@WsR%NB(W7;kc9iInGJpArt@i{%k$s0x+Ub~lClx%oR=R>H#hm`%v zR?-sE|CoC?`5BTADj$$2;QztM{=MP1>GJl*_6GBvzdlG9u-LG!;j(86YkbZS-uj#+ zym2~%c6>8;mU(i^iI_z#*M^ekX05Qz~}=CTm5+tnh;DZ?=T`!BiXn!odB zz4-bs@xANaXQKLVxvI6^)!a>g{7g#6DC)xey6!j0%#%Q_o0YNXzw}?R1O~Sie~a&I SeI5w(FoUP7pUXO@geCwBg@70U literal 0 HcmV?d00001 diff --git a/pandora_console/images/um_messages.menu_gray.png b/pandora_console/images/um_messages.menu_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..955957ff1f77b2acbbf6d3009301afb4c383a652 GIT binary patch literal 428 zcmV;d0aN~oP)d2Izbhdtc&dUo&9WI;S6cM_G>y8 zq)X-cChcBdorOf2CaYto8>_~MFm3tx*^ zH_HYCpvR3dUxut7;ZLM@h^>l|lC}h}0l)(tJMdPMeIOhEzm_GI=#H*?BX~QKdH@|5 znEU}5XIXGY=aEdf^#`M5F6jy9DcefPi2#{Tkk7pAz+KEX2^7S4i-0llVxC-Xe=>&B z|1m#F0sfTME8{z6XG$8n@J-UfbJSs{R^%K2m@str@Z~bu-x#yk6)5L~_C~d5yriF^ z6b4+WWsXFAH4{W1jb&XLFMyW%ch|7R!QC!Ayu*K=kvfB10T~aQ7eps?*nHS70t^6* WOoJ>re2{AZ0000#Y`rBg)@&?DsJO}91Eh7OfvpbZh0V1tZVf>^%Lx7wO|y!rM!JV`Udn7 z6QOxH0?v&`aDu}JrjNY+4oM_JEw-6+bw~enWQ-)z;1f%m@Jn(7TmVnhw}3sMXFijZ yawk^sQWO3ENBiR%(M$FcEjFJ_bak=41Q-BJ#bJMoa}c}$00002LI;E>41stX z{a+>Q*b8n4NyEJAE~BDm4N9N0|NodE;}DbAUI6PHER=mH-jx)IMRRrUS}39d#ZVsE zvmP(m8>ZtC0uXkzy1Fy`YU}su7RzSSZwW(5sPIWk3dT@$s86v!&Bpaw{5X#PW1FT3 zv@PMWb3MAjK#L-jIK>#fJ2jtCodNE!B1Tt(_&NL8eUg_DAV8pa9+F^^I_>pAPz(Nh zKsnk}JQcf8GlgD1HCL!g24HRuTC`zA&LVOfw7}R#Z7iGEMs2`?8c`!vqNGfswLeiz zB8}#PHdrWPBVK;A*Is9KW@k%%Z(o!2)K0ql#pT@l*@^5xtJ3~k<4O;VKCHQW+Tm!u0pv_@79vwI=5tltz4G(tTvS!)(7B@J6 z>|Y3Ao%un{Xbklx#KA#_FwUq1cf6bR^B_8JCWOs*tIUg1^Z}8(6-zcb@j#}5y)OCt zYxB;;Ae?E-bXA8pbHk+21A0AX#FU>im6J7}#{I+po!T`iUSd1 zE^GX}P0RL=M%v6;p<}iKSTx=Zkpo4QGDY?On-7{9jc}bEjlEe}UXZjTYf0A8eCt5I zV~2>WIkL4R+e=^wV+~XhR0Q3nD7vI5b46JtWyvpwV%x6u_B7%dQf_L`6 z(_7UmK*}{3E!FapHJ1a8KGO9nbN8<~FCdnLRjiH&2JRDF5-JRxvdaafQly1d2cDm#dYy{CY;TN!a6Bw*%?hb#St3Rj5MoD6x*ay&ALHgXoRRV@m1v$itJb!1sjEd zn=^Z$PXvX{WbDNYBaoj25_mI;voug&9WvO(--K4?bvcb}U!pUqluK6)!p<*yo`yl( zIp7VDrKqR(gfT%3q2K+&4waZJl6})WT|Tm4Dqb7iGYNkDm|BMfL7a*6?k`KTdIq5j zS0hB?V$-gp&ZzsLMBubBlm85)oHzeJgenk^Eu5=B4IsHzElXw2dEv(ghjMT773A-VHU%Oy+S<2Tda;Isg zK{A`K9il6IHBZS{u2~nP^i@@drIONKBqu>o$hVNPd$&}2t51i>Q_ab;*rj`!BQJ#r zegZY8o&}xyb#K^y&sa8wx(Sp|#aLOoPr0N$%B~PMDlw`_R9E$+47cnC^j6_K$tArw z50?ooacNpGIzF(X=~-wBISsLxB`Xyq2U6kK&Nu{FQVaSCOUq&E7DlWYX4C4}%Nj#Q zMLjQ8t3_apO41md7J_yc*)1MhU6m1Ul9b;aPOn>BMl$S4A;^<|I62|Q<0B8@An50H zIq8{<25x16CKqha9(PU)cq(>@eI*bR#mPa-zCC%n8@M8nd5rdheM^kN++T5&L zw1Ox^n0W5@O=(07sIb095m z^yzxVX8Lh8O$SNY2Uq!W*U<`asioR$MFiq^Q-GQ#flyvqtMHpiVdIy+3fv0b3h+pV zG3gTZMl6^!JOuH+f7dFGAs+rAsoL~XqBt4w)a+j)dJs?uP*|-Bmge2re6nk&8^G2R z)UN@i1OTc8e1Cv~STuRc8E{}g;`Bf(i=pH@O6xNh;i&5rZFDk>`#1|IIf2^&djfe7^hknZ;T{YE0-8~esG%_ zTZqw^HC9eB4%Q_1-U}~l~wJwf0 zOjrv6fF#+3vkp9<7zS!$2ai%5oZQh(z1Ofs2PiQZKs7aXhMw(Drz$v58ZytM$a1pz zBu)kLew=tJjbhYV#)+_?;9IEjD%>8TL{Bq9{%m%_KqNCOVOEw!PQ{GAA81$qNCyeM zQUvHc*ZB5eZodz7Dgfuu!Q89JeVsXJE_w4U({B2m#bBX5AjP(}7|6nTS||F@e#No!HXUPj(woY zG{m0>xPdC&)R9t;#cBmDvTI7Xq$%g{#Ym}T(ZU{BA}?Y!I^6EhxmK-t*UxkNXGm$N za8p#9s|=|_TSZbp{7}!D-GERgt=)7Dy!Kquhp{0&emX~Mc`ZoEdVQvPjjPg_y2FWC zQ~KaG3Q8}5RA0WNmo5Zy*sKj3jg-KSouXU_rK+=gmx>_ln!q3<$efFJ&jq&3hXW)x zxD|Ei^_sDI(pAzNfHm@}SpX?LlO6svt34RLb%Nk0H3ew2YfTc4_8ppDmNtbqV2DEU z)LT4}E?7ys%Nz@=W!6ehqE=~XGlj$Gom&`}_g`8`Zv?TpPz#)=IZT&+aSADq?iagFSsU5 z0Z~f>m85NZ--4~3iL$yBcJh&N}R&g~qBjdmN6YPIeNIh&ux^N;32o%7`#4hMa1b-1@i?Iu+j zK%8sTkAkH<=520W4N1AsbGiwkZ~c_p32RGJD3&G#Mr97hq(EzKwP!`oS#9eKffIKi zKZh9tEO{0A}%m!6t|zU(}!B2le)T^;F0SDYE?iGE617{ zug_6wS2mYeKk#^m1E^s{f$6h?;W>k8Ak!)ta8Com7n8a{(Xr2>OK826B>b=pET~|p z=%2P*k{0x8dPMU-ki3QD=-KkE`Rrwg&+cy7GsD*qvOPy;nC++5e?O{~M#H zL@#n>F@D!K=O&%&ddn+jb?KigXgiIcGqGx68!asJ1ef(BQ;}lZF-=}(R70%r?>LpY zB_WFSmz4{{nhI|VeEJPb?0*=4fCw~Tq~t!}|J|%qRBjpmsg8FcYoi+HZuC6M4>%|& z>GCg#=_Ofz=EN9X7}$Ef`oT<~Z_ctI+ClKfW5i$5Dl}|kM&m< z2cC5WC93as_LaI#O_B!GEa$i1h>Iw?$Qz>-G|2*}%UBxp>Wy$USdl_%*$-e8auAj% z6mwy$2lL2pO-wJVHKQP=SZhH~+8wqKFhN=R#}|-jJ!Q7%A@wJv=1bAM$f6A3q-uf+ z645v>1qhoeQ%lo!P8&#kpT|i3$BsQBucU))VcCPQ2DGL)B%#mGxyIky2NTa5GN)YF zf{HE+oAbM$RWBsB=?~9hnFS9})|Kn~l9n-^+uWRcm8Jdx##oAXxB}-3D7&xx8AVSR zGq=Z!ygVqyp&B-lIChLe98CmV`OqI$BcH8=6u?8J39 zs|4ht{BWQTD2W0Yu8ztx-L!ZWm9No-f5Vp^ND3^)nAc?c9W(6cP+j{aM4_etbO~G< zq8XMO%*jWkpILrkQ9j!%kd@C60Tro%E}-sJ_9-xa8B=1eJWz!Ka57CXF^V?|%OmsO z8P~fk;DQZ>Nu`llbP}G;B2m~3Ym-rx?dDOmE`My*%wLXieye^i2vh$ATR#+5KZB}Y zx&_>p{CCj@b6`%LIEFni({B0Vqqif@-)z}|@W~?!*KTdQSvL8NJ)f;hv;Q9Zx0VOO zWE9)3Dye>TaZ10btbTsojvVg$7FgRxn;~?20!HZ=ZIARuTK*nmSbf=X0%@_Bx2;(J z9N=HaENH}kKO&+XGcIPmIsK-;A=U#t5L8);&g83ZT0p7-BboDIl|as!Mg$P)^4 z1ioRY7DRY-k$Z@*HxdKe!{EhHUDzBcZ>DP-5xlPXZ1wTgiPtJ`e*auEQ8KVHy{Bmu z#0Tp%AFb|M8GXKX;^(I_el{Je(@!+r0y$_K*d`^%fd1q)d1m`6y~V54V=?uKEz!jK zch`=7u=^}uIj1b1D-J(#`E%A&k6b4+4W0z7+qq~A^zB-8`{B^HLQaDW-GWp*fGVK> zf7|AP1#`KpJ-ELRx$<{+_Akwyl5XU@OB9DM>e-fm5G8Ow*y7xA>U-ISbj(awaovSS zscXU6YuCHWT08l94hef05mX}e2$mMoH6~)0hjrP;mfhvc&n63lPt{!*>>E6_DccX8 zoK)6vwSK4eDd&HBtM5ZTm@l2j=}_#a-33k6G4hx$>Oj&bY41UXxbseEoeRsS;=y<& z@U`~#(vYn#r(B#}Br~@9rz{#yJzM!pzUZsFi|C47Uzcdj?|iV@aQ;V_%;ftl+x;2!TxwDsIAt#8so#Agz_60?Ih{VH;zADIZ}59;>YM)k~&JpFO= zm5%B|>+-AutIbzB#1&?WqA~=$LIp7`s}25o2j$dVO}C*Pbzj5%J0|Y|_AQrWo+t}! zqgPy!oimwzv+QtsFuU-24Jr$la8`6k<2q>?NJ|Tkl}n?DNJ(-I{6XZ)X?z4B&=b|E)^n?4n;taKTu9Kpy^HQ#t6*qa%prVtgzb!S#WMBWVY&Mv7;jWv!n3 zaCB87|HwXmcrX;@>uXD0&K(+oV%hRk_EJ|#5?UHuwndcJb$a^2h5PHtje=VsgrVWP zeVBl-iw(z$etyV5IAzyy*z2Z&wY72l-|#_>*B-L8vbrk;ziv#gn%BBhe0DG_K#g|4 zpT*5tSD}0o9FV=Yh3Of`2F9^*prA{cAmJso@S1;jWy(RhEh`3_qWW=9<5Sm_8C}9H zdV9Syddeq2&sY4M`0{f(5-f|75n9x?CwnSS5h+w@(x8;dlUKDDUnVurVl>aDK7$bp z;^#YP9;&+!A4T*3a060~1Kct_#r{(cDEKnVTKJ{a4&V}e~@=QHvqmA4g8MY7UTwc6?$ZHNKipzE<= z3-*FMK*i|)-Dd$Yqb^HBBY(@AP*sriXT8BsfX5j2OWWWZ$*#Ml#Yc88^|IGt9o}sX zS>NUj38qE>D#^C|dB)6tIeM7pv(arMZt6jx&9|~hCeD(a?d|4bNiHFHNW)1dLoPS0 z&;3Kl;l}eZy$w&m|9Eow0l54J-j2>TITPLU{x*I8@@xNw66tbubUgT~D$8&6pWy{Y z1x{`+14;Wy+Z^2fCFj%g1&Jx^Jt$2T}(tPT6t{XeD9f+wX4E)E~@uL@i~Iv z<~70M%g@6T@13<$GzyvgLRNlVe2zkh2G7gKp1W-XzHu2JO{xGwGu{Ju14w+(`UYiu zN7A=m9rvmo@i`aYlFUo&@90QsM+o)x{4C5I*A2}JV=ji6XYTS}B84t7>YdRLEtKRn46~x5p#a|CgHP4QnD)4@=B_20tv=@xTe71i{T&_B_5kZ| z^CJ^7bR_+15^078|HLL2yR9b1(3J+6ZR5SEr~WGegu4CUkAJa#cI_d7@J1 zl%s`;L$6=Q#ZwT+#7oi*>W~k=lZyf_h$g2wVR|4 zK|3;WHd$1t*`Ym`*pfLz>TXPEEYW|u;4RzcUB}}O;rEbrO)Jy^CK~$CZ$tb>FyR;( z0nwEEml|52+-q9vOS~bxw~m9GUAd=ZyM3->`j^fwW%Pm2R{!M(Ja8v=M(nyI@?!4J zb5Cb`q|)o(v_6=+LTAsBcUC)LN>FyRJvBZBZVI+{8Z7l0A!)~JDYWx^=fDNCn*1&y zeQ|ind%@cb9_r^eU|X>Tj6F+{kB;9Pd(5Q?L3>Txd9azRo$0zFZOy-J3Lj;`lK(+< z^rRNcKj|nBn?v>IdEmSy%R;O7+Dw{d`({d+5uw1yeG7GS#0JiKZ6V2NbwSaRgTXEy zy3i+P2kT${ET1LXk>$hwkh7S>!tikSl1+*0lC<@ztys5`LoDh(1)NykbPON1j`OZ3;HWRQzKXBQA7J>W+?vk=s`(c&glo)y|E&m+n`8^(Am5Vs)GOqjb0 zJUzR(-x=52Ea1ZKNaLFxda})DmAm6{&$9E(;SSwGiTNSKJaebNLf+XI@`1y03l`NS@%DlkO^kE7lT#Di z@k#E~=yfLd_MO|@TSLt9(e^e|v)0yj)3#RcEk2*}wLc4fCH%cQV zmssKpFNRwkhVaYk%9R%fA6VZ9VHqU&t|+Z4Ih^P#8=FlvWM6PtUpDgFt=HJx0}Ovo zm5y+bRV%l{)Z=)5W6ah~OvN!^oWy{e4(FPkP zm5y2?y*TV6N4PxBQ8woohkHBVBTR1f#MqUp00t9*V6y#TEG|5N#WtQjrkqn2%@u8M z{>xSXntM6taT!(8{d`u)_hLY;e+A}5(K8xq@-CMhDomkr>+_Ohc@egD?Jp~PJT`Lm zV-oO+lY1{#<_BG=WoA~2-05yO$x#lO;OcF?)zyW(yF{@6*#WBojVG8Ixk1sKe8!`_tw6CvmGUk!tjrA`omH*4@wXKkA}cPzp%%^6FLDr zq1E*+<=?5_KQ$l!eo^L$!q(a(MFu(_~EL(vjL}1b?r#gz(`lmnd@zh7e=0R2m%D5uS5jrgnv}@4~Vit zweFOS%%%d_KnbET>A~M2);b;eiT|Oa808|280$rcdDBo#{8{gCJK>W^&!6#~pR68O zCyqE&5z7m5L;3Boq0TlLtb5*1g}gTbVB##+v-jBks6Vi#kKMFpr*OqVA~JBfNv{^^ z$J}uObZn7h<*8800s_k4-Cnxa7X4|hAzwKZsyjpr8!p*9HZ(cfgY6sZ!C*({x`qL- zmee;`#Gk&Sdjpuo$3)DM(d)_xa(2e5gUDG&V(10euOm)pT=kUy{zwjuyD+%&^wTzI z^0&q`>sYyWuQws2wy7_8{^Fao`1s3z;mn%Nr`^MX>hjnOQBF*0mIuz@ae!R}EDYuS ze^X+HgxgfJVk4mnT>rb{ulbecr@tCjLIS!o?Y`#3pzN|kB2$S0L2*G~jE5iI**AwE zNY0Oqh=s@}cfC^oq^+ee@@Y}zZ80c&Aqa_$OdeqzJ~nizenX1^F8D|k_Hp$fHi*2*<;`HC7H?aK?`$V5L)3nw zlQ`&hljo5U-@O7=Uivp7gkzLAMEMi9^_lDV!|6c#y>DeDTwy@mx1$g!WJMTk zuA9HVd3E`(357bRolPCpCF8hYOl8aG@AexTXMWJ-ht=&b5?!$4JAEWrU$Q~92H~GC zZU3V~yiA#H`jA@p-cYzI_9|51IGPoF8&Z8GD~e#4^LQ?1)vw(!r8pkM7OM|kle z^tn{`ImQM48uwSt1Jr$MN1b?YSU&D~*{XOR@7>>bqO$J1!{-M>=QK8KzUB5C{m?Ee z3%H7LO}jiBwr}H0K*&1u#q*oYLj}+o^brVfK2HLX;Yuz1f4k0K@$QG7L;Fhz7b2&-0v+Vy#OdM8w@*0m z+j_#G-FP_D(suAnG(nuTu^QZvHpm}0xOGM{PRR+%O8{)WwFqau@HYn1^%(1ebDj}4 z`l7Y;B?tDcMM+g!Ec47*WO_cGZ4P0@e1xEEM(W?Qer_6Mdl)2?(!LjhNF;l{KZ`2! zhot8A6SzMa@7Gz|?;|8HUpAYnh1M>Yu4yKz@1WSEzhzRkwE}iS>~;|$rAT^ z6#{3OUhDQAmHB*w8}={E1vbpv?V0#2{bKbm3GVtc14X;&U}dirvGS*N2uR?s2JeX( zj49!&RR^+XdjfJL^yITAzV4szLeNABjj4sbHwIG@n*oN8${~YVDX!o`9O;;dZpAr5 z051gx!UT^`z|Kg49OCSo)Bx8rq~Y;%eTnxn#;aw90b9BD+Ytr8bMyz-VA#Fzl~EBW zU`?celJK9mqxA5?nG1KupB+Ob^wI`wDbeh?+lSVsBY|D=yuTyZ5}pgy8|%18SdBy&H%OHpeUtt)_)%(LfBwWuCI%goY;#03*A zi+eSx`ua0|16}n(Y@oe3{r^oI+_8$Ss7Z5B7DG;{K%@cU(9nZ4)J^}wwWbv#)EJB@ zA=y2l6Q#OQ3DY)S;yBedL*&~`mezd~IxSYf57+>h@RqdwP&f>h1PBNrbGZ1jDJundV!jEFQ6Db8PkXbMVhaC@4m9Y zSejtuP;GN8Z70q_%9DI$bD5Jiy%4#g28RO#GI45 zNr{3cpuZqX0O>_NVOsodPs}jrygf|9UCpwfoNe7;eveo&QLO=#?Tyj{y9-dlyQN2J zTx!*tZ(3toO7j2&?&{cRuesZ|ZmsVG6O2}4Isk&0tByCCIH_*#iA0mEEi^^qJz^Ah z69p4F@LQtvjUx0n*z4%g4+K<%mM91S2E2zA*m&;EA#SPLGN$H~lxk~e+g+}q>LhGs zhhPL=CS$sxbb~<-T(MmXiRUR;W~|sD0wBw*b+lw|>t@kf?S)W#OEQ>GVin5TOd7OL zf`j-+*-(y~MWuWQ2;f`NIxP{c6S7tdjnm+vJa!jg(O!51HUwZI0TF|c82~!BIDiwJ zC7p9hla{epos!UwG7vqXQtRHrDwKO3cyK5w0T4}#m>S4rOKAQ@qV!@i#|U^pUHjA% znOr;3F_lL}%|B%4M(}efLjv4qORaW%0V@?(PPi1(%!(}g5g^B|-;zmb?seES-b|YY z!{-nh%HxOwzRXeE(p2|ct2>PxTpz;HoCxkm0FxN)O{6JM$Htcic}>hdB9{ACUGB21 zfyNjj46xor4S45xaP#3VGm~SQdmC{XmpwE!1wccz&JfcLt8$IFcMPLba0u46-XWc9 zY(1!Kio0Nua!vzc(##Q-WsT9O6qr;)=Sc*>Ktmd6 zHx|(ljCV{nPAnrC0|-8tE|Xo)DuouU9g(9NcCtye9Yqi=gVTxxue^aZ)uS^#4qc2` zczHXziXx7Tv0$#mo|>&)cJC*$?^`4FD?vAlVY1>QO{FNB>Fa+Njs(RGN@6Z#(pt(wBI+SxX@a)}Q zqqD0a&+{alB81UZ0ogtw6NKSLP~jS9%*Ux`HJz|uIwz$j9a@n#f)_#)`@*KlyQyjc z%{=0TPi2hIIUuE4AB;&iR^lgDQO~^TNJ(A4E-}^mzd**W!C&5DHRE@f&a$S$C0jsA zI;hI%SF~yF0I7ikW``2$J`;d`E~-UC*nFmQw-2|l-~ax*{zgaC7v{tlWd3SjZqxL_ ze10iRkT6Ml$9(ix+=reXX0=f};vWtt+dI|s{bcU&q^#&!CB!!aOzWh$in7#?07>`Um~>YI zp+xXXI*n~hj5`R!EODMpHJ~uO0GWrKu@_T}Co=nL)l;K+u-fqSmZ~jg2YJaRkZcZX zKj~u9_O#t{K66SrZ}T)bOkUqx@=SOTu36LtzA@=BRL_>%g~FPtHMOTBeIr5tUS+Zw zJb<>2q7`_<(L4J6TwZ6cnhzt=VIE1KGOcjpe(2 zoiO%Y@>SPGQ8KZ1?46=?*7?aPad#|D1)?to&{|PckrZNdSV$Qqk7d(p>{_$0h4zr9 znkTc{ndY@6a+qCDx|E$1&{Br4z^}_#OuQBi=!g_6WQ{slW0DUc@_PqRY#13!;1bJ~ z;HEF$rwPM=lSF4U(9}}(m24}hK8={7-WSu(LZOEml?S?B{b0pSr)1b5z{DbYuZF%m zu_%k^yM>LyylBg*2Q=8@kuWwz>)Pnl8rtoO1&V%(@lYrUOl|e4jA~*{05FKPq=WqI zJ!S|1+x9x>d^uKr9`rD3ny(j!Jo*CN1Ok;Z(^PU6CJJ2#COpdS?>Vj9!Va1DJGQIv z#0uTDSatSxYwULFJiE%TdmcW(X6XZMH@u+7~5&f=%qe&|-0+1-E)H20!YW9sj1_-GYpG*FY zDJ9}4F*}lCxMv6_vcYh$%I+hlDUk>!=@>1u<{&Of%+odU-AoMq`W>`IAyY{EU$pn$ z3;BM(4Y&UNae0U1WaluVMN8tvxB8vOE^JBZBM1QF0nz9H3XBta_I839W!G|hI9?^k zRZ^Y5Uz{R6}Cb+n8V#XNa+|t!`%)*Z$}tDcA`$t zl@OE?Ka@;v>{E0hL=we}I@%aZ64dShxI`*2N3AhCr7X_Aw-@q*4DA!~e>&rxkQv_~ z7l^RhB19pEN2$e>oW^b~nUvNBI)W$}W68e$zu-rv7v1i!tJTh=>$I?NAI3QCLBuB`pOJ)G`B}%;=#&r*t!O@==YW za)KFN)sRv=%w(9T%?4mK`vl@RNw_taX-B<6{ygse4-&e2Zbi=;?)+kf@K0rxyCcB$Ma;ee-@k{o`E0gdhm z`Fm=xKZ4+#Hap_eH7w0>im;&l6vfwffrc$+5mG ziX6Z)!{9&9FCfRc>S(uHF6*bC5t;YB9;0e0uELb*!&UzU2QVASx1 znq8z(ZCb}2`kc{B4+tREwH~T=dQJPB@tt0L+XPMxu35y^nJ=G*Cx+(%O zz~b&4k+_QTMID>U`S-(ECz0(ylf*;sH=_sfrU!79pKkbGbvINN&a>HIm_(jrq^zz& z^H?U1;42p%B_VJwCe*T&i|(jG&-^6j+BJ#X6YL?x*)PWJR6r?tB~rynDuT#_9-F(iF37J}tC_+vR9tn;~T0gf|2zyG=r=l$*3 zf@iI@rRAmE-r#KzF=4mqFf~66lkuuhA~=P2owy2}pq3Wa2cMw|K1|9YIZe9= zrMKR4-g|FV*S{P&?!)`({M__5@4jo&0(ma!z;+eA_$w(*GIiIPD$K6~B9Gr869CC8 zSy4Xyo^DC$jP>I?n008uuVS0os&C>X9G<5{gv!F+P_a*E;OaaVhNVDCb!#yRFYX9g zb6{%5acVThVIc5s_5y#pTcD)uF#AYcX`=`>uzt$qbZlstJ^Rr zway6O+#4Oa{S$7Y$zK!7gm|iDFH?DSK)SD8uAj2M$y@+ZQovFF5=rfJ_5#P zZd0q8IfNHagbMsRz~^=SN#Ao8 z6nAvWxseWZ#2#au8qgOZS~gw-t6gsUU-NHW)jt~^v!9_G8sJm->si(Xv(}?q8b#Iy zjd8$dlXa{O;To#}C}LPx{Y;D`A~sqzh+)S_Wr)87d*+G z*maAE*7kbcq-AOEc582*okjMC@-cKMhkvIk&~ji^I9tLD9=J0#xBQcK=6EQNY<7&o zx1l%7U_Gs#Sbfu)DxhV(na?m!)Pd5f4Zbr@depk_HFKa71L28Lj!`}Pq)lIIjRc4E zU{}JP7R)Ik6yc4Y6es|oZ2o)vVVssv{%4(qTkcz${)hJJ-{j~1(Eq#fnSBNU4zmUY z01!Z!R7ilqPqaS+p(WpnH~XxE&{(xe!@WyIN*y<9gb3?tiq>Y@EkJJi7?t&rpxCy{ z0Ml!kJ0NFho5|*xOl)c!sW1kzof#^AN|lmqw@A%6Q?LVj9=2E)@v<=0V-#@Z7#ME) zk2f*dgJD$F(P?eb49L|pc4W8FsKhz}l1mL6?agdHMalcroxtnmf)*t<4?W2C09OD2 z`v=esj>^@hR3dsV?uS=wI8Hg_-UU6U*~K|Ko3#o=i7LT&c4 zX7`s8i?-edPW2~K!iEZw3~}67V;vdnrZPka?~}1<-USa-6JO37O=C zjVU3tjb5<${;faOxo=04Wv!}GiRd@xAUU)jpke({-N5N90TH1YvyLh*8AnH3y<{E` zE9YDZa6PoLUA`(29u`aLqPB9^geF@IJ^=X{nJ3c~`gsUU5Mn!{Xe z#~ia}9-V&?0C$b&qKFnKR3elC5D*(MJ+6T2Jju${alHY~BXHFFJPH9L&tnj7;(07Q z?K+Qxt83@+aM#$#4*4Mq$Dy{4LJu7#FbX)Q(@ZT+Pk2^<1apdi6Q zghD|JgMo#EM?geEMnOeG$H2tG#=*rCE<&V!D~vSCUbDS0+GGi;k8}bIlc3b+V|zIGx22 zNg$T!s2-#wWaLsLOO@t>0Wv6L%9droGXKhvr^XwNcDb%rog41DX{-O#+wO>M{_m(U zHrQvsJ;C8^@I*!gA}0!BgHY$4an`x+ZtmJuX6|l^jEs$!_vrUe?>`YR+5c++UCR^W zBBRn&wDOzx`ENO}ldZ?}H>K6p(geBBEzu|v#;8eVjNXh@^GmvmCM%;#lbK$n(KS^W zwR(S}o0HYbu%Zbw?vLr-nyPe?o@lE%qIWcMAJbUQMf0002;l5*z& literal 0 HcmV?d00001 diff --git a/pandora_console/include/fonts/mem5YaGs126MiZpBA-UNirkOUuhp.woff2 b/pandora_console/include/fonts/mem5YaGs126MiZpBA-UNirkOUuhp.woff2 new file mode 100755 index 0000000000000000000000000000000000000000..a0965b7a8990500590bc11075cb66bb6161b49de GIT binary patch literal 14544 zcmV;>I4{R{Pew8T0RR91065S95dZ)H0BlSE061*`0RR9100000000000000000000 z0000Q78?*8bOvAmflLU2CJB!;5ey1}tXP4RWDA2l00A}vBm;(Q1Rw>2L{c>DJ`&Hum5Aq7xL{FNWM$vEr~Xk|;W zqp+H0pFHR?KOiiw-G57o)(To#83Y46F*TN z$y0IiWFJnI1+9Pxr%I|t!NdSWuu-w^oBMxfc4&cXJM*jD_!r?`8I3w z%&s9mozb3ad|0e; z#?-#gnO$$%m0^to1px&`1f%!I93lX+88P#D)u*UpV`Ir(9d`b;I?1C7zUSl-#0Y!< zDGi(t+;`}N&>;_ez!#v9IUettA5?+{Lc~dXhz6ut+j%+?LY8#P*6sAYf(-~tWp z*Xi6f7xmh%285`4VcI5qdmlGU;Hs$Wvsbc71ShtyE+D${$Xtrjc@Lnv zmh4m5P5}~Vh%-52(PmUOPLytZT2KknEF@dD?myKs>~bz2=hHm}ZKIvEi^k|QP0=WN z`v$JF|G*v=EM2!^BUA#L@n}z5X#23Ke{79!6pvS93hVz@M&Stl|JUE6zlZxh-RXAi zwNzd~9{bS$PoM(Pw222l>rP2Z^sDKsj!$9n$X3Ux1ikBU$IlGNf92!-nlQesZEGWb zQQrdY!mk_Da+-1_%24dhUx!-KBKdfNgf?_LbLB0$PB#89^j<}4)q(`CJ=AYBPYZ0MHiSjDTuY{FV*^I4g|p@1h^X) zMHUn;lw`DXwH}Ha=2oGL2=5|!Fm3^{6MM?NjYdzA=S|y8j8pWi>4Hzn=;CS~cI zcYrz%v`UomX>0!rB6I6%>C~W=ZGZx&=ZBm>27v<7-8T4QVcabr@R0`A9YGH_*VfS~ zwikmaHmFRsq4>$87AWq}d=;eQ42Ytf#N^a5B|Dv!RlT9X=9pu@CGx43+yVyKW6;2q zjs=|ZYCdb;&+@!5G$aApyPoDvbx7G%b)^id2Q)h4me*0@Y~NF-!g~ocimcR~MNLT) zxR{(jbMFA6wy+1(KA@%`f@}eHEN1Ro(90dQ_fLpSOHQ_vGxaRfH@3`4EFh$1y*Zzx zmZ4EdfMW1V5RyX0ED<=X%HZ!}R6ANsnGG2TN+H1oPXPbc;*HjL7#2_(djH&Spz3}q z3!KX(3co0&l4(ScDmWBcwn`8!(qV`jjSF=gv5z0LB1`dd}mFv_Omd($KxgJ(QLJWe7N_8)ACa zEji45Cjug60Eus2o~#wd0qD*BOmhrg3FKT)mV0viXu5%u5%Yn-v#mVyCsaCdqOG(4+-&=xMH}7h{qR^Ga{cSPj^md+|B0!h;GRRIn;oUx)KEQ0`9MSgKghmnM+q|VL(5Ln|-iH8Sh zThw(!dGxSF#`+eznWxM$7s-$iK-Teh)nc|Vp|6-tHFjiJq2)!p+|XR10$<0#sn1cS zcg6%J8=QxyC6l@+)Nu((|$L< z6$l#1M2xYeBx3?V+rrisGRLKX8$uuqa5HF_dbKviQ2CLP87!fM_u_UPmS<0a^ss|V zgzCtH$fGnIru%ckmNcM9tw`9(yJ;$@Mi3;9=4j60n2rusHnA_#G4VW$oOeOgui;}9 zT{Z_dvZ0UMIPQTg6BJ!M*x)3N!SWzd<1##>dVC$Fon%Qj?h|*Mug&i1Xef4Iy@P2u zwQ?G>C>UHyJbOc@x24;j+ZmXCdntv=Q%-@*;V|}a{UIGu2g3xw;>ub%RLFNE`@<_H z$9xBrYhpRVH%PlvYBge-VT$jx8ZzcEUlU9v zlKBYnQD(-QTgR|xH(e6l<#y{(^WM|$V^td{n)0ZwNl%nq=$CDZRWnr8L=$`t%yIo2 zQFp<=ly5PKy0#Difi>xuz7coffbmSGHGR*Z;9dMe5~5O zn!%x9IDCZ3z&4|E?5GI9pPot>#yu^*F@Tp-OW;Rb5>Sjfo)E8o_!o8Efz?YH!57Ut z-|;`SZoB@gbkBSv`$(;J%|lkfqWzp)6Kjvv*&B4nT6}qvD&$_r)!OBLA6a=Wt};4h zNmnxCGP_($c*p`K7yQ_M@oVy%Eog?f>;ex;bU zk`@J)ST6L~xjxHoWf{IC*StX2`Eq-k0zr!#j=`(nl8c#KF4TOfW*p}F1uTZD zwI{^4&H53^3S^)-z|c`Fg$iW1Lk+M_&=5^d(>sJ(ue%+ZQu1bWXa?iN!oiJ-(ETFE z8=vddTH`_*nR1pcqs#;*+HchJb?e0^yKyqYckuxwP}fkJE(*}a*fz2%@G|oNQypXv zP-7Q}PqR2&lUAv)EMXZ%<*4#*5-0}!u9Tb2ex)&06GV-Q4}WlFH+pk#?MJNP1Fdvb z3yX0A3e6Cp3_kqM9;{Nke+GrE|DsBDc+*&J9HY6M=$!P$v`VGOtSUJI&1DP>-Y%OC z^(AVhfP|pm@$y&YohvNIfwjdXL2NwPVivhBLdt`*7>5$$UutF8t1}x$GWkfaj32Vv zH1rqs2qv1+lH`{}dKD9RZ5`SmyiYiJqA-R)fh;&K8LN{DHScj!MTN94aVWzs`K|4= zjXSVcUeD2MyK3Kye0@rb?mmcb6St4*$~zakJqPBDK;ur zq;$kFnbg>RLh8T&WkHHd#zeo>r1om7a0!#$HYUR0HbMlktykB z@(^O}tA`;HwQdB*=agY)0NtSO>^khJEE6awIJFz0YaEVg=?I;G1>rJOgLNh~Qif^5 zl4b<5gaQgFlr2LGVk%)yuyhg+D(1Y8gGEPMsKkd-dlN@>KZ6{(U$8$KgS@lRK8Std zHrTUHP5O~qx4}9ccKQp(`hUoe-zI=H?0$4_+!(BxJ~4Av15h$Ix>IK~)|25+i!uLS zgO7Oi`WCjZjX5l8@NA-PxdE0Fa;Ckuk0qR{guBiPVuqT;mYT~kZ(b2NGHiD zEE@C18r&g?(7aw(Pae6`i5d5Pic^?|Vh6wGt)&F(Y6Vw)DY?HKU?sLi?rOW3}+kfGg_JdBoal|Zndt{z>FKhb;O(SC4 zLFPc)6~tskZW&f~rR6`oJHXYJ)x1RCZ;7PT8`NG1MhT4}$u~|ibZsr&#bMn7yRUT2 zQCFZ^HW%zH{5YdPg$~&`Q%Wk+Scg1Sdf0S$qq^n8^F>%g+o`Dc6WYRp{CW?>fP>vyNey<$n2qpD=t>Hff{RH%mizC<;9iCOMEeh z*uq1)J$nxQe}5i~GE?m;`Oa$oNZHoeS=nOl;Bsku&8(=VGDGbwxpg^jxOD#PTiHhb z=xS+K&6=nzJ&$x!YLMWrpU{csTwpV%9J3O5sOc*tz8f1Poh0}^j?_!4?yD~DEw1d7 zuY0I8lmfkD%6jSONCYvtK)t}5nP`EsLRz3~%@JrU5{bfGR6d}H(@~y_^HPLNN}nX1 zMf^GYofMIA7W(_!@02eQa>V~RIf*nn1d~*fklry70rvFIAw`pUNlectAGOGi7d|NX{HQGrA81vdsuMH#z! zySvESGH;P8ZFEcZDFgV*0cAqJcQP4;a7s!r;-XcGvI$nAQrDywAV7+6ju&LsDt+^(jMl3+mhg}yJ>N*mN;<%6E^*K5D&BV*1Xxr{gn1A+l^AIG@8;&Xy#r}Sa zPp=~<6N?kjDR7H$y`t(#Qvih?oUeavlK93U3C&vE_&k37C2MA1Us}4?zCB{-`QR?C&>XT4PC494R68 zM$uIl)7k_V({?O0R+XbH{toHcCh5ZWhi(6=;%}0tsG4v*GvMrsw>IC-Jau}ic$wZC zc5mjMzDjZLOs~S#8<|!xW}e`u?Q~rh7=ee{kiD&9aHf7p`!JUPdQj3pOWJiWg}=Rj zFwu^Zi*gPKw!eZjyoymcHLNN_qO6e!G!}tC*%}4CdR^>tdNU))hG55yU{SUzwsO5S zym@c!2Y3rTD1hMS-MDz&-{#74V`l+1RYB{HZg;c!uDFJl__L2LO`8rsA{$7)bT29k zAN}6L-Wx{4ja-fgrZ}M&KI|h?N$qGfxk8Cl@kd-^l-3>u*1U6zj?_D=1c++nj6^LK zUP`YbOZRwcMtcG;bB$0*N9ior^KTq%UtJF?^V}o-%H3|RJFfq$td2~KtP8njp?daj z?L>l#^%eIc+#M)RXtfjm*vKg}@J)+@UjNSi7|vnNLcB@+vZL2=AUT;>1N@ZxxQy7} zS6ENhB|A8z|LA24>Mfy3QVUYcXoIfzsOzltMY$bIX{!(*0?#vKzep6J{c`c16(pa7 z6(_s7yO`d0?2`X^#&;N%Ar!BqYcB>qmEA1+2sq`V<4wm;Y7A9gMi&?Dcnt5KgP!*Z z^tAm4r=pk*P%c#zMoQe(V%Rg*BQ$@DBYCQMTx060$#KxCsE$D9EF%Z|hxt7>9Ru+x zpcjA^U@zStZig`A)ENb%W(=K`fu#Id5hE>}b*T2-x&FlEALP*UT@b_kd!mX{edg;^ zfIxZW1_t_Mpv=AV%%<>cdwdUfcDXrOAM)-zddw@0EckWin^ zfkT+Wr;27E&(6;q(677|_cc68*+FjDgor7tdD~m-r2{mZPqx7T4sLU$RU1(2hQt*gIq8wpU)^sb{vA z+vJ3^y>@)hZsIB)bNQ5wr2UkY2Kxm*UjHEu;SS)W4N(Q=@b3aFa(s{Cd;_kko)En`(AFOQ@D!#$e~!{;wTT zAwEHq)_4)S*6Az#s{K-0DzMm`SWY?Uo~hc_{hz#?l4j}sy%6pziZzTjJ~xmlwOR@~SkRC36s_kaM;Nu&(J4PNH3ruqp|Vhhy_$5KikIVp8^Bp&X|{hJob#m^x} z-CY1TA1&AM6ipf?4d*u$SgpPxiCz}sUO$p!=Xj^M@i^i-3rCDu*(ne_gVH4z!kcQx z$Qd`OD3>;Ky2*)I3&VqHlkj|QYH@i+c24QC*pqW8%+v&KXg)A~Q&U6uFPEm~Nub%qVG~Y7Wyki(>(1V8 zT0igf^JS8c$ZWRqW*>dL8^h!ECN&`87zm!@9~U0zmQ_)o4}IE^ay1d3o7}S|MQsm? zm9QvScR2+7$KK&k#@uxy%=OK$Zk~9>Lj=SbqZm7uXUe9`6t5^>>gp(>%5Le?^OPL7$S#W^y{Vs_xnqs$>9rsZ2daA@ZW`vQCphUvs++VsItbkL zAo3Yod)Qa`-*B)wCV$uK)w6Z5w>9V!D`8Pa_c=u^&dx7yzwb!#OAc$f{i9N+Smh=G zQ|$SEy3UOY-i(Y0{jvS@UjjZ@X*CiJ1Y;u0q{DhCyp)QT+XwrpP)uo&yO^E{DLwk3 z)r|V4*}nXu79$%`^C?N}lsgk^*q|OM#PU1+Z#pwUC|jMGqk+AFSq%&JBUQ6Fq8YQ5 z>JMuF36~$FIxARPa15hNJ529O`>7Qm$l_mFS^IdK#DA)3Yl;jrPvoS#;8CcJ{GjH4k=&~!}~^+bc3asN=V zQKE>Qc(NvZGP8?D?VOj3SKHFk$`XmPwlG84A(3cXX@i~*F}nG*)Ab8$BJ=#e{w)Zv zigq;KtfEcVHya`A`j-}rO-&cy%|~SmJ3=kxBp0XqFsS|;=ET(}XGOP*C~ih6Hu7id zY%`w1xQy_@(c7colULggLt7y*zs$_InDkU{Lju7Qo|zsOm7ZznO^7x0Oihi6$xQXq zk4$#fPfw1CNl%4&wGzB?GTl9MGQB)=ay)UlIl9mcVR-c!>Bs9TNG+rWa`y5}utu;} zuxdZ=$9Fd--A@JjM*4*Mpp4v7w&--EEE!v!_Lw~6)_loJ#^eS;B^F{Z9ikaxouk@i zQc)jrH{UtmrkHfnwDBOz{2p3rLKSn8Ay?t8;UQV5nRZ1#YQRH5$t>8UKr0yThf2UV zs$VsAwc>J!H8j>#)_AX_@&Bi6tdpzzaok@mO(R1!eozz9dcYhOd!1Ak)R3T+B>bQ; zQZ;UN_tW!-Prl#J&oP6O0yMR5C@sw6aEnU|xcNog((IHAZhd1Nw>IrUob6~6muPM4 zkmzU;Yj10VLR(wg#F{%L%*EB%gghQbYak-R{R915LtE(rX^^G}GuK!xjmToNqWrwX zqzNiLbE;sNinE8C8wM+Rl1pdM5(ye+R>@1+S%OK&(hKtk3jqRB9VT6qVKCny`-wXs`<_Rv52a7vsbIxf{=5t z9~A}<&{O}Wh6{4S#pTCzF00Sy}xfw6*9LB z^;-siJL_{5U<@S&q%NniqeuEiD!XlSr1LFX-rG-{q!6=ygK$LrxM9wr3ndb*r(a>_%RBR=+LNf7!0a^=|h1(ZCJO;RY}S3}#}Xqi<~f=RB-#04!P(pp6R7 zcELmy)iRj@mq$s2p{aL{n^jPDl`010K<%;>DNf~?Gpdw$F-*F&t>Z--VlO+0+LXS- zP3yq5BL!BDw~DJzLd)405Oi*fCm;qVUG#af7X?VEw|XT_1n0lBapJHMvtjf<17AcB z81>~2fxG4g`a5O82sl37B{)fNL2wxkhiYu>@UpUQ^KYcti36K%N0)sbNd8pD6w4{U z1``LT?6>%3Pot~pQ|HhA<88_-=3C|MwfJ`ERoMwUsV;F;DQql#sm5gnw`&_|2aFUI85DVkBIaS#N*@9jgawKLw{PskjY7iv|9ftK0P@&I3*G9o17Tp zpPi8Dt2(HtG^iRFq)3rf&fJr=6}OVL5EsV?MiMXNr<3t=m^%g8%tjzG=|Waor7C7_ z{K`0IN=Huu{WVkDP4#nQeIXhV9kBoBGk!iZ%7OX@k+s8AOk|sXv8Grs6Loc$~6Z53`` zsC^`)#aCUE1JjZ(t}s|m*YEl)&!F(Lx+a%Lk_w(%TPgWVMfl4?gOlBG4JtxBcOCNJ zXHw5(Pi{&<&Y+AYlID8*bl&Iv#>#dK=e5|x4k0^VIpG0^t!E415aN%3iowtA%Krli zo($K=haR_^=-fEmpp+E{y_1cANH5f>%6Jplv%rFmz%sqSQwoRYnHT8Yyd5GMEDOxw znPh{)(x}}7Ug>IU2rQ4E2j|g-m1}bMx>ep-5etEZkP0jt4m{O$aNe?8D^Q^oSnwgR ztl;3h>aboWw=*(1m7ek>I`|c?`IUe4JN?!#|9kJvtsyfW^@R^YDD+j&f?wgTUs-Q{ zYiNv)H(D`{frX(OSYC$?&acxUTcTWh-I!NWUUK~k_xqJM`<;&7{7$!1pYj~z%_|j1 z>?`l3nO%q7Zq)^MF#je1CXxsJdLHrP@YR9CkR<&z_4S0|tL_<)hj)2nmjw2VLC69a zgtmZz{uJhkrX&a^|NHgmW9;-T0GA&`$e2pY%%cxXDxE^{fRISb_V0`Lzc<}-CV&^| zHEhP@nU$y3`?4vZ{aIHA3}~u9V@77jY2PkYc6i!=p+2Nn8EDapZhpGJt)(+E_=nTf4EF^T#_YK_=&hA*47e_D$yD;uPu&w_R0XqL5W02K|PD zS7$`<%jSNK;@WTHu`gL6tx{p?JaJrnQB8)3>5&mQvzl{VMe>Mkz&fc9rZLO;hGh3( zOjFuySBD3WiA=cIxMH{6u2yzKII=CR$_NAYn3Mnkc}=d@!8LgPcz0Aqm@G~NV|j!_ z3*3)}uO4x6*lF(44Z9?p#uKil;~`;mJ6OhPt3SDITLh#`aixThlfl2-6sDRQp&p}p1H`edghxXE?Anq z={7c1uhCJ!n=5&CcIwK*BQb^UwCtuw{K;mKFHhLnAmFNZTX$X5pTSY3JCPPDDU zmKh8o51ijYBVpHK;yxgo1ytlj(I7&A+mTgAhQen`R2cD-=h#p~VYCuM3a!UEFuEl? zX~Pv5V@l|$uFEM4fpd|DK}t!u|7y-lv!h+YV}yhk0BlY}j@p3q+HqYi+r9B1O_5JO#u_nGP> z^Z9ViJW4u;5+Yb$bM;foe_8ba6;bTg!D5M_e+)3NieSK=~S%Gb*bs}^fU!{mH|r_sF9Wr!b5gI zTH~2gaN|HsJbbA1rbqXarZsJ4b4?kc{{o-lwv~=8;S}=XLvkZqY|o{&<48rQ%0`Q0 zpj~{bSV%*wb(;@aef+<44^LsWkvg#{g6DaTtwA&w zHWfUB5u;=Cx!Ew9ex$VkPsK^ybD4t>{J)iZ1shV+wwn3W_~|TejA>qBj0QMe0n{#6 zXt!lu+YohV8@7#yE1oG$)e0E98rvBQz|bvMA93X3UlVgmVph&TV?D`vq0zM zkfDfCUNdn$iL+rQ0J0&)luyx<6RA3!xr3S)gy;mPzcaI%`k4Al#%?-juK`CRmp36(z$!n*!3YkqHDzDR`U_GL4840;?|i#`j?u zl6sGevl6Asn`}((o{cmB3L^)qB@i&t)J)}ic3TC3QzCm=@UG94U@J%@_ikKH_u*A9;kDL<-%cTq}?PzG~} zMR~6YUO8-#&fo5N8~(~=Z85vUEG2q8h^>GOX@g=9bkXe*#lh$OklB$7*%^|b7%Gug zS_aIb;Qgf&*{+%(G3R=VIXxao3nD|?L<`8DnHtV(ze(yeC5i(leVtxXbzf71bqzwd zO9X!T@1#>D^~=JBX;u^wbp#}ItgsxF{Z>J6C6}T?Lv0I&7sY{#5+(ke&Bci{@1K$? zqa*cwt;pYMjYPV`j zm^Sm|W(e9xN{Fm3~bI-EuHm@O0Fcy5Nt#%LAMfBJQQ(r@iE z`@w#+$Xvs|v5VDBcfSd4uEdc~l0sy5X{w!OMzb>S>mTcH`rH0b^MjE&^;m=a2511T zhT8m|a3M2_Dm8}?iN&IHoqJ=BE`e)GtUR}2USTHyBA7rF-#e?m^8ncNg)v@nF)y-Y zr20m-Jm8k^1#3D=gP^$Z$2*F^^otfC!depKc`vLQudUH9ZB)^>$Xk{No*H#d3D(NJOAHi4VxWS-bsEq=o| zSg11n>vT%DdCBz33Q7QEl{`|*Gr_hzVr`MeYh0C-PpM(!`2sJeW3$BOF-s;6hg~Ad zJTun>wk8CJK`_guR7@av$6~A3K9L;ivFGCe*%9MSb_}P6U&3ZzS;I68$U28Zh;(xzkVEG#QPKXc&O9Eaf&MtuE_fPLq>E%zf|KFyYjluL0L7?MV5Y`)krq zE2-Jwm;0MF`^DdDlIO@IxT0rmoTj7pRCXU~F%D_n)bA7PGfC;(H~{$sY|&1?$JOSM zq$}jdZYI=iG_$-1a1wIuKD5d4(Fwd3l>7T~p`-igb)zkgyy@*awC$`lL><$Vi(N&t zjOrkqcOL-MmeEs5i&tfmxB6A2TgFYOH2}6@1W7(!x@xW?6=4pZnAolWJ+Ry+&2-zJ zJP8lGM_~E7d5%Dmj!id>fBF-={{D;gi5TLz{V67Q^LH4=gPtH;q(3ZKO#u^{TH_{R zUplS$&4bIIQ|8!x?kaLFV_gEXe^7 zr3F_(``8tqgAwMC!2z{N`vE`C5+R#n_KHqG^@ z2EpgYC8}~B06fgc>459XX5-M-6MgP$S)S-KtoEGmg!k4ac|{K_0+_qwWszhb zB?)RrRE_zDWJ)jm6#}uYh@@ciAR(<&aH}=g=p>dT@R*Tuh$D~ZY}aHkweOo!DTG;*>>&fnSm zu%x`;d~bx-#XN(y_(?55$AnD}v|C-yU`q9nOmT%z#U(>LcH>HPHJy=#S{h!)*Ni?} z7RCILAEIb!=WKnRQI7A6OVqMoQiIDSOWK=DbP`|A__hh*CBXc+hgH^LP~}NOj*F!n zICrLu9pt5{A6BMXT=-7__H}!|wpO}z6-*)E6!h;WY2jY3B!(5YHEt%DCcg7gyu_h0 zz!U7Y{qK9TQ2z%Hd;9&(uUIjZWES82mYV^=yD5J$b0-ip2_BZG!uJ8WHB^&jamVZTjgNlO46KPieLZ4z{Dq0c0x7;FA-@TJiE z!-ySEM%_*3(b1up43iH)eK!uP;ZJu=(p`{ss6RmAkrWt$pUvRfEb{p^-)Q#mW>FcR z(VF2M4)P-8E|ir6YfC-nua3!h2wUf>lg1 z9`t3xV`K>Qoq1QOTto$sfP7MY#)3QS`oA+)7txV#Tzi)Ux_R&T_dCDs{~zDTzxV() z00N$VDFUFS=>Ilgqwv4>Yr;l;RN!gIN4087w0NQ`kI<0Sk~;2kl!`2DI$+;VdBhi4 znFs3%2Ia-FypTsqfMpqEsmVRb#85x3KXC8$@6=ajiev+IM)srqnmgBN9cx-+8p9 zo?4e1IaT(qfjYN9QlegG6>Zt0jo_!X171y%6rBIYLIP7Bp7IANOQ3BtZTu9$B~(@wlR^&Jg0(sE2IojS)cg0H+?+6L_A>K;;Nx;Jf4kK=(jQx~*BI__+(dmc6dV z@PKir1<>`y9uoy1E2Jb?Qvhk!L#|PKbt;mTJ+N-FZ7{D7RFe$nx&#SWE{||5%$VBO zuY-&*HGa7_`cVN4kk91f_)ICyUa8@{K47(1R~62S5m^3pKYLNFg#IMPqF zU@MYJ$FeGv=}}>1n4A~_9*nGj9M?o5)ENO7QYF`n=RRxH;hQtx-E_yId0o7CE8%0AuLVnv;ceTnshgiq z$R2uNhrbi=e*+#!VOvI`@J;=2&7wY>Z9%tXr|l8U9iK{QJyc;gS5%(79Cj?+hpZ zK)dk$Ul`!l22B|nj^iVhf2(=$@5yI}Z~~f-l7j>Jov@gu2F0C5G;NneC$8yS=)Bg+ zt!eGi)fFMSqP0b1qr4$?r=zX)XQJkFs&dhf`YTn}>eVOe3_s=!UxMpYxX!o*?i$B^ zwe(AStL47R;Ivj3UG(i`G|bXnMtedqni7phEv_;6guAZ4(;`}fYijW#GTrUOBzUvTP-v;~^NZD|+ys-rVZXX$2+op%{W$X1z umypt-!${Ty+F>c$Ysq(bO-QkhkK^(4$0sN82%~-s7)pVBjJKQz0000R?+d&D literal 0 HcmV?d00001 diff --git a/pandora_console/include/fonts/mem8YaGs126MiZpBA-UFVZ0b.woff2 b/pandora_console/include/fonts/mem8YaGs126MiZpBA-UFVZ0b.woff2 new file mode 100755 index 0000000000000000000000000000000000000000..c8050c25f8c907611553a7f8131f60dd10ad766a GIT binary patch literal 14048 zcmV<6HXq4%Pew8T0RR9105;$N5dZ)H0BA%205*UC0RR9100000000000000000000 z0000Q78?*8bOvAmflLU2A_2S_gzE41x(8 z-dPpwn2&(-5CkO6-(N)4X#Cm#-xBB;V!=HHm2bk4qR0@T9BuXP&}tl!!3J3rGEfVp zlcD1u^G!g*+MmthynEcUgOg7F&W@T(I+68P#l$j?ZC%+i31S_dft9Vz8Bl0583; zQdTfu+F8MjU^y_O_ye@f&YCz~YR^Cg1Dr}sd!itMjo6qqMj1U(6srN9$*>BUt5n>K zn*06Ye=bTF_20g)TJ}Kz1fxVzBkgEYa7c6Ss>|zY?ODgNbX(s4zrXruqmZYh$+KX7 zSmAUr*4+|Nq3bsSY+G6b|DR6(yV8I(qZyVo5*sM-Pn<-LyyPr7>&Hd&&M&I1>krf} zSAg9%_5NQ@ZDu4xSPqZ^qfX_5Qd9~&hEeUOl0omyBz=8S=-FK+Es%=Wy`1v3==9X< z^5Kd%Jndd{l+&D*WILYG8m>%FeD%q&(kk}#jESkhg88hRVqBmXAbt@AC3bE0M?@gO z5982eZhCwB6Hm|wO*O^GT;n=Yh*LN z=&B4XfC1jG&6+Koveneg-3yuJ#X%L@cK{OPxHBlx12iOluJqu_Llv=zirll}f5I&? z@_63PyL;7mL*A4(=dF2vK9XaRbHPrK8@e+x5hu}$MbQ> z0r~z>Gcr#9{`cbFSHE>U9D6wWaOk1vVavnnhcN@orw1W}Y{10PR@UYOJ zKym=d-_O^_+sl(k@W8v{ux_pxm*Akl0DnJUA8#)=R~Kg|M_U_fD@){ZF(0ek8m(l; zS^8V)V}l96p#aUM1utTPMYThm71N#SIJaP42sEOwS}(F%4Z2yxDC9*nqBSLw_!(_^ z_(!-68}vLn-+WC*;YS>!J-pJ88@hLtqVTu-YCLS{J8x1L{re&#ObsdIT zb$0?)nmZA)708*i+wEziJ2YK-oYeFTv=%yp8*C%GDM5?!swbLAl8>R_zyVhE>DT|L z;;h(&rCmmVL-7K?$)e0}Z@*y3*aoA?e*lN<@4vqBMktF5cpU_!0=OxytkCqB7beM& zre0!KM7`a3sK+;0k`4|g&x()&x*-8e-{;ZF1n;f_BkbU_s^3+-rVnF{RS5(w+KD3K zw!Flw)23B8e6eoqvmwY;Ad9YPSu$98r^nISt{38lyhF5(`8nc890epSY05j4fD zYC2?=EAm@10o|_K`l1W`P6Y89(CGG{OvVft{@=7%GFqT#jwrGK1xHJJc!w#@$(2D{CCOS|qOsa;q+vti z1BqRsIBL@xU!O|0$rS5Q;5VdLAR8HBMG`XJikd3h8%$CF79i`2-cw0h;5m9^>b}e( zsU`rbQ?Sz{&-_->u)$(G0%F$z>2D7|T`=7MjOKRcMclA5420+>ZTUIDq!N}@x>v>mqHgXY z5Wzba1uDD=u6$ORJN%hD*7Yqp>RIn$v~J4#FnCDRXvI||qC`A;j1x+_C-08s%uJEI zCgS}Wp67jhkPHzs#oPRIs`>~c)F;pvgLnv^q1fHrxQFAkkDCXjILQ^aWkI{?U`4)> zko+a08duqVXh}?Wm_Mgv1l`aQ+ncJBgleR%M3X@5t_TBW7ZDIUL5fLs5c=6>83tIn z$aTqc$(2PpOz}zl)*b_?+yJcn`m54n2GH4WO&fnJsarXHPh#kP=HwgIRfICspdgnU zk@aY(yy(ijzr{whIzT1q-1hprOPul5H=hOfhS>wL0qxmtE+o@B1-uwjTaQsRNz;j zG=k-w*l>n%Cv%^0Ap{nDCQ50+@b=eIWX-EAZBJAZil_#`8BZ`yy8I%giDoQBCU{qr zp!p;OXQoKD4lXx^@f4>C=1tB^m}PFoTgih6DXgp(DT*rnv<`*nOPP8Z_BiV4Si` zGNuzc+>TqiS#L}*p(w2e!2p_gC+=$2^Kl@-4Y1oHWD5mxi1v4c4JbgdO}@yHMnQtC z1wrnqBeJYqrBiYFXwb7WU>ZazRWS@0KuH{$7#D1h1u0#bM9BQgD2rFbtGJmpL%`rL zWnHkLoh?)wKa`q&9G9SS^{F!hn@`@1X&Hw^sYr-UfhCfZUGs|YN(yFNf*inxZ@=OZ(X z9xnjX=_>X&dhjDGr?QN|U9FzkO8>|Ve~Og3+of7{w@xEKrg+{dd}j+--aZ6XbpK^h zFK(8yS`5c|+5BuztUD!Ih`1c!Rl&=NyI;)tjea0Z!d(kG-AZK zLbU3BJFG?>0&)4g77VfmSRT!AK3p#|18kFn zq1JtUq2lP)tcd68HNmdf4OF;ly3s2ZRn2L@Vu~=K*z8C%CPlGtrnc0t)px`B6c=-v zEod4Rt0D(0$tW_pVJ4aORqp7_#**W#fu3Yn$k^>Uk}*}>5^ctUP7;*kiEZ6js57li zgk-Qe!xf9V8)A@GYF#m--6&+TjHA*UGeqWP+qjUj{|V~z0=tmF0G2Rj<9>)I-?u5o z28~n(YLzt#(8$Z*mMqx@)l7-qD%MbFu~nDZMj#o~OJ=RN*kV?k0!#({{VyuYY-)0R zC)-bd&Sbm7R(AwIP1?_?CDy5v{!@Oz{Gk8V^$VX}e{K1gPGj+bp3r!Pb7dh@)i^nJ zaf57?sgp-{!SmG1+q>D0G%qKVp`V5LT~lreX_ujF<{5oj5@ZjkFtj6A3|$(-E>FT- z8`m&ix7FzU9>qUN~GkwFiN zLX4EKN}lR5eHmEBK@PgBg~hfYRtQ!(Z5vXcpj$7(#0A2}$s)!thCdV5yq9$W8w;rO zu@|JSozA(b{7msd|6+_r-jd+jx@v7WD$2Z2kp0ruOQWwnnc?Ahm4k7bF9L?^>p~A6 zOh%~7W=Jl4=Y*K5XqB;%!i=vDVKkp-Dq)!Px0vgz*qO(gHR(6yQya@iZ!zXS4)6ZY zY-sh!mEMNoPhjLv^yp`8^e@Wz7x$lHpU~8LdML+|v^6xNJoSh5Cf;~MZH{1bcF=B# zaAZ{-7*OljK?`d#<7;cDZ->~8k9!b{cx}HSba_PEMk&b>kw@{!+5ez({BJ(U2c;&+ zvI}ss)Kfyr6oSEzpik63wR2lD{k{2D->@es@z%J=Yf`zAq7~nyoR?PRm-0G{$Npqf zZ}h)vA)nOC@=*+r95<2k?e#@Q!<=M{+++7E2`qY&Tgw`d)(Es!A7xR!cn|>& zI`*+F8EPgPzPBGuFQEsxAgVykFqA9SetE+uFs2v&9E{R~X>5Bxj56qYa5llf` zgkygX6A9y8T1RUX#hU)0V5-VwG(xR_1@^9P+mg^Y81y8#M^O-{u!DjQ6uLT+ewh;> zK6X9=3Rf)1Ay=gFzURiQl$TWC?(y~!D)j?3nZ*Ccd@-oIH>Jv`A!lcZuntRI@{HLMc@ZoXMrGr!B+ln;C^&8t)Vt^&97sE+2)#`8r zd8Yi&0jL-;6=>y3w&G)M+~D4ulxVyuc}80^a?|e&fIPGeo4bz@j&MsC2Si6CCF1k) z!#EVX#eu(nx)ae6Ma&yYAcTe%!#NN2j8KZ+VHB!aY22a2h@?Xh*cm4wh=YNFexk7vzX$ySiNeL<9dl$IZ}(}9x~_MJjlsxS zNwa=UyKBE_cK0X<4msnQP(=1giU|&*Mk|TqKX>uP15_*}6rSjsDd6J&WLM44BnCz~ z#TuvDx7`|;=(`|lO|KAlMzoa|x`{O62C;hFW|+~-xv9+5uavg!4;v)B{^F>Std#^y zjbnZF*Bh3;eQcIiUG8Zb;@{C#wpJ9}X&mUOy41Y*>1)GM{q?@4asINdxrQ37s+Ouf zTcH2beI#-swL5hp^0Rx6zV2)}6;@?!wxQWs)j3=}ET|HUR+~lczS5451)=GMI>{J> z3grm-A@4o!NP8;Q31{zs!C_rp-R)6sC$)~xN{rMcBKW`As&4B~^7k@-eE2?$QM60{ zw)bNs;xpBy)kr96F>!Qkfrx~yV6%IDN7;%@ob$#=2%Qb9fk1E6pJ7i-oo=_SCui1j zizt1L@xCE6>A>Fd+x6+{jze23E_R?#@RKj1YC5Ot^*|HqLo-clhQBGZt{a8JyP_-~ zSjXg>@9%4DpC!IM?iMS^#L1iI&LXp;yL5wWY(}>EM2Li;;lQFz z_zn~3n4|UHTJi6HS}NPCoEq7?^L+RIi$CbAJ4%7?=Ic7AhZ-BtHHNnmLrd_>!qVmsPy;9Fcc0@eQH!rJVFh|JP1*E+|n%80~O0O08|sD46dp087@ta-YD#of-`YzRS@{)j zr3bxNZLcExKs5&^cO$okFHT29ael?KR_ouHREwal$PBOSt8_5ry8>7;*ZMOa;+d_N z`YQA49B*xmI{Bqp#wT(+7L=&o4T;ZvNAPha)aLUX! z{KsXV&iAlz3rg4LBH<(r@R`c zB|b|l&!5P+{#TPRVrrV(#FZ3ZBBEwdpEWR=1}b)c@^9I+w%a|!MpdLfA0(eV|M1la z*`x8Ck4X^wZ5p?T-U=`~t_S7j&V=gg8y@@FuwspXnf+lU?9!^8vmMnIrNePx4!?hj zG^5(1km#HLeVS)NK0>>^=~W3YB*7u#*YBi3uB~^-=au2kI%Z&m7O%nRriTOR6ENH% zJ6UlC!&F)7FiQDMRCps^)h9kFo4#WbfZ1^M+N$2$1-09}3TKjGTWy{$}459?6Y=dH=+L&j`Ty=Kml+fBlJonf|c;^7S928NN*AspX!| zs0;g_?)i{!FZj=;jlGRmYNc1vl;=;he`hYaQc{2F5@TuP(TwPr+W(<79srhBjG&1% z4bs?X>&Ca@fx7y};o>V#2pB`o4bAOO^kg?-7<2=kGCXpI>FpF#M`}dfBaF}Y4*fg7 z_DJG~ZWeouRJ1dby=`O4{JGXINu!t0)x!W|w$e^$UxAQXCDVT$*8_pT2LFr?Upzm5 z>*j^|+jDbJ%pJ*j@OQ}|_>M%ZE;nu8XUI41weQi1@CP<%GdI*Qs5^4%rBUgsaPpc{VlCE1QZ?^f|bunj7~^I zMhX&D{hk4iE*7f> zfIC2>q&`Ak|J*=__t8Ta6mTWfyu8X$GP1}YejO2e`|{ZJ51-pRCWrX(=l0#%H=e-^ z&xrJZy$FA}XL9i1C)k7ZNnb~jicw8Az;dFzV#Ndyv;SVzaO=(2ulaX}`K?da9<;9E z5>@x)Au6gM_;}?It_F6HYE+IP*ZGw1Euq z_RYJ&I92`cKv*lKW^JJ$J?s>YH%~82SLk4CFI zI)9YgLD~DQeZ}D{>B803d#GR$K{R7#&w`n?+S#?4!Lp2D@1qARaH?2eLSV>0qE9$w zk4Tu71=)HuBrZ1V&ZYH7EGb)|AYCAY4Tbi$iVT}z>Jw?i`2(j)PqVW+nx`%#h+gk; zc4x!IEf*1?LZ=mE={FpfCgXbnWF2%NKKtU_)%AP$4lWz*zVM(#f29BUQ2O0@`4L3m zji4$AEcTjrD)VK=RFq+RuMQ&62!-{5U;Fz9A8o7+K0McdZp&;;)dcRka&+)55x{y@ zXtaV{!iM~)k3N_mIQR*6aA#+*^@7YIR3m0o*Yk35sppZ4PnM{CN`4*sszW-Y(!W(J zyoUu7TUDn1^_t_}#oP{Vtid3I+4Po{g7|01|LHR$0`F2t5+WfNU3 zmf~$|(KqqjdYdCG3zAA!@o36n*h#;dv;Lhp_qQ?soh&)YiH}T0tKBBdOXl#dOIw)3 zD>a*x?u!+7h})N1ibKzS3{!02U-;|jRnp#M^VMuYWbM(9M7!FY~AMSiiZ?T@-M=iHAAqxDmoNrw+)eV{~YIFrwsj31kN! z34f%V#G=q-YOctv3<<1K3PW>hOJtao7-Yxxh@|?Z!VS~yrzR>-O|~ucU#Zmsigc}p z(n&M6>5b*ElOvw~oSyWsN4dMe zohCn}oM=*5;4Cj1TtEERKh@5o6+%zhTJS#W>N4c1(cbl6HoF!FYHJ-%!p=#r4w0S8 z_}=yT1^G3mqGHjL1WW}HeoUZHd*AZgv%AH2ou;4NC!Al;Bc_#CM^ehmk_qhML;|-g zio&TR(y~g4N$he8gCtmxtw_>Glj* zEs7K7N^gwyDNPYM$#VTplbcS@*_#?2l6!mNQUXmXM#RdUmP@j;C7A@ZW#Pb);HWHoP+OHwNE-{MAE_V3!iTh( zyESVbs^r*J9b5mi-ajS);}wL7Oq;6k56tt{+pQX0j;)Am$yX2wO5Bb(cC+zFOp=;P zvC0v}Z_RA+ESo(mE)68rHIf6%Dl-gr0EYk?0J|NJ9=>))5hP21PqoN;yz z7@V6o{)*R}0mt%E+fWN>^NxQ0rZ#Y2bjIP3DXI-)#ss1cmDFc&uoQ)`posD)w`ef@ z#cAQNq^)W2LT~?oxSc1QmFdk3&rM0CT=cw3aaiz}$PYx`3U1AA+-&sQhm=Oog0+_qkuo(|6Q#`@LSEZ;-Xz=iP5 z=2QyW1ntwL{46mAWB*z{zb*gA)wmE){bGmPyy&>-*vROiUu+a5Dj{y!BsxAJCQjSG z?0(-I464cYP3KSDIprTdY-^p7G3D8Qsm<4GxC*Oo68b&L>qTQ@`S z5Z=xQSsj(wnb>nWO}+kl|I_p< zid7DjP9w5OOAxdLoM>3^#=q!xYI*XGee!El!0+c-$c)Xr{sT-$u(6ssz{nnqc-R+2m1*WdimR%f${+A3Qpt5 zEV@r5`%F9F2RvK?rWZMj(S{SmIL^2y@C)7%~vgrc|0JrSS?(Pgwkn1{|_`+1oK^W}lvYI3`I_2hov z=+CYOl?Gr#HNqo?o0dZ1V3NW#4z~Mjo3@$i_&DA^`zK&+Y7QWO(t^R6!FuGd7&U0Y zJ7?xBgYmkxx{C(;DEN8m?>1#Pf(p}K=)L#_2o>4tU!6q#sChZ13U+g#99}V>L zHrJjAHqVJ#wsEwF#SQ(+XTe>i{XvIse;QViSezmX%P1=-(aa99DPvb~0#HmXURe3tUu zbq%(UYRBJrY5O2oF<+1209J`HFL_2f#im=D;n7OAxrOl$jVnqeLI>RcK9^RQk;=@^ z&t{xSOQ*9{-S`c3bd@c`03EaM61z-Ey?@$NU4UD!S4i@#|0V17uQa|e@*t%9^zBVc zc&=?TF(dE5Do#YN@U$I?l#fOVO=yb)?@p~L#aFEjqU+SX>f;c>4Lv>cbW>G(c(un+ z^&@XG@z-ZPzPn=mcc+t3bH^6*co=h{2}o-P0W&TEPPfO@N{$9NEN_4mTx}+&cNTa; zTz?1JTJmZWtm7z7K0t;VdeRzXzvY;2^=4+crELK3udCE-5@nz%v|) z+z1J~o)!Kf-a^E4LZlx<4u2XV{M~%$Xw)5}mWYmeP%JwVgornVNJpE6wb3hLTyIIs zDqI|VxU>u$BrH3l{#>~>x=EJ{|27N}?+TGNh8+ICS=iwY2?_r^M0_Mf+S)Aab5laZ ztv=z%LY4++L8kyGeVIoXX#0`WMuN1;3P2}pgeT+{l?#{lHvAtpd0^?SOWQ!Cs^jUR;7ocD2 zJ6KNA9i$U9$@(e47t=N8Hm{4He%6)P`4%S6SJ59D+Z3S$?5~6p;_nGN$$bE!mcn{sv ztFFK~vqHqKRhBgSyzGYr`x6{t!xbTZNBIqE0;+g5o2R(c@?96nD=^l)r!MRVg?>yV zCuvFWh${}$X>!No;qd8ar)h6tnsUmR2OvZU1xVzVpJlXJWfhKH42p(6$QU1cK0Rpba}nM-QO(LrtVAj z;^ibRCaW&;xy+PO4vxA$l*Jc?arl1sp!fPc^Bb-yOuHz=1n{JOl|UAn!EEqvU~7Bmclw=%IcTYz{$`+4b0|T-J6V zT#(-?R=nBRc>Drw2vzKRQmiweK)J|$kWuus2N`0glz?z-uZofxyo%(sHT(^eWbNO= ztf{6jcHM$c67af^^wkv#Wn1)y5cqmMOxbn9Clljcpp#1eDpbFpsUys}Yz$VO^N4iv z78|WQlz8S%Fh01IlRK1YwB>0Y5I%3gz5(EuqIyd~X$eN7Oa+F&l2v1~`5eGcXtNgC zaPf|87k+6Cu;OlY%J!#lE_Qf`-5Z^)C_zKMIfz#UU1 zoysjV%pJWr%57NHO8IK%m=cjoh1$q6a-3QfzM+Hjj!e;vA`h)QIp1m zI;V+<5)<@Cij=BHC^>|B{t+khu7zaw&?)?K2XJpz!v|KS;THxARpRzel*`)}>c>gm z0=&-EEqT1^)hqnd)Mo7#`|$y7_I4E9S;gddVw3&_$0`R>++t%fXm6%7?z!G-#l;4>S)_WetJmmpz_3kO)ghQG2UczAXm)I*c1-a}<>12M%pYa* zRHFoADjXr`p2%l}Wf-ms_Yq#0QJzTP=8#f-Jfg+U=~2v-@M=bVOcaC^K>X@+aLQ1@ z`F4yfPwO}y&Qg5dL(4$`EoI6I(Gz_&$;@V~fJKBLqR?6b13c!O<7Yg1vp(H0VLuRz zG9>pmGQ0#3PIBHOX?43G#pVmdW;p#t4Z^Ljk$2yfI3-z17M-ktNmM+O)iEy@5N9Wd zv;K}?JNDoOVDAZj*oXm@Wy{-^7{$IJ5P~U9h?JN^G!{O>T6Q^@biSHlB5q`}vuWY0 zN6&n^sg^`ia$pE^HejyKi~H1T-Zq6&8uykXiYk#~c9b1tVyZd8YmG}zFR*_qP1LDz zOi(h`78r+Pcxl826Oxow)YgP4j5MLg!Kx<#!KRKqy<{SY;rpQ_kL^dO48qUP2ka%n z3=VZ}umyDx2RteM#7E^w$mvn3J$|3%UtM6sMNb2$VWM_6cZCKJ6^`+=I-E7+y~wc@8m-7G9x@j^adh5>Y=aPh`dxc& z<>;_zeAkj(h&hgpm6ww1Cmf`vPkf>oA=yhAF^++q-yQGBbzi?)i}9!A-bbFqZx-FS zuK6#%)6ZM{IcECz6Z|&4*6A45>+3kcMbYl`#LkqroGjb!ur3is2RvS!{YbnEff6A^ ztgH-`V%_00XE-1(W<#GwA`j8T1_uaHvoiTix{(B_{QGhLR=PgRY6x3Xn%_`93M2Fh z@HI+9wjwf$CwI$&7Y#Bw0ca*o+46$)$l(W!p1LikREq;dBDc)kdb%p?b{A8IJLZ;X zweHHIa5a{jJR57{HA5GPu;L?b|5zQSQ;ducxkMs6T3HCz3?Xx7n(1N{57J<#H80iS zydmR7qLXeUuQO~Gu3YLCOPpaGmud&PF&)mJGbM$-h&i1!bDF+HO;ek?YSRYY4?`)v zPt@VwNcbe>>YXN$ET-fpm+6YMs3g`-k;HSEXl$boARe8&4Q1A|i#j|s9GN_4S?mb! z1NX*1p+2@w@aav==5KNrkM5I4J`p9&yeNgNEzLFF3(CxrfR!3$lJ`zTN~LO~5z~k{ z@Y%6h+Yg~slBG&Gbxb2HP8_75klBrdc#xhp-Bb#B!O>{Rq3Sri1}stg8F`k%b@{`* zSlXJSPiRD+&TP3YPTe$F02pnDkY&CY{5d3BW~!+vxbxC&_zXb1XUQoD?=G&P@0HpJ zx*UrwMYSQNaK8+s_q7urp{}XNPZWnenCeefe}cDhA=zYub9TZGe)F%zw(?BY)6&M->d7#Qs;=I{w%UU?Z}An7FQ+%+ zd7Ki>rg9Do1;eYWu_)FF9H!|oyFK=+Q%TNEkmw?pohp)0aW&ZJyF)M++K)cgv-Tod zsMy2l(n->A7et)B{wjJ*J)4Cnlw?x})DW=wWoaM4)9c|?T@Qldj{fXapdY{JZs?rN zw@=IqW}aXWZuGFU-(Rvv>ENnbqlLlY>QPa*4M-ox(f-Kv33>U73Un>5M2v1+EV^** ze(9$c!{hZJCWtzw?SZyDqIDdPe?9Lw?{x{Np_pqQ-&y~Sylu-4HE29D3(-`a;@}}|=aX2hG;R&67ivw#NW`}W1nk(%uU!g8~)vTw7!K?^c8_-~1Iz82gj@5Jkfb__XF`4AJaH7_E;+sfmL7 z!0G+keX@RQ#cwyt=GMpFr_Fqn=}qT|F+Np;rPG&soU;5{GqaHJ6dHJ+r+F1dDJd zO=8|IP(CT#-d~P}oKUqTQ97xtRmKR9=Nd%HPv3)h7orT7<47l5dqv~Fzct*w|g0rbBf;KlRm zIeI)@!^+;hs%w0Atg7)Y1O4Zx?alV)Onr~>p1A0@TYRXtM35&&1t z+<-A%@4QK4m*>1Qw*%_)5eCiAXL)rWTT9zI*tVr@dt+Nh`=icgw9SpN)UK8eY%5BJ z;^i5(qHqSCaSDkX^?qygmX>_laULpeY<#V#o_!B;>M6ONYj;79$a$Dj8DG7T&X#uY z7n0zU^EEG;{)#VSs@z(x4@J?fQ~dk1-(|Zqx8<2why3A|*vwQ5vN!{}nw#bZReVxz z>pTjErZf4qadBZZF{ygxPKArN*n-YW94E;M7FSvz1+Bi!YO%lmfQDT^=ui~&Rc+b7 zhlB|EL5up}yU4HB^%oxYCRC#|3n`Z$py{D-MXaO}gW7Fq;4T{ zA7g1u`)2X;=imQm>2-TB1?OJAUiKSe8u| zo1LyK=BI&fcUh>yd(u7Whkp7I$Cr8-hr@sv?}uveiv_&3NW6N>*Kn2&)?WA_n)4~a z5~xfp6|eqTPBLSbHFu?&r?-?=t;zw`fc(dY`)4)v z^dMl(mXm@d|5uR#bo!~zxnWgtfV{i27I@7Ir#nE^Y^BpYDg6d|9K*?C0cxdl^%X3S zpAz4N3ZJ&hEj;Sy-s`JHG@j?HdzyC$H!kakr= z`!&*PLoP$<3VIQg79*x!1(gly>=&ODVQqlIx)h?%1FBM5H8`4n=PuR}z+CHCEd!#T z1Jq0bxr!)1(u2lPl?~D6jeoW*CRUrMdSS9%z*Iz|p)<@K^s1a`y)v1sRmqN-N5dt>IkaZc(28Ztzu3#e$`7Z zQod$zI9@WGXjyno8zkg4`1V^mIbaUo&R3BCZi8a$1ccWO#jt7lOWif)(Z^0aOh+;4XwR*q@NrZygvr2EOT@ z9E>s)a>VaHV+j!*)=ZWaGFI4N}Xo7x<1-GsI zQBg=6OgnRqHuzgmEz+7P8ZVm!s7?Jtd3k2LOgOWT9?X*`sLdihUvGE{GJuoupdVMnq|85RTL9_Vt%fx9BdE($qIMmY{n z^hN`xRtuirA^2pOOI;o2tB_6;-7V?|I+$@dQgNCl%WDus6ibX&~(I6s??~{ph=51 z9mnX>qt5`CAtS~hpiG!DV-5!HI7?QnAt0fkonXV39eWNOIdOK93k+9ouyEYrc_1M2 zFh!iDSj98=kmEpLe%^T(FR6A>kFesCPHd?bU_=2h0 zaozINXDl=9JHFyORv9BTZ(N*s4HDdwXu+bll5AMDWlOs>Ae1!_k=~b-A86`g0bJ4a*QyzNa7t>})oOheptUD@j{MB+BO|*{L6%??U>60?pm)$V`qx?rn@OC(J^V0jw;ads<#yA3 z=)18B_!F>O@e1Bpfh;$Uf|XU7VtikHc<&x6&--w^C4tT>D{V|@%%_v6tX_D*ac;fv S;!94Je$jcs3Lw8Xr*8q*m{%hJ literal 0 HcmV?d00001 diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index f0163384ba..8520038f49 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -836,6 +836,10 @@ function config_update_config() $error_update[] = __('Custom logo'); } + if (!config_update_value('custom_logo_collapsed', (string) get_parameter('custom_logo_collapsed'))) { + $error_update[] = __('Custom logo collapsed'); + } + if (!config_update_value('custom_logo_white_bg', (string) get_parameter('custom_logo_white_bg'))) { $error_update[] = __('Custom logo white background'); } @@ -1750,7 +1754,11 @@ function config_process_config() } if (!isset($config['custom_logo'])) { - config_update_value('custom_logo', 'pandora_logo_head_4.png'); + config_update_value('custom_logo', 'pandora_logo_head_green.png'); + } + + if (!isset($config['custom_logo_collapsed'])) { + config_update_value('custom_logo_collapsed', 'pandora_logo_green_collapsed.png'); } if (!isset($config['custom_logo_white_bg'])) { diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index bef097c7c5..cd8ca9bbd4 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -377,7 +377,7 @@ function menu_print_menu(&$menu) $length = strlen(__($main['text'])); $padding_top = ( $length >= 18) ? 6 : 12; - $output .= ''; + $output .= ''; // Add the notification ball if defined if (isset($main['notification'])) { $output .= '
          '.$main['notification'].'
          '; diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index c591e749af..cf8e88bae7 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -16,6 +16,11 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +.operation .menu_icon ul.submenu > li, +.godmode .menu_icon ul.submenu > li { + background-color: #282828; +} + .menu { border-width: 0px 0px 0px 0px; border-style: none; @@ -34,8 +39,8 @@ } .menu li a { - color: #FFFFFF; - text-decoration:none; + color: #ffffff; + text-decoration: none; } li:hover ul { @@ -43,10 +48,12 @@ li:hover ul { } .submenu_text { - padding: 10.5px; - margin-left: 0px; - width: 100%; - color: #fff; + padding: 10.5px; + margin-left: 0px; + width: 100%; + color: #91a2a7; + font-family: "Open Sans", sans-serif; + font-size: 10pt; } .menu li.subselected a { @@ -61,7 +68,7 @@ li:hover ul { margin: 0px 0px 0px 0px; position: absolute; z-index: 999; - left: 44px; + /*left: 44px;*/ min-height: 35px; height: 35px; width: 180px; @@ -78,9 +85,10 @@ li:hover ul { height: 35px; width: 180px; font-weight: normal !important; + background-color: #202020; } .sub_subMenu.selected { - font-weight: bold !important; + font-weight: 600 !important; } .submenu2 li a { @@ -117,6 +125,18 @@ li:hover ul { margin-bottom: 0px !important; box-shadow: inset 4px 0 #80ba27 !important; } +.selected.submenu_selected { + background-color: #202020 !important; +} + +li.submenu_selected.selected { + background-color: #202020 !important; + font-weight: 600; +} + +li.sub_subMenu.selected { + background-color: #161616 !important; +} .menu .menu_icon, .menu li.links { @@ -132,21 +152,21 @@ li:hover ul { /* Icons specified here */ #icon_oper-networkconsole { - background: url(../../images/op_network.menu.png) no-repeat 50% 50%; + background: url(../../images/op_network.menu_gray.png) no-repeat; } #icon_oper-agents { border-top-right-radius: 5px; border-right-style: solid; border-right-width: 0px; - background: url(../../images/op_monitoring.menu.png) no-repeat 50% 50%; + background: url(../../images/op_monitoring.menu_gray.png) no-repeat; } #icon_oper-events { - background: url(../../images/op_events.menu.png) no-repeat 50% 50%; + background: url(../../images/op_events.menu_gray.png) no-repeat; } /* users */ #icon_oper-users { - background: url(../../images/op_workspace.menu.png) no-repeat 50% 50%; + background: url(../../images/op_workspace.menu_gray.png) no-repeat; } /* trap console */ #icon_oper-snmpc, @@ -154,7 +174,7 @@ li:hover ul { background: url(../../images/op_snmp.menu.png) no-repeat 50% 50%; } #icon_oper-reporting { - background: url(../../images/op_reporting.menu.png) no-repeat 50% 50%; + background: url(../../images/op_reporting.menu_gray.png) no-repeat; } #icon_oper-gismaps { background: url(../../images/op_gis.menu.png) no-repeat 50% 50%; @@ -163,45 +183,43 @@ li:hover ul { background: url(../../images/op_netflow.menu.png) no-repeat 50% 50%; } #icon_oper-extensions { - background: url(../../images/extensions.menu.png) no-repeat 50% 50%; + background: url(../../images/extensions.menu_gray.png) no-repeat; } /* Godmode images */ #icon_god-resources { - background: url(../../images/gm_resources.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_resources.menu_gray.png) no-repeat; } #icon_god-configuration { - background: url(../../images/gm_configuration.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_configuration.menu_gray.png) no-repeat; } #icon_god-alerts { - background: url(../../images/gm_alerts.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_alerts.menu_gray.png) no-repeat; } #icon_god-users { - background: url(../../images/gm_users.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_users.menu_gray.png) no-repeat; } #icon_god-reporting { background: url(../../images/reporting_edit.menu.png) no-repeat 50% 50%; } #icon_god-servers { - background: url(../../images/gm_servers.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_servers.menu_gray.png) no-repeat; } #icon_god-setup { - background: url(../../images/gm_setup.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_setup.menu_gray.png) no-repeat; } #icon_god-events { - background: url(../../images/gm_events.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_events.menu_gray.png) no-repeat; } #icon_god-extensions { - background: url(../../images/builder.menu.png) no-repeat 50% 50%; + background: url(../../images/builder.menu_gray.png) no-repeat; } #icon_god-links { - border-top: 4px solid #777 !important; - border-color: #777; - background: url(../../images/links.menu.png) no-repeat 50% 50%; + background: url(../../images/links.menu_gray.png) no-repeat; } #icon_god-um_messages { border-color: #777; - background: url(../../images/um_messages.menu.png) no-repeat 50% 50%; + background: url(../../images/um_messages.menu_gray.png) no-repeat; } #menu_container { @@ -258,95 +276,90 @@ ul li a:hover { } /* Hover Styles */ /*li ul li a { padding: 2px 5px; } Sub Menu Styles */ - - /* * --------------------------------------------------------------------- * - MAIN LEFT MENU and SUBMENU - * --------------------------------------------------------------------- */ -.menu li.selected { - font-weight: bold; + +.menu_icon { + transition-property: background-color; + transition-duration: 0.5s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color; + -webkit-transition-duration: 0.5s; + -webkit-transition-timing-function: ease-out; + -moz-transition-property: background-color; + -moz-transition-duration: 0.5s; + -moz-transition-timing-function: ease-out; + -o-transition-property: background-color; + -o-transition-duration: 0.5s; + -o-transition-timing-function: ease-out; } -.menu_icon{ - transition-property: background-color; - transition-duration: 0.5s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color; - -webkit-transition-duration: 0.5s; - -webkit-transition-timing-function: ease-out; - -moz-transition-property: background-color; - -moz-transition-duration: 0.5s; - -moz-transition-timing-function: ease-out; - -o-transition-property: background-color; - -o-transition-duration: 0.5s; - -o-transition-timing-function: ease-out; +.menu_icon:hover { + transition-property: background-color; + transition-duration: 0.5s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color; + -webkit-transition-duration: 0.5s; + -webkit-transition-timing-function: ease-out; + -moz-transition-property: background-color; + -moz-transition-duration: 0.5s; + -moz-transition-timing-function: ease-out; + -o-transition-property: background-color; + -o-transition-duration: 0.5s; + -o-transition-timing-function: ease-out; + background-color: #282828 !important; } - -.menu_icon:hover{ - transition-property: background-color; - transition-duration: 0.5s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color; - -webkit-transition-duration: 0.5s; - -webkit-transition-timing-function: ease-out; - -moz-transition-property: background-color; - -moz-transition-duration: 0.5s; - -moz-transition-timing-function: ease-out; - -o-transition-property: background-color; - -o-transition-duration: 0.5s; - -o-transition-timing-function: ease-out; - background-color: #585858 !important; +.submenu_not_selected:hover { + transition-property: background-color; + transition-duration: 0.5s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color; + -webkit-transition-duration: 0.5s; + -webkit-transition-timing-function: ease-out; + -moz-transition-property: background-color; + -moz-transition-duration: 0.5s; + -moz-transition-timing-function: ease-out; + -o-transition-property: background-color; + -o-transition-duration: 0.5s; + -o-transition-timing-function: ease-out; + background-color: #202020 !important; } -.submenu_not_selected:hover{ - transition-property: background-color; - transition-duration: 0.5s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color; - -webkit-transition-duration: 0.5s; - -webkit-transition-timing-function: ease-out; - -moz-transition-property: background-color; - -moz-transition-duration: 0.5s; - -moz-transition-timing-function: ease-out; - -o-transition-property: background-color; - -o-transition-duration: 0.5s; - -o-transition-timing-function: ease-out; - background-color: #585858 !important; +.submenu_selected:hover { + background-color: #202020 !important; } -.submenu_selected:hover{ - background-color: #585858 !important; +.sub_subMenu { + transition-property: background-color; + transition-duration: 0.5s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color; + -webkit-transition-duration: 0.5s; + -webkit-transition-timing-function: ease-out; + -moz-transition-property: background-color; + -moz-transition-duration: 0.5s; + -moz-transition-timing-function: ease-out; + -o-transition-property: background-color; + -o-transition-duration: 0.5s; } -.sub_subMenu{ - transition-property: background-color; - transition-duration: 0.5s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color; - -webkit-transition-duration: 0.5s; - -webkit-transition-timing-function: ease-out; - -moz-transition-property: background-color; - -moz-transition-duration: 0.5s; - -moz-transition-timing-function: ease-out; - -o-transition-property: background-color; - -o-transition-duration: 0.5s; -} -.sub_subMenu:hover{ - transition-property: background-color; - transition-duration: 0.5s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color; - -webkit-transition-duration: 0.5s; - -webkit-transition-timing-function: ease-out; - -moz-transition-property: background-color; - -moz-transition-duration: 0.5s; - -moz-transition-timing-function: ease-out; - -o-transition-property: background-color; - -o-transition-duration: 0.5s; - background-color: #585858 !important; +.sub_subMenu:hover { + transition-property: background-color; + transition-duration: 0.5s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color; + -webkit-transition-duration: 0.5s; + -webkit-transition-timing-function: ease-out; + -moz-transition-property: background-color; + -moz-transition-duration: 0.5s; + -moz-transition-timing-function: ease-out; + -o-transition-property: background-color; + -o-transition-duration: 0.5s; + background-color: #161616 !important; } .menu li.selected { - box-shadow: inset 4px 0 #80BA27; + box-shadow: inset 4px 0 #80ba27; } /* creo que no se usan .is_submenu2 li { @@ -358,35 +371,192 @@ ul li a:hover { } */ .operation { - background-color: #333 !important; - border-top-right-radius: 5px; - border-right-style: solid; - border-right-width: 0px; + background-color: #343434 !important; + border-top-right-radius: 5px; + border-right-style: solid; + border-right-width: 0px; + padding-top: 20px !important; } -.operation .selected { - background-color: #585858 !important; +.operation .selected, +.godmode .selected { + background-color: #282828 !important; } -.menu li, .menu .li.not_selected { - border-radius: 0px 0px 0px 0px; - display: block; - min-height: 35px; - border-bottom: 0px none #424242; - vertical-align: middle; +.operation .selected #title_menu, +.godmode .selected #title_menu { + color: #fff !important; + font-weight: 600; } -.godmode, .menu_icon ul li{ - background-color: #222; -} -.operation .menu_icon ul li{ - background-color: #333; +.menu li, +.menu .li.not_selected { + border-radius: 0px 0px 0px 0px; + display: block; + min-height: 35px; + border-bottom: 0px none #424242; + vertical-align: middle; } -.godmode{ - border-top: 4px solid #777 !important; - padding-bottom: 4px !important; - border-bottom-right-radius: 5px; - border-right-style: solid; - border-right-width: 0px; -} \ No newline at end of file +.godmode { + padding-bottom: 4px !important; + background-color: #343434; +} + +/* Menu icons active */ +.selected#icon_oper-networkconsole { + background: url(../../images/op_network.menu_white.png) no-repeat; +} +.selected#icon_oper-agents { + background: url(../../images/op_monitoring.menu_white.png) no-repeat; +} +.selected#icon_oper-events { + background: url(../../images/op_events.menu_white.png) no-repeat; +} +.selected#icon_oper-users { + background: url(../../images/op_workspace.menu_white.png) no-repeat; +} +.selected#icon_oper-reporting { + background: url(../../images/op_reporting.menu_white.png) no-repeat; +} +.selected#icon_oper-extensions { + background: url(../../images/extensions.menu_white.png) no-repeat; +} +.selected#icon_god-resources { + background: url(../../images/gm_resources.menu_white.png) no-repeat; +} +.selected#icon_god-configuration { + background: url(../../images/gm_configuration.menu_white.png) no-repeat; +} +.selected#icon_god-alerts { + background: url(../../images/gm_alerts.menu_white.png) no-repeat; +} +.selected#icon_god-users { + background: url(../../images/gm_users.menu_white.png) no-repeat; +} +.selected#icon_god-servers { + background: url(../../images/gm_servers.menu_white.png) no-repeat; +} +.selected#icon_god-setup { + background: url(../../images/gm_setup.menu_white.png) no-repeat; +} +.selected#icon_god-events { + background: url(../../images/gm_events.menu_white.png) no-repeat; +} +.selected#icon_god-extensions { + background: url(../../images/builder.menu_white.png) no-repeat; +} +.selected#icon_god-links { + background: url(../../images/links.menu_white.png) no-repeat; +} +.selected#icon_god-um_messages { + background: url(../../images/um_messages.menu_white.png) no-repeat; +} + +#menu_full { + /*height: 100%; Lo he quitado para que no ocupe todo el alto y fixed */ + width: 60px; /* It is changed for classic menu (215px)*/ + position: absolute; /*Fixed: Lo he quitado para que no ocupe todo el alto y fixed */ + z-index: 1; + top: 0; + left: 0; + background-color: #343434; + border-bottom: solid 5px #343434; + min-height: 943px; + /* padding-bottom: 40px; Lo he quitado para que no ocupe todo el alto y fixed */ + /*overflow-x: hidden;*/ +} + +.button_collapse { + height: 55px; + background-color: #4d4d4d; + /* bottom: 0; Lo he quitado para que no ocupe todo el alto y fixed + position: fixed;*/ + width: 60px; /* It is changed for classic menu (215px)*/ + text-align: center; + color: #fff; + cursor: pointer; + background-repeat: no-repeat; + background-position: center; + margin-top: 15px; +} + +.logo_green { + height: 60px; + display: flex; + justify-content: center; + align-items: center; +} + +.operation > li.menu_icon.no_hidden_menu, +.godmode > li.menu_icon.no_hidden_menu { + display: flex; + justify-content: flex-end; + align-items: center; +} + +.operation > li.menu_icon, +.godmode > li.menu_icon { + padding-top: 3px; + padding-bottom: 3px; +} + +.operation div, +.operation a, +.godmode div, +.godmode a { + font-family: "Open Sans", sans-serif; +} + +.menu_full_classic, +.button_classic { + width: 215px !important; + background-image: url(../../images/button_collapse_menu.png); + background-repeat: no-repeat; + background-position: center; +} + +.menu_full_collapsed, +.button_collapsed { + width: 60px !important; + background-image: url(../../images/button_classic_menu.png); + background-repeat: no-repeat; + background-position: center; +} + +#top_btn { + display: none; + position: fixed; + bottom: 100px; + left: 0px; + border: none; + outline: none; + background: url("../../images/to_top_menu.png") no-repeat center; + background-color: #82b92e; + width: 60px; + height: 60px; + /* Estos borrarles despues xk sera img */ + color: white; + cursor: pointer; + font-size: 17px; + border-radius: 5px; +} + +#top_btn:hover { + background-color: #4d4d4d; + /* border: 2px solid #fff;*/ +} + +@media screen and (max-height: 845px) { + .operation > li.menu_icon, + .godmode > li.menu_icon { + padding-top: 1px; + padding-bottom: 1px; + } + .operation { + padding-top: 10px !important; + } + .button_collapse { + margin-top: 10px; + } +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 5a4717b82f..f23bd48efe 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -1,51 +1,119 @@ -/* -Author: The Pandora FMS team -Name: Default theme -Description: The default Pandora FMS theme layout - -// Pandora FMS - http://pandorafms.com -// ========================================================== -// Copyright (c) 2004-2019 Artica Soluciones Tecnológicas S.L - -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; version 2 - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/* Tree view styles */ -/*@import url(tree.css); -@import url(fixed-bottom-box.css);*/ +/** + * + * Name: Default theme + * + * Extension to manage a list of gateways and the node address where they should + * point to. + * + * @category Extensions + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2019 Artica Soluciones Tecnologicas + * Please see http://pandorafms.org for full contribution list + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation for version 2. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * ============================================================================ + */ /* * --------------------------------------------------------------------- * - GENERAL STYLES - * --------------------------------------------------------------------- */ +/* latin-ext */ @font-face { - font-family: 'Nunito'; + font-family: "Open Sans"; font-style: normal; font-weight: 400; - src: local('Nunito-Regular'), url(../../fonts/nunito.woff) format('woff'); + src: local("Open Sans Regular"), local("OpenSans-Regular"), + url(../fonts/mem8YaGs126MiZpBA-UFW50bbck.woff2) format("woff2"); + unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, + U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: "Open Sans"; + font-style: normal; + font-weight: 400; + src: local("Open Sans Regular"), local("OpenSans-Regular"), + url(../fonts/mem8YaGs126MiZpBA-UFVZ0b.woff2) format("woff2"); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, + U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, + U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: "Open Sans"; + font-style: normal; + font-weight: 600; + src: local("Open Sans SemiBold"), local("OpenSans-SemiBold"), + url(../fonts/mem5YaGs126MiZpBA-UNirkOXOhpOqc.woff2) format("woff2"); + unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, + U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: "Open Sans"; + font-style: normal; + font-weight: 600; + src: local("Open Sans SemiBold"), local("OpenSans-SemiBold"), + url(../fonts/mem5YaGs126MiZpBA-UNirkOUuhp.woff2) format("woff2"); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, + U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, + U+FEFF, U+FFFD; +} +/* latin-ext */ +@font-face { + font-family: "Open Sans"; + font-style: normal; + font-weight: 700; + src: local("Open Sans Bold"), local("OpenSans-Bold"), + url(../fonts/mem5YaGs126MiZpBA-UN7rgOXOhpOqc.woff2) format("woff2"); + unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, + U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; +} +/* latin */ +@font-face { + font-family: "Open Sans"; + font-style: normal; + font-weight: 700; + src: local("Open Sans Bold"), local("OpenSans-Bold"), + url(../fonts/mem5YaGs126MiZpBA-UN7rgOUuhp.woff2) format("woff2"); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, + U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, + U+FEFF, U+FFFD; } @font-face { - font-family: 'lato-thin'; - src: url('../../fonts/Lato-Hairline.ttf'); + font-family: "Nunito"; + font-style: normal; + font-weight: 400; + src: local("Nunito-Regular"), url(../../fonts/nunito.woff) format("woff"); } @font-face { - font-family: 'lato-bolder'; - src: url('../../fonts/Lato-Light.ttf'); + font-family: "lato-thin"; + src: url("../../fonts/Lato-Hairline.ttf"); } @font-face { - font-family: 'lato-boldest'; - src: url('../../fonts/Lato-Regular.ttf'); + font-family: "lato-bolder"; + src: url("../../fonts/Lato-Light.ttf"); +} +@font-face { + font-family: "lato-boldest"; + src: url("../../fonts/Lato-Regular.ttf"); } * { font-family: verdana, sans-serif; @@ -59,8 +127,9 @@ body { background-color: #fff; margin: 0 auto; } -input, textarea { - border: 1px solid #ddd; +input, +textarea { + border: 1px solid #ddd; } textarea { padding: 5px; @@ -128,330 +197,312 @@ a:hover { color: #373737; text-decoration: underline; } -a:focus, input:focus, button:focus { - outline-width: 0; - outline: 0; +a:focus, +input:focus, +button:focus { + outline: 0; + outline-width: 0; } th > label { - padding-top: 7px; + padding-top: 7px; } input:disabled { - background-color: #DDD !important; + background-color: #ddd !important; } textarea:disabled { - background-color: #DDD !important; + background-color: #ddd !important; } select:disabled { - background-color: #DDD !important; + background-color: #ddd !important; } ul { - list-style-type: none; - padding-left: 0; - margin-left: 0; + list-style-type: none; + padding-left: 0; + margin-left: 0; } -code, pre { - font-family: courier, serif; +code, +pre { + font-family: courier, serif; } fieldset { - background-color:#F9FAF9; - border: 1px solid #E2E2E2; - padding:0.5em; - margin-bottom:20px; - position:relative; + background-color: #f9faf9; + border: 1px solid #e2e2e2; + padding: 0.5em; + margin-bottom: 20px; + position: relative; } fieldset legend { - font-size:1.1em; - font-weight:bold; - line-height: 20px; - color: #3F3F3F; + font-size: 1.1em; + font-weight: bold; + line-height: 20px; + color: #3f3f3f; } -td input[type=checkbox]{ +td input[type="checkbox"] { padding: 10px; margin-top: 2px; display: table-cell; } -input[type=image] { - border:0px; - background-color: transparent !important; +input[type="image"] { + border: 0px; + background-color: transparent !important; } -table, img { - border: 0px; +table, +img { + border: 0px; } -table pre{ - white-space: pre-wrap; +table pre { + white-space: pre-wrap; } -tr:first-child>th { - background-color: #373737; +tr:first-child > th { + background-color: #373737; } th { - color: #fff; - background-color: #666; - font-size: 7.5pt; - letter-spacing: 0.3pt; + color: #fff; + background-color: #666; + font-size: 7.5pt; + letter-spacing: 0.3pt; } /* --- Font ttf --- */ -@font-face -{ - font-family: 'DejaVuSerif-BoldFont'; - src: url('../fonts/DejaVuSerif-Bold.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerif-BoldFont"; + src: url("../fonts/DejaVuSerif-Bold.ttf") format("truetype"); } -.DejaVuSerif-Bold{ - font-family: DejaVuSerif-BoldFont; +.DejaVuSerif-Bold { + font-family: DejaVuSerif-BoldFont; } -@font-face -{ - font-family: 'DejaVuSerif-BoldItalicFont'; - src: url('../fonts/DejaVuSerif-BoldItalic.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerif-BoldItalicFont"; + src: url("../fonts/DejaVuSerif-BoldItalic.ttf") format("truetype"); } -.DejaVuSerif-BoldItalic{ - font-family: DejaVuSerif-BoldItalicFont; +.DejaVuSerif-BoldItalic { + font-family: DejaVuSerif-BoldItalicFont; } -@font-face -{ - font-family: 'DejaVuSerif-ItalicFont'; - src: url('../fonts/DejaVuSerif-Italic.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerif-ItalicFont"; + src: url("../fonts/DejaVuSerif-Italic.ttf") format("truetype"); } -.DejaVuSerif-Italic{ - font-family: DejaVuSerif-ItalicFont; +.DejaVuSerif-Italic { + font-family: DejaVuSerif-ItalicFont; } -@font-face -{ - font-family: 'DejaVuSerifFont'; - src: url('../fonts/DejaVuSerif.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerifFont"; + src: url("../fonts/DejaVuSerif.ttf") format("truetype"); } -.DejaVuSerif{ - font-family: DejaVuSerifFont; +.DejaVuSerif { + font-family: DejaVuSerifFont; } -@font-face -{ - font-family: 'DejaVuSerifCondensed-BoldFont'; - src: url('../fonts/DejaVuSerifCondensed-Bold.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerifCondensed-BoldFont"; + src: url("../fonts/DejaVuSerifCondensed-Bold.ttf") format("truetype"); } -.DejaVuSerifCondensed-Bold{ - font-family: DejaVuSerifCondensed-BoldFont; +.DejaVuSerifCondensed-Bold { + font-family: DejaVuSerifCondensed-BoldFont; } -@font-face -{ - font-family: 'DejaVuSerifCondensed-BoldItalicFont'; - src: url('../fonts/DejaVuSerifCondensed-BoldItalic.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerifCondensed-BoldItalicFont"; + src: url("../fonts/DejaVuSerifCondensed-BoldItalic.ttf") format("truetype"); } -.DejaVuSerifCondensed-BoldItalic{ - font-family: DejaVuSerifCondensed-BoldItalicFont; +.DejaVuSerifCondensed-BoldItalic { + font-family: DejaVuSerifCondensed-BoldItalicFont; } -@font-face -{ - font-family: 'DejaVuSerifCondensed-ItalicFont'; - src: url('../fonts/DejaVuSerifCondensed-Italic.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerifCondensed-ItalicFont"; + src: url("../fonts/DejaVuSerifCondensed-Italic.ttf") format("truetype"); } -.DejaVuSerifCondensed-Italic{ - font-family: DejaVuSerifCondensed-ItalicFont; +.DejaVuSerifCondensed-Italic { + font-family: DejaVuSerifCondensed-ItalicFont; } -@font-face -{ - font-family: 'DejaVuSerifCondensedFont'; - src: url('../fonts/DejaVuSerifCondensed.ttf') format('truetype'); +@font-face { + font-family: "DejaVuSerifCondensedFont"; + src: url("../fonts/DejaVuSerifCondensed.ttf") format("truetype"); } -.DejaVuSerifCondensed{ - font-family: DejaVuSerifCondensedFont; +.DejaVuSerifCondensed { + font-family: DejaVuSerifCondensedFont; } -@font-face -{ - font-family: 'FreeSansFont'; - src: url('../fonts/FreeSans.ttf') format('truetype'); +@font-face { + font-family: "FreeSansFont"; + src: url("../fonts/FreeSans.ttf") format("truetype"); } -.FreeSans{ - font-family: FreeSansFont; +.FreeSans { + font-family: FreeSansFont; } -@font-face -{ - font-family: 'FreeSansBoldFont'; - src: url('../fonts/FreeSansBold.ttf') format('truetype'); +@font-face { + font-family: "FreeSansBoldFont"; + src: url("../fonts/FreeSansBold.ttf") format("truetype"); } -.FreeSansBold{ - font-family: FreeSansBoldFont; +.FreeSansBold { + font-family: FreeSansBoldFont; } -@font-face -{ - font-family: 'smallfontFont'; - src: url('../fonts/smallfont.ttf') format('truetype'); +@font-face { + font-family: "smallfontFont"; + src: url("../fonts/smallfont.ttf") format("truetype"); } -.smallfont{ - font-family: smallfontFont; +.smallfont { + font-family: smallfontFont; } -@font-face -{ - font-family: 'unicodeFont'; - src: url('../fonts/unicode.ttf') format('truetype'); +@font-face { + font-family: "unicodeFont"; + src: url("../fonts/unicode.ttf") format("truetype"); } -@font-face -{ - font-family: 'roboto'; - src: url('../../fonts/roboto.woff2') format('woff2'); +@font-face { + font-family: "roboto"; + src: url("../../fonts/roboto.woff2") format("woff2"); } -@font-face -{ - font-family: 'opensans'; - src: url('../../fonts/opensans.woff2') format('woff2'); +@font-face { + font-family: "opensans"; + src: url("../../fonts/opensans.woff2") format("woff2"); } -@font-face -{ - font-family: 'lato'; - src: url('../../fonts/lato.woff2') format('woff2'); +@font-face { + font-family: "lato"; + src: url("../../fonts/lato.woff2") format("woff2"); } -@font-face -{ - font-family: 'leaguegothic'; - src: url('../../fonts/leaguegothic.woff') format('woff'); +@font-face { + font-family: "leaguegothic"; + src: url("../../fonts/leaguegothic.woff") format("woff"); } -.unicode{ - font-family: unicodeFont; +.unicode { + font-family: unicodeFont; } /* * --------------------------------------------------------------------- - * - GLOBAL STYLES - + * - GLOBAL STYLES - * --------------------------------------------------------------------- */ div#page { - background: #FFF; - background-image: none; - clear: both; - width: auto; + background: #fff; + background-image: none; + clear: both; + width: auto; + margin-top: 20px !important; + padding-left: 60px; /* It is changed for classic menu (215px)*/ + margin-right: 30px; + margin-left: 30px; } body.pure { - background-color: #fff; + background-color: #fff; } div#container { - margin: 0 auto; - min-width: 960px; - text-align: left; - height: 100%; - background: #FFF; - width: 100%; + margin: 0 auto; + min-width: 960px; + text-align: left; + height: 100%; + background: #fff; + width: 100%; } div#main { - width: auto; - margin: 0px 0% 0px 0%; - float: left; - position: relative; - min-height: 850px; - margin-left:60px; - max-width: 93%; - min-width: 93%; + width: auto; + margin: 0 auto; + position: relative; + min-height: 850px; + max-width: 100%; + min-width: 93%; } textarea.conf_editor { - padding: 5px; - width: 650px; - height: 350px; + padding: 5px; + width: 650px; + height: 350px; } textarea.conf_error { - background-image: url(../../images/err.png); - background-repeat: no-repeat; - background-position: top right; -} - -input.button { - font-family: Arial,Sans-serif; - border: 4px solid #ccc; - background: #fff; - padding: 2px 3px; - margin: 10px 15px; + background-image: url(../../images/err.png); + background-repeat: no-repeat; + background-position: top right; } a.white_bold { - color: #eee; - text-decoration: none; - font-weight: bold; + color: #eee; + text-decoration: none; + font-weight: bold; } a.white { - color: #eee; - text-decoration: none; + color: #eee; + text-decoration: none; } p.center { - text-align: center; + text-align: center; } .img_help { - cursor: help; + cursor: help; } #loading { - position:fixed; - width: 200px; - margin-left: 30%; - text-align:center; - top: 50%; - background-color: #999999; - padding: 20px; + position: fixed; + width: 200px; + margin-left: 30%; + text-align: center; + top: 50%; + background-color: #999999; + padding: 20px; } -.tactical_set legend{ - text-align:left; - color: #3F3F3F; +.tactical_set legend { + text-align: left; + color: #3f3f3f; } -.tactical_set{ - background: #FFF; - border: 1px solid #E2E2E2; - margin-left: auto; - margin-right: auto; - width: auto; +.tactical_set { + background: #fff; + border: 1px solid #e2e2e2; + margin-left: auto; + margin-right: auto; + width: auto; } /* --- Botones --- */ input.sub { - font-weight: normal; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - border-radius: 2px; - font-size: 8pt; - background-color: #333 !important; - background-repeat: no-repeat !important; - background-position: 92% 3px !important; - color: white !important; - padding: 3px 3px 5px 12px; - border-color: #333; + font-weight: normal; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + border-radius: 2px; + font-size: 8pt; + background-color: #333 !important; + background-repeat: no-repeat !important; + background-position: 92% 3px !important; + color: white !important; + padding: 3px 3px 5px 12px; + border-color: #333; } input.sub[disabled] { - color: #B4B4B4 !important; - background-color: #F3F3F3 !important; - border-color: #B6B6B6; - cursor: default; + color: #b4b4b4 !important; + background-color: #f3f3f3 !important; + border-color: #b6b6b6; + cursor: default; } /* @@ -460,43 +511,43 @@ input.sub[disabled] { * --------------------------------------------------------------------- */ #noaccess { - position: relative; - margin-top:25px; - left: 15px; - padding-top: 5px; - background-color: #FFFFFF; - border-top-left-radius: 2px; - border-top-right-radius: 2px; - border-bottom-left-radius: 2px; - border-bottom-right-radius: 2px; + position: relative; + margin-top: 25px; + left: 15px; + padding-top: 5px; + background-color: #ffffff; + border-top-left-radius: 2px; + border-top-right-radius: 2px; + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; } #noaccess-title { - color: #FFF; - font-weight: bold; - padding-top: 5px; - margin-left: 5px; - background: none repeat scroll 0% 0% #82B92E; - border-top-left-radius: 2px; - border-top-right-radius: 2px; - border-bottom-left-radius: 2px; - border-bottom-right-radius: 2px; - text-align: center; + color: #fff; + font-weight: bold; + padding-top: 5px; + margin-left: 5px; + background: none repeat scroll 0% 0% #82b92e; + border-top-left-radius: 2px; + border-top-right-radius: 2px; + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; + text-align: center; } #noaccess-text { - font-size: 12px; - text-align: justify; - padding-top: 25px; - padding-right: 50px; - float:right; + font-size: 12px; + text-align: justify; + padding-top: 25px; + padding-right: 50px; + float: right; } #noaccess-image { - position: relative; - left: 10px; - top: 10px; - float:left; + position: relative; + left: 10px; + top: 10px; + float: left; } /*div#activity{ @@ -523,61 +574,62 @@ div#db_ftxt { padding-top: 10px; }*/ - /* * --------------------------------------------------------------------- * - HELP DIALOG - login_help_dialog.php and pandora_help.php - * --------------------------------------------------------------------- */ div#main_help { - width: 100%; + width: 100%; } -div#main_help div.databox, .license_databox { - background: F3F3F3; - -moz-border-radius: 8px; - -webkit-border-radius: 8px; - border-radius: 8px; - border: 0px; - padding-left: 25px; - padding-right: 25px; - margin-top: 10px; - -moz-box-shadow: -1px 1px 6px #aaa; - -webkit-box-shadow: -1px 1px 6px #aaa; - box-shadow: -1px 1px 6px #aaa; - +div#main_help div.databox, +.license_databox { + background: F3F3F3; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + border-radius: 8px; + border: 0px; + padding-left: 25px; + padding-right: 25px; + margin-top: 10px; + -moz-box-shadow: -1px 1px 6px #aaa; + -webkit-box-shadow: -1px 1px 6px #aaa; + box-shadow: -1px 1px 6px #aaa; } -div#main_help div.databox h1{ - padding-bottom: 0px; - margin-bottom: 0px; - font-weight: bold; - font-family: sans-serif, verdana; +div#main_help div.databox h1 { + padding-bottom: 0px; + margin-bottom: 0px; + font-weight: bold; + font-family: sans-serif, verdana; } -div#main_help div.databox h3, div#main_help div.databox h2 { - color: #6EB432; - font-family: sans-serif, verdana; +div#main_help div.databox h3, +div#main_help div.databox h2 { + color: #6eb432; + font-family: sans-serif, verdana; } div#main_help div.databox h3 { - font-size: 12px; + font-size: 12px; } -div#main_help a.footer, div#main_help span { - color: #999; +div#main_help a.footer, +div#main_help span { + color: #999; } -div#main_help div.databox hr{ - width:100%; - border: 0px; - height: 1px; - background-color: #222; - margin: 0px; +div#main_help div.databox hr { + width: 100%; + border: 0px; + height: 1px; + background-color: #222; + margin: 0px; } -div#main_help div.databox p{ - line-height: 15px; - text-align: justify; +div#main_help div.databox p { + line-height: 15px; + text-align: justify; } /* @@ -585,21 +637,27 @@ div#main_help div.databox p{ * - FOOTER - * --------------------------------------------------------------------- */ -a.footer, a.footer span{ - font-size: 9px; - color: white; +a.footer, +a.footer span { + font-size: 9px; + color: white; } div#foot { - font-size: 6pt !important; - border-top: solid 2px #222; - padding-top: 8px; - padding-bottom: 5px; - text-align: center; - background: #333333; - height: 30px; - clear: both; - width: auto; + padding-top: 8px; + padding-bottom: 5px; + text-align: center; + background: #343434; + height: 30px; + clear: both; + width: auto; +} + +div#foot a, +div#foot span { + font-family: "Open Sans", sans-serif; + font-size: 8.5pt; + color: #91a2a7; } /* @@ -608,48 +666,46 @@ div#foot { * --------------------------------------------------------------------- */ div#menu_container { - -moz-border-top-right-radius: 6px; - -webkit-border-top-right-radius: 6px; - border-top-right-radius: 6px; - z-index: 1010; - width: 40px; - height: 100%; + -moz-border-top-right-radius: 6px; + -webkit-border-top-right-radius: 6px; + border-top-right-radius: 6px; + z-index: 1010; + width: 40px; + height: 100%; } div#menu { - width: 45px; - float: left; - z-index: 2000; - position: absolute; + width: 45px; + float: left; + z-index: 2000; + /*position: absolute; Lo he quitado para que no ocupe todo el alto y fixed */ } div#head { - font-size: 8pt; - width: 100%; - height: 60px; - padding-top: 0px; - margin-bottom: 20px; - border-bottom-style: solid; - border-bottom-width: 3px; - border-color: #82B92E; - min-width: 882px; - background-color: #333; - color: white; + font-size: 8pt; + width: 100%; + height: 60px; + padding-top: 0px; + margin: 0 auto; + border-bottom: 1px solid #91a2a7; + min-width: 882px; + background-color: #fff; + color: #000; + z-index: 2; } .fixed_header { - z-index: 9999; - position: fixed; - left: 0; - top: 0; - width: 100%; + z-index: 9999; + position: fixed; + left: 0; + top: 0; + width: 100%; } #ver { - margin-bottom: 25px; + margin-bottom: 25px; } - /*.databox_error { width: 657px !important; height: 400px; @@ -670,27 +726,42 @@ input.datos { background-color: #050505; }*/ - /* * --------------------------------------------------------------------- * - VISUAL MAPS - * --------------------------------------------------------------------- */ -input.vs_button_ghost{ - background-color: transparent !important; - border: 1px solid #82b92e; - color: #82b92e !important; - text-align: center; - padding: 4px 12px; - font-weight: bold; +input.vs_button_ghost { + background-color: transparent !important; + border: 1px solid #82b92e; + color: #82b92e !important; + text-align: center; + padding: 4px 12px; + font-weight: bold; } -input.next, input.upd, input.ok, input.wand, input.delete, input.cog, -input.target, input.search, input.copy, input.add, input.graph, -input.percentile, input.binary, input.camera, input.config, -input.cancel, input.default, input.filter, input.pdf,input.spinn { - padding-right: 30px; - height: 23px; +input.next, +input.upd, +input.ok, +input.wand, +input.delete, +input.cog, +input.target, +input.search, +input.copy, +input.add, +input.graph, +input.percentile, +input.binary, +input.camera, +input.config, +input.cancel, +input.default, +input.filter, +input.pdf, +input.spinn { + padding-right: 30px; + height: 23px; } input.next { @@ -906,13 +977,6 @@ input.group_item_min[disabled] { background: #fefefe url(../../images/group_green.disabled.png) no-repeat center !important; } -input.color_cloud_min { - background: #fefefe url(../../images/color_cloud_item.png) no-repeat center !important; -} -input.color_cloud_min[disabled] { - background: #fefefe url(../../images/color_cloud_item.disabled.png) no-repeat - center !important; -} div#cont { position: fixed; @@ -925,7 +989,6 @@ div#cont { background-color: #80BA27 !important; }*/ - /*tr.datos, tr.datost, tr.datosb , tr.datos_id, tr.datosf9 { #background-color: #eaeaea; @@ -948,12 +1011,13 @@ tr.datos2b:hover, tr.datos2_id:hover, tr.datos2f9:hover { * --------------------------------------------------------------------- */ .agent_reporting { - margin: 5px; - padding: 5px; + margin: 5px; + padding: 5px; } -.report_table, .agent_reporting { - border: #CCC outset 3px; +.report_table, +.agent_reporting { + border: #ccc outset 3px; } td.datos3, @@ -976,14 +1040,10 @@ td.datos4 * { /* user list php */ tr.disabled_row_user * { - color: grey; + color: grey; } /* global syles */ -.bg { /* op menu */ - background: #82b92e; -} - .bg { /* op menu */ background: #82b92e; @@ -1178,23 +1238,22 @@ div.title_line { -khtml-opacity: 0.5; } - /* * --------------------------------------------------------------------- * - RIGHT MENU SECTION - * --------------------------------------------------------------------- */ -#menu_tab_frame, +#menu_tab_frame, #menu_tab_frame_view { - display: block !important; - border-bottom: 1px solid #80BA27; - max-height: 31px; - min-height: 31px; - width: 100%; - padding-right: 0px; - margin-left: 0px !important; - margin-bottom: 20px; - height: 31px; + display: block !important; + border-bottom: 2px solid #82b92e; + max-height: 31px; + min-height: 31px; + width: 100%; + padding-right: 0px; + margin-left: 0px !important; + margin-bottom: 20px; + height: 31px; } #menu_tab { @@ -1223,7 +1282,7 @@ div.title_line { } #menu_tab li.nomn_high a { - color: #fff; + color: #fff; } #menu_tab .mn li a { display: block; @@ -1231,71 +1290,68 @@ div.title_line { padding: 0px; margin: 0px; } -#menu_tab li.nomn:hover a, #menu_tab li:hover ul a:hover { - color: #fff; +#menu_tab li.nomn:hover a, +#menu_tab li:hover ul a:hover { + color: #fff; } -#menu_tab li.nomn { +#menu_tab li.nomn, +#menu_tab li.nomn_high { min-width: 30px; height: 28px; + margin-top: 0; } -#menu_tab li.nomn_high { - min-width: 30px; - height: 28px; -} - /* --- Submenu --- */ ul.subsubmenu { - border-bottom-right-radius: 5px; - border-bottom-left-radius: 5px; - -moz-border-bottom-right-radius: 5px; - -moz-border-bottom-left-radius: 5px; - -webkit-border-bottom-right-radius: 5px; - -webkit-border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + border-bottom-left-radius: 5px; + -moz-border-bottom-right-radius: 5px; + -moz-border-bottom-left-radius: 5px; + -webkit-border-bottom-right-radius: 5px; + -webkit-border-bottom-left-radius: 5px; - background: #ECECEC !important; + background: #ececec !important; } -ul.subsubmenu li{ - background-color: #ECECEC; - font-weight: bold; - text-decoration: none; - font-size: 14px; - border-color: #E2E2E2; - border-style: solid; - border-width: 1px; +ul.subsubmenu li { + background-color: #ececec; + font-weight: bold; + text-decoration: none; + font-size: 14px; + border-color: #e2e2e2; + border-style: solid; + border-width: 1px; } -ul.subsubmenu li a{ - padding: 0px 10px 5px; +ul.subsubmenu li a { + padding: 0px 10px 5px; } -.subsubmenu{ - position: absolute; - float: right; - z-index: 9999; - display: none; - margin-top: 5px !important ; - left: 0px !important; +.subsubmenu { + position: absolute; + float: right; + z-index: 9999; + display: none; + margin-top: 5px !important ; + left: 0px !important; } -.subsubmenu li{ - margin-top: 0px !important ; +.subsubmenu li { + margin-top: 0px !important ; } div#agent_wizard_subtabs { - position: absolute; - margin-left: 0px; - display: none; - padding-bottom: 3px; - z-index: 1000; + position: absolute; + margin-left: 0px; + display: none; + padding-bottom: 3px; + z-index: 1000; } .agent_wizard_tab:hover { - cursor: default; + cursor: default; } - /* * --------------------------------------------------------------------- * - SECTION TITLE LEFT (green background) - @@ -1367,7 +1423,6 @@ div#agent_wizard_subtabs { font-weight: bold; } - /* span.users { background: url(../../images/group.png) no-repeat; @@ -1458,19 +1513,20 @@ span.rmess, span.nrmess { * - TABLES - * --------------------------------------------------------------------- */ -.databox, .databox_color, .databox_frame { - margin-bottom: 5px; - margin-top: 0px; - margin-left: 0px; - border: 1px solid #e2e2e2; - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - border-radius: 4px; - +.databox, +.databox_color, +.databox_frame { + margin-bottom: 5px; + margin-top: 0px; + margin-left: 0px; + border: 1px solid #e2e2e2; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; } -.databox_color{ - padding-top: 5px; - background-color: #fafafa; +.databox_color { + padding-top: 5px; + background-color: #fafafa; } table.databox { @@ -1493,8 +1549,7 @@ table.databox { } .databox > thead > tr > th, -.databox > tbody > tr > th, -.databox > thead > tr > th a { +.databox > tbody > tr > th { padding: 9px 7px; font-weight: normal; color: #fff; @@ -1546,7 +1601,6 @@ table.databox { color: #333; } - /* For use in Netflow */ /* table.databox_grid { @@ -1566,18 +1620,18 @@ table.databox_grid > td { */ /* events */ -table.alternate tr:nth-child(odd) td{ - background-color: #ffffff; +table.alternate tr:nth-child(odd) td { + background-color: #ffffff; } table.alternate tr:nth-child(even) td { background-color: #e4e5e4; } table.rounded_cells td { - padding: 4px 4px 4px 10px; - -moz-border-radius: 6px !important; - -webkit-border-radius: 6px !important; - border-radius: 6px !important; + padding: 4px 4px 4px 10px; + -moz-border-radius: 6px !important; + -webkit-border-radius: 6px !important; + border-radius: 6px !important; } /*#head_l { @@ -1633,15 +1687,15 @@ div#logo_text3 { /* end of classes for event priorities */ div#main_pure { - background-color: #fefefe; - text-align: left; - margin-bottom: 25px; - margin-top: 30px; - margin-left: 10px; - margin-right: 10px; - height: 1000px; - width: 98%; - position: static; + background-color: #fefefe; + text-align: left; + margin-bottom: 25px; + margin-top: 30px; + margin-left: 10px; + margin-right: 10px; + height: 1000px; + width: 98%; + position: static; } /*#table-agent-configuration radio { margin-right: 40px; @@ -1663,8 +1717,6 @@ div#main_pure { width: 300px; }*/ - - /* IE 7 Hack */ #editor { *margin-top: 10px !important; @@ -1707,9 +1759,9 @@ span.actions { .actions { min-width: 200px !important; } -select#template, +select#template, select#action { - width: 250px; + width: 250px; } /*#label-checkbox-matches_value, #label-checkbox-copy_modules, @@ -1719,8 +1771,8 @@ select#action { }*/ /* Modules */ -table#simple{ - padding: 30px; +table#simple { + padding: 30px; } table#simple select#id_module_type, table#alert_search select#id_agent, @@ -1961,20 +2013,135 @@ div#pandora_logo_header { float: left; } -#header_table img { +/* + * --------------------------------------------------------------------- + * - HEADER - + * --------------------------------------------------------------------- + */ +#header_table { + margin: 0px; + padding: 0px; margin-top: 0px; + padding-left: 90px; /* It is changed for classic menu */ + padding-right: 30px; +} + +#header_table_inner { + height: 60px; + /*width: 100%;*/ + display: flex; + align-items: center; + justify-content: space-between; +} + +#header_table_inner a, +#header_table_inner span { + font-family: "Open Sans", sans-serif; +} + +.header_left { + display: flex; + justify-content: flex-start; + align-items: center; +} + +.header_center { + display: flex; + justify-content: center; + align-items: center; +} + +.header_right { + display: flex; + justify-content: flex-end; + align-items: center; +} + +.header_left > div, +.header_center > div { + padding-right: 15px; +} + +.header_right > div { + padding-left: 15px; +} + +#header_table_inner > div { + /* border: solid 1px pink;*/ +} + +#header_table_inner > div > div { + /* border: solid 1px fuchsia;*/ +} + +#header_table_inner td a, +#header_table_inner td span { + color: #777; +} + +.header_left img, +.header_center img, +.header_right img { + vertical-align: middle; +} + +#header_user img, +#header_autorefresh { + padding-right: 5px; +} + +#header_alert, +#header_message { + padding-right: 0px; +} + +#header_alert p, +#header_message p { + border-radius: 50%; + padding: 0; + margin: 0; + width: 15px; + position: relative; + height: 15px; + top: -5px; + text-align: center; + display: inline-block; + vertical-align: super; +} + +#header_alert p { + background-color: #ec4e1b; + left: -12px; +} + +#header_message p { + background-color: #82b92e; + left: -9px; +} + +#header_alert span, +#header_message span { + color: #fff; + font-size: 7pt; + font-weight: 600; + font-family: "Open Sans", sans-serif; +} + +@media screen and (max-width: 1024px) { + #header_user span, + #header_searchbar a.tip img { + display: none; + } } .autorefresh_disabled { cursor: not-allowed !important; } -a.autorefresh { - padding-right: 8px; -} - +a.autorefresh_txt, #refrcounter { - color: white; + color: #1c1c1c; + font-size: 8.5pt; } #combo_refr select { @@ -2015,15 +2182,15 @@ div.warn { } ol.steps { - margin-bottom: 70px; + margin-bottom: 70px; } div#steps_clean { - display:none; + display: none; } div#events_list { - float: left; - width: 100%; + float: left; + width: 100%; } /*span#logo_text1 { font: bolder 3em Arial, Sans-serif; @@ -2055,86 +2222,60 @@ div#logo_text3 { vertical-align: middle; } - - /* TABLAS */ /* Cells divs to set individual styles with the table objects */ -div.cellBold { - width: 100%; - height: 100%; +td.cellBold { font-weight: bold; } -div.cellRight { - width: 100%; - height: 100%; +td.cellRight { text-align: right; } -div.cellCenter { - width: 100%; - height: 100%; +td.cellCenter { text-align: center; } -div.cellWhite { - width: 100%; - height: 100%; +td.cellWhite { background: #fff; color: #111; } -div.cellNormal { - width: 100%; - height: 100%; +td.cellNormal { background: #6eb432; color: #fff; } -div.cellCritical { - width: 100%; - height: 100%; +td.cellCritical { background: #f85858; color: #fff; } -div.cellWarning { - width: 100%; - height: 100%; +td.cellWarning { background: #ffea59; color: #111; } -div.cellUnknown { - width: 100%; - height: 100%; +td.cellUnknown { background: #aaaaaa; color: #ffffff; } -div.cellNotInit { - width: 100%; - height: 100%; +td.cellNotInit { background: #3ba0ff; color: #ffffff; } -div.cellAlert { - width: 100%; - height: 100%; +td.cellAlert { background: #ff8800; color: #111; } -div.cellBorder1 { - width: 100%; - height: 100%; +td.cellBorder1 { border: 1px solid #666; } -div.cellBig { - width: 100%; - height: 100%; +td.cellBig { font-size: 18px; } @@ -2164,15 +2305,15 @@ div.cellBig { /* Standard styles for status colos (groups, events, backgrounds...) */ .opacity_cell { - filter:alpha(opacity=80); /* For IE8 and earlier */ - -moz-opacity: 0.8; - opacity: 0.8; - -khtml-opacity: 0.8; + filter: alpha(opacity=80); /* For IE8 and earlier */ + -moz-opacity: 0.8; + opacity: 0.8; + -khtml-opacity: 0.8; } -tr.group_view_data, +tr.group_view_data, .group_view_data { - color: #3F3F3F; + color: #3f3f3f; } tr.group_view_crit, @@ -2181,10 +2322,10 @@ tr.group_view_crit, color: #fff; } -tr.group_view_ok, +tr.group_view_ok, .group_view_ok { - background-color: #80BA27; - color: #fff; + background-color: #80ba27; + color: #fff; } tr.group_view_not_init, @@ -2291,14 +2432,16 @@ td.datos_orangef9 { padding: 5px 5px 5px 5px; } - /* global */ -input#text-id_parent.ac_input, input, textarea, select { - background-color: #ffffff !important; - border: 1px solid #cbcbcb; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; +input#text-id_parent.ac_input, +input, +textarea, +select { + background-color: #ffffff !important; + border: 1px solid #cbcbcb; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } /* plugins */ @@ -2306,130 +2449,325 @@ span#plugin_description { font-size: 9px; } - /* * --------------------------------------------------------------------- * - TINYMCE - * --------------------------------------------------------------------- */ #tinymce { - text-align: left; - padding-top:20px; + text-align: left; + padding-top: 20px; } -.visual_font_size_4pt, .visual_font_size_4pt > em, .visual_font_size_4pt > strong, .visual_font_size_4pt > strong > span, .visual_font_size_4pt > span, .visual_font_size_4pt > strong > em, .visual_font_size_4pt > em > strong, .visual_font_size_4pt em span, .visual_font_size_4pt span em { - font-size: 4pt !important; - line-height: 4pt; +.visual_font_size_4pt, +.visual_font_size_4pt > em, +.visual_font_size_4pt > strong, +.visual_font_size_4pt > strong > span, +.visual_font_size_4pt > span, +.visual_font_size_4pt > strong > em, +.visual_font_size_4pt > em > strong, +.visual_font_size_4pt em span, +.visual_font_size_4pt span em { + font-size: 4pt !important; + line-height: 4pt; } -.visual_font_size_6pt, .visual_font_size_6pt > em, .visual_font_size_6pt > strong, .visual_font_size_6pt > strong > span, .visual_font_size_6pt > span, .visual_font_size_6pt > strong > em, .visual_font_size_6pt > em > strong, .visual_font_size_6pt em span, .visual_font_size_6pt span em { - font-size: 6pt !important; - line-height: 6pt; +.visual_font_size_6pt, +.visual_font_size_6pt > em, +.visual_font_size_6pt > strong, +.visual_font_size_6pt > strong > span, +.visual_font_size_6pt > span, +.visual_font_size_6pt > strong > em, +.visual_font_size_6pt > em > strong, +.visual_font_size_6pt em span, +.visual_font_size_6pt span em { + font-size: 6pt !important; + line-height: 6pt; } -.visual_font_size_8pt, .visual_font_size_8pt > em, .visual_font_size_8pt > strong, .visual_font_size_8pt > strong > span , .visual_font_size_8pt > span, .visual_font_size_8pt > strong > em, .visual_font_size_8pt > em > strong, .visual_font_size_8pt em span, .visual_font_size_8pt span em { - font-size: 8pt !important; - line-height: 8pt; +.visual_font_size_8pt, +.visual_font_size_8pt > em, +.visual_font_size_8pt > strong, +.visual_font_size_8pt > strong > span, +.visual_font_size_8pt > span, +.visual_font_size_8pt > strong > em, +.visual_font_size_8pt > em > strong, +.visual_font_size_8pt em span, +.visual_font_size_8pt span em { + font-size: 8pt !important; + line-height: 8pt; } -.visual_font_size_10pt, .visual_font_size_10pt > em, .visual_font_size_10pt > strong, .visual_font_size_10pt > strong > span , .visual_font_size_10pt > span, .visual_font_size_10pt > strong > em, .visual_font_size_10pt > em > strong, .visual_font_size_10pt em span, .visual_font_size_10pt span em { - font-size: 10pt !important; - line-height: 10pt; +.visual_font_size_10pt, +.visual_font_size_10pt > em, +.visual_font_size_10pt > strong, +.visual_font_size_10pt > strong > span, +.visual_font_size_10pt > span, +.visual_font_size_10pt > strong > em, +.visual_font_size_10pt > em > strong, +.visual_font_size_10pt em span, +.visual_font_size_10pt span em { + font-size: 10pt !important; + line-height: 10pt; } -.visual_font_size_12pt, .visual_font_size_12pt > em, .visual_font_size_12pt > strong, .visual_font_size_12pt > strong > span , .visual_font_size_12pt > span, .visual_font_size_12pt > strong > em, .visual_font_size_12pt > em > strong, .visual_font_size_12pt em span, .visual_font_size_12pt span em { - font-size: 12pt !important; - line-height: 12pt; +.visual_font_size_12pt, +.visual_font_size_12pt > em, +.visual_font_size_12pt > strong, +.visual_font_size_12pt > strong > span, +.visual_font_size_12pt > span, +.visual_font_size_12pt > strong > em, +.visual_font_size_12pt > em > strong, +.visual_font_size_12pt em span, +.visual_font_size_12pt span em { + font-size: 12pt !important; + line-height: 12pt; } -.visual_font_size_14pt, .visual_font_size_14pt > em , .visual_font_size_14pt > strong, .visual_font_size_14pt > strong > span, .visual_font_size_14pt > span, .visual_font_size_14pt > strong > em, .visual_font_size_14pt > em > strong, .visual_font_size_14pt em span, .visual_font_size_14pt span em { - font-size: 14pt !important; - line-height: 14pt; +.visual_font_size_14pt, +.visual_font_size_14pt > em, +.visual_font_size_14pt > strong, +.visual_font_size_14pt > strong > span, +.visual_font_size_14pt > span, +.visual_font_size_14pt > strong > em, +.visual_font_size_14pt > em > strong, +.visual_font_size_14pt em span, +.visual_font_size_14pt span em { + font-size: 14pt !important; + line-height: 14pt; } -.visual_font_size_18pt, .visual_font_size_18pt > em , .visual_font_size_18pt > strong, .visual_font_size_18pt > strong > span, .visual_font_size_18pt > span, .visual_font_size_18pt > strong > em, .visual_font_size_18pt > em > strong, .visual_font_size_18pt em span, .visual_font_size_18pt span em { - font-size: 18pt !important; - line-height: 18pt; +.visual_font_size_18pt, +.visual_font_size_18pt > em, +.visual_font_size_18pt > strong, +.visual_font_size_18pt > strong > span, +.visual_font_size_18pt > span, +.visual_font_size_18pt > strong > em, +.visual_font_size_18pt > em > strong, +.visual_font_size_18pt em span, +.visual_font_size_18pt span em { + font-size: 18pt !important; + line-height: 18pt; } -.visual_font_size_24pt, .visual_font_size_24pt > em, .visual_font_size_24pt > strong, .visual_font_size_24pt > strong > span , .visual_font_size_24pt > span, .visual_font_size_24pt > strong > em, .visual_font_size_24pt > em > strong, .visual_font_size_24pt em span, .visual_font_size_24pt span em { - font-size: 24pt !important; - line-height: 24pt; +.visual_font_size_24pt, +.visual_font_size_24pt > em, +.visual_font_size_24pt > strong, +.visual_font_size_24pt > strong > span, +.visual_font_size_24pt > span, +.visual_font_size_24pt > strong > em, +.visual_font_size_24pt > em > strong, +.visual_font_size_24pt em span, +.visual_font_size_24pt span em { + font-size: 24pt !important; + line-height: 24pt; } -.visual_font_size_28pt, .visual_font_size_28pt > em, .visual_font_size_28pt > strong, .visual_font_size_28pt > strong > span , .visual_font_size_28pt > span, .visual_font_size_28pt > strong > em, .visual_font_size_28pt > em > strong, .visual_font_size_28pt em span, .visual_font_size_28pt span em { - font-size: 28pt !important; - line-height: 28pt; +.visual_font_size_28pt, +.visual_font_size_28pt > em, +.visual_font_size_28pt > strong, +.visual_font_size_28pt > strong > span, +.visual_font_size_28pt > span, +.visual_font_size_28pt > strong > em, +.visual_font_size_28pt > em > strong, +.visual_font_size_28pt em span, +.visual_font_size_28pt span em { + font-size: 28pt !important; + line-height: 28pt; } -.visual_font_size_36pt, .visual_font_size_36pt > em, .visual_font_size_36pt > strong, .visual_font_size_36pt > strong > span, .visual_font_size_36pt > span, .visual_font_size_36pt > strong > em, .visual_font_size_36pt > em > strong, .visual_font_size_36pt em span, .visual_font_size_36pt span em { - font-size: 36pt !important; - line-height: 36pt; +.visual_font_size_36pt, +.visual_font_size_36pt > em, +.visual_font_size_36pt > strong, +.visual_font_size_36pt > strong > span, +.visual_font_size_36pt > span, +.visual_font_size_36pt > strong > em, +.visual_font_size_36pt > em > strong, +.visual_font_size_36pt em span, +.visual_font_size_36pt span em { + font-size: 36pt !important; + line-height: 36pt; } -.visual_font_size_48pt, .visual_font_size_48pt > em, .visual_font_size_48pt > strong, .visual_font_size_48pt > strong > span, .visual_font_size_48pt > span, .visual_font_size_48pt > strong > em, .visual_font_size_48pt > em > strong, .visual_font_size_48pt em span, .visual_font_size_48pt span em { - font-size: 48pt !important; - line-height: 48pt; +.visual_font_size_48pt, +.visual_font_size_48pt > em, +.visual_font_size_48pt > strong, +.visual_font_size_48pt > strong > span, +.visual_font_size_48pt > span, +.visual_font_size_48pt > strong > em, +.visual_font_size_48pt > em > strong, +.visual_font_size_48pt em span, +.visual_font_size_48pt span em { + font-size: 48pt !important; + line-height: 48pt; } -.visual_font_size_60pt, .visual_font_size_60pt > em, .visual_font_size_60pt > strong, .visual_font_size_60pt > strong > span, .visual_font_size_60pt > span, .visual_font_size_60pt > strong > em, .visual_font_size_60pt > em > strong, .visual_font_size_60pt em span, .visual_font_size_60pt span em { - font-size: 60pt !important; - line-height: 60pt; +.visual_font_size_60pt, +.visual_font_size_60pt > em, +.visual_font_size_60pt > strong, +.visual_font_size_60pt > strong > span, +.visual_font_size_60pt > span, +.visual_font_size_60pt > strong > em, +.visual_font_size_60pt > em > strong, +.visual_font_size_60pt em span, +.visual_font_size_60pt span em { + font-size: 60pt !important; + line-height: 60pt; } -.visual_font_size_72pt, .visual_font_size_72pt > em, .visual_font_size_72pt > strong, .visual_font_size_72pt > strong > span, .visual_font_size_72pt > span, .visual_font_size_72pt > strong > em, .visual_font_size_72pt > em > strong, .visual_font_size_72pt em span, .visual_font_size_72pt span em { - font-size: 72pt !important; - line-height: 72pt; +.visual_font_size_72pt, +.visual_font_size_72pt > em, +.visual_font_size_72pt > strong, +.visual_font_size_72pt > strong > span, +.visual_font_size_72pt > span, +.visual_font_size_72pt > strong > em, +.visual_font_size_72pt > em > strong, +.visual_font_size_72pt em span, +.visual_font_size_72pt span em { + font-size: 72pt !important; + line-height: 72pt; } -.visual_font_size_84pt, .visual_font_size_84pt > em, .visual_font_size_84pt > strong, .visual_font_size_84pt > strong > span, .visual_font_size_84pt > span, .visual_font_size_84pt > strong > em, .visual_font_size_84pt > em > strong, .visual_font_size_84pt em span, .visual_font_size_84pt span em { - font-size: 84pt !important; - line-height: 84pt; +.visual_font_size_84pt, +.visual_font_size_84pt > em, +.visual_font_size_84pt > strong, +.visual_font_size_84pt > strong > span, +.visual_font_size_84pt > span, +.visual_font_size_84pt > strong > em, +.visual_font_size_84pt > em > strong, +.visual_font_size_84pt em span, +.visual_font_size_84pt span em { + font-size: 84pt !important; + line-height: 84pt; } -.visual_font_size_96pt, .visual_font_size_96pt > em, .visual_font_size_96pt > strong, .visual_font_size_96pt > strong > span, .visual_font_size_96pt > span, .visual_font_size_96pt > strong > em, .visual_font_size_96pt > em > strong, .visual_font_size_96pt em span, .visual_font_size_96pt span em { - font-size: 96pt !important; - line-height: 96pt; +.visual_font_size_96pt, +.visual_font_size_96pt > em, +.visual_font_size_96pt > strong, +.visual_font_size_96pt > strong > span, +.visual_font_size_96pt > span, +.visual_font_size_96pt > strong > em, +.visual_font_size_96pt > em > strong, +.visual_font_size_96pt em span, +.visual_font_size_96pt span em { + font-size: 96pt !important; + line-height: 96pt; } -.visual_font_size_116pt, .visual_font_size_116pt > em, .visual_font_size_116pt > strong, .visual_font_size_116pt > strong > span, .visual_font_size_116pt > span, .visual_font_size_116pt > strong > em, .visual_font_size_116pt > em > strong, .visual_font_size_116pt em span, .visual_font_size_116pt span em { - font-size: 116pt !important; - line-height: 116pt; +.visual_font_size_116pt, +.visual_font_size_116pt > em, +.visual_font_size_116pt > strong, +.visual_font_size_116pt > strong > span, +.visual_font_size_116pt > span, +.visual_font_size_116pt > strong > em, +.visual_font_size_116pt > em > strong, +.visual_font_size_116pt em span, +.visual_font_size_116pt span em { + font-size: 116pt !important; + line-height: 116pt; } -.visual_font_size_128pt, .visual_font_size_128pt > em, .visual_font_size_128pt > strong, .visual_font_size_128pt > strong > span, .visual_font_size_128pt > span, .visual_font_size_128pt > strong > em, .visual_font_size_128pt > em > strong, .visual_font_size_128pt em span, .visual_font_size_128pt span em { - font-size: 128pt !important; - line-height: 128pt; +.visual_font_size_128pt, +.visual_font_size_128pt > em, +.visual_font_size_128pt > strong, +.visual_font_size_128pt > strong > span, +.visual_font_size_128pt > span, +.visual_font_size_128pt > strong > em, +.visual_font_size_128pt > em > strong, +.visual_font_size_128pt em span, +.visual_font_size_128pt span em { + font-size: 128pt !important; + line-height: 128pt; } -.visual_font_size_140pt, .visual_font_size_140pt > em, .visual_font_size_140pt > strong, .visual_font_size_140pt > strong > span, .visual_font_size_140pt > span, .visual_font_size_140pt > strong > em, .visual_font_size_140pt > em > strong, .visual_font_size_140pt em span, .visual_font_size_140pt span em { - font-size: 140pt !important; - line-height: 140pt; +.visual_font_size_140pt, +.visual_font_size_140pt > em, +.visual_font_size_140pt > strong, +.visual_font_size_140pt > strong > span, +.visual_font_size_140pt > span, +.visual_font_size_140pt > strong > em, +.visual_font_size_140pt > em > strong, +.visual_font_size_140pt em span, +.visual_font_size_140pt span em { + font-size: 140pt !important; + line-height: 140pt; } -.visual_font_size_154pt, .visual_font_size_154pt > em, .visual_font_size_154pt > strong, .visual_font_size_154pt > strong > span, .visual_font_size_154pt > span, .visual_font_size_154pt > strong > em, .visual_font_size_154pt > em > strong, .visual_font_size_154pt em span, .visual_font_size_154pt span em { - font-size: 154pt !important; - line-height: 154pt; +.visual_font_size_154pt, +.visual_font_size_154pt > em, +.visual_font_size_154pt > strong, +.visual_font_size_154pt > strong > span, +.visual_font_size_154pt > span, +.visual_font_size_154pt > strong > em, +.visual_font_size_154pt > em > strong, +.visual_font_size_154pt em span, +.visual_font_size_154pt span em { + font-size: 154pt !important; + line-height: 154pt; } -.visual_font_size_196pt, .visual_font_size_196pt > em, .visual_font_size_196pt > strong, .visual_font_size_196pt > strong > span, .visual_font_size_196pt > span, .visual_font_size_196pt > strong > em, .visual_font_size_196pt > em > strong, .visual_font_size_196pt em span, .visual_font_size_196pt span em { - font-size: 196pt !important; - line-height: 196pt; +.visual_font_size_196pt, +.visual_font_size_196pt > em, +.visual_font_size_196pt > strong, +.visual_font_size_196pt > strong > span, +.visual_font_size_196pt > span, +.visual_font_size_196pt > strong > em, +.visual_font_size_196pt > em > strong, +.visual_font_size_196pt em span, +.visual_font_size_196pt span em { + font-size: 196pt !important; + line-height: 196pt; } - - -.resize_visual_font_size_8pt, .resize_visual_font_size_8pt > em, .resize_visual_font_size_8pt > strong, .resize_visual_font_size_8pt > strong > span, .resize_visual_font_size_8pt > span, .resize_visual_font_size_8pt > strong > em, .resize_visual_font_size_8pt > em > strong, .visual_font_size_8pt em span, .visual_font_size_8pt span em { - font-size: 4pt !important; - line-height: 4pt; +.resize_visual_font_size_8pt, +.resize_visual_font_size_8pt > em, +.resize_visual_font_size_8pt > strong, +.resize_visual_font_size_8pt > strong > span, +.resize_visual_font_size_8pt > span, +.resize_visual_font_size_8pt > strong > em, +.resize_visual_font_size_8pt > em > strong, +.visual_font_size_8pt em span, +.visual_font_size_8pt span em { + font-size: 4pt !important; + line-height: 4pt; } -.resize_visual_font_size_14pt, .resize_visual_font_size_14pt > em , .resize_visual_font_size_14pt > strong, .resize_visual_font_size_14pt > strong > span, .resize_visual_font_size_14pt > span, .resize_visual_font_size_14pt > strong > em, .resize_visual_font_size_14pt > em > strong, .visual_font_size_14pt em span, .visual_font_size_14pt span em { - font-size: 7pt !important; - line-height: 7pt; +.resize_visual_font_size_14pt, +.resize_visual_font_size_14pt > em, +.resize_visual_font_size_14pt > strong, +.resize_visual_font_size_14pt > strong > span, +.resize_visual_font_size_14pt > span, +.resize_visual_font_size_14pt > strong > em, +.resize_visual_font_size_14pt > em > strong, +.visual_font_size_14pt em span, +.visual_font_size_14pt span em { + font-size: 7pt !important; + line-height: 7pt; } -.resize_visual_font_size_24pt, .resize_visual_font_size_24pt > em, .resize_visual_font_size_24pt > strong, .resize_visual_font_size_24pt > strong > span, .resize_visual_font_size_24pt > span, .resize_visual_font_size_24pt > strong > em, .resize_visual_font_size_24pt > em > strong, .visual_font_size_14pt em span, .visual_font_size_14pt span em { - font-size: 12pt !important; - line-height: 12pt; - +.resize_visual_font_size_24pt, +.resize_visual_font_size_24pt > em, +.resize_visual_font_size_24pt > strong, +.resize_visual_font_size_24pt > strong > span, +.resize_visual_font_size_24pt > span, +.resize_visual_font_size_24pt > strong > em, +.resize_visual_font_size_24pt > em > strong, +.visual_font_size_14pt em span, +.visual_font_size_14pt span em { + font-size: 12pt !important; + line-height: 12pt; } -.resize_visual_font_size_36pt, .resize_visual_font_size_36pt > em, .resize_visual_font_size_36pt > strong, .resize_visual_font_size_36pt > strong > span, .resize_visual_font_size_36pt > span, .resize_visual_font_size_36pt > strong > em, .resize_visual_font_size_36pt > em > strong, .visual_font_size_36pt em span, .visual_font_size_36pt span em { - font-size: 18pt !important; - line-height: 18pt; +.resize_visual_font_size_36pt, +.resize_visual_font_size_36pt > em, +.resize_visual_font_size_36pt > strong, +.resize_visual_font_size_36pt > strong > span, +.resize_visual_font_size_36pt > span, +.resize_visual_font_size_36pt > strong > em, +.resize_visual_font_size_36pt > em > strong, +.visual_font_size_36pt em span, +.visual_font_size_36pt span em { + font-size: 18pt !important; + line-height: 18pt; } -.resize_visual_font_size_72pt, .resize_visual_font_size_72pt > em, .resize_visual_font_size_72pt > strong, .resize_visual_font_size_72pt > strong > span, .resize_visual_font_size_72pt > span, .resize_visual_font_size_72pt > strong > em, .resize_visual_font_size_72pt > em > strong, .visual_font_size_72pt em span, .visual_font_size_72pt span em { - font-size: 36pt !important; - line-height: 36pt; +.resize_visual_font_size_72pt, +.resize_visual_font_size_72pt > em, +.resize_visual_font_size_72pt > strong, +.resize_visual_font_size_72pt > strong > span, +.resize_visual_font_size_72pt > span, +.resize_visual_font_size_72pt > strong > em, +.resize_visual_font_size_72pt > em > strong, +.visual_font_size_72pt em span, +.visual_font_size_72pt span em { + font-size: 36pt !important; + line-height: 36pt; } - /* * --------------------------------------------------------------------- * - LEFT SIDEBAR IN GRAPHS POPUP - stat_win.php - @@ -2550,16 +2888,26 @@ a.tip > img { * --------------------------------------------------------------------- */ input.search_input { - background: white url("../../images/input_zoom.png") no-repeat right; + background-image: url("../../images/input_zoom_gray.png"); + background-position: center right 10px; + background-repeat: no-repeat; + background-size: 17px; + background-color: #f2f6f7 !important; padding: 0px; - padding-left: 5px; margin: 0; - width: 80%; - height: 19px; + width: 200px; + height: 35px; margin-bottom: 5px; margin-left: 2px; - padding-right: 25px; + padding-left: 15px; + padding-right: 40px; color: #999; + font-family: "Open Sans", sans-serif; + border-top-left-radius: 50px; + border-bottom-left-radius: 50px; + border-top-right-radius: 50px; + border-bottom-right-radius: 50px; + border-color: transparent; } /*.vertical_fields td input, .vertical_fields td select { @@ -2574,25 +2922,25 @@ a[id^="tgl_ctrl_"] > b > img { /* Images forced title */ div.forced_title_layer { - display: block; - text-decoration: none; - position: absolute; - z-index: 100000; - border: 1px solid #708090; - background-color: #666; - color: #FFF; - padding: 4px 5px; - font-weight: bold; - font-size: small; - font-size: 11px; - /* IE 8 */ - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=9)"; - /* Netscape */ - -moz-opacity: 0.9; - opacity: 0.9; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; + display: block; + text-decoration: none; + position: absolute; + z-index: 100000; + border: 1px solid #708090; + background-color: #666; + color: #fff; + padding: 4px 5px; + font-weight: bold; + font-size: small; + font-size: 11px; + /* IE 8 */ + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=9)"; + /* Netscape */ + -moz-opacity: 0.9; + opacity: 0.9; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; } /* Graphs styles */ @@ -2627,22 +2975,21 @@ div.nodata_container { } #snmp_data { - width: 40%; - position: absolute; - top:0; - right:20px; + width: 40%; + position: absolute; + top: 0; + right: 20px; } #rmf_data { - width: 40%; - height: 80%; - position: absolute; - top:0; - right:20px; - overflow: auto; + width: 40%; + height: 80%; + position: absolute; + top: 0; + right: 20px; + overflow: auto; } - /* service map */ #container_servicemap_legend { position: absolute; @@ -2858,7 +3205,6 @@ table#policy_modules td * { vertical-align: middle; } - /*.saml_button { float: left; position: fixed; @@ -2870,15 +3216,15 @@ table#policy_modules td * { * - TACTICAL VIEW y TABLAS - * --------------------------------------------------------------------- */ -.status_tactical{ - width: 100%; - margin-left: auto; - margin-right: auto; - background-color: #fff !important; - padding: 10px; - border: 1px solid #e2e2e2; - margin-top: 5%; - text-align: left; +.status_tactical { + width: 100%; + margin-left: auto; + margin-right: auto; + background-color: #fff !important; + padding: 10px; + border: 1px solid #e2e2e2; + margin-top: 5%; + text-align: left; } .status_tactical img { @@ -2943,36 +3289,38 @@ div.div_groups_status { } #title_menu { - color: #fff; + color: #91a2a7; float: right; - width: 70%; + width: 65%; letter-spacing: 0pt; - font-size: 8pt; + font-size: 10pt; white-space: pre-wrap; + padding-top: 0 !important; /* está inline */ + font-family: "Open Sans", sans-serif; } .no_hidden_menu { - background-position: 11% 50% !important; + background-position: 18% 50% !important; } #menu_tab li.nomn, #menu_tab li.nomn_high { - background-color: #ececec; + /*background-color: #ececec;*/ padding-right: 3px; padding-left: 3px; font-weight: bold; text-decoration: none; font-size: 14px; - border-color: #e2e2e2; - border-style: solid; - border-width: 1px; - margin-top: -10px; + border-left: 2px solid #e2e2e2; + margin-top: 0; + min-width: 30px; + height: 28px; } #menu_tab li.nomn_high, #menu_tab li.nomn_high span { color: #fff; - background-color: #fff; + background-color: #ececec; } #menu_tab li.nomn img, @@ -2986,9 +3334,9 @@ div.div_groups_status { background: none !important ; } -.agents_modules_table{ - border: 1px solid #e2e2e2; - border-spacing: 0px; +.agents_modules_table { + border: 1px solid #e2e2e2; + border-spacing: 0px; } .agents_modules_table td { border: 1px solid #e2e2e2; @@ -3052,7 +3400,6 @@ div.div_groups_status { text-align: left !important; } - .green_title { background-color: #82b92e; font-weight: normal; @@ -3144,18 +3491,18 @@ div.div_groups_status { } .vertical_range { - padding: 0; - -webkit-transform: rotate(270deg); + padding: 0; + -webkit-transform: rotate(270deg); -moz-transform: rotate(270deg); transform: rotate(270deg); - width: 200px; - height: 20px; - position: relative; - background: transparent !important; - border: 0px !important; + width: 200px; + height: 20px; + position: relative; + background: transparent !important; + border: 0px !important; - left: -92px; - top: 93px; + left: -92px; + top: 93px; } @media screen and (-webkit-min-device-pixel-ratio: 0) { @@ -3280,20 +3627,18 @@ div#vc-controls div.vc-refr > div { display: inline; } div#vc-controls img.vc-qr { - margin-top: 6px; - margin-left: 8px; - margin-right: 8px; + margin-top: 6px; + margin-left: 8px; + margin-right: 8px; } -div.simple_value > span.text > p, -div.simple_value > span.text > p > span > strong, -div.simple_value > span.text > p > strong, -div.simple_value > a > span.text p -{ - font-family: monospace !important; - white-space: pre; +div.simple_value > span.text > p, +div.simple_value > span.text > p > span > strong, +div.simple_value > span.text > p > strong, +div.simple_value > a > span.text p { + font-family: monospace !important; + white-space: pre; } - /* * --------------------------------------------------------------------- * - EVENTS - @@ -3301,7 +3646,7 @@ div.simple_value > a > span.text p */ /* Image open dialog in group events by agents*/ #open_agent_groups { - cursor: pointer; + cursor: pointer; } /* @@ -3309,266 +3654,267 @@ div.simple_value > a > span.text p * - modal window and edit user - * --------------------------------------------------------------------- */ -#alert_messages{ - -moz-border-bottom-right-radius: 5px; - -webkit-border-bottom-left-radius: 5px; - border-bottom-right-radius: 5px; - border-bottom-left-radius: 5px; - z-index:3; - position:fixed; - width:750px; - max-width:750px; - top: 20%; - background:white; - opacity: 0; - transition: opacity 0.5s; - -webkit-transition: opacity 0.5s; +#alert_messages { + -moz-border-bottom-right-radius: 5px; + -webkit-border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + border-bottom-left-radius: 5px; + z-index: 3; + position: fixed; + width: 750px; + max-width: 750px; + top: 20%; + background: white; + opacity: 0; + transition: opacity 0.5s; + -webkit-transition: opacity 0.5s; } -.modalheader{ - text-align:center; - width:100%; - height:37px; - left:0px; - background-color:#82b92e; +.modalheader { + text-align: center; + width: 100%; + height: 37px; + left: 0px; + background-color: #82b92e; } -.modalheadertext{ - color:white; - position:relative; - font-family:Nunito; - font-size:13pt; - top:8px; +.modalheadertext { + color: white; + position: relative; + font-family: "Nunito", sans-serif; + font-size: 13pt; + top: 8px; } -.modalheaderh1{ - text-align:center; - width:100%; - height:26px; - left:0px; - padding-top:10px; - background-color:#82b92e; - color:white; - position:relative; - font-family:Nunito; - font-size:11pt; +.modalheaderh1 { + text-align: center; + width: 100%; + height: 26px; + left: 0px; + padding-top: 10px; + background-color: #82b92e; + color: white; + position: relative; + font-family: "Nunito", sans-serif; + font-size: 11pt; } -.modalclosex{ - cursor:pointer; - display:inline; - float:right; - margin-right:10px; - margin-top:10px; +.modalclosex { + cursor: pointer; + display: inline; + float: right; + margin-right: 10px; + margin-top: 10px; } -.modalclosex:hover{ - cursor:pointer; - display:inline; - float:right; - margin-right:10px; - margin-top:10px; +.modalclosex:hover { + cursor: pointer; + display: inline; + float: right; + margin-right: 10px; + margin-top: 10px; } -.modalcontent{ - color:black; - background:white; +.modalcontent { + color: black; + background: white; } -.modalcontentimg{ - float:left; - margin-left:30px; - margin-top:30px; - margin-bottom:30px; +.modalcontentimg { + float: left; + margin-left: 30px; + margin-top: 30px; + margin-bottom: 30px; } -.modalcontenttext{ - float:left; - text-align:justify; - color:black; - font-size: 9.5pt; - line-height:13pt; - margin-top:30px; - width:430px; - margin-left:30px; +.modalcontenttext { + float: left; + text-align: justify; + color: black; + font-size: 9.5pt; + line-height: 13pt; + margin-top: 30px; + width: 430px; + margin-left: 30px; } -.modalokbutton{ - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - cursor:pointer; - text-align:center; - margin-right:45px; - float:right; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - margin-bottom:30px; - border-radius: 3px; - width:90px; - height:30px; - background-color:white; - border: 1px solid #82b92e; +.modalokbutton { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + cursor: pointer; + text-align: center; + margin-right: 45px; + float: right; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + margin-bottom: 30px; + border-radius: 3px; + width: 90px; + height: 30px; + background-color: white; + border: 1px solid #82b92e; } -.modalokbuttontext{ - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - color:#82b92e; - font-family:Nunito; - font-size:10pt; - position:relative; - top:6px; +.modalokbuttontext { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color: #82b92e; + font-family: "Nunito", sans-serif; + font-size: 10pt; + position: relative; + top: 6px; } .modalokbutton:hover { - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - background-color:#82b92e; + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + background-color: #82b92e; } .modalokbutton:hover .modalokbuttontext { - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - color:white; + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color: white; } -.modaldeletebutton{ - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - cursor:pointer; - text-align:center; - margin-left:45px; - float:left; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - margin-bottom:30px; - border-radius: 3px; - width:90px; - height:30px; - background-color:white; - border: 1px solid #FA5858; +.modaldeletebutton { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + cursor: pointer; + text-align: center; + margin-left: 45px; + float: left; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + margin-bottom: 30px; + border-radius: 3px; + width: 90px; + height: 30px; + background-color: white; + border: 1px solid #fa5858; } -.modaldeletebuttontext{ - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - color:#FA5858; - font-family:Nunito; - font-size:10pt; - position:relative;top:6px; +.modaldeletebuttontext { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color: #fa5858; + font-family: "Nunito", sans-serif; + font-size: 10pt; + position: relative; + top: 6px; } .modaldeletebutton:hover .modaldeletebuttontext { - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - color:white; + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color: white; } .modaldeletebutton:hover { - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - background-color:#FA5858; + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + background-color: #fa5858; } -.modalgobutton{ - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - cursor:pointer; - text-align:center; - margin-right:15px; - margin-bottom:30px; - float:right; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - width:240px; - height:30px; - background-color:white; - border: 1px solid #82b92e; +.modalgobutton { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + cursor: pointer; + text-align: center; + margin-right: 15px; + margin-bottom: 30px; + float: right; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + width: 240px; + height: 30px; + background-color: white; + border: 1px solid #82b92e; } -.modalgobuttontext{ - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - color:#82b92e; - font-family:Nunito; - font-size:10pt; - position:relative; - top:6px; +.modalgobuttontext { + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color: #82b92e; + font-family: "Nunito", sans-serif; + font-size: 10pt; + position: relative; + top: 6px; } .modalgobutton:hover { - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - background-color:#82b92e; + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + background-color: #82b92e; } .modalgobutton:hover .modalgobuttontext { - transition-property: background-color, color; - transition-duration: 1s; - transition-timing-function: ease-out; - -webkit-transition-property: background-color, color; - -webkit-transition-duration: 1s; - -o-transition-property: background-color, color; - -o-transition-duration: 1s; - color:white; + transition-property: background-color, color; + transition-duration: 1s; + transition-timing-function: ease-out; + -webkit-transition-property: background-color, color; + -webkit-transition-duration: 1s; + -o-transition-property: background-color, color; + -o-transition-duration: 1s; + color: white; } /* update manager online */ -#opacidad{ - opacity:0; - transition: opacity 3s; - -webkit-transition: opacity 3s; - z-index:1; - width:100%; - height:100%; - position:absolute; - left:0px; - top:0px; +#opacidad { + opacity: 0; + transition: opacity 3s; + -webkit-transition: opacity 3s; + z-index: 1; + width: 100%; + height: 100%; + position: absolute; + left: 0px; + top: 0px; } .textodialogo { @@ -3578,98 +3924,99 @@ div.simple_value > a > span.text p font-size: 9pt; } -.cargatextodialogo{ - max-width:58.5%; - width:58.5%; - min-width:58.5%; - float:left; - margin-left: 0px; - font-size:18pt; - padding:20px; - text-align:center; +.cargatextodialogo { + max-width: 58.5%; + width: 58.5%; + min-width: 58.5%; + float: left; + margin-left: 0px; + font-size: 18pt; + padding: 20px; + text-align: center; } -.cargatextodialogo p, .cargatextodialogo b, .cargatextodialogo a{ - font-size:18pt; +.cargatextodialogo p, +.cargatextodialogo b, +.cargatextodialogo a { + font-size: 18pt; } - /* global */ -.readonly{ - background-color: #dedede !important; +.readonly { + background-color: #dedede !important; } .input_error { - border: 1px solid red; + border: 1px solid red; } -#toolbox > input{ - border-width:0px 1px 0px 0px; - border-color: lightgray; +#toolbox > input { + border-width: 0px 1px 0px 0px; + border-color: lightgray; } -#toolbox > input.service_min{ - border-width:0px 0px 0px 0px; +#toolbox > input.service_min { + border-width: 0px 0px 0px 0px; } -#toolbox > input.grid_min{ - border-width:0px 0px 0px 0px; +#toolbox > input.grid_min { + border-width: 0px 0px 0px 0px; } #filter_event_status, #filter_event_severity, #filter_event_type { - width:50%; + width: 50%; } -.rowPair:hover, .rowOdd:hover{ - background-color: #eee; +.rowPair:hover, +.rowOdd:hover { + background-color: #eee; } -.databox.data > tbody > tr:hover{ - background-color: #eee; +.databox.data > tbody > tr:hover { + background-color: #eee; } -.checkselected{ - background-color: #eee; +.checkselected { + background-color: #eee; } -.tag-wrapper{ - padding: 0 10px 0 0; - overflow: auto; +.tag-wrapper { + padding: 0 10px 0 0; + overflow: auto; } -.pandora-tag{ - float:left; - margin-bottom:18px; - padding:1px 6px 1px 0; +.pandora-tag { + float: left; + margin-bottom: 18px; + padding: 1px 6px 1px 0; } -.pandora-tag-title{ - color: white; - background-color: #373737; - font-weight: bold; - padding: 6px 6px 6px 10px; - border: #373737; - border-width: 1px; - border-top-style: solid; - border-top-left-radius: 12px; - border-left-style: solid; - border-bottom-left-radius: 12px; - border-bottom-style: solid; +.pandora-tag-title { + color: white; + background-color: #373737; + font-weight: bold; + padding: 6px 6px 6px 10px; + border: #373737; + border-width: 1px; + border-top-style: solid; + border-top-left-radius: 12px; + border-left-style: solid; + border-bottom-left-radius: 12px; + border-bottom-style: solid; } -.pandora-tag-value{ - color: #373737; - font-weight: bold; - padding: 6px 10px 6px 6px; - border: #373737; - border-width: 1px; - border-top-style: solid; - border-top-right-radius: 12px; - border-right-style: solid; - border-bottom-right-radius: 12px; - border-bottom-style: solid; +.pandora-tag-value { + color: #373737; + font-weight: bold; + padding: 6px 10px 6px 6px; + border: #373737; + border-width: 1px; + border-top-style: solid; + border-top-right-radius: 12px; + border-right-style: solid; + border-bottom-right-radius: 12px; + border-bottom-style: solid; } - /* * --------------------------------------------------------------------- * - HELP MODAL WINDOWS - pandora_help.php - @@ -3718,7 +4065,6 @@ div#footer_help { padding: 10px; } - /* EVENTS - /ajax/events.php */ /*view-agents lastest events for this agent*/ #div_all_events_24h { @@ -3730,8 +4076,8 @@ div#footer_help { * - REPORTS - graph_container.php - * --------------------------------------------------------------------- */ -.graph_conteiner_inside > .parent_graph{ - width: 100% !important; +.graph_conteiner_inside > .parent_graph { + width: 100% !important; } .graph_conteiner_inside > .parent_graph > .menu_graph { @@ -3755,15 +4101,15 @@ div#footer_help { * - WUX VIEW - * --------------------------------------------------------------------- */ -#mssg_error_div{ - color: red; - font-size: 12px; +#mssg_error_div { + color: red; + font-size: 12px; } -.wux_global_result_container{ - width: 100%; - margin-top: 30px; - margin-bottom: 30px; +.wux_global_result_container { + width: 100%; + margin-top: 30px; + margin-bottom: 30px; } .wux_global_result_title { @@ -3965,10 +4311,9 @@ form ul.form_flex li ul li { cursor: pointer; } - /* snmp */ #snmp_data { - background: #f9faf9; + background: #f9faf9; } #snmp_data .databox { border: 0px; @@ -3981,7 +4326,6 @@ form ul.form_flex li ul li { width: auto !important; } - /* dialog */ .pandora_confirm_dialog .ui-dialog-buttonset { display: flex; @@ -4032,12 +4376,12 @@ tr:first-child > td > a.up_arrow { } /* system group status */ -.group_modules_status_box>tbody>tr>td{ - border-bottom: 1px solid #e2e2e2; - border-collapse: collapse; - border-spacing:0; - width: 10%; - height: 20px; +.group_modules_status_box > tbody > tr > td { + border-bottom: 1px solid #e2e2e2; + border-collapse: collapse; + border-spacing: 0; + width: 10%; + height: 20px; } .group_modules_status_div { @@ -4051,10 +4395,10 @@ tr:first-child > td > a.up_arrow { } /* extensions -> module groups */ -.tooltip_counters h3{ - font-size: 12pt; - padding-bottom: 10px !important; - text-align: center; +.tooltip_counters h3 { + font-size: 12pt; + padding-bottom: 10px !important; + text-align: center; } .tooltip_counters li { @@ -4083,9 +4427,104 @@ div#dialog_messages table th:last-child { text-align: right; } +/* checkbox type toogle switch */ +.toogle_switch { + position: relative; + display: inline-block; + width: 47px; + height: 24px; +} + +.toogle_switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: 0.7s; + transition: 0.7s; + border-radius: 34px; +} + +.slider:before { + position: absolute; + content: ""; + height: 16px; + width: 16px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: 0.7s; + transition: 0.7s; + border-radius: 50%; +} + +input:checked + .slider { + background-color: #82b92e; +} + +input:focus + .slider { + box-shadow: 0 0 1px #82b92e; +} + +input:checked + .slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); + background-color: rgb(197, 235, 192); +} /* jQuery dialog */ .no-close .ui-dialog-titlebar-close { display: none; } /* jQuery dialog */ + +/* + * --------------------------------------------------------------------- + * - STYLES TO CHANGE CLASSIC MENU AND COLLAPSED MENU - + * --------------------------------------------------------------------- + */ +.page_classic { + padding-left: 215px !important; +} + +.page_collapsed { + padding-left: 60px !important; +} + +.header_table_classic { + padding-left: 245px !important; +} + +.header_table_collapsed { + padding-left: 90px !important; +} + +.title_menu_classic { + display: block !important; +} + +.title_menu_collapsed { + display: none !important; +} + +.logo_show { + display: block !important; +} + +.logo_hide { + display: none !important; +} + +.menu_icon_collapsed { + background-position: 50% 50% !important; +} diff --git a/pandora_console/index.php b/pandora_console/index.php index ad4b93465a..b68424d805 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1029,11 +1029,11 @@ if ($config['pure'] == 0) { echo ''; - echo '
          '; + echo '
          '; } else { echo '
          '; } @@ -1363,4 +1363,3 @@ require 'include/php_to_js_values.php'; if (__PAN_XHPROF__ === 1) { pandora_xhprof_display_result('node_index'); } - From 6ec148c59c7980e4b9c792b59480ab3589ad29d3 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Mon, 25 Feb 2019 12:28:41 +0100 Subject: [PATCH 187/262] new header and menu Former-commit-id: 4375597f0b77ccc577fa486c409e214a7ba00362 --- pandora_console/include/styles/menu.css | 21 --------------------- pandora_console/include/styles/pandora.css | 18 +----------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index d9ba90e604..cf8e88bae7 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -51,13 +51,9 @@ li:hover ul { padding: 10.5px; margin-left: 0px; width: 100%; -<<<<<<< HEAD color: #91a2a7; font-family: "Open Sans", sans-serif; font-size: 10pt; -======= - color: #fff; ->>>>>>> 01fee147745dfd638487449f20211abd8e83b71e } .menu li.subselected a { @@ -285,12 +281,6 @@ ul li a:hover { * - MAIN LEFT MENU and SUBMENU - * --------------------------------------------------------------------- */ -<<<<<<< HEAD -======= -.menu li.selected { - font-weight: bold; -} ->>>>>>> 01fee147745dfd638487449f20211abd8e83b71e .menu_icon { transition-property: background-color; @@ -320,11 +310,7 @@ ul li a:hover { -o-transition-property: background-color; -o-transition-duration: 0.5s; -o-transition-timing-function: ease-out; -<<<<<<< HEAD background-color: #282828 !important; -======= - background-color: #585858 !important; ->>>>>>> 01fee147745dfd638487449f20211abd8e83b71e } .submenu_not_selected:hover { transition-property: background-color; @@ -339,17 +325,10 @@ ul li a:hover { -o-transition-property: background-color; -o-transition-duration: 0.5s; -o-transition-timing-function: ease-out; -<<<<<<< HEAD background-color: #202020 !important; } .submenu_selected:hover { background-color: #202020 !important; -======= - background-color: #585858 !important; -} -.submenu_selected:hover { - background-color: #585858 !important; ->>>>>>> 01fee147745dfd638487449f20211abd8e83b71e } .sub_subMenu { transition-property: background-color; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index bcd011188d..e8e2632188 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -441,14 +441,6 @@ textarea.conf_error { background-position: top right; } -input.button { - font-family: Arial, Sans-serif; - border: 4px solid #ccc; - background: #fff; - padding: 2px 3px; - margin: 10px 15px; -} - a.white_bold { color: #eee; text-decoration: none; @@ -1562,9 +1554,6 @@ table.databox { font-weight: normal; color: #fff; } -.databox > td { - #border-bottom: 1px solid #e2e2e2; -} .databox > th * { color: #fff; @@ -2192,9 +2181,6 @@ div.warn { min-height: 35px !important; } -ol.steps { - margin-bottom: 70px; -} div#steps_clean { display: none; } @@ -2990,6 +2976,7 @@ div.nodata_container { position: absolute; top: 0; right: 20px; + background: #f9faf9; } #rmf_data { @@ -4323,9 +4310,6 @@ form ul.form_flex li ul li { } /* snmp */ -#snmp_data { - background: #f9faf9; -} #snmp_data .databox { border: 0px; } From cdca720d9abb9a8d388ac5f5118baf0cf8496860 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 25 Feb 2019 14:41:27 +0100 Subject: [PATCH 188/262] minor fix user_edig Former-commit-id: 2e13b75edd5625fa2d1d6d9360d55a19f0992ac0 --- pandora_console/godmode/servers/discovery.php | 15 --------------- pandora_console/operation/users/user_edit.php | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 9606e296bf..41f7fd1ffc 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -96,21 +96,6 @@ foreach ($classes as $classpath) { include_once $classpath; } -// Load enterprise wizards. -if (enterprise_installed() === true) { - $enterprise_classes = glob( - $config['homedir'].'/'.ENTERPRISE_DIR.'/wizards/*.class.php' - ); - foreach ($enterprise_classes as $classpath) { - $r = enterprise_include_once( - 'wizards/'.basename($classpath) - ); - } -} - -// Combine class paths. -$classes = array_merge($classes, $enterprise_classes); - // Sort output. uasort($classes, 'cl_load_cmp'); diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 46ebe87999..3e3338ff96 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -600,7 +600,7 @@ $table->rowclass[] = ''; $table->rowstyle[] = ''; $table->data[] = $data; -echo '
          '; +echo ''; html_print_table($table); From 67e53bf7a7894006b5e06dccd135e634b16b34e0 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 25 Feb 2019 16:15:17 +0100 Subject: [PATCH 189/262] add new way of importing css for treeview Former-commit-id: d88bb38ac7d20ab5f554cfb1399b17ddf6f62fb2 --- pandora_console/include/styles/pandora.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 180c187db0..70a9c4920e 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -21,8 +21,8 @@ Description: The default Pandora FMS theme layout */ /* Tree view styles */ -@import url(tree.css); -@import url(fixed-bottom-box.css); +/*@import url(tree.css); +@import url(fixed-bottom-box.css);*/ /* * --------------------------------------------------------------------- From b7cc25314da49d96b8f6e243f7c763b76df2d572 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 25 Feb 2019 16:20:05 +0100 Subject: [PATCH 190/262] Unified sizes of the checkbox switch Former-commit-id: 392fdf006c81fb5586349b8a4b4544e0c07aa903 --- pandora_console/include/styles/pandora.css | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 7cc134c76a..51c7ab8fc5 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4488,8 +4488,8 @@ ul.ui-front li a.ui-menu-item-wrapper:hover { .toogle_switch { position: relative; display: inline-block; - width: 47px; - height: 24px; + width: 30px; + height: 17px; } .toogle_switch input { @@ -4506,21 +4506,21 @@ ul.ui-front li a.ui-menu-item-wrapper:hover { right: 0; bottom: 0; background-color: #ccc; - -webkit-transition: 0.7s; - transition: 0.7s; + -webkit-transition: 0.4s; + transition: 0.4s; border-radius: 34px; } .slider:before { position: absolute; content: ""; - height: 16px; - width: 16px; - left: 4px; - bottom: 4px; + height: 13px; + width: 13px; + left: 2px; + bottom: 2px; background-color: white; - -webkit-transition: 0.7s; - transition: 0.7s; + -webkit-transition: 0.4s; + transition: 0.4s; border-radius: 50%; } @@ -4533,10 +4533,9 @@ input:focus + .slider { } input:checked + .slider:before { - -webkit-transform: translateX(26px); - -ms-transform: translateX(26px); - transform: translateX(26px); - background-color: rgb(197, 235, 192); + -webkit-transform: translateX(13px); + -ms-transform: translateX(13px); + transform: translateX(13px); } /* jQuery dialog */ From ac9452583a6103eaa8134f747f0f55812bc063f3 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Feb 2019 16:50:27 +0100 Subject: [PATCH 191/262] Added no data to show to some graphs where id not found Former-commit-id: 1697a482e80521666f679eb18d2f44fc3975e304 --- pandora_console/include/functions_graph.php | 25 ++++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index cbdada69b9..71049d7804 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -549,12 +549,6 @@ function grafico_modulo_sparse($params) return false; } - if (!isset($params['agent_module_id'])) { - return false; - } else { - $agent_module_id = $params['agent_module_id']; - } - if (!isset($params['period'])) { return false; } @@ -710,6 +704,12 @@ function grafico_modulo_sparse($params) $params['projection'] = false; } + if (!isset($params['agent_module_id'])) { + return graph_nodata_image($params['width'], $params['height']); + } else { + $agent_module_id = $params['agent_module_id']; + } + // XXXX Configurable $params['grid_color'] = '#C1C1C1'; $params['legend_color'] = '#636363'; @@ -1318,6 +1318,10 @@ function graphic_combined_module( $array_data = []; foreach ($module_list as $key => $agent_module_id) { + if ((bool) $agent_module_id === false) { + continue; + } + if (is_metaconsole() && $params_combined['type_report'] == 'automatic_graph') { $server = metaconsole_get_connection_by_id($agent_module_id['server']); if (metaconsole_connect($server) != NOERR) { @@ -1394,6 +1398,15 @@ function graphic_combined_module( } } + if (empty($array_data)) { + if ($params_combined['return']) { + return graph_nodata_image($width, $height); + } + + echo graph_nodata_image($width, $height); + return false; + } + if ($params_combined['projection']) { // If projection doesn't have data then don't draw graph if ($output_projection != null) { From db5d2ceee142a2154e6a2a3b747cbd9e5e08edbe Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 25 Feb 2019 17:04:07 +0100 Subject: [PATCH 192/262] fix bad routes in services treeview Former-commit-id: 27bfcca5a7e0f7c3929e2a1f449c0f1d318891c9 --- pandora_console/include/class/TreeService.class.php | 4 ++-- .../include/javascript/tree/TreeController.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index bbddc8dc2a..d211cd1055 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -161,7 +161,7 @@ class TreeService extends Tree { $services[$service['id']]['counters'] = array('total_services'=>$service['total_services'], 'total_agents'=>$service['total_agents'], 'total_modules'=>$service['total_modules']); $services[$service['id']]['name'] = $service['name']; $services[$service['id']]['id'] = $service['id']; - $services[$service['id']]['serviceDetail']='http://localhost/pandora_console/index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id']; + $services[$service['id']]['serviceDetail']='index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id']; } return $services; @@ -241,7 +241,7 @@ class TreeService extends Tree { $service_stats[$service['id']]['rootType'] = $service['rootType']; $service_stats[$service['id']]['type'] = 'services'; $service_stats[$service['id']]['children']=array(); - $service_stats[$service['id']]['serviceDetail']='http://localhost/pandora_console/index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id']; + $service_stats[$service['id']]['serviceDetail']='index.php?sec=network&sec2=enterprise/operation/services/services&tab=service_map&id_service='.(int)$service['id']; $service_stats[$service['id']]['counters']=array('total_services'=>$service['total_services'], 'total_agents'=>$service['total_agents'], 'total_modules'=>$service['total_modules']); } diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 3fab4f6dab..3e177f3ae9 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -523,7 +523,8 @@ var TreeController = { if (typeof element.eventAgent != 'undefined') { $content.append(''); - var $eventImage = $(''); + var $eventImage = $(' '); $eventImage.addClass("agent-alerts-fired"); $eventImage .click(function (e) { @@ -550,7 +551,8 @@ var TreeController = { } - var $serviceDetailImage = $(''); + var $serviceDetailImage = $(' '); if (typeof element.serviceDetail != 'undefined') { @@ -585,7 +587,8 @@ var TreeController = { if (typeof element.eventModule != 'undefined') { $content.append(''); - var $moduleImage = $(''); + var $moduleImage = $(' '); $moduleImage .click(function (e) { e.preventDefault(); From 16f14746917d29b7c8a9b5016c4e6b18438bb0a4 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 25 Feb 2019 17:45:37 +0100 Subject: [PATCH 193/262] Added models in tlog_graph_models Former-commit-id: 76d6f1358677c02eab4681a1bb290fda0476c91b --- pandora_console/extras/mr/25.sql | 24 ++++++++++++++++++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 25 ++++++++++++++++++- pandora_console/pandoradb_data.sql | 24 ++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 3f0c2f7c0b..828e6972e3 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -118,4 +118,28 @@ INSERT INTO `tnotification_source_user` (`id_source`, `id_user`, `enabled`, `als INSERT INTO `tnotification_source_group` SELECT `id`,0 FROM `tnotification_source` WHERE `description`="Message"; INSERT INTO `tnotification_user` (`id_mensaje`, `id_user`) SELECT `id_mensaje`, `id_usuario_destino` FROM `tmensajes` WHERE `id_usuario_destino` != ''; +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Apache accesses per client and status', +'(.*?)\ -.*1.1"\ (\d+)\ \d+', +'host,status', 1); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Apache time per requester and html code', +'(.*?)\ -.*1.1"\ (\d+)\ (\d+)', +'origin,respose,_time_', 1); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Count output', +'.*', +'Coincidences', 0); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Events replicated to metaconsole', +'.* (.*?) .* (\d+) events replicated to metaconsole', +'server,_events_', 0); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Pages with warnings', +'PHP Warning:.*in (.*?) on', +'page', 0); + +INSERT INTO tlog_graph_models (`title`,`regexp`,`fields`,`average`) VALUES ('Users login', +'Starting Session \d+\ of user (.*)', +'user', 0); + COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 21e46e3697..8e30b63487 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1820,7 +1820,30 @@ CREATE TABLE IF NOT EXISTS `tlog_graph_models` ( INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', 'pagina, html_err_code, _tiempo_', 1); - + +INSERT INTO tlog_graph_models VALUES (2, 'Apache accesses per client and status', +'(.*?)\ -.*1.1"\ (\d+)\ \d+', +'host,status', 1); + +INSERT INTO tlog_graph_models VALUES (3, 'Apache time per requester and html code', +'(.*?)\ -.*1.1"\ (\d+)\ (\d+)', +'origin,respose,_time_', 1); + +INSERT INTO tlog_graph_models VALUES (4, 'Count output', +'.*', +'Coincidences', 0); + +INSERT INTO tlog_graph_models VALUES (5, 'Events replicated to metaconsole', +'.* (.*?) .* (\d+) events replicated to metaconsole', +'server,_events_', 0); + +INSERT INTO tlog_graph_models VALUES (6, 'Pages with warnings', +'PHP Warning:.*in (.*?) on', +'page', 0); + +INSERT INTO tlog_graph_models VALUES (7, 'Users login', +'Starting Session \d+\ of user (.*)', +'user', 0); -- ----------------------------------------------------- -- Add column in table `treport` -- ----------------------------------------------------- diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 4f9c9c54ec..f5da1f12fa 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -1269,6 +1269,30 @@ INSERT INTO tlog_graph_models VALUES (1, 'Apache log model', '^.*?\s+.*".*?\s(\/.*?)\?.*1.1"\s+(.*?)\s+(.*?)\s+', 'pagina, html_err_code, _tiempo_', 1); +INSERT INTO tlog_graph_models VALUES (2, 'Apache accesses per client and status', +'(.*?)\ -.*1.1"\ (\d+)\ \d+', +'host,status', 1); + +INSERT INTO tlog_graph_models VALUES (3, 'Apache time per requester and html code', +'(.*?)\ -.*1.1"\ (\d+)\ (\d+)', +'origin,respose,_time_', 1); + +INSERT INTO tlog_graph_models VALUES (4, 'Count output', +'.*', +'Coincidences', 0); + +INSERT INTO tlog_graph_models VALUES (5, 'Events replicated to metaconsole', +'.* (.*?) .* (\d+) events replicated to metaconsole', +'server,_events_', 0); + +INSERT INTO tlog_graph_models VALUES (6, 'Pages with warnings', +'PHP Warning:.*in (.*?) on', +'page', 0); + +INSERT INTO tlog_graph_models VALUES (7, 'Users login', +'Starting Session \d+\ of user (.*)', +'user', 0); + -- -- Dumping data for table `tnotification_source` -- From 13cbc78fddf6ca417efb16e553f9a0551051b7e1 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 25 Feb 2019 18:41:24 +0100 Subject: [PATCH 194/262] change mr and migrate for table twidget Former-commit-id: d7d07f5e036a8dd81debcb974bd42217e2b59b26 --- pandora_console/extras/mr/25.sql | 5 +++++ .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + 2 files changed, 6 insertions(+) create mode 100644 pandora_console/extras/mr/25.sql diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql new file mode 100644 index 0000000000..29da43216c --- /dev/null +++ b/pandora_console/extras/mr/25.sql @@ -0,0 +1,5 @@ +START TRANSACTION; + +UPDATE `twidget` SET `unique_name`='example2' WHERE `class_name` LIKE 'WelcomeWidget'; + +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index bedb9927cd..bdbb4d958f 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1412,6 +1412,7 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; -- --------------------------------------------------------------------- UPDATE twidget_dashboard SET id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_module_histogram') WHERE id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_availability'); DELETE FROM twidget WHERE unique_name = 'graph_availability'; +UPDATE `twidget` SET `unique_name`='example2' WHERE `class_name` LIKE 'WelcomeWidget'; -- --------------------------------------------------------------------- -- Table `tbackup` (Extension table. Modify only if exists) From 4bf746956509a9b2de4275ffa100ba3fca643857 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 25 Feb 2019 18:42:52 +0100 Subject: [PATCH 195/262] change mr and migrate for table twidget Former-commit-id: fb7bfc3771b2c019a7e70771d4e5bd47043ba99b --- pandora_console/extras/mr/25.sql | 2 +- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/extras/mr/25.sql b/pandora_console/extras/mr/25.sql index 29da43216c..35a0587abb 100644 --- a/pandora_console/extras/mr/25.sql +++ b/pandora_console/extras/mr/25.sql @@ -1,5 +1,5 @@ START TRANSACTION; -UPDATE `twidget` SET `unique_name`='example2' WHERE `class_name` LIKE 'WelcomeWidget'; +UPDATE `twidget` SET `unique_name`='example' WHERE `class_name` LIKE 'WelcomeWidget'; COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index bdbb4d958f..0b3292fd02 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1412,7 +1412,7 @@ ALTER TABLE trecon_task ADD `vlan_enabled` int(2) unsigned default '0'; -- --------------------------------------------------------------------- UPDATE twidget_dashboard SET id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_module_histogram') WHERE id_widget = (SELECT id FROM twidget WHERE unique_name = 'graph_availability'); DELETE FROM twidget WHERE unique_name = 'graph_availability'; -UPDATE `twidget` SET `unique_name`='example2' WHERE `class_name` LIKE 'WelcomeWidget'; +UPDATE `twidget` SET `unique_name`='example' WHERE `class_name` LIKE 'WelcomeWidget'; -- --------------------------------------------------------------------- -- Table `tbackup` (Extension table. Modify only if exists) From 88202977fa8baf2cd3d989b3aaf2a61866f333f1 Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 26 Feb 2019 00:01:57 +0100 Subject: [PATCH 196/262] Auto-updated build strings. Former-commit-id: e3e3a3aba908a64a4743bd8b18337510e0c6e609 --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 4 ++-- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 6af9c8cebe..e9d22f629b 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.731-190225 +Version: 7.0NG.731-190226 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 885349a84a..64c13e926e 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190225" +pandora_version="7.0NG.731-190226" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 1b0beb6592..bb7d98e310 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.731'; -use constant AGENT_BUILD => '190225'; +use constant AGENT_BUILD => '190226'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 479ec78469..d4e33903d4 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190225 +%define release 190226 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 958ec6edb9..87436366bb 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190225 +%define release 190226 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 324749839f..3ff9b6a963 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190225" +PI_BUILD="190226" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index a9f356dcf9..abdf2e0ce4 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190225} +{190226} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 1cdb4731e9..01f027089d 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.731(Build 190225)") +#define PANDORA_VERSION ("7.0NG.731(Build 190226)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 4ed34ac285..cb30f2163d 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.731(Build 190225))" + VALUE "ProductVersion", "(7.0NG.731(Build 190226))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 84bd5108d8..fe87752dff 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.731-190225 +Version: 7.0NG.731-190226 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index ed29060a70..60d17de09e 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190225" +pandora_version="7.0NG.731-190226" package_pear=0 package_pandora=1 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/install.php b/pandora_console/install.php index 063fa77556..ec9414274a 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -128,8 +128,8 @@
          [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 5da2297eb0..076f19497a 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190225 +%define release 190226 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index e56f0ab35b..e3adf2711e 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190225 +%define release 190226 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index d06e349eb9..55915d85a0 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190225" +PI_BUILD="190226" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 5885720b13..c8eb037f7a 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.731 PS190225"; +my $version = "7.0NG.731 PS190226"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 7a04ff00f1..33a9c811b8 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.731 PS190225"; +my $version = "7.0NG.731 PS190226"; # save program name for logging my $progname = basename($0); From d4c46ec14f12359aaf1d31dbbb7a3626d6c1b8d5 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 26 Feb 2019 08:44:50 +0100 Subject: [PATCH 197/262] fix minor error Former-commit-id: 81b5c41c49a5e121c5ac34c12bfd5b1b7f5f943a --- pandora_console/include/functions_config.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 475ef2db79..ce69858132 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -755,6 +755,10 @@ function config_update_config() if (!config_update_value('max_graph_container', get_parameter('max_graph_container'))) { $error_update[] = __('Graph container - Max. Items'); } + + if (!config_update_value('max_execution_event_response', get_parameter('max_execution_event_response'))) { + $error_update[] = __('Max execution event response'); + } break; case 'vis': @@ -1547,6 +1551,10 @@ function config_process_config() config_update_value('max_graph_container', 10); } + if (!isset($config['max_execution_event_response'])) { + config_update_value('max_execution_event_response', 10); + } + if (!isset($config['max_macro_fields'])) { config_update_value('max_macro_fields', 10); } From de7c1ce978f508e071aad2923b6dbe7358dfd98b Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Tue, 26 Feb 2019 09:40:04 +0100 Subject: [PATCH 198/262] Fixed ACL selection menu wrong sec for visual console Former-commit-id: dd9f4a212f43774c2602932baa0c1a83e3ba6e56 --- pandora_console/include/functions_menu.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 39e5adf455..7012094570 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -510,8 +510,6 @@ function menu_add_extras(&$menu) $menu_extra['workspace']['sub']['operation/incidents/incident_detail']['text'] = __('Manage incident'); - $menu_extra['reporting']['sub']['godmode/reporting/visual_console_builder']['text'] = __('Manage visual console'); - // Duplicate extensions as sec=extension to check it from url foreach ($menu as $k => $m) { if (!isset($m['sub'])) { @@ -649,6 +647,7 @@ function menu_get_sec_pages($sec, $menu_hash=false) /** * Get the pages in a section2 + * $menu * * @param string sec code * @param string menu hash. All the menu structure (For example From c38ac4b837aaa8ecb2a1a3de489889243ef8864e Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 Feb 2019 10:34:37 +0100 Subject: [PATCH 199/262] Updated breadcrum Former-commit-id: 51c14ea50e6c7d419d610ef1b52c4769214495ef --- pandora_console/godmode/wizards/HostDevices.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 6e31299b9a..aa5c94666c 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -476,6 +476,10 @@ class HostDevices extends Wizard $task_url = '&task='.$this->task['id_rt']; } + $breadcrum[] = [ + 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd', + 'label' => __($this->label), + ]; for ($i = 0; $i < $this->maxPagesNetScan; $i++) { $breadcrum[] = [ 'link' => 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd&mode=netscan&page='.$i.$task_url, @@ -710,9 +714,6 @@ $("select#interval_manual_defined").change(function() { // XXX: Could be improved validating inputs before continue (JS) // Print NetScan page 0. $this->printForm($form); - $this->printGoBackButton( - $this->url.'&page='.($this->page - 1).$task_url - ); } } From 3e87c8e93127e1e121dc6b2c4c5ebda44e3e63d1 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Tue, 26 Feb 2019 10:43:59 +0100 Subject: [PATCH 200/262] new header and menu Former-commit-id: 975b72219cb07e0d4f9b332607e554bd65ea7cc3 --- pandora_console/general/footer.php | 25 +- pandora_console/general/header.php | 1 + pandora_console/general/main_menu.php | 52 +-- pandora_console/godmode/menu.php | 19 +- pandora_console/include/functions_config.php | 423 ++++++------------- pandora_console/include/functions_menu.php | 4 +- pandora_console/include/styles/menu.css | 96 ++++- pandora_console/include/styles/pandora.css | 329 ++++++++++++++- 8 files changed, 589 insertions(+), 360 deletions(-) diff --git a/pandora_console/general/footer.php b/pandora_console/general/footer.php index b847b93f48..48d0613c98 100644 --- a/pandora_console/general/footer.php +++ b/pandora_console/general/footer.php @@ -1,16 +1,19 @@ "; +/* +var type_menu = " + +"; if(type_menu){ console.log('es clasico, mantenlo'); } else{ - console.log('es colapsado, mantenlo'); + console.log('es collapsed, mantenlo'); } - -//Asignar por defecto colapsado !!! IMPORTANTE!!!!!!!!!!!!!!!!!!!!!!!!! +*/ +//Asignar por defecto collapsed !!! IMPORTANTE!!!!!!!!!!!!!!!!!!!!!!!!! $(document).ready(function(){ - var variable_boton = localStorage.getItem("variable"); - document.getElementById("menu_type").innerHTML = variable_boton; + var menuType_value = localStorage.getItem("menuType"); + document.getElementById("menu_type").innerHTML = menuType_value; - if ($('#menu_type').text() == 'colapsado' || $('#menu_type').text() == '') { + if ($('#menu_type').text() == 'collapsed' || $('#menu_type').text() == '') { if($('#menu_type').text() == ''){ - localStorage.setItem("variable", "colapsado"); - document.getElementById("menu_type").innerHTML = localStorage.variable; + localStorage.setItem("menuType", "collapsed"); + document.getElementById("menu_type").innerHTML = localStorage.menuType; } $('#menu_full').removeClass('menu_full_classic').addClass('menu_full_collapsed'); @@ -58,7 +62,7 @@ $(document).ready(function(){ $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed');//PROBLEMA Y TB SBMENU NO HIDDEN $('#top_btn').css('left', '0px'); } - else if ($('#menu_type').text() == 'clasico') { + else if ($('#menu_type').text() == 'classic') { $('#menu_full').removeClass('menu_full_collapsed').addClass('menu_full_classic'); /* $('.logo_icon').removeClass('logo_show').addClass('logo_hide'); $('.logo_full').removeClass("logo_hide").addClass("logo_show");*/ @@ -74,8 +78,8 @@ $(document).ready(function(){ } else{ console.log('else no ha elegido aun, default-else'); - localStorage.setItem("variable", "colapsado"); - document.getElementById("menu_type").innerHTML = localStorage.variable; + localStorage.setItem("menuType", "collapsed"); + document.getElementById("menu_type").innerHTML = localStorage.menuType; } }); @@ -95,11 +99,11 @@ $(document).ready(function(){ window.onscroll = function() {scrollFunction()}; function scrollFunction() { - if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) { + /* if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) { document.getElementById("top_btn").style.display = "block"; } else { document.getElementById("top_btn").style.display = "none"; - } + }*/ } // When the user clicks on the button, scroll to the top of the document. @@ -189,16 +193,16 @@ $('#button_collapse').on('click', function() { elem.className = elem.className.replace('button_collapse', 'cambiar'); */ if($('#menu_full').hasClass('menu_full_classic')){ - localStorage.setItem("variable", "colapsado"); + localStorage.setItem("menuType", "collapsed"); //$('#button_collapse').css('color','pink'); - document.getElementById("menu_type").innerHTML = localStorage.variable; + document.getElementById("menu_type").innerHTML = localStorage.menuType; $('ul.submenu').css('left', '59px');//hacer que esto se haga aqui $('#top_btn').css('left', '0px'); } else if($('#menu_full').hasClass('menu_full_collapsed')){ - localStorage.setItem("variable", "clasico"); + localStorage.setItem("menuType", "classic"); //$('#button_collapse').css('color','blue'); - document.getElementById("menu_type").innerHTML = localStorage.variable; + document.getElementById("menu_type").innerHTML = localStorage.menuType; $('ul.submenu').css('left', '214px');//hacer que esto se haga aqui $('#top_btn').css('left', '77.5px'); } @@ -220,9 +224,9 @@ elem.className = elem.className.replace('button_collapse', 'cambiar'); console.log('entra click'); - console.log(localStorage.variable); + console.log(localStorage.menuType); /* -if ($('#button_collapse').text() == 'clasico') { +if ($('#button_collapse').text() == 'classic') { classic_menu = true; } else { @@ -249,9 +253,9 @@ var click_display = ""; //if ((isNaN(classic_menu)) || (classic_menu == 0)) { -//f(localStorage.variable == 'clasico'){ +//f(localStorage.menuType == 'classic'){ /* -if ($('#button_collapse').text() == 'clasico') { +if ($('#button_collapse').text() == 'classic') { classic_menu = true; } else { @@ -296,7 +300,7 @@ $(document).ready( function() { // repeticion de if var classic_menu; -if ($('#menu_type').text() == 'clasico') { +if ($('#menu_type').text() == 'classic') { classic_menu = true; } diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 47d298cc84..3596fa5875 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -21,6 +21,21 @@ require_once 'include/functions_menu.php'; $menu_godmode = []; $menu_godmode['class'] = 'godmode'; + +if (check_acl($config['id_user'], 0, 'PM')) { + $sub = []; + $sub['godmode/servers/discovery']['text'] = __('Discover'); + $sub['godmode/servers/discovery']['id'] = 'Discover'; + $sub['godmode/servers/discovery']['subsecs'] = ['godmode/servers/discovery']; + + // Add to menu. + $menu_godmode['discover']['text'] = __('Discovery'); + $menu_godmode['discover']['sec2'] = 'godmode/servers/discovery'; + $menu_godmode['discover']['id'] = 'god-discovery'; + $menu_godmode['discover']['sub'] = $sub; +} + + $sub = []; if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'AD')) { $sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents'); @@ -54,7 +69,6 @@ if (check_acl($config['id_user'], 0, 'AW')) { } } -$menu_godmode['nuevo_texto']['text'] = __('nuevo_texto'); if (!empty($sub)) { $menu_godmode['gagente']['text'] = __('Resources'); $menu_godmode['gagente']['sec2'] = 'godmode/agentes/modificar_agente'; @@ -270,6 +284,9 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=ehorus']['text'] = __('eHorus'); $sub2['godmode/setup/setup&section=ehorus']['refr'] = 0; + $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); + $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; + if ($config['activate_gis']) { $sub2['godmode/setup/gis']['text'] = __('Map conections GIS'); } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 5074cf5219..5f0cb20ae6 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1,26 +1,39 @@ 0) { @@ -1158,7 +1174,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); @@ -1180,7 +1196,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'); } @@ -1341,7 +1357,15 @@ function config_update_config() $error_update[] = __('eHorus id custom field'); } break; + + default: + // Ignore. + break; } + + default: + // Ignore. + break; } if (count($error_update) > 0) { @@ -1363,7 +1387,9 @@ function config_update_config() /** - * Process config variables + * Process config variables. + * + * @return void */ function config_process_config() { @@ -1381,7 +1407,7 @@ function config_process_config() $is_windows = true; } - // Compatibility fix + // Compatibility fix. foreach ($configs as $c) { $config[$c['token']] = $c['value']; } @@ -1438,18 +1464,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); } @@ -1458,7 +1484,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'); } @@ -1470,7 +1496,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']; } @@ -1677,9 +1703,9 @@ function config_process_config() 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'])) { @@ -1695,7 +1721,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'; @@ -2295,7 +2321,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'); @@ -2317,15 +2343,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 { @@ -2339,7 +2365,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 { @@ -2469,12 +2495,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); @@ -2501,7 +2527,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); } @@ -2611,7 +2637,7 @@ function config_process_config() config_update_value('instance_registered', 0); } - // eHorus + // Ehorus. if (!isset($config['ehorus_enabled'])) { config_update_value('ehorus_enabled', 0); } @@ -2646,285 +2672,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.').'
          '."
          1. ".__('Report download in PDF format').'
          2. '."
          3. ".__('Emails Sending').'
          4. '."
          5. ".__('Metaconsole Collections').'
          6. '."
          7. ".'...'.'
          8. '.'
          '.''.__('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()]); } @@ -2933,7 +2751,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']); @@ -2946,6 +2764,11 @@ function config_user_set_custom_config() } +/** + * Undocumented function + * + * @return void + */ function config_prepare_session() { global $config; @@ -2958,10 +2781,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; } @@ -2971,7 +2794,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_menu.php b/pandora_console/include/functions_menu.php index d118dbd87f..d6384595a8 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -737,12 +737,12 @@ function menu_calculate_top($level1, $level2, $level3=false) // Positionate in the middle if ($total > 12 && (($total < 18) || (($level1 - $comp) <= 4))) { - return - ( floor($comp / 2) * 35); + return - ( floor($comp / 2) * 39); } // Positionate in the bottom if ($total >= 18) { - return (- $comp * 35); + return (- $comp * 39); } // return 0 by default diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index cf8e88bae7..63b9c3a0db 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -70,7 +70,7 @@ li:hover ul { z-index: 999; /*left: 44px;*/ min-height: 35px; - height: 35px; + /*height: 35px;*/ width: 180px; } @@ -82,7 +82,7 @@ li:hover ul { .sub_subMenu { min-height: 35px !important; - height: 35px; + /*height: 35px;*/ width: 180px; font-weight: normal !important; background-color: #202020; @@ -187,6 +187,9 @@ li.sub_subMenu.selected { } /* Godmode images */ +#icon_god-discovery { + background: url(../../images/gm_discovery.menu.png) no-repeat 50% 50%; +} #icon_god-resources { background: url(../../images/gm_resources.menu_gray.png) no-repeat; } @@ -454,24 +457,24 @@ ul li a:hover { } #menu_full { - /*height: 100%; Lo he quitado para que no ocupe todo el alto y fixed */ + /*height: 100%; /*Lo he quitado para que no ocupe todo el alto y fixed */ width: 60px; /* It is changed for classic menu (215px)*/ - position: absolute; /*Fixed: Lo he quitado para que no ocupe todo el alto y fixed */ + position: fixed; /*Fixed: Lo he quitado para que no ocupe todo el alto y fixed */ /*absolute*/ z-index: 1; top: 0; left: 0; background-color: #343434; - border-bottom: solid 5px #343434; - min-height: 943px; - /* padding-bottom: 40px; Lo he quitado para que no ocupe todo el alto y fixed */ + border-bottom: solid 3px #343434; + /*min-height: 943px;*/ + padding-bottom: 40px; /*Lo he quitado para que no ocupe todo el alto y fixed */ /*overflow-x: hidden;*/ } .button_collapse { height: 55px; background-color: #4d4d4d; - /* bottom: 0; Lo he quitado para que no ocupe todo el alto y fixed - position: fixed;*/ + /*bottom: 0; /* Lo he quitado para que no ocupe todo el alto y fixed*/ + /*position: fixed; /*coemntar tb*/ width: 60px; /* It is changed for classic menu (215px)*/ text-align: center; color: #fff; @@ -497,8 +500,8 @@ ul li a:hover { .operation > li.menu_icon, .godmode > li.menu_icon { - padding-top: 3px; - padding-bottom: 3px; + padding-top: 2px; /* 3px */ + padding-bottom: 2px; } .operation div, @@ -511,14 +514,21 @@ ul li a:hover { .menu_full_classic, .button_classic { width: 215px !important; - background-image: url(../../images/button_collapse_menu.png); - background-repeat: no-repeat; - background-position: center; } .menu_full_collapsed, .button_collapsed { width: 60px !important; +} + +.button_classic { + width: 215px !important; + background-image: url(../../images/button_collapse_menu.png); + background-repeat: no-repeat; + background-position: center; +} + +.button_collapsed { background-image: url(../../images/button_classic_menu.png); background-repeat: no-repeat; background-position: center; @@ -547,7 +557,7 @@ ul li a:hover { /* border: 2px solid #fff;*/ } -@media screen and (max-height: 845px) { +@media screen and (max-height: 600px) { .operation > li.menu_icon, .godmode > li.menu_icon { padding-top: 1px; @@ -558,5 +568,61 @@ ul li a:hover { } .button_collapse { margin-top: 10px; + background-color: green; + } + .menu li, + .menu .li.not_selected { + min-height: 25px !important; + } + .button_collapse { + height: 45px; + } + .submenu_text { + /* padding: 7.5px;*/ + } +} + +@media screen and (min-height: 601px) and (max-height: 700px) { + .operation > li.menu_icon, + .godmode > li.menu_icon { + padding-top: 1px; + padding-bottom: 2px; + } + .operation { + padding-top: 10px !important; + } + .button_collapse { + margin-top: 10px; + background-color: red; + } + .menu li, + .menu .li.not_selected { + min-height: 25px !important; + } + .button_collapse { + height: 48px; + } + .submenu_text { + /*padding: 7.5px;*/ + } +} + +@media screen and (min-height: 701px) and (max-height: 845px) { + .operation { + padding-top: 10px !important; + } + .button_collapse { + margin-top: 10px; + background-color: blue; + } + .menu li, + .menu .li.not_selected { + min-height: 28px !important; + } + .button_collapse { + height: 50px; + } + .submenu_text { + /*padding: 7.5px;*/ } } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index e8e2632188..b35c00584e 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -678,7 +678,7 @@ div#menu { width: 45px; float: left; z-index: 2000; - /*position: absolute; Lo he quitado para que no ocupe todo el alto y fixed */ + position: absolute; /*Lo he quitado para que no ocupe todo el alto y fixed */ } div#head { @@ -978,6 +978,14 @@ input.group_item_min[disabled] { center !important; } +input.color_cloud_min { + background: #fefefe url(../../images/color_cloud_item.png) no-repeat center !important; +} +input.color_cloud_min[disabled] { + background: #fefefe url(../../images/color_cloud_item.disabled.png) no-repeat + center !important; +} + div#cont { position: fixed; max-height: 320px; @@ -1549,7 +1557,8 @@ table.databox { } .databox > thead > tr > th, -.databox > tbody > tr > th { +.databox > tbody > tr > th, +.databox > thead > tr > th a { padding: 9px 7px; font-weight: normal; color: #fff; @@ -4422,7 +4431,177 @@ div#dialog_messages table th:last-child { text-align: right; } -/* checkbox type toogle switch */ +/* + * --------------------------------------------------------------------- + * - Notifications + * --------------------------------------------------------------------- + */ + +.notification-ball { + border: white solid 2px; + border-radius: 50px; + width: 18px; + height: 18px; + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; +} + +.notification-ball-no-messages { + background-color: #82b92e; + cursor: pointer; +} +.notification-ball-new-messages { + background-color: #fc4444; +} + +#notification-wrapper { + background: white; + border: #a5a5a5 solid 1px; + z-index: 900000; + position: absolute; + width: 400px; + margin-top: -5px; + border-radius: 5px; +} +#notification-wrapper::before { + content: ""; + display: block; + position: absolute; + width: 0px; + height: 0; + border-color: transparent; + border-width: 12px; + border-style: solid; + bottom: 100%; + left: 78%; + left: calc(78% - 2px); + margin-left: -12px; + border-bottom-color: white; +} +#notification-wrapper-inner { + max-height: 400px; + overflow: auto; +} +#notification-wrapper-shadow { + height: 100%; + width: 100%; + background: #111; + position: fixed; + z-index: 9009; + top: 0; + opacity: 0.3; +} +.notification-item { + background: whitesmoke; + height: 100px; + margin: 7px; + border: #e4e4e4 solid 1px; + display: flex; + flex-flow: row nowrap; + align-items: center; + padding: 5px; +} +.notification-item:hover { + border: #ccc solid 1px; +} +.notification-item > * { + padding-left: 15px; + pointer-events: none; +} + +.notification-item:hover { + text-decoration: none; +} + +.notification-info { + width: 87%; + display: flex; + flex-flow: column nowrap; + overflow: hidden; + max-height: 83px; + line-height: 1.4em; +} +.notification-item img { + max-width: 100%; + max-height: 100%; +} +.notification-title { + margin: 0; +} +.notification-subtitle { + margin: 0; + color: #373737; +} + +.global-config-notification-title { + display: flex; + flex-direction: row; + align-items: center; +} + +.global-config-notification-title h2 { + margin-left: 10px; +} + +.global-config-notification-checkboxes :first-child { + font-weight: bold; +} + +.global-config-notification-selectors { + display: flex; + flex-direction: row; + margin-bottom: 10px; +} + +.global-config-notification-selectors h4 { + margin: 0; +} + +.global-config-notification-single-selector, +.global_config_notifications_dialog_add select { + display: flex; + width: 100%; + padding: 0 10px; +} + +.global-config-notification-single-selector :first-child, +.global-config-notification-single-selector :first-child select { + width: 99%; +} + +.global-config-notification-single-selector :last-child, +.global_config_notifications_dialog_add_wrapper { + flex-direction: column; + display: flex; + justify-content: flex-end; +} + +.global_config_notifications_dialog_add { + display: flex; + flex-direction: row; + margin: 8px; +} + +.global_config_notifications_two_ways_form_arrows { + display: flex; + flex-flow: column; + justify-content: center; + margin: 0 5px; +} + +.global_config_notifications_two_ways_form_arrows img { + margin: 15px 0; +} + +/* jQuery dialog */ +.no-close .ui-dialog-titlebar-close { + display: none; +} +/* jQuery dialog */ + +/* --- SWITCH --- */ .toogle_switch { position: relative; display: inline-block; @@ -4477,11 +4656,147 @@ input:checked + .slider:before { background-color: rgb(197, 235, 192); } -/* jQuery dialog */ -.no-close .ui-dialog-titlebar-close { - display: none; +.p-switch { + position: relative; + display: inline-block; + width: 30px; + height: 17px; } -/* jQuery dialog */ + +.p-switch input { + opacity: 0; + width: 0; + height: 0; +} + +.p-slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: 0.4s; + transition: 0.4s; + border-radius: 34px; +} + +.p-slider:before { + position: absolute; + content: ""; + height: 13px; + width: 13px; + left: 2px; + bottom: 2px; + background-color: white; + -webkit-transition: 0.4s; + transition: 0.4s; + border-radius: 50%; +} + +input:checked + .p-slider { + background-color: #82b92e; +} + +input:focus + .p-slider { + box-shadow: 0 0 1px #82b92e; +} + +input:checked + .p-slider:before { + -webkit-transform: translateX(13px); + -ms-transform: translateX(13px); + transform: translateX(13px); +} + +/* --- END SWITCH --- */ + +/* --- TOAST --- */ +#notifications-toasts-wrapper { + position: fixed; + right: 20px; + top: 70px; + width: 270px; + height: 100%; + z-index: 6; + pointer-events: none; +} + +.snackbar { + max-width: 270px; + background-color: #333; + color: #fff; + text-align: center; + /* border-radius: 2px; */ + padding: 16px; + margin: 10px; + border-radius: 4px; + visibility: hidden; + pointer-events: all; +} + +.snackbar.show { + visibility: visible; + -webkit-animation: fadein 0.5s, fadeout 0.5s 7.5s; + animation: fadein 0.5s, fadeout 0.5s 7.5s; +} + +.snackbar p, +.snackbar h3 { + text-align: left; + margin: 0; + pointer-events: none; +} +.snackbar h3 { + color: white; + margin-bottom: 10px; +} + +@-webkit-keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + to { + bottom: 30px; + opacity: 1; + } +} + +@keyframes fadein { + from { + bottom: 0; + opacity: 0; + } + to { + bottom: 30px; + opacity: 1; + } +} + +@-webkit-keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + to { + bottom: 0; + opacity: 0; + } +} + +@keyframes fadeout { + from { + bottom: 30px; + opacity: 1; + } + to { + bottom: 0; + opacity: 0; + } +} + +/* --- END TOAST --- */ /* * --------------------------------------------------------------------- From 875d7ecabae5bde85035443d9ab3e8f9b10e6d4b Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 26 Feb 2019 12:04:18 +0100 Subject: [PATCH 201/262] Unified sizes of the checkbox switch Former-commit-id: f6f8eca748f67fdf1e4a98256c3ca590b61328ac --- pandora_console/godmode/setup/performance.php | 6 +- pandora_console/godmode/setup/setup_auth.php | 8 +- .../godmode/setup/setup_general.php | 26 +- .../godmode/setup/setup_visuals.php | 32 +- pandora_console/include/functions_html.php | 61 +- pandora_console/install.php | 1105 ----------------- 6 files changed, 87 insertions(+), 1151 deletions(-) delete mode 100644 pandora_console/install.php diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index e51f6ff7a9..0bbf28001f 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -582,7 +582,7 @@ $table_other->data[3][1] = html_print_input_text( ); $table_other->data[5][0] = __('Use realtime statistics'); -$table_other->data[5][1] = html_print_checkbox_toogle_switch( +$table_other->data[5][1] = html_print_checkbox_switch( 'realtimestats', 1, $config['realtimestats'], @@ -604,7 +604,7 @@ $table_other->data[6][1] = html_print_input_text( ); $table_other->data[7][0] = __('Use agent access graph').ui_print_help_icon('agent_access', true); -$table_other->data[7][1] = html_print_checkbox_toogle_switch('agentaccess', 1, $config['agentaccess'], true); +$table_other->data[7][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true); $table_other->data[8][0] = __('Max. recommended number of files in attachment directory'); $table_other->data[8][0] .= ui_print_help_tip( @@ -621,7 +621,7 @@ $table_other->data[8][1] = html_print_input_text( ); $table_other->data[9][0] = __('Delete not init modules'); -$table_other->data[9][1] = html_print_checkbox_toogle_switch('delete_notinit', 1, $config['delete_notinit'], true); +$table_other->data[9][1] = html_print_checkbox_switch('delete_notinit', 1, $config['delete_notinit'], true); $table_other->data[10][0] = __('Big Operation Step to purge old data'); $table_other->data[10][0] .= ui_print_help_tip( diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index 3ff5cb305b..cdb75816cc 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -44,14 +44,14 @@ if (is_ajax()) { // Fallback to local authentication $row = []; $row['name'] = __('Fallback to local authentication').ui_print_help_tip(__('Enable this option if you want to fallback to local authentication when remote (ldap etc...) authentication failed.'), true); - $row['control'] = html_print_checkbox_toogle_switch('fallback_local_auth', 1, $config['fallback_local_auth'], true); + $row['control'] = html_print_checkbox_switch('fallback_local_auth', 1, $config['fallback_local_auth'], true); $table->data['fallback_local_auth'] = $row; if (enterprise_installed()) { // Autocreate remote users $row = []; $row['name'] = __('Autocreate remote users'); - $row['control'] = html_print_checkbox_toogle_switch_extended('autocreate_remote_users', 1, $config['autocreate_remote_users'], false, '', '', true).'  '; + $row['control'] = html_print_checkbox_switch_extended('autocreate_remote_users', 1, $config['autocreate_remote_users'], false, '', '', true).'  '; $table->data['autocreate_remote_users'] = $row; add_enterprise_auth_autocreate_profiles($table, $type_auth); @@ -89,7 +89,7 @@ if (is_ajax()) { // Start TLS $row = []; $row['name'] = __('Start TLS'); - $row['control'] = html_print_checkbox_toogle_switch('ldap_start_tls', 1, $config['ldap_start_tls'], true); + $row['control'] = html_print_checkbox_switch('ldap_start_tls', 1, $config['ldap_start_tls'], true); $table->data['ldap_start_tls'] = $row; // Base DN @@ -135,7 +135,7 @@ if (is_ajax()) { $row = []; $row['name'] = __('Double authentication').ui_print_help_tip(__('If this option is enabled, the users can use double authentication with their accounts'), true); $row['control'] = html_print_input_hidden('double_auth_enabled', 0); - $row['control'] .= html_print_checkbox_toogle_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true); + $row['control'] .= html_print_checkbox_switch('double_auth_enabled', 1, $config['double_auth_enabled'], true); $table->data['double_auth_enabled'] = $row; // Session timeout diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 82899cde6b..8f07d3d88d 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -82,17 +82,17 @@ $sources['sql'] = __('Database'); $table->data[9][1] = html_print_select($sources, 'timesource', $config['timesource'], '', '', '', true); $table->data[10][0] = __('Automatic check for updates'); -$table->data[10][1] = html_print_checkbox_toogle_switch('autoupdate', 1, $config['autoupdate'], true); +$table->data[10][1] = html_print_checkbox_switch('autoupdate', 1, $config['autoupdate'], true); echo "'; $table->data[11][0] = __('Enforce https'); -$table->data[11][1] = html_print_checkbox_toogle_switch_extended('https', 1, $config['https'], false, '', '', true); +$table->data[11][1] = html_print_checkbox_switch_extended('https', 1, $config['https'], false, '', '', true); $table->data[12][0] = __('Use cert of SSL'); -$table->data[12][1] = html_print_checkbox_toogle_switch_extended('use_cert', 1, $config['use_cert'], false, '', '', true); +$table->data[12][1] = html_print_checkbox_switch_extended('use_cert', 1, $config['use_cert'], false, '', '', true); $table->rowstyle[13] = 'display: none;'; $table->data[13][0] = __('Path of SSL Cert.').ui_print_help_tip(__('Path where you put your cert and name of this cert. Remember your cert only in .pem extension.'), true); @@ -114,7 +114,7 @@ $table->data[16][0] = __('API password').ui_print_help_tip(__('Please be careful $table->data[16][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true); $table->data[17][0] = __('Enable GIS features'); -$table->data[17][1] = html_print_checkbox_toogle_switch('activate_gis', 1, $config['activate_gis'], true); +$table->data[17][1] = html_print_checkbox_switch('activate_gis', 1, $config['activate_gis'], true); $table->data[19][0] = __('Enable Netflow'); $rbt_disabled = false; @@ -123,7 +123,7 @@ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $table->data[19][0] .= ui_print_help_tip(__('Not supported in Windows systems'), true); } -$table->data[19][1] = html_print_checkbox_toogle_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true); +$table->data[19][1] = html_print_checkbox_switch_extended('activate_netflow', 1, $config['activate_netflow'], $rbt_disabled, '', '', true); $zone_name = [ @@ -202,15 +202,15 @@ $table->data[28][1] = html_print_input_text('public_url', $config['public_url'], $table->data[29][0] = __('Referer security'); $table->data[29][0] .= ui_print_help_tip(__("If enabled, actively checks if the user comes from %s's URL", get_product_name()), true); -$table->data[29][1] = html_print_checkbox_toogle_switch('referer_security', 1, $config['referer_security'], true); +$table->data[29][1] = html_print_checkbox_switch('referer_security', 1, $config['referer_security'], true); $table->data[30][0] = __('Event storm protection'); $table->data[30][0] .= ui_print_help_tip(__('If set to yes no events or alerts will be generated, but agents will continue receiving data.'), true); -$table->data[30][1] = html_print_checkbox_toogle_switch('event_storm_protection', 1, $config['event_storm_protection'], true); +$table->data[30][1] = html_print_checkbox_switch('event_storm_protection', 1, $config['event_storm_protection'], true); $table->data[31][0] = __('Command Snapshot').ui_print_help_tip(__('The string modules with several lines show as command output'), true); -$table->data[31][1] = html_print_checkbox_toogle_switch('command_snapshot', 1, $config['command_snapshot'], true); +$table->data[31][1] = html_print_checkbox_switch('command_snapshot', 1, $config['command_snapshot'], true); $table->data[32][0] = __('Server logs directory').ui_print_help_tip(__('Directory where the server logs are stored.'), true); $table->data[32][1] = html_print_input_text( @@ -250,7 +250,7 @@ $table->data['tutorial_mode'][1] = html_print_select( $config['past_planned_downtimes'] = isset($config['past_planned_downtimes']) ? $config['past_planned_downtimes'] : 1; $table->data[34][0] = __('Allow create planned downtimes in the past').ui_print_help_tip(__('The planned downtimes created in the past will affect the SLA reports'), true); -$table->data[34][1] = html_print_checkbox_toogle_switch('past_planned_downtimes', 1, $config['past_planned_downtimes'], true); +$table->data[34][1] = html_print_checkbox_switch('past_planned_downtimes', 1, $config['past_planned_downtimes'], true); $table->data[35][0] = __('Limit for bulk operations').ui_print_help_tip(__('Your PHP environment is set to 1000 max_input_vars. This parameter should have the same value or lower.', ini_get('max_input_vars')), true); $table->data[35][1] = html_print_input_text( @@ -263,7 +263,7 @@ $table->data[35][1] = html_print_input_text( ); $table->data[36][0] = __('Include agents manually disabled'); -$table->data[36][1] = html_print_checkbox_toogle_switch('include_agents', 1, $config['include_agents'], true); +$table->data[36][1] = html_print_checkbox_switch('include_agents', 1, $config['include_agents'], true); $table->data[37][0] = __('Audit log directory').ui_print_help_tip(__('Directory where audit log is stored.'), true); $table->data[37][1] = html_print_input_text('auditdir', io_safe_output($config['auditdir']), '', 30, 100, true); @@ -339,9 +339,9 @@ $(document).ready (function () { $("#timezone").attr("hidden", false); }); - if ($("input[name=use_cert]").is(':checked')) { - $('#setup_general-13').show(); - } + if ($("input[name=use_cert]").is(':checked')) { + $('#setup_general-13').show(); + } $("input[name=use_cert]").change(function () { if( $(this).is(":checked") ) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 8d18cf40d7..85047cd488 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -75,7 +75,7 @@ $table_behaviour->data[$row][1] = html_print_select($values, 'vc_refr', $config[ $row++; $table_behaviour->data[$row][0] = __('Paginated module view'); -$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( +$table_behaviour->data[$row][1] = html_print_checkbox_switch( 'paginate_module', 1, $config['paginate_module'], @@ -84,7 +84,7 @@ $table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( $row++; $table_behaviour->data[$row][0] = __('Display data of proc modules in other format'); -$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( +$table_behaviour->data[$row][1] = html_print_checkbox_switch( 'render_proc', 1, $config['render_proc'], @@ -102,7 +102,7 @@ $row++; // Daniel maya 02/06/2016 Display menu with click --INI $table_behaviour->data[$row][0] = __('Click to display lateral menus').ui_print_help_tip(__('When enabled, the lateral menus are shown when left clicking them, instead of hovering over them'), true); -$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( +$table_behaviour->data[$row][1] = html_print_checkbox_switch( 'click_display', 1, $config['click_display'], @@ -121,7 +121,7 @@ if (enterprise_installed()) { } $table_behaviour->data[$row][0] = __('Classic menu mode').ui_print_help_tip(__('Text menu options always visible, don\'t hide'), true); -$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( +$table_behaviour->data[$row][1] = html_print_checkbox_switch( 'classic_menu', 1, $config['classic_menu'], @@ -491,7 +491,7 @@ if (enterprise_installed()) { if (enterprise_installed()) { $table_styles->data[$row][0] = __('Disable logo in graphs'); - $table_styles->data[$row][1] = html_print_checkbox_toogle_switch( + $table_styles->data[$row][1] = html_print_checkbox_switch( 'fixed_graph', 1, $config['fixed_graph'], @@ -507,7 +507,7 @@ if (enterprise_installed()) { */ $table_styles->data[$row][0] = __('Disable helps'); -$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( +$table_styles->data[$row][1] = html_print_checkbox_switch( 'disable_help', 1, $config['disable_help'], @@ -516,7 +516,7 @@ $table_styles->data[$row][1] = html_print_checkbox_toogle_switch( $row++; $table_styles->data[$row][0] = __('Fixed header'); -$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( +$table_styles->data[$row][1] = html_print_checkbox_switch( 'fixed_header', 1, $config['fixed_header'], @@ -525,7 +525,7 @@ $table_styles->data[$row][1] = html_print_checkbox_toogle_switch( $row++; $table_styles->data[$row][0] = __('Fixed menu'); -$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( +$table_styles->data[$row][1] = html_print_checkbox_switch( 'fixed_menu', 1, $config['fixed_menu'], @@ -535,7 +535,7 @@ $row++; // For 5.1 Autohidden menu feature $table_styles->data['autohidden'][0] = __('Autohidden menu'); -$table_styles->data['autohidden'][1] = html_print_checkbox_toogle_switch( +$table_styles->data['autohidden'][1] = html_print_checkbox_switch( 'autohidden_menu', 1, $config['autohidden_menu'], @@ -543,7 +543,7 @@ $table_styles->data['autohidden'][1] = html_print_checkbox_toogle_switch( ); $table_styles->data[$row][0] = __('Visual effects and animation'); -$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( +$table_styles->data[$row][1] = html_print_checkbox_switch( 'visual_animation', 1, $config['visual_animation'], @@ -567,7 +567,7 @@ $table_gis->size[0] = '50%'; $table_gis->data = []; $table_gis->data[$row][0] = __('GIS Labels').ui_print_help_tip(__('This enabling this, you get a label with agent name in GIS maps. If you have lots of agents in the map, will be unreadable. Disabled by default.'), true); -$table_gis->data[$row][1] = html_print_checkbox_toogle_switch( +$table_gis->data[$row][1] = html_print_checkbox_switch( 'gis_label', 1, $config['gis_label'], @@ -680,7 +680,7 @@ $table_font->data[$row][1] = html_print_input_text( $row++; $table_font->data[$row][0] = __('Show unit along with value in reports').ui_print_help_tip(__('This enabling this, max, min and avg values will be shown with units.'), true); -$table_font->data[$row][1] = html_print_checkbox_toogle_switch( +$table_font->data[$row][1] = html_print_checkbox_switch( 'simple_module_value', 1, $config['simple_module_value'], @@ -778,7 +778,7 @@ $table_chars->data[$row][1] = html_print_input_text( $row++; $table_chars->data[$row][0] = __('Use round corners'); -$table_chars->data[$row][1] = html_print_checkbox_toogle_switch( +$table_chars->data[$row][1] = html_print_checkbox_switch( 'round_corner', 1, $config['round_corner'], @@ -947,7 +947,7 @@ $table_other->data[$row][0] = __('Show report info with description').ui_print_h __('Custom report description info. It will be applied to all reports and templates by default.'), true ); -$table_other->data[$row][1] = html_print_checkbox_toogle_switch( +$table_other->data[$row][1] = html_print_checkbox_switch( 'custom_report_info', 1, $config['custom_report_info'], @@ -1061,7 +1061,7 @@ $table_other->data['custom_report_front-footer'][1] = html_print_textarea( $table_other->data[$row][0] = __('Show QR Code icon in the header'); -$table_other->data[$row][1] = html_print_checkbox_toogle_switch( +$table_other->data[$row][1] = html_print_checkbox_switch( 'show_qr_code_header', 1, $config['show_qr_code_header'], @@ -1099,7 +1099,7 @@ $table_other->data[$row][0] .= ui_print_help_tip( __('Show the group name instead the group icon.'), true ); -$table_other->data[$row][1] = html_print_checkbox_toogle_switch( +$table_other->data[$row][1] = html_print_checkbox_switch( 'show_group_name', 1, $config['show_group_name'], diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 701042448f..cb100db256 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -20,19 +20,19 @@ if (!isset($config)) { $working_dir = getcwd(); $working_dir = str_replace('\\', '/', $working_dir); - // Windows compatibility + // Windows compatibility. $levels = substr_count($working_dir, '/'); for ($i = 0; $i < $levels; $i++) { if (file_exists(str_repeat('../', $i).'config.php')) { include_once str_repeat('../', $i).'config.php'; break; - // Skip config.php loading after load the first one + // Skip config.php loading after load the first one. } else if (file_exists(str_repeat('../', $i).'include/config.php')) { // For path from the enterprise structure dirs. include_once str_repeat('../', $i).'include/config.php'; break; - // Skip config.php loading after load the first one + // Skip config.php loading after load the first one. } } } else { @@ -2307,7 +2307,7 @@ function html_print_checkbox($name, $value, $checked=false, $return=false, $disa /** - * Render a checkbox button input toogle switch type. Extended version, use html_print_checkbox_toogle_switch() to simplify. + * Render a checkbox button input switch type. Extended version, use html_print_checkbox_switch() to simplify. * * @param string Input name. * @param string Input value. @@ -2321,7 +2321,7 @@ function html_print_checkbox($name, $value, $checked=false, $return=false, $disa */ -function html_print_checkbox_toogle_switch_extended($name, $value, $checked, $disabled, $script, $attributes, $return=false, $id='') +function html_print_checkbox_switch_extended($name, $value, $checked, $disabled, $script, $attributes, $return=false, $id='') { static $idcounter = []; @@ -2334,7 +2334,7 @@ function html_print_checkbox_toogle_switch_extended($name, $value, $checked, $di $id_aux = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); - $output = '"; +} diff --git a/pandora_console/install.php b/pandora_console/install.php deleted file mode 100644 index fa60433a98..0000000000 --- a/pandora_console/install.php +++ /dev/null @@ -1,1105 +0,0 @@ - - - - - Pandora FMS - Installation Wizard - - - - - - - - - - - - - - - -
          - -
          - - - -'; - echo " $label "; - echo ''; - if (!extension_loaded($ext)) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - -function check_include($ext, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!include $ext) { - echo ""; - return 1; - } else { - echo ""; - return 0; - } - - echo ''; -} - - -function check_exists($file, $label) -{ - echo ''; - echo " $label "; - echo ''; - if (!file_exists($file)) { - echo " "; - return 1; - } else { - echo " "; - return 0; - } - - echo ''; -} - - -function check_generic($ok, $label) -{ - echo ""; - if ($ok == 0) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } -} - - -function check_writable($fullpath, $label) -{ - echo ""; - if (file_exists($fullpath)) { - if (is_writable($fullpath)) { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 0; - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } - } else { - echo " "; - echo ''; - echo " $label "; - echo ''; - echo ''; - return 1; - } -} - - -function check_variable($var, $value, $label, $mode) -{ - echo ''; - echo " $label "; - echo ''; - if ($mode == 1) { - if ($var >= $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - } else if ($var == $value) { - echo " "; - return 0; - } else { - echo " "; - return 1; - } - - echo ''; -} - - -function parse_mysql_dump($url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysql_query($query)) { - echo mysql_error(); - // Uncomment for debug - echo "
          $query
          "; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function parse_mysqli_dump($connection, $url) -{ - if (file_exists($url)) { - $file_content = file($url); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) { - $query .= $sql_line; - if (preg_match("/;[\040]*\$/", $sql_line)) { - if (!$result = mysqli_query($connection, $query)) { - echo mysqli_error(); - // Uncomment for debug - echo "
          $query
          "; - return 0; - } - - $query = ''; - } - } - } - - return 1; - } else { - return 0; - } -} - - -function random_name($size) -{ - $temp = ''; - for ($a = 0; $a < $size; $a++) { - $temp = $temp.chr(rand(122, 97)); - } - - return $temp; -} - - -function print_logo_status($step, $step_total) -{ - global $banner; - - $header = " -
          -
          -
          - $banner -
          -
          "; - $header .= " -
          - Install step $step of $step_total -
          "; - - 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. -
          "; - - echo '
          '; - - if ($writable == 0) { - echo "
          "; - echo ""; - echo '
          '; - } else { - echo "
          ERROR:You need to setup permissions to be able to write in ./include directory
          "; - } - - echo '
          '; - - echo "
          "; - echo " -
          -
          - Pandora FMS is an OpenSource Software project registered at - SourceForge -
          -
          "; -} - - -function install_step1_licence() -{ - echo " -
          -
          - ".print_logo_status(2, 6)." -
          -

          GPL2 Licence terms agreement

          -

          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 "'; - echo '

          '; - echo "

          "; - } - - echo '
          '; - - echo "
          -
          -
          - Pandora FMS is an OpenSource Software project registered at - SourceForge -
          -
          "; -} - - -function install_step2() -{ - echo " -
          -
          - ".print_logo_status(3, 6)." -
          "; - echo '

          Checking software dependencies

          '; - echo ''; - $res = 0; - $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1); - $res += check_extension('gd', 'PHP GD extension'); - $res += check_extension('ldap', 'PHP LDAP extension'); - $res += check_extension('snmp', 'PHP SNMP extension'); - $res += check_extension('session', 'PHP session extension'); - $res += check_extension('gettext', 'PHP gettext extension'); - $res += check_extension('mbstring', 'PHP Multibyte String'); - $res += check_extension('zip', 'PHP Zip'); - $res += check_extension('zlib', 'PHP Zlib extension'); - $res += check_extension('json', 'PHP json extension'); - $res += check_extension('curl', 'CURL (Client URL Library)'); - $res += check_extension('filter', 'PHP filter extension'); - $res += check_extension('calendar', 'PHP calendar extension'); - if (PHP_OS == 'FreeBSD') { - $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary'); - } else if (PHP_OS == 'NetBSD') { - $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary'); - } else if (substr(PHP_OS, 0, 3) == 'WIN') { - $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary'); - } else { - $res += check_exists('/usr/bin/twopi', 'Graphviz Binary'); - } - - echo ''; - check_extension('mysqli', 'PHP MySQL(mysqli) extension'); - echo '
          '; - echo "DB Engines"; - echo ''; - echo '
          '; - - if ($res > 0) { - echo " -
          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. -
          -
          - Ignore it. -
          "; - } else { - echo "
          "; - echo " - "; - echo '
          '; - } - - echo '
          '; - echo "
          "; - echo " -
          -
          -
          -
          - Pandora FMS is an OpenSource Software project registered at - SourceForge -
          -
          "; -} - - -function install_step3() -{ - $options = ''; - if (extension_loaded('mysql')) { - $options .= ""; - } - - if (extension_loaded('mysqli')) { - $options .= ""; - } - - $error = false; - if (empty($options)) { - $error = true; - } - - echo " -
          -
          - ".print_logo_status(4, 6)." -
          -

          Environment and database setup

          -

          - 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.
          "; - } - - if (!$error) { - echo ""; - } - - echo ""; - echo '"; - - // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost - echo " - - "; - - echo " "; - - echo ""; - echo '
          '; - echo 'DB Engine
          '; - - if ($error) { - echo " -
          - Warning: You haven't a any DB engine with PHP. Please check the previous step to DB engine dependencies. -
          "; - } else { - echo "'; - - echo '
          '; - echo ' Installation in
          '; - echo "'; - } - - echo "
          DB User with privileges
          - - -
          DB Password for this user
          - - -
          DB Hostname
          - - -
          DB Name (pandora by default)
          - - -
          Drop Database if exists
          - -
          Full path to HTTP publication directory
          - For example /var/www/pandora_console/ -
          - - -
          '; - echo "URL path to Pandora FMS Console
          - For example '/pandora_console' -
          - -
          - "; - - if (!$error) { - echo "
          "; - echo " - "; - echo '
          '; - ?> - - '; - - echo ''; - - echo "
          "; - echo "
          -
          - Pandora FMS is an OpenSource Software project registered at - SourceForge -
          -
          "; -} - - -function install_step4() -{ - $pandora_config = 'include/config.php'; - - if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host'])) - || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action'])) - ) { - $dbpassword = ''; - $dbuser = ''; - $dbhost = ''; - $dbname = ''; - $engine = ''; - $dbaction = ''; - $dbgrant = ''; - } else { - $engine = $_POST['engine']; - $dbpassword = $_POST['pass']; - $dbuser = $_POST['user']; - $dbhost = $_POST['host']; - $dbaction = $_POST['db_action']; - if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') { - $dbgrant = $_POST['dbgrant']; - } else { - $dbgrant = $_SERVER['SERVER_ADDR']; - } - - if (isset($_POST['drop'])) { - $dbdrop = $_POST['drop']; - } else { - $dbdrop = 0; - } - - $dbname = $_POST['dbname']; - if (isset($_POST['url'])) { - $url = $_POST['url']; - } else { - $url = 'http://localhost'; - } - - if (isset($_POST['path'])) { - $path = $_POST['path']; - $path = str_replace('\\', '/', $path); - // Windows compatibility - } else { - $path = '/var/www'; - } - } - - $everything_ok = 0; - $step1 = 0; - $step2 = 0; - $step3 = 0; - $step4 = 0; - $step5 = 0; - $step6 = 0; - $step7 = 0; - - echo " -
          -
          - ".print_logo_status(5, 6)." -
          -

          Creating database and default configuration file

          - "; - switch ($engine) { - case 'mysql': - if (! mysql_connect($dbhost, $dbuser, $dbpassword)) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysql_query("DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysql_query("CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysql_select_db($dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysql_dump('pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysql_dump('pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysql_query( - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysql_query('FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
          Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
          "); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - - case 'mysqli': - $connection = mysqli_connect($dbhost, $dbuser, $dbpassword); - if (mysqli_connect_error() > 0) { - check_generic(0, 'Connection with Database'); - } else { - check_generic(1, 'Connection with Database'); - - // Drop database if needed and don't want to install over an existing DB - if ($dbdrop == 1) { - mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`"); - } - - // Create schema - if ($dbaction == 'db_new' || $dbdrop == 1) { - $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`"); - check_generic($step1, "Creating database '$dbname'"); - } else { - $step1 = 1; - } - - if ($step1 == 1) { - $step2 = mysqli_select_db($connection, $dbname); - check_generic($step2, "Opening database '$dbname'"); - - $step3 = parse_mysqli_dump($connection, 'pandoradb.sql'); - check_generic($step3, 'Creating schema'); - - $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql'); - check_generic($step4, 'Populating database'); - if (PHP_OS == 'FreeBSD') { - $step_freebsd = adjust_paths_for_freebsd($engine, $connection); - check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD'); - } - - $random_password = random_name(8); - $host = $dbhost; - // set default granted origin to the origin of the queries - if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) { - $host = $dbgrant; - // if the granted origin is different from local machine, set the valid origin - } - - $step5 = mysqli_query( - $connection, - "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host - IDENTIFIED BY '".$random_password."'" - ); - mysqli_query($connection, 'FLUSH PRIVILEGES'); - check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
          Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
          "); - - $step6 = is_writable('include'); - check_generic($step6, "Write permissions to save config file in './include'"); - - $cfgin = fopen('include/config.inc.php', 'r'); - $cfgout = fopen($pandora_config, 'w'); - $config_contents = fread($cfgin, filesize('include/config.inc.php')); - $dbtype = 'mysql'; - $config_new = ''; - $step7 = fputs($cfgout, $config_new); - $step7 = ($step7 + fputs($cfgout, $config_contents)); - if ($step7 > 0) { - $step7 = 1; - } - - fclose($cfgin); - fclose($cfgout); - chmod($pandora_config, 0600); - check_generic($step7, "Created new config file at '".$pandora_config."'"); - } - } - - if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { - $everything_ok = 1; - } - break; - } - - echo '
          '; - - if ($everything_ok == 1) { - echo "
          "; - echo " - "; - echo '
          '; - } else { - $info = "
          There were some problems. - Installation was not completed. -

          Please correct failures before trying again. - All database "; - if ($engine == 'oracle') { - $info .= 'objects '; - } else { - $info .= 'schemes '; - } - - $info .= 'created in this step have been dropped.

          -
          '; - echo $info; - - switch ($engine) { - case 'mysql': - if (mysql_error() != '') { - echo "
          ERROR: ".mysql_error().'.
          '; - } - - if ($step1 == 1) { - mysql_query("DROP DATABASE $dbname"); - } - break; - - case 'mysqli': - if (mysqli_error($connection) != '') { - echo "
          ERROR: ".mysqli_error($connection).'.
          '; - } - - if ($step1 == 1) { - mysqli_query($connection, "DROP DATABASE $dbname"); - } - break; - } - - echo '
          '; - } - - echo '
          '; - echo "
          "; - echo " -
          -
          - Pandora FMS is an Open Source Software project registered at - SourceForge -
          -
          "; -} - - -function install_step5() -{ - echo " -
          -
          - ".print_logo_status(6, 6)." -
          -

          Installation complete

          -

          For security, you now must manually delete this installer - ('install.php') file before trying to access to your Pandora FMS console. -

          You should also install Pandora FMS Servers before trying to monitor anything; - please read documentation on how to install it.

          -

          Default user is 'admin' with password 'pandora', - please change it both as soon as possible.

          -

          Don't forget to check http://pandorafms.com - for updates. -

          Select if you want to rename 'install.php'.

          -
          - - -
          -


          . -

          -
          "; - - echo "
          -
          - Pandora FMS is an OpenSource Software project registered at - SourceForge -
          -
          "; -} From 45419fbfb0f9e6ab2bab62c32b7e889b58b6d95b Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 26 Feb 2019 12:23:46 +0100 Subject: [PATCH 202/262] Fixed href in plugins with centralized node Former-commit-id: 03fa2c15b7a9fb14cdc12499c3bc2a204bae3cd5 --- pandora_console/godmode/servers/plugin.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index fcb34363f0..4380f3ba31 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -634,9 +634,8 @@ if (($create != '') || ($view != '')) { } - // Update plugin + // Update plugin. if (isset($_GET['update_plugin'])) { - // if modified any parameter $plugin_id = get_parameter('update_plugin', 0); $plugin_name = get_parameter('form_name', ''); $plugin_description = get_parameter('form_description', ''); @@ -978,7 +977,10 @@ if (($create != '') || ($view != '')) { echo ''; echo ""; - echo ""; + if ($management_allowed) { + echo ""; + } + echo $row['name']; echo ''; echo ""; From 7791639b3545145dd9cd2a137dc93d76dd73cb67 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Tue, 26 Feb 2019 13:31:35 +0100 Subject: [PATCH 203/262] fix bad image routes Former-commit-id: 236701131f5c2f5b11c01b878d8a04b71f76ddd3 --- .../include/class/TreeService.class.php | 24 +++++++++---------- .../include/javascript/tree/TreeController.js | 14 ++++++----- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index d211cd1055..b55643219d 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -91,20 +91,20 @@ class TreeService extends Tree { switch ($status) { case SERVICE_STATUS_NORMAL: - $processed_items[$row['id']]['statusImageHTML']='NORMAL status.'; + $processed_items[$row['id']]['statusImageHTML']='NORMAL status.'; break; case SERVICE_STATUS_CRITICAL: - $processed_items[$row['id']]['statusImageHTML']='CRITICAL status.'; + $processed_items[$row['id']]['statusImageHTML']='CRITICAL status.'; break; case SERVICE_STATUS_WARNING: - $processed_items[$row['id']][$key]['statusImageHTML']='WARNING status.'; + $processed_items[$row['id']][$key]['statusImageHTML']='WARNING status.'; break; case SERVICE_STATUS_UNKNOWN: default: - $processed_items[$row['id']]['statusImageHTML']='UNKNOWN status.'; + $processed_items[$row['id']]['statusImageHTML']='UNKNOWN status.'; break; } } @@ -201,16 +201,16 @@ class TreeService extends Tree { foreach ($data_modules as $key => $module) { switch ($module['estado']) { case '0': - $data_modules[$key]['statusImageHTML'] = 'NORMAL status.'; + $data_modules[$key]['statusImageHTML'] = 'NORMAL status.'; break; case '1': - $data_modules[$key]['statusImageHTML'] = 'CRITICAL status.'; + $data_modules[$key]['statusImageHTML'] = 'CRITICAL status.'; break; case '2': - $data_modules[$key]['statusImageHTML'] = 'WARNING status.'; + $data_modules[$key]['statusImageHTML'] = 'WARNING status.'; break; case '4': - $data_modules[$key]['statusImageHTML'] = 'UNKNOWN status.'; + $data_modules[$key]['statusImageHTML'] = 'UNKNOWN status.'; break; default: # code... @@ -267,20 +267,20 @@ class TreeService extends Tree { switch ($status) { case SERVICE_STATUS_NORMAL: - $service_stats[$row['id']]['statusImageHTML']='NORMAL status.'; + $service_stats[$row['id']]['statusImageHTML']='NORMAL status.'; break; case SERVICE_STATUS_CRITICAL: - $service_stats[$row['id']]['statusImageHTML']='CRITICAL status.'; + $service_stats[$row['id']]['statusImageHTML']='CRITICAL status.'; break; case SERVICE_STATUS_WARNING: - $service_stats[$row['id']][$key]['statusImageHTML']='WARNING status.'; + $service_stats[$row['id']][$key]['statusImageHTML']='WARNING status.'; break; case SERVICE_STATUS_UNKNOWN: default: - $service_stats[$row['id']]['statusImageHTML']='UNKNOWN status.'; + $service_stats[$row['id']]['statusImageHTML']='UNKNOWN status.'; break; } } diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 3e177f3ae9..04e67e670b 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -931,12 +931,14 @@ var TreeController = { } controller.recipient.empty(); - controller.recipient.html( - "
          " + - controller.foundMessage + ": " + controller.tree.length + - "
          " + - "
          " - ); + if (controller.tree.length !== undefined) { + controller.recipient.html( + "
          " + + controller.foundMessage + ": " + controller.tree.length + + "
          " + + "
          " + ); + } var $children = _processGroup(this.recipient, this.tree, true); $children.show(); From 86509caf6b13b372cd7c6bf52c54954a6766d903 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 26 Feb 2019 14:44:51 +0100 Subject: [PATCH 204/262] Fixed downtimes disabled and enabled agents Former-commit-id: a5c2362e4faf6c0ed9ff2047b6d070aa4d7cdac8 --- .../include/functions_planned_downtimes.php | 20 ++++++++++++++----- pandora_server/bin/pandora_server | 2 +- pandora_server/lib/PandoraFMS/Core.pm | 6 ++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_planned_downtimes.php b/pandora_console/include/functions_planned_downtimes.php index 6660a19f10..7f1a587b65 100644 --- a/pandora_console/include/functions_planned_downtimes.php +++ b/pandora_console/include/functions_planned_downtimes.php @@ -534,9 +534,10 @@ function planned_downtimes_migrate_malformed_downtimes_copy_items($original_down /** * Stop a planned downtime. * - * @param array Planned downtime data. + * @param array $downtime Planned downtime data. * - * @return mixes False on error or an array with the result and a message of the operation. + * @return mixed False on error or an array with the result and a message of + * the operation. */ function planned_downtimes_stop($downtime) { @@ -566,7 +567,9 @@ function planned_downtimes_stop($downtime) case 'periodically': return false; - break; + default: + // Nothing to do. + break; } $message .= ui_print_result_message( @@ -593,7 +596,7 @@ function planned_downtimes_stop($downtime) true ); - // Reenabled the Agents or Modules or alerts...depends of type + // Reenabled the Agents or Modules or alerts...depends of type. switch ($downtime['type_downtime']) { case 'quiet': $agents = db_get_all_rows_filter( @@ -658,7 +661,10 @@ function planned_downtimes_stop($downtime) foreach ($agents as $agent) { $result = db_process_sql_update( 'tagente', - ['disabled' => 0], + [ + 'disabled' => 0, + 'update_module_count' => 1, + ], ['id_agente' => $agent['id_agent']] ); @@ -702,6 +708,10 @@ function planned_downtimes_stop($downtime) } } break; + + default: + // Nothing to do. + break; } $message .= ui_print_info_message( diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 53265cb0a0..bb177be783 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -306,7 +306,7 @@ sub pandora_server_tasks ($) { if (($counter % 30) == 0) { # Update module status and fired alert counts - my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count, update_secondary_groups FROM tagente WHERE disabled = 0 AND (update_module_count=1 OR update_alert_count=1 OR update_secondary_groups=1)'); + my @agents = get_db_rows ($dbh, 'SELECT id_agente, nombre, update_module_count, update_alert_count, update_secondary_groups FROM tagente WHERE (update_module_count=1 OR update_alert_count=1 OR update_secondary_groups=1)'); foreach my $agent (@agents) { logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10); diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 4155b2d432..f45731ba13 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1820,7 +1820,8 @@ sub pandora_planned_downtime_set_disabled_elements($$$) { WHERE tp.id_agent = ta.id_agente AND tp.id_downtime = ?',$downtime->{'id'}); db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa - SET ta.disabled = 1 WHERE tpa.id_agent = ta.id_agente AND + SET ta.disabled = 1, ta.update_module_count = 1 + WHERE tpa.id_agent = ta.id_agente AND tpa.id_downtime = ?',$downtime->{'id'}); } else { @@ -1857,7 +1858,8 @@ sub pandora_planned_downtime_unset_disabled_elements($$$) { if ($only_alerts == 0) { db_do($dbh,'UPDATE tagente ta, tplanned_downtime_agents tpa - set ta.disabled = 0 WHERE tpa.id_agent = ta.id_agente AND + set ta.disabled = 0, ta.update_module_count = 1 + WHERE tpa.id_agent = ta.id_agente AND tpa.manually_disabled = 0 AND tpa.id_downtime = ?',$downtime->{'id'}); } else { my @downtime_agents = get_db_rows($dbh, 'SELECT * From 2c0c05050768424c081ac1451efe426c9a7d30af Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 26 Feb 2019 17:20:23 +0100 Subject: [PATCH 205/262] Disabled cache in server plugin synchronization Former-commit-id: c8d60db8aece2db8611ee7d8ac44347f661d9b83 --- pandora_console/godmode/servers/plugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 4380f3ba31..b04643e1c3 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -827,12 +827,12 @@ if (($create != '') || ($view != '')) { // recorremos todos los nodos. foreach ($setup as $key => $value) { // Obtenemos los plugins de la meta. - $all_plugin_meta = db_get_all_rows_in_table('tplugin'); + $all_plugin_meta = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); // Conectamos con el nodo. if (metaconsole_connect($value) == NOERR) { $values = []; // Obtenemos los plugin del nodo. - $node_plugin_server = db_get_all_rows_in_table('tplugin'); + $node_plugin_server = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); foreach ($node_plugin_server as $key2 => $plugin) { // Comprobamos si el id esta meta y nodo al mismo tiempo. $key_exists = array_search($plugin['id'], array_column($all_plugin_meta, 'id')); @@ -896,11 +896,11 @@ if (($create != '') || ($view != '')) { } } - $all_plugin_meta = db_get_all_rows_in_table('tplugin'); + $all_plugin_meta = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); foreach ($setup as $key => $value) { if (metaconsole_connect($value) == NOERR) { - $all_plugin_node = db_get_all_rows_in_table('tplugin'); + $all_plugin_node = db_get_all_rows_sql('SELECT SQL_NO_CACHE * FROM tplugin', false, false); $array_diff = array_diff(array_column($all_plugin_meta, 'id'), array_column($all_plugin_node, 'id')); foreach ($array_diff as $key2 => $pluginid) { From e19e7d3484c29b7bdf1a6f5ae3408bcdf770ecf3 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 26 Feb 2019 17:30:21 +0100 Subject: [PATCH 206/262] Modified agents_create_agent to permit create agents with name as alias Former-commit-id: 9d3524e2dc02beb92d819cd877b9b44f64154fd5 --- pandora_console/include/functions_agents.php | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 8c4f5db14b..0ac9bb876f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -82,17 +82,25 @@ function agents_get_agent_id_by_alias($alias) /** - * Creates an agent + * Creates an agent. * - * @param string Agent name. - * @param string Group to be included. - * @param int Agent interval - * @param string Agent IP + * @param string $name Agent name. + * @param string $id_group Group to be included. + * @param integer $interval Agent interval. + * @param string $ip_address Agent IP. + * @param mixed $values Other tagente fields. + * @param boolean $alias_as_name True to not assign an alias as name. * * @return integer New agent id if created. False if it could not be created. */ -function agents_create_agent($name, $id_group, $interval, $ip_address, $values=false) -{ +function agents_create_agent( + $name, + $id_group, + $interval, + $ip_address, + $values=false, + $alias_as_name=false +) { if (empty($name)) { return false; } @@ -101,7 +109,7 @@ function agents_create_agent($name, $id_group, $interval, $ip_address, $values=f return false; } - // Check interval greater than zero + // Check interval greater than zero. if ($interval < 0) { $interval = false; } @@ -115,7 +123,7 @@ function agents_create_agent($name, $id_group, $interval, $ip_address, $values=f } $values['alias'] = $name; - $values['nombre'] = hash('sha256', $name.'|'.$ip_address.'|'.time().'|'.sprintf('%04d', rand(0, 10000))); + $values['nombre'] = ($alias_as_name === false) ? hash('sha256', $name.'|'.$ip_address.'|'.time().'|'.sprintf('%04d', rand(0, 10000))) : $name; $values['id_grupo'] = $id_group; $values['intervalo'] = $interval; @@ -128,12 +136,12 @@ function agents_create_agent($name, $id_group, $interval, $ip_address, $values=f return false; } - // Create address for this agent in taddress + // Create address for this agent in taddress. if (!empty($ip_address)) { agents_add_address($id_agent, $ip_address); } - db_pandora_audit('Agent management', "New agent '$name' created"); + db_pandora_audit('Agent management', 'New agent '.$name.' created'); return $id_agent; } From 5b3ce095150e4fc7f899ee6e5b885de994aa1d35 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 Feb 2019 17:41:42 +0100 Subject: [PATCH 207/262] Comment updates in wizard class Former-commit-id: 0b820729a631d906fe4816ba74f84f700b500c01 --- .../godmode/wizards/Wizard.main.php | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index c584e6a9b7..708caa4c52 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -1,11 +1,39 @@ Date: Tue, 26 Feb 2019 17:42:12 +0100 Subject: [PATCH 208/262] Comment updates in wizard class Former-commit-id: 9fbb1d0c6499dd1ad71c472970b3993193b581da --- pandora_console/godmode/wizards/Wizard.main.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 708caa4c52..c763e0ff29 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -526,6 +526,8 @@ class Wizard /** * Prints a go back button redirecting to main page. * + * @param string $url Optional target url. + * * @return void */ public function printGoBackButton($url=null) From 0e7c498e1abd6a628f12ea7cf1782729ffb11960 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 Feb 2019 17:53:58 +0100 Subject: [PATCH 209/262] Comment updates Former-commit-id: a711916af981c065d26def1943fc526d936de5d3 --- pandora_console/include/ajax/events.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index af05a8c07f..9d327bb540 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -580,7 +580,6 @@ if ($get_extended_event) { dataType : "html", success: function (data) { $("#related_data").html(data); - console.log("vamos puta"); } }); });'; From a8874f9b1b0922f8bc82b713833aa924b143d42b Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 Feb 2019 20:00:41 +0100 Subject: [PATCH 210/262] Minor fixes Former-commit-id: c3abb9964c61f0535ab59644f6eb1d0a8328212a --- .../wizards/DiscoveryTaskList.class.php | 888 +++++------------- .../godmode/wizards/HostDevices.class.php | 315 +------ 2 files changed, 246 insertions(+), 957 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 9f7c416854..0daa3d3cd7 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -30,6 +30,7 @@ require_once __DIR__.'/Wizard.main.php'; require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_reports.php'; require_once $config['homedir'].'/include/functions_cron.php'; +enterprise_include('include/functions_tasklist.php'); /** * Defined as wizard to guide user to explore running tasks. @@ -72,6 +73,9 @@ class DiscoveryTaskList extends Wizard /** * Implements run method. * + * @param string $message Redirected input. + * @param boolean $status Redirected input. + * * @return mixed Returns null if wizard is ongoing. Result if done. */ public function run($message='', $status=null) @@ -115,45 +119,41 @@ class DiscoveryTaskList extends Wizard if (enterprise_installed()) { // This check only applies to enterprise users. - // Check if DiscoveryCronTasks is running. Warn user if not. - if ($config['cron_last_run'] == 0 - || (get_system_time() - $config['cron_last_run']) > 3600 - ) { - $message_conf_cron = __('DiscoveryConsoleTasks is not running properly').'. '; - if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { - $message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service'); - $message_conf_cron .= '. '.__('Please, add the following line to your crontab file:'); - $message_conf_cron .= '
          * * * * * <user> wget -q -O - --no-check-certificate ';
          -                    $message_conf_cron .= str_replace(
          -                        ENTERPRISE_DIR.'/meta/',
          -                        '',
          -                        ui_get_full_url(false)
          -                    );
          -                    $message_conf_cron .= ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
          -                    $message_conf_cron .= '/cron/cron.php >> ';
          -                    $message_conf_cron .= $config['homedir'].'/pandora_console.log
          '; - } + enterprise_hook('tasklist_checkrunning'); - if (isset($config['cron_last_run']) === true - && $config['cron_last_run'] > 0 - ) { - $message_conf_cron .= '

          '.__('Last execution').': '; - $message_conf_cron .= date('Y/m/d H:i:s', $config['cron_last_run']).'

          '; - $message_conf_cron .= '

          '; - $message_conf_cron .= __('Please check process is no locked.').'

          '; - } - - ui_print_warning_message($message_conf_cron, '', false); - } + $ret = $this->showListConsoleTask(); + } else { + $ret = false; } - $ret = $this->showListConsoleTask(); $ret2 = $this->showList(); if ($ret === false && $ret2 === false) { include_once $config['homedir'].'/general/firts_task/recon_view.php'; + } else { + $form = [ + 'form' => [ + 'method' => 'POST', + 'action' => ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery' + ), + ], + 'inputs' => [ + [ + 'arguments' => [ + 'name' => 'submit', + 'label' => __('Go back'), + 'type' => 'submit', + 'attributes' => 'class="sub cancel"', + 'return' => true, + ], + ], + ], + ]; } + $this->printForm($form); + return $ret; } @@ -237,7 +237,7 @@ class DiscoveryTaskList extends Wizard $id_console_task = (int) get_parameter('id_console_task'); if ($id_console_task !== null) { - cron_task_run($id_console_task, true); + enterprise_include('cron_task_run', $id_console_task, true); // Trick to avoid double execution. header('Location: '.$this->url); } @@ -313,255 +313,229 @@ class DiscoveryTaskList extends Wizard ui_print_error_message(__('Discovery Server is disabled')); return false; } else { - $recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task'); - if ($recon_task === false) { - return false; - } else { - include_once $config['homedir'].'/include/functions_graph.php'; - include_once $config['homedir'].'/include/functions_servers.php'; - include_once $config['homedir'].'/include/functions_network_profiles.php'; + include_once $config['homedir'].'/include/functions_graph.php'; + include_once $config['homedir'].'/include/functions_servers.php'; + include_once $config['homedir'].'/include/functions_network_profiles.php'; - $modules_server = 0; - $total_modules = 0; - $total_modules_data = 0; + $modules_server = 0; + $total_modules = 0; + $total_modules_data = 0; - // -------------------------------- - // FORCE A RECON TASK - // -------------------------------- - if (check_acl($config['id_user'], 0, 'PM')) { - if (isset($_GET['force'])) { - $id = (int) get_parameter_get('force', 0); - servers_force_recon_task($id); - header( - 'Location: '.ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist' + // -------------------------------- + // FORCE A RECON TASK + // -------------------------------- + if (check_acl($config['id_user'], 0, 'PM')) { + if (isset($_GET['force'])) { + $id = (int) get_parameter_get('force', 0); + servers_force_recon_task($id); + header( + 'Location: '.ui_get_full_url( + 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist' + ) + ); + } + } + + foreach ($servers as $serverItem) { + $id_server = $serverItem['id_server']; + $server_name = servers_get_name($id_server); + $recon_tasks = db_get_all_rows_field_filter( + 'trecon_task', + 'id_recon_server', + $id_server + ); + + $user_groups = implode(',', array_keys(users_get_groups())); + $defined_tasks = db_get_all_rows_filter( + 'tuser_task_scheduled', + 'id_grupo IN ('.$user_groups.')' + ); + + if (isset($tasks_console) === true + && is_array($tasks_console) === true + ) { + foreach ($tasks_console as $key => $value) { + $value['parameters'] = unserialize( + $value['parameters'] + ); + + $value['type'] = 'Cron'; + array_push($recon_tasks, $value); + } + } + + // Show network tasks for Recon Server. + if ($recon_tasks === false) { + $recon_tasks = []; + } + + $table = new StdClass(); + $table->cellpadding = 4; + $table->cellspacing = 4; + $table->width = '100%'; + $table->class = 'databox data'; + $table->head = []; + $table->data = []; + $table->align = []; + $table->headstyle = []; + for ($i = 0; $i < 9; $i++) { + $table->headstyle[$i] = 'text-align: left;'; + } + + $table->head[0] = __('Force'); + $table->align[0] = 'left'; + + $table->head[1] = __('Task name'); + $table->align[1] = 'left'; + + $table->head[2] = __('Interval'); + $table->align[2] = 'left'; + + $table->head[3] = __('Network'); + $table->align[3] = 'left'; + + $table->head[4] = __('Status'); + $table->align[4] = 'left'; + + $table->head[5] = __('Task type'); + $table->align[5] = 'left'; + + $table->head[6] = __('Progress'); + $table->align[6] = 'left'; + + $table->head[7] = __('Updated at'); + $table->align[7] = 'left'; + + $table->head[8] = __('Operations'); + $table->align[8] = 'left'; + + foreach ($recon_tasks as $task) { + $data = []; + + if ($task['disabled'] == 0) { + $data[0] = ''; + $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]); + $data[0] .= ''; + } else if ($task['disabled'] == 2) { + $data[0] = ui_print_help_tip( + __('This task has not been completely defined, please edit it'), + true + ); + } else { + $data[0] = ''; + } + + $data[1] = ''.$task['name'].''; + + if ($task['interval_sweep'] > 0) { + $data[2] = human_time_description_raw( + $task['interval_sweep'] + ); + } else { + $data[2] = __('Manual'); + } + + if ($task['id_recon_script'] == 0) { + $data[3] = $task['subnet']; + } else { + $data[3] = '-'; + } + + if ($task['status'] <= 0) { + $data[4] = __('Done'); + } else { + $data[4] = __('Pending'); + } + + if ($task['id_recon_script'] == 0) { + // Discovery NetScan. + $data[5] = html_print_image( + 'images/network.png', + true, + ['title' => __('Discovery NetScan')] + ).'  '; + $data[5] .= network_profiles_get_name( + $task['id_network_profile'] + ); + } else { + // APP recon task. + $data[5] = html_print_image( + 'images/plugin.png', + true + ).'  '; + $data[5] .= db_get_sql( + sprintf( + 'SELECT name FROM trecon_script WHERE id_recon_script = %d', + $task['id_recon_script'] ) ); } - } - foreach ($servers as $serverItem) { - $id_server = $serverItem['id_server']; - $server_name = servers_get_name($id_server); - $recon_tasks = db_get_all_rows_field_filter( - 'trecon_task', - 'id_recon_server', - $id_server - ); - - $user_groups = implode(',', array_keys(users_get_groups())); - $defined_tasks = db_get_all_rows_filter( - 'tuser_task_scheduled', - 'id_grupo IN ('.$user_groups.')' - ); - - if (isset($tasks_console) === true - && is_array($tasks_console) === true - ) { - foreach ($tasks_console as $key => $value) { - $value['parameters'] = unserialize( - $value['parameters'] - ); - - $value['type'] = 'Cron'; - array_push($recon_tasks, $value); - } - } - - // Show network tasks for Recon Server. - if ($recon_tasks === false) { - $recon_tasks = []; - } - - $table = new StdClass(); - $table->cellpadding = 4; - $table->cellspacing = 4; - $table->width = '100%'; - $table->class = 'databox data'; - $table->head = []; - $table->data = []; - $table->align = []; - $table->headstyle = []; - for ($i = 0; $i < 9; $i++) { - $table->headstyle[$i] = 'text-align: left;'; - } - - $table->head[0] = __('Force'); - $table->align[0] = 'left'; - - $table->head[1] = __('Task name'); - $table->align[1] = 'left'; - - $table->head[2] = __('Interval'); - $table->align[2] = 'left'; - - $table->head[3] = __('Network'); - $table->align[3] = 'left'; - - $table->head[4] = __('Status'); - $table->align[4] = 'left'; - - $table->head[5] = __('Task type'); - $table->align[5] = 'left'; - - $table->head[6] = __('Progress'); - $table->align[6] = 'left'; - - $table->head[7] = __('Updated at'); - $table->align[7] = 'left'; - - $table->head[8] = __('Operations'); - $table->align[8] = 'left'; - - foreach ($recon_tasks as $task) { - $data = []; - - if ($task['disabled'] == 0) { - $data[0] = ''; - $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]); - $data[0] .= ''; - } else if ($task['disabled'] == 2) { - $data[0] = ui_print_help_tip( - __('This task has not been completely defined, please edit it'), - true - ); - } else { - $data[0] = ''; - } - - $data[1] = ''.$task['name'].''; - - if ($task['interval_sweep'] > 0) { - $data[2] = human_time_description_raw( - $task['interval_sweep'] - ); - } else { - $data[2] = __('Manual'); - } - - if ($task['id_recon_script'] == 0) { - $data[3] = $task['subnet']; - } else { - $data[3] = '-'; - } - - if ($task['status'] <= 0) { - $data[4] = __('Done'); - } else { - $data[4] = __('Pending'); - } - - if ($task['id_recon_script'] == 0) { - // Discovery NetScan. - $data[5] = html_print_image( - 'images/network.png', - true, - ['title' => __('Discovery NetScan')] - ).'  '; - $data[5] .= network_profiles_get_name( - $task['id_network_profile'] - ); - } else { - // APP recon task. - $data[5] = html_print_image( - 'images/plugin.png', - true - ).'  '; - $data[5] .= db_get_sql( - sprintf( - 'SELECT name FROM trecon_script WHERE id_recon_script = %d', - $task['id_recon_script'] - ) - ); - } - - if ($task['status'] <= 0 || $task['status'] > 100) { - $data[6] = '-'; - } else { - $data[6] = progress_bar( - $task['status'], - 100, - 20, - __('Progress').':'.$task['status'].'%', - 1 - ); - } - - if ($task['utimestamp'] > 0) { - $data[7] = ui_print_timestamp( - $task['utimestamp'], - true - ); - } else { - $data[7] = __('Not executed yet'); - } - - if (check_acl( - $config['id_user'], - $task['id_group'], - 'PM' - ) - ) { - // Check if is a H&D, Cloud or Application. - $data[8] = ''.html_print_image( - 'images/config.png', - true - ).''; - $data[8] .= ''.html_print_image( - 'images/cross.png', - true - ).''; - } else { - $data[8] = ''; - } - - array_push($table->data, $data); - } - - if (empty($table->data)) { - echo '
          '.__('Server').' '.$server_name.' '.__('has no recon tasks assigned').'
          '; + if ($task['status'] <= 0 || $task['status'] > 100) { + $data[6] = '-'; } else { - echo '

          '.__('Server task').'

          '; - html_print_table($table); + $data[6] = progress_bar( + $task['status'], + 100, + 20, + __('Progress').':'.$task['status'].'%', + 1 + ); } - unset($table); + if ($task['utimestamp'] > 0) { + $data[7] = ui_print_timestamp( + $task['utimestamp'], + true + ); + } else { + $data[7] = __('Not executed yet'); + } + + if (check_acl( + $config['id_user'], + $task['id_group'], + 'PM' + ) + ) { + // Check if is a H&D, Cloud or Application. + $data[8] = ''.html_print_image( + 'images/config.png', + true + ).''; + $data[8] .= ''.html_print_image( + 'images/cross.png', + true + ).''; + } else { + $data[8] = ''; + } + + array_push($table->data, $data); } + + echo '

          '.__('Server tasks').'

          '; + if (empty($table->data)) { + echo '
          '.__('Server').' '.$server_name.' '.__('has no discovery tasks assigned').'
          '; + return false; + } else { + html_print_table($table); + } + + unset($table); } } - $form = [ - 'form' => [ - 'method' => 'POST', - 'action' => ui_get_full_url( - 'index.php?sec=gservers&sec2=godmode/servers/discovery' - ), - ], - 'inputs' => [ - [ - 'arguments' => [ - 'name' => 'submit', - 'label' => __('Go back'), - 'type' => 'submit', - 'attributes' => 'class="sub cancel"', - 'return' => true, - ], - ], - ], - ]; - - $this->printForm($form); - return true; } @@ -573,385 +547,7 @@ class DiscoveryTaskList extends Wizard */ public function showListConsoleTask() { - global $config; - - check_login(); - - if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access recon task viewer' - ); - include 'general/noaccess.php'; - return false; - } - - $read_perms = check_acl( - $config['id_user'], - 0, - 'RR' - ); - $write_perms = check_acl( - $config['id_user'], - 0, - 'RW' - ); - $manage_perms = check_acl( - $config['id_user'], - 0, - 'RM' - ); - $manage_pandora = check_acl( - $config['id_user'], - 0, - 'PM' - ); - - $url = 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=tasklist&'; - - $user_groups = implode( - ',', - array_keys(users_get_groups()) - ); - - $defined_tasks = db_get_all_rows_filter( - 'tuser_task_scheduled', - 'id_grupo IN ('.$user_groups.')' - ); - - if (!check_acl($config['id_user'], 0, 'PM')) { - $read_tasks = []; - foreach ($defined_tasks as $task) { - $function_name = db_get_value( - 'function_name', - 'tuser_task', - 'id', - $task['id_user_task'] - ); - - if (($function_name != 'cron_task_execute_custom_script') - && ($function_name != 'cron_task_do_backup') - ) { - $read_tasks[] = $task; - } - } - - $defined_tasks = $read_tasks; - - if (empty($defined_tasks)) { - $defined_tasks = false; - } - } - - if ($defined_tasks !== false) { - echo '

          '.__('Console task').'

          '; - - $table = new stdClass(); - $table->class = 'databox data'; - $table->width = '100%'; - $table->data = []; - $table->head = []; - $table->head[0] = ''; - $table->head[1] = __('User'); - $table->head[2] = __('Task'); - $table->head[3] = __('Scheduled'); - $table->head[4] = __('Next execution'); - $table->head[5] = __('Last run'); - $table->head[6] = __('Group'); - $table->head[7] = __('Operations'); - $table->align[7] = 'left'; - - foreach ($defined_tasks as $task) { - $data = []; - - $function_name = db_get_value( - 'function_name', - 'tuser_task', - 'id', - $task['id_user_task'] - ); - - switch ($function_name) { - case 'cron_task_generate_report': - if ($write_perms || $manage_pandora) { - $data[0] = ''; - $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')] - ).''; - } - - 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')] - ).''; - } - - 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); - } else { - return false; - } - - return true; + return enterprise_hook('tasklist_showListConsoleTask', [$this]); } diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index aa5c94666c..1626b1db0b 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -780,266 +780,10 @@ $("select#interval_manual_defined").change(function() { ]; } - // Feature configuration. - // Input: SNMP enabled. - $form['inputs'][] = [ - 'label' => __('SNMP enabled'), - 'arguments' => [ - 'name' => 'snmp_enabled', - 'type' => 'switch', - 'return' => true, - 'value' => (isset($this->task['snmp_enabled'])) ? $this->task['snmp_enabled'] : 1, - 'onclick' => 'extraSNMP();', - - ], - ]; - - // SNMP CONFIGURATION. - $form['inputs'][] = [ - 'hidden' => 1, - 'block_id' => 'snmp_extra', - 'block_content' => [ - [ - 'label' => __('SNMP version'), - 'arguments' => [ - 'name' => 'snmp_version', - 'fields' => [ - '1' => 'v. 1', - '2c' => 'v. 2c', - '3' => 'v. 3', - ], - 'type' => 'select', - 'script' => 'SNMPExtraShow(this.value)', - 'selected' => $this->task['snmp_version'], - 'return' => true, - ], - ], - ], - ]; - - // SNMP Options pack v1. - $form['inputs'][] = [ - 'hidden' => 1, - 'block_id' => 'snmp_options_basic', - 'block_content' => [ - [ - 'label' => ''.__('SNMP Default community').''.ui_print_help_tip( - __( - 'You can specify several values, separated by commas, for example: public,mysecret,1234' - ), - true - ), - 'arguments' => [ - 'name' => 'community', - 'type' => 'text', - 'value' => $this->task['snmp_community'], - 'size' => 25, - 'return' => true, - - ], - ], - ], - ]; - - // SNMP Options pack v3. - $form['inputs'][] = [ - 'hidden' => 1, - 'block_id' => 'snmp_options_v3', - 'block_content' => [ - [ - 'label' => ''.__('Context').'', - 'arguments' => [ - 'name' => 'snmp_context', - 'type' => 'text', - 'value' => $this->task['snmp_community'], - 'size' => 15, - 'return' => true, - - ], - ], - [ - 'label' => ''.__('Auth user').'', - 'arguments' => [ - 'name' => 'snmp_auth_user', - 'type' => 'text', - 'value' => $this->task['snmp_auth_user'], - 'size' => 15, - 'return' => true, - - ], - ], - [ - 'label' => ''.__('Auth password').''.ui_print_help_tip( - __( - 'The pass length must be eight character minimum.' - ), - true - ), - 'arguments' => [ - 'name' => 'snmp_auth_pass', - 'type' => 'password', - 'value' => $this->task['snmp_auth_pass'], - 'size' => 15, - 'return' => true, - - ], - ], - [ - 'label' => ''.__('Privacy method').'', - 'arguments' => [ - 'name' => 'snmp_privacy_method', - 'type' => 'select', - 'fields' => [ - 'DES' => __('DES'), - 'AES' => __('AES'), - ], - 'selected' => $this->task['snmp_privacy_method'], - 'size' => 15, - 'return' => true, - - ], - ], - [ - 'label' => ''.__('Privacy pass').''.ui_print_help_tip( - __( - 'The pass length must be eight character minimum.' - ), - true - ), - 'arguments' => [ - 'name' => 'snmp_privacy_pass', - 'type' => 'password', - 'value' => $this->task['snmp_privacy_pass'], - 'size' => 15, - 'return' => true, - - ], - ], - [ - 'label' => ''.__('Auth method').'', - 'arguments' => [ - 'name' => 'snmp_auth_method', - 'type' => 'select', - 'fields' => [ - 'MD5' => __('MD5'), - 'SHA' => __('SHA'), - ], - 'selected' => $this->task['snmp_auth_method'], - 'size' => 15, - 'return' => true, - - ], - ], - [ - 'label' => ''.__('Security level').'', - 'arguments' => [ - 'name' => 'snmp_security_level', - 'type' => 'select', - 'fields' => [ - 'noAuthNoPriv' => __('Not auth and not privacy method'), - 'authNoPriv' => __('Auth and not privacy method'), - 'authPriv' => __('Auth and privacy method'), - ], - 'selected' => $this->task['snmp_security_level'], - 'size' => 15, - 'return' => true, - - ], - ], - - ], - ]; - - // Input: WMI enabled. - $form['inputs'][] = [ - 'label' => __('WMI enabled'), - 'arguments' => [ - 'name' => 'wmi_enabled', - 'type' => 'switch', - 'value' => (isset($this->task['wmi_enabled'])) ? $this->task['wmi_enabled'] : 0, - 'return' => true, - 'onclick' => 'toggleWMI();', - - ], - ]; - - // WMI CONFIGURATION. - $form['inputs'][] = [ - 'block_id' => 'wmi_extra', - 'hidden' => 1, - 'block_content' => [ - [ - 'label' => ''.__('WMI Auth. strings').''.ui_print_help_tip( - __( - 'Auth strings must be defined as user%pass, comma separated as many you need.' - ), - true - ), - 'arguments' => [ - 'name' => 'auth_strings', - 'type' => 'text', - 'value' => $this->task['auth_strings'], - 'return' => true, - ], - ], - ], - ]; - - // Input: Enforce os detection. - $form['inputs'][] = [ - 'label' => __('OS detection'), - 'arguments' => [ - 'name' => 'os_detect', - 'type' => 'switch', - 'return' => true, - 'value' => (isset($this->task['os_detect'])) ? $this->task['os_detect'] : 1, - - ], - ]; - - // Input: Name resolution. - $form['inputs'][] = [ - 'label' => __('Name resolution'), - 'arguments' => [ - 'name' => 'resolve_names', - 'type' => 'switch', - 'return' => true, - 'value' => (isset($this->task['resolve_names'])) ? $this->task['resolve_names'] : 0, - ], - ]; - - // Input: Parent detection. - $form['inputs'][] = [ - 'label' => __('Parent detection'), - 'arguments' => [ - 'name' => 'parent_detection', - 'type' => 'switch', - 'return' => true, - 'value' => (isset($this->task['parent_detection'])) ? $this->task['parent_detection'] : 1, - ], - ]; - - // Input: Parent recursion. - $form['inputs'][] = [ - 'label' => __('Parent recursion'), - 'arguments' => [ - 'name' => 'parent_recursion', - 'type' => 'switch', - 'return' => true, - 'value' => (isset($this->task['parent_recursion'])) ? $this->task['parent_recursion'] : 1, - ], - ]; - - // Input: VLAN enabled. - $form['inputs'][] = [ - 'label' => __('VLAN enabled'), - 'arguments' => [ - 'name' => 'vlan_enabled', - 'type' => 'switch', - 'return' => true, - 'value' => (isset($this->task['vlan_enabled'])) ? $this->task['vlan_enabled'] : 1, - ], - ]; + if (enterprise_installed()) { + // Feature configuration. + enterprise_require('include/hostdevices_extra.php'); + } // Submit button. $form['inputs'][] = [ @@ -1052,57 +796,6 @@ $("select#interval_manual_defined").change(function() { ], ]; - $form['js'] = ' -function SNMPExtraShow(target) { - $("#snmp_options_basic").hide(); - $("#snmp_options_v3").hide(); - if (document.getElementsByName("snmp_enabled")[0].checked) { - $("#snmp_extra").show(); - if (target == 3) { - $("#snmp_options_v3").show(); - } else { - $("#snmp_options_basic").show(); - } - } - -} - -function extraSNMP() { - if (document.getElementsByName("snmp_enabled")[0].checked) { - SNMPExtraShow($("#snmp_version").val()); - $("#snmp_extra").show(); - } else { - // Hide unusable sections - $("#snmp_extra").hide(); - $("#snmp_options_basic").hide(); - $("#snmp_options_v3").hide(); - - // Disable snmp dependant checks - if (document.getElementsByName("parent_recursion")[0].checked) - $("input[name=parent_recursion]").click(); - - if (document.getElementsByName("parent_detection")[0].checked) - $("input[name=parent_detection]").click(); - - if (document.getElementsByName("vlan_enabled")[0].checked) - $("input[name=vlan_enabled]").click(); - - } -} - -function toggleWMI() { - if (document.getElementsByName("wmi_enabled")[0].checked) - $("#wmi_extra").show(); - else - $("#wmi_extra").hide(); -} - -$(function() { - SNMPExtraShow($("#snmp_version").val()); - toggleWMI(); -}); - '; - $form['form'] = [ 'method' => 'POST', 'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'], From 24a1adfb9fa293e4d33ef9dc50a52ad17ccb0b20 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 Feb 2019 20:08:01 +0100 Subject: [PATCH 211/262] minor fix Former-commit-id: 6729d11217d0fecb7b64283b6e4d0485b9bdfdc8 --- pandora_console/godmode/wizards/HostDevices.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index 1626b1db0b..a1143fad03 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -782,7 +782,7 @@ $("select#interval_manual_defined").change(function() { if (enterprise_installed()) { // Feature configuration. - enterprise_require('include/hostdevices_extra.php'); + enterprise_require_once('include/hostdevices_extra.php'); } // Submit button. From 7ed3252ca5a3afb929b8d0f2fd6308a896647bfa Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 26 Feb 2019 20:23:52 +0100 Subject: [PATCH 212/262] minor fixes Former-commit-id: 75b33343bed508ff3ff136fa0fedc5d9d8c952be --- .../godmode/wizards/DiscoveryTaskList.class.php | 14 +++++--------- .../godmode/wizards/HostDevices.class.php | 10 +++++++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index 0daa3d3cd7..144e6e29ee 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -150,9 +150,9 @@ class DiscoveryTaskList extends Wizard ], ], ]; - } - $this->printForm($form); + $this->printForm($form); + } return $ret; } @@ -311,7 +311,8 @@ class DiscoveryTaskList extends Wizard if ($servers === false) { $servers = []; ui_print_error_message(__('Discovery Server is disabled')); - return false; + $check = db_get_all_rows_sql('SELECT * FROM trecon_task'); + return (bool) $check; } else { include_once $config['homedir'].'/include/functions_graph.php'; include_once $config['homedir'].'/include/functions_servers.php'; @@ -339,12 +340,7 @@ class DiscoveryTaskList extends Wizard foreach ($servers as $serverItem) { $id_server = $serverItem['id_server']; $server_name = servers_get_name($id_server); - $recon_tasks = db_get_all_rows_field_filter( - 'trecon_task', - 'id_recon_server', - $id_server - ); - + $recon_tasks = db_get_all_rows_sql('SELECT * FROM trecon_task'); $user_groups = implode(',', array_keys(users_get_groups())); $defined_tasks = db_get_all_rows_filter( 'tuser_task_scheduled', diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index a1143fad03..f405641fde 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -29,6 +29,7 @@ require_once __DIR__.'/Wizard.main.php'; require_once $config['homedir'].'/include/functions_users.php'; enterprise_include('include/class/CSVImportAgents.class.php'); +enterprise_include_once('include/functions_hostdevices.php'); /** * Wizard section Host&devices. @@ -782,7 +783,14 @@ $("select#interval_manual_defined").change(function() { if (enterprise_installed()) { // Feature configuration. - enterprise_require_once('include/hostdevices_extra.php'); + $extra = enterprise_hook('hd_showextrainputs', [$this]); + if (is_array($extra) === true) { + $form['inputs'] = array_merge( + $form['inputs'], + $extra['inputs'] + ); + $form['js'] = $extra['js']; + } } // Submit button. From 65b89f66880123f0ffd51197640b0497a994f1f8 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 27 Feb 2019 00:01:47 +0100 Subject: [PATCH 213/262] Auto-updated build strings. Former-commit-id: 59e3d47f8cc8c9fedb86f0ba6fd7fe183cb908b8 --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index e9d22f629b..015f306205 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.731-190226 +Version: 7.0NG.731-190227 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 64c13e926e..4e132515b9 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190226" +pandora_version="7.0NG.731-190227" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index bb7d98e310..97b13365d3 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.731'; -use constant AGENT_BUILD => '190226'; +use constant AGENT_BUILD => '190227'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index d4e33903d4..ce3173b9f3 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190226 +%define release 190227 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 87436366bb..f5be518e22 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.731 -%define release 190226 +%define release 190227 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 3ff9b6a963..e27ad14333 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190226" +PI_BUILD="190227" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index abdf2e0ce4..3d62982f64 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190226} +{190227} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 01f027089d..8ce589ce8a 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.731(Build 190226)") +#define PANDORA_VERSION ("7.0NG.731(Build 190227)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index cb30f2163d..f54a5ebd36 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.731(Build 190226))" + VALUE "ProductVersion", "(7.0NG.731(Build 190227))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index fe87752dff..8ece3fcc84 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.731-190226 +Version: 7.0NG.731-190227 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 60d17de09e..ea4a0bd5a1 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190226" +pandora_version="7.0NG.731-190227" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 81ddb9f336..3a5efda30b 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 = 'PC190226'; +$build_version = 'PC190227'; $pandora_version = 'v7.0NG.731'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index ec9414274a..e63f181b52 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
          [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 076f19497a..2ce12d8e32 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190226 +%define release 190227 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index e3adf2711e..c29be2cabf 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.731 -%define release 190226 +%define release 190227 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 55915d85a0..c59ea4898c 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.731" -PI_BUILD="190226" +PI_BUILD="190227" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index c8eb037f7a..e8f8a43cdd 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.731 PS190226"; +my $version = "7.0NG.731 PS190227"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 33a9c811b8..bcfc3939bd 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.731 PS190226"; +my $version = "7.0NG.731 PS190227"; # save program name for logging my $progname = basename($0); From 8780571a74085fa0a26cf90c7b269938311ec0d8 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 27 Feb 2019 10:59:44 +0100 Subject: [PATCH 214/262] add new functionality in event response Former-commit-id: 2cf28b95c068c40e79b8f05b212aad0f720de79b --- pandora_console/include/ajax/events.php | 96 +++++++++++++- .../include/javascript/pandora_events.js | 82 ++++++++++-- .../operation/events/events.build_table.php | 119 ++++++++++++------ pandora_console/operation/events/events.php | 1 + 4 files changed, 243 insertions(+), 55 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 9d327bb540..0d7d3f5a9f 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -54,6 +54,7 @@ $table_events = get_parameter('table_events', 0); $total_events = (bool) get_parameter('total_events'); $total_event_graph = (bool) get_parameter('total_event_graph'); $graphic_event_group = (bool) get_parameter('graphic_event_group'); +$get_table_response_command = (bool) get_parameter('get_table_response_command'); if ($get_event_name) { $event_id = get_parameter('event_id'); @@ -116,6 +117,7 @@ if ($get_response_target) { } echo events_get_response_target($event_id, $response_id, $server_id); + return; } @@ -129,6 +131,7 @@ if ($get_response) { } echo json_encode($event_response); + return; } @@ -136,6 +139,7 @@ if ($perform_event_response) { global $config; $command = get_parameter('target', ''); + $response_id = get_parameter('response_id'); $event_response = db_get_row('tevent_response', 'id', $response_id); @@ -148,7 +152,11 @@ if ($perform_event_response) { 'nano', ]; - $server_data = db_get_row('tserver', 'id_server', $event_response['server_to_exec']); + $server_data = db_get_row( + 'tserver', + 'id_server', + $event_response['server_to_exec'] + ); if (in_array(strtolower($command), $commandExclusions)) { echo 'Only stdin/stdout commands are supported'; @@ -234,13 +242,29 @@ if ($dialogue_event_response) { ); echo '

          '; - echo "'; + echo "'; echo "
          "; if ($end) { echo "
          '; } } else { @@ -796,3 +820,67 @@ if ($graphic_event_group) { echo $prueba; return; } + +if ($get_table_response_command) { + global $config; + + $response_id = get_parameter('event_response_id'); + $params_string = db_get_value( + 'params', + 'tevent_response', + 'id', + $response_id + ); + + $params = explode(',', $params_string); + + $table = new stdClass; + $table->id = 'events_responses_table_command'; + $table->width = '90%'; + $table->styleTable = 'text-align:center; margin: 0 auto;'; + + $table->style = []; + $table->style[0] = 'text-align:center;'; + $table->style[1] = 'text-align:center;'; + + $table->head = []; + $table->head[0] = __('Commands'); + $table->head[0] .= ui_print_help_tip( + __('These commands will apply to all selected events'), + true + ); + $table->head[1] = __('Value'); + + if (isset($params) === true + && is_array($params) === true + ) { + foreach ($params as $key => $value) { + $table->data[$key][0] = $value; + $table->data[$key][1] = html_print_input_text( + $value.'-'.$key, + '', + '', + 50, + 255, + true, + false, + false, + '', + 'response_command_input' + ); + } + } + + echo '
          '; + echo html_print_table($table, true); + echo '
          '; + echo html_print_submit_button( + __('Execute'), + 'enter_command', + false, + 'class="sub next" style="float:right; margin-top:15px; margin-right:25px;"', + true + ); + + return; +} diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 8fbef6b03d..42d67fffd6 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -241,6 +241,7 @@ function show_massive_response_dialog( }, close: function(event, ui) { $(".chk_val").prop("checked", false); + $("#event_response_command_window").dialog("close"); }, width: response["modal_width"], height: response["modal_height"] @@ -375,7 +376,12 @@ function add_row_param(id_table, param) { } // Get an event response from db -function get_response_target(event_id, response_id, server_id) { +function get_response_target( + event_id, + response_id, + server_id, + response_command +) { var ajax_file = $("#hidden-ajax_file").val(); var target = ""; @@ -400,15 +406,21 @@ function get_response_target(event_id, response_id, server_id) { } }); - // Replace the custom params macros + // Replace the custom params macros. var response_params = get_response_params(response_id); - if (response_params.length > 1 || response_params[0] != "") { for (i = 0; i < response_params.length; i++) { - target = target.replace( - "_" + response_params[i] + "_", - $("#" + response_params[i]).val() - ); + if (!response_command) { + target = target.replace( + "_" + response_params[i] + "_", + $("#" + response_params[i]).val() + ); + } else { + target = target.replace( + "_" + response_params[i] + "_", + response_command[response_params[i] + "-" + i] + ); + } } } @@ -459,10 +471,6 @@ function perform_response_massive(target, response_id, out_iterator) { $("#response_loading_command_" + out_iterator).show(); $("#response_out_" + out_iterator).html(""); - var finished = 0; - var time = Math.round(+new Date() / 1000); - var timeout = time + 10; - var params = []; params.push("page=include/ajax/events"); params.push("perform_event_response=1"); @@ -487,7 +495,7 @@ function perform_response_massive(target, response_id, out_iterator) { return false; } -// Change the status of an event to new, in process or validated +// Change the status of an event to new, in process or validated. function event_change_status(event_ids) { var ajax_file = $("#hidden-ajax_file").val(); @@ -681,3 +689,53 @@ function show_events_group_agent(id_insert, id_agent, server_id) { } }); } + +function show_event_response_command_dialog(id, response, total_checked) { + var ajax_file = $("#hidden-ajax_file").val(); + + var params = []; + params.push("page=include/ajax/events"); + params.push("get_table_response_command=1"); + params.push("event_response_id=" + id); + + jQuery.ajax({ + data: params.join("&"), + type: "POST", + url: (action = ajax_file), + dataType: "html", + success: function(data) { + $("#event_response_command_window") + .hide() + .empty() + .append(data) + .dialog({ + resizable: true, + draggable: true, + modal: false, + open: function() { + $("#response_loading_dialog").hide(); + $("#button-submit_event_response").show(); + }, + width: 600, + height: 300 + }) + .show(); + + $("#submit-enter_command").on("click", function(e) { + e.preventDefault(); + var response_command = []; + + $(".response_command_input").each(function() { + response_command[$(this).attr("name")] = $(this).val(); + }); + + check_massive_response_event( + id, + response, + total_checked, + response_command + ); + }); + } + }); +} diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index a9e319c82a..d38bd1918e 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -988,6 +988,10 @@ if ($group_rep == 2) { 'A maximum of %s event custom responses can be selected', $config['max_execution_event_response'] ).''; + echo ''; echo '
          '; } } @@ -995,12 +999,14 @@ if ($group_rep == 2) { ?>
          "; echo "
          "; +echo "
          "; ui_require_jquery_file('bgiframe'); ui_require_javascript_file('pandora_events'); From 26560c734ca93b970ff8f94a77ae35c91cdab000 Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 27 Feb 2019 11:25:50 +0100 Subject: [PATCH 215/262] Updated version and build strings. Former-commit-id: 39df6ee0aee9f29c9afb8729f9e95b316ca8cd67 --- pandora_agents/pc/AIX/pandora_agent.conf | 2 +- pandora_agents/pc/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/pc/HP-UX/pandora_agent.conf | 2 +- pandora_agents/pc/Linux/pandora_agent.conf | 2 +- pandora_agents/pc/NT4/pandora_agent.conf | 2 +- pandora_agents/pc/SunOS/pandora_agent.conf | 2 +- pandora_agents/pc/Win32/pandora_agent.conf | 2 +- pandora_agents/shellscript/aix/pandora_agent.conf | 2 +- pandora_agents/shellscript/bsd-ipso/pandora_agent.conf | 2 +- pandora_agents/shellscript/hp-ux/pandora_agent.conf | 2 +- pandora_agents/shellscript/linux/pandora_agent.conf | 2 +- pandora_agents/shellscript/mac_osx/pandora_agent.conf | 2 +- pandora_agents/shellscript/openWRT/pandora_agent.conf | 2 +- pandora_agents/shellscript/solaris/pandora_agent.conf | 2 +- pandora_agents/unix/AIX/pandora_agent.conf | 2 +- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/Darwin/pandora_agent.conf | 2 +- pandora_agents/unix/FreeBSD/pandora_agent.conf | 2 +- pandora_agents/unix/HP-UX/pandora_agent.conf | 2 +- pandora_agents/unix/Linux/pandora_agent.conf | 2 +- pandora_agents/unix/NT4/pandora_agent.conf | 2 +- pandora_agents/unix/NetBSD/pandora_agent.conf | 2 +- pandora_agents/unix/SunOS/pandora_agent.conf | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 4 ++-- pandora_agents/unix/pandora_agent.spec | 4 ++-- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/bin/pandora_agent.conf | 2 +- pandora_agents/win32/installer/pandora.mpi | 4 ++-- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 4 ++-- pandora_console/pandora_console.redhat.spec | 4 ++-- pandora_console/pandora_console.spec | 4 ++-- pandora_console/pandora_console_install | 2 +- pandora_console/pandoradb_data.sql | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/conf/pandora_server.conf.new | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 4 ++-- pandora_server/pandora_server.spec | 4 ++-- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 50 files changed, 58 insertions(+), 58 deletions(-) diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index bff05d8732..07054ee2e1 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, AIX version +# Version 7.0NG.732, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 938691a2af..9d8a49bb99 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, FreeBSD Version +# Version 7.0NG.732, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index d6f6d248c9..c02e4647e1 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, HP-UX Version +# Version 7.0NG.732, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 0de221f790..153113e070 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, GNU/Linux +# Version 7.0NG.732, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index cb90a522a3..6ddeba7edc 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, GNU/Linux +# Version 7.0NG.732, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index 1758206b7b..502317f893 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, Solaris Version +# Version 7.0NG.732, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index bc4a50047f..96b20ea7e3 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2010 Artica Soluciones Tecnologicas -# Version 7.0NG.731 +# Version 7.0NG.732 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 6ca5613d16..200ff9db97 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.731, AIX version +# Version 7.0NG.732, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index b55b3033f6..2002f4db65 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.731 +# Version 7.0NG.732 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 4a5a240381..f9c19dbd06 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.731, HPUX Version +# Version 7.0NG.732, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 8e2600567a..dc272a7a71 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731 +# Version 7.0NG.732 # Licensed under GPL license v2, # (c) 2003-2010 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 8dfed3e54d..5a466677d2 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731 +# Version 7.0NG.732 # Licensed under GPL license v2, # (c) 2003-2009 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index ca04eca187..170188cc6f 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731 +# Version 7.0NG.732 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index 563805acdb..aad04ca60d 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.731, Solaris version +# Version 7.0NG.732, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 9d787783ff..3ce7da3c7e 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, AIX version +# Version 7.0NG.732, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 015f306205..e22ad033cd 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.731-190227 +Version: 7.0NG.732 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 4e132515b9..3bf9ddbeab 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190227" +pandora_version="7.0NG.732" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/pandora_agent.conf b/pandora_agents/unix/Darwin/pandora_agent.conf index 2164faaedc..35202fcbe5 100644 --- a/pandora_agents/unix/Darwin/pandora_agent.conf +++ b/pandora_agents/unix/Darwin/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, GNU/Linux +# Version 7.0NG.732, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf index 0c5a190f9b..c505d5f75e 100644 --- a/pandora_agents/unix/FreeBSD/pandora_agent.conf +++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, FreeBSD Version +# Version 7.0NG.732, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/HP-UX/pandora_agent.conf b/pandora_agents/unix/HP-UX/pandora_agent.conf index f039431f7a..237bffb291 100644 --- a/pandora_agents/unix/HP-UX/pandora_agent.conf +++ b/pandora_agents/unix/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, HP-UX Version +# Version 7.0NG.732, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index df03402446..5a65e0e095 100644 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, GNU/Linux +# Version 7.0NG.732, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NT4/pandora_agent.conf b/pandora_agents/unix/NT4/pandora_agent.conf index 12421565e8..1394067390 100644 --- a/pandora_agents/unix/NT4/pandora_agent.conf +++ b/pandora_agents/unix/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, GNU/Linux +# Version 7.0NG.732, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/NetBSD/pandora_agent.conf b/pandora_agents/unix/NetBSD/pandora_agent.conf index 6dd394db7a..677615a47c 100644 --- a/pandora_agents/unix/NetBSD/pandora_agent.conf +++ b/pandora_agents/unix/NetBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, NetBSD Version +# Version 7.0NG.732, NetBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/SunOS/pandora_agent.conf b/pandora_agents/unix/SunOS/pandora_agent.conf index 3d7294a56a..89d5b46100 100644 --- a/pandora_agents/unix/SunOS/pandora_agent.conf +++ b/pandora_agents/unix/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.731, Solaris Version +# Version 7.0NG.732, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 97b13365d3..d23b2dbc8b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -41,7 +41,7 @@ my $Sem = undef; # Semaphore used to control the number of threads my $ThreadSem = undef; -use constant AGENT_VERSION => '7.0NG.731'; +use constant AGENT_VERSION => '7.0NG.732'; use constant AGENT_BUILD => '190227'; # Agent log default file size maximum and instances diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index ce3173b9f3..68e68b96da 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.731 -%define release 190227 +%define version 7.0NG.732 +%define release 1 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index f5be518e22..d0ba8171de 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -2,8 +2,8 @@ #Pandora FMS Linux Agent # %define name pandorafms_agent_unix -%define version 7.0NG.731 -%define release 190227 +%define version 7.0NG.732 +%define release 1 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index e27ad14333..066c36036d 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -9,7 +9,7 @@ # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.731" +PI_VERSION="7.0NG.732" PI_BUILD="190227" OS_NAME=`uname -s` diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index aab9a2f315..3d1e208de8 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2017 Artica Soluciones Tecnologicas -# Version 7.0NG.731 +# Version 7.0NG.732 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3d62982f64..160347190c 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -3,7 +3,7 @@ AllowLanguageSelection {Yes} AppName -{Pandora FMS Windows Agent v7.0NG.731} +{Pandora FMS Windows Agent v7.0NG.732} ApplicationID {17E3D2CF-CA02-406B-8A80-9D31C17BD08F} @@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives {No} Windows,Executable -{<%AppName%>-<%Version%>-Setup<%Ext%>} +{<%AppName%>-Setup<%Ext%>} Windows,FileDescription {<%AppName%> <%Version%> Setup} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 8ce589ce8a..9698e9c322 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.731(Build 190227)") +#define PANDORA_VERSION ("7.0NG.732(Build 190227)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index f54a5ebd36..0feb88dcc9 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.731(Build 190227))" + VALUE "ProductVersion", "(7.0NG.732(Build 190227))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8ece3fcc84..5e56471fa3 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.731-190227 +Version: 7.0NG.732 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index ea4a0bd5a1..6f582418aa 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.731-190227" +pandora_version="7.0NG.732" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 3a5efda30b..d5ca8db9fe 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -21,7 +21,7 @@ * Pandora build version and version */ $build_version = 'PC190227'; -$pandora_version = 'v7.0NG.731'; +$pandora_version = 'v7.0NG.732'; // Do not overwrite default timezone set if defined. $script_tz = @date_default_timezone_get(); diff --git a/pandora_console/install.php b/pandora_console/install.php index 0799f277b9..ae179b9418 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -128,8 +128,8 @@
          Date: Wed, 27 Feb 2019 11:32:39 +0100 Subject: [PATCH 216/262] add changes to migrate script Former-commit-id: 7e1beeed2a8ff709cdd2e2ff992b610cd4aa7409 --- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 2492a9913f..a60e6bfd8a 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1900,14 +1900,18 @@ CREATE TABLE IF NOT EXISTS `tevent_extended` ( -- ----------------------------------------------------- -- Table `tgis_map_layer_groups` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( - `layer_id` INT NOT NULL, - `group_id` MEDIUMINT(4) UNSIGNED NOT NULL, - `agent_id` INT(10) UNSIGNED NOT NULL COMMENT 'Used to link the position to the group', - PRIMARY KEY (`layer_id`, `group_id`), - FOREIGN KEY (`layer_id`) REFERENCES `tgis_map_layer` (`id_tmap_layer`) ON DELETE CASCADE, - FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, - FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE +DROP TABLE IF EXISTS `tgis_map_layer_groups`; + +CREATE TABLE `tgis_map_layer_groups` ( + `layer_id` int(11) NOT NULL, + `group_id` mediumint(4) unsigned NOT NULL, + `agent_id` int(10) unsigned NOT NULL COMMENT 'Used to link the position to the group', + PRIMARY KEY (`layer_id`,`group_id`), + KEY `group_id` (`group_id`), + KEY `agent_id` (`agent_id`), + CONSTRAINT `tgis_map_layer_groups_ibfk_1` FOREIGN KEY (`layer_id`) REFERENCES `tgis_map_layer` (`id_tmap_layer`) ON DELETE CASCADE, + CONSTRAINT `tgis_map_layer_groups_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `tgrupo` (`id_grupo`) ON DELETE CASCADE, + CONSTRAINT `tgis_map_layer_groups_ibfk_3` FOREIGN KEY (`agent_id`) REFERENCES `tagente` (`id_agente`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ----------------------------------------------------- @@ -2018,6 +2022,11 @@ CREATE TABLE `tnotification_source_group_user` ( ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- ---------------------------------------------------------------------- +-- Table `tuser_task_scheduled` +-- ---------------------------------------------------------------------- +ALTER TABLE `tuser_task_scheduled` ADD COLUMN `flag_delete` tinyint(1) unsigned NOT NULL DEFAULT '0'; + -- ---------------------------------------------------------------------- -- Add alert command 'Generate notification' -- ---------------------------------------------------------------------- From e55e47cbfa80e12a31728e2cb207db2dc87b5aad Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 27 Feb 2019 11:35:00 +0100 Subject: [PATCH 217/262] change mr Former-commit-id: 4ec37be9caef34e88b3e5ca65bca2c1aee7f03dd --- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 4 ++-- pandora_console/pandoradb_data.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 2492a9913f..d8377484c3 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1199,13 +1199,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 24); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 25); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '731'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '732'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); -- --------------------------------------------------------------------- diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index b471ca22f0..25bff0eb4d 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -111,7 +111,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 24), +('MR', 25), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), ('current_package_enterprise', '732'), From ec5c9d7c2765d5ec565fb11ee18287ed7c723b0b Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 27 Feb 2019 13:41:26 +0100 Subject: [PATCH 218/262] clippy returns Former-commit-id: b9ed010f5af1002593471a0d0298848b3593e41e --- pandora_console/general/header.php | 3 + pandora_console/include/functions_clippy.php | 108 ++++++++++++++----- 2 files changed, 83 insertions(+), 28 deletions(-) diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index e35d401502..3d7ce7dd6e 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -294,6 +294,9 @@ config_check(); + +; + '; - echo ''; @@ -155,23 +102,17 @@ if (check_acl($config['id_user'], 0, 'AW') require 'godmode/menu.php'; echo '
          '; -echo ''; -echo ''; -/* - echo '
          '; - html_print_input_hidden('button_collapse', 1); - echo '
          '; -*/ + // require ("links_menu.php"); echo '
          '; // menu_container ui_require_jquery_file('cookie'); - -$config_fixed_menu = false; -if (isset($config['fixed_menu'])) { +/* + $config_fixed_menu = false; + if (isset($config['fixed_menu'])) { $config_fixed_menu = $config['fixed_menu']; -} +}*/ $config_fixed_header = false; if (isset($config['fixed_header'])) { @@ -184,34 +125,20 @@ if (isset($config['fixed_header'])) { -//var classic_menu; -//$(document).ready(function(){ +//var classic_menu; $('#button_collapse').on('click', function() { - -/* - var elem = document.getElementById('button_collapse'); -elem.className = elem.className.replace('button_collapse', 'cambiar'); -*/ if($('#menu_full').hasClass('menu_full_classic')){ localStorage.setItem("menuType", "collapsed"); - //$('#button_collapse').css('color','pink'); - document.getElementById("menu_type").innerHTML = localStorage.menuType; - $('ul.submenu').css('left', '59px');//hacer que esto se haga aqui - $('#top_btn').css('left', '0px'); + $('ul.submenu').css('left', '59px'); } else if($('#menu_full').hasClass('menu_full_collapsed')){ localStorage.setItem("menuType", "classic"); - //$('#button_collapse').css('color','blue'); - document.getElementById("menu_type").innerHTML = localStorage.menuType; - $('ul.submenu').css('left', '214px');//hacer que esto se haga aqui - $('#top_btn').css('left', '77.5px'); + $('ul.submenu').css('left', '214px'); } else{ console.log('else'); } - /* $('.logo_full').toggleClass("logo_show logo_hide"); - $('.logo_icon').toggleClass('logo_hide logo_show');*/ $('.logo_full').toggle(); $('.logo_icon').toggle(); $('#menu_full').toggleClass('menu_full_classic menu_full_collapsed'); @@ -222,53 +149,31 @@ elem.className = elem.className.replace('button_collapse', 'cambiar'); $('li.menu_icon').toggleClass("no_hidden_menu menu_icon_collapsed"); - - console.log('entra click'); - console.log(localStorage.menuType); -/* -if ($('#button_collapse').text() == 'classic') { - classic_menu = true; -} -else { - classic_menu = false; -} -console.log('aqui comprueba click, y si el menu no ha cambiado, no deberia recargar todo'); -console.log(classic_menu); -*/ - + console.log('entra click: '+localStorage.menuType); }); -//}); var autohidden_menu = ; -var fixed_menu = ; +//var fixed_menu = + +; var fixed_header = ; var id_user = ""; var cookie_name = id_user + '-pandora_menu_state'; var cookie_name_encoded = btoa(cookie_name); var click_display = ""; -//var classic_menu = parseInt(""); +//var classic_menu = parseInt(" + +"); + -//if ((isNaN(classic_menu)) || (classic_menu == 0)) { -//f(localStorage.menuType == 'classic'){ -/* -if ($('#button_collapse').text() == 'classic') { - classic_menu = true; -} -else { - classic_menu = false; -} -console.log('aqui comprueba si es classic_menu'); -console.log(classic_menu); -*/ -/* -if (classic_menu) { - autohidden_menu = 1; -} -*/ var menuState = $.cookie(cookie_name_encoded); if (!menuState) { @@ -295,175 +200,7 @@ function close_submenus () { $('div.menu>ul>li.selected>ul').addClass('invisible'); } -$(document).ready( function() { -// repeticion de if - -var classic_menu; -if ($('#menu_type').text() == 'classic') { - classic_menu = true; - -} -else { - classic_menu = false; - -} - - - -console.log('aqui comprueba repeticion '); -console.log(classic_menu); -// fin repeticion de if - - - //Daniel maya 02/06/2016 Fixed menu position--INI - /* if (fixed_menu) { - $('div#menu') - .css('position', 'fixed') - .css('z-index', '9000') - .css('top','80px') - }else{ - $('div#menu') - .css('z-index', '9000') - } - if (fixed_header) { - $('div#menu') - .css('position', 'fixed') - .css('z-index', '9000') - .css('top','80px') - $('#menu_tab_frame_view').css('margin-top','20px') - }*/ - - //console.log(click_display); - - // if (autohidden_menu) { - handsInMenu = 0; - openTimeMenu = 0; - if (classic_menu) { - //$('div#title_menu').show(); - handsInMenu = 1; - openTimeMenu = new Date().getTime(); - /*$('#menu').css('width', '145px'); - $('#menu').css('position', 'block'); - $('div#menu').css('top', '80px'); - $('li.menu_icon').removeClass('menu_icon_collapsed').addClass("no_hidden_menu");*/ - /*$('ul.submenu').css('left', '214px');*/ - /* $('#menu_full').css('width','215px'); - $('.button_collapse').css('width','215px'); - $('div#page').addClass('page_classic'); - $('#header_table').addClass('header_table_classic'); */ - console.log('a (es clasico)'); - /*$('#menu').mouseleave(function() { - handsInMenu = 0; - setTimeout(function() { - openedMenu = new Date().getTime() - openTimeMenu; - if(openedMenu > 1000 && handsInMenu == 0) { - /* $('#menu').css('width', '145px'); - $('#menu').css('position', 'block');*/ - /* console.log('a'); - console.log(classic_menu); - /* $('li.menu_icon').removeClass('menu_icon_collapsed').addClass("no_hidden_menu");*/ - /* $('ul.submenu').css('left', '214px'); - /* $('#menu_full').css('width','215px'); - $('.button_collapse').css('width','215px'); - $('div#page').addClass('page_classic'); - $('#header_table').addClass('header_table_classic');*/ - /* } - }, 2500); - });*/ - } - else { - //NO ES CLASSIC MENU - if(!click_display){ - $('#menu').mouseenter(function() { - // $('div#title_menu').show(); - handsInMenu = 1; - openTimeMenu = new Date().getTime(); - /*$('#menu').css('width', '145px');*/ - console.log('b (collapsed)'); - /* $('li.menu_icon').removeClass('menu_icon_collapsed').addClass("no_hidden_menu");*/ - $('li.menu_icon').find('li').addClass("no_hidden_menu"); - /*$('ul.submenu').css('left', '214px');*/ - /*$('#menu_full').css('width','215px'); - $('.button_collapse').css('width','215px'); - $('div#page').addClass('page_classic'); - $('#header_table').addClass('header_table_classic'); */ - }).mouseleave(function() { - handsInMenu = 0; - setTimeout(function() { - openedMenu = new Date().getTime() - openTimeMenu; - if(openedMenu > 1000 && handsInMenu == 0) { - console.log('c (collapsed)'); - /* $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed');*/ - $('li.menu_icon').find('li').removeClass( " no_hidden_menu" ); - /* $('ul.submenu').css('left', '44px');*/ - //$('div#title_menu').hide(); - } - }, 2500); - }); - }else{ - $(document).ready(function() { - $('#menu').on("click", function() { - //$('div#title_menu').show(); - handsInMenu = 1; - openTimeMenu = new Date().getTime(); - /* $('#menu').css('width', '145px');*/ - console.log('d (collapsed)'); - /* $('li.menu_icon').removeClass('menu_icon_collapsed').addClass("no_hidden_menu");*/ - $('li.menu_icon').find('li').addClass("no_hidden_menu"); - /* $('ul.submenu').css('left', '44px');*/ - /* $('#menu_full').css('width','215px'); - $('.button_collapse').css('width','215px'); - $('div#page').addClass('page_classic'); - $('#header_table').addClass('header_table_classic'); */ - }) - .mouseleave(function() { - handsInMenu = 0; - setTimeout(function() { - openedMenu = new Date().getTime() - openTimeMenu; - if(openedMenu > 1000 && handsInMenu == 0) { - console.log('e (collapsed)'); - /* $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed');*/ - $('li.menu_icon').find('li').removeClass( " no_hidden_menu" ); - /* $('ul.submenu').css('left', '44px');*/ - //$('div#title_menu').hide(); - } - }, 5500); - }); - }); - } - } - /* } - else { - $('div#title_menu').hide(); - if(!click_display){ - $('#menu').mouseenter(function() { - handsInMenu = 1; - openTimeMenu = new Date().getTime(); - $('ul.submenu').css('left', '44px'); - }).mouseleave(function() { - handsInMenu = 0; - setTimeout(function() { - openedMenu = new Date().getTime() - openTimeMenu; - if(openedMenu > 1000 && handsInMenu == 0) { - console.log('f'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); - $('li.menu_icon').find('li').removeClass( " no_hidden_menu" ); - $('ul.submenu').css('left', '44px'); - } - }, 2500); - }); - } - } - } - } - } - } - } - }*/ -}); /* ]]> */ @@ -551,122 +288,49 @@ console.log(classic_menu); $(document).ready(function() { - - // if (!classic_menu) { - //Daniel maya 02/06/2016 Display menu with click --INI - if(!click_display){ - $('#container').click(function() { - openTime = 4000; - if( typeof(table_hover) != 'undefined') - $("ul#sub"+table_hover[0].id).hide(); - if( typeof(table_hover2) != 'undefined') - $("ul#sub"+table_hover2[0].id).hide(); - /* $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); - $('ul.submenu').css('left', '44px');*/ - //$('div#title_menu').hide(); - console.log('m (collapsed)'); - }); - }else{ - $('#main').click(function() { - openTime = 4000; - if( typeof(table_hover) != 'undefined') - $("ul#sub"+table_hover[0].id).hide(); - if( typeof(table_hover2) != 'undefined') - $("ul#sub"+table_hover2[0].id).hide(); - /*$('#menu').css('width', '45px'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); - $('ul.submenu').css('left', '44px');*/ - // $('div#title_menu').hide(); - console.log('n (collapsed)'); - }); - } - //Daniel maya 02/06/2016 Display menu with click --END - /* } - else { - if(!click_display){ - $('#container').click(function() { - openTime = 4000; - if( typeof(table_hover) != 'undefined') - $("ul#sub"+table_hover[0].id).hide(); - if( typeof(table_hover2) != 'undefined') - $("ul#sub"+table_hover2[0].id).hide(); - /*$('#menu').css('width', '145px');*/ - /* $('ul.submenu').css('left', '214px'); - $('#menu_full').css('width','215px'); - $('.button_collapse').css('width','215px'); - $('div#page').addClass('page_classic'); - $('#header_table').addClass('header_table_classic'); */ - /* console.log('o (es clasico)'); - }); - }else{ - $('#main').click(function() { - openTime = 4000; - if( typeof(table_hover) != 'undefined') - $("ul#sub"+table_hover[0].id).hide(); - if( typeof(table_hover2) != 'undefined') - $("ul#sub"+table_hover2[0].id).hide(); - /*$('#menu').css('width', '145px');*/ - /* $('ul.submenu').css('left', '214px'); - $('#menu_full').css('width','215px'); - $('.button_collapse').css('width','215px'); - $('div#page').addClass('page_classic'); - $('#header_table').addClass('header_table_classic'); */ - /* console.log('p (es clasico)'); - }); - } - }*/ - - // if (classic_menu) { - $('div.menu>ul>li>ul>li>a').click(function() { + if(!click_display){ + $('#container').click(function() { openTime = 4000; if( typeof(table_hover) != 'undefined') $("ul#sub"+table_hover[0].id).hide(); if( typeof(table_hover2) != 'undefined') $("ul#sub"+table_hover2[0].id).hide(); - /* $('ul.submenu').css('left', '214px');*/ - console.log('q (es clasico)'); - }); + + console.log('m'); // cuando no es de click, pero pinchas (dentro o fuera) (¿sirve de algo?) + }); + }else{ + $('#main').click(function() { + openTime = 4000; + if( typeof(table_hover) != 'undefined') + $("ul#sub"+table_hover[0].id).hide(); + if( typeof(table_hover2) != 'undefined') + $("ul#sub"+table_hover2[0].id).hide(); + + console.log('n'); //al pinchar fuera (es de click) + }); + } + + + $('div.menu>ul>li>ul>li>a').click(function() { + openTime = 4000; + if( typeof(table_hover) != 'undefined') + $("ul#sub"+table_hover[0].id).hide(); + if( typeof(table_hover2) != 'undefined') + $("ul#sub"+table_hover2[0].id).hide(); - $('div.menu>ul>li>ul>li>ul>li>a').click(function() { - openTime = 4000; - if( typeof(table_hover) != 'undefined') - $("ul#sub"+table_hover[0].id).hide(); - if( typeof(table_hover2) != 'undefined') - $("ul#sub"+table_hover2[0].id).hide(); - /*$('ul.submenu').css('left', '214px');*/ - console.log('r (es clasico)'); - }); - /* } - else { - $('div.menu>ul>li>ul>li>a').click(function() { - openTime = 4000; - if( typeof(table_hover) != 'undefined') - $("ul#sub"+table_hover[0].id).hide(); - if( typeof(table_hover2) != 'undefined') - $("ul#sub"+table_hover2[0].id).hide(); - /*$('#menu').css('width', '45px'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); - $('ul.submenu').css('left', '44px');*/ - //$('div#title_menu').hide(); - /* console.log('s (no es clasico)'); - }); - - $('div.menu>ul>li>ul>li>ul>li>a').click(function() { - openTime = 4000; - if( typeof(table_hover) != 'undefined') - $("ul#sub"+table_hover[0].id).hide(); - if( typeof(table_hover2) != 'undefined') - $("ul#sub"+table_hover2[0].id).hide(); - /* $('#menu').css('width', '45px'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); - $('ul.submenu').css('left', '44px');*/ - // $('div#title_menu').hide(); - /* console.log('t (no es clasico)'); - }); - }*/ + console.log('q'); //al pinchar en un enlace de un submenu + }); + + $('div.menu>ul>li>ul>li>ul>li>a').click(function() { + openTime = 4000; + if( typeof(table_hover) != 'undefined') + $("ul#sub"+table_hover[0].id).hide(); + if( typeof(table_hover2) != 'undefined') + $("ul#sub"+table_hover2[0].id).hide(); + + console.log('r'); //al pinchar en un enlace de un sub-submenu + }); + }); - - diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 6aeab7bd8b..e74844585f 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -120,15 +120,16 @@ if (enterprise_installed()) { $row++; } -$table_behaviour->data[$row][0] = __('Classic menu mode').ui_print_help_tip(__('Text menu options always visible, don\'t hide'), true); -$table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( +/* + $table_behaviour->data[$row][0] = __('Classic menu mode').ui_print_help_tip(__('Text menu options always visible, don\'t hide'), true); + $table_behaviour->data[$row][1] = html_print_checkbox_toogle_switch( 'classic_menu', 1, $config['classic_menu'], true -); -$row++; - + ); + $row++; +*/ echo '
          '; echo ''.__('Behaviour configuration').''; html_print_table($table_behaviour); @@ -543,16 +544,16 @@ $table_styles->data[$row][1] = html_print_checkbox_toogle_switch( true ); $row++; - -$table_styles->data[$row][0] = __('Fixed menu'); -$table_styles->data[$row][1] = html_print_checkbox_toogle_switch( +/* + $table_styles->data[$row][0] = __('Fixed menu'); + $table_styles->data[$row][1] = html_print_checkbox_toogle_switch( 'fixed_menu', 1, $config['fixed_menu'], true -); -$row++; - + ); + $row++; +*/ // For 5.1 Autohidden menu feature $table_styles->data['autohidden'][0] = __('Autohidden menu'); $table_styles->data['autohidden'][1] = html_print_checkbox_toogle_switch( diff --git a/pandora_console/images/builder.menu_gray.png b/pandora_console/images/builder.menu_gray.png index 9c3b0b6ff3ac42c9a5aa5e755ee2c0530a81ad85..bee9c472baa1869628b9c7fcae30a0a85c0df1c1 100644 GIT binary patch delta 603 zcmV-h0;K)Q0+el;>PyVI#Y z=@tt!%aK>FULNagYJ7;*pnw1Vu>i3c5Q_r2B0&5XNu4MwD}Sr3xVVHh10!RIppekr ziuwkJj>d*xOgOyEj^uT?W&i*GX8;<+40JW;ub)4~fG#wala~(w$zd1-^wxJFVd3pS z+YSP84F?Bj8PIjtKyn-$9M7&?zSJx7zW^{v|KYRM?#Ia*n zjvUy(_vpcc+kgHu{C}^ks^$dLAO|$)`JJ1$rmtPOV)xfCU(PtYxj+B&_m9?w)vMQH zgweGtSN;I0$1uL6j0`s$8yoAluU|o4V`67#=LU&yShM;MP;BwnuU~Fr1h%WE7dy~9 z#()3*eZs}bDY$3nj>muh{Q3DG6gWuX1OvOaZv$~oVt*Lq>FejGtg7k>49Km*A|f%@ zu3nk*^T&_7NMQ-m_zzp`pcwS|(lKph1@}Ubyt>xtc88)QUO%%YEML;$RfD$=1 p48oeBNj2yrl>UuJ4F&)RFaQFb*L8c8%nbkl002ovPDHLkV1n5gBm4jW delta 267 zcmV+m0rdWu11S7Wk2(7ai~uV-P4|B|r@X#Re!a70}ch5aYFlNGWy! zFd#v+0y$yCfRx8RQWDq{0h$`*0QDXNxzP{HYp?((+n@_jEP!Mn(EuR807rR4uhU9> R7ytkO07*qoL+_WfN+&3c&_#@R5Ek-5wtF(Sf1-KD2?C@SUNmH9dTDwQUJE>tmBPDR!cqssU{zfb zF-W68G_oa3iFvhvew6Flcdf4oY})e+vjn6X_Xi zY6+SGGb;u*Nl*rXAtH^Ju+lM)H8Yj0A7A3XailpH;CaIuv6n(CKrPCRuY&MrF$$$3 zL4jNYX*|foKb1a1S=%rBQH2oB4bb6Ph$p>heAWN8^3cPHNF2TTaPp_e ft=~F8J_Hy5;63oGV9?7Q00000NkvXXu0mjf6-vuR delta 720 zcmV;>0x$i91nC7KiBL{Q4GJ0x0000DNk~Le0000Z0000Z2nGNE03O-1S&<aqdU-d3`0?}ffV!!ndEW- z&EUI>8Vu&eT7+bwrCR`-A-jA-0~esE1jtsq8zm^ovJ+6`_-M}<*?>-c*to&c7DGsY zdSE;M0|poG8Tt(@%vuc#_}Mc+7x2-e{~5M!!hl%%rWFQXtx?c%4Lr|if8R<1Hs)8% zU?2HlAM~nn1lE7CKW#p3YUI$Fg{xyzftY#WRij8&?tJab5ZWgj)XRRuG-fE53S(I) zAZ!&RqaQF>%2Yi&ZRLal!YbNP=eD6UqQky>(jCeW_ct_n`jQ-cOCt~v_t!P-V9V<^ zx4M9M!?US!1tz4Kl>i!gf3TC7h8ye@E0QGf_%?0~3_DI@F>YujH!M8u27n~D#sr6? zPB3WnZb0xD`kiwO4$l(hJs6Sxjz-k_(;b0Ge+N3XKUv~E-0C+?01=ad?QtEdrWIQ^ zQ`ib+MEZH-r}mQdhY8LbRT2aQ?5D0t!C?0+1Uu^+mGz7xKph}4e-7t-ekxo8`I+t7 z-irne&%ZL)u6)Q2oUw4FIOoRy1f)QJEhiYHe82%&1Bx8d&3t8EQBE|0JczcKy(^^{bG-6p@Ht{|~*NKtm z>7HZD*aW}NROFMTCclepCHPBkH3fUQ^6Ej~0t^5Mo>C!bAdXl70000E){7K%i5Psx?Je%lSe^9^P2?C@RQIzBt8q_VM*8Bf9dO1VD@^ z^{L28sjaY1c=9g+kO=eWT0g9%Ekj{34rS?4U1LZ&GhZD_-P%!!Xr5a^e}u87mY{B9 zh}0ZF2|{fg5VH~@H5290Uv4E|(MnS+gtg=<)dEd}H2Urotl2AU6%jT_R|?9NFxG4( zC|k()8dxSl6&g8q;Z0!B;^U)ISlJxa*`t!iu)U)zYqgfaRd*5t^8i>gwf>-Cq_#Yd z?g+J?+K~e)P2(g;u&o`&Ip%cCIBX&YycC$2B8x`|G9$=$Og>_m3k7V zs!os_7vJfC!?vC!OO~A`fvw-~58=asJb~PkaH~i@K=y~jVIMMgY6L)q6Oa)|9x#6m zvI1EGSltN*AW-oXWZuw)Ex}D&f9eMm0KNSQ20+jirJ5Wk-GaQ68|sDy6d=!JN!d;y zV;FZb!_dB1E0-*+=2l>HvaVdvzz38zfRxtN7@-_3&b0xho~I(6X9l6Wl-h1n7W=Z75~BQaW)3HRI^e2mFzAb?y1 zpu!7dnKUL49YYtlXH-0E%3A?ReIJ>M_2+=Fi~%I|?fKOH6i32c;E|vUvJ+KtwZTPa zk>egXnpUFUJTP(jEL0kXNe>&^X%_xAdG#Fp0 zh1aTns(l6dQLGB@MT5xoZ%+Hmt3zktu`qQ(^=$r6AT`y)i5JG>`+~yNbp$D>=GFJ6 z+H#}R;mUWYg*x^v8FsF&x%L~SnyB0EsAU;;zS71sHqfG2F?J{32g_BK^`3^SF*f)*oG6KhD1Uwf^DFAbcz^vuGJkD0S--nxJ7aj@vE$Wq+PjClDC$ojbsM1Tmr1q<0+{Qk9@u6XS|S%4^1U!|9CR_+uEY-lHq~G&L)ZV z+~n)Eh~>v<-~7Va)UBMdT{1kp=|u*fK#76Wdt)koNi$iV&Uq|FMrP@S8vXB zxP5%i*ds@iL#YLnBnSi}{#v~LrtMgPwI?Inw$|@0TI~9ul8YECmRR%4v&qFPKTK|a zu$)UgUJKVRIMQl@{p7b#=eG4h`y#BQ!pE3G0!U)!@F$;1dOzBk>1599|5|fnqAlNl zdF-Xl-}AfKKfm1Zx!?NI&wm{W05K&B1Ix_(^40`J^!7W`!TFPoJ(9Bzv_H3ay6wor zC7kvbC!A=Lm0V&T?0=s}Xt1w$$gLY|z#RSc$pdqwU1*HIO!vw^x?%k$hL3lQn`iYi zqp8vk?WM>;*81KTayj9Ph_OhsvshUJXLB~v^?TiC^4zNTEF?QN`hSuW$msD!WGi`Q zVt6V!bLm8z6)h5Y8PmYtQMZw7n%^IScRm$rf3AYTJ!4Mr`gRZJ_Jd&ZVw}uh3s;QW zOxx!UzV7w_1t)tKyFTpAk5eVm@tI2bWkKc`TA%Fku4RsK>akPFYrlG`W1T|;Pp;fk zBqYgVLuD6!n2>uSCI6U%$d4E3UTr&&EL7wZ&=gS)L zb&yyJhtwMQa-fy4WV=y9_mx~sDo+zJ0pA*Ei-!hcQ6QgxaEvf!#c>=;S0R`07Wo>D zxv;p5gFdw2{dDfcra&@wtUz=^CZK7Hlz@<2lN5y`0&pmGRarOf3We6&DXf%edc4wB zV|9JG&4m*8OMknt+PY3C;%WC*yW>Sx%AaEyus<>fy;pf2h90Z0T(p-`MAR+G7UoSV zk5~van=O+-XpW^;Lr;qKGl6(T7NSTi#^UO&OYI6{@93t56cojXF-e9P3!eupzaGQj z-cF^1f(otol9x0JwJj3JPUSeMtjwERl4#O>=>5T!(|?LEOCAN!rn2YD5EdD?_e`op zo3dK9ESH{OEU~iU195LIUis0c2BkfMEgIXmeBIbkk`TU2Q?(!FB36-i5;S!V#A&PD zG#__zGJ-|fLW!UJgoIXjS`q2J&vW6bgcMop#LvV96xWb<*(-7PLYC+J!s#~4Bwy2J z#U;=d+<$x1HLjJ&#e_nWs6wpv!1M(de~I=$W8=p7eU0=_)+U#WvpnK5ZoTPf!U0dy z4@SmYC<%m6h;Tfezn>JSGxjFI=ViHZtigHZQitLxKcg2jzPtoOmJ%W^ly=1G?bdy| zBV(v769wXaNuDH%Qt2#|-z_88K!$4pDXJ1nTYoV$i6lWtkNVat*0pI%%NN8+60B>j z45`b+S3YoUsWOp`tm7VP1(TNysAREK62&JE#L|lFfJdaFjB1nMY*fhQdrt01V>mlh zK{=ecd15oe%k7L^>DSChC$>n`l!=kMmM!$-f{-=wGg>hqV-8m1=&46DG|zUhT7^R3eSHdRR}_6$n)C8r#4+n&Wf7Asq+)1+c0(% zizJ^kvGQDB=D>XBugy3m3emI+s1rs_CNwIMtFL#cQ#id0lnnG(dnm5DcB@#o)c{$mDv>Dbl@i2vVTm}NJN`^7kJ?z}{_oBzfrjshxf+PWW%u#`Bug;eAxI=TmYtVwmdEKDrUdE)p zn}$!On8X$?f6SPe@7X_`Y;3HREPt2386oTRc+In&rB>=UM9|oCC$ujmRR}Q!tVO^o zNa1VN^DZ!+JJFHZ;(6(BWo;qo9`bX&$L&R>7M``*OO8s+(?uJdn98E zrMDTY{(T4t+J=kahiK;?5TtbYeWE(r(H#~jk>nnOuy%wB$ZGcF(_=N|(5DRBtur;zUj z+S8?yBKq>6jzbEQG-=`&AElahDHw5Ui3+WiL$DZSRl0Y*|s6 zb@tb~%sRaY z_)YTrzy8dTNWUPe)Q&y*=t)8Mn;6OdN$Ow|B=Glm=g{7bZuQWnUu14=OZS;JbO2^l#&|m=&U^$#)l9}49f8(mg?Ut~%-C4q|>_1qTcEBi%YFn>O|=SR3wr|^Kx;eB@t z1;j{{%fw~{rK&lrsy%J62^NmEK^y!XNn2sqC`j zVBMts;N8)-!}+FxVx~d^`G8IvASN~a@4Vuthco1y{US{pb|>u5Ay0h$`S?TqvOOn z7dbT=`-{7Bw$=1?2#7VCadFaM*v@F|kAk9AV@q+$xPrK4Ml8caO|A_;f6-M|)UBR? zpp+O@bp;KE?SQWQM+}m<;1;p2+Aj3-Z_SmCEewW-j$vFH1dE*c_=l4c@OGSv7>ry7gTcsUFc`TE1|yfjU@&qS e4BHm}6JP*3NQXzX9TW2a0000=F_{u$Z`n1Xz$=L>Mdr62{*WLSQk7xCBH*lKroX6K~BG zVFNKxR{hHs{te1$hrzf&Kp;;~PoSqL5bbIU0zY{0;EF>;L6r5fDO^b5-Ynkv12J(WrfWScEt111hsIC3K zt2#UXTiXp|fc%fY|0A)Rk+%yHWPo%-ySu{ifwQ@HWy%GjH%66}21Ft|PHYJmSwgtj(B1LcN+q2NdjWhf_}188rLfT&7}h>EI6DvKyd zNrJ&D52PeT6%>@k6jhbLU{x_CiNCSRXt=vG5{3C2i}(*#8jQx2%kGwf8_G zR9(@|?0-%gV*k&+DE=egUs%LH`=a!ZSP(Pkt;mJL?G7;byx$83%l&zQIDU5jbZ>8eD4kTTYfwSbfM^_U9C>H0T$QK=w=D{m7Q%|K0@ z`AS!L>^4Ko$1c5etCo5#Prp8y9@R{kg9&3n159Od1lG)tns%?PKUv&mU~U|!R8!FLE;8cMuh4KB8yZGX%~uB zeYkB6N~0v@BAN|VW97TRt)@n56NKCmv`9b8cOy;jho?-+%FcS_;PiqW+lp@9J*5*l z7*5Q#QJIQNiBupbqQGxv|ib(TEQ z<5g#h^p3`00T2M8zU88p@vf@zT=NYgph0hzu3&2X@FISQn{$J%M7Cg`a39NFr6IC^#o)c9H!tAcu?R(ccT@r0?&d z99pd8s&D0~Mwj7E2u}u(grcX*Zs^I&YjMmSU8zw z7VVO{>~2qf5k+TXF|f0aXj*J588-+nfBXQTaJ13%<^0!_(h`K%=hsxK`?Z<)I!g4g zmDH04R?P(;XO3l8B;YTntfxJhp$<7rJ`wf zye+x6fON$$$5^ETcd~fLc595ObT!`(eMq5J8ax}&#PVv@;G_X)cZ?2ylfa%SP##kO zc+0I|IqF&z2DFSnNz98-a}e3;^@gvcZ9xW@qN`mzMxidM9&#s*^S@|~TOt%_D(OA! z0{Z+LXL^y&pLD+dWMlyc1MiPyHE=9Y1ZY^Ps6Seo{yp{5{igR=g}xe3(r4?Mi3xp2 z7uL5i*|!@YEf+!-i>wdZ$b=$#+_Ra9gy>PmCl&4Ih0?W0WTHjWG3Lq{&vJh#nQ3uT z1~Rq!bhy8jSn2)-;C1x02E2xdoWqx?iDMU*mEKosW%YS#499}=r?hxq%YggnPNM_9 zeX~SZ;)WT2{hZogfgM&d+NcE_xGWiVpVk`jBUQofr)|pA; zAhn*X`zTpHFE-I@k~gY7*LyOGHfBNrIpupU#Yk(BcJyLOHbXUqkq3K8sNEn#JM~}+ zvT-rD8K<8vSU&S0G%Rsd?+shhYO>!tw}MF`PWQvFh9I;m1Tn%EyiuEFlRu;w%_ z@7hU%KT~nZus&FQKj9pg|2l*KK&nl?&UF(MtPoZiVtxu zPR)sZk+emB&ga>^7tj-D)4{!x6!r6-n!SkgIW+lT7UV>uN9FvHe}3m+qN2lpZY=mc zkt7fj;~iF=Hwra4vG7F;T>|BhCQkBS^5Lalnopkn<}-e#O9rT29wuWxYC6Vqs#sGB zuWt8l*0sIXHm5M$plHc${EDPxgn#F@D3^u_fnIuajm(X{eZ?wirXah+yhZE^fI@2L z1?<$)i4qj5Tr2kjEanWpd)K8@zYnx`%G^Bo>ioygH@<9Xmv`SvYY~2y@8mY>yzi~~ z@VjgS(DIM>onJ|tJz;J?#s+Q{cS_rQ2uy;4OLntp&!L}JI*={x>B|d+xs;mN--A>2 zH;paUda|eDo;~NCSK+;Efzay}ZYFxR6+LJh^InZTo{*igFW4 z5!WhDW^o=b(Mjim?l#W?%AEeIXZ8qXjr?$zLp7n1ekW(JNnB)|V5l*~?9fl4qd9HF zb@BR2SV=-FQ6F7lc%M$o8qV{JoWq@##x_NTrri0c^h*xDYKN0YYIONxmPySA4rsud za6TkEY#RjpGWgLHTXh;Rkh5v9p+8Df^hzn?Mb22++GUjukx$S!7n%Sj&moPVa?*s; zoeo=b%{eaj;M#|Rj;U76OvW`t&8Y@@Kx0)mgH!~QlI2W){gSfwG%X1NwF<1cf1+t7 zyL3zMWkz$qc{#^$yS_uRTk{xi$rFwz)HDzDZbu&uM1A;fzFG0oF}c8L!mtvyD`@0v zsp%!L9xYeqXR1f=E}DI}79_`A^`kh$6MG)W{W;YuN5MW#6qoOr{O+?X--L+RFi~~C zE}^#K4C{wu^3m(v)B&bc$I{oFy8G;BbCp7qw^_w3Zl~S7Nbe)I(io2gkWt1D5_QeJ zqLo@{;{3(`t*HFsmQDdugLUP3=3Mqz1!-pLh)ioPe#6hXJ^G#Mu}A+>?2EYQ2Sb;& z!WS^F*pQU0YyR^;+`9$NI6Ok5*fm&&LO`5?Tp|g*0ta{>YUb?dF{{H%+CUHT4x+u8 z=~?3Mt=zcshPwq?LISLUJ99~vtRHHwpXu9TEu(Xv3roqml)Dd&Z-P#O=4ObNe=4lb zo&AQukx%-w(HbXUoH9g!KCizSw+LRyrxLc&>8-7r&3t^$%wSXZ)Y*ilAepPx2LmXa z6#fy2N!9NgZv*Bd_-k0|p1i|^B?9x~0}SGfJh=Zkq@>BsTmuCKkthq!90X&z-k zJHN-3u}l2%oD>Y&QKT{qCZDP8u4fQgeqSlxl68JLu zONZhK9n#(V(3COGIpelktSk_lTV5LYLB^oby<_U*Q%cpXxdJdVGQQ6Qay#@cYrU4)G5tj+N;FR z>MqdZNyWK>bx3oMQD(L8hA|yvXim&=c|tEggr!NpI`WVW9AUU4AKK8+o;ABxT|RUH zgH}ATUMAu(%dtK2J`LJWmsKEG)boXn_)6e9}JgUR2^(&*OBSG)cgQPSF173)ri zLlkZht_#%h0N#+Wyc3{L#VV8S1Hb=Vj7Z6X&K`SGr)>DKdHWx3yvtl_nF?^l4ut~B z*?=++F{K+`2c^c9Vfe~;9C025lJvy-wNBHZ=8DBpK6C^wMqC& zo5|wKB>3{XnCAP49*(_^^Wn&Q^!Yl2AS{w^!Yq*aUJ1)B5?M>m_(AK!Ar2`dZ~Cj~ zj|;)0I{{I83kJ8|FSi8{Q`G(TjqvR~Q|;DTS_&mF`9<2m99>yZMCYuBJAcR38X(O? zk_N&Ekh}R>37LN6t2l`4Ud=V&Z6Xx@p4`tEsrJ|k>Mx?smLC(6P+IhpI5}(IipCYZ97?QRc83# zC~B1(H|+ZDPi%G$as$6TAfRMnJ-aKsc9Tf;j{$M=y2g!hd7ra}xMxn{UQ&KivxUK( z9w|(WWgsry|8;bS9qTv^6MSgij3Na!?8P+l&W8j?^x{ zWZZP!KWRKJxt0)<2#p~7%-lxuEdw(kg78bbKeB9uv6h#IyQA6O zCKQj}%9u9MLL!~U<$0$i&Qo@R_GF8X0f|zK$y7D$Q|QJPkty>{A}o>iAcC)W@D+QE zh(SUFWDhx0ClZ-;7Ua{5-1^6|%o3Beb1kb^QfOHD%R<#)P( z9zCB`vM`lWJ)Afq`sVfQ=(x@h(@mow1_pH|OB^D8i90fpC>&7EG8fompzd$sEd?ok zbR(l5U+}BZqd%Be^8{3tR<50UgO3zs^H_Tg>sczMWc#tV&c%c<{GU^-F26Q(dy+99 zPWWH<@`g`^PsAS${=C;eu{)3*-^>wMR8ov2>_-#<6 zfkV30E!=kPVPgHh1zl!iW!LU#kzL~C%wy4~RIvFn{tWeWk|4{(<#1hrCm1@6;am0d z-#-pP4O8X>lQtO@wOy=CAbN5CKq^uN5~rZOJ)`7qb${UxR-_Hn>jat$g-7~~}Y zG!rEY0nV{qvuXDZv?uGUzu!g5eD#?sEnLJHpE3ZUb@lYvPOkUOZ7xDLsPldvYmrOP z-lJXvk0i-#yqU;fT%ZA^K_Kj8c; zu3jEK(xJ**8sB<#r+TJi2SqN3%=7?WSU52`6|FwQK4G!6W*Oe8Hs#EdusL~u*7f@x zWncY7OSZs1rRTW$?XtQ1%&$>Y=|Pz;^zOkIED4{x$0{BDd5x)5WQ|_|^m$n;&V(N6 z;0sm#Yu1Oub#Ox|$MS&FwULs?*Nybc{fGv{&9ap%EI@KlCw?d=_qr_K)lN-fD$>yy zD^?q*jLYGH#i@I5GM@|ntsP)=`d~(vVV@i5d!7+Dst04e$I0n+3aAIjByz+9Q2-h5YwnY+I)VXK1BML&D*)U8^opNVT^E7$M&!Rg0PkPD; zyY4XEyoACo7|w^|d|M`NUi>g_c{K7Y>RboVA=#}Mtm?mmKSCi}Cc3t@tKt|{DoL?F zkI0w`<r6Qv(AEg!q=?YdS2s13Q zNMbZme>j)m5=~~@hE6~o!m!S@>H;j&lmP}LVT=I#h>FUVxTtfRb3{j3g;EBL^3hUY zbZdKWdp}ywMNu~OpKo%K_v<|8oaa36iy;5g;Qia?E4#}Dn|}%lJ|;+FyG$nkrT2JO z?LhyRgWQ=`rxTehAC>x6ZaynO1tFTI->ca5s#mZcVDDS|kZolzmZWMlO(K!#8IcH! zrLQ(QW>CWq8j>$2{=uDa>9o_Z%-hcetw{9WPNCd@k{OLU7Lm~jy zg~Q=|UiazGP2g7zb>a|-%VZQlvO=K{PbQNweOWyFUbq z;rOU;WrYM}Tq2bspS3i9P`q_(QhK`91YAf{HR&(tGVafzX)1vO;kF(`1b^*46V0N%cbl|Ig1Qnt^KpLlsi+=xY|MKu6GV+`KP)25!k)p!Sude}Q@#BJL zeh=rjeyr-q>2M$;_G^w186t8v8nha%_TF5hv42P&uXvJWnUuTua6@MH<>e)}dw%|( z$~NRZC@ZggbK3@GQYk~zSTGPMf^NuHv%s)0pU0!20a9))j)}1mL1L%%aKqs6(AB>) z%FfZFRW&tLkoI99G#eZ;p@TSg79)`?&$^~Nz21fMDz!QbbS8m7NjQ!bK2lhC$>|vN zEPpL7{sGirwJLcCuOB+MgbIaDBpQ{%91{wKNWky!>1b`;eg6CJ&gDN^D3->?766bi z5{V?jD|o!Pq-1dT>d;L-2NVbdl+X>Adv30FVtl+H7!3CC`TVd@TDG?0xVHiene(;nssW5e^{u8TV6@O^S>-G8l{yi2`U8lLOmbx)9aTYGmN23S> zrLk)~PEAgD4%Y3jrWy8Y2u%OEJvZ)j#N8oLkUdg!;C;O=BeNZpZUk*z=xA-J`u6OZ zU)SGLs*@8B9XZm*(99-}$6Z!aS#j=;zMAVBvCb2xeroIL4xjqw%*n@!w`BjjbD1l$)Ts z35xFJ9$^F6;JQH>ff2CLZ_bxGt*~TSB+iGO-)Z6^_VxXfQDE=)yY1c0SQ3GJQ0VZJ zAtk}C*efWs5<<;)&94Yu3ABIWkmMTIy+7fp5-R_7GqI2^ z{yeN|nQ<8s8Wk<;7Z}_Dv?`8`jg6m~nORF&MMasPU*Ph^^XEPgWl%&+te1zk&s0W6 z2Dd+d{&4^Q|DWOCzkh6ujEtJ{ii-Y%LP9(j&YeAi*PzI_IDa!&53e>B78VPjA*{%9 zKm%EUE)$lOmzNb55xI2X?AeD{4T?!jW^i(K>t|(Ub@~1KHxoA30$s+y%)%ldE3d#O zA}YH2{FyUgaTLY6`UdJ8oSeo$LzwYJ!rwoCm|0m^Obm>S6kuW~2L1T)-Qe%vzZ}Fw zH_&C=-@kvi#D8iK5OCp(Nh}d1gv+46pfDxUAdtF0xD5J7fX7=g)w z9m60s4GjivZf=ABz(6F*U;qDeva_=rX=-aD(vhOFGJ9o1qc<@5SN{6-OAwfXi7|*3 zXt9#Lv-AB+=P%p`>sYjUjRq4V(@J3a5e6Cp3c&xsWPiX6RLla+*#BWPQ2sA4b^if- z4d@UiM#gWveEg9hg$(!Z+yQ!vC;A`IUr-DG@bd6VvvY8o{{R0^2pXG=AVYrr{CWM; z=TE1Bd|38jeDUHr?qVc4Gt1P?!)w;(&z}rnVnDC_I)3!iM(CUo^oI8z%l^J$>h n&Y*?M6&@yL=FQmD0|XcVA|kd<)nh_r00000NkvXXu0mjf$Gr{$ delta 234 zcmVBYWXxIU~1_2ELX+96c0(g7@GRzQY*aKuiCNxF$1Poz- z%J<`R5zsXt1@9S%2ZG4qh3p~&2GW27F0YYlkO3}(1Q;j)Ok)gG0yHs*pG3X<7|{<+ z&HG6VCs5Qo0+YZ6ut8)Rf{|rdU>ri}1PUHNF}h)RbN_!V!i_-N8%T|{16ag1kQ4oZ kNE#nN!{P!i#Q*^Y006r=6kvOz+5i9m07*qoM6N<$f{!~?3;+NC diff --git a/pandora_console/images/gm_configuration.menu_gray.png b/pandora_console/images/gm_configuration.menu_gray.png index f791bed3e225f01323931d56a67ed4667cd9c50f..1d69e0f85b91a92c614bae6dfe4d173262122f0f 100644 GIT binary patch delta 753 zcmV< zEQv4qfAf9c;g|P+@6E^K{ii_o9tMXW78Vv2w^9@-RVuOf&woZozE4k0W(7j`9UYVPx%P{CW7#;)iyM!0|YVS+gMK=3G{9HORDm8l>=Af)?_lNM{{z_W{V{T`|;J~ zr9(k{Zt3eEc<^LoRJ_(_Q&usX$y`Q7M(0^5ekL3XqwLFKn%l3 zwAzAHG#dFx_P#k+k#P_%7@8L1xY~S5XNX54;fYP(#=#&+ z-33L}qbOR!G7JpGpQ+dd;HPvtEe7i?C3>AN8jk$f4}bO>ZgEtfm&Jmlw{oB8?xag;8Y7FY|W?|m>O|DchDwWC% zb~OO{0Ga?;om`>lEHhSk{KTfyPZ0ah(URNEo3Y#3S%<@)NF>Hebb6^wCcgkMD}df{ zFxXd1^MCR>%~jS_ug5dL6$tzd+8gU@Yt+up_Gd$BxmYU8vr!~@7C>)7^U#osB2jK@ zO?~~+;)2T+4uuW|ak1g`QsHoD+-Ry4!+yZ}$xg^F jA0W?r@7{UzOMn3Y=8Z;(+Dcf600000NkvXXu0mjf_H$ks delta 303 zcmV+~0nq-f2JQloNPhtkNklICQn#0d~z zeAEqa18@UIUoZehNoNGaB!k{GljjtR z_j3bjk3dQyO_R(bYupB?xgY2u>q*v55_!n%F4u-kg$&!sv5DM<#34ownTZX@W|+S? z^mLDy3FV6SKPVL~jFD{)3oJIW%yQCQWTyTC3;^SPY|x~vjc@<}002ovPDHLkV1hYR Bh_V0x diff --git a/pandora_console/images/gm_discovery.menu.png b/pandora_console/images/gm_discovery.menu.png index 0f396c08c688a8b396bd2f6817ed999fa71774dc..65fcf321e430260b9056db4caaec811bca089e31 100644 GIT binary patch delta 766 zcmVbTnI=r1Y0AjRD0Auj`KP$lF%vRKRb9hdOIv5ToV!M-adB6m0q=Nu zcou1>s_y3J<>6FNR(1-Hj^RdE&w|YmFJC_f9X-9cj~_q00J>)HkDotfxwtr$MMZ=d zzWw+iuc4*w3{po{bjjl?A+rL6e4xli!(@qPX9@sr2>hmVy0{`tose=R8~{^8@t z0HUH_-_XcIT2?j`=o&5wF;RVG1qB&#QBj6JfB!PPc>S9B_aC5%3=B)}-MRf6r;9AC zZ5U+b<=y}O{mcLH^JkM!pFe8>6C(qV&+zi~Ylf#!pEF2HON)B?`dQ!&Bfp>^UL|E^ z!;c?7vav8TGdzFwn&I)Yf9DJg|AEd2^4Zu}8GtSl`uypWD^U4foCX0E82|e9iy!0) zu-}=O7&v)(8JK|lA3uJ;lyL*omIY6uZr|Dk%p&(# z+1MEV{r$@bOjGjenwnfV4f_B8pEi)<=j7u0{o?ua{de!&E?Ty5f1%6FDU;pr-@TLn z=)wI1K>44NQc~On07*qoM6N<$f=&^KJpcdz delta 282 zcmV+#0p7i)&_E3X6aJ%u_dqN_Emu;zv zKw{s=r;mw%x$$WH2T)o8Xm9{Iu2et^OHc~fkHlY3j-mZ%UKfB`gdDa4lq4e%C_uC5 zKS@CV$~pfr!Fw!X^GS&)Y%aj&a8(CV47DfHQ=l+bAl6U^9O4InI1q>niBL;0JV77< zN9yP&H?KQjQ6~URA^V9jv;oaP0|E|sPi$dKbUGwd4!{)c#}EmgjK`^F9A{sZE_KrG6|#r5yh z@#6<3ba#G0*TaI%pud0rPG@9fbO$mSVPgOP|7T)mVL8mk#D#AIAAcW6%gC_v^9!&&dhp;4K^FmI${ZL*LNG%>;K%pxVp=-78BwtbQ;bZ_ zl8EveHxJJ*K7Rf;EG#Sxuvh~c%JlQc4~ZW?zRLi)FNpFQJ3IT^M-Lu8=Hljl0}LBk zU_kRg#Tgzwe6aE0-aQRpK7VGhcXn0~5ET0T?CFzVSbtr#dHuS#3uez;`SAYzQlRD= zurwqfAo$_j=~J5yAK3p0FzW#xf+jg^g!;m)mFYk&OsvD47R zL`Pai*68Wu$A-Uu|N5k>Z*b+$pFdZxU%m2$1&5bGq0IGo~$g`}WO;S&NqD zK7aDm3xCMw7nhJwZ||FM_v5Dzb9i4#5yA<(6&iTOiU=n1~ANCet7?W+4t|?J}EE|0zeljZ$EH&lC8aiD+7@LAiw}J W78=2>SA>}W0000Tr&Y^JBW6Ky7mCFYj7na&qCB(X@kjOB^YY-?LHc-Q$Mg|f9K!5=NztlowxQ{wA00000NkvXX Hu0mjf-$7uk diff --git a/pandora_console/images/gm_resources.menu_gray.png b/pandora_console/images/gm_resources.menu_gray.png index 7733a069d1db39115aed0623b66d53b48773ed39..7915645c477723303738428641e31622480742f9 100644 GIT binary patch delta 218 zcmV<0044vo0-FMmNq@abL_t(|+G1d!5@5t7F=xp#2SS=tVxkVo0uB7Yh-QcakXjGK22e#C@fhNdq|T8AP0|4>xd4a@K{ny>`UD`gAF6&oHm?}~ z4Y)u|07HWTY#1X{paDqP6QTD3(2_(n!$5lLVP3O`dW#s4h*M3FiCXDs7#jo&?1eNVN7UFZG_sefl!zL)g%I` z1yGmGX9Sw8Kty=JG#|j?vj3o9V1Wj#12F~xH92B43t5c1`!6JSeppM2Z>aF zf#|$O3IHaD1ZeUBrz2#E_0Tj0N-r0PGz83LL6d&~&5-+n3Mb+*haZRwplooyWWan{Yl!?wl<9? zr5&*?s~0|!bMHCd{qA>ef@3v?bLa}*-P1FWPN(gqDHVWgPk*D)_}Rbo>G`;8q@b_C zD@iU54$<}l-BbB|{-mm^MCCe;<5?V`slf6V=S|nh<~*rSx;%Up+t<~3TTv7Tkkk^3 z!8}8eq=RL-c?h4@B(gL%T1k>RmCI(|K==-T^s0eGF&GR2$Mb!#*`S^X>4{*GhvXo< zP6JYaHb8S341dE|mlhX%x5iwAaGF>(}CsXF_QeZ zw2G)uD9|8%m7=H(Ed*rBKC>)Kn9b%CtTAeZiB&{`ATW~;CKke>&t%}gVqz@0$)Xw$<$kysN_j2 z;24-5_s-3EUcZ`+=@V=n9aT3T)wsD?%3!d;H+2S%betCiYmLsTbrnHtP2YpTc}Wy! zS&j`w)_>MQ*nf;FBDg1n$9?bD>dMM{mg8DL+3wc%b}T7Lu|zx`Ep@iOB9KkwGTHR` z3m1FOo^v>pNvYXv-iDq%c|7^hecz+q=%%La2=cZh%7aHcIF8>1i9R@`i=2DZ@u2!Rz&ecB9Xr~Iy$ZG2rwkYNl=9y>_3F{A3mZr1KU_%*Zxah dec@jL1^{g}3MQ)HP5A%-002ovPDHLkV1l$kSj+$b delta 272 zcmV+r0q_3v1!4km~!1Gfng zjF4dB4aI;O0Rs{u8ax@)10H}V2E)O`_>V-vgm6*9MPtwdibfKU8-JCt31i*bZvE$L z!T{z<&FDHi)SihEXS~NeH58niNG5VQ5-sGG`u^Vv$G$kz#o^TS5Ev&PE8a z3RJP1rm3F6{(pWU20ByUaMWl_Ddq*9%CTDQurs1iC=ixq<#p+v<2b~al42`%IBr9T zM^O|DkO2+sg`)bh_oKPamJn&&_?$wtrd=!T{ab9M1zKxD+!QjiY0)M>;3Q-+lx1WO+rU6+lO})sSAV_wl2L12Zx> z3VJg(HskSldLbe9jsOsYonx zAUeHX)M~XG;c%D;k|YR3C4WRPc@?f}fxy;gb3=V)%xo$Ynol+)&uTDCns+MCab`&| zc%p!F*S5hjBoqwJ&n_(70oXf=3K4NrTUlCqNq>hZAIJ0W1)g`Orls{749N!sftQOx zB@4c2)M_=q?pd3B(AP5r6P8MU%I{giFIlNXny$1BIo)No3_~-}(lkJpj0E8TrTdfg z`l(+ltM-o8%VM+!O$2IbzlxMPT>{9apw-b=FP_&7-0Q1_Z>+wyO0Onbc^d`JJ6 zOD`?0Y2zOz+fGzfmqlYv_c5ZY`)+Qc{67K=0Q5j#Pwr+LSO5S307*qoM6N<$f(`zD A{Qv*} delta 363 zcmV-x0hIpn2C4&)NPhuLNkl)Q}47 z$tTa)6@(5Xg@5ED^V;l5sLsYw+tr9j z)OlY?+;qsk5@hWk5f66n?hher+3qgp1P&7gE#XIE2J(2B8pzhtcVP1xzdZ;fpOP1Q zU-+lQ`h|Jp?df?|)q?)mn$g}9JxCf=bOv4nigFG@-M$LgAf=GY)IRZCO?*|`DXysk zDly~<_~v3wKV;b`X4;eeMdV#pIj6514C!bY9e)-DZvJ`Z;KhiQ90@?kr0^{ZcjwOT?>~P0#3Iee z!pi#p*^|dlaT)|HM!+suJb&&UV)GhI58NPN7WmK2&BF`Aq-0tyZf-slgMhK|sk*6o o8Zb0JkRMncvHtz@hXEkK0D$s)^#_s+0)l=dLqMPah(U%Y zVpELIYY9Y(Q8$e68FYY1G28}019~D5KR^-&u_prM6o@hiYH0{4ear{qKp=L6;y|d_ zeyAFPu~vYT%FlxmDpD$DfW}-udhB5{C>~2TKnD)QgpmRfk)%M-YrvGtNbTq+JFgia q=VlU$kqgKMEhN(+7hrk;0t^7*&@U{&+@37}0000coNq-MXL_t(|+N@T+P69y?UM>_^pcg9wg(MaCo~1UxFYvUZFjA3dg`tqd#u+k;>$-a!#z`g@_IBUAc{?+Q10i;L zx0u354t)*X)n3=p1N7?A##3O!a4f)Sd|WW7kKSM~2}JKHcz+gsi-Q$SfgA&Pfx$iW z5*}(r$nuyorTr(?0JyorjPkhAH%O(LuQJ9xbgshd`CkE;IWfs-2PvC^B>_(bV`*#X zWtoYiFnmGZ)|ls*RhW_Xms%z_=*vV@@cJ>Q=4*#{V7O(~AB^GgJwi;;cLx5?N~8!$ zCiqhQVbwB!%}h+=6|L#gLMQ-SkBPssjIVyCgK(k zH_3tkDr>X*H;3zwFdd(R&4n`z@ToDme8u^gykC8bx;@tlI+Q)jbjk4C-PA~`jU}LEM*qc@%g?a6o{lF_K)pb p3K;#PAM&>)t#y2)zb#(^3;>~b@X0>k`mF!}002ovPDHLkV1nXxB+>u? diff --git a/pandora_console/images/links.menu_gray.png b/pandora_console/images/links.menu_gray.png index c390e9a268e0e03d8968a3bc1040eb9b735aa10e..7520e0f0562c4e3a260378637c72f5497a6744bc 100644 GIT binary patch delta 812 zcmV+{1JnG21Lp>iNPhzfNklz6No0adiEUa@@1zMVV&<1>gE#_$UYj+Bs)ER~Xx zZJW~H+r4<++!fL?GM^2NO>-3#l$ifB{6Bf?#&!J8Dkv*wn18Wg(W4y)kCeK3`EanY zvw_8d-s6c&PMNyr*on0fv2jxP%wPf$8d_TFK<|9)X>ZxGch`;|zkdD#OPZQne9<>F zI{os+3sq}dJ7-T{Kl}y(Z5CtW;P?a#hmU{%{DDiVs;fIFsiOuq5r`F}IDqRMJR4o*(EFXm;{)$b#xi{`1vmU{rmR-1H=D4OiavIB_t#`1%-tEKYH-sH`eI) z^z-8j3X5o!m6MlaWMudN6#DZ0+qW-2e*E|i1Pnm$F@N##@v}=vNpb)UVO_p>(OaNP z_x$?xYwzBjJ5Up(m!Cg_xP*i)&>L1jE*B90|Mm0dcNsZ3Ml%abuDf^c{JwVOGK-j) zxR_sXu+Gn)KYu-Y`eaICMEH6ZWP`SC+6bZ!Lopbzv9SrpBqs6m^7DVbcJ<1iCG+Qf zr0LgQ4ak2mV z_wV5Qckkqx@EHUQXriLP~AVt{wX~u3gO{EF!`!DJ9L@*4yU|O!ZoC-@e(%NK6r7@8ry! zo|D@GjOs{WsW2ZX^bY6}`=394n7?}UGO?gb;Aiw~LVLeG_?Rpge00002rvNm Wqioz2lBQz-0000 diff --git a/pandora_console/images/op_events.menu_gray.png b/pandora_console/images/op_events.menu_gray.png index 4073f154b0b78084485f0546ac3ce105fdebde73..84ab4bebf2e329f7241585c66dacf04ef53bd865 100644 GIT binary patch delta 569 zcmV-90>=H40`>%uNPhwtNklpy z-(hN4@EH&k9+BWe^{~fH)Tym-wGQe}CYHfM_;0wkJS5?c;|J zKakbqbkVvUaaQVW8%k$^V+KH~72~QBI0%_5RYv#?IaR{4wW^97aZtmRHcJ`UTfK>sy0OE8e z#t&b=emy22D1Y!&Ttec09=1Dg@%8g6dx>-X;5S-5fS8U|9*5d$=D0Wl~=vw!>e z@#D7VPoG}KrjUi0+|R_s!T=2DLz_3OpS}r;Ylv|XxYXd|uLh#u=5G!n3FI?Ya00000NkvXX Hu0mjf>I@|L delta 210 zcmV;@04@La1d;-fNPhsdNkl0u(#HI2BOkINtf9IiP)szLUoxCUPs{l^wt zK>Pt3YZw8}g2fO661OV M07*qoM6N<$f;1;n3;+NC diff --git a/pandora_console/images/op_monitoring.menu_gray.png b/pandora_console/images/op_monitoring.menu_gray.png index 3d1bc0e007ff5c9ea0c991c89a200719b517ec64..5456d64b1d9a9a7c923bbb92726da77547ff59d2 100644 GIT binary patch delta 679 zcmV;Y0$BZn1LFmdNPhx_Nkl*uH^iTy4ejO@^T8WWVsKvBROMBATU{n+n*RaVZ z{%4ugbdAA-13z}>&71$cee>Qj%zqkeHKWhp%edTbxBOE+f`92w&;-7NHzvUpnVpW0 z4u`L%Y6_hQ1h%?&crTSoB`;V7lc~Zl&$4VzQIu3Rlev*je+&@gVt0hr9 zl+Wimoo@l$0aZ$S>E-EU3ET(o=x20*FMs4funkNB2_(QMy>0T|2uMj@DVe-gC=?!JLHVa{hX|OOOU(3M4qo`(Yp)^^rfEyd!wpue z17Z!dS*r@5*GQR6&(9@%gP~CTkEV@9U#gp%oA06-Q);nj#|D8WQ>C4+AnG)_|K{St zLf_CpaK7gMNc$(9>}9%p_O~N?QRUgZ)X4i N002ovPDHLkV1je`Muz|Z delta 324 zcmV-K0lWU=1%m^SNPht(Nkl+s2S_l<5 z@Zkwm5K{qA0i**;V8yK9P$c08H?t#+tlL|!PD&F`%$KVY!w|>;&E*Tw0Ncsu_{Ysj z9RibB1KlJZXP^M#!7eCA#jl6t+e2jb?3wc*5=z|Ipz1WDtbaysCKc6zjXP}A^d=PR zn@5xvA{qcQ;K(r)mE!4y4Anfj=7sq~Lo^C}Y*<9|=wp$q$j2SkBrQ~FC8}>ciZago zB({xN00+6b15BCJr7s!BTuL{F((sDET*=N?tgyGo$jX1f#A(2@ASsz+<{ws(jIWrX z981sIB4uZvT0Pvai@3l~ZG!IaS+lF;b?Cr)alay9Y+922>uCD|yzLoD-}SIv1sDJ< W+FEZy@rl_00000-NqmgBajWU0nG$7zle`iVgR}UouC;2 z>GFa2ZJ2;E0o|b8fQ-O<(L2e6D-?<)%NN_RU+i~Dk~8Gt@hOLvJg4Urf!RZ8yG+g* z%nNjY7PmLo!wI!Y6`?fFI1>eCC!o25*{CsPl^U1~UO_LQm4A{NB_4pXLmp#Z%~}=+ z=+j6yCe97)AP4zq7bvi^!7PG&X^>bUnk@=cvCnl!hWKl7$v?@LLV&*gCjZ&YvV`6T zLS~U+&vhIo1Lu5N^SsgAF1ckFVXN0_3k`k+<%V*_gY2xGBJzP?;zz3ny_mn|>P>!+ zyyd4EA-NHM7HQKfBF@yL1@hK%la#L^Coua>YbS#X`2vdv_-fP4oB7p<^WDZ z6}PDwy-yY}64c>9%J&Mix@VO>h5pV^B0ttC{lkCA>k18;=Lq6MfB^s~aevis`CthE O0000|=I!Zr91xKhNvO=NeZB$sqMgiZ3a)<&z)R)4@?h+`bPNG6$fxGG2k z*%{MFGo;l20>O=qO#)?C${0G0K*p&djgS~S=MYE?D4PLV#|$B$eg|1#4G!(r>4fN9uk{wlJ|)?6c^_(xL)IdILDvwz>PFQZHAnvVWbO|ToDL$ou*j;S zkgb|L$_t10cWRE5#SbD4hncnDPS%ij{l0HdwmUO652xVlyGl&8hmSZ z06RE;h2!XMfGi%={185-i~VzkmOjzJL2B2vo%eZ@Av7`#}*Ku1=$v67M5o(o_{~T`Si(?e}oMB{rfiq z6BCm$$PMTQG5r7kpXJB*Z!BK^{{MCL^aWX2*_d{0+5F+msgpm@4Ps?wWk=S}g0A4# zuV24a)YQ!_ZEQ<8I5_w(oj(V1`az6QadCm9KBB9|YY@_zeOoVtMuQ z<*9pj?j(Ny@dKus6No{v_lupKZ7DGIe*h|D!e`JwUOs+?RZExr0OE%@y!{$PNJ~qz zz_JIrK}Y|9&gB6{wFoft63n!mT-0`LToNPhwnNkl z{=661)H35TBs418$1gB=3ec)hHa0dpW@cs&Wff&TVPVk&=g*$`g07wkn<24@$($bE zK8gST|1-I-SPc@Fkl^L!=6@CgYDV$;|9}73{{H=I zNVGv5oSbZ|tgP(+|NkdCT(KH7Z|00ACypIE$;HKuY62tUw_m@0Z6rFdHMF!8jm^xz z@$m4x1$u=CCDxQEZn*-}%YtlBa6}{@FTa4@w=Z8n;QElPqKfizfgBn68N66ufH8ytke@skFjDJLCufI4Ax_j%^x36Em{016E z$dG?P{065%bEZ#y`rzK(vm6{8fARW@k?{>M@6ExRAc29{0gT$CKv!Wk3@HBN&!6A> z-@Sdi5N|p#6Gib_hlz|1NN4U0b@40Op478aHj=g*u;o6yzyhp6%>H9LpH z+11_U%Pg1AhR|g4m5Yn(#K~jF4o&Ro!cY$oU;u8U$Ia$JHD>?-002ovPDHLkV1n_a BA4vcJ delta 276 zcmV+v0qg$o1k(bLNPhtJNklebK$(E%$p_I1XeTHe028$E z;Yl}W*q}^6MqmWal94J%BFBxA4n;yE(Y_rU8%|;pkX8 z0j&8=E&_yFPrgPGB?7|60wD_&QBp=z5@}8#%;1e+JZCJ{O@GXcDpqQ4R6vVV!+dBq zBY)DNVkZ9p?>M&tvnj-gB+uEufQH%J;Ux>vc^R>+uZS6Iuo_&9%1E)6zSgoxpj@Jw z#H{( zJaZG%Q-e|yQz{EjrrH1%E%9`545_%4l)}*T|Nnn&hLsEoVhIambP`&mD&~2yH637A zQ<&)B%IxUS(AmhAAR+bZ(`R3UWwREF&(BSoQEJ1}r&?>=f9=kI2!{to2&yG0) z7p8wwJ|B?6Jdsy1!@%I9`JdxVdNy}|?9W^-H$%;pk7a|Dmxr*TsYIJlvV!7Pof)3b z+1w-^F&UUD*z)kywH%%zWH9S{`-Fw;D{?g)8W2CH7g62Dtz})w`Me9DGWj(JCNex>J&XAP2tGH#Yi~tMM(Eh$or_B&@wv7B!Fw z6~5hJ&*AySoSFO5zD+q(k>nzYO>d*#?e)G*1BZo3c(^(sfu$Y&uc^_@=31rnS*Bo} z4NYHiO^^Cm9&*u;Q?PErp6HcC(ov&qoJyMqB=_>Ktk#BRb0xHXtVWD}5Q(%@+w9Pi zW?+=fgS!(iJ%dg-pwu+lDYN9nyVl00Mtv+y8HaBFr1$m*e**tMvNCw5qC*YQegqf* Xifn`UI9YYV00000NkvXXu0mjf*=ewo delta 364 zcmV-y0h9i@1FQp(Nq=4QMuC1C9yWeDXtk6Tk+v6I7WX zz)wF*CTK>;2E7q(gVsjxkmWi-6_%`v?D(DiY+vCFX}re2{AZ0000< KMNUMnLSTX}oTH@x diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index efb08fc02d..6c54271b70 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1032,9 +1032,10 @@ function config_update_config() $error_update[] = __('Fixed header'); } - if (!config_update_value('fixed_menu', get_parameter('fixed_menu'))) { + /* + if (!config_update_value('fixed_menu', get_parameter('fixed_menu'))) { $error_update[] = __('Fixed menu'); - } + }*/ if (!config_update_value('paginate_module', get_parameter('paginate_module'))) { $error_update[] = __('Paginate module'); @@ -1116,9 +1117,10 @@ function config_update_config() $error_update[] = __('Default height of the chart image'); } - if (!config_update_value('classic_menu', (bool) get_parameter('classic_menu', false))) { + /* + if (!config_update_value('classic_menu', (bool) get_parameter('classic_menu', false))) { $error_update[] = __('Classic menu mode'); - } + }*/ // -------------------------------------------------- // CUSTOM VALUES POST PROCESS @@ -1791,9 +1793,10 @@ function config_process_config() config_update_value('fixed_graph', false); } - if (!isset($config['fixed_menu'])) { + /* + if (!isset($config['fixed_menu'])) { config_update_value('fixed_menu', false); - } + }*/ if (!isset($config['custom_favicon'])) { config_update_value('custom_favicon', ''); @@ -2515,9 +2518,10 @@ function config_process_config() } } - if (!isset($config['classic_menu'])) { + /* + if (!isset($config['classic_menu'])) { config_update_value('classic_menu', 0); - } + }*/ if (!isset($config['csv_divider'])) { config_update_value('csv_divider', ';'); diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index d6384595a8..c0ae82b4ec 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -723,6 +723,28 @@ function menu_sec3_in_sec2($sec, $sec2, $sec3) // 35px is the height of a menu item function menu_calculate_top($level1, $level2, $level3=false) { + /* + if(menu verde ){ + $item_height = 28; + } + else{ + $item_height = 35; + } + */ + + // $(".menu li").css("min-height"); + // console.log( parseInt($("#icon_oper-agents").css("min-height"))); + /* + $item_height= ''; + */ + $item_height = 35; + + // echo ' '.$level1.' '.$level2.' '.$level3.' '; $level2--; if ($level3 !== false) { // If level3 is set, the position is calculated like box is in the center. @@ -737,12 +759,12 @@ function menu_calculate_top($level1, $level2, $level3=false) // Positionate in the middle if ($total > 12 && (($total < 18) || (($level1 - $comp) <= 4))) { - return - ( floor($comp / 2) * 39); + return - ( floor($comp / 2) * $item_height); } // Positionate in the bottom if ($total >= 18) { - return (- $comp * 39); + return (- $comp * $item_height); } // return 0 by default diff --git a/pandora_console/include/styles/menu.css b/pandora_console/include/styles/menu.css index 63b9c3a0db..faa72fb288 100644 --- a/pandora_console/include/styles/menu.css +++ b/pandora_console/include/styles/menu.css @@ -16,16 +16,25 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +.operation li, +.godmode li { + display: flex !important; + justify-content: flex-start; + align-items: center; +} + +.operation > li.menu_icon.no_hidden_menu, +.godmode > li.menu_icon.no_hidden_menu { + justify-content: flex-end; +} + .operation .menu_icon ul.submenu > li, .godmode .menu_icon ul.submenu > li { background-color: #282828; + padding-left: 10px; + padding-right: 10px; } -.menu { - border-width: 0px 0px 0px 0px; - border-style: none; - border-color: #777; -} .menu ul { list-style-type: none; padding: 0; @@ -33,14 +42,15 @@ } .menu li.selected, .menu li.not_selected { - border: 0px none black; - border-bottom: 0px none #d4d4d4; + border: 0px none black; /* borrar?? */ + border-bottom: 0px none #d4d4d4; /* borrar?? */ margin: 0; } .menu li a { color: #ffffff; text-decoration: none; + width: 100%; } li:hover ul { @@ -48,16 +58,16 @@ li:hover ul { } .submenu_text { - padding: 10.5px; + /* padding: 10.5px; eee */ margin-left: 0px; width: 100%; - color: #91a2a7; + color: #9ca4a6; font-family: "Open Sans", sans-serif; - font-size: 10pt; + font-size: 9.4pt; } .menu li.subselected a { - background-color: grey !important; + background-color: grey !important; /* borrar?? */ } .menu a:hover { @@ -68,25 +78,23 @@ li:hover ul { margin: 0px 0px 0px 0px; position: absolute; z-index: 999; - /*left: 44px;*/ - min-height: 35px; - /*height: 35px;*/ - width: 180px; + width: 214px; } .submenu2 { position: absolute; z-index: 999; - left: 180px; + left: 214px; + width: 214px; } .sub_subMenu { - min-height: 35px !important; - /*height: 35px;*/ - width: 180px; font-weight: normal !important; background-color: #202020; + padding-left: 10px; + padding-right: 10px; } + .sub_subMenu.selected { font-weight: 600 !important; } @@ -103,17 +111,14 @@ li:hover ul { border-left: 1px; } -.menu li.has_submenu > a > div { - background: url(../../images/arrow.png) no-repeat 80% 50%; - z-index: 1; /* Positions it on top of the rest */ -} -.menu li.has_submenu > .SubNoLink { - background: url(../../images/arrow.png) no-repeat 80% 50%; +/*.menu li.has_submenu > a > div,*/ +.menu li.has_submenu /*> .SubNoLink*/ { + background: url(../../images/arrow.png) no-repeat 95% 50%; z-index: 1; /* Positions it on top of the rest */ } .is_submenu2 { - background-color: #e4e4e4 !important; + background-color: #e4e4e4 !important; /* borrar?? */ } .menu li.submenu_not_selected a, @@ -155,9 +160,9 @@ li.sub_subMenu.selected { background: url(../../images/op_network.menu_gray.png) no-repeat; } #icon_oper-agents { - border-top-right-radius: 5px; - border-right-style: solid; - border-right-width: 0px; + border-top-right-radius: 5px; /* borrar?? */ + border-right-style: solid; /* borrar?? */ + border-right-width: 0px; /* borrar?? */ background: url(../../images/op_monitoring.menu_gray.png) no-repeat; } #icon_oper-events { @@ -188,7 +193,7 @@ li.sub_subMenu.selected { /* Godmode images */ #icon_god-discovery { - background: url(../../images/gm_discovery.menu.png) no-repeat 50% 50%; + background: url(../../images/gm_discovery.menu.png) no-repeat; } #icon_god-resources { background: url(../../images/gm_resources.menu_gray.png) no-repeat; @@ -221,7 +226,7 @@ li.sub_subMenu.selected { background: url(../../images/links.menu_gray.png) no-repeat; } #icon_god-um_messages { - border-color: #777; + border-color: #777; /* borrar?? */ background: url(../../images/um_messages.menu_gray.png) no-repeat; } @@ -229,7 +234,7 @@ li.sub_subMenu.selected { z-index: 3; position: absolute; left: -80px; - background-color: #aaa; + background-color: #aaa; /* borrar?? */ } .notification_ball { @@ -286,7 +291,7 @@ ul li a:hover { */ .menu_icon { - transition-property: background-color; + /*transition-property: background-color; transition-duration: 0.5s; transition-timing-function: ease-out; -webkit-transition-property: background-color; @@ -297,11 +302,11 @@ ul li a:hover { -moz-transition-timing-function: ease-out; -o-transition-property: background-color; -o-transition-duration: 0.5s; - -o-transition-timing-function: ease-out; + -o-transition-timing-function: ease-out;*/ } .menu_icon:hover { - transition-property: background-color; + /*transition-property: background-color; transition-duration: 0.5s; transition-timing-function: ease-out; -webkit-transition-property: background-color; @@ -312,11 +317,11 @@ ul li a:hover { -moz-transition-timing-function: ease-out; -o-transition-property: background-color; -o-transition-duration: 0.5s; - -o-transition-timing-function: ease-out; + -o-transition-timing-function: ease-out;*/ background-color: #282828 !important; } .submenu_not_selected:hover { - transition-property: background-color; + /* transition-property: background-color; transition-duration: 0.5s; transition-timing-function: ease-out; -webkit-transition-property: background-color; @@ -327,14 +332,14 @@ ul li a:hover { -moz-transition-timing-function: ease-out; -o-transition-property: background-color; -o-transition-duration: 0.5s; - -o-transition-timing-function: ease-out; + -o-transition-timing-function: ease-out;*/ background-color: #202020 !important; } .submenu_selected:hover { background-color: #202020 !important; } .sub_subMenu { - transition-property: background-color; + /*transition-property: background-color; transition-duration: 0.5s; transition-timing-function: ease-out; -webkit-transition-property: background-color; @@ -344,10 +349,10 @@ ul li a:hover { -moz-transition-duration: 0.5s; -moz-transition-timing-function: ease-out; -o-transition-property: background-color; - -o-transition-duration: 0.5s; + -o-transition-duration: 0.5s;*/ } .sub_subMenu:hover { - transition-property: background-color; + /* transition-property: background-color; transition-duration: 0.5s; transition-timing-function: ease-out; -webkit-transition-property: background-color; @@ -357,7 +362,7 @@ ul li a:hover { -moz-transition-duration: 0.5s; -moz-transition-timing-function: ease-out; -o-transition-property: background-color; - -o-transition-duration: 0.5s; + -o-transition-duration: 0.5s;*/ background-color: #161616 !important; } @@ -375,9 +380,9 @@ ul li a:hover { */ .operation { background-color: #343434 !important; - border-top-right-radius: 5px; - border-right-style: solid; - border-right-width: 0px; + border-top-right-radius: 5px; /* borrar?? */ + border-right-style: solid; /* borrar?? */ + border-right-width: 0px; /* borrar?? */ padding-top: 20px !important; } @@ -393,12 +398,15 @@ ul li a:hover { } .menu li, -.menu .li.not_selected { - border-radius: 0px 0px 0px 0px; - display: block; +.menu li a, +.menu li div { min-height: 35px; - border-bottom: 0px none #424242; - vertical-align: middle; + display: flex; + align-items: center; +} + +.menu li div { + background-clip: text; /* Very important to fix a bug in Firefox */ } .godmode { @@ -465,14 +473,14 @@ ul li a:hover { left: 0; background-color: #343434; border-bottom: solid 3px #343434; - /*min-height: 943px;*/ - padding-bottom: 40px; /*Lo he quitado para que no ocupe todo el alto y fixed */ + min-height: 943px; + /*padding-bottom: 40px;*/ /*Lo he quitado para que no ocupe todo el alto y fixed */ /*overflow-x: hidden;*/ } .button_collapse { - height: 55px; - background-color: #4d4d4d; + height: 38px; + background-color: #6c6c6d; /*bottom: 0; /* Lo he quitado para que no ocupe todo el alto y fixed*/ /*position: fixed; /*coemntar tb*/ width: 60px; /* It is changed for classic menu (215px)*/ @@ -491,19 +499,6 @@ ul li a:hover { align-items: center; } -.operation > li.menu_icon.no_hidden_menu, -.godmode > li.menu_icon.no_hidden_menu { - display: flex; - justify-content: flex-end; - align-items: center; -} - -.operation > li.menu_icon, -.godmode > li.menu_icon { - padding-top: 2px; /* 3px */ - padding-bottom: 2px; -} - .operation div, .operation a, .godmode div, @@ -534,95 +529,57 @@ ul li a:hover { background-position: center; } -#top_btn { - display: none; - position: fixed; - bottom: 100px; - left: 0px; - border: none; - outline: none; - background: url("../../images/to_top_menu.png") no-repeat center; - background-color: #82b92e; - width: 60px; - height: 60px; - /* Estos borrarles despues xk sera img */ - color: white; - cursor: pointer; - font-size: 17px; - border-radius: 5px; -} - -#top_btn:hover { - background-color: #4d4d4d; - /* border: 2px solid #fff;*/ -} - -@media screen and (max-height: 600px) { - .operation > li.menu_icon, - .godmode > li.menu_icon { - padding-top: 1px; - padding-bottom: 1px; - } - .operation { - padding-top: 10px !important; - } - .button_collapse { - margin-top: 10px; - background-color: green; - } +@media screen and (max-height: 720px) { .menu li, - .menu .li.not_selected { - min-height: 25px !important; - } - .button_collapse { - height: 45px; - } - .submenu_text { - /* padding: 7.5px;*/ - } -} - -@media screen and (min-height: 601px) and (max-height: 700px) { - .operation > li.menu_icon, - .godmode > li.menu_icon { - padding-top: 1px; - padding-bottom: 2px; - } - .operation { - padding-top: 10px !important; - } - .button_collapse { - margin-top: 10px; - background-color: red; - } - .menu li, - .menu .li.not_selected { - min-height: 25px !important; - } - .button_collapse { - height: 48px; - } - .submenu_text { - /*padding: 7.5px;*/ - } -} - -@media screen and (min-height: 701px) and (max-height: 845px) { - .operation { - padding-top: 10px !important; - } - .button_collapse { - margin-top: 10px; - background-color: blue; - } - .menu li, - .menu .li.not_selected { + .menu li a, + .menu li div { min-height: 28px !important; } - .button_collapse { - height: 50px; +} +/* +Medidas menu: +601 verde y rojo +720 azul +735 normal +*/ +@media screen and (max-height: 735px) { + .operation { + padding-top: 10px !important; } - .submenu_text { - /*padding: 7.5px;*/ + .button_collapse { + margin-top: 10px; } } + +/* + * --------------------------------------------------------------------- + * - STYLES TO CHANGE CLASSIC MENU AND COLLAPSED MENU - + * --------------------------------------------------------------------- + */ +.page_classic { + padding-left: 215px !important; +} + +.page_collapsed { + padding-left: 60px !important; +} + +.header_table_classic { + padding-left: 250px !important; /* 215 + 35 */ +} + +.header_table_collapsed { + padding-left: 95px !important; /* 60 + 35 */ +} + +.title_menu_classic { + display: flex !important; +} + +.title_menu_collapsed { + display: none !important; +} + +.menu_icon_collapsed { + background-position: 50% 50% !important; +} diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 779deb39c7..70fb57a231 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -197,6 +197,9 @@ a:hover { color: #373737; text-decoration: underline; } +:focus { + outline-color: #82b92e; +} a:focus, input:focus, button:focus { @@ -403,8 +406,8 @@ div#page { width: auto; margin-top: 20px !important; padding-left: 60px; /* It is changed for classic menu (215px)*/ - margin-right: 30px; - margin-left: 30px; + margin-right: 35px; + margin-left: 35px; } body.pure { @@ -657,7 +660,7 @@ div#foot a, div#foot span { font-family: "Open Sans", sans-serif; font-size: 8.5pt; - color: #91a2a7; + color: #9ca4a6; } /* @@ -687,7 +690,7 @@ div#head { height: 60px; padding-top: 0px; margin: 0 auto; - border-bottom: 1px solid #91a2a7; + border-bottom: 1px solid #9ca4a6; min-width: 882px; background-color: #fff; color: #000; @@ -1317,7 +1320,7 @@ div.title_line { margin-top: 0; } -/* --- Submenu --- */ +/* --- Tabs Submenu --- */ ul.subsubmenu { border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; @@ -1325,12 +1328,10 @@ ul.subsubmenu { -moz-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px; - - background: #ececec !important; } ul.subsubmenu li { - background-color: #ececec; + background-color: #fff; font-weight: bold; text-decoration: none; font-size: 14px; @@ -2038,8 +2039,8 @@ div#pandora_logo_header { margin: 0px; padding: 0px; margin-top: 0px; - padding-left: 90px; /* It is changed for classic menu */ - padding-right: 30px; + padding-left: 95px; /* It is changed for classic menu */ + padding-right: 35px; } #header_table_inner { @@ -2143,13 +2144,6 @@ div#pandora_logo_header { font-family: "Open Sans", sans-serif; } -@media screen and (max-width: 1024px) { - #header_user span, - #header_searchbar a.tip img { - display: none; - } -} - .autorefresh_disabled { cursor: not-allowed !important; } @@ -2174,7 +2168,7 @@ div.warn { } .submenu_not_selected { - transition-property: background-color; + /*transition-property: background-color; transition-duration: 0.5s; transition-timing-function: ease-out; -webkit-transition-property: background-color; @@ -2186,7 +2180,7 @@ div.warn { -o-transition-property: background-color; -o-transition-duration: 0.5s; -o-transition-timing-function: ease-out; - font-weight: normal !important; + font-weight: normal !important;*/ } /* Submenus havent borders */ @@ -3303,7 +3297,7 @@ div.div_groups_status { } #title_menu { - color: #91a2a7; + color: #9ca4a6; float: right; width: 65%; letter-spacing: 0pt; @@ -3319,7 +3313,7 @@ div.div_groups_status { #menu_tab li.nomn, #menu_tab li.nomn_high { - /*background-color: #ececec;*/ + background-color: #fff; padding-right: 3px; padding-left: 3px; font-weight: bold; @@ -3331,6 +3325,10 @@ div.div_groups_status { height: 28px; } +#menu_tab li:hover { + background-color: #ececec; +} + #menu_tab li.nomn_high, #menu_tab li.nomn_high span { color: #fff; @@ -4445,10 +4443,10 @@ div#dialog_messages table th:last-child { */ .notification-ball { - border: white solid 2px; - border-radius: 50px; - width: 18px; - height: 18px; + border: #343434 solid 2px; + border-radius: 50%; + width: 20px; + height: 20px; display: flex; justify-content: center; align-items: center; @@ -4804,43 +4802,25 @@ input:checked + .p-slider:before { /* --- END TOAST --- */ -/* - * --------------------------------------------------------------------- - * - STYLES TO CHANGE CLASSIC MENU AND COLLAPSED MENU - - * --------------------------------------------------------------------- - */ -.page_classic { - padding-left: 215px !important; +/* Button for Go to top */ +#top_btn { + display: none; + position: fixed; + bottom: 100px; + right: 4px; + border: none; + outline: none; + background: url("../../images/to_top_menu.png") no-repeat center; + background-color: #82b92e; + width: 27px; + height: 27px; + background-size: 21px; + cursor: pointer; + border-radius: 5px; } -.page_collapsed { - padding-left: 60px !important; -} - -.header_table_classic { - padding-left: 245px !important; -} - -.header_table_collapsed { - padding-left: 90px !important; -} - -.title_menu_classic { - display: block !important; -} - -.title_menu_collapsed { - display: none !important; -} - -.logo_show { - display: block !important; -} - -.logo_hide { - display: none !important; -} - -.menu_icon_collapsed { - background-position: 50% 50% !important; +#top_btn:hover { + background: url("../../images/to_top_menu_hover.png") no-repeat center; + background-color: #fff; + border: 2px solid #82b92e; } diff --git a/pandora_console/index.php b/pandora_console/index.php index b68424d805..38e12621cb 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1024,11 +1024,13 @@ if (get_parameter('login', 0) !== 0) { // Header if ($config['pure'] == 0) { if ($config['classic_menu']) { + // ya no existe BORRAR!!! echo '
          '; + echo ''; echo '
          '; } else { echo '
          '; + echo ''; } } else { echo '
          '; @@ -1248,6 +1251,27 @@ require 'include/php_to_js_values.php'; ?> \ No newline at end of file + diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index adda158e9b..cb5126b621 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -21,22 +21,7 @@ if (! isset($config['id_user'])) { $(document).ready(function(){ var menuType_value = localStorage.getItem("menuType"); - if (menuType_value == 'collapsed' || menuType_value == '' || menuType_value == null || menuType_value == undefined) { - if(menuType_value == '' || menuType_value == null || menuType_value == undefined){ - localStorage.setItem("menuType", "collapsed"); - } - - $('#menu_full').removeClass('menu_full_classic').addClass('menu_full_collapsed'); - $('.logo_full').css('display','none'); - $('.logo_icon').css('display','block'); - $('div#title_menu').removeClass('title_menu_classic').addClass('title_menu_collapsed'); - $('div#page').removeClass('page_classic').addClass('page_collapsed'); - $('#header_table').removeClass('header_table_classic').addClass('header_table_collapsed'); - $('#button_collapse').removeClass('button_classic').addClass('button_collapsed'); - $('ul.submenu').css('left', '59px'); - $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); - } - else if (menuType_value == 'classic') { + if (menuType_value == 'classic') { $('#menu_full').removeClass('menu_full_collapsed').addClass('menu_full_classic'); $('.logo_icon').css('display','none'); $('.logo_full').css('display','block'); @@ -48,18 +33,26 @@ $(document).ready(function(){ $('li.menu_icon').removeClass('menu_icon_collapsed').addClass("no_hidden_menu"); } else{ - console.log('else no ha elegido aun, default-else'); - localStorage.setItem("menuType", "collapsed"); + if(menuType_value != 'collapsed'){ + localStorage.setItem("menuType", "collapsed"); + } + $('#menu_full').removeClass('menu_full_classic').addClass('menu_full_collapsed'); + $('.logo_full').css('display','none'); + $('.logo_icon').css('display','block'); + $('div#title_menu').removeClass('title_menu_classic').addClass('title_menu_collapsed'); + $('div#page').removeClass('page_classic').addClass('page_collapsed'); + $('#header_table').removeClass('header_table_classic').addClass('header_table_collapsed'); + $('#button_collapse').removeClass('button_classic').addClass('button_collapsed'); + $('ul.submenu').css('left', '59px'); + $('li.menu_icon').removeClass("no_hidden_menu").addClass('menu_icon_collapsed'); } - }); - // Set the height of the menu. - $(window).on('load', function (){ - $("#menu_full").height($("#container").height()); - }); - +// Set the height of the menu. +$(window).on('load', function (){ + $("#menu_full").height($("#container").height()); +}); '; +$custom_logo = 'images/custom_logo/'.$config['custom_logo']; +$custom_logo_collapsed = 'images/custom_logo/'.$config['custom_logo_collapsed']; + +if (!defined('PANDORA_ENTERPRISE')) { + $logo_title = get_product_name().' Opensource'; + $custom_logo = 'images/custom_logo/pandora_logo_head_green.png'; + $custom_logo_collapsed = 'images/custom_logo/pandora_logo_green_collapsed.png'; +} else { + if (file_exists(ENTERPRISE_DIR.'/'.$custom_logo)) { + $custom_logo = ENTERPRISE_DIR.'/'.$custom_logo; + } + + $logo_title = get_product_name().' Enterprise'; +} + echo ''; @@ -108,11 +116,6 @@ echo '
          '; echo '
          '; // menu_container ui_require_jquery_file('cookie'); -/* - $config_fixed_menu = false; - if (isset($config['fixed_menu'])) { - $config_fixed_menu = $config['fixed_menu']; -}*/ $config_fixed_header = false; if (isset($config['fixed_header'])) { @@ -123,10 +126,8 @@ if (isset($config['fixed_header'])) { diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index dbe33feb41..f2042193fb 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -120,17 +120,6 @@ if (enterprise_installed()) { $row++; } -/* - $table_behaviour->data[$row][0] = __('Classic menu mode').ui_print_help_tip(__('Text menu options always visible, don\'t hide'), true); - $table_behaviour->data[$row][1] = html_print_checkbox_switch( - 'classic_menu', - 1, - $config['classic_menu'], - true - ); - $row++; -*/ - echo '
          '; echo ''.__('Behaviour configuration').''; html_print_table($table_behaviour); @@ -278,12 +267,12 @@ function logo_custom_enterprise($name, $logo) } -$table_styles->data[$row][0] = __('Custom logo (header)').ui_print_help_icon('custom_logo', true); +$table_styles->data[$row][0] = __('Custom logo (menu)').ui_print_help_icon('custom_logo', true); $table_styles->data[$row][1] = logo_custom_enterprise('custom_logo', $config['custom_logo']); $table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'custom_logo_preview', $open, '', 'class="sub camera logo_preview"', true, false, $open, 'visualmodal'); $row++; -$table_styles->data[$row][0] = __('Custom logo collapsed (header)').ui_print_help_icon('custom_logo_collapsed', true); +$table_styles->data[$row][0] = __('Custom logo collapsed (menu)').ui_print_help_icon('custom_logo_collapsed', true); $table_styles->data[$row][1] = logo_custom_enterprise('custom_logo_collapsed', $config['custom_logo_collapsed']); $table_styles->data[$row][1] .= ' '.html_print_button(__('View'), 'custom_logo_collapsed_preview', $open, '', 'class="sub camera logo_preview"', true, false, $open, 'visualmodal'); $row++; @@ -545,16 +534,7 @@ $table_styles->data[$row][1] = html_print_checkbox_switch( true ); $row++; -/* - $table_styles->data[$row][0] = __('Fixed menu'); - $table_styles->data[$row][1] = html_print_checkbox_switch( - 'fixed_menu', - 1, - $config['fixed_menu'], - true - ); - $row++; -*/ + // For 5.1 Autohidden menu feature $table_styles->data['autohidden'][0] = __('Autohidden menu'); diff --git a/pandora_console/images/custom_logo/pandora_logo_head_green.png b/pandora_console/images/custom_logo/pandora_logo_head_green.png index f2c8b2ca447ff47d55f00570fc8554b6493d9138..8bf5fbb1d389fcc31398444d8deb8fccc81299ca 100644 GIT binary patch delta 2686 zcmV-^3W4>L7oQc783+OZ004TNxTBFFCw~e-Nkl z7b7&(lxjj~YtThPH@b6C(`-UYTm-Vp&Q0CfO`r=)LN;l#ap!D8varN1#5m9zQkYo? zvEX15@OPm$q4axmoa6D{_jBjXOk2`(knl2d-~BoFJKy=aSC4)7=#zws%D*bdReuF4 zib53?MWKqKP(?*isG=xTQBf4CC<;|n6oo2^LKPK7p^BnVMMY7lq9{~RIU+Tc?XI;x zRrh|q{A6W4qgqy}ItuG*>QgNPsg}WHb1$Cl1}}GVOZl1HtDiS_^Qv(bTaJ};%N3YA zo4j-;IqC~OTbA1iJVYXXQ1D-TrlDlG2}eA61^ zHQ?#%&!&tJ&sh-PR0u!^?SNrv zbp{y{9?o}-A)_}wG=|%IvornM4Lrc=e8XP=3%S4V=;#4vW;A}5PfN`pstyWif_la@ zV8(3?DO2rlc3{uwIYd`-v43ZiqtFk(`#3i#jRf=W=@_<^27%I29}XH5z`HB!i&BTx zMIrVh#Es4^|LBW9>_=OD3bCO5N`Kc_WCf?KzB}2}>-!Zxhe9##ljSL9AozL%0Y;uq z+T=dbcx5BQbFhaaoADdn`wH()|9XQ~jnPLwz2!Sw0I0v~+9&NpKz}y*2OuVBlGL+Y z7fk~O9Hf8nE>IhyE2)7CDU(Xb-bn0GNNIQr+76m6(0_07ioN?4Mxop}o9AYpkF)cY zbsXp&77wU__L5C~hU(D_Q?>G6J}N5-=2=4c-4;*PzWy;WLuB3lZFwX@tNc(6alse z1nEOe5gTSuOTp-!iim)e#0r+pDNaxOFi=>){ir=FOa?m|W`AG>PL0$cTq=_jU;&p( z8-Sg|f3XA}9SfJlfVX(zcm+QaBC=a*@a?&2dTuOqiw8JjS}FPj;@Me`Uswv_1sA)L zKqSIrPi;Fie*WQ?uM7`KO9RWqL!oPq3@!Vb9i~nZiEIfaV%MQHyh3Lx{4E+2KN%{B zF?A@KH-ngl`+vcFY{Q5m)UlFsc7WqiZc;8mE)%FSMxPTn>ue5ln)`m!?mUcQ(-k}v zW#cFCK?6bI$CjW87{9Tn_%Y&#s&Jt%PzZvC#TX?RFVt-xlFWoxuAZBgZJ>g9He^Ki z$>zQT)?CjxLJ;G^k6<$7mt}Yq&CLQ0bu|r!Lk!w)yMHlu^nBvL&(s!`c8+X} zsR%yWWo`&UY~N)^?Qm1X-{gpSXnbz$xEEmL(?!nfz1({jpFjiP0xule$ov!83CK1E z1SJ-cppcWoejtyQE;2Hp4)PKF;@Wo3;6iDvjln@7hzF~HZ>87cv2vM$RoEJUmS7SD z8u={@FMrt_tu9K2?9UCl!txn#bQz$C!dY7tP!t%E4{VF~2L}2R*C<}%EUj87G@^T0 zfI9?b0}9Mxl!lIsP${GbU+m^y&vH=D1nju9LTU40CqRdAdGT~oLBU?$nIGXDm9ZK~ zsEls6{T$j1t(~h&M0>tfVSpGvRQheL?WJ;?12&%Sj7h>k8$*v=C<*DA{c>2ag%qs_2;hwA9Nv>gr0w)l+Tb&s-tFcC)*?8d+_w5|D~DZOI~pD_nITB%K3XNE8A=~b z-O{P1kq=@1JR(Lx;zgs_H5&AW;eV*^Lp2>2T^$*^*e9S*3x{S77LuK$Hmo#^_4JSX zG8&d)acm+?xZkzr`Z#nXOXnbGBo^-VUaIe4hh(mY?f-uEi-gMmRa`yt%K9RE8KyBJ zLc}hPPS88h%T6Y&!$AEFDMg`cQo_!ZIhigIA+@A4obbGfPJz+Md2!_Ln}3w4C<+7P zId=SX(9mAzjCkUwQZHPTvCCJz1U#N|X=_UQFGzQ)2|YkwYW;d{#uN5#!r(xz8(+(6Kdm zH?n;puJA5j(GcNB^4^(m*MAsy$TzPdXO4w?v$875LG7tn=suZL%K#dOrwC}@+0+-_ zC*2i#QS39aG)VV_St0Q*G?ais%m#TVG1=MVs9nFHLvAWKZS8p}WWu{Nnrf`;pu11L zkz%R$7+iu#M6tl4QJwV`6euK6SjaDKN&KO`9&3}RR2YSc;?cWz|J3_E z(Z05Zl)MiIdo56mqC%-#b)Mscu}TqM|5NQ534EC<;{+g(@nFLKQ`! sii)C8MNz1tq9{~R6so9HMgA6G0GpbD({M)p8vpp@Bjb+ delta 2932 zcmV-)3ybuh6_Xc`83+ad008y=FZ7WiCw~hyNkl0EsAU;;zS71sHqfG2F?J{32g_BK^`3^SF*f)*oG6KhD1Uwf^DFAbcz^vuGJkD0S--nxJ7aj@vE$Wq+PjClDC$ojbsM1Tmr1q<0+{Qk9@u6XS|S%4^1U!|9CR_+uEY-lHq~G&L)ZV z+~n)Eh~>v<-~7Va)UBMdT{1kp=|u*fK#76Wdt)koNi$iV&Uq|FMrP@S8vXB zxP5%i*ds@iL#YLnBnSi}{#v~LrtMgPwI?Inw$|@0TI~9ul8YECmRR%4v&qFPKTK|a zu$)UgUJKVRIMQl@{p7b#=eG4h`y#BQ!pE3G0!U)!@F$;1dOzBk>1599|5|fnqAlNl zdF-Xl-}AfKKfm1Zx!?NI&wm{W05K&B1Ix_(^40`J^!7W`!TFPoJ(9Bzv_H3ay6wor zC7kvbC!A=Lm0V&T?0=s}Xt1w$$gLY|z#RSc$pdqwU1*HIO!vw^x?%k$hL3lQn`iYi zqp8vk?WM>;*81KTayj9Ph_OhsvshUJXLB~v^?TiC^4zNTEF?QN`hSuW$msD!WGi`Q zVt6V!bLm8z6)h5Y8PmYtQMZw7n%^IScRm$rf3AYTJ!4Mr`gRZJ_Jd&ZVw}uh3s;QW zOxx!UzV7w_1t)tKyFTpAk5eVm@tI2bWkKc`TA%Fku4RsK>akPFYrlG`W1T|;Pp;fk zBqYgVLuD6!n2>uSCI6U%$d4E3UTr&&EL7wZ&=gS)L zb&yyJhtwMQa-fy4WV=y9_mx~sDo+zJ0pA*Ei-!hcQ6QgxaEvf!#c>=;S0R`07Wo>D zxv;p5gFdw2{dDfcra&@wtUz=^CZK7Hlz@<2lN5y`0&pmGRarOf3We6&DXf%edc4wB zV|9JG&4m*8OMknt+PY3C;%WC*yW>Sx%AaEyus<>fy;pf2h90Z0T(p-`MAR+G7UoSV zk5~van=O+-XpW^;Lr;qKGl6(T7NSTi#^UO&OYI6{@93t56cojXF-e9P3!eupzaGQj z-cF^1f(otol9x0JwJj3JPUSeMtjwERl4#O>=>5T!(|?LEOCAN!rn2YD5EdD?_e`op zo3dK9ESH{OEU~iU195LIUis0c2BkfMEgIXmeBIbkk`TU2Q?(!FB36-i5;S!V#A&PD zG#__zGJ-|fLW!UJgoIXjS`q2J&vW6bgcMop#LvV96xWb<*(-7PLYC+J!s#~4Bwy2J z#U;=d+<$x1HLjJ&#e_nWs6wpv!1M(de~I=$W8=p7eU0=_)+U#WvpnK5ZoTPf!U0dy z4@SmYC<%m6h;Tfezn>JSGxjFI=ViHZtigHZQitLxKcg2jzPtoOmJ%W^ly=1G?bdy| zBV(v769wXaNuDH%Qt2#|-z_88K!$4pDXJ1nTYoV$i6lWtkNVat*0pI%%NN8+60B>j z45`b+S3YoUsWOp`tm7VP1(TNysAREK62&JE#L|lFfJdaFjB1nMY*fhQdrt01V>mlh zK{=ecd15oe%k7L^>DSChC$>n`l!=kMmM!$-f{-=wGg>hqV-8m1=&46DG|zUhT7^R3eSHdRR}_6$n)C8r#4+n&Wf7Asq+)1+c0(% zizJ^kvGQDB=D>XBugy3m3emI+s1rs_CNwIMtFL#cQ#id0lnnG(dnm5DcB@#o)c{$mDv>Dbl@i2vVTm}NJN`^7kJ?z}{_oBzfrjshxf+PWW%u#`Bug;eAxI=TmYtVwmdEKDrUdE)p zn}$!On8X$?f6SPe@7X_`Y;3HREPt2386oTRc+In&rB>=UM9|oCC$ujmRR}Q!tVO^o zNa1VN^DZ!+JJFHZ;(6(BWo;qo9`bX&$L&R>7M``*OO8s+(?uJdn98E zrMDTY{(T4t+J=kahiK;?5TtbYeWE(r(H#~jk>nnOuy%wB$ZGcF(_=N|(5DRBtur;zUj z+S8?yBKq>6jzbEQG-=`&AElahDHw5Ui3+WiL$DZSRl0Y*|s6 zb@tb~%sRaY z_)YTrzy8dTNWUPe)Q&y*=t)8Mn;6OdN$Ow|B=Glm=g{7bZuQWnUu14=OZS;JbO2^l#&|m=&U^$#)l9}49f8(mg?Ut~%-C4q|>_1qTcEBi%YFn>O|=SR3wr|^Kx;eB@t z1;j{{%fw~{rK&lrsy%J62^NmEK^y!XNn2sqC`j zVBMts;N8)-!}+FxVx~d^`G8IvASN~a@4Vuthco1y{US{pb|>u5Ay0h$`S?TqvOOn z7dbT=`-{7Bw$=1?2#7VCadFaM*v@F|kAk9AV@q+$xPrK4Ml8caO|A_;f6-M|)UBR? zpp+O@bp;KE?SQWQM+}m<;1;p2+Aj3-Z_SmCEewW-j$vFH1dE*c_=l4c@OGSv7>ry7gTcsUFc`TE1|yfjU@&qS e4BHm}6JP*3NQXzX9TW2a0000JP-dK(-@3wamCAq7#!C+`W8! zzkmPM`s>$EcQp-7F>W62U6(GL|Bg*PBR0YKD8$6X#Qf{$ z&mT{L#PaJ`FE`AXJoz_X7o}uoiP_pa%w}L@3;-I!3$yJ1|9}6?EG#U7T-@9SlG4%& zvU2j9PoFpr*T;lzkf@kgJtr5J*WbT?+0o^IhB5s9{hODSjonpRM%E5l4#l9D#AJC{ zc?E~>-@miq3s|6uQa`?b&%tSsuD*dDA3s0ezkmPmn)B!PZ&qaq_er3gF5Xeve8Hfk}u^I%lG}SgG`hj_c6_~`C zfoX}6g_V^V2(~muyQ1V+SPm<}N!Azp4C9togf@DvU-fBw002ovPDHLkV1n~2Cp-WE delta 548 zcmV+<0^9wK1>yvdNq+=ML_t(|+G1d!5@5t985ADD;Oiea_0#8%5j@qtSy@<242+BvU}7i+{rK_S;P2nR9K=L7 z&}H1;zkj#HYJU(AaN&zdEDrYFeTC;kh(v(4EjfcK``~01_AxePJ-7Mfysd# z!yq*c4F+y*ZiD~8KqSgv|NnEcv$Gp%YHK6Xk)pCPdu2nTH!%5E{`&Px5SW6AF^Cmt zv68*B^ZiTbFWd*~ShRYL1`{LGN?`gC1{wki!2iHxz<&%>%mU5W|6w#x{x2|f{{edq z=ny7G#&5iQ{E;Aq4EOHb0eXuk`XA6=Pz(R?^6*Ntb8wpe|Nl=28k>wDLw^1IdHvJp zPp5%=SoUFj@!~n|Vk9{;%hb)oYu4w_pA2APK(G8de)w?fq`saeboER)QyVk$X`t86 mpoPm7CLLzx&Dhif1Q-A!BDPM|V?tyA0000L%cG5zMAUWJ5pznhYGF z0k1&FYaoLb05vVZ7C1n0kXHlIy~czV&<4;jDa04jK*K=cwE;Q6(Oo0}4VMo@6fcFy dNdh3i0Ev`Hoe+$%Wb6O{002ovPDHLkV1hExYCZq} delta 731 zcmV<10wn#`0+$AmNPhykNklNL5|K zTT5GKxtzR$G9N$xmW$`k{lcb>37;WBVd0!XAz^_ZKYS2pXXkKdW?{+4r53M2Z0zhl zynOs#|Ni}B`10j5o29jlYiwe&0!aq>hlFt2J39M){`^tm|9}7g3_pMVWZ>rJHWd;U zP9(`7Q896IF>!HMpaJiAd3Y9SsH*Pf=jGv4P*!#dkB;F+SI>gY5HDXp1|2=UxQ`z{ zya2jp?~k89Wx2RGl|@B_7{2}ZA+MpO?F>}5iJ*)042{GkB&DqQxVca8^YMNC@bQz! z{fCc~{{H#LAb%|>DgNQ(#{ifpbtZf)%<>lS~{{74U@$+YsPoF<)0TUwwkk9b)^=pQwPoFbL zOG}G-`ubVm4I{sxAYLV9Wy6mjKeDkfGc!DY^_t=Fvw!Cd4F7@72lCn2SQ&sW68ik< zlPgg9UYrI26&U~e^@|_m3b5aqm>4*Dc^R01{2xDlz?5+V)0PRLz%~M6AyC?3Wo2dH z1YAEdI1T#$|DQIH;^*Yz`u*bh^Zj@4 z+%8(SaDSo8%qf%I@87+X|LDQ}13>wol2TIK1?3gGSiL4DF2T&f!DYzA#KipN%a?77 z=FZ8!dil~rn0!TH!4@S|)x-T$XDoRC?ybwGj~_t>oy2faX-%z|in=;KCpY)y$-O-V z$cDfGD+|lV*RNjHv#_w-0&;b+dhOfSuS&o`{8aSy%jYs+_}syk#%^A}&QM!kdV`UX zsRI}x%DBSFR6syrdTV{%nR91O<17`PKYjA6tRVLc4>!*jm>58S0RWU+0W N002ovPDHLkV1hy=f+7F_ diff --git a/pandora_console/images/gm_discovery.menu_white.png b/pandora_console/images/gm_discovery.menu_white.png new file mode 100644 index 0000000000000000000000000000000000000000..d05d5e761672650352fc998ca20b209ae449391b GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1Gn><|{Ln>}1B`7fc`Tsw@u`!6jh^6B_^G3#{Y-|7XGk(`J zJo3<9%R}M%g1-UG_a?v9%D8dhK+UGu)@3&tI`_^CX->FT$^Ue|yAhAFrNKi36$TGZ zhn?&T?pZc0InpSTzt??n=XW_1#z)NWJ$rR)4m1WxEd2eSQ9$2;TUo$BLA6He!V{he zd-l$o;Q0Kbs?Cb)j*Rs{_Jb)tK5|EvGdwF{RPttJuQ5}dFhQI-p{9X>nIUsy)>_jm S>QO+~GkCiCxvX0onfB0_6gbNPhtbNklUFkK43v&&xg{EKo=gMY7jw#<~u11&S4x&=U2Zvf>FY?e?h4u61_EWl<73!ZQV<>+`a z?D~LYi6Op7)(2t-3Oog}M1Td4mq8h>ki^sk3YPs)!$D=%1**jX7Q+`%Es}8=PR&#l zkIisuTF?l@is*(@t*8JR`~g?}0rSBFv{IG&RVFZ^K((0ywgQV<79ghtTs0cVr-jfU sA*<2{`Jf)^6CYgR?Z_~g06>5N06n`_;ztkWN&o-=07*qoM6N<$g3n!g2LJ#7 delta 284 zcmV+%0ptGV0^0(RNPhtRNklB=(zlM#2mBOzN&&AAfL<;nBQ=3a1P7=uz$uDqaR4=ZK9b=Vs20h%45wx)ipOR+)p9Zr z1VZEO15JtwYzEVK&wJl)8Qt4lSR{FRqpbh9Lg`fpUmh=O0 i0JI9FO0xwZz!d;eBUoq%9P4-h0000jyy(9MYCpF>E}L(I=P0pm2aet!hO}^c~gfKr0wLUHx3vIVCg!0BNEz6aWAK delta 293 zcmV+=0owkp0mA|ziBL{Q4GJ0x0000DNk~Le0000j0000j2nGNE06H4tnvo$Wf8|L; zK~#9!?AYxMgCGzF;9@#}BXpFG;0U^bn{))biEh*p=#kjO{;+%q+-vh*LLlJ+5BHC2 zE+>qJXrhTGIw`It4z%lc8~y`~2@e2c!6U#Ja1Zza2ls&c zHK&Jxhk!S^`tTSq1Uv<-3O@o?dx7TwSB2*USAmxR7loGu7lGFRXNA`UXMt;g55YCT zNpJ*k6kHY~3OEoxx`Y`C8~~s9`W}OP{hylX_5NY+Mcw8VFYO9@D(-yUXXEA?EHYZq rpMHz%V*`?CqKPJ&Xrlic{T5&VMyUOB+_mRX00000NkvXXu0mjfsquG9l0e}Dl0F=K+c9_s{CjbBd00>D%PDHLkV1gc~I57YK delta 193 zcmV;y06zcF0fGXMNq?kCL_t(|+G1n?g8%>jD*&kgAQoVt94ugj8hD;c27F+u^7BnFrkbG_pKW58bvz7=L2N>Rg%|@jU8!a8(`g3tL2MAvm+~Xe zP-Fv<4IyYSF!4A1#{w=q-T1$0ryiIlMGge88cIkLAvG9=5;|ibA+;=+N#_Pe7~%pj vH6T3<41R>eloBwS_lJ<72dHf*K!5=N;S_Ao0gwnF00000NkvXXu0mjfcnn9| diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 6c54271b70..3152430931 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -309,6 +309,10 @@ function config_update_config() if (!config_update_value('auditdir', get_parameter('auditdir'))) { $error_update[] = __('Audit log directory'); } + + if (!config_update_value('unique_ip', get_parameter('unique_ip'))) { + $error_update[] = __('unique_ip'); + } break; case 'enterprise': @@ -1032,11 +1036,6 @@ function config_update_config() $error_update[] = __('Fixed header'); } - /* - if (!config_update_value('fixed_menu', get_parameter('fixed_menu'))) { - $error_update[] = __('Fixed menu'); - }*/ - if (!config_update_value('paginate_module', get_parameter('paginate_module'))) { $error_update[] = __('Paginate module'); } @@ -1117,11 +1116,6 @@ function config_update_config() $error_update[] = __('Default height of the chart image'); } - /* - if (!config_update_value('classic_menu', (bool) get_parameter('classic_menu', false))) { - $error_update[] = __('Classic menu mode'); - }*/ - // -------------------------------------------------- // CUSTOM VALUES POST PROCESS // -------------------------------------------------- @@ -1793,11 +1787,6 @@ function config_process_config() config_update_value('fixed_graph', false); } - /* - if (!isset($config['fixed_menu'])) { - config_update_value('fixed_menu', false); - }*/ - if (!isset($config['custom_favicon'])) { config_update_value('custom_favicon', ''); } @@ -2518,11 +2507,6 @@ function config_process_config() } } - /* - if (!isset($config['classic_menu'])) { - config_update_value('classic_menu', 0); - }*/ - if (!isset($config['csv_divider'])) { config_update_value('csv_divider', ';'); } diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index c0ae82b4ec..9ff78b3e05 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -342,11 +342,8 @@ function menu_print_menu(&$menu) $sub_title = ''; } - // Added a top on inline styles - $top = menu_calculate_top($config['count_main_menu'], $count_sub, $count_sub2); - // Add submenu2 to submenu string - $submenu_output .= '