Rev 321 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 321 | Rev 360 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | } |
23 | } |
24 | 24 | ||
25 | public function gui($id, &$out, &$handled) { |
25 | public function gui($id, &$out, &$handled) { |
26 | if ($id == 'oidplus:system_log') { |
26 | if ($id == 'oidplus:system_log') { |
27 | $handled = true; |
27 | $handled = true; |
28 | $out['title'] = "All log messages"; |
28 | $out['title'] = _L('All log messages'); |
29 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
29 | $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : ''; |
30 | 30 | ||
31 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
31 | if (!OIDplus::authUtils()::isAdminLoggedIn()) { |
32 | $out['icon'] = 'img/error_big.png'; |
32 | $out['icon'] = 'img/error_big.png'; |
33 | $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>'; |
33 | $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login')).'</p>'; |
34 | return; |
34 | return; |
35 | } |
35 | } |
36 | 36 | ||
37 | $res = OIDplus::db()->query("select lo.id, lo.unix_ts, lo.addr, lo.event from ###log lo ". |
37 | $res = OIDplus::db()->query("select lo.id, lo.unix_ts, lo.addr, lo.event from ###log lo ". |
38 | "order by lo.unix_ts desc"); |
38 | "order by lo.unix_ts desc"); |
Line 46... | Line 46... | ||
46 | "where log_id = ?", array($row['id'])); |
46 | "where log_id = ?", array($row['id'])); |
47 | while ($row2 = $res2->fetch_array()) { |
47 | while ($row2 = $res2->fetch_array()) { |
48 | $users[] = $row2['username']; |
48 | $users[] = $row2['username']; |
49 | if ($row2['username'] == 'admin') $severity = $row2['severity']; |
49 | if ($row2['username'] == 'admin') $severity = $row2['severity']; |
50 | } |
50 | } |
51 | $users = count($users) > 0 ? "; affected users: ".implode(', ',$users) : ''; |
51 | $users = count($users) > 0 ? '; '._L('affected users: %1',implode(', ',$users)) : ''; |
52 | // --- |
52 | // --- |
53 | $objects = array(); |
53 | $objects = array(); |
54 | $res2 = OIDplus::db()->query("select object, severity from ###log_object ". |
54 | $res2 = OIDplus::db()->query("select object, severity from ###log_object ". |
55 | "where log_id = ?", array($row['id'])); |
55 | "where log_id = ?", array($row['id'])); |
56 | while ($row2 = $res2->fetch_array()) { |
56 | while ($row2 = $res2->fetch_array()) { |
57 | $objects[] = $row2['object']; |
57 | $objects[] = $row2['object']; |
58 | } |
58 | } |
59 | $objects = count($objects) > 0 ? "; affected objects: ".implode(', ',$objects) : ''; |
59 | $objects = count($objects) > 0 ? '; '._L('affected objects: %1',implode(', ',$objects)) : ''; |
60 | // --- |
60 | // --- |
61 | $addr = empty($row['addr']) ? 'no address' : $row['addr']; |
61 | $addr = empty($row['addr']) ? _L('no address') : $row['addr']; |
62 | // --- |
62 | // --- |
63 | $out['text'] .= '<span class="severity_'.$severity.'">' . date('Y-m-d H:i:s', $row['unix_ts']) . ': ' . htmlentities($row["event"])." (" . htmlentities($addr.$users.$objects) . ")</span>\n"; |
63 | $out['text'] .= '<span class="severity_'.$severity.'">' . date('Y-m-d H:i:s', $row['unix_ts']) . ': ' . htmlentities($row["event"])." (" . htmlentities($addr.$users.$objects) . ")</span>\n"; |
64 | } |
64 | } |
65 | $out['text'] .= '</pre>'; |
65 | $out['text'] .= '</pre>'; |
66 | } else { |
66 | } else { |
67 | $out['text'] .= '<p>Currently there are no log entries</p>'; |
67 | $out['text'] .= '<p>'._L('Currently there are no log entries').'</p>'; |
68 | } |
68 | } |
69 | 69 | ||
70 | // TODO: List logs in a table instead of a <pre> text |
70 | // TODO: List logs in a table instead of a <pre> text |
71 | // TODO: Load only X events and then re-load new events via AJAX when the user scrolls down |
71 | // TODO: Load only X events and then re-load new events via AJAX when the user scrolls down |
72 | } |
72 | } |
Line 82... | Line 82... | ||
82 | } |
82 | } |
83 | 83 | ||
84 | $json[] = array( |
84 | $json[] = array( |
85 | 'id' => 'oidplus:system_log', |
85 | 'id' => 'oidplus:system_log', |
86 | 'icon' => $tree_icon, |
86 | 'icon' => $tree_icon, |
87 | 'text' => 'All log events' |
87 | 'text' => _L('All log messages') |
88 | ); |
88 | ); |
89 | 89 | ||
90 | return true; |
90 | return true; |
91 | } |
91 | } |
92 | 92 |