Issues (1270)

classes/pref/system.php (3 issues)

1
<?php
2
3
class Pref_System extends Handler_Protected {
4
5
    public 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
    public function csrf_ignore($method) {
17
        $csrf_ignored = array("index");
18
19
        return array_search($method, $csrf_ignored) !== false;
20
    }
21
22
    public function clearLog() {
23
        $this->pdo->query("DELETE FROM ttrss_error_log");
24
    }
25
26
    public function index() {
27
28
        print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
29
        print "<div dojoType=\"dijit.layout.AccordionPane\"
30
			title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">";
31
32
        if (LOG_DESTINATION == "sql") {
0 ignored issues
show
The constant LOG_DESTINATION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
34
            $res = $this->pdo->query("SELECT errno, errstr, filename, lineno,
35
				created_at, login, context FROM ttrss_error_log
36
				LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
37
				ORDER BY ttrss_error_log.id DESC
38
				LIMIT 100");
39
40
            print "<button dojoType=\"dijit.form.Button\"
41
				onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> ";
42
43
            print "&nbsp;<button dojoType=\"dijit.form.Button\"
44
				class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> ";
45
46
            print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
47
48
            print "<tr class=\"title\">
49
				<td width='5%'>".__("Error")."</td>
50
				<td>".__("Filename")."</td>
51
				<td>".__("Message")."</td>
52
				<td width='5%'>".__("User")."</td>
53
				<td width='5%'>".__("Date")."</td>
54
				</tr>";
55
56
            while ($line = $res->fetch()) {
57
                print "<tr>";
58
59
                foreach ($line as $k => $v) {
60
                    $line[$k] = htmlspecialchars($v);
61
                }
62
63
                print "<td class='errno'>".Logger::$errornames[$line["errno"]]." (".$line["errno"].")</td>";
64
                print "<td class='filename'>".$line["filename"].":".$line["lineno"]."</td>";
65
                print "<td class='errstr'>".$line["errstr"]."<hr/>".nl2br($line["context"])."</td>";
66
                print "<td class='login'>".$line["login"]."</td>";
67
68
                print "<td class='timestamp'>".
69
                    make_local_datetime(
70
                    $line["created_at"], false)."</td>";
71
72
                print "</tr>";
73
            }
74
75
            print "</table>";
76
        } else {
77
78
            print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
0 ignored issues
show
Deprecated Code introduced by
The function print_notice() has been deprecated: Use twig function noticeMessage ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

78
            /** @scrutinizer ignore-deprecated */ print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
The call to print_notice() has too many arguments starting with 'Please set LOG_DESTINAT...able database logging.'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

78
            /** @scrutinizer ignore-call */ 
79
            print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
79
80
        }
81
82
        print "</div>";
83
84
        print "<div dojoType=\"dijit.layout.AccordionPane\"
85
			title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">";
86
87
        ob_start();
88
        phpinfo();
89
        $info = ob_get_contents();
90
        ob_end_clean();
91
92
        print "<div class='phpinfo'>";
93
        print preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);
94
        print "</div>";
95
96
        print "</div>";
97
98
        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
99
            "hook_prefs_tab", "prefSystem");
100
101
        print "</div>"; #container
102
    }
103
104
}
105