1 && in_array ($ev_group, array_keys ($groups))) { //If a group is selected and it's in the groups allowed $sql_post = " AND id_grupo = $ev_group"; } elseif (dame_admin ($config["id_user"])) { //Do nothing if you're admin, you get full access $sql_post = ""; $groups[0] = __('System Events'); } else { //Otherwise select all groups the user has rights to. $sql_post = " AND id_grupo IN (".implode (",", array_keys ($groups)).")"; } if ($status == 1) { $sql_post .= " AND estado = 1"; } elseif ($status == 0) { $sql_post .= " AND estado = 0"; } if ($search != "") $sql_post .= " AND evento LIKE '%".$search."%'"; if ($event_type != "") $sql_post .= " AND event_type = '".$event_type."'"; if ($severity != -1) $sql_post .= " AND criticity >= ".$severity; if ($id_agent != -1) $sql_post .= " AND id_agente = ".$id_agent; if ($id_event != -1) $sql_post .= " AND id_evento = ".$id_event; if ($id_user_ack != 0) $sql_post .= " AND id_usuario == '".$id_user_ack."'"; if ($event_view_hr > 0) { $unixtime = get_system_time () - ($event_view_hr * 3600); //Put hours in seconds $sql_post .= " AND utimestamp > ".$unixtime; } $url = "index.php?sec=eventos&sec2=operation/events/events&search=".rawurlencode($search)."&event_type=".$event_type."&severity=".$severity."&status=".$status."&ev_group=".$ev_group."&refr=".$config["refr"]."&id_agent=".$id_agent."&id_event=".$id_event."&pagination=".$pagination."&group_rep=".$group_rep."&event_view_hr=".$event_view_hr."&id_user_ack=".$id_user_ack; echo "

".__('Events')." > ".__('Main event view'). " "; if ($config["pure"] == 1) { echo ''; print_image ("images/monitor.png", false, array ("title" => __('Normal screen'))); echo ''; } else { // Fullscreen echo ''; print_image ("images/monitor.png", false, array ("title" => __('Full screen'))); echo ''; } echo "

"; //Link to toggle filter echo ''.__('Event control filter').' '.print_image ("images/wand.png", true, array ("title" => __('Toggle filter'))).''; //Start div echo '"; //This is the filter div echo '
'; print_image ("reporting/fgraph.php?tipo=group_events&width=220&height=180&url=".rawurlencode ($sql_post), false, array ("border" => 0)); echo '
 
'; if ($group_rep == 0) { $sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination; } else { $sql = "SELECT *, COUNT(*) AS event_rep, MAX(utimestamp) AS timestamp_rep FROM tevento WHERE 1=1 ".$sql_post." GROUP BY evento, id_agentmodule ORDER BY timestamp_rep DESC LIMIT ".$offset.",".$pagination; } $result = get_db_all_rows_sql ($sql); if ($group_rep == 0) { $sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post; } else { $sql = "SELECT COUNT(DISTINCT(evento)) FROM tevento WHERE 1=1 ".$sql_post; } $total_events = (int) get_db_sql ($sql); if (empty ($result)) { $result = array (); } // Show pagination header $offset = get_parameter ("offset", 0); pagination ($total_events, $url."&pure=".$config["pure"], $offset, $pagination); // If pure, table width takes more space if ($config["pure"] != 0) { $table->width = 765; } else { $table->width = 750; } $table->id = "eventtable"; $table->cellpadding = 4; $table->cellspacing = 4; $table->class = "databox"; $table->head = array (); $table->data = array (); $table->head[0] = ''; $table->align[0] = 'center'; $table->head[1] = __('Type'); $table->headclass[1] = 'f9'; $table->align[1] = 'center'; $table->head[2] = __('Event name'); $table->head[3] = __('Agent name'); $table->align[3] = 'center'; $table->head[4] = __('Source'); $table->align[4] = 'center'; $table->head[5] = __('Group'); $table->align[5] = 'center'; if ($group_rep == 0) { $table->head[6] = __('User ID'); } else { $table->head[6] = __('Rep'); } $table->align[6] = 'center'; $table->head[7] = __('Timestamp'); $table->align[7] = 'center'; $table->head[8] = __('Action'); $table->align[8] = 'center'; $table->head[9] = print_checkbox ("allbox", "1", false, true); $table->align[9] = 'center'; //Arrange data. We already did ACL's in the query foreach ($result as $row) { $data = array (); //First pass along the class of this row $table->rowclass[] = get_priority_class ($row["criticity"]); // Colored box if ($row["estado"] == 0) { $data[0] = print_image ("images/pixel_red.png", true, array ("width" => 20, "height" => 20, "title" => get_priority_name ($row["criticity"]))); } else { $data[0] = print_image ("images/pixel_green.png", true, array ("width" => 20, "height" => 20, "title" => get_priority_name ($row["criticity"]))); } $data[1] = print_event_type_img ($row["event_type"], true); // Event description $data[2] = ''; $data[2] .= ''; if (strlen ($row["evento"]) > 50) { $data[2] .= mb_substr ($row["evento"], 0, 50)."..."; } else { $data[2] .= $row["evento"]; } $data[2] .= ''; if ($row["event_type"] == "system") { $data[3] = __('System'); } elseif ($row["id_agente"] > 0) { // Agent name $data[3] = print_agent_name ($row["id_agente"], true); } else { $data[3] = __('Alert').__('SNMP'); } $data[4] = ''; if ($row["id_agentmodule"] != 0) { $data[4] .= ''; $data[4] .= print_image ("images/bricks.png", true, array ("border" => 0, "title" => __('Go to data overview'))); $data[4] .= ' '; } if ($row["id_alert_am"] != 0) { $data[4] .= ''; $data[4] .= print_image ("images/bell.png", true, array ("border" => 0, "title" => __('Go to alert overview'))); $data[4] .= ''; } $data[5] = print_group_icon ($row["id_grupo"], true); if ($group_rep == 1) { $data[6] = $row["event_rep"]; } else { if (!empty ($row["estado"])) { if ($row["id_usuario"] != '0' && $row["id_usuario"] != ''){ $data[6] = ''.mb_substr ($row["id_usuario"],0,8).''; } else { $data[6] = __('System'); } } else { $data[6] = ''; } } //Time if ($group_rep == 1) { $data[7] = print_timestamp ($row['timestamp_rep'], true); } else { $data[7] = print_timestamp ($row["timestamp"], true); } //Actions $data[8] = ''; // Validate event if (($row["estado"] == 0) and (give_acl ($config["id_user"], $row["id_grupo"], "IW") == 1)) { $data[8] .= ''; $data[8] .= print_image ("images/ok.png", true, array ("border" => 0, "title" => __('Validate event'))); $data[8] .= ''; } // Delete event if (give_acl ($config["id_user"], $row["id_grupo"], "IM") == 1) { $data[8] .= ''; $data[8] .= print_image ("images/cross.png", true, array ("border" => 0, "title" => __('Delete event'))); $data[8] .= ''; } // Create incident from this event if (give_acl ($config["id_user"], $row["id_grupo"], "IW") == 1) { $data[8] .= ''; $data[8] .= print_image ("images/page_lightning.png", true, array ("border" => 0, "title" => __('Create incident from event'))); $data[8] .= ''; } //Checkbox $data[9] = print_checkbox_extended ("eventid[]", $row["id_evento"], false, false, false, 'class="chk"', true); array_push ($table->data, $data); } if (!empty ($table->data)) { echo '
'; print_table ($table); echo '
'; if (give_acl ($config["id_user"], 0, "IW") == 1) { print_submit_button (__('Validate'), 'validate', false, 'class="sub ok"'); } if (give_acl ($config["id_user"], 0,"IM") == 1) { print_submit_button (__('Delete'), 'delete', false, 'class="sub delete"'); } echo '
'; if ($config["pure"]== 0) { //Print legend echo '
'; echo '

'.__('Status').'

'; print_image ("images/pixel_green.png", false, array ("width" => 10, "height" => 10, "title" => __('Validated event'))); echo ' - '.__('Validated event'); echo '
'; print_image ("images/pixel_red.png", false, array ("width" => 10, "height" => 10, "title" => __('Event not validated'))); echo ' - '.__('Event not validated'); echo '
'; echo '

'.__('Actions').'

'; print_image ("images/ok.png", false, array ("title" => __('Validate event'))); echo ' - '.__('Validate event'); echo '
'; print_image ("images/cross.png", false, array ("title" => __('Delete event'))); echo ' - '.__('Delete event'); echo '
'; print_image ("images/page_lightning.png", false, array ("title" => __('Create incident from event'))); echo ' - '.__('Create incident from event'); echo '
 
'; } } else { echo '
'.__('No events').'
'; } unset ($table); ?>