$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); $op = get_parameter('op', 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); } if (isset($id_agente) === false || empty($id_agente) === true) { $idAgent = get_parameter_get('id_agente', 0); } else { $idAgent = $id_agente; } // 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; // Header. ui_print_standard_header( __('Alert detail'), 'images/op_alerts.png', false, '', false, [], [ [ 'link' => '', 'label' => __('Monitoring'), ], [ 'link' => '', 'label' => __('Views'), ], ] ); } $alerts = []; if ($op != null) { $url = $url.'&op='.$op; } 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 ((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'), ], [ 'title' => __('Operations'), 'text' => __('Operations'), 'class' => 'left pdd_l_0px pdd_r_0px w100p', ], ); $columns = array_merge( ['standby'], ['force'], $columns ); if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { array_unshift( $column_names, [ 'title' => __('Policy'), 'text' => __('Policy'), ] ); $columns = array_merge( ['policy'], $columns ); } /* if ($print_agent === true) { array_push( $column_names, ['text' => 'Agent'] ); $columns = array_merge( $columns, ['agent_name'] ); }*/ } array_push( $column_names, ['text' => 'Agent'], ['text' => 'Module'], ['text' => 'Template'], [ 'title' => __('Action'), 'text' => __('Action'), 'style' => 'min-width: 15%;', ], ['text' => 'Last fired'], ['text' => 'Status'] ); $columns = array_merge( $columns, ['agent_name'], ['agent_module_name'], ['template_name'], ['action'], ['last_fired'], ['status'] ); 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 (is_metaconsole()) { array_push($column_names, ['text' => 'actions']); array_push($columns, 'actions'); } if (is_metaconsole() === true) { $no_sortable_columns = [ 0, 1, 2, 5, -1, ]; } else { if (enterprise_installed() === true) { $no_sortable_columns = [ 0, 1, 2, 3, -3, -1, ]; } else { $no_sortable_columns = [ 0, 1, 2, -3, -1, ]; } } 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', 'dom_elements' => 'pfrti', '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 secondary', '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, 'class' => 'flex', ], ] ); } else { 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, ], '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 secondary', '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 ), ], 'start_disabled' => true, ] ); } if (is_metaconsole() === false) { if (((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_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'] ); } } } else { echo "
'; } $html_content = ob_get_clean(); if ($agent_view_page === true) { // Create controlled toggle content. $alerts_count = alerts_get_alerts(0, '', 'all', -1, $true, true, $agent['id_agente']); html_print_div( [ 'class' => 'agent_details_line', 'content' => ui_toggle( $html_content, ''.__('Full list of alerts').'', 'status_monitor_agent', !$alerts_defined, ($alerts_count > 0) ? false : true, true, '', '', 'box-flat white_table_graph w100p' ), ], ); } else { // Dump entire content. echo $html_content; } // Strict user hidden. echo ' '; ui_require_css_file('cluetip', 'include/styles/js/'); ui_require_jquery_file('cluetip'); ?>