]> git.wh0rd.org - tt-rss.git/blame - classes/pref/system.php
make logging configurable; add logging to syslog
[tt-rss.git] / classes / pref / system.php
CommitLineData
2cbdc95b
AD
1<?php
2
3class 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
22 function index() {
23
24 print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
25 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Error Log')."\">";
26
b367c951
AD
27 if (LOG_DESTINATION == "sql") {
28
29 $result = $this->dbh->query("SELECT errno, errstr, filename, lineno,
30 created_at, login FROM ttrss_error_log
31 LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
32 ORDER BY ttrss_error_log.id DESC
33 LIMIT 100");
34
35 print "<button dojoType=\"dijit.form.Button\"
36 onclick=\"updateSystemList()\">".__('Refresh')."</button> ";
37
38 print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
39
40 print "<tr class=\"title\">
41 <td width='5%'>".__("Error")."</td>
42 <td>".__("Filename")."</td>
43 <td>".__("Message")."</td>
44 <td width='5%'>".__("User")."</td>
45 <td width='5%'>".__("Date")."</td>
46 </tr>";
47
48 while ($line = $this->dbh->fetch_assoc($result)) {
49 print "<tr class=\"errrow\">";
50
51 foreach ($line as $k => $v) {
52 $line[$k] = htmlspecialchars($v);
53 }
54
55 print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>";
56 print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>";
57 print "<td class='errstr'>" . $line["errstr"] . "</td>";
58 print "<td class='login'>" . $line["login"] . "</td>";
59
60 print "<td class='timestamp'>" .
61 make_local_datetime(
62 $line["created_at"], false) . "</td>";
63
64 print "</tr>";
2cbdc95b
AD
65 }
66
b367c951
AD
67 print "</table>";
68 } else {
2cbdc95b 69
b367c951 70 print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
2cbdc95b 71
2cbdc95b
AD
72 }
73
2cbdc95b
AD
74 print "</div>";
75
1ffe3391 76 PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
2cbdc95b
AD
77 "hook_prefs_tab", "prefSystem");
78
79 print "</div>"; #container
80 }
81
82}
83?>