96ac2cdd1ac541ca6b39983bfb7c8d63ab3d2617
[gnucomo.git] / src / web / log.php
1 <?php 
2
3 /**************************************************************************
4 ** This is free software; you can redistribute it and/or modify it under the
5 ** terms of the GNU General Public License, see the file COPYING.
6 ***************************************************************************/
7
8 /*
9  *
10  * Objects Administration page.
11  * Input parameters: action (POST) : empty, 'Create'
12  *                   objname (POST) : name of the object to create or remove
13  */
14
15 session_start();
16 require_once('classes/gnucomo_config.php');
17 ?>
18
19 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
20 <html>
21 <head>
22 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
23 <link rel='stylesheet' href='gnucomo.css' type='text/css'>
24 <title>GNUCoMo login</title>
25
26 <script language='JavaScript'>
27 function CheckCreate(f)
28 {
29    if (f.objectname.value == "")
30    {
31       alert("You must supply a name");
32       return false;
33    }
34    return true;
35 }
36
37 function CheckRemove(f)
38 {
39    var message = "Are you sure you want to remove object ";
40    message += f.objectname.value;
41    message += " ?";
42
43    return confirm(message);
44 }
45
46 </script>
47
48 </head>
49 <body>
50 <?php
51 if (empty($_SESSION['username']))
52 {
53    echo "Please log in first.";
54 }
55 else
56 {
57
58    $config = new gnucomo_config;
59
60    $config->read("gnucomo");
61
62    //  Connect to the database
63    $conn = pg_connect($config->Database($_SESSION['username'], $_SESSION['password']));
64
65    if (!empty($_GET['oid']))
66    {
67       $res = pg_exec("SELECT objectname FROM object WHERE objectid=" . $_GET['oid']);
68       $obj = pg_fetch_object($res, 0);
69       echo "<h1>Log for " . $obj->objectname . "</h1><hr>";
70
71       $res = pg_exec("SELECT object_timestamp, servicecode, rawdata FROM log "
72                      ."WHERE objectid=" . $_GET['oid']);
73       
74       echo "<table>";
75       $row = 0;
76       while ($row < pg_numrows($res))
77       {
78          $log = pg_fetch_object($res, $row);
79          ?>
80          <tr><td align='center'>
81             <?php echo $log->object_timestamp?>
82          </td><td>
83             <?php echo $log->servicecode?>
84          </td><td>
85             <?php echo $log->rawdata?>
86          </td></tr>
87          <?php
88          $row++;
89       }
90       echo "</table>";
91    }
92 }
93 ?>
94
95 </body>
96 </html>