]>
Commit | Line | Data |
---|---|---|
2cbdc95b AD |
1 | <?php |
2 | ||
3 | class Pref_System extends Handler_Protected { | |
4 | ||
2cbdc95b AD |
5 | function before($method) { |
6 | if (parent::before($method)) { | |
7 | if ($_SESSION["access_level"] < 10) { | |
8 | print __("Your access level is insufficient to open this tab."); | |
9 | return false; | |
10 | } | |
11 | return true; | |
12 | } | |
13 | return false; | |
14 | } | |
15 | ||
16 | function csrf_ignore($method) { | |
17 | $csrf_ignored = array("index"); | |
18 | ||
19 | return array_search($method, $csrf_ignored) !== false; | |
20 | } | |
21 | ||
52e7b5a0 AD |
22 | function clearLog() { |
23 | $this->dbh->query("DELETE FROM ttrss_error_log"); | |
24 | } | |
25 | ||
2cbdc95b AD |
26 | function index() { |
27 | ||
28 | print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; | |
29 | print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Error Log')."\">"; | |
30 | ||
b367c951 AD |
31 | if (LOG_DESTINATION == "sql") { |
32 | ||
33 | $result = $this->dbh->query("SELECT errno, errstr, filename, lineno, | |
34 | created_at, login FROM ttrss_error_log | |
35 | LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) | |
36 | ORDER BY ttrss_error_log.id DESC | |
37 | LIMIT 100"); | |
38 | ||
39 | print "<button dojoType=\"dijit.form.Button\" | |
40 | onclick=\"updateSystemList()\">".__('Refresh')."</button> "; | |
41 | ||
52e7b5a0 AD |
42 | print " <button dojoType=\"dijit.form.Button\" |
43 | onclick=\"clearSqlLog()\">".__('Clear log')."</button> "; | |
44 | ||
b367c951 AD |
45 | print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; |
46 | ||
47 | print "<tr class=\"title\"> | |
48 | <td width='5%'>".__("Error")."</td> | |
49 | <td>".__("Filename")."</td> | |
50 | <td>".__("Message")."</td> | |
51 | <td width='5%'>".__("User")."</td> | |
52 | <td width='5%'>".__("Date")."</td> | |
53 | </tr>"; | |
54 | ||
55 | while ($line = $this->dbh->fetch_assoc($result)) { | |
56 | print "<tr class=\"errrow\">"; | |
57 | ||
58 | foreach ($line as $k => $v) { | |
59 | $line[$k] = htmlspecialchars($v); | |
60 | } | |
61 | ||
62 | print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>"; | |
63 | print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>"; | |
64 | print "<td class='errstr'>" . $line["errstr"] . "</td>"; | |
65 | print "<td class='login'>" . $line["login"] . "</td>"; | |
66 | ||
67 | print "<td class='timestamp'>" . | |
68 | make_local_datetime( | |
69 | $line["created_at"], false) . "</td>"; | |
70 | ||
71 | print "</tr>"; | |
2cbdc95b AD |
72 | } |
73 | ||
b367c951 AD |
74 | print "</table>"; |
75 | } else { | |
2cbdc95b | 76 | |
b367c951 | 77 | print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); |
2cbdc95b | 78 | |
2cbdc95b AD |
79 | } |
80 | ||
2cbdc95b AD |
81 | print "</div>"; |
82 | ||
1ffe3391 | 83 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
2cbdc95b AD |
84 | "hook_prefs_tab", "prefSystem"); |
85 | ||
86 | print "</div>"; #container | |
87 | } | |
88 | ||
89 | } | |
90 | ?> |