system.php 2.4 KB

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