diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 9d87093584..e6553ada2f 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-230306 +Version: 7.0NG.769-230313 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 e30ef809b8..cadc4a6fd2 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-230306" +pandora_version="7.0NG.769-230313" 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 2376f66ea0..f828e1a7ae 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 => '230306'; +use constant AGENT_BUILD => '230313'; # 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 2fe2b071e4..4ff8cf8848 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 230306 +%define release 230313 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 cf54a0a5bb..6705e0ee72 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 230306 +%define release 230313 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 9b77363457..06c37d34cd 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="230306" +PI_BUILD="230313" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index ef28e5b8d7..60ebc7abad 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{230306} +{230313} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 15de30d4ea..e7aeba8540 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 230306") +#define PANDORA_VERSION ("7.0NG.769 Build 230313") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index bf6685685a..394e2e2be5 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 230306))" + VALUE "ProductVersion", "(7.0NG.769(Build 230313))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index fc04649747..020733306e 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.769-230306 +Version: 7.0NG.769-230313 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 ce174aea69..5a23822ad2 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-230306" +pandora_version="7.0NG.769-230313" package_pear=0 package_pandora=1 diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 487f1b476d..d3467b846c 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -377,17 +377,17 @@ function mainAgentsModules() $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; + &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } else if ($full_modules_selected[0] && $full_agents_id[0]) { $full_modules = urlencode(implode(';', $full_modules_selected)); $full_agents = urlencode(implode(';', $full_agents_id)); $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; + &full_agents_id='.$full_agents.'&selection_agent_module='.$selection_a_m.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } else { $fullscreen['text'] = ''.html_print_image('images/full_screen.png', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; + offset='.$offset.'&group_id='.$group_id.'&modulegroup='.$modulegroup.'&refresh='.$refr.'&show_type='.$show_type.'">'.html_print_image('images/fullscreen@svg.svg', true, ['title' => __('Full screen mode'), 'class' => 'invert_filter']).''; } } @@ -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)); @@ -525,11 +597,11 @@ function mainAgentsModules() echo '
  • '; echo ''; echo html_print_image( - 'images/normal_screen.png', + 'images/exit_fullscreen@svg.svg', true, [ 'title' => __('Back to normal mode'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); echo ''; @@ -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..9b08815349 100755 --- a/pandora_console/extensions/api_checker.php +++ b/pandora_console/extensions/api_checker.php @@ -195,129 +195,183 @@ function extension_api_checker() ); } - ui_print_page_header( - __('API checker'), + // Header. + ui_print_standard_header( + __('Extensions'), 'images/extensions.png', false, '', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('API checker'), + ], + ] ); $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox filters filter-table-adv'; + $table->size[0] = '50%'; + $table->size[1] = '50%'; $table->data = []; $row = []; - $row[] = __('IP'); - $row[] = html_print_input_text('ip', $ip, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('IP'), + html_print_input_text('ip', $ip, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('%s Console URL', get_product_name()), + html_print_input_text('pandora_url', $pandora_url, '', 50, 255, true) + ); $table->data[] = $row; $row = []; - $row[] = __('%s Console URL', get_product_name()); - $row[] = html_print_input_text('pandora_url', $pandora_url, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('API Token').ui_print_help_tip(__('Use API Token instead API Pass, User and Password.'), true), + html_print_input_text('token', $token, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('API Pass'), + html_print_input_password('apipass', $apipass, '', 50, 255, true) + ); $table->data[] = $row; $row = []; - $row[] = __('API Token').ui_print_help_tip(__('Use API Token instead API Pass, User and Password.'), true); - $row[] = html_print_input_text('token', $token, '', 50, 255, true); - $table->data[] = $row; + $row[] = html_print_label_input_block( + __('User'), + html_print_input_text('user', $user, '', 50, 255, true) + ); - $row = []; - $row[] = __('API Pass'); - $row[] = html_print_input_password('apipass', $apipass, '', 50, 255, true); - $table->data[] = $row; - - $row = []; - $row[] = __('User'); - $row[] = html_print_input_text('user', $user, '', 50, 255, true); - $table->data[] = $row; - - $row = []; - $row[] = __('Password'); - $row[] = html_print_input_password('password', $password, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Password'), + html_print_input_password('password', $password, '', 50, 255, true) + ); $table->data[] = $row; $table2 = new stdClass(); + $table2->width = '100%'; + $table2->class = 'databox filters filter-table-adv'; + $table2->size[0] = '50%'; + $table2->size[1] = '50%'; $table2->data = []; $row = []; - $row[] = __('Action (get or set)'); - $row[] = html_print_input_text('op', $op, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Action (get or set)'), + html_print_input_text('op', $op, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('Operation'), + html_print_input_text('op2', $op2, '', 50, 255, true) + ); $table2->data[] = $row; $row = []; - $row[] = __('Operation'); - $row[] = html_print_input_text('op2', $op2, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('ID'), + html_print_input_text('id', $id, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('ID 2'), + html_print_input_text('id2', $id2, '', 50, 255, true) + ); $table2->data[] = $row; $row = []; - $row[] = __('ID'); - $row[] = html_print_input_text('id', $id, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Return Type'), + html_print_input_text('return_type', $return_type, '', 50, 255, true) + ); + + $row[] = html_print_label_input_block( + __('Other'), + html_print_input_text('other', $other, '', 50, 255, true) + ); $table2->data[] = $row; $row = []; - $row[] = __('ID 2'); - $row[] = html_print_input_text('id2', $id2, '', 50, 255, true); - $table2->data[] = $row; - - $row = []; - $row[] = __('Return Type'); - $row[] = html_print_input_text('return_type', $return_type, '', 50, 255, true); - $table2->data[] = $row; - - $row = []; - $row[] = __('Other'); - $row[] = html_print_input_text('other', $other, '', 50, 255, true); - $table2->data[] = $row; - - $row = []; - $row[] = __('Other Mode'); - $row[] = html_print_input_text('other_mode', $other_mode, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('Other Mode'), + html_print_input_text('other_mode', $other_mode, '', 50, 255, true) + ); $table2->data[] = $row; $table3 = new stdClass(); + $table3->width = '100%'; + $table3->class = 'databox filters filter-table-adv'; + $table3->size[0] = '50%'; + $table3->size[1] = '50%'; $table3->data = []; $row = []; - $row[] = __('Raw URL'); - $row[] = html_print_input_text('url', $url, '', 50, 2048, true); + $row[] = html_print_label_input_block( + __('Raw URL'), + html_print_input_text('url', $url, '', 50, 2048, true) + ); $table3->data[] = $row; - echo ""; - echo '
    '; + echo ""; + echo '
    '; echo ''.__('Credentials').''; html_print_table($table); echo '
    '; - echo '
    '; + echo '
    '; echo ''.__('Call parameters').' '.ui_print_help_tip(__('Action: get Operation: module_last_value id: 63'), true).''; html_print_table($table2); echo '
    '; echo "
    "; echo '
    '; - echo '
    '; + echo '
    '; echo ''.__('Custom URL').''; 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_action_buttons( + html_print_submit_button( + __('Call'), + 'submit', + false, + [ 'icon' => 'next' ], + true + ) + ); + echo ''; if ($api_execute === true) { - echo '
    '; + echo '
    '; echo ''.__('Result').''; - echo __('URL').'
    '; - html_print_input_password('url', $return_call_api['url'], '', 150, 255, false, true); - echo " "; - html_print_image('images/input_zoom.png'); - echo ''; + echo html_print_label_input_block( + __('URL'), + html_print_input_password('url', $return_call_api['url'], '', 150, 255, true, true, false, 'mrgn_top_10px'), + ['label_class' => 'font-title-font'] + ); echo '
    '; - echo __('Result').'
    '; - html_print_textarea('result', 30, 20, $return_call_api['result'], 'readonly="readonly"'); + echo html_print_label_input_block( + __('Result'), + html_print_textarea('result', 30, 20, $return_call_api['result'], 'readonly="readonly"', true, 'w100p mrgn_top_10px'), + ['label_class' => 'font-title-font'] + ); echo '
    '; } ?> diff --git a/pandora_console/extensions/db_status.php b/pandora_console/extensions/db_status.php index 638d795b31..25965efb0c 100755 --- a/pandora_console/extensions/db_status.php +++ b/pandora_console/extensions/db_status.php @@ -21,13 +21,23 @@ function extension_db_status() $db_name = get_parameter('db_name', ''); $db_status_execute = (bool) get_parameter('db_status_execute', false); - ui_print_page_header( + ui_print_standard_header( __('DB Schema check'), 'images/extensions.png', false, 'db_status_tab', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Run test'), + ], + ] ); if (!is_user_admin($config['id_user'])) { @@ -46,32 +56,89 @@ function extension_db_status() __('At the moment the checks is for MySQL/MariaDB.') ); - echo "
    "; + echo ""; echo '
    '; echo ''.__('DB settings').''; $table = new stdClass(); $table->data = []; $row = []; - $row[] = __('DB User with privileges'); - $row[] = html_print_input_text('db_user', $db_user, '', 50, 255, true); - $row[] = __('DB Password for this user'); - $row[] = html_print_input_password('db_password', $db_password, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('DB User with privileges'), + html_print_input_text( + 'db_user', + $db_user, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); + $row[] = html_print_label_input_block( + __('DB Password for this user'), + html_print_input_password( + 'db_password', + $db_password, + '', + 50, + 255, + true, + false, + false, + 'w100p mrgn_top_10px' + ) + ); $table->data[] = $row; $row = []; - $row[] = __('DB Hostname'); - $row[] = html_print_input_text('db_host', $db_host, '', 50, 255, true); - $row[] = __('DB Name (temporal for testing)'); - $row[] = html_print_input_text('db_name', $db_name, '', 50, 255, true); + $row[] = html_print_label_input_block( + __('DB Hostname'), + html_print_input_text( + 'db_host', + $db_host, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); + $row[] = html_print_label_input_block( + __('DB Name (temporal for testing)'), + html_print_input_text( + 'db_name', + $db_name, + '', + 50, + 255, + true, + false, + false, + '', + 'w100p mrgn_top_10px' + ) + ); $table->data[] = $row; 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_action_buttons( + 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..1ec40b79f1 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'; @@ -122,47 +132,37 @@ function dbmgr_extension_main() echo $warning_message; } + ui_print_warning_message( + __( + "This is an advanced extension to interface with %s database directly from WEB console + using native SQL sentences. Please note that you can damage your %s installation + if you don't know exactly what are you are doing, + this means that you can severily damage your setup using this extension. + This extension is intended to be used only by experienced users + with a depth knowledge of %s internals.", + get_product_name(), + get_product_name(), + get_product_name() + ) + ); + echo "
    "; $table = new stdClass(); $table->id = 'db_interface'; - $table->class = 'databox'; + $table->class = 'databox no_border filter-table-adv'; $table->width = '100%'; $table->data = []; - $table->head = []; $table->colspan = []; - $table->rowstyle = []; + $table->style[0] = 'width: 30%;'; + $table->style[1] = 'width: 70%;'; - $table->colspan[0][0] = 2; $table->colspan[1][0] = 2; - $table->rowspan[2][0] = 3; - $table->rowclass[0] = 'notify'; - $table->rowclass[3] = 'pdd_5px'; - $table->rowclass[3] = 'flex-content-right'; - $table->rowclass[4] = 'flex-content-right'; - - $data[0][0] = __( - "This is an advanced extension to interface with %s database directly from WEB console - using native SQL sentences. Please note that you can damage your %s installation - if you don't know exactly what are you are doing, - this means that you can severily damage your setup using this extension. - This extension is intended to be used only by experienced users - with a depth knowledge of %s internals.", - get_product_name(), - get_product_name(), - get_product_name() - ); - - $data[1][0] = "Some samples of usage:
    SHOW STATUS;
    DESCRIBE tagente
    SELECT * FROM tserver
    UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
    "; - - $data[2][0] = html_print_textarea( - 'sql', - 5, - 50, - html_entity_decode($sql, ENT_QUOTES), - '', - true + $data[0][0] = "Some samples of usage:
    SHOW STATUS;
    DESCRIBE tagente
    SELECT * FROM tserver
    UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
    "; + $data[0][0] = html_print_label_input_block( + __('Some samples of usage:'), + "
    SHOW STATUS;
    DESCRIBE tagente
    SELECT * FROM tserver
    UPDATE tagente SET id_grupo = 15 WHERE nombre LIKE '%194.179%'
    " ); if (is_metaconsole() === true) { @@ -181,32 +181,57 @@ function dbmgr_extension_main() $servers = []; } - $data[3][2] = html_print_input( - [ - 'name' => 'node_id', - 'type' => 'select', - 'fields' => $servers, - 'selected' => $node_id, - 'nothing' => __('This metaconsole'), - 'nothing_value' => -1, - 'return' => true, - 'label' => _('Select query target'), - ] + $data[0][1] = html_print_label_input_block( + __('Select query target'), + html_print_select( + $servers, + 'node_id', + $node_id, + '', + __('This metaconsole'), + -1, + true, + false, + false, + 'w40p', + false, + 'width: 40%;' + ) ); } - $data[4][2] = '
    '; - $data[4][2] .= html_print_submit_button( + $data[1][0] = html_print_textarea( + 'sql', + 3, + 50, + html_entity_decode($sql, ENT_QUOTES), + 'placeholder="'.__('Type your query here...').'"', + true, + 'w100p' + ); + + $execute_button = html_print_submit_button( __('Execute SQL'), '', false, - 'class="sub next"', + [ 'icon' => 'cog' ], true ); - $data[4][2] .= '
    '; $table->data = $data; - html_print_table($table); + // html_print_table($table); + html_print_action_buttons($execute_button); + ui_toggle( + html_print_table($table, true), + ''.__('SQL query').'', + __('SQL query'), + 'query', + false, + false, + '', + 'white-box-content no_border', + 'box-flat white_table_graph fixed_filter_bar' + ); echo ''; // Processing SQL Code. @@ -214,10 +239,6 @@ function dbmgr_extension_main() return; } - echo '
    '; - echo '
    '; - echo '
    '; - try { if (\is_metaconsole() === true && $node_id !== -1) { $node = new Node($node_id); @@ -282,22 +303,17 @@ function dbmgr_extension_main() html_print_table($table); echo ''; - if (is_metaconsole()) { - close_meta_frame(); - } - } if (is_metaconsole() === true) { // This adds a option in the operation menu. extensions_add_meta_menu_option( - 'DB interface', + __('DB interface'), 'PM', 'gextensions', 'database.png', - 'v1r1', - 'gdbman' + 'v1r1' ); extensions_add_meta_function('dbmgr_extension_main'); diff --git a/pandora_console/extensions/dbmanager/dbmanager.css b/pandora_console/extensions/dbmanager/dbmanager.css index 1e44dce3a8..1882b71e92 100644 --- a/pandora_console/extensions/dbmanager/dbmanager.css +++ b/pandora_console/extensions/dbmanager/dbmanager.css @@ -24,7 +24,6 @@ table.dbmanager th { } textarea { - min-height: 50px; - height: 50px; - width: 95%; + width: 100% !important; + max-width: 100% !important; } diff --git a/pandora_console/extensions/extension_uploader.php b/pandora_console/extensions/extension_uploader.php index f5447703e8..d989a3661b 100644 --- a/pandora_console/extensions/extension_uploader.php +++ b/pandora_console/extensions/extension_uploader.php @@ -25,13 +25,28 @@ function extension_uploader_extensions() return; } - ui_print_page_header( - __('Uploader extension'), + // Header. + ui_print_standard_header( + __('Extensions'), 'images/extensions.png', false, '', true, - '' + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('Uploader extension'), + ], + ] ); $upload = (bool) get_parameter('upload', 0); @@ -77,20 +92,52 @@ function extension_uploader_extensions() $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox filters'; + $table->class = 'databox filters filter-table-adv'; + $table->size[0] = '20%'; + $table->size[1] = '20%'; + $table->size[2] = '60%'; $table->data = []; - $table->data[0][0] = __('Upload extension'); - $table->data[0][1] = html_print_input_file('extension', true).ui_print_help_tip(__('Upload the extension as a zip file.'), true); + + $table->data[0][0] = html_print_label_input_block( + __('Upload extension').ui_print_help_tip(__('Upload the extension as a zip file.'), true), + html_print_input_file( + 'extension', + true, + [ + 'required' => true, + 'accept' => '.zip', + ] + ) + ); + if (enterprise_installed()) { - $table->data[0][2] = __('Upload enterprise extension').' '.html_print_checkbox('upload_enterprise', 1, false, true); + $table->data[0][1] = html_print_label_input_block( + __('Upload enterprise extension'), + html_print_checkbox( + 'upload_enterprise', + 1, + false, + true + ) + ); + } else { + $table->data[0][1] = ''; } + $table->data[0][2] = ''; + echo "
    "; html_print_table($table); - echo "
    "; html_print_input_hidden('upload', 1); - html_print_submit_button(__('Upload'), 'submit', false, 'class="sub add"'); - echo '
    '; + html_print_action_buttons( + html_print_submit_button( + __('Upload'), + 'submit', + false, + ['icon' => 'wand'], + true + ) + ); echo ''; } diff --git a/pandora_console/extensions/files_repo.php b/pandora_console/extensions/files_repo.php index c319954748..656c3377c7 100644 --- a/pandora_console/extensions/files_repo.php +++ b/pandora_console/extensions/files_repo.php @@ -115,19 +115,41 @@ function pandora_files_repo_godmode() } // Header tabs. - $godmode['text'] = ''.html_print_image('images/setup.png', true, ['title' => __('Administration view'), 'class' => 'invert_filter']).''; + $godmode['text'] = ''.html_print_image('images/configuration@svg.svg', true, ['title' => __('Administration view'), 'class' => 'main_menu_icon invert_filter']).''; $godmode['godmode'] = 1; $godmode['active'] = 1; - $operation['text'] = ''.html_print_image('images/eye_show.png', true, ['title' => __('Operation view'), 'class' => 'invert_filter']).''; + $operation['text'] = ''.html_print_image('images/see-details@svg.svg', true, ['title' => __('Operation view'), 'class' => 'main_menu_icon invert_filter']).''; $operation['operation'] = 1; $onheader = [ 'godmode' => $godmode, 'operation' => $operation, ]; + // Header. - ui_print_page_header(__('Files repository manager'), 'images/extensions.png', false, '', true, $onheader); + ui_print_standard_header( + __('Extensions'), + 'images/extensions.png', + false, + '', + true, + $onheader, + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('Files repository manager'), + ], + ] + ); $full_extensions_dir = $config['homedir'].'/'.EXTENSIONS_DIR.'/'; include_once $full_extensions_dir.'files_repo/functions_files_repo.php'; @@ -204,10 +226,10 @@ function pandora_files_repo_operation() // Header tabs. $onheader = []; if (check_acl($config['id_user'], 0, 'PM')) { - $godmode['text'] = ''.html_print_image('images/setup.png', true, ['title' => __('Administration view'), 'class' => 'invert_filter']).''; + $godmode['text'] = ''.html_print_image('images/configuration@svg.svg', true, ['title' => __('Administration view'), 'class' => 'main_menu_icon invert_filter']).''; $godmode['godmode'] = 1; - $operation['text'] = ''.html_print_image('images/eye_show.png', true, ['title' => __('Operation view'), 'class' => 'invert_filter']).''; + $operation['text'] = ''.html_print_image('images/see-details@svg.svg', true, ['title' => __('Operation view'), 'class' => 'main_menu_icon invert_filter']).''; $operation['operation'] = 1; $operation['active'] = 1; diff --git a/pandora_console/extensions/files_repo/files_repo_form.php b/pandora_console/extensions/files_repo/files_repo_form.php index a78606c271..d96357e87b 100644 --- a/pandora_console/extensions/files_repo/files_repo_form.php +++ b/pandora_console/extensions/files_repo/files_repo_form.php @@ -32,17 +32,15 @@ if (isset($file_id) && $file_id > 0) { $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox filters'; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; -$table->style[2] = 'text-align: center;'; -$table->colspan = []; +$table->class = 'databox filters filter-table-adv'; +$table->size[0] = '50%'; +$table->size[1] = '50%'; $table->data = []; -// GROUPS +// GROUPS. $groups = groups_get_all(); -// Add the All group to the beginning to be always the first -// Use this instead array_unshift to keep the array keys +// Add the All group to the beginning to be always the first. +// Use this instead array_unshift to keep the array keys. $groups = ([0 => __('All')] + $groups); $groups_selected = []; foreach ($groups as $id => $name) { @@ -52,66 +50,110 @@ foreach ($groups as $id => $name) { } $row = []; -$row[0] = __('Groups'); -$row[1] = '
    '.html_print_select_groups( - // Id_user. - false, - // Privilege. - 'AR', - // ReturnAllGroup. - true, - // Name. - 'groups[]', - // Selected. - $groups_selected, - // Script. - '', - // Nothing. - '', - // Nothing_value. - 0, - // Return. - true, - // Multiple. - true -).'
    '; -$table->data[] = $row; -$table->colspan[][1] = 3; +$row[0] = html_print_label_input_block( + __('Groups'), + html_print_select_groups( + // Id_user. + false, + // Privilege. + 'AR', + // ReturnAllGroup. + true, + // Name. + 'groups[]', + // Selected. + $groups_selected, + // Script. + '', + // Nothing. + '', + // Nothing_value. + 0, + // Return. + true, + // Multiple. + true + ) +); -// DESCRIPTION -$row = []; -$row[0] = __('Description'); -$row[0] .= ui_print_help_tip(__('Only 200 characters are permitted'), true); -$row[1] = html_print_textarea('description', 3, 20, $file['description'], 'class="file_repo_description"', true); +// DESCRIPTION. +$row[1] = html_print_label_input_block( + __('Description').ui_print_help_tip(__('Only 200 characters are permitted'), true), + html_print_textarea( + 'description', + 4, + 20, + $file['description'], + 'class="file_repo_description" style="min-height: 60px; max-height: 60px;"', + true + ) +); $table->data[] = $row; -$table->colspan[][1] = 3; -// FILE and SUBMIT BUTTON +// FILE and SUBMIT BUTTON. $row = []; -// Public checkbox +// Public checkbox. $checkbox = html_print_checkbox('public', 1, (bool) !empty($file['hash']), true); $style = 'class="inline padding-2-10"'; $row[0] = __('File'); if ($file_id > 0) { - $row[1] = $file['name']; - $row[2] = "
    ".__('Public link')." $checkbox
    "; - $row[3] = html_print_submit_button(__('Update'), 'submit', false, 'class="sub upd"', true); - $row[3] .= html_print_input_hidden('update_file', 1, true); - $row[3] .= html_print_input_hidden('file_id', $file_id, true); + $submit_button = html_print_submit_button( + __('Update'), + 'submit', + false, + ['icon' => 'wand'], + true + ); + + $row[0] = html_print_label_input_block( + __('File'), + $file['name'] + ); + + $row[1] = html_print_label_input_block( + __('Public link'), + $checkbox.html_print_input_hidden( + 'file_id', + $file_id, + true + ) + ); } else { - $row[1] = html_print_input_file('upfile', true); - $row[2] = "
    ".__('Public link')." $checkbox
    "; - $row[3] = html_print_submit_button(__('Add'), 'submit', false, 'class="sub add"', true); - $row[3] .= html_print_input_hidden('add_file', 1, true); + $submit_button = html_print_submit_button( + __('Add'), + 'submit', + false, + ['icon' => 'wand'], + true + ); + + $row[0] = html_print_label_input_block( + __('File'), + html_print_input_file( + 'upfile', + true + ) + ); + + $row[1] = html_print_label_input_block( + __('Public link'), + $checkbox.html_print_input_hidden( + 'add_file', + 1, + true + ) + ); } + + $table->data[] = $row; -$table->colspan[][1] = 1; $url = ui_get_full_url('index.php?sec=godmode/extensions&sec2=extensions/files_repo'); echo "
    "; html_print_table($table); +html_print_action_buttons($submit_button); echo ''; ?> diff --git a/pandora_console/extensions/files_repo/files_repo_list.php b/pandora_console/extensions/files_repo/files_repo_list.php index 783e155dc4..2cb464eec3 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'] @@ -133,9 +133,12 @@ if (!empty($files)) { ); $data[4] .= ""; $data[4] .= html_print_image( - 'images/config.png', + 'images/edit.svg', true, - ['title' => __('Edit')] + [ + 'title' => __('Edit'), + 'class' => 'main_menu_icon invert_filter', + ] ); // Edit image $data[4] .= ''; @@ -145,11 +148,11 @@ if (!empty($files)) { ); $data[4] .= " "; $data[4] .= html_print_image( - 'images/cross.png', + 'images/delete.svg', true, [ 'title' => __('Delete'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); // Delete image 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/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index 21b817b978..28dcaa0814 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -11,11 +11,12 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function view_logfile($file_name) +function view_logfile($file_name, $toggle=false) { global $config; $memory_limit = ini_get('memory_limit'); + $code = ''; if (strstr($memory_limit, 'M') !== false) { $memory_limit = str_replace('M', '', $memory_limit); @@ -31,21 +32,37 @@ function view_logfile($file_name) $file_size = filesize($file_name); if ($memory_limit < $file_size) { - echo "

    $file_name (".__('File is too large than PHP memory allocated in the system.').')

    '; - echo '

    '.__('The preview file is imposible.').'

    '; + $code .= '

    '.$file_name.' ('.__('File is too large than PHP memory allocated in the system.').')

    '; + $code .= '

    '.__('The preview file is imposible.').'

    '; } else if ($file_size > ($config['max_log_size'] * 1000)) { $data = file_get_contents($file_name, false, null, ($file_size - ($config['max_log_size'] * 1000))); - echo "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; - echo "

    '; + $code .= "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; + $code .= "

    '; } else { $data = file_get_contents($file_name); - echo "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; - echo "

    '; + $code .= "

    $file_name (".format_numeric(filesize($file_name) / 1024).' KB) '.ui_print_help_tip(__('The folder /var/log/pandora must have pandora:apache and its content too.'), true).'

    '; + $code .= "

    '; + } + + if ($toggle === true) { + ui_toggle( + $code, + ''.$file_name.'', + $file_name, + 'a', + false, + false, + '', + 'white-box-content no_border', + 'filter-datatable-main box-flat white_table_graph' + ); + } else { + echo $code; } } } @@ -64,21 +81,45 @@ function pandoralogs_extension_main() return; } - ui_print_page_header(__('System logfile viewer'), 'images/extensions.png', false, '', true, ''); + // Header. + ui_print_standard_header( + __('Extensions'), + 'images/extensions.png', + false, + '', + true, + [], + [ + [ + 'link' => '', + 'label' => __('Admin tools'), + ], + [ + 'link' => '', + 'label' => __('Extension manager'), + ], + [ + 'link' => '', + 'label' => __('System logfile viewer'), + ], + ] + ); - echo '

    '.__('Use this tool to view your %s logfiles directly on the console', get_product_name()).'

    '; - - echo '

    '.__('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), '.($config['max_log_size'] * 1000).'B at the moment').'

    '; + ui_print_info_message( + __('Use this tool to view your %s logfiles directly on the console', get_product_name()).'
    + '.__('You can choose the amount of information shown in general setup (Log size limit in system logs viewer extension), '.($config['max_log_size'] * 1000).'B at the moment') + ); $logs_directory = (!empty($config['server_log_dir'])) ? io_safe_output($config['server_log_dir']) : '/var/log/pandora'; // Do not attempt to show console log if disabled. if ($config['console_log_enabled']) { - view_logfile($config['homedir'].'/log/console.log'); + view_logfile($config['homedir'].'/log/console.log', true); } - view_logfile($logs_directory.'/pandora_server.log'); - view_logfile($logs_directory.'/pandora_server.error'); + view_logfile($logs_directory.'/pandora_server.log', true); + view_logfile($logs_directory.'/pandora_server.error', true); + } 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/extensions/users_connected.php b/pandora_console/extensions/users_connected.php index 40b17f4903..ad6282c598 100644 --- a/pandora_console/extensions/users_connected.php +++ b/pandora_console/extensions/users_connected.php @@ -1,16 +1,33 @@ '', + 'label' => __('Workspace'), + ], + [ + 'link' => '', + 'label' => __('Users connected'), + ], + ] + ); $check_profile = db_get_row('tusuario_perfil', 'id_usuario', $config['id_user'], 'id_up'); if ($check_profile === false && !users_is_admin()) { diff --git a/pandora_console/extras/mr/62.sql b/pandora_console/extras/mr/62.sql index e4ef421b1f..76f0a84c4e 100644 --- a/pandora_console/extras/mr/62.sql +++ b/pandora_console/extras/mr/62.sql @@ -1,5 +1,65 @@ 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, @@ -27,4 +87,72 @@ 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'); +CREATE TABLE IF NOT EXISTS `twelcome_tip` ( + `id` INT NOT NULL AUTO_INCREMENT, + `id_lang` VARCHAR(20) NULL, + `id_profile` INT NOT NULL, + `title` VARCHAR(255) NOT NULL, + `text` TEXT NOT NULL, + `url` VARCHAR(255) NULL, + `enable` TINYINT NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +CREATE TABLE IF NOT EXISTS `twelcome_tip_file` ( + `id` INT NOT NULL AUTO_INCREMENT, + `twelcome_tip_file` INT NOT NULL, + `filename` VARCHAR(255) NOT NULL, + `path` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `twelcome_tip_file` + FOREIGN KEY (`twelcome_tip_file`) + REFERENCES `twelcome_tip` (`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; + +INSERT INTO `twelcome_tip` VALUES +(1,'es',0,'¿Sabías que puedes monitorizar webs?','De manera sencilla a través de chequeos HTTP estándar o transaccional mediante transacciones centralizadas WUX, o descentralizadas con el plugin UX de agente.','https://pandorafms.com/manual/es/documentation/03_monitoring/06_web_monitoring','1'), +(2,'es',0,'Monitorización remota de dispositivos SNMP','Los dispositivos de red como switches, AP, routers y firewalls se pueden monitorizar remotamente usando el protocolo SNMP. Basta con saber su IP, la comunidad SNMP y lanzar un wizard SNMP desde la consola.','https://pandorafms.com/manual/es/documentation/03_monitoring/03_remote_monitoring#monitorizacion_snmp','1'), +(3,'es',0,'Monitorizar rutas desde una IP a otra','Existe un plugin especial que sirve para monitorizar visualmente las rutas desde una IP a otra de manera visual y dinámica, según va cambiando con el tiempo.','https://pandorafms.com/manual/es/documentation/03_monitoring/03_remote_monitoring#monitorizacion_de_rutas','1'), +(4,'es',0,'¿Tu red pierde paquetes?','Se puede medir la pérdida de paquetes en tu red usando un agente y un plugin libre llamado “Packet Loss”. Esto es especialmente útil en redes Wifi o redes compartidas con muchos usuarios. Escribimos un artículo en nuestro blog hablando de ello, echale un vistazo','https://pandorafms.com/blog/es/perdida-de-paquetes/','1'), +(5,'es',0,'Usar Telegram con Pandora FMS','Perfecto para recibir alertas con gráficas empotradas y personalizar así la recepción de avisos de manera individual o en un canal común con mas personas. ','https://pandorafms.com/library/telegram-bot-cli/','1'), +(6,'es',0,'Monitorizar JMX (Tomcat, Websphere, Weblogic, Jboss, Apache Kafka, Jetty, GlassFish…)','Existe un plugin Enterprise que sirve para monitorizar cualquier tecnología JMX. Se puede usar de manera local (como plugin local) o de manera remota con el plugin server.','https://pandorafms.com/library/jmx-monitoring/','1'), +(7,'es',0,'¿Sabes que cada usuario puede tener su propia Zona Horaria?','Se puede establecer zonas horarias diferentes para cada usuario, de manera que interprete los datos teniendo en cuenta la diferencia horaria. Pandora FMS también puede tener servidores y agentes en diferentes zonas horarias. ¡Por todo el mundo!','','1'), +(8,'es',0,'Paradas planificadas','Se puede definir, a nivel de agente y a nivel de módulo, períodos en los cuales se ignoren las alertas y/o los datos recogidos. Es perfecto para planificar paradas de servicio o desconexión de los sistemas monitorizados. También afecta a los informes SLA, evitando que se tengan en cuenta esos intervalos de tiempo. ','https://pandorafms.com/manual/es/documentation/04_using/11_managing_and_administration#paradas_de_servicio_planificadas','1'), +(9,'es',0,'Personalizar los emails de alerta ','¿Sabías que se pueden personalizar los mails de alertas de Pandora? Solo tienes que editar el código HTML por defecto de las acciones de alerta de tipo email. ','https://pandorafms.com/manual/en/documentation/04_using/01_alerts#editing_an_action','1'), +(10,'es',0,'Usando iconos personalizados en consolas visuales ','Gracias a los iconos personalizados se pueden crear vistas muy personalizadas, como la de la imagen, que representa racks con los tipos de servidores en el orden que están colocados dentro del rack. Perfecto para que un técnico sepa exactamente qué máquina esta fallando. Más visual no puede ser, de ahi el nombre. ','https://pandorafms.com/manual/start?id=es/documentation/04_using/05_data_presentation_visual_maps','1'), +(11,'es',0,'Consolas visuales: mapas de calor ','La consola permite integrar en un fondo personalizado una serie de datos, que en función de su valor se representen con unos colores u otros, en tiempo real. Las aplicaciones son infinitas, solo depende de tu imaginación. ','https://pandorafms.com/manual/es/documentation/04_using/05_data_presentation_visual_maps#mapa_de_calor_o_nube_de_color','1'), +(12,'es',0,'Auditoría interna de la consola ','La consola registra todas las actividades relevantes de cada usuario conectado a la consola. Esto incluye la aplicación de configuraciones, validaciones de eventos y alertas, conexión y desconexión y cientos de otras operaciones. La seguridad en Pandora FMS ha sido siempre una de las características del diseño de su arquitectura. ','https://pandorafms.com/manual/es/documentation/04_using/11_managing_and_administration#log_de_auditoria','1'), +(13,'es',0,'Sistema de provisión automática de agentes ','El sistema de autoprovisión de agentes, permite que un agente recién ingresado en el sistema aplique automáticamente cambios en su configuración (como moverlo de grupo, asignarle ciertos valores en campos personalizados) y por supuesto aplicarle determinadas politicas de monitorización. Es una de las funcionalidades más potentes, orientadas a gestionar parques de sistemas muy extensos. ','https://pandorafms.com/manual/start?id=es/documentation/02_installation/05_configuration_agents#configuracion_automatica_de_agentes','1'), +(14,'es',0,'Modo oscuro ','¿Sabes que existe un modo oscuro en Pandora FMS? Un administrador lo puede activar a nivel global desde las opciones de configuración visuales o cualquier usuario a nivel individual, en las opciones de usuario. ','','1'), +(15,'es',0,'Google Sheet ','¿Sabes que se puede coger el valor de una celda de una hoja de cálculo de Google Sheet?, utilizamos la API para pedir el dato a través de un plugin remoto. Es perfecto para construir cuadros de mando de negocio, obtener alertas en tiempo real y crear tus propios informes a medida. ','https://pandorafms.com/library/google-sheets-plugin/','1'), +(16,'es',0,'Tablas de ARP','¿Sabes que existe un módulo de inventario para sacar las tablas ARP de tus servidores windows? Es fácil de instalar y puede darte información muy detallada de tus equipos.','https://pandorafms.com/library/arp-table-windows-local/','1'), +(17,'es',0,'Enlaces de red en la consola visual ','Existe un elemento de consola visual llamado “Network link” que permite mostrar visualmente la unión de dos interfaces de red, su estado y el tráfico de subida/bajada, de una manera muy visual. ','https://pandorafms.com/manual/es/documentation/04_using/05_data_presentation_visual_maps#enlace_de_red','1'), +(18,'es',0,'¿Conoces los informes de disponibilidad? ','Son muy útiles ya que te dicen el tiempo (%) que un chequeo ha estado en diferentes estados a lo largo de un lapso de tiempo, por ejemplo, una semana. Ofrece datos crudos completos de lo que se ha hecho con el detalle suficiente para convencer a un proveedor o un cliente. ','','1'), +(19,'es',0,'Gráficas de disponibilidad ','Parecidos a los informes de disponibilidad, pero mucho mas visuales, ofrecen el detalle de estado de un monitor a lo largo del tiempo. Se pueden agrupar con otro módulo para ofrecer datos finales teniendo en cuenta la alta disponibilidad de un servicio. Son perfectos para su uso en informes a proveedores y/o clientes. ','https://pandorafms.com/manual/es/documentation/04_using/08_data_presentation_reports#grafico_de_disponibilidad','1'), +(20,'es',0,'Zoom en gráficas de datos ','¿Sabes que Pandora FMS permite hacer zoom en una parte de la gráfica. Con eso ampliarás la información de la gráfica. Si estás viendo una gráfica de un mes y amplías, podrás ver los datos de ese intervalo. Si utilizas una gráfica con datos de resolución completa (los llamamos gráficas TIP) podrás ver el detalle de cada dato, aunque tu gráfica tenga miles de muestras. ','','1'), +(21,'es',0,'Gráficas de resolución completa ','Pandora FMS y otras herramientas cuando tienen que mostrar una gráfica obtienen los datos de la fuente de datos y luego “simplifican” la gráfica, ya que si la serie de datos tiene 10,000 elementos y la gráfica solo tiene 300 pixeles de ancho no pueden caber todos, asi que se “simplifican” esos 10,000 puntos en solo 300. Sin embargo al simplificar se pierde “detalle” en la gráfica, y por supuesto no podemos “hacer zoom”. Las gráficas de Pandora FMS permiten mostrar y usar todos los datos en una gráfica, que llamamos “TIP” que muestra todos los puntos superpuestos y además permite que al hacer zoom no se pierda resolución. ','','1'), +(22,'es',0,'Política de contraseñas','La consola de Pandora FMS tiene un sistema de gestión de política de credenciales, para reforzar la seguridad local (además de permitir la autenticación externa contra un LDAP, Active Directory o SAML). A través de este sistema podemos forzar cambios de password cada X días, guardar un histórico de passwords usadas o evitar el uso de ciertas contraseñas entre otras acciones. ','https://pandorafms.com/manual/es/documentation/04_using/12_console_setup?s%5B%5D%3Dcontrase%25C3%25B1as#password_policy','1'), +(23,'es',0,'Autenticación de doble factor ','Es posible activar (y forzar su uso a todos los usuarios) un sistema de doble autenticación (usando Google Auth) para que cualquier usuario se autentique además de con una contraseña, con un sistema de token de un solo uso, dando al sistema mucha más seguridad. ','https://pandorafms.com/manual/en/documentation/04_using/12_console_setup?s%5B%5D%3Dgoogle%26s%5B%5D%3Dauth#authentication','1'); + +INSERT INTO `twelcome_tip_file` (`twelcome_tip_file`, `filename`, `path`) VALUES +(1, 'monitorizar_web.png', 'images/tips/'), +(2, 'monitorizar_snmp.png', 'images/tips/'), +(3, 'monitorizar_desde_ip.png', 'images/tips/'), +(4, 'tu_red_pierde_paquetes.png', 'images/tips/'), +(5, 'telegram_con_pandora.png', 'images/tips/'), +(6, 'monitorizar_con_jmx.png', 'images/tips/'), +(7, 'usuario_zona_horaria.png', 'images/tips/'), +(8, 'paradas_planificadas.png', 'images/tips/'), +(9, 'personalizar_los_emails.png', 'images/tips/'), +(10, 'iconos_personalizados.png', 'images/tips/'), +(11, 'mapa_de_calor.png', 'images/tips/'), +(12, 'auditoria.png', 'images/tips/'), +(15, 'google_sheets.png', 'images/tips/'), +(17, 'enlaces_consola_visual.png', 'images/tips/'), +(18, 'informe_disponibiliad.png', 'images/tips/'), +(19, 'graficas_disponibilidad.png', 'images/tips/'), +(20, 'zoom_en_graficas.png', 'images/tips/'), +(22, 'politica_de_pass.png', 'images/tips/'); + 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'); @@ -107,6 +117,7 @@ echo sprintf('
    ', $menuTypeClass); } } + $search_bar .= '
    '; $search_bar .= '', $menuTypeClass); $search_bar .= "value='".$config['search_keywords']."'"; } - $search_bar .= 'type="search" onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" - onkeyup="showinterpreter()" class="search_input"/>'; + $search_bar .= 'type="search" onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" onkeyup="showinterpreter()" class="search_input"/>'; - - $search_bar .= '
    '; // $search_bar .= 'onClick="javascript: document.quicksearch.submit()"'; $search_bar .= ""; $search_bar .= ''; - $header_searchbar = ''; } @@ -227,10 +234,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 +300,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 +319,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 +357,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 +381,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 +395,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 +407,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 = ' - - - - 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..1f9a204d95 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,401 @@ 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/general/register.php b/pandora_console/general/register.php index 1c8249ddf5..8714d1ec12 100644 --- a/pandora_console/general/register.php +++ b/pandora_console/general/register.php @@ -31,6 +31,7 @@ global $config; require_once $config['homedir'].'/include/functions_register.php'; require_once $config['homedir'].'/include/class/WelcomeWindow.class.php'; +require_once $config['homedir'].'/include/class/TipsWindow.class.php'; if ((bool) is_ajax() === true) { @@ -109,6 +110,16 @@ try { $welcome = false; } +try { + if (isset($_SESSION['showed_tips_window']) === false) { + $tips_window = new TipsWindow(); + if ($tips_window !== null) { + $tips_window->run(); + } + } +} catch (Exception $e) { +} + $double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']); if (isset($config['2FA_all_users']) === false) { 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..a5a1445341 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,94 +376,97 @@ $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( - 'images/page_white_text.png', + 'images/hardware-software-component@svg.svg', true, [ 'title' => __('Inventory'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).''; @@ -474,11 +476,6 @@ if ($id_agente) { $inventorytab['active'] = false; } - if ($inventorytab == -1) { - $inventorytab = ''; - } - - $has_remote_conf = enterprise_hook( 'config_agents_has_remote_configuration', [$id_agente] @@ -490,7 +487,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 +497,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'] = '
    '; -enterprise_hook('close_meta_frame'); +// This is an image generated for JS. $delete_image = html_print_input_image( 'del', - 'images/cross.png', + 'images/delete.svg', 1, '', true, @@ -1757,7 +1898,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'); - ?> 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, @@ -1350,7 +1376,7 @@ if (check_login()) { html_print_table($table); - if ($paginate_module) { + if ($paginate_module === true) { ui_pagination( $count_modules, false, @@ -1373,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']); @@ -1627,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 { @@ -1799,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 '
    '; ?> @@ -1874,55 +1898,49 @@ 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/delete 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( @@ -1932,32 +1950,23 @@ if (check_login()) { 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); @@ -1969,45 +1978,74 @@ if (check_login()) { } } - $data[0] .= html_print_select( - $_filters_update, - 'overwrite_filter', - '', - '', - '', - 0, + $data[2][0] = html_print_label_input_block( + __('Overwrite 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 ); - $table->data[] = $data; - $table->rowclass[] = ''; + $input_actions .= html_print_submit_button( + __('Update filter'), + 'srcbutton', + false, + [ + 'icon' => 'update', + 'mode' => 'mini', + 'onclick' => 'save_update_filter();', + ], + true + ); - html_print_table($table); - echo '

    '; - echo html_print_submit_button( - __('Update filter'), - 'update_filter', - false, - 'class="sub upd" onclick="save_update_filter();"', - true - ); - echo html_print_submit_button( - __('Delete filter'), - 'delete_filter', - false, - 'class="sub delete float-right" onclick="save_delete_filter();"', - true - ); - echo '
    '; - echo '

    '; - echo html_print_submit_button( - __('Save current filter'), - 'save_filter', - false, - 'class="sub upd float-right" onclick="save_new_filter();"', - true - ); - echo '
    '; + html_print_div( + [ + 'id' => 'update_filter_row', + 'class' => 'action-buttons', + 'content' => $input_actions, + ], + false + ); } else { include 'general/noaccess.php'; } @@ -2016,32 +2054,34 @@ if (check_login()) { ?> '; $output .= '
    fullSize) { $output .= ' width:100%'; @@ -3665,11 +3757,7 @@ class NetworkMap // Open networkconsole_id div. $output .= '
    fullSize) { - if ($this->widget) { - $output .= ' class="networkconsole">'; - } else { - $output .= ' class="networkconsole">'; - } + $output .= ' class="networkconsole">'; } else { $output .= ' style="width: '.$this->mapOptions['width'].'px; height: '.$this->mapOptions['height'].'px;position: relative; overflow: hidden; background: #FAFAFA">'; } @@ -3691,7 +3779,7 @@ class NetworkMap $output .= '
    '; - $output .= html_print_image('/images/icono_borrar.png', true, ['id' => 'image_hide_show_labels']); + $output .= html_print_image('/images/disable.svg', true, ['id' => 'image_hide_show_labels', 'class' => 'main_menu_icon invert_filter']); $output .= '
    '; $output .= '
    __('Tactical View'), 'icon' => ui_get_full_url( - 'images/menu/op_monitoring.menu_gray.png' + 'images/menu/monitoring.svg' ), 'url' => ui_get_full_url( 'index.php?sec=view&sec2=operation/agentes/tactical' @@ -122,7 +122,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Agent Management'), 'icon' => ui_get_full_url( - 'images/menu/gm_resources.menu_gray.png' + 'images/menu/resources.svg' ), 'url' => ui_get_full_url( 'index.php?sec=gagente&sec2=godmode/agentes/modificar_agente' @@ -140,7 +140,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('General Setup'), 'icon' => ui_get_full_url( - 'images/menu/gm_setup.menu_gray.png' + 'images/menu/settings.svg' ), 'url' => ui_get_full_url( 'index.php?sec=general&sec2=godmode/setup/setup§ion=general' @@ -156,7 +156,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Manage Policies'), 'icon' => ui_get_full_url( - 'images/menu/gm_configuration.menu_gray.png' + 'images/menu/configuration.svg' ), 'url' => ui_get_full_url( 'index.php?sec=gmodules&sec2=enterprise/godmode/policies/policies' @@ -170,7 +170,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('List Alerts'), 'icon' => ui_get_full_url( - 'images/menu/gm_alerts.menu_gray.png' + 'images/menu/alerts.svg' ), 'url' => ui_get_full_url( 'index.php?sec=galertas&sec2=godmode/alerts/alert_list' @@ -194,7 +194,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('View Events'), 'icon' => ui_get_full_url( - 'images/menu/op_events.menu_gray.png' + 'images/menu/events.svg' ), 'url' => ui_get_full_url( 'index.php?sec=eventos&sec2=operation/events/events' @@ -218,7 +218,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Dashboard'), 'icon' => ui_get_full_url( - 'images/menu/op_reporting.menu_gray.png' + 'images/menu/reporting.svg' ), 'url' => ui_get_full_url( 'index.php?sec=reporting&sec2=operation/dashboard/dashboard' @@ -232,7 +232,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Visual Console'), 'icon' => ui_get_full_url( - 'images/menu/op_network.menu_gray.png' + 'images/menu/network.svg' ), 'url' => ui_get_full_url( 'index.php?sec=network&sec2=godmode/reporting/map_builder' @@ -246,7 +246,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Manage Servers'), 'icon' => ui_get_full_url( - 'images/menu/gm_servers.menu_gray.png' + 'images/menu/servers.svg' ), 'url' => ui_get_full_url( 'index.php?sec=gservers&sec2=godmode/servers/modificar_server' @@ -260,7 +260,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Edit User'), 'icon' => ui_get_full_url( - 'images/menu/gm_users.menu_gray.png' + 'images/menu/users.svg' ), 'url' => ui_get_full_url( 'index.php?sec=workspace&sec2=operation/users/user_edit' @@ -270,7 +270,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Tree View'), 'icon' => ui_get_full_url( - 'images/menu/op_monitoring.menu_gray.png' + 'images/menu/monitoring.svg' ), 'url' => ui_get_full_url( 'index.php?sec=view&sec2=operation/tree' @@ -280,7 +280,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Network Component'), 'icon' => ui_get_full_url( - 'images/menu/gm_configuration.menu_gray.png' + 'images/menu/configuration.svg' ), 'url' => ui_get_full_url( 'index.php?sec=gmodules&sec2=godmode/modules/manage_network_components' @@ -294,7 +294,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Task List'), 'icon' => ui_get_full_url( - 'images/menu/gm_discovery.menu.png' + 'images/menu/discovery.svg' ), 'url' => ui_get_full_url( 'index.php?sec=discovery&sec2=godmode/servers/discovery&wiz=tasklist' @@ -338,7 +338,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Warp Update'), 'icon' => ui_get_full_url( - 'images/menu/um_messages.menu_gray.png' + 'images/menu/warp_update.svg' ), 'url' => ui_get_full_url( 'index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=setup' @@ -352,7 +352,7 @@ class OrderInterpreter extends Wizard [ 'name' => __('Manage Agent Groups'), 'icon' => ui_get_full_url( - 'images/menu/gm_users.menu_gray.png' + 'images/menu/users.svg' ), 'url' => ui_get_full_url( 'index.php?sec=gagente&sec2=godmode/groups/group_list&tab=groups' diff --git a/pandora_console/include/class/SatelliteAgent.class.php b/pandora_console/include/class/SatelliteAgent.class.php index 72c15795a4..18a4806bb5 100644 --- a/pandora_console/include/class/SatelliteAgent.class.php +++ b/pandora_console/include/class/SatelliteAgent.class.php @@ -157,11 +157,6 @@ class SatelliteAgent extends HTML $this->tableId = 'satellite_agents'; - if (is_metaconsole() === true) { - // Only in case of Metaconsole, format the frame. - open_meta_frame(); - } - // Load datatables user interface. ui_print_datatable( [ @@ -211,11 +206,6 @@ class SatelliteAgent extends HTML echo $e->getMessage(); } - if (is_metaconsole() === true) { - // Close the frame. - close_meta_frame(); - } - // Auxiliar div. $modal = ''; $msg = ''; @@ -411,7 +401,7 @@ class SatelliteAgent extends HTML if ($disable === false) { $tmp->actions .= html_print_image( - ($delete === true) ? 'images/add.png' : 'images/cross.png', + ($delete === true) ? 'images/add.png' : 'images/delete.svg', true, [ 'border' => '0', @@ -969,41 +959,28 @@ class SatelliteAgent extends HTML */ private function ajaxMsg($type, $msg, $delete=false, $disable=false) { - $msg_err = 'Failed while saving: %s'; - $msg_ok = 'Successfully saved agent '; - - if ($delete === true) { - $msg_err = 'Failed while removing: %s'; - $msg_ok = 'Successfully deleted '; - } - - if ($disable === true) { - $msg_err = 'Failed while disabling: %s'; - $msg_ok = 'Successfully disabled'; - } - - if ($type == 'error') { - echo json_encode( - [ - $type => ui_print_error_message( - __($msg), - '', - true - ), - ] - ); + if ($type === 'error') { + if ($delete === true) { + $msg_title = 'Failed while removing'; + } else if ($disable === true) { + $msg_title = 'Failed while disabling'; + } else { + $msg_title = 'Failed while saving'; + } } else { - echo json_encode( - [ - $type => ui_print_success_message( - __($msg), - '', - true - ), - ] - ); + if ($delete === true) { + $msg_title = 'Successfully deleted'; + } else if ($disable === true) { + $msg_title = 'Successfully disabled'; + } else { + $msg_title = 'Successfully saved agent'; + } } + echo json_encode( + [ $type => __($msg_title).':
    '.$msg ] + ); + exit; } @@ -1258,7 +1235,7 @@ class SatelliteAgent extends HTML $('body').append('
    '); - $("#submit-create").on('click', function() { + $("#button-create").on('click', function() { show_form(); }); diff --git a/pandora_console/include/class/SatelliteCollection.class.php b/pandora_console/include/class/SatelliteCollection.class.php index 769ec5c6f4..a8af32d3b6 100644 --- a/pandora_console/include/class/SatelliteCollection.class.php +++ b/pandora_console/include/class/SatelliteCollection.class.php @@ -84,7 +84,7 @@ class SatelliteCollection extends HTML return; } - if ((int) $config['license_nms'] === 0) { + if ((int) $config['license_nms'] === 1) { db_pandora_audit( AUDIT_LOG_NMS_VIOLATION, 'Trying to access satellite collections' @@ -119,11 +119,6 @@ class SatelliteCollection extends HTML $this->createBlock(); - if (is_metaconsole() === true) { - // Only in case of Metaconsole, format the frame. - open_meta_frame(); - } - // Datatables list. try { $columns = [ @@ -179,11 +174,6 @@ class SatelliteCollection extends HTML echo $e->getMessage(); } - if (is_metaconsole() === true) { - // Close the frame. - close_meta_frame(); - } - echo ''; echo ''; @@ -246,7 +236,7 @@ class SatelliteCollection extends HTML $tmp->actions = ''; $tmp->actions .= html_print_image( - ($delete === 0) ? 'images/add.png' : 'images/cross.png', + ($delete === 0) ? 'images/add.png' : 'images/delete.svg', true, [ 'border' => '0', @@ -485,27 +475,11 @@ class SatelliteCollection extends HTML */ private function ajaxMsg(string $type, string $msg) { - if ($type === 'error') { - echo json_encode( - [ - $type => ui_print_error_message( - __($msg), - '', - true - ), - ] - ); - } else { - echo json_encode( - [ - $type => ui_print_success_message( - __($msg), - '', - true - ), - ] - ); - } + echo json_encode( + [ + $type => __($msg), + ] + ); exit; } diff --git a/pandora_console/include/class/SnmpConsole.class.php b/pandora_console/include/class/SnmpConsole.class.php index 3e31f810d5..ec7e3394dd 100644 --- a/pandora_console/include/class/SnmpConsole.class.php +++ b/pandora_console/include/class/SnmpConsole.class.php @@ -183,29 +183,29 @@ class SnmpConsole extends HTML if (!isset($config['pure']) || $config['pure'] === false) { $statistics['text'] = ''.html_print_image( - 'images/op_reporting.png', + 'images/logs@svg.svg', true, [ 'title' => __('Statistics'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).''; $list['text'] = ''.html_print_image( - 'images/op_snmp.png', + 'images/SNMP-network-numeric-data@svg.svg', true, [ 'title' => __('List'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ).''; $list['active'] = true; $screen['text'] = ''.html_print_image( - 'images/full_screen.png', + 'images/fullscreen@svg.svg', true, [ - 'title' => __('List'), - 'class' => 'invert_filter', + 'title' => __('View in full screen'), + 'class' => 'main_menu_icon invert_filter', ] ).''; @@ -242,11 +242,11 @@ class SnmpConsole extends HTML echo ''; echo html_print_image( - 'images/normal_screen.png', + 'images/exit_fullscreen@svg.svg', true, [ 'title' => __('Exit fullscreen'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); echo ''; @@ -383,14 +383,13 @@ class SnmpConsole extends HTML 5 => __('Other'), ]; - $this->tableId = 'snmp_console'; - + $tableId = 'snmp_console'; // Load datatables user interface. ui_print_datatable( [ - 'id' => $this->tableId, + 'id' => $tableId, 'class' => 'info_table', - 'style' => 'width: 100%', + 'style' => 'width: 99%', 'columns' => $columns, 'column_names' => $column_names, 'ajax_url' => $this->ajaxController, @@ -421,6 +420,7 @@ class SnmpConsole extends HTML 'fields' => $show_alerts, 'return' => true, 'selected' => $this->filter_alert, + 'style' => 'widht:100% !important', ], [ 'label' => __('Severity'), @@ -431,6 +431,7 @@ class SnmpConsole extends HTML 'fields' => $severities, 'return' => true, 'selected' => $this->filter_severity, + 'style' => 'widht:100%', ], [ 'label' => __('Free search'), @@ -449,6 +450,7 @@ class SnmpConsole extends HTML 'fields' => $status_array, 'return' => true, 'selected' => $this->filter_status, + 'style' => 'widht:100%', ], [ 'label' => __('Group by Enterprise String/IP'), @@ -484,77 +486,103 @@ class SnmpConsole extends HTML ], ], ], + 'pagination_options' => [ + [ + $config['block_size'], + 5, + 10, + 25, + 100, + 200, + 500, + 1000, + ], + [ + $config['block_size'], + 5, + 10, + 25, + 100, + 200, + 500, + 1000, + ], + ], + 'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar', ] ); } catch (Exception $e) { echo $e->getMessage(); } - echo '
    '; - html_print_submit_button(__('Validate'), 'updatebt', false, 'class="sub ok"'); - echo ' '; - html_print_submit_button( + $buttons[] = html_print_submit_button( + __('Validate'), + 'updatebt', + false, + [ + 'class' => 'sub ok', + 'icon' => 'next', + ], + true + ); + $buttons[] = html_print_submit_button( __('Delete'), 'deletebt', false, - 'class="sub delete" onClick="javascript:return confirm(\''.__('Are you sure?').'\')"' + [ + 'icon' => 'delete', + 'mode' => 'secondary', + 'onClick' => "javascript:return confirm('".__('Are you sure?')."')", + ], + true ); - echo '
    '; - echo '
    '; - echo '

    '.__('Status').'

    '; - echo html_print_image( - 'images/pixel_green.png', - true, - [ - 'width' => '20', - 'height' => '20', - ] - ).' - '.__('Validated'); - echo '
    '; - echo html_print_image( - 'images/pixel_red.png', - true, - [ - 'width' => '20', - 'height' => '20', - ] - ).' - '.__('Not validated'); - echo '
    '; - echo '
    '; - echo '

    '.__('Alert').'

    '; - echo html_print_image( - 'images/pixel_yellow.png', - true, - [ - 'width' => '20', - 'height' => '20', - ] - ).' - '.__('Fired'); - echo '
    '; - echo html_print_image( - 'images/pixel_gray.png', - true, - [ - 'width' => '20', - 'height' => '20', - ] - ).' - '.__('Not fired'); - echo '
    '; - echo '
    '; - echo '

    '.__('Action').'

    '; - echo html_print_image('images/ok.png', true).' - '.__('Validate'); - echo '
    '; - echo html_print_image('images/cross.png', true, ['class' => 'invert_filter']).' - '.__('Delete'); - echo '
    '; - echo '
    '; - echo '

    '.__('Severity').'

    '; - foreach (get_priorities() as $num => $name) { - echo ''.$name.''; - echo '
    '; + html_print_action_buttons( + implode('', $buttons), + ['type' => 'form_action'] + ); + + $legend = ''; + $legend .= ''; + $legend .= ''; + $legend .= ''; + + ui_toggle($legend, __('Legend')); // Load own javascript file. echo $this->loadJS(); @@ -816,7 +844,7 @@ class SnmpConsole extends HTML $tmp->snmp_agent .= ''.$tmp->source.''; } else { $tmp->snmp_agent .= ''; } @@ -882,12 +910,13 @@ class SnmpConsole extends HTML $tmp->action = ''; if ($status != 1) { $tmp->action .= ''.html_print_image( - 'images/ok.png', + 'images/validate.svg', true, [ 'border' => '0', 'title' => __('Validate'), 'onclick' => 'validate_trap(\''.$tmp->id_trap.'\')', + 'class' => 'invert_filter main_menu_icon', ] ).' '; } @@ -895,41 +924,63 @@ class SnmpConsole extends HTML if ($tmp->source === '') { if (\users_is_admin()) { $tmp->action .= ''.html_print_image( - 'images/cross.png', + 'images/delete.svg', true, [ 'border' => '0', 'title' => __('Delete'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', 'onclick' => 'delete_trap(\''.$tmp->id_trap.'\')', ] ).' '; } } else { $tmp->action .= ''.html_print_image( - 'images/cross.png', + 'images/delete.svg', true, [ 'border' => '0', 'title' => __('Delete'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', 'onclick' => 'delete_trap(\''.$tmp->id_trap.'\')', ] ).' '; } - $tmp->action .= ''.html_print_image( - 'images/eye.png', + $tmp->action .= ''.html_print_image( + 'images/see-details@svg.svg', true, [ + 'id' => 'img_'.$tmp->id_trap, 'alt' => __('Show more'), 'title' => __('Show more'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', + ] + ).' '.html_print_image( + 'images/disable.svg', + true, + [ + 'id' => 'img_hide_'.$tmp->id_trap, + 'alt' => __('Hide details'), + 'title' => __('Hide details'), + 'class' => 'invert_filter main_menu_icon', + 'style' => 'display:none', ] ).''; if ($config['enterprise_installed']) { - $tmp->action .= ''.html_print_image('images/edit.png', true, ['alt' => __('SNMP trap editor'), 'title' => __('SNMP trap editor')]).''; + $tmp->action .= ''; + $tmp->action .= html_print_image( + 'images/edit.svg', + true, + [ + 'alt' => __('SNMP trap editor'), + 'title' => __('SNMP trap editor'), + 'class' => 'main_menu_icon invert_filter', + ] + ); + $tmp->action .= ''; } $tmp->m = html_print_checkbox_extended('snmptrapid[]', $tmp->id_trap, false, false, '', 'class="chk"', true); @@ -1341,119 +1392,138 @@ class SnmpConsole extends HTML * Show more information */ function toggleVisibleExtendedInfo(id, position) { - $('tr[id^=show_]').remove() - $.ajax({ - method: 'get', - url: '', - data: { - page: 'operation/snmpconsole/snmp_view', - method: 'showInfo', - id: id, - group_by : $('#filter_group_by').val(), - alert: $('#filter_alert').val(), - severity: $('#filter_severity').val(), - search: $('#text-filter_free_search').val(), - status: $('#filter_status').val(), - hours_ago: $('#text-filter_hours_ago').val(), - trap_type: $('#filter_trap_type').val() - }, - datatype: "json", - success: function(data) { - let trap = JSON.parse(data); - var tr = $('#snmp_console tr').eq(position+1); - - // Count. - if ($('#filter_group_by').val() == 1) { - let labelCount = ''; - let variableCount = ``; - - tr.after(`${labelCount}${variableCount}`); - } - - // Type. - desc_trap_type = ""; - switch (trap['type']) { - case -1: - desc_trap_type = ""; - break; - - case 0: - desc_trap_type = ""; - break; - - case 1: - desc_trap_type = ""; - break; - - case 2: - desc_trap_type = ""; - break; - - case 3: - desc_trap_type = ""; - break; - - case 4: - desc_trap_type = ""; - break; - - default: - desc_trap_type = ""; - break; - } - - let labelType = ''; - let variableType = ``; - - tr.after(`${labelType}${variableType}`); - - // Description. - if (trap['description']) { - let labelDesc = ''; - let variableDesc = ``; - - tr.after(`${labelDesc}${variableDesc}`); - } - - // Enterprise String. - let labelOid = ''; - let variableOId = ``; - - tr.after(`${labelOid}${variableOId}`); - - // Variable bindings. - let labelBindings = ''; - let variableBindings = ''; - if ($('#filter_group_by').val() == 1) { - labelBindings = ''; - - let new_url = 'index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view'; - new_url += '&filter_severity='+$('#filter_severity').val(); - new_url += '&filter_status='+$('#filter_status').val(); - new_url += '&filter_alert='+$('#filter_alert').val(); - new_url += '&filter_group_by=0&filter_free_search='+$('#text-filter_free_search').val(); - new_url += '&filter_hours_ago='+$('#text-filter_hours_ago').val(); - new_url += '&filter_trap_type='+$('#filter_trap_type').val(); - - const string = ''; - - variableBindings = ``; - } else { - labelBindings = ''; - const binding_vars = trap['oid_custom'].split("\t"); - let string = ''; - binding_vars.forEach(function(oid) { - string += oid+'
    '; - }); - variableBindings = `
    `; - } - - tr.after(`${labelBindings}${variableBindings}`); - }, - error: function(e) { - console.error(e); - } + // Show all "Show more" + $('[id^=img_]').each(function() { + $(this).show(); }); + // Hide all "Hide details" + $('[id^=img_hide_]').each(function() { + $(this).hide(); + }); + var status = $('#eye_'+id).attr('data-show'); + if(status == "show"){ + $('tr[id^=show_]').remove() + $.ajax({ + method: 'get', + url: '', + data: { + page: 'operation/snmpconsole/snmp_view', + method: 'showInfo', + id: id, + group_by : $('#filter_group_by').val(), + alert: $('#filter_alert').val(), + severity: $('#filter_severity').val(), + search: $('#text-filter_free_search').val(), + status: $('#filter_status').val(), + hours_ago: $('#text-filter_hours_ago').val(), + trap_type: $('#filter_trap_type').val() + }, + datatype: "json", + success: function(data) { + let trap = JSON.parse(data); + var tr = $('#snmp_console tr').eq(position+1); + + // Count. + if ($('#filter_group_by').val() == 1) { + let labelCount = ''; + let variableCount = ``; + + tr.after(`${labelCount}${variableCount}`); + } + + // Type. + desc_trap_type = ""; + switch (trap['type']) { + case -1: + desc_trap_type = ""; + break; + + case 0: + desc_trap_type = ""; + break; + + case 1: + desc_trap_type = ""; + break; + + case 2: + desc_trap_type = ""; + break; + + case 3: + desc_trap_type = ""; + break; + + case 4: + desc_trap_type = ""; + break; + + default: + desc_trap_type = ""; + break; + } + + let labelType = ''; + let variableType = ``; + + tr.after(`${labelType}${variableType}`); + + // Description. + if (trap['description']) { + let labelDesc = ''; + let variableDesc = ``; + + tr.after(`${labelDesc}${variableDesc}`); + } + + // Enterprise String. + let labelOid = ''; + let variableOId = ``; + + tr.after(`${labelOid}${variableOId}`); + + // Variable bindings. + let labelBindings = ''; + let variableBindings = ''; + if ($('#filter_group_by').val() == 1) { + labelBindings = ''; + + let new_url = 'index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view'; + new_url += '&filter_severity='+$('#filter_severity').val(); + new_url += '&filter_status='+$('#filter_status').val(); + new_url += '&filter_alert='+$('#filter_alert').val(); + new_url += '&filter_group_by=0&filter_free_search='+$('#text-filter_free_search').val(); + new_url += '&filter_hours_ago='+$('#text-filter_hours_ago').val(); + new_url += '&filter_trap_type='+$('#filter_trap_type').val(); + + const string = ''; + + variableBindings = ``; + } else { + labelBindings = ''; + const binding_vars = trap['oid_custom'].split("\t"); + let string = ''; + binding_vars.forEach(function(oid) { + string += oid+'
    '; + }); + variableBindings = `
    `; + } + + tr.after(`${labelBindings}${variableBindings}`); + }, + error: function(e) { + console.error(e); + } + }); + $('#eye_'+id).attr('data-show', 'hide'); + $('#img_'+id).hide(); + $('#img_hide_'+id).show(); + } else{ + $('tr[id^=show_]').remove(); + $('#eye_'+id).attr('data-show', 'show'); + $('#img_'+id).show(); + $('#img_hide_'+id).hide(); + } } $(document).ready(function() { @@ -1469,7 +1539,7 @@ class SnmpConsole extends HTML } }); - $('#submit-updatebt').click(function() { + $('#button-updatebt').click(function() { let array = []; $('input[name="snmptrapid[]"]:checked').each(function() { array.push(this.value); @@ -1496,7 +1566,7 @@ class SnmpConsole extends HTML } }); - $('#submit-deletebt').click(function() { + $('#button-deletebt').click(function() { let array = []; $('input[name="snmptrapid[]"]:checked').each(function() { array.push(this.value); diff --git a/pandora_console/include/class/TipsWindow.class.php b/pandora_console/include/class/TipsWindow.class.php new file mode 100644 index 0000000000..6f159c8ec7 --- /dev/null +++ b/pandora_console/include/class/TipsWindow.class.php @@ -0,0 +1,1057 @@ + $msg] + ); + } + + + /** + * Checks if target method is available to be called using AJAX. + * + * @param string $method Target method. + * + * @return boolean True allowed, false not. + */ + public function ajaxMethod($method) + { + // Check access. + check_login(); + + return in_array($method, $this->AJAXMethods); + } + + + /** + * Constructor. + * + * @param string $ajax_controller Controller. + * + * @return object + * @throws Exception On error. + */ + public function __construct( + $ajax_controller='include/ajax/tips_window.ajax' + ) { + $this->ajaxController = $ajax_controller; + + return $this; + } + + + /** + * Main method. + * + * @return void + */ + public function run() + { + global $config; + $_SESSION['showed_tips_window'] = true; + $userInfo = users_get_user_by_id($config['id_user']); + + if ((bool) $userInfo['show_tips_startup'] === false) { + return; + } + + ui_require_css_file('tips_window'); + ui_require_css_file('jquery.bxslider'); + ui_require_javascript_file('tipsWindow'); + ui_require_javascript_file('jquery.bxslider.min'); + echo '
    '; + $totalTips = $this->getTotalTipsShowUser(); + if ($totalTips > 0) { + echo ''; + } + } + + + /** + * Render view modal with random tip + * + * @return void + */ + public function renderView() + { + $initialTip = $this->getRandomTip(true); + View::render( + 'dashboard/tipsWindow', + [ + 'title' => $initialTip['title'], + 'text' => $initialTip['text'], + 'url' => $initialTip['url'], + 'files' => $initialTip['files'], + 'id' => $initialTip['id'], + ] + ); + } + + + /** + * Render preview view modal with parameter + * + * @return void + */ + public function renderPreview() + { + $title = get_parameter('title', ''); + $text = get_parameter('text', ''); + $url = get_parameter('url', ''); + $files = get_parameter('files', ''); + $totalFiles64 = get_parameter('totalFiles64', ''); + $files64 = false; + + if ($totalFiles64 > 0) { + $files64 = []; + for ($i = 0; $i < $totalFiles64; $i++) { + $files64[] = get_parameter('file64_'.$i, ''); + } + } + + if (empty($files) === false) { + $files = explode(',', $files); + foreach ($files as $key => $value) { + $files[$key] = str_replace(ui_get_full_url('/'), '', $value); + } + } + + View::render( + 'dashboard/tipsWindow', + [ + 'title' => $title, + 'text' => $text, + 'url' => $url, + 'preview' => true, + 'files' => (empty($files) === false) ? $files : false, + 'files64' => (empty($files64) === false) ? $files64 : false, + ] + ); + } + + + /** + * Search a tip by id + * + * @param integer $idTip Id from tip. + * + * @return array $tip + */ + public function getTipById($idTip) + { + $tip = db_get_row( + 'twelcome_tip', + 'id', + $idTip, + ); + if ($tip !== false) { + $tip['title'] = io_safe_output($tip['title']); + $tip['text'] = io_safe_output($tip['text']); + $tip['url'] = io_safe_output($tip['url']); + } + + return $tip; + } + + + /** + * Return a tip or print it in json + * + * @param boolean $return Param for return or print json. + * + * @return array $tip + */ + public function getRandomTip($return=false) + { + global $config; + $exclude = get_parameter('exclude', ''); + $userInfo = users_get_user_by_id($config['id_user']); + $profilesUser = users_get_user_profile($config['id_user']); + $language = ($userInfo['language'] !== 'default') ? $userInfo['language'] : $config['language']; + + $idProfilesFilter = '0'; + foreach ($profilesUser as $key => $profile) { + $idProfilesFilter .= ','.$profile['id_perfil']; + } + + $sql = 'SELECT id, title, text, url + FROM twelcome_tip + WHERE enable = "1" '; + + if (empty($exclude) === false && $exclude !== null) { + $exclude = implode(',', json_decode($exclude, true)); + if ($exclude !== '') { + $sql .= sprintf(' AND id NOT IN (%s)', $exclude); + } + } + + $sql .= sprintf(' AND id_profile IN (%s)', $idProfilesFilter); + + $sql .= ' ORDER BY CASE WHEN id_lang = "'.$language.'" THEN id_lang END DESC, RAND()'; + + $tip = db_get_row_sql($sql); + + if (empty($tip) === false) { + $tip['files'] = $this->getFilesFromTip($tip['id']); + + $tip['title'] = io_safe_output($tip['title']); + $tip['text'] = io_safe_output($tip['text']); + $tip['url'] = io_safe_output($tip['url']); + } + + if ($return) { + if (empty($tip) === false) { + return $tip; + } else { + return false; + } + } else { + if (empty($tip) === false) { + echo json_encode(['success' => true, 'data' => $tip]); + return; + } else { + echo json_encode(['success' => false]); + return; + } + } + } + + + /** + * Get number of tips in database + * + * @return integer + */ + public function getTotalTips() + { + return db_get_sql('SELECT count(*) FROM twelcome_tip'); + } + + + /** + * Get totals tips that user can show + * + * @return array + */ + public function getTotalTipsShowUser() + { + global $config; + $profilesUser = users_get_user_profile($config['id_user']); + $idProfilesFilter = '0'; + foreach ($profilesUser as $key => $profile) { + $idProfilesFilter .= ','.$profile['id_perfil']; + } + + $sql = 'SELECT count(*) + FROM twelcome_tip + WHERE enable = "1" '; + + $sql .= sprintf(' AND id_profile IN (%s)', $idProfilesFilter); + + $sql .= ' ORDER BY CASE WHEN id_lang = "'.$config['language'].'" THEN id_lang END DESC, RAND()'; + + return db_get_sql($sql); + } + + + /** + * Return files from tip + * + * @param integer $idTip Id from tip. + * + * @return array + */ + public function getFilesFromTip($idTip) + { + if (empty($idTip) === true) { + return false; + } + + $sql = sprintf('SELECT id, filename, path FROM twelcome_tip_file WHERE twelcome_tip_file = %s', $idTip); + + return db_get_all_rows_sql($sql); + + } + + + /** + * Delete all images from tip in db and files + * + * @param integer $idTip Id from tip. + * @param array $imagesToRemove Array with id and images path. + * + * @return void + */ + public function deleteImagesFromTip($idTip, $imagesToRemove) + { + foreach ($imagesToRemove as $id => $image) { + unlink($image); + db_process_sql_delete( + 'twelcome_tip_file', + [ + 'id' => $id, + 'twelcome_tip_file' => $idTip, + ] + ); + } + } + + + /** + * Update token user for show tips at startup + * + * @return void + */ + public function setShowTipsAtStartup() + { + global $config; + $showTipsStartup = get_parameter('show_tips_startup', ''); + if ($showTipsStartup !== '' && $showTipsStartup !== null) { + $result = db_process_sql_update( + 'tusuario', + ['show_tips_startup' => $showTipsStartup], + ['id_user' => $config['id_user']] + ); + + if ($result !== false) { + echo json_encode(['success' => true]); + return; + } else { + echo json_encode(['success' => false]); + return; + } + } else { + echo json_encode(['success' => false]); + return; + } + + } + + + /** + * Draw table in list tips + * + * @param array $errors Array of errors if exists. + * + * @return void + */ + public function draw($errors=null) + { + ui_require_css_file('tips_window'); + + if ($errors !== null) { + if (count($errors) > 0) { + foreach ($errors as $key => $value) { + ui_print_error_message($value); + } + } else { + ui_print_success_message(__('Tip deleted')); + } + } + + try { + $columns = [ + 'language', + 'title', + 'text', + 'enable', + 'actions', + ]; + + $columnNames = [ + __('Language'), + __('Title'), + __('Text'), + __('Enable'), + __('Actions'), + ]; + + // Load datatables user interface. + ui_print_datatable( + [ + 'id' => 'list_tips_windows', + 'class' => 'info_table', + 'style' => 'width: 100%', + 'columns' => $columns, + 'column_names' => $columnNames, + 'ajax_url' => $this->ajaxController, + 'ajax_data' => ['method' => 'getTips'], + 'no_sortable_columns' => [-1], + 'order' => [ + 'field' => 'title', + 'direction' => 'asc', + ], + 'search_button_class' => 'sub filter float-right', + 'form' => [ + 'inputs' => [ + [ + 'label' => __('Search by title'), + 'type' => 'text', + 'name' => 'filter_title', + 'size' => 12, + ], + ], + ], + ] + ); + echo ''; + } catch (Exception $e) { + echo $e->getMessage(); + } + } + + + /** + * Delete tip and his files. + * + * @param integer $idTip Id from tip. + * + * @return integer Status from sql query. + */ + public function deleteTip($idTip) + { + $files = $this->getFilesFromTip($idTip); + if ($files !== false) { + if (count($files) > 0) { + foreach ($files as $key => $file) { + unlink($file['path'].'/'.$file['filename']); + } + } + } + + return db_process_sql_delete( + 'twelcome_tip', + ['id' => $idTip] + ); + } + + + /** + * Return tips for datatable + * + * @return void + */ + public function getTips() + { + global $config; + + $data = []; + $start = get_parameter('start', 0); + $length = get_parameter('length', $config['block_size']); + $orderDatatable = get_datatable_order(true); + $filters = get_parameter('filter', []); + $pagination = ''; + $filter = ''; + $order = ''; + + try { + ob_start(); + + if (key_exists('filter_title', $filters) === true) { + if (empty($filters['filter_title']) === false) { + $filter = ' WHERE title like "%'.$filters['filter_title'].'%"'; + } + } + + if (isset($orderDatatable)) { + $order = sprintf( + ' ORDER BY %s %s', + $orderDatatable['field'], + $orderDatatable['direction'] + ); + } + + if (isset($length) && $length > 0 + && isset($start) && $start >= 0 + ) { + $pagination = sprintf( + ' LIMIT %d OFFSET %d ', + $length, + $start + ); + } + + $sql = sprintf( + 'SELECT id, name AS language, title, text, url, enable + FROM twelcome_tip t + LEFT JOIN tlanguage l ON t.id_lang = l.id_language + %s %s %s', + $filter, + $order, + $pagination + ); + + $data = db_get_all_rows_sql($sql); + + foreach ($data as $key => $row) { + if ($row['enable'] === '1') { + $data[$key]['enable'] = ''; + } else { + $data[$key]['enable'] = ''; + } + + $data[$key]['title'] = io_safe_output($row['title']); + $data[$key]['text'] = io_safe_output($row['text']); + $data[$key]['url'] = io_safe_output($row['url']); + $data[$key]['actions'] = '
    '; + $data[$key]['actions'] .= ''; + $data[$key]['actions'] .= html_print_image( + 'images/edit.svg', + true, + ['class' => 'main_menu_icon'] + ); + $data[$key]['actions'] .= ''; + $data[$key]['actions'] .= '
    '; + $data[$key]['actions'] .= html_print_input_image( + 'button_delete_tip', + 'images/delete.svg', + '', + '', + true, + [ + 'onclick' => 'if (!confirm(\''.__('Are you sure?').'\')) return false;', + 'class' => 'main_menu_icon', + ] + ); + $data[$key]['actions'] .= html_print_input_hidden('idTip', $row['id'], true); + $data[$key]['actions'] .= ''; + $data[$key]['actions'] .= '
    '; + } + + if (empty($data) === true) { + $total = 0; + $data = []; + } else { + $total = $this->getTotalTips(); + } + + echo json_encode( + [ + 'data' => $data, + 'recordsTotal' => $total, + 'recordsFiltered' => $total, + ] + ); + // Capture output. + $response = ob_get_clean(); + } catch (Exception $e) { + echo json_encode(['error' => $e->getMessage()]); + exit; + } + + json_decode($response); + if (json_last_error() === JSON_ERROR_NONE) { + echo $response; + } else { + echo json_encode( + [ + 'success' => false, + 'error' => $response, + ] + ); + } + + exit; + } + + + /** + * Render view create tips + * + * @param array $errors Array of errors if exists. + * + * @return void + */ + public function viewCreate($errors=null) + { + ui_require_css_file('tips_window'); + ui_require_css_file('jquery.bxslider'); + ui_require_javascript_file('tipsWindow'); + ui_require_javascript_file('jquery.bxslider.min'); + + if ($errors !== null) { + if (count($errors) > 0) { + foreach ($errors as $key => $value) { + ui_print_error_message($value); + } + } else { + ui_print_success_message(__('Tip created')); + } + } + + $profiles = profile_get_profiles(); + + echo ''; + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox filters'; + + $table->style[0] = 'font-weight: bold'; + + $table->data = []; + $table->data[0][0] = __('Images'); + $table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true); + $table->data[0][1] .= html_print_div( + [ + 'id' => 'notices_images', + 'class' => 'invisible', + 'content' => '

    '.__('Wrong size, we recommend images of 464x260 px').'

    ', + ], + true + ); + $table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true); + $table->data[1][0] = __('Language'); + $table->data[1][1] = html_print_select_from_sql( + 'SELECT id_language, name FROM tlanguage', + 'id_lang', + '', + '', + '', + '0', + true + ); + $table->data[2][0] = __('Profile'); + $table->data[2][1] = html_print_select($profiles, 'id_profile', '0', '', __('All'), 0, true); + $table->data[3][0] = __('Title'); + $table->data[3][1] = html_print_input_text('title', '', '', 35, 100, true); + $table->data[4][0] = __('Text'); + $table->data[4][1] = html_print_textarea('text', 5, 50, '', '', true); + $table->data[5][0] = __('Url'); + $table->data[5][1] = html_print_input_text('url', '', '', 35, 100, true); + $table->data[6][0] = __('Enable'); + $table->data[6][1] = html_print_checkbox_switch('enable', true, true, true); + + echo '
    '; + html_print_table($table); + echo '
    '; + html_print_submit_button( + __('Send'), + 'submit_button', + false, + [ + 'class' => 'sub', + 'icon' => 'update', + ] + ); + html_print_submit_button( + __('Preview'), + 'preview_button', + false, + [ + 'class' => 'sub preview', + 'id' => 'prev_button', + 'icon' => 'preview', + ] + ); + echo '
    '; + echo ''; + html_print_div(['id' => 'tips_window_modal_preview']); + } + + + /** + * Render view edit tips + * + * @param integer $idTip Id from tips. + * @param array $errors Array of errors if exists. + * + * @return void + */ + public function viewEdit($idTip, $errors=null) + { + $tip = $this->getTipById($idTip); + if ($tip === false) { + return; + } + + $files = $this->getFilesFromTip($idTip); + + ui_require_css_file('tips_window'); + ui_require_css_file('jquery.bxslider'); + ui_require_javascript_file('tipsWindow'); + ui_require_javascript_file('jquery.bxslider.min'); + + if ($errors !== null) { + if (count($errors) > 0) { + foreach ($errors as $key => $value) { + ui_print_error_message($value); + } + } else { + ui_print_success_message(__('Tip edited')); + } + } + + $outputImagesTip = ''; + if (empty($files) === false) { + foreach ($files as $key => $value) { + $namePath = $value['path'].$value['filename']; + $imageTip = html_print_image($namePath, true); + $imageTip .= html_print_input_image( + 'delete_image_tip', + 'images/delete.svg', + '', + '', + true, + [ + 'onclick' => 'deleteImage(this, \''.$value['id'].'\', \''.$namePath.'\')', + 'class' => 'remove-image', + ] + ); + $outputImagesTip .= html_print_div( + [ + 'class' => 'image_tip', + 'content' => $imageTip, + ], + true + ); + } + } + + $profiles = profile_get_profiles(); + + echo ''; + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox filters'; + + $table->style[0] = 'font-weight: bold'; + + $table->data = []; + $table->data[0][0] = __('Images'); + $table->data[0][1] .= $outputImagesTip; + $table->data[0][1] .= html_print_div(['id' => 'inputs_images'], true); + $table->data[0][1] .= html_print_input_hidden('images_to_delete', '{}', true); + $table->data[0][1] .= html_print_div( + [ + 'id' => 'notices_images', + 'class' => 'invisible', + 'content' => '

    '.__('Wrong size, we recommend images of 464x260 px').'

    ', + ], + true + ); + $table->data[0][1] .= html_print_button(__('Add image'), 'button_add_image', false, '', '', true); + $table->data[1][0] = __('Language'); + $table->data[1][1] = html_print_select_from_sql( + 'SELECT id_language, name FROM tlanguage', + 'id_lang', + $tip['id_lang'], + '', + '', + '0', + true + ); + $table->data[2][0] = __('Profile'); + $table->data[2][1] = html_print_select($profiles, 'id_profile', $tip['id_profile'], '', __('All'), 0, true); + $table->data[3][0] = __('Title'); + $table->data[3][1] = html_print_input_text('title', $tip['title'], '', 35, 100, true); + $table->data[4][0] = __('Text'); + $table->data[4][1] = html_print_textarea('text', 5, 50, $tip['text'], '', true); + $table->data[5][0] = __('Url'); + $table->data[5][1] = html_print_input_text('url', $tip['url'], '', 35, 100, true); + $table->data[6][0] = __('Enable'); + $table->data[6][1] = html_print_checkbox_switch('enable', 1, ($tip['enable'] === '1') ? true : false, true); + + echo '
    '; + html_print_table($table); + echo '
    '; + html_print_submit_button( + __('Send'), + 'submit_button', + false, + [ + 'class' => 'sub', + 'icon' => 'update', + ] + ); + html_print_submit_button( + __('Preview'), + 'preview_button', + false, + [ + 'class' => 'sub preview', + 'id' => 'prev_button', + 'icon' => 'preview', + ] + ); + + echo '
    '; + echo ''; + html_print_div(['id' => 'tips_window_modal_preview']); + } + + + /** + * Udpdate tip + * + * @param integer $id Id from tip. + * @param integer $id_profile Id profile. + * @param string $id_lang Id langugage. + * @param string $title Title from tip. + * @param string $text Text from tip. + * @param string $url Url from tip. + * @param boolean $enable Indicates if the tip is activated. + * @param array $images Images from tip. + * + * @return boolean + */ + public function updateTip($id, $id_profile, $id_lang, $title, $text, $url, $enable, $images=null) + { + db_process_sql_begin(); + + $idTip = db_process_sql_update( + 'twelcome_tip', + [ + 'id_lang' => $id_lang, + 'id_profile' => (empty($id_profile) === false) ? $id_profile : 0, + 'title' => $title, + 'text' => $text, + 'url' => $url, + 'enable' => $enable, + ], + ['id' => $id] + ); + if ($idTip === false) { + db_process_sql_rollback(); + return false; + } + + if ($images !== null) { + foreach ($images as $key => $image) { + $res = db_process_sql_insert( + 'twelcome_tip_file', + [ + 'twelcome_tip_file' => $id, + 'filename' => $image, + 'path' => 'images/tips/', + ] + ); + if ($res === false) { + db_process_sql_rollback(); + return false; + } + } + } + + db_process_sql_commit(); + + return true; + } + + + /** + * Create tip + * + * @param string $id_lang Id langugage. + * @param integer $id_profile Id profile. + * @param string $title Title from tip. + * @param string $text Text from tip. + * @param string $url Url from tip. + * @param boolean $enable Indicates if the tip is activated. + * @param array $images Images from tip. + * + * @return boolean + */ + public function createTip($id_lang, $id_profile, $title, $text, $url, $enable, $images=null) + { + db_process_sql_begin(); + $idTip = db_process_sql_insert( + 'twelcome_tip', + [ + 'id_lang' => $id_lang, + 'id_profile' => (empty($id_profile) === false) ? $id_profile : 0, + 'title' => $title, + 'text' => $text, + 'url' => $url, + 'enable' => $enable, + ] + ); + if ($idTip === false) { + db_process_sql_rollback(); + return false; + } + + if ($images !== null) { + foreach ($images as $key => $image) { + $res = db_process_sql_insert( + 'twelcome_tip_file', + [ + 'twelcome_tip_file' => $idTip, + 'filename' => $image, + 'path' => 'images/tips/', + ] + ); + if ($res === false) { + db_process_sql_rollback(); + return false; + } + } + } + + db_process_sql_commit(); + + return true; + } + + + /** + * Validate images uploads for the user + * + * @param array $files List images for validate. + * + * @return boolean Return boolean or array errors. + */ + public function validateImages($files) + { + $formats = [ + 'image/png', + 'image/jpg', + 'image/jpeg', + 'image/gif', + ]; + $errors = []; + $maxsize = 6097152; + + foreach ($files as $key => $file) { + if ($file['error'] !== 0) { + $errors[] = __('Incorrect file'); + } + + if (in_array($file['type'], $formats) === false) { + $errors[] = __('Format image invalid'); + } + + if ($file['size'] > $maxsize) { + $errors[] = __('Image size too large'); + } + } + + if (count($errors) > 0) { + return $errors; + } else { + return false; + } + } + + + /** + * Upload images passed by user + * + * @param array $files List of files for upload. + * + * @return array List of names files. + */ + public function uploadImages($files) + { + $dir = 'images/tips/'; + $imagesOk = []; + foreach ($files as $key => $file) { + $name = str_replace(' ', '_', $file['name']); + $name = str_replace('.', uniqid().'.', $name); + move_uploaded_file($file['tmp_name'], $dir.'/'.$name); + $imagesOk[] = $name; + } + + return $imagesOk; + } + + +} diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index bf3fbf9b5d..c5af28b54f 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -405,13 +405,13 @@ class Tree $processed_item['rootType'] = $this->rootType; $processed_item['searchChildren'] = 1; - if (isset($item['type'])) { + if (isset($item['type']) === true) { $processed_item['type'] = $item['type']; } else { $processed_item['type'] = $this->type; } - if (isset($item['rootType'])) { + if (isset($item['rootType']) === true) { $processed_item['rootType'] = $item['rootType']; } else { $processed_item['rootType'] = $this->rootType; @@ -420,23 +420,23 @@ class Tree if ($processed_item['type'] == 'group') { $processed_item['parent'] = $item['parent']; - $processed_item['icon'] = empty($item['icon']) ? 'without_group.png' : $item['icon'].'.png'; + $processed_item['icon'] = empty($item['icon']) === true ? 'unknown@groups.svg' : $item['icon']; } - if (isset($item['iconHTML'])) { + if (isset($item['iconHTML']) === true) { $processed_item['icon'] = $item['iconHTML']; } - if (is_metaconsole() && !empty($server)) { + if (is_metaconsole() === true && empty($server) === false) { $processed_item['serverID'] = $server['id']; } $counters = []; - if (isset($item['total_unknown_count'])) { + if (isset($item['total_unknown_count']) === true) { $counters['unknown'] = $item['total_unknown_count']; } - if (isset($item['total_critical_count'])) { + if (isset($item['total_critical_count']) === true) { $counters['critical'] = $item['total_critical_count']; } @@ -677,10 +677,9 @@ class Tree } } - $module['statusImageHTML'] = ui_print_status_image($statusType, htmlspecialchars($statusTitle), true); - - // HTML of the server type image - $module['serverTypeHTML'] = servers_show_type($module['server_type']); + $module['statusImageHTML'] = ui_print_status_image($statusType, htmlspecialchars($statusTitle), true, ['is_tree_view' => true]); + // HTML of the server type image. + $module['serverTypeHTML'] = ui_print_servertype_icon((int) $module['server_type']); // Link to the Module graph. // ACL. @@ -781,10 +780,19 @@ class Tree if ((bool) $module['alerts']) { // Module has alerts triggered. if ($module_alert_triggered === true) { - $module['alertsImageHTML'] = html_print_image('images/bell_orange.png', true, ['title' => __('Module alerts'), 'style' => 'filter: initial']); + $colorAlertButton = COL_ALERTFIRED; } else { - $module['alertsImageHTML'] = html_print_image('images/bell_green.png', true, ['title' => __('Module alerts'), 'style' => 'filter: initial']); + $colorAlertButton = COL_NORMAL; } + + $module['alertsImageHTML'] = html_print_div( + [ + 'title' => __('Module alerts'), + 'class' => 'alert_background_state main_menu_icon module-button', + 'style' => 'background-color: '.$colorAlertButton, + ], + true + ); } } @@ -925,7 +933,7 @@ class Tree // Quiet image if (isset($agent['quiet']) && $agent['quiet']) { - $agent['statusImageHTML'] = ui_print_status_sets('agent_no_monitors_ball.png', __('Quiet'), 1, ['class' => 'status_balls', 'style' => 'background: '.COL_QUIET.';'], '', false); + $agent['statusImageHTML'] = ui_print_status_sets('agent_no_monitors_ball.png', __('Quiet'), 1, ['is_tree_view' => 'yes', 'class' => 'status_balls', 'style' => 'background: '.COL_QUIET.';'], '', false); } // Children diff --git a/pandora_console/include/class/TreeService.class.php b/pandora_console/include/class/TreeService.class.php index e68158c117..bfb1556202 100644 --- a/pandora_console/include/class/TreeService.class.php +++ b/pandora_console/include/class/TreeService.class.php @@ -222,22 +222,30 @@ class TreeService extends Tree switch ($status) { case SERVICE_STATUS_NORMAL: - $processed_items[$row['id']]['statusImageHTML'] = 'NORMAL status.'; + $serviceStatusLine = COL_NORMAL; break; case SERVICE_STATUS_CRITICAL: - $processed_items[$row['id']]['statusImageHTML'] = 'CRITICAL status.'; + $serviceStatusLine = COL_CRITICAL; break; case SERVICE_STATUS_WARNING: - $processed_items[$row['id']]['statusImageHTML'] = 'WARNING status.'; + $serviceStatusLine = COL_WARNING; break; case SERVICE_STATUS_UNKNOWN: default: - $processed_items[$row['id']]['statusImageHTML'] = 'UNKNOWN status.'; + $serviceStatusLine = COL_UNKNOWN; break; } + + $processed_items[$row['id']]['statusImageHTML'] = html_print_div( + [ + 'class' => 'node-service-status', + 'style' => 'background-color: '.$serviceStatusLine, + ], + true + ); } $this->tree = $processed_items; @@ -416,21 +424,21 @@ class TreeService extends Tree switch ($item->agent()->lastStatus()) { case AGENT_STATUS_NORMAL: - $tmp['statusImageHTML'] = 'NORMAL status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #82b92e', 'title' => __('Normal status') ], true); break; case AGENT_STATUS_CRITICAL: case AGENT_STATUS_ALERT_FIRED: - $tmp['statusImageHTML'] = 'CRITICAL status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #e63c52', 'title' => __('Critical status') ], true); break; case AGENT_STATUS_WARNING: - $tmp['statusImageHTML'] = 'WARNING status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #f3b200', 'title' => __('Warning status') ], true); break; case AGENT_STATUS_UNKNOWN: default: - $tmp['statusImageHTML'] = 'UNKNOWN status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #B2B2B2', 'title' => __('Unknown status') ], true); break; } @@ -510,14 +518,11 @@ class TreeService extends Tree $tmp['eventAgent'] = $item->module()->id_agente(); $tmp['disabled'] = $item->module()->disabled(); - $html = 'module()->lastStatusTitle().'" />'; + $tmp['statusImageHTML'] = $html; $tmp = array_merge( $tmp, @@ -629,36 +634,20 @@ class TreeService extends Tree $tmp['rootID'] = $this->rootID; switch ($item->service()->lastStatus()) { case SERVICE_STATUS_NORMAL: - $tmp['statusImageHTML'] = 'NORMAL status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #82b92e', 'title' => __('Normal status') ], true); break; case SERVICE_STATUS_CRITICAL: - $tmp['statusImageHTML'] = 'CRITICAL status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #e63c52', 'title' => __('Critical status') ], true); break; case SERVICE_STATUS_WARNING: - $tmp['statusImageHTML'] = 'WARNING status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #f3b200', 'title' => __('Warning status') ], true); break; case SERVICE_STATUS_UNKNOWN: default: - $tmp['statusImageHTML'] = 'UNKNOWN status.'; + $tmp['statusImageHTML'] = html_print_div(['class' => 'tree-service-status', 'style' => 'background-color: #B2B2B2', 'title' => __('Unknown status') ], true); break; } break; diff --git a/pandora_console/include/class/WelcomeWindow.class.php b/pandora_console/include/class/WelcomeWindow.class.php index 43c68cd533..d1f14c2217 100644 --- a/pandora_console/include/class/WelcomeWindow.class.php +++ b/pandora_console/include/class/WelcomeWindow.class.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2022 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 @@ -392,15 +392,10 @@ class WelcomeWindow extends Wizard 'class' => 'modal', ]; - $logo_url = ''; - if (enterprise_installed()) { - $logo_url = ENTERPRISE_DIR.'/'; - } + $logo_url = 'images/custom_logo/pandora_logo_head_white_bg.png'; - if (empty($config['custom_logo_white_bg']) === false) { - $logo_url .= 'images/custom_logo/'.$config['custom_logo_white_bg']; - } else { - $logo_url .= 'images/custom_logo/pandora_logo_head_white_bg.png'; + if (enterprise_installed() === true) { + $logo_url = ENTERPRISE_DIR.'/'.$logo_url; } $inputs = [ @@ -421,7 +416,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_configure_mail', - 'class' => 'hole flex-row w98p '.$li_configure_mail_class, + 'class' => 'hole flex-row flex-items-center w98p '.$li_configure_mail_class, 'direct' => 1, 'block_content' => [ [ @@ -436,7 +431,10 @@ class WelcomeWindow extends Wizard 'arguments' => [ 'label' => '', 'type' => 'button', - 'attributes' => 'class="go '.$btn_configure_mail_class.' second_background"', + 'attributes' => [ + 'class' => (empty($btn_configure_mail_class) === false) ? $btn_configure_mail_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], 'name' => 'btn_email_conf', 'id' => 'btn_email_conf', ], @@ -455,7 +453,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_create_agent', - 'class' => 'learn_content_indented flex-row w98p '.$li_create_agent_class, + 'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_agent_class, 'direct' => 1, 'block_content' => [ [ @@ -470,7 +468,10 @@ class WelcomeWindow extends Wizard 'arguments' => [ 'label' => '', 'type' => 'button', - 'attributes' => 'class="go '.$btn_create_agent_class.' second_background"', + 'attributes' => [ + 'class' => (empty($btn_create_agent_class) === false) ? $btn_create_agent_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], 'name' => 'btn_create_agent', 'id' => 'btn_create_agent', ], @@ -480,7 +481,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_monitor_actions', - 'class' => 'learn_content_indented flex-row w98p '.$li_create_module_class, + 'class' => 'learn_content_indented flex-row flex-items-center w98p '.$li_create_module_class, 'direct' => 1, 'block_content' => [ [ @@ -495,7 +496,10 @@ class WelcomeWindow extends Wizard 'arguments' => [ 'label' => '', 'type' => 'button', - 'attributes' => 'class="go '.$btn_create_module_class.' second_background"', + 'attributes' => [ + 'class' => (empty($btn_create_module_class) === false) ? $btn_create_module_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], 'name' => 'btn_create_module', 'id' => 'btn_create_module', ], @@ -505,7 +509,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_monitor_actions', - 'class' => 'hole learn_content_indented flex-row w98p '.$li_create_alert_class, + 'class' => 'hole learn_content_indented flex-row flex-items-center w98p '.$li_create_alert_class, 'direct' => 1, 'block_content' => [ [ @@ -520,7 +524,10 @@ class WelcomeWindow extends Wizard 'arguments' => [ 'label' => '', 'type' => 'button', - 'attributes' => 'class="go '.$btn_create_alert_class.' second_background"', + 'attributes' => [ + 'class' => (empty($btn_create_alert_class) === false) ? $btn_create_alert_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], 'name' => 'btn_create_alert', 'id' => 'btn_create_alert', ], @@ -530,7 +537,7 @@ class WelcomeWindow extends Wizard [ 'wrapper' => 'div', 'block_id' => 'div_discover', - 'class' => 'hole flex-row w98p '.$li_create_discovery_class, + 'class' => 'hole flex-row flex-items-center w98p '.$li_create_discovery_class, 'direct' => 1, 'block_content' => [ [ @@ -545,7 +552,10 @@ class WelcomeWindow extends Wizard 'arguments' => [ 'label' => '', 'type' => 'button', - 'attributes' => 'class="go '.$btn_create_discovery_class.' second_background"', + 'attributes' => [ + 'class' => (empty($btn_create_discovery_class) === false) ? $btn_create_discovery_class : 'invisible_important', + 'mode' => 'onlyIcon', + ], 'name' => 'btn_discover_devices', 'id' => 'btn_discover_devices', ], @@ -554,11 +564,11 @@ class WelcomeWindow extends Wizard ], ]; - if (enterprise_installed()) { + if (enterprise_installed() === true) { $inputs[] = [ 'wrapper' => 'div', 'block_id' => 'div_not_working', - 'class' => 'hole flex-row w98p', + 'class' => 'hole flex-row flex-items-center w98p', 'direct' => 1, 'block_content' => [ [ @@ -773,7 +783,7 @@ class WelcomeWindow extends Wizard // Create Discovery task is pending. // Host&Devices finishses on page 2. if ($sec2 === 'godmode/servers/discovery' - && get_parameter('page', 0) == 2 + && (int) get_parameter('page') === 2 ) { // Discovery task have been created. $this->step = W_CREATE_TASK; @@ -882,8 +892,8 @@ class WelcomeWindow extends Wizard window.location = 'getWelcomeAgent().''); ?>'; } - function monitorRemoteCommands() { - window.location = ''; + function monitorRemoteCommands() { + window.location = ''; } function discoverDevicesNetwork() { @@ -896,7 +906,7 @@ class WelcomeWindow extends Wizard function cierre_dialog(){ this.dialog("close"); } - + $type_graph_pdf, 'data_module_list' => $module_list, 'data_combined' => $params_combined, + 'id_user' => $config['id_user'], ]; } else { $data = [ 'data' => $params, 'session_id' => $session_id, 'type_graph_pdf' => $type_graph_pdf, + 'id_user' => $config['id_user'], ]; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index bd33e1ddf8..0bca01f557 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3050,7 +3050,10 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, STATUS_AGENT_NO_MONITORS_BALL, __('No Monitors'), true, - false, + [ + 'is_tree_view', + true, + ], false, // Use CSS shape instead of image. true @@ -3062,7 +3065,10 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, STATUS_ALERT_FIRED_BALL, __('Alert fired on agent'), true, - false, + [ + 'is_tree_view', + true, + ], false, // Use CSS shape instead of image. true @@ -3074,7 +3080,10 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, STATUS_AGENT_CRITICAL_BALL, __('At least one module in CRITICAL status'), true, - false, + [ + 'is_tree_view', + true, + ], false, // Use CSS shape instead of image. true @@ -3084,7 +3093,10 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, STATUS_AGENT_WARNING_BALL, __('At least one module in WARNING status'), true, - false, + [ + 'is_tree_view', + true, + ], false, // Use CSS shape instead of image. true @@ -3094,7 +3106,10 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, STATUS_AGENT_DOWN_BALL, __('At least one module is in UKNOWN status'), true, - false, + [ + 'is_tree_view', + true, + ], false, // Use CSS shape instead of image. true @@ -3104,7 +3119,10 @@ function agents_tree_view_status_img_ball($critical, $warning, $unknown, $total, STATUS_AGENT_OK_BALL, __('All Monitors OK'), true, - false, + [ + 'is_tree_view', + true, + ], false, // Use CSS shape instead of image. true @@ -4378,6 +4396,14 @@ function agents_get_starmap(int $id_agent, float $width=0, float $height=0) $total_modules = count($all_modules); + if ($width !== 0 && $height !== 0) { + $measuresProvided = false; + $width = 200; + $height = 50; + } else { + $measuresProvided = true; + } + // Best square. $high = (float) max($width, $height); $low = 0.0; @@ -4394,6 +4420,7 @@ function agents_get_starmap(int $id_agent, float $width=0, float $height=0) $square_length = min(($width / floor($width / $low)), ($height / floor($height / $low))); + // $measureSymbol = ($measuresProvided === true) ? '' : '%'; // Print starmap. $html = sprintf( '', @@ -4444,6 +4471,7 @@ function agents_get_starmap(int $id_agent, float $width=0, float $height=0) $y, $row, $column, + // $square_length.$measureSymbol, $square_length, $square_length, $status, @@ -4502,3 +4530,17 @@ function agents_get_starmap(int $id_agent, float $width=0, float $height=0) return $html; } + + +/** + * Defines a hash for agent name. + * + * @param string $alias Alias. + * @param string $nombre_agente Agent name. + * + * @return string. + */ +function hash_agent_name(string $alias, string $nombre_agente) +{ + return hash('sha256', $alias.'|'.$nombre_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000))); +} \ No newline at end of file diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 7b6e133f22..24d2de537d 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -947,6 +947,10 @@ function config_update_config() $error_update[] = __('Date format string'); } + if (config_update_value('notification_autoclose_time', (string) get_parameter('notification_autoclose_time'), true) === false) { + $error_update[] = __('Notification Autoclose time'); + } + if (config_update_value('prominent_time', (string) get_parameter('prominent_time'), true) === false) { $error_update[] = __('Timestamp or time comparation'); } @@ -1120,6 +1124,14 @@ function config_update_config() $error_update[] = __('Copyright notice'); } + if (config_update_value('background_opacity', (string) get_parameter('background_opacity'), true) === false) { + $error_update[] = __('Background opacity % (login)'); + } + + if (config_update_value('meta_background_opacity', (string) get_parameter('meta_background_opacity'), true) === false) { + $error_update[] = __('Background opacity % (login)'); + } + if (config_update_value('meta_custom_logo_white_bg', (string) get_parameter('meta_custom_logo_white_bg'), true) === false) { $error_update[] = __('Custom logo metaconsole (white background)'); } @@ -1225,7 +1237,15 @@ function config_update_config() } if (config_update_value('visual_animation', get_parameter('visual_animation'), true) === false) { - $error_update[] = __('visual_animation'); + $error_update[] = __('Visual animation'); + } + + if (config_update_value('random_background', get_parameter('random_background'), true) === false) { + $error_update[] = __('Random background'); + } + + if (config_update_value('meta_random_background', get_parameter('meta_random_background'), true) === false) { + $error_update[] = __('Random background'); } if (config_update_value('disable_help', get_parameter('disable_help'), true) === false) { @@ -2541,7 +2561,7 @@ function config_process_config() } if (!isset($config['custom_splash_login'])) { - config_update_value('custom_splash_login', 'splash_image_default.png'); + config_update_value('custom_splash_login', 'default'); } if (!isset($config['custom_docs_logo'])) { @@ -2600,6 +2620,14 @@ function config_process_config() config_update_value('rb_copyright_notice', get_copyright_notice()); } + if (!isset($config['background_opacity'])) { + config_update_value('background_opacity', 30); + } + + if (!isset($config['meta_background_opacity'])) { + config_update_value('meta_background_opacity', 30); + } + if (!isset($config['meta_custom_docs_url'])) { config_update_value('meta_custom_docs_url', 'https://pandorafms.com/manual/'); } @@ -2617,7 +2645,7 @@ function config_process_config() } if (!isset($config['meta_custom_splash_login'])) { - config_update_value('meta_custom_splash_login', 'splash_image_metaconsola.png'); + config_update_value('meta_custom_splash_login', 'default'); } if (!isset($config['meta_custom_title1_login'])) { @@ -3453,6 +3481,14 @@ function config_process_config() config_update_value('visual_animation', 1); } + if (!isset($config['random_background'])) { + config_update_value('random_background', ''); + } + + if (!isset($config['meta_random_background'])) { + config_update_value('meta_random_background', ''); + } + if (!isset($config['networkmap_max_width'])) { config_update_value('networkmap_max_width', 900); } @@ -3575,6 +3611,10 @@ function config_process_config() config_update_value('decimal_separator', '.'); } + if (isset($config['notification_autoclose_time']) === false) { + config_update_value('notification_autoclose_time', 5); + } + // Finally, check if any value was overwritten in a form. config_update_config(); } diff --git a/pandora_console/include/functions_container.php b/pandora_console/include/functions_container.php index 502db2b4ad..9137a7fa3a 100644 --- a/pandora_console/include/functions_container.php +++ b/pandora_console/include/functions_container.php @@ -180,7 +180,7 @@ function folder_table($graphs) if (($report_w || $report_m) && users_can_manage_group_all($access)) { $data[4] = ''.html_print_image( - 'images/config.png', + 'images/edit.svg', true, ['class' => 'invert_filter'] ).''; @@ -188,7 +188,7 @@ function folder_table($graphs) $data[4] .= ' '; $data[4] .= ''.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter']).''.html_print_checkbox_extended('delete_multiple[]', $graph['id_graph'], false, false, '', 'class="check_delete mrgn_lft_2px"', true); + return false;">'.html_print_image('images/delete.svg', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter']).''.html_print_checkbox_extended('delete_multiple[]', $graph['id_graph'], false, false, '', 'class="check_delete mrgn_lft_2px"', true); } array_push($table->data, $data); @@ -316,13 +316,13 @@ function ui_toggle_container($code, $name, $title='', $hidden_default=true, $ret $data[0] = ''.html_print_image($original, true, ['title' => $title, 'id' => 'image_'.$uniqid, 'class' => 'invert_filter']).'  '.$name.''; $data[1] = ui_print_group_icon($group, true); if ($report_r && $report_w) { - $data[2] = ''.html_print_image('images/config.png', true, ['class' => 'invert_filter']).''; + $data[2] = ''.html_print_image('images/edit.svg', true, ['class' => 'invert_filter main_menu_icon']).''; } if ($report_r && $report_w && $report_m) { if ($id_container !== '1') { $data[2] .= '    '.''.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter']).''; + return false;">'.html_print_image('images/delete.svg', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'class' => 'invert_filter main_menu_icon']).''; } } diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index 62333f00b8..462c5459b4 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -532,11 +532,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -570,11 +570,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -625,11 +625,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -717,11 +717,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -753,11 +753,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -799,11 +799,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -841,11 +841,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -875,11 +875,11 @@ function cron_list_table() $task['id'] ), 'content' => html_print_image( - 'images/target.png', + 'images/change-active.svg', true, [ 'title' => __('Force run'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], @@ -915,11 +915,11 @@ function cron_list_table() $data[7] = ''; $data[7] .= html_print_image( - 'images/config.png', + 'images/edit.svg', true, [ 'title' => __('Edit'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $data[7] .= ''; @@ -929,11 +929,11 @@ function cron_list_table() $data[7] .= ''; $data[7] .= html_print_image( - 'images/cross.png', + 'images/delete.svg', true, [ 'title' => __('Delete'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $data[7] .= ''; @@ -943,11 +943,11 @@ function cron_list_table() $data[7] = ''; $data[7] .= html_print_image( - 'images/config.png', + 'images/edit.svg', true, [ 'title' => __('Edit'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $data[7] .= ''; @@ -957,11 +957,11 @@ function cron_list_table() $data[7] .= ''; $data[7] .= html_print_image( - 'images/cross.png', + 'images/delete.svg', true, [ 'title' => __('Delete'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $data[7] .= ''; @@ -982,7 +982,7 @@ function cron_list_table() true, [ 'title' => ((bool) $task['enabled'] === true) ? __('Disable task') : __('Enable task'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), ], diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index c41c909c27..1c6740efff 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2470,13 +2470,9 @@ function events_print_event_table( ui_require_css_file('events'); - if ($agent_id == 0) { - $agent_condition = ''; - } else { - $agent_condition = ' id_agente = '.$agent_id.' AND '; - } + $agent_condition = ($agent_id === 0) ? '' : ' id_agente = '.$agent_id.' AND '; - if ($filter == '') { + if (empty($filter) === true) { $filter = '1 = 1'; } @@ -2496,7 +2492,7 @@ function events_print_event_table( $result = db_get_all_rows_sql($sql); if ($result === false) { - if ($return) { + if ($return === true) { $returned = ui_print_info_message(__('No events'), '', true); return $returned; } else { @@ -2508,8 +2504,8 @@ function events_print_event_table( $table->cellpadding = 0; $table->cellspacing = 0; $table->width = $width; - $table->class = 'info_table no-td-padding'; - if (!$tactical_view) { + $table->class = 'tactical_table info_table no-td-padding'; + if ($tactical_view === false) { $table->title = __('Latest events'); } @@ -2524,31 +2520,28 @@ function events_print_event_table( $table->style = []; $i = 0; - $table->head[$i] = "".__('S.').''; - $table->headstyle[$i] = 'width: 1%;text-align: center;'; - $table->style[$i++] = 'text-align: center;'; - $table->head[$i] = __('Type'); + $table->head[$i] = ''.__('Type').''; $table->headstyle[$i] = 'width: 3%;text-align: center;'; $table->style[$i++] = 'text-align: center;'; - $table->head[$i] = __('Event name'); + $table->head[$i] = ''.__('Event name').''; $table->headstyle[$i] = ''; - $table->style[$i++] = 'word-break: break-word;'; + $table->style[$i++] = 'padding: 0 5px;word-break: break-word'; - if ($agent_id == 0) { - $table->head[$i] = __('Agent name'); + if ($agent_id === 0) { + $table->head[$i] = ''.__('Agent name').''; $table->headstyle[$i] = ''; $table->style[$i++] = 'word-break: break-all;'; } - $table->head[$i] = __('Timestamp'); + $table->head[$i] = ''.__('Timestamp').''; $table->headstyle[$i] = 'width: 150px;'; - $table->style[$i++] = 'word-break: break-word;'; + $table->style[$i++] = 'padding: 0 5px;word-break: break-word;'; - $table->head[$i] = __('Status'); + $table->head[$i] = ''.__('Status').''; $table->headstyle[$i] = 'width: 150px;text-align: center;'; - $table->style[$i++] = 'text-align: center;'; + $table->style[$i++] = 'padding: 0 5px;text-align: center;'; $table->head[$i] = "".__('V.').''; $table->headstyle[$i] = 'width: 1%;text-align: center;'; @@ -2563,7 +2556,7 @@ function events_print_event_table( // Copy all groups of the agent and append the event group. $check_events = $all_groups; $check_events[] = $event['id_grupo']; - if (! check_acl_one_of_groups($config['id_user'], $check_events, 'ER')) { + if ((bool) check_acl_one_of_groups($config['id_user'], $check_events, 'ER') === false) { continue; } @@ -2571,30 +2564,24 @@ function events_print_event_table( // Colored box. switch ($event['estado']) { - case 0: - $img = 'images/star.png'; + case EVENT_STATUS_NEW: + default: + $img = 'images/star@svg.svg'; $title = __('New event'); break; - case 1: - $img = 'images/tick.png'; + case EVENT_STATUS_VALIDATED: + $img = 'images/validate.svg'; $title = __('Event validated'); break; - case 2: - $img = 'images/hourglass.png'; + case EVENT_STATUS_INPROCESS: + $img = 'images/clock.svg'; $title = __('Event in process'); break; - - default: - // Ignore. - break; } $i = 0; - // Criticity. - $data[$i++] = ui_print_event_priority($event['criticity'], true, true); - // Event type. $data[$i++] = events_print_type_img($event['event_type'], true); @@ -2603,14 +2590,19 @@ function events_print_event_table( strip_tags(io_safe_output($event['evento'])), 75, true, - '7.5' ); - if ($agent_id == 0) { + if ($agent_id === 0) { if ($event['id_agente'] > 0) { // Agent name. // Get class name, for the link color, etc. - $data[$i] = "".agents_get_alias($event['id_agente']).''; + $data[$i] = html_print_anchor( + [ + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$event['id_agente'], + 'content' => agents_get_alias($event['id_agente']), + ], + true + ); // For System or SNMP generated alerts. } else if ($event['event_type'] === 'system') { $data[$i] = __('System'); @@ -2622,10 +2614,10 @@ function events_print_event_table( } // Timestamp. - $data[$i++] = ui_print_timestamp($event['timestamp'], true, ['style' => 'font-size: 7.5pt; letter-spacing: 0.3pt;']); + $data[$i++] = ui_print_timestamp($event['timestamp'], true, ['style' => 'letter-spacing: 0.3pt;']); // Status. - $data[$i++] = ui_print_event_type($event['event_type'], true); + $data[$i++] = ui_print_event_type($event['event_type'], true, true); $data[$i++] = html_print_image( $img, @@ -2643,7 +2635,7 @@ function events_print_event_table( unset($table); - if ($return) { + if ($return === true) { return $out; } else { echo $out; @@ -2671,84 +2663,85 @@ function events_print_type_img( $output = ''; $urlImage = ui_get_full_url(false); - - $style = ''; + $icon = ''; + $style = 'invert_filter main_menu_icon'; switch ($type) { case 'alert_recovered': - $icon = 'images/bell.png'; - $style = 'invert_filter'; + $icon = 'images/alert@svg.svg'; break; case 'alert_manual_validation': - $icon = 'images/ok.png'; - $style = 'invert_filter'; + $icon = 'images/validate.svg'; break; case 'going_down_critical': case 'going_up_critical': // This is to be backwards compatible. - $icon = 'images/module_critical.png'; + $style .= ' event_module_background_state icon_background_critical'; break; case 'going_up_normal': case 'going_down_normal': // This is to be backwards compatible. - $icon = 'images/module_ok.png'; + $style .= ' event_module_background_state icon_background_normal'; break; case 'going_up_warning': case 'going_down_warning': - $icon = 'images/module_warning.png'; + $style .= ' event_module_background_state icon_background_warning'; break; case 'going_unknown': - $icon = 'images/module_unknown.png'; + $style .= ' event_module_background_state icon_background_unknown'; break; case 'alert_fired': $icon = 'images/bell_error.png'; - $style = 'invert_filter'; break; case 'system': - $icon = 'images/cog.png'; - $style = 'invert_filter'; + $icon = 'images/configuration@svg.svg'; break; case 'recon_host_detected': $icon = 'images/recon.png'; - $style = 'invert_filter'; break; case 'new_agent': - $icon = 'images/agent.png'; - $style = 'invert_filter'; + $icon = 'images/agents@svg.svg'; break; case 'configuration_change': - $icon = 'images/config.png'; - $style = 'invert_filter'; + $icon = 'images/configuration@svg.svg'; break; case 'unknown': default: - $icon = 'images/lightning_go.png'; - $style = 'invert_filter'; + $icon = 'images/event.svg'; break; } if ($only_url) { $output = $urlImage.'/'.$icon; } else { - $output .= html_print_image( + $output .= html_print_div( + [ + 'title' => events_print_type_description($type, true), + 'class' => $style, + 'style' => 'margin: 0 auto;'.((empty($icon) === false) ? 'background-image: url('.$icon.'); background-repeat: no-repeat;' : ''), + ], + true + ); + /* + $output .= html_print_image( $icon, true, [ 'title' => events_print_type_description($type, true), 'class' => $style, ] - ); + );*/ } if ($return) { @@ -3379,7 +3372,10 @@ function events_page_responses($event) 'owner_button', false, 'event_change_owner('.$event['id_evento'].', '.$event['server_id'].');', - 'class="sub next w70p"', + [ + 'icon' => 'next', + 'mode' => 'link', + ], true ); @@ -3457,8 +3453,11 @@ function events_page_responses($event) __('Update'), 'status_button', false, - 'event_change_status(\''.$event['similar_ids'].'\','.$event['server_id'].');', - 'class="sub next w70p"', + 'event_change_status("'.$event['similar_ids'].'",'.$event['server_id'].');', + [ + 'icon' => 'next', + 'mode' => 'link', + ], true ); } @@ -3485,8 +3484,11 @@ function events_page_responses($event) __('Add comment'), 'comment_button', false, - '$(\'#link_comments\').trigger(\'click\');', - 'class="sub next w70p"', + '$("#link_comments").trigger("click");', + [ + 'icon' => 'next', + 'mode' => 'link', + ], true ); @@ -3509,8 +3511,11 @@ function events_page_responses($event) __('Delete event'), 'delete_button', false, - 'if(!confirm(\''.__('Are you sure?').'\')) { return false; } this.form.submit();', - 'class="sub cancel w70p"', + 'if(!confirm("'.__('Are you sure?').'")) { return false; } this.form.submit();', + [ + 'icon' => 'cancel', + 'mode' => 'link', + ], true ); $data[2] .= html_print_input_hidden('delete', 1, true); @@ -3565,7 +3570,7 @@ function events_page_responses($event) 'custom_response_button', false, 'execute_response('.$event['id_evento'].','.$server_id.',0)', - "class='sub next w70p'", + ['mode' => 'link'], true ); } @@ -4184,7 +4189,7 @@ function events_page_details($event, $server_id=0) $agent = []; } - $data[0] = __('Agent details'); + $data[0] = ''.__('Agent details').''; $data[1] = empty($agent) ? ''.__('N/A').'' : ''; $table_details->data[] = $data; @@ -4229,11 +4234,14 @@ function events_page_details($event, $server_id=0) $data = []; $data[0] = '
    '.__('OS').'
    '; - $data[1] = ui_print_os_icon($agent['id_os'], true, true); + $data[1] = '
    '; + $data[1] .= get_os_name($agent['id_os']); if (empty($agent['os_version']) === false) { $data[1] .= ' ('.$agent['os_version'].')'; } + $data[1] .= '
    '; + $table_details->data[] = $data; $data = []; @@ -4252,8 +4260,8 @@ function events_page_details($event, $server_id=0) __('View custom fields'), 'custom_button', false, - '$(\'#link_custom_fields\').trigger(\'click\');', - 'class="sub next"', + '$("#link_custom_fields").trigger("click");', + [ 'mode' => 'link' ], true ); $table_details->data[] = $data; @@ -4272,8 +4280,8 @@ function events_page_details($event, $server_id=0) } $data = []; - $data[0] = __('Module details'); - $data[1] = empty($module) ? ''.__('N/A').'' : ''; + $data[0] = ''.__('Module details').''; + $data[1] = (empty($module) === true) ? ''.__('N/A').'' : ''; $table_details->data[] = $data; if (empty($module) === false) { @@ -4349,10 +4357,7 @@ function events_page_details($event, $server_id=0) $graph_params_str = http_build_query($graph_params); $link = "winopeng_var('".$url.'?'.$graph_params_str."','".$win_handle."', 800, 480)"; - - $data[1] = ''; - $data[1] .= html_print_image('images/chart_curve.png', true, ['class' => 'invert_filter']); - $data[1] .= ''; + $data[1] = html_print_button(__('View graph'), 'view_graph_button', false, $link, ['mode' => 'link'], true); $table_details->data[] = $data; } } @@ -4369,7 +4374,7 @@ function events_page_details($event, $server_id=0) $standby = db_get_value('standby', 'talert_template_modules', 'id', $event['id_alert_am']); if (!$standby) { $data[1] .= html_print_image( - 'images/bell.png', + 'images/alert@svg.svg', true, [ 'title' => __('Go to data overview'), @@ -4378,11 +4383,12 @@ function events_page_details($event, $server_id=0) ); } else { $data[1] .= html_print_image( - 'images/bell_pause.png', + 'images/alert@svg.svg', true, [ 'title' => __('Go to data overview'), 'class' => 'invert_filter', + 'style' => 'opacity: .5', ] ); } @@ -4550,19 +4556,19 @@ function events_display_status($status) switch ($status) { case 0: return [ - 'img' => 'images/star.png', + 'img' => 'images/star@svg.svg', 'title' => __('New event'), ]; case 1: return [ - 'img' => 'images/tick.png', + 'img' => 'images/validate.svg', 'title' => __('Event validated'), ]; case 2: return [ - 'img' => 'images/hourglass.png', + 'img' => 'images/clock.svg', 'title' => __('Event in process'), ]; @@ -4808,7 +4814,7 @@ function events_page_general($event) $table_general->cellclass[count($table_general->data)][1] = 'general_status'; $data[0] = __('Status'); $data[1] = $event_st['title']; - $data[2] = html_print_image($event_st['img'], true); + $data[2] = html_print_image($event_st['img'], true, [ 'class' => 'invert_filter main_menu_icon']); $table_general->data[] = $data; // If event is validated, show who and when acknowleded it. @@ -5166,8 +5172,11 @@ function events_page_comments($event, $ajax=false, $groupedComments=[]) __('Add comment'), 'comment_button', false, - 'event_comment(\''.base64_encode(json_encode($event)).'\');', - 'class="sub next"', + 'event_comment("'.base64_encode(json_encode($event)).'");', + [ + 'icon' => 'next', + 'mode' => 'mini secondary', + ], true ); $comments_form .= '
    '; @@ -5770,8 +5779,11 @@ function get_row_response_action( __('Execute again'), 'btn_str', false, - 'perform_response(\''.base64_encode(json_encode($event_response)).'\','.$response_id.',\''.trim($index).'\')', - "class='sub next'", + 'perform_response("'.base64_encode(json_encode($event_response)).'",'.$response_id.',"'.trim($index).'")', + [ + 'icon' => 'next', + 'mode' => 'mini secondary', + ], true ); $output .= ''; diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index 4fc6dd0b14..0012804398 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -542,7 +542,7 @@ function filemanager_file_explorer( break; case 'create_text_file': - title_action = ""; + title_action = ""; break; case 'upload_file': @@ -744,15 +744,14 @@ function filemanager_file_explorer( // Actions buttons // Delete button. - $data[4] = ''; - $data[4] .= ''; + $data[4] = '
    '; $typefile = array_pop(explode('.', $fileinfo['name'])); if (is_writable($fileinfo['realpath']) === true && (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3) && ($readOnly === false) ) { $data[4] .= '
    '; - $data[4] .= ''; + $data[4] .= ''; $data[4] .= html_print_input_hidden('filename', $fileinfo['realpath'], true); $data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'].$config['server_unique_identifier']), true); $data[4] .= html_print_input_hidden('delete_file', 1, true); @@ -774,7 +773,7 @@ function filemanager_file_explorer( && ($typefile !== 'iso') && ($typefile !== 'docx') && ($typefile !== 'doc') && ($fileinfo['mime'] != MIME_DIR) ) { $hash = md5($fileinfo['realpath'].$config['server_unique_identifier']); - $data[4] .= "".html_print_image('images/edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file'), 'class' => 'invert_filter']).''; + $data[4] .= "".html_print_image('images/edit.svg', true, ['style' => 'margin-top: 2px;', 'title' => __('Edit file'), 'class' => 'main_menu_icon invert_filter']).''; } } } @@ -791,10 +790,10 @@ function filemanager_file_explorer( && (is_dir($fileinfo['realpath']) === false || count(scandir($fileinfo['realpath'])) < 3) && ($readOnly === false) ) { - $data[4] .= ''.html_print_image('images/book_edit.png', true, ['style' => 'margin-top: 2px;', 'title' => __('Real path'), 'class' => 'invert_filter']).''; + $data[4] .= ''.html_print_image('images/enable.svg', true, ['style' => 'margin-top: 2px;', 'title' => __('Real path'), 'class' => 'invert_filter main_menu_icon']).''; } - $data[4] .= ''; + $data[4] .= '
    '; array_push($table->data, $data); } @@ -830,10 +829,10 @@ function filemanager_file_explorer( 'images/create_file.png', true, [ - 'title' => __('Create a Text'), + 'title' => __('Create File'), 'class' => 'invert_filter', ] - ).''.__('Create a Text').' + ).''.__('Create File').' '; } @@ -857,7 +856,7 @@ function filemanager_file_explorer( $createFolderElements = $tabs_dialog; $createFolderElements .= sprintf('', $url); $createFolderElements .= html_print_input_text('dirname', '', '', 30, 255, true); - $createFolderElements .= html_print_submit_button(__('Create'), 'crt', false, 'class="sub next"', true); + $createFolderElements .= html_print_submit_button(__('Create'), 'crt', false, [ 'class' => 'submitButton', 'style' => 'float:right', 'icon' => 'next'], true); $createFolderElements .= html_print_input_hidden('directory', $relative_directory, true); $createFolderElements .= html_print_input_hidden('create_dir', 1, true); $createFolderElements .= html_print_input_hidden('hash', md5($relative_directory.$config['server_unique_identifier']), true); @@ -897,7 +896,7 @@ function filemanager_file_explorer( $uploadFileElements .= html_print_input_hidden('upload_file', 1, true); } - $uploadFileElements .= html_print_submit_button(__('Go'), 'go', false, 'class="sub next"', true); + $uploadFileElements .= html_print_submit_button(__('Go'), 'go', false, [ 'class' => 'submitButton', 'style' => 'float:right', 'icon' => 'next'], true); $uploadFileElements .= html_print_input_hidden('real_directory', $real_directory, true); $uploadFileElements .= html_print_input_hidden('directory', $relative_directory, true); $uploadFileElements .= html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true); @@ -918,7 +917,7 @@ function filemanager_file_explorer( $createTextElements = $tabs_dialog; $createTextElements .= ''; $createTextElements .= html_print_input_text('name_file', '', '', 30, 50, true); - $createTextElements .= html_print_submit_button(__('Create'), 'create', false, 'class="sub next"', true); + $createTextElements .= html_print_submit_button(__('Create'), 'create', false, [ 'class' => 'submitButton', 'style' => 'float:right', 'icon' => 'next'], true); $createTextElements .= html_print_input_hidden('real_directory', $real_directory, true); $createTextElements .= html_print_input_hidden('directory', $relative_directory, true); $createTextElements .= html_print_input_hidden('hash', md5($real_directory.$relative_directory.$config['server_unique_identifier']), true); @@ -937,47 +936,53 @@ function filemanager_file_explorer( echo "
    "; - echo ""; - echo html_print_image( - 'images/create_directory.png', - true, + $buttons[] = html_print_button( + __('Create directory'), + 'create_directory', + false, + 'show_form_create_folder()', [ - 'title' => __('Create directory'), - 'class' => 'invert_filter', - ] + 'class' => 'margin-right-2 invert_filter secondary', + 'icon' => 'create_directory', + ], + true, + false ); - echo ''; if ($allowCreateText === true) { - echo ""; - echo html_print_image( - 'images/create_file.png', - true, + $buttons[] = html_print_button( + __('Create file'), + 'create_text', + false, + 'show_create_text_file()', [ - 'title' => __('Create text'), - 'class' => 'invert_filter', - ] + 'class' => 'margin-right-2 invert_filter secondary', + 'icon' => 'create_file', + ], + true, + false ); - echo ''; } - echo ""; - echo html_print_image( - 'images/upload_file.png', - true, + $buttons[] = html_print_button( + __('Upload file/s'), + 'upload_file', + false, + 'show_upload_file()', [ - 'title' => __('Upload file/s'), - 'class' => 'invert_filter', - ] + 'class' => 'margin-right-2 invert_filter secondary', + 'icon' => 'upload_file', + ], + true, + false ); - echo ''; // Show Modal Real Path $modal_real_path = "
    Real path to plugin execution is:
    "; if (isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'on' || $_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '127.0.0.1') { - $modal_real_path .= "
    ".html_print_submit_button(__('Copy'), 'submit', false, 'class="sub next"', true).'
    '; + $modal_real_path .= "
    ".html_print_submit_button(__('Copy'), 'submit', false, ['icon' => 'wand', 'mode' => 'mini'], true).'
    '; } html_print_div( @@ -991,12 +996,17 @@ function filemanager_file_explorer( echo '
    '; } else { echo "
    "; - echo "".__('The directory is read-only'); + echo "".__('The directory is read-only'); echo '
    '; } } html_print_table($table); + + html_print_action_buttons( + implode('', $buttons), + ['type' => 'form_action'] + ); } diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 4dedff553a..48d42d43c5 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -1585,7 +1585,7 @@ function gis_add_conection_maps_in_form($map_connection_list)
    - + + '; + $html .= ''; + + return $html; +} + + +/** + * Return html count from agents and monitoring by group. + * + * @param [type] $id_groups + * + * @return string Html + */ +function tactical_groups_get_agents_and_monitoring($id_groups) +{ + global $config; + + $data = [ + 'total_agents' => groups_agents_total_counters($id_groups, false)['total'], + 'monitor_total' => groups_get_total_monitors($id_groups, [], [], false, false, false, false), + ]; + + // Link URLS + $urls = []; + $urls['total_agents'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id='.$id_groups[0].'&recursion=1'; + $urls['monitor_total'] = $config['homeurl'].'index.php?sec=view&sec2=operation/agentes/status_monitor&refr=60&status=-1&ag_group='.$id_groups[0].'&recursion=1'; + + $table_am = html_get_predefined_table(); + $tdata = []; + $tdata[0] = html_print_image('images/agent.png', true, ['title' => __('Total agents'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[1] = $data['total_agents'] <= 0 ? '-' : $data['total_agents']; + $tdata[1] = ''.$tdata[1].''; + + if ($data['total_agents'] > 500 && !enterprise_installed()) { + $tdata[2] = "
    "; + } + + $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Monitor checks'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[4] = $data['monitor_total'] <= 0 ? '-' : $data['monitor_total']; + $tdata[4] = ''.$tdata[4].''; + + /* + Hello there! :) + We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger’ of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :( + You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years. + */ + if ($data['total_agents']) { + if (($data['monitor_total'] / $data['total_agents'] > 100) && !enterprise_installed()) { + $tdata[5] = "
    "; + } + } + + $table_am->rowclass[] = ''; + $table_am->data[] = $tdata; + + $output = '
    + '.__('Total agents and monitors').''.html_print_table($table_am, true).'
    '; + + return $output; +} + + +/** + * Return html count from stats alerts by group. + * + * @param [type] $id_groups + * @return string Html. + */ +function tactical_groups_get_stats_alerts($id_groups) +{ + global $config; + + $alerts = groups_monitor_alerts_total_counters($id_groups, false); + $data = [ + 'monitor_alerts' => $alerts['total'], + 'monitor_alerts_fired' => $alerts['fired'], + + ]; + + $urls = []; + $urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&ag_group='.$id_groups[0]; + $urls['monitor_alerts_fired'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&disabled=fired&ag_group='.$id_groups[0]; + + // Alerts table. + $table_al = html_get_predefined_table(); + + $tdata = []; + $tdata[0] = html_print_image('images/bell.png', true, ['title' => __('Defined alerts'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[1] = $data['monitor_alerts'] <= 0 ? '-' : $data['monitor_alerts']; + $tdata[1] = ''.$tdata[1].''; + + /* + Hello there! :) + We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger’ of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :( + You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years. + */ + + if ($data['monitor_alerts'] > $data['total_agents'] && !enterprise_installed()) { + $tdata[2] = "
    "; + } + + $tdata[3] = html_print_image( + 'images/bell_error.png', + true, + [ + 'title' => __('Fired alerts'), + 'class' => 'invert_filter', + ], + false, + false, + false, + true + ); + $tdata[4] = $data['monitor_alerts_fired'] <= 0 ? '-' : $data['monitor_alerts_fired']; + $tdata[4] = ''.$tdata[4].''; + $table_al->rowclass[] = ''; + $table_al->data[] = $tdata; + + if (!is_metaconsole()) { + $output = '
    + '.__('Defined and fired alerts').''.html_print_table($table_al, true).'
    '; + } else { + // Remove the defined alerts cause with the new cache table is difficult to retrieve them. + unset($table_al->data[0][0], $table_al->data[0][1]); + + $table_al->class = 'tactical_view'; + $table_al->style = []; + $output = '
    + '.__('Fired alerts').''.html_print_table($table_al, true).'
    '; + } + + return $output; +} + + +/** + * Return html count from stats modules by group. + * + * @param [type] $id_groups + * @param integer $graph_width + * @param integer $graph_height + * @param boolean $links + * @param boolean $data_agents + * @return void + */ +function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_height=150, $links=false, $data_agents=false) +{ + global $config; + + $data = [ + 'monitor_critical' => groups_get_critical_monitors($id_groups, [], [], false, false, false, false), + 'monitor_warning' => groups_get_warning_monitors($id_groups, [], [], false, false, false, false), + 'monitor_ok' => groups_get_normal_monitors($id_groups, [], [], false, false, false, false), + 'monitor_unknown' => groups_get_unknown_monitors($id_groups, [], [], false, false, false, false), + 'monitor_not_init' => groups_get_not_init_monitors($id_groups, [], [], false, false, false, false), + ]; + + // Link URLS. + if ($links === false) { + $urls = []; + $urls['monitor_critical'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_CRITICAL_BAD.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_warning'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_WARNING.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_ok'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NORMAL.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_unknown'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_UNKNOWN.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + $urls['monitor_not_init'] = $config['homeurl'].'index.php?'.'sec=view&sec2=operation/agentes/status_monitor&'.'refr=60&status='.AGENT_MODULE_STATUS_NOT_INIT.'&pure='.$config['pure'].'&recursion=1&ag_group='.$id_groups[0]; + } else { + $urls = []; + $urls['monitor_critical'] = $links['monitor_critical']; + $urls['monitor_warning'] = $links['monitor_warning']; + $urls['monitor_ok'] = $links['monitor_ok']; + $urls['monitor_unknown'] = $links['monitor_unknown']; + $urls['monitor_not_init'] = $links['monitor_not_init']; + } + + // Fixed width non interactive charts + $status_chart_width = $graph_width; + + // Modules by status table + $table_mbs = html_get_predefined_table(); + + $tdata = []; + $tdata[0] = html_print_image('images/module_critical.png', true, ['title' => __('Monitor critical')], false, false, false, true); + $tdata[1] = $data['monitor_critical'] <= 0 ? '-' : $data['monitor_critical']; + $tdata[1] = ''.$tdata[1].''; + + $tdata[2] = html_print_image('images/module_warning.png', true, ['title' => __('Monitor warning')], false, false, false, true); + $tdata[3] = $data['monitor_warning'] <= 0 ? '-' : $data['monitor_warning']; + $tdata[3] = ''.$tdata[3].''; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + + $tdata = []; + $tdata[0] = html_print_image('images/module_ok.png', true, ['title' => __('Monitor normal')], false, false, false, true); + $tdata[1] = $data['monitor_ok'] <= 0 ? '-' : $data['monitor_ok']; + $tdata[1] = ''.$tdata[1].''; + + $tdata[2] = html_print_image('images/module_unknown.png', true, ['title' => __('Monitor unknown')], false, false, false, true); + $tdata[3] = $data['monitor_unknown'] <= 0 ? '-' : $data['monitor_unknown']; + $tdata[3] = ''.$tdata[3].''; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + + $tdata = []; + $tdata[0] = html_print_image('images/module_notinit.png', true, ['title' => __('Monitor not init')], false, false, false, true); + $tdata[1] = $data['monitor_not_init'] <= 0 ? '-' : $data['monitor_not_init']; + $tdata[1] = ''.$tdata[1].''; + + $tdata[2] = $tdata[3] = ''; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + + if ($data['monitor_checks'] > 0) { + $tdata = []; + $table_mbs->colspan[count($table_mbs->data)][0] = 4; + $table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;'; + $tdata[0] = '
    '.'
    '.graph_agent_status(false, $graph_width, $graph_height, true, true, $data_agents).'
    '; + $table_mbs->rowclass[] = ''; + $table_mbs->data[] = $tdata; + } + + if (!is_metaconsole()) { + $output = ' +
    + '.__('Monitors by status').''.html_print_table($table_mbs, true).'
    '; + } else { + $table_mbs->class = 'tactical_view'; + $table_mbs->style = []; + $output = ' +
    + '.__('Monitors by status').''.html_print_table($table_mbs, true).'
    '; + } + + return $output; +} \ No newline at end of file diff --git a/pandora_console/include/functions_groupview.php b/pandora_console/include/functions_groupview.php index a87bea1650..5554343730 100644 --- a/pandora_console/include/functions_groupview.php +++ b/pandora_console/include/functions_groupview.php @@ -176,7 +176,7 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat [] ); - $total_counters = []; + $list = []; foreach ($agents_counters as $id_group => $agent_counter) { $list[$id_group]['_name_'] = $agent_counter['name']; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 44a8289b0d..01d8172633 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -495,7 +495,8 @@ function html_print_select_groups( $size=false, $simple_multiple_options=false, $required=false, - $inverse='' + $inverse='', + $form='' ) { $output = ''; @@ -609,7 +610,12 @@ function html_print_select_groups( '', false, $simple_multiple_options, - $required + $required, + false, + true, + false, + false, + $form ); if ($required !== false) { @@ -761,7 +767,8 @@ function html_print_select( $truncate_size=false, $select2_enable=true, $select2_multiple_enable=false, - $select2_multiple_enable_all=false + $select2_multiple_enable_all=false, + $form='' ) { $output = "\n"; @@ -802,6 +809,10 @@ function html_print_select( $attributes .= ' class="'.$class.'"'; } + if (!empty($form)) { + $attributes .= ' form="'.$form.'"'; + } + if (!empty($disabled)) { $attributes .= ' disabled="disabled"'; } @@ -953,12 +964,12 @@ function html_print_select( } $select2 = 'select2.min'; - if ($config['style'] === 'pandora_black' && !is_metaconsole()) { + if ($config['style'] === 'pandora_black' && is_metaconsole() === false) { $select2 = 'select2_dark.min'; } if (($multiple === false || $select2_multiple_enable === true) && $select2_enable === true) { - if (is_ajax()) { + if (is_ajax() === true) { $output .= '"; + $value = ''; + } + // Attributes specified by function call. $attrs = [ 'name' => 'unnamed', @@ -2611,6 +2687,17 @@ function html_print_input_text_extended( $output .= $function.'/>'; + if ($password === true && $hide_div_eye === false) { + $output .= html_print_div( + [ + 'id' => 'show-hide-'.$id, + 'class' => 'show-hide-pass', + 'onClick' => 'show_hide_password(event, \''.$config['homeurl'].'\')', + ], + true + ); + } + if (!$return) { echo $output; } @@ -2645,10 +2732,11 @@ function html_print_div( 'style', 'class', 'title', + 'onClick', ]; - if (isset($options['hidden'])) { - if (isset($options['style'])) { + if (isset($options['hidden']) === true) { + if (isset($options['style']) === true) { $options['style'] .= 'display:none;'; } else { $options['style'] = 'display:none;'; @@ -2656,7 +2744,7 @@ function html_print_div( } foreach ($attrs as $attribute) { - if (isset($options[$attribute])) { + if (isset($options[$attribute]) === true) { $output .= ' '.$attribute.'="'.io_safe_input_html($options[$attribute]).'"'; } } @@ -2667,7 +2755,7 @@ function html_print_div( $output .= ''; - if ($return) { + if ($return === true) { return $output; } else { echo $output; @@ -2739,7 +2827,7 @@ function html_print_anchor( $output .= (isset($options['href']) === true) ? 'href="'.io_safe_input_html($options['href']).'"' : ui_get_full_url(); foreach ($attrs as $attribute) { - if (isset($options[$attribute])) { + if (isset($options[$attribute]) === true && empty($options[$attribute]) === false) { $output .= ' '.$attribute.'="'.io_safe_input_html($options[$attribute]).'"'; } } @@ -2784,7 +2872,8 @@ function html_print_input_password( $disabled=false, $required=false, $class='', - $autocomplete='off' + $autocomplete='off', + $hide_div_eye=false, ) { if ($maxlength == 0) { $maxlength = 255; @@ -2815,7 +2904,7 @@ function html_print_input_password( } } - return html_print_input_text_extended($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, true, '', $autocomplete); + return '
    '.html_print_input_text_extended($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, true, '', $autocomplete, false, $hide_div_eye).'
    '; } @@ -3138,19 +3227,19 @@ function html_print_input_image($name, $src, $value, $style='', $return=false, $ } } - // If metaconsole is activated and image doesn't exists try to search on normal console - if (is_metaconsole()) { + // If metaconsole is activated and image doesn't exists try to search on normal console. + if (is_metaconsole() === true) { if (false === @file_get_contents($src, 0, null, 0, 1)) { $src = '../../'.$src; } } - // path to image + // Path to image. $src = ui_get_full_url($src); $output = ' Type of action-buttons: + * 'form_action' => Fits into form size (fixed size). + * 'data_table' => Fits into browser window. + * $var['class'] => Added class for action-buttons container. + * $var['id'] => Customize Id. By default `principal_action_buttons` (Handled by JS). + * $var['background_mask'] => Boolean. True by default. Set a background for action buttons. + * $var['background_mask_style'] => String. Empty by default. Set a manual style. + * @param boolean $return Return formed string if is true. + * + * @return mixed. + */ +function html_print_action_buttons(mixed $content, array $parameters=[], bool $return=false) +{ + if (is_array($content) === true) { + $content = implode('', $content); + } + + $typeClass = 'fixed_action_buttons '; + switch (($parameters['type'] ?? '')) { + case 'form_action': + case 'fixed_size': + $typeClass .= 'fixed_action_buttons_size'; + break; + + default: + case 'data_table': + // For fill. + break; + } + + if (isset($parameters['background_mask']) === false || $parameters['background_mask'] !== false) { + $backgroundId = 'backgroundMaskId'; + + $content .= html_print_div( + [ + 'id' => $backgroundId, + 'class' => 'action_buttons_background_mask', + 'content' => '', + 'style' => ($parameters['background_mask_style'] ?? ''), + ], + true + ); + } + + // Optional content. + $content .= html_print_div( + [ + 'class' => 'action_buttons_right_content', + 'content' => ($parameters['right_content'] ?? ''), + ], + true + ); + + return html_print_div( + [ + 'id' => ($parameters['id'] ?? 'principal_action_buttons'), + 'class' => 'action-buttons '.$typeClass.' '.($parameters['class'] ?? ''), + 'content' => $content, + 'style' => 'z-index: 6', + ], + $return + ); +} + + /** * Render an submit input button element. * @@ -3343,36 +3503,31 @@ function html_print_input_color($name, $value, $id='', $class=false, $return=fal * @param string $label Input label. * @param string $name Input name. * @param boolean $disabled Whether to disable by default or not. Enabled by default. - * @param array $attributes Additional HTML attributes. + * @param mixed $attributes Additional HTML attributes. * @param boolean $return Whether to return an output string or echo now (optional, echo by default). * * @return string HTML code if return parameter is true. */ function html_print_submit_button($label='OK', $name='', $disabled=false, $attributes='', $return=false) { - if (!$name) { - $name = 'unnamed'; + if (is_string($attributes) === true) { + // Convert Attributes in array for handle in the principal function. + $tmp = []; + $tmp['rawAttributes'] = $attributes; + $attributes = $tmp; } - if (is_array($attributes)) { - $attr_array = $attributes; - $attributes = ''; - foreach ($attr_array as $attribute => $value) { - $attributes .= $attribute.'="'.$value.'" '; - } - } + // Set the button type from here. + $attributes['type'] = 'submit'; - $output = ' $value) { + if ($attribute === 'icon') { + $iconToUse = $value; + } else if ($attribute === 'mode') { + if ($value !== 'link') { + $buttonMode = $value; + } else { + $iconToUse = ''; + } + + $classes .= ' '.$value; + } else if ($attribute === 'type') { + $buttonType = $value; + $classes .= ' '.$value.'Button'; + } else if ($attribute === 'class') { + $classes .= ' '.$value; + } else if ($attribute === 'fixed_id') { + $fixedId = $value; + } else if ($attribute === 'icon_style') { + $iconStyle = $value; + } else if ($attribute === 'span_style') { + $spanStyle .= $value; + } else if ($attribute === 'rawAttributes') { + $buttonType = ($attr_array['type'] ?? 'button'); + $buttonAttributes = $value; + break; + } else { + $attributes .= $attribute.'="'.$value.'" '; + } + } + } else if (empty($attributes) === false && is_string($attributes) === true) { + $buttonAttrutes = explode(' ', $attributes); } - $output .= ' />'; + if (empty($iconToUse) === false || (isset($buttonMode) === true && $buttonMode !== 'onlyIcon')) { + $iconDiv = html_print_div( + [ + 'style' => $iconStyle, + 'class' => sprintf( + 'subIcon %s %s', + $iconToUse, + (empty($buttonMode) === false) ? $buttonMode : '' + ), + ], + true + ); + } else { + $iconDiv = ''; + } - if ($modal && !enterprise_installed()) { + // Defined id. Is usable for span and button. + // TODO. Check if will be proper use button or submit when where appropiate. + $mainId = ((empty($fixedId) === false) ? $fixedId : 'button-'.$name); + + if ($imageButton === false) { + $content = ''.$label.''; + $content .= $iconDiv; + } else { + $content = $iconDiv; + } + + // In case of not selected button type, in this case, will be normal button. + if (isset($buttonType) === false || ($buttonType !== 'button' && $buttonType !== 'submit')) { + $buttonType = 'button'; + $classes .= ' buttonButton'; + } + + if ($disabled === true) { + $classes .= ' disabled_action_button'; + } + + if (empty($buttonAttributes) === true) { + $parameters = []; + $parameters[] = 'class="'.$classes.'"'; + $parameters[] = (empty($name) === false) ? ' name="'.$name.'"' : ''; + $parameters[] = 'id="'.$mainId.'"'; + $parameters[] = (empty($label) === false) ? ' value="'.$label.'"' : ''; + $parameters[] = (empty($script) === false) ? " onClick='".$script."'" : ''; + $parameters[] = ($disabled === true) ? ' disabled' : ''; + $parameters[] = (empty($attributes) === false) ? $attributes : ''; + + $buttonAttributes = implode(' ', $parameters); + } + + $output = sprintf( + '', + $buttonType, + $buttonAttributes, + $content + ); + + if ($modal !== false && enterprise_installed() === false) { $output .= "
    "; } - if ($return) { + if ($return === true) { return $output; + } else { + echo $output; } - echo $output; } @@ -3743,7 +3990,13 @@ function html_print_table(&$table, $return=false) $output .= ''."\n"; } - $output .= '
    '."\n"; + $tbodyStyle = ''; + + if (empty($table->width) === false) { + $tbodyStyle .= 'width:'.$table->width.';'; + } + + $output .= ''."\n"; if (!empty($table->data)) { $oddeven = 1; foreach ($table->data as $keyrow => $row) { @@ -3891,22 +4144,22 @@ function html_print_radio_button_extended( $output .= ' />'; if (is_array($label)) { - if (!empty($label)) { - $output .= ''."\n"; + if (empty($label) === false) { + $output .= ''."\n"; } } else { if ($label != '') { - $output .= ''."\n"; + $output .= ''."\n"; } } - if ($modal && !enterprise_installed()) { + if ($modal === true && enterprise_installed() === false) { $output .= "
    "; } - if ($return) { + if ($return === true) { return $output; } @@ -3937,17 +4190,48 @@ function html_print_radio_button($name, $value, $label='', $checkedvalue='', $re } +/** + * Render a Switch-Radio selector buttons. + * + * @param array $switches Switches for add (html_print_radio_button). + * @param array $attributes Special attributes. + * @param boolean $return Return. False by default. + * + * @return mixed. + */ +function html_print_switch_radio_button(array $switches, array $attributes=[], bool $return=false) +{ + // By default, the content are only the switches added. + $content = implode('', $switches); + // If you want add more content, you can attach in attributes. + if (isset($attributes['add_content']) === true) { + $content .= $attributes['add_content']; + } + + return html_print_div( + [ + 'id' => ($attributes['id'] ?? ''), + 'class' => 'switch_radio_button '.($attributes['class'] ?? ''), + 'content' => $content, + ], + $return + ); +} + + /** * Render a checkbox button input. Extended version, use html_print_checkbox() to simplify. * - * @param string $name Input name. - * @param string $value Input value. - * @param string $checked Set the button to be marked (optional, unmarked by default). - * @param boolean $disabled Disable the button (optional, button enabled by default). - * @param string $script Script to execute when onClick event is triggered (optional). - * @param string $attributes Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional). - * @param boolean $return Whether to return an output string or echo now (optional, echo by default). - * @param string $id Custom id. + * @param string $name Input name. + * @param string $value Input value. + * @param string $checked Set the button to be marked (optional, unmarked by default). + * @param boolean $disabled Disable the button (optional, button enabled by default). + * @param string $script Script to execute when onClick event is triggered (optional). + * @param mixed $attributes Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional). + * @param boolean $return Whether to return an output string or echo now (optional, echo by default). + * @param string $id Custom id. + * @param string $customAttributes Custom Attribute for customized checkbox. + * @param string $customHTML Custom HTML for customized checkbox. * * @return string HTML code if return parameter is true. */ @@ -3959,7 +4243,9 @@ function html_print_checkbox_extended( $script, $attributes, $return=false, - $id='' + $id='', + $customAttributes='', + $customHTML='' ) { static $idcounter = []; @@ -3970,25 +4256,47 @@ function html_print_checkbox_extended( $idcounter[$name] = 0; } + $inputClass = 'custom_checkbox_input'; + $labelClass = 'custom_checkbox'; + $labelStyle = ' '; + + if (is_array($attributes) === true) { + $tmpAttributes = []; + foreach ($attributes as $key => $value) { + switch ($key) { + case 'input_class': + $inputClass .= ' '.$value; + break; + + case 'label_class': + $labelClass .= ' '.$value; + break; + + case 'label_style': + $labelStyle .= 'style="'.$value.'"'; + break; + + default: + $tmpAttributes[] = $key.'="'.$value.'"'; + break; + } + } + + $attributes = implode(' ', $tmpAttributes); + } + $id_aux = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); - $output = ''; + $output .= ''; + $output .= ''; $output .= "\n"; if ($return === false) { @@ -4002,15 +4310,17 @@ function html_print_checkbox_extended( /** * Render a checkbox button input. * - * @param string $name Input name. - * @param string $value Input value. - * @param string $checked Set the button to be marked (optional, unmarked by default). - * @param boolean $return Whether to return an output string or echo now (optional, echo by default). - * @param boolean $disabled Disable the button (optional, button enabled by default). - * @param string $script Script. - * @param string $disabled_hidden Disabled_hidden. - * @param string $attributes Extra attributes. - * @param string $id Custom ID. + * @param string $name Input name. + * @param string $value Input value. + * @param string $checked Set the button to be marked (optional, unmarked by default). + * @param boolean $return Whether to return an output string or echo now (optional, echo by default). + * @param boolean $disabled Disable the button (optional, button enabled by default). + * @param string $script Script. + * @param string $disabled_hidden Disabled_hidden. + * @param string $attributes Extra attributes. + * @param string $id Custom ID. + * @param string $customAttributes Custom Attribute for customized checkbox. + * @param string $customHTML Custom HTML for customized checkbox. * * @return string HTML code if return parameter is true. */ @@ -4023,7 +4333,9 @@ function html_print_checkbox( $script='', $disabled_hidden=false, $attributes='', - $id='' + $id='', + $customAttributes='', + $customHTML='' ) { $output = html_print_checkbox_extended( $name, @@ -4033,7 +4345,9 @@ function html_print_checkbox( $script, $attributes, true, - $id + $id, + $customAttributes, + $customHTML ); if (!$disabled_hidden) { $output .= html_print_input_hidden($name.'_sent', 1, true); @@ -4251,6 +4565,12 @@ function html_print_image( // Dont use safe_input here or the performance will dead. $style = ''; + if (empty($options) === false && isset($options['class']) === true) { + $options['class'] .= ' main_menu_icon'; + } else { + $options['class'] = 'main_menu_icon invert_filter'; + } + if (!empty($options)) { // Deprecated or value-less attributes. if (isset($options['align'])) { @@ -4413,7 +4733,7 @@ function html_print_header_logo_image(bool $menuCollapsed, bool $return=false) true, [ 'border' => '0', - 'width' => '60', + 'width' => '35', 'alt' => $logo_title, 'class' => 'logo_icon', 'style' => ($menuCollapsed === true) ? 'display:block' : 'display:none', @@ -4442,7 +4762,8 @@ function html_print_header_logo_image(bool $menuCollapsed, bool $return=false) function html_print_input_file($name, $return=false, $options=false) { $output = ''; - + // Start to build the input. + $output .= '
    '; + $legend .= '

    '.__('Severity').'

    '; + $legend .= '
    '; + $priorities = get_priorities(); + $half = (count($priorities) / 2); + $count = 0; + foreach ($priorities as $num => $name) { + if ($count == $half) { + $legend .= '
    '; + } + + $legend .= ''.$name.''; + $legend .= '
    '; + $count++; } - echo '
    '; + $legend .= '
    '; + $legend .= '

    '.__('Status').'

    '; + $legend .= ''.__('Validated').''; + $legend .= '
    '; + $legend .= ''.__('Not validated').''; + $legend .= '
    '; + $legend .= '

    '.__('Alert').'

    '; + $legend .= ''.__('Alert').''; + $legend .= '
    '; + $legend .= ''.__('Not fired').''; + $legend .= '
    '; + $legend .= '

    '.__('Action').'

    '; + $legend .= '
    '; + $legend .= html_print_image('images/validate.svg', true, ['class' => 'main_menu_icon invert_filter']).' - '.__('Validate'); + $legend .= '
    '; + $legend .= '
    '; + $legend .= '
    '; + $legend .= html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']).' - '.__('Delete'); + $legend .= '
    '; + $legend .= '


    ${trap['count']}
    ${trap['first']}
    ${trap['last']}
    ${desc_trap_type}
    ${trap['description']}
    ${trap['oid']}
    ${string}${string}


    ${trap['count']}
    ${trap['first']}
    ${trap['last']}
    ${desc_trap_type}
    ${trap['description']}
    ${trap['oid']}
    ${string}${string}
    '.html_print_input_text('map_connection_name_'.$mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true).' '.$radioButton.''.html_print_image('images/cross.png', true, ['alt' => '', 'class' => 'invert_filter']).''.html_print_image('images/delete.svg', true, ['alt' => '', 'class' => 'invert_filter']).'
    - - diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index aa45aacc10..dbb988782a 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1019,7 +1019,7 @@ function modules_format_delete($id) $txt = ''; if (check_acl($config['id_user'], $group, 'AW') == 1) { - $txt = ''.html_print_image('images/cross.png', true, ['border' => '0', 'class' => 'invert_filter']).''; + $txt = ''.html_print_image('images/delete.svg', true, ['border' => '0', 'class' => 'invert_filter']).''; } return $txt; @@ -1040,7 +1040,7 @@ function modules_format_delete_string($id) $txt = ''; if (check_acl($config['id_user'], $group, 'AW') == 1) { - $txt = ''.html_print_image('images/cross.png', true, ['border' => '0', 'class' => 'invert_filter']).''; + $txt = ''.html_print_image('images/delete.svg', true, ['border' => '0', 'class' => 'invert_filter']).''; } return $txt; @@ -1061,7 +1061,7 @@ function modules_format_delete_log4x($id) $txt = ''; if (check_acl($config['id_user'], $group, 'AW') == 1) { - $txt = ''.html_print_image('images/cross.png', true, ['border' => '0', 'class' => 'invert_filter']).''; + $txt = ''.html_print_image('images/delete.svg', true, ['border' => '0', 'class' => 'invert_filter']).''; } return $txt; @@ -2580,8 +2580,8 @@ function modules_get_agentmodule_data_for_humans($module) switch ($module['id_tipo_modulo']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); - if (($value == '.1.3.6.1.2.1.1.3.0' - || $value == '.1.3.6.1.2.1.25.1.1.0') + if (($value === '.1.3.6.1.2.1.1.3.0' + || $value === '.1.3.6.1.2.1.25.1.1.0') && modules_get_unit_macro($module['data'], $module['unit']) === true ) { if ($module['post_process'] > 0) { @@ -2604,8 +2604,8 @@ function modules_get_agentmodule_data_for_humans($module) switch ($module['id_tipo_modulo']) { case 15: $value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module['id_agente_modulo']); - if (($value == '.1.3.6.1.2.1.1.3.0' - || $value == '.1.3.6.1.2.1.25.1.1.0') + if (($value === '.1.3.6.1.2.1.1.3.0' + || $value === '.1.3.6.1.2.1.25.1.1.0') && modules_get_unit_macro($module['data'], $module['unit']) === true ) { if ($module['post_process'] > 0) { @@ -2624,8 +2624,8 @@ function modules_get_agentmodule_data_for_humans($module) } } - // Show units ONLY in numeric data types - if (isset($module['unit'])) { + // Show units ONLY in numeric data types. + if (isset($module['unit']) === true) { $data_macro = modules_get_unit_macro($module['datos'], $module['unit']); if ($data_macro) { $salida = $data_macro; @@ -4133,12 +4133,12 @@ function get_module_realtime_link_graph($module) 'community' => urlencode($module['snmp_community']), 'starting_oid' => urlencode($module['snmp_oid']), 'snmp_browser_version' => urlencode($module['tcp_send']), - 'snmp3_auth_user' => urlencode($module['plugin_user']), - 'snmp3_security_level' => urlencode($module['custom_string_3']), - 'snmp3_auth_method' => urlencode($module['plugin_parameters']), - 'snmp3_auth_pass' => urlencode($module['plugin_pass']), - 'snmp3_privacy_method' => urlencode($module['custom_string_1']), - 'snmp3_privacy_pass' => urlencode($module['custom_string_2']), + 'snmp3_auth_user' => urlencode(($module['plugin_user'] ?? '')), + 'snmp3_security_level' => urlencode(($module['custom_string_3'] ?? '')), + 'snmp3_auth_method' => urlencode(($module['plugin_parameters'] ?? '')), + 'snmp3_auth_pass' => urlencode(($module['plugin_pass'] ?? '')), + 'snmp3_privacy_method' => urlencode(($module['custom_string_1'] ?? '')), + 'snmp3_privacy_pass' => urlencode(($module['custom_string_2'] ?? '')), 'hide_header' => 1, 'rel_path' => '../../', ]; @@ -4161,13 +4161,13 @@ function get_module_realtime_link_graph($module) $link_button = ''; $link_button .= html_print_image( - 'images/realtime_shortcut.png', + 'images/prediction@svg.svg', true, [ 'border' => '0', 'alt' => '', 'title' => __('Realtime SNMP graph'), - 'class' => 'invert_filter', + 'class' => 'invert_filter main_menu_icon', ] ); $link_button .= ''; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 657ce1ff35..6918bad686 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -863,18 +863,22 @@ function notifications_print_source_select_box($info_selec, $id, $source_id) true ), html_print_image( - 'images/input_add.png', + 'images/fail@svg.svg', true, [ + 'style' => 'width: 14px;rotate: 45deg', 'title' => $add_title, + 'class' => 'main_menu_icon invert_filter', 'onclick' => sprintf("add_source_dialog('%s', '%s')", $id, $source_id), ] ), html_print_image( - 'images/input_delete.png', + 'images/delete.svg', true, [ + 'style' => 'width: 14px', 'title' => $delete_title, + 'class' => 'main_menu_icon invert_filter', 'onclick' => sprintf( "remove_source_elements('%s', '%s')", $id, @@ -923,29 +927,31 @@ function notifications_print_two_ways_select($info_selec, $users, $source_id) '' ), html_print_image( - 'images/darrowright.png', + 'images/arrow@svg.svg', true, [ 'title' => __('Add elements'), + 'style' => 'rotate: 90deg', 'onclick' => sprintf( "notifications_modify_two_ways_element('%s', '%s', 'add')", $users, $source_id ), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), html_print_image( - 'images/darrowleft.png', + 'images/arrow@svg.svg', true, [ 'title' => __('Remove elements'), + 'style' => 'rotate: 0', 'onclick' => sprintf( "notifications_modify_two_ways_element('%s', '%s', 'remove')", $users, $source_id ), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ), html_print_select( diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index 5132817588..d656cdeff2 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -191,24 +191,20 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $table->id = 'table_profiles'; $table->width = '100%'; $table->class = 'info_table'; - if (defined('METACONSOLE')) { + if (is_metaconsole() === true) { $table->head_colspan[0] = 0; $table->width = '100%'; $table->class = 'databox_tactical data'; $table->title = $title; } else { - echo '
    '; - echo '

    '.$title.'

    '; + echo '
    '; + echo '

    '.$title.'

    '; } $table->data = []; $table->head = []; $table->align = []; $table->style = []; - if (!defined('METACONSOLE')) { - $table->style['name'] = 'font-weight: bold'; - $table->style['group'] = 'font-weight: bold'; - } $table->head['name'] = __('Profile name'); $table->head['group'] = __('Group'); @@ -217,6 +213,10 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $table->head['actions'] = __('Action'); $table->align['actions'] = 'center'; + $table->headstyle['tags'] = 'width: 33%'; + $table->headstyle['hierarchy'] = 'text-align: center'; + $table->headstyle['actions'] = 'text-align: center'; + if (users_is_admin()) { $result = db_get_all_rows_filter( 'tusuario_perfil', @@ -225,7 +225,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c } else { // Only profiles that can be viewed by the user. $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)); @@ -238,7 +238,6 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c $id, $group_um_string ); - $result = db_get_all_rows_sql($sql); } @@ -262,26 +261,40 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c } } - foreach ($result as $profile) { - if ($profile['id_grupo'] == -1) { + $lastKey = 0; + foreach ($result as $key => $profile) { + if ((int) $profile['id_grupo'] === -1) { continue; } $data = []; - $data['name'] = ''.profile_get_name($profile['id_perfil']).''; + $profileName = profile_get_name($profile['id_perfil']); + + if (is_management_allowed() === false) { + $data['name'] = $profileName; + } else { + $data['name'] = html_print_anchor( + [ + 'href' => 'index.php?sec2=godmode/users/configure_profile&id='.$profile['id_perfil'], + 'content' => $profileName, + ], + true + ); + } + $data['group'] = ui_print_group_icon($profile['id_grupo'], true); - if (!defined('METACONSOLE')) { - $data['group'] .= ''; + if (is_metaconsole() === false) { + $data['group'] .= ''; } $data['group'] .= ' '.ui_print_truncate_text(groups_get_name($profile['id_grupo'], true), GENERIC_SIZE_TEXT); - if (!defined('METACONSOLE')) { + if (is_metaconsole() === false) { $data['group'] .= ''; } - if (empty($profile['tags'])) { + if (empty($profile['tags']) === true) { $data['tags'] = ''; } else { if (is_array($profile['tags']) === false) { @@ -299,7 +312,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c if ($create_user) { $data['actions'] .= html_print_input_image( 'del', - 'images/cross.png', + 'images/delete.svg', 1, '', true, @@ -310,7 +323,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c ); } else { $data['actions'] = ''; - $data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true); + $data['actions'] .= html_print_input_image('del', 'images/delete.svg', 1, 'width:40px; height: 28px', true); $data['actions'] .= html_print_input_hidden('delete_profile', 1, true); $data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true); $data['actions'] .= html_print_input_hidden('id_user', $id, true); @@ -318,13 +331,23 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c } array_push($table->data, $data); + $lastKey++; + } + + if (is_metaconsole() === false) { + $table->style['last_name'] = 'vertical-align: top'; + $table->style['last_group'] = 'vertical-align: top'; + $table->style['hierarchy'] = 'text-align:center;'; + $table->style['last_hierarchy'] = 'text-align:center;vertical-align: top'; + $table->style['actions'] = 'text-align:center;vertical-align: top'; + $table->style['last_actions'] = 'text-align:center;vertical-align: top'; } $data = []; - $data['name'] = ''; + $data['last_name'] = ''; if (check_acl($config['id_user'], 0, 'PM')) { - $data['name'] .= html_print_select( + $data['last_name'] .= html_print_select( profile_get_profiles(), 'assign_profile', 0, @@ -336,7 +359,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c false ); } else { - $data['name'] .= html_print_select( + $data['last_name'] .= html_print_select( profile_get_profiles( [ 'pandora_management' => '<> 1', @@ -355,7 +378,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c ); } - $data['group'] = html_print_select_groups( + $data['last_group'] = html_print_select_groups( $config['id_user'], 'UM', users_can_manage_group_all('UM'), @@ -370,18 +393,19 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c ); $tags = tags_get_all_tags(); - $data['tags'] = html_print_select($tags, 'assign_tags[]', '', '', __('Any'), '', true, true); + $data['last_tags'] = html_print_select($tags, 'assign_tags[]', '', '', __('Any'), '', true, true, true, 'w100p'); - $data['hierarchy'] = html_print_checkbox('no_hierarchy', 1, false, true); + $data['last_hierarchy'] = html_print_checkbox('no_hierarchy', 1, false, true); - $data['actions'] = html_print_input_image('add', 'images/add.png', 1, '', true); - $data['actions'] .= html_print_input_hidden('id', $id, true); - $data['actions'] .= html_print_input_hidden('add_profile', 1, true); - $data['actions'] .= ''; + $data['last_actions'] = html_print_input_image('add', 'images/validate.svg', 1, 'width: 40px; height: 28px', true); + $data['last_actions'] .= html_print_input_hidden('id', $id, true); + $data['last_actions'] .= html_print_input_hidden('add_profile', 1, true); + $data['last_actions'] .= ''; array_push($table->data, $data); html_print_table($table, $return); - if (!is_metaconsole()) { + + if (is_metaconsole() === false) { echo '
    '; } diff --git a/pandora_console/include/functions_register.php b/pandora_console/include/functions_register.php index 82c94441e7..2fa6f4a8df 100644 --- a/pandora_console/include/functions_register.php +++ b/pandora_console/include/functions_register.php @@ -179,7 +179,7 @@ function config_wiz_modal( __('Cancel'), 'cancel', false, - 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub cancel submit-cancel w100px"', + ['icon' => 'cancel'], true ); $output .= '
    '; @@ -188,7 +188,7 @@ function config_wiz_modal( __('Continue'), 'register-next', false, - 'class="ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next w100px"', + ['icon' => 'next'], true ); $output .= ''; @@ -287,7 +287,7 @@ function show_configuration_wizard() { // CLICK EVENTS: Cancel and Registration - $("#submit-cancel").click (function (e) { + $("#button-cancel").click (function (e) { e.preventDefault(); $("#wiz_ensure_cancel").dialog({ buttons: [ @@ -320,7 +320,7 @@ function show_configuration_wizard() { $("#wiz_ensure_cancel").dialog('open'); }); - $("#submit-register-next").click (function () { + $("#button-register-next").click (function () { // All fields are required. if ($("#text-email").val() == '') { $("#all-required").show(); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6fc5e600cd..9c99d47a2a 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2618,11 +2618,16 @@ function reporting_agents_inventory($report, $content) $es_agents_inventory_display_options = []; } + if ($es_agent_custom_fields === '') { + $es_agent_custom_fields = []; + } + $custom_field_sql = ''; $search_sql = ''; + $sql_order_by = 'ORDER BY tagente.id_agente ASC'; if (empty(array_filter($es_agent_custom_fields)) === false) { - $custom_field_sql = 'INNER JOIN tagent_custom_data tacd ON tacd.id_agent = tagente.id_agente'; + $custom_field_sql = 'LEFT JOIN tagent_custom_data tacd ON tacd.id_agent = tagente.id_agente'; if ($es_agent_custom_fields[0] != 0) { $custom_field_sql .= ' AND tacd.id_field IN ('.implode(',', $es_agent_custom_fields).')'; } @@ -2656,6 +2661,12 @@ function reporting_agents_inventory($report, $content) $user_groups_to_sql = implode(',', array_keys(users_get_groups())); + if (array_search('alias', $es_agents_inventory_display_options) !== false) { + $sql_order_by = 'ORDER BY tagente.alias ASC'; + } else if (array_search('direccion', $es_agents_inventory_display_options) !== false) { + $sql_order_by = 'ORDER BY tagente.direccion ASC'; + } + $sql = sprintf( 'SELECT DISTINCT(tagente.id_agente) AS id_agente, tagente.id_os, @@ -2671,12 +2682,12 @@ function reporting_agents_inventory($report, $content) LEFT JOIN tagente_modulo tam ON tam.id_agente = tagente.id_agente %s - WHERE (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s)) - %s', + WHERE (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s))%s%s', $custom_field_sql, $user_groups_to_sql, $user_groups_to_sql, - $search_sql + $search_sql, + $sql_order_by ); if (is_metaconsole()) { @@ -2808,11 +2819,16 @@ function reporting_modules_inventory($report, $content) $search_sql = ''; if (empty($es_agent_group_filter) === false) { - $search_sql .= ' AND (ta.id_grupo = '.$es_agent_group_filter.' OR tasg.id_group = '.$es_agent_group_filter.')'; + $search_sql .= '(ta.id_grupo = '.$es_agent_group_filter.' OR tasg.id_group = '.$es_agent_group_filter.')'; } if (empty($module_group) === false && $module_group > -1) { - $search_sql .= ' AND tam.id_module_group = '.$module_group; + $modules = implode(',', $module_group); + if ($search_sql !== '') { + $search_sql .= ' AND '; + } + + $search_sql .= 'tam.id_module_group IN ('.$modules.')'; } $user_groups_to_sql = ''; @@ -2822,25 +2838,80 @@ function reporting_modules_inventory($report, $content) $user_groups = $user_groupsAR; $user_groups_to_sql = implode(',', array_keys($user_groups)); + $sql_alias = ''; + $sql_order_by = 'ORDER BY tam.nombre ASC'; + if ((int) $external_source['alias'] === 1) { + $sql_alias = " ta.alias,\n "; + $sql_order_by = 'ORDER BY ta.alias ASC, tam.nombre ASC'; + } + + $sql_description = ''; + if ((int) $external_source['description_switch'] === 1) { + $sql_description = "\n tam.descripcion,"; + } + + $sql_last_status = ''; + $sql_last_status_join = ''; + if ((int) $external_source['last_status_change'] === 1) { + $sql_last_status = ",\n tae.last_status_change"; + $sql_last_status_join = "\n LEFT JOIN tagente_estado tae"; + $sql_last_status_join .= "\n ON tae.id_agente_modulo = tam.id_agente_modulo"; + } + + if (empty($external_source['search_module_name']) === false) { + if ($search_sql !== '') { + $search_sql .= ' AND '; + } + + $search_sql .= "tam.nombre LIKE '%".$external_source['search_module_name']."%'"; + } + + $tags_condition = tags_get_user_tags(); + $tags_imploded = implode(',', array_keys($tags_condition)); + if (users_is_admin() === false) { + if ($search_sql !== '') { + $search_sql .= ' AND '; + } + + $search_sql .= 'ttm.id_tag IN ('.$tags_imploded.')'; + } + + if (empty($external_source['tags']) === false) { + $external_tags_imploded = implode(',', $external_source['tags']); + if ($search_sql !== '') { + $search_sql .= ' AND '; + } + + $search_sql .= 'ttm.id_tag IN ('.$external_tags_imploded.')'; + } + + $sql_where = ''; + if (empty($search_sql) === false) { + $sql_where .= 'WHERE '.$search_sql; + } + $sql = sprintf( - 'SELECT tam.id_agente_modulo, - tam.nombre, - tam.descripcion, + 'SELECT DISTINCT(tam.id_agente_modulo), + %s tam.id_agente_modulo, + tam.nombre,%s tam.id_module_group, - ttm.id_tag, ta.id_grupo AS group_id, - tasg.id_group AS sec_group_id + tasg.id_group AS sec_group_id%s FROM tagente_modulo tam INNER JOIN tagente ta ON tam.id_agente = ta.id_agente LEFT JOIN tagent_secondary_group tasg ON ta.id_agente = tasg.id_agent LEFT JOIN ttag_module ttm - ON ttm.id_agente_modulo = tam.id_agente_modulo - WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)) %s', - $user_groups_to_sql, - $user_groups_to_sql, - $search_sql + ON ttm.id_agente_modulo = tam.id_agente_modulo%s + %s + %s', + $sql_alias, + $sql_description, + $sql_last_status, + $sql_last_status_join, + $sql_where, + $sql_order_by ); if (is_metaconsole()) { @@ -2866,6 +2937,23 @@ function reporting_modules_inventory($report, $content) $agents = db_get_all_rows_sql($sql); + foreach ($agents as $agent_key => $agent_value) { + $sql2 = 'SELECT tm.id_tag + FROM ttag_module tm + WHERE tm.id_agente_modulo = '.$agent_value['id_agente_modulo']; + + $tags_rows = db_get_all_rows_sql($sql2); + $tags_ids = []; + + foreach ($tags_rows as $tag_row) { + array_push($tags_ids, $tag_row['id_tag']); + } + + $column_value = implode(',', $tags_ids); + $agents[$agent_key]['tags'] = $column_value; + $agents[$agent_key]['server_id'] = $server_id; + } + $return_data[$server_id] = $agents; if (is_metaconsole()) { @@ -2885,33 +2973,44 @@ function reporting_modules_inventory($report, $content) $module_row_data = []; + $i = 0; + foreach ($return['data'] as $row) { - if (is_array($module_row_data[$row['id_agente_modulo']]) === false) { - $module_row_data[$row['id_agente_modulo']]['nombre'] = $row['nombre']; - $module_row_data[$row['id_agente_modulo']]['descripcion'] = $row['descripcion']; - $module_row_data[$row['id_agente_modulo']]['id_module_group'] = $row['id_module_group']; - $module_row_data[$row['id_agente_modulo']]['id_tag'] = []; - $module_row_data[$row['id_agente_modulo']]['group_id'] = []; - $module_row_data[$row['id_agente_modulo']]['sec_group_id'] = []; + if (array_key_exists('alias', $row) === true) { + $module_row_data[$i]['alias'] = $row['alias']; } - if (in_array($row['id_tag'], $module_row_data[$row['id_agente_modulo']]['id_tag']) === false - && $row['id_tag'] !== null - ) { - $module_row_data[$row['id_agente_modulo']]['id_tag'][] = $row['id_tag']; + if (array_key_exists('nombre', $row) === true) { + $module_row_data[$i]['nombre'] = $row['nombre']; } - if (in_array($row['group_id'], $module_row_data[$row['id_agente_modulo']]['group_id']) === false - && $row['group_id'] !== null - ) { - $module_row_data[$row['id_agente_modulo']]['group_id'][] = $row['group_id']; + if (array_key_exists('descripcion', $row) === true) { + $module_row_data[$i]['descripcion'] = $row['descripcion']; } - if (in_array($row['sec_group_id'], $module_row_data[$row['id_agente_modulo']]['sec_group_id']) === false - && $row['sec_group_id'] !== null - ) { - $module_row_data[$row['id_agente_modulo']]['sec_group_id'][] = $row['sec_group_id']; + $module_row_data[$i]['id_module_group'] = $row['id_module_group']; + $module_row_data[$i]['id_tag'] = []; + $module_row_data[$i]['group_id'] = []; + $module_row_data[$i]['sec_group_id'] = []; + + if (array_key_exists('tags', $row) === true) { + $module_row_data[$i]['id_tag'][] = $row['tags']; } + + if (array_key_exists('id_group', $row) === true) { + $module_row_data[$i]['group_id'][] = $row['group_id']; + } + + if (array_key_exists('sec_group_id', $row) === true) { + $module_row_data[$i]['sec_group_id'][] = $row['sec_group_id']; + } + + if (array_key_exists('last_status_change', $row) === true) { + $human_last_status_change = human_time_comparation($row['last_status_change']); + $module_row_data[$i]['last_status_change'] = $human_last_status_change; + } + + $i++; } $return['data'] = $module_row_data; @@ -11987,7 +12086,7 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru $table_ind->data[] = $tdata; $tdata[0] = '
    - '.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), (int) $data['monitor_not_init']), true).''.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'
    '; + '.__('Module sanityX').ui_print_help_tip(sprintf(__('%d Not inited monitors'), (int) $data['monitor_not_init']), true).''.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).''; $table_ind->rowclass[] = ''; $table_ind->data[] = $tdata; @@ -12053,7 +12152,7 @@ function reporting_get_stats_alerts($data, $links=false) $table_al = html_get_predefined_table(); $tdata = []; - $tdata[0] = html_print_image('images/bell.png', true, ['title' => __('Defined alerts'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[0] = html_print_image('images/alert@svg.svg', true, ['title' => __('Defined alerts'), 'class' => 'main_menu_icon invert_filter'], false, false, false, true); $tdata[1] = $data['monitor_alerts'] <= 0 ? '-' : $data['monitor_alerts']; $tdata[1] = ''.$tdata[1].''; @@ -12064,19 +12163,15 @@ function reporting_get_stats_alerts($data, $links=false) */ if ($data['monitor_alerts'] > $data['total_agents'] && !enterprise_installed()) { - $tdata[2] = "
    "; + $tdata[2] = "
    "; } - $tdata[3] = html_print_image( - 'images/bell_error.png', - true, + $tdata[3] = html_print_div( [ 'title' => __('Fired alerts'), - 'class' => 'invert_filter', + 'style' => 'background-color: '.COL_ALERTFIRED, + 'class' => 'alert_background_state main_menu_icon', ], - false, - false, - false, true ); $tdata[4] = $data['monitor_alerts_fired'] <= 0 ? '-' : $data['monitor_alerts_fired']; @@ -12129,29 +12224,29 @@ function reporting_get_stats_modules_status($data, $graph_width=250, $graph_heig $table_mbs = html_get_predefined_table(); $tdata = []; - $tdata[0] = html_print_image('images/module_critical.png', true, ['title' => __('Monitor critical')], false, false, false, true); + $tdata[0] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_CRITICAL, 'title' => __('Monitor critical')], true); $tdata[1] = $data['monitor_critical'] <= 0 ? '-' : $data['monitor_critical']; $tdata[1] = ''.$tdata[1].''; - $tdata[2] = html_print_image('images/module_warning.png', true, ['title' => __('Monitor warning')], false, false, false, true); + $tdata[2] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_WARNING_DARK, 'title' => __('Monitor warning')], true); $tdata[3] = $data['monitor_warning'] <= 0 ? '-' : $data['monitor_warning']; $tdata[3] = ''.$tdata[3].''; $table_mbs->rowclass[] = ''; $table_mbs->data[] = $tdata; $tdata = []; - $tdata[0] = html_print_image('images/module_ok.png', true, ['title' => __('Monitor normal')], false, false, false, true); + $tdata[0] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_NORMAL, 'title' => __('Monitor normal')], true); $tdata[1] = $data['monitor_ok'] <= 0 ? '-' : $data['monitor_ok']; $tdata[1] = ''.$tdata[1].''; - $tdata[2] = html_print_image('images/module_unknown.png', true, ['title' => __('Monitor unknown')], false, false, false, true); + $tdata[2] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_UNKNOWN, 'title' => __('Monitor unknown')], true); $tdata[3] = $data['monitor_unknown'] <= 0 ? '-' : $data['monitor_unknown']; $tdata[3] = ''.$tdata[3].''; $table_mbs->rowclass[] = ''; $table_mbs->data[] = $tdata; $tdata = []; - $tdata[0] = html_print_image('images/module_notinit.png', true, ['title' => __('Monitor not init')], false, false, false, true); + $tdata[0] = html_print_div(['class' => 'main_menu_icon module_background_state', 'style' => 'background-color: '.COL_NOTINIT, 'title' => __('Monitor not init')], true); $tdata[1] = $data['monitor_not_init'] <= 0 ? '-' : $data['monitor_not_init']; $tdata[1] = ''.$tdata[1].''; @@ -12210,7 +12305,7 @@ function reporting_get_stats_agents_monitors($data) $table_am = html_get_predefined_table(); $tdata = []; - $tdata[0] = html_print_image('images/agent.png', true, ['title' => __('Total agents'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[0] = html_print_image('images/agents@svg.svg', true, ['title' => __('Total agents'), 'class' => 'invert_filter main_menu_icon'], false, false, false, true); $tdata[1] = $data['total_agents'] <= 0 ? '-' : $data['total_agents']; $tdata[1] = ''.$tdata[1].''; @@ -12221,10 +12316,10 @@ function reporting_get_stats_agents_monitors($data) */ if ($data['total_agents'] > 500 && !enterprise_installed()) { - $tdata[2] = "
    "; + $tdata[2] = "
    "; } - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Monitor checks'), 'class' => 'invert_filter'], false, false, false, true); + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Monitor checks'), 'class' => 'main_menu_icon invert_filter'], false, false, false, true); $tdata[4] = $data['monitor_total'] <= 0 ? '-' : $data['monitor_total']; $tdata[4] = ''.$tdata[4].''; @@ -12235,7 +12330,7 @@ function reporting_get_stats_agents_monitors($data) */ if ($data['total_agents']) { if (($data['monitor_total'] / $data['total_agents'] > 100) && !enterprise_installed()) { - $tdata[5] = "
    "; + $tdata[5] = "
    "; } } @@ -12265,7 +12360,7 @@ function reporting_get_stats_users($data) $table_us = html_get_predefined_table(); $tdata = []; - $tdata[0] = html_print_image('images/user.png', true, ['title' => __('Defined users'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/user.svg', true, ['title' => __('Defined users'), 'class' => 'main_menu_icon invert_filter']); $user_is_admin = users_is_admin(); $users = []; @@ -14541,10 +14636,10 @@ function reporting_get_stats_servers() $table_srv->style[1] = $table_srv->style[3] = 'text-align: left; padding: 5px;'; $tdata = []; - $tdata[0] = html_print_image('images/module.png', true, ['title' => __('Total running modules'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/modules@svg.svg', true, ['title' => __('Total running modules'), 'class' => 'main_menu_icon invert_filter']); $tdata[1] = ''.format_numeric($server_performance['total_modules']).''; $tdata[2] = ''.format_numeric($server_performance['total_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'invert_filter']).'/sec '; + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'main_menu_icon invert_filter']).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -14556,25 +14651,25 @@ function reporting_get_stats_servers() $table_srv->data[] = $tdata; $tdata = []; - $tdata[0] = html_print_image('images/database.png', true, ['title' => __('Local modules'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/data-server@svg.svg', true, ['title' => __('Local modules'), 'class' => 'main_menu_icon invert_filter']); $tdata[1] = ''.format_numeric($server_performance['total_local_modules']).''; $tdata[2] = ''.format_numeric($server_performance['local_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'invert_filter']).'/sec '; + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'main_menu_icon invert_filter']).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; if (isset($server_performance['total_network_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/network.png', true, ['title' => __('Network modules'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/network@svg.svg', true, ['title' => __('Network modules'), 'class' => 'main_menu_icon invert_filter']); $tdata[1] = ''.format_numeric($server_performance['total_network_modules']).''; $tdata[2] = ''.format_numeric($server_performance['network_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'invert_filter']).'/sec '; + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'main_menu_icon invert_filter']).'/sec '; if ($server_performance['total_remote_modules'] > 10000 && !enterprise_installed()) { - $tdata[4] = "
    "; + $tdata[4] = "
    "; } else { $tdata[4] = ' '; } @@ -14585,11 +14680,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_plugin_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/plugin.png', true, ['title' => __('Plugin modules'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/plugins@svg.svg', true, ['title' => __('Plugin modules'), 'class' => 'main_menu_icon invert_filter']); $tdata[1] = ''.format_numeric($server_performance['total_plugin_modules']).''; $tdata[2] = ''.format_numeric($server_performance['plugin_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'invert_filter']).'/sec '; + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'main_menu_icon invert_filter']).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -14597,11 +14692,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_prediction_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/chart_bar.png', true, ['title' => __('Prediction modules'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/prediction@svg.svg', true, ['title' => __('Prediction modules'), 'class' => 'main_menu_icon invert_filter']); $tdata[1] = ''.format_numeric($server_performance['total_prediction_modules']).''; $tdata[2] = ''.format_numeric($server_performance['prediction_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'invert_filter']).'/sec '; + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'main_menu_icon invert_filter']).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -14609,11 +14704,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_wmi_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/wmi.png', true, ['title' => __('WMI modules'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/WMI@svg.svg', true, ['title' => __('WMI modules'), 'class' => 'main_menu_icon invert_filter']); $tdata[1] = ''.format_numeric($server_performance['total_wmi_modules']).''; $tdata[2] = ''.format_numeric($server_performance['wmi_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'invert_filter']).'/sec '; + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'main_menu_icon invert_filter']).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -14621,11 +14716,11 @@ function reporting_get_stats_servers() if (isset($server_performance['total_web_modules'])) { $tdata = []; - $tdata[0] = html_print_image('images/world.png', true, ['title' => __('Web modules'), 'class' => 'invert_filter']); + $tdata[0] = html_print_image('images/web-analisys-data@svg.svg', true, ['title' => __('Web modules'), 'class' => 'main_menu_icon invert_filter']); $tdata[1] = ''.format_numeric($server_performance['total_web_modules']).''; $tdata[2] = ''.format_numeric($server_performance['web_modules_rate'], 2).''; - $tdata[3] = html_print_image('images/module.png', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'invert_filter']).'/sec '; + $tdata[3] = html_print_image('images/modules@svg.svg', true, ['title' => __('Ratio').': '.__('Modules by second'), 'class' => 'main_menu_icon invert_filter']).'/sec '; $table_srv->rowclass[] = ''; $table_srv->data[] = $tdata; @@ -14639,17 +14734,17 @@ function reporting_get_stats_servers() $tdata = []; $tdata[0] = html_print_image( - 'images/lightning_go.png', + 'images/event.svg', true, [ 'title' => __('Total events'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $tdata[1] = ''.html_print_image('images/spinner.gif', true).''; if (isset($system_events) && $system_events > 50000 && !enterprise_installed()) { - $tdata[2] = "
    "; + $tdata[2] = "
    "; } else { $tdata[3] = ' '; } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 8d709a1003..59140ac1a2 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -532,6 +532,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) if (isset($item['data']) === true) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->align = []; $table1->align[0] = 'left'; @@ -567,6 +568,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) // Second_table for time globals. $table2 = new stdClass(); $table2->width = '99%'; + $table2->class = 'info_table'; $table2->align = []; $table2->align[0] = 'left'; @@ -600,6 +602,7 @@ function reporting_html_SLA($table, $item, $mini, $pdf=0) // Third_table for time globals. $table3 = new stdClass(); $table3->width = '99%'; + $table3->class = 'info_table'; $table3->align = []; $table3->align[0] = 'left'; @@ -926,6 +929,7 @@ function reporting_html_top_n($table, $item, $pdf=0) } else { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->align = []; $table1->align[0] = 'left'; @@ -1034,6 +1038,7 @@ function reporting_html_event_report_group($table, $item, $pdf=0) if ($item['total_events']) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->align = []; $table1->align[0] = 'center'; @@ -1305,6 +1310,7 @@ function reporting_html_event_report_module($table, $item, $pdf=0) foreach ($item['data'] as $item) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->data = []; $table1->head = []; $table1->align = []; @@ -1531,7 +1537,7 @@ function reporting_html_agents_inventory($table, $item, $pdf=0) $table1->width = '100%'; $table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;'; - $table1->class = 'databox data'; + $table1->class = 'info_table'; $table1->cellpadding = 1; $table1->cellspacing = 1; $table1->styleTable = 'overflow: wrap; table-layout: fixed;'; @@ -1551,6 +1557,57 @@ function reporting_html_agents_inventory($table, $item, $pdf=0) $table1->head = []; + // Sort array columns. + $tmp_sort_array = []; + foreach ($item['data'] as $data_key => $data_value) { + if (array_key_exists('alias', $data_value) === true) { + $tmp_sort_array['alias'] = $data_value['alias']; + } + + if (array_key_exists('direccion', $data_value) === true) { + $tmp_sort_array['direccion'] = $data_value['direccion']; + } + + if (array_key_exists('id_os', $data_value) === true) { + $tmp_sort_array['id_os'] = $data_value['id_os']; + } + + if (array_key_exists('agent_version', $data_value) === true) { + $tmp_sort_array['agent_version'] = $data_value['agent_version']; + } + + if (array_key_exists('id_grupo', $data_value) === true) { + $tmp_sort_array['id_grupo'] = $data_value['id_grupo']; + } + + if (array_key_exists('comentarios', $data_value) === true) { + $tmp_sort_array['comentarios'] = $data_value['comentarios']; + } + + if (array_key_exists('url_address', $data_value) === true) { + $tmp_sort_array['url_address'] = $data_value['url_address']; + } + + if (array_key_exists('remote', $data_value) === true) { + $tmp_sort_array['remote'] = $data_value['remote']; + } + + if (array_key_exists('secondary_groups', $data_value) === true) { + $tmp_sort_array['secondary_groups'] = $data_value['secondary_groups']; + } + + if (array_key_exists('custom_fields', $data_value) === true) { + $tmp_sort_array['custom_fields'] = $data_value['custom_fields']; + } + + if (array_key_exists('estado', $data_value) === true) { + $tmp_sort_array['estado'] = $data_value['estado']; + } + + unset($item['data'][$data_key]); + $item['data'][$data_key] = $tmp_sort_array; + } + foreach ($item['data'][0] as $field_key => $field_value) { switch ($field_key) { case 'alias': @@ -1632,7 +1689,7 @@ function reporting_html_agents_inventory($table, $item, $pdf=0) } else if ($data_field_key === 'estado') { $column_value = ($pdf === 0) ? ui_print_module_status((int) $data_field_value, true) : modules_get_modules_status((int) $data_field_value); } else if ($data_field_key === 'id_grupo') { - $column_value = ui_print_group_icon((int) $data_field_value, true, 'groups_small', '', $show_link); + $column_value = groups_get_name((int) $data_field_value); } else if ($data_field_key === 'custom_fields') { $custom_fields_value = []; @@ -1648,7 +1705,7 @@ function reporting_html_agents_inventory($table, $item, $pdf=0) if (is_array($data_field_value)) { foreach ($data_field_value as $value) { - $custom_fields_value[] = ui_print_group_icon((int) $value['id_group'], true, 'groups_small', '', $show_link); + $custom_fields_value[] = groups_get_name((int) $value['id_group']); } } @@ -1698,26 +1755,57 @@ function reporting_html_modules_inventory($table, $item, $pdf=0) $table1->width = '100%'; $table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;'; - $table1->class = 'databox data'; + $table1->class = 'info_table'; $table1->cellpadding = 1; $table1->cellspacing = 1; $table1->styleTable = 'overflow: wrap; table-layout: fixed;'; $table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;'; $table1->style[1] = 'text-align: left;vertical-align: top;min-width: 100px;'; - $table1->style[2] = 'text-align: left;vertical-align: top; min-width: 100px'; + $table1->style[2] = 'text-align: left;vertical-align: top;min-width: 100px;'; $table1->style[3] = 'text-align: left;vertical-align: top;min-width: 100px;'; $table1->style[4] = 'text-align: left;vertical-align: top;min-width: 100px;'; - $table1->style[5] = 'text-align: left;vertical-align: top; min-width: 100px'; + $table1->style[5] = 'text-align: left;vertical-align: top;min-width: 100px;'; + $table1->style[6] = 'text-align: left;vertical-align: top;min-width: 100px;'; + $table1->style[7] = 'text-align: left;vertical-align: top;min-width: 100px;'; $table1->head = []; + $first_index = array_key_first($item['data']); - $table1->head[] = __('Name'); - $table1->head[] = __('Description'); - $table1->head[] = __('Module group'); - $table1->head[] = __('Tags'); - $table1->head[] = __('Agent group'); - $table1->head[] = __('Agent secondary groups'); + foreach ($item['data'][$first_index] as $field_key => $field_value) { + switch ($field_key) { + case 'alias': + $table1->head[] = __('Alias'); + break; + + case 'nombre': + $table1->head[] = __('Name'); + break; + + case 'descripcion': + $table1->head[] = __('Description'); + break; + + case 'id_module_group': + $table1->head[] = __('Module group'); + break; + + case 'id_tag': + $table1->head[] = __('Tags'); + break; + + case 'group_id': + $table1->head[] = __('Agent group'); + break; + + case 'sec_group_id': + $table1->head[] = __('Agent secondary groups'); + break; + + case 'last_status_change': + $table1->head[] = __('Last status change'); + } + } $table1->headstyle[0] = 'text-align: left'; $table1->headstyle[1] = 'text-align: left'; @@ -1725,15 +1813,20 @@ function reporting_html_modules_inventory($table, $item, $pdf=0) $table1->headstyle[3] = 'text-align: left'; $table1->headstyle[4] = 'text-align: left'; $table1->headstyle[5] = 'text-align: left'; + $table1->headstyle[6] = 'text-align: left'; + $table1->headstyle[7] = 'text-align: left'; $table1->data = []; foreach ($item['data'] as $module_id => $module_data) { + unset($module_data['server_id']); $row = []; $first_item = array_pop(array_reverse($module_data)); foreach ($module_data as $data_field_key => $data_field_value) { - if ($data_field_key === 'nombre') { + if ($data_field_key === 'alias') { + $column_value = $data_field_value; + } else if ($data_field_key === 'nombre') { $column_value = $data_field_value; } else if ($data_field_key === 'descripcion') { $column_value = $data_field_value; @@ -1746,13 +1839,27 @@ function reporting_html_modules_inventory($table, $item, $pdf=0) $column_value = $module_group_name; } else if ($data_field_key === 'id_tag') { - $tags_names = array_map( - function ($tag_id) { - return db_get_value('name', 'ttag', 'id_tag', $tag_id); - }, - $data_field_value - ); - $column_value = implode('
    ', $tags_names); + if (empty($data_field_value[0]) === false) { + $sql = 'SELECT name + FROM ttag + WHERE id_tag IN ('.$data_field_value[0].')'; + + $tags_rows = db_get_all_rows_sql($sql); + $tags_names = []; + foreach ($tags_rows as $tag_row) { + array_push($tags_names, $tag_row['name']); + } + + $column_value = implode('
    ', $tags_names); + } else { + $tags_names = array_map( + function ($tag_id) { + return db_get_value('name', 'ttag', 'id_tag', $tag_id); + }, + $data_field_value + ); + $column_value = implode('
    ', $tags_names); + } } else if ($data_field_key === 'group_id') { $column_value = groups_get_name($data_field_value[0]); } else if ($data_field_key === 'sec_group_id') { @@ -1764,6 +1871,8 @@ function reporting_html_modules_inventory($table, $item, $pdf=0) ); $column_value = implode('
    ', $sec_groups_names); + } else if ($data_field_key === 'last_status_change') { + $column_value = $data_field_value; } $row[] = $column_value; @@ -1816,6 +1925,7 @@ function reporting_html_inventory_changes($table, $item, $pdf=0) foreach ($item['data'] as $module_item) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->cellstyle = []; $table1->cellstyle[0][0] = 'background: #373737; color: #FFF;'; @@ -1910,6 +2020,7 @@ function reporting_html_inventory($table, $item, $pdf=0) foreach ($type_modules as $key_type_module => $type_module) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->data = []; $table1->head = []; $table1->cellstyle = []; @@ -2000,7 +2111,7 @@ function reporting_html_agent_module($table, $item) if (!empty($item['failed'])) { $table->data['agent_module']['cell'] = $item['failed']; } else { - $table_data = '
    + logo +

    '.$product_name.'

    '.__('Version').' '.$pandora_version.' - '.(enterprise_installed() ? 'Enterprise' : 'Community').'

    '.__('MR version').' MR'.$config['MR'].'

    '.__('Build').' '.$build_version.'

    '.__('Support expires').' 2023/04/26

    '; - if ((bool) check_acl($config['id_user'], 0, 'PM') === true) { - $dialog .= ' -
    - - -
    - '; + + if (((bool) check_acl($config['id_user'], 0, 'PM') === true) && (is_metaconsole() === false)) { + $dialogButtons = []; + + $dialogButtons[] = html_print_button( + __('Update manager'), + 'update_manager', + false, + 'location.href="'.ui_get_full_url('/index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=history', false, false, false).'"', + [ + 'icon' => 'cog', + 'mode' => 'mini secondary', + ], + true + ); + + $dialogButtons[] = html_print_button( + __('System report'), + 'system_report', + false, + 'location.href="'.ui_get_full_url('/index.php?sec=gextensions&sec2=tools/diagnostics', false, false, false).'"', + [ + 'icon' => 'info', + 'mode' => 'mini secondary', + ], + true + ); + + $dialog .= html_print_div( + [ + 'style' => 'flex-direction: row;', + 'class' => 'action-buttons', + 'content' => implode('', $dialogButtons), + ], + true + ); } $dialog .= '
    '; + $table_data = '
    '; $table_data .= ''; $table_data .= ''; @@ -2349,6 +2460,7 @@ function reporting_html_exception($table, $item, $pdf=0) } else { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->align = []; $table1->align['agent'] = 'left'; @@ -2466,7 +2578,7 @@ function reporting_html_group_report($table, $item, $pdf=0) $table->colspan['group_report']['cell'] = 3; $table->cellstyle['group_report']['cell'] = 'text-align: center;'; - $data = "
    '.__('Agents').' / '.__('Modules').'
    + $data = "
    @@ -2528,6 +2640,7 @@ function reporting_html_event_report_agent($table, $item, $pdf=0) if ($item['total_events'] != 0) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->align = []; $table1->align[0] = 'center'; $table1->align[1] = 'center'; @@ -2750,6 +2863,7 @@ function reporting_html_historical_data($table, $item, $pdf=0) $table1 = new stdClass(); $table1->width = '100%'; + $table1->class = 'info_table'; $table1->head = [ __('Date'), __('Data'), @@ -2834,6 +2948,7 @@ function reporting_html_database_serialized($table, $item, $pdf=0) $table1 = new stdClass(); $table1->width = '100%'; + $table1->class = 'info_table'; $table1->head = [ __('Date'), __('Data'), @@ -2902,6 +3017,7 @@ function reporting_html_last_value($table, $item, $pdf=0) if (empty($item['data']) === false) { $table_data = new stdClass(); $table_data->width = '100%'; + $table_data->class = 'info_table'; $table_data->headstyle = []; $table_data->headstyle[0] = 'text-align: left;'; $table_data->style = []; @@ -3064,6 +3180,7 @@ function reporting_html_group_configuration($table, $item, $pdf=0) if ($pdf === 0) { $table2 = new stdClass(); $table2->width = '100%'; + $table2->class = 'info_table'; $table2->data = []; reporting_html_agent_configuration( $table2, @@ -3214,6 +3331,7 @@ function reporting_html_network_interfaces_report($table, $item, $pdf=0) foreach ($item['data'] as $agent) { $table_agent = new StdCLass(); $table_agent->width = '100%'; + $table_agent->class = 'info_table'; $table_agent->data = []; $table_agent->head = []; $table_agent->head[0] = __('Agent').' '.$agent['agent']; @@ -3337,6 +3455,7 @@ function reporting_html_alert_report($table, $item, $pdf=0) $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->head = []; $table1->data = []; $table1->rowspan = []; @@ -3461,6 +3580,7 @@ function reporting_html_monitor_report($table, $item, $mini, $pdf=0) $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->head = []; $table1->data = []; if ($item['data']['unknown'] == 1) { @@ -3560,6 +3680,7 @@ function reporting_html_agent_configuration( $table1 = new stdClass(); $table1->width = '99%'; $table1->head = []; + $table1->class = 'info_table'; $table1->head['name'] = __('Agent name'); $table1->head['group'] = __('Group'); $table1->head['os'] = __('OS'); @@ -3734,6 +3855,7 @@ function reporting_html_value( ) { $table2 = new stdClass(); $table2->width = '100%'; + $table2->class = 'info_table'; switch ($item['type']) { case 'max_value': $table2->head = [ @@ -4040,6 +4162,7 @@ function reporting_html_availability($table, $item, $pdf=0) if (empty($item['data']) === false) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->data = []; $table1->head = []; @@ -4623,6 +4746,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) ) { $table1 = new stdClass(); $table1->width = '100%'; + $table1->class = 'info_table'; $table1->autosize = 1; $table1->styleTable = 'overflow: wrap; table-layout: fixed;'; $table1->data = []; @@ -4643,7 +4767,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table1->data[$k_chart][0] .= ' (24 x 7)'; } - $total_values += $sla_value; + $total_values .= $sla_value; $count_total_charts++; $table1->data[$k_chart][1] = $chart['chart']; $table1->data[$k_chart][2] = "".$sla_value.'
    '; @@ -4720,7 +4844,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) case 'result': default: - $total_values += $sla_value; + $total_values .= $sla_value; $count_total_charts++; $title = ''.__('Result').''; $sla_value_text = "".$sla_value.''; @@ -4864,6 +4988,7 @@ function reporting_html_general($table, $item, $pdf=0) if (!$data_in_same_row) { $table1 = new stdClass(); $table1->width = '99%'; + $table1->class = 'info_table'; $table1->data = []; $table1->head = []; $table1->head[0] = __('Agent'); @@ -5065,7 +5190,7 @@ function reporting_html_sql($table, $item, $pdf=0) $first = true; $table2 = new stdClass(); - $table2->class = 'databox'; + $table2->class = 'info_table'; $table2->width = '100%'; foreach ($item['data'] as $row) { @@ -5763,7 +5888,7 @@ function reporting_get_agents_by_status($data, $graph_width=250, $graph_height=1 $agent_data = []; $agent_data[0] = html_print_image('images/agent_ok.png', true, ['title' => __('Agents ok')]); - $agent_data[1] = "".format_numeric($data['agent_ok']).''; + $agent_data[1] = "".format_numeric($data['agent_ok']).''; $agent_data[2] = html_print_image('images/agent_unknown.png', true, ['title' => __('Agents unknown')]); $agent_data[3] = "".format_numeric($data['agent_unknown']).''; @@ -5883,7 +6008,7 @@ function reporting_get_events($data, $links=false) $table_events->data[0][1] = html_print_image('images/module_warning.png', true, ['title' => __('Warning events')]); $table_events->data[0][1] .= '   '."".format_numeric($data['warning']).''; $table_events->data[0][2] = html_print_image('images/module_ok.png', true, ['title' => __('OK events')]); - $table_events->data[0][2] .= '   '."".format_numeric($data['normal']).''; + $table_events->data[0][2] .= '   '."".format_numeric($data['normal']).''; $table_events->data[0][3] = html_print_image('images/module_unknown.png', true, ['title' => __('Unknown events')]); $table_events->data[0][3] .= '   '."".format_numeric($data['unknown']).''; } @@ -6372,7 +6497,7 @@ function reporting_html_permissions($table, $item, $pdf=0) $table1->width = '100%'; $table1->style[0] = 'text-align: left;vertical-align: top;min-width: 100px;'; - $table1->class = 'databox data'; + $table1->class = 'info_table'; $table1->cellpadding = 1; $table1->cellspacing = 1; $table1->styleTable = 'overflow: wrap; table-layout: fixed;'; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 0d39f5b916..41356e9455 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -1059,7 +1059,7 @@ function get_table_custom_macros_report($data) $table = new StdClass(); $table->data = []; $table->width = '100%'; - $table->class = 'databox data fullwidth'; + $table->class = 'info_table'; $table->id = 'table-macros-definition'; $table->rowclass = []; diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 3f9fe1a6b2..649df85725 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -550,11 +550,11 @@ function servers_get_info($id_server=-1) switch ($server['server_type']) { case SERVER_TYPE_DATA: $server['img'] = html_print_image( - 'images/database.png', + 'images/data-server@svg.svg', true, [ 'title' => __('Data server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'data'; @@ -563,11 +563,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_NETWORK: $server['img'] = html_print_image( - 'images/network.png', + 'images/network-server@os.svg', true, [ 'title' => __('Network server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'network'; @@ -576,11 +576,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_SNMP: $server['img'] = html_print_image( - 'images/snmp.png', + 'images/snmp-trap@svg.svg', true, [ 'title' => __('SNMP Trap server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'snmp'; @@ -589,11 +589,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_DISCOVERY: $server['img'] = html_print_image( - 'images/recon.png', + 'images/rrs@svg.svg', true, [ 'title' => __('Discovery server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'recon'; @@ -602,11 +602,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_PLUGIN: $server['img'] = html_print_image( - 'images/plugin.png', + 'images/plugins@svg.svg', true, [ 'title' => __('Plugin server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'plugin'; @@ -615,11 +615,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_PREDICTION: $server['img'] = html_print_image( - 'images/chart_bar.png', + 'images/prediction@svg.svg', true, [ 'title' => __('Prediction server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'prediction'; @@ -628,11 +628,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_WMI: $server['img'] = html_print_image( - 'images/wmi.png', + 'images/WMI@svg.svg', true, [ 'title' => __('WMI server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'wmi'; @@ -641,11 +641,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_EXPORT: $server['img'] = html_print_image( - 'images/server_export.png', + 'images/server-export@svg.svg', true, [ 'title' => __('Export server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'export'; @@ -654,11 +654,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_INVENTORY: $server['img'] = html_print_image( - 'images/page_white_text.png', + 'images/hardware-software-component@svg.svg', true, [ 'title' => __('Inventory server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'inventory'; @@ -667,11 +667,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_WEB: $server['img'] = html_print_image( - 'images/world.png', + 'images/server-web@svg.svg', true, [ 'title' => __('Web server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'web'; @@ -680,11 +680,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_EVENT: $server['img'] = html_print_image( - 'images/lightning_go.png', + 'images/server-events@svg.svg', true, [ 'title' => __('Event server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'event'; @@ -693,11 +693,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_CORRELATION: $server['img'] = html_print_image( - 'images/lightning_go.png', + 'images/server-events@svg.svg', true, [ 'title' => __('Correlation server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'correlation'; @@ -706,11 +706,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_ENTERPRISE_ICMP: $server['img'] = html_print_image( - 'images/network.png', + 'images/network@svg.svg', true, [ 'title' => __('Enterprise ICMP server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'enterprise icmp'; @@ -719,11 +719,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_ENTERPRISE_SNMP: $server['img'] = html_print_image( - 'images/network.png', + 'images/network@svg.svg', true, [ 'title' => __('Enterprise SNMP server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'enterprise snmp'; @@ -732,11 +732,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_ENTERPRISE_SATELLITE: $server['img'] = html_print_image( - 'images/satellite.png', + 'images/satellite@os.svg', true, [ 'title' => __('Enterprise Satellite server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'enterprise satellite'; @@ -745,11 +745,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: $server['img'] = html_print_image( - 'images/transactional_map.png', + 'images/server-transactions@svg.svg', true, [ 'title' => __('Enterprise Transactional server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'enterprise transactional'; @@ -758,11 +758,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_MAINFRAME: $server['img'] = html_print_image( - 'images/mainframe.png', + 'images/mainframe@os.svg', true, [ 'title' => __('Mainframe server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'mainframe'; @@ -775,7 +775,7 @@ function servers_get_info($id_server=-1) true, [ 'title' => __('Sync server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'sync'; @@ -784,11 +784,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_WUX: $server['img'] = html_print_image( - 'images/icono-wux.png', + 'images/wux@svg.svg', true, [ 'title' => __('Wux server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'wux'; @@ -797,11 +797,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_SYSLOG: $server['img'] = html_print_image( - 'images/syslog.png', + 'images/logs@svg.svg', true, [ 'title' => __('Log server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'syslog'; @@ -810,11 +810,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_NCM: $server['img'] = html_print_image( - 'images/book_edit.png', + 'images/custom-input@svg.svg', true, [ 'title' => __('NCM server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'ncm'; @@ -827,7 +827,7 @@ function servers_get_info($id_server=-1) true, [ 'title' => __('Autoprovision server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'autoprovision'; @@ -836,11 +836,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_MIGRATION: $server['img'] = html_print_image( - 'images/migration.png', + 'images/server-export@svg.svg', true, [ 'title' => __('Migration server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'migration'; @@ -849,11 +849,11 @@ function servers_get_info($id_server=-1) case SERVER_TYPE_ALERT: $server['img'] = html_print_image( - 'images/alerts_extern.png', + 'images/alert@svg.svg', true, [ 'title' => __('Alert server'), - 'class' => 'invert_filter', + 'class' => 'main_menu_icon invert_filter', ] ); $server['type'] = 'alert'; @@ -1152,108 +1152,6 @@ function servers_check_remote_config($server_name) } -/** - * Return a string containing image tag for a given target id (server). - * TODO: Make this print_servertype_icon and move to functions_ui.php. - * Make XHTML compatible. Make string translatable. - * - * @param integer $id Server type id. - * - * @deprecated Use print_servertype_icon instead. - * - * @return string Fully formatted IMG HTML tag with icon. - */ -function servers_show_type($id) -{ - global $config; - - switch ($id) { - case 1: - $return = html_print_image( - 'images/database.png', - true, - [ - 'title' => get_product_name().' Data server', - 'class' => 'invert_filter', - ] - ); - break; - - case 2: - $return = html_print_image( - 'images/network.png', - true, - [ - 'title' => get_product_name().' Network server', - 'class' => 'invert_filter', - ] - ); - break; - - case 4: - $return = html_print_image( - 'images/plugin.png', - true, - [ - 'title' => get_product_name().' Plugin server', - 'class' => 'invert_filter', - ] - ); - break; - - case 5: - $return = html_print_image( - 'images/chart_bar.png', - true, - [ - 'title' => get_product_name().' Prediction server', - 'class' => 'invert_filter', - ] - ); - break; - - case 6: - $return = html_print_image( - 'images/wmi.png', - true, - [ - 'title' => get_product_name().' WMI server', - 'class' => 'invert_filter', - ] - ); - break; - - case 7: - $return = html_print_image( - 'images/server_web.png', - true, - [ - 'title' => get_product_name().' WEB server', - 'class' => 'invert_filter', - ] - ); - break; - - case 8: - $return = html_print_image( - 'images/module-wux.png', - true, - [ - 'title' => get_product_name().' WUX server', - 'class' => 'invert_filter', - ] - ); - break; - - default: - $return = '--'; - break; - } - - return $return; -} - - /** * Get the numbers of servers up. * diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index b97f6cc313..0e51faa66c 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -144,7 +144,7 @@ function snmp_browser_get_html_tree( // Branch or leave with branches! if (isset($sub_level['__OID__'])) { $output .= ""; - $output .= ''; + $output .= ''; $output .= ''; } @@ -612,8 +612,8 @@ function snmp_browser_print_oid( $table->head[1] = __('OID Information'); $output .= html_print_table($table, true); - $url = 'index.php?'.'sec=gmodules&'.'sec2=godmode/modules/manage_network_components'; - $output .= '
    '; + $url = 'index.php?sec=gmodules&sec2=godmode/modules/manage_network_components'; + $output .= ''; $output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true); $output .= html_print_input_hidden('id_component_type', 2, true); $output .= html_print_input_hidden('type', 17, true); @@ -638,19 +638,21 @@ function snmp_browser_print_oid( __('Create network component'), 'create_network_component', false, - 'class="sub add float-left mrgn_right_20px"', + 'class="buttonButton mrgn_right_20px"', true ); - // Hidden by default. - $output .= html_print_button( - __('Create agent module'), - 'create_module_agent_single', - false, - 'show_add_module()', - 'class="sub add invisible"', - true - ); + if (isset($_POST['print_create_agent_module'])) { + // Hidden by default. + $output .= html_print_button( + __('Create agent module'), + 'create_module_agent_single', + false, + 'show_add_module()', + 'class="sub add invisible"', + true + ); + } // Select agent modal. $output .= snmp_browser_print_create_modules(true); @@ -685,81 +687,98 @@ function snmp_browser_print_container( $width='100%', $height='60%', $display='', - $show_massive_buttons=false + $show_massive_buttons=false, + $toggle=false ) { global $config; $snmp_version = get_parameter('snmp_browser_version', '2c'); + // Target selection. $table = new stdClass(); $table->width = '100%'; - $table->class = 'databox filters'; + $table->class = 'filter-table-adv'; $table->size = []; $table->data = []; $table->size[0] = '30%'; + $table->size[1] = '30%'; + $table->size[2] = '30%'; - $table->data[0][0] = '
    '.__('Target IP').'   '; - $table->data[0][0] .= html_print_input( - [ - 'type' => 'text', - 'name' => 'target_ip', - 'value' => get_parameter('target_ip', ''), - 'required' => true, - 'size' => 25, - 'maxlength' => 0, - 'return' => true, - ] - ); - $table->data[0][0] .= '  '.__('Port').'  '; - $table->data[0][0] .= html_print_input( - [ - 'type' => 'number', - 'name' => 'target_port', - 'id' => 'target_port', - 'value' => get_parameter('target_port', 161), - 'required' => true, - 'return' => true, - ] - ); - $table->data[0][0] .= '
    '; - - $table->data[0][1] = ''.__('Community').'   '; - $table->data[0][1] .= html_print_input_text( - 'community', - get_parameter('community', ''), - '', - 25, - 0, - true - ); - $table->data[0][2] = ''.__('Starting OID').'   '; - $table->data[0][2] .= html_print_input_text( - 'starting_oid', - get_parameter('starting_oid', '.1.3.6.1.2.1.2.2'), - '', - 25, - 0, - true + $table->data[0][0] = html_print_label_input_block( + __('Target IP'), + html_print_input( + [ + 'type' => 'text', + 'name' => 'target_ip', + 'value' => get_parameter('target_ip', ''), + 'required' => true, + 'size' => 25, + 'maxlength' => 0, + 'return' => true, + ] + ) ); - $table->data[1][0] = ''.__('Version').'   '; - $table->data[1][0] .= html_print_select( - [ - '1' => 'v. 1', - '2' => 'v. 2', - '2c' => 'v. 2c', - '3' => 'v. 3', - ], - 'snmp_browser_version', - get_parameter('snmp_browser_version', '2c'), - 'checkSNMPVersion();', - '', - '', - true, - false, - false, - '' + $table->data[0][1] .= html_print_label_input_block( + __('Port'), + html_print_input( + [ + 'type' => 'number', + 'name' => 'target_port', + 'id' => 'target_port', + 'value' => get_parameter('target_port', 161), + 'required' => true, + 'return' => true, + ] + ) + ); + + $table->data[0][2] = html_print_label_input_block( + __('Community'), + html_print_input_text( + 'community', + get_parameter('community', ''), + '', + 25, + 0, + true + ) + ); + + $table->data[1][0] = html_print_label_input_block( + __('Starting OID'), + html_print_input_text( + 'starting_oid', + get_parameter('starting_oid', '.1.3.6.1.2.1.2.2'), + '', + 25, + 0, + true + ) + ); + + $table->data[1][1] = html_print_label_input_block( + __('Version'), + html_print_select( + [ + '1' => 'v. 1', + '2' => 'v. 2', + '2c' => 'v. 2c', + '3' => 'v. 3', + ], + 'snmp_browser_version', + get_parameter('snmp_browser_version', '2c'), + 'checkSNMPVersion();', + '', + '', + true, + false, + false, + '', + false, + 'width: 100%', + ) ); $servers_to_exec = []; @@ -782,31 +801,22 @@ function snmp_browser_print_container( } } - $table->data[1][1] = ''; - $table->data[1][1] .= __('Server to execute'); - $table->data[1][1] .= '   '; - $table->data[1][1] .= html_print_select( - $servers_to_exec, - 'server_to_exec', - '', - '', - '', - '', - true - ); - - $table->data[1][2] = html_print_input( - [ - 'type' => 'submit', - 'label' => __('Browse'), - 'name' => 'browse', - 'disabled' => false, - 'script' => 'snmpBrowse()', - 'attributes' => 'class="sub search mrgn_top_0px"', - 'return' => true, - ], - 'div', - true + $table->data[1][2] = html_print_label_input_block( + __('Server to execute'), + html_print_select( + $servers_to_exec, + 'server_to_exec', + '', + '', + '', + '', + true, + false, + false, + '', + false, + 'width: 100%', + ) ); // SNMP v3 options. @@ -819,88 +829,176 @@ function snmp_browser_print_container( $table3 = new stdClass(); $table3->width = '100%'; + $table3->class = 'filter-table-adv'; - $table3->valign[0] = ''; - $table3->valign[1] = ''; + $table3->size[0] = '30%'; + $table3->size[1] = '30%'; + $table3->size[2] = '30%'; - $table3->data[2][1] = ''.__('Auth user').''; - $table3->data[2][2] = html_print_input_text( - 'snmp3_browser_auth_user', - $snmp3_auth_user, - '', - 15, - 60, - true + $table3->data[0][0] = html_print_label_input_block( + __('Auth user'), + html_print_input_text( + 'snmp3_browser_auth_user', + $snmp3_auth_user, + '', + 15, + 60, + true + ) ); - $table3->data[2][3] = ''.__('Auth password').''; - $table3->data[2][4] = html_print_input_password( - 'snmp3_browser_auth_pass', - $snmp3_auth_pass, - '', - 15, - 60, - true + $table3->data[0][1] = html_print_label_input_block( + __('Auth password'), + '
    '.html_print_input_password( + 'snmp3_browser_auth_pass', + $snmp3_auth_pass, + '', + 15, + 60, + true + ).'
    ' ); - $table3->data[2][4] .= html_print_input_hidden_extended( + $table3->data[0][1] .= html_print_input_hidden_extended( 'active_snmp_v3', 0, 'active_snmp_v3_fsb', true ); - $table3->data[5][0] = ''.__('Privacy method').''; - $table3->data[5][1] = html_print_select( + $table3->data[0][2] = html_print_label_input_block( + __('Privacy method'), + html_print_select( + [ + 'DES' => __('DES'), + 'AES' => __('AES'), + ], + 'snmp3_browser_privacy_method', + $snmp3_privacy_method, + '', + '', + '', + true + ) + ); + + $table3->data[1][0] = html_print_label_input_block( + __('Privacy pass'), + '
    '.html_print_input_password( + 'snmp3_browser_privacy_pass', + $snmp3_privacy_pass, + '', + 15, + 60, + true + ).'
    ' + ); + + $table3->data[1][1] = html_print_label_input_block( + __('Auth method'), + html_print_select( + [ + 'MD5' => __('MD5'), + 'SHA' => __('SHA'), + ], + 'snmp3_browser_auth_method', + $snmp3_auth_method, + '', + '', + '', + true + ) + ); + + $table3->data[1][2] = html_print_label_input_block( + __('Security level'), + html_print_select( + [ + 'noAuthNoPriv' => __('Not auth and not privacy method'), + 'authNoPriv' => __('Auth and not privacy method'), + 'authPriv' => __('Auth and privacy method'), + ], + 'snmp3_browser_security_level', + $snmp3_security_level, + '', + '', + '', + true + ) + ); + + if (isset($snmp_version) === false) { + $snmp_version = null; + } + + if ($snmp_version == 3) { + $table->data[2] = '
    '; + } else { + $table->data[2] = ''; + + if ($toggle == true) { + $print_create_agent_module = 1; + } else { + $print_create_agent_module = 0; + } + + $searchForm = ''; + $searchForm .= html_print_table($table, true); + $searchForm .= html_print_input_hidden( + 'print_create_agent_module', + $print_create_agent_module, + true, + false, + false, + 'print_create_agent_module' + ); + $searchForm .= html_print_div( [ - 'DES' => __('DES'), - 'AES' => __('AES'), + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Execute'), + 'srcbutton', + false, + [ + 'mode' => 'mini', + 'icon' => 'cog', + ], + true + ), ], - 'snmp3_browser_privacy_method', - $snmp3_privacy_method, - '', - '', - '', true ); - $table3->data[5][2] = ''.__('Privacy pass').''; - $table3->data[5][3] = html_print_input_password( - 'snmp3_browser_privacy_pass', - $snmp3_privacy_pass, - '', - 15, - 60, - true - ); + $searchForm .= ''; - $table3->data[6][0] = ''.__('Auth method').''; - $table3->data[6][1] = html_print_select( - [ - 'MD5' => __('MD5'), - 'SHA' => __('SHA'), - ], - 'snmp3_browser_auth_method', - $snmp3_auth_method, - '', - '', - '', - true - ); - $table3->data[6][2] = ''.__('Security level').''; - $table3->data[6][3] = html_print_select( - [ - 'noAuthNoPriv' => __('Not auth and not privacy method'), - 'authNoPriv' => __('Auth and not privacy method'), - 'authPriv' => __('Auth and privacy method'), - ], - 'snmp3_browser_security_level', - $snmp3_security_level, - '', - '', - '', - true - ); + if ($toggle == true) { + ui_toggle( + $searchForm, + ''.__('Filters').'', + 'filter_form', + '', + false, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' + ); + } // Search tools. $table2 = new stdClass(); @@ -1011,34 +1109,7 @@ function snmp_browser_print_container( $table2->data[0][2] .= ''; $table2->cellstyle[0][2] = 'text-align:center;'; - // This extra div that can be handled by jquery's dialog. - $output = '
    '; - $output .= '
    '; - $output .= '
    '; - $output .= '
    '; - $output .= html_print_table($table, true); - $output .= '
    '; - - if (isset($snmp_version) === false) { - $snmp_version = null; - } - - if ($snmp_version == 3) { - $output .= '
    '; - } else { - $output .= ''; - $output .= '
    '; + $output = ''; + if ($toggle === false) { + // This extra div that can be handled by jquery's dialog. + $output .= '
    ".__('Total')."
    - - - - - - - - - - '; + $messageTable = new stdClass(); + $messageTable->cellpadding = 0; + $messageTable->cellspacing = 0; + $messageTable->id = 'table_'.$id; + $messageTable->class = 'info_box '.$class.' textodialogo'; + $messageTable->styleTable = $force_style; - if (($first_execution) && (!$no_close_bool)) { - $first_execution = false; + $messageTable->rowclass = []; + $messageTable->rowclass[0] = 'title font_16pt text_left'; + $messageTable->rowclass[1] = 'black font_10pt invert_filter'; + $messageTable->colspan[1][0] = 2; - $output .= ' - - '; + $messageTable->data = []; + $messageTable->data[0][0] = ''.$text_title.''; + $messageTable->data[0][1] = $closeButton; + $messageTable->data[1][0] = ''.$text_message.''; + + // JavaScript help vars. + $messageCreated = html_print_table($messageTable, true); + $autocloseTime = ((int) $config['notification_autoclose_time'] * 1000); + + $classes[] = 'info_box_container'; + $classes[] = (($autoclose === true) && ($autocloseTime > 0)) ? ' info_box_autoclose' : ''; + + // This session var is defined in index. + if (isset($_SESSION['info_box_count']) === false) { + $_SESSION['info_box_count'] = 1; + } else { + $_SESSION['info_box_count']++; } - if ($return) { + $position = (20 + ((int) $_SESSION['info_box_count'] * 100)); + + $output = html_print_div( + [ + 'id' => $id, + 'style' => 'top: '.$position.'px;', + 'class' => implode(' ', $classes), + 'content' => $messageCreated, + ], + true + ); + + if ($return === true) { return $output; } else { echo $output; } - - return ''; } @@ -461,15 +505,15 @@ function ui_print_empty_data($message, $attributes='', $return=false, $tag='h3') */ function ui_print_result_message($result, $good='', $bad='', $attributes='', $return=false, $tag='h3') { - if ($good == '' || $good === false) { + if (empty($good) === true || $good === false) { $good = __('Request successfully processed'); } - if ($bad == '' || $bad === false) { + if (empty($bad) === true || $bad === false) { $bad = __('Error processing request'); } - if (empty($result)) { + if (empty($result) === true) { return ui_print_error_message($bad, $attributes, $return, $tag); } else { return ui_print_success_message($good, $attributes, $return, $tag); @@ -516,31 +560,31 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) // TODO: Add/use a javascript timer for the seconds so it automatically // updates as time passes by. - if (isset($option['html_attr'])) { + if (isset($option['html_attr']) === true) { $attributes = $option['html_attr']; } else { $attributes = ''; } - if (isset($option['tag'])) { + if (isset($option['tag']) === true) { $tag = $option['tag']; } else { $tag = 'span'; } - if (empty($option['style'])) { - $style = 'class="nowrap"'; + if (empty($option['style']) === true) { + $style = 'class="'.($option['class'] ?? 'nowrap').'"'; } else { $style = 'style="'.$option['style'].'"'; } - if (!empty($option['prominent'])) { + if (empty($option['prominent']) === false) { $prominent = $option['prominent']; } else { $prominent = $config['prominent_time']; } - if (!is_numeric($unixtime)) { + if (is_numeric($unixtime) === false) { $unixtime = time_w_fixed_tz($unixtime); } @@ -562,7 +606,7 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) } else { $title = date($config['date_format'], $unixtime); $units = 'large'; - if (isset($option['units'])) { + if (isset($option['units']) === true) { $units = $option['units']; } @@ -584,11 +628,11 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) break; } - if ($return) { + if ($return === true) { return $output; + } else { + echo $output; } - - echo $output; } @@ -596,19 +640,20 @@ function ui_print_timestamp($unixtime, $return=false, $option=[]) * Prints a username with real name, link to the user_edit page etc. * * @param string $username The username to render. + * @param boolean $fullname If true, returns the user fullname. * @param boolean $return Whether to return or print. * - * @return string HTML code if return parameter is true. + * @return void|string HTML code if return parameter is true. */ -function ui_print_username($username, $return=false) +function ui_print_username($username, $fullname=false, $return=false) { - $string = ''.get_user_fullname($username).''; - - if ($return) { - return $string; - } - - echo $string; + return html_print_anchor( + [ + 'href' => sprintf('index.php?sec=gusuarios&sec2=godmode/users/configure_user&edit_user=1&pure=0&id_user=%s', $username), + 'content' => ($fullname === true) ? get_user_fullname($username) : $username, + ], + $return + ); } @@ -644,47 +689,52 @@ function ui_print_tags_warning($return=false) * @param boolean $link Whether the group have link or not. * @param boolean $force_show_image Force show image. * @param boolean $show_as_image Show as image. + * @param string $class Overrides the default class. * * @return string HTML code if return parameter is true. */ -function ui_print_group_icon($id_group, $return=false, $path='groups_small', $style='', $link=true, $force_show_image=false, $show_as_image=false) +function ui_print_group_icon($id_group, $return=false, $path='', $style='', $link=true, $force_show_image=false, $show_as_image=false, $class='', $tactical_view=false) { global $config; - if ($id_group > 0) { - $icon = (string) db_get_value('icon', 'tgrupo', 'id_grupo', (int) $id_group); - } else { - $icon = 'world'; - } - $output = ''; + $icon = ($id_group > 0) ? (string) db_get_value('icon', 'tgrupo', 'id_grupo', (int) $id_group) : 'unknown@groups.svg'; + // Don't show link in metaconsole. - if (defined('METACONSOLE')) { + if (is_metaconsole() === true) { $link = false; } - if ($link) { - $output = ''; + if ($link === true) { + if ($tactical_view === true) { + $output = ''; + } else { + $output = ''; + } } - if ($config['show_group_name']) { + if ((bool) $config['show_group_name'] === true) { $output .= ''.groups_get_name($id_group, true).' '; } else { - if (empty($icon)) { + if (empty($icon) === true) { $output .= '  '; } else { - $class = 'bot'; - if ($icon === 'transmit') { - $class .= ' invert_filter'; + if (empty($class) === true) { + $class = 'bot'; + if ($icon === 'transmit') { + $class .= ' invert_filter'; + } } + $icon = (str_contains($icon, '.svg') === true) ? $icon : $icon.'.svg'; + $output .= html_print_image( - 'images/'.$path.'/'.$icon.'.png', + 'images/'.$icon, true, [ 'style' => $style, - 'class' => $class, + 'class' => 'main_menu_icon '.$class, 'alt' => groups_get_name($id_group, true), 'title' => groups_get_name($id_group, true), ], @@ -696,15 +746,15 @@ function ui_print_group_icon($id_group, $return=false, $path='groups_small', $st } } - if ($link) { + if ($link === true) { $output .= ''; } - if (!$return) { + if ($return === false) { echo $output; + } else { + return $output; } - - return $output; } @@ -720,7 +770,7 @@ function ui_print_group_icon($id_group, $return=false, $path='groups_small', $st * * @return string HTML code if return parameter is true. */ -function ui_print_group_icon_path($id_group, $return=false, $path='images/groups_small', $style='', $link=true) +function ui_print_group_icon_path($id_group, $return=false, $path='images', $style='', $link=true) { if ($id_group > 0) { $icon = (string) db_get_value('icon', 'tgrupo', 'id_grupo', (int) $id_group); @@ -781,7 +831,7 @@ function ui_print_os_icon( $options=false, $big_icons=false ) { - $subfolder = 'os_icons'; + $subfolder = '.'; if ($networkmap) { $subfolder = 'networkmap'; } @@ -790,15 +840,15 @@ function ui_print_os_icon( $subfolder .= '/so_big_icons'; } - if (is_metaconsole()) { - $no_in_meta = false; - } else { - $no_in_meta = true; + if (isset($options['class']) === false) { + $options['class'] = 'main_menu_icon'; } + $no_in_meta = (is_metaconsole() === false); + $icon = (string) db_get_value('icon_name', 'tconfig_os', 'id_os', (int) $id_os); $os_name = get_os_name($id_os); - if (empty($icon)) { + if (empty($icon) === true) { if ($only_src) { $output = html_print_image( 'images/'.$subfolder.'/unknown.png', @@ -814,13 +864,29 @@ function ui_print_os_icon( } } else if ($apply_skin) { if ($only_src) { - $output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, true, $relative, $no_in_meta, true); + $output = html_print_image( + 'images/'.$subfolder.'/'.$icon, + true, + $options, + true, + $relative, + $no_in_meta, + true + ); } else { if (!isset($options['title'])) { $options['title'] = $os_name; } - $output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, false, $relative, $no_in_meta, true); + $output = html_print_image( + 'images/'.$subfolder.'/'.$icon, + true, + $options, + false, + $relative, + $no_in_meta, + true + ); } } else { // $output = "" . $os_name . ""; @@ -861,18 +927,18 @@ function ui_print_type_agent_icon( ) { global $config; - if ($id_os == 19) { + if ((int) $id_os === SATELLITE_OS_ID) { // Satellite. $options['title'] = __('Satellite'); - $output = html_print_image('images/satellite.png', true, ['class' => 'invert_filter'], false, false, false, true); - } else if ($remote_contact == $contact && $remote == 0 && $version == '') { + $output = html_print_image('images/satellite@os.svg', true, ['class' => 'main_menu_icon invert_filter'], false, false, false, true); + } else if ($remote_contact === $contact && $remote === 0 && empty($version) === true) { // Network. $options['title'] = __('Network'); - $output = html_print_image('images/network.png', true, ['class' => 'invert_filter'], false, false, false, true); + $output = html_print_image('images/network-server@os.svg', true, ['class' => 'main_menu_icon invert_filter'], false, false, false, true); } else { // Software. $options['title'] = __('Software'); - $output = html_print_image('images/data.png', true, ['class' => 'invert_filter'], false, false, false, true); + $output = html_print_image('images/data-server@svg.svg', true, ['class' => 'main_menu_icon invert_filter'], false, false, false, true); } return $output; @@ -1157,15 +1223,60 @@ function ui_format_alert_row( if (is_metaconsole() === false) { // Force alert execution. - if (check_acl($config['id_user'], $id_group, 'AW') || check_acl($config['id_user'], $id_group, 'LM')) { - if ($alert['force_execution'] == 0) { - $data[$index['force_execution']] = ''.html_print_image('images/target.png', true, ['border' => '0', 'title' => __('Force'), 'class' => 'invert_filter']).''; + if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) { + if ((int) $alert['force_execution'] === 0) { + $forceTitle = __('Force check'); + $additionUrl = '&force_execution=1'; } else { - $data[$index['force_execution']] = ''.html_print_image('images/refresh.png', true, ['class' => 'invert_filter']).''; + $forceTitle = __('Refresh'); + $additionUrl = ''; } + + $forceExecButtons[] = html_print_button( + $forceTitle, + 'force_execution_'.$alert['id'], + false, + 'window.location.assign("'.$url.'&id_alert='.$alert['id'].'&refr=60'.$additionUrl.'");', + [ 'mode' => 'link' ], + true + ); } + + $forceExecButtons[] = html_print_button( + __('View'), + 'view_template_'.$alert['id'], + false, + '', + [ + 'mode' => 'link', + 'class' => 'template_details', + 'href' => 'ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$template['id'], + ], + true + ); + } else { + $forceExecButtons[] = html_print_button( + __('View'), + 'view_template_'.$alert['id'], + false, + '', + [ + 'mode' => 'link', + 'class' => 'template_details', + 'href' => ui_get_full_url('/', false, false, false).'/ajax.php?page=enterprise/meta/include/ajax/tree_view.ajax&action=get_template_tooltip&id_template='.$template['id'].'&server_name='.$alert['server_data']['server_name'], + ], + true + ); } + $data[$index['force_execution']] = html_print_div( + [ + 'class' => 'table_action_buttons flex', + 'content' => implode('', $forceExecButtons), + ], + true + ); + $data[$index['agent_name']] = $disabledHtmlStart; if ($agent == 0) { $data[$index['module_name']] .= ui_print_truncate_text(isset($alert['agent_module_name']) ? $alert['agent_module_name'] : modules_get_agentmodule_name($alert['id_agent_module']), 'module_small', false, true, true, '[…]', ''); @@ -1182,16 +1293,24 @@ function ui_format_alert_row( // Do not show link if user cannot access node if ((bool) can_user_access_node() === true) { $url = $server['server_url'].'/index.php?'.'sec=estado&'.'sec2=operation/agentes/ver_agente&'.'id_agente='.$agente['id_agente']; - $data[$index['agent_name']] .= ''.''.$agente['alias'].''; + $data[$index['agent_name']] .= html_print_anchor( + [ + 'href' => $url, + 'content' => ''.$agente['alias'].'', + ], + true + ); } else { - $data[$index['agent_name']] .= ''.$agente['alias'].''; + $data[$index['agent_name']] .= ''.$agente['alias'].''; } } else { - if ($agent_style !== false) { - $data[$index['agent_name']] .= ' '.$agente['alias'].''; - } else { - $data[$index['agent_name']] .= ' '.$agente['alias'].''; - } + $data[$index['agent_name']] .= html_print_anchor( + [ + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$id_agent, + 'content' => ''.$agente['alias'].'', + ], + true + ); } $data[$index['module_name']] = ui_print_truncate_text(isset($alert['agent_module_name']) ? $alert['agent_module_name'] : modules_get_agentmodule_name($alert['id_agent_module']), 'module_small', false, true, true, '[…]', ''); @@ -1201,14 +1320,6 @@ function ui_format_alert_row( $data[$index['description']] = ''; - if (is_metaconsole() === true) { - $data[$index['template']] .= ''; - } else { - $data[$index['template']] .= ''; - } - - $data[$index['template']] .= html_print_image('images/zoom.png', true, ['class' => 'invert_filter']); - $data[$index['template']] .= ' '; $actionDefault = db_get_value_sql( 'SELECT id_alert_action FROM talert_templates WHERE id = '.$alert['id_alert_template'] @@ -1411,6 +1522,7 @@ function ui_print_alert_template_example($id_alert_template, $return=false, $pri * @param string $image Image path. * @param boolean $is_relative Route is relative or not. * @param string $id Target id. + * @param string $isHeader If true, the view is header. * * @return string The help tip */ @@ -1418,22 +1530,29 @@ function ui_print_help_icon( $help_id, $return=false, $home_url='', - $image='images/help_green.png', + $image='images/info@svg.svg', $is_relative=false, - $id='' + $id='', + $isHeader=false ) { global $config; + if (empty($image) === true) { + $image = 'images/info@svg.svg'; + } + + $iconClass = ($isHeader === true) ? 'header_help_icon' : 'main_menu_icon'; + // Do not display the help icon if help is disabled. - if ($config['disable_help']) { + if ((bool) $config['disable_help'] === true) { return ''; } - if (empty($home_url)) { + if (empty($home_url) === true) { $home_url = ''; } - if (defined('METACONSOLE')) { + if (is_metaconsole() === true) { $home_url = '../../'.$home_url; } @@ -1448,7 +1567,7 @@ function ui_print_help_icon( $image, true, [ - 'class' => 'img_help', + 'class' => 'img_help '.$iconClass, 'title' => __('Help'), 'onclick' => "open_help ('".ui_get_full_url($help_handler)."')", 'id' => $id, @@ -2048,25 +2167,26 @@ function ui_pagination( $set_id='' ) { global $config; + ui_require_css_file('tables'); - if (empty($pagination)) { + if (empty($pagination) === true) { $pagination = (int) $config['block_size']; } - if (is_string($offset)) { + if (is_string($offset) === true) { $offset_name = $offset; $offset = (int) get_parameter($offset_name); } - if (empty($offset)) { + if (empty($offset) === true) { $offset = (int) get_parameter($offset_name); } - if (empty($url)) { + if (empty($url) === true) { $url = ui_get_url_refresh([$offset_name => false]); } - if (!empty($set_id)) { + if (empty($set_id) === false) { $set_id = " id = '".$set_id."'"; } @@ -2108,7 +2228,7 @@ function ui_pagination( // Visualize only $block_limit blocks. if ($count <= $pagination) { if ($print_total_items) { - $output = "