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;
$url = "index.php?sec=eventos&sec2=operation/events/events&search=$search&event_type=$event_type&severity=$severity&status=$status&ev_group=$ev_group&refr=60&id_agent=$id_agent&id_event=$id_event&pagination=$pagination";
echo "
';
} else {
echo '
'; //There is no value all to property display
}
// Table for filter controls
echo '
"; //This is the internal table
echo '
';
echo '
';
$sql = "SELECT * FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC LIMIT ".$offset.",".$pagination;
$result = get_db_all_rows_sql ($sql);
$sql = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 ".$sql_post;
$total_events = get_db_sql ($sql);
if (empty ($result)) {
$result = array ();
}
if (empty ($total_events)) {
$total_events = 0;
}
// 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->head[1] = __('Type');
$table->headclass[1] = 'f9';
$table->head[2] = __('Event name');
//$table->headclass[2] = 'f9';
$table->head[3] = __('Agent name');
//$table->headclass[3] = 'f9';
$table->head[4] = __('Source');
//$table->headclass[4] = 'f9';
$table->head[5] = __('Group');
//$table->headclass[5] = 'f9';
$table->head[6] = __('User ID');
//$table->headclass[6] = 'f9';
$table->head[7] = __('Timestamp');
//$table->headclass[7] = 'f9';
$table->head[8] = __('Action');
//$table->headclass[8] = 'f9';
$table->head[9] = print_checkbox ("allbox", "1", false, true);
//$table->headclass[9] = 'p10';
//Arrange data. We already did ACL's in the query
foreach ($result as $row) {
$data = array ();
//First pass along the class of this row
switch ($row["criticity"]) {
case 0:
$table->rowclass[] = "datos_blue";
break;
case 1:
$table->rowclass[] = "datos_grey";
break;
case 2:
$table->rowclass[] = "datos_green";
break;
case 3:
$table->rowclass[] = "datos_yellow";
break;
case 4:
$table->rowclass[] = "datos_red";
break;
default:
$table->rowclass[] = "datos_grey";
}
// Colored box
if ($row["estado"] == 0) {
$data[0] = '

';
} else {
$data[0] = '

';
}
switch ($row["event_type"]) {
case "alert_recovered":
$data[1] = '

';
break;
case "alert_manual_validation":
$data[1] = '

';
break;
case "monitor_up":
$data[1] = '

';
break;
case "monitor_down":
$data[1] = '

';
break;
case "alert_fired":
$data[1] = '

';
break;
case "system";
$data[1] = '

';
break;
case "recon_host_detected";
$data[1] = '

';
break;
case "new_agent";
$data[1] = '

';
break;
case "unknown":
default:
$data[1] = '

';
break;
}
// Event description
$data[2] = '
';
if (strlen ($row["evento"]) > 39) {
$data[2] .= substr ($row["evento"], 0, 37)."...";
} else {
$data[2] .= $row["evento"];
}
$data[2] .= '';
if ($row["event_type"] == "system") {
$data[3] = __('System');
} elseif ($row["id_agente"] > 0) {
// Agent name
$agent_name = dame_nombre_agente ($row["id_agente"]);
$data[3] = '
';
if (strlen ($agent_name) > 16) {
$data[3] .= substr ($agent_name, 0, 14)."...";
} else {
$data[3] .= $agent_name;
}
$data[3] .= '';
} else {
$data[3] = __('Alert').__('SNMP');
}
$data[4] = '';
if ($row["id_agentmodule"] != 0) {
$data[4] .= '

';
}
if ($row["id_alert_am"] != 0) {
$data[4] .= '

';
}
if (!empty ($row["id_grupo"])) {
$data[5] = '

';
} else {
$data[5] = '';
}
if (!empty ($row["estado"])) {
$data[6] = '
'.substr ($row["id_usuario"],0,8).'';
} else {
$data[6] = '';
}
//Time
$data[7] = '
'.human_time_comparation ($row["timestamp"]).'';
//Actions
$data[8] = '';
// Validate event
if (($row["estado"] == 0) and (give_acl ($config["id_user"], $row["id_grupo"], "IW") == 1)) {
$data[8] .= '

';
}
// Delete event
if (give_acl ($config["id_user"], $row["id_grupo"], "IM") == 1) {
$data[8] .= '

';
}
// Create incident from this event
if (give_acl ($config["id_user"], $row["id_grupo"], "IW") == 1) {
$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 '
';
} else {
echo '
'.__('No events').'
';
}
unset ($table);
echo '
';
echo '
'.__('Status').'
';
echo '

- '.__('Validated event');
echo '
';
echo '

- '.__('Not validated event');
echo '
';
echo '
'.__('Action').'
';
echo '

- '.__('Validate event');
echo '
';
echo '

- '.__('Delete event');
echo '
';
echo '

- '.__('Create incident');
echo '
';
?>