1) $filter['id_grupo'] = $ev_group; /*if ($status == 1) $filter['estado'] = 1; if ($status == 0) $filter['estado'] = 0; */ $filter_state = ''; switch($status) { case 0: case 1: case 2: $filter_state = " AND estado = " . $status; break; case 3: $filter_state = " AND (estado = 0 OR estado = 2)"; break; } if ($search != "") $filter[] = 'evento LIKE "%'.io_safe_input($search).'%"'; if (($event_type != "all") OR ($event_type != 0)) $filter['event_type'] = $event_type; if ($severity != -1) $filter[] = 'criticity >= '.$severity; if ($id_agent == -2) { $text_agent = (string) get_parameter("text_agent", __("All")); switch ($text_agent) { case __('All'): $id_agent = -1; break; case __('Server'): $id_agent = 0; break; default: $id_agent = agents_get_agent_id($text_agent); break; } } else { switch ($id_agent) { case -1: $text_agent = __('All'); break; case 0: $text_agent = __('Server'); break; default: $text_agent = agents_get_name($id_agent); break; } } if ($id_agent != -1) $filter['id_agente'] = $id_agent; if ($id_event != -1) $filter['id_evento'] = $id_event; $timestamp_filter = ''; if ($event_view_hr > 0) { $unixtime = get_system_time () - ($event_view_hr * SECONDS_1HOUR); //Put hours in seconds $timestamp_filter = " AND (utimestamp > $unixtime OR estado = 2)"; } if ($id_user_ack != "0") $filter['id_usuario'] = $id_user_ack; //Search by tag if ($tag != "") { $filter['tags'] = "%".io_safe_input($tag)."%"; } //$filter['order'] = 'timestamp DESC'; $now = date ("Y-m-d"); // Show contentype header Header ("Content-type: text/txt"); header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.txt"'); echo "timestamp, agent, group, event, status, user, event_type, severity"; echo chr (13); $fields = array ('id_grupo', 'id_agente', 'evento', 'estado', 'id_usuario', 'event_type', 'criticity', 'timestamp'); $sql = db_get_all_rows_filter ('tevento', $filter, $fields, 'AND', true, true); // If filter is empty and there are others filters not empty append "WHERE" clause if (empty($filter) and (!empty($filter_state) or !empty($timestamp_filter))) $sql .= ' WHERE 1=1 '; $sql .= $filter_state . $timestamp_filter . ' ORDER BY timestamp DESC'; $new = true; while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) { $new = false; if (!check_acl($config["id_user"], $event["id_grupo"], "AR") || (!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system')) continue; echo $event["timestamp"]; echo ","; echo io_safe_output(agents_get_name($event["id_agente"])); echo ","; echo io_safe_output(groups_get_name($event["id_grupo"])); echo ","; echo io_safe_output($event["evento"]); echo ","; echo io_safe_output($event["estado"]); echo ","; echo io_safe_output($event["id_usuario"]); echo ","; echo io_safe_output($event["event_type"]); echo ","; echo $event["criticity"]; echo chr (13); } ?>