diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 5a22f8ecae..d48173512f 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.769-230228 +Version: 7.0NG.769-230307 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 ac85303303..cb6b963504 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.769-230228" +pandora_version="7.0NG.769-230307" 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 a994aabc8b..012a228cd2 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1023,7 +1023,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.769'; -use constant AGENT_BUILD => '230228'; +use constant AGENT_BUILD => '230307'; # 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 1e35d4443c..26931473af 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.769 -%define release 230228 +%define release 230307 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 3519ff8837..329768dfa7 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.769 -%define release 230228 +%define release 230307 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 ec3075858c..1a32864bd8 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.769" -PI_BUILD="230228" +PI_BUILD="230307" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 2f2c4f1324..48912e2ff3 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230228} +{230307} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 9d41d77811..11a3383389 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.769 Build 230228") +#define PANDORA_VERSION ("7.0NG.769 Build 230307") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index ab42fb366e..3c842ed958 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.769(Build 230228))" + VALUE "ProductVersion", "(7.0NG.769(Build 230307))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 12ed651bf5..d71a8ffb94 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.769-230228 +Version: 7.0NG.769-230307 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 32b28e5e53..ecb6a40251 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.769-230228" +pandora_version="7.0NG.769-230307" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 487f1b476d..44d4bc64b6 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -397,61 +397,139 @@ function mainAgentsModules() 1 => __('Show module data'), ]; - $filter_type_label = ''.__('Information to be shown').''; - $filter_type = html_print_select($show_select, 'show_type', $show_type, '', '', 0, true, false, false, '', false, 'min-width: 180px;'); - - // Groups. - $filter_groups_label = ''.__('Group').''; - $filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;'); - - $filter_recursion_label = ''.__('Recursion').''; - $filter_recursion = html_print_checkbox('recursion', 1, 0, true).''; - // Groups module. - $filter_module_groups_label = ''.__('Module group').''; - $filter_module_groups = html_print_select_from_sql( - 'SELECT * FROM tmodule_group ORDER BY name', - 'modulegroup', - $modulegroup, - '', - __('All'), - 0, - true, - false, - true, - false, - 'width: auto;' + $filter_type = html_print_label_input_block( + __('Information to be shown'), + html_print_select( + $show_select, + 'show_type', + $show_type, + '', + '', + 0, + true, + false, + false, + '', + false, + 'width: 100%;' + ) + ); + + $filter_groups = html_print_label_input_block( + __('Group'), + html_print_select_groups( + false, + 'AR', + true, + 'group_id', + $group_id, + '', + '', + '', + true, + false, + true, + '', + false, + 'width: 100%;' + ) + ); + + $filter_groups .= html_print_label_input_block( + __('Recursion'), + html_print_checkbox_switch('recursion', 1, 0, true), + [ + 'div_class' => 'add-input-reverse', + 'label_class' => 'label-thin', + ] + ); + + $filter_module_groups = html_print_label_input_block( + __('Module group'), + html_print_select_from_sql( + 'SELECT * FROM tmodule_group ORDER BY name', + 'modulegroup', + $modulegroup, + '', + __('All'), + 0, + true, + false, + true, + false, + 'width: 100%;' + ) ); - // Agent. $agents = agents_get_group_agents($group_id); if ((empty($agents)) || $agents == -1) { $agents = []; } - $filter_agents_label = ''.__('Agents').''; - $filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, 'min-width: 180px; max-width: 200px;'); + $filter_agents = html_print_label_input_block( + __('Agents'), + html_print_select( + $agents, + 'id_agents2[]', + $agents_id, + '', + '', + 0, + true, + true, + true, + '', + false, + 'width: 100%;' + ) + ); // Type show. $selection = [ 0 => __('Show common modules'), 1 => __('Show all modules'), ]; - $filter_type_show_label = ''.__('Show common modules').''; - $filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', '', 0, true, false, true, '', false, 'min-width: 180px;'); + $filter_type_show = html_print_label_input_block( + __('Show common modules'), + html_print_select( + $selection, + 'selection_agent_module', + $selection_a_m, + '', + '', + 0, + true, + false, + true, + '', + false, + 'width: 100%;' + ) + ); // Modules. $all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false); - $filter_modules_label = ''.__('Module').''; - $filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, 'min-width: 180px; max-width: 200px;'); - - // Update. - $filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true); + $filter_modules = html_print_label_input_block( + __('Module'), + html_print_select( + $all_modules, + 'module[]', + $modules_selected, + '', + '', + 0, + true, + true, + false, + '', + false, + 'width: 100%;' + ) + ); $onheader = [ - 'updated_time' => $updated_time, - 'fullscreen' => $fullscreen, - 'combo_module_groups' => $filter_module_groups, - 'combo_groups' => $filter_groups, + 'updated_time' => $updated_time, + 'fullscreen' => $fullscreen, ]; /* @@ -467,7 +545,7 @@ function mainAgentsModules() false, '', false, - (array) $updated_time, + $onheader, [ [ 'link' => '', @@ -479,12 +557,6 @@ function mainAgentsModules() ], ] ); - - echo ''; - echo ''; - echo "'; - echo ''; - echo '
".$fullscreen['text'].'
'; } else { if ($full_agents_id[0]) { $full_modules = urlencode(implode(';', $full_modules_selected)); @@ -574,35 +646,46 @@ function mainAgentsModules() if ($config['pure'] != 1) { $show_filters = '
'; - $show_filters .= ''; + $show_filters .= '
'; $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; + $show_filters .= ''; $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; - $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; $show_filters .= ''; $show_filters .= ''; - $show_filters .= ''; - $show_filters .= "'; - $show_filters .= ''; $show_filters .= '
'.$filter_type_label.''.$filter_type.''.$filter_type.''.$filter_groups.''.$filter_module_groups.'
'.$filter_groups_label.''.$filter_groups.'   '.$filter_recursion_label.$filter_recursion.''.$filter_module_groups_label.''.$filter_module_groups.'
'.$filter_agents_label.''.$filter_agents.''.$filter_type_show_label.''.$filter_type_show.''.$filter_modules_label.''.$filter_modules.'
".$filter_update.'
'; + $show_filters .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + true + ); $show_filters .= '
'; + ui_toggle( $show_filters, - __('Filters ').ui_print_help_tip(__('Secondary groups and agent subgroups will be taken into account.'), true) + ''.__('Filters ').''.ui_print_help_tip(__('Secondary groups and agent subgroups will be taken into account.'), true), + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' ); } @@ -751,11 +834,11 @@ function mainAgentsModules() return; } - echo ''; + echo '
'; echo ''; - echo "'; + echo "'; if ($hor_offset > 0) { $new_hor_offset = ($hor_offset - $block); @@ -804,7 +887,20 @@ function mainAgentsModules() // Prepare pagination. $url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m; - ui_pagination($total_pagination, $url); + $tablePagination = ui_pagination( + $total_pagination, + $url, + 0, + 0, + true, + 'offset', + false + ); + + html_print_action_buttons( + '', + [ 'right_content' => $tablePagination ] + ); foreach ($agents as $agent) { // Get stats for this group. diff --git a/pandora_console/extensions/api_checker.php b/pandora_console/extensions/api_checker.php index 6b4dcf4d72..2ffc5ef6c8 100755 --- a/pandora_console/extensions/api_checker.php +++ b/pandora_console/extensions/api_checker.php @@ -301,10 +301,21 @@ function extension_api_checker() html_print_table($table3); echo ''; - echo "
"; html_print_input_hidden('api_execute', 1); - html_print_submit_button(__('Call'), 'submit', false, 'class="sub next"'); - echo '
'; + + html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Call'), + 'submit', + false, + [ 'icon' => 'next' ], + true + ), + ] + ); + echo ''; if ($api_execute === true) { diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 638d795b31..98b95783be 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -67,11 +67,20 @@ function extension_db_status() html_print_table($table); echo ''; - echo "
"; - html_print_input_hidden('db_status_execute', 1); - html_print_submit_button(__('Execute Test'), 'submit', false, 'class="sub next"'); - echo '
'; + html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Execute Test'), + 'submit', + false, + [ 'icon' => 'cog' ], + true + ), + ] + ); + html_print_input_hidden('db_status_execute', 1); echo ''; if ($db_status_execute) { diff --git a/pandora_console/extensions/dbmanager.php b/pandora_console/extensions/dbmanager.php index 3f36935e5c..ffcc2fdb72 100644 --- a/pandora_console/extensions/dbmanager.php +++ b/pandora_console/extensions/dbmanager.php @@ -76,10 +76,6 @@ function dbmgr_extension_main() global $config; - if (is_metaconsole() === true) { - open_meta_frame(); - } - if (!is_user_admin($config['id_user'])) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, @@ -92,7 +88,21 @@ function dbmgr_extension_main() $sql = (string) get_parameter('sql'); $node_id = (int) get_parameter('node_id', -1); - ui_print_page_header(__('Database interface'), 'images/gm_db.png', false, false, true); + // Header. + ui_print_standard_header( + __('Database interface'), + 'images/gm_db.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Extensions'), + ], + ] + ); if (is_metaconsole() === true) { $img = '../../images/warning_modern.png'; @@ -195,15 +205,18 @@ function dbmgr_extension_main() ); } - $data[4][2] = '
'; - $data[4][2] .= html_print_submit_button( - __('Execute SQL'), - '', - false, - 'class="sub next"', - true + $data[4][2] = html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Execute SQL'), + '', + false, + [ 'icon' => 'cog' ], + true + ), + ] ); - $data[4][2] .= '
'; $table->data = $data; html_print_table($table); @@ -282,10 +295,6 @@ function dbmgr_extension_main() html_print_table($table); echo ''; - if (is_metaconsole()) { - close_meta_frame(); - } - } diff --git a/pandora_console/extensions/files_repo/files_repo_list.php b/pandora_console/extensions/files_repo/files_repo_list.php index 783e155dc4..6c75218d18 100644 --- a/pandora_console/extensions/files_repo/files_repo_list.php +++ b/pandora_console/extensions/files_repo/files_repo_list.php @@ -98,7 +98,7 @@ if (!empty($files)) { // Last modification // Public URL $data[4] = ''; - $table->cellclass[][4] = 'action_buttons'; + $table->cellclass[][4] = 'table_action_buttons'; if (!empty($file['hash'])) { $public_url = ui_get_full_url( EXTENSIONS_DIR.'/files_repo/files_repo_get_file.php?file='.$file['hash'] diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 54306ac5d7..3ccf1af688 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -1,16 +1,32 @@ '', + 'label' => __('Resources'), + ], + [ + 'link' => '', + 'label' => __('Insert Data'), + ], + ] + ); if (! check_acl($config['id_user'], 0, 'AW') && ! is_user_admin($config['id_user'])) { db_pandora_audit( @@ -84,6 +117,13 @@ function mainInsertData() $csv = false; } + ui_print_warning_message( + sprintf( + __('Please check that the directory "%s" is writeable by the apache user.

The CSV file format is date;value<newline>date;value<newline>... The date in CSV is in format Y/m/d H:i:s.'), + $config['remote_config'] + ) + ); + if ($save) { if (!check_acl($config['id_user'], agents_get_agent_group($agent_id), 'AW')) { ui_print_error_message(__('You haven\'t privileges for insert data in the agent.')); @@ -140,27 +180,25 @@ function mainInsertData() } } - echo '
'; - echo sprintf( - __('Please check that the directory "%s" is writeable by the apache user.

The CSV file format is date;value<newline>date;value<newline>... The date in CSV is in format Y/m/d H:i:s.'), - $config['remote_config'] - ); - echo '
'; + $modules = []; + if ($agent_id > 0) { + $modules = agents_get_modules($agent_id, false, ['delete_pending' => 0]); + } $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox filters'; + $table->class = 'databox filter-table-adv'; $table->style = []; - $table->style[0] = 'font-weight: bolder;'; - + $table->cellstyle[0][0] = 'width: 0'; + $table->cellstyle[0][1] = 'width: 0'; $table->data = []; - - $table->data[0][0] = __('Agent'); + $table->data[0][0] = ''; + $table->data[0][1] = ''; + $table->data[0][2] = ''; $params = []; $params['return'] = true; $params['show_helptip'] = true; $params['input_name'] = 'agent_name'; - $params['value'] = $agent_name; + $params['value'] = ($save === true) ? '' : $agent_name; $params['javascript_is_function_select'] = true; $params['javascript_name_function_select'] = 'custom_select_function'; $params['javascript_code_function_select'] = ''; @@ -170,18 +208,12 @@ function mainInsertData() $params['hidden_input_idagent_name'] = 'agent_id'; $params['hidden_input_idagent_value'] = $agent_id; - $table->data[0][1] = ui_print_agent_autocomplete_input($params); - - $table->data[1][0] = __('Module'); - $modules = []; - if ($agent_id) { - $modules = agents_get_modules($agent_id, false, ['delete_pending' => 0]); - } + $table->data[1][0] = html_print_div(['class' => 'flex flex-items-center', 'content' => ui_print_agent_autocomplete_input($params)], true); $table->data[1][1] = html_print_select( $modules, 'id_agent_module', - $id_agent_module, + ($save === true) ? '' : $id_agent_module, true, __('Select'), 0, @@ -191,22 +223,45 @@ function mainInsertData() '', empty($agent_id) ); - $table->data[2][0] = __('Data'); - $table->data[2][1] = html_print_input_text('data', $data, __('Data'), 40, 60, true); - $table->data[3][0] = __('Date'); - $table->data[3][1] = html_print_input_text('date', $date, '', 11, 11, true).' '; - $table->data[3][1] .= html_print_input_text('time', $time, '', 7, 7, true); - $table->data[4][0] = __('CSV'); - $table->data[4][1] = html_print_input_file('csv', true); + $table->data[1][2] = html_print_input_text('data', ($save === true) ? date(DATE_FORMAT) : $data, __('Data'), 10, 60, true); + $table->data[1][2] .= ' '; + $table->data[1][2] .= html_print_input_text('time', ($save === true) ? date(TIME_FORMAT) : $time, '', 10, 7, true); + + $table->data[2][0] = ''; + $table->data[2][1] = ''; + $table->data[3][0] = html_print_input_text( + 'data', + $data, + __('Data'), + 40, + 60, + true + ); + $table->data[3][1] = html_print_div( + [ + 'class' => '', + 'content' => html_print_input_file('csv', true), + ], + true + ); echo ""; html_print_table($table); - echo "
"; html_print_input_hidden('save', 1); - html_print_submit_button(__('Save'), 'submit', ($id_agent === ''), 'class="sub next"'); - echo '
'; + + html_print_action_buttons( + html_print_submit_button( + __('Save'), + 'submit', + // (empty($id_agent) === true), + false, + [ 'icon' => 'next' ], + true + ), + ['type' => 'form_action'] + ); echo ''; @@ -257,8 +312,8 @@ function mainInsertData() $('#id_agent_module').enable(); $('#id_agent_module').fadeIn ('normal'); - $('#submit-submit').enable(); - $('#submit-submit').fadeIn ('normal'); + $('button [name="submit"]').removeClass('disabled_action_button'); + $('button [name="submit"]').fadeIn ('normal'); } }); } diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index a04e6a08dc..e554b34b51 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -266,24 +266,68 @@ function mainModuleGroups() ] ); - echo "
".__('Agents').' / '.__('Modules').'".__('Agents').' / '.__('Modules').'
- "; - echo ""; + $output = ""; - echo '
'; - echo __('Search by agent group').' '; - html_print_input_text('agent_group_search', $agent_group_search); + $output .= ""; + $output .= ''; + $output .= '
'; + $output .= html_print_label_input_block( + __('Search by agent group'), + html_print_input_text( + 'agent_group_search', + $agent_group_search, + '', + 50, + 255, + true + ) + ); - echo ''; - echo __('Search by module group').' '; - html_print_input_text('module_group_search', $module_group_search); + $output .= ''; + $output .= html_print_label_input_block( + __('Search by module group'), + html_print_input_text( + 'module_group_search', + $module_group_search, + '', + 50, + 255, + true + ) + ); + $output .= '
'; - echo '
'; - echo ""; - echo ''; - echo ''; - echo '
'; + $output .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + true + ); + + $output .= ''; + + ui_toggle( + $output, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); $cell_style = ' min-width: 60px; @@ -299,26 +343,35 @@ function mainModuleGroups() if ($info && $array_module_group) { $table = new StdClass(); - $table->style[0] = 'color: #ffffff; background-color: #373737; font-weight: bolder; min-width: 230px;'; + $table->class = 'info_table'; + $table->style[0] = 'font-weight: bolder; min-width: 230px;'; $table->width = '100%'; - if ($config['style'] === 'pandora_black' && !is_metaconsole()) { - $background_color = '#333'; - } else { - $background_color = '#fff'; - } - $head[0] = __('Groups'); $headstyle[0] = 'width: 20%; font-weight: bolder;'; foreach ($array_module_group as $key => $value) { - $headstyle[] = 'min-width: 60px;max-width: 5%;text-align:center; color: #ffffff; background-color: #373737; font-weight: bolder;'; - $head[] = ui_print_truncate_text($value, GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + $headstyle[] = 'min-width: 60px;max-width: 5%;text-align:center; font-weight: bolder;'; + $head[] = ui_print_truncate_text( + $value, + GENERIC_SIZE_TEXT, + true, + true, + true, + '…' + ); } $i = 0; foreach ($array_for_defect as $key => $value) { $deep = groups_get_group_deep($key); - $data[$i][0] = $deep.ui_print_truncate_text($value['data']['name'], GENERIC_SIZE_TEXT, true, true, true, '…', 'color:#FFF'); + $data[$i][0] = $deep.ui_print_truncate_text( + $value['data']['name'], + GENERIC_SIZE_TEXT, + true, + true, + true, + '…' + ); $j = 1; if (isset($array_data[$key])) { foreach ($value['gm'] as $k => $v) { @@ -378,25 +431,37 @@ function mainModuleGroups() $table->headstyle = $headstyle; $table->data = $data; - ui_pagination($counter); - echo "
"; html_print_table($table); echo '
'; - ui_pagination($counter); + $tablePagination = ui_pagination( + $counter, + false, + 0, + 0, + true, + 'offset', + false + ); - echo "
"; - echo ''; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo "'; - echo '
".__('Legend').'
".__('Orange cell when the module group and agent have at least one alarm fired.').'
".__('Red cell when the module group and agent have at least one module in critical status and the others in any status').'
".__('Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status').'
".__('Grey cell when the module group and agent have at least one in unknown status and the others in green status').'
".__('Green cell when the module group and agent have all modules in OK status').'
".__('Blue cell when the module group and agent have all modules in not init status.').'
'; - echo '
'; + html_print_action_buttons( + '', + [ 'right_content' => $tablePagination ] + ); + + $show_legend = '
'; + $show_legend .= ''; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= "'; + $show_legend .= '
".__('Orange cell when the module group and agent have at least one alarm fired.').'
".__('Red cell when the module group and agent have at least one module in critical status and the others in any status').'
".__('Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status').'
".__('Grey cell when the module group and agent have at least one in unknown status and the others in green status').'
".__('Green cell when the module group and agent have all modules in OK status').'
".__('Blue cell when the module group and agent have all modules in not init status.').'
'; + $show_legend .= '
'; + + ui_toggle($show_legend, __('Legend')); } else { ui_print_info_message(['no_close' => true, 'message' => __('This table shows in columns the modules group and in rows agents group. The cell shows all modules') ]); ui_print_info_message(['no_close' => true, 'message' => __('There are no defined groups or module groups') ]); diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 7cbb5607e1..9182380a95 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -151,7 +151,7 @@ function quickShell() 'name' => 'submit', 'label' => __('Retry'), 'type' => 'submit', - 'attributes' => 'class="sub next"', + 'attributes' => ['icon' => 'next'], 'return' => true, ], ], @@ -202,7 +202,7 @@ function quickShell() 'arguments' => [ 'type' => 'submit', 'label' => __('Connect'), - 'attributes' => 'class="sub next"', + 'attributes' => ['icon' => 'cog'], ], ], ], @@ -544,7 +544,7 @@ if (empty($agent_id) === false // TabName. __('QuickShell'), // TabIcon. - 'images/ehorus/terminal.png', + 'images/quick-shell@svg.svg', // TabFunction. 'quickShell', // Version. diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php index 8f978f0fac..133af5b3f8 100644 --- a/pandora_console/extensions/realtime_graphs.php +++ b/pandora_console/extensions/realtime_graphs.php @@ -74,61 +74,11 @@ function pandora_realtime_graphs() ); } - $chart[time()]['graph'] = '0'; - $interactive_graph = true; - $color = []; - $legend = ''; - $long_index = []; - $no_data_image = ''; - - $canvas = '
'; - $canvas .= '
'; - - $width = 800; - $height = 300; - - $data_array['realtime']['data'][0][0] = (time() - 10); - $data_array['realtime']['data'][0][1] = 0; - $data_array['realtime']['data'][1][0] = time(); - $data_array['realtime']['data'][1][1] = 0; - $data_array['realtime']['color'] = 'green'; - - $params = [ - 'agent_module_id' => false, - 'period' => 300, - 'width' => $width, - 'height' => $height, - 'unit' => $unit, - 'only_image' => $only_image, - 'homeurl' => $homeurl, - 'type_graph' => 'area', - 'font' => $config['fontpath'], - 'font-size' => $config['font_size'], - 'array_data_create' => $data_array, - 'show_legend' => false, - 'show_menu' => false, - ]; - - $canvas .= grafico_modulo_sparse($params); - - $canvas .= '
'; - echo $canvas; - $table = new stdClass(); $table->width = '100%'; $table->id = 'table-form'; - $table->class = 'databox filters'; + $table->class = 'filter-table-adv'; $table->style = []; - $table->cellpadding = '0'; - $table->cellspacing = '0'; - $table->style['graph'] = 'font-weight: bold;'; - $table->style['refresh'] = 'font-weight: bold;'; - $table->style['incremental'] = 'font-weight: bold;'; - $table->style['reset'] = 'font-weight: bold;'; - $table->style['snmp_address'] = 'font-weight: bold;'; - $table->style['snmp_community'] = 'font-weight: bold;'; - $table->style['snmp_oid'] = 'font-weight: bold;'; - $table->style['snmp_oid'] = 'font-weight: bold;'; $table->data = []; $graph_fields['cpu_load'] = __('%s Server CPU', get_product_name()); @@ -158,15 +108,22 @@ function pandora_realtime_graphs() $refresh = get_parameter('refresh', '1000'); if ($graph != 'snmp_module') { - $data['graph'] = __('Graph').'  '; - $data['graph'] .= html_print_select( - $graph_fields, - 'graph', - $graph, - '', - '', - 0, - true + $data['graph'] = html_print_label_input_block( + __('Graph'), + html_print_select( + $graph_fields, + 'graph', + $graph, + '', + '', + 0, + true, + false, + true, + '', + false, + 'width: 100%' + ) ); } @@ -179,18 +136,35 @@ function pandora_realtime_graphs() $agent_alias = io_safe_output(get_parameter('agent_alias', '')); $module_name = io_safe_output(get_parameter('module_name', '')); $module_incremental = get_parameter('incremental', 0); - $data['module_info'] = $agent_alias.': '.$module_name.''; - - // Append all the hidden in this cell. - $data['module_info'] .= html_print_input_hidden( - 'incremental', - $module_incremental, - true + $data['module_info'] = html_print_label_input_block( + $agent_alias.': '.$module_name, + html_print_input_hidden( + 'incremental', + $module_incremental, + true + ).html_print_select( + ['snmp_module' => '-'], + 'graph', + 'snmp_module', + '', + '', + 0, + true, + false, + true, + '', + false, + 'width: 100%; display: none;' + ) ); - $data['module_info'] .= html_print_select( - ['snmp_module' => '-'], - 'graph', - 'snmp_module', + } + + $data['refresh'] = html_print_label_input_block( + __('Refresh interval'), + html_print_select( + $refresh_fields, + 'refresh', + $refresh, '', '', 0, @@ -199,33 +173,17 @@ function pandora_realtime_graphs() true, '', false, - 'display: none;' + 'width: 100%' + ) + ); + + if ($graph != 'snmp_module') { + $data['incremental'] = html_print_label_input_block( + __('Incremental'), + html_print_checkbox_switch('incremental', 1, 0, true) ); } - $data['refresh'] = __('Refresh interval').'  '; - $data['refresh'] .= html_print_select( - $refresh_fields, - 'refresh', - $refresh, - '', - '', - 0, - true - ); - if ($graph != 'snmp_module') { - $data['incremental'] = __('Incremental').'  '; - $data['incremental'] .= html_print_checkbox('incremental', 1, 0, true); - } - - $data['reset'] = html_print_button( - __('Clear graph'), - 'reset', - false, - 'javascript:realtimeGraphs.clearGraph();', - 'class="sub delete mgn_tp_0" ', - true - ); $table->data[] = $data; if ($graph == 'snmp_interface' || $graph == 'snmp_module') { @@ -236,10 +194,79 @@ function pandora_realtime_graphs() html_print_input_hidden('rel_path', get_parameter('rel_path', '')); // Print the form. - echo '
'; - html_print_table($table); - echo '
'; + $searchForm = '
'; + $searchForm .= html_print_table($table, true); + $searchForm .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Clear graph'), + 'srcbutton', + false, + [ + 'icon' => 'delete', + 'mode' => 'mini', + 'onClick' => 'javascript:realtimeGraphs.clearGraph();', + ], + true + ), + ], + true + ); + $searchForm .= '
'; + ui_toggle( + $searchForm, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); + + $chart[time()]['graph'] = '0'; + $canvas = '
'; + $canvas .= '
'; + + $width = 800; + $height = 300; + + $data_array['realtime']['data'][0][0] = (time() - 10); + $data_array['realtime']['data'][0][1] = 0; + $data_array['realtime']['data'][1][0] = time(); + $data_array['realtime']['data'][1][1] = 0; + $data_array['realtime']['color'] = 'green'; + + $params = [ + 'agent_module_id' => false, + 'period' => 300, + 'width' => $width, + 'height' => $height, + 'only_image' => false, + 'type_graph' => 'area', + 'font' => $config['fontpath'], + 'font-size' => $config['font_size'], + 'array_data_create' => $data_array, + 'show_legend' => false, + 'show_menu' => false, + 'backgroundColor' => 'transparent', + ]; + + $canvas .= grafico_modulo_sparse($params); + + $canvas .= '
'; + + html_print_div( + [ + 'class' => 'white_box', + 'content' => $canvas, + ] + ); + + // echo $canvas; // Define a custom action to save // the OID selected in the SNMP browser to the form. html_print_input_hidden( diff --git a/pandora_console/extensions/realtime_graphs/realtime_graphs.css b/pandora_console/extensions/realtime_graphs/realtime_graphs.css index a5dfa19975..a839ad6ab0 100644 --- a/pandora_console/extensions/realtime_graphs/realtime_graphs.css +++ b/pandora_console/extensions/realtime_graphs/realtime_graphs.css @@ -12,6 +12,5 @@ #graph_container { width: 800px; margin: 20px auto; - background-color: white; border-radius: 3px; } diff --git a/pandora_console/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php index b6e594c744..905b389eee 100755 --- a/pandora_console/extensions/resource_exportation.php +++ b/pandora_console/extensions/resource_exportation.php @@ -1,16 +1,32 @@ \n"; break; @@ -224,18 +209,6 @@ function output_xml_report($id) echo '\n"; break; - case 'event_report_module': - break; - - case 'alert_report_module': - break; - - case 'alert_report_agent': - break; - - case 'alert_report_group': - break; - case 'url': echo ''; break; @@ -245,6 +218,29 @@ function output_xml_report($id) echo ''; echo ''; break; + + case 1: + case 'simple_graph': + case 'simple_baseline_graph': + case 6: + case 'monitor_report': + case 7: + case 'avg_value': + case 8: + case 'max_value': + case 9: + case 'min_value': + case 10: + case 'sumatory': + case 'agent_detailed_event': + case 'event_report_agent': + case 'event_report_module': + case 'alert_report_module': + case 'alert_report_agent': + case 'alert_report_group': + default: + // Do nothing. + break; } echo "\n"; @@ -417,25 +413,59 @@ function resource_exportation_extension_main() $hook_enterprise = enterprise_include('extensions/resource_exportation/functions.php'); - ui_print_page_header(__('Resource exportation'), 'images/extensions.png', false, '', true, ''); + ui_print_standard_header( + __('Resource exportation'), + 'images/extensions.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Resources'), + ], + [ + 'link' => '', + 'label' => __('Resource exporting'), + ], + ] + ); - echo '
'; - echo __('This extension makes exportation of resource template more easy.').' '.__('You can export resource templates in .ptr format.'); - echo '
'; - - echo '

'; + ui_print_warning_message( + __('This extension makes exportation of resource template more easy.').'
'.__('You can export resource templates in .ptr format.') + ); $table = new stdClass(); - $table->width = '100%'; - $table->style[0] = 'width: 30%;'; - $table->style[1] = 'width: 10%;'; - $table->class = 'databox filters'; - $table->data[0][0] = __('Report'); - $table->data[0][1] = html_print_select_from_sql('SELECT id_report, name FROM treport', 'report', '', '', '', 0, true); - $table->data[0][2] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'report\');', 'class="sub config"', true); - $table->data[1][0] = __('Visual console'); - $table->data[1][1] = html_print_select_from_sql('SELECT id, name FROM tlayout', 'visual_console', '', '', '', 0, true); - $table->data[1][2] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'visual_console\');', 'class="sub config"', true); + $table->class = 'databox filter-table-adv'; + $table->id = 'resource_exportation_table'; + $table->style = []; + $table->style[0] = 'width: 30%'; + $table->style[1] = 'vertical-align: bottom;'; + $table->data = []; + $table->data[0][] = html_print_label_input_block( + __('Report'), + html_print_div( + [ + 'class' => 'flex-content-left', + 'content' => html_print_select_from_sql('SELECT id_report, name FROM treport', 'report', '', '', '', 0, true), + ], + true + ) + ); + $table->data[0][] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'report\');', ['mode' => 'link'], true); + + $table->data[1][] = html_print_label_input_block( + __('Visual console'), + html_print_div( + [ + 'class' => 'flex-content-left', + 'content' => html_print_select_from_sql('SELECT id, name FROM tlayout', 'visual_console', '', '', '', 0, true), + ], + true + ) + ); + $table->data[1][] = html_print_button(__('Export'), '', false, 'export_to_ptr(\'visual_console\');', ['mode' => 'link'], true); if ($hook_enterprise === true) { add_rows_for_enterprise($table->data); diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index 732c0151ea..d76814e886 100755 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -1,4 +1,5 @@ group)); break; - case 'event_report_module': - break; - - case 'alert_report_module': - break; - - case 'alert_report_agent': - break; - - case 'alert_report_group': - break; - case 'url': $values['external_source'] = io_safe_input($item['url']); break; @@ -426,9 +384,32 @@ function process_upload_xml_report($xml, $group_filter=0) $values['line_separator'] = io_safe_input($item['line_separator']); $values['column_separator'] = io_safe_input($item['column_separator']); break; + + case 1: + case 'simple_graph': + case 'simple_baseline_graph': + case 6: + case 'monitor_report': + case 7: + case 'avg_value': + case 8: + case 'max_value': + case 9: + case 'min_value': + case 10: + case 'sumatory': + case 'event_report_module': + case 'alert_report_module': + case 'alert_report_agent': + case 'alert_report_group': + case 'agent_detailed_event': + case 'event_report_agent': + default: + // Do nothing. + break; } - if (empty($agents_item)) { + if (empty($agents_item) === true) { $id_content = db_process_sql_insert('treport_content', $values); ui_print_result_message( $id_content, @@ -782,7 +763,7 @@ function process_upload_xml_visualmap($xml, $filter_group=0) function process_upload_xml_component($xml) { - // Extract components + // Extract components. $components = []; foreach ($xml->xpath('/component') as $componentElement) { $name = io_safe_input((string) $componentElement->name); @@ -838,7 +819,7 @@ function process_upload_xml_component($xml) $idComponent = false; switch ((int) $componentElement->module_source) { case 1: - // Local component + // Local component. $values = [ 'description' => $description, 'id_network_component_group' => $group, @@ -854,12 +835,12 @@ function process_upload_xml_component($xml) // Network component // for modules // 15 = remote_snmp, 16 = remote_snmp_inc, - // 17 = remote_snmp_string, 18 = remote_snmp_proc + // 17 = remote_snmp_string, 18 = remote_snmp_proc. $custom_string_1 = ''; $custom_string_2 = ''; $custom_string_3 = ''; if ($type >= 15 && $type <= 18) { - // New support for snmp v3 + // New support for snmp v3. $tcp_send = $snmp_version; $plugin_user = $auth_user; $plugin_pass = $auth_password; @@ -909,13 +890,13 @@ function process_upload_xml_component($xml) 'post_process' => $post_process, ] ); - if ((bool) $idComponent) { + if ((bool) $idComponent === true) { $components[] = $idComponent; } break; case 4: - // Plugin component + // Plugin component. $idComponent = network_components_create_network_component( $name, $type, @@ -956,17 +937,13 @@ function process_upload_xml_component($xml) 'post_process' => $post_process, ] ); - if ((bool) $idComponent) { + if ((bool) $idComponent === true) { $components[] = $idComponent; } break; - case 5: - // Prediction component - break; - case 6: - // WMI component + // WMI component. $idComponent = network_components_create_network_component( $name, $type, @@ -1013,13 +990,17 @@ function process_upload_xml_component($xml) 'post_process' => $post_process, ] ); - if ((bool) $idComponent) { + if ((bool) $idComponent === true) { $components[] = $idComponent; } break; + case 5: + // Prediction component. case 7: - // Web component + // Web component. + default: + // Do nothing. break; } @@ -1030,9 +1011,9 @@ function process_upload_xml_component($xml) ); } - // Extract the template + // Extract the template. $templateElement = $xml->xpath('//template'); - if (!empty($templateElement)) { + if (empty($templateElement) === false) { $templateElement = $templateElement[0]; $templateName = (string) $templateElement->name; @@ -1092,9 +1073,26 @@ function resource_registration_extension_main() include_once $config['homedir'].'/include/functions_db.php'; enterprise_include_once('include/functions_local_components.php'); - ui_print_page_header(__('Resource registration'), 'images/extensions.png', false, '', true, ''); + ui_print_standard_header( + __('Resource registration'), + 'images/extensions.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Resources'), + ], + [ + 'link' => '', + 'label' => __('Resource registration'), + ], + ] + ); - if (!extension_loaded('libxml')) { + if (extension_loaded('libxml') === false) { ui_print_error_message(_('Error, please install the PHP libXML in the system.')); return; @@ -1119,15 +1117,42 @@ function resource_registration_extension_main() return; } - echo '
'; - echo __('This extension makes registering resource templates easier.').' '.__('Here you can upload a resource template in .ptr format.').' '.__('Please refer to our documentation for more information on how to obtain and use %s resources.', get_product_name()).' '.'

