$value) { if ($value === end($user_tag_array)) { $user_tag .= $value; } else { $user_tag .= $value.','; } } $tag_filter = get_parameter('tag_filter', $user_tag); $tag_param_validate = explode(',', $tag_filter); foreach ($tag_param_validate as $key => $value) { if (!in_array($value, $user_tag_array)) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access Alert view' ); include 'general/noaccess.php'; exit; } } } else { $tag_filter = get_parameter('tag_filter', 0); } if ($tag_filter) { if ($id_group && $strict_user) { $tag_filter = 0; } } $action_filter = get_parameter('action', 0); $sec2 = get_parameter_get('sec2'); $sec2 = safe_url_extraclean($sec2); $sec = get_parameter_get('sec'); $sec = safe_url_extraclean($sec); $flag_alert = (bool) get_parameter('force_execution', 0); $alert_validate = (bool) get_parameter('alert_validate', 0); $tab = get_parameter_get('tab', null); $refr = (int) get_parameter('refr', 0); $pure = get_parameter('pure', 0); $url = 'index.php?sec='.$sec.'&sec2='.$sec2.'&refr='.$refr.'&disabled='.$disabled.'&filter_standby='.$filter_standby.'&ag_group='.$id_group.'&tag_filter='.$tag_filter.'&action_filter='.$action_filter; if ($flag_alert == 1 && check_acl($config['id_user'], $id_group, 'AW')) { forceExecution($id_group); } $idAgent = get_parameter_get('id_agente', 0); // Show alerts for specific agent. if ($idAgent != 0) { $url = $url.'&id_agente='.$idAgent; $id_group = agents_get_agent_group($idAgent); // All groups is calculated in ver_agente.php. Avoid to calculate it again. if (!isset($all_groups)) { $all_groups = agents_get_all_groups_agent($idAgent, $id_group); } if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && !check_acl_one_of_groups($config['id_user'], $id_group, 'AW')) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access alert view' ); include 'general/noaccess.php'; exit; } $idGroup = false; $print_agent = false; $tab = get_parameter('tab', 'main'); ob_start(); if ($tab == 'main') { $agent_view_page = true; } } else { $agent_a = check_acl($config['id_user'], 0, 'AR'); $agent_w = check_acl($config['id_user'], 0, 'AW'); $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); if (!$agent_a && !$agent_w) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access alert view' ); include 'general/noaccess.php'; return; } $agents = array_keys( agents_get_group_agents( array_keys( users_get_groups($config['id_user'], $access, false) ), false, 'lower', true ) ); $idGroup = $id_group; // If there is no agent defined, it means that it cannot search for the secondary groups. $all_groups = [$id_group]; $print_agent = true; if (is_metaconsole() === false) { // Header. ui_print_standard_header( __('Alert detail'), 'images/op_alerts.png', false, '', false, [], [ [ 'link' => '', 'label' => __('Monitoring'), ], [ 'link' => '', 'label' => __('Views'), ], ] ); } else { ui_meta_print_header(__('Alerts view')); } } enterprise_hook('open_meta_frame'); $alerts = []; if ($tab != null) { $url = $url.'&tab='.$tab; } if ($pure) { $url .= '&pure='.$pure; } if (empty($free_search) === false) { $url .= '&free_search='.$free_search; } $columns = []; $column_names = []; if (is_metaconsole() === false) { if ((bool) check_acl($config['id_user'], $id_group, 'LW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) { array_unshift( $column_names, [ 'title' => __('Standby'), 'text' => __('Standby'), 'style' => 'max-width: 5%;', ], ); $columns = array_merge( ['standby'], $columns ); if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { array_unshift( $column_names, [ 'title' => __('Policy'), 'text' => __('Policy'), 'style' => 'max-width: 5%;vertical-align: baseline;', ] ); $columns = array_merge( ['policy'], $columns ); } if ($print_agent === true) { array_push( $column_names, ['text' => 'Agent'] ); $columns = array_merge( $columns, ['agent_name'] ); } } if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) { array_push( $column_names, [ 'text' => 'Module', 'style' => 'min-width: 15%;vertical-align: baseline;', ], [ 'text' => 'Template', 'style' => 'min-width: 10%;vertical-align: baseline;', ], [ 'text' => 'Operation', 'style' => 'min-width: 15%;vertical-align: baseline;', ], [ 'text' => 'Last fired', 'style' => 'min-width: 15%;', ], [ 'text' => 'Status', 'style' => 'width: 5%;', ] ); $columns = array_merge( $columns, ['agent_module_name'], ['template_name'], ['operation'], ['last_fired'], ['status'] ); } } if ($print_agent === true) { array_push( $column_names, ['text' => 'Agent'] ); $columns = array_merge( $columns, ['agent_name'] ); } if (is_metaconsole() === false) { if ((bool) check_acl($config['id_user'], $id_group, 'LW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) { array_unshift( $column_names, [ 'title' => __('Validate'), 'text' => html_print_checkbox('all_validate', 0, false, true, false), 'class' => 'dt-left', 'style' => 'max-width: 5%;', ] ); $columns = array_merge( ['validate'], $columns ); } if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) { array_push( $column_names, [ 'title' => __('Actions'), 'text' => __('Actions'), 'style' => 'min-width: 15%;', ] ); $columns = array_merge( $columns, ['actions'] ); } } if (is_metaconsole() === true) { $no_sortable_columns = [ 0, 1, 5, ]; } else { if (enterprise_installed() === true) { $no_sortable_columns = [ 0, 1, 2, 3, 7, ]; } else { $no_sortable_columns = [ 0, 1, 2, 6, ]; } } $alert_action = empty(alerts_get_alert_actions_filter()) === false ? alerts_get_alert_actions_filter() : ['' => __('No actions')]; ob_start(); if ($agent_view_page === true) { ui_print_datatable( [ 'id' => 'alerts_status_datatable', 'class' => 'info_table', 'style' => 'width: 100%', 'columns' => $columns, 'column_names' => $column_names, 'no_sortable_columns' => $no_sortable_columns, 'ajax_url' => 'include/ajax/alert_list.ajax', 'ajax_data' => [ 'get_agent_alerts_datatable' => 1, 'id_agent' => $idAgent, 'url' => $url, 'agent_view_page' => true, 'all_groups' => $all_groups, ], 'drawCallback' => 'alerts_table_controls()', 'order' => [ 'field' => 'agent_module_name', 'direction' => 'asc', ], 'zeroRecords' => __('No alerts found'), 'emptyTable' => __('No alerts found'), 'search_button_class' => 'sub filter float-right', 'form' => [ 'inputs' => [ [ 'label' => __('Free text for search (*):').ui_print_help_tip( __('Filter by module name, template name or action name'), true ), 'type' => 'text', 'name' => 'free_search_alert', 'value' => $free_search, 'size' => 20, 'maxlength' => 100, ], ], 'no_toggle' => true, ], ] ); } else { ui_print_datatable( [ 'id' => 'alerts_status_datatable', 'class' => 'info_table', 'style' => 'width: 99%', 'columns' => $columns, 'column_names' => $column_names, 'no_sortable_columns' => $no_sortable_columns, 'ajax_url' => 'include/ajax/alert_list.ajax', 'ajax_data' => [ 'get_agent_alerts_datatable' => 1, 'id_agent' => $idAgent, 'url' => $url, ], 'drawCallback' => 'alerts_table_controls()', 'order' => [ 'field' => 'agent_module_name', 'direction' => 'asc', ], 'zeroRecords' => __('No alerts found'), 'emptyTable' => __('No alerts found'), 'search_button_class' => 'sub filter float-right', 'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar', 'form' => [ 'html' => printFormFilterAlert( $id_group, $disabled, $free_search, $url, $filter_standby, $tag_filter, true, true, $strict_user ), ], ] ); } if ((is_metaconsole() === false) && ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true)) { if ($agent_view_page === true) { html_print_div( [ 'class' => 'action-buttons pdd_b_10px pdd_r_5px w100p', 'content' => html_print_submit_button( __('Validate'), 'alert_validate', false, [ 'icon' => 'wand', 'mode' => 'secondary mini', ], true ), ] ); } else { html_print_action_buttons( html_print_submit_button( __('Validate'), 'alert_validate', false, [ 'icon' => 'wand' ], true ), ['type' => 'form_action'] ); } } $html_content = ob_get_clean(); if ($agent_view_page === true) { // Create controlled toggle content. html_print_div( [ 'class' => 'agent_details_line', 'content' => ui_toggle( $html_content, ''.__('Full list of alerts').'', 'status_monitor_agent', !$alerts_defined, false, true, 'box-flat agent_details_col', 'white-box-content', 'width_available' ), ], ); } else { // Dump entire content. echo $html_content; } // Strict user hidden. echo '
'; enterprise_hook('close_meta_frame'); ui_require_css_file('cluetip', 'include/styles/js/'); ui_require_jquery_file('cluetip'); ?>