Removed link to advanced log analysis
[gnucomo.git] / src / web / log.php
1 <?php
2
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.7 $
13 **
14 **  DESCRIPTION      : Logs page
15 **
16 **  EXPORTED OBJECTS : 
17 **  LOCAL    OBJECTS : 
18 **  MODULES  USED    :
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
25 **      MODIFICATIONS   : 
26 **************************************************************************/
27
28 /*****************************
29    $Log: log.php,v $
30    Revision 1.7  2007-10-27 08:38:18  arjen
31    Removed link to advanced log analysis
32
33    Revision 1.6  2005/06/04 07:18:26  arjen
34    Added a view for the log analysis with a link from the log page.
35
36    Revision 1.5  2003/08/11 17:59:17  arjen
37    BUGFIX: Convert special characters for HTML (<, >, and &) into
38    their entities.
39
40    Revision 1.4  2003/07/15 11:03:39  arjen
41    Show the log one day at a time.
42
43    Revision 1.3  2003/02/21 08:50:12  arjen
44    Database optimizations.
45
46    Revision 1.2  2003/02/13 09:01:29  arjen
47    All web interface pages use the page class.
48
49    Revision 1.2  2003/02/05 09:48:14  arjen
50    Added display and handling of notifications
51
52 ******************************/
53
54 // RCSID = "$Id: log.php,v 1.7 2007-10-27 08:38:18 arjen Exp $";
55
56 ini_set('include_path', '.:./classes:../phpclasses');
57
58 require_once('page.class.php');
59
60
61 class log_page extends page
62 {
63
64    function Body()
65    {
66       if (!empty($_GET['oid']))
67       {
68          $res = pg_exec($this->database, "SELECT objectname FROM object
69                                WHERE objectid=CAST('" . $_GET['oid']. "' AS BIGINT)");
70          $obj = pg_fetch_object($res, 0);
71          echo "<h1>Log for " . $obj->objectname . "</h1><hr>";
72
73          //  Determine which day to display.
74          //  This is either from a previous button though a _POST[] variable
75          //  or the last day in the log table by default.
76
77          if (empty($_POST['logday']))
78          {
79             $res = pg_exec($this->database, "SELECT date_trunc('day',object_timestamp) FROM log
80                                   WHERE objectid='". $_GET['oid'] ."'
81                                   ORDER BY object_timestamp DESC LIMIT 1");
82
83             $last_time = pg_fetch_object($res, 0);
84             $logday = strtotime($last_time->date_trunc);
85          }
86          else
87          {
88             $logday = $_POST['logday'];
89          }
90
91          //  Make buttons to request the previous and the next day of logs.
92
93          echo "<form method='POST'>";
94          echo "<input type='submit' value='<<'>";
95          echo "<input type='hidden' name='logday' value='" . ($logday - 24 * 60 * 60) . "'>";
96          echo "</form>";
97
98          echo "<h3>" . date('F d, Y', $logday) ."</h3>";
99
100          echo "<form method='POST'>";
101          echo "<input type='submit' value='>>'>";
102          echo "<input type='hidden' name='logday' value='" . ($logday + 24 * 60 * 60) . "'>";
103          echo "</form>";
104
105          // Show the log for one day only.
106
107          $res = pg_exec($this->database, "SELECT logid, object_timestamp, servicecode, rawdata FROM log "
108                         ."WHERE objectid = CAST('" . $_GET['oid'] . "' AS BIGINT)
109                          AND date_trunc('day', object_timestamp)='" . date('Y-m-d', $logday) . "'
110                          ORDER BY object_timestamp, logid");
111
112          echo "<table>\n";
113          echo "<tr><th>Date</th><th>Service</th><th>Log</th></tr>\n";
114          $row = 0;
115          while ($row < pg_numrows($res))
116          {
117             $log = pg_fetch_object($res, $row);
118             ?>
119             <tr><td class='time'>
120                  <?php echo $log->object_timestamp?>
121             </td><td>
122                <?php echo $log->servicecode?>
123             </td><td>
124                <?php echo htmlentities($log->rawdata)?>
125             </td></tr>
126             <?php
127             $row++;
128          }
129          echo "</table>";
130       }
131    }
132 }
133
134 $page = new log_page("Gnucomo system logs");
135
136 $page->Showpage();
137
138 ?>