Rev 1445 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1445 | Rev 1448 | ||
---|---|---|---|
Line 76... | Line 76... | ||
76 | $res = OIDplus::db()->query("select lo.id, lo.unix_ts, lo.addr, lo.event, lu.severity from ###log lo ". |
76 | $res = OIDplus::db()->query("select lo.id, lo.unix_ts, lo.addr, lo.event, lu.severity from ###log lo ". |
77 | "left join ###log_object lu on lu.log_id = lo.id ". |
77 | "left join ###log_object lu on lu.log_id = lo.id ". |
78 | "where lu.object = ? " . |
78 | "where lu.object = ? " . |
79 | "order by lo.unix_ts desc", array($id)); |
79 | "order by lo.unix_ts desc", array($id)); |
80 | $text .= '<h2>'._L('Log messages for object %1',htmlentities($id)).'</h2>'; |
80 | $text .= '<h2>'._L('Log messages for object %1',htmlentities($id)).'</h2>'; |
- | 81 | ||
- | 82 | $text .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
|
- | 83 | $text .= '<table class="table table-bordered table-striped">'; |
|
81 | $max_ent = 0; |
84 | $text .= '<thead>'; |
- | 85 | $text .= '<tr><th>'._L('Time').'</th><th>'._L('Event').'</th><th>'._L('Affected users').'</th><!--<th>'._L('Affected objects').'</th>--><th>'._L('IP Address').'</th></tr>'; |
|
- | 86 | $text .= '</thead>'; |
|
- | 87 | $text .= '<tbody>'; |
|
- | 88 | ||
82 | if ($res->any()) { |
89 | if ($res->any()) { |
83 | $text .= '<pre>'; |
90 | $count = 0; |
84 | while ($row = $res->fetch_array()) { |
91 | while ($row = $res->fetch_array()) { |
85 | $max_ent++; |
92 | $count++; |
86 | if ($max_ent > 100) break; // TODO: also allow to watch older entries |
93 | if ($count > 100) break; // TODO: also allow to watch older entries |
- | 94 | ||
- | 95 | $addr = empty($row['addr']) ? _L('no address') : $row['addr']; |
|
- | 96 | ||
87 | $users = array(); |
97 | $users = array(); |
88 | $res2 = OIDplus::db()->query("select username, severity from ###log_user ". |
98 | $res2 = OIDplus::db()->query("select username, severity from ###log_user ". |
89 | "where log_id = ?", array((int)$row['id'])); |
99 | "where log_id = ?", array((int)$row['id'])); |
90 | while ($row2 = $res2->fetch_array()) { |
100 | while ($row2 = $res2->fetch_array()) { |
91 | $users[] = $row2['username']; |
101 | $users[] = $row2['username']; |
92 | } |
102 | } |
93 | $users = count($users) > 0 ? ", ".implode('/',$users) : ''; |
103 | $users = implode("\n",$users); |
94 | - | ||
95 | $addr = empty($row['addr']) ? _L('no address') : $row['addr']; |
- | |
96 | 104 | ||
- | 105 | $a = '<span class="severity_'.$row['severity'].'">'; |
|
- | 106 | $b = '</span>'; |
|
- | 107 | $text .= '<tr>'; |
|
97 | $text .= '<span class="severity_'.$row['severity'].'">' . date('Y-m-d H:i:s', (int)$row['unix_ts']) . ': ' . htmlentities($row["event"]??'')." (" . htmlentities($addr.$users) . ")</span>\n"; |
108 | $text .= '<td>'.$a.date('Y-m-d H:i:s', (int)$row['unix_ts']).$b.'</td>'; |
- | 109 | $text .= '<td>'.$a.htmlentities($row['event']).$b.'</td>'; |
|
- | 110 | $text .= '<td>'.$a.nl2br(htmlentities($users)).$b.'</td>'; |
|
- | 111 | #$text .= '<td>'.$a.nl2br(htmlentities($objects)).$b.'</td>'; |
|
- | 112 | $text .= '<td>'.$a.htmlentities($addr).$b.'</td>'; |
|
- | 113 | $text .= '<tr>'; |
|
98 | } |
114 | } |
99 | $text .= '</pre>'; |
- | |
100 | - | ||
101 | // TODO: List logs in a table instead of a <pre> text |
- | |
102 | } else { |
115 | } else { |
103 | $text .= '<p>'._L('Currently there are no log entries').'</p>'; |
116 | $text .= '<tr><td colspan="4">'._L('There are no log entries on this page').'</td></tr>'; |
104 | } |
117 | } |
105 | 118 | ||
- | 119 | $text .= '</tbody>'; |
|
- | 120 | $text .= '</table>'; |
|
- | 121 | $text .= '</div></div>'; |
|
106 | } |
122 | } |
107 | 123 | ||
108 | /** |
124 | /** |
109 | * @param string $request |
125 | * @param string $request |
110 | * @return array|false |
126 | * @return array|false |