pandorafms/pandora_console/operation/events/export_csv.php

94 lines
3.1 KiB
PHP
Raw Normal View History

<?php
2008-07-25 Sancho Lerena <slerena@gmail.com> * pandoradb.sql: Added new tables for planned downtimes. * godmode/menu.php: Added entry for manage downtimes. * group_list.php: Stetic changes in table. * modificar_server.php: Fixed timestamp render for start/update timestamp of each server. * functions.php: Minimal estetic changes in help function. * functions_db.php: Change header (Flexible <- Free) * functions_html.php: Now select admits multiselect option. Default class for table render is now databox not databox_color. * AUTHORS: Update list of authors and make a reference to contributors. * function_reporting.php: Header change, updated datetime string format. * language_en.php, language_es_es.php: Changed FREE for Flexible. * pandora.css: Minimal changes. Update color of Monitor count in tactical. * menu.php: Added some new event options: CSV Export, RSS and new marquee event visualizer. * estado_ultimopaquete.php: Header update. * tactical.php: Added link to data module alerts. * ver_agente.php: Fixed a problem in ajax code that was rending bad count of down monitors. Using boolean comparation on result of function get_db_sql(). This kind problem could be in more lines of code. * events.php: New quicklinks to RSS, CSV and Marquee in event viewer. * export_csv.php, events_rss.php: Fixed duped call to function includes. * graph_viewer.php: I hope this fix FINALLY the annoying bug of graph type selector. * visual_console/index.php: Updated header. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@973 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-07-25 20:37:32 +02:00
// Pandora FMS - the Flexible Monitoring System
// ============================================
// Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
session_start();
include ("../../include/config.php");
include ("../../include/functions.php");
2008-07-25 Sancho Lerena <slerena@gmail.com> * pandoradb.sql: Added new tables for planned downtimes. * godmode/menu.php: Added entry for manage downtimes. * group_list.php: Stetic changes in table. * modificar_server.php: Fixed timestamp render for start/update timestamp of each server. * functions.php: Minimal estetic changes in help function. * functions_db.php: Change header (Flexible <- Free) * functions_html.php: Now select admits multiselect option. Default class for table render is now databox not databox_color. * AUTHORS: Update list of authors and make a reference to contributors. * function_reporting.php: Header change, updated datetime string format. * language_en.php, language_es_es.php: Changed FREE for Flexible. * pandora.css: Minimal changes. Update color of Monitor count in tactical. * menu.php: Added some new event options: CSV Export, RSS and new marquee event visualizer. * estado_ultimopaquete.php: Header update. * tactical.php: Added link to data module alerts. * ver_agente.php: Fixed a problem in ajax code that was rending bad count of down monitors. Using boolean comparation on result of function get_db_sql(). This kind problem could be in more lines of code. * events.php: New quicklinks to RSS, CSV and Marquee in event viewer. * export_csv.php, events_rss.php: Fixed duped call to function includes. * graph_viewer.php: I hope this fix FINALLY the annoying bug of graph type selector. * visual_console/index.php: Updated header. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@973 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-07-25 20:37:32 +02:00
include_once ("../../include/functions_db.php");
session_write_close();
$config["id_user"] = $_SESSION["id_usuario"];
if ( (give_acl($config["id_user"], 0, "AR")==0) AND (give_acl($config["id_user"], 0, "AW")==0) ){
require ("../../general/noaccess.php");
exit;
}
$offset = get_parameter ( "offset",0);
$ev_group = get_parameter ("ev_group", 0); // group
$search = get_parameter ("search", ""); // free search
$event_type = get_parameter ("event_type", "all"); // 0 all
$severity = get_parameter ("severity", -1); // -1 all
$status = get_parameter ("status", -1); // -1 all, 0 only red, 1 only green
$id_agent = get_parameter ("id_agent", -1);
$sql_post = "";
if ($ev_group > 1)
$sql_post .= " AND id_grupo = $ev_group";
if ($status == 1)
$sql_post .= " AND estado = 1";
if ($status == 0)
$sql_post .= " AND estado = 0";
if ($search != "")
$sql_post .= " AND evento LIKE '%$search%'";
if (($event_type != "all") AND ($event_type != 0))
$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";
$sql2 = "SELECT * FROM tevento WHERE 1=1 ";
$sql2 .= $sql_post . " ORDER BY 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);
$result=mysql_query($sql2);
while ($row=mysql_fetch_array($result)){
$id_grupo = $row["id_grupo"];
if (give_acl($config["id_user"], $id_grupo, "AR") == 1){ // Only incident read access to view data !
echo $row["timestamp"];
echo ", ";
echo get_db_sql("SELECT nombre FROM tagente WHERE id_agente = '".$row["id_agente"]."'");
echo ", ";
echo get_db_sql("SELECT nombre FROM tgrupo WHERE id_grupo = '".$row["id_grupo"]."'");
echo ", ";
echo $row["evento"];
echo ", ";
echo $row["estado"];
echo ", ";
echo $row["id_usuario"];
echo ", ";
echo $row["event_type"];
echo ", ";
echo $row["criticity"];
echo chr(13);
}
}
?>