diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index dd03c476be..29054e9598 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-240117 +Version: 7.0NG.775-240119 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 cdc539a810..5c84c36bc8 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-240117" +pandora_version="7.0NG.775-240119" 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 dec33aa8fc..e14d1810ae 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 => '240117'; +use constant AGENT_BUILD => '240119'; # 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 fe4cf2f3c1..1876217583 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 240117 +%define release 240119 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 5af1c4ece1..cf03ff4fc1 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 240117 +%define release 240119 %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 7921ccdebb..02ccbcb2f2 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 240117 +%define release 240119 %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 22653a0605..0ec826977e 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 240117 +%define release 240119 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 bedceaaea9..e71e28d915 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 240117 +%define release 240119 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 83de892a8c..fa69febd2f 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="240117" +PI_BUILD="240119" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b16cef6aab..b7e5685ffd 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{240117} +{240119} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 0a285f6560..ad5dd5bc83 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 240117") +#define PANDORA_VERSION ("7.0NG.775 Build 240119") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index d3ebaf59be..11e08a1b22 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 240117))" + VALUE "ProductVersion", "(7.0NG.775(Build 240119))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index b898706e72..c91dd82f91 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.775-240117 +Version: 7.0NG.775-240119 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 d13917196a..509defd0a7 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-240117" +pandora_version="7.0NG.775-240119" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index 6a3f67b2ab..92dea644a3 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -3,4 +3,6 @@ START TRANSACTION; 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 '' ; + COMMIT; \ No newline at end of file diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 82da1a66dd..5ad89d8d31 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -397,21 +397,23 @@ echo sprintf('
', $menuTypeClass); $modal_box .= ''.__('Join discord community').''; $modal_box .= '
'; - $modal_help = html_print_div( - [ - 'id' => 'modal-help-content', - 'content' => html_print_image( - 'images/help@header.svg', - true, - [ - 'title' => __('Help'), - 'class' => 'main_menu_icon bot invert_filter', - 'alt' => 'user', - ] - ).$modal_box, - ], - true, - ); + if ($config['activate_feedback'] === '1') { + $modal_help = html_print_div( + [ + 'id' => 'modal-help-content', + 'content' => html_print_image( + 'images/help@header.svg', + true, + [ + 'title' => __('Help'), + 'class' => 'main_menu_icon bot invert_filter', + 'alt' => 'user', + ] + ).$modal_box, + ], + true, + ); + } // User. diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 1af5e3d780..4e62337547 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -399,12 +399,12 @@ if ($new_agent === true) { // Ip adress. $tableAgent->data['caption_ip_address'] = __('IP Address'); -$tableAgent->rowclass['ip_address'] = 'w540px'; +$tableAgent->rowclass['ip_address'] = 'w400px'; $tableAgent->data['ip_address'][0] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true, false, false, '', 'w540px'); +$tableAgent->data['ip_address'][1] = html_print_button(__('Check unique IP'), 'check_unique_ip', false, '', ['class' => 'secondary w130px'], true); +$tableAgent->data['message_check_ip'][0] = html_print_div(['id' => 'message_check_ip'], true); $tableAgent->rowclass['additional_ip_address'] = 'subinput'; -$tableAgent->data['additional_ip_address'][0] = html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true); -$tableAgent->data['additional_ip_address'][1] = __('Unique IP'); $tableAgent->cellclass['additional_ip_address'][1] = 'w120px'; $tableAgent->data['additional_ip_address'][2] = html_print_input( [ @@ -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']) { @@ -1301,6 +1296,7 @@ ui_require_jquery_file('bgiframe'); ?> diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 3da403ef80..c2e3a2f4f6 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -102,7 +102,6 @@ $alias_as_name = 0; $direccion_agente = get_parameter('direccion', ''); $direccion_agente = trim(io_safe_output($direccion_agente)); $direccion_agente = io_safe_input($direccion_agente); -$unique_ip = 0; $intervalo = SECONDS_5MINUTES; $ff_interval = 0; $quiet_module = 0; @@ -186,7 +185,6 @@ if ($create_agent) { $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); - $unique_ip = (int) get_parameter_post('unique_ip', 0); // Safe_output only validate ip. $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -269,12 +267,7 @@ if ($create_agent) { $nombre_agente = $alias; } - if ($unique_ip && $direccion_agente != '') { - $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; - $exists_ip = db_get_row_sql($sql); - } - - if (!$exists_alias && !$exists_ip) { + if (!$exists_alias) { $id_agente = db_process_sql_insert( 'tagente', [ @@ -371,8 +364,6 @@ if ($create_agent) { $agent_creation_error = __('Could not be created'); if ($exists_alias) { $agent_creation_error = __('Could not be created, because name already exists'); - } else if ($exists_ip) { - $agent_creation_error = __('Could not be created, because IP already exists'); } } } @@ -962,7 +953,6 @@ if ($update_agent) { $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); - $unique_ip = (int) get_parameter_post('unique_ip', 0); // Safe_output only validate ip. $direccion_agente = trim(io_safe_output($direccion_agente)); @@ -1097,18 +1087,11 @@ if ($update_agent) { // If there is an agent with the same name, but a different ID. } - if ($direccion_agente !== $address_list && (bool) $unique_ip === true && $direccion_agente != '') { - $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; - $exists_ip = db_get_row_sql($sql); - } - $old_group = agents_get_agent_group($id_agente); if ($grupo <= 0) { ui_print_error_message(__('The group id %d is incorrect.', $grupo)); } else if ($old_group !== $grupo && group_allow_more_agents($grupo, true, 'update') === false) { ui_print_error_message(__('Agent cannot be updated due to the maximum agent limit for this group')); - } else if ($exists_ip) { - ui_print_error_message(__('Duplicate main IP address')); } else { // If different IP is specified than previous, add the IP. if ($direccion_agente != '' 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/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index e8915b05eb..7ba527b61e 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -497,7 +497,12 @@ foreach ($actions as $action) { $pagination = ''; if (isset($data)) { html_print_table($table); - $pagination = ui_pagination($total_actions, $url, 0, 0, true, 'offset', false, ''); + $show_count = false; + if (is_metaconsole() === true) { + $show_count = true; + } + + $pagination = ui_pagination($total_actions, $url, 0, 0, true, 'offset', $show_count, ''); } else { ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]); } diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index a59de7f5e2..a5b4de7c80 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -1080,7 +1080,12 @@ foreach ($commands as $command) { if (isset($data) === true && count($table->data) > 0) { html_print_table($table); - $pagination = ui_pagination($total_commands, $url, 0, 0, true, 'offset', false, ''); + $show_count = false; + if (is_metaconsole() === true) { + $show_count = true; + } + + $pagination = ui_pagination($total_commands, $url, 0, 0, true, 'offset', $show_count, ''); } else { ui_print_info_message( [ diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 8236d1e69c..537c346bac 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -493,6 +493,11 @@ foreach ($templates as $template) { $pagination = ''; if (isset($data) === true) { + $show_count = false; + if (is_metaconsole() === true) { + $show_count = true; + } + html_print_table($table); $pagination = ui_pagination( $total_templates, @@ -501,7 +506,7 @@ if (isset($data) === true) { 0, true, 'offset', - false, + $show_count, '' ); } else { 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/menu.php b/pandora_console/godmode/menu.php index 2c6661c1f6..a77e63b95b 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -770,11 +770,14 @@ $("#conf_wizard").click(function() { modal: { title: "", cancel: '', - ok: '' + ok: '', + overlay: true, + overlayExtraClass: 'welcome-overlay', }, onshow: { page: 'include/ajax/welcome_window', method: 'loadWelcomeWindow', + width: 1000, }, oncancel: { page: 'include/ajax/welcome_window', @@ -792,6 +795,34 @@ $("#conf_wizard").click(function() { } }) } + }, + onload: () => { + $(document).ready(function () { + var buttonpane = $("div[aria-describedby='welcome_modal_window'] .ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix"); + $(buttonpane).append(` +
+ + +
+ `); + + var closeWizard = $("button.close-wizard-button"); + + $(closeWizard).click(function (e) { + var close = $("div[aria-describedby='welcome_modal_window'] button.sub.ok.submit-next.ui-button"); + var cancel = $("div[aria-describedby='welcome_modal_window'] button.sub.upd.submit-cancel.ui-button"); + var checkbox = $("div[aria-describedby='welcome_modal_window'] .welcome-wizard-do-not-show:checked").length; + + if (checkbox === 1) { + $(cancel).click(); + } else { + $(close).click() + } + }); + }); } }); }); diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index d5540d2472..e7ceff1f01 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -394,11 +394,11 @@ html_print_action_buttons( $('[id^=checkbox-all_delete]').change(function(){ if ($("#checkbox-all_delete").prop("checked")) { $('[id^=checkbox-delete_multiple]').parent().parent().addClass('checkselected'); - $(".check_delete").prop("checked", true); + $(".custom_checkbox_input").prop("checked", true); } else{ $('[id^=checkbox-delete_multiple]').parent().parent().removeClass('checkselected'); - $(".check_delete").prop("checked", false); + $(".custom_checkbox_input").prop("checked", false); } }); }); diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 0256c28f92..705e7a8fe4 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -30,7 +30,7 @@ if (!$report_w && !$report_m) { require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_modules.php'; require_once $config['homedir'].'/include/functions_groups.php'; - +ui_require_css_file('custom_graph'); $editGraph = (bool) get_parameter('edit_graph', 0); $action = get_parameter('action', ''); @@ -41,113 +41,6 @@ if (isset($_GET['get_agent'])) { } } -switch ($action) { - case 'sort_items': - $resultOperationDB = null; - $position_to_sort = (int) get_parameter('position_to_sort', 1); - $ids_serialize = (string) get_parameter('ids_items_to_sort', ''); - $move_to = (string) get_parameter('move_to', 'after'); - - $countItems = db_get_sql( - ' - SELECT COUNT(id_gs) - FROM tgraph_source - WHERE id_graph = '.$id_graph - ); - - if (($countItems < $position_to_sort) || ($position_to_sort < 1)) { - $resultOperationDB = false; - } else if (!empty($ids_serialize)) { - $ids = explode('|', $ids_serialize); - $items = db_get_all_rows_sql( - 'SELECT id_gs, `field_order` - FROM tgraph_source - WHERE id_graph = '.$id_graph.' - ORDER BY `field_order`' - ); - - if ($items === false) { - $items = []; - } - - - // Clean the repeated order values. - $order_temp = 1; - foreach ($items as $item) { - db_process_sql_update( - 'tgraph_source', - ['`field_order`' => $order_temp], - ['id_gs' => $item['id_rc']] - ); - - $order_temp++; - } - - $items = db_get_all_rows_sql( - 'SELECT id_gs, `field_order` - FROM tgraph_source - WHERE id_graph = '.$id_graph.' - ORDER BY `field_order`' - ); - - if ($items === false) { - $items = []; - } - - - - $temp = []; - - $temp = []; - foreach ($items as $item) { - // Remove the contents from the block to sort. - if (array_search($item['id_gs'], $ids) === false) { - $temp[$item['field_order']] = $item['id_gs']; - } - } - - $items = $temp; - - - - $sorted_items = []; - foreach ($items as $pos => $id_unsort) { - if ($pos == $position_to_sort) { - if ($move_to == 'after') { - $sorted_items[] = $id_unsort; - } - - foreach ($ids as $id) { - $sorted_items[] = $id; - } - - if ($move_to != 'after') { - $sorted_items[] = $id_unsort; - } - } else { - $sorted_items[] = $id_unsort; - } - } - - $items = $sorted_items; - - - - foreach ($items as $order => $id) { - db_process_sql_update( - 'tgraph_source', - ['`field_order`' => ($order + 1)], - ['id_gs' => $id] - ); - } - - $resultOperationDB = true; - } else { - $resultOperationDB = false; - } - break; -} - if ($editGraph) { $graphRows = db_get_all_rows_sql( 'SELECT t1.*, @@ -257,41 +150,6 @@ $table->data[0][1] = html_print_label_input_block( ); -$SortItems = "
"; -$SortItems .= html_print_table($table, true); -$SortItems .= html_print_input_hidden('action', 'sort_items', true); -$SortItems .= html_print_div( - [ - 'class' => 'action-buttons', - 'content' => html_print_submit_button( - __('Sort'), - 'srcbutton', - false, - [ - 'class' => 'mini', - 'icon' => 'search', - 'mode' => 'secondary', - ], - true - ), - ], - true -); -$SortItems .= '
'; - -ui_toggle( - $SortItems, - ''.__('Sort items').'', - '', - '', - false, - false, - '', - 'white-box-content no_border', - 'filter-datatable-main box-flat white_table_graph max_floating_element_size' -); - - // Configuration form. echo ''; echo "
"; @@ -300,10 +158,11 @@ echo "'; echo ''; echo ''; @@ -340,6 +199,7 @@ echo ''; // Modules table. if ($count_module_array > 0) { echo "
'.html_print_input( [ - 'type' => 'select_multiple_modules_filtered', - 'uniqId' => 'modules', - 'class' => 'flex flex-row', - 'searchBar' => true, + 'type' => 'select_multiple_modules_filtered', + 'uniqId' => 'modules', + 'class' => 'flex flex-row', + 'searchBar' => false, + 'placeholderAgents' => __('Search agent name'), ] ).'
"; + echo ''; echo ' @@ -348,6 +208,8 @@ if ($count_module_array > 0) { '; + echo ''; + echo ''; $color = 0; for ($a = 0; $a < $count_module_array; $a++) { // Calculate table line color. @@ -359,7 +221,7 @@ if ($count_module_array > 0) { $color = 1; } - echo ""; + echo ""; echo "'; echo "'; @@ -410,9 +272,30 @@ if ($count_module_array > 0) { echo ''; - echo ''; @@ -420,6 +303,8 @@ if ($count_module_array > 0) { echo ''; } + echo ''; + echo '
'.__('P.').' '.__('Agent').''.__('Weight').' '.__('Delete').' '.__('Sort').'
$position_array[$a]
$position_array[$a]".$agent_array[$a].'"; echo modules_get_agentmodule_name($module_array[$a]).''; + echo ''; - echo html_print_checkbox_extended('sorted_items[]', $idgs_array[$a], false, false, '', 'class="selected_check"', true); + echo html_print_input_image( + 'up', + 'images/arrow-up-white.png', + 'up', + ($config['style'] !== 'pandora_black') ? 'filter: invert(100%)' : '', + true, + [ + 'class' => 'invert_filter main_menu_icon', + 'onclick' => 'reorder(\'up\', \''.$idgs_array[$a].'\', this)', + ], + ); + echo html_print_input_image( + 'down', + 'images/arrow-down-white.png', + 'down', + ($config['style'] !== 'pandora_black') ? 'filter: invert(100%)' : '', + true, + [ + 'class' => 'invert_filter main_menu_icon', + 'onclick' => 'reorder(\'down\', \''.$idgs_array[$a].'\', this)', + ] + ); echo '
'; } @@ -464,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; @@ -482,4 +367,65 @@ function added_ids_sorted_items_to_hidden_input() { return true; } } + + +function reorder(action, idElement, element) { + var tr = $(element).parent().parent(); + switch (action) { + case "up": + changePosition(action, idElement) + .then((data) => { + if(data.success) { + $(tr).find('.position').html(parseInt($(tr).find('.position').html()) - 1); + $($(tr).prev()).find('.position').html(parseInt($($(tr).prev()).find('.position').html()) + 1); + $(tr).prev().insertAfter(tr); + } + }) + .catch((err) => { + console.log(err); + }) + break; + + case "down": + changePosition(action, idElement) + .then((data) => { + if(data.success) { + $(tr).find('.position').html(parseInt($(tr).find('.position').html()) + 1); + $($(tr).next()).find('.position').html(parseInt(($(tr).next()).find('.position').html()) - 1); + $(tr).next().insertBefore(tr); + } + }) + .catch((err) => { + console.log(err); + }) + break; + + default: + break; + } +} + +function changePosition(order, idElement) { + return new Promise(function(resolve, reject) { + $.ajax({ + method: "POST", + url: "", + dataType: "json", + data: { + page: "include/ajax/graph.ajax", + sort_items: 1, + order, + id_graph: , + id: idElement + }, + success: function(data) { + resolve(data); + }, + error: function(error) { + reject(error); + } + }); + }); +} + diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 7524b64861..a39cff30b7 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -247,7 +247,7 @@ if ($add_module === true) { $id_agent_modules = db_get_all_rows_sql($sql); - if (count($id_agent_modules) > 0 && $id_agent_modules != '') { + if (is_array($id_agent_modules) === true && count($id_agent_modules) > 0 && $id_agent_modules != '') { $sql_order = sprintf( 'SELECT `field_order` FROM tgraph_source diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 842e05147d..8ad15c98f8 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1259,6 +1259,10 @@ switch ($action) { $reports_table .= html_print_table($table, true); $reports_table .= '
'; echo $reports_table; + $show_count = false; + if (is_metaconsole() === true) { + $show_count = true; + } $tablePagination = ui_pagination( $total_reports, @@ -1267,7 +1271,7 @@ switch ($action) { $pagination, true, 'offset', - false + $show_count ); } else { ui_print_info_message( diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php index c51c0476d3..8a78de9592 100644 --- a/pandora_console/godmode/servers/modificar_server.php +++ b/pandora_console/godmode/servers/modificar_server.php @@ -521,7 +521,7 @@ $(document).ready (function () { function (data) { $(".white-box-content").html(data); - $("#submit-add").click(function (e) { + $("#button-add").click(function (e) { add_credential_boxes(); }); @@ -550,7 +550,7 @@ $(document).ready (function () { $(".white-box-content").html(data2); // Insert credential - $("#submit-add").click(function (e) { + $("#button-add").click(function (e) { save_credential_boxes(); }) }, @@ -609,7 +609,7 @@ $(document).ready (function () { function (data) { $(".white-box-content").html(data); - $("#submit-update").click(function (e) { + $("#button-update").click(function (e) { update_credential_boxes(datas); }); }, diff --git a/pandora_console/godmode/setup/setup_ITSM.php b/pandora_console/godmode/setup/setup_ITSM.php index 012d80f849..313e6763c0 100644 --- a/pandora_console/godmode/setup/setup_ITSM.php +++ b/pandora_console/godmode/setup/setup_ITSM.php @@ -559,7 +559,7 @@ $table_cr_settings->data[4][0] = html_print_label_input_block( // Print. echo '
'; -echo ''; +echo ''; html_print_image( 'images/pandoraITSM_logo.png', false, @@ -570,8 +570,8 @@ echo '
'; echo '
'; echo __('Pandora ITSM'); echo '
'; -echo '
'; -echo 'https://pandorafms.com/es/itsm/'; +echo ''; +echo 'https://pandorafms.com/itsm/'; echo ''; echo '
'; 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/configure_user.php b/pandora_console/godmode/users/configure_user.php index 83e54f24c5..09835fe150 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -424,10 +424,13 @@ if ($create_user === true) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER) { - $values['data_section'] = get_parameter('data_section_other'); - } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section'); + } + + if (is_metaconsole() === true) { + $values['metaconsole_section'] = $values['section']; + $values['metaconsole_data_section'] = $values['data_section']; } // $values['section'] = $homeScreenValues[$values['section']]; @@ -724,10 +727,8 @@ if ($update_user) { $values['data_section'] = $dashboard; } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === HOME_SCREEN_OTHER) { - $values['data_section'] = get_parameter('data_section_other'); - } else if (io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { - $values['data_section'] = get_parameter('data_section_external'); + } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { + $values['data_section'] = get_parameter('data_section'); } // $values['section'] = $homeScreenValues[$values['section']]; diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index d488b4faad..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) { @@ -1023,8 +1027,13 @@ foreach ($info as $user_id => $user_info) { array_push($table->data, $data); } +$show_count = false; +if (is_metaconsole() === true) { + $show_count = true; +} + html_print_table($table); -$tablePagination = ui_pagination(count($info), false, 0, 0, true, 'offset', false, 'dataTables_paginate paging_simple_numbers'); +$tablePagination = ui_pagination(count($info), false, 0, 0, true, 'offset', $show_count, 'dataTables_paginate paging_simple_numbers'); unset($table); if ($is_management_allowed === true) { if ($config['admin_can_add_user'] !== false) { @@ -1052,43 +1061,13 @@ if ($is_management_allowed === true) { ?> diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index b1212c11ec..7a5abb8503 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -84,8 +84,7 @@ $customHomeScreenAddition[HOME_SCREEN_DASHBOARD] = html_print_select( // Home screen. Visual consoles. $customHomeScreenAddition[HOME_SCREEN_VISUAL_CONSOLE] = html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true, false, true, 'w100p', false, 'width: 100%'); // Home screen. External link and Other. -$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section_external', $user_info['data_section'], '', 60, 255, true); -$customHomeScreenAddition[HOME_SCREEN_OTHER] = html_print_input_text('data_section_other', $user_info['data_section'], '', 60, 255, true); +$customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text('data_section', $user_info['data_section'], '', 60, 400, true); $layouts = visual_map_get_user_layouts($config['id_user'], true); $layouts_aux = []; @@ -118,7 +117,7 @@ $customHomeScreenAddition[HOME_SCREEN_EXTERNAL_LINK] = html_print_input_text( $user_info['data_section'], '', 60, - 255, + 999, true ); $customHomeScreenDataField = ''; diff --git a/pandora_console/images/check-white.svg b/pandora_console/images/check-white.svg new file mode 100644 index 0000000000..e7863cf1ba --- /dev/null +++ b/pandora_console/images/check-white.svg @@ -0,0 +1,21 @@ + + + F1630B1D-C694-489C-8C8F-E98AF57D4F04 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pandora_console/images/welcome-wizard-image.png b/pandora_console/images/welcome-wizard-image.png new file mode 100644 index 0000000000..aba9647c54 Binary files /dev/null and b/pandora_console/images/welcome-wizard-image.png differ diff --git a/pandora_console/include/ajax/agent.php b/pandora_console/include/ajax/agent.php index 65dcd96aef..b03a9e5b40 100644 --- a/pandora_console/include/ajax/agent.php +++ b/pandora_console/include/ajax/agent.php @@ -39,6 +39,7 @@ $get_agent_filters = get_parameter('get_agent_filters', 0); $save_agent_filter = get_parameter('save_agent_filter', 0); $update_agent_filter = get_parameter('update_agent_filter', 0); $delete_agent_filter = get_parameter('delete_agent_filter', 0); +$check_unique_ip = (bool) get_parameter('check_unique_ip', 0); if (https_is_running()) { header('Content-type: application/json'); @@ -1020,4 +1021,29 @@ $(document).ready(function() { return; } +if ($check_unique_ip === true) { + $direccion_agente = (string) get_parameter_post('direccion', ''); + $ip_all = get_parameter_post('ip_all', ''); + + if (empty($direccion_agente) === true) { + echo json_encode(['success' => false, 'message' => __('Please enter an IP address.')]); + return; + } + + $sql = 'SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'; + $exists_ip = db_get_row_sql($sql); + + if ($exists_ip !== false) { + if (is_array($ip_all) === true && in_array($direccion_agente, $ip_all) === true) { + echo json_encode(['success' => true, 'message' => __('Success! but this IP is already in the list.')]); + } else { + echo json_encode(['success' => false, 'message' => __('This IP is already being used'), 'exist_ip' => true]); + } + } else { + echo json_encode(['success' => true, 'message' => __('Success! this IP is available to be used.')]); + } + + return; +} + return; 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/ajax/graph.ajax.php b/pandora_console/include/ajax/graph.ajax.php index 6ea76f373b..2db3a72912 100644 --- a/pandora_console/include/ajax/graph.ajax.php +++ b/pandora_console/include/ajax/graph.ajax.php @@ -17,6 +17,8 @@ $save_custom_graph = (bool) get_parameter('save_custom_graph'); $print_custom_graph = (bool) get_parameter('print_custom_graph', false); $print_sparse_graph = (bool) get_parameter('print_sparse_graph'); $get_graphs = (bool) get_parameter('get_graphs_container'); +$sort_items = (bool) get_parameter('sort_items'); + $width = get_parameter('width', 0); $height = get_parameter('height', 0); @@ -337,3 +339,104 @@ if ($get_graphs) { return; } } + + +if ($sort_items === true) { + $order = (string) get_parameter('order'); + $id = (string) get_parameter('id', ''); + $idGraph = (string) get_parameter('id_graph', ''); + $total = db_get_num_rows('SELECT * FROM tgraph_source WHERE id_graph = '.$idGraph.''); + $item = db_get_row_sql( + 'SELECT id_gs, field_order + FROM tgraph_source + WHERE id_gs = '.$id.' + ORDER BY field_order' + ); + + switch ($order) { + case 'up': + if (($item['field_order'] - 1) < 1) { + echo json_encode(['success' => false]); + return; + } + + $prevItem = db_get_row_sql( + 'SELECT id_gs, field_order + FROM tgraph_source + WHERE id_graph = '.$idGraph.' + AND field_order = '.($item['field_order'] - 1).' + ORDER BY field_order' + ); + + db_process_sql_begin(); + + $resultItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($item['field_order'] - 1)], + ['id_gs' => $item['id_gs']], + false + ); + $resultPrevItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($prevItem['field_order'] + 1)], + ['id_gs' => $prevItem['id_gs']], + false + ); + + if ($resultItem !== false && $resultPrevItem !== false) { + db_process_sql_commit(); + echo json_encode(['success' => true]); + return; + } else { + db_process_sql_rollback(); + echo json_encode(['success' => false]); + return; + } + break; + + case 'down': + if (($item['field_order'] + 1) > $total) { + echo json_encode(['success' => false]); + return; + } + + $nextItem = db_get_row_sql( + 'SELECT id_gs, field_order + FROM tgraph_source + WHERE id_graph = '.$idGraph.' + AND field_order = '.($item['field_order'] + 1).' + ORDER BY field_order' + ); + + + db_process_sql_begin(); + + $resultItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($item['field_order'] + 1)], + ['id_gs' => $item['id_gs']], + false + ); + $resultNextItem = db_process_sql_update( + 'tgraph_source', + ['field_order' => ($nextItem['field_order'] - 1)], + ['id_gs' => $nextItem['id_gs']], + false + ); + + if ($resultItem !== false && $resultNextItem !== false) { + db_process_sql_commit(); + echo json_encode(['success' => true]); + return; + } else { + db_process_sql_rollback(); + echo json_encode(['success' => false]); + return; + } + break; + + default: + echo json_encode(['success' => false]); + break; + } +} 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/auth/mysql.php b/pandora_console/include/auth/mysql.php index 76a6458f32..3141272352 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -816,8 +816,6 @@ function update_user(string $id_user, array $values) $values['metaconsole_data_section'] = $values['data_section']; $values['metaconsole_default_event_filter'] = $values['default_event_filter']; unset($values['id_skin']); - unset($values['section']); - unset($values['data_section']); unset($values['default_event_filter']); } } diff --git a/pandora_console/include/class/AuditLog.class.php b/pandora_console/include/class/AuditLog.class.php index 261ffac531..ceb98875a1 100644 --- a/pandora_console/include/class/AuditLog.class.php +++ b/pandora_console/include/class/AuditLog.class.php @@ -123,7 +123,7 @@ class AuditLog extends HTML ], [ 'text' => 'action', - 'class' => 'w80px table_action_buttons show_extended_info', + 'class' => 'w80px show_extended_info', ] ); @@ -187,7 +187,7 @@ class AuditLog extends HTML 'no_sortable_columns' => [-1], 'order' => [ 'field' => 'date', - 'direction' => 'asc', + 'direction' => 'desc', ], 'search_button_class' => 'sub filter float-right', 'form' => [ @@ -441,7 +441,7 @@ class AuditLog extends HTML $(document).ready(function() { // Add event listener for opening and closing details - $('#audit_logs tbody').on('click', 'td.show_extended_info', function() { + $(document).on('click', '#audit_logs tbody tr:has(td.show_extended_info)', function() { var tr = $(this).closest('tr'); var table = $("#tableId; ?>").DataTable(); var row = table.row(tr); diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 92552242f3..f60c4dc241 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -928,7 +928,9 @@ class ConsoleSupervisor false ); - if ($prev !== false + if ($data['type'] === 'NOTIF.LOG.ALERT' && $prev !== false) { + return; + } else if ($prev !== false && (time() - $prev['timestamp']) > $max_age ) { // Clean previous notification. diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index 29fa2e3b77..a40b3ecc7a 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -388,26 +388,40 @@ class SatelliteAgent extends HTML $tmp->actions = ''; if ($delete === false) { - $tmp->actions .= html_print_image( - ($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png', - true, + $tmp->actions .= html_print_anchor( [ - 'border' => '0', - 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', - 'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')', - ] + 'href' => '#', + 'content' => html_print_image( + ($disable === true) ? 'images/lightbulb_off.png' : 'images/lightbulb.png', + true, + [ + 'title' => ($disable === true) ? __('Enable') : __('Disable'), + 'border' => '0', + 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', + 'onclick' => 'disable_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $disable.'\',\''.$id_agente.'\')', + ] + ), + ], + true ); } if ($disable === false) { - $tmp->actions .= html_print_image( - ($delete === true) ? 'images/add.png' : 'images/delete.svg', - true, + $tmp->actions .= html_print_anchor( [ - 'border' => '0', - 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', - 'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')', - ] + 'href' => '#', + 'content' => html_print_image( + ($delete === true) ? 'images/add.png' : 'images/delete.svg', + true, + [ + 'title' => ($delete === true) ? __('Add') : __('Delete'), + 'border' => '0', + 'class' => 'main_menu_icon mrgn_lft_05em invert_filter', + 'onclick' => 'delete_agent(\''.$tmp->address.'\',\''.strip_tags($tmp->name).'\',\''.(int) $delete.'\',\''.$id_agente.'\')', + ] + ), + ], + true ); } 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/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 4c72046548..378a194e32 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -156,11 +156,14 @@ class WelcomeWindow extends Wizard modal: { title: "", cancel: '', - ok: '' + ok: '', + overlay: true, + overlayExtraClass: 'welcome-overlay', }, onshow: { page: 'ajaxController; ?>', method: 'loadWelcomeWindow', + width: 1000, }, oncancel: { page: 'ajaxController; ?>', @@ -178,6 +181,34 @@ class WelcomeWindow extends Wizard } }) } + }, + onload: () => { + $(document).ready(function () { + var buttonpane = $("div[aria-describedby='welcome_modal_window'] .ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix"); + $(buttonpane).append(` +
+ + +
+ `); + + var closeWizard = $("button.close-wizard-button"); + + $(closeWizard).click(function (e) { + var close = $("div[aria-describedby='welcome_modal_window'] button.sub.ok.submit-next.ui-button"); + var cancel = $("div[aria-describedby='welcome_modal_window'] button.sub.upd.submit-cancel.ui-button"); + var checkbox = $("div[aria-describedby='welcome_modal_window'] .welcome-wizard-do-not-show:checked").length; + + if (checkbox === 1) { + $(cancel).click(); + } else { + $(close).click() + } + }); + }); } }); @@ -412,11 +443,11 @@ class WelcomeWindow extends Wizard $inputs[] = [ 'wrapper' => 'div', 'block_id' => 'div_diagnosis', - 'class' => 'flex-row flex-items-center w98p ', + 'class' => 'flex-row flex-items-center ', 'direct' => 1, 'block_content' => [ [ - 'label' => __('Post-installation status diagnostic'), + 'label' => __('This is your post-installation status diagnostic:'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_diagnosis', @@ -434,7 +465,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('Warp Update registration'), + 'label' => ''.__('Warp Update registration'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_update_manager', @@ -443,7 +474,7 @@ class WelcomeWindow extends Wizard ], [ 'arguments' => [ - 'label' => '', + 'label' => __('Cancel'), 'type' => 'button', 'attributes' => [ 'class' => (empty($btn_update_manager_class) === false) ? $btn_update_manager_class : 'invisible_important', @@ -462,7 +493,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('Default mail to send alerts'), + 'label' => ''.__('Default mail to send alerts'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_create_agent', @@ -471,7 +502,7 @@ class WelcomeWindow extends Wizard ], [ 'arguments' => [ - 'label' => '', + 'label' => __('Cancel'), 'type' => 'button', 'attributes' => [ 'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important', @@ -490,7 +521,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('All servers running'), + 'label' => ''.__('All servers running'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_servers_up', @@ -499,7 +530,7 @@ class WelcomeWindow extends Wizard ], [ 'arguments' => [ - 'label' => '', + 'label' => __('Cancel'), 'type' => 'button', 'attributes' => [ 'class' => (empty($btn_servers_up_class) === false) ? $btn_servers_up_class : 'invisible_important', @@ -518,7 +549,7 @@ class WelcomeWindow extends Wizard 'direct' => 1, 'block_content' => [ [ - 'label' => __('Enterprise licence valid'), + 'label' => ''.__('Enterprise licence valid'), 'arguments' => [ 'class' => 'first_lbl', 'name' => 'lbl_license_valid', @@ -527,7 +558,7 @@ class WelcomeWindow extends Wizard ], [ 'arguments' => [ - 'label' => '', + 'label' => __('Cancel'), 'type' => 'button', 'attributes' => [ 'class' => (empty($btn_license_valid_class) === false) ? $btn_license_valid_class : 'invisible_important', @@ -567,7 +598,7 @@ class WelcomeWindow extends Wizard $inputs[] = [ 'wrapper' => 'div', 'block_id' => 'div_task_todo', - 'class' => 'flex-row flex-items-center w98p', + 'class' => 'flex-row flex-items-center', 'direct' => 1, 'block_content' => [ [ @@ -591,7 +622,7 @@ class WelcomeWindow extends Wizard $inputs[] = [ 'wrapper' => 'div', 'block_id' => 'div_wizard_agent', - 'class' => 'flex space-between w98p', + 'class' => 'flex space-between', 'direct' => 1, 'block_content' => [ [ @@ -599,7 +630,7 @@ class WelcomeWindow extends Wizard 'type' => 'select', 'fields' => $fields, 'name' => 'task_to_perform', - 'selected' => '', + 'selected' => 'check_net', 'return' => true, 'nothing' => \__('Please select one'), 'nothing_value' => '', @@ -630,6 +661,24 @@ class WelcomeWindow extends Wizard $output .= $this->loadJS($flag_task); echo $output; + + echo ' +
+
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+ +
+ '; ?>