3 /**************************************************************************
4 ** (c) Copyright 2003, Andromeda Technology & Automation
5 ** This is free software; you can redistribute it and/or modify it under the
6 ** terms of the GNU General Public License, see the file COPYING.
7 ***************************************************************************
8 ** MODULE INFORMATION *
9 ***********************
10 ** FILE NAME : log.php
11 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
12 ** VERSION NUMBER : $Revision: 1.8 $
14 ** DESCRIPTION : Logs page
19 ***************************************************************************
20 ** ADMINISTRATIVE INFORMATION *
21 ********************************
22 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
23 ** CREATION DATE : Dec 04, 2002
24 ** LAST UPDATE : Jul 15, 2003
26 **************************************************************************/
28 /*****************************
30 Revision 1.8 2007-11-21 14:38:06 arjen
31 The buttonbar at the top of each page is now a fixed 'div' element
32 instead of a framed page.
33 Contributed by Edwin Nadorp.
35 Revision 1.7 2007/10/27 08:38:18 arjen
36 Removed link to advanced log analysis
38 Revision 1.6 2005/06/04 07:18:26 arjen
39 Added a view for the log analysis with a link from the log page.
41 Revision 1.5 2003/08/11 17:59:17 arjen
42 BUGFIX: Convert special characters for HTML (<, >, and &) into
45 Revision 1.4 2003/07/15 11:03:39 arjen
46 Show the log one day at a time.
48 Revision 1.3 2003/02/21 08:50:12 arjen
49 Database optimizations.
51 Revision 1.2 2003/02/13 09:01:29 arjen
52 All web interface pages use the page class.
54 Revision 1.2 2003/02/05 09:48:14 arjen
55 Added display and handling of notifications
57 ******************************/
59 // RCSID = "$Id: log.php,v 1.8 2007-11-21 14:38:06 arjen Exp $";
61 ini_set('include_path', '.:./classes:../phpclasses');
63 require_once('page.class.php');
66 class log_page extends page
71 if (!empty($_GET['oid']))
74 $res = pg_exec($this->database, "SELECT objectname FROM object
75 WHERE objectid=CAST('$oid' AS BIGINT)");
76 $obj = pg_fetch_object($res, 0);
77 echo "<script type='text/ecmascript'>
78 document.getElementById('menu_title').innerHTML = \"<h1>Log for "
79 . $obj->objectname . "<\/h1>\"
82 // Determine which day to display.
83 // This is either from a previous button though a _POST[] variable
84 // or the last day in the log table by default.
86 if (empty($_GET['logday']))
88 $res = pg_exec($this->database, "SELECT date_trunc('day',object_timestamp) FROM log
90 ORDER BY object_timestamp DESC LIMIT 1");
92 if( pg_num_rows($res) > 0 )
94 $last_time = pg_fetch_object($res, 0);
95 $logday = strtotime($last_time->date_trunc);
104 $logday = $_GET['logday'];
107 // Make buttons to request the previous and the next day of logs.
109 echo "<div id=\"log_date\">";
110 $logday1 = $logday - 24 * 60 * 60;
111 echo "<a href=\"log.php?oid=$oid&logday=$logday1\" title=\"previous day\"><<</a>";
112 echo " " . date('F d, Y', $logday) . " ";
113 $logday2 = $logday + 24 * 60 * 60;
114 echo "<a href=\"log.php?oid=$oid&logday=$logday2\" title=\"next day\">>></a>";
117 // Show the log for one day only.
119 $res = pg_exec($this->database, "SELECT logid, object_timestamp, servicecode, rawdata FROM log "
120 ."WHERE objectid = CAST('$oid' AS BIGINT)
121 AND date_trunc('day', object_timestamp)='" . date('Y-m-d', $logday) . "'
122 ORDER BY object_timestamp, logid");
125 echo "<tr><th>Date</th><th>Service</th><th>Log</th></tr>\n";
127 while ($row < pg_numrows($res))
129 $log = pg_fetch_object($res, $row);
131 <tr><td class='time'>
132 <?php echo $log->object_timestamp?>
134 <?php echo $log->servicecode?>
136 <?php echo htmlentities($log->rawdata)?>
146 $page = new log_page("Gnucomo system logs");