diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 79e7ac2d75..4fd5136eee 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.775-240118 +Version: 7.0NG.775-240122 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 c1029f651b..a84d1c1048 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.775-240118" +pandora_version="7.0NG.775-240122" 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 c4b788fe46..1bdfa2c98d 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1039,7 +1039,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.775'; -use constant AGENT_BUILD => '240118'; +use constant AGENT_BUILD => '240122'; # 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 03bec971e3..9d6bcf8f51 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240118 +%define release 240122 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec index bfcb50e59f..5b9e48578d 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el8.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240118 +%define release 240122 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec index 1cf8be22e9..8ed84f4eb2 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.el9.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240118 +%define release 240122 %define debug_package %{nil} Summary: Pandora FMS Linux agent, binary version diff --git a/pandora_agents/unix/pandora_agent.redhat_bin.spec b/pandora_agents/unix/pandora_agent.redhat_bin.spec index f16c07fc1e..e1ac0c3dd6 100644 --- a/pandora_agents/unix/pandora_agent.redhat_bin.spec +++ b/pandora_agents/unix/pandora_agent.redhat_bin.spec @@ -5,7 +5,7 @@ %define name pandorafms_agent_linux_bin %define source_name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240118 +%define release 240122 Summary: Pandora FMS Linux agent, binary version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index f6d4e075f5..710699686d 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_agent_linux %define version 7.0NG.775 -%define release 240118 +%define release 240122 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 e91df83438..54a64fa46d 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240118" +PI_BUILD="240122" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index a278d97f8d..efc085bfe6 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{240118} +{240122} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 34a6dd3be8..2a05f4e9ce 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.775 Build 240118") +#define PANDORA_VERSION ("7.0NG.775 Build 240122") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7763dcb321..7600b129ae 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Pandora FMS" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.775(Build 240118))" + VALUE "ProductVersion", "(7.0NG.775(Build 240122))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index bd76e0003c..6ba70f63f8 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.775-240118 +Version: 7.0NG.775-240122 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 81f525de04..69659ab510 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.775-240118" +pandora_version="7.0NG.775-240122" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index c4f71a08ef..254cb2e7c1 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -3,6 +3,12 @@ START TRANSACTION; -- Update version for plugin oracle UPDATE `tdiscovery_apps` SET `version` = '1.2' WHERE `short_name` = 'pandorafms.oracle'; +ALTER TABLE `tncm_agent_data` +ADD COLUMN `id_agent_data` int not null default 0 AFTER `script_type`; + ALTER TABLE `tusuario` CHANGE COLUMN `metaconsole_data_section` `metaconsole_data_section` TEXT NOT NULL DEFAULT '' ; +ALTER TABLE `tmensajes` ADD COLUMN `icon_notification` VARCHAR(250) NULL DEFAULT NULL AFTER `url`; + + COMMIT; \ No newline at end of file diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index d0c255e25e..4e62337547 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1130,17 +1130,12 @@ foreach ($fields as $field) { } if ((bool) $field['is_password_type'] === true) { - $customContent = html_print_input_text_extended( + $customContent = html_print_input_password( 'customvalue_'.$field['id_field'], $custom_value, - 'customvalue_'.$field['id_field'], '', - 30, - 100, - $view_mode, - '', - '', - true, + 45, + 255, true ); } else if ($field['is_link_enabled']) { diff --git a/pandora_console/godmode/agentes/configure_field.php b/pandora_console/godmode/agentes/configure_field.php index 839040cb00..904b807bbd 100755 --- a/pandora_console/godmode/agentes/configure_field.php +++ b/pandora_console/godmode/agentes/configure_field.php @@ -275,21 +275,27 @@ $(document).ready (function () { $('#configure_field-3').show(); dialog_message("#message_no_set_password"); $('#configure_field-1').hide(); + $('#configure_field-2-0').hide(); } else{ $('#configure_field-3').hide(); $('#configure_field-1').show(); + $('#configure_field-2-0').show(); } }); $('input[type=checkbox][name=is_password_type]').change(function () { if( $('input[type=checkbox][name=is_password_type]').prop('checked')){ + $('#configure_field-1').hide(); dialog_message("#message_no_set_combo"); $('#configure_field-3').hide(); + $('#configure_field-2-1').hide(); } else{ if($('input[type=checkbox][name=is_combo_enable]').prop('checked') === true) { $('#configure_field-3').show(); } + $('#configure_field-1').show(); + $('#configure_field-2-1').show(); } }); }); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 15620240cd..47c843f2d9 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1131,13 +1131,13 @@ if (isset($id_agente) === true && (int) $moduletype === MODULE_DATA) { $tableCron->data['cron_to_select'][0] = html_print_extended_select_for_cron($hour_to, $minute_to, $mday_to, $month_to, $wday_to, true, $disabledBecauseInPolicy, true); } -$table_advanced->rowclass['cron_section'] = 'table_section full_section'; +$table_advanced->rowclass['cron_section'] = 'table_section full_section mrgn_top_mod_0px'; $table_advanced->data['cron_section'] = html_print_table($tableCron, true); $table_advanced->data['title_3'] = html_print_subtitle_table(__('Thresholds and state changes')); $table_advanced->rowclass['caption_min_max_values'] = 'w50p pdd_t_10px'; -$table_advanced->rowclass['min_max_values'] = 'w50p'; +$table_advanced->rowclass['min_max_values'] = 'w50p pdd_b_10px'; $table_advanced->data['caption_min_max_values'][0] = __('Min. Value'); $table_advanced->data['caption_min_max_values'][1] = __('Max. Value'); @@ -1214,7 +1214,7 @@ $tableDynamicThreshold->data['adv_dynamic_threshold_twotailed'][0] = html_print_ $disabledBecauseInPolicy ); -$table_advanced->rowclass['dynamic_threshold_table'] = 'table_section full_section'; +$table_advanced->rowclass['dynamic_threshold_table'] = 'table_section full_section mrgn_top_mod_0px'; $table_advanced->data['dynamic_threshold_table'] = html_print_table($tableDynamicThreshold, true); $tableFFThreshold = new stdClass(); @@ -1304,10 +1304,15 @@ $tableFFThreshold->data['ff_thresholds_each'][2] = html_print_input_text( $classdisabledBecauseInPolicy ); +$table_advanced->rowclass['gap_flipflop'] = 'mrgn_top_btn_10px_imp'; +$table_advanced->data['gap_flipflop'] = html_print_input_hidden('gap_flipflop', 0); -$table_advanced->rowclass['flipflop_thresholds_table'] = 'table_section full_section'; +$table_advanced->rowclass['flipflop_thresholds_table'] = 'table_section full_section mrgn_top_mod_0px'; $table_advanced->data['flipflop_thresholds_table'] = html_print_table($tableFFThreshold, true); +$table_advanced->rowclass['gap_ff'] = 'mrgn_top_btn_10px_imp'; +$table_advanced->data['gap_ff'] = html_print_input_hidden('gap_ff', 0); + $table_advanced->rowclass['caption_ff_interval_timeout'] = 'w50p'; $table_advanced->rowclass['ff_interval_timeout'] = 'w50p'; $table_advanced->cellclass['caption_ff_interval_timeout'][0] = 'w50p'; diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index c4f1860e6f..a2ed2c72d5 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -88,7 +88,17 @@ if ($multiple_delete) { ['id_filter' => $id] ); - if ($result === false) { + if ($result !== false) { + db_process_sql_delete( + 'tfavmenu_user', + [ + 'id_element' => $id, + 'section' => 'Events', + 'id_user' => $config['id_user'], + ] + ); + $result = true; + } else { break; } } @@ -210,7 +220,7 @@ foreach ($filters as $filter) { true, [ 'title' => __('Delete'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).''; } diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 4711821c52..9b11b86916 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -1529,7 +1529,7 @@ $array_os = [ 'windows' => __('Windows'), ]; $table->data[40][0] = html_print_label_input_block( - __('rget OS'), + __('Target OS'), html_print_select( $array_os, 'custom_string_2', diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index c4da379ebd..705e7a8fe4 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -349,7 +349,7 @@ function added_ids_sorted_items_to_hidden_input() { var ids = ''; var first = true; - $("input.selected_check:checked").each(function(i, val) { + $("input.custom_checkbox_input:checked").each(function(i, val) { if (!first) ids = ids + '|'; first = false; diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index bb1617d001..46a91e27c6 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -527,9 +527,12 @@ $table->data[$i++][] = html_print_label_input_block( true ) ); - +$help_tip = ui_print_help_tip( + __('No events or alerts will be generated, but data will still be received.'), + true +); $table->data[$i][] = html_print_label_input_block( - __('Event storm protection'), + __('Event storm protection').$help_tip, html_print_checkbox_switch( 'event_storm_protection', 1, diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 99c96fdf6d..017de9869b 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -689,7 +689,7 @@ foreach ($info as $user_id => $user_info) { // User profiles. if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { $user_profiles = db_get_all_rows_sql( - 'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5' + 'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'"' ); } else { $user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5'); @@ -778,17 +778,25 @@ foreach ($info as $user_id => $user_info) { if ($user_profiles !== false) { $total_profile = 0; - $data[4] .= '
'; + $data[4] .= '
'; foreach ($user_profiles as $row) { + $total_profile++; + if ($total_profile > 5) { + $data[4] .= "'; + } + + if ($total_profile == 1 && count($user_profiles) > 5) { + $data[4] .= ''.html_print_image( 'images/zoom.png', true, [ @@ -803,10 +811,6 @@ foreach ($info as $user_id => $user_info) { true ); } - - $data[4] .= '
'; - - $total_profile++; } if (isset($user_info['not_delete']) === true) { @@ -1057,43 +1061,13 @@ if ($is_management_allowed === true) { ?> diff --git a/pandora_console/images/notification/congrats.svg b/pandora_console/images/notification/congrats.svg new file mode 100644 index 0000000000..2f744df78d --- /dev/null +++ b/pandora_console/images/notification/congrats.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon congrats + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/disable.svg b/pandora_console/images/notification/disable.svg new file mode 100644 index 0000000000..ac34ab01b3 --- /dev/null +++ b/pandora_console/images/notification/disable.svg @@ -0,0 +1,18 @@ + + + Icons/Dark/40/Alert icon disable + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/error.svg b/pandora_console/images/notification/error.svg new file mode 100644 index 0000000000..05b07ebfb9 --- /dev/null +++ b/pandora_console/images/notification/error.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon error + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/favorite.svg b/pandora_console/images/notification/favorite.svg new file mode 100644 index 0000000000..eff171b67f --- /dev/null +++ b/pandora_console/images/notification/favorite.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon favorite + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/headsup.svg b/pandora_console/images/notification/headsup.svg new file mode 100644 index 0000000000..57e26bc4d9 --- /dev/null +++ b/pandora_console/images/notification/headsup.svg @@ -0,0 +1,21 @@ + + + Icons/Dark/40/Alert icon heads up + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/information.svg b/pandora_console/images/notification/information.svg new file mode 100644 index 0000000000..11319a4bb5 --- /dev/null +++ b/pandora_console/images/notification/information.svg @@ -0,0 +1,17 @@ + + + Icons/Dark/40/Alert icon information + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/popular.svg b/pandora_console/images/notification/popular.svg new file mode 100644 index 0000000000..20b00a83ad --- /dev/null +++ b/pandora_console/images/notification/popular.svg @@ -0,0 +1,18 @@ + + + Icons/Dark/40/Alert icon popular + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/notification/question.svg b/pandora_console/images/notification/question.svg new file mode 100644 index 0000000000..5694e5d9b2 --- /dev/null +++ b/pandora_console/images/notification/question.svg @@ -0,0 +1,18 @@ + + + Icons/Dark/40/Alert icon question + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/include/ajax/dashboard.ajax.php b/pandora_console/include/ajax/dashboard.ajax.php index 50a0e0b7a1..40497a2ebc 100644 --- a/pandora_console/include/ajax/dashboard.ajax.php +++ b/pandora_console/include/ajax/dashboard.ajax.php @@ -41,7 +41,20 @@ if ($method === 'draw') { $length = get_parameter('length', $config['block_size']); $orderBy = get_datatable_order(true); - $sort_field = $orderBy['field']; + switch ($orderBy['field']) { + case 'groups': + $sort_field = 'nombre'; + break; + + case 'favorite': + $sort_field = 'active'; + break; + + default: + $sort_field = $orderBy['field']; + break; + } + $order = $orderBy['direction']; $pagination = ''; @@ -121,7 +134,7 @@ if ($method === 'draw') { ); } - $sql = 'SELECT * FROM tdashboard '.$where.' ORDER BY id '.$pagination; + $sql = 'SELECT * FROM tdashboard LEFT JOIN tgrupo ON tgrupo.id_grupo = tdashboard.id_group '.$where.' ORDER BY '.$sort_field.' '.$order.$pagination; $dashboards = db_get_all_rows_sql($sql); $count = db_get_value_sql('SELECT COUNT(*) FROM tdashboard '.$where); foreach ($dashboards as $dashboard) { diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 5488622b25..007ba77d89 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -98,6 +98,8 @@ $draw_events_graph = get_parameter('drawEventsGraph', false); // User private filter. $current_filter = get_parameter('current_filter', 0); $private_filter_event = get_parameter('private_filter_event', 0); +// Asteroids. +$playAsteroids = (bool) get_parameter('playAsteroids', false); if ($get_comments === true) { global $config; @@ -2763,6 +2765,17 @@ if ($draw_row_response_info === true) { return; } +// Asteroids. +if ($playAsteroids === true) { + echo ui_require_css_file('asteroids', 'include/styles/', true); + echo ui_require_javascript_file('asteroids', 'include/asteroids/', true); + + $output = '
Asteroids game goes here!
'; + + echo $output; + return; +} + if ($update_event_custom_id) { $event_custom_id = get_parameter('event_custom_id'); $event_id = get_parameter('event_id'); @@ -2814,4 +2827,4 @@ if ((bool) $draw_events_graph === true) { $output = event_print_graph($filter); echo $output; return; -} \ No newline at end of file +} diff --git a/pandora_console/include/asteroids/LICENSE.txt b/pandora_console/include/asteroids/LICENSE.txt new file mode 100644 index 0000000000..0dc661d166 --- /dev/null +++ b/pandora_console/include/asteroids/LICENSE.txt @@ -0,0 +1,25 @@ +Copyright (c) 2023, James Socol +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + diff --git a/pandora_console/include/asteroids/README.rst b/pandora_console/include/asteroids/README.rst new file mode 100644 index 0000000000..c7465358c2 --- /dev/null +++ b/pandora_console/include/asteroids/README.rst @@ -0,0 +1,46 @@ +========= +ASTEROIDS +========= + +Last week, at work, we joked about creating an Asteroids clone where every +asteroid had a bug number in it, as a bit of a joke. (Ha ha, every bug you +kill spawns two more!) + +I was bored this afternoon, so here's a port of Asteroids to JS/Canvas. + +Now all I need to do is hook in the bug numbers. + + +Gameplay +======== + +You're the triangle in the middle. You want to destroy the circles. You have +a gun (spacebar), some thrusters to turn (left and right arrow keys) and an +engine (up arrow key). + +Remember, it's kill or be killed out there. + + +Rights +====== + +The name *Asteroids* is, as far as I know, still property of Atari. I mean no +ill-will towards Atari by releasing this code. Frankly, it's a poor +substitute for anything resembling a real game. I just wanted to see if I +could do it. + +If anyone from Atari asks, I will gladly rename and/or remove this code. But +since there are so many *Asteroids* clones as it is, and the original was +released in 1979, and it was kind of a copy of *Spacewar!*, I doubt they'll +mind too much. + + +Strikes me as funny... +====================== + +The original *Spacewar!*, one of the earliest (if not the original) computer +games, took `200 hours to code `_. + +This probably took me 6. + +I am so glad we've moved past the PDP-1. diff --git a/pandora_console/include/asteroids/asteroids.js b/pandora_console/include/asteroids/asteroids.js new file mode 100644 index 0000000000..d6e9a460f4 --- /dev/null +++ b/pandora_console/include/asteroids/asteroids.js @@ -0,0 +1,840 @@ +// Asteroids.js +// Copyright (c) 2010–2023 James Socol +// See LICENSE.txt for license terms. + +// Game settings +GAME_HEIGHT = 480; +GAME_WIDTH = 640; +FRAME_PERIOD = 60; // 1 frame / x frames/sec +LEVEL_TIMEOUT = 2000; // How long to wait after clearing a level. + +// Player settings +ROTATE_SPEED = Math.PI / 10; // How fast do players turn? (radians) +MAX_SPEED = 15; // Maximum player speed +THRUST_ACCEL = 1; +DEATH_TIMEOUT = 2000; // milliseconds +INVINCIBLE_TIMEOUT = 1500; // How long to stay invincible after resurrecting? +PLAYER_LIVES = 3; +POINTS_PER_SHOT = 1; // How many points does a shot cost? (Should be >= 0.) +POINTS_TO_EXTRA_LIFE = 1000; // How many points to get a 1-up? + +// Bullet settings +BULLET_SPEED = 20; +MAX_BULLETS = 3; +MAX_BULLET_AGE = 25; + +// Asteroid settings +ASTEROID_COUNT = 2; // This + current level = number of asteroids. +ASTEROID_GENERATIONS = 3; // How many times to they split before dying? +ASTEROID_CHILDREN = 2; // How many does each death create? +ASTEROID_SPEED = 3; +ASTEROID_SCORE = 10; // How many points is each one worth? + +var Asteroids = function(home) { + // Constructor + // Order matters. + + // Set up logging. + this.log_level = Asteroids.LOG_DEBUG; + this.log = Asteroids.logger(this); + + // Create the info pane, player, and playfield. + home.innerHTML = ""; + this.info = Asteroids.infoPane(this, home); + this.playfield = Asteroids.playfield(this, home); + this.player = Asteroids.player(this); + + // Set up the event listeners. + this.keyState = Asteroids.keyState(this); + this.listen = Asteroids.listen(this); + + // Useful functions. + this.asteroids = Asteroids.asteroids(this); + this.overlays = Asteroids.overlays(this); + this.highScores = Asteroids.highScores(this); + this.level = Asteroids.level(this); + this.gameOver = Asteroids.gameOver(this); + + // Play the game. + Asteroids.play(this); + return this; +}; + +Asteroids.infoPane = function(game, home) { + var pane = document.createElement("div"); + pane.innerHTML = "ASTEROIDS"; + + var lives = document.createElement("span"); + lives.className = "lives"; + lives.innerHTML = "LIVES: " + PLAYER_LIVES; + + var score = document.createElement("span"); + score.className = "score"; + score.innerHTML = "SCORE: 0"; + + var level = document.createElement("span"); + level.className = "level"; + level.innerHTML = "LEVEL: 1"; + + pane.appendChild(lives); + pane.appendChild(score); + pane.appendChild(level); + home.appendChild(pane); + + return { + setLives: function(game, l) { + lives.innerHTML = "LIVES: " + l; + }, + setScore: function(game, s) { + score.innerHTML = "SCORE: " + s; + }, + setLevel: function(game, _level) { + level.innerHTML = "LEVEL: " + _level; + }, + getPane: function() { + return pane; + } + }; +}; + +Asteroids.playfield = function(game, home) { + var canvas = document.createElement("canvas"); + canvas.width = GAME_WIDTH; + canvas.height = GAME_HEIGHT; + home.appendChild(canvas); + return canvas; +}; + +Asteroids.logger = function(game) { + if (typeof console != "undefined" && typeof console.log != "undefined") { + return { + info: function(msg) { + if (game.log_level <= Asteroids.LOG_INFO) console.log(msg); + }, + debug: function(msg) { + if (game.log_level <= Asteroids.LOG_DEBUG) console.log(msg); + }, + warning: function(msg) { + if (game.log_level <= Asteroids.LOG_WARNING) console.log(msg); + }, + error: function(msg) { + if (game.log_level <= Asteroids.LOG_ERROR) console.log(msg); + }, + critical: function(msg) { + if (game.log_level <= Asteroids.LOG_CRITICAL) console.log(msg); + } + }; + } else { + return { + info: function(msg) {}, + debug: function(msg) {}, + warning: function(msg) {}, + error: function(msg) {}, + critical: function(msg) {} + }; + } +}; + +Asteroids.asteroids = function(game) { + var asteroids = []; + + return { + push: function(obj) { + return asteroids.push(obj); + }, + pop: function() { + return asteroids.pop(); + }, + splice: function(i, j) { + return asteroids.splice(i, j); + }, + get length() { + return asteroids.length; + }, + getIterator: function() { + return asteroids; + }, + generationCount: function(_gen) { + var total = 0; + for (var i = 0; i < asteroids.length; i++) { + if (asteroids[i].getGeneration() == _gen) total++; + } + game.log.debug("Found " + total + " asteroids in generation " + _gen); + return total; + } + }; +}; + +/** + * Creates an overlays controller. + */ +Asteroids.overlays = function(game) { + var overlays = []; + + return { + draw: function(ctx) { + for (var i = 0; i < overlays.length; i++) { + overlays[i].draw(ctx); + } + }, + add: function(obj) { + if (-1 == overlays.indexOf(obj) && typeof obj.draw != "undefined") { + overlays.push(obj); + return true; + } + return false; + }, + remove: function(obj) { + var i = overlays.indexOf(obj); + if (-1 != i) { + overlays.splice(i, 1); + return true; + } + return false; + } + }; +}; + +/** + * Creates a player object. + */ +Asteroids.player = function(game) { + // implements IScreenObject + var position = [GAME_WIDTH / 2, GAME_HEIGHT / 2], + velocity = [0, 0], + direction = -Math.PI / 2, + dead = false, + invincible = false, + lastRez = null, + lives = PLAYER_LIVES, + score = 0, + radius = 3, + path = [ + [10, 0], + [-5, 5], + [-5, -5], + [10, 0] + ]; + + return { + getPosition: function() { + return position; + }, + getVelocity: function() { + return velocity; + }, + getSpeed: function() { + return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2)); + }, + getDirection: function() { + return direction; + }, + getRadius: function() { + return radius; + }, + getScore: function() { + return score; + }, + addScore: function(pts) { + score += pts; + }, + lowerScore: function(pts) { + score -= pts; + if (score < 0) { + score = 0; + } + }, + getLives: function() { + return lives; + }, + rotate: function(rad) { + if (!dead) { + direction += rad; + game.log.info(direction); + } + }, + thrust: function(force) { + if (!dead) { + velocity[0] += force * Math.cos(direction); + velocity[1] += force * Math.sin(direction); + + if (this.getSpeed() > MAX_SPEED) { + velocity[0] = MAX_SPEED * Math.cos(direction); + velocity[1] = MAX_SPEED * Math.sin(direction); + } + + game.log.info(velocity); + } + }, + move: function() { + Asteroids.move(position, velocity); + }, + draw: function(ctx) { + let color = "#fff"; + if (invincible) { + const dt = (new Date() - lastRez) / 200; + const c = Math.floor(Math.cos(dt) * 16).toString(16); + color = `#${c}${c}${c}`; + } + Asteroids.drawPath(ctx, position, direction, 1, path, color); + }, + isDead: function() { + return dead; + }, + isInvincible: function() { + return invincible; + }, + extraLife: function(game) { + game.log.debug("Woo, extra life!"); + lives++; + }, + die: function(game) { + if (!dead) { + game.log.info("You died!"); + dead = true; + invincible = true; + lives--; + position = [GAME_WIDTH / 2, GAME_HEIGHT / 2]; + velocity = [0, 0]; + direction = -Math.PI / 2; + if (lives > 0) { + setTimeout( + (function(player, _game) { + return function() { + player.resurrect(_game); + }; + })(this, game), + DEATH_TIMEOUT + ); + } else { + game.gameOver(); + } + } + }, + resurrect: function(game) { + if (dead) { + dead = false; + invincible = true; + lastRez = new Date(); + setTimeout(function() { + invincible = false; + game.log.debug("No longer invincible!"); + }, INVINCIBLE_TIMEOUT); + game.log.debug("You ressurrected!"); + } + }, + fire: function(game) { + if (!dead) { + game.log.debug("You fired!"); + var _pos = [position[0], position[1]], + _dir = direction; + + this.lowerScore(POINTS_PER_SHOT); + + return Asteroids.bullet(game, _pos, _dir); + } + } + }; +}; + +Asteroids.bullet = function(game, _pos, _dir) { + // implements IScreenObject + var position = [_pos[0], _pos[1]], + velocity = [0, 0], + direction = _dir, + age = 0, + radius = 1, + path = [ + [0, 0], + [-4, 0] + ]; + + velocity[0] = BULLET_SPEED * Math.cos(_dir); + velocity[1] = BULLET_SPEED * Math.sin(_dir); + + return { + getPosition: function() { + return position; + }, + getVelocity: function() { + return velocity; + }, + getSpeed: function() { + return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2)); + }, + getRadius: function() { + return radius; + }, + getAge: function() { + return age; + }, + birthday: function() { + age++; + }, + move: function() { + Asteroids.move(position, velocity); + }, + draw: function(ctx) { + Asteroids.drawPath(ctx, position, direction, 1, path); + } + }; +}; + +Asteroids.keyState = function(_) { + var state = { + [Asteroids.LEFT]: false, + [Asteroids.UP]: false, + [Asteroids.RIGHT]: false, + [Asteroids.DOWN]: false, + [Asteroids.FIRE]: false + }; + + return { + on: function(key) { + state[key] = true; + }, + off: function(key) { + state[key] = false; + }, + getState: function(key) { + if (typeof state[key] != "undefined") return state[key]; + return false; + } + }; +}; + +Asteroids.listen = function(game) { + const keyMap = { + ArrowLeft: Asteroids.LEFT, + KeyA: Asteroids.LEFT, + ArrowRight: Asteroids.RIGHT, + KeyD: Asteroids.RIGHT, + ArrowUp: Asteroids.UP, + KeyW: Asteroids.UP, + Space: Asteroids.FIRE + }; + + window.addEventListener( + "keydown", + function(e) { + const state = keyMap[e.code]; + if (state) { + e.preventDefault(); + e.stopPropagation(); + game.keyState.on(state); + return false; + } + return true; + }, + true + ); + + window.addEventListener( + "keyup", + function(e) { + const state = keyMap[e.code]; + if (state) { + e.preventDefault(); + e.stopPropagation(); + game.keyState.off(state); + return false; + } + return true; + }, + true + ); +}; + +Asteroids.asteroid = function(game, _gen) { + // implements IScreenObject + var position = [0, 0], + velocity = [0, 0], + direction = 0, + generation = _gen, + radius = 7, + path = [ + [1, 7], + [5, 5], + [7, 1], + [5, -3], + [7, -7], + [3, -9], + [-1, -5], + [-4, -2], + [-8, -1], + [-9, 3], + [-5, 5], + [-1, 3], + [1, 7] + ]; + + return { + getPosition: function() { + return position; + }, + setPosition: function(pos) { + position = pos; + }, + getVelocity: function() { + return velocity; + }, + setVelocity: function(vel) { + velocity = vel; + direction = Math.atan2(vel[1], vel[0]); + }, + getSpeed: function() { + return Math.sqrt(Math.pow(velocity[0], 2) + Math.pow(velocity[1], 2)); + }, + getRadius: function() { + return radius * generation; + }, + getGeneration: function() { + return generation; + }, + move: function() { + Asteroids.move(position, velocity); + }, + draw: function(ctx) { + Asteroids.drawPath(ctx, position, direction, generation, path); + // ctx.setTransform(1, 0, 0, 1, position[0], position[1]); + // ctx.beginPath(); + // ctx.arc(0, 0, radius*generation, 0, Math.PI*2, false); + // ctx.stroke(); + // ctx.closePath(); + } + }; +}; + +Asteroids.collision = function(a, b) { + // if a.getPosition() inside b.getBounds? + var a_pos = a.getPosition(), + b_pos = b.getPosition(); + + function sq(x) { + return Math.pow(x, 2); + } + + var distance = Math.sqrt(sq(a_pos[0] - b_pos[0]) + sq(a_pos[1] - b_pos[1])); + + if (distance <= a.getRadius() + b.getRadius()) return true; + return false; +}; + +Asteroids.level = function(game) { + var level = 0, + speed = ASTEROID_SPEED, + hspeed = ASTEROID_SPEED / 2; + + return { + getLevel: function() { + return level; + }, + levelUp: function(game) { + level++; + game.log.debug("Congrats! On to level " + level); + while ( + game.asteroids.generationCount(ASTEROID_GENERATIONS) < + level + ASTEROID_COUNT + ) { + var a = Asteroids.asteroid(game, ASTEROID_GENERATIONS); + a.setPosition([ + Math.random() * GAME_WIDTH, + Math.random() * GAME_HEIGHT + ]); + a.setVelocity([ + Math.random() * speed - hspeed, + Math.random() * speed - hspeed + ]); + game.asteroids.push(a); + } + } + }; +}; + +Asteroids.gameOver = function(game) { + return function() { + game.log.debug("Game over!"); + + if (game.player.getScore() > 0) { + game.highScores.addScore("Player", game.player.getScore()); + } + + game.overlays.add({ + // implements IOverlay + draw: function(ctx) { + ctx.font = "30px System, monospace"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.fillText("GAME OVER", GAME_WIDTH / 2, GAME_HEIGHT / 2); + + var scores = game.highScores.getScores(); + ctx.font = "12px System, monospace"; + for (var i = 0; i < scores.length; i++) { + ctx.fillText( + scores[i].name + " " + scores[i].score, + GAME_WIDTH / 2, + GAME_HEIGHT / 2 + 20 + 14 * i + ); + } + } + }); + }; +}; + +Asteroids.highScores = function(game) { + var scores = []; + + if ((t = localStorage.getItem("high-scores"))) { + scores = JSON.parse(t); + } + + return { + getScores: function() { + return scores; + }, + addScore: function(_name, _score) { + scores.push({ name: _name, score: _score }); + scores.sort(function(a, b) { + return b.score - a.score; + }); + if (scores.length > 10) { + scores.length = 10; + } + game.log.debug("Saving high scores."); + var str = JSON.stringify(scores); + localStorage.setItem("high-scores", str); + } + }; +}; + +Asteroids.drawPath = function(ctx, position, direction, scale, path, color) { + if (!color) { + color = "#fff"; + } + ctx.strokeStyle = color; + ctx.setTransform( + Math.cos(direction) * scale, + Math.sin(direction) * scale, + -Math.sin(direction) * scale, + Math.cos(direction) * scale, + position[0], + position[1] + ); + + ctx.beginPath(); + ctx.moveTo(path[0][0], path[0][1]); + for (i = 1; i < path.length; i++) { + ctx.lineTo(path[i][0], path[i][1]); + } + ctx.stroke(); + ctx.closePath(); + ctx.strokeStyle = "#fff"; +}; + +Asteroids.move = function(position, velocity) { + position[0] += velocity[0]; + if (position[0] < 0) position[0] = GAME_WIDTH + position[0]; + else if (position[0] > GAME_WIDTH) position[0] -= GAME_WIDTH; + + position[1] += velocity[1]; + if (position[1] < 0) position[1] = GAME_HEIGHT + position[1]; + else if (position[1] > GAME_HEIGHT) position[1] -= GAME_HEIGHT; +}; + +Asteroids.stars = function() { + var stars = []; + for (var i = 0; i < 50; i++) { + stars.push([Math.random() * GAME_WIDTH, Math.random() * GAME_HEIGHT]); + } + + return { + draw: function(ctx) { + var ii = stars.length; + for (var i = 0; i < ii; i++) { + ctx.fillRect(stars[i][0], stars[i][1], 1, 1); + } + } + }; +}; + +Asteroids.play = function(game) { + var ctx = game.playfield.getContext("2d"); + ctx.fillStyle = "white"; + ctx.strokeStyle = "white"; + + var speed = ASTEROID_SPEED, + hspeed = ASTEROID_SPEED / 2; + + game.level.levelUp(game); + + var bullets = [], + last_fire_state = false, + last_asteroid_count = 0; + + var extra_lives = 0; + + // Add a star field. + game.overlays.add(Asteroids.stars()); + + game.pulse = setInterval(function() { + var kill_asteroids = [], + new_asteroids = [], + kill_bullets = []; + + ctx.save(); + ctx.clearRect(0, 0, GAME_WIDTH, GAME_HEIGHT); + + // Be nice and award extra lives first. + var t_extra_lives = game.player.getScore() / POINTS_TO_EXTRA_LIFE; + t_extra_lives = Math.floor(t_extra_lives); + if (t_extra_lives > extra_lives) { + game.player.extraLife(game); + } + extra_lives = t_extra_lives; + + if (game.keyState.getState(Asteroids.UP)) { + game.player.thrust(THRUST_ACCEL); + } + + if (game.keyState.getState(Asteroids.LEFT)) { + game.player.rotate(-ROTATE_SPEED); + } + + if (game.keyState.getState(Asteroids.RIGHT)) { + game.player.rotate(ROTATE_SPEED); + } + + var fire_state = game.keyState.getState(Asteroids.FIRE); + if ( + fire_state && + fire_state != last_fire_state && + bullets.length < MAX_BULLETS + ) { + var b = game.player.fire(game); + bullets.push(b); + } + last_fire_state = fire_state; + + if (!game.player.isDead()) { + game.player.move(); + game.player.draw(ctx); + } + + for (var k = 0; k < bullets.length; k++) { + if (!bullets[k]) continue; + + if (bullets[k].getAge() > MAX_BULLET_AGE) { + kill_bullets.push(k); + continue; + } + bullets[k].birthday(); + bullets[k].move(); + bullets[k].draw(ctx); + } + + for (var r = kill_bullets.length - 1; r >= 0; r--) { + bullets.splice(r, 1); + } + + var asteroids = game.asteroids.getIterator(); + for (var i = 0; i < game.asteroids.length; i++) { + var killit = false; + asteroids[i].move(); + asteroids[i].draw(ctx); + + // Destroy the asteroid + for (var j = 0; j < bullets.length; j++) { + if (!bullets[j]) continue; + if (Asteroids.collision(bullets[j], asteroids[i])) { + game.log.debug("You shot an asteroid!"); + // Destroy the bullet. + bullets.splice(j, 1); + killit = true; // JS doesn't have "continue 2;" + continue; + } + } + + // Kill the asteroid? + if (killit) { + var _gen = asteroids[i].getGeneration() - 1; + if (_gen > 0) { + // Create children ;) + for (var n = 0; n < ASTEROID_CHILDREN; n++) { + var a = Asteroids.asteroid(game, _gen); + var _pos = [ + asteroids[i].getPosition()[0], + asteroids[i].getPosition()[1] + ]; + a.setPosition(_pos); + a.setVelocity([ + Math.random() * speed - hspeed, + Math.random() * speed - hspeed + ]); + new_asteroids.push(a); + } + } + game.player.addScore(ASTEROID_SCORE); + kill_asteroids.push(i); + continue; + } + + // Kill the player? + if ( + !game.player.isDead() && + !game.player.isInvincible() && + Asteroids.collision(game.player, asteroids[i]) + ) { + game.player.die(game); + } + } + + kill_asteroids.sort(function(a, b) { + return a - b; + }); + for (var m = kill_asteroids.length - 1; m >= 0; m--) { + game.asteroids.splice(kill_asteroids[m], 1); + } + + for (var o = 0; o < new_asteroids.length; o++) { + game.asteroids.push(new_asteroids[o]); + } + + ctx.restore(); + + // Do we need to level up? + if (0 == game.asteroids.length && last_asteroid_count != 0) { + setTimeout(function() { + game.level.levelUp(game); + }, LEVEL_TIMEOUT); + } + + last_asteroid_count = game.asteroids.length; + + // Draw overlays. + game.overlays.draw(ctx); + + // Update the info pane. + game.info.setLives(game, game.player.getLives()); + game.info.setScore(game, game.player.getScore()); + game.info.setLevel(game, game.level.getLevel()); + }, FRAME_PERIOD); +}; + +// Some boring constants. +Asteroids.LOG_ALL = 0; +Asteroids.LOG_INFO = 1; +Asteroids.LOG_DEBUG = 2; +Asteroids.LOG_WARNING = 3; +Asteroids.LOG_ERROR = 4; +Asteroids.LOG_CRITICAL = 5; +Asteroids.LOG_NONE = 6; + +Asteroids.LEFT = 37; +Asteroids.UP = 38; +Asteroids.RIGHT = 39; +Asteroids.DOWN = 40; +Asteroids.FIRE = 32; + +// Load it up! +window.onload = Asteroids(document.getElementById("asteroids")); diff --git a/pandora_console/include/asteroids/index.html b/pandora_console/include/asteroids/index.html new file mode 100644 index 0000000000..3c1dfbd690 --- /dev/null +++ b/pandora_console/include/asteroids/index.html @@ -0,0 +1,14 @@ + + + + + Asteroids + + + + +
Asteroids game goes here!
+ + + + diff --git a/pandora_console/include/asteroids/style.css b/pandora_console/include/asteroids/style.css new file mode 100644 index 0000000000..ab877caa06 --- /dev/null +++ b/pandora_console/include/asteroids/style.css @@ -0,0 +1,46 @@ +/* Style for Asteroids.js + * Copyright (c) 2010 James Socol + * See LICENSE.txt for license. + */ + +body { + background-color: #000; + color: #fff; + font-family: "Calibri", "System", monospace; + font-size: 14px; +} + +div#asteroids { + margin: 50px auto; + width: 640px; + border: 1px solid #fff; + padding: 5px; +} + +div#asteroids > * { + color: #fff; +} + +div#asteroids > div { + font-family: "System", monospace; + font-size: 11px; + padding-bottom: 5px; +} + +div#asteroids > div > span { + float: right; + padding-left: 20px; +} + +div#instructions { + width: 640px; + margin: 20px auto; +} + +h1 { + font-size: 18px; +} + +h2 { + font-size: 16px; +} diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index f60c4dc241..1b1d06d8b9 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -58,6 +58,18 @@ class ConsoleSupervisor */ public const MIN_SYNC_QUEUE_LENGTH = 200; + /** + * Icons for notifications. + */ + public const ICON_CONGRATS = 'images/notification/congrats.svg'; + public const ICON_DISABLE = 'images/notification/disable.svg'; + public const ICON_ERROR = 'images/notification/error.svg'; + public const ICON_FAVORITE = 'images/notification/favorite.svg'; + public const ICON_HEADSUP = 'images/notification/headsup.svg'; + public const ICON_INFORMATION = 'images/notification/information.svg'; + public const ICON_POPULAR = 'images/notification/popular.svg'; + public const ICON_QUESTION = 'images/notification/question.svg'; + /** * Show if console supervisor is enabled or not. * @@ -666,14 +678,15 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable, - 'title' => __('Incorrect config value'), - 'message' => __( + 'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable, + 'title' => __('Incorrect config value'), + 'message' => __( $message, $names[$variable], $limit_value ), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } @@ -710,12 +723,13 @@ class ConsoleSupervisor db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']); $this->notify( [ - 'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE', - 'title' => __('Access statistics performance'), - 'message' => __( + 'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE', + 'title' => __('Access statistics performance'), + 'message' => __( 'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -962,6 +976,9 @@ class ConsoleSupervisor $notification['subject'] = io_safe_input($data['title']); $notification['subtype'] = $data['type']; $notification['url'] = io_safe_input($data['url']); + if (isset($data['icon_notification']) === true) { + $notification['icon_notification'] = $data['icon_notification']; + } $id = db_process_sql_insert('tmensajes', $notification); @@ -1055,13 +1072,14 @@ class ConsoleSupervisor // Warn user if license is going to expire in 15 days or less. $this->notify( [ - 'type' => 'NOTIF.LICENSE.EXPIRATION', - 'title' => $title, - 'message' => __( + 'type' => 'NOTIF.LICENSE.EXPIRATION', + 'title' => $title, + 'message' => __( $msg, $days_to_expiry ), - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else if (($days_to_expiry <= 0) && ((is_user_admin($config['id_user'])) || (check_acl($config['id_user'], 0, 'PM')))) { @@ -1076,10 +1094,11 @@ class ConsoleSupervisor // Warn user, license has expired. $this->notify( [ - 'type' => 'NOTIF.LICENSE.EXPIRATION', - 'title' => $title, - 'message' => $msg, - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'type' => 'NOTIF.LICENSE.EXPIRATION', + 'title' => $title, + 'message' => $msg, + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/license', + 'icon_notification' => self::ICON_HEADSUP, ] ); return false; @@ -1150,13 +1169,14 @@ class ConsoleSupervisor if (is_writable($config['attachment_store']) !== true) { $this->notify( [ - 'type' => 'NOTIF.WRITABLE.ATTACHMENT', - 'title' => __('Attachment directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.WRITABLE.ATTACHMENT', + 'title' => __('Attachment directory is not writable'), + 'message' => __( 'Directory %s is not writable. Please, configure corresponding permissions.', $config['attachment_store'] ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); return; @@ -1206,13 +1226,14 @@ class ConsoleSupervisor if (is_readable($remote_config_dir) !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG', - 'title' => __('Remote configuration directory is not readable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG', + 'title' => __('Remote configuration directory is not readable'), + 'message' => __( 'Remote configuration directory %s is not readable. Please, adjust configuration.', $remote_config_dir ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); return; @@ -1225,13 +1246,14 @@ class ConsoleSupervisor if (is_writable($remote_config_dir.'/conf') !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF', - 'title' => __('Remote configuration directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF', + 'title' => __('Remote configuration directory is not writable'), + 'message' => __( 'Remote configuration directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/conf' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -1243,13 +1265,14 @@ class ConsoleSupervisor if (is_writable($remote_config_dir.'/collections') !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS', - 'title' => __('Remote collections directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS', + 'title' => __('Remote collections directory is not writable'), + 'message' => __( 'Collections directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/collections' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -1261,13 +1284,14 @@ class ConsoleSupervisor if (is_writable($remote_config_dir.'/md5') !== true) { $this->notify( [ - 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5', - 'title' => __('Remote md5 directory is not writable'), - 'message' => __( + 'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5', + 'title' => __('Remote md5 directory is not writable'), + 'message' => __( 'MD5 directory %s is not writable. Please, adjust configuration.', $remote_config_dir.'/md5' ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -1291,14 +1315,15 @@ class ConsoleSupervisor if ($filecount > $MAX_FILES_DATA_IN) { $this->notify( [ - 'type' => 'NOTIF.FILES.DATAIN', - 'title' => __('There are too much files in spool').'.', - 'message' => __( + 'type' => 'NOTIF.FILES.DATAIN', + 'title' => __('There are too much files in spool').'.', + 'message' => __( 'There are more than %d files in %s. Consider checking DataServer performance', $MAX_FILES_DATA_IN, $remote_config_dir ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1314,14 +1339,15 @@ class ConsoleSupervisor if ($filecount > $MAX_BADXML_FILES_DATA_IN) { $this->notify( [ - 'type' => 'NOTIF.FILES.DATAIN.BADXML', - 'title' => __('There are too many BADXML files in spool'), - 'message' => __( + 'type' => 'NOTIF.FILES.DATAIN.BADXML', + 'title' => __('There are too many BADXML files in spool'), + 'message' => __( 'There are more than %d files in %s. Consider checking software agents.', $MAX_BADXML_FILES_DATA_IN, $remote_config_dir ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1402,18 +1428,19 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.QUEUE.'.$key, - 'title' => __( + 'type' => 'NOTIF.SERVER.QUEUE.'.$key, + 'title' => __( '%s (%s) is lacking performance.', servers_get_server_string_name($type), $queue['name'] ), - 'message' => __( + 'message' => __( $msg, $modules_queued, $queue['queued_modules'] ), - 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1471,10 +1498,11 @@ class ConsoleSupervisor $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, + 'type' => 'NOTIF.SERVER.STATUS', + 'title' => __('No servers available.'), + 'message' => __('There are no servers registered in this console. Please, check installation guide.'), + 'url' => $url, + 'icon_notification' => self::ICON_ERROR, ] ); } @@ -1515,6 +1543,7 @@ class ConsoleSupervisor } } + $icon_notification = self::ICON_QUESTION; if ($server['status'] == 1) { // Fatal error. Component has die. $msg = __( @@ -1528,6 +1557,8 @@ class ConsoleSupervisor servers_get_server_string_name($server['server_type']), $server['name'] ); + + $icon_notification = self::ICON_ERROR; } else { // Non-fatal error. Controlated exit. Component is not running. $msg = __( @@ -1544,10 +1575,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], - 'title' => $msg, - 'message' => $description, - 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'type' => 'NOTIF.SERVER.STATUS.'.$server['id_server'], + 'title' => $msg, + 'message' => $description, + 'url' => '__url__/index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'icon_notification' => $icon_notification, ] ); } @@ -1587,10 +1619,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.MASTER', - 'title' => __('No master servers found.'), - 'message' => __('At least one server must be defined to run as master. Please, check documentation.'), - 'url' => $url, + 'type' => 'NOTIF.SERVER.MASTER', + 'title' => __('No master servers found.'), + 'message' => __('At least one server must be defined to run as master. Please, check documentation.'), + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1643,10 +1676,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.SAFE_MODE', - 'title' => __('PHP safe mode is enabled. Some features may not work properly'), - 'message' => __('To disable it, go to your PHP configuration file (php.ini) and put safe_mode = Off (Do not forget to restart apache process after changes)'), - 'url' => $url, + 'type' => 'NOTIF.PHP.SAFE_MODE', + 'title' => __('PHP safe mode is enabled. Some features may not work properly'), + 'message' => __('To disable it, go to your PHP configuration file (php.ini) and put safe_mode = Off (Do not forget to restart apache process after changes)'), + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1661,16 +1695,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.INPUT_TIME', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.INPUT_TIME', + 'title' => sprintf( __('%s value in PHP configuration is not recommended'), 'max_input_time' ), - 'message' => sprintf( + 'message' => sprintf( __('Recommended value is %s'), '-1 ('.__('Unlimited').')' ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator (Do not forget to restart Apache process after)'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1685,16 +1720,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.EXECUTION_TIME', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.EXECUTION_TIME', + 'title' => sprintf( __("Not recommended '%s' value in PHP configuration"), 'max_execution_time' ), - 'message' => sprintf( + 'message' => 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)'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1709,16 +1745,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.UPLOAD_MAX_FILESIZE', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.UPLOAD_MAX_FILESIZE', + 'title' => sprintf( __("Not recommended '%s' value in PHP configuration"), 'upload_max_filesize' ), - 'message' => sprintf( + 'message' => 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)'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1738,16 +1775,17 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.MEMORY_LIMIT', - 'title' => sprintf( + 'type' => 'NOTIF.PHP.MEMORY_LIMIT', + 'title' => sprintf( __("Not recommended '%s' value in PHP configuration"), 'memory_limit' ), - 'message' => sprintf( + 'message' => sprintf( __('Recommended value is: %s'), sprintf(__('%s or greater'), $recommended_memory) ).'

'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_INFORMATION, ] ); } else { @@ -1762,10 +1800,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PHP.DISABLE_FUNCTIONS', - 'title' => __('Problems with disable_functions in php.ini'), - 'message' => __('The variable disable_functions contains 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' => $url, + 'type' => 'NOTIF.PHP.DISABLE_FUNCTIONS', + 'title' => __('Problems with disable_functions in php.ini'), + 'message' => __('The variable disable_functions contains 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' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1779,10 +1818,11 @@ class ConsoleSupervisor // } $this->notify( [ - 'type' => 'NOTIF.PHP.CHROMIUM', - 'title' => __('chromium is not installed'), - 'message' => __('To be able to create images of the graphs for PDFs, please install the chromium extension. For that, it is necessary to follow these steps:'), - 'url' => $url, + 'type' => 'NOTIF.PHP.CHROMIUM', + 'title' => __('chromium is not installed'), + 'message' => __('To be able to create images of the graphs for PDFs, please install the chromium extension. For that, it is necessary to follow these steps:'), + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1840,10 +1880,11 @@ class ConsoleSupervisor $url = 'https://www.php.net/supported-versions.php'; $this->notify( [ - 'type' => 'NOTIF.PHP.VERSION.SUPPORT', - 'title' => __('PHP UPDATE REQUIRED'), - 'message' => __('You should update your PHP version because it will be out of official support').'
'.__('Current PHP version: ').PHP_VERSION, - 'url' => $url, + 'type' => 'NOTIF.PHP.VERSION.SUPPORT', + 'title' => __('PHP UPDATE REQUIRED'), + 'message' => __('You should update your PHP version because it will be out of official support').'
'.__('Current PHP version: ').PHP_VERSION, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1866,10 +1907,11 @@ class ConsoleSupervisor $url = 'https://www.mysql.com/support/eol-notice.html'; $this->notify( [ - 'type' => 'NOTIF.MYSQL.VERSION', - 'title' => __('MYSQL UPDATE REQUIRED'), - 'message' => __('You should update your MYSQL version because it will be out of official support').'
'.__('Current MYSQL version: ').$mysql_version, - 'url' => $url, + 'type' => 'NOTIF.MYSQL.VERSION', + 'title' => __('MYSQL UPDATE REQUIRED'), + 'message' => __('You should update your MYSQL version because it will be out of official support').'
'.__('Current MYSQL version: ').$mysql_version, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -1908,10 +1950,11 @@ class ConsoleSupervisor if ($config['history_db_connection'] === false) { $this->notify( [ - 'type' => 'NOTIF.HISTORYDB', - 'title' => __('Historical database not available'), - 'message' => __('Historical database is enabled, though not accessible with the current configuration.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'type' => 'NOTIF.HISTORYDB', + 'title' => __('Historical database not available'), + 'message' => __('Historical database is enabled, though not accessible with the current configuration.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -1952,13 +1995,14 @@ class ConsoleSupervisor if ($last_maintance > 172800) { $this->notify( [ - 'type' => 'NOTIF.PANDORADB', - 'title' => __('Database maintenance problem'), - 'message' => __( + 'type' => 'NOTIF.PANDORADB', + 'title' => __('Database maintenance problem'), + 'message' => __( 'Your database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', io_safe_output(get_product_name()) ), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -2013,12 +2057,13 @@ class ConsoleSupervisor if ($last_maintance > 172800) { $this->notify( [ - 'type' => 'NOTIF.PANDORADB.HISTORY', - 'title' => __( + 'type' => 'NOTIF.PANDORADB.HISTORY', + 'title' => __( 'Historical database maintenance problem.' ), - 'message' => __('Your historical database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', get_product_name()), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'message' => __('Your historical database hasn\'t been through maintenance for 48hrs. Please, check documentation on how to perform this maintenance process on %s and enable it as soon as possible.', get_product_name()), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2054,10 +2099,11 @@ class ConsoleSupervisor if ($mrh_version != $config['MR']) { $this->notify( [ - 'type' => 'NOTIF.HISTORYDB.MR', - 'title' => __('Historical database MR mismatch'), - 'message' => __('Your historical database is not using the same schema as the main DB. This could produce anomalies while storing historical data.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'type' => 'NOTIF.HISTORYDB.MR', + 'title' => __('Historical database MR mismatch'), + 'message' => __('Your historical database is not using the same schema as the main DB. This could produce anomalies while storing historical data.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=hist_db', + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -2095,10 +2141,11 @@ class ConsoleSupervisor if ($elasticsearch === false) { $this->notify( [ - 'type' => 'NOTIF.EXT.ELASTICSEARCH', - 'title' => __('Log collector cannot connect to OpenSearch'), - 'message' => __('OpenSearch is not available using current configuration.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=log', + 'type' => 'NOTIF.EXT.ELASTICSEARCH', + 'title' => __('Log collector cannot connect to OpenSearch'), + 'message' => __('OpenSearch is not available using current configuration.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=log', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2165,10 +2212,11 @@ class ConsoleSupervisor } else { $this->notify( [ - 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', - 'title' => __('Metaconsole DB is not available.'), - 'message' => __('Cannot connect with Metaconsole DB using current configuration.'), - 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise', + 'type' => 'NOTIF.METACONSOLE.DB_CONNECTION', + 'title' => __('Metaconsole DB is not available.'), + 'message' => __('Cannot connect with Metaconsole DB using current configuration.'), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=enterprise', + 'icon_notification' => self::ICON_ERROR, ] ); } @@ -2384,10 +2432,11 @@ class ConsoleSupervisor if (update_manager_verify_registration() === false) { $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', - 'title' => __('This instance is not registered in the Warp Update section'), - 'message' => __('Click here to start the registration process'), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', + 'title' => __('This instance is not registered in the Warp Update section'), + 'message' => __('Click here to start the registration process'), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -2414,9 +2463,10 @@ class ConsoleSupervisor if (update_manager_verify_api() === false) { $this->notify( [ - 'type' => 'NOTIF.API.ACCESS', - 'title' => __('Cannot access the Pandora FMS API '), - 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'), + 'type' => 'NOTIF.API.ACCESS', + 'title' => __('Cannot access the Pandora FMS API '), + 'message' => __('Please check the configuration, some components may fail due to this misconfiguration in '.$server_name.' ('.$config['public_url'].')'), + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2447,10 +2497,11 @@ class ConsoleSupervisor 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 since it is a commonly reported vulnerability.'), - 'url' => '__url__/index.php?sec=gusuarios&sec2=godmode/users/user_list', + 'type' => 'NOTIF.SECURITY.DEFAULT_PASSWORD', + 'title' => __('Default password for "Admin" user has not been changed'), + 'message' => __('Please, change the default password since it is a commonly reported vulnerability.'), + 'url' => '__url__/index.php?sec=gusuarios&sec2=godmode/users/user_list', + 'icon_notification' => self::ICON_HEADSUP, ] ); } else { @@ -2562,10 +2613,11 @@ class ConsoleSupervisor foreach ($_SESSION['return_installation_open']['text'] as $message) { $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', - 'title' => __('Failed to retrieve updates, please configure utility'), - 'message' => $message, - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', + 'type' => 'NOTIF.UPDATEMANAGER.OPENSETUP', + 'title' => __('Failed to retrieve updates, please configure utility'), + 'message' => $message, + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=general', + 'icon_notification' => self::ICON_ERROR, ] ); } @@ -2579,13 +2631,14 @@ class ConsoleSupervisor if ($_SESSION['new_update'] == 'new') { $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.UPDATE', - 'title' => __( + 'type' => 'NOTIF.UPDATEMANAGER.UPDATE', + 'title' => __( 'New %s Console update', get_product_name() ), - 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), - 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online', + 'message' => __('There is a new update available. Please go to Administration:Setup:Update Manager for more details.'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_CONGRATS, ] ); } else { @@ -2617,13 +2670,14 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.UPDATEMANAGER.MINOR', - 'title' => __('Minor release/s available'), - 'message' => __( + 'type' => 'NOTIF.UPDATEMANAGER.MINOR', + 'title' => __('Minor release/s available'), + 'message' => __( 'There is one or more minor releases available. .About minor release update.', $url ), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_CONGRATS, ] ); } else { @@ -2680,10 +2734,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.CRON.CONFIGURED', - 'title' => __('DiscoveryConsoleTasks is not configured.'), - 'message' => __($message_conf_cron), - 'url' => $url, + 'type' => 'NOTIF.CRON.CONFIGURED', + 'title' => __('DiscoveryConsoleTasks is not configured.'), + 'message' => __($message_conf_cron), + 'url' => $url, + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -2782,10 +2837,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SERVER.MISALIGNED', - 'title' => __($title_ver_misaligned), - 'message' => __($message_ver_misaligned), - 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'type' => 'NOTIF.SERVER.MISALIGNED', + 'title' => __($title_ver_misaligned), + 'message' => __($message_ver_misaligned), + 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', + 'icon_notification' => self::ICON_HEADSUP, ] ); @@ -2838,10 +2894,11 @@ class ConsoleSupervisor $is_none = true; $this->notify( [ - 'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE', - 'title' => __('AllowOverride is disabled'), - 'message' => __($message), - 'url' => '__url__/index.php', + 'type' => 'NOTIF.ALLOWOVERRIDE.MESSAGE', + 'title' => __('AllowOverride is disabled'), + 'message' => __($message), + 'url' => '__url__/index.php', + 'icon_notification' => self::ICON_HEADSUP, ] ); } @@ -2884,10 +2941,11 @@ class ConsoleSupervisor if ((int) $db_master !== (int) $cluster_master) { $this->notify( [ - 'type' => 'NOTIF.HAMASTER.MESSAGE', - 'title' => __('Desynchronized operation on the node '.$node['host']), - 'message' => __($message), - 'url' => '__url__/index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster', + 'type' => 'NOTIF.HAMASTER.MESSAGE', + 'title' => __('Desynchronized operation on the node '.$node['host']), + 'message' => __($message), + 'url' => '__url__/index.php?sec=gservers&sec2=enterprise/godmode/servers/HA_cluster', + 'icon_notification' => self::ICON_ERROR, ] ); } else { @@ -2924,10 +2982,11 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.PANDORACONSOLE.LOG.OLD', - 'title' => __($title_pandoraconsole_old_log), - 'message' => __($message_pandoraconsole_old_log), - 'url' => $url, + 'type' => 'NOTIF.PANDORACONSOLE.LOG.OLD', + 'title' => __($title_pandoraconsole_old_log), + 'message' => __($message_pandoraconsole_old_log), + 'url' => $url, + 'icon_notification' => self::ICON_QUESTION, ] ); } else { @@ -3008,15 +3067,16 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SYNCQUEUE.LENGTH.'.$node_id, - 'title' => __('Node %s sync queue length exceeded, ', $node->server_name()), - 'message' => __( + 'type' => 'NOTIF.SYNCQUEUE.LENGTH.'.$node_id, + 'title' => __('Node %s sync queue length exceeded, ', $node->server_name()), + 'message' => __( 'Synchronization queue lenght for node %s is %d items, this value should be 0 or lower than %d, please check the queue status.', $node->server_name(), $count, $items_min ), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_HEADSUP, ] ); } catch (\Exception $e) { @@ -3063,14 +3123,15 @@ class ConsoleSupervisor $this->notify( [ - 'type' => 'NOTIF.SYNCQUEUE.STATUS.'.$node_id, - 'title' => __('Node %s sync queue failed, ', $node->server_name()), - 'message' => __( + 'type' => 'NOTIF.SYNCQUEUE.STATUS.'.$node_id, + 'title' => __('Node %s sync queue failed, ', $node->server_name()), + 'message' => __( 'Node %s cannot process synchronization queue due %s, please check the queue status.', $node->server_name(), $item->error() ), - 'url' => $url, + 'url' => $url, + 'icon_notification' => self::ICON_ERROR, ] ); } catch (\Exception $e) { @@ -3096,13 +3157,14 @@ class ConsoleSupervisor if ($error_dependecies > 0) { $this->notify( [ - 'type' => 'NOTIF.AGENT.LIBRARY', - 'title' => __('Agent dependency error'), - 'message' => __( + 'type' => 'NOTIF.AGENT.LIBRARY', + 'title' => __('Agent dependency error'), + 'message' => __( 'There are omnishell agents with dependency errors', ), - 'url' => '__url__/index.php?sec=gextensions&sec2=enterprise/tools/omnishell', + 'url' => '__url__/index.php?sec=gextensions&sec2=enterprise/tools/omnishell', + 'icon_notification' => self::ICON_ERROR, ] ); } diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index 99b4f5b039..ed515dee87 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -995,6 +995,11 @@ class Tree } } } + + // Quiet name on agent. + if (isset($agent['quiet']) && $agent['quiet']) { + $agent['alias'] .= ' '.__('(Quiet)'); + } } diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index d9022d917c..68a52be97d 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 = 'PC240118'; +$build_version = 'PC240122'; $pandora_version = 'v7.0NG.775'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 7417a48125..974a6ff9de 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -2016,7 +2016,7 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false, } returnError('No agent alias specified'); - } else if (agents_get_agent_id($nombre_agente)) { + } else if (agents_get_agent_id($agent->nombre())) { if ($message === true) { return 'The agent name already exists in DB.'; } @@ -2064,7 +2064,7 @@ function api_set_new_agent($id_node, $thrash2, $other, $trhash3, $return=false, } } - if ($return === false) { + if ($return !== true) { returnData( 'string', [ diff --git a/pandora_console/include/functions_cron_task.php b/pandora_console/include/functions_cron_task.php index 40a6e159cc..042d79dad7 100644 --- a/pandora_console/include/functions_cron_task.php +++ b/pandora_console/include/functions_cron_task.php @@ -383,6 +383,13 @@ function cron_task_run( $nameday = strtolower($datetime->format('l')); } } + } else if (empty($old_args['first_execution']) === false) { + $datetime = new DateTime(); + $datetime->setTimestamp($old_args['first_execution']); + $datetime->modify('+7 day'); + $weekly_date = $datetime->format('Y-m-d'); + $weekly_time = $datetime->format('H:i:s'); + $old_args['first_execution'] = strtotime($weekly_date.' '.$weekly_time); } } else { // Add it to next execution. diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 2c378cdb10..61330b66f7 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -27,6 +27,7 @@ */ require_once $config['homedir'].'/include/functions_messages.php'; +require_once __DIR__.'/class/ConsoleSupervisor.php'; define('NOTIFICATIONS_POSTPONE_FOREVER', -1); @@ -1265,6 +1266,12 @@ function notifications_print_dropdown_element($message_info) $body_preview .= __('. Read More...'); } + $icon_notification = ConsoleSupervisor::ICON_INFORMATION; + + if (isset($message_info['icon_notification']) === true && empty($message_info['icon_notification']) === false) { + $icon_notification = $message_info['icon_notification']; + } + return sprintf( " 'height: 40px;margin-left: -20px;margin-top: -40px;']), + html_print_image($icon_notification, true, ['style' => 'height: 56px; padding: 0px;']), io_safe_output($message_info['subject']), $body_preview ); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 3ea3e8a740..d6078c56a7 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -96,7 +96,8 @@ function ui_print_truncate_text( $showTextInTitle=true, $suffix='…', $style=false, - $forced_title=false + $forced_title=false, + $text_title='' ) { global $config; $truncate_at_end = false; @@ -211,7 +212,11 @@ function ui_print_truncate_text( } if ($forced_title === true) { - $truncateText = ''.$truncateText.''; + } else { + $truncateText = ''.$truncateText.''; + } } if ($return == true) { diff --git a/pandora_console/include/javascript/graph_analytics.js b/pandora_console/include/javascript/graph_analytics.js index 6c14f3f8c8..475a310ebc 100644 --- a/pandora_console/include/javascript/graph_analytics.js +++ b/pandora_console/include/javascript/graph_analytics.js @@ -1,3 +1,4 @@ +/* global $ */ // Droppable options. var droppableOptions = { accept: ".draggable", @@ -422,12 +423,38 @@ $("[data-button=new]").click(function(e) { }); }); +function updateSelect(element, fields, selected) { + if (typeof fields === "object") { + $(element) + .find("select option[value!=0]") + .remove(); + $(element) + .find(".select2-container .select2-selection__rendered") + .empty(); + Object.keys(fields).forEach(function(key) { + if (key === selected) { + $(element) + .find(".select2-container .select2-selection__rendered") + .append(`${fields[key]}`); + $(element) + .find("select") + .append(``); + } else { + $(element) + .find("select") + .append(``); + } + }); + } +} + // Save graps modal. $("[data-button=save]").click(function(e) { // Filter save mode selector $("#save_filter_row1").show(); $("#save_filter_row2").show(); $("#update_filter_row1").hide(); + $("#delete_filter_row2").hide(); $("#radiobtn0002").prop("checked", false); $("#radiobtn0001").prop("checked", true); $("#text-id_name").val(""); @@ -438,20 +465,43 @@ $("[data-button=save]").click(function(e) { $("#save_filter_row2").show(); $("#submit-save_filter").show(); $("#update_filter_row1").hide(); - } else { + $("#delete_filter_row2").hide(); + } else if ($(this).val() == "update") { $("#save_filter_row1").hide(); $("#save_filter_row2").hide(); $("#update_filter_row1").show(); $("#submit-save_filter").hide(); + $("#delete_filter_row2").hide(); + } else { + $("#save_filter_row1").hide(); + $("#save_filter_row2").hide(); + $("#update_filter_row1").hide(); + $("#submit-save_filter").hide(); + $("#delete_filter_row2").show(); } }); - $("#save-filter-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: 350 + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#save_filter_form", data, 0); + $("#save-filter-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: 350, + title: titleModalActions + }); + } + } }); }); @@ -535,14 +585,67 @@ function save_update_filter() { }); } +// Delete filter. +function delete_filter() { + confirmDialog({ + title: titleDelete, + message: messageDelete, + onAccept: function() { + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "html", + data: { + page: "operation/reporting/graph_analytics", + delete_filter: $("#delete_filter").val() + }, + success: function(data) { + if (data == "deleted") { + confirmDialog({ + title: titleDeleteConfirm, + message: messageDeleteConfirm, + hideCancelButton: true, + onAccept: function() { + $( + "button.ui-button.ui-corner-all.ui-widget.ui-button-icon-only.ui-dialog-titlebar-close" + ).click(); + } + }); + } else { + confirmDialog({ + title: titleDeleteError, + message: messageDeleteError, + hideCancelButton: true + }); + } + } + }); + } + }); +} + // Load graps modal. $("[data-button=load]").click(function(e) { - $("#load-filter-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: "auto" + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#load_filter_form", data, 0); + $("#load-filter-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto" + }); + } + } }); }); @@ -618,12 +721,26 @@ function loadFilter(url, filterId, homeurl, id) { // Share button. $("[data-button=share]").click(function(e) { - $("#share-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: "auto" + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#share_form-0-0", data, 0); + $("#share-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto" + }); + } + } }); }); @@ -643,13 +760,27 @@ $("#button-share-modal").click(function(e) { // Export button. $("[data-button=export]").click(function(e) { - $("#export-select").dialog({ - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - width: "auto", - title: titleExport + $.ajax({ + method: "POST", + url: "ajax.php", + dataType: "json", + data: { + page: "operation/reporting/graph_analytics", + load_list_filters: 1 + }, + success: function(data) { + if (data) { + updateSelect("#export_form-0-0", data, 0); + $("#export-select").dialog({ + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + width: "auto", + title: titleExport + }); + } + } }); }); @@ -669,10 +800,10 @@ function exportCustomGraph() { group }, success: function(data) { - if (data) { + if (data === "created") { confirmDialog({ title: titleExportConfirm, - message: data + " " + messageExportConfirm, + message: messageExportConfirm, hideCancelButton: true, onAccept: function() { $( diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index 5d81b7e9a4..3f3ba0e448 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -966,6 +966,11 @@ function processTreeSearch(settings) { recipient: $("div#tree-controller-recipient_" + settings.cellId), detailRecipient: { render: function(element, data) { + let title = "Module information"; + if ($(data).find("#tree_view_agent_detail-name").length > 0) { + title = "Agent information"; + } + return { open: function() { $("#module_details_window") @@ -976,7 +981,7 @@ function processTreeSearch(settings) { resizable: true, draggable: true, modal: true, - title: "Info module", + title: title, overlay: { opacity: 0.5, background: "black" diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index fe807833b7..936c4a0cfb 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1783,3 +1783,49 @@ function openEvents(severity) { $('input[name="filter[severity]"]').val(severity); $("#event_redirect").submit(); } + +// Load Asteroids game. +$(window).on("load", function() { + let counter = 0; + $("#button-sound_events_button") + .off("click") + .on("click", function(e) { + counter++; + let flagEasternEgg = $("#flagEasternEgg").val(); + if (counter == 12 && flagEasternEgg == true) { + $("#modal-asteroids") + .dialog({ + title: "Asteroids", + resizable: true, + modal: true, + width: 900, + height: 700, + open: function() { + $.ajax({ + method: "post", + url: getUrlAjax(), + data: { + page: "include/ajax/events", + playAsteroids: 1 + }, + dataType: "html", + success: function(data) { + $("#modal-asteroids").html(data); + $(".ui-widget-content").css("background", "#222"); + $(".ui-dialog-title").css("color", "#fff"); + }, + error: function(error) { + console.error(error); + } + }); + }, + close: function() { + counter = 0; + $(".ui-widget-content").css("background", "#fff"); + $(".ui-dialog-title").css("color", "rgb(51, 51, 51)"); + } + }) + .show(); + } + }); +}); diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index 4e2f73db28..b4445e0877 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -160,6 +160,7 @@ function configure_modules_form() { } $("#id_module_group").val(data["id_module_group"]); + $("#id_module_group").trigger("change"); if (data["history_data"]) $("#checkbox-history_data").check(); else $("#checkbox-history_data").uncheck(); diff --git a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php index 0e9612cd29..9f7d726677 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php +++ b/pandora_console/include/lib/Dashboard/Widgets/security_hardening.php @@ -252,7 +252,7 @@ class SecurityHardening extends Widget ]; $inputs[] = [ - 'label' => __('Ingore skipped'), + 'label' => __('Ignore skipped'), 'id' => 'row_ignore_skipped', 'class' => 'row_input', 'arguments' => [ diff --git a/pandora_console/include/lib/TacticalView/elements/Groups.php b/pandora_console/include/lib/TacticalView/elements/Groups.php index c314381b59..facaf0002c 100644 --- a/pandora_console/include/lib/TacticalView/elements/Groups.php +++ b/pandora_console/include/lib/TacticalView/elements/Groups.php @@ -485,7 +485,7 @@ class Groups extends Element $y = 0; $cont = 1; foreach ($groups as $key => $value) { - if ($value['_name_'] === 'All') { + if ($value['_name_'] === __('All')) { continue; } diff --git a/pandora_console/include/styles/asteroids.css b/pandora_console/include/styles/asteroids.css new file mode 100644 index 0000000000..8b434b59ba --- /dev/null +++ b/pandora_console/include/styles/asteroids.css @@ -0,0 +1,65 @@ +/** + * + * Name: Default theme + * Pandora Stylesheet + * + * @category Stylesheet + * @package Pandora FMS + * @subpackage Community + * @version 1.0.0 + * @license See below + * + * ______ ___ _______ _______ ________ + * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| + * | __/| _ | | _ || _ | _| _ | | ___| |__ | + * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| + * + * ============================================================================ + * Copyright (c) 2005-2023 Pandora FMS + * Please see https://pandorafms.com 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. + * ============================================================================ + */ + +div#asteroids { + background-color: #000; + color: #fff; + margin: 50px auto; + width: 640px; + border: 1px solid #fff; + padding: 5px; +} + +div#asteroids > * { + color: #fff; +} + +div#asteroids > div { + font-family: "System", monospace; + font-size: 11px; + padding-bottom: 5px; +} + +div#asteroids > div > span { + float: right; + padding-left: 20px; +} + +div#instructions { + width: 640px; + margin: 20px auto; +} + +h1 { + font-size: 18px; +} + +h2 { + font-size: 16px; +} diff --git a/pandora_console/include/styles/events.css b/pandora_console/include/styles/events.css index 825e35903e..9a69ea8c56 100644 --- a/pandora_console/include/styles/events.css +++ b/pandora_console/include/styles/events.css @@ -129,6 +129,12 @@ table#table_events > tbody > tr > td.column-estado { padding: 0px !important; text-align: center; } +@-moz-document url-prefix() { + table#table_events > tbody > tr, + table#table_events > tbody > tr > td { + height: 100%; + } +} .sorting_desc { background: url(../../images/sort_down_green.png) no-repeat; background-position-x: left; diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 94c8718b6a..fec8feef43 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -994,6 +994,12 @@ select:-internal-list-box { justify-content: flex-start !important; } +.flex-column-start { + display: flex; + flex-direction: column; + align-items: flex-start; +} + .padding-2 { padding: 2em; } @@ -4986,7 +4992,7 @@ div#dialog_messages table th:last-child { } .notification-item > * { - padding-left: 15px; + padding-left: 7px; pointer-events: none; } @@ -5012,6 +5018,10 @@ div#dialog_messages table th:last-child { margin: 0; } +.notification-subtitle { + margin-top: 2px; +} + .notification-subtitle, .color-black-grey { color: #373737; @@ -5539,6 +5549,11 @@ input:checked + .p-slider:before { color: #4d4d4d; } +.show-profiles { + position: absolute; + margin-left: 15%; +} + /* Tables to upload files */ #table_filemanager tr:first-child th span { font-weight: bold; @@ -7065,6 +7080,10 @@ div.graph div.legend table { margin: 0 1em 0 2em; } +.mrgn_top_btn_10px_imp { + margin: 10px 0 10px 0 !important; +} + /* * MARGIN LEFT */ @@ -7226,6 +7245,10 @@ div.graph div.legend table { margin-top: 0px; } +.mrgn_top_mod_0px { + margin-top: 0px !important; +} + .mrgn_top_5px { margin-top: 5px; } @@ -11852,7 +11875,7 @@ p.trademark-copyright { } .show-hide-pass { - position: fixed; + position: absolute; border: 0; outline: none; margin-left: -50px; diff --git a/pandora_console/install.php b/pandora_console/install.php index 91de00f8a8..a5765f9bb2 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -130,8 +130,8 @@
event_title = $output_event_name; $tmp->b64 = base64_encode(json_encode($tmp)); $tmp->evento = $output_event_name; + $tmp->event_force_title = (strlen($output_event_name) >= 300) ? substr($output_event_name, 0, 300).'...' : $output_event_name; if (empty($tmp->module_name) === false) { $tmp->module_name = ui_print_truncate_text( @@ -641,32 +642,17 @@ if (is_ajax() === true) { } if (empty($user_timezone) === true) { - if (date_default_timezone_get() !== $config['timezone']) { - $timezone = timezone_open(date_default_timezone_get()); - $datetime_eur = date_create('now', timezone_open($config['timezone'])); - $dif = timezone_offset_get($timezone, $datetime_eur); - date($config['date_format'], $dif); - if (!date('I')) { - // For summer -3600sec. - $dif -= 3600; - } - - $total_sec = strtotime($tmp->timestamp); - $total_sec += $dif; - $last_contact = date($config['date_format'], $total_sec); - $last_contact_value = ui_print_timestamp($last_contact, true, $options); - } else { - $title = date($config['date_format'], strtotime($tmp->timestamp)); - $value = ui_print_timestamp(strtotime($tmp->timestamp), true, $options); - $last_contact_value = ''.$value.''; + $user_timezone = $config['timezone']; + if (empty($user_timezone) === true) { + $user_timezone = date_default_timezone_get(); } - } else { - date_default_timezone_set($user_timezone); - $title = date($config['date_format'], strtotime($tmp->timestamp)); - $value = ui_print_timestamp(strtotime($tmp->timestamp), true, $options); - $last_contact_value = ''.$value.''; } + date_default_timezone_set($user_timezone); + $title = date($config['date_format'], $tmp->utimestamp); + $value = ui_print_timestamp($tmp->utimestamp, true, $options); + $last_contact_value = ''.$value.''; + $tmp->timestamp = $last_contact_value; if (is_numeric($tmp->data) === true) { @@ -783,6 +769,7 @@ if (is_ajax() === true) { '…', true, true, + $tmp->event_force_title ); $evn .= $tmp->evento.''; diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index f0777a61f1..89101f5b64 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -603,6 +603,7 @@ if ($access_console_node === true) { $sub[$javascript]['type'] = 'direct'; echo ''; + echo ''; ui_require_javascript_file('pandora_events'); diff --git a/pandora_console/operation/reporting/graph_analytics.php b/pandora_console/operation/reporting/graph_analytics.php index 8797376070..ff6272bdd6 100644 --- a/pandora_console/operation/reporting/graph_analytics.php +++ b/pandora_console/operation/reporting/graph_analytics.php @@ -45,8 +45,10 @@ if (is_ajax()) { $save_filter = get_parameter('save_filter'); $load_filter = get_parameter('load_filter'); $update_filter = get_parameter('update_filter'); + $delete_filter = get_parameter('delete_filter'); $get_new_values = get_parameter('get_new_values'); $export_filter = get_parameter('export_filter'); + $load_list_filters = get_parameter('load_list_filters'); if (empty($search_left) === false) { $output = []; @@ -289,6 +291,11 @@ if (is_ajax()) { return; } + if (empty($delete_filter) === false) { + $result = db_process_sql_delete('tgraph_analytics_filter', ['id' => $delete_filter]); + echo ((bool) $result === true) ? 'deleted' : ''; + } + // Get new values. if (empty($get_new_values) === false) { $data = []; @@ -322,19 +329,19 @@ if (is_ajax()) { $graphs = json_decode(db_get_value('graph_modules', 'tgraph_analytics_filter', 'id', $filter)); $interval = db_get_value('tgraph_analytics_filter.interval', 'tgraph_analytics_filter', 'id', $filter); - foreach ($graphs as $graph) { - $id_graph = db_process_sql_insert( - 'tgraph', - [ - 'id_user' => $config['id_user'], - 'id_group' => $group, - 'name' => $filter_name.' ('.__('Graph').' '.($counter + 1).')', - 'description' => __('Created from Graph analytics. Filter:').' '.$filter_name.'. '.__('Graph').' '.($counter + 1), - 'period' => $interval, - 'stacked' => 2, - ] - ); + $id_graph = db_process_sql_insert( + 'tgraph', + [ + 'id_user' => $config['id_user'], + 'id_group' => $group, + 'name' => $filter_name.' ('.__('Graph').') ', + 'description' => __('Created from Graph analytics. Filter:').' '.$filter_name.'. '.__('Graph'), + 'period' => $interval, + 'stacked' => 2, + ] + ); + foreach ($graphs as $graph) { if ($id_graph > 0) { $counter++; $field_order = 1; @@ -357,7 +364,16 @@ if (is_ajax()) { } } - echo $counter; + if ($id_graph > 0) { + echo 'created'; + } else { + echo ''; + } + } + + if (empty($load_list_filters) === false) { + $filters = graph_analytics_filter_select(); + echo json_encode($filters); } return; @@ -384,7 +400,7 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'] 'content' => html_print_radio_button( 'filter_mode', 'new', - __('New filter'), + __('Create'), true, true ), @@ -398,7 +414,21 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'] 'content' => html_print_radio_button( 'filter_mode', 'update', - __('Update filter'), + __('Update'), + false, + true + ), + ], + true + ); + + $data[2] = html_print_div( + [ + 'style' => 'display: flex;', + 'content' => html_print_radio_button( + 'filter_mode', + 'delete', + __('Delete'), false, true ), @@ -466,7 +496,37 @@ if (check_acl($config['id_user'], 0, 'RW') === 1 || check_acl($config['id_user'] ); $table->data[] = $data; - $table->rowclass[] = ''; + $table->rowclass[] = 'display-grid'; + + $data = []; + $table->rowid[4] = 'delete_filter_row2'; + $data[0] = __('Delete filter'); + + $select_filters_delete = graph_analytics_filter_select(); + + $data[0] .= html_print_select( + $select_filters_delete, + 'delete_filter', + '', + '', + '', + 0, + true + ); + $data[1] = html_print_submit_button( + __('Delete filter'), + 'delete_filter', + false, + [ + 'class' => 'mini ', + 'icon' => 'delete', + 'style' => 'margin-left: 155px; width: 145px;', + 'onclick' => 'delete_filter();', + ], + true + ); + + $table->data[] = $data; html_print_table($table); } else { @@ -583,7 +643,7 @@ echo '
'; echo '
+ '.__('Agents').'
'.ui_toggle( - '', - __('Agents'), - 'agents-toggle', - 'agents-toggle', - true, - true, - '', - 'white-box-content', - 'box-flat white_table_graph', - 'images/arrow@svg.svg', - 'images/arrow@svg.svg', - false, - false, - false, - '', - '', - null, - null, - false, - false, - 'static' + '', + __('Agents'), + 'agents-toggle', + 'agents-toggle', + true, + true, + '', + 'white-box-content', + 'box-flat white_table_graph', + 'images/arrow@svg.svg', + 'images/arrow@svg.svg', + false, + false, + false, + '', + '', + null, + null, + false, + false, + 'static' ).ui_toggle( '', __('Groups'), @@ -842,6 +903,7 @@ $left_content .= ' ).'
+ '.__('Modules').' @@ -920,6 +982,15 @@ const titleError = ""; const titleUpdate = ""; const messageUpdate = ""; +const titleDelete = ""; +const messageDelete = ""; + +const titleDeleteConfirm = ""; +const messageDeleteConfirm = ""; + +const titleDeleteError = ""; +const messageDeleteError = ""; + const titleUpdateConfirm = ""; const messageUpdateConfirm = ""; @@ -935,7 +1006,7 @@ const messageLoadConfirm = ""; const titleExport = ""; const titleExportConfirm = ""; -const messageExportConfirm = ""; +const messageExportConfirm = ""; const titleExportError = ""; const messageExportError = ""; @@ -943,4 +1014,6 @@ const messageExportError = ""; const titleRemoveConfirm = ""; const messageRemoveConfirm = ""; +const titleModalActions = "" + \ No newline at end of file diff --git a/pandora_console/operation/search_agents.getdata.php b/pandora_console/operation/search_agents.getdata.php index 0284f8e738..7e6128edf5 100644 --- a/pandora_console/operation/search_agents.getdata.php +++ b/pandora_console/operation/search_agents.getdata.php @@ -170,12 +170,26 @@ if ($searchAgents) { } foreach ($agents as $key => $agent) { + $agent_quiet = ''; + if ((bool) $agent['quiet'] === true) { + $agent_quiet = html_print_image( + 'images/dot_blue.png', + true, + [ + 'border' => '0', + 'title' => __('Quiet'), + 'alt' => '', + 'class' => 'mrgn_lft_5px', + ] + ); + } + if ($agent['disabled']) { $agents[$key]['agent'] = ''.ucfirst(strtolower($agent['alias'])).''.ui_print_help_tip(__('Disabled'), true).''; + title="'.$agent['id_agente'].'">'.ucfirst(strtolower($agent['alias'])).''.ui_print_help_tip(__('Disabled'), true).''.$agent_quiet; } else { $agents[$key]['agent'] = ''.ucfirst(strtolower($agent['alias'])).''; + title='.$agent['nombre'].'>'.ucfirst(strtolower($agent['alias'])).''.$agent_quiet; } $agents[$key]['os'] = ui_print_os_icon($agent['id_os'], false, true); diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 8c989f488b..b8cb1c4e8e 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -6,7 +6,7 @@ %define debug_package %{nil} %define name pandorafms_console %define version 7.0NG.775 -%define release 240118 +%define release 240122 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 3fb2a1d420..9d073814b5 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -6,7 +6,7 @@ %define debug_package %{nil} %define name pandorafms_console %define version 7.0NG.775 -%define release 240118 +%define release 240122 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 87f868971d..059e4d94ef 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.775 -%define release 240118 +%define release 240122 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 792ca2770c..0c2f58120c 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1395,6 +1395,7 @@ CREATE TABLE IF NOT EXISTS `tmensajes` ( `subject` VARCHAR(255) NOT NULL DEFAULT '', `estado` INT UNSIGNED NOT NULL DEFAULT 0, `url` TEXT, + `icon_notification` VARCHAR(250) DEFAULT NULL, `response_mode` VARCHAR(200) DEFAULT NULL, `citicity` INT UNSIGNED DEFAULT 0, `id_source` BIGINT UNSIGNED NOT NULL, diff --git a/pandora_console/views/dashboard/list.php b/pandora_console/views/dashboard/list.php index aae6778f6d..aaf675e64a 100644 --- a/pandora_console/views/dashboard/list.php +++ b/pandora_console/views/dashboard/list.php @@ -112,7 +112,11 @@ if (empty($dashboards) === true) { 'manageDashboards' => $manageDashboards, ], 'default_pagination' => $config['block_size'], - 'no_sortable_columns' => [], + 'no_sortable_columns' => [ + 4, + 5, + 6, + ], 'order' => [ 'field' => 'name', 'direction' => 'desc', diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index dd3fcfa9ed..c4ab00d63c 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.775-240118 +Version: 7.0NG.775-240122 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index ba528a83e1..72d2ed0de6 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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.775-240118" +pandora_version="7.0NG.775-240122" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 1afb7d6544..6802cf94ca 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -46,7 +46,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.775"; -my $pandora_build = "240118"; +my $pandora_build = "240122"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index af5feb583d..ccd9d8f7dd 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.775"; -my $pandora_build = "240118"; +my $pandora_build = "240122"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index b41ea2d0a3..c74934e734 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -7,7 +7,7 @@ %define debug_package %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240118 +%define release 240122 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 9a4ede27c7..dc859972e9 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -4,7 +4,7 @@ %global __os_install_post %{nil} %define name pandorafms_server %define version 7.0NG.775 -%define release 240118 +%define release 240122 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index b3d52e02f6..18312cc95f 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.775" -PI_BUILD="240118" +PI_BUILD="240122" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 40cf3b54be..9c9ad0d5a0 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -38,7 +38,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.775 Build 240118"; +my $version = "7.0NG.775 Build 240122"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 9f5877ca23..63b39f7771 100755 --- 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.775 Build 240118"; +my $version = "7.0NG.775 Build 240122"; # save program name for logging my $progname = basename($0); @@ -264,7 +264,7 @@ sub help_screen{ ######################################################################## # ######################################################################## -sub api_call($$$;$$$$) { +sub manage_api_call($$$;$$$$) { my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_; my $content = undef; @@ -400,7 +400,7 @@ sub pandora_disable_group ($$$) { foreach my $id_agent (@agents_bd) { # Call the API. - $result += api_call( + $result += manage_api_call( $conf, 'set', 'disabled_and_standby', $id_agent->{'id_agente'}, $server, '1|1' ); } @@ -2261,7 +2261,7 @@ sub cli_module_group_synch() { if ($return_type eq '') { $return_type = 'csv'; } - my $result = api_call(\%conf,'set', 'module_group_synch', undef, undef, "$other", $return_type); + my $result = manage_api_call(\%conf,'set', 'module_group_synch', undef, undef, "$other", $return_type); print "$result \n\n "; } @@ -2329,7 +2329,7 @@ sub cli_create_network_component() { my $other2 = join('|', @todo2); # Call the API. - my $result = api_call( $conf, 'set', 'new_network_component', $c_name, undef, "$c_type|$other|$c_group|$other2"); + my $result = manage_api_call( $conf, 'set', 'new_network_component', $c_name, undef, "$c_type|$other|$c_group|$other2"); print "$result \n\n "; } @@ -4337,7 +4337,7 @@ sub cli_get_alert_actions() { if ($return_type eq '') { $return_type = 'csv'; } - my $result = api_call(\%conf,'get', 'alert_actions', undef, undef, "$action_name|$separator",$return_type); + my $result = manage_api_call(\%conf,'get', 'alert_actions', undef, undef, "$action_name|$separator",$return_type); print "$result \n\n "; } @@ -4352,7 +4352,7 @@ sub cli_get_alert_actions_meta() { $return_type = 'csv'; } - my $result = api_call(\%conf,'get', 'alert_actions_meta', undef, undef, "$server_name|$action_name|$separator",$return_type); + my $result = manage_api_call(\%conf,'get', 'alert_actions_meta', undef, undef, "$server_name|$action_name|$separator",$return_type); print "$result \n\n "; } @@ -4574,7 +4574,7 @@ sub cli_create_event() { sub cli_update_event_custom_id() { my ($id_event, $event_custom_id) = @ARGV[2..3]; - my $result = api_call(\%conf, 'set', 'event_custom_id', $id_event, $event_custom_id); + my $result = manage_api_call(\%conf, 'set', 'event_custom_id', $id_event, $event_custom_id); print "\n$result\n"; } @@ -4866,7 +4866,7 @@ sub cli_apply_policy() { my ($id_policy, $id_agent, $name, $id_server) = @ARGV[2..5]; # Call the API. - my $result = api_call(\%conf, 'set', 'apply_policy', $id_policy, $id_agent, "$name|$id_server"); + my $result = manage_api_call(\%conf, 'set', 'apply_policy', $id_policy, $id_agent, "$name|$id_server"); print "\n$result\n"; } @@ -6039,7 +6039,7 @@ sub cli_policy_add_agent() { sub cli_policy_delete_agent() { my ($policy_id, $agent_id) = @ARGV[2..3]; - my $result = api_call(\%conf,'set', 'remove_agent_from_policy', $policy_id, $agent_id); + my $result = manage_api_call(\%conf,'set', 'remove_agent_from_policy', $policy_id, $agent_id); print "$result \n\n "; } @@ -6049,7 +6049,7 @@ sub cli_create_planned_downtime() { my @todo = @ARGV[3..21]; my $other = join('|', @todo); - my $result = api_call(\%conf,'set', 'planned_downtimes_created', $name, undef, "$other"); + my $result = manage_api_call(\%conf,'set', 'planned_downtimes_created', $name, undef, "$other"); print "$result \n\n "; } @@ -6063,7 +6063,7 @@ sub cli_add_item_planned_downtime() { my $other_modules = join(';', @modules); my $other = $other_agents . "|" . $other_modules; - my $result = api_call(\%conf,'set', 'planned_downtimes_additem', $id, undef, "$other"); + my $result = manage_api_call(\%conf,'set', 'planned_downtimes_additem', $id, undef, "$other"); print_log "$result \n\n"; } @@ -8662,7 +8662,7 @@ sub cli_create_tag() { my ($tag_name, $tag_description, $tag_url, $tag_email) = @ARGV[2..5]; # Call the API. - my $result = api_call(\%conf, 'set', 'create_tag', undef, undef, "$tag_name|$tag_description|$tag_url|$tag_email"); + my $result = manage_api_call(\%conf, 'set', 'create_tag', undef, undef, "$tag_name|$tag_description|$tag_url|$tag_email"); print "\n$result\n"; } @@ -8699,7 +8699,7 @@ sub cli_add_tag_to_user_profile() { exist_check($user_profile_id, 'given profile and group combination for user', $user_id); # Call the API. - my $result = api_call(\%conf, 'set', 'tag_user_profile', $user_id, $tag_id, "$group_id|$profile_id"); + my $result = manage_api_call(\%conf, 'set', 'tag_user_profile', $user_id, $tag_id, "$group_id|$profile_id"); print "\n$result\n"; } @@ -8723,7 +8723,7 @@ sub cli_add_tag_to_module() { exist_check($module_id, 'module name', $module_name); # Call the API. - my $result = api_call(\%conf, 'set', 'add_tag_module', $module_id, $tag_id); + my $result = manage_api_call(\%conf, 'set', 'add_tag_module', $module_id, $tag_id); print "\n$result\n"; } @@ -8742,7 +8742,7 @@ sub cli_migration_agent_queue() { } # Call the API. - my $result = api_call( $conf, 'set', 'migrate_agent', $id_agent, 0, "$source_name|$target_name|$only_db" ); + my $result = manage_api_call( $conf, 'set', 'migrate_agent', $id_agent, 0, "$source_name|$target_name|$only_db" ); print "\n$result\n"; } @@ -8757,7 +8757,7 @@ sub cli_migration_agent() { } # Call the API. - my $result = api_call( $conf, 'get', 'migrate_agent', $id_agent); + my $result = manage_api_call( $conf, 'get', 'migrate_agent', $id_agent); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8866,7 +8866,7 @@ sub cli_new_cluster() { my ($cluster_name,$cluster_type,$description,$group_id) = @ARGV[2..5]; # Call the API. - my $result = api_call( $conf, 'set', 'new_cluster', undef, undef, "$cluster_name|$cluster_type|$description|$group_id"); + my $result = manage_api_call( $conf, 'set', 'new_cluster', undef, undef, "$cluster_name|$cluster_type|$description|$group_id"); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8884,7 +8884,7 @@ sub cli_add_cluster_agent() { my ($other) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'add_cluster_agent', undef, undef, $other); + my $result = manage_api_call( $conf, 'set', 'add_cluster_agent', undef, undef, $other); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8902,7 +8902,7 @@ sub cli_add_cluster_item() { my ($other) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'add_cluster_item', undef, undef, $other); + my $result = manage_api_call( $conf, 'set', 'add_cluster_item', undef, undef, $other); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8920,7 +8920,7 @@ sub cli_delete_cluster() { my ($id) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'delete_cluster', $id); + my $result = manage_api_call( $conf, 'set', 'delete_cluster', $id); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8938,7 +8938,7 @@ sub cli_delete_cluster_agent() { my ($id_agent,$id_cluster) = @ARGV[2..3]; # Call the API. - my $result = api_call( $conf, 'set', 'delete_cluster_agent', undef, undef, "$id_agent|$id_cluster"); + my $result = manage_api_call( $conf, 'set', 'delete_cluster_agent', undef, undef, "$id_agent|$id_cluster"); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8956,7 +8956,7 @@ sub cli_delete_cluster_item() { my ($id) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'set', 'delete_cluster_item', $id); + my $result = manage_api_call( $conf, 'set', 'delete_cluster_item', $id); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8975,7 +8975,7 @@ sub cli_get_cluster_status() { my ($id) = @ARGV[2..2]; # Call the API. - my $result = api_call( $conf, 'get', 'cluster_status', $id); + my $result = manage_api_call( $conf, 'get', 'cluster_status', $id); if( defined($result) && "$result" ne "" ){ print "\n1\n"; @@ -8996,7 +8996,7 @@ sub cli_set_disabled_and_standby() { $value = 1 unless defined($value); #Set to disabled by default # Call the API. - my $result = api_call( + my $result = manage_api_call( $conf, 'set', 'disabled_and_standby', $id, $id_node, $value ); @@ -9012,7 +9012,7 @@ sub cli_set_disabled_and_standby() { sub cli_reset_agent_counts() { my $agent_id = @ARGV[2]; - my $result = api_call(\%conf,'set', 'reset_agent_counts', $agent_id); + my $result = manage_api_call(\%conf,'set', 'reset_agent_counts', $agent_id); print "$result \n\n "; } @@ -9027,7 +9027,7 @@ sub cli_event_in_progress() { my $event_id = @ARGV[2]; # Call the API. - my $result = api_call( + my $result = manage_api_call( $conf, 'set', 'event_in_progress', $event_id ); @@ -9097,7 +9097,7 @@ sub cli_get_gis_agent(){ my $agent_id = @ARGV[2]; - my $result = api_call(\%conf,'get', 'gis_agent', $agent_id); + my $result = manage_api_call(\%conf,'get', 'gis_agent', $agent_id); print "$result \n\n "; } @@ -9113,7 +9113,7 @@ sub cli_insert_gis_data(){ my @position = @ARGV[3..5]; my $other = join('|', @position); - my $result = api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other"); + my $result = manage_api_call(\%conf,'set', 'gis_agent_only_position', $agent_id, undef, "$other"); print "$result \n\n "; }