'.__('You can get more resurces in our Public Resource Library'); - echo '
'; + ui_print_warning_message( + __('This extension makes registering resource templates easier.').'
'.__('Here you can upload a resource template in .ptr format.').'
'.__('Please refer to our documentation for more information on how to obtain and use %s resources.', get_product_name()).' '.'

'.__('You can get more resurces in our Public Resource Library') + ); - echo '

'; + $table = new stdClass(); + $table->class = 'databox filter-table-adv'; + $table->id = 'resource_registration_table'; + + $table->data = []; + + $table->data[0][] = html_print_label_input_block( + __('File to upload'), + html_print_input_file('resource_upload', true) + ); + + $table->data[0][] = html_print_label_input_block( + __('Group filter'), + html_print_select_groups(false, 'AW', true, 'group', '', '', __('All'), 0, true) + ); // Upload form. - echo "
"; - echo ''; + echo ''; + html_print_table($table); + html_print_action_buttons( + html_print_submit_button( + __('Upload'), + 'upload', + false, + [ 'icon' => 'wand' ], + true + ), + ['type' => 'form_action'] + ); + echo ''; + /* + echo '
'; echo ''; echo "'; @@ -1136,8 +1161,7 @@ function resource_registration_extension_main() echo ''; echo "'; - echo '
"; echo ''.__('Group filter: ').'"; echo '
'; - echo ''; + echo '';*/ if (isset($_FILES['resource_upload']['tmp_name']) === false) { return; diff --git a/pandora_console/extras/mr/62.sql b/pandora_console/extras/mr/62.sql new file mode 100644 index 0000000000..f92441a5f0 --- /dev/null +++ b/pandora_console/extras/mr/62.sql @@ -0,0 +1,90 @@ +START TRANSACTION; + +UPDATE tconfig_os SET `icon_name` = 'linux@os.svg' WHERE `id_os` = 1; +UPDATE tconfig_os SET `icon_name` = 'solaris@os.svg' WHERE `id_os` = 2; +UPDATE tconfig_os SET `icon_name` = 'aix@os.svg' WHERE `id_os` = 3; +UPDATE tconfig_os SET `icon_name` = 'freebsd@os.svg' WHERE `id_os` = 4; +UPDATE tconfig_os SET `icon_name` = 'HP@os.svg' WHERE `id_os` = 5; +UPDATE tconfig_os SET `icon_name` = 'cisco@os.svg' WHERE `id_os` = 7; +UPDATE tconfig_os SET `icon_name` = 'apple@os.svg' WHERE `id_os` = 8; +UPDATE tconfig_os SET `icon_name` = 'windows@os.svg' WHERE `id_os` = 9; +UPDATE tconfig_os SET `icon_name` = 'other-OS@os.svg' WHERE `id_os` = 10; +UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 11; +UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 12; +UPDATE tconfig_os SET `icon_name` = 'network-server@os.svg' WHERE `id_os` = 13; +UPDATE tconfig_os SET `icon_name` = 'embedded@os.svg' WHERE `id_os` = 14; +UPDATE tconfig_os SET `icon_name` = 'android@os.svg' WHERE `id_os` = 15; +UPDATE tconfig_os SET `icon_name` = 'vmware@os.svg' WHERE `id_os` = 16; +UPDATE tconfig_os SET `icon_name` = 'routers@os.svg' WHERE `id_os` = 17; +UPDATE tconfig_os SET `icon_name` = 'switch@os.svg' WHERE `id_os` = 18; +UPDATE tconfig_os SET `icon_name` = 'satellite@os.svg' WHERE `id_os` = 19; +UPDATE tconfig_os SET `icon_name` = 'mainframe@os.svg' WHERE `id_os` = 20; +UPDATE tconfig_os SET `icon_name` = 'cluster@os.svg' WHERE `id_os` = 100; + +UPDATE tgrupo SET `icon` = 'servers@groups.svg' WHERE `id_grupo` = 2; +UPDATE tgrupo SET `icon` = 'firewall@groups.svg' WHERE `id_grupo` = 4; +UPDATE tgrupo SET `icon` = 'database@groups.svg' WHERE `id_grupo` = 8; +UPDATE tgrupo SET `icon` = 'network@groups.svg' WHERE `id_grupo` = 9; +UPDATE tgrupo SET `icon` = 'unknown@groups.svg' WHERE `id_grupo` = 10; +UPDATE tgrupo SET `icon` = 'workstation@groups.svg' WHERE `id_grupo` = 11; +UPDATE tgrupo SET `icon` = 'applications@groups.svg' WHERE `id_grupo` = 12; +UPDATE tgrupo SET `icon` = 'web@groups.svg' WHERE `id_grupo` = 13; + +UPDATE `ttipo_modulo` SET `icon` = 'data-server@svg.svg' WHERE `id_tipo` = 1; +UPDATE `ttipo_modulo` SET `icon` = 'generic-boolean@svg.svg' WHERE `id_tipo` = 2; +UPDATE `ttipo_modulo` SET `icon` = 'generic-string@svg.svg' WHERE `id_tipo` = 3; +UPDATE `ttipo_modulo` SET `icon` = 'data-server@svg.svg' WHERE `id_tipo` = 4; +UPDATE `ttipo_modulo` SET `icon` = 'data-server@svg.svg' WHERE `id_tipo` = 5; +UPDATE `ttipo_modulo` SET `icon` = 'ICMP-network-boolean-data@svg.svg' WHERE `id_tipo` = 6; +UPDATE `ttipo_modulo` SET `icon` = 'ICMP-network-latency@svg.svg' WHERE `id_tipo` = 7; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-numeric-data@svg.svg' WHERE `id_tipo` = 8; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-boolean-data@svg.svg' WHERE `id_tipo` = 9; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-alphanumeric-data@svg.svg' WHERE `id_tipo` = 10; +UPDATE `ttipo_modulo` SET `icon` = 'TCP-network-incremental-data@svg.svg' WHERE `id_tipo` = 11; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-numeric-data@svg.svg' WHERE `id_tipo` = 15; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-incremental-data@svg.svg' WHERE `id_tipo` = 16; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-alphanumeric-data@svg.svg' WHERE `id_tipo` = 17; +UPDATE `ttipo_modulo` SET `icon` = 'SNMP-network-incremental-data@svg.svg' WHERE `id_tipo` = 18; +UPDATE `ttipo_modulo` SET `icon` = 'asynchronus-data@svg.svg' WHERE `id_tipo` = 21; +UPDATE `ttipo_modulo` SET `icon` = 'asynchronus-data@svg.svg' WHERE `id_tipo` = 22; +UPDATE `ttipo_modulo` SET `icon` = 'asynchronus-data@svg.svg' WHERE `id_tipo` = 23; +UPDATE `ttipo_modulo` SET `icon` = 'wux@svg.svg' WHERE `id_tipo` = 25; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 30; +UPDATE `ttipo_modulo` SET `icon` = 'web-analisys-data@svg.svg' WHERE `id_tipo` = 31; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 32; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 33; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-numeric-data@svg.svg' WHERE `id_tipo` = 34; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-boolean-data@svg.svg' WHERE `id_tipo` = 35; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-alphanumeric-data@svg.svg' WHERE `id_tipo` = 36; +UPDATE `ttipo_modulo` SET `icon` = 'remote-execution-incremental-data@svg.svg' WHERE `id_tipo` = 37; +UPDATE `ttipo_modulo` SET `icon` = 'server-web@svg.svg' WHERE `id_tipo` = 38; +UPDATE `ttipo_modulo` SET `icon` = 'keepalive@svg.svg' WHERE `id_tipo` = 100; + +CREATE TABLE IF NOT EXISTS `tagent_filter` ( + `id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_name` VARCHAR(600) NOT NULL, + `id_group_filter` INT NOT NULL DEFAULT 0, + `group_id` INT NOT NULL DEFAULT 0, + `recursion` TEXT, + `status` INT NOT NULL DEFAULT -1, + `search` TEXT, + `id_os` INT NOT NULL DEFAULT 0, + `policies` TEXT, + `search_custom` TEXT, + `ag_custom_fields` TEXT, + PRIMARY KEY (`id_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE `tevent_sound` ( + `id` INT NOT NULL AUTO_INCREMENT, + `name` TEXT NULL, + `sound` TEXT NULL, + `active` TINYINT NOT NULL DEFAULT '1', +PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE INDEX agente_modulo_estado ON tevento (estado, id_agentmodule); +CREATE INDEX idx_disabled ON talert_template_modules (disabled); + +INSERT INTO `treport_custom_sql` (`name`, `sql`) VALUES ('Agent safe mode not enable', 'select alias from tagente where safe_mode_module = 0'); + +COMMIT; diff --git a/pandora_console/general/first_task/custom_fields.php b/pandora_console/general/first_task/custom_fields.php index c8767a3c48..11f9f30c2d 100644 --- a/pandora_console/general/first_task/custom_fields.php +++ b/pandora_console/general/first_task/custom_fields.php @@ -1,16 +1,32 @@ true, 'message' => __('There are no custom __('Custom Fields')]); ?>
-

+

true, 'message' => __('There are no custom ?>

+ 'action-buttons', + 'content' => html_print_submit_button( + __('Create Custom Fields'), + 'button_task', + false, + [ 'icon' => 'next' ], + true + ), + ] + ); + ?>
diff --git a/pandora_console/general/first_task/custom_graphs.php b/pandora_console/general/first_task/custom_graphs.php index 9429218133..96f4c1262b 100644 --- a/pandora_console/general/first_task/custom_graphs.php +++ b/pandora_console/general/first_task/custom_graphs.php @@ -15,9 +15,6 @@ global $config; check_login(); ui_require_css_file('first_task'); ?> - true, 'message' => __('There are no custom graphs defined yet.') ]); -?>
@@ -36,7 +33,17 @@ ui_print_info_message(['no_close' => true, 'message' => __('There are no custom ?>

- + 'wand'], + true + ) + ); + ?>
\ No newline at end of file diff --git a/pandora_console/general/first_task/map_builder.php b/pandora_console/general/first_task/map_builder.php index de964bf087..6091b45d61 100755 --- a/pandora_console/general/first_task/map_builder.php +++ b/pandora_console/general/first_task/map_builder.php @@ -1,28 +1,38 @@ true, - 'message' => __('There are no visual console defined yet.'), - ] -); if ($vconsoles_write || $vconsoles_manage) { ?> @@ -31,7 +41,7 @@ if ($vconsoles_write || $vconsoles_manage) { __('Visual Console')]); ?>
-

+

- - + 'wand'], + true + ) + ); + ?>
diff --git a/pandora_console/general/first_task/planned_downtime.php b/pandora_console/general/first_task/planned_downtime.php index 6bfbe5627b..a88a3e0fc3 100644 --- a/pandora_console/general/first_task/planned_downtime.php +++ b/pandora_console/general/first_task/planned_downtime.php @@ -1,16 +1,32 @@ __('Scehduled Downtime')]); ?>
-

+

- +
diff --git a/pandora_console/general/first_task/service_list.php b/pandora_console/general/first_task/service_list.php index f3b816c006..dae4eedb08 100755 --- a/pandora_console/general/first_task/service_list.php +++ b/pandora_console/general/first_task/service_list.php @@ -1,29 +1,44 @@ - true, 'message' => __('There are no services defined yet.') ]); ?>
- __('Services')]); ?> + __('Services'), 'class' => 'w120px']); ?>
-

+

- + 'wand'], + true + ) + ); + ?>
-
', $menuTypeClass); ?> -
+
', $menuTypeClass); // ======= Servers List =============================================== if ((bool) check_acl($config['id_user'], 0, 'AW') !== false) { - $servers_list = '
'; $servers = []; $servers['all'] = (int) db_get_value('COUNT(id_server)', 'tserver'); if ($servers['all'] != 0) { @@ -45,22 +44,33 @@ echo sprintf('
', $menuTypeClass); $servers['down'] = ($servers['all'] - $servers['up']); if ($servers['up'] == 0) { // All Servers down or no servers at all. - $servers_check_img = html_print_image('images/header_down_gray.png', true, ['alt' => 'cross', 'class' => 'bot', 'title' => __('All systems').': '.__('Down')]); + $servers_check_img = html_print_image('images/system_error@header.svg', true, ['alt' => 'cross', 'class' => 'main_menu_icon bot', 'title' => __('All systems').': '.__('Down')]); } else if ($servers['down'] != 0) { // Some servers down. - $servers_check_img = html_print_image('images/header_warning_gray.png', true, ['alt' => 'error', 'class' => 'bot', 'title' => $servers['down'].' '.__('servers down')]); + $servers_check_img = html_print_image('images/system_warning@header.svg', true, ['alt' => 'error', 'class' => 'main_menu_icon bot', 'title' => $servers['down'].' '.__('servers down')]); } else { // All servers up. - $servers_check_img = html_print_image('images/header_ready_gray.png', true, ['alt' => 'ok', 'class' => 'bot', 'title' => __('All systems').': '.__('Ready')]); + $servers_check_img = html_print_image('images/system_ok@header.svg', true, ['alt' => 'ok', 'class' => 'main_menu_icon bot', 'title' => __('All systems').': '.__('Ready')]); } unset($servers); // Since this is the header, we don't like to trickle down variables. - $servers_check_img_link = ''; - $servers_check_img_link .= $servers_check_img; - $servers_check_img_link .= ''; + $servers_check_img_link = html_print_anchor( + [ + 'href' => 'index.php?sec=gservers&sec2=godmode/servers/modificar_server&refr=60', + 'content' => $servers_check_img, + ], + true + ); }; - $servers_list .= $servers_check_img_link.'
'; + + $servers_list = html_print_div( + [ + 'id' => 'servers_list', + 'content' => $servers_check_img_link, + ], + true + ); } @@ -71,9 +81,9 @@ echo sprintf('
', $menuTypeClass); $check_minor_release_available = db_check_minor_relase_available(); - if ($check_minor_release_available) { + if ($check_minor_release_available === true) { if (users_is_admin($config['id_user'])) { - if ($config['language'] == 'es') { + if ($config['language'] === 'es') { set_pandora_error_for_header('Hay una o mas revisiones menores en espera para ser actualizadas. '.__('Sobre actualizaciรณn de revisiรณn menor').'', 'Revisiรณn/es menor/es disponible/s'); } else { set_pandora_error_for_header('There are one or more minor releases waiting for update. '.__('About minor release update').'', 'minor release/s available'); @@ -227,10 +237,10 @@ echo sprintf('
', $menuTypeClass); if ($do_refresh) { $autorefresh_img = html_print_image( - 'images/header_refresh_gray.png', + 'images/auto_refresh@header.svg', true, [ - 'class' => 'bot', + 'class' => 'main_menu_icon bot', 'alt' => 'lightning', 'title' => __('Configure autorefresh'), ] @@ -293,10 +303,10 @@ echo sprintf('
', $menuTypeClass); $display_counter = 'display:block'; } else { $autorefresh_img = html_print_image( - 'images/header_refresh_disabled_gray.png', + 'images/auto_refresh@header.svg', true, [ - 'class' => 'bot autorefresh_disabled invert_filter', + 'class' => 'main_menu_icon bot autorefresh_disabled invert_filter', 'alt' => 'lightning', 'title' => __('Disabled autorefresh'), ] @@ -312,10 +322,10 @@ echo sprintf('
', $menuTypeClass); } } else { $autorefresh_img = html_print_image( - 'images/header_refresh_disabled_gray.png', + 'images/auto_refresh@header.svg', true, [ - 'class' => 'bot autorefresh_disabled invert_filter', + 'class' => 'main_menu_icon bot autorefresh_disabled invert_filter', 'alt' => 'lightning', 'title' => __('Disabled autorefresh'), ] @@ -350,9 +360,10 @@ echo sprintf('
', $menuTypeClass); $header_feedback .= ''; $header_feedback .= ''; $header_feedback .= html_print_image( - 'images/feedback-header.png', + 'images/send_feedback@header.svg', true, [ + 'class' => 'main_menu_icon invert_filter', 'title' => __('Feedback'), 'id' => 'feedback-header', 'alt' => __('Feedback'), @@ -373,11 +384,11 @@ echo sprintf('
', $menuTypeClass); $header_support = '
'; $header_support .= ''; $header_support .= html_print_image( - 'images/header_support.png', + 'images/support@header.svg', true, [ 'title' => __('Go to support'), - 'class' => 'bot invert_filter', + 'class' => 'main_menu_icon bot invert_filter', 'alt' => 'user', ] ); @@ -387,11 +398,11 @@ echo sprintf('
', $menuTypeClass); $header_docu = '
'; $header_docu .= ''; $header_docu .= html_print_image( - 'images/header_docu.png', + 'images/documentation@header.svg', true, [ 'title' => __('Go to documentation'), - 'class' => 'bot invert_filter', + 'class' => 'main_menu_icon bot invert_filter', 'alt' => 'user', ] ); @@ -399,34 +410,38 @@ echo sprintf('
', $menuTypeClass); // User. - if (is_user_admin($config['id_user']) == 1) { - $header_user = html_print_image( - 'images/header_user_admin_green.png', - true, - [ - 'title' => __('Edit my user'), - 'class' => 'bot', - 'alt' => 'user', - ] - ); - } else { - $header_user = html_print_image( - 'images/header_user_green.png', - true, - [ - 'title' => __('Edit my user'), - 'class' => 'bot', - 'alt' => 'user', - ] - ); - } + // $headerUserImage = (is_user_admin($config['id_user']) === true) ? 'images/header_user_admin_green.png' : 'images/header_user_green.png'; + $headerUser = []; + $headerUser[] = html_print_image( + 'images/edit_user@header.svg', + true, + [ + 'title' => __('Edit my user'), + 'class' => 'main_menu_icon bot invert_filter', + 'alt' => 'user', + ] + ); - $header_user = ''; + $headerUser[] = sprintf('[ %s ]', $config['id_user']); + + $header_user = html_print_div( + [ + 'id' => 'header_user', + 'content' => html_print_anchor( + [ + 'href' => sprintf('index.php?sec=gusuarios&sec2=godmode/users/configure_user&edit_user=1&pure=0&id_user=%s', $config['id_user']), + 'content' => implode('', $headerUser), + ], + true + ), + ], + true + ); // Logout. $header_logout = '
'; $header_logout .= html_print_image( - 'images/header_logout_gray.png', + 'images/sign_out@header.svg', true, [ 'alt' => __('Logout'), diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index cd45f34f48..8517b1c46c 100755 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -30,16 +30,21 @@ require_once __DIR__.'/../include/functions_html.php'; if ($config['visual_animation']) { echo ''; } @@ -87,18 +92,36 @@ if (!empty($page) && !empty($sec)) { } $login_body_style = ''; -$login_body_class = ''; // Overrides the default background with the defined by the user. -if (!empty($config['login_background'])) { +$background_url = 'images/backgrounds/background_pandora_console_keys.jpg'; + +if (empty($config['random_background']) === false) { + $random_backgrounds = scandir($config['homedir'].'/images/backgrounds/random_backgrounds'); + unset($random_backgrounds[0], $random_backgrounds[1]); + $random_background = array_rand($random_backgrounds); + $background_url = 'images/backgrounds/random_backgrounds/'.$random_backgrounds[$random_background]; + $background_100 = 'background-size: 100% 100% !important; '; +} + +if (empty($config['login_background']) === false) { $background_url = 'images/backgrounds/'.$config['login_background']; - $login_body_style = "style=\"background-size: 100% 100% !important;background:linear-gradient(74deg, rgba(2, 2, 2, 0.333) 36%, transparent 36%), url('".$background_url."');\""; + $background_100 = 'background-size: 100% 100% !important; '; } // Support for Internet Explorer and Microsoft Edge browsers if (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false) { - $login_body_class = "class='login_body_trident'"; + $background_url = 'images/backgrounds/background_pandora_console_keys.jpg'; + $background_100 = ''; } +if (empty($config['background_opacity']) === false) { + $opacity = $config['background_opacity']; +} else { + $opacity = 30; +} + +$login_body_style = 'style="'.$background_100.'background: linear-gradient(rgba(0,0,0,.'.$opacity.'), rgba(0,0,0,.'.$opacity.")), url('".$background_url."');\""; + // Get alternative custom in case of db fail. $custom_fields = [ 'custom_logo_login', @@ -123,36 +146,36 @@ foreach ($custom_fields as $field) { // Get the custom icons. $docs_logo = ui_get_docs_logo(); $support_logo = ui_get_support_logo(); -echo '
'; +echo '
'; echo ''; echo ''; echo ''; echo ''; } else { echo ''; echo ''; } break; @@ -302,12 +348,13 @@ switch ($login_screen) { echo ''; echo ''; break; @@ -337,17 +384,18 @@ if ($config['enterprise_installed']) { echo ''.__('Forgot your password?'); echo ''; - echo ''; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'reset_correct_button', false); + html_print_submit_button('Ok', 'reset_correct_button', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo '
'; echo '
'; } else if (isset($process_error_message) && !empty($process_error_message)) { - echo '
'; + echo '
'; echo '
'; echo '
'; - echo html_print_image('images/icono_stop.png', true, ['alt' => __('Password reset'), 'border' => 0]); + echo html_print_image('images/icono_stop.png', true, ['alt' => __('Forbidden'), 'border' => 0]); echo '
'; echo '
'; echo '
'; echo '

'.__('ERROR').'

'; echo '

'.$process_error_message.'

'; + echo '
'; echo '
'; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'reset_correct_button', false); + html_print_submit_button('Ok', 'reset_correct_button', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo '
'; @@ -476,8 +551,9 @@ if (isset($correct_reset_pass_process)) { echo '

'.__('SUCCESS').'

'; echo '

'.$correct_reset_pass_process.'

'; echo '
'; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'final_process_correct_button', false); + html_print_submit_button('Ok', 'final_process_correct_button', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo '
'; @@ -485,9 +561,36 @@ if (isset($correct_reset_pass_process)) { } if (isset($login_failed)) { - $nick = get_parameter_post('nick'); - $fails = db_get_value('failed_attempt', 'tusuario', 'id_user', $nick); + $nick = io_safe_input(get_parameter_post('nick')); + $user_in_db = db_get_row_filter( + 'tusuario', + ['id_user' => $nick], + '*' + ); + $fails = $user_in_db['failed_attempt']; + // If user not exist, and attempts its enable, lets make array and fails attemps. + if ($fails == false && $config['enable_pass_policy'] && $user_in_db === false) { + $nick_array_error = json_decode(base64_decode($config['nicks_error']), true); + $nick = strtolower($nick); + if (isset($nick_array_error[$nick]) !== false) { + $nick_array_error[$nick] += 1; + } else { + $nick_array_error[$nick] = 1; + } + + $fails = $nick_array_error[$nick]; + // Save or update the array. + if ($config['nicks_error']) { + config_update_value('nicks_error', base64_encode(json_encode($nick_array_error))); + } else { + config_create_value('nicks_error', base64_encode(json_encode($nick_array_error))); + } + } else { + $fails = ++$fails; + } + $attemps = ($config['number_attempts'] - $fails); + $attemps = ($attemps < 0) ? 0 : $attemps; echo '
'; echo '
'; echo '
'; @@ -500,12 +603,18 @@ if (isset($login_failed)) { echo '
'; if ($config['enable_pass_policy']) { echo '
'; - echo '

Remaining attempts: '.$attemps.'

'; + if ($attemps !== 0 && $user_in_db['login_blocked'] == 0) { + echo '

'.__('Remaining attempts: ').$attemps.'

'; + } else { + echo '

'.__('User is blocked').'

'; + } + echo '
'; } + echo '
'; echo '
'; - html_print_submit_button('Ok', 'hide-login-error', false); + html_print_submit_button('Ok', 'hide-login-error', false, ['class' => ' mini float-right']); echo '
'; echo '
'; echo '
'; @@ -528,8 +637,9 @@ if ($login_screen == 'logout') { } echo '
'; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'hide-login-logout', false); + html_print_submit_button('Ok', 'hide-login-logout', false, ['class' => ' mini float-right']); echo '
'; echo '
'; echo '
'; @@ -547,8 +657,9 @@ if ($login_screen === 'disabled_access_node') { echo '

'.__('Centralized user in metaconsole').'

'; echo '

'.__('This user does not have access on node, please enable node access on this user from metaconsole.').'

'; echo '
'; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'hide-login-logout', false); + html_print_submit_button('Ok', 'hide-login-logout', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo '
'; @@ -655,8 +766,9 @@ if ($login_screen == 'error_authconfig' || $login_screen == 'error_emptyconfig' echo '

'.$title.'

'; echo '

'.$message.''; echo '

'; + echo '
'; echo '
'; - html_print_submit_button('Ok', 'hide-login-error', false); + html_print_submit_button('Ok', 'hide-login-error', false, ['class' => 'mini float-right']); echo '
'; echo '
'; echo '
'; @@ -711,7 +823,7 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-hide-login-error").click (function () { + $("#button-hide-login-error").click (function () { $("#modal_alert" ).dialog('close'); }); @@ -726,19 +838,23 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { opacity: 0.5, background: "black" + }, + open: function (event, ui) { + $(".ui-widget-overlay").click(function () { + $('#login_logout').dialog('close'); + }); } }); }); - $("#submit-hide-login-logout").click (function () { - document.location = ""; - }); + $("#button-hide-login-logout").click (function () { + $( "#login_logout" ).dialog( "close" ); + }); }); break; @@ -749,7 +865,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { @@ -759,7 +874,7 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-hide-login-logout").click (function () { + $("#button-hide-login-logout").click (function () { document.location = ""; }); }); @@ -773,7 +888,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 400, width: 700, overlay: { opacity: 0.5, @@ -791,8 +905,8 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, - width: 528, + height: 230, + width: 530, overlay: { opacity: 0.5, background: "black" @@ -800,12 +914,11 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-hide-login-error").click (function () { + $("#button-hide-login-error").click (function () { $("#login_failed" ).dialog('close'); $("#login_correct_pass").dialog('close'); }); }); - $('#nick').focus(); break; } @@ -816,7 +929,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { @@ -826,7 +938,7 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); }); - $("#submit-reset_correct_button").click (function () { + $("#button-reset_correct_button").click (function () { $("#reset_correct").dialog('close'); }); }); @@ -837,7 +949,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, clickOutside: true, overlay: { @@ -857,7 +968,6 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' resizable: true, draggable: true, modal: true, - height: 220, width: 528, overlay: { opacity: 0.5, @@ -870,5 +980,18 @@ html_print_div(['id' => 'forced_title_layer', 'class' => 'forced_title_layer', ' }); } + $(document).ready(function () { + $('#submit-login_button span').removeAttr('style'); + $('#spinner_login').hide(); + }); + + $('#submit-login_button').click(function (e) { + $('.login_nick').hide(); + $('.login_pass').hide(); + $('.login_button').hide(); + $('.reset_password').hide(); + $('#spinner_login').show(); + }); + /* ]]> */ diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 972e6f37ca..2b88b6a103 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -124,8 +124,14 @@ foreach ($stats as $stat) { } $status .= ''; +$table->rowclass = []; +$table->rowclass[0] = 'w100p'; +$table->rowclass[1] = 'w100p'; +$table->rowclass[2] = 'w100p'; +$table->rowclass[3] = 'w100p'; +$table->rowclass[4] = 'w100p'; +$table->rowclass[5] = 'w100p'; $table->data[0][0] = $status; -$table->rowclass[] = ''; $table->data[] = $tdata; diff --git a/pandora_console/general/main_menu.php b/pandora_console/general/main_menu.php index 3ce49b646a..a961a62ecb 100644 --- a/pandora_console/general/main_menu.php +++ b/pandora_console/general/main_menu.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,38 +26,21 @@ * ============================================================================ */ -use function PHPSTORM_META\map; - // Begin. if (isset($config['id_user']) === false) { include 'general/login_page.php'; exit(); } -?> - -', $menuTypeClass); + $url_logo = ui_get_full_url('index.php'); if (is_reporting_console_node() === true) { $url_logo = 'index.php?logged=1&sec=discovery&sec2=godmode/servers/discovery&wiz=tasklist'; @@ -76,311 +59,400 @@ html_print_div( ), ], true - ), + ).'
', ] ); -require 'operation/menu.php'; -require 'godmode/menu.php'; +$display_classic = ''; +$display_collapsed = 'display: none;'; +if ($menuTypeClass === 'collapsed') { + $display_classic = 'display: none;'; + $display_collapsed = ''; +} -html_print_div( - [ - 'id' => 'button_collapse', - 'class' => sprintf('button_collapse button_%s', $menuTypeClass), - ] -); + +// Tabs. +echo ''; -// Menu_container. -ui_require_jquery_file('cookie'); -$config_fixed_header = false; -if (isset($config['fixed_header']) === true) { - $config_fixed_header = $config['fixed_header']; -} +echo '
'; +require 'operation/menu.php'; +echo '
'; +echo '
'; +require 'godmode/menu.php'; +echo '
'; +echo '
'; ?> - - - diff --git a/pandora_console/general/mysqlerr.php b/pandora_console/general/mysqlerr.php index fe24117d3a..6368122da3 100644 --- a/pandora_console/general/mysqlerr.php +++ b/pandora_console/general/mysqlerr.php @@ -1,167 +1,77 @@ - - - - - - -
- -
- - - - /images/icono_cerrar.png'> -
- -
- /images/mysqlerr.png'> -
- -
-
- $value) { - if (preg_match('/._alt/i', $key)) { - $custom_conf_enabled = true; - break; - } +$custom_conf_enabled = false; +foreach ($config as $key => $value) { + if (preg_match('/._alt/i', $key)) { + $custom_conf_enabled = true; + break; } +} - if (!$custom_conf_enabled || isset($config['custom_docs_url_alt'])) { - if (isset($config['custom_docs_url_alt'])) { - $docs_url = $config['custom_docs_url_alt']; - } else { - $docs_url = 'https://pandorafms.com/manual/en/documentation/02_installation/04_configuration'; - } - - echo ' - -
- '.__('Documentation').' - -
-
- '; +if (empty($custom_conf_enabled) === true || isset($config['custom_docs_url_alt']) === true) { + if (isset($config['custom_docs_url_alt']) === true) { + $docs_url = $config['custom_docs_url_alt']; + } else { + $docs_url = 'https://pandorafms.com/manual/en/documentation/02_installation/04_configuration'; } +} + +echo '
'; + echo '
'; + echo '
'; + echo html_print_image('images/mysqlerr.png', true, ['alt' => __('Mysql error'), 'border' => 0]); + echo '
'; + echo '
'; + echo '
'; + echo '

'.__('Database error').'

'; + echo '

'.$message.'

'; + echo '
'; + echo '
'; + echo '
'; + html_print_submit_button( + __('Documentation'), + 'mysqlerr_button', + false, + ['class' => 'mini float-right'] + ); + echo '
'; + echo '
'; + echo '
'; + echo '
'; + ?> - ?> - - - -
- -
- - - diff --git a/pandora_console/general/pandora_help.php b/pandora_console/general/pandora_help.php index 9d0a5e79d6..c78c006a9f 100644 --- a/pandora_console/general/pandora_help.php +++ b/pandora_console/general/pandora_help.php @@ -77,7 +77,7 @@ if (! $id || ! file_exists($help_file)) { echo '
'.__("%s help system has been called with a help reference that currently don't exist. There is no help content to show.", get_product_name()).'
'; echo '

'; echo ''; echo ''; ?> diff --git a/pandora_console/godmode/agentes/agent_conf_gis.php b/pandora_console/godmode/agentes/agent_conf_gis.php index 6b80ed752a..ca213bae37 100644 --- a/pandora_console/godmode/agentes/agent_conf_gis.php +++ b/pandora_console/godmode/agentes/agent_conf_gis.php @@ -59,7 +59,7 @@ ui_print_warning_message( ] ); -$table = new StdClass(); +$table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; $table->data = []; diff --git a/pandora_console/godmode/agentes/agent_incidents.php b/pandora_console/godmode/agentes/agent_incidents.php index 796a3afd77..e7e442e7e3 100644 --- a/pandora_console/godmode/agentes/agent_incidents.php +++ b/pandora_console/godmode/agentes/agent_incidents.php @@ -59,23 +59,22 @@ $result = integria_api_call(null, null, null, null, 'get_incidents', $params, fa $result = json_decode($result, true); -$count = count($result); - -$result = array_slice($result, $offset, $config['block_size']); - -if (empty($result)) { +if (empty($result) === true) { $result = []; $count = 0; echo '
'.__('No incidents associated to this agent').'

'; return; +} else { + $count = count($result); + $result = array_slice($result, $offset, $config['block_size']); } -// Show pagination +// Show pagination. ui_pagination($count, $url, $offset, 0, false, 'offset'); // ($count + $offset) it's real count of incidents because it's use LIMIT $offset in query. echo '
'; -// Show headers +// Show headers. $table->width = '100%'; $table->class = 'databox'; $table->cellpadding = 4; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 836b68ba68..f524fb7d9e 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -1,11 +1,11 @@ '; echo '
'; // Custom ID. $custom_id_div = '
'; -$custom_id_div .= '

'.__('Custom ID').':

'; +$custom_id_div .= '

'.__('Custom ID').':

'; $custom_id_div .= html_print_input_text( 'custom_id', $custom_id, @@ -209,107 +206,214 @@ $custom_id_div .= html_print_input_text( 'agent_custom_id' ).'
'; -if (!$new_agent && $alias != '') { - $table_agent_name = '

'.__('Agent name').'

'; - $table_agent_name .= '
'; - $table_agent_name .= '
'.html_print_input_text('agente', $nombre_agente, '', 50, 100, true).'
'; - $table_agent_name .= '
'; +// Get groups. +$groups = users_get_groups($config['id_user'], 'AR', false); - if ($id_agente) { - $table_agent_name .= ''; - $table_agent_name .= ''; - $table_agent_name .= html_print_image( - 'images/zoom.png', - true, - [ - 'border' => 0, - 'title' => __('Agent detail'), - 'class' => 'invert_filter', - ] - ); - $table_agent_name .= ''; +// Get modules. +$modules = db_get_all_rows_sql( + 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo + WHERE id_agente = '.$id_parent +); +$modules_values = []; +$modules_values[0] = __('Any'); +if (is_array($modules) === true) { + foreach ($modules as $m) { + $modules_values[$m['id_module']] = $m['name']; } +} - $agent_options_update = 'agent_options_update'; - - // Delete link from here. - if (is_management_allowed() === true) { - $table_agent_name .= "".html_print_image( - 'images/cross.png', - true, - [ - 'title' => __('Delete agent'), - 'class' => 'invert_filter', - ] - ).''; - } - - // Remote configuration available. +// Remote configuration available. +if (isset($filename) === true && file_exists($filename['md5']) === true) { + $remote_agent = true; + $agent_md5 = md5(io_safe_output(agents_get_name($id_agente)), false); +} else { $remote_agent = false; - if (isset($filename)) { - if (file_exists($filename['md5'])) { - $remote_agent = true; +} - $agent_name = agents_get_name($id_agente); - $agent_name = io_safe_output($agent_name); - $agent_md5 = md5($agent_name, false); +// Get Servers. +$servers = servers_get_names(); +// Set the agent have not server. +if (array_key_exists($server_name, $servers) === false) { + $server_name = 0; +} - $table_agent_name .= ''; - $table_agent_name .= html_print_image( - 'images/application_edit.png', - true, - [ - 'border' => 0, - 'title' => __('This agent can be remotely configured'), - 'class' => 'invert_filter', - ] - ); - $table_agent_name .= ''; +if ($new_agent === true) { + // Set first server by default. + $servers_get_names = $servers; + $array_keys_servers_get_names = array_keys($servers_get_names); + $server_name = reset($array_keys_servers_get_names); +} + + +// QR Code table. +if ($new_agent === false) { + $CodeQRContent .= html_print_div(['id' => 'qr_container_image'], true); + $CodeQRContent .= html_print_anchor( + [ + 'id' => 'qr_code_agent_view', + 'href' => ui_get_full_url('mobile/index.php?page=agent&id='.$id_agente), + ], + true + ); + $CodeQRContent .= '
'.$custom_id_div; + + // QR code div. + $CodeQRTable = html_print_div( + [ + 'class' => 'agent_qr', + 'content' => $CodeQRContent, + ], + true + ); +} else { + $CodeQRTable = ''; +} + +// Advanced mode. +if (enterprise_installed() === true) { + // Safe operation mode. + if ($new_agent === false) { + $sql_modules = db_get_all_rows_sql( + 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo + WHERE id_agente = '.$id_agente + ); + $safe_mode_modules = []; + $safe_mode_modules[0] = __('Any'); + if (is_array($sql_modules) === true) { + foreach ($sql_modules as $m) { + $safe_mode_modules[$m['id_module']] = $m['name']; + } } } - $table_agent_name .= '
'; - - // QR code div. - $table_qr_code = '
'; - $table_qr_code .= '

'.__('QR Code Agent view').'

'; - $table_qr_code .= '
'; - if ($id_agente) { - $table_qr_code .= ""; + // Calculate cps value - agents. + if ($new_agent === false) { + $cps_val = service_agents_cps($id_agente); + } else { + // No agent defined, use received cps as base value. + if ($cps >= 0) { + $cps_val = $cps; + } } - // Add Custom id div. - $table_qr_code .= '
'; - $table_qr_code .= $custom_id_div; - $table_qr_code .= '
'; + // Parent agents. + $paramsParentAgent = []; + $paramsParentAgent['return'] = true; + $paramsParentAgent['show_helptip'] = false; + $paramsParentAgent['input_name'] = 'id_parent'; + $paramsParentAgent['print_hidden_input_idagent'] = true; + $paramsParentAgent['hidden_input_idagent_name'] = 'id_agent_parent'; + $paramsParentAgent['hidden_input_idagent_value'] = $id_parent; + $paramsParentAgent['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent); + $paramsParentAgent['selectbox_id'] = 'cascade_protection_module'; + $paramsParentAgent['javascript_is_function_select'] = true; + $paramsParentAgent['cascade_protection'] = true; + $paramsParentAgent['input_style'] = 'width: 100%;'; + + if ($id_agente !== 0) { + // Deletes the agent's offspring. + $paramsParentAgent['delete_offspring_agents'] = $id_agente; + } } -if ($new_agent) { - $label_select_child_left = 'label_select_child_left'; - $label_select_parent = 'label_select_parent'; +$listIcons = gis_get_array_list_icons(); + +$arraySelectIcon = []; +foreach ($listIcons as $index => $value) { + $arraySelectIcon[$index] = $index; } -$table_alias = '

'.__('Alias').'

'; -$table_alias .= '
'; -$table_alias .= '
'.html_print_input_text('alias', $alias, '', 50, 100, true, false, true).'
'; -if ($new_agent) { - $table_alias .= '
'.html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true).__('Use alias as name').'
'; +// Agent icons. +$path = 'images/gis_map/icons/'; +// TODO set better method the path. +$table_adv_agent_icon = '

'.__('Agent icon').'

'; +if ($icon_path == '') { + $display_icons = 'none'; + // Hack to show no icon. Use any given image to fix not found image errors. + $path_without = 'images/spinner.gif'; + $path_default = 'images/spinner.gif'; + $path_ok = 'images/spinner.gif'; + $path_bad = 'images/spinner.gif'; + $path_warning = 'images/spinner.gif'; +} else { + $display_icons = ''; + $path_without = $path.$icon_path.'.default.png'; + $path_default = $path.$icon_path.'.default.png'; + $path_ok = $path.$icon_path.'.ok.png'; + $path_bad = $path.$icon_path.'.bad.png'; + $path_warning = $path.$icon_path.'.warning.png'; } -$table_alias .= '
'; +$tableAgent = new stdClass(); +$tableAgent->class = 'floating_form primary_form'; +$tableAgent->data = []; +$tableAgent->style = []; +$tableAgent->cellclass = []; +$tableAgent->colspan = []; +$tableAgent->rowspan = []; -$table_ip = '

'.__('IP Address').'

'; -$table_ip .= '
'; -$table_ip .= '
'.html_print_input_text('direccion', $direccion_agente, '', 16, 100, true).'
'; -$table_ip .= '
'.html_print_checkbox_switch('unique_ip', 1, $config['unique_ip'], true).__('Unique IP').'
'; -$table_ip .= '
'.html_print_input( +// Agent name. +if ($new_agent === false) { + $tableAgent->data['caption_name'][0] = __('Agent name'); + $tableAgent->rowclass['name'] = 'w540px'; + $tableAgent->cellstyle['name'][0] = 'width: 100%;'; + $tableAgent->data['name'][0] = html_print_input_text('agente', $nombre_agente, '', 76, 100, true, false, false, '', 'w100p'); + $tableAgent->data['name'][0] .= html_print_div( + [ + 'class' => 'moduleIdBox', + 'content' => __('ID').' '.$id_agente.'', + ], + true + ); + // Agent options for QR code. + $agent_options_update = 'agent_options_update'; +} + +// Alias. +$tableAgent->data['caption_alias'][0] = __('Alias'); +$tableAgent->rowclass['alias'] = 'w540px'; +$tableAgent->data['alias'][0] = html_print_input_text('alias', $alias, '', 50, 100, true, false, true, '', 'w540px'); +if ($new_agent === true) { + $tableAgent->rowclass['additional_alias'] = 'subinput'; + $tableAgent->data['additional_alias'][0] = html_print_checkbox_switch('alias_as_name', 1, $config['alias_as_name'], true); + $tableAgent->data['additional_alias'][1] = __('Use alias as name'); +} else { + if ($remote_agent === true) { + $tableAgent->data['alias'][0] .= html_print_anchor( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=remote_configuration&id_agente='.$id_agente.'&disk_conf='.$agent_md5, + 'content' => html_print_image( + 'images/remote-configuration@svg.svg', + true, + [ + 'border' => 0, + 'title' => __('This agent can be remotely configured'), + 'class' => 'invert_filter after_input_icon', + ] + ), + ], + true + ); + } +} + +// Ip adress. +$tableAgent->data['caption_ip_address'] = __('IP Address'); +$tableAgent->rowclass['ip_address'] = 'w540px'; +$tableAgent->data['ip_address'][0] = html_print_input_text('direccion', $direccion_agente, '', 16, 100, true, false, false, '', 'w540px'); + +$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( [ 'type' => 'switch', 'id' => 'fixed_ip', 'name' => 'fixed_ip', 'value' => $fixed_ip, ] -).__('Fix IP address').'

'.ui_print_help_tip(__('Avoid automatic IP address update when agent IP changes.'), true).'

'; +); $table_ip .= '
'; @@ -336,48 +440,73 @@ $modules = db_get_all_rows_sql( 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo WHERE id_agente = '.$id_parent ); -$modules_values = []; -$modules_values[0] = __('Any'); -if (is_array($modules)) { - foreach ($modules as $m) { - $modules_values[$m['id_module']] = $m['name']; - } +$tableAgent->data['additional_ip_address'][3] = __('Fix IP address'); +$tableAgent->data['additional_ip_address'][3] .= ui_print_help_tip(__('Avoid automatic IP address update when agent IP changes.'), true); + +// IP Address List. +if ($new_agent === false) { + $tableAgent->data['caption_ip_address_list'] = __('IP Address list'); + $tableAgent->data['ip_address_list'][0] = html_print_select(agents_get_addresses($id_agente), 'address_list', $direccion_agente, '', '', 0, true, false, true, 'w540px'); + $tableAgent->rowclass['additional_ip_address_list'] = 'subinput'; + $tableAgent->data['additional_ip_address_list'][0] = html_print_checkbox_switch('delete_ip', 1, false, true); + $tableAgent->data['additional_ip_address_list'][1] = __('Delete selected IPs'); } -$table_primary_group = '

'.__('Primary group').'

'; -$table_primary_group .= '
'; -// Cannot change primary group if user have not permission for that group. -if (isset($groups[$grupo]) || $new_agent) { - $table_primary_group .= html_print_input( - [ - 'type' => 'select_groups', - 'returnAllGroup' => false, - 'name' => 'grupo', - 'selected' => $grupo, - 'return' => true, - 'required' => true, - 'privilege' => 'AW', - ] +// Select primary group. +$tableAgent->data['caption_primary_group'][0] = __('Primary group'); +if (isset($groups[$grupo]) === true || $new_agent === true) { + $tableAgent->rowclass['primary_group'] = 'w540px'; + // Cannot change primary group if user have not permission for that group. + $tableAgent->data['primary_group'][0] = html_print_select_groups( + false, + 'AW', + false, + 'grupo', + $grupo, + '', + '', + 0, + true, + false, + true, + '', + false, + '', + '', + false, + 'id_grupo', + false, + false, + false, + '540px', + false, + true, ); } else { - $table_primary_group .= groups_get_name($grupo); - $table_primary_group .= html_print_input_hidden('grupo', $grupo, true); + $tableAgent->data['primary_group'][0] .= groups_get_name($grupo); + $tableAgent->data['primary_group'][0] .= html_print_input_hidden('grupo', $grupo, true); } -$table_primary_group .= '
'; -if ($id_agente === 0) { - $hidden = 'display: none;'; -} else { - $hidden = ''; -} +$tableAgent->data['primary_group'][0] .= html_print_div( + [ + 'content' => ui_print_group_icon( + $grupo, + true, + '', + ($id_agente === 0) ? 'display: none;' : '', + true, + false, + false, + 'after_input_icon' + ), + ], + true +); -$table_primary_group .= ui_print_group_icon($grupo, true, 'groups_small', $hidden); - -$table_primary_group .= '
'; - -$table_interval = '

'.__('Interval').'

'; -$table_interval .= '
'; -$table_interval .= html_print_extended_select_for_time( +$tableAgent->data['caption_interval'][0] = __('Interval'); +// $tableAgent->rowstyle['interval'] = 'width: 260px'; +$tableAgent->rowclass['interval'] = 'w540px'; +$tableAgent->data['interval'][0] = html_print_extended_select_for_time( 'intervalo', $intervalo, '', @@ -387,61 +516,82 @@ $table_interval .= html_print_extended_select_for_time( true, false, true, - 'w40p' + 'w33p' ); - - if ($intervalo < SECONDS_5MINUTES) { - $table_interval .= clippy_context_help('interval_agent_min'); + $tableAgent->data['interval'][0] .= clippy_context_help('interval_agent_min'); } -$table_interval .= '
'; - -$table_os = '

'.__('OS').'

'; -$table_os .= '
'; -$table_os .= html_print_select_from_sql( +$tableAgent->data['caption_os'][0] = __('OS'); +$tableAgent->rowclass['os'] = 'w540px'; +$tableAgent->data['os'][0] = html_print_select_from_sql( 'SELECT id_os, name FROM tconfig_os', 'id_os', $id_os, '', '', '0', + true, + false, + true, + false, + 'width: 540px;' +); +$tableAgent->data['os'][0] .= html_print_div( + [ + 'class' => 'after_input_icon', + 'id' => 'os_preview', + 'content' => ui_print_os_icon( + $id_os, + false, + true + ), + ], true ); -$table_os .= '
'; -$table_os .= ui_print_os_icon($id_os, false, true); -$table_os .= '
'; -// Network server. -$servers = servers_get_names(); -// Set the agent have not server. -if (array_key_exists($server_name, $servers) === false) { - $server_name = 0; -} - -$table_server = '

'.__('Server').'

'; -$table_server .= '
'; -if ($new_agent) { - // Set first server by default. - $servers_get_names = $servers; - $array_keys_servers_get_names = array_keys($servers_get_names); - $server_name = reset($array_keys_servers_get_names); -} - -$table_server .= html_print_select( +$tableAgent->data['caption_server'][0] = __('Server'); +$tableAgent->rowclass['server'] = 'w540px'; +$tableAgent->data['server'][0] = html_print_select( $servers, 'server_name', $server_name, '', __('None'), 0, - true -).'
'; + true, + false, + true, + 'w540px', + false, + 'width: 540px;' +); +// Description. +$tableAgent->data['caption_description'][0] = __('Description'); +$tableAgent->rowclass['description'] = 'w540px'; +$tableAgent->data['description'][0] = html_print_textarea( + 'comentarios', + 3, + 80, + $comentarios, + '', + true, + 'agent_description w540px' +); -$table_satellite = ''; -if ($remote_agent === true) { +html_print_div( + [ + 'class' => 'box-flat white_table_flex white_box agent_details_col', + 'style' => 'display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px', + 'content' => html_print_table($tableAgent, true).$CodeQRTable, + ] +); +/* + TODO REVIEW + $table_satellite = ''; + if ($remote_agent === true) { // Satellite server selector. $satellite_servers = db_get_all_rows_filter( 'tserver', @@ -473,148 +623,70 @@ if ($remote_agent === true) { ] ).'
'; } -} + } +*/ -// Description. -$table_description = '

'.__('Description').'

'; -$table_description .= html_print_textarea( - 'comentarios', - 3, - 10, - $comentarios, - '', - true, - 'agent_description' -).'
'; - -// QR code. -echo '
-
-
'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'
-
'.$table_interval.$table_os.$table_server.$table_satellite.$table_description.'
-
'; -if (!$new_agent && $alias != '') { - echo $table_qr_code; -} - -echo '
'; - -if (enterprise_installed()) { - $adv_secondary_groups_label = '
'; - $adv_secondary_groups_label .= '

'; - $adv_secondary_groups_label .= __('Secondary groups'); - $adv_secondary_groups_label .= '

'; - $adv_secondary_groups_label .= '
'; - $select_agent_secondary = html_print_select_agent_secondary( +// Advanced options. +$tableAdvancedAgent = new stdClass(); +$tableAdvancedAgent->class = 'filter-table-adv floating_form primary_form'; +$tableAdvancedAgent->data = []; +$tableAdvancedAgent->style = []; +$tableAdvancedAgent->cellclass = []; +$tableAdvancedAgent->colspan = []; +$tableAdvancedAgent->rowspan = []; +// Secondary groups. +$tableAdvancedAgent->data['secondary_groups'][] = html_print_label_input_block( + __('Secondary groups'), + html_print_select_agent_secondary( $agent, $id_agente - ); + ) +); - // Safe operation mode. - if ($id_agente) { - $sql_modules = db_get_all_rows_sql( - 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo - WHERE id_agente = '.$id_agente - ); - $safe_mode_modules = []; - $safe_mode_modules[0] = __('Any'); - if (is_array($sql_modules)) { - foreach ($sql_modules as $m) { - $safe_mode_modules[$m['id_module']] = $m['name']; - } - } - - $table_adv_safe = '

'.__('Safe operation mode').'

'; - $table_adv_safe .= html_print_checkbox_switch('safe_mode', 1, $safe_mode, true); - $table_adv_safe .= __('Module').' '.html_print_select($safe_mode_modules, 'safe_mode_module', $safe_mode_module, '', '', 0, true).'
'; - } - - // Remote configuration. - $table_adv_remote = '

'.__('Remote configuration').'

'; - - if (!$new_agent && isset($filename) && file_exists($filename['md5'])) { - $table_adv_remote .= date('F d Y H:i:s', fileatime($filename['md5'])); - // Delete remote configuration. - $table_adv_remote .= ''; - $table_adv_remote .= html_print_image( - 'images/cross.png', - true, - [ - 'title' => __('Delete remote configuration file'), - 'style' => 'vertical-align: middle;', - 'class' => 'invert_filter', - ] - ).''; - $table_adv_remote .= ''; - } else { - $table_adv_remote .= ''.__('Not available').''; - } - - $table_adv_remote .= '
'; +// Parent agent. +$tableAdvancedAgent->data['parent_agent'][] = html_print_label_input_block( + __('Parent'), + ui_print_agent_autocomplete_input($paramsParentAgent) +); - // Calculate cps value - agents. - if ($id_agente) { - $cps_val = service_agents_cps($id_agente); - } else { - // No agent defined, use received cps as base value. - if ($cps >= 0) { - $cps_val = $cps; - } - } - - $cps_html = '
'; - $cps_html .= html_print_checkbox_switch('cps', $cps_val, ($cps >= 0), true); - $cps_html .= __('Cascade protection services').' '; - $cps_html .= '
'; - - $table_adv_cascade .= $cps_html; -} - -$table_adv_parent = '
'; -$params = []; -$params['return'] = true; -$params['show_helptip'] = true; -$params['input_name'] = 'id_parent'; -$params['print_hidden_input_idagent'] = true; -$params['hidden_input_idagent_name'] = 'id_agent_parent'; -$params['hidden_input_idagent_value'] = $id_parent; -$params['value'] = db_get_value('alias', 'tagente', 'id_agente', $id_parent); -$params['selectbox_id'] = 'cascade_protection_module'; -$params['javascript_is_function_select'] = true; -$params['cascade_protection'] = true; -if ($id_agente !== 0) { - // Deletes the agent's offspring. - $params['delete_offspring_agents'] = $id_agente; -} - -$table_adv_parent .= '
'; -$table_adv_parent .= ui_print_agent_autocomplete_input($params); -if (enterprise_installed()) { - $table_adv_parent .= html_print_checkbox_switch( +if (enterprise_installed() === true) { + $cascadeProtectionContents = []; + $cascadeProtectionContents[] = html_print_checkbox_switch( 'cascade_protection', 1, $cascade_protection, true - ).__('Cascade protection').' '; + ); - $table_adv_parent .= __('Module').' '.html_print_select( + $cascadeProtectionContents[] = html_print_select( $modules_values, 'cascade_protection_module', $cascade_protection_module, '', '', 0, - true + true, + false, + true, + 'w220p' + ); + + $tableAdvancedAgent->data['caption_cascade_protection'][] = html_print_label_input_block( + __('Cascade protection modules'), + html_print_div( + [ + 'class' => 'flex-row-center', + 'content' => implode('', $cascadeProtectionContents), + ], + true + ) ); } -$table_adv_parent .= '
'; - -// Learn mode / Normal mode. -$table_adv_module_mode = '

'.__('Module definition').'

'; -$table_adv_module_mode .= '
'; -$table_adv_module_mode .= html_print_radio_button_extended( +// Module Definition (Learn mode). +$switchButtons = []; +$switchButtons[] = html_print_radio_button_extended( 'modo', 1, __('Learning mode'), @@ -624,7 +696,7 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= html_print_radio_button_extended( +$switchButtons[] = html_print_radio_button_extended( 'modo', 0, __('Normal mode'), @@ -634,7 +706,7 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= html_print_radio_button_extended( +$switchButtons[] = html_print_radio_button_extended( 'modo', 2, __('Autodisable mode'), @@ -644,23 +716,73 @@ $table_adv_module_mode .= html_print_radio_button_extended( '', true ); -$table_adv_module_mode .= '
'; -// Status (Disabled / Enabled). -$table_adv_status = '
'; -$table_adv_status .= html_print_checkbox_switch( - 'disabled', - 1, - $disabled, - true +$tableAdvancedAgent->data['module_definition'][] = html_print_label_input_block( + __('Module definition'), + html_print_div( + [ + 'class' => 'switch_radio_button', + 'content' => implode('', $switchButtons), + ], + true + ) +); + +// CPS - Cascade Protection Services. +$tableAdvancedAgent->data['cps_value'][] = html_print_label_input_block( + __('Cascade protection services'), + html_print_checkbox_switch('cps', $cps_val, ($cps >= 0), true) +); + +// Update GIS data. +if ((bool) $config['activate_gis'] === true) { + $tableAdvancedAgent->data['gis'][] = html_print_label_input_block( + __('Update new GIS data'), + html_print_checkbox_switch('update_gis_data', 1, ($new_agent === true), true) + ); +} + +// Agent Icons. +$tableAdvancedAgent->data['agent_icon'][] = html_print_label_input_block( + __('Agent icon'), + html_print_select( + $arraySelectIcon, + 'icon_path', + $icon_path, + 'changeIcons();', + __('None'), + '', + true, + false, + true, + 'w540px' + ).html_print_image( + $path_ok, + true, + [ + 'id' => 'icon_ok', + 'style' => 'display:'.$display_icons.';', + ] + ).html_print_image( + $path_bad, + true, + [ + 'id' => 'icon_bad', + 'style' => 'display:'.$display_icons.';', + ] + ).html_print_image( + $path_warning, + true, + [ + 'id' => 'icon_warning', + 'style' => 'display:'.$display_icons.';', + ] + ) ); -$table_adv_status .= '

'.__('Disabled mode').'

'; -$table_adv_status .= '
'; // Url address. -if (enterprise_installed()) { - $table_adv_url = '

'.__('Url address').'

'; - $table_adv_url .= html_print_input_text( +if (enterprise_installed() === true) { + $urlAddressInput = html_print_input_text( 'url_description', $url_description, '', @@ -670,152 +792,131 @@ if (enterprise_installed()) { false, false, '', - '', + 'w540px', '', // Autocomplete. 'new-password' - ).'
'; + ); } else { - $table_adv_url = '

'.__('Url address').'

'; - $table_adv_url .= html_print_input_text( + $urlAddressInput = html_print_input_text( 'url_description', $url_description, '', 45, 255, true - ).''; + ); } -$table_adv_quiet = '
'; -$table_adv_quiet .= html_print_checkbox_switch('quiet', 1, $quiet, true); -$table_adv_quiet .= '

'.__('Quiet').'

'; -$table_adv_quiet .= '
'; +$tableAdvancedAgent->data['url_description'][] = html_print_label_input_block( + __('URL Address'), + $urlAddressInput +); -$listIcons = gis_get_array_list_icons(); +// Agent status. +$tableAdvancedAgent->data['agent_status'][] = html_print_label_input_block( + __('Disabled mode'), + html_print_checkbox_switch( + 'disabled', + 1, + $disabled, + true + ) +); -$arraySelectIcon = []; -foreach ($listIcons as $index => $value) { - $arraySelectIcon[$index] = $index; +// Quiet mode. +$tableAdvancedAgent->data['agent_quiet'][] = html_print_label_input_block( + __('Quiet'), + html_print_checkbox_switch('quiet', 1, $quiet, true) +); + +// Remote configuration. +if ($new_agent === false && isset($filename) === true && file_exists($filename['md5']) === true) { + $remoteConfigurationElements = []; + $remoteConfigurationElements[] = html_print_input_text( + 'remote_file_timestamp', + date('F d Y H:i:s', fileatime($filename['md5'])), + '', + 0, + 100, + true, + true, + false, + '', + 'w540px' + ); + $remoteConfigurationElements[] = html_print_anchor( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&disk_conf_delete=1&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/delete.svg', + true, + [ + 'border' => 0, + 'title' => __('Delete remote configuration file'), + 'class' => 'invert_filter after_input_icon', + ] + ), + ], + true + ); + + $tableAdvancedAgent->data['remote_configuration'][] = html_print_label_input_block( + __('Remote configuration'), + html_print_div( + [ + 'class' => 'flex-row-center', + 'content' => implode('', $remoteConfigurationElements), + ], + true + ) + ); } -$path = 'images/gis_map/icons/'; -// TODO set better method the path. -$table_adv_agent_icon = '

'.__('Agent icon').'

'; -if ($icon_path == '') { - $display_icons = 'none'; - // Hack to show no icon. Use any given image to fix not found image errors. - $path_without = 'images/spinner.gif'; - $path_default = 'images/spinner.gif'; - $path_ok = 'images/spinner.gif'; - $path_bad = 'images/spinner.gif'; - $path_warning = 'images/spinner.gif'; -} else { - $display_icons = ''; - $path_without = $path.$icon_path.'.default.png'; - $path_default = $path.$icon_path.'.default.png'; - $path_ok = $path.$icon_path.'.ok.png'; - $path_bad = $path.$icon_path.'.bad.png'; - $path_warning = $path.$icon_path.'.warning.png'; -} - -$table_adv_agent_icon .= html_print_select( - $arraySelectIcon, - 'icon_path', - $icon_path, - 'changeIcons();', - __('None'), - '', +// Safe operation mode. +$safeOperationElements = []; +$safeOperationElements[] = html_print_checkbox_switch( + 'safe_mode', + 1, + $safe_mode, true -).html_print_image( - $path_ok, - true, - [ - 'id' => 'icon_ok', - 'style' => 'display:'.$display_icons.';', - ] -).html_print_image( - $path_bad, - true, - [ - 'id' => 'icon_bad', - 'style' => 'display:'.$display_icons.';', - ] -).html_print_image( - $path_warning, - true, - [ - 'id' => 'icon_warning', - 'style' => 'display:'.$display_icons.';', - ] -).'
'; +); +$safeOperationElements[] = html_print_select( + $safe_mode_modules, + 'safe_mode_module', + $safe_mode_module, + '', + '', + 0, + true +); -if ($config['activate_gis']) { - $table_adv_gis = '

'.__('Update new GIS data:').'

'; - if ($new_agent) { - $update_gis_data = true; - } +$tableAdvancedAgent->data['safe_operation'][] = html_print_label_input_block( + __('Safe operation mode'), + html_print_div( + [ + 'class' => 'flex-row-center', + 'content' => implode('', $safeOperationElements), + ], + true + ) +); - $table_adv_gis .= html_print_checkbox_switch('update_gis_data', 1, $update_gis_data, true).'No / Yes
'; -} - - -if (enterprise_installed()) { - $advanced_div = '
'; -} else { - $advanced_div = ''; - -$table_adv_options .= '
'; -$table_adv_options .= $table_adv_parent; -$table_adv_options .= $table_adv_module_mode; -$table_adv_options .= $table_adv_cascade; - -if ($new_agent) { - // If agent is new, show custom id as old style format. - $table_adv_options .= $custom_id_div; -} - -$table_adv_options .= '
'; - -$table_adv_options .= ' -
- '.$table_adv_gis.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.' -
'; - -if (enterprise_installed()) { - echo '
'; +if (enterprise_installed() === true) { ui_toggle( - $table_adv_options, - __('Advanced options'), + html_print_table($tableAdvancedAgent, true), + ''.__('Advanced options').'', '', '', true, false, - 'white_box white_box_opened', - 'no-border flex' + 'white_box_content', + 'no-border white_table_graph' ); - echo '
'; } -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'custom_fields_table'; - -$table->head = [ - 0 => __('Click to display'), -]; -$table->class = 'info_table'; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->data = []; -$table->rowstyle = []; +// Custom fields. +$customOutputData = ''; $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -823,13 +924,8 @@ if ($fields === false) { $fields = []; } -$i = 0; foreach ($fields as $field) { - $id_custom_field = $field['id_field']; - - $data[0] = '
'; - $data[0] .= ''.$field['name'].''; - $data[0] .= '
'; + // Filling the data. $combo = []; $combo = $field['combo_values']; $combo = explode(',', $combo); @@ -851,15 +947,8 @@ foreach ($fields as $field) { $custom_value = ''; } - $table->rowstyle[$i] = 'cursor: pointer;user-select: none;'; - if (!empty($custom_value)) { - $table->rowstyle[($i + 1)] = 'display: table-row;'; - } else { - $table->rowstyle[($i + 1)] = 'display: none;'; - } - - if ($field['is_password_type']) { - $data_field[1] = html_print_input_text_extended( + if ((bool) $field['is_password_type'] === true) { + $customContent = html_print_input_text_extended( 'customvalue_'.$field['id_field'], $custom_value, 'customvalue_'.$field['id_field'], @@ -887,7 +976,7 @@ foreach ($fields as $field) { 2, 65, $link_text, - 'class="min-height-30px', + 'class="min-height-30px w100p"', true ); $data_field[1] .= '
'; @@ -898,22 +987,22 @@ foreach ($fields as $field) { 2, 65, $link_url, - 'class="min-height-30px', + 'class="min-height-30px w100p"', true ); } else { - $data_field[1] = html_print_textarea( + $customContent = html_print_textarea( 'customvalue_'.$field['id_field'], 2, 65, $custom_value, - 'class="min-height-30px', + 'class="min-height-30px w100p"', true ); } - if ($field['combo_values'] !== '') { - $data_field[1] = html_print_input( + if (empty($field['combo_values']) === false) { + $customContent = html_print_input( [ 'type' => 'select_search', 'fields' => $combo_values, @@ -929,61 +1018,32 @@ foreach ($fields as $field) { ); }; - $table->rowid[] = 'name_field-'.$id_custom_field; - $table->data[] = $data; - - $table->rowid[] = 'field-'.$id_custom_field; - $table->data[] = $data_field; - $i += 2; + $customOutputData .= ui_toggle( + html_print_div( + [ 'content' => $customContent ], + true + ), + $field['name'], + $field['name'], + 'custom_field_toggle_'.$field['id_field'], + true, + true, + ); } -if (enterprise_installed()) { - if (!empty($fields)) { - echo '
'; - ui_toggle( - html_print_table($table, true), - __('Custom fields'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border' - ); - echo '
'; - } -} else { - echo '
'; +if (empty($fields) === false) { ui_toggle( - $table_adv_options, - __('Advanced options'), + $customOutputData, + ''.__('Custom fields').'', '', '', true, false, - 'white_box white_box_opened', - 'no-border flex' + 'white_box white_box_opened white_table_graph_fixed', + 'no-border custom_fields_elements' ); - if (!empty($fields)) { - ui_toggle( - html_print_table($table, true), - __('Custom fields'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border' - ); - } - - echo '
'; - - echo '
'; } -echo '
'; - // The context help about the learning mode. if ($modo == 0) { echo ""; @@ -994,28 +1054,51 @@ if ($modo == 0) { echo clippy_context_help('modules_not_learning_mode'); echo ''; - -if ($id_agente) { - echo '
'; - html_print_submit_button( +if ($new_agent === false) { + $actionButtons = html_print_submit_button( __('Update'), 'updbutton', false, - 'class="sub upd"' + [ 'icon' => 'update'], + true ); - html_print_input_hidden('update_agent', 1); - html_print_input_hidden('id_agente', $id_agente); + $actionButtons .= html_print_input_hidden('update_agent', 1); + $actionButtons .= html_print_input_hidden('id_agente', $id_agente); + + if (is_management_allowed() === true) { + $actionButtons .= html_print_button( + __('Delete agent'), + 'deleteAgent', + false, + 'deleteAgentDialog('.$id_agente.')', + [ + 'icon' => 'delete', + 'mode' => 'secondary dialog_opener', + ], + true + ); + } } else { - html_print_submit_button( + $actionButtons = html_print_input_hidden('create_agent', 1); + $actionButtons .= html_print_submit_button( __('Create'), 'crtbutton', false, - 'class="sub wand"' + [ 'icon' => 'wand'], + true ); - html_print_input_hidden('create_agent', 1); } -echo '
'; +$actionButtons .= html_print_go_back_button( + 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente', + ['button_class' => ''], + true +); + +html_print_action_buttons($actionButtons, ['type' => 'form_action']); + +echo '
'; +echo ''; ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('ajaxqueue'); @@ -1035,6 +1118,15 @@ ui_require_jquery_file('bgiframe'); } } + function deleteAgentDialog($idAgente) { + confirmDialog({ + title: "", + message: "", + onAccept: function() { + window.location.assign('index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&borrar_agente='+$idAgente); + } + }); + } //Use this function for change 3 icons when change the selectbox function changeIcons() { diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 933b37fbce..ea5c8176c8 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -1,20 +1,35 @@ $id_agente, 'id_tipo_modulo' => $row2['type'], @@ -113,14 +129,14 @@ if (isset($_POST['template_id'])) { $name = $row2['name']; - // Put tags in array if the component has to add them later - if (!empty($row2['tags'])) { + // Put tags in array if the component has to add them later. + if (empty($row2['tags']) === false) { $tags = explode(',', $row2['tags']); } else { $tags = []; } - // Check if this module exists in the agent + // Check if this module exists in the agent. $module_name_check = db_get_value_filter('id_agente_modulo', 'tagente_modulo', ['delete_pending' => 0, 'nombre' => $name, 'id_agente' => $id_agente]); if ($module_name_check !== false) { @@ -132,13 +148,13 @@ if (isset($_POST['template_id'])) { if ($id_agente_modulo === false) { $error_count++; } else { - if (!empty($tags)) { - // Creating tags + if (empty($tags) === false) { + // Creating tags. $tag_ids = []; foreach ($tags as $tag_name) { $tag_id = tags_get_id($tag_name); - // If tag exists in the system we store to create it + // If tag exists in the system we store to create it. $tag_ids[] = $tag_id; } @@ -152,7 +168,7 @@ if (isset($_POST['template_id'])) { } if ($error_count > 0) { - if (empty($modules_already_added)) { + if (empty($modules_already_added) === true) { ui_print_error_message(__('Error adding modules').sprintf(' (%s)', $error_count)); } else { ui_print_error_message(__('Error adding modules. The following errors already exists: ').implode(', ', $modules_already_added)); @@ -168,8 +184,6 @@ if (isset($_POST['template_id'])) { // ========================== // TEMPLATE ASSIGMENT FORM // ========================== -echo '
'; - $nps = db_get_all_fields_in_table('tnetwork_profile', 'name'); if ($nps === false) { $nps = []; @@ -180,44 +194,45 @@ foreach ($nps as $row) { $select[$row['id_np']] = $row['name']; } -echo ''; -echo "'; -echo ''; -echo ''; -echo ''; -echo '
"; -html_print_select($select, 'template_id', '', '', '', 0, false, false, true, '', false, 'max-width: 200px !important'); -echo ''; -html_print_submit_button(__('Assign'), 'crt', false, 'class="sub next mgn_tp_0"'); -echo '
'; -echo ''; +$filterTable = new stdClass(); +$filterTable->width = '100%'; +$filterTable->class = 'fixed_filter_bar'; +$filterTable->data = []; +$filterTable->data[0][0] = __('Module templates'); +$filterTable->data[1][0] = html_print_select($select, 'template_id', '', '', '', 0, true, false, true, '', false, 'max-width: 200px !important'); +$filterTable->data[1][1] = html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Assign'), + 'crt', + false, + [ + 'icon' => 'wand', + 'mode' => 'secondary mini', + ], + true + ), + ], + true +); + +$outputFilterTable = '
'; +$outputFilterTable .= html_print_table($filterTable, true); +$outputFilterTable .= '
'; + +echo $outputFilterTable; // ========================== // MODULE VISUALIZATION TABLE // ========================== -switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $sql = sprintf( - 'SELECT * - FROM tagente_modulo - WHERE id_agente = %d AND delete_pending = false - ORDER BY id_module_group, nombre', - $id_agente - ); - break; - - case 'oracle': - $sql = sprintf( - 'SELECT * - FROM tagente_modulo - WHERE id_agente = %d - AND (delete_pending <> 1 AND delete_pending IS NOT NULL) - ORDER BY id_module_group, dbms_lob.substr(nombre,4000,1)', - $id_agente - ); - break; -} +$sql = sprintf( + 'SELECT * + FROM tagente_modulo + WHERE id_agente = %d AND delete_pending = false + ORDER BY id_module_group, nombre', + $id_agente +); $result = db_get_all_rows_sql($sql); if ($result === false) { @@ -233,10 +248,10 @@ $table->head = []; $table->data = []; $table->align = []; -$table->head[0] = __('Module name'); -$table->head[1] = __('Type'); -$table->head[2] = __('Description'); -$table->head[3] = __('Action'); +$table->head[0] = ''.__('Module name').''; +$table->head[1] = ''.__('Type').''; +$table->head[2] = ''.__('Description').''; +$table->head[3] = ''.__('Action').''; $table->align[1] = 'left'; $table->align[3] = 'left'; @@ -245,27 +260,43 @@ $table->size[1] = '5%'; $table->size[3] = '8%'; foreach ($result as $row) { + $table->cellclass[][3] = 'table_action_buttons'; + $data = []; $data[0] = ''.$row['nombre']; - if ($row['id_tipo_modulo'] > 0) { - $data[1] = html_print_image('images/'.modules_show_icon_type($row['id_tipo_modulo']), true, ['border' => '0', 'class' => 'invert_filter']); - } else { - $data[1] = ''; - } - + $data[1] = ($row['id_tipo_modulo'] > 0) ? ui_print_moduletype_icon($row['id_tipo_modulo'], true, false, true) : ''; $data[2] = mb_substr($row['descripcion'], 0, 60); - - $table->cellclass[][3] = 'action_buttons'; - $data[3] = ''.html_print_image('images/cross.png', true, ['class' => 'invert_filter', 'border' => '0', 'alt' => __('Delete'), 'onclick' => "if (!confirm('".__('Are you sure?')."')) return false;"]).''; - $data[3] .= ''.html_print_image('images/config.png', true, ['class' => 'invert_filter', 'border' => '0', 'alt' => __('Update')]).''; + $data[3] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente.'&delete_module='.$row['id_agente_modulo'], + 'image' => 'images/delete.svg', + 'title' => __('Delete'), + 'onClick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;', + ], + true + ); + $data[3] .= html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&tab=module&edit_module=1&id_agent_module='.$row['id_agente_modulo'], + 'image' => 'images/edit.svg', + 'title' => __('Edit'), + ], + true + ); array_push($table->data, $data); } -if (!empty($table->data)) { - html_print_table($table); - unset($table); +if (empty($table->data) === false) { + $output = html_print_table($table, true); } else { - ui_print_empty_data(__('No modules')); + $output = ui_print_empty_data(__('No modules'), '', true); } + +html_print_div( + [ + 'class' => 'datatable_form', + 'content' => $output, + ] +); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index ab01bbf47f..27f3b7ea3a 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -295,7 +295,6 @@ if ($create_agent) { 'fixed_ip' => $fixed_ip, ] ); - enterprise_hook('update_agent', [$id_agente]); } else { $id_agente = false; } @@ -377,86 +376,89 @@ $img_style = [ if ($id_agente) { // View tab. - $viewtab['text'] = ''.html_print_image( - 'images/eye.png', - true, + $viewtab['text'] = html_print_anchor( [ - 'title' => __('View'), - 'class' => 'invert_filter', - ] - ).''; - - if ($tab == 'view') { - $viewtab['active'] = true; - } else { - $viewtab['active'] = false; - } + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/enable.svg', + true, + [ + 'title' => __('View'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); + $viewtab['active'] = ($tab === 'view'); $viewtab['operation'] = 1; // Main tab. - $maintab['text'] = ''.html_print_image( - 'images/gm_setup.png', - true, + $maintab['text'] = html_print_anchor( [ - 'title' => __('Setup'), - 'class' => 'invert_filter', - ] - ).''; - if ($tab == 'main') { - $maintab['active'] = true; - } else { - $maintab['active'] = false; - } + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=main&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/configuration@svg.svg', + true, + [ + 'title' => __('Setup'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); + + $maintab['active'] = ($tab === 'main'); // Module tab. - $moduletab['text'] = ''.html_print_image( - 'images/gm_modules.png', - true, + $moduletab['text'] = html_print_anchor( [ - 'title' => __('Modules'), - 'class' => 'invert_filter', - ] - ).''; + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/modules@svg.svg', + true, + [ + 'title' => __('Modules'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); - if ($tab == 'module') { - $moduletab['active'] = true; - } else { - $moduletab['active'] = false; - } + $moduletab['active'] = ($tab === 'module'); // Alert tab. - $alerttab['text'] = ''.html_print_image( - 'images/gm_alerts.png', - true, + $alerttab['text'] = html_print_anchor( [ - 'title' => __('Alerts'), - 'class' => 'invert_filter', - ] - ).''; + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente, + 'content' => html_print_image( + 'images/alert@svg.svg', + true, + [ + 'title' => __('Alerts'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); - if ($tab == 'alert') { - $alerttab['active'] = true; - } else { - $alerttab['active'] = false; - } + $alerttab['active'] = ($tab === 'alert'); // Template tab. - $templatetab['text'] = ''.html_print_image( - 'images/templates.png', - true, + $templatetab['text'] = html_print_menu_button( [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=template&id_agente='.$id_agente, + 'image' => 'images/modules-group@svg.svg', 'title' => __('Module templates'), - 'class' => 'invert_filter', - ] - ).''; - - if ($tab == 'template') { - $templatetab['active'] = true; - } else { - $templatetab['active'] = false; - } + ], + true + ); + $templatetab['active'] = ($tab === 'template'); // Inventory. $inventorytab['text'] = ''.html_print_image( @@ -474,11 +476,11 @@ if ($id_agente) { $inventorytab['active'] = false; } - if ($inventorytab == -1) { + $inventorytab = enterprise_hook('inventory_tab'); + if ($inventorytab === ENTERPRISE_NOT_HOOK) { $inventorytab = ''; } - $has_remote_conf = enterprise_hook( 'config_agents_has_remote_configuration', [$id_agente] @@ -490,7 +492,7 @@ if ($id_agente) { if ($has_remote_conf === true) { // Plugins. $pluginstab = enterprise_hook('plugins_tab'); - if ($pluginstab == -1) { + if ($pluginstab === ENTERPRISE_NOT_HOOK) { $pluginstab = ''; } } else { @@ -500,60 +502,60 @@ if ($id_agente) { // Collection. if ((int) $config['license_nms'] !== 1) { $collectiontab = enterprise_hook('collection_tab'); - - if ($collectiontab == -1) { + if ($collectiontab === ENTERPRISE_NOT_HOOK) { $collectiontab = ''; } + } else { + $collectiontab = ''; } // NetworkConfigManager tab. $ncm_tab = enterprise_hook('networkconfigmanager_tab'); - if ($ncm_tab === ENTERPRISE_NOT_HOOK) { $ncm_tab = ''; } // Group tab. - $grouptab['text'] = ''.html_print_image( - 'images/group.png', - true, + $grouptab['text'] = html_print_menu_button( [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&ag_group='.$group, + 'image' => 'images/groups@svg.svg', 'title' => __('Group'), - 'class' => 'invert_filter', - ] - ).''; + ], + true + ); $grouptab['active'] = false; $gistab = []; - // GIS tab. - if ($config['activate_gis']) { - $gistab['text'] = ''.html_print_image( - 'images/gm_gis.png', - true, - [ - 'title' => __('GIS data'), - 'class' => 'invert_filter', - ] - ).''; + // TODO. OVERRIDE. + $config['activate_gis'] = true; - if ($tab == 'gis') { - $gistab['active'] = true; - } else { - $gistab['active'] = false; - } + // GIS tab. + if ((bool) $config['activate_gis'] === true) { + $gistab['text'] = html_print_menu_button( + [ + 'href' => 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=gis&id_agente='.$id_agente, + 'image' => 'images/poi@svg.svg', + 'title' => __('GIS data'), + ], + true + ); + + $gistab['active'] = ($tab === 'gis'); } // Agent wizard tab. - $agent_wizard['text'] = ''.html_print_image( - 'images/wand_agent.png', - true, + $agent_wizard['text'] = html_print_menu_button( [ + 'href' => 'javascript:', + 'class' => 'agent_wizard_tab', + 'image' => 'images/wizard@svg.svg', 'title' => __('Agent wizard'), - 'class' => 'invert_filter', - ] - ).''; + ], + true + ); // Hidden subtab layer. $agent_wizard['sub_menu'] = '
'; echo ''; echo ''; @@ -398,21 +409,31 @@ if ($id_profile || $new_profile) { html_print_table($table); - echo '
'; - if ($new_profile) { - html_print_submit_button(__('Add'), 'crt', false, 'class="sub wand"'); + $actionButtons = []; + + if ($new_profile === true) { + $actionButtons[] = html_print_submit_button(__('Create profile'), 'crt', false, [ 'icon' => 'wand' ], true); html_print_input_hidden('create_profile', 1); } else { + $actionButtons[] = html_print_submit_button(__('Update'), 'upd', false, [ 'icon' => 'update' ], true); html_print_input_hidden('id', $id_profile); html_print_input_hidden('old_name_profile', $name); html_print_input_hidden('update_profile', 1); - html_print_submit_button(__('Update'), 'upd', false, 'class="sub upd"'); } - echo '
'; -} + $actionButtons[] = html_print_go_back_button( + ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/profile_list&tab=profile&pure=0'), + ['button_class' => ''], + true + ); -enterprise_hook('close_meta_frame'); + html_print_action_buttons( + implode('', $actionButtons), + ['type' => 'form_action'] + ); + + echo ''; +} ?> diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 513f7c83de..468d789e0f 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -1,4 +1,5 @@ 'Gray', - 'blue-marble' => 'Blue marble', - 'night-electric' => 'Night Electric', - 'living' => 'Living Earth', - ]; - - $local_file = 'include/javascript/timezonepicker/images/gray-400.png'; - - // Dimensions must always be exact since the imagemap does not scale. - $array_size = getimagesize($local_file); - - $map_width = $array_size[0]; - $map_height = $array_size[1]; - - $timezones = timezone_picker_parse_files( - $map_width, - $map_height, - 'include/javascript/timezonepicker/tz_world.txt', - 'include/javascript/timezonepicker/tz_islands.txt' - ); - - - foreach ($timezones as $timezone_name => $tz) { - if ($timezone_name == 'America/Montreal') { - $timezone_name = 'America/Toronto'; - } else if ($timezone_name == 'Asia/Chongqing') { - $timezone_name = 'Asia/Shanghai'; - } - - $area_data_timezone_polys .= ''; - foreach ($tz['polys'] as $coords) { - $area_data_timezone_polys .= ''; - } - - $area_data_timezone_rects .= ''; - foreach ($tz['rects'] as $coords) { - $area_data_timezone_rects .= ''; - } - } -} - // This defines the working user. Beware with this, old code get confusses // and operates with current logged user (dangerous). $id = get_parameter('id', get_parameter('id_user', '')); +// Check if we are the same user for edit or we have a proper profile for edit users. +if ($id !== $config['id_user']) { + if ((is_centralized() === true) || (bool) check_acl($config['id_user'], 0, 'UM') === false) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access User Management' + ); + include 'general/noaccess.php'; + + return; + } +} + // ID given as parameter. $pure = get_parameter('pure', 0); - $user_info = get_user_info($id); $is_err = false; -if ((bool) check_acl($config['id_user'], 0, 'UM') === false) { - db_pandora_audit( - AUDIT_LOG_ACL_VIOLATION, - 'Trying to access User Management' - ); - include 'general/noaccess.php'; - - return; -} - if (is_ajax() === true) { $delete_profile = (bool) get_parameter('delete_profile'); $get_user_profile = (bool) get_parameter('get_user_profile'); @@ -268,44 +222,50 @@ if (is_ajax() === true) { } } -enterprise_hook('open_meta_frame'); - $tab = get_parameter('tab', 'user'); +// Save autorefresh list. +$autorefresh_list = (array) get_parameter_post('autorefresh_list'); +$autorefresh_white_list = (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) ? '' : json_encode($autorefresh_list); + // Header. if (is_metaconsole() === true) { user_meta_print_header(); $sec = 'advanced'; } else { - $buttons = [ - 'user' => [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/user.png', - true, - [ - 'title' => __('User management'), - 'class' => 'invert_filter', - ] - ).'', - ], - 'profile' => [ - 'active' => false, - 'text' => ''.html_print_image( - 'images/profiles.png', - true, - [ - 'title' => __('Profile management'), - 'class' => 'invert_filter', - ] - ).'', - ], - ]; + if ((bool) check_acl($config['id_user'], 0, 'UM') === false) { + $buttons = []; + } else { + $buttons = [ + 'user' => [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/user.svg', + true, + [ + 'title' => __('User management'), + 'class' => 'invert_filter main_menu_icon', + ] + ).'', + ], + 'profile' => [ + 'active' => false, + 'text' => ''.html_print_image( + 'images/suitcase@svg.svg', + true, + [ + 'title' => __('Profile management'), + 'class' => 'invert_filter main_menu_icon', + ] + ).'', + ], + ]; - $buttons[$tab]['active'] = true; + $buttons[$tab]['active'] = true; + } ui_print_standard_header( - (empty($id) === false) ? __('Update user') : __('Create user'), + (empty($id) === false) ? sprintf('%s [ %s ]', __('Update User'), $id) : __('Create User'), 'images/gm_users.png', false, '', @@ -337,6 +297,7 @@ if ((bool) $config['user_can_update_info'] === true) { $view_mode = true; } +$delete_profile = (is_ajax() === true) ? (bool) get_parameter('delete_profile') : false; $new_user = (bool) get_parameter('new_user'); $create_user = (bool) get_parameter('create_user'); $add_profile = (bool) get_parameter('add_profile'); @@ -442,13 +403,13 @@ if ($create_user === true) { $values['block_size'] = (int) get_parameter('block_size', $config['block_size']); $values['section'] = get_parameter('section'); - if (($values['section'] === 'Event list') || ($values['section'] === 'Group view') || ($values['section'] === 'Alert detail') || ($values['section'] === 'Tactical view') || ($values['section'] === 'Default')) { + if (($values['section'] === HOME_SCREEN_EVENT_LIST) || ($values['section'] === HOME_SCREEN_GROUP_VIEW) || ($values['section'] === HOME_SCREEN_ALERT_DETAIL) || ($values['section'] === HOME_SCREEN_TACTICAL_VIEW) || ($values['section'] === HOME_SCREEN_DEFAULT)) { $values['data_section'] = ''; - } else if ($values['section'] === 'Dashboard') { + } else if ($values['section'] === HOME_SCREEN_DASHBOARD) { $values['data_section'] = $dashboard; - } else if (io_safe_output($values['section']) === 'Visual console') { + } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === 'Other' || io_safe_output($values['section']) === 'External link') { + } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { $values['data_section'] = get_parameter('data_section'); } @@ -582,7 +543,7 @@ if ($create_user === true) { $user_info = get_user_info($id); $new_user = false; - if (!empty($json_profile)) { + if (empty($json_profile) === false) { $json_profile = json_decode(io_safe_output($json_profile), true); foreach ($json_profile as $key => $profile) { if (is_array($profile) === false) { @@ -723,13 +684,13 @@ if ($update_user) { $values['block_size'] = get_parameter('block_size', $config['block_size']); $values['section'] = get_parameter('section'); - if (($values['section'] === 'Event list') || ($values['section'] === 'Group view') || ($values['section'] === 'Alert detail') || ($values['section'] === 'Tactical view') || ($values['section'] === 'Default')) { + if (($values['section'] === HOME_SCREEN_EVENT_LIST) || ($values['section'] === HOME_SCREEN_GROUP_VIEW) || ($values['section'] === HOME_SCREEN_ALERT_DETAIL) || ($values['section'] === HOME_SCREEN_TACTICAL_VIEW) || ($values['section'] === HOME_SCREEN_DEFAULT)) { $values['data_section'] = ''; - } else if ($values['section'] === 'Dashboard') { + } else if ($values['section'] === HOME_SCREEN_DASHBOARD) { $values['data_section'] = $dashboard; - } else if (io_safe_output($values['section']) === 'Visual console') { + } else if (io_safe_output($values['section']) === HOME_SCREEN_VISUAL_CONSOLE) { $values['data_section'] = $visual_console; - } else if ($values['section'] === 'Other' || io_safe_output($values['section']) === 'External link') { + } else if ($values['section'] === HOME_SCREEN_OTHER || io_safe_output($values['section']) === HOME_SCREEN_EXTERNAL_LINK) { $values['data_section'] = get_parameter('data_section'); } @@ -743,7 +704,8 @@ if ($update_user) { $values['local_user'] = (bool) get_parameter('local_user', false); $values['strict_acl'] = (bool) get_parameter('strict_acl', false); $values['session_time'] = (int) get_parameter('session_time', 0); - + // Previously defined. + $values['autorefresh_white_list'] = $autorefresh_white_list; $res1 = update_user($id, $values); @@ -930,7 +892,7 @@ if ((int) $status !== -1) { } if ($add_profile && empty($json_profile)) { - $id2 = (string) get_parameter('id'); + $id2 = (string) get_parameter('id', get_parameter('id_user')); $group2 = (int) get_parameter('assign_group'); $profile2 = (int) get_parameter('assign_profile'); $tags = (array) get_parameter('assign_tags'); @@ -951,6 +913,7 @@ if ($add_profile && empty($json_profile)) { false, 'Profile: '.$profile2.' Group: '.$group2.' Tags: '.$tags ); + $return = profile_create_user_profile($id2, $profile2, $group2, false, $tags, $no_hierarchy); if ($return === false) { $is_err = true; @@ -1000,13 +963,13 @@ if ($add_profile && empty($json_profile)) { ); } -if ($values) { +if (isset($values) === true && empty($values) === false) { $user_info = $values; } -if (!users_is_admin() && $config['id_user'] != $id && !$new_user) { +if (!users_is_admin() && $config['id_user'] !== $id && $new_user === false) { $group_um = users_get_groups_UM($config['id_user']); - if (isset($group_um[0])) { + if (isset($group_um[0]) === true) { $group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true))); } else { $group_um_string = implode(',', array_keys($group_um)); @@ -1036,7 +999,7 @@ if (is_metaconsole() === true) { html_print_div( [ 'class' => 'user_form_title', - 'content' => ((bool) $id === true) ? __('Update User') : __('Create User'), + 'content' => ((bool) $id === true) ? sprintf('%s [ %s ]', __('Update User'), $id) : __('Create User'), ] ); } @@ -1046,48 +1009,49 @@ if (!$new_user) { $user_id .= ''.$id.''; $user_id .= html_print_input_hidden('id_user', $id, true); $user_id .= ''; - $user_id .= '

'.__('API Token').'

'; - $user_id .= html_print_anchor( + + $apiTokenContentElements[] = ''.__('API Token').''; + $apiTokenContentElements[] = html_print_button( + __('Renew'), + 'renew_api_token', + false, + sprintf( + 'javascript:renewAPIToken(\'%s\', \'%s\', \'%s\')', + __('Warning'), + __('The API token will be renewed. After this action, the last token you were using will not work. Are you sure?'), + 'user_profile_form', + ), [ - 'onClick' => sprintf( - 'javascript:renewAPIToken(\'%s\', \'%s\', \'%s\')', - __('Warning'), - __('The API token will be renewed. After this action, the last token you were using will not work. Are you sure?'), - 'user_profile_form', - ), - 'content' => html_print_image( - 'images/icono-refrescar.png', - true, - [ - 'class' => 'renew_api_token_image clickable', - 'title' => __('Renew API Token'), - ] - ), - 'class' => 'renew_api_token_link', + 'mode' => 'link', + 'style' => 'min-width: initial;', + ], + true, + ); + $apiTokenContentElements[] = html_print_button( + __('Show'), + 'show_api_token', + false, + sprintf( + 'javascript:showAPIToken(\'%s\', \'%s\')', + __('API Token'), + base64_encode(__('Your API Token is:').' 
'.users_get_API_token($id).'
 '.__('Please, avoid share this string with others.')), + ), + [ + 'mode' => 'link', + 'style' => 'min-width: initial;', + ], + true, + ); + + $apiTokenContent = html_print_div( + [ + 'class' => 'flex-row-center', + 'content' => implode('', $apiTokenContentElements), ], true ); - $user_id .= html_print_anchor( - [ - 'onClick' => sprintf( - 'javascript:showAPIToken(\'%s\', \'%s\')', - __('API Token'), - base64_encode(__('Your API Token is:').' 
'.users_get_API_token($id).'
 '.__('Please, avoid share this string with others.')), - ), - 'content' => html_print_image( - 'images/eye_show.png', - true, - [ - 'class' => 'renew_api_token_image clickable', - 'title' => __('Show API Token'), - ] - ), - 'class' => 'renew_api_token_link', - ], - true - ); - $user_id .= '
'; + $user_id .= $apiTokenContent; } else { $user_id = '
'.html_print_input_text_extended( 'id_user', @@ -1099,7 +1063,7 @@ if (!$new_user) { !$new_user || $view_mode, '', [ - 'class' => 'input_line user_icon_input', + 'class' => 'input_line', 'placeholder' => __('User ID'), ], true @@ -1236,7 +1200,7 @@ $email = '
'.html_print_input_text_extended( $view_mode, '', [ - 'class' => 'input input_line email_icon_input', + 'class' => 'input input_line', 'placeholder' => __('E-mail'), ], true @@ -1304,7 +1268,7 @@ if ($new_user) { $id_usr = $id; } -if ((bool) $meta === false) { +if (is_metaconsole() === false) { // User only can change skins if has more than one group. if (count($usr_groups) > 1) { if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { @@ -1314,7 +1278,7 @@ if ((bool) $meta === false) { } } -if ((bool) $meta === true) { +if (is_metaconsole() === true) { $array_filters = get_filters_custom_fields_view(0, true); $search_custom_fields_view = '

'.__('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true).'

'; @@ -1343,20 +1307,9 @@ $home_screen = '

'.__('Home __('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true ).'

'; -; -$values = [ - 'Default' => __('Default'), - 'Visual console' => __('Visual console'), - 'Event list' => __('Event list'), - 'Group view' => __('Group view'), - 'Tactical view' => __('Tactical view'), - 'Alert detail' => __('Alert detail'), - 'External link' => __('External link'), - 'Other' => __('Other'), - 'Dashboard' => __('Dashboard'), -]; -$home_screen .= html_print_select( +/* + $home_screen .= html_print_select( $values, 'section', io_safe_output($user_info['section']), @@ -1366,8 +1319,8 @@ $home_screen .= html_print_select( true, false, false -).'
'; - + ).'
'; +*/ $dashboards = Manager::getDashboards( -1, @@ -1433,7 +1386,7 @@ $size_pagination .= html_print_input_text( true ).'
'; -if ($id == $config['id_user']) { +if ($id === $config['id_user']) { $language .= html_print_input_hidden( 'quick_language_change', 1, @@ -1441,14 +1394,14 @@ if ($id == $config['id_user']) { ); } -if (enterprise_installed() && defined('METACONSOLE')) { +if (enterprise_installed() && is_metaconsole() === true) { $user_info_metaconsole_access = 'only_console'; if (isset($user_info['metaconsole_access'])) { $user_info_metaconsole_access = $user_info['metaconsole_access']; } // TODO review help tips on meta. - $meta_access = '

'.__('Metaconsole access').' './* ui_print_help_icon('meta_access', true). */'

'; + $meta_access = '

'.__('Metaconsole access').' './* ui_print_help_icon('meta_access', true). */ '

'; $metaconsole_accesses = [ 'basic' => __('Basic'), 'advanced' => __('Advanced'), @@ -1466,36 +1419,37 @@ if (enterprise_installed() && defined('METACONSOLE')) { ).'
'; } -$not_login = '

'.__('Not Login').'

'; -$not_login .= ui_print_help_tip( +/* + $not_login = '

'.__('Not Login').'

'; + $not_login .= ui_print_help_tip( __('The user with not login set only can access to API.'), true -); -$not_login .= html_print_checkbox_switch( + ); + $not_login .= html_print_checkbox_switch( 'not_login', 1, $user_info['not_login'], true -).'
'; + ).'
'; -$local_user = '

'.__('Local user').'

'; -$local_user .= ui_print_help_tip( + $local_user = '

'.__('Local user').'

'; + $local_user .= ui_print_help_tip( __('The user with local authentication enabled will always use local authentication.'), true -); -$local_user .= html_print_checkbox_switch( + ); + $local_user .= html_print_checkbox_switch( 'local_user', 1, $user_info['local_user'], true -).'
'; + ).'
'; -$session_time = '

'.__('Session Time'); -$session_time .= ui_print_help_tip( + $session_time = '

'.__('Session Time'); + $session_time .= ui_print_help_tip( __('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'), true -).'

'; -$session_time .= html_print_input_text( + ).'

'; + $session_time .= html_print_input_text( 'session_time', $user_info['session_time'], '', @@ -1505,8 +1459,8 @@ $session_time .= html_print_input_text( false, '', 'class="input_line_small"' -).'
'; - + ).'
'; +*/ $user_groups = implode(',', array_keys((users_get_groups($id, 'AR', $display_all_group)))); if (empty($user_groups) === false) { @@ -1538,7 +1492,7 @@ $default_event_filter .= html_print_select( false ).'
'; -if ($config['ehorus_user_level_conf']) { +if (isset($config['ehorus_user_level_conf']) === true && (bool) $config['ehorus_user_level_conf'] === true) { $ehorus = '

'.__('eHorus user access enabled').'

'; $ehorus .= html_print_checkbox_switch( 'ehorus_user_level_enabled', @@ -1568,27 +1522,50 @@ if ($config['ehorus_user_level_conf']) { $ehorus .= '
'; } -$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $id); - -if ($config['double_auth_enabled'] && check_acl($config['id_user'], 0, 'PM')) { - $double_authentication = '

'.__('Double authentication').'

'; +// Double authentication. +$doubleAuthElementsContent = []; +if (isset($config['double_auth_enabled']) === true && (bool) ($config['double_auth_enabled']) === true && check_acl($config['id_user'], 0, 'PM')) { + // Know if Double Auth is enabled. + $double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $id); + // Double authentication elements. + $doubleAuthElementsSubContent = []; + // Caption. + $doubleAuthElementsSubContent[] = ''.__('Double authentication').''; + // Switch. if (($config['2FA_all_users'] == '' && !$double_auth_enabled) || ($config['double_auth_enabled'] == '' && $double_auth_enabled) || check_acl($config['id_user'], 0, 'PM') ) { if ($new_user === false) { - $double_authentication .= html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true); + $doubleAuthElementsSubContent[] = html_print_checkbox_switch('double_auth', 1, $double_auth_enabled, true); } else { - $double_authentication .= ui_print_help_tip(__('User must be created before activating double authentication.'), true); + $doubleAuthElementsSubContent[] = ui_print_help_tip(__('User must be created before activating double authentication.'), true); } } + // Control for show. + $doubleAuthElementsContent[] = html_print_div( + [ + 'style' => 'display: flex; flex-direction: row-reverse; align-items: center;', + 'class' => 'margin-top-10', + 'content' => implode('', $doubleAuthElementsSubContent), + ], + true + ); + // Dialog. - $double_authentication .= ''; + $doubleAuthElementsContent[] = html_print_div( + [ + 'id' => 'dialog-double_auth', + 'class' => 'invisible', + 'content' => html_print_div(['id' => 'dialog-double_auth-container'], true), + ], + true + ); } -if ($double_auth_enabled && $config['double_auth_enabled'] && $config['2FA_all_users'] != '') { - $double_authentication .= html_print_button( +if ($double_auth_enabled === true && (bool) $config['double_auth_enabled'] === true && empty($config['2FA_all_users']) === false) { + $doubleAuthElementsContent[] = html_print_button( __('Show information'), 'show_info', false, @@ -1598,11 +1575,98 @@ if ($double_auth_enabled && $config['double_auth_enabled'] && $config['2FA_all_u ); } -if (isset($double_authentication)) { - $double_authentication .= '
'; +if (empty($doubleAuthElementsContent) === false) { + $doubleAuthentication = html_print_div(['content' => implode('', $doubleAuthElementsContent)], true); +} else { + $doubleAuthentication = ''; } -if ($meta) { + +/* + if (isset($double_authentication)) { + $double_authentication .= '
'; +}*/ + + + + + + + + + + + + + + + + + + + + +$autorefresh_list_out = []; +if (is_metaconsole() === false || is_centralized() === true) { + $autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail'; + $autorefresh_list_out['operation/agentes/alerts_status'] = 'Alert detail'; + $autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view'; + $autorefresh_list_out['operation/gis_maps/render_view'] = 'Gis Map'; + $autorefresh_list_out['operation/reporting/graph_viewer'] = 'Graph Viewer'; + $autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console'; + + if (enterprise_installed()) { + $autorefresh_list_out['general/sap_view'] = 'SAP view'; + } +} + +$autorefresh_list_out['operation/agentes/tactical'] = 'Tactical view'; +$autorefresh_list_out['operation/agentes/group_view'] = 'Group view'; +$autorefresh_list_out['operation/agentes/status_monitor'] = 'Monitor detail'; +$autorefresh_list_out['enterprise/operation/services/services'] = 'Services'; +$autorefresh_list_out['operation/dashboard/dashboard'] = 'Dashboard'; + +$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map'; +$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console'; +$autorefresh_list_out['operation/events/events'] = 'Events'; + + +if (isset($autorefresh_list) === false) { + $select = db_process_sql("SELECT autorefresh_white_list FROM tusuario WHERE id_user = '".$config['id_user']."'"); + $autorefresh_list = json_decode($select[0]['autorefresh_white_list']); + if ($autorefresh_list === null) { + $autorefresh_list[0] = __('None'); + } else { + $aux = []; + $count_autorefresh_list = count($autorefresh_list); + for ($i = 0; $i < $count_autorefresh_list; $i++) { + $aux[$autorefresh_list[$i]] = $autorefresh_list_out[$autorefresh_list[$i]]; + unset($autorefresh_list_out[$autorefresh_list[$i]]); + $autorefresh_list[$i] = $aux; + } + + $autorefresh_list = $aux; + } +} else { + if (is_array($autorefresh_list) === false || empty($autorefresh_list[0]) === true || $autorefresh_list[0] === '0') { + $autorefresh_list = []; + $autorefresh_list[0] = __('None'); + } else { + $aux = []; + $count_autorefresh_list = count($autorefresh_list); + for ($i = 0; $i < $count_autorefresh_list; $i++) { + $aux[$autorefresh_list[$i]] = $autorefresh_list_out[$autorefresh_list[$i]]; + unset($autorefresh_list_out[$autorefresh_list[$i]]); + $autorefresh_list[$i] = $aux; + } + + $autorefresh_list = $aux; + } +} + + + +if (is_metaconsole() === true) { enterprise_include_once('include/functions_metaconsole.php'); $access_node = db_get_value('metaconsole_access_node', 'tusuario', 'id_user', $id); @@ -1624,8 +1688,9 @@ if ($meta) { ).''; } -echo '
'; +echo '
'; +echo ''; if (!$id) { $user_id_update_view = $user_id; @@ -1637,71 +1702,139 @@ if (!$id) { if (is_metaconsole() === true) { $access_or_pagination = $meta_access; -} else { - $access_or_pagination = $size_pagination; -} + if ($id != '' && !$is_err) { + $div_user_info = ' + '; + } else { + $div_user_info = ' + '; + } -if ($id != '' && !$is_err) { - $div_user_info = ' - '; -} else { - $div_user_info = ' - '; -} + echo '
+
+ +

Extra info

'.$email.$phone.$not_login.$local_user.$session_time.'
+
+
+
'.$language.$access_or_pagination.$skin.$default_event_filter.$double_authentication.'
+ +
'.$timezone; -echo '
-
- -

Extra info

'.$email.$phone.$not_login.$local_user.$session_time.'
-
-
-
'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$double_authentication.'
- -
'.$timezone; -if (is_metaconsole() === false) { - echo '
- - - '.$area_data_timezone_polys.$area_data_timezone_rects.' -
'; -} else { echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node; -} -echo '
-
+ $autorefresh_show = '

'._('Autorefresh').ui_print_help_tip( + __('This will activate autorefresh in selected pages'), + true + ).'

'; + $select_out = html_print_select( + $autorefresh_list_out, + 'autorefresh_list_out[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%' + ); + $arrows = ' '; + $select_in = html_print_select( + $autorefresh_list, + 'autorefresh_list[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%' + ); -
-
'.$comments.'
-
'; + $table_ichanges = ''; -html_print_div( - [ - 'class' => 'user_edit_third_row white_box', - 'content' => html_print_div( + $autorefresh_show .= $table_ichanges; + + // Time autorefresh. + $times = get_refresh_time_array(); + $time_autorefresh = '

'.__('Time autorefresh'); + $time_autorefresh .= ui_print_help_tip( + __('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'), + true + ).'

'; + $time_autorefresh .= html_print_select( + $times, + 'time_autorefresh', + $user_info['time_autorefresh'], + '', + '', + '', + true, + false, + false + ).'
'; + + + echo '
+
+
'.$autorefresh_show.$time_autorefresh.'
+
+
'.$comments.'
+
'; + + if (empty($ehorus) === false) { + html_print_div( [ - 'class' => 'edit_user_allowed_ip', - 'content' => $allowedIP, + 'class' => 'user_edit_third_row white_box', + 'content' => $ehorus, ], true - ), - ] -); - -if (!empty($ehorus)) { - echo '
'.$ehorus.'
'; + ); + } +} else { + $access_or_pagination = $size_pagination; + // WIP: Only for node. + include_once 'user_management.php'; } -echo '
'; -echo '
'; -if ($config['admin_can_add_user']) { +if ((bool) $config['admin_can_add_user'] === true) { html_print_csrf_hidden(); - if ($new_user) { - html_print_input_hidden('create_user', 1); - } else { - html_print_input_hidden('update_user', 1); - } + html_print_input_hidden((($new_user === true) ? 'create_user' : 'update_user'), 1); } echo '
'; @@ -1709,42 +1842,49 @@ if ($new_user === true) { html_print_input_hidden('json_profile', $json_profile); } +echo '
'; echo ''; +echo '
'; -if ($is_err === true && $new_user === true) { - profile_print_profile_table($id, io_safe_output($json_profile), false, true); -} else { - profile_print_profile_table($id, io_safe_output($json_profile)); -} +$actionButtons = []; -echo '
'; - -echo '
'; -if ($config['admin_can_add_user']) { - if ($new_user) { - html_print_submit_button( - __('Create'), - 'crtbutton', - false, - 'class="sub wand" form="user_profile_form"' - ); +if ((bool) $config['admin_can_add_user'] === true) { + if ($new_user === true) { + $submitButtonCaption = __('Create'); + $submitButtonName = 'crtbutton'; + $submitButtonIcon = 'wand'; } else { - html_print_submit_button( - __('Update'), - 'uptbutton', - false, - 'class="sub upd" form="user_profile_form"' - ); + $submitButtonCaption = __('Update'); + $submitButtonName = 'uptbutton'; + $submitButtonIcon = 'update'; } + + $actionButtons[] = html_print_submit_button( + $submitButtonCaption, + $submitButtonName, + false, + [ + 'icon' => $submitButtonIcon, + 'form' => 'user_profile_form', + ], + true + ); } -echo '
'; +if ((bool) check_acl($config['id_user'], 0, 'UM') === true) { + $actionButtons[] = html_print_go_back_button( + ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0'), + ['button_class' => ''], + true + ); +} +html_print_action_buttons(implode('', $actionButtons), ['type' => 'form_action']); echo ''; -enterprise_hook('close_meta_frame'); +// This is an image generated for JS. $delete_image = html_print_input_image( 'del', 'images/cross.png', @@ -1757,7 +1897,7 @@ $delete_image = html_print_input_image( ] ); -if (!is_metaconsole()) { +if (is_metaconsole() === false) { ?> + $dialogContainer + .empty() + .append(message) + .append($button); + + var request; + + $button.click(function(e) { + e.preventDefault(); + + $dialogContainer.html($loadingSpinner); + + // Deactivate the double auth + request = $.ajax({ + url: "", + type: 'POST', + dataType: 'json', + data: { + page: 'include/ajax/double_auth.ajax', + id_user: userID, + FA_forced: 1, + deactivate_double_auth: 1 + }, + complete: function(xhr, textStatus) { + + }, + success: function(data, textStatus, xhr) { + if (data === -1) { + $dialogContainer.html("
'.__('Authentication error').'
'; ?>"); + } else if (data) { + $dialogContainer.html("
'.__('The double autentication was deactivated successfully').'
'; ?>"); + $("input#checkbox-double_auth").prop("checked", false); + } else { + $dialogContainer.html("
'.__('There was an error deactivating the double autentication').'
'; ?>"); + } + }, + error: function(xhr, textStatus, errorThrown) { + $dialogContainer.html("
'.__('There was an error deactivating the double autentication').'
'; ?>"); + } + }); + }); + + + $("div#dialog-double_auth").dialog({ + resizable: true, + draggable: true, + modal: true, + title: "", + overlay: { + opacity: 0.5, + background: "black" + }, + width: 300, + height: 150, + close: function(event, ui) { + // Abort the ajax request + if (typeof request != 'undefined') + request.abort(); + // Remove the contained html + $dialogContainer.empty(); + + } + }) + .show(); + } + + + /* ]]> */ + \ No newline at end of file diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php index 7ce7c82cc0..e47e989d0f 100644 --- a/pandora_console/godmode/users/profile_list.php +++ b/pandora_console/godmode/users/profile_list.php @@ -31,8 +31,6 @@ global $config; check_login(); -enterprise_hook('open_meta_frame'); - require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_groups.php'; @@ -57,22 +55,22 @@ if (is_metaconsole() === false) { 'user' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/gm_users.png', + 'images/user.svg', true, [ 'title' => __('User management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_user', ] ).'', ], 'profile' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/profiles.png', + 'images/suitcase@svg.svg', true, [ 'title' => __('Profile management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_user', ] ).'', ], @@ -80,13 +78,24 @@ if (is_metaconsole() === false) { $buttons[$tab]['active'] = true; - ui_print_page_header( - __('User management').' » '.__('Profiles defined on %s', get_product_name()), - 'images/gm_users.png', + // Header. + ui_print_standard_header( + __('User Profile management'), + 'images/user.svg', false, 'profile_tab', - true, - $buttons + false, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Profiles'), + ], + [ + 'link' => '', + 'label' => __('Manage users'), + ], + ] ); $sec = 'gusuarios'; } else { @@ -312,8 +321,8 @@ if ($is_management_allowed === true && $create_profile === true) { $table = new stdClass(); $table->cellpadding = 0; $table->cellspacing = 0; +$table->styleTable = 'margin: 10px'; $table->class = 'info_table profile_list'; -$table->width = '100%'; $table->head = []; $table->data = []; @@ -322,36 +331,37 @@ $table->align = []; $table->head['profiles'] = __('Profiles'); -$table->head['AR'] = 'AR'; -$table->head['AW'] = 'AW'; -$table->head['AD'] = 'AD'; -$table->head['LW'] = 'LW'; -$table->head['LM'] = 'LM'; -$table->head['UM'] = 'UM'; -$table->head['DM'] = 'DM'; -$table->head['ER'] = 'ER'; -$table->head['EW'] = 'EW'; -$table->head['EM'] = 'EM'; -$table->head['RR'] = 'RR'; -$table->head['RW'] = 'RW'; -$table->head['RM'] = 'RM'; -$table->head['MR'] = 'MR'; -$table->head['MW'] = 'MW'; -$table->head['MM'] = 'MM'; -$table->head['VR'] = 'VR'; -$table->head['VW'] = 'VW'; -$table->head['VM'] = 'VM'; -$table->head['NR'] = 'NR'; -$table->head['NW'] = 'NW'; -$table->head['NM'] = 'NM'; -$table->head['PM'] = 'PM'; +$table->head['AR'] = ''.'AR'.''; +$table->head['AW'] = ''.'AW'.''; +$table->head['AD'] = ''.'AD'.''; +$table->head['LW'] = ''.'LW'.''; +$table->head['LM'] = ''.'LM'.''; +$table->head['UM'] = ''.'UM'.''; +$table->head['DM'] = ''.'DM'.''; +$table->head['ER'] = ''.'ER'.''; +$table->head['EW'] = ''.'EW'.''; +$table->head['EM'] = ''.'EM'.''; +$table->head['RR'] = ''.'RR'.''; +$table->head['RW'] = ''.'RW'.''; +$table->head['RM'] = ''.'RM'.''; +$table->head['MR'] = ''.'MR'.''; +$table->head['MW'] = ''.'MW'.''; +$table->head['MM'] = ''.'MM'.''; +$table->head['VR'] = ''.'VR'.''; +$table->head['VW'] = ''.'VW'.''; +$table->head['VM'] = ''.'VM'.''; +$table->head['NR'] = ''.'NR'.''; +$table->head['NW'] = ''.'NW'.''; +$table->head['NM'] = ''.'NM'.''; +$table->head['PM'] = ''.'PM'.''; + if ($is_management_allowed === true) { $table->head['operations'] = ''.__('Op.').''; } $table->align = array_fill(1, 11, 'center'); -$table->size['profiles'] = '200px'; +$table->size['profiles'] = '150px'; $table->size['AR'] = '10px'; $table->size['AW'] = '10px'; $table->size['AD'] = '10px'; @@ -376,7 +386,7 @@ $table->size['NW'] = '10px'; $table->size['NM'] = '10px'; $table->size['PM'] = '10px'; if ($is_management_allowed === true) { - $table->size['operations'] = '5%'; + $table->size['operations'] = '6%'; } $profiles = db_get_all_rows_in_table('tperfil'); @@ -385,11 +395,11 @@ if ($profiles === false) { } $img = html_print_image( - 'images/ok.png', + 'images/validate.svg', true, [ 'border' => 0, - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ); @@ -425,25 +435,32 @@ foreach ($profiles as $profile) { $data['NW'] = (empty($profile['network_config_edit']) === false) ? $img : ''; $data['NM'] = (empty($profile['network_config_management']) === false) ? $img : ''; $data['PM'] = (empty($profile['pandora_management']) === false) ? $img : ''; - $table->cellclass[]['operations'] = 'action_buttons'; + $table->cellclass[]['operations'] = 'table_action_buttons'; if ($is_management_allowed === true) { $data['operations'] = ''.html_print_image( - 'images/config.png', + 'images/edit.svg', true, [ 'title' => __('Edit'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).''; - if (check_acl($config['id_user'], 0, 'PM') || users_is_admin()) { - $data['operations'] .= ''.html_print_image( - 'images/cross.png', - true, + if ((bool) check_acl($config['id_user'], 0, 'PM') === true || (bool) users_is_admin() === true) { + $data['operations'] .= html_print_anchor( [ - 'title' => __('Delete'), - 'class' => 'invert_filter', - ] - ).''; + 'href' => 'index.php?sec='.$sec.'&sec2=godmode/users/profile_list&delete_profile=1&id='.$profile['id_perfil'].'&pure='.$pure, + 'onClick' => 'if (!confirm(\' '.__('Are you sure?').'\')) return false;', + 'content' => html_print_image( + 'images/delete.svg', + true, + [ + 'title' => __('Delete'), + 'class' => 'invert_filter main_menu_icon', + ] + ), + ], + true + ); } } @@ -458,13 +475,21 @@ if (isset($data) === true) { if ($is_management_allowed === true) { echo '
'; - echo '
'; html_print_input_hidden('new_profile', 1); - html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"'); - echo '
'; + html_print_action_buttons( + html_print_submit_button( + __('Create profile'), + 'crt', + false, + [ 'icon' => 'next' ], + true + ), + [ + 'type' => 'data_table', + 'class' => 'fixed_action_buttons', + ] + ); echo '
'; } unset($table); - -enterprise_hook('close_meta_frame'); diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 11ecc02f11..e4fe4225fa 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -132,8 +132,6 @@ if (is_ajax()) { } } -enterprise_hook('open_meta_frame'); - $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $tab = get_parameter('tab', 'user'); @@ -247,22 +245,22 @@ if (is_metaconsole() === true) { 'user' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/gm_users.png', + 'images/user.svg', true, [ 'title' => __('User management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).'', ], 'profile' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/profiles.png', + 'images/suitcase@svg.svg', true, [ 'title' => __('Profile management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).'', ], @@ -272,11 +270,11 @@ if (is_metaconsole() === true) { 'user' => [ 'active' => false, 'text' => ''.html_print_image( - 'images/gm_users.png', + 'images/user.svg', true, [ 'title' => __('User management'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ).'', ], @@ -285,13 +283,24 @@ if (is_metaconsole() === true) { $buttons[$tab]['active'] = true; - ui_print_page_header( - __('User management').' » '.__('Users defined on %s', get_product_name()), - 'images/gm_users.png', + // Header. + ui_print_standard_header( + __('Users management'), + 'images/user.svg', false, '', - true, - $buttons + false, + $buttons, + [ + [ + 'link' => '', + 'label' => __('Profiles'), + ], + [ + 'link' => '', + 'label' => __('Manage users'), + ], + ] ); $sec = 'gusuarios'; @@ -326,8 +335,11 @@ if ($delete_user === true) { ); if (isset($private_dashboards) === true) { - db_process_sql_delete('tdashboard', ['id_user' => $id_user]); - header('Refresh:1'); + $dashboardRemoveResult = db_process_sql_delete('tdashboard', ['id_user' => $id_user]); + // Refresh the view when delete private dashboards. For review. + if ($dashboardRemoveResult === false || (int) $dashboardRemoveResult > 0) { + header('Refresh:1'); + } } $result = delete_user($id_user); @@ -449,12 +461,14 @@ if (($filter_group == 0) && ($filter_search == '')) { $search = false; } -$table = new stdClass(); -$table->width = '100%'; -$table->class = 'databox filters'; -$table->rowclass[0] = ''; -$table->data[0][0] = ''.__('Group').''; -$table->data[0][1] = html_print_select_groups( +$filterTable = new stdClass(); +$filterTable->width = '100%'; +$filterTable->class = 'fixed_filter_bar'; +$filterTable->rowclass[0] = ''; +$filterTable->cellstyle[0][0] = 'width:0'; +$filterTable->cellstyle[0][1] = 'width:0'; +$filterTable->data[0][0] = __('Group'); +$filterTable->data[1][0] = html_print_select_groups( false, 'AR', true, @@ -465,8 +479,8 @@ $table->data[0][1] = html_print_select_groups( 0, true ); -$table->data[0][2] = ''.__('Search').''.ui_print_help_tip(__('Search by username, fullname or email'), true); -$table->data[0][3] = html_print_input_text( +$filterTable->data[0][1] = __('Search').ui_print_help_tip(__('Search by username, fullname or email'), true); +$filterTable->data[1][1] = html_print_input_text( 'filter_search', $filter_search, __('Search by username, fullname or email'), @@ -474,11 +488,16 @@ $table->data[0][3] = html_print_input_text( 90, true ); -$table->data[0][4] = html_print_submit_button( +$filterTable->cellstyle[1][2] = 'vertical-align: bottom'; +$filterTable->data[1][2] = html_print_submit_button( __('Search'), 'search', false, - ['class' => 'sub search'], + [ + 'icon' => 'search', + 'class' => 'float-right', + 'mode' => 'secondary mini', + ], true ); @@ -503,22 +522,16 @@ if (is_metaconsole() === false && is_management_allowed() === false) { if (is_metaconsole() === true) { - $table->width = '96%'; + $filterTable->width = '96%'; $form_filter = "
"; - $form_filter .= html_print_table($table, true); + $form_filter .= html_print_table($filterTable, true); $form_filter .= '
'; ui_toggle($form_filter, __('Show Options')); } else { $form_filter = "
"; - $form_filter .= html_print_table($table, true); + $form_filter .= html_print_table($filterTable, true); $form_filter .= '
'; - ui_toggle( - $form_filter, - __('Users control filter'), - __('Toggle filter(s)'), - '', - !$search - ); + echo $form_filter; } // Urls to sort the table. @@ -533,8 +546,9 @@ $url_down_last = '?sec='.$sec.'&sec2=godmode/users/user_list&sort_field=last_con $table = new stdClass(); $table->cellpadding = 0; $table->cellspacing = 0; -$table->width = '100%'; -$table->class = 'info_table'; +$table->class = 'info_table tactical_table'; +$table->id = 'user_list'; +$table->styleTable = 'margin: 0 10px'; $table->head = []; $table->data = []; @@ -542,15 +556,18 @@ $table->align = []; $table->size = []; $table->valign = []; -$table->head[0] = __('User ID').ui_get_sorting_arrows($url_up_id, $url_down_id, $selectUserIDUp, $selectUserIDDown); -$table->head[1] = __('Name').ui_get_sorting_arrows($url_up_name, $url_down_name, $selectFullnameUp, $selectFullnameDown); -$table->head[2] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastConnectUp, $selectLastConnectDown); +$table->head[0] = ''.__('User ID').''; +$table->head[0] .= ui_get_sorting_arrows($url_up_id, $url_down_id, $selectUserIDUp, $selectUserIDDown); +$table->head[1] = ''.__('Name').''; +$table->head[1] .= ui_get_sorting_arrows($url_up_name, $url_down_name, $selectFullnameUp, $selectFullnameDown); +$table->head[2] = ''.__('Last contact').''; +$table->head[2] .= ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastConnectUp, $selectLastConnectDown); -$table->head[3] = __('Admin'); -$table->head[4] = __('Profile / Group'); -$table->head[5] = __('Description'); +$table->head[3] = ''.__('Admin').''; +$table->head[4] = ''.__('Profile / Group').''; +$table->head[5] = ''.__('Description').''; if ($is_management_allowed === true) { - $table->head[6] = ''.__('Op.').''; + $table->head[6] = ''.__('Actions').''; } if (is_metaconsole() === false) { @@ -585,7 +602,7 @@ if ($user_is_admin) { } else { $group_um = users_get_groups_UM($config['id_user']); // 0 is the group 'all'. - if (isset($group_um[0])) { + if (isset($group_um[0]) === true) { $info1 = get_users($order); } else { foreach ($group_um as $group => $value) { @@ -642,9 +659,6 @@ foreach ($info1 as $user_id => $user_info) { $info = $info1; -// Prepare pagination. -ui_pagination(count($info)); - $offset = (int) get_parameter('offset'); $limit = (int) $config['block_size']; @@ -714,7 +728,13 @@ foreach ($info as $user_id => $user_info) { || isset($group_um[0]) || (isset($user_info['edit']) && $user_info['edit'])))) ) { - $data[0] = ''.$user_id.''; + $data[0] = html_print_anchor( + [ + 'href' => ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/configure_user&edit_user=1&pure=0&id_user='.$user_id), + 'content' => $user_id, + ], + true + ); } else { $data[0] = $user_id; } @@ -728,12 +748,12 @@ foreach ($info as $user_id => $user_info) { if ($user_info['is_admin']) { $data[3] = html_print_image( - 'images/user_suit.png', + 'images/user.svg', true, [ 'alt' => __('Admin'), 'title' => __('Administrator'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).' '; } else { @@ -792,10 +812,10 @@ foreach ($info as $user_id => $user_info) { } $data[5] = ui_print_string_substr($user_info['comments'], 24, true); - + $table->cellclass[][6] = 'table_action_buttons'; + $data[6] = ''; + $userListActionButtons = []; if ($is_management_allowed === true) { - $table->cellclass[][6] = 'action_buttons'; - $data[6] = ''; if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || isset($group_um[0]) @@ -804,32 +824,49 @@ foreach ($info as $user_id => $user_info) { ) { // Disable / Enable user. if (isset($user_info['not_delete']) === false) { - if ($user_info['disabled'] == 0) { + if ((int) $user_info['disabled'] === 0) { $toDoString = __('Disable'); $toDoAction = '1'; - $toDoImage = 'images/lightbulb.png'; + $toDoImage = 'images/disable.svg'; $toDoClass = ''; } else { $toDoString = __('Enable'); $toDoAction = '0'; - $toDoImage = 'images/lightbulb_off.png'; + $toDoImage = 'images/enable.svg'; $toDoClass = 'filter_none'; } - $data[6] = '
'; - $data[6] .= html_print_input_hidden( + $userListActionButtons[] = html_print_menu_button( + [ + 'href' => ui_get_full_url( + sprintf( + 'index.php?sec=%s&sec2=godmode/users/user_list&disable_user=%s&pure=%s&id=%s', + $sec, + $toDoAction, + $pure, + $user_info['id_user'] + ) + ), + 'image' => $toDoImage, + 'title' => $toDoString, + ], + true + ); + /* + $data[6] = ''; + $data[6] .= html_print_input_hidden( 'id', $user_info['id_user'], true - ); - // Same csrf for every disable button for submit. - $data[6] .= $csrf; - $data[6] .= html_print_input_hidden( + ); + // Same csrf for every disable button for submit. + $data[6] .= $csrf; + $data[6] .= html_print_input_hidden( 'disable_user', $toDoAction, true - ); - $data[6] .= html_print_input_image( + ); + $data[6] .= html_print_input_image( 'submit_disable_enable', $toDoImage, '', @@ -838,67 +875,102 @@ foreach ($info as $user_id => $user_info) { [ 'data-title' => $toDoString, 'data-use_title_for_force_title' => '1', - 'class' => 'forced_title no-padding '.$toDoClass, + 'class' => 'main_menu_icon forced_title no-padding '.$toDoClass, ] - ); - $data[6] .= '
'; + ); + $data[6] .= ''; + */ } - // Edit user. - $data[6] .= '
'; - $data[6] .= html_print_input_hidden( + /* + // Edit user. + $data[6] .= ''; + $data[6] .= html_print_input_hidden( 'id_user', $user_info['id_user'], true - ); - $data[6] .= html_print_input_hidden( + ); + $data[6] .= html_print_input_hidden( 'edit_user', '1', true - ); - $data[6] .= html_print_input_image( + ); + $data[6] .= html_print_input_image( 'submit_edit_user', - 'images/config.png', + 'images/edit.svg', '', 'padding:0', true, [ 'data-title' => __('Edit'), 'data-use_title_for_force_title' => '1', - 'class' => 'forced_title no-padding', + 'class' => 'main_menu_icon forced_title no-padding', ] + ); + $data[6] .= '
';*/ + + $userListActionButtons[] = html_print_menu_button( + [ + 'href' => ui_get_full_url( + sprintf( + 'index.php?sec=%s&sec2=godmode/users/configure_user&edit_user=1&pure=%s&id_user=%s', + $sec, + $pure, + $user_info['id_user'] + ) + ), + 'image' => 'images/edit.svg', + 'title' => __('Edit user'), + ], + true ); - $data[6] .= ''; if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && isset($user_info['not_delete']) === false ) { - $offset_delete = ($offset >= count($info) - 1) ? ($offset - $config['block_size']) : $offset; - $data[6] .= '
'; - $data[6] .= html_print_input_hidden( + /* + $offset_delete = ($offset >= count($info) - 1) ? ($offset - $config['block_size']) : $offset; + $data[6] .= ''; + $data[6] .= html_print_input_hidden( 'delete_user', $user_info['id_user'], true - ); - $data[6] .= html_print_input_hidden( + ); + $data[6] .= html_print_input_hidden( 'user_del', '1', true - ); - $data[6] .= html_print_input_image( + ); + $data[6] .= html_print_input_image( 'submit_delete_user', - 'images/cross.png', + 'images/delete.svg', '', 'padding:0', true, [ 'data-title' => __('Delete'), 'data-use_title_for_force_title' => '1', - 'class' => 'forced_title no-padding', + 'class' => 'main_menu_icon forced_title no-padding', ] + ); + $data[6] .= '
'; + */ + $userListActionButtons[] = html_print_menu_button( + [ + 'href' => ui_get_full_url( + sprintf( + 'index.php?sec=%s&sec2=godmode/users/user_list&user_del=1&pure=%s&delete_user=%s', + $sec, + $pure, + $user_info['id_user'] + ) + ), + 'image' => 'images/delete.svg', + 'title' => __('Delete'), + ], + true ); - $data[6] .= ''; if (is_metaconsole() === true) { $data[6] .= '
'; @@ -918,11 +990,16 @@ foreach ($info as $user_id => $user_info) { true ); $data[6] .= '
'; + } else { + $data[6] = implode('', $userListActionButtons); } } else { $data[6] .= ''; // Delete button not in this mode. } + + // TODO. Check this in META!!! + $data[6] = implode('', $userListActionButtons); } else { $data[6] .= ''; // Delete button not in this mode. @@ -933,26 +1010,45 @@ foreach ($info as $user_id => $user_info) { } html_print_table($table); -ui_pagination(count($info), false, 0, 0, false, 'offset', true, 'pagination-bottom'); - -echo '
'; +$tablePagination = ui_pagination(count($info), false, 0, 0, true, 'offset', false, 'dataTables_paginate paging_simple_numbers'); unset($table); if ($is_management_allowed === true) { if ($config['admin_can_add_user'] !== false) { echo '
'; + html_print_action_buttons( + html_print_submit_button( + __('Create user'), + 'crt', + false, + [ 'icon' => 'wand' ], + true + ), + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], + ); html_print_input_hidden('new_user', 1); - html_print_submit_button(__('Create user'), 'crt', false, 'class="sub next"'); echo '
'; } else { echo ''.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).''; } +} else { + html_print_action_buttons( + html_print_submit_button( + __('Create user'), + 'none', + true, + [ 'icon' => 'wand' ], + true + ), + [ + 'type' => 'form_action', + 'right_content' => $tablePagination, + ], + ); } - -echo '
'; - -enterprise_hook('close_meta_frame'); - ?> + '; + if (check_acl($config['id_user'], 0, 'AW')) { + echo '
'; + + $table = new StdClass; + $table->id = 'save_filter_form'; + $table->width = '100%'; + $table->size = []; + $table->size[0] = '50%'; + $table->size[1] = '50%'; + $table->class = 'filter-table-adv'; + $data = []; + + $table->rowid[0] = 'update_save_selector'; + $data[0][0] = html_print_label_input_block( + __('New filter'), + html_print_radio_button( + 'filter_mode', + 'new', + '', + true, + true + ) + ); + + $data[0][1] = html_print_label_input_block( + __('Update/delete filter'), + html_print_radio_button( + 'filter_mode', + 'update', + '', + false, + true + ) + ); + + $table->rowid[1] = 'save_filter_row1'; + $data[1][0] = html_print_label_input_block( + __('Filter name'), + html_print_input_text('id_name', '', '', 15, 255, true) + ); + + $labelInput = __('Filter group'); + if (is_metaconsole() === true) { + $labelInput = __('Save in Group'); + } + + $user_groups_array = users_get_groups_for_select( + $config['id_user'], + 'AW', + users_can_manage_group_all('AW'), + true + ); + + $data[1][1] = html_print_label_input_block( + $labelInput, + html_print_select( + $user_groups_array, + 'id_group_filter_dialog', + $id_group_filter, + '', + '', + 0, + true, + false, + false + ), + ['div_class' => 'filter-group-dialog'] + ); + + $table->rowid[2] = 'save_filter_row2'; + + $table->data[] = $data; + $table->rowclass[] = ''; + $user_groups = users_get_groups( + $config['id_user'], + 'AW', + users_can_manage_group_all('AW'), + true + ); + + $sql = 'SELECT id_filter, id_name + FROM tagent_filter + WHERE id_group_filter IN ('.implode(',', array_keys($user_groups)).')'; + + $agent_filters = db_get_all_rows_sql($sql); + + $_filters_update = []; + + if ($agent_filters !== false) { + foreach ($agent_filters as $agent_filter) { + $_filters_update[$agent_filter['id_filter']] = $agent_filter['id_name']; + } + } + + $data[2][0] = html_print_label_input_block( + __('Filter'), + html_print_select( + $_filters_update, + 'overwrite_filter', + '', + '', + '', + 0, + true + ) + ); + + $table->data = $data; + + html_print_table($table); + html_print_div( + [ + 'id' => 'submit-save_filter', + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Save current filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + 'onclick' => 'save_new_filter();', + ], + true + ), + ], + false + ); + + $input_actions = html_print_submit_button( + __('Delete filter'), + 'delete_filter', + false, + [ + 'icon' => 'delete', + 'mode' => 'mini', + 'onclick' => 'save_delete_filter();', + ], + true + ); + + $input_actions .= html_print_submit_button( + __('Update filter'), + 'srcbutton', + false, + [ + 'icon' => 'update', + 'mode' => 'mini', + 'onclick' => 'save_update_filter();', + ], + true + ); + + html_print_div( + [ + 'id' => 'update_filter_row', + 'class' => 'action-buttons', + 'content' => $input_actions, + ], + false + ); + } else { + include 'general/noaccess.php'; + } + + echo ''; + ?> + + data[] = $row; } - if (!empty($table->data)) { + if (empty($table->data) === false) { html_print_table($table); } else { ui_print_info_message(['no_close' => true, 'message' => __('No alerts found') ]); @@ -663,9 +663,9 @@ if ($get_agent_alerts_datatable === true) { include_once $config['homedir'].'/operation/agentes/alerts_status.functions.php'; include_once $config['homedir'].'/include/functions_users.php'; - $agent_a = check_acl($config['id_user'], 0, 'AR'); - $agent_w = check_acl($config['id_user'], 0, 'AW'); - $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); + $agent_a = (bool) check_acl($config['id_user'], 0, 'AR'); + $agent_w = (bool) check_acl($config['id_user'], 0, 'AW'); + $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); $all_groups = get_parameter('all_groups'); $idAgent = (int) get_parameter('id_agent'); @@ -861,7 +861,7 @@ if ($get_agent_alerts_datatable === true) { if (is_metaconsole() === true) { include_once $config['homedir'].'/enterprise/meta/include/functions_alerts_meta.php'; - if ($idAgent != 0) { + if ($idAgent !== 0) { $alerts['alerts_simple'] = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter, $action_filter); $countAlertsSimple = alerts_meta_get_alerts($agents, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); @@ -875,7 +875,7 @@ if ($get_agent_alerts_datatable === true) { $countAlertsSimple = alerts_meta_get_group_alerts($id_groups, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter, $action_filter); } } else { - if ($idAgent != 0) { + if ($idAgent !== 0) { $alerts['alerts_simple'] = agents_get_alerts_simple($idAgent, $filter_alert, $options_simple, $whereAlertSimple, false, false, $idGroup, false, $strict_user, $tag_filter); $countAlertsSimple = agents_get_alerts_simple($idAgent, $filter_alert, false, $whereAlertSimple, false, false, $idGroup, true, $strict_user, $tag_filter); diff --git a/pandora_console/include/ajax/double_auth.ajax.php b/pandora_console/include/ajax/double_auth.ajax.php index 0f85c9c0f5..3a995ce43a 100644 --- a/pandora_console/include/ajax/double_auth.ajax.php +++ b/pandora_console/include/ajax/double_auth.ajax.php @@ -1,21 +1,39 @@ $id_user]; db_process_sql_delete('tuser_double_auth', $where); - // Insert the new value + // Insert the new value. $values = [ 'id_user' => $id_user, 'secret' => $secret, @@ -116,12 +134,12 @@ if ($save_double_auth_secret) { return; } -// Disable the double auth for the user +// Disable the double auth for the user. $deactivate_double_auth = (bool) get_parameter('deactivate_double_auth'); if ($deactivate_double_auth) { $result = false; - // Delete the actual value (if exists) + // Delete the actual value (if exists). $where = ['id_user' => $id_user]; $result = db_process_sql_delete('tuser_double_auth', $where); @@ -129,7 +147,7 @@ if ($deactivate_double_auth) { return; } -// Get the info page to the container dialog +// Get the info page to the container dialog. $get_double_auth_data_page = (bool) get_parameter('get_double_auth_data_page'); if ($get_double_auth_data_page) { $secret = db_get_value('secret', 'tuser_double_auth', 'id_user', $id_user); @@ -146,7 +164,7 @@ if ($get_double_auth_data_page) { $html .= '

'; $html .= ''; $html .= '
'; - $html .= __('Code').": $secret"; + $html .= __('Code').': '.$secret.''; $html .= '
'; $html .= __('QR').':
'; $html .= '
'; @@ -161,7 +179,7 @@ if ($get_double_auth_data_page) { var secret = ""; var id_user_auth = ""; - // QR code with the secret to add it to the app + // QR code with the secret to add it to the app. paint_qrcode("otpauth://totp/"+id_user_auth+"?secret="+secret, $("div#qr-container").get(0), 200, 200); $("div#qr-container").attr("title", "").find("canvas").remove(); @@ -179,7 +197,7 @@ if ($get_double_auth_data_page) { return; } -// Get the info page to the container dialog +// Get the info page to the container dialog. $get_double_auth_info_page = (bool) get_parameter('get_double_auth_info_page'); if ($get_double_auth_info_page) { $container_id = (string) get_parameter('containerID'); @@ -209,14 +227,14 @@ if ($get_double_auth_info_page) { ob_clean(); ?> data)) { - if ($filter_monitors) { - ui_print_info_message([ 'no_close' => true, 'message' => __('Any monitors aren\'t with this filter.') ]); - } else { - ui_print_info_message([ 'no_close' => true, 'message' => __('This agent doesn\'t have any active monitors.') ]); - } + if (empty($table->data) === true) { + ui_print_info_message( + [ + 'no_close' => true, + 'message' => ($filter_monitors === true) ? __('Any monitors aren\'t with this filter.') : __('This agent doesn\'t have any active monitors.'), + ] + ); } else { $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agente.'&refr=&filter_monitors=1&status_filter_monitor='.$status_filter_monitor.'&status_text_monitor='.$status_text_monitor.'&status_module_group='.$status_module_group; - if ($paginate_module) { + if ($paginate_module === true) { ui_pagination( $count_modules, false, @@ -1349,7 +1376,7 @@ if (check_login()) { html_print_table($table); - if ($paginate_module) { + if ($paginate_module === true) { ui_pagination( $count_modules, false, @@ -1372,7 +1399,7 @@ if (check_login()) { unset($table_data); } - if ($get_type) { + if ($get_type === true) { $id_module = (int) get_parameter('id_module'); $module = modules_get_agentmodule($id_module); $graph_type = return_graphtype($module['id_tipo_modulo']); @@ -1626,7 +1653,7 @@ if (check_login()) { // If not valid it will throw an exception. json_decode($response); - if (json_last_error() == JSON_ERROR_NONE) { + if (json_last_error() === JSON_ERROR_NONE) { // If valid dump. echo $response; } else { @@ -1740,6 +1767,29 @@ if (check_login()) { } } + if ($delete_monitor_filter) { + $id = get_parameter('id'); + + $user_groups = users_get_groups( + $config['id_user'], + 'AW', + users_can_manage_group_all('AW'), + true + ); + + $sql = 'DELETE + FROM tmonitor_filter + WHERE id_filter = '.$id.' AND id_group_filter IN ('.implode(',', array_keys($user_groups)).')'; + + $monitor_filters = db_process_sql($sql); + + if ($monitor_filters === false) { + echo 'error'; + } else { + echo 'ok'; + } + } + if ($get_monitor_filters) { $sql = 'SELECT id_filter, id_name FROM tmonitor_filter'; @@ -1760,7 +1810,7 @@ if (check_login()) { $user_groups = users_get_groups( $config['id_user'], 'AR', - users_can_manage_group_all(), + users_can_manage_group_all('AR'), true ); @@ -1775,56 +1825,54 @@ if (check_login()) { $filters[$event_filter['id_filter']] = $event_filter['id_name']; } - echo '
'; + echo '
'; echo '
'; $table = new StdClass; $table->id = 'load_filter_form'; $table->width = '100%'; - $table->cellspacing = 4; - $table->cellpadding = 4; - $table->class = 'databox'; - if (is_metaconsole()) { - $table->cellspacing = 0; - $table->cellpadding = 0; - $table->class = 'databox filters'; - } - - $table->styleTable = 'font-weight: bold; color: #555; text-align:left;'; - $filter_id_width = '200px'; - if (is_metaconsole()) { - $filter_id_width = '150px'; - } + $table->class = 'filter-table-adv'; $data = []; $table->rowid[3] = 'update_filter_row1'; - $data[0] = __('Load filter').$jump; - $data[0] .= html_print_select( - $filters, - 'filter_id', - $current, - '', - __('None'), - 0, - true, - false, - true, - '', - false, - 'margin-left:5px; width:'.$filter_id_width.';' - ); - $data[1] = html_print_submit_button( + $data[0] = html_print_label_input_block( __('Load filter'), - 'load_filter', - false, - 'class="sub upd"', - true + html_print_select( + $filters, + 'filter_id', + $current, + '', + __('None'), + 0, + true, + false, + true, + '', + false + ) ); - $data[1] .= html_print_input_hidden('load_filter', 1, true); + $table->data[] = $data; $table->rowclass[] = ''; html_print_table($table); + html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Load filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], + true + ), + ], + false + ); + echo html_print_input_hidden('load_filter', 1, true); echo '
'; echo '
'; ?> @@ -1850,90 +1898,75 @@ if (check_login()) { } if ($save_filter_modal) { - echo '
'; + echo '
'; if (check_acl($config['id_user'], 0, 'AW')) { echo '
'; $table = new StdClass; $table->id = 'save_filter_form'; - $table->width = '100%'; - $table->cellspacing = 4; - $table->cellpadding = 4; - $table->class = 'databox'; - if (is_metaconsole()) { - $table->class = 'databox filters'; - $table->cellspacing = 0; - $table->cellpadding = 0; - } - - $table->styleTable = 'font-weight: bold; text-align:left;'; - if (!is_metaconsole()) { - $table->style[0] = 'width: 50%; width:50%;'; - } - + $table->size = []; + $table->size[0] = '50%'; + $table->size[1] = '50%'; + $table->class = 'filter-table-adv'; $data = []; + $table->rowid[0] = 'update_save_selector'; - $data[0] = html_print_radio_button( - 'filter_mode', - 'new', - '', - true, - true - ).__('New filter').''; + $data[0][0] = html_print_label_input_block( + __('New filter'), + html_print_radio_button( + 'filter_mode', + 'new', + '', + true, + true + ) + ); - $data[1] = html_print_radio_button( - 'filter_mode', - 'update', - '', - false, - true - ).__('Update filter').''; + $data[0][1] = html_print_label_input_block( + __('Update/delete filter'), + html_print_radio_button( + 'filter_mode', + 'update', + '', + false, + true + ) + ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; $table->rowid[1] = 'save_filter_row1'; - $data[0] = __('Filter name').$jump; - $data[0] .= html_print_input_text('id_name', '', '', 15, 255, true); - if (is_metaconsole()) { - $data[1] = __('Save in Group').$jump; - } else { - $data[1] = __('Filter group').$jump; + $data[1][0] = html_print_label_input_block( + __('Filter name'), + html_print_input_text('id_name', '', '', 15, 255, true) + ); + + $labelInput = __('Filter group'); + if (is_metaconsole() === true) { + $labelInput = __('Save in Group'); } $user_groups_array = users_get_groups_for_select( $config['id_user'], 'AW', - users_can_manage_group_all(), + users_can_manage_group_all('AW'), true ); - $data[1] .= html_print_select( - $user_groups_array, - 'id_group_filter_dialog', - $id_group_filter, - '', - '', - 0, - true, - false, - false, - 'w130' + $data[1][1] = html_print_label_input_block( + $labelInput, + html_print_select( + $user_groups_array, + 'id_group_filter_dialog', + $id_group_filter, + '', + '', + 0, + true, + false, + false + ), + ['div_class' => 'filter-group-dialog'] ); - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; $table->rowid[2] = 'save_filter_row2'; - - $table->data[] = $data; - $table->rowclass[] = ''; - - $data = []; - $table->rowid[3] = 'update_filter_row1'; - $data[0] = __('Overwrite filter').$jump; - $sql = 'SELECT id_filter, id_name FROM tmonitor_filter'; $monitor_filters = db_get_all_rows_sql($sql); @@ -1945,36 +1978,74 @@ if (check_login()) { } } - $data[0] .= html_print_select( - $_filters_update, - 'overwrite_filter', - '', - '', - '', - 0, - true - ); - $data[1] = html_print_submit_button( - __('Update filter'), - 'update_filter', - false, - 'class="sub upd" onclick="save_update_filter();"', - true + $data[2][0] = html_print_label_input_block( + __('Overwrite filter'), + html_print_select( + $_filters_update, + 'overwrite_filter', + '', + '', + '', + 0, + true + ) ); - $table->data[] = $data; - $table->rowclass[] = ''; + $table->data = $data; html_print_table($table); - echo '
'; - echo html_print_submit_button( - __('Save filter'), - 'save_filter', - false, - 'class="sub upd float-right" onclick="save_new_filter();"', - true - ); - echo '
'; + + html_print_div( + [ + 'id' => 'submit-save_filter', + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Save current filter'), + 'srcbutton', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + 'onclick' => 'save_new_filter();', + ], + true + ), + ], + false + ); + + $input_actions = html_print_submit_button( + __('Delete filter'), + 'delete_filter', + false, + [ + 'icon' => 'delete', + 'mode' => 'mini', + 'onclick' => 'save_delete_filter();', + ], + true + ); + + $input_actions .= html_print_submit_button( + __('Update filter'), + 'srcbutton', + false, + [ + 'icon' => 'update', + 'mode' => 'mini', + 'onclick' => 'save_update_filter();', + ], + true + ); + + html_print_div( + [ + 'id' => 'update_filter_row', + 'class' => 'action-buttons', + 'content' => $input_actions, + ], + false + ); } else { include 'general/noaccess.php'; } @@ -1983,29 +2054,34 @@ if (check_login()) { ?> + id_agente = (int) get_parameter('id_agente', 0); - $this->operation = get_parameter('operation', 0); + $this->id_agente = (int) get_parameter('id_agente'); + $this->operation = (int) get_parameter('operation'); $this->community = (string) get_parameter('community', 'public'); $this->ip = (string) get_parameter('select_ips'); $this->snmp_version = (string) get_parameter('select_version'); @@ -389,7 +389,13 @@ class ExternalTools extends HTML 'id' => '', 'class' => 'action-buttons', 'style' => 'width: 100%', - 'content' => html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"', true), + 'content' => html_print_submit_button( + __('Update'), + 'update_button', + false, + [ 'icon' => 'update' ], + true + ), ], true ); @@ -522,14 +528,16 @@ class ExternalTools extends HTML // Form table. $table = new StdClass(); - $table->class = 'databox filters w100p'; + $table->class = 'fixed_filter_bar'; $table->id = 'externalToolTable'; - + $table->cellstyle['captions'][0] = 'width: 0'; + $table->cellstyle['captions'][1] = 'width: 0'; + $table->cellstyle['captions'][2] = 'width: 0'; $table->data = []; - $table->data[0][0] = __('Operation'); + $table->data['captions'][0] = __('Operation'); - $table->data[0][1] = html_print_select( + $table->data['inputs'][0] = html_print_select( $commandList, 'operation', $this->operation, @@ -539,8 +547,8 @@ class ExternalTools extends HTML true ); - $table->data[0][2] = __('IP Adress'); - $table->data[0][3] = html_print_select( + $table->data['captions'][1] = __('IP Adress'); + $table->data['inputs'][1] = html_print_select( $ipsSelect, 'select_ips', $principal_ip, @@ -550,10 +558,10 @@ class ExternalTools extends HTML true ); - $table->cellclass[0][4] = 'snmpcolumn'; - $table->data[0][4] = __('SNMP Version'); - $table->data[0][4] .= ' '; - $table->data[0][4] .= html_print_select( + $table->cellclass['captions'][2] = 'snmpcolumn'; + $table->cellclass['inputs'][2] = 'snmpcolumn'; + $table->data['captions'][2] = __('SNMP Version'); + $table->data['inputs'][2] = html_print_select( [ '1' => 'v1', '2c' => 'v2c', @@ -566,10 +574,10 @@ class ExternalTools extends HTML true ); - $table->cellclass[0][5] = 'snmpcolumn'; - $table->data[0][5] = __('SNMP Community'); - $table->data[0][5] .= ' '; - $table->data[0][5] .= html_print_input_text( + $table->cellclass['captions'][3] = 'snmpcolumn'; + $table->cellclass['inputs'][3] = 'snmpcolumn'; + $table->data['captions'][3] = __('SNMP Community'); + $table->data['inputs'][3] = html_print_input_text( 'community', $this->community, '', @@ -578,7 +586,22 @@ class ExternalTools extends HTML true ); - $table->data[0][6] = ""; + $table->data['inputs'][4] = html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Execute'), + 'submit', + false, + [ + 'icon' => 'cog', + 'mode' => 'mini', + ], + true + ), + ], + true + ); // Output string. $output = ''; @@ -698,10 +721,10 @@ class ExternalTools extends HTML try { // If caption is not added, don't show anything. if (empty($caption) === false) { - $output .= sprintf('

%s

', $caption); + $output .= sprintf('

%s

', $caption); } - $output .= '
';
+            $output .= '
';
 
             // Only perform an execution if command is passed. Avoid errors.
             if (empty($command) === false) {
@@ -766,7 +789,7 @@ class ExternalTools extends HTML
                     'format'         => '-Oqn',
                 ];
 
-                echo '

'.__('SNMP information for ').$ip.'

'; + echo '

'.__('SNMP information for ').$ip.'

'; $snmp_obj['base_oid'] = '.1.3.6.1.2.1.1.3.0'; $result = get_h_snmpwalk($snmp_obj); @@ -828,7 +851,7 @@ class ExternalTools extends HTML html_print_table($table); } else if ((int) $operation === COMMAND_DIGWHOIS) { - echo '

'.__('Domain and IP information for ').$ip.'

'; + echo '

'.__('Domain and IP information for ').$ip.'

'; // Dig execution. $dig = $this->whereIsTheCommand('dig'); diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php index f2b6ed3630..a8f7c54985 100644 --- a/pandora_console/include/class/HTML.class.php +++ b/pandora_console/include/class/HTML.class.php @@ -311,7 +311,7 @@ class HTML public function printBreadcrum() { return implode( - ' / ', + ' / ', $this->breadcrum ); } @@ -398,7 +398,7 @@ class HTML * * @return void */ - public static function printGoBackButton($url=null) + public static function printGoBackButton($url=null, $return=false) { if (isset($url) === false) { $url = ui_get_full_url( @@ -418,14 +418,21 @@ class HTML 'name' => 'submit', 'label' => __('Go back'), 'type' => 'submit', - 'attributes' => 'class="sub cancel"', + 'attributes' => [ + 'icon' => 'back', + 'mode' => 'secondary', + ], 'return' => true, ], ], ], ]; - self::printForm($form); + if ($return === true) { + return self::printForm($form, $return); + } + + self::printForm($form, $return); } @@ -803,10 +810,13 @@ class HTML $output_head .= 'id="'.$form['id'].'" '; } + $output_head .= 'class="max_floating_element_size '; if (isset($form['class']) === true) { - $output_head .= 'class="discovery '.$form['class'].'" '; + $output_head .= 'discovery '.$form['class'].' '; } + $output_head .= '"'; + if (isset($form['onsubmit']) === true) { $output_head .= 'onsubmit="'.$form['onsubmit'].'" '; } @@ -870,7 +880,7 @@ class HTML $output .= '
'; } else { if ($print_white_box === true) { - $output .= '
'; + $output .= '
'; } $output .= '