system.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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->pdo->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\"
  23. title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">";
  24. if (LOG_DESTINATION == "sql") {
  25. $res = $this->pdo->query("SELECT errno, errstr, filename, lineno,
  26. created_at, login, context FROM ttrss_error_log
  27. LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
  28. ORDER BY ttrss_error_log.id DESC
  29. LIMIT 100");
  30. print "<button dojoType=\"dijit.form.Button\"
  31. onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> ";
  32. print "&nbsp;<button dojoType=\"dijit.form.Button\"
  33. class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> ";
  34. print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
  35. print "<tr class=\"title\">
  36. <td width='5%'>".__("Error")."</td>
  37. <td>".__("Filename")."</td>
  38. <td>".__("Message")."</td>
  39. <td width='5%'>".__("User")."</td>
  40. <td width='5%'>".__("Date")."</td>
  41. </tr>";
  42. while ($line = $res->fetch()) {
  43. print "<tr class=\"errrow\">";
  44. foreach ($line as $k => $v) {
  45. $line[$k] = htmlspecialchars($v);
  46. }
  47. print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>";
  48. print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>";
  49. print "<td class='errstr'>" . $line["errstr"] . "<hr/>" . nl2br($line["context"]) . "</td>";
  50. print "<td class='login'>" . $line["login"] . "</td>";
  51. print "<td class='timestamp'>" .
  52. make_local_datetime(
  53. $line["created_at"], false) . "</td>";
  54. print "</tr>";
  55. }
  56. print "</table>";
  57. } else {
  58. print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
  59. }
  60. print "</div>";
  61. PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
  62. "hook_prefs_tab", "prefSystem");
  63. print "</div>"; #container
  64. }
  65. }