@@ -2,50 +2,50 @@ discard block |
||
2 | 2 | |
3 | 3 | class Pref_System extends Handler_Protected { |
4 | 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\" |
|
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 | 30 | title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">"; |
31 | 31 | |
32 | - if (LOG_DESTINATION == "sql") { |
|
32 | + if (LOG_DESTINATION == "sql") { |
|
33 | 33 | |
34 | - $res = $this->pdo->query("SELECT errno, errstr, filename, lineno, |
|
34 | + $res = $this->pdo->query("SELECT errno, errstr, filename, lineno, |
|
35 | 35 | created_at, login, context FROM ttrss_error_log |
36 | 36 | LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) |
37 | 37 | ORDER BY ttrss_error_log.id DESC |
38 | 38 | LIMIT 100"); |
39 | 39 | |
40 | - print "<button dojoType=\"dijit.form.Button\" |
|
40 | + print "<button dojoType=\"dijit.form.Button\" |
|
41 | 41 | onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> "; |
42 | 42 | |
43 | - print " <button dojoType=\"dijit.form.Button\" |
|
43 | + print " <button dojoType=\"dijit.form.Button\" |
|
44 | 44 | class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> "; |
45 | 45 | |
46 | - print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; |
|
46 | + print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">"; |
|
47 | 47 | |
48 | - print "<tr class=\"title\"> |
|
48 | + print "<tr class=\"title\"> |
|
49 | 49 | <td width='5%'>".__("Error")."</td> |
50 | 50 | <td>".__("Filename")."</td> |
51 | 51 | <td>".__("Message")."</td> |
@@ -53,52 +53,52 @@ discard block |
||
53 | 53 | <td width='5%'>".__("Date")."</td> |
54 | 54 | </tr>"; |
55 | 55 | |
56 | - while ($line = $res->fetch()) { |
|
57 | - print "<tr>"; |
|
56 | + while ($line = $res->fetch()) { |
|
57 | + print "<tr>"; |
|
58 | 58 | |
59 | - foreach ($line as $k => $v) { |
|
60 | - $line[$k] = htmlspecialchars($v); |
|
61 | - } |
|
59 | + foreach ($line as $k => $v) { |
|
60 | + $line[$k] = htmlspecialchars($v); |
|
61 | + } |
|
62 | 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>"; |
|
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 | 67 | |
68 | - print "<td class='timestamp'>" . |
|
69 | - make_local_datetime( |
|
70 | - $line["created_at"], false) . "</td>"; |
|
68 | + print "<td class='timestamp'>" . |
|
69 | + make_local_datetime( |
|
70 | + $line["created_at"], false) . "</td>"; |
|
71 | 71 | |
72 | - print "</tr>"; |
|
73 | - } |
|
72 | + print "</tr>"; |
|
73 | + } |
|
74 | 74 | |
75 | - print "</table>"; |
|
76 | - } else { |
|
75 | + print "</table>"; |
|
76 | + } else { |
|
77 | 77 | |
78 | - print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); |
|
78 | + print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); |
|
79 | 79 | |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | - print "</div>"; |
|
82 | + print "</div>"; |
|
83 | 83 | |
84 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
84 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
85 | 85 | title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">"; |
86 | 86 | |
87 | - ob_start(); |
|
88 | - phpinfo(); |
|
89 | - $info = ob_get_contents(); |
|
90 | - ob_end_clean(); |
|
87 | + ob_start(); |
|
88 | + phpinfo(); |
|
89 | + $info = ob_get_contents(); |
|
90 | + ob_end_clean(); |
|
91 | 91 | |
92 | - print "<div class='phpinfo'>"; |
|
93 | - print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info); |
|
94 | - print "</div>"; |
|
92 | + print "<div class='phpinfo'>"; |
|
93 | + print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info); |
|
94 | + print "</div>"; |
|
95 | 95 | |
96 | - print "</div>"; |
|
96 | + print "</div>"; |
|
97 | 97 | |
98 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
99 | - "hook_prefs_tab", "prefSystem"); |
|
98 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
99 | + "hook_prefs_tab", "prefSystem"); |
|
100 | 100 | |
101 | - print "</div>"; #container |
|
102 | - } |
|
101 | + print "</div>"; #container |
|
102 | + } |
|
103 | 103 | |
104 | 104 | } |
@@ -1,206 +1,206 @@ |
||
1 | 1 | <?php |
2 | 2 | class Dlg extends Handler_Protected { |
3 | - private $param; |
|
3 | + private $param; |
|
4 | 4 | private $params; |
5 | 5 | |
6 | 6 | function before($method) { |
7 | - if (parent::before($method)) { |
|
8 | - header("Content-Type: text/html"); # required for iframe |
|
7 | + if (parent::before($method)) { |
|
8 | + header("Content-Type: text/html"); # required for iframe |
|
9 | 9 | |
10 | - $this->param = $_REQUEST["param"]; |
|
11 | - return true; |
|
12 | - } |
|
13 | - return false; |
|
14 | - } |
|
10 | + $this->param = $_REQUEST["param"]; |
|
11 | + return true; |
|
12 | + } |
|
13 | + return false; |
|
14 | + } |
|
15 | 15 | |
16 | - public function importOpml() { |
|
17 | - print_notice("If you have imported labels and/or filters, you might need to reload preferences to see your new data."); |
|
16 | + public function importOpml() { |
|
17 | + print_notice("If you have imported labels and/or filters, you might need to reload preferences to see your new data."); |
|
18 | 18 | |
19 | - print "<div class='panel panel-scrollable'>"; |
|
19 | + print "<div class='panel panel-scrollable'>"; |
|
20 | 20 | |
21 | - $opml = new Opml($_REQUEST); |
|
21 | + $opml = new Opml($_REQUEST); |
|
22 | 22 | |
23 | - $opml->opml_import($_SESSION["uid"]); |
|
23 | + $opml->opml_import($_SESSION["uid"]); |
|
24 | 24 | |
25 | - print "</div>"; |
|
25 | + print "</div>"; |
|
26 | 26 | |
27 | - print "<footer class='text-center'>"; |
|
28 | - print "<button dojoType='dijit.form.Button' |
|
27 | + print "<footer class='text-center'>"; |
|
28 | + print "<button dojoType='dijit.form.Button' |
|
29 | 29 | onclick=\"dijit.byId('opmlImportDlg').execute()\">". |
30 | - __('Close this window')."</button>"; |
|
31 | - print "</footer>"; |
|
30 | + __('Close this window')."</button>"; |
|
31 | + print "</footer>"; |
|
32 | 32 | |
33 | - print "</div>"; |
|
33 | + print "</div>"; |
|
34 | 34 | |
35 | - //return; |
|
36 | - } |
|
35 | + //return; |
|
36 | + } |
|
37 | 37 | |
38 | - public function pubOPMLUrl() { |
|
39 | - $url_path = Opml::opml_publish_url(); |
|
38 | + public function pubOPMLUrl() { |
|
39 | + $url_path = Opml::opml_publish_url(); |
|
40 | 40 | |
41 | - print "<header>" . __("Your Public OPML URL is:") . "</header>"; |
|
41 | + print "<header>" . __("Your Public OPML URL is:") . "</header>"; |
|
42 | 42 | |
43 | - print "<section>"; |
|
43 | + print "<section>"; |
|
44 | 44 | |
45 | - print "<div class='panel text-center'>"; |
|
46 | - print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>"; |
|
47 | - print "</div>"; |
|
45 | + print "<div class='panel text-center'>"; |
|
46 | + print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>"; |
|
47 | + print "</div>"; |
|
48 | 48 | |
49 | - print "</section>"; |
|
49 | + print "</section>"; |
|
50 | 50 | |
51 | - print "<footer class='text-center'>"; |
|
51 | + print "<footer class='text-center'>"; |
|
52 | 52 | |
53 | - print "<button dojoType='dijit.form.Button' onclick=\"return Helpers.OPML.changeKey()\">". |
|
54 | - __('Generate new URL')."</button> "; |
|
53 | + print "<button dojoType='dijit.form.Button' onclick=\"return Helpers.OPML.changeKey()\">". |
|
54 | + __('Generate new URL')."</button> "; |
|
55 | 55 | |
56 | - print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">". |
|
57 | - __('Close this window')."</button>"; |
|
56 | + print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">". |
|
57 | + __('Close this window')."</button>"; |
|
58 | 58 | |
59 | - print "</footer>"; |
|
59 | + print "</footer>"; |
|
60 | 60 | |
61 | - //return; |
|
62 | - } |
|
61 | + //return; |
|
62 | + } |
|
63 | 63 | |
64 | - public function explainError() { |
|
65 | - print "<div class=\"errorExplained\">"; |
|
64 | + public function explainError() { |
|
65 | + print "<div class=\"errorExplained\">"; |
|
66 | 66 | |
67 | - if ($this->param == 1) { |
|
68 | - print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner."); |
|
67 | + if ($this->param == 1) { |
|
68 | + print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner."); |
|
69 | 69 | |
70 | - $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
70 | + $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
71 | 71 | |
72 | - print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); |
|
72 | + print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); |
|
73 | 73 | |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | - if ($this->param == 3) { |
|
77 | - print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner."); |
|
76 | + if ($this->param == 3) { |
|
77 | + print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner."); |
|
78 | 78 | |
79 | - $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
79 | + $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
80 | 80 | |
81 | - print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); |
|
81 | + print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp); |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | - print "</div>"; |
|
85 | + print "</div>"; |
|
86 | 86 | |
87 | - print "<footer class='text-center'>"; |
|
88 | - print "<button onclick=\"return CommonDialogs.closeInfoBox()\">". |
|
89 | - __('Close this window')."</button>"; |
|
90 | - print "</footer>"; |
|
87 | + print "<footer class='text-center'>"; |
|
88 | + print "<button onclick=\"return CommonDialogs.closeInfoBox()\">". |
|
89 | + __('Close this window')."</button>"; |
|
90 | + print "</footer>"; |
|
91 | 91 | |
92 | - //return; |
|
93 | - } |
|
92 | + //return; |
|
93 | + } |
|
94 | 94 | |
95 | - public function printTagCloud() { |
|
96 | - print "<div class='panel text-center'>"; |
|
95 | + public function printTagCloud() { |
|
96 | + print "<div class='panel text-center'>"; |
|
97 | 97 | |
98 | - // from here: http://www.roscripts.com/Create_tag_cloud-71.html |
|
98 | + // from here: http://www.roscripts.com/Create_tag_cloud-71.html |
|
99 | 99 | |
100 | - $sth = $this->pdo->prepare("SELECT tag_name, COUNT(post_int_id) AS count |
|
100 | + $sth = $this->pdo->prepare("SELECT tag_name, COUNT(post_int_id) AS count |
|
101 | 101 | FROM ttrss_tags WHERE owner_uid = ? |
102 | 102 | GROUP BY tag_name ORDER BY count DESC LIMIT 50"); |
103 | - $sth->execute([$_SESSION['uid']]); |
|
103 | + $sth->execute([$_SESSION['uid']]); |
|
104 | 104 | |
105 | - $tags = array(); |
|
105 | + $tags = array(); |
|
106 | 106 | |
107 | - while ($line = $sth->fetch()) { |
|
108 | - $tags[$line["tag_name"]] = $line["count"]; |
|
109 | - } |
|
107 | + while ($line = $sth->fetch()) { |
|
108 | + $tags[$line["tag_name"]] = $line["count"]; |
|
109 | + } |
|
110 | 110 | |
111 | 111 | if(count($tags) == 0 ){ return; } |
112 | 112 | |
113 | - ksort($tags); |
|
113 | + ksort($tags); |
|
114 | 114 | |
115 | - $max_size = 32; // max font size in pixels |
|
116 | - $min_size = 11; // min font size in pixels |
|
115 | + $max_size = 32; // max font size in pixels |
|
116 | + $min_size = 11; // min font size in pixels |
|
117 | 117 | |
118 | - // largest and smallest array values |
|
119 | - $max_qty = max(array_values($tags)); |
|
120 | - $min_qty = min(array_values($tags)); |
|
118 | + // largest and smallest array values |
|
119 | + $max_qty = max(array_values($tags)); |
|
120 | + $min_qty = min(array_values($tags)); |
|
121 | 121 | |
122 | - // find the range of values |
|
123 | - $spread = $max_qty - $min_qty; |
|
124 | - if ($spread == 0) { // we don't want to divide by zero |
|
125 | - $spread = 1; |
|
126 | - } |
|
122 | + // find the range of values |
|
123 | + $spread = $max_qty - $min_qty; |
|
124 | + if ($spread == 0) { // we don't want to divide by zero |
|
125 | + $spread = 1; |
|
126 | + } |
|
127 | 127 | |
128 | - // set the font-size increment |
|
129 | - $step = ($max_size - $min_size) / ($spread); |
|
128 | + // set the font-size increment |
|
129 | + $step = ($max_size - $min_size) / ($spread); |
|
130 | 130 | |
131 | - // loop through the tag array |
|
132 | - foreach ($tags as $key => $value) { |
|
133 | - // calculate font-size |
|
134 | - // find the $value in excess of $min_qty |
|
135 | - // multiply by the font-size increment ($size) |
|
136 | - // and add the $min_size set above |
|
137 | - $size = round($min_size + (($value - $min_qty) * $step)); |
|
131 | + // loop through the tag array |
|
132 | + foreach ($tags as $key => $value) { |
|
133 | + // calculate font-size |
|
134 | + // find the $value in excess of $min_qty |
|
135 | + // multiply by the font-size increment ($size) |
|
136 | + // and add the $min_size set above |
|
137 | + $size = round($min_size + (($value - $min_qty) * $step)); |
|
138 | 138 | |
139 | - $key_escaped = str_replace("'", "\\'", $key); |
|
139 | + $key_escaped = str_replace("'", "\\'", $key); |
|
140 | 140 | |
141 | - echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: " . |
|
142 | - $size . "px\" title=\"$value articles tagged with " . |
|
143 | - $key . '">' . $key . '</a> '; |
|
144 | - } |
|
141 | + echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: " . |
|
142 | + $size . "px\" title=\"$value articles tagged with " . |
|
143 | + $key . '">' . $key . '</a> '; |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | 147 | |
148 | - print "</div>"; |
|
148 | + print "</div>"; |
|
149 | 149 | |
150 | - print "<footer class='text-center'>"; |
|
151 | - print "<button dojoType='dijit.form.Button' |
|
150 | + print "<footer class='text-center'>"; |
|
151 | + print "<button dojoType='dijit.form.Button' |
|
152 | 152 | onclick=\"return CommonDialogs.closeInfoBox()\">". |
153 | - __('Close this window')."</button>"; |
|
154 | - print "</footer>"; |
|
153 | + __('Close this window')."</button>"; |
|
154 | + print "</footer>"; |
|
155 | 155 | |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | - public function generatedFeed() { |
|
158 | + public function generatedFeed() { |
|
159 | 159 | |
160 | - $this->params = explode(":", $this->param, 3); |
|
161 | - $feed_id = $this->params[0]; |
|
162 | - $is_cat = (bool) $this->params[1]; |
|
160 | + $this->params = explode(":", $this->param, 3); |
|
161 | + $feed_id = $this->params[0]; |
|
162 | + $is_cat = (bool) $this->params[1]; |
|
163 | 163 | |
164 | - $key = Feeds::get_feed_access_key($feed_id, $is_cat); |
|
164 | + $key = Feeds::get_feed_access_key($feed_id, $is_cat); |
|
165 | 165 | |
166 | - $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key; |
|
166 | + $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key; |
|
167 | 167 | |
168 | - $feed_title = Feeds::getFeedTitle($feed_id, $is_cat); |
|
168 | + $feed_title = Feeds::getFeedTitle($feed_id, $is_cat); |
|
169 | 169 | |
170 | - print "<header>".T_sprintf("%s can be accessed via the following secret URL:", $feed_title)."</header>"; |
|
170 | + print "<header>".T_sprintf("%s can be accessed via the following secret URL:", $feed_title)."</header>"; |
|
171 | 171 | |
172 | - print "<section>"; |
|
173 | - print "<div class='panel text-center'>"; |
|
174 | - print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>"; |
|
175 | - print "</div>"; |
|
176 | - print "</section>"; |
|
172 | + print "<section>"; |
|
173 | + print "<div class='panel text-center'>"; |
|
174 | + print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>"; |
|
175 | + print "</div>"; |
|
176 | + print "</section>"; |
|
177 | 177 | |
178 | - print "<footer>"; |
|
178 | + print "<footer>"; |
|
179 | 179 | |
180 | - print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/GeneratedFeeds\")'> |
|
180 | + print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/GeneratedFeeds\")'> |
|
181 | 181 | <i class='material-icons'>help</i> ".__("More info...")."</button>"; |
182 | 182 | |
183 | - print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">". |
|
184 | - __('Generate new URL')."</button> "; |
|
183 | + print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">". |
|
184 | + __('Generate new URL')."</button> "; |
|
185 | 185 | |
186 | - print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">". |
|
187 | - __('Close this window')."</button>"; |
|
186 | + print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">". |
|
187 | + __('Close this window')."</button>"; |
|
188 | 188 | |
189 | - print "</footer>"; |
|
189 | + print "</footer>"; |
|
190 | 190 | |
191 | - //return; |
|
192 | - } |
|
191 | + //return; |
|
192 | + } |
|
193 | 193 | |
194 | - public function defaultPasswordWarning() { |
|
194 | + public function defaultPasswordWarning() { |
|
195 | 195 | |
196 | - print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
196 | + print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
197 | 197 | |
198 | - print "<footer class='text-center'>"; |
|
199 | - print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">". |
|
200 | - __('Open Preferences')."</button> "; |
|
201 | - print "<button dojoType='dijit.form.Button' |
|
198 | + print "<footer class='text-center'>"; |
|
199 | + print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">". |
|
200 | + __('Open Preferences')."</button> "; |
|
201 | + print "<button dojoType='dijit.form.Button' |
|
202 | 202 | onclick=\"return CommonDialogs.closeInfoBox()\">". |
203 | - __('Close this window')."</button>"; |
|
204 | - print "</footeer>"; |
|
205 | - } |
|
203 | + __('Close this window')."</button>"; |
|
204 | + print "</footeer>"; |
|
205 | + } |
|
206 | 206 | } |
@@ -1,45 +1,45 @@ |
||
1 | 1 | <?php |
2 | 2 | class Logger_SQL { |
3 | 3 | |
4 | - private $pdo; |
|
4 | + private $pdo; |
|
5 | 5 | |
6 | - public function log_error($errno, $errstr, $file, $line, $context) { |
|
6 | + public function log_error($errno, $errstr, $file, $line, $context) { |
|
7 | 7 | |
8 | - // separate PDO connection object is used for logging |
|
9 | - if (!$this->pdo) $this->pdo = Db::instance()->pdo_connect(); |
|
8 | + // separate PDO connection object is used for logging |
|
9 | + if (!$this->pdo) $this->pdo = Db::instance()->pdo_connect(); |
|
10 | 10 | |
11 | - if ($this->pdo && get_schema_version() > 117) { |
|
11 | + if ($this->pdo && get_schema_version() > 117) { |
|
12 | 12 | |
13 | - $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
13 | + $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
14 | 14 | |
15 | - // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
16 | - $context = mb_substr($context, 0, 8192); |
|
15 | + // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
16 | + $context = mb_substr($context, 0, 8192); |
|
17 | 17 | |
18 | - $server_params = [ |
|
19 | - "IP" => "REMOTE_ADDR", |
|
20 | - "Request URI" => "REQUEST_URI", |
|
21 | - "User agent" => "HTTP_USER_AGENT", |
|
22 | - ]; |
|
18 | + $server_params = [ |
|
19 | + "IP" => "REMOTE_ADDR", |
|
20 | + "Request URI" => "REQUEST_URI", |
|
21 | + "User agent" => "HTTP_USER_AGENT", |
|
22 | + ]; |
|
23 | 23 | |
24 | - foreach ($server_params as $n => $p) { |
|
25 | - if (isset($_SERVER[$p])) |
|
26 | - $context .= "\n$n: " . $_SERVER[$p]; |
|
27 | - } |
|
24 | + foreach ($server_params as $n => $p) { |
|
25 | + if (isset($_SERVER[$p])) |
|
26 | + $context .= "\n$n: " . $_SERVER[$p]; |
|
27 | + } |
|
28 | 28 | |
29 | - // passed error message may contain invalid unicode characters, failing to insert an error here |
|
30 | - // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
31 | - $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
32 | - $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
29 | + // passed error message may contain invalid unicode characters, failing to insert an error here |
|
30 | + // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
31 | + $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
32 | + $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
33 | 33 | |
34 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
34 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
35 | 35 | (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES |
36 | 36 | (?, ?, ?, ?, ?, ?, NOW())"); |
37 | - $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
37 | + $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
38 | 38 | |
39 | - return $sth->rowCount(); |
|
40 | - } |
|
39 | + return $sth->rowCount(); |
|
40 | + } |
|
41 | 41 | |
42 | - return false; |
|
43 | - } |
|
42 | + return false; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
@@ -1,33 +1,33 @@ |
||
1 | 1 | <?php |
2 | 2 | class Logger_Syslog { |
3 | 3 | |
4 | - /** |
|
5 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
6 | - */ |
|
7 | - public function log_error($errno, $errstr, $file, $line, $context) { |
|
4 | + /** |
|
5 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
6 | + */ |
|
7 | + public function log_error($errno, $errstr, $file, $line, $context) { |
|
8 | 8 | |
9 | - switch ($errno) { |
|
10 | - case E_ERROR: |
|
11 | - case E_PARSE: |
|
12 | - case E_CORE_ERROR: |
|
13 | - case E_COMPILE_ERROR: |
|
14 | - case E_USER_ERROR: |
|
15 | - $priority = LOG_ERR; |
|
16 | - break; |
|
17 | - case E_WARNING: |
|
18 | - case E_CORE_WARNING: |
|
19 | - case E_COMPILE_WARNING: |
|
20 | - case E_USER_WARNING: |
|
21 | - $priority = LOG_WARNING; |
|
22 | - break; |
|
23 | - default: |
|
24 | - $priority = LOG_INFO; |
|
25 | - } |
|
9 | + switch ($errno) { |
|
10 | + case E_ERROR: |
|
11 | + case E_PARSE: |
|
12 | + case E_CORE_ERROR: |
|
13 | + case E_COMPILE_ERROR: |
|
14 | + case E_USER_ERROR: |
|
15 | + $priority = LOG_ERR; |
|
16 | + break; |
|
17 | + case E_WARNING: |
|
18 | + case E_CORE_WARNING: |
|
19 | + case E_COMPILE_WARNING: |
|
20 | + case E_USER_WARNING: |
|
21 | + $priority = LOG_WARNING; |
|
22 | + break; |
|
23 | + default: |
|
24 | + $priority = LOG_INFO; |
|
25 | + } |
|
26 | 26 | |
27 | - $errname = Logger::$errornames[$errno] . " ($errno)"; |
|
27 | + $errname = Logger::$errornames[$errno] . " ($errno)"; |
|
28 | 28 | |
29 | - syslog($priority, "[tt-rss] $errname ($file:$line) $errstr"); |
|
29 | + syslog($priority, "[tt-rss] $errname ($file:$line) $errstr"); |
|
30 | 30 | |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Db_Prefs { |
3 | - private $pdo; |
|
4 | - private static $instance; |
|
5 | - private $cache; |
|
3 | + private $pdo; |
|
4 | + private static $instance; |
|
5 | + private $cache; |
|
6 | 6 | |
7 | - public function __construct() { |
|
8 | - $this->pdo = Db::pdo(); |
|
9 | - $this->cache = array(); |
|
7 | + public function __construct() { |
|
8 | + $this->pdo = Db::pdo(); |
|
9 | + $this->cache = array(); |
|
10 | 10 | |
11 | - if ($_SESSION["uid"]) $this->cache(); |
|
12 | - } |
|
11 | + if ($_SESSION["uid"]) $this->cache(); |
|
12 | + } |
|
13 | 13 | |
14 | - public static function get() { |
|
15 | - if (self::$instance == null) |
|
16 | - self::$instance = new self(); |
|
14 | + public static function get() { |
|
15 | + if (self::$instance == null) |
|
16 | + self::$instance = new self(); |
|
17 | 17 | |
18 | - return self::$instance; |
|
19 | - } |
|
18 | + return self::$instance; |
|
19 | + } |
|
20 | 20 | |
21 | - public function cache() { |
|
22 | - $user_id = $_SESSION["uid"]; |
|
23 | - @$profile = $_SESSION["profile"]; |
|
21 | + public function cache() { |
|
22 | + $user_id = $_SESSION["uid"]; |
|
23 | + @$profile = $_SESSION["profile"]; |
|
24 | 24 | |
25 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
25 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
26 | 26 | |
27 | - $sth = $this->pdo->prepare("SELECT |
|
27 | + $sth = $this->pdo->prepare("SELECT |
|
28 | 28 | value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name |
29 | 29 | FROM |
30 | 30 | ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | owner_uid = :uid AND |
36 | 36 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name"); |
37 | 37 | |
38 | - $sth->execute([":profile" => $profile, ":uid" => $user_id]); |
|
38 | + $sth->execute([":profile" => $profile, ":uid" => $user_id]); |
|
39 | 39 | |
40 | - while ($line = $sth->fetch()) { |
|
41 | - if ($user_id == $_SESSION["uid"]) { |
|
42 | - $pref_name = $line["pref_name"]; |
|
40 | + while ($line = $sth->fetch()) { |
|
41 | + if ($user_id == $_SESSION["uid"]) { |
|
42 | + $pref_name = $line["pref_name"]; |
|
43 | 43 | |
44 | - $this->cache[$pref_name]["type"] = $line["type_name"]; |
|
45 | - $this->cache[$pref_name]["value"] = $line["value"]; |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
44 | + $this->cache[$pref_name]["type"] = $line["type_name"]; |
|
45 | + $this->cache[$pref_name]["value"] = $line["value"]; |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - public function read($pref_name, $user_id = false, $die_on_error = false) { |
|
50 | + public function read($pref_name, $user_id = false, $die_on_error = false) { |
|
51 | 51 | |
52 | - if (!$user_id) { |
|
53 | - $user_id = $_SESSION["uid"]; |
|
54 | - @$profile = $_SESSION["profile"]; |
|
55 | - } else { |
|
56 | - $profile = false; |
|
57 | - } |
|
52 | + if (!$user_id) { |
|
53 | + $user_id = $_SESSION["uid"]; |
|
54 | + @$profile = $_SESSION["profile"]; |
|
55 | + } else { |
|
56 | + $profile = false; |
|
57 | + } |
|
58 | 58 | |
59 | - if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) { |
|
60 | - $tuple = $this->cache[$pref_name]; |
|
61 | - return $this->convert($tuple["value"], $tuple["type"]); |
|
62 | - } |
|
59 | + if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) { |
|
60 | + $tuple = $this->cache[$pref_name]; |
|
61 | + return $this->convert($tuple["value"], $tuple["type"]); |
|
62 | + } |
|
63 | 63 | |
64 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
64 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
65 | 65 | |
66 | - $sth = $this->pdo->prepare("SELECT |
|
66 | + $sth = $this->pdo->prepare("SELECT |
|
67 | 67 | value,ttrss_prefs_types.type_name as type_name |
68 | 68 | FROM |
69 | 69 | ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types |
@@ -73,96 +73,96 @@ discard block |
||
73 | 73 | ttrss_prefs_types.id = type_id AND |
74 | 74 | owner_uid = :uid AND |
75 | 75 | ttrss_user_prefs.pref_name = ttrss_prefs.pref_name"); |
76 | - $sth->execute([":uid" => $user_id, ":profile" => $profile, ":pref_name" => $pref_name]); |
|
77 | - |
|
78 | - if ($row = $sth->fetch()) { |
|
79 | - $value = $row["value"]; |
|
80 | - $type_name = $row["type_name"]; |
|
81 | - |
|
82 | - if ($user_id == $_SESSION["uid"]) { |
|
83 | - $this->cache[$pref_name]["type"] = $type_name; |
|
84 | - $this->cache[$pref_name]["value"] = $value; |
|
85 | - } |
|
86 | - |
|
87 | - return $this->convert($value, $type_name); |
|
88 | - |
|
89 | - } else if ($die_on_error) { |
|
90 | - user_error("Fatal error, unknown preferences key: $pref_name (owner: $user_id)", E_USER_ERROR); |
|
91 | - return null; |
|
92 | - } else { |
|
93 | - return null; |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - public function convert($value, $type_name) { |
|
98 | - if ($type_name == "bool") { |
|
99 | - return $value == "true"; |
|
100 | - } else if ($type_name == "integer") { |
|
101 | - return (int)$value; |
|
102 | - } else { |
|
103 | - return $value; |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - public function write($pref_name, $value, $user_id = false, $strip_tags = true) { |
|
108 | - if ($strip_tags) $value = strip_tags($value); |
|
109 | - |
|
110 | - if (!$user_id) { |
|
111 | - $user_id = $_SESSION["uid"]; |
|
112 | - @$profile = $_SESSION["profile"]; |
|
113 | - } else { |
|
114 | - $profile = null; |
|
115 | - } |
|
116 | - |
|
117 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
118 | - |
|
119 | - $type_name = ""; |
|
120 | - $current_value = ""; |
|
121 | - |
|
122 | - if (isset($this->cache[$pref_name])) { |
|
123 | - $type_name = $this->cache[$pref_name]["type"]; |
|
124 | - $current_value = $this->cache[$pref_name]["value"]; |
|
125 | - } |
|
126 | - |
|
127 | - if (!$type_name) { |
|
128 | - $sth = $this->pdo->prepare("SELECT type_name |
|
76 | + $sth->execute([":uid" => $user_id, ":profile" => $profile, ":pref_name" => $pref_name]); |
|
77 | + |
|
78 | + if ($row = $sth->fetch()) { |
|
79 | + $value = $row["value"]; |
|
80 | + $type_name = $row["type_name"]; |
|
81 | + |
|
82 | + if ($user_id == $_SESSION["uid"]) { |
|
83 | + $this->cache[$pref_name]["type"] = $type_name; |
|
84 | + $this->cache[$pref_name]["value"] = $value; |
|
85 | + } |
|
86 | + |
|
87 | + return $this->convert($value, $type_name); |
|
88 | + |
|
89 | + } else if ($die_on_error) { |
|
90 | + user_error("Fatal error, unknown preferences key: $pref_name (owner: $user_id)", E_USER_ERROR); |
|
91 | + return null; |
|
92 | + } else { |
|
93 | + return null; |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + public function convert($value, $type_name) { |
|
98 | + if ($type_name == "bool") { |
|
99 | + return $value == "true"; |
|
100 | + } else if ($type_name == "integer") { |
|
101 | + return (int)$value; |
|
102 | + } else { |
|
103 | + return $value; |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + public function write($pref_name, $value, $user_id = false, $strip_tags = true) { |
|
108 | + if ($strip_tags) $value = strip_tags($value); |
|
109 | + |
|
110 | + if (!$user_id) { |
|
111 | + $user_id = $_SESSION["uid"]; |
|
112 | + @$profile = $_SESSION["profile"]; |
|
113 | + } else { |
|
114 | + $profile = null; |
|
115 | + } |
|
116 | + |
|
117 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
118 | + |
|
119 | + $type_name = ""; |
|
120 | + $current_value = ""; |
|
121 | + |
|
122 | + if (isset($this->cache[$pref_name])) { |
|
123 | + $type_name = $this->cache[$pref_name]["type"]; |
|
124 | + $current_value = $this->cache[$pref_name]["value"]; |
|
125 | + } |
|
126 | + |
|
127 | + if (!$type_name) { |
|
128 | + $sth = $this->pdo->prepare("SELECT type_name |
|
129 | 129 | FROM ttrss_prefs,ttrss_prefs_types |
130 | 130 | WHERE pref_name = ? AND type_id = ttrss_prefs_types.id"); |
131 | - $sth->execute([$pref_name]); |
|
132 | - |
|
133 | - if ($row = $sth->fetch()) |
|
134 | - $type_name = $row["type_name"]; |
|
135 | - |
|
136 | - } else if ($current_value == $value) { |
|
137 | - return; |
|
138 | - } |
|
139 | - |
|
140 | - if ($type_name) { |
|
141 | - if ($type_name == "bool") { |
|
142 | - if ($value == "1" || $value == "true") { |
|
143 | - $value = "true"; |
|
144 | - } else { |
|
145 | - $value = "false"; |
|
146 | - } |
|
147 | - } else if ($type_name == "integer") { |
|
148 | - $value = (int)$value; |
|
149 | - } |
|
150 | - |
|
151 | - if ($pref_name == 'USER_TIMEZONE' && $value == '') { |
|
152 | - $value = 'UTC'; |
|
153 | - } |
|
154 | - |
|
155 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_prefs SET |
|
131 | + $sth->execute([$pref_name]); |
|
132 | + |
|
133 | + if ($row = $sth->fetch()) |
|
134 | + $type_name = $row["type_name"]; |
|
135 | + |
|
136 | + } else if ($current_value == $value) { |
|
137 | + return; |
|
138 | + } |
|
139 | + |
|
140 | + if ($type_name) { |
|
141 | + if ($type_name == "bool") { |
|
142 | + if ($value == "1" || $value == "true") { |
|
143 | + $value = "true"; |
|
144 | + } else { |
|
145 | + $value = "false"; |
|
146 | + } |
|
147 | + } else if ($type_name == "integer") { |
|
148 | + $value = (int)$value; |
|
149 | + } |
|
150 | + |
|
151 | + if ($pref_name == 'USER_TIMEZONE' && $value == '') { |
|
152 | + $value = 'UTC'; |
|
153 | + } |
|
154 | + |
|
155 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_prefs SET |
|
156 | 156 | value = :value WHERE pref_name = :pref_name |
157 | 157 | AND (profile = :profile OR (:profile IS NULL AND profile IS NULL)) |
158 | 158 | AND owner_uid = :uid"); |
159 | 159 | |
160 | - $sth->execute([":pref_name" => $pref_name, ":value" => $value, ":uid" => $user_id, ":profile" => $profile]); |
|
160 | + $sth->execute([":pref_name" => $pref_name, ":value" => $value, ":uid" => $user_id, ":profile" => $profile]); |
|
161 | 161 | |
162 | - if ($user_id == $_SESSION["uid"]) { |
|
163 | - $this->cache[$pref_name]["type"] = $type_name; |
|
164 | - $this->cache[$pref_name]["value"] = $value; |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
162 | + if ($user_id == $_SESSION["uid"]) { |
|
163 | + $this->cache[$pref_name]["type"] = $type_name; |
|
164 | + $this->cache[$pref_name]["value"] = $value; |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | 168 | } |
@@ -1,112 +1,112 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Labels |
3 | 3 | { |
4 | - public static function label_to_feed_id($label) { |
|
5 | - return LABEL_BASE_INDEX - 1 - abs($label); |
|
6 | - } |
|
4 | + public static function label_to_feed_id($label) { |
|
5 | + return LABEL_BASE_INDEX - 1 - abs($label); |
|
6 | + } |
|
7 | 7 | |
8 | - public static function feed_to_label_id($feed) { |
|
9 | - return LABEL_BASE_INDEX - 1 + abs($feed); |
|
10 | - } |
|
8 | + public static function feed_to_label_id($feed) { |
|
9 | + return LABEL_BASE_INDEX - 1 + abs($feed); |
|
10 | + } |
|
11 | 11 | |
12 | - public static function find_id($label, $owner_uid) { |
|
13 | - $pdo = Db::pdo(); |
|
12 | + public static function find_id($label, $owner_uid) { |
|
13 | + $pdo = Db::pdo(); |
|
14 | 14 | |
15 | - $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE caption = ? |
|
15 | + $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE caption = ? |
|
16 | 16 | AND owner_uid = ? LIMIT 1"); |
17 | - $sth->execute([$label, $owner_uid]); |
|
17 | + $sth->execute([$label, $owner_uid]); |
|
18 | 18 | |
19 | - if ($row = $sth->fetch()) { |
|
20 | - return $row['id']; |
|
21 | - } else { |
|
22 | - return 0; |
|
23 | - } |
|
24 | - } |
|
19 | + if ($row = $sth->fetch()) { |
|
20 | + return $row['id']; |
|
21 | + } else { |
|
22 | + return 0; |
|
23 | + } |
|
24 | + } |
|
25 | 25 | |
26 | - public static function find_caption($label, $owner_uid) { |
|
27 | - $pdo = Db::pdo(); |
|
26 | + public static function find_caption($label, $owner_uid) { |
|
27 | + $pdo = Db::pdo(); |
|
28 | 28 | |
29 | - $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ? |
|
29 | + $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ? |
|
30 | 30 | AND owner_uid = ? LIMIT 1"); |
31 | - $sth->execute([$label, $owner_uid]); |
|
31 | + $sth->execute([$label, $owner_uid]); |
|
32 | 32 | |
33 | - if ($row = $sth->fetch()) { |
|
34 | - return $row['caption']; |
|
35 | - } else { |
|
36 | - return ""; |
|
37 | - } |
|
38 | - } |
|
33 | + if ($row = $sth->fetch()) { |
|
34 | + return $row['caption']; |
|
35 | + } else { |
|
36 | + return ""; |
|
37 | + } |
|
38 | + } |
|
39 | 39 | |
40 | - public static function get_all_labels($owner_uid) { |
|
41 | - $rv = array(); |
|
40 | + public static function get_all_labels($owner_uid) { |
|
41 | + $rv = array(); |
|
42 | 42 | |
43 | - $pdo = Db::pdo(); |
|
43 | + $pdo = Db::pdo(); |
|
44 | 44 | |
45 | - $sth = $pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 |
|
45 | + $sth = $pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 |
|
46 | 46 | WHERE owner_uid = ? ORDER BY caption"); |
47 | - $sth->execute([$owner_uid]); |
|
47 | + $sth->execute([$owner_uid]); |
|
48 | 48 | |
49 | - while ($line = $sth->fetch()) { |
|
50 | - array_push($rv, $line); |
|
51 | - } |
|
49 | + while ($line = $sth->fetch()) { |
|
50 | + array_push($rv, $line); |
|
51 | + } |
|
52 | 52 | |
53 | - return $rv; |
|
54 | - } |
|
53 | + return $rv; |
|
54 | + } |
|
55 | 55 | |
56 | - public static function update_cache($owner_uid, $id, $labels = false, $force = false) { |
|
57 | - $pdo = Db::pdo(); |
|
56 | + public static function update_cache($owner_uid, $id, $labels = false, $force = false) { |
|
57 | + $pdo = Db::pdo(); |
|
58 | 58 | |
59 | - if ($force) |
|
60 | - Labels::clear_cache($id); |
|
59 | + if ($force) |
|
60 | + Labels::clear_cache($id); |
|
61 | 61 | |
62 | - if (!$labels) |
|
63 | - $labels = Article::get_article_labels($id); |
|
62 | + if (!$labels) |
|
63 | + $labels = Article::get_article_labels($id); |
|
64 | 64 | |
65 | - $labels = json_encode($labels); |
|
65 | + $labels = json_encode($labels); |
|
66 | 66 | |
67 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
67 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
68 | 68 | label_cache = ? WHERE ref_id = ? AND owner_uid = ?"); |
69 | - $sth->execute([$labels, $id, $owner_uid]); |
|
69 | + $sth->execute([$labels, $id, $owner_uid]); |
|
70 | 70 | |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | - public static function clear_cache($id) { |
|
73 | + public static function clear_cache($id) { |
|
74 | 74 | |
75 | - $pdo = Db::pdo(); |
|
75 | + $pdo = Db::pdo(); |
|
76 | 76 | |
77 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
77 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
78 | 78 | label_cache = '' WHERE ref_id = ?"); |
79 | - $sth->execute([$id]); |
|
79 | + $sth->execute([$id]); |
|
80 | 80 | |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - public static function remove_article($id, $label, $owner_uid) { |
|
83 | + public static function remove_article($id, $label, $owner_uid) { |
|
84 | 84 | |
85 | - $label_id = Labels::find_id($label, $owner_uid); |
|
85 | + $label_id = Labels::find_id($label, $owner_uid); |
|
86 | 86 | |
87 | - if (!$label_id) return; |
|
87 | + if (!$label_id) return; |
|
88 | 88 | |
89 | - $pdo = Db::pdo(); |
|
89 | + $pdo = Db::pdo(); |
|
90 | 90 | |
91 | - $sth = $pdo->prepare("DELETE FROM ttrss_user_labels2 |
|
91 | + $sth = $pdo->prepare("DELETE FROM ttrss_user_labels2 |
|
92 | 92 | WHERE |
93 | 93 | label_id = ? AND |
94 | 94 | article_id = ?"); |
95 | 95 | |
96 | - $sth->execute([$label_id, $id]); |
|
96 | + $sth->execute([$label_id, $id]); |
|
97 | 97 | |
98 | - Labels::clear_cache($id); |
|
99 | - } |
|
98 | + Labels::clear_cache($id); |
|
99 | + } |
|
100 | 100 | |
101 | - public static function add_article($id, $label, $owner_uid) { |
|
101 | + public static function add_article($id, $label, $owner_uid) { |
|
102 | 102 | |
103 | - $label_id = Labels::find_id($label, $owner_uid); |
|
103 | + $label_id = Labels::find_id($label, $owner_uid); |
|
104 | 104 | |
105 | - if (!$label_id) return; |
|
105 | + if (!$label_id) return; |
|
106 | 106 | |
107 | - $pdo = Db::pdo(); |
|
107 | + $pdo = Db::pdo(); |
|
108 | 108 | |
109 | - $sth = $pdo->prepare("SELECT |
|
109 | + $sth = $pdo->prepare("SELECT |
|
110 | 110 | article_id FROM ttrss_labels2, ttrss_user_labels2 |
111 | 111 | WHERE |
112 | 112 | label_id = id AND |
@@ -114,92 +114,92 @@ discard block |
||
114 | 114 | article_id = ? AND owner_uid = ? |
115 | 115 | LIMIT 1"); |
116 | 116 | |
117 | - $sth->execute([$label_id, $id, $owner_uid]); |
|
117 | + $sth->execute([$label_id, $id, $owner_uid]); |
|
118 | 118 | |
119 | - if (!$sth->fetch()) { |
|
120 | - $sth = $pdo->prepare("INSERT INTO ttrss_user_labels2 |
|
119 | + if (!$sth->fetch()) { |
|
120 | + $sth = $pdo->prepare("INSERT INTO ttrss_user_labels2 |
|
121 | 121 | (label_id, article_id) VALUES (?, ?)"); |
122 | 122 | |
123 | - $sth->execute([$label_id, $id]); |
|
124 | - } |
|
123 | + $sth->execute([$label_id, $id]); |
|
124 | + } |
|
125 | 125 | |
126 | - Labels::clear_cache($id); |
|
126 | + Labels::clear_cache($id); |
|
127 | 127 | |
128 | - } |
|
128 | + } |
|
129 | 129 | |
130 | - public static function remove($id, $owner_uid) { |
|
131 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
130 | + public static function remove($id, $owner_uid) { |
|
131 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
132 | 132 | |
133 | - $pdo = Db::pdo(); |
|
134 | - $tr_in_progress = false; |
|
133 | + $pdo = Db::pdo(); |
|
134 | + $tr_in_progress = false; |
|
135 | 135 | |
136 | - try { |
|
137 | - $pdo->beginTransaction(); |
|
138 | - } catch (Exception $e) { |
|
139 | - $tr_in_progress = true; |
|
140 | - } |
|
136 | + try { |
|
137 | + $pdo->beginTransaction(); |
|
138 | + } catch (Exception $e) { |
|
139 | + $tr_in_progress = true; |
|
140 | + } |
|
141 | 141 | |
142 | - $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 |
|
142 | + $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 |
|
143 | 143 | WHERE id = ?"); |
144 | - $sth->execute([$id]); |
|
144 | + $sth->execute([$id]); |
|
145 | 145 | |
146 | - $row = $sth->fetch(); |
|
147 | - $caption = $row['caption']; |
|
146 | + $row = $sth->fetch(); |
|
147 | + $caption = $row['caption']; |
|
148 | 148 | |
149 | - $sth = $pdo->prepare("DELETE FROM ttrss_labels2 WHERE id = ? |
|
149 | + $sth = $pdo->prepare("DELETE FROM ttrss_labels2 WHERE id = ? |
|
150 | 150 | AND owner_uid = ?"); |
151 | - $sth->execute([$id, $owner_uid]); |
|
151 | + $sth->execute([$id, $owner_uid]); |
|
152 | 152 | |
153 | - if ($sth->rowCount() != 0 && $caption) { |
|
153 | + if ($sth->rowCount() != 0 && $caption) { |
|
154 | 154 | |
155 | - /* Remove access key for the label */ |
|
155 | + /* Remove access key for the label */ |
|
156 | 156 | |
157 | - $ext_id = LABEL_BASE_INDEX - 1 - $id; |
|
157 | + $ext_id = LABEL_BASE_INDEX - 1 - $id; |
|
158 | 158 | |
159 | - $sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE |
|
159 | + $sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE |
|
160 | 160 | feed_id = ? AND owner_uid = ?"); |
161 | - $sth->execute([$ext_id, $owner_uid]); |
|
161 | + $sth->execute([$ext_id, $owner_uid]); |
|
162 | 162 | |
163 | - /* Remove cached data */ |
|
163 | + /* Remove cached data */ |
|
164 | 164 | |
165 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries SET label_cache = '' |
|
165 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET label_cache = '' |
|
166 | 166 | WHERE owner_uid = ?"); |
167 | - $sth->execute([$owner_uid]); |
|
167 | + $sth->execute([$owner_uid]); |
|
168 | 168 | |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - if (!$tr_in_progress) $pdo->commit(); |
|
172 | - } |
|
171 | + if (!$tr_in_progress) $pdo->commit(); |
|
172 | + } |
|
173 | 173 | |
174 | - public static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { |
|
174 | + public static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { |
|
175 | 175 | |
176 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
176 | + if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
177 | 177 | |
178 | - $pdo = Db::pdo(); |
|
178 | + $pdo = Db::pdo(); |
|
179 | 179 | |
180 | - $tr_in_progress = false; |
|
180 | + $tr_in_progress = false; |
|
181 | 181 | |
182 | - try { |
|
183 | - $pdo->beginTransaction(); |
|
184 | - } catch (Exception $e) { |
|
185 | - $tr_in_progress = true; |
|
186 | - } |
|
182 | + try { |
|
183 | + $pdo->beginTransaction(); |
|
184 | + } catch (Exception $e) { |
|
185 | + $tr_in_progress = true; |
|
186 | + } |
|
187 | 187 | |
188 | - $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 |
|
188 | + $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 |
|
189 | 189 | WHERE caption = ? AND owner_uid = ?"); |
190 | - $sth->execute([$caption, $owner_uid]); |
|
190 | + $sth->execute([$caption, $owner_uid]); |
|
191 | 191 | |
192 | - if (!$sth->fetch()) { |
|
193 | - $sth = $pdo->prepare("INSERT INTO ttrss_labels2 |
|
192 | + if (!$sth->fetch()) { |
|
193 | + $sth = $pdo->prepare("INSERT INTO ttrss_labels2 |
|
194 | 194 | (caption,owner_uid,fg_color,bg_color) VALUES (?, ?, ?, ?)"); |
195 | 195 | |
196 | - $sth->execute([$caption, $owner_uid, $fg_color, $bg_color]); |
|
196 | + $sth->execute([$caption, $owner_uid, $fg_color, $bg_color]); |
|
197 | 197 | |
198 | - $result = $sth->rowCount(); |
|
199 | - } |
|
198 | + $result = $sth->rowCount(); |
|
199 | + } |
|
200 | 200 | |
201 | - if (!$tr_in_progress) $pdo->commit(); |
|
201 | + if (!$tr_in_progress) $pdo->commit(); |
|
202 | 202 | |
203 | - return $result; |
|
204 | - } |
|
203 | + return $result; |
|
204 | + } |
|
205 | 205 | } |
@@ -2,126 +2,126 @@ discard block |
||
2 | 2 | class Digest |
3 | 3 | { |
4 | 4 | |
5 | - /** |
|
6 | - * Send by mail a digest of last articles. |
|
7 | - * |
|
8 | - * @param mixed $link The database connection. |
|
9 | - * @param integer $limit The maximum number of articles by digest. |
|
10 | - * @return boolean Return false if digests are not enabled. |
|
11 | - */ |
|
12 | - public static function send_headlines_digests() { |
|
5 | + /** |
|
6 | + * Send by mail a digest of last articles. |
|
7 | + * |
|
8 | + * @param mixed $link The database connection. |
|
9 | + * @param integer $limit The maximum number of articles by digest. |
|
10 | + * @return boolean Return false if digests are not enabled. |
|
11 | + */ |
|
12 | + public static function send_headlines_digests() { |
|
13 | 13 | |
14 | - $user_limit = 15; // amount of users to process (e.g. emails to send out) |
|
15 | - $limit = 1000; // maximum amount of headlines to include |
|
14 | + $user_limit = 15; // amount of users to process (e.g. emails to send out) |
|
15 | + $limit = 1000; // maximum amount of headlines to include |
|
16 | 16 | |
17 | - Debug::log("Sending digests, batch of max $user_limit users, headline limit = $limit"); |
|
17 | + Debug::log("Sending digests, batch of max $user_limit users, headline limit = $limit"); |
|
18 | 18 | |
19 | - if (DB_TYPE == "pgsql") { |
|
20 | - $interval_qpart = "last_digest_sent < NOW() - INTERVAL '1 days'"; |
|
21 | - } else if (DB_TYPE == "mysql") { |
|
22 | - $interval_qpart = "last_digest_sent < DATE_SUB(NOW(), INTERVAL 1 DAY)"; |
|
23 | - } |
|
19 | + if (DB_TYPE == "pgsql") { |
|
20 | + $interval_qpart = "last_digest_sent < NOW() - INTERVAL '1 days'"; |
|
21 | + } else if (DB_TYPE == "mysql") { |
|
22 | + $interval_qpart = "last_digest_sent < DATE_SUB(NOW(), INTERVAL 1 DAY)"; |
|
23 | + } |
|
24 | 24 | |
25 | - $pdo = Db::pdo(); |
|
25 | + $pdo = Db::pdo(); |
|
26 | 26 | |
27 | - $res = $pdo->query("SELECT id,email FROM ttrss_users |
|
27 | + $res = $pdo->query("SELECT id,email FROM ttrss_users |
|
28 | 28 | WHERE email != '' AND (last_digest_sent IS NULL OR $interval_qpart)"); |
29 | 29 | |
30 | - while ($line = $res->fetch()) { |
|
30 | + while ($line = $res->fetch()) { |
|
31 | 31 | |
32 | - if (@get_pref('DIGEST_ENABLE', $line['id'], false)) { |
|
33 | - $preferred_ts = strtotime(get_pref('DIGEST_PREFERRED_TIME', $line['id'], '00:00')); |
|
32 | + if (@get_pref('DIGEST_ENABLE', $line['id'], false)) { |
|
33 | + $preferred_ts = strtotime(get_pref('DIGEST_PREFERRED_TIME', $line['id'], '00:00')); |
|
34 | 34 | |
35 | - // try to send digests within 2 hours of preferred time |
|
36 | - if ($preferred_ts && time() >= $preferred_ts && |
|
37 | - time() - $preferred_ts <= 7200 |
|
38 | - ) { |
|
35 | + // try to send digests within 2 hours of preferred time |
|
36 | + if ($preferred_ts && time() >= $preferred_ts && |
|
37 | + time() - $preferred_ts <= 7200 |
|
38 | + ) { |
|
39 | 39 | |
40 | - Debug::log("Sending digest for UID:" . $line['id'] . " - " . $line["email"]); |
|
40 | + Debug::log("Sending digest for UID:" . $line['id'] . " - " . $line["email"]); |
|
41 | 41 | |
42 | - $do_catchup = get_pref('DIGEST_CATCHUP', $line['id'], false); |
|
42 | + $do_catchup = get_pref('DIGEST_CATCHUP', $line['id'], false); |
|
43 | 43 | |
44 | - global $tz_offset; |
|
44 | + global $tz_offset; |
|
45 | 45 | |
46 | - // reset tz_offset global to prevent tz cache clash between users |
|
47 | - $tz_offset = -1; |
|
46 | + // reset tz_offset global to prevent tz cache clash between users |
|
47 | + $tz_offset = -1; |
|
48 | 48 | |
49 | - $tuple = Digest::prepare_headlines_digest($line["id"], 1, $limit); |
|
50 | - $digest = $tuple[0]; |
|
51 | - $headlines_count = $tuple[1]; |
|
52 | - $affected_ids = $tuple[2]; |
|
53 | - $digest_text = $tuple[3]; |
|
49 | + $tuple = Digest::prepare_headlines_digest($line["id"], 1, $limit); |
|
50 | + $digest = $tuple[0]; |
|
51 | + $headlines_count = $tuple[1]; |
|
52 | + $affected_ids = $tuple[2]; |
|
53 | + $digest_text = $tuple[3]; |
|
54 | 54 | |
55 | - if ($headlines_count > 0) { |
|
55 | + if ($headlines_count > 0) { |
|
56 | 56 | |
57 | - $mailer = new Mailer(); |
|
57 | + $mailer = new Mailer(); |
|
58 | 58 | |
59 | - //$rc = $mail->quickMail($line["email"], $line["login"], DIGEST_SUBJECT, $digest, $digest_text); |
|
59 | + //$rc = $mail->quickMail($line["email"], $line["login"], DIGEST_SUBJECT, $digest, $digest_text); |
|
60 | 60 | |
61 | - $rc = $mailer->mail(["to_name" => $line["login"], |
|
62 | - "to_address" => $line["email"], |
|
63 | - "subject" => DIGEST_SUBJECT, |
|
64 | - "message" => $digest_text, |
|
65 | - "message_html" => $digest]); |
|
61 | + $rc = $mailer->mail(["to_name" => $line["login"], |
|
62 | + "to_address" => $line["email"], |
|
63 | + "subject" => DIGEST_SUBJECT, |
|
64 | + "message" => $digest_text, |
|
65 | + "message_html" => $digest]); |
|
66 | 66 | |
67 | - //if (!$rc && $debug) Debug::log("ERROR: " . $mailer->lastError()); |
|
67 | + //if (!$rc && $debug) Debug::log("ERROR: " . $mailer->lastError()); |
|
68 | 68 | |
69 | - Debug::log("RC=$rc"); |
|
69 | + Debug::log("RC=$rc"); |
|
70 | 70 | |
71 | - if ($rc && $do_catchup) { |
|
72 | - Debug::log("Marking affected articles as read..."); |
|
73 | - Article::catchupArticlesById($affected_ids, 0, $line["id"]); |
|
74 | - } |
|
75 | - } else { |
|
76 | - Debug::log("No headlines"); |
|
77 | - } |
|
71 | + if ($rc && $do_catchup) { |
|
72 | + Debug::log("Marking affected articles as read..."); |
|
73 | + Article::catchupArticlesById($affected_ids, 0, $line["id"]); |
|
74 | + } |
|
75 | + } else { |
|
76 | + Debug::log("No headlines"); |
|
77 | + } |
|
78 | 78 | |
79 | - $sth = $pdo->prepare("UPDATE ttrss_users SET last_digest_sent = NOW() |
|
79 | + $sth = $pdo->prepare("UPDATE ttrss_users SET last_digest_sent = NOW() |
|
80 | 80 | WHERE id = ?"); |
81 | - $sth->execute([$line["id"]]); |
|
81 | + $sth->execute([$line["id"]]); |
|
82 | 82 | |
83 | - } |
|
84 | - } |
|
85 | - } |
|
83 | + } |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - Debug::log("All done."); |
|
87 | + Debug::log("All done."); |
|
88 | 88 | |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | - public static function prepare_headlines_digest($user_id, $days = 1, $limit = 1000) { |
|
91 | + public static function prepare_headlines_digest($user_id, $days = 1, $limit = 1000) { |
|
92 | 92 | |
93 | - require_once "lib/MiniTemplator.class.php"; |
|
93 | + require_once "lib/MiniTemplator.class.php"; |
|
94 | 94 | |
95 | - $tpl = new MiniTemplator; |
|
96 | - $tpl_t = new MiniTemplator; |
|
95 | + $tpl = new MiniTemplator; |
|
96 | + $tpl_t = new MiniTemplator; |
|
97 | 97 | |
98 | - $tpl->readTemplateFromFile("templates/digest_template_html.txt"); |
|
99 | - $tpl_t->readTemplateFromFile("templates/digest_template.txt"); |
|
98 | + $tpl->readTemplateFromFile("templates/digest_template_html.txt"); |
|
99 | + $tpl_t->readTemplateFromFile("templates/digest_template.txt"); |
|
100 | 100 | |
101 | - $user_tz_string = get_pref('USER_TIMEZONE', $user_id); |
|
102 | - $local_ts = convert_timestamp(time(), 'UTC', $user_tz_string); |
|
101 | + $user_tz_string = get_pref('USER_TIMEZONE', $user_id); |
|
102 | + $local_ts = convert_timestamp(time(), 'UTC', $user_tz_string); |
|
103 | 103 | |
104 | - $tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts)); |
|
105 | - $tpl->setVariable('CUR_TIME', date('G:i', $local_ts)); |
|
106 | - $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
104 | + $tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts)); |
|
105 | + $tpl->setVariable('CUR_TIME', date('G:i', $local_ts)); |
|
106 | + $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
107 | 107 | |
108 | - $tpl_t->setVariable('CUR_DATE', date('Y/m/d', $local_ts)); |
|
109 | - $tpl_t->setVariable('CUR_TIME', date('G:i', $local_ts)); |
|
110 | - $tpl_t->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
108 | + $tpl_t->setVariable('CUR_DATE', date('Y/m/d', $local_ts)); |
|
109 | + $tpl_t->setVariable('CUR_TIME', date('G:i', $local_ts)); |
|
110 | + $tpl_t->setVariable('TTRSS_HOST', SELF_URL_PATH); |
|
111 | 111 | |
112 | - $affected_ids = array(); |
|
112 | + $affected_ids = array(); |
|
113 | 113 | |
114 | - $days = (int) $days; |
|
114 | + $days = (int) $days; |
|
115 | 115 | |
116 | - if (DB_TYPE == "pgsql") { |
|
117 | - $interval_qpart = "ttrss_entries.date_updated > NOW() - INTERVAL '$days days'"; |
|
118 | - } else if (DB_TYPE == "mysql") { |
|
119 | - $interval_qpart = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL $days DAY)"; |
|
120 | - } |
|
116 | + if (DB_TYPE == "pgsql") { |
|
117 | + $interval_qpart = "ttrss_entries.date_updated > NOW() - INTERVAL '$days days'"; |
|
118 | + } else if (DB_TYPE == "mysql") { |
|
119 | + $interval_qpart = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL $days DAY)"; |
|
120 | + } |
|
121 | 121 | |
122 | - $pdo = Db::pdo(); |
|
122 | + $pdo = Db::pdo(); |
|
123 | 123 | |
124 | - $sth = $pdo->prepare("SELECT ttrss_entries.title, |
|
124 | + $sth = $pdo->prepare("SELECT ttrss_entries.title, |
|
125 | 125 | ttrss_feeds.title AS feed_title, |
126 | 126 | COALESCE(ttrss_feed_categories.title, '" . __('Uncategorized') . "') AS cat_title, |
127 | 127 | date_updated, |
@@ -143,76 +143,76 @@ discard block |
||
143 | 143 | AND score >= 0 |
144 | 144 | ORDER BY ttrss_feed_categories.title, ttrss_feeds.title, score DESC, date_updated DESC |
145 | 145 | LIMIT :limit"); |
146 | - $sth->bindParam(':user_id', intval($user_id, 10), PDO::PARAM_INT); |
|
147 | - $sth->bindParam(':limit', intval($limit, 10), PDO::PARAM_INT); |
|
148 | - $sth->execute(); |
|
146 | + $sth->bindParam(':user_id', intval($user_id, 10), PDO::PARAM_INT); |
|
147 | + $sth->bindParam(':limit', intval($limit, 10), PDO::PARAM_INT); |
|
148 | + $sth->execute(); |
|
149 | 149 | |
150 | - $headlines_count = 0; |
|
151 | - $headlines = array(); |
|
150 | + $headlines_count = 0; |
|
151 | + $headlines = array(); |
|
152 | 152 | |
153 | - while ($line = $sth->fetch()) { |
|
154 | - array_push($headlines, $line); |
|
155 | - $headlines_count++; |
|
156 | - } |
|
153 | + while ($line = $sth->fetch()) { |
|
154 | + array_push($headlines, $line); |
|
155 | + $headlines_count++; |
|
156 | + } |
|
157 | 157 | |
158 | - for ($i = 0; $i < sizeof($headlines); $i++) { |
|
158 | + for ($i = 0; $i < sizeof($headlines); $i++) { |
|
159 | 159 | |
160 | - $line = $headlines[$i]; |
|
160 | + $line = $headlines[$i]; |
|
161 | 161 | |
162 | - array_push($affected_ids, $line["ref_id"]); |
|
162 | + array_push($affected_ids, $line["ref_id"]); |
|
163 | 163 | |
164 | - $updated = make_local_datetime($line['last_updated'], false, |
|
165 | - $user_id); |
|
164 | + $updated = make_local_datetime($line['last_updated'], false, |
|
165 | + $user_id); |
|
166 | 166 | |
167 | - if (get_pref('ENABLE_FEED_CATS', $user_id)) { |
|
168 | - $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title']; |
|
169 | - } |
|
167 | + if (get_pref('ENABLE_FEED_CATS', $user_id)) { |
|
168 | + $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title']; |
|
169 | + } |
|
170 | 170 | |
171 | - $article_labels = Article::get_article_labels($line["ref_id"], $user_id); |
|
172 | - $article_labels_formatted = ""; |
|
171 | + $article_labels = Article::get_article_labels($line["ref_id"], $user_id); |
|
172 | + $article_labels_formatted = ""; |
|
173 | 173 | |
174 | - if (is_array($article_labels) && count($article_labels) > 0) { |
|
175 | - $article_labels_formatted = implode(", ", array_map(function($a) { |
|
176 | - return $a[1]; |
|
177 | - }, $article_labels)); |
|
178 | - } |
|
174 | + if (is_array($article_labels) && count($article_labels) > 0) { |
|
175 | + $article_labels_formatted = implode(", ", array_map(function($a) { |
|
176 | + return $a[1]; |
|
177 | + }, $article_labels)); |
|
178 | + } |
|
179 | 179 | |
180 | - $tpl->setVariable('FEED_TITLE', $line["feed_title"]); |
|
181 | - $tpl->setVariable('ARTICLE_TITLE', $line["title"]); |
|
182 | - $tpl->setVariable('ARTICLE_LINK', $line["link"]); |
|
183 | - $tpl->setVariable('ARTICLE_UPDATED', $updated); |
|
184 | - $tpl->setVariable('ARTICLE_EXCERPT', |
|
185 | - truncate_string(strip_tags($line["content"]), 300)); |
|
180 | + $tpl->setVariable('FEED_TITLE', $line["feed_title"]); |
|
181 | + $tpl->setVariable('ARTICLE_TITLE', $line["title"]); |
|
182 | + $tpl->setVariable('ARTICLE_LINK', $line["link"]); |
|
183 | + $tpl->setVariable('ARTICLE_UPDATED', $updated); |
|
184 | + $tpl->setVariable('ARTICLE_EXCERPT', |
|
185 | + truncate_string(strip_tags($line["content"]), 300)); |
|
186 | 186 | // $tpl->setVariable('ARTICLE_CONTENT', |
187 | 187 | // strip_tags($article_content)); |
188 | - $tpl->setVariable('ARTICLE_LABELS', $article_labels_formatted, true); |
|
188 | + $tpl->setVariable('ARTICLE_LABELS', $article_labels_formatted, true); |
|
189 | 189 | |
190 | - $tpl->addBlock('article'); |
|
190 | + $tpl->addBlock('article'); |
|
191 | 191 | |
192 | - $tpl_t->setVariable('FEED_TITLE', $line["feed_title"]); |
|
193 | - $tpl_t->setVariable('ARTICLE_TITLE', $line["title"]); |
|
194 | - $tpl_t->setVariable('ARTICLE_LINK', $line["link"]); |
|
195 | - $tpl_t->setVariable('ARTICLE_UPDATED', $updated); |
|
196 | - $tpl_t->setVariable('ARTICLE_LABELS', $article_labels_formatted, true); |
|
197 | - $tpl_t->setVariable('ARTICLE_EXCERPT', |
|
198 | - truncate_string(strip_tags($line["content"]), 300, "..."), true); |
|
192 | + $tpl_t->setVariable('FEED_TITLE', $line["feed_title"]); |
|
193 | + $tpl_t->setVariable('ARTICLE_TITLE', $line["title"]); |
|
194 | + $tpl_t->setVariable('ARTICLE_LINK', $line["link"]); |
|
195 | + $tpl_t->setVariable('ARTICLE_UPDATED', $updated); |
|
196 | + $tpl_t->setVariable('ARTICLE_LABELS', $article_labels_formatted, true); |
|
197 | + $tpl_t->setVariable('ARTICLE_EXCERPT', |
|
198 | + truncate_string(strip_tags($line["content"]), 300, "..."), true); |
|
199 | 199 | |
200 | - $tpl_t->addBlock('article'); |
|
200 | + $tpl_t->addBlock('article'); |
|
201 | 201 | |
202 | - if ($headlines[$i]['feed_title'] != $headlines[$i + 1]['feed_title']) { |
|
203 | - $tpl->addBlock('feed'); |
|
204 | - $tpl_t->addBlock('feed'); |
|
205 | - } |
|
202 | + if ($headlines[$i]['feed_title'] != $headlines[$i + 1]['feed_title']) { |
|
203 | + $tpl->addBlock('feed'); |
|
204 | + $tpl_t->addBlock('feed'); |
|
205 | + } |
|
206 | 206 | |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | - $tpl->addBlock('digest'); |
|
210 | - $tpl->generateOutputToString($tmp); |
|
209 | + $tpl->addBlock('digest'); |
|
210 | + $tpl->generateOutputToString($tmp); |
|
211 | 211 | |
212 | - $tpl_t->addBlock('digest'); |
|
213 | - $tpl_t->generateOutputToString($tmp_t); |
|
212 | + $tpl_t->addBlock('digest'); |
|
213 | + $tpl_t->generateOutputToString($tmp_t); |
|
214 | 214 | |
215 | - return array($tmp, $headlines_count, $affected_ids, $tmp_t); |
|
216 | - } |
|
215 | + return array($tmp, $headlines_count, $affected_ids, $tmp_t); |
|
216 | + } |
|
217 | 217 | |
218 | 218 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Debug { |
3 | - public static $LOG_DISABLED = -1; |
|
3 | + public static $LOG_DISABLED = -1; |
|
4 | 4 | public static $LOG_NORMAL = 0; |
5 | 5 | public static $LOG_VERBOSE = 1; |
6 | 6 | public static $LOG_EXTENDED = 2; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | private static $logfile = false; |
11 | 11 | private static $loglevel = 0; |
12 | 12 | |
13 | - public static function set_logfile($logfile) { |
|
13 | + public static function set_logfile($logfile) { |
|
14 | 14 | Debug::$logfile = $logfile; |
15 | 15 | } |
16 | 16 |
@@ -1,48 +1,48 @@ |
||
1 | 1 | <?php |
2 | 2 | class Auth_Base { |
3 | - private $pdo; |
|
3 | + private $pdo; |
|
4 | 4 | |
5 | - const AUTH_SERVICE_API = '_api'; |
|
5 | + const AUTH_SERVICE_API = '_api'; |
|
6 | 6 | |
7 | - public function __construct() { |
|
8 | - $this->pdo = Db::pdo(); |
|
9 | - } |
|
7 | + public function __construct() { |
|
8 | + $this->pdo = Db::pdo(); |
|
9 | + } |
|
10 | 10 | |
11 | - // Auto-creates specified user if allowed by system configuration |
|
12 | - // Can be used instead of find_user_by_login() by external auth modules |
|
13 | - public function auto_create_user($login, $password = false) { |
|
14 | - if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
|
15 | - $user_id = $this->find_user_by_login($login); |
|
11 | + // Auto-creates specified user if allowed by system configuration |
|
12 | + // Can be used instead of find_user_by_login() by external auth modules |
|
13 | + public function auto_create_user($login, $password = false) { |
|
14 | + if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
|
15 | + $user_id = $this->find_user_by_login($login); |
|
16 | 16 | |
17 | - if (!$password) $password = make_password(); |
|
17 | + if (!$password) $password = make_password(); |
|
18 | 18 | |
19 | - if (!$user_id) { |
|
20 | - $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
21 | - $pwd_hash = encrypt_password($password, $salt, true); |
|
19 | + if (!$user_id) { |
|
20 | + $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
21 | + $pwd_hash = encrypt_password($password, $salt, true); |
|
22 | 22 | |
23 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_users |
|
23 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_users |
|
24 | 24 | (login,access_level,last_login,created,pwd_hash,salt) |
25 | 25 | VALUES (?, 0, null, NOW(), ?,?)"); |
26 | - $sth->execute([$login, $pwd_hash, $salt]); |
|
26 | + $sth->execute([$login, $pwd_hash, $salt]); |
|
27 | 27 | |
28 | - return $this->find_user_by_login($login); |
|
28 | + return $this->find_user_by_login($login); |
|
29 | 29 | |
30 | - } else { |
|
31 | - return $user_id; |
|
32 | - } |
|
33 | - } |
|
30 | + } else { |
|
31 | + return $user_id; |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - return $this->find_user_by_login($login); |
|
36 | - } |
|
35 | + return $this->find_user_by_login($login); |
|
36 | + } |
|
37 | 37 | |
38 | - public function find_user_by_login($login) { |
|
39 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
|
40 | - $sth->execute([$login]); |
|
38 | + public function find_user_by_login($login) { |
|
39 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
|
40 | + $sth->execute([$login]); |
|
41 | 41 | |
42 | - if ($row = $sth->fetch()) { |
|
43 | - return $row["id"]; |
|
44 | - } else { |
|
45 | - return false; |
|
46 | - } |
|
47 | - } |
|
42 | + if ($row = $sth->fetch()) { |
|
43 | + return $row["id"]; |
|
44 | + } else { |
|
45 | + return false; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | } |