@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | $ERRORS[0] = ""; |
8 | 8 | |
9 | -$ERRORS[1] = __("This program requires XmlHttpRequest " . |
|
9 | +$ERRORS[1] = __("This program requires XmlHttpRequest ". |
|
10 | 10 | "to function properly. Your browser doesn't seem to support it."); |
11 | 11 | |
12 | -$ERRORS[2] = __("This program requires cookies " . |
|
12 | +$ERRORS[2] = __("This program requires cookies ". |
|
13 | 13 | "to function properly. Your browser doesn't seem to support them."); |
14 | 14 | |
15 | 15 | $ERRORS[3] = __("Backend sanity check failed."); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $new_feed_id = $row['id']; |
238 | 238 | } else { |
239 | 239 | $row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch(); |
240 | - $new_feed_id = (int)$row['id'] + 1; |
|
240 | + $new_feed_id = (int) $row['id'] + 1; |
|
241 | 241 | |
242 | 242 | $sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds |
243 | 243 | (id, owner_uid, title, feed_url, site_url, created) |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ |
288 | 288 | public function catchupSelected() { |
289 | 289 | $ids = explode(",", clean($_REQUEST["ids"])); |
290 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
290 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
291 | 291 | |
292 | 292 | Article::catchupArticlesById($ids, $cmode); |
293 | 293 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | public function markSelected() { |
298 | 298 | $ids = explode(",", clean($_REQUEST["ids"])); |
299 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
299 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
300 | 300 | |
301 | 301 | $this->markArticlesById($ids, $cmode); |
302 | 302 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | public function publishSelected() { |
307 | 307 | $ids = explode(",", clean($_REQUEST["ids"])); |
308 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
308 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
309 | 309 | |
310 | 310 | $this->publishArticlesById($ids, $cmode); |
311 | 311 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | print "<ul>"; |
344 | 344 | while ($line = $sth->fetch()) { |
345 | - print "<li>" . $line["caption"] . "</li>"; |
|
345 | + print "<li>".$line["caption"]."</li>"; |
|
346 | 346 | } |
347 | 347 | print "</ul>"; |
348 | 348 | } |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | |
579 | 579 | if ($msg) { |
580 | 580 | Logger::get()->log_error(E_USER_WARNING, |
581 | - $msg, 'client-js:' . $file, $line, $context); |
|
581 | + $msg, 'client-js:'.$file, $line, $context); |
|
582 | 582 | |
583 | 583 | echo json_encode(array("message" => "HOST_ERROR_LOGGED")); |
584 | 584 | } else { |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $content = json_decode($content, true); |
603 | 603 | |
604 | 604 | if ($content && isset($content["changeset"])) { |
605 | - if ($git_timestamp < (int)$content["changeset"]["timestamp"] && |
|
605 | + if ($git_timestamp < (int) $content["changeset"]["timestamp"] && |
|
606 | 606 | $git_commit != $content["changeset"]["id"]) { |
607 | 607 | |
608 | 608 | $rv = $content["changeset"]; |
@@ -1,435 +1,435 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class RPC extends Handler_Protected { |
3 | 3 | |
4 | - public function csrf_ignore($method) { |
|
5 | - $csrf_ignored = array("sanitycheck", "completelabels", "saveprofile"); |
|
4 | + public function csrf_ignore($method) { |
|
5 | + $csrf_ignored = array("sanitycheck", "completelabels", "saveprofile"); |
|
6 | 6 | |
7 | - return array_search($method, $csrf_ignored) !== false; |
|
8 | - } |
|
7 | + return array_search($method, $csrf_ignored) !== false; |
|
8 | + } |
|
9 | 9 | |
10 | - public function setprofile() { |
|
11 | - $_SESSION["profile"] = (int) clean($_REQUEST["id"]); |
|
10 | + public function setprofile() { |
|
11 | + $_SESSION["profile"] = (int) clean($_REQUEST["id"]); |
|
12 | 12 | |
13 | - // default value |
|
14 | - if (!$_SESSION["profile"]) $_SESSION["profile"] = null; |
|
15 | - } |
|
13 | + // default value |
|
14 | + if (!$_SESSION["profile"]) $_SESSION["profile"] = null; |
|
15 | + } |
|
16 | 16 | |
17 | - public function remprofiles() { |
|
18 | - $ids = explode(",", trim(clean($_REQUEST["ids"]))); |
|
17 | + public function remprofiles() { |
|
18 | + $ids = explode(",", trim(clean($_REQUEST["ids"]))); |
|
19 | 19 | |
20 | - foreach ($ids as $id) { |
|
21 | - if ($_SESSION["profile"] != $id) { |
|
22 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_settings_profiles WHERE id = ? AND |
|
20 | + foreach ($ids as $id) { |
|
21 | + if ($_SESSION["profile"] != $id) { |
|
22 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_settings_profiles WHERE id = ? AND |
|
23 | 23 | owner_uid = ?"); |
24 | - $sth->execute([$id, $_SESSION['uid']]); |
|
25 | - } |
|
26 | - } |
|
27 | - } |
|
24 | + $sth->execute([$id, $_SESSION['uid']]); |
|
25 | + } |
|
26 | + } |
|
27 | + } |
|
28 | 28 | |
29 | - // Silent |
|
30 | - public function addprofile() { |
|
31 | - $title = trim(clean($_REQUEST["title"])); |
|
29 | + // Silent |
|
30 | + public function addprofile() { |
|
31 | + $title = trim(clean($_REQUEST["title"])); |
|
32 | 32 | |
33 | - if ($title) { |
|
34 | - $this->pdo->beginTransaction(); |
|
33 | + if ($title) { |
|
34 | + $this->pdo->beginTransaction(); |
|
35 | 35 | |
36 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles |
|
36 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles |
|
37 | 37 | WHERE title = ? AND owner_uid = ?"); |
38 | - $sth->execute([$title, $_SESSION['uid']]); |
|
38 | + $sth->execute([$title, $_SESSION['uid']]); |
|
39 | 39 | |
40 | - if (!$sth->fetch()) { |
|
40 | + if (!$sth->fetch()) { |
|
41 | 41 | |
42 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_settings_profiles (title, owner_uid) |
|
42 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_settings_profiles (title, owner_uid) |
|
43 | 43 | VALUES (?, ?)"); |
44 | 44 | |
45 | - $sth->execute([$title, $_SESSION['uid']]); |
|
45 | + $sth->execute([$title, $_SESSION['uid']]); |
|
46 | 46 | |
47 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles WHERE |
|
47 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles WHERE |
|
48 | 48 | title = ? AND owner_uid = ?"); |
49 | - $sth->execute([$title, $_SESSION['uid']]); |
|
49 | + $sth->execute([$title, $_SESSION['uid']]); |
|
50 | 50 | |
51 | - if ($row = $sth->fetch()) { |
|
52 | - $profile_id = $row['id']; |
|
51 | + if ($row = $sth->fetch()) { |
|
52 | + $profile_id = $row['id']; |
|
53 | 53 | |
54 | - if ($profile_id) { |
|
55 | - initialize_user_prefs($_SESSION["uid"], $profile_id); |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
54 | + if ($profile_id) { |
|
55 | + initialize_user_prefs($_SESSION["uid"], $profile_id); |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - $this->pdo->commit(); |
|
61 | - } |
|
62 | - } |
|
60 | + $this->pdo->commit(); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - public function saveprofile() { |
|
65 | - $id = clean($_REQUEST["id"]); |
|
66 | - $title = trim(clean($_REQUEST["value"])); |
|
64 | + public function saveprofile() { |
|
65 | + $id = clean($_REQUEST["id"]); |
|
66 | + $title = trim(clean($_REQUEST["value"])); |
|
67 | 67 | |
68 | - if ($id == 0) { |
|
69 | - print __("Default profile"); |
|
70 | - return; |
|
71 | - } |
|
68 | + if ($id == 0) { |
|
69 | + print __("Default profile"); |
|
70 | + return; |
|
71 | + } |
|
72 | 72 | |
73 | - if ($title) { |
|
74 | - $sth = $this->pdo->prepare("UPDATE ttrss_settings_profiles |
|
73 | + if ($title) { |
|
74 | + $sth = $this->pdo->prepare("UPDATE ttrss_settings_profiles |
|
75 | 75 | SET title = ? WHERE id = ? AND |
76 | 76 | owner_uid = ?"); |
77 | 77 | |
78 | - $sth->execute([$title, $id, $_SESSION['uid']]); |
|
79 | - print $title; |
|
80 | - } |
|
81 | - } |
|
78 | + $sth->execute([$title, $id, $_SESSION['uid']]); |
|
79 | + print $title; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - // Silent |
|
84 | - public function remarchive() { |
|
85 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
83 | + // Silent |
|
84 | + public function remarchive() { |
|
85 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
86 | 86 | |
87 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_archived_feeds WHERE |
|
87 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_archived_feeds WHERE |
|
88 | 88 | (SELECT COUNT(*) FROM ttrss_user_entries |
89 | 89 | WHERE orig_feed_id = :id) = 0 AND |
90 | 90 | id = :id AND owner_uid = :uid"); |
91 | 91 | |
92 | - foreach ($ids as $id) { |
|
93 | - $sth->execute([":id" => $id, ":uid" => $_SESSION['uid']]); |
|
94 | - } |
|
95 | - } |
|
92 | + foreach ($ids as $id) { |
|
93 | + $sth->execute([":id" => $id, ":uid" => $_SESSION['uid']]); |
|
94 | + } |
|
95 | + } |
|
96 | 96 | |
97 | - public function addfeed() { |
|
98 | - $feed = clean($_REQUEST['feed']); |
|
99 | - $cat = clean($_REQUEST['cat']); |
|
100 | - $need_auth = isset($_REQUEST['need_auth']); |
|
101 | - $login = $need_auth ? clean($_REQUEST['login']) : ''; |
|
102 | - $pass = $need_auth ? trim(clean($_REQUEST['pass'])) : ''; |
|
97 | + public function addfeed() { |
|
98 | + $feed = clean($_REQUEST['feed']); |
|
99 | + $cat = clean($_REQUEST['cat']); |
|
100 | + $need_auth = isset($_REQUEST['need_auth']); |
|
101 | + $login = $need_auth ? clean($_REQUEST['login']) : ''; |
|
102 | + $pass = $need_auth ? trim(clean($_REQUEST['pass'])) : ''; |
|
103 | 103 | |
104 | - $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); |
|
104 | + $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); |
|
105 | 105 | |
106 | - print json_encode(array("result" => $rc)); |
|
107 | - } |
|
106 | + print json_encode(array("result" => $rc)); |
|
107 | + } |
|
108 | 108 | |
109 | - public function togglepref() { |
|
110 | - $key = clean($_REQUEST["key"]); |
|
111 | - set_pref($key, !get_pref($key)); |
|
112 | - $value = get_pref($key); |
|
109 | + public function togglepref() { |
|
110 | + $key = clean($_REQUEST["key"]); |
|
111 | + set_pref($key, !get_pref($key)); |
|
112 | + $value = get_pref($key); |
|
113 | 113 | |
114 | - print json_encode(array("param" =>$key, "value" => $value)); |
|
115 | - } |
|
114 | + print json_encode(array("param" =>$key, "value" => $value)); |
|
115 | + } |
|
116 | 116 | |
117 | - public function setpref() { |
|
118 | - // set_pref escapes input, so no need to double escape it here |
|
119 | - $key = clean($_REQUEST['key']); |
|
120 | - $value = $_REQUEST['value']; |
|
117 | + public function setpref() { |
|
118 | + // set_pref escapes input, so no need to double escape it here |
|
119 | + $key = clean($_REQUEST['key']); |
|
120 | + $value = $_REQUEST['value']; |
|
121 | 121 | |
122 | - set_pref($key, $value, false, $key != 'USER_STYLESHEET'); |
|
122 | + set_pref($key, $value, false, $key != 'USER_STYLESHEET'); |
|
123 | 123 | |
124 | - print json_encode(array("param" =>$key, "value" => $value)); |
|
125 | - } |
|
124 | + print json_encode(array("param" =>$key, "value" => $value)); |
|
125 | + } |
|
126 | 126 | |
127 | - public function mark() { |
|
128 | - $mark = clean($_REQUEST["mark"]); |
|
129 | - $id = clean($_REQUEST["id"]); |
|
127 | + public function mark() { |
|
128 | + $mark = clean($_REQUEST["mark"]); |
|
129 | + $id = clean($_REQUEST["id"]); |
|
130 | 130 | |
131 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET marked = ?, |
|
131 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET marked = ?, |
|
132 | 132 | last_marked = NOW() |
133 | 133 | WHERE ref_id = ? AND owner_uid = ?"); |
134 | 134 | |
135 | - $sth->execute([$mark, $id, $_SESSION['uid']]); |
|
135 | + $sth->execute([$mark, $id, $_SESSION['uid']]); |
|
136 | 136 | |
137 | - print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
138 | - } |
|
137 | + print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
138 | + } |
|
139 | 139 | |
140 | - public function delete() { |
|
141 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
142 | - $ids_qmarks = arr_qmarks($ids); |
|
140 | + public function delete() { |
|
141 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
142 | + $ids_qmarks = arr_qmarks($ids); |
|
143 | 143 | |
144 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_user_entries |
|
144 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_user_entries |
|
145 | 145 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
146 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
146 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
147 | 147 | |
148 | - Article::purge_orphans(); |
|
148 | + Article::purge_orphans(); |
|
149 | 149 | |
150 | - print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
151 | - } |
|
150 | + print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
151 | + } |
|
152 | 152 | |
153 | - public function unarchive() { |
|
154 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
153 | + public function unarchive() { |
|
154 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
155 | 155 | |
156 | - foreach ($ids as $id) { |
|
157 | - $this->pdo->beginTransaction(); |
|
156 | + foreach ($ids as $id) { |
|
157 | + $this->pdo->beginTransaction(); |
|
158 | 158 | |
159 | - $sth = $this->pdo->prepare("SELECT feed_url,site_url,title FROM ttrss_archived_feeds |
|
159 | + $sth = $this->pdo->prepare("SELECT feed_url,site_url,title FROM ttrss_archived_feeds |
|
160 | 160 | WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = :id |
161 | 161 | AND owner_uid = :uid) AND owner_uid = :uid"); |
162 | - $sth->execute([":uid" => $_SESSION['uid'], ":id" => $id]); |
|
162 | + $sth->execute([":uid" => $_SESSION['uid'], ":id" => $id]); |
|
163 | 163 | |
164 | - if ($row = $sth->fetch()) { |
|
165 | - $feed_url = $row['feed_url']; |
|
166 | - $site_url = $row['site_url']; |
|
167 | - $title = $row['title']; |
|
164 | + if ($row = $sth->fetch()) { |
|
165 | + $feed_url = $row['feed_url']; |
|
166 | + $site_url = $row['site_url']; |
|
167 | + $title = $row['title']; |
|
168 | 168 | |
169 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
|
169 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
|
170 | 170 | AND owner_uid = ?"); |
171 | - $sth->execute([$feed_url, $_SESSION['uid']]); |
|
171 | + $sth->execute([$feed_url, $_SESSION['uid']]); |
|
172 | 172 | |
173 | - if ($row = $sth->fetch()) { |
|
174 | - $feed_id = $row["id"]; |
|
175 | - } else { |
|
176 | - if (!$title) $title = '[Unknown]'; |
|
173 | + if ($row = $sth->fetch()) { |
|
174 | + $feed_id = $row["id"]; |
|
175 | + } else { |
|
176 | + if (!$title) $title = '[Unknown]'; |
|
177 | 177 | |
178 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
|
178 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
|
179 | 179 | (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method) |
180 | 180 | VALUES (?, ?, ?, ?, NULL, '', '', 0)"); |
181 | - $sth->execute([$_SESSION['uid'], $feed_url, $site_url, $title]); |
|
181 | + $sth->execute([$_SESSION['uid'], $feed_url, $site_url, $title]); |
|
182 | 182 | |
183 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
|
183 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
|
184 | 184 | AND owner_uid = ?"); |
185 | - $sth->execute([$feed_url, $_SESSION['uid']]); |
|
185 | + $sth->execute([$feed_url, $_SESSION['uid']]); |
|
186 | 186 | |
187 | - if ($row = $sth->fetch()) { |
|
188 | - $feed_id = $row['id']; |
|
189 | - } |
|
190 | - } |
|
187 | + if ($row = $sth->fetch()) { |
|
188 | + $feed_id = $row['id']; |
|
189 | + } |
|
190 | + } |
|
191 | 191 | |
192 | - if ($feed_id) { |
|
193 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries |
|
192 | + if ($feed_id) { |
|
193 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries |
|
194 | 194 | SET feed_id = ?, orig_feed_id = NULL |
195 | 195 | WHERE ref_id = ? AND owner_uid = ?"); |
196 | - $sth->execute([$feed_id, $id, $_SESSION['uid']]); |
|
197 | - } |
|
198 | - } |
|
196 | + $sth->execute([$feed_id, $id, $_SESSION['uid']]); |
|
197 | + } |
|
198 | + } |
|
199 | 199 | |
200 | - $this->pdo->commit(); |
|
201 | - } |
|
200 | + $this->pdo->commit(); |
|
201 | + } |
|
202 | 202 | |
203 | - print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
204 | - } |
|
203 | + print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
204 | + } |
|
205 | 205 | |
206 | - public function archive() { |
|
207 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
206 | + public function archive() { |
|
207 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
208 | 208 | |
209 | - foreach ($ids as $id) { |
|
210 | - $this->archive_article($id, $_SESSION["uid"]); |
|
211 | - } |
|
209 | + foreach ($ids as $id) { |
|
210 | + $this->archive_article($id, $_SESSION["uid"]); |
|
211 | + } |
|
212 | 212 | |
213 | - print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
214 | - } |
|
213 | + print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
214 | + } |
|
215 | 215 | |
216 | - private function archive_article($id, $owner_uid) { |
|
217 | - $this->pdo->beginTransaction(); |
|
216 | + private function archive_article($id, $owner_uid) { |
|
217 | + $this->pdo->beginTransaction(); |
|
218 | 218 | |
219 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
219 | + if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
220 | 220 | |
221 | - $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries |
|
221 | + $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries |
|
222 | 222 | WHERE ref_id = ? AND owner_uid = ?"); |
223 | - $sth->execute([$id, $owner_uid]); |
|
223 | + $sth->execute([$id, $owner_uid]); |
|
224 | 224 | |
225 | - if ($row = $sth->fetch()) { |
|
225 | + if ($row = $sth->fetch()) { |
|
226 | 226 | |
227 | - /* prepare the archived table */ |
|
227 | + /* prepare the archived table */ |
|
228 | 228 | |
229 | - $feed_id = (int) $row['feed_id']; |
|
229 | + $feed_id = (int) $row['feed_id']; |
|
230 | 230 | |
231 | - if ($feed_id) { |
|
232 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_archived_feeds |
|
231 | + if ($feed_id) { |
|
232 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_archived_feeds |
|
233 | 233 | WHERE id = ? AND owner_uid = ?"); |
234 | - $sth->execute([$feed_id, $owner_uid]); |
|
234 | + $sth->execute([$feed_id, $owner_uid]); |
|
235 | 235 | |
236 | - if ($row = $sth->fetch()) { |
|
237 | - $new_feed_id = $row['id']; |
|
238 | - } else { |
|
239 | - $row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch(); |
|
240 | - $new_feed_id = (int)$row['id'] + 1; |
|
236 | + if ($row = $sth->fetch()) { |
|
237 | + $new_feed_id = $row['id']; |
|
238 | + } else { |
|
239 | + $row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch(); |
|
240 | + $new_feed_id = (int)$row['id'] + 1; |
|
241 | 241 | |
242 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds |
|
242 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds |
|
243 | 243 | (id, owner_uid, title, feed_url, site_url, created) |
244 | 244 | SELECT ?, owner_uid, title, feed_url, site_url, NOW() from ttrss_feeds |
245 | 245 | WHERE id = ?"); |
246 | 246 | |
247 | - $sth->execute([$new_feed_id, $feed_id]); |
|
248 | - } |
|
247 | + $sth->execute([$new_feed_id, $feed_id]); |
|
248 | + } |
|
249 | 249 | |
250 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries |
|
250 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries |
|
251 | 251 | SET orig_feed_id = ?, feed_id = NULL |
252 | 252 | WHERE ref_id = ? AND owner_uid = ?"); |
253 | - $sth->execute([$new_feed_id, $id, $owner_uid]); |
|
254 | - } |
|
255 | - } |
|
253 | + $sth->execute([$new_feed_id, $id, $owner_uid]); |
|
254 | + } |
|
255 | + } |
|
256 | 256 | |
257 | - $this->pdo->commit(); |
|
258 | - } |
|
257 | + $this->pdo->commit(); |
|
258 | + } |
|
259 | 259 | |
260 | - public function publ() { |
|
261 | - $pub = clean($_REQUEST["pub"]); |
|
262 | - $id = clean($_REQUEST["id"]); |
|
260 | + public function publ() { |
|
261 | + $pub = clean($_REQUEST["pub"]); |
|
262 | + $id = clean($_REQUEST["id"]); |
|
263 | 263 | |
264 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
264 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
265 | 265 | published = ?, last_published = NOW() |
266 | 266 | WHERE ref_id = ? AND owner_uid = ?"); |
267 | 267 | |
268 | - $sth->execute([$pub, $id, $_SESSION['uid']]); |
|
268 | + $sth->execute([$pub, $id, $_SESSION['uid']]); |
|
269 | 269 | |
270 | - print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
271 | - } |
|
270 | + print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
271 | + } |
|
272 | 272 | |
273 | - public function getAllCounters() { |
|
274 | - @$seq = (int) $_REQUEST['seq']; |
|
273 | + public function getAllCounters() { |
|
274 | + @$seq = (int) $_REQUEST['seq']; |
|
275 | 275 | |
276 | - $reply = [ |
|
277 | - 'counters' => Counters::getAllCounters(), |
|
278 | - 'seq' => $seq |
|
279 | - ]; |
|
276 | + $reply = [ |
|
277 | + 'counters' => Counters::getAllCounters(), |
|
278 | + 'seq' => $seq |
|
279 | + ]; |
|
280 | 280 | |
281 | - if ($seq % 2 == 0) |
|
282 | - $reply['runtime-info'] = make_runtime_info(); |
|
281 | + if ($seq % 2 == 0) |
|
282 | + $reply['runtime-info'] = make_runtime_info(); |
|
283 | 283 | |
284 | - print json_encode($reply); |
|
285 | - } |
|
284 | + print json_encode($reply); |
|
285 | + } |
|
286 | 286 | |
287 | - /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ |
|
288 | - public function catchupSelected() { |
|
289 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
290 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
287 | + /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ |
|
288 | + public function catchupSelected() { |
|
289 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
290 | + $cmode = (int)clean($_REQUEST["cmode"]); |
|
291 | 291 | |
292 | - Article::catchupArticlesById($ids, $cmode); |
|
292 | + Article::catchupArticlesById($ids, $cmode); |
|
293 | 293 | |
294 | - print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids)); |
|
295 | - } |
|
294 | + print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids)); |
|
295 | + } |
|
296 | 296 | |
297 | - public function markSelected() { |
|
298 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
299 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
297 | + public function markSelected() { |
|
298 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
299 | + $cmode = (int)clean($_REQUEST["cmode"]); |
|
300 | 300 | |
301 | - $this->markArticlesById($ids, $cmode); |
|
301 | + $this->markArticlesById($ids, $cmode); |
|
302 | 302 | |
303 | - print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
304 | - } |
|
303 | + print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
304 | + } |
|
305 | 305 | |
306 | - public function publishSelected() { |
|
307 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
308 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
306 | + public function publishSelected() { |
|
307 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
308 | + $cmode = (int)clean($_REQUEST["cmode"]); |
|
309 | 309 | |
310 | - $this->publishArticlesById($ids, $cmode); |
|
310 | + $this->publishArticlesById($ids, $cmode); |
|
311 | 311 | |
312 | - print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
313 | - } |
|
312 | + print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
313 | + } |
|
314 | 314 | |
315 | - public function sanityCheck() { |
|
316 | - $_SESSION["hasAudio"] = clean($_REQUEST["hasAudio"]) === "true"; |
|
317 | - $_SESSION["hasSandbox"] = clean($_REQUEST["hasSandbox"]) === "true"; |
|
318 | - $_SESSION["hasMp3"] = clean($_REQUEST["hasMp3"]) === "true"; |
|
319 | - $_SESSION["clientTzOffset"] = clean($_REQUEST["clientTzOffset"]); |
|
315 | + public function sanityCheck() { |
|
316 | + $_SESSION["hasAudio"] = clean($_REQUEST["hasAudio"]) === "true"; |
|
317 | + $_SESSION["hasSandbox"] = clean($_REQUEST["hasSandbox"]) === "true"; |
|
318 | + $_SESSION["hasMp3"] = clean($_REQUEST["hasMp3"]) === "true"; |
|
319 | + $_SESSION["clientTzOffset"] = clean($_REQUEST["clientTzOffset"]); |
|
320 | 320 | |
321 | - $reply = array(); |
|
321 | + $reply = array(); |
|
322 | 322 | |
323 | - $reply['error'] = sanity_check(); |
|
323 | + $reply['error'] = sanity_check(); |
|
324 | 324 | |
325 | - if ($reply['error']['code'] == 0) { |
|
326 | - $reply['init-params'] = make_init_params(); |
|
327 | - $reply['runtime-info'] = make_runtime_info(); |
|
328 | - } |
|
325 | + if ($reply['error']['code'] == 0) { |
|
326 | + $reply['init-params'] = make_init_params(); |
|
327 | + $reply['runtime-info'] = make_runtime_info(); |
|
328 | + } |
|
329 | 329 | |
330 | - print json_encode($reply); |
|
331 | - } |
|
330 | + print json_encode($reply); |
|
331 | + } |
|
332 | 332 | |
333 | - public function completeLabels() { |
|
334 | - $search = clean($_REQUEST["search"]); |
|
333 | + public function completeLabels() { |
|
334 | + $search = clean($_REQUEST["search"]); |
|
335 | 335 | |
336 | - $sth = $this->pdo->prepare("SELECT DISTINCT caption FROM |
|
336 | + $sth = $this->pdo->prepare("SELECT DISTINCT caption FROM |
|
337 | 337 | ttrss_labels2 |
338 | 338 | WHERE owner_uid = ? AND |
339 | 339 | LOWER(caption) LIKE LOWER(?) ORDER BY caption |
340 | 340 | LIMIT 5"); |
341 | - $sth->execute([$_SESSION['uid'], "%$search%"]); |
|
341 | + $sth->execute([$_SESSION['uid'], "%$search%"]); |
|
342 | 342 | |
343 | - print "<ul>"; |
|
344 | - while ($line = $sth->fetch()) { |
|
345 | - print "<li>" . $line["caption"] . "</li>"; |
|
346 | - } |
|
347 | - print "</ul>"; |
|
348 | - } |
|
343 | + print "<ul>"; |
|
344 | + while ($line = $sth->fetch()) { |
|
345 | + print "<li>" . $line["caption"] . "</li>"; |
|
346 | + } |
|
347 | + print "</ul>"; |
|
348 | + } |
|
349 | 349 | |
350 | - // Silent |
|
351 | - public function massSubscribe() { |
|
350 | + // Silent |
|
351 | + public function massSubscribe() { |
|
352 | 352 | |
353 | - $payload = json_decode(clean($_REQUEST["payload"]), false); |
|
354 | - $mode = clean($_REQUEST["mode"]); |
|
353 | + $payload = json_decode(clean($_REQUEST["payload"]), false); |
|
354 | + $mode = clean($_REQUEST["mode"]); |
|
355 | 355 | |
356 | - if (!$payload || !is_array($payload)) return; |
|
356 | + if (!$payload || !is_array($payload)) return; |
|
357 | 357 | |
358 | - if ($mode == 1) { |
|
359 | - foreach ($payload as $feed) { |
|
358 | + if ($mode == 1) { |
|
359 | + foreach ($payload as $feed) { |
|
360 | 360 | |
361 | - $title = $feed[0]; |
|
362 | - $feed_url = $feed[1]; |
|
361 | + $title = $feed[0]; |
|
362 | + $feed_url = $feed[1]; |
|
363 | 363 | |
364 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
364 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
365 | 365 | feed_url = ? AND owner_uid = ?"); |
366 | - $sth->execute([$feed_url, $_SESSION['uid']]); |
|
366 | + $sth->execute([$feed_url, $_SESSION['uid']]); |
|
367 | 367 | |
368 | - if (!$sth->fetch()) { |
|
369 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
|
368 | + if (!$sth->fetch()) { |
|
369 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
|
370 | 370 | (owner_uid,feed_url,title,cat_id,site_url) |
371 | 371 | VALUES (?, ?, ?, NULL, '')"); |
372 | 372 | |
373 | - $sth->execute([$_SESSION['uid'], $feed_url, $title]); |
|
374 | - } |
|
375 | - } |
|
376 | - } else if ($mode == 2) { |
|
377 | - // feed archive |
|
378 | - foreach ($payload as $id) { |
|
379 | - $sth = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds |
|
373 | + $sth->execute([$_SESSION['uid'], $feed_url, $title]); |
|
374 | + } |
|
375 | + } |
|
376 | + } else if ($mode == 2) { |
|
377 | + // feed archive |
|
378 | + foreach ($payload as $id) { |
|
379 | + $sth = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds |
|
380 | 380 | WHERE id = ? AND owner_uid = ?"); |
381 | - $sth->execute([$id, $_SESSION['uid']]); |
|
381 | + $sth->execute([$id, $_SESSION['uid']]); |
|
382 | 382 | |
383 | - if ($row = $sth->fetch()) { |
|
384 | - $site_url = $row['site_url']; |
|
385 | - $feed_url = $row['feed_url']; |
|
386 | - $title = $row['title']; |
|
383 | + if ($row = $sth->fetch()) { |
|
384 | + $site_url = $row['site_url']; |
|
385 | + $feed_url = $row['feed_url']; |
|
386 | + $title = $row['title']; |
|
387 | 387 | |
388 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
388 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
389 | 389 | feed_url = ? AND owner_uid = ?"); |
390 | - $sth->execute([$feed_url, $_SESSION['uid']]); |
|
390 | + $sth->execute([$feed_url, $_SESSION['uid']]); |
|
391 | 391 | |
392 | - if (!$sth->fetch()) { |
|
393 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
|
392 | + if (!$sth->fetch()) { |
|
393 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
|
394 | 394 | (owner_uid,feed_url,title,cat_id,site_url) |
395 | 395 | VALUES (?, ?, ?, NULL, ?)"); |
396 | 396 | |
397 | - $sth->execute([$_SESSION['uid'], $feed_url, $title, $site_url]); |
|
398 | - } |
|
399 | - } |
|
400 | - } |
|
401 | - } |
|
402 | - } |
|
397 | + $sth->execute([$_SESSION['uid'], $feed_url, $title, $site_url]); |
|
398 | + } |
|
399 | + } |
|
400 | + } |
|
401 | + } |
|
402 | + } |
|
403 | 403 | |
404 | - public function catchupFeed() { |
|
405 | - $feed_id = clean($_REQUEST['feed_id']); |
|
406 | - $is_cat = clean($_REQUEST['is_cat']) == "true"; |
|
407 | - $mode = clean($_REQUEST['mode']); |
|
408 | - $search_query = clean($_REQUEST['search_query']); |
|
409 | - $search_lang = clean($_REQUEST['search_lang']); |
|
404 | + public function catchupFeed() { |
|
405 | + $feed_id = clean($_REQUEST['feed_id']); |
|
406 | + $is_cat = clean($_REQUEST['is_cat']) == "true"; |
|
407 | + $mode = clean($_REQUEST['mode']); |
|
408 | + $search_query = clean($_REQUEST['search_query']); |
|
409 | + $search_lang = clean($_REQUEST['search_lang']); |
|
410 | 410 | |
411 | - Feeds::catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]); |
|
411 | + Feeds::catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]); |
|
412 | 412 | |
413 | - // return counters here synchronously so that frontend can figure out next unread feed properly |
|
414 | - print json_encode(['counters' => Counters::getAllCounters()]); |
|
413 | + // return counters here synchronously so that frontend can figure out next unread feed properly |
|
414 | + print json_encode(['counters' => Counters::getAllCounters()]); |
|
415 | 415 | |
416 | - //print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
417 | - } |
|
416 | + //print json_encode(array("message" => "UPDATE_COUNTERS")); |
|
417 | + } |
|
418 | 418 | |
419 | - public function setpanelmode() { |
|
420 | - $wide = (int) clean($_REQUEST["wide"]); |
|
419 | + public function setpanelmode() { |
|
420 | + $wide = (int) clean($_REQUEST["wide"]); |
|
421 | 421 | |
422 | - setcookie("ttrss_widescreen", $wide, |
|
423 | - time() + COOKIE_LIFETIME_LONG); |
|
422 | + setcookie("ttrss_widescreen", $wide, |
|
423 | + time() + COOKIE_LIFETIME_LONG); |
|
424 | 424 | |
425 | - print json_encode(array("wide" => $wide)); |
|
426 | - } |
|
425 | + print json_encode(array("wide" => $wide)); |
|
426 | + } |
|
427 | 427 | |
428 | - public static function updaterandomfeed_real() { |
|
428 | + public static function updaterandomfeed_real() { |
|
429 | 429 | |
430 | - // Test if the feed need a update (update interval exceded). |
|
431 | - if (DB_TYPE == "pgsql") { |
|
432 | - $update_limit_qpart = "AND (( |
|
430 | + // Test if the feed need a update (update interval exceded). |
|
431 | + if (DB_TYPE == "pgsql") { |
|
432 | + $update_limit_qpart = "AND (( |
|
433 | 433 | ttrss_feeds.update_interval = 0 |
434 | 434 | AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL) |
435 | 435 | ) OR ( |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL) |
438 | 438 | ) OR ttrss_feeds.last_updated IS NULL |
439 | 439 | OR last_updated = '1970-01-01 00:00:00')"; |
440 | - } else { |
|
441 | - $update_limit_qpart = "AND (( |
|
440 | + } else { |
|
441 | + $update_limit_qpart = "AND (( |
|
442 | 442 | ttrss_feeds.update_interval = 0 |
443 | 443 | AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE) |
444 | 444 | ) OR ( |
@@ -446,28 +446,28 @@ discard block |
||
446 | 446 | AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE) |
447 | 447 | ) OR ttrss_feeds.last_updated IS NULL |
448 | 448 | OR last_updated = '1970-01-01 00:00:00')"; |
449 | - } |
|
449 | + } |
|
450 | 450 | |
451 | - // Test if feed is currently being updated by another process. |
|
452 | - if (DB_TYPE == "pgsql") { |
|
453 | - $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')"; |
|
454 | - } else { |
|
455 | - $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))"; |
|
456 | - } |
|
451 | + // Test if feed is currently being updated by another process. |
|
452 | + if (DB_TYPE == "pgsql") { |
|
453 | + $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')"; |
|
454 | + } else { |
|
455 | + $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))"; |
|
456 | + } |
|
457 | 457 | |
458 | - $random_qpart = sql_random_function(); |
|
458 | + $random_qpart = sql_random_function(); |
|
459 | 459 | |
460 | - $pdo = Db::pdo(); |
|
460 | + $pdo = Db::pdo(); |
|
461 | 461 | |
462 | - // we could be invoked from public.php with no active session |
|
463 | - if ($_SESSION["uid"]) { |
|
464 | - $owner_check_qpart = "AND ttrss_feeds.owner_uid = ".$pdo->quote($_SESSION["uid"]); |
|
465 | - } else { |
|
466 | - $owner_check_qpart = ""; |
|
467 | - } |
|
462 | + // we could be invoked from public.php with no active session |
|
463 | + if ($_SESSION["uid"]) { |
|
464 | + $owner_check_qpart = "AND ttrss_feeds.owner_uid = ".$pdo->quote($_SESSION["uid"]); |
|
465 | + } else { |
|
466 | + $owner_check_qpart = ""; |
|
467 | + } |
|
468 | 468 | |
469 | - // We search for feed needing update. |
|
470 | - $res = $pdo->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id |
|
469 | + // We search for feed needing update. |
|
470 | + $res = $pdo->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id |
|
471 | 471 | FROM |
472 | 472 | ttrss_feeds, ttrss_users, ttrss_user_prefs |
473 | 473 | WHERE |
@@ -479,139 +479,139 @@ discard block |
||
479 | 479 | $updstart_thresh_qpart |
480 | 480 | ORDER BY $random_qpart LIMIT 30"); |
481 | 481 | |
482 | - $num_updated = 0; |
|
482 | + $num_updated = 0; |
|
483 | 483 | |
484 | - $tstart = time(); |
|
484 | + $tstart = time(); |
|
485 | 485 | |
486 | - while ($line = $res->fetch()) { |
|
487 | - $feed_id = $line["id"]; |
|
486 | + while ($line = $res->fetch()) { |
|
487 | + $feed_id = $line["id"]; |
|
488 | 488 | |
489 | - if (time() - $tstart < ini_get("max_execution_time") * 0.7) { |
|
490 | - RSSUtils::update_rss_feed($feed_id, true); |
|
491 | - ++$num_updated; |
|
492 | - } else { |
|
493 | - break; |
|
494 | - } |
|
495 | - } |
|
489 | + if (time() - $tstart < ini_get("max_execution_time") * 0.7) { |
|
490 | + RSSUtils::update_rss_feed($feed_id, true); |
|
491 | + ++$num_updated; |
|
492 | + } else { |
|
493 | + break; |
|
494 | + } |
|
495 | + } |
|
496 | 496 | |
497 | - // Purge orphans and cleanup tags |
|
498 | - Article::purge_orphans(); |
|
499 | - //cleanup_tags(14, 50000); |
|
497 | + // Purge orphans and cleanup tags |
|
498 | + Article::purge_orphans(); |
|
499 | + //cleanup_tags(14, 50000); |
|
500 | 500 | |
501 | - if ($num_updated > 0) { |
|
502 | - print json_encode(array("message" => "UPDATE_COUNTERS", |
|
503 | - "num_updated" => $num_updated)); |
|
504 | - } else { |
|
505 | - print json_encode(array("message" => "NOTHING_TO_UPDATE")); |
|
506 | - } |
|
501 | + if ($num_updated > 0) { |
|
502 | + print json_encode(array("message" => "UPDATE_COUNTERS", |
|
503 | + "num_updated" => $num_updated)); |
|
504 | + } else { |
|
505 | + print json_encode(array("message" => "NOTHING_TO_UPDATE")); |
|
506 | + } |
|
507 | 507 | |
508 | - } |
|
508 | + } |
|
509 | 509 | |
510 | - public function updaterandomfeed() { |
|
511 | - RPC::updaterandomfeed_real(); |
|
512 | - } |
|
510 | + public function updaterandomfeed() { |
|
511 | + RPC::updaterandomfeed_real(); |
|
512 | + } |
|
513 | 513 | |
514 | - private function markArticlesById($ids, $cmode) { |
|
514 | + private function markArticlesById($ids, $cmode) { |
|
515 | 515 | |
516 | - $ids_qmarks = arr_qmarks($ids); |
|
516 | + $ids_qmarks = arr_qmarks($ids); |
|
517 | 517 | |
518 | - if ($cmode == 0) { |
|
519 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
518 | + if ($cmode == 0) { |
|
519 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
520 | 520 | marked = false, last_marked = NOW() |
521 | 521 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
522 | - } else if ($cmode == 1) { |
|
523 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
522 | + } else if ($cmode == 1) { |
|
523 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
524 | 524 | marked = true, last_marked = NOW() |
525 | 525 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
526 | - } else { |
|
527 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
526 | + } else { |
|
527 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
528 | 528 | marked = NOT marked,last_marked = NOW() |
529 | 529 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
530 | - } |
|
530 | + } |
|
531 | 531 | |
532 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
533 | - } |
|
532 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
533 | + } |
|
534 | 534 | |
535 | - private function publishArticlesById($ids, $cmode) { |
|
535 | + private function publishArticlesById($ids, $cmode) { |
|
536 | 536 | |
537 | - $ids_qmarks = arr_qmarks($ids); |
|
537 | + $ids_qmarks = arr_qmarks($ids); |
|
538 | 538 | |
539 | - if ($cmode == 0) { |
|
540 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
539 | + if ($cmode == 0) { |
|
540 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
541 | 541 | published = false, last_published = NOW() |
542 | 542 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
543 | - } else if ($cmode == 1) { |
|
544 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
543 | + } else if ($cmode == 1) { |
|
544 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
545 | 545 | published = true, last_published = NOW() |
546 | 546 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
547 | - } else { |
|
548 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
547 | + } else { |
|
548 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
549 | 549 | published = NOT published,last_published = NOW() |
550 | 550 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
551 | - } |
|
551 | + } |
|
552 | 552 | |
553 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
554 | - } |
|
553 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
554 | + } |
|
555 | 555 | |
556 | - public function getlinktitlebyid() { |
|
557 | - $id = clean($_REQUEST['id']); |
|
556 | + public function getlinktitlebyid() { |
|
557 | + $id = clean($_REQUEST['id']); |
|
558 | 558 | |
559 | - $sth = $this->pdo->prepare("SELECT link, title FROM ttrss_entries, ttrss_user_entries |
|
559 | + $sth = $this->pdo->prepare("SELECT link, title FROM ttrss_entries, ttrss_user_entries |
|
560 | 560 | WHERE ref_id = ? AND ref_id = id AND owner_uid = ?"); |
561 | - $sth->execute([$id, $_SESSION['uid']]); |
|
561 | + $sth->execute([$id, $_SESSION['uid']]); |
|
562 | 562 | |
563 | - if ($row = $sth->fetch()) { |
|
564 | - $link = $row['link']; |
|
565 | - $title = $row['title']; |
|
563 | + if ($row = $sth->fetch()) { |
|
564 | + $link = $row['link']; |
|
565 | + $title = $row['title']; |
|
566 | 566 | |
567 | - echo json_encode(array("link" => $link, "title" => $title)); |
|
568 | - } else { |
|
569 | - echo json_encode(array("error" => "ARTICLE_NOT_FOUND")); |
|
570 | - } |
|
571 | - } |
|
567 | + echo json_encode(array("link" => $link, "title" => $title)); |
|
568 | + } else { |
|
569 | + echo json_encode(array("error" => "ARTICLE_NOT_FOUND")); |
|
570 | + } |
|
571 | + } |
|
572 | 572 | |
573 | - public function log() { |
|
574 | - $msg = clean($_REQUEST['msg']); |
|
575 | - $file = clean_filename($_REQUEST['file']); |
|
576 | - $line = (int) clean($_REQUEST['line']); |
|
577 | - $context = clean($_REQUEST['context']); |
|
573 | + public function log() { |
|
574 | + $msg = clean($_REQUEST['msg']); |
|
575 | + $file = clean_filename($_REQUEST['file']); |
|
576 | + $line = (int) clean($_REQUEST['line']); |
|
577 | + $context = clean($_REQUEST['context']); |
|
578 | 578 | |
579 | - if ($msg) { |
|
580 | - Logger::get()->log_error(E_USER_WARNING, |
|
581 | - $msg, 'client-js:' . $file, $line, $context); |
|
579 | + if ($msg) { |
|
580 | + Logger::get()->log_error(E_USER_WARNING, |
|
581 | + $msg, 'client-js:' . $file, $line, $context); |
|
582 | 582 | |
583 | - echo json_encode(array("message" => "HOST_ERROR_LOGGED")); |
|
584 | - } else { |
|
585 | - echo json_encode(array("error" => "MESSAGE_NOT_FOUND")); |
|
586 | - } |
|
583 | + echo json_encode(array("message" => "HOST_ERROR_LOGGED")); |
|
584 | + } else { |
|
585 | + echo json_encode(array("error" => "MESSAGE_NOT_FOUND")); |
|
586 | + } |
|
587 | 587 | |
588 | - } |
|
588 | + } |
|
589 | 589 | |
590 | - public function checkforupdates() { |
|
591 | - $rv = []; |
|
590 | + public function checkforupdates() { |
|
591 | + $rv = []; |
|
592 | 592 | |
593 | - $git_timestamp = false; |
|
594 | - $git_commit = false; |
|
593 | + $git_timestamp = false; |
|
594 | + $git_commit = false; |
|
595 | 595 | |
596 | - get_version($git_commit, $git_timestamp); |
|
596 | + get_version($git_commit, $git_timestamp); |
|
597 | 597 | |
598 | - if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && $git_timestamp) { |
|
599 | - $content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]); |
|
598 | + if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && $git_timestamp) { |
|
599 | + $content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]); |
|
600 | 600 | |
601 | - if ($content) { |
|
602 | - $content = json_decode($content, true); |
|
601 | + if ($content) { |
|
602 | + $content = json_decode($content, true); |
|
603 | 603 | |
604 | - if ($content && isset($content["changeset"])) { |
|
605 | - if ($git_timestamp < (int)$content["changeset"]["timestamp"] && |
|
606 | - $git_commit != $content["changeset"]["id"]) { |
|
604 | + if ($content && isset($content["changeset"])) { |
|
605 | + if ($git_timestamp < (int)$content["changeset"]["timestamp"] && |
|
606 | + $git_commit != $content["changeset"]["id"]) { |
|
607 | 607 | |
608 | - $rv = $content["changeset"]; |
|
609 | - } |
|
610 | - } |
|
611 | - } |
|
612 | - } |
|
608 | + $rv = $content["changeset"]; |
|
609 | + } |
|
610 | + } |
|
611 | + } |
|
612 | + } |
|
613 | 613 | |
614 | - print json_encode($rv); |
|
615 | - } |
|
614 | + print json_encode($rv); |
|
615 | + } |
|
616 | 616 | |
617 | 617 | } |
@@ -11,7 +11,9 @@ discard block |
||
11 | 11 | $_SESSION["profile"] = (int) clean($_REQUEST["id"]); |
12 | 12 | |
13 | 13 | // default value |
14 | - if (!$_SESSION["profile"]) $_SESSION["profile"] = null; |
|
14 | + if (!$_SESSION["profile"]) { |
|
15 | + $_SESSION["profile"] = null; |
|
16 | + } |
|
15 | 17 | } |
16 | 18 | |
17 | 19 | public function remprofiles() { |
@@ -173,7 +175,9 @@ discard block |
||
173 | 175 | if ($row = $sth->fetch()) { |
174 | 176 | $feed_id = $row["id"]; |
175 | 177 | } else { |
176 | - if (!$title) $title = '[Unknown]'; |
|
178 | + if (!$title) { |
|
179 | + $title = '[Unknown]'; |
|
180 | + } |
|
177 | 181 | |
178 | 182 | $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
179 | 183 | (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method) |
@@ -216,7 +220,9 @@ discard block |
||
216 | 220 | private function archive_article($id, $owner_uid) { |
217 | 221 | $this->pdo->beginTransaction(); |
218 | 222 | |
219 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
223 | + if (!$owner_uid) { |
|
224 | + $owner_uid = $_SESSION['uid']; |
|
225 | + } |
|
220 | 226 | |
221 | 227 | $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries |
222 | 228 | WHERE ref_id = ? AND owner_uid = ?"); |
@@ -278,8 +284,9 @@ discard block |
||
278 | 284 | 'seq' => $seq |
279 | 285 | ]; |
280 | 286 | |
281 | - if ($seq % 2 == 0) |
|
282 | - $reply['runtime-info'] = make_runtime_info(); |
|
287 | + if ($seq % 2 == 0) { |
|
288 | + $reply['runtime-info'] = make_runtime_info(); |
|
289 | + } |
|
283 | 290 | |
284 | 291 | print json_encode($reply); |
285 | 292 | } |
@@ -353,7 +360,9 @@ discard block |
||
353 | 360 | $payload = json_decode(clean($_REQUEST["payload"]), false); |
354 | 361 | $mode = clean($_REQUEST["mode"]); |
355 | 362 | |
356 | - if (!$payload || !is_array($payload)) return; |
|
363 | + if (!$payload || !is_array($payload)) { |
|
364 | + return; |
|
365 | + } |
|
357 | 366 | |
358 | 367 | if ($mode == 1) { |
359 | 368 | foreach ($payload as $feed) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | public static function create_published_article($title, $url, $content, $labels_str, |
31 | 31 | $owner_uid) { |
32 | 32 | |
33 | - $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash |
|
33 | + $guid = 'SHA1:'.sha1("ttshared:".$url.$owner_uid); // include owner_uid to prevent global GUID clash |
|
34 | 34 | |
35 | 35 | if (!$content) { |
36 | 36 | $pluginhost = new PluginHost(); |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | content = ?, content_hash = ? WHERE id = ?"); |
86 | 86 | $sth->execute([$content, $content_hash, $ref_id]); |
87 | 87 | |
88 | - if (DB_TYPE == "pgsql"){ |
|
88 | + if (DB_TYPE == "pgsql") { |
|
89 | 89 | $sth = $pdo->prepare("UPDATE ttrss_entries |
90 | 90 | SET tsvector_combined = to_tsvector( :ts_content) |
91 | 91 | WHERE id = :id"); |
92 | 92 | $params = [ |
93 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
93 | + ":ts_content" => mb_substr(strip_tags($content), 0, 900000), |
|
94 | 94 | ":id" => $ref_id]; |
95 | 95 | $sth->execute($params); |
96 | 96 | } |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | |
131 | 131 | if ($row = $sth->fetch()) { |
132 | 132 | $ref_id = $row["id"]; |
133 | - if (DB_TYPE == "pgsql"){ |
|
133 | + if (DB_TYPE == "pgsql") { |
|
134 | 134 | $sth = $pdo->prepare("UPDATE ttrss_entries |
135 | 135 | SET tsvector_combined = to_tsvector( :ts_content) |
136 | 136 | WHERE id = :id"); |
137 | 137 | $params = [ |
138 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
138 | + ":ts_content" => mb_substr(strip_tags($content), 0, 900000), |
|
139 | 139 | ":id" => $ref_id]; |
140 | 140 | $sth->execute($params); |
141 | 141 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | print_hidden("op", "article"); |
174 | 174 | print_hidden("method", "setArticleTags"); |
175 | 175 | |
176 | - print "<header class='horizontal'>" . __("Tags for this article (separated by commas):")."</header>"; |
|
176 | + print "<header class='horizontal'>".__("Tags for this article (separated by commas):")."</header>"; |
|
177 | 177 | |
178 | 178 | print "<section>"; |
179 | 179 | print "<textarea dojoType='dijit.form.SimpleTextarea' rows='4' |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | public function setScore() { |
196 | 196 | $ids = explode(",", clean($_REQUEST['id'])); |
197 | - $score = (int)clean($_REQUEST['score']); |
|
197 | + $score = (int) clean($_REQUEST['score']); |
|
198 | 198 | |
199 | 199 | $ids_qmarks = arr_qmarks($ids); |
200 | 200 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | $sth->execute(array_merge([$score], $ids, [$_SESSION['uid']])); |
205 | 205 | |
206 | - print json_encode(["id" => $ids, "score" => (int)$score]); |
|
206 | + print json_encode(["id" => $ids, "score" => (int) $score]); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | public function getScore() { |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $score = $row['score']; |
217 | 217 | |
218 | - print json_encode(["id" => $id, "score" => (int)$score]); |
|
218 | + print json_encode(["id" => $id, "score" => (int) $score]); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | |
294 | 294 | print "<ul>"; |
295 | 295 | while ($line = $sth->fetch()) { |
296 | - print "<li>" . $line["tag_name"] . "</li>"; |
|
296 | + print "<li>".$line["tag_name"]."</li>"; |
|
297 | 297 | } |
298 | 298 | print "</ul>"; |
299 | 299 | } |
@@ -432,21 +432,21 @@ discard block |
||
432 | 432 | if (!$hide_images) { |
433 | 433 | $encsize = ''; |
434 | 434 | if ($entry['height'] > 0) |
435 | - $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
435 | + $encsize .= ' height="'.intval($entry['height']).'"'; |
|
436 | 436 | if ($entry['width'] > 0) |
437 | - $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
437 | + $encsize .= ' width="'.intval($entry['width']).'"'; |
|
438 | 438 | $rv .= "<p><img |
439 | 439 | alt=\"".htmlspecialchars($entry["filename"])."\" |
440 | - src=\"" .htmlspecialchars($entry["url"]) . "\" |
|
441 | - " . $encsize . " /></p>"; |
|
440 | + src=\"" .htmlspecialchars($entry["url"])."\" |
|
441 | + " . $encsize." /></p>"; |
|
442 | 442 | } else { |
443 | 443 | $rv .= "<p><a target=\"_blank\" rel=\"noopener noreferrer\" |
444 | 444 | href=\"".htmlspecialchars($entry["url"])."\" |
445 | - >" .htmlspecialchars($entry["url"]) . "</a></p>"; |
|
445 | + >" .htmlspecialchars($entry["url"])."</a></p>"; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | if ($entry['title']) { |
449 | - $rv.= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
449 | + $rv .= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
@@ -461,13 +461,13 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | $rv .= "<div class=\"attachments\" dojoType=\"fox.form.DropDownButton\">". |
464 | - "<span>" . __('Attachments')."</span>"; |
|
464 | + "<span>".__('Attachments')."</span>"; |
|
465 | 465 | |
466 | 466 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
467 | 467 | |
468 | 468 | foreach ($entries as $entry) { |
469 | 469 | if ($entry["title"]) |
470 | - $title = " — " . truncate_string($entry["title"], 30); |
|
470 | + $title = " — ".truncate_string($entry["title"], 30); |
|
471 | 471 | else |
472 | 472 | $title = ""; |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $filename = ""; |
478 | 478 | |
479 | 479 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
480 | - dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; |
|
480 | + dojoType=\"dijit.MenuItem\">".$filename.$title."</div>"; |
|
481 | 481 | |
482 | 482 | }; |
483 | 483 | |
@@ -546,10 +546,10 @@ discard block |
||
546 | 546 | $tags_str = ""; |
547 | 547 | |
548 | 548 | for ($i = 0; $i < $maxtags; $i++) { |
549 | - $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">" . $tags[$i] . "</a>, "; |
|
549 | + $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">".$tags[$i]."</a>, "; |
|
550 | 550 | } |
551 | 551 | |
552 | - $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
|
552 | + $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str) - 2); |
|
553 | 553 | |
554 | 554 | if (count($tags) > $maxtags) |
555 | 555 | $tags_str .= ", …"; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | if (!$article_image && !$article_stream) { |
742 | 742 | $tmpdoc = new DOMDocument(); |
743 | 743 | |
744 | - if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">' . mb_substr($content, 0, 131070))) { |
|
744 | + if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">'.mb_substr($content, 0, 131070))) { |
|
745 | 745 | $tmpxpath = new DOMXPath($tmpdoc); |
746 | 746 | $elems = $tmpxpath->query('(//img[@src]|//video[@poster]|//iframe[contains(@src , "youtube.com/embed/")])'); |
747 | 747 | |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | if ($e->nodeName == "iframe") { |
750 | 750 | $matches = []; |
751 | 751 | if (preg_match("/\/embed\/([\w-]+)/", $e->getAttribute("src"), $matches)) { |
752 | - $article_image = "https://img.youtube.com/vi/" . $matches[1] . "/hqdefault.jpg"; |
|
753 | - $article_stream = "https://youtu.be/" . $matches[1]; |
|
752 | + $article_image = "https://img.youtube.com/vi/".$matches[1]."/hqdefault.jpg"; |
|
753 | + $article_stream = "https://youtu.be/".$matches[1]; |
|
754 | 754 | break; |
755 | 755 | } |
756 | 756 | } else if ($e->nodeName == "video") { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if (!$title) $title = $url; |
61 | 61 | if (!$title && !$url) return false; |
62 | 62 | |
63 | - if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; |
|
63 | + if (filter_var($url, FILTER_VALIDATE_URL) === false) return false; |
|
64 | 64 | |
65 | 65 | $pdo = Db::pdo(); |
66 | 66 | |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | if (Debug::enabled()) { |
631 | 631 | $rows = $res->rowCount(); |
632 | - Debug::log("Purged $rows orphaned posts."); |
|
632 | + Debug::log("purged $rows orphaned posts."); |
|
633 | 633 | } |
634 | 634 | } |
635 | 635 | |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | |
775 | 775 | if (!$article_image) |
776 | 776 | foreach ($enclosures as $enc) { |
777 | - if (strpos($enc["content_type"], "image/") !== FALSE) { |
|
777 | + if (strpos($enc["content_type"], "image/") !== false) { |
|
778 | 778 | $article_image = $enc["content_url"]; |
779 | 779 | break; |
780 | 780 | } |
@@ -1,620 +1,620 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Article extends Handler_Protected { |
3 | 3 | |
4 | - public function csrf_ignore($method) { |
|
5 | - $csrf_ignored = array("redirect", "editarticletags"); |
|
4 | + public function csrf_ignore($method) { |
|
5 | + $csrf_ignored = array("redirect", "editarticletags"); |
|
6 | 6 | |
7 | - return array_search($method, $csrf_ignored) !== false; |
|
8 | - } |
|
7 | + return array_search($method, $csrf_ignored) !== false; |
|
8 | + } |
|
9 | 9 | |
10 | - public function redirect() { |
|
11 | - $id = clean($_REQUEST['id']); |
|
10 | + public function redirect() { |
|
11 | + $id = clean($_REQUEST['id']); |
|
12 | 12 | |
13 | - $sth = $this->pdo->prepare("SELECT link FROM ttrss_entries, ttrss_user_entries |
|
13 | + $sth = $this->pdo->prepare("SELECT link FROM ttrss_entries, ttrss_user_entries |
|
14 | 14 | WHERE id = ? AND id = ref_id AND owner_uid = ? |
15 | 15 | LIMIT 1"); |
16 | 16 | $sth->execute([$id, $_SESSION['uid']]); |
17 | 17 | |
18 | - if ($row = $sth->fetch()) { |
|
19 | - $article_url = $row['link']; |
|
20 | - $article_url = str_replace("\n", "", $article_url); |
|
18 | + if ($row = $sth->fetch()) { |
|
19 | + $article_url = $row['link']; |
|
20 | + $article_url = str_replace("\n", "", $article_url); |
|
21 | 21 | |
22 | - header("Location: $article_url"); |
|
23 | - return; |
|
22 | + header("Location: $article_url"); |
|
23 | + return; |
|
24 | 24 | |
25 | - } else { |
|
26 | - print_error(__("Article not found.")); |
|
27 | - } |
|
28 | - } |
|
25 | + } else { |
|
26 | + print_error(__("Article not found.")); |
|
27 | + } |
|
28 | + } |
|
29 | 29 | |
30 | - public static function create_published_article($title, $url, $content, $labels_str, |
|
31 | - $owner_uid) { |
|
30 | + public static function create_published_article($title, $url, $content, $labels_str, |
|
31 | + $owner_uid) { |
|
32 | 32 | |
33 | - $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash |
|
33 | + $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash |
|
34 | 34 | |
35 | - if (!$content) { |
|
36 | - $pluginhost = new PluginHost(); |
|
37 | - $pluginhost->load_all(PluginHost::KIND_ALL, $owner_uid); |
|
38 | - $pluginhost->load_data(); |
|
35 | + if (!$content) { |
|
36 | + $pluginhost = new PluginHost(); |
|
37 | + $pluginhost->load_all(PluginHost::KIND_ALL, $owner_uid); |
|
38 | + $pluginhost->load_data(); |
|
39 | 39 | |
40 | - foreach ($pluginhost->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) { |
|
41 | - $extracted_content = $p->hook_get_full_text($url); |
|
40 | + foreach ($pluginhost->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) { |
|
41 | + $extracted_content = $p->hook_get_full_text($url); |
|
42 | 42 | |
43 | - if ($extracted_content) { |
|
44 | - $content = $extracted_content; |
|
45 | - break; |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
43 | + if ($extracted_content) { |
|
44 | + $content = $extracted_content; |
|
45 | + break; |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - $content_hash = sha1($content); |
|
50 | + $content_hash = sha1($content); |
|
51 | 51 | |
52 | - if ($labels_str != "") { |
|
53 | - $labels = explode(",", $labels_str); |
|
54 | - } else { |
|
55 | - $labels = array(); |
|
56 | - } |
|
52 | + if ($labels_str != "") { |
|
53 | + $labels = explode(",", $labels_str); |
|
54 | + } else { |
|
55 | + $labels = array(); |
|
56 | + } |
|
57 | 57 | |
58 | - $rc = false; |
|
58 | + $rc = false; |
|
59 | 59 | |
60 | - if (!$title) $title = $url; |
|
61 | - if (!$title && !$url) return false; |
|
60 | + if (!$title) $title = $url; |
|
61 | + if (!$title && !$url) return false; |
|
62 | 62 | |
63 | - if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; |
|
63 | + if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; |
|
64 | 64 | |
65 | - $pdo = Db::pdo(); |
|
65 | + $pdo = Db::pdo(); |
|
66 | 66 | |
67 | - $pdo->beginTransaction(); |
|
67 | + $pdo->beginTransaction(); |
|
68 | 68 | |
69 | - // only check for our user data here, others might have shared this with different content etc |
|
70 | - $sth = $pdo->prepare("SELECT id FROM ttrss_entries, ttrss_user_entries WHERE |
|
69 | + // only check for our user data here, others might have shared this with different content etc |
|
70 | + $sth = $pdo->prepare("SELECT id FROM ttrss_entries, ttrss_user_entries WHERE |
|
71 | 71 | guid = ? AND ref_id = id AND owner_uid = ? LIMIT 1"); |
72 | - $sth->execute([$guid, $owner_uid]); |
|
72 | + $sth->execute([$guid, $owner_uid]); |
|
73 | 73 | |
74 | - if ($row = $sth->fetch()) { |
|
75 | - $ref_id = $row['id']; |
|
74 | + if ($row = $sth->fetch()) { |
|
75 | + $ref_id = $row['id']; |
|
76 | 76 | |
77 | - $sth = $pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE |
|
77 | + $sth = $pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE |
|
78 | 78 | ref_id = ? AND owner_uid = ? LIMIT 1"); |
79 | 79 | $sth->execute([$ref_id, $owner_uid]); |
80 | 80 | |
81 | - if ($row = $sth->fetch()) { |
|
82 | - $int_id = $row['int_id']; |
|
81 | + if ($row = $sth->fetch()) { |
|
82 | + $int_id = $row['int_id']; |
|
83 | 83 | |
84 | - $sth = $pdo->prepare("UPDATE ttrss_entries SET |
|
84 | + $sth = $pdo->prepare("UPDATE ttrss_entries SET |
|
85 | 85 | content = ?, content_hash = ? WHERE id = ?"); |
86 | - $sth->execute([$content, $content_hash, $ref_id]); |
|
86 | + $sth->execute([$content, $content_hash, $ref_id]); |
|
87 | 87 | |
88 | - if (DB_TYPE == "pgsql"){ |
|
89 | - $sth = $pdo->prepare("UPDATE ttrss_entries |
|
88 | + if (DB_TYPE == "pgsql"){ |
|
89 | + $sth = $pdo->prepare("UPDATE ttrss_entries |
|
90 | 90 | SET tsvector_combined = to_tsvector( :ts_content) |
91 | 91 | WHERE id = :id"); |
92 | - $params = [ |
|
93 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
94 | - ":id" => $ref_id]; |
|
95 | - $sth->execute($params); |
|
96 | - } |
|
92 | + $params = [ |
|
93 | + ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
94 | + ":id" => $ref_id]; |
|
95 | + $sth->execute($params); |
|
96 | + } |
|
97 | 97 | |
98 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries SET published = true, |
|
98 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET published = true, |
|
99 | 99 | last_published = NOW() WHERE |
100 | 100 | int_id = ? AND owner_uid = ?"); |
101 | - $sth->execute([$int_id, $owner_uid]); |
|
101 | + $sth->execute([$int_id, $owner_uid]); |
|
102 | 102 | |
103 | - } else { |
|
103 | + } else { |
|
104 | 104 | |
105 | - $sth = $pdo->prepare("INSERT INTO ttrss_user_entries |
|
105 | + $sth = $pdo->prepare("INSERT INTO ttrss_user_entries |
|
106 | 106 | (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, |
107 | 107 | last_read, note, unread, last_published) |
108 | 108 | VALUES |
109 | 109 | (?, '', NULL, NULL, ?, true, '', '', NOW(), '', false, NOW())"); |
110 | - $sth->execute([$ref_id, $owner_uid]); |
|
111 | - } |
|
110 | + $sth->execute([$ref_id, $owner_uid]); |
|
111 | + } |
|
112 | 112 | |
113 | - if (count($labels) != 0) { |
|
114 | - foreach ($labels as $label) { |
|
115 | - Labels::add_article($ref_id, trim($label), $owner_uid); |
|
116 | - } |
|
117 | - } |
|
113 | + if (count($labels) != 0) { |
|
114 | + foreach ($labels as $label) { |
|
115 | + Labels::add_article($ref_id, trim($label), $owner_uid); |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | - $rc = true; |
|
119 | + $rc = true; |
|
120 | 120 | |
121 | - } else { |
|
122 | - $sth = $pdo->prepare("INSERT INTO ttrss_entries |
|
121 | + } else { |
|
122 | + $sth = $pdo->prepare("INSERT INTO ttrss_entries |
|
123 | 123 | (title, guid, link, updated, content, content_hash, date_entered, date_updated) |
124 | 124 | VALUES |
125 | 125 | (?, ?, ?, NOW(), ?, ?, NOW(), NOW())"); |
126 | - $sth->execute([$title, $guid, $url, $content, $content_hash]); |
|
126 | + $sth->execute([$title, $guid, $url, $content, $content_hash]); |
|
127 | 127 | |
128 | - $sth = $pdo->prepare("SELECT id FROM ttrss_entries WHERE guid = ?"); |
|
129 | - $sth->execute([$guid]); |
|
128 | + $sth = $pdo->prepare("SELECT id FROM ttrss_entries WHERE guid = ?"); |
|
129 | + $sth->execute([$guid]); |
|
130 | 130 | |
131 | - if ($row = $sth->fetch()) { |
|
132 | - $ref_id = $row["id"]; |
|
133 | - if (DB_TYPE == "pgsql"){ |
|
134 | - $sth = $pdo->prepare("UPDATE ttrss_entries |
|
131 | + if ($row = $sth->fetch()) { |
|
132 | + $ref_id = $row["id"]; |
|
133 | + if (DB_TYPE == "pgsql"){ |
|
134 | + $sth = $pdo->prepare("UPDATE ttrss_entries |
|
135 | 135 | SET tsvector_combined = to_tsvector( :ts_content) |
136 | 136 | WHERE id = :id"); |
137 | - $params = [ |
|
138 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
139 | - ":id" => $ref_id]; |
|
140 | - $sth->execute($params); |
|
141 | - } |
|
142 | - $sth = $pdo->prepare("INSERT INTO ttrss_user_entries |
|
137 | + $params = [ |
|
138 | + ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
139 | + ":id" => $ref_id]; |
|
140 | + $sth->execute($params); |
|
141 | + } |
|
142 | + $sth = $pdo->prepare("INSERT INTO ttrss_user_entries |
|
143 | 143 | (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, |
144 | 144 | last_read, note, unread, last_published) |
145 | 145 | VALUES |
146 | 146 | (?, '', NULL, NULL, ?, true, '', '', NOW(), '', false, NOW())"); |
147 | - $sth->execute([$ref_id, $owner_uid]); |
|
147 | + $sth->execute([$ref_id, $owner_uid]); |
|
148 | 148 | |
149 | - if (count($labels) != 0) { |
|
150 | - foreach ($labels as $label) { |
|
151 | - Labels::add_article($ref_id, trim($label), $owner_uid); |
|
152 | - } |
|
153 | - } |
|
149 | + if (count($labels) != 0) { |
|
150 | + foreach ($labels as $label) { |
|
151 | + Labels::add_article($ref_id, trim($label), $owner_uid); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - $rc = true; |
|
156 | - } |
|
157 | - } |
|
155 | + $rc = true; |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - $pdo->commit(); |
|
159 | + $pdo->commit(); |
|
160 | 160 | |
161 | - return $rc; |
|
162 | - } |
|
161 | + return $rc; |
|
162 | + } |
|
163 | 163 | |
164 | - public function editArticleTags() { |
|
164 | + public function editArticleTags() { |
|
165 | 165 | |
166 | - $param = clean($_REQUEST['param']); |
|
166 | + $param = clean($_REQUEST['param']); |
|
167 | 167 | |
168 | - $tags = Article::get_article_tags($param); |
|
168 | + $tags = Article::get_article_tags($param); |
|
169 | 169 | |
170 | - $tags_str = join(", ", $tags); |
|
170 | + $tags_str = join(", ", $tags); |
|
171 | 171 | |
172 | - print_hidden("id", "$param"); |
|
173 | - print_hidden("op", "article"); |
|
174 | - print_hidden("method", "setArticleTags"); |
|
172 | + print_hidden("id", "$param"); |
|
173 | + print_hidden("op", "article"); |
|
174 | + print_hidden("method", "setArticleTags"); |
|
175 | 175 | |
176 | - print "<header class='horizontal'>" . __("Tags for this article (separated by commas):")."</header>"; |
|
176 | + print "<header class='horizontal'>" . __("Tags for this article (separated by commas):")."</header>"; |
|
177 | 177 | |
178 | - print "<section>"; |
|
179 | - print "<textarea dojoType='dijit.form.SimpleTextarea' rows='4' |
|
178 | + print "<section>"; |
|
179 | + print "<textarea dojoType='dijit.form.SimpleTextarea' rows='4' |
|
180 | 180 | style='height : 100px; font-size : 12px; width : 98%' id='tags_str' |
181 | 181 | name='tags_str'>$tags_str</textarea> |
182 | 182 | <div class='autocomplete' id='tags_choices' |
183 | 183 | style='display:none'></div>"; |
184 | - print "</section>"; |
|
184 | + print "</section>"; |
|
185 | 185 | |
186 | - print "<footer>"; |
|
187 | - print "<button dojoType='dijit.form.Button' |
|
186 | + print "<footer>"; |
|
187 | + print "<button dojoType='dijit.form.Button' |
|
188 | 188 | type='submit' class='alt-primary' onclick=\"dijit.byId('editTagsDlg').execute()\">".__('Save')."</button> "; |
189 | - print "<button dojoType='dijit.form.Button' |
|
189 | + print "<button dojoType='dijit.form.Button' |
|
190 | 190 | onclick=\"dijit.byId('editTagsDlg').hide()\">".__('Cancel')."</button>"; |
191 | - print "</footer>"; |
|
191 | + print "</footer>"; |
|
192 | 192 | |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | - public function setScore() { |
|
196 | - $ids = explode(",", clean($_REQUEST['id'])); |
|
197 | - $score = (int)clean($_REQUEST['score']); |
|
195 | + public function setScore() { |
|
196 | + $ids = explode(",", clean($_REQUEST['id'])); |
|
197 | + $score = (int)clean($_REQUEST['score']); |
|
198 | 198 | |
199 | - $ids_qmarks = arr_qmarks($ids); |
|
199 | + $ids_qmarks = arr_qmarks($ids); |
|
200 | 200 | |
201 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
201 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
202 | 202 | score = ? WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
203 | 203 | |
204 | - $sth->execute(array_merge([$score], $ids, [$_SESSION['uid']])); |
|
204 | + $sth->execute(array_merge([$score], $ids, [$_SESSION['uid']])); |
|
205 | 205 | |
206 | - print json_encode(["id" => $ids, "score" => (int)$score]); |
|
207 | - } |
|
206 | + print json_encode(["id" => $ids, "score" => (int)$score]); |
|
207 | + } |
|
208 | 208 | |
209 | - public function getScore() { |
|
210 | - $id = clean($_REQUEST['id']); |
|
209 | + public function getScore() { |
|
210 | + $id = clean($_REQUEST['id']); |
|
211 | 211 | |
212 | - $sth = $this->pdo->prepare("SELECT score FROM ttrss_user_entries WHERE ref_id = ? AND owner_uid = ?"); |
|
213 | - $sth->execute([$id, $_SESSION['uid']]); |
|
214 | - $row = $sth->fetch(); |
|
212 | + $sth = $this->pdo->prepare("SELECT score FROM ttrss_user_entries WHERE ref_id = ? AND owner_uid = ?"); |
|
213 | + $sth->execute([$id, $_SESSION['uid']]); |
|
214 | + $row = $sth->fetch(); |
|
215 | 215 | |
216 | - $score = $row['score']; |
|
216 | + $score = $row['score']; |
|
217 | 217 | |
218 | - print json_encode(["id" => $id, "score" => (int)$score]); |
|
219 | - } |
|
218 | + print json_encode(["id" => $id, "score" => (int)$score]); |
|
219 | + } |
|
220 | 220 | |
221 | 221 | |
222 | - public function setArticleTags() { |
|
222 | + public function setArticleTags() { |
|
223 | 223 | |
224 | - $id = clean($_REQUEST["id"]); |
|
224 | + $id = clean($_REQUEST["id"]); |
|
225 | 225 | |
226 | - $tags_str = clean($_REQUEST["tags_str"]); |
|
227 | - $tags = array_unique(trim_array(explode(",", $tags_str))); |
|
226 | + $tags_str = clean($_REQUEST["tags_str"]); |
|
227 | + $tags = array_unique(trim_array(explode(",", $tags_str))); |
|
228 | 228 | |
229 | - $this->pdo->beginTransaction(); |
|
229 | + $this->pdo->beginTransaction(); |
|
230 | 230 | |
231 | - $sth = $this->pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE |
|
231 | + $sth = $this->pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE |
|
232 | 232 | ref_id = ? AND owner_uid = ? LIMIT 1"); |
233 | - $sth->execute([$id, $_SESSION['uid']]); |
|
233 | + $sth->execute([$id, $_SESSION['uid']]); |
|
234 | 234 | |
235 | - if ($row = $sth->fetch()) { |
|
235 | + if ($row = $sth->fetch()) { |
|
236 | 236 | |
237 | - $tags_to_cache = array(); |
|
237 | + $tags_to_cache = array(); |
|
238 | 238 | |
239 | - $int_id = $row['int_id']; |
|
239 | + $int_id = $row['int_id']; |
|
240 | 240 | |
241 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE |
|
241 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE |
|
242 | 242 | post_int_id = ? AND owner_uid = ?"); |
243 | - $sth->execute([$int_id, $_SESSION['uid']]); |
|
243 | + $sth->execute([$int_id, $_SESSION['uid']]); |
|
244 | 244 | |
245 | - $tags = FeedItem_Common::normalize_categories($tags); |
|
245 | + $tags = FeedItem_Common::normalize_categories($tags); |
|
246 | 246 | |
247 | - foreach ($tags as $tag) { |
|
248 | - if ($tag != '') { |
|
249 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_tags |
|
247 | + foreach ($tags as $tag) { |
|
248 | + if ($tag != '') { |
|
249 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_tags |
|
250 | 250 | (post_int_id, owner_uid, tag_name) |
251 | 251 | VALUES (?, ?, ?)"); |
252 | 252 | |
253 | - $sth->execute([$int_id, $_SESSION['uid'], $tag]); |
|
254 | - } |
|
253 | + $sth->execute([$int_id, $_SESSION['uid'], $tag]); |
|
254 | + } |
|
255 | 255 | |
256 | - array_push($tags_to_cache, $tag); |
|
257 | - } |
|
256 | + array_push($tags_to_cache, $tag); |
|
257 | + } |
|
258 | 258 | |
259 | - /* update tag cache */ |
|
259 | + /* update tag cache */ |
|
260 | 260 | |
261 | - $tags_str = join(",", $tags_to_cache); |
|
261 | + $tags_str = join(",", $tags_to_cache); |
|
262 | 262 | |
263 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries |
|
263 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries |
|
264 | 264 | SET tag_cache = ? WHERE ref_id = ? AND owner_uid = ?"); |
265 | - $sth->execute([$tags_str, $id, $_SESSION['uid']]); |
|
266 | - } |
|
265 | + $sth->execute([$tags_str, $id, $_SESSION['uid']]); |
|
266 | + } |
|
267 | 267 | |
268 | - $this->pdo->commit(); |
|
268 | + $this->pdo->commit(); |
|
269 | 269 | |
270 | - $tags = Article::get_article_tags($id); |
|
271 | - $tags_str = $this->format_tags_string($tags); |
|
272 | - $tags_str_full = join(", ", $tags); |
|
270 | + $tags = Article::get_article_tags($id); |
|
271 | + $tags_str = $this->format_tags_string($tags); |
|
272 | + $tags_str_full = join(", ", $tags); |
|
273 | 273 | |
274 | - if (!$tags_str_full) $tags_str_full = __("no tags"); |
|
274 | + if (!$tags_str_full) $tags_str_full = __("no tags"); |
|
275 | 275 | |
276 | - print json_encode([ |
|
277 | - "id" => (int) $id, |
|
278 | - "content" => $tags_str, |
|
279 | - "content_full" => $tags_str_full |
|
280 | - ]); |
|
281 | - } |
|
276 | + print json_encode([ |
|
277 | + "id" => (int) $id, |
|
278 | + "content" => $tags_str, |
|
279 | + "content_full" => $tags_str_full |
|
280 | + ]); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | |
284 | - public function completeTags() { |
|
285 | - $search = clean($_REQUEST["search"]); |
|
284 | + public function completeTags() { |
|
285 | + $search = clean($_REQUEST["search"]); |
|
286 | 286 | |
287 | - $sth = $this->pdo->prepare("SELECT DISTINCT tag_name FROM ttrss_tags |
|
287 | + $sth = $this->pdo->prepare("SELECT DISTINCT tag_name FROM ttrss_tags |
|
288 | 288 | WHERE owner_uid = ? AND |
289 | 289 | tag_name LIKE ? ORDER BY tag_name |
290 | 290 | LIMIT 10"); |
291 | 291 | |
292 | - $sth->execute([$_SESSION['uid'], "$search%"]); |
|
292 | + $sth->execute([$_SESSION['uid'], "$search%"]); |
|
293 | 293 | |
294 | - print "<ul>"; |
|
295 | - while ($line = $sth->fetch()) { |
|
296 | - print "<li>" . $line["tag_name"] . "</li>"; |
|
297 | - } |
|
298 | - print "</ul>"; |
|
299 | - } |
|
294 | + print "<ul>"; |
|
295 | + while ($line = $sth->fetch()) { |
|
296 | + print "<li>" . $line["tag_name"] . "</li>"; |
|
297 | + } |
|
298 | + print "</ul>"; |
|
299 | + } |
|
300 | 300 | |
301 | - public function assigntolabel() { |
|
302 | - return $this->labelops(true); |
|
303 | - } |
|
301 | + public function assigntolabel() { |
|
302 | + return $this->labelops(true); |
|
303 | + } |
|
304 | 304 | |
305 | - public function removefromlabel() { |
|
306 | - return $this->labelops(false); |
|
307 | - } |
|
305 | + public function removefromlabel() { |
|
306 | + return $this->labelops(false); |
|
307 | + } |
|
308 | 308 | |
309 | - private function labelops($assign) { |
|
310 | - $reply = array(); |
|
309 | + private function labelops($assign) { |
|
310 | + $reply = array(); |
|
311 | 311 | |
312 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
313 | - $label_id = clean($_REQUEST["lid"]); |
|
312 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
313 | + $label_id = clean($_REQUEST["lid"]); |
|
314 | 314 | |
315 | - $label = Labels::find_caption($label_id, $_SESSION["uid"]); |
|
315 | + $label = Labels::find_caption($label_id, $_SESSION["uid"]); |
|
316 | 316 | |
317 | - $reply["info-for-headlines"] = array(); |
|
317 | + $reply["info-for-headlines"] = array(); |
|
318 | 318 | |
319 | - if ($label) { |
|
319 | + if ($label) { |
|
320 | 320 | |
321 | - foreach ($ids as $id) { |
|
321 | + foreach ($ids as $id) { |
|
322 | 322 | |
323 | - if ($assign) |
|
324 | - Labels::add_article($id, $label, $_SESSION["uid"]); |
|
325 | - else |
|
326 | - Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
323 | + if ($assign) |
|
324 | + Labels::add_article($id, $label, $_SESSION["uid"]); |
|
325 | + else |
|
326 | + Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
327 | 327 | |
328 | - $labels = $this->get_article_labels($id, $_SESSION["uid"]); |
|
328 | + $labels = $this->get_article_labels($id, $_SESSION["uid"]); |
|
329 | 329 | |
330 | - array_push($reply["info-for-headlines"], |
|
331 | - array("id" => $id, "labels" => $this->format_article_labels($labels))); |
|
330 | + array_push($reply["info-for-headlines"], |
|
331 | + array("id" => $id, "labels" => $this->format_article_labels($labels))); |
|
332 | 332 | |
333 | - } |
|
334 | - } |
|
333 | + } |
|
334 | + } |
|
335 | 335 | |
336 | - $reply["message"] = "UPDATE_COUNTERS"; |
|
336 | + $reply["message"] = "UPDATE_COUNTERS"; |
|
337 | 337 | |
338 | - print json_encode($reply); |
|
339 | - } |
|
338 | + print json_encode($reply); |
|
339 | + } |
|
340 | 340 | |
341 | - public function getArticleFeed($id) { |
|
342 | - $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries |
|
341 | + public function getArticleFeed($id) { |
|
342 | + $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries |
|
343 | 343 | WHERE ref_id = ? AND owner_uid = ?"); |
344 | - $sth->execute([$id, $_SESSION['uid']]); |
|
344 | + $sth->execute([$id, $_SESSION['uid']]); |
|
345 | 345 | |
346 | - if ($row = $sth->fetch()) { |
|
347 | - return $row["feed_id"]; |
|
348 | - } else { |
|
349 | - return 0; |
|
350 | - } |
|
351 | - } |
|
346 | + if ($row = $sth->fetch()) { |
|
347 | + return $row["feed_id"]; |
|
348 | + } else { |
|
349 | + return 0; |
|
350 | + } |
|
351 | + } |
|
352 | 352 | |
353 | - public static function format_article_enclosures($id, $always_display_enclosures, |
|
354 | - $article_content, $hide_images = false) { |
|
353 | + public static function format_article_enclosures($id, $always_display_enclosures, |
|
354 | + $article_content, $hide_images = false) { |
|
355 | 355 | |
356 | - $result = Article::get_article_enclosures($id); |
|
357 | - $rv = ''; |
|
356 | + $result = Article::get_article_enclosures($id); |
|
357 | + $rv = ''; |
|
358 | 358 | |
359 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) { |
|
360 | - $retval = $plugin->hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images); |
|
361 | - if (is_array($retval)) { |
|
362 | - $rv = $retval[0]; |
|
363 | - $result = $retval[1]; |
|
364 | - } else { |
|
365 | - $rv = $retval; |
|
366 | - } |
|
367 | - } |
|
368 | - unset($retval); // Unset to prevent breaking render if there are no HOOK_RENDER_ENCLOSURE hooks below. |
|
359 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) { |
|
360 | + $retval = $plugin->hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images); |
|
361 | + if (is_array($retval)) { |
|
362 | + $rv = $retval[0]; |
|
363 | + $result = $retval[1]; |
|
364 | + } else { |
|
365 | + $rv = $retval; |
|
366 | + } |
|
367 | + } |
|
368 | + unset($retval); // Unset to prevent breaking render if there are no HOOK_RENDER_ENCLOSURE hooks below. |
|
369 | 369 | |
370 | - if ($rv === '' && !empty($result)) { |
|
371 | - $entries_html = array(); |
|
372 | - $entries = array(); |
|
373 | - $entries_inline = array(); |
|
370 | + if ($rv === '' && !empty($result)) { |
|
371 | + $entries_html = array(); |
|
372 | + $entries = array(); |
|
373 | + $entries_inline = array(); |
|
374 | 374 | |
375 | - foreach ($result as $line) { |
|
375 | + foreach ($result as $line) { |
|
376 | 376 | |
377 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ENCLOSURE_ENTRY) as $plugin) { |
|
378 | - $line = $plugin->hook_enclosure_entry($line, $id); |
|
379 | - } |
|
377 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ENCLOSURE_ENTRY) as $plugin) { |
|
378 | + $line = $plugin->hook_enclosure_entry($line, $id); |
|
379 | + } |
|
380 | 380 | |
381 | - $url = $line["content_url"]; |
|
382 | - $ctype = $line["content_type"]; |
|
383 | - $title = $line["title"]; |
|
384 | - $width = $line["width"]; |
|
385 | - $height = $line["height"]; |
|
381 | + $url = $line["content_url"]; |
|
382 | + $ctype = $line["content_type"]; |
|
383 | + $title = $line["title"]; |
|
384 | + $width = $line["width"]; |
|
385 | + $height = $line["height"]; |
|
386 | 386 | |
387 | - if (!$ctype) $ctype = __("unknown type"); |
|
387 | + if (!$ctype) $ctype = __("unknown type"); |
|
388 | 388 | |
389 | - //$filename = substr($url, strrpos($url, "/")+1); |
|
390 | - $filename = basename($url); |
|
389 | + //$filename = substr($url, strrpos($url, "/")+1); |
|
390 | + $filename = basename($url); |
|
391 | 391 | |
392 | - $player = format_inline_player($url, $ctype); |
|
392 | + $player = format_inline_player($url, $ctype); |
|
393 | 393 | |
394 | - if ($player) array_push($entries_inline, $player); |
|
394 | + if ($player) array_push($entries_inline, $player); |
|
395 | 395 | |
396 | 396 | # $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" . |
397 | 397 | # $filename . " (" . $ctype . ")" . "</a>"; |
398 | 398 | |
399 | - $entry = "<div onclick=\"popupOpenUrl('".htmlspecialchars($url)."')\" |
|
399 | + $entry = "<div onclick=\"popupOpenUrl('".htmlspecialchars($url)."')\" |
|
400 | 400 | dojoType=\"dijit.MenuItem\">$filename ($ctype)</div>"; |
401 | 401 | |
402 | - array_push($entries_html, $entry); |
|
402 | + array_push($entries_html, $entry); |
|
403 | 403 | |
404 | - $entry = array(); |
|
404 | + $entry = array(); |
|
405 | 405 | |
406 | - $entry["type"] = $ctype; |
|
407 | - $entry["filename"] = $filename; |
|
408 | - $entry["url"] = $url; |
|
409 | - $entry["title"] = $title; |
|
410 | - $entry["width"] = $width; |
|
411 | - $entry["height"] = $height; |
|
406 | + $entry["type"] = $ctype; |
|
407 | + $entry["filename"] = $filename; |
|
408 | + $entry["url"] = $url; |
|
409 | + $entry["title"] = $title; |
|
410 | + $entry["width"] = $width; |
|
411 | + $entry["height"] = $height; |
|
412 | 412 | |
413 | - array_push($entries, $entry); |
|
414 | - } |
|
413 | + array_push($entries, $entry); |
|
414 | + } |
|
415 | 415 | |
416 | - if ($_SESSION['uid'] && !get_pref("STRIP_IMAGES") && !$_SESSION["bw_limit"]) { |
|
417 | - if ($always_display_enclosures || |
|
418 | - !preg_match("/<img/i", $article_content)) { |
|
416 | + if ($_SESSION['uid'] && !get_pref("STRIP_IMAGES") && !$_SESSION["bw_limit"]) { |
|
417 | + if ($always_display_enclosures || |
|
418 | + !preg_match("/<img/i", $article_content)) { |
|
419 | 419 | |
420 | - foreach ($entries as $entry) { |
|
420 | + foreach ($entries as $entry) { |
|
421 | 421 | |
422 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) |
|
423 | - $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
422 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) |
|
423 | + $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
424 | 424 | |
425 | 425 | |
426 | - if ($retval) { |
|
427 | - $rv .= $retval; |
|
428 | - } else { |
|
426 | + if ($retval) { |
|
427 | + $rv .= $retval; |
|
428 | + } else { |
|
429 | 429 | |
430 | - if (preg_match("/image/", $entry["type"])) { |
|
430 | + if (preg_match("/image/", $entry["type"])) { |
|
431 | 431 | |
432 | - if (!$hide_images) { |
|
433 | - $encsize = ''; |
|
434 | - if ($entry['height'] > 0) |
|
435 | - $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
436 | - if ($entry['width'] > 0) |
|
437 | - $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
438 | - $rv .= "<p><img |
|
432 | + if (!$hide_images) { |
|
433 | + $encsize = ''; |
|
434 | + if ($entry['height'] > 0) |
|
435 | + $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
436 | + if ($entry['width'] > 0) |
|
437 | + $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
438 | + $rv .= "<p><img |
|
439 | 439 | alt=\"".htmlspecialchars($entry["filename"])."\" |
440 | 440 | src=\"" .htmlspecialchars($entry["url"]) . "\" |
441 | 441 | " . $encsize . " /></p>"; |
442 | - } else { |
|
443 | - $rv .= "<p><a target=\"_blank\" rel=\"noopener noreferrer\" |
|
442 | + } else { |
|
443 | + $rv .= "<p><a target=\"_blank\" rel=\"noopener noreferrer\" |
|
444 | 444 | href=\"".htmlspecialchars($entry["url"])."\" |
445 | 445 | >" .htmlspecialchars($entry["url"]) . "</a></p>"; |
446 | - } |
|
447 | - |
|
448 | - if ($entry['title']) { |
|
449 | - $rv.= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
450 | - } |
|
451 | - } |
|
452 | - } |
|
453 | - } |
|
454 | - } |
|
455 | - } |
|
456 | - |
|
457 | - if (count($entries_inline) > 0) { |
|
458 | - //$rv .= "<hr clear='both'/>"; |
|
459 | - foreach ($entries_inline as $entry) { $rv .= $entry; }; |
|
460 | - $rv .= "<br clear='both'/>"; |
|
461 | - } |
|
462 | - |
|
463 | - $rv .= "<div class=\"attachments\" dojoType=\"fox.form.DropDownButton\">". |
|
464 | - "<span>" . __('Attachments')."</span>"; |
|
465 | - |
|
466 | - $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
467 | - |
|
468 | - foreach ($entries as $entry) { |
|
469 | - if ($entry["title"]) |
|
470 | - $title = " — " . truncate_string($entry["title"], 30); |
|
471 | - else |
|
472 | - $title = ""; |
|
473 | - |
|
474 | - if ($entry["filename"]) |
|
475 | - $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
476 | - else |
|
477 | - $filename = ""; |
|
478 | - |
|
479 | - $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
|
446 | + } |
|
447 | + |
|
448 | + if ($entry['title']) { |
|
449 | + $rv.= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
450 | + } |
|
451 | + } |
|
452 | + } |
|
453 | + } |
|
454 | + } |
|
455 | + } |
|
456 | + |
|
457 | + if (count($entries_inline) > 0) { |
|
458 | + //$rv .= "<hr clear='both'/>"; |
|
459 | + foreach ($entries_inline as $entry) { $rv .= $entry; }; |
|
460 | + $rv .= "<br clear='both'/>"; |
|
461 | + } |
|
462 | + |
|
463 | + $rv .= "<div class=\"attachments\" dojoType=\"fox.form.DropDownButton\">". |
|
464 | + "<span>" . __('Attachments')."</span>"; |
|
465 | + |
|
466 | + $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
467 | + |
|
468 | + foreach ($entries as $entry) { |
|
469 | + if ($entry["title"]) |
|
470 | + $title = " — " . truncate_string($entry["title"], 30); |
|
471 | + else |
|
472 | + $title = ""; |
|
473 | + |
|
474 | + if ($entry["filename"]) |
|
475 | + $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
476 | + else |
|
477 | + $filename = ""; |
|
478 | + |
|
479 | + $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
|
480 | 480 | dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; |
481 | 481 | |
482 | - }; |
|
482 | + }; |
|
483 | 483 | |
484 | - $rv .= "</div>"; |
|
485 | - $rv .= "</div>"; |
|
486 | - } |
|
484 | + $rv .= "</div>"; |
|
485 | + $rv .= "</div>"; |
|
486 | + } |
|
487 | 487 | |
488 | - return $rv; |
|
489 | - } |
|
488 | + return $rv; |
|
489 | + } |
|
490 | 490 | |
491 | - public static function get_article_tags($id, $owner_uid = 0, $tag_cache = false) { |
|
491 | + public static function get_article_tags($id, $owner_uid = 0, $tag_cache = false) { |
|
492 | 492 | |
493 | - $a_id = $id; |
|
493 | + $a_id = $id; |
|
494 | 494 | |
495 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
495 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
496 | 496 | |
497 | - $pdo = Db::pdo(); |
|
497 | + $pdo = Db::pdo(); |
|
498 | 498 | |
499 | - $sth = $pdo->prepare("SELECT DISTINCT tag_name, |
|
499 | + $sth = $pdo->prepare("SELECT DISTINCT tag_name, |
|
500 | 500 | owner_uid as owner FROM ttrss_tags |
501 | 501 | WHERE post_int_id = (SELECT int_id FROM ttrss_user_entries WHERE |
502 | 502 | ref_id = ? AND owner_uid = ? LIMIT 1) ORDER BY tag_name"); |
503 | 503 | |
504 | - $tags = array(); |
|
504 | + $tags = array(); |
|
505 | 505 | |
506 | - /* check cache first */ |
|
506 | + /* check cache first */ |
|
507 | 507 | |
508 | - if ($tag_cache === false) { |
|
509 | - $csth = $pdo->prepare("SELECT tag_cache FROM ttrss_user_entries |
|
508 | + if ($tag_cache === false) { |
|
509 | + $csth = $pdo->prepare("SELECT tag_cache FROM ttrss_user_entries |
|
510 | 510 | WHERE ref_id = ? AND owner_uid = ?"); |
511 | - $csth->execute([$id, $owner_uid]); |
|
511 | + $csth->execute([$id, $owner_uid]); |
|
512 | 512 | |
513 | - if ($row = $csth->fetch()) $tag_cache = $row["tag_cache"]; |
|
514 | - } |
|
513 | + if ($row = $csth->fetch()) $tag_cache = $row["tag_cache"]; |
|
514 | + } |
|
515 | 515 | |
516 | - if ($tag_cache) { |
|
517 | - $tags = explode(",", $tag_cache); |
|
518 | - } else { |
|
516 | + if ($tag_cache) { |
|
517 | + $tags = explode(",", $tag_cache); |
|
518 | + } else { |
|
519 | 519 | |
520 | - /* do it the hard way */ |
|
520 | + /* do it the hard way */ |
|
521 | 521 | |
522 | - $sth->execute([$a_id, $owner_uid]); |
|
522 | + $sth->execute([$a_id, $owner_uid]); |
|
523 | 523 | |
524 | - while ($tmp_line = $sth->fetch()) { |
|
525 | - array_push($tags, $tmp_line["tag_name"]); |
|
526 | - } |
|
524 | + while ($tmp_line = $sth->fetch()) { |
|
525 | + array_push($tags, $tmp_line["tag_name"]); |
|
526 | + } |
|
527 | 527 | |
528 | - /* update the cache */ |
|
528 | + /* update the cache */ |
|
529 | 529 | |
530 | - $tags_str = join(",", $tags); |
|
530 | + $tags_str = join(",", $tags); |
|
531 | 531 | |
532 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
532 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
533 | 533 | SET tag_cache = ? WHERE ref_id = ? |
534 | 534 | AND owner_uid = ?"); |
535 | - $sth->execute([$tags_str, $id, $owner_uid]); |
|
536 | - } |
|
535 | + $sth->execute([$tags_str, $id, $owner_uid]); |
|
536 | + } |
|
537 | 537 | |
538 | - return $tags; |
|
539 | - } |
|
538 | + return $tags; |
|
539 | + } |
|
540 | 540 | |
541 | - public static function format_tags_string($tags) { |
|
542 | - if (!is_array($tags) || count($tags) == 0) { |
|
543 | - return __("no tags"); |
|
544 | - } else { |
|
545 | - $maxtags = min(5, count($tags)); |
|
546 | - $tags_str = ""; |
|
541 | + public static function format_tags_string($tags) { |
|
542 | + if (!is_array($tags) || count($tags) == 0) { |
|
543 | + return __("no tags"); |
|
544 | + } else { |
|
545 | + $maxtags = min(5, count($tags)); |
|
546 | + $tags_str = ""; |
|
547 | 547 | |
548 | - for ($i = 0; $i < $maxtags; $i++) { |
|
549 | - $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">" . $tags[$i] . "</a>, "; |
|
550 | - } |
|
548 | + for ($i = 0; $i < $maxtags; $i++) { |
|
549 | + $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">" . $tags[$i] . "</a>, "; |
|
550 | + } |
|
551 | 551 | |
552 | - $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
|
552 | + $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
|
553 | 553 | |
554 | - if (count($tags) > $maxtags) |
|
555 | - $tags_str .= ", …"; |
|
554 | + if (count($tags) > $maxtags) |
|
555 | + $tags_str .= ", …"; |
|
556 | 556 | |
557 | - return $tags_str; |
|
558 | - } |
|
559 | - } |
|
557 | + return $tags_str; |
|
558 | + } |
|
559 | + } |
|
560 | 560 | |
561 | - public static function format_article_labels($labels) { |
|
561 | + public static function format_article_labels($labels) { |
|
562 | 562 | |
563 | - if (!is_array($labels)) return ''; |
|
563 | + if (!is_array($labels)) return ''; |
|
564 | 564 | |
565 | - $labels_str = ""; |
|
565 | + $labels_str = ""; |
|
566 | 566 | |
567 | - foreach ($labels as $l) { |
|
568 | - $labels_str .= sprintf("<div class='label' |
|
567 | + foreach ($labels as $l) { |
|
568 | + $labels_str .= sprintf("<div class='label' |
|
569 | 569 | style='color : %s; background-color : %s'>%s</div>", |
570 | - $l[2], $l[3], $l[1]); |
|
571 | - } |
|
570 | + $l[2], $l[3], $l[1]); |
|
571 | + } |
|
572 | 572 | |
573 | - return $labels_str; |
|
573 | + return $labels_str; |
|
574 | 574 | |
575 | - } |
|
575 | + } |
|
576 | 576 | |
577 | - public static function format_article_note($id, $note, $allow_edit = true) { |
|
577 | + public static function format_article_note($id, $note, $allow_edit = true) { |
|
578 | 578 | |
579 | - if ($allow_edit) { |
|
580 | - $onclick = "onclick='Plugins.Note.edit($id)'"; |
|
581 | - $note_class = 'editable'; |
|
582 | - } else { |
|
583 | - $onclick = ''; |
|
584 | - $note_class = ''; |
|
585 | - } |
|
579 | + if ($allow_edit) { |
|
580 | + $onclick = "onclick='Plugins.Note.edit($id)'"; |
|
581 | + $note_class = 'editable'; |
|
582 | + } else { |
|
583 | + $onclick = ''; |
|
584 | + $note_class = ''; |
|
585 | + } |
|
586 | 586 | |
587 | - return "<div class='article-note $note_class'> |
|
587 | + return "<div class='article-note $note_class'> |
|
588 | 588 | <i class='material-icons'>note</i> |
589 | 589 | <div $onclick class='body'>$note</div> |
590 | 590 | </div>"; |
591 | - } |
|
591 | + } |
|
592 | 592 | |
593 | - public static function get_article_enclosures($id) { |
|
593 | + public static function get_article_enclosures($id) { |
|
594 | 594 | |
595 | - $pdo = Db::pdo(); |
|
595 | + $pdo = Db::pdo(); |
|
596 | 596 | |
597 | - $sth = $pdo->prepare("SELECT * FROM ttrss_enclosures |
|
597 | + $sth = $pdo->prepare("SELECT * FROM ttrss_enclosures |
|
598 | 598 | WHERE post_id = ? AND content_url != ''"); |
599 | - $sth->execute([$id]); |
|
599 | + $sth->execute([$id]); |
|
600 | 600 | |
601 | - $rv = array(); |
|
601 | + $rv = array(); |
|
602 | 602 | |
603 | - $cache = new DiskCache("images"); |
|
603 | + $cache = new DiskCache("images"); |
|
604 | 604 | |
605 | - while ($line = $sth->fetch()) { |
|
605 | + while ($line = $sth->fetch()) { |
|
606 | 606 | |
607 | - if ($cache->exists(sha1($line["content_url"]))) { |
|
608 | - $line["content_url"] = $cache->getUrl(sha1($line["content_url"])); |
|
609 | - } |
|
607 | + if ($cache->exists(sha1($line["content_url"]))) { |
|
608 | + $line["content_url"] = $cache->getUrl(sha1($line["content_url"])); |
|
609 | + } |
|
610 | 610 | |
611 | - array_push($rv, $line); |
|
612 | - } |
|
611 | + array_push($rv, $line); |
|
612 | + } |
|
613 | 613 | |
614 | - return $rv; |
|
615 | - } |
|
614 | + return $rv; |
|
615 | + } |
|
616 | 616 | |
617 | - public static function purge_orphans() { |
|
617 | + public static function purge_orphans() { |
|
618 | 618 | |
619 | 619 | // purge orphaned posts in main content table |
620 | 620 | |
@@ -633,169 +633,169 @@ discard block |
||
633 | 633 | } |
634 | 634 | } |
635 | 635 | |
636 | - public static function catchupArticlesById($ids, $cmode, $owner_uid = false) { |
|
636 | + public static function catchupArticlesById($ids, $cmode, $owner_uid = false) { |
|
637 | 637 | |
638 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
638 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
639 | 639 | |
640 | - $pdo = Db::pdo(); |
|
640 | + $pdo = Db::pdo(); |
|
641 | 641 | |
642 | - $ids_qmarks = arr_qmarks($ids); |
|
642 | + $ids_qmarks = arr_qmarks($ids); |
|
643 | 643 | |
644 | - if ($cmode == 1) { |
|
645 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
644 | + if ($cmode == 1) { |
|
645 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
646 | 646 | unread = true |
647 | 647 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
648 | - } else if ($cmode == 2) { |
|
649 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
648 | + } else if ($cmode == 2) { |
|
649 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
650 | 650 | unread = NOT unread,last_read = NOW() |
651 | 651 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
652 | - } else { |
|
653 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
652 | + } else { |
|
653 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET |
|
654 | 654 | unread = false,last_read = NOW() |
655 | 655 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
656 | - } |
|
656 | + } |
|
657 | 657 | |
658 | - $sth->execute(array_merge($ids, [$owner_uid])); |
|
658 | + $sth->execute(array_merge($ids, [$owner_uid])); |
|
659 | 659 | |
660 | - /* update ccache */ |
|
660 | + /* update ccache */ |
|
661 | 661 | |
662 | - $sth = $pdo->prepare("SELECT DISTINCT feed_id FROM ttrss_user_entries |
|
662 | + $sth = $pdo->prepare("SELECT DISTINCT feed_id FROM ttrss_user_entries |
|
663 | 663 | WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?"); |
664 | - $sth->execute(array_merge($ids, [$owner_uid])); |
|
664 | + $sth->execute(array_merge($ids, [$owner_uid])); |
|
665 | 665 | |
666 | - while ($line = $sth->fetch()) { |
|
667 | - CCache::update($line["feed_id"], $owner_uid); |
|
668 | - } |
|
669 | - } |
|
666 | + while ($line = $sth->fetch()) { |
|
667 | + CCache::update($line["feed_id"], $owner_uid); |
|
668 | + } |
|
669 | + } |
|
670 | 670 | |
671 | - public static function getLastArticleId() { |
|
672 | - $pdo = DB::pdo(); |
|
671 | + public static function getLastArticleId() { |
|
672 | + $pdo = DB::pdo(); |
|
673 | 673 | |
674 | - $sth = $pdo->prepare("SELECT ref_id AS id FROM ttrss_user_entries |
|
674 | + $sth = $pdo->prepare("SELECT ref_id AS id FROM ttrss_user_entries |
|
675 | 675 | WHERE owner_uid = ? ORDER BY ref_id DESC LIMIT 1"); |
676 | - $sth->execute([$_SESSION['uid']]); |
|
676 | + $sth->execute([$_SESSION['uid']]); |
|
677 | 677 | |
678 | - if ($row = $sth->fetch()) { |
|
679 | - return $row['id']; |
|
680 | - } else { |
|
681 | - return -1; |
|
682 | - } |
|
683 | - } |
|
678 | + if ($row = $sth->fetch()) { |
|
679 | + return $row['id']; |
|
680 | + } else { |
|
681 | + return -1; |
|
682 | + } |
|
683 | + } |
|
684 | 684 | |
685 | - public static function get_article_labels($id, $owner_uid = false) { |
|
686 | - $rv = array(); |
|
685 | + public static function get_article_labels($id, $owner_uid = false) { |
|
686 | + $rv = array(); |
|
687 | 687 | |
688 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
688 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
689 | 689 | |
690 | - $pdo = Db::pdo(); |
|
690 | + $pdo = Db::pdo(); |
|
691 | 691 | |
692 | - $sth = $pdo->prepare("SELECT label_cache FROM |
|
692 | + $sth = $pdo->prepare("SELECT label_cache FROM |
|
693 | 693 | ttrss_user_entries WHERE ref_id = ? AND owner_uid = ?"); |
694 | - $sth->execute([$id, $owner_uid]); |
|
694 | + $sth->execute([$id, $owner_uid]); |
|
695 | 695 | |
696 | - if ($row = $sth->fetch()) { |
|
697 | - $label_cache = $row["label_cache"]; |
|
696 | + if ($row = $sth->fetch()) { |
|
697 | + $label_cache = $row["label_cache"]; |
|
698 | 698 | |
699 | - if ($label_cache) { |
|
700 | - $tmp = json_decode($label_cache, true); |
|
699 | + if ($label_cache) { |
|
700 | + $tmp = json_decode($label_cache, true); |
|
701 | 701 | |
702 | - if (!$tmp || $tmp["no-labels"] == 1) |
|
703 | - return $rv; |
|
704 | - else |
|
705 | - return $tmp; |
|
706 | - } |
|
707 | - } |
|
702 | + if (!$tmp || $tmp["no-labels"] == 1) |
|
703 | + return $rv; |
|
704 | + else |
|
705 | + return $tmp; |
|
706 | + } |
|
707 | + } |
|
708 | 708 | |
709 | - $sth = $pdo->prepare("SELECT DISTINCT label_id,caption,fg_color,bg_color |
|
709 | + $sth = $pdo->prepare("SELECT DISTINCT label_id,caption,fg_color,bg_color |
|
710 | 710 | FROM ttrss_labels2, ttrss_user_labels2 |
711 | 711 | WHERE id = label_id |
712 | 712 | AND article_id = ? |
713 | 713 | AND owner_uid = ? |
714 | 714 | ORDER BY caption"); |
715 | - $sth->execute([$id, $owner_uid]); |
|
716 | - |
|
717 | - while ($line = $sth->fetch()) { |
|
718 | - $rk = array(Labels::label_to_feed_id($line["label_id"]), |
|
719 | - $line["caption"], $line["fg_color"], |
|
720 | - $line["bg_color"]); |
|
721 | - array_push($rv, $rk); |
|
722 | - } |
|
723 | - |
|
724 | - if (count($rv) > 0) |
|
725 | - Labels::update_cache($owner_uid, $id, $rv); |
|
726 | - else |
|
727 | - Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
728 | - |
|
729 | - return $rv; |
|
730 | - } |
|
731 | - |
|
732 | - public static function get_article_image($enclosures, $content, $site_url) { |
|
733 | - |
|
734 | - $article_image = ""; |
|
735 | - $article_stream = ""; |
|
736 | - |
|
737 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_IMAGE) as $p) { |
|
738 | - list ($article_image, $article_stream, $content) = $p->hook_article_image($enclosures, $content, $site_url); |
|
739 | - } |
|
740 | - |
|
741 | - if (!$article_image && !$article_stream) { |
|
742 | - $tmpdoc = new DOMDocument(); |
|
743 | - |
|
744 | - if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">' . mb_substr($content, 0, 131070))) { |
|
745 | - $tmpxpath = new DOMXPath($tmpdoc); |
|
746 | - $elems = $tmpxpath->query('(//img[@src]|//video[@poster]|//iframe[contains(@src , "youtube.com/embed/")])'); |
|
747 | - |
|
748 | - foreach ($elems as $e) { |
|
749 | - if ($e->nodeName == "iframe") { |
|
750 | - $matches = []; |
|
751 | - if (preg_match("/\/embed\/([\w-]+)/", $e->getAttribute("src"), $matches)) { |
|
752 | - $article_image = "https://img.youtube.com/vi/" . $matches[1] . "/hqdefault.jpg"; |
|
753 | - $article_stream = "https://youtu.be/" . $matches[1]; |
|
754 | - break; |
|
755 | - } |
|
756 | - } else if ($e->nodeName == "video") { |
|
757 | - $article_image = $e->getAttribute("poster"); |
|
758 | - |
|
759 | - $src = $tmpxpath->query("//source[@src]", $e)->item(0); |
|
760 | - |
|
761 | - if ($src) { |
|
762 | - $article_stream = $src->getAttribute("src"); |
|
763 | - } |
|
764 | - |
|
765 | - break; |
|
766 | - } else if ($e->nodeName == 'img') { |
|
767 | - if (mb_strpos($e->getAttribute("src"), "data:") !== 0) { |
|
768 | - $article_image = $e->getAttribute("src"); |
|
769 | - } |
|
770 | - break; |
|
771 | - } |
|
772 | - } |
|
773 | - } |
|
774 | - |
|
775 | - if (!$article_image) |
|
776 | - foreach ($enclosures as $enc) { |
|
777 | - if (strpos($enc["content_type"], "image/") !== FALSE) { |
|
778 | - $article_image = $enc["content_url"]; |
|
779 | - break; |
|
780 | - } |
|
781 | - } |
|
782 | - |
|
783 | - if ($article_image) |
|
784 | - $article_image = rewrite_relative_url($site_url, $article_image); |
|
785 | - |
|
786 | - if ($article_stream) |
|
787 | - $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
788 | - } |
|
789 | - |
|
790 | - $cache = new DiskCache("images"); |
|
791 | - |
|
792 | - if ($article_image && $cache->exists(sha1($article_image))) |
|
793 | - $article_image = $cache->getUrl(sha1($article_image)); |
|
794 | - |
|
795 | - if ($article_stream && $cache->exists(sha1($article_stream))) |
|
796 | - $article_stream = $cache->getUrl(sha1($article_stream)); |
|
797 | - |
|
798 | - return [$article_image, $article_stream]; |
|
799 | - } |
|
715 | + $sth->execute([$id, $owner_uid]); |
|
716 | + |
|
717 | + while ($line = $sth->fetch()) { |
|
718 | + $rk = array(Labels::label_to_feed_id($line["label_id"]), |
|
719 | + $line["caption"], $line["fg_color"], |
|
720 | + $line["bg_color"]); |
|
721 | + array_push($rv, $rk); |
|
722 | + } |
|
723 | + |
|
724 | + if (count($rv) > 0) |
|
725 | + Labels::update_cache($owner_uid, $id, $rv); |
|
726 | + else |
|
727 | + Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
728 | + |
|
729 | + return $rv; |
|
730 | + } |
|
731 | + |
|
732 | + public static function get_article_image($enclosures, $content, $site_url) { |
|
733 | + |
|
734 | + $article_image = ""; |
|
735 | + $article_stream = ""; |
|
736 | + |
|
737 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_IMAGE) as $p) { |
|
738 | + list ($article_image, $article_stream, $content) = $p->hook_article_image($enclosures, $content, $site_url); |
|
739 | + } |
|
740 | + |
|
741 | + if (!$article_image && !$article_stream) { |
|
742 | + $tmpdoc = new DOMDocument(); |
|
743 | + |
|
744 | + if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">' . mb_substr($content, 0, 131070))) { |
|
745 | + $tmpxpath = new DOMXPath($tmpdoc); |
|
746 | + $elems = $tmpxpath->query('(//img[@src]|//video[@poster]|//iframe[contains(@src , "youtube.com/embed/")])'); |
|
747 | + |
|
748 | + foreach ($elems as $e) { |
|
749 | + if ($e->nodeName == "iframe") { |
|
750 | + $matches = []; |
|
751 | + if (preg_match("/\/embed\/([\w-]+)/", $e->getAttribute("src"), $matches)) { |
|
752 | + $article_image = "https://img.youtube.com/vi/" . $matches[1] . "/hqdefault.jpg"; |
|
753 | + $article_stream = "https://youtu.be/" . $matches[1]; |
|
754 | + break; |
|
755 | + } |
|
756 | + } else if ($e->nodeName == "video") { |
|
757 | + $article_image = $e->getAttribute("poster"); |
|
758 | + |
|
759 | + $src = $tmpxpath->query("//source[@src]", $e)->item(0); |
|
760 | + |
|
761 | + if ($src) { |
|
762 | + $article_stream = $src->getAttribute("src"); |
|
763 | + } |
|
764 | + |
|
765 | + break; |
|
766 | + } else if ($e->nodeName == 'img') { |
|
767 | + if (mb_strpos($e->getAttribute("src"), "data:") !== 0) { |
|
768 | + $article_image = $e->getAttribute("src"); |
|
769 | + } |
|
770 | + break; |
|
771 | + } |
|
772 | + } |
|
773 | + } |
|
774 | + |
|
775 | + if (!$article_image) |
|
776 | + foreach ($enclosures as $enc) { |
|
777 | + if (strpos($enc["content_type"], "image/") !== FALSE) { |
|
778 | + $article_image = $enc["content_url"]; |
|
779 | + break; |
|
780 | + } |
|
781 | + } |
|
782 | + |
|
783 | + if ($article_image) |
|
784 | + $article_image = rewrite_relative_url($site_url, $article_image); |
|
785 | + |
|
786 | + if ($article_stream) |
|
787 | + $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
788 | + } |
|
789 | + |
|
790 | + $cache = new DiskCache("images"); |
|
791 | + |
|
792 | + if ($article_image && $cache->exists(sha1($article_image))) |
|
793 | + $article_image = $cache->getUrl(sha1($article_image)); |
|
794 | + |
|
795 | + if ($article_stream && $cache->exists(sha1($article_stream))) |
|
796 | + $article_stream = $cache->getUrl(sha1($article_stream)); |
|
797 | + |
|
798 | + return [$article_image, $article_stream]; |
|
799 | + } |
|
800 | 800 | |
801 | 801 | } |
@@ -57,10 +57,16 @@ discard block |
||
57 | 57 | |
58 | 58 | $rc = false; |
59 | 59 | |
60 | - if (!$title) $title = $url; |
|
61 | - if (!$title && !$url) return false; |
|
60 | + if (!$title) { |
|
61 | + $title = $url; |
|
62 | + } |
|
63 | + if (!$title && !$url) { |
|
64 | + return false; |
|
65 | + } |
|
62 | 66 | |
63 | - if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; |
|
67 | + if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { |
|
68 | + return false; |
|
69 | + } |
|
64 | 70 | |
65 | 71 | $pdo = Db::pdo(); |
66 | 72 | |
@@ -271,7 +277,9 @@ discard block |
||
271 | 277 | $tags_str = $this->format_tags_string($tags); |
272 | 278 | $tags_str_full = join(", ", $tags); |
273 | 279 | |
274 | - if (!$tags_str_full) $tags_str_full = __("no tags"); |
|
280 | + if (!$tags_str_full) { |
|
281 | + $tags_str_full = __("no tags"); |
|
282 | + } |
|
275 | 283 | |
276 | 284 | print json_encode([ |
277 | 285 | "id" => (int) $id, |
@@ -320,10 +328,11 @@ discard block |
||
320 | 328 | |
321 | 329 | foreach ($ids as $id) { |
322 | 330 | |
323 | - if ($assign) |
|
324 | - Labels::add_article($id, $label, $_SESSION["uid"]); |
|
325 | - else |
|
326 | - Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
331 | + if ($assign) { |
|
332 | + Labels::add_article($id, $label, $_SESSION["uid"]); |
|
333 | + } else { |
|
334 | + Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
335 | + } |
|
327 | 336 | |
328 | 337 | $labels = $this->get_article_labels($id, $_SESSION["uid"]); |
329 | 338 | |
@@ -384,14 +393,18 @@ discard block |
||
384 | 393 | $width = $line["width"]; |
385 | 394 | $height = $line["height"]; |
386 | 395 | |
387 | - if (!$ctype) $ctype = __("unknown type"); |
|
396 | + if (!$ctype) { |
|
397 | + $ctype = __("unknown type"); |
|
398 | + } |
|
388 | 399 | |
389 | 400 | //$filename = substr($url, strrpos($url, "/")+1); |
390 | 401 | $filename = basename($url); |
391 | 402 | |
392 | 403 | $player = format_inline_player($url, $ctype); |
393 | 404 | |
394 | - if ($player) array_push($entries_inline, $player); |
|
405 | + if ($player) { |
|
406 | + array_push($entries_inline, $player); |
|
407 | + } |
|
395 | 408 | |
396 | 409 | # $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" . |
397 | 410 | # $filename . " (" . $ctype . ")" . "</a>"; |
@@ -419,8 +432,9 @@ discard block |
||
419 | 432 | |
420 | 433 | foreach ($entries as $entry) { |
421 | 434 | |
422 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) |
|
423 | - $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
435 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) { |
|
436 | + $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
437 | + } |
|
424 | 438 | |
425 | 439 | |
426 | 440 | if ($retval) { |
@@ -431,10 +445,12 @@ discard block |
||
431 | 445 | |
432 | 446 | if (!$hide_images) { |
433 | 447 | $encsize = ''; |
434 | - if ($entry['height'] > 0) |
|
435 | - $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
436 | - if ($entry['width'] > 0) |
|
437 | - $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
448 | + if ($entry['height'] > 0) { |
|
449 | + $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
450 | + } |
|
451 | + if ($entry['width'] > 0) { |
|
452 | + $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
453 | + } |
|
438 | 454 | $rv .= "<p><img |
439 | 455 | alt=\"".htmlspecialchars($entry["filename"])."\" |
440 | 456 | src=\"" .htmlspecialchars($entry["url"]) . "\" |
@@ -466,15 +482,17 @@ discard block |
||
466 | 482 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
467 | 483 | |
468 | 484 | foreach ($entries as $entry) { |
469 | - if ($entry["title"]) |
|
470 | - $title = " — " . truncate_string($entry["title"], 30); |
|
471 | - else |
|
472 | - $title = ""; |
|
485 | + if ($entry["title"]) { |
|
486 | + $title = " — " . truncate_string($entry["title"], 30); |
|
487 | + } else { |
|
488 | + $title = ""; |
|
489 | + } |
|
473 | 490 | |
474 | - if ($entry["filename"]) |
|
475 | - $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
476 | - else |
|
477 | - $filename = ""; |
|
491 | + if ($entry["filename"]) { |
|
492 | + $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
493 | + } else { |
|
494 | + $filename = ""; |
|
495 | + } |
|
478 | 496 | |
479 | 497 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
480 | 498 | dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; |
@@ -492,7 +510,9 @@ discard block |
||
492 | 510 | |
493 | 511 | $a_id = $id; |
494 | 512 | |
495 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
513 | + if (!$owner_uid) { |
|
514 | + $owner_uid = $_SESSION["uid"]; |
|
515 | + } |
|
496 | 516 | |
497 | 517 | $pdo = Db::pdo(); |
498 | 518 | |
@@ -510,7 +530,9 @@ discard block |
||
510 | 530 | WHERE ref_id = ? AND owner_uid = ?"); |
511 | 531 | $csth->execute([$id, $owner_uid]); |
512 | 532 | |
513 | - if ($row = $csth->fetch()) $tag_cache = $row["tag_cache"]; |
|
533 | + if ($row = $csth->fetch()) { |
|
534 | + $tag_cache = $row["tag_cache"]; |
|
535 | + } |
|
514 | 536 | } |
515 | 537 | |
516 | 538 | if ($tag_cache) { |
@@ -551,8 +573,9 @@ discard block |
||
551 | 573 | |
552 | 574 | $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
553 | 575 | |
554 | - if (count($tags) > $maxtags) |
|
555 | - $tags_str .= ", …"; |
|
576 | + if (count($tags) > $maxtags) { |
|
577 | + $tags_str .= ", …"; |
|
578 | + } |
|
556 | 579 | |
557 | 580 | return $tags_str; |
558 | 581 | } |
@@ -560,7 +583,9 @@ discard block |
||
560 | 583 | |
561 | 584 | public static function format_article_labels($labels) { |
562 | 585 | |
563 | - if (!is_array($labels)) return ''; |
|
586 | + if (!is_array($labels)) { |
|
587 | + return ''; |
|
588 | + } |
|
564 | 589 | |
565 | 590 | $labels_str = ""; |
566 | 591 | |
@@ -618,10 +643,11 @@ discard block |
||
618 | 643 | |
619 | 644 | // purge orphaned posts in main content table |
620 | 645 | |
621 | - if (DB_TYPE == "mysql") |
|
622 | - $limit_qpart = "LIMIT 5000"; |
|
623 | - else |
|
624 | - $limit_qpart = ""; |
|
646 | + if (DB_TYPE == "mysql") { |
|
647 | + $limit_qpart = "LIMIT 5000"; |
|
648 | + } else { |
|
649 | + $limit_qpart = ""; |
|
650 | + } |
|
625 | 651 | |
626 | 652 | $pdo = Db::pdo(); |
627 | 653 | $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
@@ -635,7 +661,9 @@ discard block |
||
635 | 661 | |
636 | 662 | public static function catchupArticlesById($ids, $cmode, $owner_uid = false) { |
637 | 663 | |
638 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
664 | + if (!$owner_uid) { |
|
665 | + $owner_uid = $_SESSION["uid"]; |
|
666 | + } |
|
639 | 667 | |
640 | 668 | $pdo = Db::pdo(); |
641 | 669 | |
@@ -685,7 +713,9 @@ discard block |
||
685 | 713 | public static function get_article_labels($id, $owner_uid = false) { |
686 | 714 | $rv = array(); |
687 | 715 | |
688 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
716 | + if (!$owner_uid) { |
|
717 | + $owner_uid = $_SESSION["uid"]; |
|
718 | + } |
|
689 | 719 | |
690 | 720 | $pdo = Db::pdo(); |
691 | 721 | |
@@ -699,10 +729,11 @@ discard block |
||
699 | 729 | if ($label_cache) { |
700 | 730 | $tmp = json_decode($label_cache, true); |
701 | 731 | |
702 | - if (!$tmp || $tmp["no-labels"] == 1) |
|
703 | - return $rv; |
|
704 | - else |
|
705 | - return $tmp; |
|
732 | + if (!$tmp || $tmp["no-labels"] == 1) { |
|
733 | + return $rv; |
|
734 | + } else { |
|
735 | + return $tmp; |
|
736 | + } |
|
706 | 737 | } |
707 | 738 | } |
708 | 739 | |
@@ -721,10 +752,11 @@ discard block |
||
721 | 752 | array_push($rv, $rk); |
722 | 753 | } |
723 | 754 | |
724 | - if (count($rv) > 0) |
|
725 | - Labels::update_cache($owner_uid, $id, $rv); |
|
726 | - else |
|
727 | - Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
755 | + if (count($rv) > 0) { |
|
756 | + Labels::update_cache($owner_uid, $id, $rv); |
|
757 | + } else { |
|
758 | + Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
759 | + } |
|
728 | 760 | |
729 | 761 | return $rv; |
730 | 762 | } |
@@ -772,28 +804,33 @@ discard block |
||
772 | 804 | } |
773 | 805 | } |
774 | 806 | |
775 | - if (!$article_image) |
|
776 | - foreach ($enclosures as $enc) { |
|
807 | + if (!$article_image) { |
|
808 | + foreach ($enclosures as $enc) { |
|
777 | 809 | if (strpos($enc["content_type"], "image/") !== FALSE) { |
778 | 810 | $article_image = $enc["content_url"]; |
811 | + } |
|
779 | 812 | break; |
780 | 813 | } |
781 | 814 | } |
782 | 815 | |
783 | - if ($article_image) |
|
784 | - $article_image = rewrite_relative_url($site_url, $article_image); |
|
816 | + if ($article_image) { |
|
817 | + $article_image = rewrite_relative_url($site_url, $article_image); |
|
818 | + } |
|
785 | 819 | |
786 | - if ($article_stream) |
|
787 | - $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
820 | + if ($article_stream) { |
|
821 | + $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
822 | + } |
|
788 | 823 | } |
789 | 824 | |
790 | 825 | $cache = new DiskCache("images"); |
791 | 826 | |
792 | - if ($article_image && $cache->exists(sha1($article_image))) |
|
793 | - $article_image = $cache->getUrl(sha1($article_image)); |
|
827 | + if ($article_image && $cache->exists(sha1($article_image))) { |
|
828 | + $article_image = $cache->getUrl(sha1($article_image)); |
|
829 | + } |
|
794 | 830 | |
795 | - if ($article_stream && $cache->exists(sha1($article_stream))) |
|
796 | - $article_stream = $cache->getUrl(sha1($article_stream)); |
|
831 | + if ($article_stream && $cache->exists(sha1($article_stream))) { |
|
832 | + $article_stream = $cache->getUrl(sha1($article_stream)); |
|
833 | + } |
|
797 | 834 | |
798 | 835 | return [$article_image, $article_stream]; |
799 | 836 | } |
@@ -398,21 +398,21 @@ discard block |
||
398 | 398 | $message = $query_error_override; |
399 | 399 | } else { |
400 | 400 | switch ($view_mode) { |
401 | - case "unread": |
|
402 | - $message = __("No unread articles found to display."); |
|
403 | - break; |
|
404 | - case "updated": |
|
405 | - $message = __("No updated articles found to display."); |
|
406 | - break; |
|
407 | - case "marked": |
|
408 | - $message = __("No starred articles found to display."); |
|
409 | - break; |
|
410 | - default: |
|
411 | - if ($feed < LABEL_BASE_INDEX) { |
|
412 | - $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter."); |
|
413 | - } else { |
|
414 | - $message = __("No articles found to display."); |
|
415 | - } |
|
401 | + case "unread": |
|
402 | + $message = __("No unread articles found to display."); |
|
403 | + break; |
|
404 | + case "updated": |
|
405 | + $message = __("No updated articles found to display."); |
|
406 | + break; |
|
407 | + case "marked": |
|
408 | + $message = __("No starred articles found to display."); |
|
409 | + break; |
|
410 | + default: |
|
411 | + if ($feed < LABEL_BASE_INDEX) { |
|
412 | + $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter."); |
|
413 | + } else { |
|
414 | + $message = __("No articles found to display."); |
|
415 | + } |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -874,29 +874,29 @@ discard block |
||
874 | 874 | // TODO: all this interval stuff needs some generic generator function |
875 | 875 | |
876 | 876 | switch ($mode) { |
877 | - case "1day": |
|
878 | - if (DB_TYPE == "pgsql") { |
|
879 | - $date_qpart = "date_entered < NOW() - INTERVAL '1 day' "; |
|
880 | - } else { |
|
881 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
882 | - } |
|
883 | - break; |
|
884 | - case "1week": |
|
885 | - if (DB_TYPE == "pgsql") { |
|
886 | - $date_qpart = "date_entered < NOW() - INTERVAL '1 week' "; |
|
887 | - } else { |
|
888 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) "; |
|
889 | - } |
|
890 | - break; |
|
891 | - case "2week": |
|
892 | - if (DB_TYPE == "pgsql") { |
|
893 | - $date_qpart = "date_entered < NOW() - INTERVAL '2 week' "; |
|
894 | - } else { |
|
895 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) "; |
|
896 | - } |
|
897 | - break; |
|
898 | - default: |
|
899 | - $date_qpart = "true"; |
|
877 | + case "1day": |
|
878 | + if (DB_TYPE == "pgsql") { |
|
879 | + $date_qpart = "date_entered < NOW() - INTERVAL '1 day' "; |
|
880 | + } else { |
|
881 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
882 | + } |
|
883 | + break; |
|
884 | + case "1week": |
|
885 | + if (DB_TYPE == "pgsql") { |
|
886 | + $date_qpart = "date_entered < NOW() - INTERVAL '1 week' "; |
|
887 | + } else { |
|
888 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) "; |
|
889 | + } |
|
890 | + break; |
|
891 | + case "2week": |
|
892 | + if (DB_TYPE == "pgsql") { |
|
893 | + $date_qpart = "date_entered < NOW() - INTERVAL '2 week' "; |
|
894 | + } else { |
|
895 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) "; |
|
896 | + } |
|
897 | + break; |
|
898 | + default: |
|
899 | + $date_qpart = "true"; |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | if (is_numeric($feed)) { |
@@ -1212,28 +1212,28 @@ discard block |
||
1212 | 1212 | |
1213 | 1213 | public static function getFeedIcon($id) { |
1214 | 1214 | switch ($id) { |
1215 | - case 0: |
|
1216 | - return "archive"; |
|
1217 | - case -1: |
|
1218 | - return "star"; |
|
1219 | - case -2: |
|
1220 | - return "rss_feed"; |
|
1221 | - case -3: |
|
1222 | - return "whatshot"; |
|
1223 | - case -4: |
|
1224 | - return "inbox"; |
|
1225 | - case -6: |
|
1226 | - return "restore"; |
|
1227 | - default: |
|
1228 | - if ($id < LABEL_BASE_INDEX) { |
|
1229 | - return "label"; |
|
1230 | - } else { |
|
1231 | - $icon = self::getIconFile($id); |
|
1215 | + case 0: |
|
1216 | + return "archive"; |
|
1217 | + case -1: |
|
1218 | + return "star"; |
|
1219 | + case -2: |
|
1220 | + return "rss_feed"; |
|
1221 | + case -3: |
|
1222 | + return "whatshot"; |
|
1223 | + case -4: |
|
1224 | + return "inbox"; |
|
1225 | + case -6: |
|
1226 | + return "restore"; |
|
1227 | + default: |
|
1228 | + if ($id < LABEL_BASE_INDEX) { |
|
1229 | + return "label"; |
|
1230 | + } else { |
|
1231 | + $icon = self::getIconFile($id); |
|
1232 | 1232 | |
1233 | 1233 | if ($icon && file_exists($icon)) { |
1234 | - return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
1235 | - } |
|
1234 | + return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
1236 | 1235 | } |
1236 | + } |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | return false; |
@@ -2201,102 +2201,102 @@ discard block |
||
2201 | 2201 | $commandpair = explode(":", mb_strtolower($k), 2); |
2202 | 2202 | |
2203 | 2203 | switch ($commandpair[0]) { |
2204 | - case "title": |
|
2205 | - if ($commandpair[1]) { |
|
2206 | - array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
|
2207 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
2208 | - } else { |
|
2209 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2204 | + case "title": |
|
2205 | + if ($commandpair[1]) { |
|
2206 | + array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
|
2207 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
2208 | + } else { |
|
2209 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2210 | 2210 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2211 | - array_push($search_words, $k); |
|
2212 | - } |
|
2213 | - break; |
|
2214 | - case "author": |
|
2215 | - if ($commandpair[1]) { |
|
2216 | - array_push($query_keywords, "($not (LOWER(author) LIKE ". |
|
2217 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2218 | - } else { |
|
2219 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2211 | + array_push($search_words, $k); |
|
2212 | + } |
|
2213 | + break; |
|
2214 | + case "author": |
|
2215 | + if ($commandpair[1]) { |
|
2216 | + array_push($query_keywords, "($not (LOWER(author) LIKE ". |
|
2217 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2218 | + } else { |
|
2219 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2220 | 2220 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2221 | - array_push($search_words, $k); |
|
2222 | - } |
|
2223 | - break; |
|
2224 | - case "note": |
|
2225 | - if ($commandpair[1]) { |
|
2226 | - if ($commandpair[1] == "true") |
|
2227 | - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2228 | - else if ($commandpair[1] == "false") |
|
2229 | - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2230 | - else |
|
2231 | - array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2232 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2233 | - } else { |
|
2234 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2221 | + array_push($search_words, $k); |
|
2222 | + } |
|
2223 | + break; |
|
2224 | + case "note": |
|
2225 | + if ($commandpair[1]) { |
|
2226 | + if ($commandpair[1] == "true") |
|
2227 | + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2228 | + else if ($commandpair[1] == "false") |
|
2229 | + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2230 | + else |
|
2231 | + array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2232 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2233 | + } else { |
|
2234 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2235 | 2235 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2236 | - if (!$not) array_push($search_words, $k); |
|
2237 | - } |
|
2238 | - break; |
|
2239 | - case "star": |
|
2236 | + if (!$not) array_push($search_words, $k); |
|
2237 | + } |
|
2238 | + break; |
|
2239 | + case "star": |
|
2240 | 2240 | |
2241 | - if ($commandpair[1]) { |
|
2242 | - if ($commandpair[1] == "true") |
|
2243 | - array_push($query_keywords, "($not (marked = true))"); |
|
2244 | - else |
|
2245 | - array_push($query_keywords, "($not (marked = false))"); |
|
2246 | - } else { |
|
2247 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2241 | + if ($commandpair[1]) { |
|
2242 | + if ($commandpair[1] == "true") |
|
2243 | + array_push($query_keywords, "($not (marked = true))"); |
|
2244 | + else |
|
2245 | + array_push($query_keywords, "($not (marked = false))"); |
|
2246 | + } else { |
|
2247 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2248 | 2248 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2249 | - if (!$not) array_push($search_words, $k); |
|
2250 | - } |
|
2251 | - break; |
|
2252 | - case "pub": |
|
2253 | - if ($commandpair[1]) { |
|
2254 | - if ($commandpair[1] == "true") |
|
2255 | - array_push($query_keywords, "($not (published = true))"); |
|
2256 | - else |
|
2257 | - array_push($query_keywords, "($not (published = false))"); |
|
2249 | + if (!$not) array_push($search_words, $k); |
|
2250 | + } |
|
2251 | + break; |
|
2252 | + case "pub": |
|
2253 | + if ($commandpair[1]) { |
|
2254 | + if ($commandpair[1] == "true") |
|
2255 | + array_push($query_keywords, "($not (published = true))"); |
|
2256 | + else |
|
2257 | + array_push($query_keywords, "($not (published = false))"); |
|
2258 | 2258 | |
2259 | - } else { |
|
2260 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2259 | + } else { |
|
2260 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2261 | 2261 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2262 | - if (!$not) array_push($search_words, $k); |
|
2263 | - } |
|
2264 | - break; |
|
2265 | - case "unread": |
|
2266 | - if ($commandpair[1]) { |
|
2267 | - if ($commandpair[1] == "true") |
|
2268 | - array_push($query_keywords, "($not (unread = true))"); |
|
2269 | - else |
|
2270 | - array_push($query_keywords, "($not (unread = false))"); |
|
2262 | + if (!$not) array_push($search_words, $k); |
|
2263 | + } |
|
2264 | + break; |
|
2265 | + case "unread": |
|
2266 | + if ($commandpair[1]) { |
|
2267 | + if ($commandpair[1] == "true") |
|
2268 | + array_push($query_keywords, "($not (unread = true))"); |
|
2269 | + else |
|
2270 | + array_push($query_keywords, "($not (unread = false))"); |
|
2271 | 2271 | |
2272 | - } else { |
|
2273 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2272 | + } else { |
|
2273 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2274 | 2274 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2275 | - if (!$not) array_push($search_words, $k); |
|
2276 | - } |
|
2277 | - break; |
|
2278 | - default: |
|
2279 | - if (strpos($k, "@") === 0) { |
|
2275 | + if (!$not) array_push($search_words, $k); |
|
2276 | + } |
|
2277 | + break; |
|
2278 | + default: |
|
2279 | + if (strpos($k, "@") === 0) { |
|
2280 | 2280 | |
2281 | - $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); |
|
2282 | - $orig_ts = strtotime(substr($k, 1)); |
|
2283 | - $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); |
|
2281 | + $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); |
|
2282 | + $orig_ts = strtotime(substr($k, 1)); |
|
2283 | + $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); |
|
2284 | 2284 | |
2285 | - //$k = date("Y-m-d", strtotime(substr($k, 1))); |
|
2285 | + //$k = date("Y-m-d", strtotime(substr($k, 1))); |
|
2286 | 2286 | |
2287 | - array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); |
|
2288 | - } else { |
|
2287 | + array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); |
|
2288 | + } else { |
|
2289 | 2289 | |
2290 | - if (DB_TYPE == "pgsql") { |
|
2291 | - $k = mb_strtolower($k); |
|
2292 | - array_push($search_query_leftover, $not ? "!$k" : $k); |
|
2293 | - } else { |
|
2294 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2290 | + if (DB_TYPE == "pgsql") { |
|
2291 | + $k = mb_strtolower($k); |
|
2292 | + array_push($search_query_leftover, $not ? "!$k" : $k); |
|
2293 | + } else { |
|
2294 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2295 | 2295 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2296 | - } |
|
2297 | - |
|
2298 | - if (!$not) array_push($search_words, $k); |
|
2299 | 2296 | } |
2297 | + |
|
2298 | + if (!$not) array_push($search_words, $k); |
|
2299 | + } |
|
2300 | 2300 | } |
2301 | 2301 | } |
2302 | 2302 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | require_once "colors.php"; |
3 | 3 | |
4 | 4 | class Feeds extends Handler_Protected { |
5 | - const NEVER_GROUP_FEEDS = [ -6, 0 ]; |
|
6 | - const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ]; |
|
5 | + const NEVER_GROUP_FEEDS = [ -6, 0]; |
|
6 | + const NEVER_GROUP_BY_DATE = [ -2, -1, -3]; |
|
7 | 7 | |
8 | 8 | private $params; |
9 | 9 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | $reply = ""; |
29 | 29 | |
30 | - $rss_link = htmlspecialchars(get_self_url_prefix() . |
|
30 | + $rss_link = htmlspecialchars(get_self_url_prefix(). |
|
31 | 31 | "/public.php?op=rss&id=$feed_id$cat_q$search_q"); |
32 | 32 | |
33 | 33 | $reply .= "<span class='left'>"; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | if ($error) |
52 | - $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
52 | + $reply .= " <i title=\"".htmlspecialchars($error)."\" class='material-icons icon-error'>error</i>"; |
|
53 | 53 | |
54 | 54 | $reply .= "</span>"; |
55 | 55 | $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $sth->execute([$feed]); |
140 | 140 | } |
141 | 141 | |
142 | - if ($method_split[0] == "MarkAllReadGR") { |
|
142 | + if ($method_split[0] == "MarkAllReadGR") { |
|
143 | 143 | $this->catchup_feed($method_split[1], false); |
144 | 144 | } |
145 | 145 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | if (!get_pref('SHOW_CONTENT_PREVIEW')) { |
244 | 244 | $line["content_preview"] = ""; |
245 | 245 | } else { |
246 | - $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); |
|
246 | + $line["content_preview"] = "— ".truncate_string(strip_tags($line["content"]), 250); |
|
247 | 247 | |
248 | 248 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
249 | 249 | $line = $p->hook_query_headlines($line, 250, false); |
@@ -322,10 +322,10 @@ discard block |
||
322 | 322 | if (!get_pref("CDM_EXPANDED")) { |
323 | 323 | $line["cdm_excerpt"] = "<span class='collapse'> |
324 | 324 | <i class='material-icons' onclick='return Article.cdmUnsetActive(event)' |
325 | - title=\"" . __("Collapse article") . "\">remove_circle</i></span>"; |
|
325 | + title=\"" . __("Collapse article")."\">remove_circle</i></span>"; |
|
326 | 326 | |
327 | 327 | if (get_pref('SHOW_CONTENT_PREVIEW')) { |
328 | - $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; |
|
328 | + $line["cdm_excerpt"] .= "<span class='excerpt'>".$line["content_preview"]."</span>"; |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); |
340 | 340 | |
341 | 341 | if ($tmp_line = $ofgh->fetch()) { |
342 | - $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; |
|
342 | + $line["orig_feed"] = [$tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"]]; |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - $line["updated_long"] = make_local_datetime($line["updated"],true); |
|
346 | + $line["updated_long"] = make_local_datetime($line["updated"], true); |
|
347 | 347 | $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); |
348 | 348 | |
349 | 349 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | if (isset($rgba_cache[$feed_id])) { |
380 | - $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
380 | + $line['feed_bg_color'] = 'rgba('.implode(",", $rgba_cache[$feed_id]).',0.3)'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /* we don't need those */ |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | |
422 | 422 | $reply['content'] .= "<p><span class=\"text-muted\">"; |
423 | 423 | |
424 | - $sth = $this->pdo->prepare("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
424 | + $sth = $this->pdo->prepare("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
425 | 425 | WHERE owner_uid = ?"); |
426 | 426 | $sth->execute([$_SESSION['uid']]); |
427 | 427 | $row = $sth->fetch(); |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | |
440 | 440 | if ($num_errors > 0) { |
441 | 441 | $reply['content'] .= "<br/>"; |
442 | - $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">" . |
|
443 | - __('Some feeds have update errors (click for details)') . "</a>"; |
|
442 | + $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">". |
|
443 | + __('Some feeds have update errors (click for details)')."</a>"; |
|
444 | 444 | } |
445 | 445 | $reply['content'] .= "</span></p></div>"; |
446 | 446 | |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $reply['headlines']['is_cat'] = false; |
636 | 636 | |
637 | 637 | $reply['headlines']['toolbar'] = ''; |
638 | - $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>"; |
|
638 | + $reply['headlines']['content'] = "<div class='whiteBox'>".$error."</div>"; |
|
639 | 639 | |
640 | 640 | $reply['headlines-info'] = array("count" => 0, |
641 | 641 | "unread" => 0, |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | print "<fieldset>"; |
670 | 670 | |
671 | 671 | if (get_pref('ENABLE_FEED_CATS')) { |
672 | - print "<label class='inline'>" . __('Place in category:') . "</label> "; |
|
672 | + print "<label class='inline'>".__('Place in category:')."</label> "; |
|
673 | 673 | print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"'); |
674 | 674 | } |
675 | 675 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | print "</section>"; |
679 | 679 | |
680 | 680 | print '<div id="feedDlg_feedsContainer" style="display : none"> |
681 | - <header>' . __('Available feeds') . '</header> |
|
681 | + <header>' . __('Available feeds').'</header> |
|
682 | 682 | <section> |
683 | 683 | <fieldset> |
684 | 684 | <select id="feedDlg_feedContainerSelect" |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | |
744 | 744 | if (DB_TYPE == "pgsql") { |
745 | 745 | print "<fieldset>"; |
746 | - print "<label class='inline'>" . __("Language:") . "</label>"; |
|
746 | + print "<label class='inline'>".__("Language:")."</label>"; |
|
747 | 747 | print_select("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), |
748 | 748 | "dojoType='fox.form.Select' title=\"".__('Used for word stemming')."\""); |
749 | 749 | print "</fieldset>"; |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | Debug::set_enabled(true); |
773 | 773 | Debug::set_loglevel($_REQUEST["xdebug"]); |
774 | 774 | |
775 | - $feed_id = (int)$_REQUEST["feed_id"]; |
|
775 | + $feed_id = (int) $_REQUEST["feed_id"]; |
|
776 | 776 | @$do_update = $_REQUEST["action"] == "do_update"; |
777 | 777 | $csrf_token = $_REQUEST["csrf_token"]; |
778 | 778 | |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | </script> |
812 | 812 | |
813 | 813 | <div class="container"> |
814 | - <h1>Feed Debugger: <?php echo "$feed_id: " . $this->getFeedTitle($feed_id) ?></h1> |
|
814 | + <h1>Feed Debugger: <?php echo "$feed_id: ".$this->getFeedTitle($feed_id) ?></h1> |
|
815 | 815 | <div class="content"> |
816 | 816 | <form method="GET" action=""> |
817 | 817 | <input type="hidden" name="op" value="feeds"> |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | } else if ($n_feed >= 0) { |
1075 | 1075 | |
1076 | 1076 | if ($n_feed != 0) { |
1077 | - $match_part = "feed_id = " . (int)$n_feed; |
|
1077 | + $match_part = "feed_id = ".(int) $n_feed; |
|
1078 | 1078 | } else { |
1079 | 1079 | $match_part = "feed_id IS NULL"; |
1080 | 1080 | } |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted) |
1185 | 1185 | VALUES (?, ?, ?, ?, ?, ?, 0, false)"); |
1186 | 1186 | |
1187 | - $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string)$auth_login, (string)$auth_pass]); |
|
1187 | + $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string) $auth_login, (string) $auth_pass]); |
|
1188 | 1188 | |
1189 | 1189 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
1190 | 1190 | AND owner_uid = ?"); |
@@ -1203,11 +1203,11 @@ discard block |
||
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | public static function getIconFile($feed_id) { |
1206 | - return ICONS_DIR . "/$feed_id.ico"; |
|
1206 | + return ICONS_DIR."/$feed_id.ico"; |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | public static function feedHasIcon($id) { |
1210 | - return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0; |
|
1210 | + return is_file(ICONS_DIR."/$id.ico") && filesize(ICONS_DIR."/$id.ico") > 0; |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | public static function getFeedIcon($id) { |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | $icon = self::getIconFile($id); |
1232 | 1232 | |
1233 | 1233 | if ($icon && file_exists($icon)) { |
1234 | - return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
1234 | + return ICONS_URL."/".basename($icon)."?".filemtime($icon); |
|
1235 | 1235 | } |
1236 | 1236 | } |
1237 | 1237 | } |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | |
1304 | 1304 | $cat_feeds = array(); |
1305 | 1305 | while ($line = $sth->fetch()) { |
1306 | - array_push($cat_feeds, "feed_id = " . (int)$line["id"]); |
|
1306 | + array_push($cat_feeds, "feed_id = ".(int) $line["id"]); |
|
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | if (count($cat_feeds) == 0) return 0; |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | if ($limit > 0) { |
1520 | - $limit_query_part = "LIMIT " . (int)$limit; |
|
1520 | + $limit_query_part = "LIMIT ".(int) $limit; |
|
1521 | 1521 | } |
1522 | 1522 | |
1523 | 1523 | $allow_archived = false; |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | implode(",", $subcats).")"; |
1545 | 1545 | |
1546 | 1546 | } else { |
1547 | - $query_strategy_part = "cat_id = " . $pdo->quote($feed); |
|
1547 | + $query_strategy_part = "cat_id = ".$pdo->quote($feed); |
|
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | } else { |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
1555 | 1555 | |
1556 | 1556 | } else { |
1557 | - $query_strategy_part = "feed_id = " . $pdo->quote($feed); |
|
1557 | + $query_strategy_part = "feed_id = ".$pdo->quote($feed); |
|
1558 | 1558 | } |
1559 | 1559 | } else if ($feed == 0 && !$cat_view) { // archive virtual feed |
1560 | 1560 | $query_strategy_part = "feed_id IS NULL"; |
@@ -1676,7 +1676,7 @@ discard block |
||
1676 | 1676 | $content_query_part = "content, "; |
1677 | 1677 | |
1678 | 1678 | if ($limit_query_part) { |
1679 | - $offset_query_part = "OFFSET " . (int)$offset; |
|
1679 | + $offset_query_part = "OFFSET ".(int) $offset; |
|
1680 | 1680 | } else { |
1681 | 1681 | $offset_query_part = ""; |
1682 | 1682 | } |
@@ -1765,7 +1765,7 @@ discard block |
||
1765 | 1765 | $res = $pdo->query($query); |
1766 | 1766 | |
1767 | 1767 | if ($row = $res->fetch()) { |
1768 | - $first_id = (int)$row["id"]; |
|
1768 | + $first_id = (int) $row["id"]; |
|
1769 | 1769 | |
1770 | 1770 | if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) { |
1771 | 1771 | return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override); |
@@ -1912,9 +1912,9 @@ discard block |
||
1912 | 1912 | } |
1913 | 1913 | |
1914 | 1914 | function color_of($name) { |
1915 | - $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
|
1916 | - "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", |
|
1917 | - "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; |
|
1915 | + $colormap = ["#1cd7d7", "#d91111", "#1212d7", "#8e16e5", "#7b7b7b", |
|
1916 | + "#39f110", "#0bbea6", "#ec0e0e", "#1534f2", "#b9e416", |
|
1917 | + "#479af2", "#f36b14", "#10c7e9", "#1e8fe7", "#e22727"]; |
|
1918 | 1918 | |
1919 | 1919 | $sum = 0; |
1920 | 1920 | |
@@ -1978,13 +1978,13 @@ discard block |
||
1978 | 1978 | |
1979 | 1979 | // support schema-less urls |
1980 | 1980 | if (strpos($url, '//') === 0) { |
1981 | - $url = 'https:' . $url; |
|
1981 | + $url = 'https:'.$url; |
|
1982 | 1982 | } |
1983 | 1983 | |
1984 | 1984 | if (strpos($url, '://') === false) { |
1985 | - $url = 'http://' . $url; |
|
1985 | + $url = 'http://'.$url; |
|
1986 | 1986 | } else if (substr($url, 0, 5) == 'feed:') { |
1987 | - $url = 'http:' . substr($url, 5); |
|
1987 | + $url = 'http:'.substr($url, 5); |
|
1988 | 1988 | } |
1989 | 1989 | |
1990 | 1990 | //prepend slash if the URL has no slash in it |
@@ -2034,7 +2034,7 @@ discard block |
||
2034 | 2034 | |
2035 | 2035 | $sth = $pdo->prepare("INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat,order_id) |
2036 | 2036 | VALUES (?, ?, ?, ?)"); |
2037 | - $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int)$order_id]); |
|
2037 | + $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int) $order_id]); |
|
2038 | 2038 | |
2039 | 2039 | if (!$tr_in_progress) $pdo->commit(); |
2040 | 2040 | |
@@ -2134,7 +2134,7 @@ discard block |
||
2134 | 2134 | $sth->execute([$feed_id]); |
2135 | 2135 | |
2136 | 2136 | } else { |
2137 | - $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
2137 | + $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
2138 | 2138 | USING ttrss_user_entries, ttrss_entries |
2139 | 2139 | WHERE ttrss_entries.id = ref_id AND |
2140 | 2140 | marked = false AND |
@@ -2204,7 +2204,7 @@ discard block |
||
2204 | 2204 | case "title": |
2205 | 2205 | if ($commandpair[1]) { |
2206 | 2206 | array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
2207 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
2207 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
2208 | 2208 | } else { |
2209 | 2209 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
2210 | 2210 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2214,7 +2214,7 @@ discard block |
||
2214 | 2214 | case "author": |
2215 | 2215 | if ($commandpair[1]) { |
2216 | 2216 | array_push($query_keywords, "($not (LOWER(author) LIKE ". |
2217 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2217 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
2218 | 2218 | } else { |
2219 | 2219 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
2220 | 2220 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2229,7 +2229,7 @@ discard block |
||
2229 | 2229 | array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
2230 | 2230 | else |
2231 | 2231 | array_push($query_keywords, "($not (LOWER(note) LIKE ". |
2232 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2232 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
2233 | 2233 | } else { |
2234 | 2234 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
2235 | 2235 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2306,7 +2306,7 @@ discard block |
||
2306 | 2306 | |
2307 | 2307 | // if there's no joiners consider this a "simple" search and |
2308 | 2308 | // concatenate everything with &, otherwise don't try to mess with tsquery syntax |
2309 | - if (preg_match("/[&|]/", implode(" " , $search_query_leftover))) { |
|
2309 | + if (preg_match("/[&|]/", implode(" ", $search_query_leftover))) { |
|
2310 | 2310 | $tsquery = $pdo->quote(implode(" ", $search_query_leftover)); |
2311 | 2311 | } else { |
2312 | 2312 | $tsquery = $pdo->quote(implode(" & ", $search_query_leftover)); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $feed_title = $qfh_ret[1]; |
211 | 211 | $feed_site_url = $qfh_ret[2]; |
212 | 212 | $last_error = $qfh_ret[3]; |
213 | - $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? |
|
213 | + $last_updated = strpos($qfh_ret[4], '1970-') === false ? |
|
214 | 214 | make_local_datetime($qfh_ret[4], false) : __("Never"); |
215 | 215 | $highlight_words = $qfh_ret[5]; |
216 | 216 | $reply['first_id'] = $qfh_ret[6]; |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | return array("code" => 5, "message" => $fetch_last_error); |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - if (mb_strpos($fetch_last_content_type, "html") !== FALSE && Feeds::is_html($contents)) { |
|
1161 | + if (mb_strpos($fetch_last_content_type, "html") !== false && Feeds::is_html($contents)) { |
|
1162 | 1162 | $feedUrls = Feeds::get_feeds_from_html($url, $contents); |
1163 | 1163 | |
1164 | 1164 | if (count($feedUrls) == 0) { |
@@ -2,298 +2,298 @@ discard block |
||
2 | 2 | require_once "colors.php"; |
3 | 3 | |
4 | 4 | class Feeds extends Handler_Protected { |
5 | - const NEVER_GROUP_FEEDS = [ -6, 0 ]; |
|
6 | - const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ]; |
|
5 | + const NEVER_GROUP_FEEDS = [ -6, 0 ]; |
|
6 | + const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ]; |
|
7 | 7 | |
8 | 8 | private $params; |
9 | 9 | |
10 | 10 | function csrf_ignore($method) { |
11 | - $csrf_ignored = array("index", "quickaddfeed", "search"); |
|
11 | + $csrf_ignored = array("index", "quickaddfeed", "search"); |
|
12 | 12 | |
13 | - return array_search($method, $csrf_ignored) !== false; |
|
14 | - } |
|
13 | + return array_search($method, $csrf_ignored) !== false; |
|
14 | + } |
|
15 | 15 | |
16 | - private function format_headline_subtoolbar($feed_site_url, $feed_title, |
|
17 | - $feed_id, $is_cat, $search, |
|
18 | - $error, $feed_last_updated) { |
|
16 | + private function format_headline_subtoolbar($feed_site_url, $feed_title, |
|
17 | + $feed_id, $is_cat, $search, |
|
18 | + $error, $feed_last_updated) { |
|
19 | 19 | |
20 | - if ($is_cat) $cat_q = "&is_cat=$is_cat"; |
|
20 | + if ($is_cat) $cat_q = "&is_cat=$is_cat"; |
|
21 | 21 | |
22 | - if ($search) { |
|
23 | - $search_q = "&q=$search"; |
|
24 | - } else { |
|
25 | - $search_q = ""; |
|
26 | - } |
|
22 | + if ($search) { |
|
23 | + $search_q = "&q=$search"; |
|
24 | + } else { |
|
25 | + $search_q = ""; |
|
26 | + } |
|
27 | 27 | |
28 | - $reply = ""; |
|
28 | + $reply = ""; |
|
29 | 29 | |
30 | - $rss_link = htmlspecialchars(get_self_url_prefix() . |
|
31 | - "/public.php?op=rss&id=$feed_id$cat_q$search_q"); |
|
30 | + $rss_link = htmlspecialchars(get_self_url_prefix() . |
|
31 | + "/public.php?op=rss&id=$feed_id$cat_q$search_q"); |
|
32 | 32 | |
33 | - $reply .= "<span class='left'>"; |
|
33 | + $reply .= "<span class='left'>"; |
|
34 | 34 | |
35 | - $reply .= "<a href=\"#\" |
|
35 | + $reply .= "<a href=\"#\" |
|
36 | 36 | title=\"".__("Show as feed")."\" |
37 | 37 | onclick=\"App.displayDlg('".__("Show as feed")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\"> |
38 | 38 | <i class='icon-syndicate material-icons'>rss_feed</i></a>"; |
39 | 39 | |
40 | - $reply .= "<span id='feed_title'>"; |
|
40 | + $reply .= "<span id='feed_title'>"; |
|
41 | 41 | |
42 | - if ($feed_site_url) { |
|
43 | - $last_updated = T_sprintf("Last updated: %s", $feed_last_updated); |
|
42 | + if ($feed_site_url) { |
|
43 | + $last_updated = T_sprintf("Last updated: %s", $feed_last_updated); |
|
44 | 44 | |
45 | - $reply .= "<a title=\"$last_updated\" target='_blank' href=\"$feed_site_url\">". |
|
46 | - truncate_string(strip_tags($feed_title), 30)."</a>"; |
|
47 | - } else { |
|
48 | - $reply .= strip_tags($feed_title); |
|
49 | - } |
|
45 | + $reply .= "<a title=\"$last_updated\" target='_blank' href=\"$feed_site_url\">". |
|
46 | + truncate_string(strip_tags($feed_title), 30)."</a>"; |
|
47 | + } else { |
|
48 | + $reply .= strip_tags($feed_title); |
|
49 | + } |
|
50 | 50 | |
51 | - if ($error) |
|
52 | - $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
51 | + if ($error) |
|
52 | + $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
53 | 53 | |
54 | - $reply .= "</span>"; |
|
55 | - $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
|
56 | - $reply .= "</span>"; |
|
54 | + $reply .= "</span>"; |
|
55 | + $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
|
56 | + $reply .= "</span>"; |
|
57 | 57 | |
58 | - $reply .= "<span class=\"right\">"; |
|
59 | - $reply .= "<span id='selected_prompt'></span>"; |
|
60 | - $reply .= " "; |
|
61 | - $reply .= "<select dojoType=\"fox.form.Select\" |
|
58 | + $reply .= "<span class=\"right\">"; |
|
59 | + $reply .= "<span id='selected_prompt'></span>"; |
|
60 | + $reply .= " "; |
|
61 | + $reply .= "<select dojoType=\"fox.form.Select\" |
|
62 | 62 | onchange=\"Headlines.onActionChanged(this)\">"; |
63 | 63 | |
64 | - $reply .= "<option value=\"0\" disabled='1'>".__('Select...')."</option>"; |
|
64 | + $reply .= "<option value=\"0\" disabled='1'>".__('Select...')."</option>"; |
|
65 | 65 | |
66 | - $reply .= "<option value=\"Headlines.select('all')\">".__('All')."</option>"; |
|
67 | - $reply .= "<option value=\"Headlines.select('unread')\">".__('Unread')."</option>"; |
|
68 | - $reply .= "<option value=\"Headlines.select('invert')\">".__('Invert')."</option>"; |
|
69 | - $reply .= "<option value=\"Headlines.select('none')\">".__('None')."</option>"; |
|
66 | + $reply .= "<option value=\"Headlines.select('all')\">".__('All')."</option>"; |
|
67 | + $reply .= "<option value=\"Headlines.select('unread')\">".__('Unread')."</option>"; |
|
68 | + $reply .= "<option value=\"Headlines.select('invert')\">".__('Invert')."</option>"; |
|
69 | + $reply .= "<option value=\"Headlines.select('none')\">".__('None')."</option>"; |
|
70 | 70 | |
71 | - $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>"; |
|
71 | + $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection toggle:')."</option>"; |
|
72 | 72 | |
73 | - $reply .= "<option value=\"Headlines.selectionToggleUnread()\">".__('Unread')."</option> |
|
73 | + $reply .= "<option value=\"Headlines.selectionToggleUnread()\">".__('Unread')."</option> |
|
74 | 74 | <option value=\"Headlines.selectionToggleMarked()\">".__('Starred')."</option> |
75 | 75 | <option value=\"Headlines.selectionTogglePublished()\">".__('Published')."</option>"; |
76 | 76 | |
77 | - $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>"; |
|
77 | + $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>"; |
|
78 | 78 | |
79 | - $reply .= "<option value=\"Headlines.catchupSelection()\">".__('Mark as read')."</option>"; |
|
80 | - $reply .= "<option value=\"Article.selectionSetScore()\">".__('Set score')."</option>"; |
|
79 | + $reply .= "<option value=\"Headlines.catchupSelection()\">".__('Mark as read')."</option>"; |
|
80 | + $reply .= "<option value=\"Article.selectionSetScore()\">".__('Set score')."</option>"; |
|
81 | 81 | |
82 | - if ($feed_id == 0 && !$is_cat) { |
|
83 | - $reply .= "<option value=\"Headlines.archiveSelection()\">".__('Move back')."</option>"; |
|
84 | - $reply .= "<option value=\"Headlines.deleteSelection()\">".__('Delete')."</option>"; |
|
85 | - } else { |
|
86 | - $reply .= "<option value=\"Headlines.archiveSelection()\">".__('Archive')."</option>"; |
|
87 | - } |
|
82 | + if ($feed_id == 0 && !$is_cat) { |
|
83 | + $reply .= "<option value=\"Headlines.archiveSelection()\">".__('Move back')."</option>"; |
|
84 | + $reply .= "<option value=\"Headlines.deleteSelection()\">".__('Delete')."</option>"; |
|
85 | + } else { |
|
86 | + $reply .= "<option value=\"Headlines.archiveSelection()\">".__('Archive')."</option>"; |
|
87 | + } |
|
88 | 88 | |
89 | - if (PluginHost::getInstance()->get_plugin("mail")) { |
|
90 | - $reply .= "<option value=\"Plugins.Mail.send()\">".__('Forward by email'). |
|
91 | - "</option>"; |
|
92 | - } |
|
89 | + if (PluginHost::getInstance()->get_plugin("mail")) { |
|
90 | + $reply .= "<option value=\"Plugins.Mail.send()\">".__('Forward by email'). |
|
91 | + "</option>"; |
|
92 | + } |
|
93 | 93 | |
94 | - if (PluginHost::getInstance()->get_plugin("mailto")) { |
|
95 | - $reply .= "<option value=\"Plugins.Mailto.send()\">".__('Forward by email'). |
|
96 | - "</option>"; |
|
97 | - } |
|
94 | + if (PluginHost::getInstance()->get_plugin("mailto")) { |
|
95 | + $reply .= "<option value=\"Plugins.Mailto.send()\">".__('Forward by email'). |
|
96 | + "</option>"; |
|
97 | + } |
|
98 | 98 | |
99 | - $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>"; |
|
99 | + $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>"; |
|
100 | 100 | |
101 | - //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; |
|
101 | + //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; |
|
102 | 102 | |
103 | - $reply .= "<option value=\"App.displayDlg('".__("Show as feed")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">". |
|
103 | + $reply .= "<option value=\"App.displayDlg('".__("Show as feed")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">". |
|
104 | 104 | __('Show as feed')."</option>"; |
105 | 105 | |
106 | - $reply .= "</select>"; |
|
106 | + $reply .= "</select>"; |
|
107 | 107 | |
108 | - //$reply .= "</h2"; |
|
108 | + //$reply .= "</h2"; |
|
109 | 109 | |
110 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) { |
|
111 | - $reply .= $p->hook_headline_toolbar_button($feed_id, $is_cat); |
|
112 | - } |
|
110 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) { |
|
111 | + $reply .= $p->hook_headline_toolbar_button($feed_id, $is_cat); |
|
112 | + } |
|
113 | 113 | |
114 | - $reply .= "</span>"; |
|
114 | + $reply .= "</span>"; |
|
115 | 115 | |
116 | - return $reply; |
|
117 | - } |
|
116 | + return $reply; |
|
117 | + } |
|
118 | 118 | |
119 | - private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, |
|
120 | - $offset, $override_order = false, $include_children = false, $check_first_id = false, |
|
121 | - $skip_first_id_check = false, $order_by = false) { |
|
119 | + private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, |
|
120 | + $offset, $override_order = false, $include_children = false, $check_first_id = false, |
|
121 | + $skip_first_id_check = false, $order_by = false) { |
|
122 | 122 | |
123 | - $disable_cache = false; |
|
123 | + $disable_cache = false; |
|
124 | 124 | |
125 | - $reply = array(); |
|
125 | + $reply = array(); |
|
126 | 126 | |
127 | - $rgba_cache = array(); |
|
128 | - $topmost_article_ids = array(); |
|
127 | + $rgba_cache = array(); |
|
128 | + $topmost_article_ids = array(); |
|
129 | 129 | |
130 | - if (!$offset) $offset = 0; |
|
131 | - if ($method == "undefined") $method = ""; |
|
130 | + if (!$offset) $offset = 0; |
|
131 | + if ($method == "undefined") $method = ""; |
|
132 | 132 | |
133 | - $method_split = explode(":", $method); |
|
133 | + $method_split = explode(":", $method); |
|
134 | 134 | |
135 | - if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) { |
|
135 | + if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) { |
|
136 | 136 | $sth = $this->pdo->prepare("UPDATE ttrss_feeds |
137 | 137 | SET last_updated = '1970-01-01', last_update_started = '1970-01-01' |
138 | 138 | WHERE id = ?"); |
139 | 139 | $sth->execute([$feed]); |
140 | - } |
|
141 | - |
|
142 | - if ($method_split[0] == "MarkAllReadGR") { |
|
143 | - $this->catchup_feed($method_split[1], false); |
|
144 | - } |
|
145 | - |
|
146 | - // FIXME: might break tag display? |
|
147 | - |
|
148 | - if (is_numeric($feed) && $feed > 0 && !$cat_view) { |
|
149 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? LIMIT 1"); |
|
150 | - $sth->execute([$feed]); |
|
151 | - |
|
152 | - if (!$sth->fetch()) { |
|
153 | - $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>"; |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - @$search = $_REQUEST["query"]; |
|
158 | - @$search_language = $_REQUEST["search_language"]; // PGSQL only |
|
159 | - |
|
160 | - if ($search) { |
|
161 | - $disable_cache = true; |
|
162 | - } |
|
163 | - |
|
164 | - if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { |
|
165 | - $handler = PluginHost::getInstance()->get_feed_handler( |
|
166 | - PluginHost::feed_to_pfeed_id($feed)); |
|
167 | - |
|
168 | - if ($handler) { |
|
169 | - $options = array( |
|
170 | - "limit" => $limit, |
|
171 | - "view_mode" => $view_mode, |
|
172 | - "cat_view" => $cat_view, |
|
173 | - "search" => $search, |
|
174 | - "override_order" => $override_order, |
|
175 | - "offset" => $offset, |
|
176 | - "owner_uid" => $_SESSION["uid"], |
|
177 | - "filter" => false, |
|
178 | - "since_id" => 0, |
|
179 | - "include_children" => $include_children, |
|
180 | - "order_by" => $order_by); |
|
181 | - |
|
182 | - $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), |
|
183 | - $options); |
|
184 | - } |
|
185 | - |
|
186 | - } else { |
|
187 | - |
|
188 | - $params = array( |
|
189 | - "feed" => $feed, |
|
190 | - "limit" => $limit, |
|
191 | - "view_mode" => $view_mode, |
|
192 | - "cat_view" => $cat_view, |
|
193 | - "search" => $search, |
|
194 | - "search_language" => $search_language, |
|
195 | - "override_order" => $override_order, |
|
196 | - "offset" => $offset, |
|
197 | - "include_children" => $include_children, |
|
198 | - "check_first_id" => $check_first_id, |
|
199 | - "skip_first_id_check" => $skip_first_id_check, |
|
200 | - "order_by" => $order_by |
|
201 | - ); |
|
140 | + } |
|
141 | + |
|
142 | + if ($method_split[0] == "MarkAllReadGR") { |
|
143 | + $this->catchup_feed($method_split[1], false); |
|
144 | + } |
|
145 | + |
|
146 | + // FIXME: might break tag display? |
|
147 | + |
|
148 | + if (is_numeric($feed) && $feed > 0 && !$cat_view) { |
|
149 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? LIMIT 1"); |
|
150 | + $sth->execute([$feed]); |
|
202 | 151 | |
203 | - $qfh_ret = $this->queryFeedHeadlines($params); |
|
204 | - } |
|
152 | + if (!$sth->fetch()) { |
|
153 | + $reply['content'] = "<div align='center'>".__('Feed not found.')."</div>"; |
|
154 | + } |
|
155 | + } |
|
205 | 156 | |
206 | - $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && |
|
207 | - !(in_array($feed, Feeds::NEVER_GROUP_FEEDS) && !$cat_view); |
|
157 | + @$search = $_REQUEST["query"]; |
|
158 | + @$search_language = $_REQUEST["search_language"]; // PGSQL only |
|
208 | 159 | |
209 | - $result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed |
|
210 | - $feed_title = $qfh_ret[1]; |
|
211 | - $feed_site_url = $qfh_ret[2]; |
|
212 | - $last_error = $qfh_ret[3]; |
|
213 | - $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? |
|
214 | - make_local_datetime($qfh_ret[4], false) : __("Never"); |
|
215 | - $highlight_words = $qfh_ret[5]; |
|
216 | - $reply['first_id'] = $qfh_ret[6]; |
|
217 | - $reply['is_vfeed'] = $qfh_ret[7]; |
|
218 | - $query_error_override = $qfh_ret[8]; |
|
160 | + if ($search) { |
|
161 | + $disable_cache = true; |
|
162 | + } |
|
219 | 163 | |
220 | - $reply['search_query'] = [$search, $search_language]; |
|
221 | - $reply['vfeed_group_enabled'] = $vfeed_group_enabled; |
|
164 | + if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { |
|
165 | + $handler = PluginHost::getInstance()->get_feed_handler( |
|
166 | + PluginHost::feed_to_pfeed_id($feed)); |
|
167 | + |
|
168 | + if ($handler) { |
|
169 | + $options = array( |
|
170 | + "limit" => $limit, |
|
171 | + "view_mode" => $view_mode, |
|
172 | + "cat_view" => $cat_view, |
|
173 | + "search" => $search, |
|
174 | + "override_order" => $override_order, |
|
175 | + "offset" => $offset, |
|
176 | + "owner_uid" => $_SESSION["uid"], |
|
177 | + "filter" => false, |
|
178 | + "since_id" => 0, |
|
179 | + "include_children" => $include_children, |
|
180 | + "order_by" => $order_by); |
|
181 | + |
|
182 | + $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), |
|
183 | + $options); |
|
184 | + } |
|
185 | + |
|
186 | + } else { |
|
187 | + |
|
188 | + $params = array( |
|
189 | + "feed" => $feed, |
|
190 | + "limit" => $limit, |
|
191 | + "view_mode" => $view_mode, |
|
192 | + "cat_view" => $cat_view, |
|
193 | + "search" => $search, |
|
194 | + "search_language" => $search_language, |
|
195 | + "override_order" => $override_order, |
|
196 | + "offset" => $offset, |
|
197 | + "include_children" => $include_children, |
|
198 | + "check_first_id" => $check_first_id, |
|
199 | + "skip_first_id_check" => $skip_first_id_check, |
|
200 | + "order_by" => $order_by |
|
201 | + ); |
|
222 | 202 | |
223 | - $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, |
|
224 | - $feed_title, |
|
225 | - $feed, $cat_view, $search, |
|
226 | - $last_error, $last_updated); |
|
203 | + $qfh_ret = $this->queryFeedHeadlines($params); |
|
204 | + } |
|
227 | 205 | |
228 | - if ($offset == 0) { |
|
229 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) { |
|
230 | - $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret); |
|
231 | - } |
|
232 | - } |
|
206 | + $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && |
|
207 | + !(in_array($feed, Feeds::NEVER_GROUP_FEEDS) && !$cat_view); |
|
208 | + |
|
209 | + $result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed |
|
210 | + $feed_title = $qfh_ret[1]; |
|
211 | + $feed_site_url = $qfh_ret[2]; |
|
212 | + $last_error = $qfh_ret[3]; |
|
213 | + $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? |
|
214 | + make_local_datetime($qfh_ret[4], false) : __("Never"); |
|
215 | + $highlight_words = $qfh_ret[5]; |
|
216 | + $reply['first_id'] = $qfh_ret[6]; |
|
217 | + $reply['is_vfeed'] = $qfh_ret[7]; |
|
218 | + $query_error_override = $qfh_ret[8]; |
|
219 | + |
|
220 | + $reply['search_query'] = [$search, $search_language]; |
|
221 | + $reply['vfeed_group_enabled'] = $vfeed_group_enabled; |
|
222 | + |
|
223 | + $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, |
|
224 | + $feed_title, |
|
225 | + $feed, $cat_view, $search, |
|
226 | + $last_error, $last_updated); |
|
227 | + |
|
228 | + if ($offset == 0) { |
|
229 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_BEFORE) as $p) { |
|
230 | + $reply['content'] .= $p->hook_headlines_before($feed, $cat_view, $qfh_ret); |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | - $reply['content'] = []; |
|
234 | + $reply['content'] = []; |
|
235 | 235 | |
236 | - $headlines_count = 0; |
|
236 | + $headlines_count = 0; |
|
237 | 237 | |
238 | 238 | if (is_object($result)) { |
239 | - while ($line = $result->fetch(PDO::FETCH_ASSOC)) { |
|
239 | + while ($line = $result->fetch(PDO::FETCH_ASSOC)) { |
|
240 | 240 | |
241 | - ++$headlines_count; |
|
241 | + ++$headlines_count; |
|
242 | 242 | |
243 | - if (!get_pref('SHOW_CONTENT_PREVIEW')) { |
|
244 | - $line["content_preview"] = ""; |
|
245 | - } else { |
|
246 | - $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); |
|
243 | + if (!get_pref('SHOW_CONTENT_PREVIEW')) { |
|
244 | + $line["content_preview"] = ""; |
|
245 | + } else { |
|
246 | + $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); |
|
247 | 247 | |
248 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
|
249 | - $line = $p->hook_query_headlines($line, 250, false); |
|
250 | - } |
|
248 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
|
249 | + $line = $p->hook_query_headlines($line, 250, false); |
|
250 | + } |
|
251 | 251 | } |
252 | 252 | |
253 | - $id = $line["id"]; |
|
253 | + $id = $line["id"]; |
|
254 | 254 | |
255 | - // frontend doesn't expect pdo returning booleans as strings on mysql |
|
256 | - if (DB_TYPE == "mysql") { |
|
257 | - foreach (["unread", "marked", "published"] as $k) { |
|
258 | - $line[$k] = $line[$k] === "1"; |
|
259 | - } |
|
260 | - } |
|
255 | + // frontend doesn't expect pdo returning booleans as strings on mysql |
|
256 | + if (DB_TYPE == "mysql") { |
|
257 | + foreach (["unread", "marked", "published"] as $k) { |
|
258 | + $line[$k] = $line[$k] === "1"; |
|
259 | + } |
|
260 | + } |
|
261 | 261 | |
262 | - // normalize archived feed |
|
263 | - if ($line['feed_id'] === null) { |
|
264 | - $line['feed_id'] = 0; |
|
265 | - $line["feed_title"] = __("Archived articles"); |
|
266 | - } |
|
262 | + // normalize archived feed |
|
263 | + if ($line['feed_id'] === null) { |
|
264 | + $line['feed_id'] = 0; |
|
265 | + $line["feed_title"] = __("Archived articles"); |
|
266 | + } |
|
267 | 267 | |
268 | - $feed_id = $line["feed_id"]; |
|
268 | + $feed_id = $line["feed_id"]; |
|
269 | 269 | |
270 | - $label_cache = $line["label_cache"]; |
|
271 | - $labels = false; |
|
270 | + $label_cache = $line["label_cache"]; |
|
271 | + $labels = false; |
|
272 | 272 | |
273 | - if ($label_cache) { |
|
274 | - $label_cache = json_decode($label_cache, true); |
|
273 | + if ($label_cache) { |
|
274 | + $label_cache = json_decode($label_cache, true); |
|
275 | 275 | |
276 | - if ($label_cache) { |
|
277 | - if ($label_cache["no-labels"] == 1) |
|
278 | - $labels = array(); |
|
279 | - else |
|
280 | - $labels = $label_cache; |
|
281 | - } |
|
282 | - } |
|
276 | + if ($label_cache) { |
|
277 | + if ($label_cache["no-labels"] == 1) |
|
278 | + $labels = array(); |
|
279 | + else |
|
280 | + $labels = $label_cache; |
|
281 | + } |
|
282 | + } |
|
283 | 283 | |
284 | - if (!is_array($labels)) $labels = Article::get_article_labels($id); |
|
284 | + if (!is_array($labels)) $labels = Article::get_article_labels($id); |
|
285 | 285 | |
286 | - $labels_str = "<span class=\"HLLCTR-$id\">"; |
|
287 | - $labels_str .= Article::format_article_labels($labels); |
|
288 | - $labels_str .= "</span>"; |
|
286 | + $labels_str = "<span class=\"HLLCTR-$id\">"; |
|
287 | + $labels_str .= Article::format_article_labels($labels); |
|
288 | + $labels_str .= "</span>"; |
|
289 | 289 | |
290 | - $line["labels"] = $labels_str; |
|
290 | + $line["labels"] = $labels_str; |
|
291 | 291 | |
292 | - if (count($topmost_article_ids) < 3) { |
|
293 | - array_push($topmost_article_ids, $id); |
|
294 | - } |
|
292 | + if (count($topmost_article_ids) < 3) { |
|
293 | + array_push($topmost_article_ids, $id); |
|
294 | + } |
|
295 | 295 | |
296 | - if (!$line["feed_title"]) $line["feed_title"] = ""; |
|
296 | + if (!$line["feed_title"]) $line["feed_title"] = ""; |
|
297 | 297 | |
298 | 298 | $line["buttons_left"] = ""; |
299 | 299 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
@@ -343,341 +343,341 @@ discard block |
||
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - $line["updated_long"] = make_local_datetime($line["updated"],true); |
|
347 | - $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); |
|
346 | + $line["updated_long"] = make_local_datetime($line["updated"],true); |
|
347 | + $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); |
|
348 | 348 | |
349 | 349 | |
350 | - $line['imported'] = T_sprintf("Imported at %s", |
|
351 | - make_local_datetime($line["date_entered"], false)); |
|
350 | + $line['imported'] = T_sprintf("Imported at %s", |
|
351 | + make_local_datetime($line["date_entered"], false)); |
|
352 | 352 | |
353 | - if ($line["tag_cache"]) |
|
354 | - $tags = explode(",", $line["tag_cache"]); |
|
355 | - else |
|
356 | - $tags = false; |
|
353 | + if ($line["tag_cache"]) |
|
354 | + $tags = explode(",", $line["tag_cache"]); |
|
355 | + else |
|
356 | + $tags = false; |
|
357 | 357 | |
358 | - $line["tags_str"] = Article::format_tags_string($tags); |
|
358 | + $line["tags_str"] = Article::format_tags_string($tags); |
|
359 | 359 | |
360 | - if (feeds::feedHasIcon($feed_id)) { |
|
361 | - $line['feed_icon'] = "<img class=\"icon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">"; |
|
362 | - } else { |
|
363 | - $line['feed_icon'] = "<i class='icon-no-feed material-icons'>rss_feed</i>"; |
|
364 | - } |
|
360 | + if (feeds::feedHasIcon($feed_id)) { |
|
361 | + $line['feed_icon'] = "<img class=\"icon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">"; |
|
362 | + } else { |
|
363 | + $line['feed_icon'] = "<i class='icon-no-feed material-icons'>rss_feed</i>"; |
|
364 | + } |
|
365 | 365 | |
366 | - //setting feed headline background color, needs to change text color based on dark/light |
|
367 | - $fav_color = $line['favicon_avg_color']; |
|
366 | + //setting feed headline background color, needs to change text color based on dark/light |
|
367 | + $fav_color = $line['favicon_avg_color']; |
|
368 | 368 | |
369 | - require_once "colors.php"; |
|
369 | + require_once "colors.php"; |
|
370 | 370 | |
371 | - if (!isset($rgba_cache[$feed_id])) { |
|
372 | - if ($fav_color && $fav_color != 'fail') { |
|
373 | - $rgba_cache[$feed_id] = _color_unpack($fav_color); |
|
374 | - } else { |
|
375 | - $rgba_cache[$feed_id] = _color_unpack($this->color_of($line['feed_title'])); |
|
376 | - } |
|
377 | - } |
|
371 | + if (!isset($rgba_cache[$feed_id])) { |
|
372 | + if ($fav_color && $fav_color != 'fail') { |
|
373 | + $rgba_cache[$feed_id] = _color_unpack($fav_color); |
|
374 | + } else { |
|
375 | + $rgba_cache[$feed_id] = _color_unpack($this->color_of($line['feed_title'])); |
|
376 | + } |
|
377 | + } |
|
378 | 378 | |
379 | - if (isset($rgba_cache[$feed_id])) { |
|
380 | - $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
379 | + if (isset($rgba_cache[$feed_id])) { |
|
380 | + $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
381 | 381 | } |
382 | 382 | |
383 | - /* we don't need those */ |
|
383 | + /* we don't need those */ |
|
384 | 384 | |
385 | 385 | foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
386 | - "uuid", "label_cache", "yyiw"] as $k) |
|
386 | + "uuid", "label_cache", "yyiw"] as $k) |
|
387 | 387 | unset($line[$k]); |
388 | 388 | |
389 | - array_push($reply['content'], $line); |
|
390 | - } |
|
391 | - } |
|
392 | - |
|
393 | - if (!$headlines_count) { |
|
394 | - |
|
395 | - if (is_object($result)) { |
|
396 | - |
|
397 | - if ($query_error_override) { |
|
398 | - $message = $query_error_override; |
|
399 | - } else { |
|
400 | - switch ($view_mode) { |
|
401 | - case "unread": |
|
402 | - $message = __("No unread articles found to display."); |
|
403 | - break; |
|
404 | - case "updated": |
|
405 | - $message = __("No updated articles found to display."); |
|
406 | - break; |
|
407 | - case "marked": |
|
408 | - $message = __("No starred articles found to display."); |
|
409 | - break; |
|
410 | - default: |
|
411 | - if ($feed < LABEL_BASE_INDEX) { |
|
412 | - $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter."); |
|
413 | - } else { |
|
414 | - $message = __("No articles found to display."); |
|
415 | - } |
|
416 | - } |
|
417 | - } |
|
418 | - |
|
419 | - if (!$offset && $message) { |
|
420 | - $reply['content'] = "<div class='whiteBox'>$message"; |
|
421 | - |
|
422 | - $reply['content'] .= "<p><span class=\"text-muted\">"; |
|
423 | - |
|
424 | - $sth = $this->pdo->prepare("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
389 | + array_push($reply['content'], $line); |
|
390 | + } |
|
391 | + } |
|
392 | + |
|
393 | + if (!$headlines_count) { |
|
394 | + |
|
395 | + if (is_object($result)) { |
|
396 | + |
|
397 | + if ($query_error_override) { |
|
398 | + $message = $query_error_override; |
|
399 | + } else { |
|
400 | + switch ($view_mode) { |
|
401 | + case "unread": |
|
402 | + $message = __("No unread articles found to display."); |
|
403 | + break; |
|
404 | + case "updated": |
|
405 | + $message = __("No updated articles found to display."); |
|
406 | + break; |
|
407 | + case "marked": |
|
408 | + $message = __("No starred articles found to display."); |
|
409 | + break; |
|
410 | + default: |
|
411 | + if ($feed < LABEL_BASE_INDEX) { |
|
412 | + $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter."); |
|
413 | + } else { |
|
414 | + $message = __("No articles found to display."); |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | + |
|
419 | + if (!$offset && $message) { |
|
420 | + $reply['content'] = "<div class='whiteBox'>$message"; |
|
421 | + |
|
422 | + $reply['content'] .= "<p><span class=\"text-muted\">"; |
|
423 | + |
|
424 | + $sth = $this->pdo->prepare("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
425 | 425 | WHERE owner_uid = ?"); |
426 | - $sth->execute([$_SESSION['uid']]); |
|
427 | - $row = $sth->fetch(); |
|
426 | + $sth->execute([$_SESSION['uid']]); |
|
427 | + $row = $sth->fetch(); |
|
428 | 428 | |
429 | - $last_updated = make_local_datetime($row["last_updated"], false); |
|
429 | + $last_updated = make_local_datetime($row["last_updated"], false); |
|
430 | 430 | |
431 | - $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); |
|
431 | + $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); |
|
432 | 432 | |
433 | - $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors |
|
433 | + $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors |
|
434 | 434 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?"); |
435 | - $sth->execute([$_SESSION['uid']]); |
|
436 | - $row = $sth->fetch(); |
|
435 | + $sth->execute([$_SESSION['uid']]); |
|
436 | + $row = $sth->fetch(); |
|
437 | 437 | |
438 | - $num_errors = $row["num_errors"]; |
|
438 | + $num_errors = $row["num_errors"]; |
|
439 | 439 | |
440 | - if ($num_errors > 0) { |
|
441 | - $reply['content'] .= "<br/>"; |
|
442 | - $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">" . |
|
443 | - __('Some feeds have update errors (click for details)') . "</a>"; |
|
444 | - } |
|
445 | - $reply['content'] .= "</span></p></div>"; |
|
440 | + if ($num_errors > 0) { |
|
441 | + $reply['content'] .= "<br/>"; |
|
442 | + $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">" . |
|
443 | + __('Some feeds have update errors (click for details)') . "</a>"; |
|
444 | + } |
|
445 | + $reply['content'] .= "</span></p></div>"; |
|
446 | 446 | |
447 | - } |
|
448 | - } else if (is_numeric($result) && $result == -1) { |
|
449 | - $reply['first_id_changed'] = true; |
|
450 | - } |
|
451 | - } |
|
447 | + } |
|
448 | + } else if (is_numeric($result) && $result == -1) { |
|
449 | + $reply['first_id_changed'] = true; |
|
450 | + } |
|
451 | + } |
|
452 | 452 | |
453 | - return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $reply); |
|
454 | - } |
|
453 | + return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $reply); |
|
454 | + } |
|
455 | 455 | |
456 | - public function catchupAll() { |
|
457 | - $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
456 | + public function catchupAll() { |
|
457 | + $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET |
|
458 | 458 | last_read = NOW(), unread = false WHERE unread = true AND owner_uid = ?"); |
459 | - $sth->execute([$_SESSION['uid']]); |
|
459 | + $sth->execute([$_SESSION['uid']]); |
|
460 | 460 | |
461 | - CCache::zero_all($_SESSION["uid"]); |
|
462 | - } |
|
461 | + CCache::zero_all($_SESSION["uid"]); |
|
462 | + } |
|
463 | 463 | |
464 | - public function view() { |
|
465 | - $reply = array(); |
|
464 | + public function view() { |
|
465 | + $reply = array(); |
|
466 | 466 | |
467 | - $feed = $_REQUEST["feed"]; |
|
468 | - $method = $_REQUEST["m"]; |
|
469 | - $view_mode = $_REQUEST["view_mode"]; |
|
470 | - $limit = 30; |
|
471 | - @$cat_view = $_REQUEST["cat"] == "true"; |
|
472 | - @$next_unread_feed = $_REQUEST["nuf"]; |
|
473 | - @$offset = $_REQUEST["skip"]; |
|
474 | - $order_by = $_REQUEST["order_by"]; |
|
475 | - $check_first_id = $_REQUEST["fid"]; |
|
467 | + $feed = $_REQUEST["feed"]; |
|
468 | + $method = $_REQUEST["m"]; |
|
469 | + $view_mode = $_REQUEST["view_mode"]; |
|
470 | + $limit = 30; |
|
471 | + @$cat_view = $_REQUEST["cat"] == "true"; |
|
472 | + @$next_unread_feed = $_REQUEST["nuf"]; |
|
473 | + @$offset = $_REQUEST["skip"]; |
|
474 | + $order_by = $_REQUEST["order_by"]; |
|
475 | + $check_first_id = $_REQUEST["fid"]; |
|
476 | 476 | |
477 | - if (is_numeric($feed)) $feed = (int) $feed; |
|
477 | + if (is_numeric($feed)) $feed = (int) $feed; |
|
478 | 478 | |
479 | - /* Feed -5 is a special case: it is used to display auxiliary information |
|
479 | + /* Feed -5 is a special case: it is used to display auxiliary information |
|
480 | 480 | * when there's nothing to load - e.g. no stuff in fresh feed */ |
481 | 481 | |
482 | - if ($feed == -5) { |
|
483 | - print json_encode($this->generate_dashboard_feed()); |
|
484 | - return; |
|
485 | - } |
|
482 | + if ($feed == -5) { |
|
483 | + print json_encode($this->generate_dashboard_feed()); |
|
484 | + return; |
|
485 | + } |
|
486 | 486 | |
487 | - $sth = false; |
|
488 | - if ($feed < LABEL_BASE_INDEX) { |
|
487 | + $sth = false; |
|
488 | + if ($feed < LABEL_BASE_INDEX) { |
|
489 | 489 | |
490 | - $label_feed = Labels::feed_to_label_id($feed); |
|
490 | + $label_feed = Labels::feed_to_label_id($feed); |
|
491 | 491 | |
492 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_labels2 WHERE |
|
492 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_labels2 WHERE |
|
493 | 493 | id = ? AND owner_uid = ?"); |
494 | - $sth->execute([$label_feed, $_SESSION['uid']]); |
|
494 | + $sth->execute([$label_feed, $_SESSION['uid']]); |
|
495 | 495 | |
496 | - } else if (!$cat_view && is_numeric($feed) && $feed > 0) { |
|
496 | + } else if (!$cat_view && is_numeric($feed) && $feed > 0) { |
|
497 | 497 | |
498 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
498 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE |
|
499 | 499 | id = ? AND owner_uid = ?"); |
500 | - $sth->execute([$feed, $_SESSION['uid']]); |
|
500 | + $sth->execute([$feed, $_SESSION['uid']]); |
|
501 | 501 | |
502 | - } else if ($cat_view && is_numeric($feed) && $feed > 0) { |
|
502 | + } else if ($cat_view && is_numeric($feed) && $feed > 0) { |
|
503 | 503 | |
504 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories WHERE |
|
504 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories WHERE |
|
505 | 505 | id = ? AND owner_uid = ?"); |
506 | 506 | |
507 | - $sth->execute([$feed, $_SESSION['uid']]); |
|
508 | - } |
|
507 | + $sth->execute([$feed, $_SESSION['uid']]); |
|
508 | + } |
|
509 | 509 | |
510 | - if ($sth && !$sth->fetch()) { |
|
511 | - print json_encode($this->generate_error_feed(__("Feed not found."))); |
|
512 | - return; |
|
513 | - } |
|
510 | + if ($sth && !$sth->fetch()) { |
|
511 | + print json_encode($this->generate_error_feed(__("Feed not found."))); |
|
512 | + return; |
|
513 | + } |
|
514 | 514 | |
515 | - /* Updating a label ccache means recalculating all of the caches |
|
515 | + /* Updating a label ccache means recalculating all of the caches |
|
516 | 516 | * so for performance reasons we don't do that here */ |
517 | 517 | |
518 | - if ($feed >= 0) { |
|
519 | - CCache::update($feed, $_SESSION["uid"], $cat_view); |
|
520 | - } |
|
518 | + if ($feed >= 0) { |
|
519 | + CCache::update($feed, $_SESSION["uid"], $cat_view); |
|
520 | + } |
|
521 | 521 | |
522 | - set_pref("_DEFAULT_VIEW_MODE", $view_mode); |
|
523 | - set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by); |
|
522 | + set_pref("_DEFAULT_VIEW_MODE", $view_mode); |
|
523 | + set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by); |
|
524 | 524 | |
525 | - /* bump login timestamp if needed */ |
|
526 | - if (time() - $_SESSION["last_login_update"] > 3600) { |
|
527 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?"); |
|
528 | - $sth->execute([$_SESSION['uid']]); |
|
525 | + /* bump login timestamp if needed */ |
|
526 | + if (time() - $_SESSION["last_login_update"] > 3600) { |
|
527 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?"); |
|
528 | + $sth->execute([$_SESSION['uid']]); |
|
529 | 529 | |
530 | - $_SESSION["last_login_update"] = time(); |
|
531 | - } |
|
530 | + $_SESSION["last_login_update"] = time(); |
|
531 | + } |
|
532 | 532 | |
533 | - if (!$cat_view && is_numeric($feed) && $feed > 0) { |
|
534 | - $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET last_viewed = NOW() |
|
533 | + if (!$cat_view && is_numeric($feed) && $feed > 0) { |
|
534 | + $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET last_viewed = NOW() |
|
535 | 535 | WHERE id = ? AND owner_uid = ?"); |
536 | - $sth->execute([$feed, $_SESSION['uid']]); |
|
537 | - } |
|
538 | - |
|
539 | - $reply['headlines'] = []; |
|
540 | - |
|
541 | - $override_order = false; |
|
542 | - $skip_first_id_check = false; |
|
536 | + $sth->execute([$feed, $_SESSION['uid']]); |
|
537 | + } |
|
543 | 538 | |
544 | - switch ($order_by) { |
|
545 | - case "title": |
|
546 | - $override_order = "ttrss_entries.title, date_entered, updated"; |
|
547 | - break; |
|
548 | - case "date_reverse": |
|
549 | - $override_order = "score DESC, date_entered, updated"; |
|
550 | - $skip_first_id_check = true; |
|
551 | - break; |
|
552 | - case "feed_dates": |
|
553 | - $override_order = "updated DESC"; |
|
554 | - break; |
|
555 | - } |
|
539 | + $reply['headlines'] = []; |
|
540 | + |
|
541 | + $override_order = false; |
|
542 | + $skip_first_id_check = false; |
|
543 | + |
|
544 | + switch ($order_by) { |
|
545 | + case "title": |
|
546 | + $override_order = "ttrss_entries.title, date_entered, updated"; |
|
547 | + break; |
|
548 | + case "date_reverse": |
|
549 | + $override_order = "score DESC, date_entered, updated"; |
|
550 | + $skip_first_id_check = true; |
|
551 | + break; |
|
552 | + case "feed_dates": |
|
553 | + $override_order = "updated DESC"; |
|
554 | + break; |
|
555 | + } |
|
556 | 556 | |
557 | - $ret = $this->format_headlines_list($feed, $method, |
|
558 | - $view_mode, $limit, $cat_view, $offset, |
|
559 | - $override_order, true, $check_first_id, $skip_first_id_check, $order_by); |
|
557 | + $ret = $this->format_headlines_list($feed, $method, |
|
558 | + $view_mode, $limit, $cat_view, $offset, |
|
559 | + $override_order, true, $check_first_id, $skip_first_id_check, $order_by); |
|
560 | 560 | |
561 | - $headlines_count = $ret[1]; |
|
562 | - $disable_cache = $ret[3]; |
|
563 | - $reply['headlines'] = $ret[4]; |
|
561 | + $headlines_count = $ret[1]; |
|
562 | + $disable_cache = $ret[3]; |
|
563 | + $reply['headlines'] = $ret[4]; |
|
564 | 564 | |
565 | - if (!$next_unread_feed) |
|
566 | - $reply['headlines']['id'] = $feed; |
|
567 | - else |
|
568 | - $reply['headlines']['id'] = $next_unread_feed; |
|
565 | + if (!$next_unread_feed) |
|
566 | + $reply['headlines']['id'] = $feed; |
|
567 | + else |
|
568 | + $reply['headlines']['id'] = $next_unread_feed; |
|
569 | 569 | |
570 | - $reply['headlines']['is_cat'] = (bool) $cat_view; |
|
570 | + $reply['headlines']['is_cat'] = (bool) $cat_view; |
|
571 | 571 | |
572 | - $reply['headlines-info'] = ["count" => (int) $headlines_count, |
|
573 | - "disable_cache" => (bool) $disable_cache]; |
|
572 | + $reply['headlines-info'] = ["count" => (int) $headlines_count, |
|
573 | + "disable_cache" => (bool) $disable_cache]; |
|
574 | 574 | |
575 | - // this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc |
|
576 | - $reply['runtime-info'] = make_runtime_info(); |
|
575 | + // this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc |
|
576 | + $reply['runtime-info'] = make_runtime_info(); |
|
577 | 577 | |
578 | - $reply_json = json_encode($reply); |
|
578 | + $reply_json = json_encode($reply); |
|
579 | 579 | |
580 | - if (!$reply_json) { |
|
581 | - $reply_json = json_encode(["error" => ["code" => 15, |
|
580 | + if (!$reply_json) { |
|
581 | + $reply_json = json_encode(["error" => ["code" => 15, |
|
582 | 582 | "message" => json_last_error_msg()]]); |
583 | 583 | } |
584 | 584 | |
585 | - print $reply_json; |
|
585 | + print $reply_json; |
|
586 | 586 | |
587 | - } |
|
587 | + } |
|
588 | 588 | |
589 | - private function generate_dashboard_feed() { |
|
590 | - $reply = array(); |
|
589 | + private function generate_dashboard_feed() { |
|
590 | + $reply = array(); |
|
591 | 591 | |
592 | - $reply['headlines']['id'] = -5; |
|
593 | - $reply['headlines']['is_cat'] = false; |
|
592 | + $reply['headlines']['id'] = -5; |
|
593 | + $reply['headlines']['is_cat'] = false; |
|
594 | 594 | |
595 | - $reply['headlines']['toolbar'] = ''; |
|
595 | + $reply['headlines']['toolbar'] = ''; |
|
596 | 596 | |
597 | - $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.'); |
|
597 | + $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.'); |
|
598 | 598 | |
599 | - $reply['headlines']['content'] .= "<p><span class=\"text-muted\">"; |
|
599 | + $reply['headlines']['content'] .= "<p><span class=\"text-muted\">"; |
|
600 | 600 | |
601 | - $sth = $this->pdo->prepare("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
601 | + $sth = $this->pdo->prepare("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
602 | 602 | WHERE owner_uid = ?"); |
603 | - $sth->execute([$_SESSION['uid']]); |
|
604 | - $row = $sth->fetch(); |
|
603 | + $sth->execute([$_SESSION['uid']]); |
|
604 | + $row = $sth->fetch(); |
|
605 | 605 | |
606 | - $last_updated = make_local_datetime($row["last_updated"], false); |
|
606 | + $last_updated = make_local_datetime($row["last_updated"], false); |
|
607 | 607 | |
608 | - $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); |
|
608 | + $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); |
|
609 | 609 | |
610 | - $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors |
|
610 | + $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors |
|
611 | 611 | FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?"); |
612 | - $sth->execute([$_SESSION['uid']]); |
|
613 | - $row = $sth->fetch(); |
|
612 | + $sth->execute([$_SESSION['uid']]); |
|
613 | + $row = $sth->fetch(); |
|
614 | 614 | |
615 | - $num_errors = $row["num_errors"]; |
|
615 | + $num_errors = $row["num_errors"]; |
|
616 | 616 | |
617 | - if ($num_errors > 0) { |
|
618 | - $reply['headlines']['content'] .= "<br/>"; |
|
619 | - $reply['headlines']['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">". |
|
620 | - __('Some feeds have update errors (click for details)')."</a>"; |
|
621 | - } |
|
622 | - $reply['headlines']['content'] .= "</span></p>"; |
|
617 | + if ($num_errors > 0) { |
|
618 | + $reply['headlines']['content'] .= "<br/>"; |
|
619 | + $reply['headlines']['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">". |
|
620 | + __('Some feeds have update errors (click for details)')."</a>"; |
|
621 | + } |
|
622 | + $reply['headlines']['content'] .= "</span></p>"; |
|
623 | 623 | |
624 | - $reply['headlines-info'] = array("count" => 0, |
|
625 | - "unread" => 0, |
|
626 | - "disable_cache" => true); |
|
624 | + $reply['headlines-info'] = array("count" => 0, |
|
625 | + "unread" => 0, |
|
626 | + "disable_cache" => true); |
|
627 | 627 | |
628 | - return $reply; |
|
629 | - } |
|
628 | + return $reply; |
|
629 | + } |
|
630 | 630 | |
631 | - private function generate_error_feed($error) { |
|
632 | - $reply = array(); |
|
631 | + private function generate_error_feed($error) { |
|
632 | + $reply = array(); |
|
633 | 633 | |
634 | - $reply['headlines']['id'] = -7; |
|
635 | - $reply['headlines']['is_cat'] = false; |
|
634 | + $reply['headlines']['id'] = -7; |
|
635 | + $reply['headlines']['is_cat'] = false; |
|
636 | 636 | |
637 | - $reply['headlines']['toolbar'] = ''; |
|
638 | - $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>"; |
|
637 | + $reply['headlines']['toolbar'] = ''; |
|
638 | + $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>"; |
|
639 | 639 | |
640 | - $reply['headlines-info'] = array("count" => 0, |
|
641 | - "unread" => 0, |
|
642 | - "disable_cache" => true); |
|
640 | + $reply['headlines-info'] = array("count" => 0, |
|
641 | + "unread" => 0, |
|
642 | + "disable_cache" => true); |
|
643 | 643 | |
644 | - return $reply; |
|
645 | - } |
|
644 | + return $reply; |
|
645 | + } |
|
646 | 646 | |
647 | - public function quickAddFeed() { |
|
648 | - print "<form onsubmit='return false'>"; |
|
647 | + public function quickAddFeed() { |
|
648 | + print "<form onsubmit='return false'>"; |
|
649 | 649 | |
650 | - print_hidden("op", "rpc"); |
|
651 | - print_hidden("method", "addfeed"); |
|
650 | + print_hidden("op", "rpc"); |
|
651 | + print_hidden("method", "addfeed"); |
|
652 | 652 | |
653 | - print "<div id='fadd_error_message' style='display : none' class='alert alert-danger'></div>"; |
|
653 | + print "<div id='fadd_error_message' style='display : none' class='alert alert-danger'></div>"; |
|
654 | 654 | |
655 | - print "<div id='fadd_multiple_notify' style='display : none'>"; |
|
656 | - print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below."); |
|
657 | - print "<p></div>"; |
|
655 | + print "<div id='fadd_multiple_notify' style='display : none'>"; |
|
656 | + print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below."); |
|
657 | + print "<p></div>"; |
|
658 | 658 | |
659 | - print "<section>"; |
|
659 | + print "<section>"; |
|
660 | 660 | |
661 | - print "<fieldset>"; |
|
662 | - print "<div style='float : right'><img style='display : none' id='feed_add_spinner' src='images/indicator_white.gif'></div>"; |
|
663 | - print "<input style='font-size : 16px; width : 500px;' |
|
661 | + print "<fieldset>"; |
|
662 | + print "<div style='float : right'><img style='display : none' id='feed_add_spinner' src='images/indicator_white.gif'></div>"; |
|
663 | + print "<input style='font-size : 16px; width : 500px;' |
|
664 | 664 | placeHolder=\"".__("Feed or site URL")."\" |
665 | 665 | dojoType='dijit.form.ValidationTextBox' required='1' name='feed' id='feedDlg_feedUrl'>"; |
666 | 666 | |
667 | - print "</fieldset>"; |
|
667 | + print "</fieldset>"; |
|
668 | 668 | |
669 | - print "<fieldset>"; |
|
669 | + print "<fieldset>"; |
|
670 | 670 | |
671 | - if (get_pref('ENABLE_FEED_CATS')) { |
|
672 | - print "<label class='inline'>" . __('Place in category:') . "</label> "; |
|
673 | - print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"'); |
|
674 | - } |
|
671 | + if (get_pref('ENABLE_FEED_CATS')) { |
|
672 | + print "<label class='inline'>" . __('Place in category:') . "</label> "; |
|
673 | + print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"'); |
|
674 | + } |
|
675 | 675 | |
676 | - print "</fieldset>"; |
|
676 | + print "</fieldset>"; |
|
677 | 677 | |
678 | - print "</section>"; |
|
678 | + print "</section>"; |
|
679 | 679 | |
680 | - print '<div id="feedDlg_feedsContainer" style="display : none"> |
|
680 | + print '<div id="feedDlg_feedsContainer" style="display : none"> |
|
681 | 681 | <header>' . __('Available feeds') . '</header> |
682 | 682 | <section> |
683 | 683 | <fieldset> |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | </section> |
692 | 692 | </div>'; |
693 | 693 | |
694 | - print "<div id='feedDlg_loginContainer' style='display : none'> |
|
694 | + print "<div id='feedDlg_loginContainer' style='display : none'> |
|
695 | 695 | <section> |
696 | 696 | <fieldset> |
697 | 697 | <input dojoType=\"dijit.form.TextBox\" name='login'\" |
@@ -707,98 +707,98 @@ discard block |
||
707 | 707 | </section> |
708 | 708 | </div>"; |
709 | 709 | |
710 | - print "<section>"; |
|
711 | - print "<label> |
|
710 | + print "<section>"; |
|
711 | + print "<label> |
|
712 | 712 | <label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox' id='feedDlg_loginCheck' |
713 | 713 | onclick='displayIfChecked(this, \"feedDlg_loginContainer\")'> |
714 | 714 | ".__('This feed requires authentication.')."</label>"; |
715 | - print "</section>"; |
|
715 | + print "</section>"; |
|
716 | 716 | |
717 | - print "<footer>"; |
|
718 | - print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' |
|
717 | + print "<footer>"; |
|
718 | + print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' |
|
719 | 719 | onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>"; |
720 | 720 | |
721 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>"; |
|
722 | - print "</footer>"; |
|
721 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>"; |
|
722 | + print "</footer>"; |
|
723 | 723 | |
724 | - print "</form>"; |
|
725 | - } |
|
724 | + print "</form>"; |
|
725 | + } |
|
726 | 726 | |
727 | - public function search() { |
|
728 | - $this->params = explode(":", $_REQUEST["param"], 2); |
|
727 | + public function search() { |
|
728 | + $this->params = explode(":", $_REQUEST["param"], 2); |
|
729 | 729 | |
730 | - $active_feed_id = sprintf("%d", $this->params[0]); |
|
731 | - $is_cat = $this->params[1] != "false"; |
|
730 | + $active_feed_id = sprintf("%d", $this->params[0]); |
|
731 | + $is_cat = $this->params[1] != "false"; |
|
732 | 732 | |
733 | - print "<form onsubmit='return false;'>"; |
|
733 | + print "<form onsubmit='return false;'>"; |
|
734 | 734 | |
735 | - print "<section>"; |
|
735 | + print "<section>"; |
|
736 | 736 | |
737 | - print "<fieldset>"; |
|
738 | - print "<input dojoType='dijit.form.ValidationTextBox' id='search_query' |
|
737 | + print "<fieldset>"; |
|
738 | + print "<input dojoType='dijit.form.ValidationTextBox' id='search_query' |
|
739 | 739 | style='font-size : 16px; width : 540px;' |
740 | 740 | placeHolder=\"".T_sprintf("Search %s...", $this->getFeedTitle($active_feed_id, $is_cat))."\" |
741 | 741 | name='query' type='search' value=''>"; |
742 | - print "</fieldset>"; |
|
743 | - |
|
744 | - if (DB_TYPE == "pgsql") { |
|
745 | - print "<fieldset>"; |
|
746 | - print "<label class='inline'>" . __("Language:") . "</label>"; |
|
747 | - print_select("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), |
|
748 | - "dojoType='fox.form.Select' title=\"".__('Used for word stemming')."\""); |
|
749 | - print "</fieldset>"; |
|
750 | - } |
|
742 | + print "</fieldset>"; |
|
743 | + |
|
744 | + if (DB_TYPE == "pgsql") { |
|
745 | + print "<fieldset>"; |
|
746 | + print "<label class='inline'>" . __("Language:") . "</label>"; |
|
747 | + print_select("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), |
|
748 | + "dojoType='fox.form.Select' title=\"".__('Used for word stemming')."\""); |
|
749 | + print "</fieldset>"; |
|
750 | + } |
|
751 | 751 | |
752 | - print "</section>"; |
|
752 | + print "</section>"; |
|
753 | 753 | |
754 | - print "<footer>"; |
|
754 | + print "<footer>"; |
|
755 | 755 | |
756 | - if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) { |
|
757 | - print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/SearchSyntax\")'> |
|
756 | + if (count(PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH)) == 0) { |
|
757 | + print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/SearchSyntax\")'> |
|
758 | 758 | <i class='material-icons'>help</i> ".__("Search syntax")."</button>"; |
759 | - } |
|
759 | + } |
|
760 | 760 | |
761 | - print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button> |
|
761 | + print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"dijit.byId('searchDlg').execute()\">".__('Search')."</button> |
|
762 | 762 | <button dojoType='dijit.form.Button' onclick=\"dijit.byId('searchDlg').hide()\">".__('Cancel')."</button>"; |
763 | 763 | |
764 | - print "</footer>"; |
|
764 | + print "</footer>"; |
|
765 | 765 | |
766 | - print "</form>"; |
|
767 | - } |
|
766 | + print "</form>"; |
|
767 | + } |
|
768 | 768 | |
769 | - public function update_debugger() { |
|
770 | - header("Content-type: text/html"); |
|
769 | + public function update_debugger() { |
|
770 | + header("Content-type: text/html"); |
|
771 | 771 | |
772 | - Debug::set_enabled(true); |
|
773 | - Debug::set_loglevel($_REQUEST["xdebug"]); |
|
772 | + Debug::set_enabled(true); |
|
773 | + Debug::set_loglevel($_REQUEST["xdebug"]); |
|
774 | 774 | |
775 | - $feed_id = (int)$_REQUEST["feed_id"]; |
|
776 | - @$do_update = $_REQUEST["action"] == "do_update"; |
|
777 | - $csrf_token = $_REQUEST["csrf_token"]; |
|
775 | + $feed_id = (int)$_REQUEST["feed_id"]; |
|
776 | + @$do_update = $_REQUEST["action"] == "do_update"; |
|
777 | + $csrf_token = $_REQUEST["csrf_token"]; |
|
778 | 778 | |
779 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
|
780 | - $sth->execute([$feed_id, $_SESSION['uid']]); |
|
779 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
|
780 | + $sth->execute([$feed_id, $_SESSION['uid']]); |
|
781 | 781 | |
782 | - if (!$sth->fetch()) { |
|
783 | - print "Access denied."; |
|
784 | - return; |
|
782 | + if (!$sth->fetch()) { |
|
783 | + print "Access denied."; |
|
784 | + return; |
|
785 | 785 | } |
786 | 786 | |
787 | - $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : ""; |
|
788 | - $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : ""; |
|
787 | + $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : ""; |
|
788 | + $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : ""; |
|
789 | 789 | |
790 | - ?> |
|
790 | + ?> |
|
791 | 791 | <!DOCTYPE html> |
792 | 792 | <html> |
793 | 793 | <head> |
794 | 794 | <?php echo stylesheet_tag("css/default.css") ?> |
795 | 795 | <title>Feed Debugger</title> |
796 | 796 | <?php |
797 | - echo stylesheet_tag("css/default.css"); |
|
798 | - echo javascript_tag("lib/prototype.js"); |
|
799 | - echo javascript_tag("lib/dojo/dojo.js"); |
|
800 | - echo javascript_tag("lib/dojo/tt-rss-layer.js"); |
|
801 | - ?> |
|
797 | + echo stylesheet_tag("css/default.css"); |
|
798 | + echo javascript_tag("lib/prototype.js"); |
|
799 | + echo javascript_tag("lib/dojo/dojo.js"); |
|
800 | + echo javascript_tag("lib/dojo/tt-rss-layer.js"); |
|
801 | + ?> |
|
802 | 802 | </head> |
803 | 803 | <body class="flat ttrss_utility feed_debugger"> |
804 | 804 | <script type="text/javascript"> |
@@ -836,904 +836,904 @@ discard block |
||
836 | 836 | |
837 | 837 | <pre><?php |
838 | 838 | |
839 | - if ($do_update) { |
|
840 | - RSSUtils::update_rss_feed($feed_id, true); |
|
841 | - } |
|
839 | + if ($do_update) { |
|
840 | + RSSUtils::update_rss_feed($feed_id, true); |
|
841 | + } |
|
842 | 842 | |
843 | - ?></pre> |
|
843 | + ?></pre> |
|
844 | 844 | </div> |
845 | 845 | </div> |
846 | 846 | </body> |
847 | 847 | </html> |
848 | 848 | <?php |
849 | 849 | |
850 | - } |
|
851 | - |
|
852 | - public static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) { |
|
853 | - |
|
854 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
855 | - |
|
856 | - $pdo = Db::pdo(); |
|
857 | - |
|
858 | - if (is_array($search) && $search[0]) { |
|
859 | - $search_qpart = ""; |
|
860 | - |
|
861 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) { |
|
862 | - list($search_qpart, $search_words) = $plugin->hook_search($search[0]); |
|
863 | - break; |
|
864 | - } |
|
865 | - |
|
866 | - // fall back in case of no plugins |
|
867 | - if (!$search_qpart) { |
|
868 | - list($search_qpart, $search_words) = Feeds::search_to_sql($search[0], $search[1]); |
|
869 | - } |
|
870 | - } else { |
|
871 | - $search_qpart = "true"; |
|
872 | - } |
|
873 | - |
|
874 | - // TODO: all this interval stuff needs some generic generator function |
|
875 | - |
|
876 | - switch ($mode) { |
|
877 | - case "1day": |
|
878 | - if (DB_TYPE == "pgsql") { |
|
879 | - $date_qpart = "date_entered < NOW() - INTERVAL '1 day' "; |
|
880 | - } else { |
|
881 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
882 | - } |
|
883 | - break; |
|
884 | - case "1week": |
|
885 | - if (DB_TYPE == "pgsql") { |
|
886 | - $date_qpart = "date_entered < NOW() - INTERVAL '1 week' "; |
|
887 | - } else { |
|
888 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) "; |
|
889 | - } |
|
890 | - break; |
|
891 | - case "2week": |
|
892 | - if (DB_TYPE == "pgsql") { |
|
893 | - $date_qpart = "date_entered < NOW() - INTERVAL '2 week' "; |
|
894 | - } else { |
|
895 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) "; |
|
896 | - } |
|
897 | - break; |
|
898 | - default: |
|
899 | - $date_qpart = "true"; |
|
900 | - } |
|
901 | - |
|
902 | - if (is_numeric($feed)) { |
|
903 | - if ($cat_view) { |
|
904 | - |
|
905 | - if ($feed >= 0) { |
|
906 | - |
|
907 | - if ($feed > 0) { |
|
908 | - $children = Feeds::getChildCategories($feed, $owner_uid); |
|
909 | - array_push($children, $feed); |
|
910 | - $children = array_map("intval", $children); |
|
911 | - |
|
912 | - $children = join(",", $children); |
|
913 | - |
|
914 | - $cat_qpart = "cat_id IN ($children)"; |
|
915 | - } else { |
|
916 | - $cat_qpart = "cat_id IS NULL"; |
|
917 | - } |
|
918 | - |
|
919 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
850 | + } |
|
851 | + |
|
852 | + public static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) { |
|
853 | + |
|
854 | + if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
855 | + |
|
856 | + $pdo = Db::pdo(); |
|
857 | + |
|
858 | + if (is_array($search) && $search[0]) { |
|
859 | + $search_qpart = ""; |
|
860 | + |
|
861 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) { |
|
862 | + list($search_qpart, $search_words) = $plugin->hook_search($search[0]); |
|
863 | + break; |
|
864 | + } |
|
865 | + |
|
866 | + // fall back in case of no plugins |
|
867 | + if (!$search_qpart) { |
|
868 | + list($search_qpart, $search_words) = Feeds::search_to_sql($search[0], $search[1]); |
|
869 | + } |
|
870 | + } else { |
|
871 | + $search_qpart = "true"; |
|
872 | + } |
|
873 | + |
|
874 | + // TODO: all this interval stuff needs some generic generator function |
|
875 | + |
|
876 | + switch ($mode) { |
|
877 | + case "1day": |
|
878 | + if (DB_TYPE == "pgsql") { |
|
879 | + $date_qpart = "date_entered < NOW() - INTERVAL '1 day' "; |
|
880 | + } else { |
|
881 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
882 | + } |
|
883 | + break; |
|
884 | + case "1week": |
|
885 | + if (DB_TYPE == "pgsql") { |
|
886 | + $date_qpart = "date_entered < NOW() - INTERVAL '1 week' "; |
|
887 | + } else { |
|
888 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) "; |
|
889 | + } |
|
890 | + break; |
|
891 | + case "2week": |
|
892 | + if (DB_TYPE == "pgsql") { |
|
893 | + $date_qpart = "date_entered < NOW() - INTERVAL '2 week' "; |
|
894 | + } else { |
|
895 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) "; |
|
896 | + } |
|
897 | + break; |
|
898 | + default: |
|
899 | + $date_qpart = "true"; |
|
900 | + } |
|
901 | + |
|
902 | + if (is_numeric($feed)) { |
|
903 | + if ($cat_view) { |
|
904 | + |
|
905 | + if ($feed >= 0) { |
|
906 | + |
|
907 | + if ($feed > 0) { |
|
908 | + $children = Feeds::getChildCategories($feed, $owner_uid); |
|
909 | + array_push($children, $feed); |
|
910 | + $children = array_map("intval", $children); |
|
911 | + |
|
912 | + $children = join(",", $children); |
|
913 | + |
|
914 | + $cat_qpart = "cat_id IN ($children)"; |
|
915 | + } else { |
|
916 | + $cat_qpart = "cat_id IS NULL"; |
|
917 | + } |
|
918 | + |
|
919 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
920 | 920 | SET unread = false, last_read = NOW() WHERE ref_id IN |
921 | 921 | (SELECT id FROM |
922 | 922 | (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id |
923 | 923 | AND owner_uid = ? AND unread = true AND feed_id IN |
924 | 924 | (SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart AND $search_qpart) as tmp)"); |
925 | - $sth->execute([$owner_uid]); |
|
925 | + $sth->execute([$owner_uid]); |
|
926 | 926 | |
927 | - } else if ($feed == -2) { |
|
927 | + } else if ($feed == -2) { |
|
928 | 928 | |
929 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
929 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
930 | 930 | SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*) |
931 | 931 | FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart AND $search_qpart) > 0 |
932 | 932 | AND unread = true AND owner_uid = ?"); |
933 | - $sth->execute([$owner_uid]); |
|
934 | - } |
|
933 | + $sth->execute([$owner_uid]); |
|
934 | + } |
|
935 | 935 | |
936 | - } else if ($feed > 0) { |
|
936 | + } else if ($feed > 0) { |
|
937 | 937 | |
938 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
938 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
939 | 939 | SET unread = false, last_read = NOW() WHERE ref_id IN |
940 | 940 | (SELECT id FROM |
941 | 941 | (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id |
942 | 942 | AND owner_uid = ? AND unread = true AND feed_id = ? AND $date_qpart AND $search_qpart) as tmp)"); |
943 | - $sth->execute([$owner_uid, $feed]); |
|
943 | + $sth->execute([$owner_uid, $feed]); |
|
944 | 944 | |
945 | - } else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred |
|
945 | + } else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred |
|
946 | 946 | |
947 | - if ($feed == -1) { |
|
948 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
947 | + if ($feed == -1) { |
|
948 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
949 | 949 | SET unread = false, last_read = NOW() WHERE ref_id IN |
950 | 950 | (SELECT id FROM |
951 | 951 | (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id |
952 | 952 | AND owner_uid = ? AND unread = true AND marked = true AND $date_qpart AND $search_qpart) as tmp)"); |
953 | - $sth->execute([$owner_uid]); |
|
954 | - } |
|
953 | + $sth->execute([$owner_uid]); |
|
954 | + } |
|
955 | 955 | |
956 | - if ($feed == -2) { |
|
957 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
956 | + if ($feed == -2) { |
|
957 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
958 | 958 | SET unread = false, last_read = NOW() WHERE ref_id IN |
959 | 959 | (SELECT id FROM |
960 | 960 | (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id |
961 | 961 | AND owner_uid = ? AND unread = true AND published = true AND $date_qpart AND $search_qpart) as tmp)"); |
962 | - $sth->execute([$owner_uid]); |
|
963 | - } |
|
962 | + $sth->execute([$owner_uid]); |
|
963 | + } |
|
964 | 964 | |
965 | - if ($feed == -3) { |
|
965 | + if ($feed == -3) { |
|
966 | 966 | |
967 | - $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE"); |
|
967 | + $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE"); |
|
968 | 968 | |
969 | - if (DB_TYPE == "pgsql") { |
|
970 | - $match_part = "date_entered > NOW() - INTERVAL '$intl hour' "; |
|
971 | - } else { |
|
972 | - $match_part = "date_entered > DATE_SUB(NOW(), |
|
969 | + if (DB_TYPE == "pgsql") { |
|
970 | + $match_part = "date_entered > NOW() - INTERVAL '$intl hour' "; |
|
971 | + } else { |
|
972 | + $match_part = "date_entered > DATE_SUB(NOW(), |
|
973 | 973 | INTERVAL $intl HOUR) "; |
974 | - } |
|
974 | + } |
|
975 | 975 | |
976 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
976 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
977 | 977 | SET unread = false, last_read = NOW() WHERE ref_id IN |
978 | 978 | (SELECT id FROM |
979 | 979 | (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id |
980 | 980 | AND owner_uid = ? AND score >= 0 AND unread = true AND $date_qpart AND $match_part AND $search_qpart) as tmp)"); |
981 | - $sth->execute([$owner_uid]); |
|
982 | - } |
|
981 | + $sth->execute([$owner_uid]); |
|
982 | + } |
|
983 | 983 | |
984 | - if ($feed == -4) { |
|
985 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
984 | + if ($feed == -4) { |
|
985 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
986 | 986 | SET unread = false, last_read = NOW() WHERE ref_id IN |
987 | 987 | (SELECT id FROM |
988 | 988 | (SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id |
989 | 989 | AND owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)"); |
990 | - $sth->execute([$owner_uid]); |
|
991 | - } |
|
990 | + $sth->execute([$owner_uid]); |
|
991 | + } |
|
992 | 992 | |
993 | - } else if ($feed < LABEL_BASE_INDEX) { // label |
|
993 | + } else if ($feed < LABEL_BASE_INDEX) { // label |
|
994 | 994 | |
995 | - $label_id = Labels::feed_to_label_id($feed); |
|
995 | + $label_id = Labels::feed_to_label_id($feed); |
|
996 | 996 | |
997 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
997 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
998 | 998 | SET unread = false, last_read = NOW() WHERE ref_id IN |
999 | 999 | (SELECT id FROM |
1000 | 1000 | (SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id |
1001 | 1001 | AND label_id = ? AND ref_id = article_id |
1002 | 1002 | AND owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)"); |
1003 | - $sth->execute([$label_id, $owner_uid]); |
|
1003 | + $sth->execute([$label_id, $owner_uid]); |
|
1004 | 1004 | |
1005 | - } |
|
1005 | + } |
|
1006 | 1006 | |
1007 | - CCache::update($feed, $owner_uid, $cat_view); |
|
1007 | + CCache::update($feed, $owner_uid, $cat_view); |
|
1008 | 1008 | |
1009 | - } else { // tag |
|
1010 | - $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
1009 | + } else { // tag |
|
1010 | + $sth = $pdo->prepare("UPDATE ttrss_user_entries |
|
1011 | 1011 | SET unread = false, last_read = NOW() WHERE ref_id IN |
1012 | 1012 | (SELECT id FROM |
1013 | 1013 | (SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id |
1014 | 1014 | AND post_int_id = int_id AND tag_name = ? |
1015 | 1015 | AND ttrss_user_entries.owner_uid = ? AND unread = true AND $date_qpart AND $search_qpart) as tmp)"); |
1016 | - $sth->execute([$feed, $owner_uid]); |
|
1016 | + $sth->execute([$feed, $owner_uid]); |
|
1017 | 1017 | |
1018 | - } |
|
1019 | - } |
|
1018 | + } |
|
1019 | + } |
|
1020 | 1020 | |
1021 | - public static function getFeedArticles($feed, $is_cat = false, $unread_only = false, |
|
1022 | - $owner_uid = false) { |
|
1021 | + public static function getFeedArticles($feed, $is_cat = false, $unread_only = false, |
|
1022 | + $owner_uid = false) { |
|
1023 | 1023 | |
1024 | - $n_feed = (int) $feed; |
|
1025 | - $need_entries = false; |
|
1024 | + $n_feed = (int) $feed; |
|
1025 | + $need_entries = false; |
|
1026 | 1026 | |
1027 | - $pdo = Db::pdo(); |
|
1027 | + $pdo = Db::pdo(); |
|
1028 | 1028 | |
1029 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1029 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1030 | 1030 | |
1031 | - if ($unread_only) { |
|
1032 | - $unread_qpart = "unread = true"; |
|
1033 | - } else { |
|
1034 | - $unread_qpart = "true"; |
|
1035 | - } |
|
1031 | + if ($unread_only) { |
|
1032 | + $unread_qpart = "unread = true"; |
|
1033 | + } else { |
|
1034 | + $unread_qpart = "true"; |
|
1035 | + } |
|
1036 | 1036 | |
1037 | - $match_part = ""; |
|
1037 | + $match_part = ""; |
|
1038 | 1038 | |
1039 | - if ($is_cat) { |
|
1040 | - return Feeds::getCategoryUnread($n_feed, $owner_uid); |
|
1041 | - } else if ($n_feed == -6) { |
|
1042 | - return 0; |
|
1043 | - } else if ($feed != "0" && $n_feed == 0) { |
|
1039 | + if ($is_cat) { |
|
1040 | + return Feeds::getCategoryUnread($n_feed, $owner_uid); |
|
1041 | + } else if ($n_feed == -6) { |
|
1042 | + return 0; |
|
1043 | + } else if ($feed != "0" && $n_feed == 0) { |
|
1044 | 1044 | |
1045 | - $sth = $pdo->prepare("SELECT SUM((SELECT COUNT(int_id) |
|
1045 | + $sth = $pdo->prepare("SELECT SUM((SELECT COUNT(int_id) |
|
1046 | 1046 | FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id |
1047 | 1047 | AND ref_id = id AND $unread_qpart)) AS count FROM ttrss_tags |
1048 | 1048 | WHERE owner_uid = ? AND tag_name = ?"); |
1049 | 1049 | |
1050 | - $sth->execute([$owner_uid, $feed]); |
|
1051 | - $row = $sth->fetch(); |
|
1050 | + $sth->execute([$owner_uid, $feed]); |
|
1051 | + $row = $sth->fetch(); |
|
1052 | 1052 | |
1053 | - return $row["count"]; |
|
1053 | + return $row["count"]; |
|
1054 | 1054 | |
1055 | - } else if ($n_feed == -1) { |
|
1056 | - $match_part = "marked = true"; |
|
1057 | - } else if ($n_feed == -2) { |
|
1058 | - $match_part = "published = true"; |
|
1059 | - } else if ($n_feed == -3) { |
|
1060 | - $match_part = "unread = true AND score >= 0"; |
|
1055 | + } else if ($n_feed == -1) { |
|
1056 | + $match_part = "marked = true"; |
|
1057 | + } else if ($n_feed == -2) { |
|
1058 | + $match_part = "published = true"; |
|
1059 | + } else if ($n_feed == -3) { |
|
1060 | + $match_part = "unread = true AND score >= 0"; |
|
1061 | 1061 | |
1062 | - $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid); |
|
1062 | + $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid); |
|
1063 | 1063 | |
1064 | - if (DB_TYPE == "pgsql") { |
|
1065 | - $match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' "; |
|
1066 | - } else { |
|
1067 | - $match_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; |
|
1068 | - } |
|
1064 | + if (DB_TYPE == "pgsql") { |
|
1065 | + $match_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' "; |
|
1066 | + } else { |
|
1067 | + $match_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; |
|
1068 | + } |
|
1069 | 1069 | |
1070 | - $need_entries = true; |
|
1070 | + $need_entries = true; |
|
1071 | 1071 | |
1072 | - } else if ($n_feed == -4) { |
|
1073 | - $match_part = "true"; |
|
1074 | - } else if ($n_feed >= 0) { |
|
1072 | + } else if ($n_feed == -4) { |
|
1073 | + $match_part = "true"; |
|
1074 | + } else if ($n_feed >= 0) { |
|
1075 | 1075 | |
1076 | - if ($n_feed != 0) { |
|
1077 | - $match_part = "feed_id = " . (int)$n_feed; |
|
1078 | - } else { |
|
1079 | - $match_part = "feed_id IS NULL"; |
|
1080 | - } |
|
1076 | + if ($n_feed != 0) { |
|
1077 | + $match_part = "feed_id = " . (int)$n_feed; |
|
1078 | + } else { |
|
1079 | + $match_part = "feed_id IS NULL"; |
|
1080 | + } |
|
1081 | 1081 | |
1082 | - } else if ($feed < LABEL_BASE_INDEX) { |
|
1082 | + } else if ($feed < LABEL_BASE_INDEX) { |
|
1083 | 1083 | |
1084 | - $label_id = Labels::feed_to_label_id($feed); |
|
1084 | + $label_id = Labels::feed_to_label_id($feed); |
|
1085 | 1085 | |
1086 | - return Feeds::getLabelUnread($label_id, $owner_uid); |
|
1087 | - } |
|
1086 | + return Feeds::getLabelUnread($label_id, $owner_uid); |
|
1087 | + } |
|
1088 | 1088 | |
1089 | - if ($match_part) { |
|
1089 | + if ($match_part) { |
|
1090 | 1090 | |
1091 | - if ($need_entries) { |
|
1092 | - $from_qpart = "ttrss_user_entries,ttrss_entries"; |
|
1093 | - $from_where = "ttrss_entries.id = ttrss_user_entries.ref_id AND"; |
|
1094 | - } else { |
|
1095 | - $from_qpart = "ttrss_user_entries"; |
|
1096 | - $from_where = ""; |
|
1097 | - } |
|
1091 | + if ($need_entries) { |
|
1092 | + $from_qpart = "ttrss_user_entries,ttrss_entries"; |
|
1093 | + $from_where = "ttrss_entries.id = ttrss_user_entries.ref_id AND"; |
|
1094 | + } else { |
|
1095 | + $from_qpart = "ttrss_user_entries"; |
|
1096 | + $from_where = ""; |
|
1097 | + } |
|
1098 | 1098 | |
1099 | - $sth = $pdo->prepare("SELECT count(int_id) AS unread |
|
1099 | + $sth = $pdo->prepare("SELECT count(int_id) AS unread |
|
1100 | 1100 | FROM $from_qpart WHERE |
1101 | 1101 | $unread_qpart AND $from_where ($match_part) AND ttrss_user_entries.owner_uid = ?"); |
1102 | - $sth->execute([$owner_uid]); |
|
1103 | - $row = $sth->fetch(); |
|
1102 | + $sth->execute([$owner_uid]); |
|
1103 | + $row = $sth->fetch(); |
|
1104 | 1104 | |
1105 | - return $row["unread"]; |
|
1105 | + return $row["unread"]; |
|
1106 | 1106 | |
1107 | - } else { |
|
1107 | + } else { |
|
1108 | 1108 | |
1109 | - $sth = $pdo->prepare("SELECT COUNT(post_int_id) AS unread |
|
1109 | + $sth = $pdo->prepare("SELECT COUNT(post_int_id) AS unread |
|
1110 | 1110 | FROM ttrss_tags,ttrss_user_entries,ttrss_entries |
1111 | 1111 | WHERE tag_name = ? AND post_int_id = int_id AND ref_id = ttrss_entries.id |
1112 | 1112 | AND $unread_qpart AND ttrss_tags.owner_uid = ,"); |
1113 | 1113 | |
1114 | - $sth->execute([$feed, $owner_uid]); |
|
1115 | - $row = $sth->fetch(); |
|
1116 | - |
|
1117 | - return $row["unread"]; |
|
1118 | - } |
|
1119 | - } |
|
1120 | - |
|
1121 | - /** |
|
1122 | - * @return array (code => Status code, message => error message if available) |
|
1123 | - * |
|
1124 | - * 0 - OK, Feed already exists |
|
1125 | - * 1 - OK, Feed added |
|
1126 | - * 2 - Invalid URL |
|
1127 | - * 3 - URL content is HTML, no feeds available |
|
1128 | - * 4 - URL content is HTML which contains multiple feeds. |
|
1129 | - * Here you should call extractfeedurls in rpc-backend |
|
1130 | - * to get all possible feeds. |
|
1131 | - * 5 - Couldn't download the URL content. |
|
1132 | - * 6 - Content is an invalid XML. |
|
1133 | - */ |
|
1134 | - public static function subscribe_to_feed($url, $cat_id = 0, |
|
1135 | - $auth_login = '', $auth_pass = '') { |
|
1136 | - |
|
1137 | - global $fetch_last_error; |
|
1138 | - global $fetch_last_error_content; |
|
1139 | - global $fetch_last_content_type; |
|
1140 | - |
|
1141 | - $pdo = Db::pdo(); |
|
1142 | - |
|
1143 | - $url = Feeds::fix_url($url); |
|
1144 | - |
|
1145 | - if (!$url || !Feeds::validate_feed_url($url)) return array("code" => 2); |
|
1146 | - |
|
1147 | - $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass); |
|
1114 | + $sth->execute([$feed, $owner_uid]); |
|
1115 | + $row = $sth->fetch(); |
|
1148 | 1116 | |
1149 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) { |
|
1150 | - $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass); |
|
1151 | - } |
|
1117 | + return $row["unread"]; |
|
1118 | + } |
|
1119 | + } |
|
1120 | + |
|
1121 | + /** |
|
1122 | + * @return array (code => Status code, message => error message if available) |
|
1123 | + * |
|
1124 | + * 0 - OK, Feed already exists |
|
1125 | + * 1 - OK, Feed added |
|
1126 | + * 2 - Invalid URL |
|
1127 | + * 3 - URL content is HTML, no feeds available |
|
1128 | + * 4 - URL content is HTML which contains multiple feeds. |
|
1129 | + * Here you should call extractfeedurls in rpc-backend |
|
1130 | + * to get all possible feeds. |
|
1131 | + * 5 - Couldn't download the URL content. |
|
1132 | + * 6 - Content is an invalid XML. |
|
1133 | + */ |
|
1134 | + public static function subscribe_to_feed($url, $cat_id = 0, |
|
1135 | + $auth_login = '', $auth_pass = '') { |
|
1136 | + |
|
1137 | + global $fetch_last_error; |
|
1138 | + global $fetch_last_error_content; |
|
1139 | + global $fetch_last_content_type; |
|
1140 | + |
|
1141 | + $pdo = Db::pdo(); |
|
1142 | + |
|
1143 | + $url = Feeds::fix_url($url); |
|
1144 | + |
|
1145 | + if (!$url || !Feeds::validate_feed_url($url)) return array("code" => 2); |
|
1146 | + |
|
1147 | + $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass); |
|
1148 | + |
|
1149 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) { |
|
1150 | + $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass); |
|
1151 | + } |
|
1152 | 1152 | |
1153 | - if (!$contents) { |
|
1154 | - if (preg_match("/cloudflare\.com/", $fetch_last_error_content)) { |
|
1155 | - $fetch_last_error .= " (feed behind Cloudflare)"; |
|
1156 | - } |
|
1153 | + if (!$contents) { |
|
1154 | + if (preg_match("/cloudflare\.com/", $fetch_last_error_content)) { |
|
1155 | + $fetch_last_error .= " (feed behind Cloudflare)"; |
|
1156 | + } |
|
1157 | 1157 | |
1158 | - return array("code" => 5, "message" => $fetch_last_error); |
|
1159 | - } |
|
1158 | + return array("code" => 5, "message" => $fetch_last_error); |
|
1159 | + } |
|
1160 | 1160 | |
1161 | - if (mb_strpos($fetch_last_content_type, "html") !== FALSE && Feeds::is_html($contents)) { |
|
1162 | - $feedUrls = Feeds::get_feeds_from_html($url, $contents); |
|
1161 | + if (mb_strpos($fetch_last_content_type, "html") !== FALSE && Feeds::is_html($contents)) { |
|
1162 | + $feedUrls = Feeds::get_feeds_from_html($url, $contents); |
|
1163 | 1163 | |
1164 | - if (count($feedUrls) == 0) { |
|
1165 | - return array("code" => 3); |
|
1166 | - } else if (count($feedUrls) > 1) { |
|
1167 | - return array("code" => 4, "feeds" => $feedUrls); |
|
1168 | - } |
|
1169 | - //use feed url as new URL |
|
1170 | - $url = key($feedUrls); |
|
1171 | - } |
|
1164 | + if (count($feedUrls) == 0) { |
|
1165 | + return array("code" => 3); |
|
1166 | + } else if (count($feedUrls) > 1) { |
|
1167 | + return array("code" => 4, "feeds" => $feedUrls); |
|
1168 | + } |
|
1169 | + //use feed url as new URL |
|
1170 | + $url = key($feedUrls); |
|
1171 | + } |
|
1172 | 1172 | |
1173 | - if (!$cat_id) $cat_id = null; |
|
1173 | + if (!$cat_id) $cat_id = null; |
|
1174 | 1174 | |
1175 | - $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
|
1175 | + $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
|
1176 | 1176 | WHERE feed_url = ? AND owner_uid = ?"); |
1177 | - $sth->execute([$url, $_SESSION['uid']]); |
|
1177 | + $sth->execute([$url, $_SESSION['uid']]); |
|
1178 | 1178 | |
1179 | - if ($row = $sth->fetch()) { |
|
1180 | - return array("code" => 0, "feed_id" => (int) $row["id"]); |
|
1181 | - } else { |
|
1182 | - $sth = $pdo->prepare( |
|
1183 | - "INSERT INTO ttrss_feeds |
|
1179 | + if ($row = $sth->fetch()) { |
|
1180 | + return array("code" => 0, "feed_id" => (int) $row["id"]); |
|
1181 | + } else { |
|
1182 | + $sth = $pdo->prepare( |
|
1183 | + "INSERT INTO ttrss_feeds |
|
1184 | 1184 | (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted) |
1185 | 1185 | VALUES (?, ?, ?, ?, ?, ?, 0, false)"); |
1186 | 1186 | |
1187 | - $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string)$auth_login, (string)$auth_pass]); |
|
1187 | + $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string)$auth_login, (string)$auth_pass]); |
|
1188 | 1188 | |
1189 | - $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
|
1189 | + $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
|
1190 | 1190 | AND owner_uid = ?"); |
1191 | - $sth->execute([$url, $_SESSION['uid']]); |
|
1192 | - $row = $sth->fetch(); |
|
1193 | - |
|
1194 | - $feed_id = $row["id"]; |
|
1195 | - |
|
1196 | - if ($feed_id) { |
|
1197 | - RSSUtils::set_basic_feed_info($feed_id); |
|
1198 | - } |
|
1199 | - |
|
1200 | - return array("code" => 1, "feed_id" => (int) $feed_id); |
|
1201 | - |
|
1202 | - } |
|
1203 | - } |
|
1204 | - |
|
1205 | - public static function getIconFile($feed_id) { |
|
1206 | - return ICONS_DIR . "/$feed_id.ico"; |
|
1207 | - } |
|
1208 | - |
|
1209 | - public static function feedHasIcon($id) { |
|
1210 | - return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0; |
|
1211 | - } |
|
1212 | - |
|
1213 | - public static function getFeedIcon($id) { |
|
1214 | - switch ($id) { |
|
1215 | - case 0: |
|
1216 | - return "archive"; |
|
1217 | - case -1: |
|
1218 | - return "star"; |
|
1219 | - case -2: |
|
1220 | - return "rss_feed"; |
|
1221 | - case -3: |
|
1222 | - return "whatshot"; |
|
1223 | - case -4: |
|
1224 | - return "inbox"; |
|
1225 | - case -6: |
|
1226 | - return "restore"; |
|
1227 | - default: |
|
1228 | - if ($id < LABEL_BASE_INDEX) { |
|
1229 | - return "label"; |
|
1230 | - } else { |
|
1231 | - $icon = self::getIconFile($id); |
|
1232 | - |
|
1233 | - if ($icon && file_exists($icon)) { |
|
1234 | - return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
1235 | - } |
|
1236 | - } |
|
1237 | - } |
|
1238 | - |
|
1239 | - return false; |
|
1240 | - } |
|
1241 | - |
|
1242 | - public static function getFeedTitle($id, $cat = false) { |
|
1243 | - $pdo = Db::pdo(); |
|
1244 | - |
|
1245 | - if ($cat) { |
|
1246 | - return Feeds::getCategoryTitle($id); |
|
1247 | - } else if ($id == -1) { |
|
1248 | - return __("Starred articles"); |
|
1249 | - } else if ($id == -2) { |
|
1250 | - return __("Published articles"); |
|
1251 | - } else if ($id == -3) { |
|
1252 | - return __("Fresh articles"); |
|
1253 | - } else if ($id == -4) { |
|
1254 | - return __("All articles"); |
|
1255 | - } else if ($id === 0 || $id === "0") { |
|
1256 | - return __("Archived articles"); |
|
1257 | - } else if ($id == -6) { |
|
1258 | - return __("Recently read"); |
|
1259 | - } else if ($id < LABEL_BASE_INDEX) { |
|
1260 | - |
|
1261 | - $label_id = Labels::feed_to_label_id($id); |
|
1191 | + $sth->execute([$url, $_SESSION['uid']]); |
|
1192 | + $row = $sth->fetch(); |
|
1262 | 1193 | |
1263 | - $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ?"); |
|
1264 | - $sth->execute([$label_id]); |
|
1194 | + $feed_id = $row["id"]; |
|
1265 | 1195 | |
1266 | - if ($row = $sth->fetch()) { |
|
1267 | - return $row["caption"]; |
|
1268 | - } else { |
|
1269 | - return "Unknown label ($label_id)"; |
|
1270 | - } |
|
1196 | + if ($feed_id) { |
|
1197 | + RSSUtils::set_basic_feed_info($feed_id); |
|
1198 | + } |
|
1271 | 1199 | |
1272 | - } else if (is_numeric($id) && $id > 0) { |
|
1200 | + return array("code" => 1, "feed_id" => (int) $feed_id); |
|
1273 | 1201 | |
1274 | - $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?"); |
|
1275 | - $sth->execute([$id]); |
|
1202 | + } |
|
1203 | + } |
|
1204 | + |
|
1205 | + public static function getIconFile($feed_id) { |
|
1206 | + return ICONS_DIR . "/$feed_id.ico"; |
|
1207 | + } |
|
1208 | + |
|
1209 | + public static function feedHasIcon($id) { |
|
1210 | + return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0; |
|
1211 | + } |
|
1212 | + |
|
1213 | + public static function getFeedIcon($id) { |
|
1214 | + switch ($id) { |
|
1215 | + case 0: |
|
1216 | + return "archive"; |
|
1217 | + case -1: |
|
1218 | + return "star"; |
|
1219 | + case -2: |
|
1220 | + return "rss_feed"; |
|
1221 | + case -3: |
|
1222 | + return "whatshot"; |
|
1223 | + case -4: |
|
1224 | + return "inbox"; |
|
1225 | + case -6: |
|
1226 | + return "restore"; |
|
1227 | + default: |
|
1228 | + if ($id < LABEL_BASE_INDEX) { |
|
1229 | + return "label"; |
|
1230 | + } else { |
|
1231 | + $icon = self::getIconFile($id); |
|
1276 | 1232 | |
1277 | - if ($row = $sth->fetch()) { |
|
1278 | - return $row["title"]; |
|
1279 | - } else { |
|
1280 | - return "Unknown feed ($id)"; |
|
1281 | - } |
|
1233 | + if ($icon && file_exists($icon)) { |
|
1234 | + return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
1235 | + } |
|
1236 | + } |
|
1237 | + } |
|
1282 | 1238 | |
1283 | - } else { |
|
1284 | - return $id; |
|
1285 | - } |
|
1286 | - } |
|
1239 | + return false; |
|
1240 | + } |
|
1241 | + |
|
1242 | + public static function getFeedTitle($id, $cat = false) { |
|
1243 | + $pdo = Db::pdo(); |
|
1244 | + |
|
1245 | + if ($cat) { |
|
1246 | + return Feeds::getCategoryTitle($id); |
|
1247 | + } else if ($id == -1) { |
|
1248 | + return __("Starred articles"); |
|
1249 | + } else if ($id == -2) { |
|
1250 | + return __("Published articles"); |
|
1251 | + } else if ($id == -3) { |
|
1252 | + return __("Fresh articles"); |
|
1253 | + } else if ($id == -4) { |
|
1254 | + return __("All articles"); |
|
1255 | + } else if ($id === 0 || $id === "0") { |
|
1256 | + return __("Archived articles"); |
|
1257 | + } else if ($id == -6) { |
|
1258 | + return __("Recently read"); |
|
1259 | + } else if ($id < LABEL_BASE_INDEX) { |
|
1260 | + |
|
1261 | + $label_id = Labels::feed_to_label_id($id); |
|
1262 | + |
|
1263 | + $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ?"); |
|
1264 | + $sth->execute([$label_id]); |
|
1265 | + |
|
1266 | + if ($row = $sth->fetch()) { |
|
1267 | + return $row["caption"]; |
|
1268 | + } else { |
|
1269 | + return "Unknown label ($label_id)"; |
|
1270 | + } |
|
1271 | + |
|
1272 | + } else if (is_numeric($id) && $id > 0) { |
|
1273 | + |
|
1274 | + $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?"); |
|
1275 | + $sth->execute([$id]); |
|
1276 | + |
|
1277 | + if ($row = $sth->fetch()) { |
|
1278 | + return $row["title"]; |
|
1279 | + } else { |
|
1280 | + return "Unknown feed ($id)"; |
|
1281 | + } |
|
1282 | + |
|
1283 | + } else { |
|
1284 | + return $id; |
|
1285 | + } |
|
1286 | + } |
|
1287 | 1287 | |
1288 | - public static function getCategoryUnread($cat, $owner_uid = false) { |
|
1288 | + public static function getCategoryUnread($cat, $owner_uid = false) { |
|
1289 | 1289 | |
1290 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1290 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1291 | 1291 | |
1292 | - $pdo = Db::pdo(); |
|
1292 | + $pdo = Db::pdo(); |
|
1293 | 1293 | |
1294 | - if ($cat >= 0) { |
|
1294 | + if ($cat >= 0) { |
|
1295 | 1295 | |
1296 | - if (!$cat) $cat = null; |
|
1296 | + if (!$cat) $cat = null; |
|
1297 | 1297 | |
1298 | - $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
|
1298 | + $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
|
1299 | 1299 | WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) |
1300 | 1300 | AND owner_uid = :uid"); |
1301 | 1301 | |
1302 | - $sth->execute([":cat" => $cat, ":uid" => $owner_uid]); |
|
1302 | + $sth->execute([":cat" => $cat, ":uid" => $owner_uid]); |
|
1303 | 1303 | |
1304 | - $cat_feeds = array(); |
|
1305 | - while ($line = $sth->fetch()) { |
|
1306 | - array_push($cat_feeds, "feed_id = " . (int)$line["id"]); |
|
1307 | - } |
|
1304 | + $cat_feeds = array(); |
|
1305 | + while ($line = $sth->fetch()) { |
|
1306 | + array_push($cat_feeds, "feed_id = " . (int)$line["id"]); |
|
1307 | + } |
|
1308 | 1308 | |
1309 | - if (count($cat_feeds) == 0) return 0; |
|
1309 | + if (count($cat_feeds) == 0) return 0; |
|
1310 | 1310 | |
1311 | - $match_part = implode(" OR ", $cat_feeds); |
|
1311 | + $match_part = implode(" OR ", $cat_feeds); |
|
1312 | 1312 | |
1313 | - $sth = $pdo->prepare("SELECT COUNT(int_id) AS unread |
|
1313 | + $sth = $pdo->prepare("SELECT COUNT(int_id) AS unread |
|
1314 | 1314 | FROM ttrss_user_entries |
1315 | 1315 | WHERE unread = true AND ($match_part) |
1316 | 1316 | AND owner_uid = ?"); |
1317 | - $sth->execute([$owner_uid]); |
|
1317 | + $sth->execute([$owner_uid]); |
|
1318 | 1318 | |
1319 | - $unread = 0; |
|
1319 | + $unread = 0; |
|
1320 | 1320 | |
1321 | - # this needs to be rewritten |
|
1322 | - while ($line = $sth->fetch()) { |
|
1323 | - $unread += $line["unread"]; |
|
1324 | - } |
|
1321 | + # this needs to be rewritten |
|
1322 | + while ($line = $sth->fetch()) { |
|
1323 | + $unread += $line["unread"]; |
|
1324 | + } |
|
1325 | 1325 | |
1326 | - return $unread; |
|
1327 | - } else if ($cat == -1) { |
|
1328 | - return getFeedUnread(-1) + getFeedUnread(-2) + getFeedUnread(-3) + getFeedUnread(0); |
|
1329 | - } else if ($cat == -2) { |
|
1326 | + return $unread; |
|
1327 | + } else if ($cat == -1) { |
|
1328 | + return getFeedUnread(-1) + getFeedUnread(-2) + getFeedUnread(-3) + getFeedUnread(0); |
|
1329 | + } else if ($cat == -2) { |
|
1330 | 1330 | |
1331 | - $sth = $pdo->prepare("SELECT COUNT(unread) AS unread FROM |
|
1331 | + $sth = $pdo->prepare("SELECT COUNT(unread) AS unread FROM |
|
1332 | 1332 | ttrss_user_entries, ttrss_user_labels2 |
1333 | 1333 | WHERE article_id = ref_id AND unread = true |
1334 | 1334 | AND ttrss_user_entries.owner_uid = ?"); |
1335 | - $sth->execute([$owner_uid]); |
|
1335 | + $sth->execute([$owner_uid]); |
|
1336 | 1336 | $row = $sth->fetch(); |
1337 | 1337 | |
1338 | - return $row["unread"]; |
|
1339 | - } |
|
1340 | - } |
|
1338 | + return $row["unread"]; |
|
1339 | + } |
|
1340 | + } |
|
1341 | 1341 | |
1342 | - // only accepts real cats (>= 0) |
|
1343 | - public static function getCategoryChildrenUnread($cat, $owner_uid = false) { |
|
1344 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1342 | + // only accepts real cats (>= 0) |
|
1343 | + public static function getCategoryChildrenUnread($cat, $owner_uid = false) { |
|
1344 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1345 | 1345 | |
1346 | - $pdo = Db::pdo(); |
|
1346 | + $pdo = Db::pdo(); |
|
1347 | 1347 | |
1348 | - $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories WHERE parent_cat = ? |
|
1348 | + $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories WHERE parent_cat = ? |
|
1349 | 1349 | AND owner_uid = ?"); |
1350 | - $sth->execute([$cat, $owner_uid]); |
|
1350 | + $sth->execute([$cat, $owner_uid]); |
|
1351 | 1351 | |
1352 | - $unread = 0; |
|
1352 | + $unread = 0; |
|
1353 | 1353 | |
1354 | - while ($line = $sth->fetch()) { |
|
1355 | - $unread += Feeds::getCategoryUnread($line["id"], $owner_uid); |
|
1356 | - $unread += Feeds::getCategoryChildrenUnread($line["id"], $owner_uid); |
|
1357 | - } |
|
1354 | + while ($line = $sth->fetch()) { |
|
1355 | + $unread += Feeds::getCategoryUnread($line["id"], $owner_uid); |
|
1356 | + $unread += Feeds::getCategoryChildrenUnread($line["id"], $owner_uid); |
|
1357 | + } |
|
1358 | 1358 | |
1359 | - return $unread; |
|
1360 | - } |
|
1359 | + return $unread; |
|
1360 | + } |
|
1361 | 1361 | |
1362 | - public static function getGlobalUnread($user_id = false) { |
|
1362 | + public static function getGlobalUnread($user_id = false) { |
|
1363 | 1363 | |
1364 | - if (!$user_id) $user_id = $_SESSION["uid"]; |
|
1364 | + if (!$user_id) $user_id = $_SESSION["uid"]; |
|
1365 | 1365 | |
1366 | - $pdo = Db::pdo(); |
|
1366 | + $pdo = Db::pdo(); |
|
1367 | 1367 | |
1368 | - $sth = $pdo->prepare("SELECT SUM(value) AS c_id FROM ttrss_counters_cache |
|
1368 | + $sth = $pdo->prepare("SELECT SUM(value) AS c_id FROM ttrss_counters_cache |
|
1369 | 1369 | WHERE owner_uid = ? AND feed_id > 0"); |
1370 | - $sth->execute([$user_id]); |
|
1371 | - $row = $sth->fetch(); |
|
1370 | + $sth->execute([$user_id]); |
|
1371 | + $row = $sth->fetch(); |
|
1372 | 1372 | |
1373 | - return $row["c_id"]; |
|
1374 | - } |
|
1373 | + return $row["c_id"]; |
|
1374 | + } |
|
1375 | 1375 | |
1376 | - public static function getCategoryTitle($cat_id) { |
|
1376 | + public static function getCategoryTitle($cat_id) { |
|
1377 | 1377 | |
1378 | - if ($cat_id == -1) { |
|
1379 | - return __("Special"); |
|
1380 | - } else if ($cat_id == -2) { |
|
1381 | - return __("Labels"); |
|
1382 | - } else { |
|
1378 | + if ($cat_id == -1) { |
|
1379 | + return __("Special"); |
|
1380 | + } else if ($cat_id == -2) { |
|
1381 | + return __("Labels"); |
|
1382 | + } else { |
|
1383 | 1383 | |
1384 | - $pdo = Db::pdo(); |
|
1384 | + $pdo = Db::pdo(); |
|
1385 | 1385 | |
1386 | - $sth = $pdo->prepare("SELECT title FROM ttrss_feed_categories WHERE |
|
1386 | + $sth = $pdo->prepare("SELECT title FROM ttrss_feed_categories WHERE |
|
1387 | 1387 | id = ?"); |
1388 | - $sth->execute([$cat_id]); |
|
1388 | + $sth->execute([$cat_id]); |
|
1389 | 1389 | |
1390 | - if ($row = $sth->fetch()) { |
|
1391 | - return $row["title"]; |
|
1392 | - } else { |
|
1393 | - return __("Uncategorized"); |
|
1394 | - } |
|
1395 | - } |
|
1396 | - } |
|
1390 | + if ($row = $sth->fetch()) { |
|
1391 | + return $row["title"]; |
|
1392 | + } else { |
|
1393 | + return __("Uncategorized"); |
|
1394 | + } |
|
1395 | + } |
|
1396 | + } |
|
1397 | 1397 | |
1398 | - public static function getLabelUnread($label_id, $owner_uid = false) { |
|
1399 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1398 | + public static function getLabelUnread($label_id, $owner_uid = false) { |
|
1399 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1400 | 1400 | |
1401 | - $pdo = Db::pdo(); |
|
1401 | + $pdo = Db::pdo(); |
|
1402 | 1402 | |
1403 | - $sth = $pdo->prepare("SELECT COUNT(ref_id) AS unread FROM ttrss_user_entries, ttrss_user_labels2 |
|
1403 | + $sth = $pdo->prepare("SELECT COUNT(ref_id) AS unread FROM ttrss_user_entries, ttrss_user_labels2 |
|
1404 | 1404 | WHERE owner_uid = ? AND unread = true AND label_id = ? AND article_id = ref_id"); |
1405 | 1405 | |
1406 | - $sth->execute([$owner_uid, $label_id]); |
|
1406 | + $sth->execute([$owner_uid, $label_id]); |
|
1407 | 1407 | |
1408 | - if ($row = $sth->fetch()) { |
|
1409 | - return $row["unread"]; |
|
1410 | - } else { |
|
1411 | - return 0; |
|
1412 | - } |
|
1413 | - } |
|
1408 | + if ($row = $sth->fetch()) { |
|
1409 | + return $row["unread"]; |
|
1410 | + } else { |
|
1411 | + return 0; |
|
1412 | + } |
|
1413 | + } |
|
1414 | 1414 | |
1415 | - public static function queryFeedHeadlines($params) { |
|
1415 | + public static function queryFeedHeadlines($params) { |
|
1416 | 1416 | |
1417 | - $pdo = Db::pdo(); |
|
1417 | + $pdo = Db::pdo(); |
|
1418 | 1418 | |
1419 | - // WARNING: due to highly dynamic nature of this query its going to quote parameters |
|
1419 | + // WARNING: due to highly dynamic nature of this query its going to quote parameters |
|
1420 | 1420 | // right before adding them to SQL part |
1421 | 1421 | |
1422 | - $feed = $params["feed"]; |
|
1423 | - $limit = isset($params["limit"]) ? $params["limit"] : 30; |
|
1424 | - $view_mode = $params["view_mode"]; |
|
1425 | - $cat_view = isset($params["cat_view"]) ? $params["cat_view"] : false; |
|
1426 | - $search = isset($params["search"]) ? $params["search"] : false; |
|
1427 | - $search_language = isset($params["search_language"]) ? $params["search_language"] : ""; |
|
1428 | - $override_order = isset($params["override_order"]) ? $params["override_order"] : false; |
|
1429 | - $offset = isset($params["offset"]) ? $params["offset"] : 0; |
|
1430 | - $owner_uid = isset($params["owner_uid"]) ? $params["owner_uid"] : $_SESSION["uid"]; |
|
1431 | - $since_id = isset($params["since_id"]) ? $params["since_id"] : 0; |
|
1432 | - $include_children = isset($params["include_children"]) ? $params["include_children"] : false; |
|
1433 | - $ignore_vfeed_group = isset($params["ignore_vfeed_group"]) ? $params["ignore_vfeed_group"] : false; |
|
1434 | - $override_strategy = isset($params["override_strategy"]) ? $params["override_strategy"] : false; |
|
1435 | - $override_vfeed = isset($params["override_vfeed"]) ? $params["override_vfeed"] : false; |
|
1436 | - $start_ts = isset($params["start_ts"]) ? $params["start_ts"] : false; |
|
1437 | - $check_first_id = isset($params["check_first_id"]) ? $params["check_first_id"] : false; |
|
1438 | - $skip_first_id_check = isset($params["skip_first_id_check"]) ? $params["skip_first_id_check"] : false; |
|
1439 | - //$order_by = isset($params["order_by"]) ? $params["order_by"] : false; |
|
1440 | - |
|
1441 | - $ext_tables_part = ""; |
|
1442 | - $limit_query_part = ""; |
|
1443 | - $query_error_override = ""; |
|
1444 | - |
|
1445 | - $search_words = []; |
|
1446 | - |
|
1447 | - if ($search) { |
|
1448 | - $search_query_part = ""; |
|
1449 | - |
|
1450 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) { |
|
1451 | - list($search_query_part, $search_words) = $plugin->hook_search($search); |
|
1452 | - break; |
|
1453 | - } |
|
1454 | - |
|
1455 | - // fall back in case of no plugins |
|
1456 | - if (!$search_query_part) { |
|
1457 | - list($search_query_part, $search_words) = Feeds::search_to_sql($search, $search_language); |
|
1458 | - } |
|
1459 | - |
|
1460 | - if (DB_TYPE == "pgsql") { |
|
1461 | - $test_sth = $pdo->prepare("select $search_query_part |
|
1422 | + $feed = $params["feed"]; |
|
1423 | + $limit = isset($params["limit"]) ? $params["limit"] : 30; |
|
1424 | + $view_mode = $params["view_mode"]; |
|
1425 | + $cat_view = isset($params["cat_view"]) ? $params["cat_view"] : false; |
|
1426 | + $search = isset($params["search"]) ? $params["search"] : false; |
|
1427 | + $search_language = isset($params["search_language"]) ? $params["search_language"] : ""; |
|
1428 | + $override_order = isset($params["override_order"]) ? $params["override_order"] : false; |
|
1429 | + $offset = isset($params["offset"]) ? $params["offset"] : 0; |
|
1430 | + $owner_uid = isset($params["owner_uid"]) ? $params["owner_uid"] : $_SESSION["uid"]; |
|
1431 | + $since_id = isset($params["since_id"]) ? $params["since_id"] : 0; |
|
1432 | + $include_children = isset($params["include_children"]) ? $params["include_children"] : false; |
|
1433 | + $ignore_vfeed_group = isset($params["ignore_vfeed_group"]) ? $params["ignore_vfeed_group"] : false; |
|
1434 | + $override_strategy = isset($params["override_strategy"]) ? $params["override_strategy"] : false; |
|
1435 | + $override_vfeed = isset($params["override_vfeed"]) ? $params["override_vfeed"] : false; |
|
1436 | + $start_ts = isset($params["start_ts"]) ? $params["start_ts"] : false; |
|
1437 | + $check_first_id = isset($params["check_first_id"]) ? $params["check_first_id"] : false; |
|
1438 | + $skip_first_id_check = isset($params["skip_first_id_check"]) ? $params["skip_first_id_check"] : false; |
|
1439 | + //$order_by = isset($params["order_by"]) ? $params["order_by"] : false; |
|
1440 | + |
|
1441 | + $ext_tables_part = ""; |
|
1442 | + $limit_query_part = ""; |
|
1443 | + $query_error_override = ""; |
|
1444 | + |
|
1445 | + $search_words = []; |
|
1446 | + |
|
1447 | + if ($search) { |
|
1448 | + $search_query_part = ""; |
|
1449 | + |
|
1450 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) { |
|
1451 | + list($search_query_part, $search_words) = $plugin->hook_search($search); |
|
1452 | + break; |
|
1453 | + } |
|
1454 | + |
|
1455 | + // fall back in case of no plugins |
|
1456 | + if (!$search_query_part) { |
|
1457 | + list($search_query_part, $search_words) = Feeds::search_to_sql($search, $search_language); |
|
1458 | + } |
|
1459 | + |
|
1460 | + if (DB_TYPE == "pgsql") { |
|
1461 | + $test_sth = $pdo->prepare("select $search_query_part |
|
1462 | 1462 | FROM ttrss_entries, ttrss_user_entries WHERE id = ref_id limit 1"); |
1463 | 1463 | |
1464 | - try { |
|
1465 | - $test_sth->execute(); |
|
1466 | - } catch (PDOException $e) { |
|
1467 | - // looks like tsquery syntax is invalid |
|
1468 | - $search_query_part = "false"; |
|
1464 | + try { |
|
1465 | + $test_sth->execute(); |
|
1466 | + } catch (PDOException $e) { |
|
1467 | + // looks like tsquery syntax is invalid |
|
1468 | + $search_query_part = "false"; |
|
1469 | 1469 | |
1470 | - $query_error_override = T_sprintf("Incorrect search syntax: %s.", implode(" ", $search_words)); |
|
1471 | - } |
|
1472 | - } |
|
1470 | + $query_error_override = T_sprintf("Incorrect search syntax: %s.", implode(" ", $search_words)); |
|
1471 | + } |
|
1472 | + } |
|
1473 | 1473 | |
1474 | - $search_query_part .= " AND "; |
|
1475 | - } else { |
|
1476 | - $search_query_part = ""; |
|
1477 | - } |
|
1474 | + $search_query_part .= " AND "; |
|
1475 | + } else { |
|
1476 | + $search_query_part = ""; |
|
1477 | + } |
|
1478 | 1478 | |
1479 | - if ($since_id) { |
|
1480 | - $since_id_part = "ttrss_entries.id > ".$pdo->quote($since_id)." AND "; |
|
1481 | - } else { |
|
1482 | - $since_id_part = ""; |
|
1483 | - } |
|
1479 | + if ($since_id) { |
|
1480 | + $since_id_part = "ttrss_entries.id > ".$pdo->quote($since_id)." AND "; |
|
1481 | + } else { |
|
1482 | + $since_id_part = ""; |
|
1483 | + } |
|
1484 | 1484 | |
1485 | - $view_query_part = ""; |
|
1485 | + $view_query_part = ""; |
|
1486 | 1486 | |
1487 | - if ($view_mode == "adaptive") { |
|
1488 | - if ($search) { |
|
1489 | - $view_query_part = " "; |
|
1490 | - } else if ($feed != -1) { |
|
1487 | + if ($view_mode == "adaptive") { |
|
1488 | + if ($search) { |
|
1489 | + $view_query_part = " "; |
|
1490 | + } else if ($feed != -1) { |
|
1491 | 1491 | |
1492 | - $unread = getFeedUnread($feed, $cat_view); |
|
1492 | + $unread = getFeedUnread($feed, $cat_view); |
|
1493 | 1493 | |
1494 | - if ($cat_view && $feed > 0 && $include_children) |
|
1495 | - $unread += Feeds::getCategoryChildrenUnread($feed); |
|
1494 | + if ($cat_view && $feed > 0 && $include_children) |
|
1495 | + $unread += Feeds::getCategoryChildrenUnread($feed); |
|
1496 | 1496 | |
1497 | - if ($unread > 0) { |
|
1498 | - $view_query_part = " unread = true AND "; |
|
1499 | - } |
|
1500 | - } |
|
1501 | - } |
|
1497 | + if ($unread > 0) { |
|
1498 | + $view_query_part = " unread = true AND "; |
|
1499 | + } |
|
1500 | + } |
|
1501 | + } |
|
1502 | 1502 | |
1503 | - if ($view_mode == "marked") { |
|
1504 | - $view_query_part = " marked = true AND "; |
|
1505 | - } |
|
1503 | + if ($view_mode == "marked") { |
|
1504 | + $view_query_part = " marked = true AND "; |
|
1505 | + } |
|
1506 | 1506 | |
1507 | - if ($view_mode == "has_note") { |
|
1508 | - $view_query_part = " (note IS NOT NULL AND note != '') AND "; |
|
1509 | - } |
|
1507 | + if ($view_mode == "has_note") { |
|
1508 | + $view_query_part = " (note IS NOT NULL AND note != '') AND "; |
|
1509 | + } |
|
1510 | 1510 | |
1511 | - if ($view_mode == "published") { |
|
1512 | - $view_query_part = " published = true AND "; |
|
1513 | - } |
|
1511 | + if ($view_mode == "published") { |
|
1512 | + $view_query_part = " published = true AND "; |
|
1513 | + } |
|
1514 | 1514 | |
1515 | - if ($view_mode == "unread" && $feed != -6) { |
|
1516 | - $view_query_part = " unread = true AND "; |
|
1517 | - } |
|
1515 | + if ($view_mode == "unread" && $feed != -6) { |
|
1516 | + $view_query_part = " unread = true AND "; |
|
1517 | + } |
|
1518 | 1518 | |
1519 | - if ($limit > 0) { |
|
1520 | - $limit_query_part = "LIMIT " . (int)$limit; |
|
1521 | - } |
|
1519 | + if ($limit > 0) { |
|
1520 | + $limit_query_part = "LIMIT " . (int)$limit; |
|
1521 | + } |
|
1522 | 1522 | |
1523 | - $allow_archived = false; |
|
1523 | + $allow_archived = false; |
|
1524 | 1524 | |
1525 | - $vfeed_query_part = ""; |
|
1525 | + $vfeed_query_part = ""; |
|
1526 | 1526 | |
1527 | - /* tags */ |
|
1528 | - if (!is_numeric($feed)) { |
|
1529 | - $query_strategy_part = "true"; |
|
1530 | - $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
|
1527 | + /* tags */ |
|
1528 | + if (!is_numeric($feed)) { |
|
1529 | + $query_strategy_part = "true"; |
|
1530 | + $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE |
|
1531 | 1531 | id = feed_id) as feed_title,"; |
1532 | - } else if ($feed > 0) { |
|
1533 | - |
|
1534 | - if ($cat_view) { |
|
1535 | - |
|
1536 | - if ($feed > 0) { |
|
1537 | - if ($include_children) { |
|
1538 | - # sub-cats |
|
1539 | - $subcats = Feeds::getChildCategories($feed, $owner_uid); |
|
1540 | - array_push($subcats, $feed); |
|
1541 | - $subcats = array_map("intval", $subcats); |
|
1542 | - |
|
1543 | - $query_strategy_part = "cat_id IN (". |
|
1544 | - implode(",", $subcats).")"; |
|
1545 | - |
|
1546 | - } else { |
|
1547 | - $query_strategy_part = "cat_id = " . $pdo->quote($feed); |
|
1548 | - } |
|
1549 | - |
|
1550 | - } else { |
|
1551 | - $query_strategy_part = "cat_id IS NULL"; |
|
1552 | - } |
|
1532 | + } else if ($feed > 0) { |
|
1553 | 1533 | |
1554 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1534 | + if ($cat_view) { |
|
1555 | 1535 | |
1556 | - } else { |
|
1557 | - $query_strategy_part = "feed_id = " . $pdo->quote($feed); |
|
1558 | - } |
|
1559 | - } else if ($feed == 0 && !$cat_view) { // archive virtual feed |
|
1560 | - $query_strategy_part = "feed_id IS NULL"; |
|
1561 | - $allow_archived = true; |
|
1562 | - } else if ($feed == 0 && $cat_view) { // uncategorized |
|
1563 | - $query_strategy_part = "cat_id IS NULL AND feed_id IS NOT NULL"; |
|
1564 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1565 | - } else if ($feed == -1) { // starred virtual feed |
|
1566 | - $query_strategy_part = "marked = true"; |
|
1567 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1568 | - $allow_archived = true; |
|
1536 | + if ($feed > 0) { |
|
1537 | + if ($include_children) { |
|
1538 | + # sub-cats |
|
1539 | + $subcats = Feeds::getChildCategories($feed, $owner_uid); |
|
1540 | + array_push($subcats, $feed); |
|
1541 | + $subcats = array_map("intval", $subcats); |
|
1569 | 1542 | |
1570 | - if (!$override_order) { |
|
1571 | - $override_order = "last_marked DESC, date_entered DESC, updated DESC"; |
|
1572 | - } |
|
1543 | + $query_strategy_part = "cat_id IN (". |
|
1544 | + implode(",", $subcats).")"; |
|
1573 | 1545 | |
1574 | - } else if ($feed == -2) { // published virtual feed OR labels category |
|
1546 | + } else { |
|
1547 | + $query_strategy_part = "cat_id = " . $pdo->quote($feed); |
|
1548 | + } |
|
1575 | 1549 | |
1576 | - if (!$cat_view) { |
|
1577 | - $query_strategy_part = "published = true"; |
|
1578 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1579 | - $allow_archived = true; |
|
1550 | + } else { |
|
1551 | + $query_strategy_part = "cat_id IS NULL"; |
|
1552 | + } |
|
1580 | 1553 | |
1581 | - if (!$override_order) { |
|
1582 | - $override_order = "last_published DESC, date_entered DESC, updated DESC"; |
|
1583 | - } |
|
1554 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1555 | + |
|
1556 | + } else { |
|
1557 | + $query_strategy_part = "feed_id = " . $pdo->quote($feed); |
|
1558 | + } |
|
1559 | + } else if ($feed == 0 && !$cat_view) { // archive virtual feed |
|
1560 | + $query_strategy_part = "feed_id IS NULL"; |
|
1561 | + $allow_archived = true; |
|
1562 | + } else if ($feed == 0 && $cat_view) { // uncategorized |
|
1563 | + $query_strategy_part = "cat_id IS NULL AND feed_id IS NOT NULL"; |
|
1564 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1565 | + } else if ($feed == -1) { // starred virtual feed |
|
1566 | + $query_strategy_part = "marked = true"; |
|
1567 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1568 | + $allow_archived = true; |
|
1569 | + |
|
1570 | + if (!$override_order) { |
|
1571 | + $override_order = "last_marked DESC, date_entered DESC, updated DESC"; |
|
1572 | + } |
|
1573 | + |
|
1574 | + } else if ($feed == -2) { // published virtual feed OR labels category |
|
1575 | + |
|
1576 | + if (!$cat_view) { |
|
1577 | + $query_strategy_part = "published = true"; |
|
1578 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1579 | + $allow_archived = true; |
|
1580 | + |
|
1581 | + if (!$override_order) { |
|
1582 | + $override_order = "last_published DESC, date_entered DESC, updated DESC"; |
|
1583 | + } |
|
1584 | 1584 | |
1585 | - } else { |
|
1586 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1585 | + } else { |
|
1586 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1587 | 1587 | |
1588 | - $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,"; |
|
1588 | + $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,"; |
|
1589 | 1589 | |
1590 | - $query_strategy_part = "ttrss_labels2.id = ttrss_user_labels2.label_id AND |
|
1590 | + $query_strategy_part = "ttrss_labels2.id = ttrss_user_labels2.label_id AND |
|
1591 | 1591 | ttrss_user_labels2.article_id = ref_id"; |
1592 | 1592 | |
1593 | - } |
|
1594 | - } else if ($feed == -6) { // recently read |
|
1595 | - $query_strategy_part = "unread = false AND last_read IS NOT NULL"; |
|
1593 | + } |
|
1594 | + } else if ($feed == -6) { // recently read |
|
1595 | + $query_strategy_part = "unread = false AND last_read IS NOT NULL"; |
|
1596 | 1596 | |
1597 | - if (DB_TYPE == "pgsql") { |
|
1598 | - $query_strategy_part .= " AND last_read > NOW() - INTERVAL '1 DAY' "; |
|
1599 | - } else { |
|
1600 | - $query_strategy_part .= " AND last_read > DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
1601 | - } |
|
1597 | + if (DB_TYPE == "pgsql") { |
|
1598 | + $query_strategy_part .= " AND last_read > NOW() - INTERVAL '1 DAY' "; |
|
1599 | + } else { |
|
1600 | + $query_strategy_part .= " AND last_read > DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
1601 | + } |
|
1602 | 1602 | |
1603 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1604 | - $allow_archived = true; |
|
1605 | - $ignore_vfeed_group = true; |
|
1603 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1604 | + $allow_archived = true; |
|
1605 | + $ignore_vfeed_group = true; |
|
1606 | 1606 | |
1607 | - if (!$override_order) $override_order = "last_read DESC"; |
|
1607 | + if (!$override_order) $override_order = "last_read DESC"; |
|
1608 | 1608 | |
1609 | - } else if ($feed == -3) { // fresh virtual feed |
|
1610 | - $query_strategy_part = "unread = true AND score >= 0"; |
|
1609 | + } else if ($feed == -3) { // fresh virtual feed |
|
1610 | + $query_strategy_part = "unread = true AND score >= 0"; |
|
1611 | 1611 | |
1612 | - $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid); |
|
1612 | + $intl = (int) get_pref("FRESH_ARTICLE_MAX_AGE", $owner_uid); |
|
1613 | 1613 | |
1614 | - if (DB_TYPE == "pgsql") { |
|
1615 | - $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' "; |
|
1616 | - } else { |
|
1617 | - $query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; |
|
1618 | - } |
|
1614 | + if (DB_TYPE == "pgsql") { |
|
1615 | + $query_strategy_part .= " AND date_entered > NOW() - INTERVAL '$intl hour' "; |
|
1616 | + } else { |
|
1617 | + $query_strategy_part .= " AND date_entered > DATE_SUB(NOW(), INTERVAL $intl HOUR) "; |
|
1618 | + } |
|
1619 | 1619 | |
1620 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1621 | - } else if ($feed == -4) { // all articles virtual feed |
|
1622 | - $allow_archived = true; |
|
1623 | - $query_strategy_part = "true"; |
|
1624 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1625 | - } else if ($feed <= LABEL_BASE_INDEX) { // labels |
|
1626 | - $label_id = Labels::feed_to_label_id($feed); |
|
1620 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1621 | + } else if ($feed == -4) { // all articles virtual feed |
|
1622 | + $allow_archived = true; |
|
1623 | + $query_strategy_part = "true"; |
|
1624 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1625 | + } else if ($feed <= LABEL_BASE_INDEX) { // labels |
|
1626 | + $label_id = Labels::feed_to_label_id($feed); |
|
1627 | 1627 | |
1628 | - $query_strategy_part = "label_id = ".$pdo->quote($label_id)." AND |
|
1628 | + $query_strategy_part = "label_id = ".$pdo->quote($label_id)." AND |
|
1629 | 1629 | ttrss_labels2.id = ttrss_user_labels2.label_id AND |
1630 | 1630 | ttrss_user_labels2.article_id = ref_id"; |
1631 | 1631 | |
1632 | - $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1633 | - $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,"; |
|
1634 | - $allow_archived = true; |
|
1632 | + $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
|
1633 | + $ext_tables_part = "ttrss_labels2,ttrss_user_labels2,"; |
|
1634 | + $allow_archived = true; |
|
1635 | 1635 | |
1636 | - } else { |
|
1637 | - $query_strategy_part = "true"; |
|
1638 | - } |
|
1636 | + } else { |
|
1637 | + $query_strategy_part = "true"; |
|
1638 | + } |
|
1639 | 1639 | |
1640 | - $order_by = "score DESC, date_entered DESC, updated DESC"; |
|
1640 | + $order_by = "score DESC, date_entered DESC, updated DESC"; |
|
1641 | 1641 | |
1642 | - if ($override_order) { |
|
1643 | - $order_by = $override_order; |
|
1644 | - } |
|
1642 | + if ($override_order) { |
|
1643 | + $order_by = $override_order; |
|
1644 | + } |
|
1645 | 1645 | |
1646 | - if ($override_strategy) { |
|
1647 | - $query_strategy_part = $override_strategy; |
|
1648 | - } |
|
1646 | + if ($override_strategy) { |
|
1647 | + $query_strategy_part = $override_strategy; |
|
1648 | + } |
|
1649 | 1649 | |
1650 | - if ($override_vfeed) { |
|
1651 | - $vfeed_query_part = $override_vfeed; |
|
1652 | - } |
|
1650 | + if ($override_vfeed) { |
|
1651 | + $vfeed_query_part = $override_vfeed; |
|
1652 | + } |
|
1653 | 1653 | |
1654 | - if ($search) { |
|
1655 | - $feed_title = T_sprintf("Search results: %s", $search); |
|
1656 | - } else { |
|
1657 | - if ($cat_view) { |
|
1658 | - $feed_title = Feeds::getCategoryTitle($feed); |
|
1659 | - } else { |
|
1660 | - if (is_numeric($feed) && $feed > 0) { |
|
1661 | - $ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated |
|
1654 | + if ($search) { |
|
1655 | + $feed_title = T_sprintf("Search results: %s", $search); |
|
1656 | + } else { |
|
1657 | + if ($cat_view) { |
|
1658 | + $feed_title = Feeds::getCategoryTitle($feed); |
|
1659 | + } else { |
|
1660 | + if (is_numeric($feed) && $feed > 0) { |
|
1661 | + $ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated |
|
1662 | 1662 | FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
1663 | - $ssth->execute([$feed, $owner_uid]); |
|
1663 | + $ssth->execute([$feed, $owner_uid]); |
|
1664 | 1664 | $row = $ssth->fetch(); |
1665 | 1665 | |
1666 | - $feed_title = $row["title"]; |
|
1667 | - $feed_site_url = $row["site_url"]; |
|
1668 | - $last_error = $row["last_error"]; |
|
1669 | - $last_updated = $row["last_updated"]; |
|
1670 | - } else { |
|
1671 | - $feed_title = Feeds::getFeedTitle($feed); |
|
1672 | - } |
|
1673 | - } |
|
1674 | - } |
|
1675 | - |
|
1676 | - $content_query_part = "content, "; |
|
1677 | - |
|
1678 | - if ($limit_query_part) { |
|
1679 | - $offset_query_part = "OFFSET " . (int)$offset; |
|
1680 | - } else { |
|
1681 | - $offset_query_part = ""; |
|
1682 | - } |
|
1683 | - |
|
1684 | - if ($start_ts) { |
|
1685 | - $start_ts_formatted = date("Y/m/d H:i:s", strtotime($start_ts)); |
|
1686 | - $start_ts_query_part = "date_entered >= '$start_ts_formatted' AND"; |
|
1687 | - } else { |
|
1688 | - $start_ts_query_part = ""; |
|
1689 | - } |
|
1690 | - |
|
1691 | - if (is_numeric($feed)) { |
|
1692 | - // proper override_order applied above |
|
1693 | - if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) { |
|
1694 | - |
|
1695 | - if (!(in_array($feed, Feeds::NEVER_GROUP_BY_DATE) && !$cat_view)) { |
|
1696 | - $yyiw_desc = $order_by == "date_reverse" ? "" : "desc"; |
|
1697 | - $yyiw_order_qpart = "yyiw $yyiw_desc, "; |
|
1698 | - } else { |
|
1699 | - $yyiw_order_qpart = ""; |
|
1700 | - } |
|
1701 | - |
|
1702 | - if (!$override_order) { |
|
1703 | - $order_by = "$yyiw_order_qpart ttrss_feeds.title, $order_by"; |
|
1704 | - } else { |
|
1705 | - $order_by = "$yyiw_order_qpart ttrss_feeds.title, $override_order"; |
|
1706 | - } |
|
1707 | - } |
|
1708 | - |
|
1709 | - if (!$allow_archived) { |
|
1710 | - $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id),ttrss_feeds"; |
|
1711 | - $feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND"; |
|
1712 | - |
|
1713 | - } else { |
|
1714 | - $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id) |
|
1666 | + $feed_title = $row["title"]; |
|
1667 | + $feed_site_url = $row["site_url"]; |
|
1668 | + $last_error = $row["last_error"]; |
|
1669 | + $last_updated = $row["last_updated"]; |
|
1670 | + } else { |
|
1671 | + $feed_title = Feeds::getFeedTitle($feed); |
|
1672 | + } |
|
1673 | + } |
|
1674 | + } |
|
1675 | + |
|
1676 | + $content_query_part = "content, "; |
|
1677 | + |
|
1678 | + if ($limit_query_part) { |
|
1679 | + $offset_query_part = "OFFSET " . (int)$offset; |
|
1680 | + } else { |
|
1681 | + $offset_query_part = ""; |
|
1682 | + } |
|
1683 | + |
|
1684 | + if ($start_ts) { |
|
1685 | + $start_ts_formatted = date("Y/m/d H:i:s", strtotime($start_ts)); |
|
1686 | + $start_ts_query_part = "date_entered >= '$start_ts_formatted' AND"; |
|
1687 | + } else { |
|
1688 | + $start_ts_query_part = ""; |
|
1689 | + } |
|
1690 | + |
|
1691 | + if (is_numeric($feed)) { |
|
1692 | + // proper override_order applied above |
|
1693 | + if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) { |
|
1694 | + |
|
1695 | + if (!(in_array($feed, Feeds::NEVER_GROUP_BY_DATE) && !$cat_view)) { |
|
1696 | + $yyiw_desc = $order_by == "date_reverse" ? "" : "desc"; |
|
1697 | + $yyiw_order_qpart = "yyiw $yyiw_desc, "; |
|
1698 | + } else { |
|
1699 | + $yyiw_order_qpart = ""; |
|
1700 | + } |
|
1701 | + |
|
1702 | + if (!$override_order) { |
|
1703 | + $order_by = "$yyiw_order_qpart ttrss_feeds.title, $order_by"; |
|
1704 | + } else { |
|
1705 | + $order_by = "$yyiw_order_qpart ttrss_feeds.title, $override_order"; |
|
1706 | + } |
|
1707 | + } |
|
1708 | + |
|
1709 | + if (!$allow_archived) { |
|
1710 | + $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id),ttrss_feeds"; |
|
1711 | + $feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND"; |
|
1712 | + |
|
1713 | + } else { |
|
1714 | + $from_qpart = "${ext_tables_part}ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id) |
|
1715 | 1715 | LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; |
1716 | - } |
|
1716 | + } |
|
1717 | 1717 | |
1718 | - if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,"; |
|
1718 | + if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,"; |
|
1719 | 1719 | |
1720 | - $first_id = 0; |
|
1721 | - $first_id_query_strategy_part = $query_strategy_part; |
|
1720 | + $first_id = 0; |
|
1721 | + $first_id_query_strategy_part = $query_strategy_part; |
|
1722 | 1722 | |
1723 | - if ($feed == -3) |
|
1724 | - $first_id_query_strategy_part = "true"; |
|
1723 | + if ($feed == -3) |
|
1724 | + $first_id_query_strategy_part = "true"; |
|
1725 | 1725 | |
1726 | - if (DB_TYPE == "pgsql") { |
|
1727 | - $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND"; |
|
1728 | - $yyiw_qpart = "to_char(date_entered, 'IYYY-IW') AS yyiw"; |
|
1729 | - } else { |
|
1730 | - $sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND"; |
|
1731 | - $yyiw_qpart = "date_format(date_entered, '%Y-%u') AS yyiw"; |
|
1732 | - } |
|
1726 | + if (DB_TYPE == "pgsql") { |
|
1727 | + $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND"; |
|
1728 | + $yyiw_qpart = "to_char(date_entered, 'IYYY-IW') AS yyiw"; |
|
1729 | + } else { |
|
1730 | + $sanity_interval_qpart = "date_entered >= DATE_SUB(NOW(), INTERVAL 1 hour) AND"; |
|
1731 | + $yyiw_qpart = "date_format(date_entered, '%Y-%u') AS yyiw"; |
|
1732 | + } |
|
1733 | 1733 | |
1734 | - if (!$search && !$skip_first_id_check) { |
|
1735 | - // if previous topmost article id changed that means our current pagination is no longer valid |
|
1736 | - $query = "SELECT DISTINCT |
|
1734 | + if (!$search && !$skip_first_id_check) { |
|
1735 | + // if previous topmost article id changed that means our current pagination is no longer valid |
|
1736 | + $query = "SELECT DISTINCT |
|
1737 | 1737 | ttrss_feeds.title, |
1738 | 1738 | date_entered, |
1739 | 1739 | $yyiw_qpart, |
@@ -1758,22 +1758,22 @@ discard block |
||
1758 | 1758 | $sanity_interval_qpart |
1759 | 1759 | $first_id_query_strategy_part ORDER BY $order_by LIMIT 1"; |
1760 | 1760 | |
1761 | - /*if ($_REQUEST["debug"]) { |
|
1761 | + /*if ($_REQUEST["debug"]) { |
|
1762 | 1762 | print $query; |
1763 | 1763 | }*/ |
1764 | 1764 | |
1765 | - $res = $pdo->query($query); |
|
1765 | + $res = $pdo->query($query); |
|
1766 | 1766 | |
1767 | - if ($row = $res->fetch()) { |
|
1768 | - $first_id = (int)$row["id"]; |
|
1767 | + if ($row = $res->fetch()) { |
|
1768 | + $first_id = (int)$row["id"]; |
|
1769 | 1769 | |
1770 | - if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) { |
|
1771 | - return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override); |
|
1772 | - } |
|
1773 | - } |
|
1774 | - } |
|
1770 | + if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) { |
|
1771 | + return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override); |
|
1772 | + } |
|
1773 | + } |
|
1774 | + } |
|
1775 | 1775 | |
1776 | - $query = "SELECT DISTINCT |
|
1776 | + $query = "SELECT DISTINCT |
|
1777 | 1777 | date_entered, |
1778 | 1778 | $yyiw_qpart, |
1779 | 1779 | guid, |
@@ -1807,14 +1807,14 @@ discard block |
||
1807 | 1807 | $query_strategy_part ORDER BY $order_by |
1808 | 1808 | $limit_query_part $offset_query_part"; |
1809 | 1809 | |
1810 | - //if ($_REQUEST["debug"]) print $query; |
|
1810 | + //if ($_REQUEST["debug"]) print $query; |
|
1811 | 1811 | |
1812 | - $res = $pdo->query($query); |
|
1812 | + $res = $pdo->query($query); |
|
1813 | 1813 | |
1814 | - } else { |
|
1815 | - // browsing by tag |
|
1814 | + } else { |
|
1815 | + // browsing by tag |
|
1816 | 1816 | |
1817 | - $query = "SELECT DISTINCT |
|
1817 | + $query = "SELECT DISTINCT |
|
1818 | 1818 | date_entered, |
1819 | 1819 | guid, |
1820 | 1820 | note, |
@@ -1853,63 +1853,63 @@ discard block |
||
1853 | 1853 | $query_strategy_part ORDER BY $order_by |
1854 | 1854 | $limit_query_part $offset_query_part"; |
1855 | 1855 | |
1856 | - if ($_REQUEST["debug"]) print $query; |
|
1856 | + if ($_REQUEST["debug"]) print $query; |
|
1857 | 1857 | |
1858 | - $res = $pdo->query($query); |
|
1859 | - } |
|
1858 | + $res = $pdo->query($query); |
|
1859 | + } |
|
1860 | 1860 | |
1861 | - return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override); |
|
1861 | + return array($res, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override); |
|
1862 | 1862 | |
1863 | - } |
|
1863 | + } |
|
1864 | 1864 | |
1865 | - public static function getParentCategories($cat, $owner_uid) { |
|
1866 | - $rv = array(); |
|
1865 | + public static function getParentCategories($cat, $owner_uid) { |
|
1866 | + $rv = array(); |
|
1867 | 1867 | |
1868 | - $pdo = Db::pdo(); |
|
1868 | + $pdo = Db::pdo(); |
|
1869 | 1869 | |
1870 | - $sth = $pdo->prepare("SELECT parent_cat FROM ttrss_feed_categories |
|
1870 | + $sth = $pdo->prepare("SELECT parent_cat FROM ttrss_feed_categories |
|
1871 | 1871 | WHERE id = ? AND parent_cat IS NOT NULL AND owner_uid = ?"); |
1872 | - $sth->execute([$cat, $owner_uid]); |
|
1872 | + $sth->execute([$cat, $owner_uid]); |
|
1873 | 1873 | |
1874 | - while ($line = $sth->fetch()) { |
|
1875 | - array_push($rv, $line["parent_cat"]); |
|
1876 | - $rv = array_merge($rv, Feeds::getParentCategories($line["parent_cat"], $owner_uid)); |
|
1877 | - } |
|
1874 | + while ($line = $sth->fetch()) { |
|
1875 | + array_push($rv, $line["parent_cat"]); |
|
1876 | + $rv = array_merge($rv, Feeds::getParentCategories($line["parent_cat"], $owner_uid)); |
|
1877 | + } |
|
1878 | 1878 | |
1879 | - return $rv; |
|
1880 | - } |
|
1879 | + return $rv; |
|
1880 | + } |
|
1881 | 1881 | |
1882 | - public static function getChildCategories($cat, $owner_uid) { |
|
1883 | - $rv = array(); |
|
1882 | + public static function getChildCategories($cat, $owner_uid) { |
|
1883 | + $rv = array(); |
|
1884 | 1884 | |
1885 | - $pdo = Db::pdo(); |
|
1885 | + $pdo = Db::pdo(); |
|
1886 | 1886 | |
1887 | - $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories |
|
1887 | + $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories |
|
1888 | 1888 | WHERE parent_cat = ? AND owner_uid = ?"); |
1889 | - $sth->execute([$cat, $owner_uid]); |
|
1889 | + $sth->execute([$cat, $owner_uid]); |
|
1890 | 1890 | |
1891 | - while ($line = $sth->fetch()) { |
|
1892 | - array_push($rv, $line["id"]); |
|
1893 | - $rv = array_merge($rv, Feeds::getChildCategories($line["id"], $owner_uid)); |
|
1894 | - } |
|
1891 | + while ($line = $sth->fetch()) { |
|
1892 | + array_push($rv, $line["id"]); |
|
1893 | + $rv = array_merge($rv, Feeds::getChildCategories($line["id"], $owner_uid)); |
|
1894 | + } |
|
1895 | 1895 | |
1896 | - return $rv; |
|
1897 | - } |
|
1896 | + return $rv; |
|
1897 | + } |
|
1898 | 1898 | |
1899 | - public static function getFeedCategory($feed) { |
|
1900 | - $pdo = Db::pdo(); |
|
1899 | + public static function getFeedCategory($feed) { |
|
1900 | + $pdo = Db::pdo(); |
|
1901 | 1901 | |
1902 | - $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds |
|
1902 | + $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds |
|
1903 | 1903 | WHERE id = ?"); |
1904 | - $sth->execute([$feed]); |
|
1904 | + $sth->execute([$feed]); |
|
1905 | 1905 | |
1906 | - if ($row = $sth->fetch()) { |
|
1907 | - return $row["cat_id"]; |
|
1908 | - } else { |
|
1909 | - return false; |
|
1910 | - } |
|
1906 | + if ($row = $sth->fetch()) { |
|
1907 | + return $row["cat_id"]; |
|
1908 | + } else { |
|
1909 | + return false; |
|
1910 | + } |
|
1911 | 1911 | |
1912 | - } |
|
1912 | + } |
|
1913 | 1913 | |
1914 | 1914 | function color_of($name) { |
1915 | 1915 | $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
@@ -1925,402 +1925,402 @@ discard block |
||
1925 | 1925 | $sum %= count($colormap); |
1926 | 1926 | |
1927 | 1927 | return $colormap[$sum]; |
1928 | - } |
|
1929 | - |
|
1930 | - public static function get_feeds_from_html($url, $content) { |
|
1931 | - $url = Feeds::fix_url($url); |
|
1932 | - $baseUrl = substr($url, 0, strrpos($url, '/') + 1); |
|
1933 | - |
|
1934 | - $feedUrls = []; |
|
1935 | - |
|
1936 | - $doc = new DOMDocument(); |
|
1937 | - if ($doc->loadHTML($content)) { |
|
1938 | - $xpath = new DOMXPath($doc); |
|
1939 | - $entries = $xpath->query('/html/head/link[@rel="alternate" and '. |
|
1940 | - '(contains(@type,"rss") or contains(@type,"atom"))]|/html/head/link[@rel="feed"]'); |
|
1941 | - |
|
1942 | - foreach ($entries as $entry) { |
|
1943 | - if ($entry->hasAttribute('href')) { |
|
1944 | - $title = $entry->getAttribute('title'); |
|
1945 | - if ($title == '') { |
|
1946 | - $title = $entry->getAttribute('type'); |
|
1947 | - } |
|
1948 | - $feedUrl = rewrite_relative_url( |
|
1949 | - $baseUrl, $entry->getAttribute('href') |
|
1950 | - ); |
|
1951 | - $feedUrls[$feedUrl] = $title; |
|
1952 | - } |
|
1953 | - } |
|
1954 | - } |
|
1955 | - return $feedUrls; |
|
1956 | - } |
|
1957 | - |
|
1958 | - public static function is_html($content) { |
|
1959 | - return preg_match("/<html|DOCTYPE html/i", substr($content, 0, 8192)) !== 0; |
|
1960 | - } |
|
1961 | - |
|
1962 | - public static function validate_feed_url($url) { |
|
1963 | - $parts = parse_url($url); |
|
1964 | - |
|
1965 | - return ($parts['scheme'] == 'http' || $parts['scheme'] == 'feed' || $parts['scheme'] == 'https'); |
|
1966 | - } |
|
1967 | - |
|
1968 | - /** |
|
1969 | - * Fixes incomplete URLs by prepending "http://". |
|
1970 | - * Also replaces feed:// with http://, and |
|
1971 | - * prepends a trailing slash if the url is a domain name only. |
|
1972 | - * |
|
1973 | - * @param string $url Possibly incomplete URL |
|
1974 | - * |
|
1975 | - * @return string Fixed URL. |
|
1976 | - */ |
|
1977 | - public static function fix_url($url) { |
|
1978 | - |
|
1979 | - // support schema-less urls |
|
1980 | - if (strpos($url, '//') === 0) { |
|
1981 | - $url = 'https:' . $url; |
|
1982 | - } |
|
1983 | - |
|
1984 | - if (strpos($url, '://') === false) { |
|
1985 | - $url = 'http://' . $url; |
|
1986 | - } else if (substr($url, 0, 5) == 'feed:') { |
|
1987 | - $url = 'http:' . substr($url, 5); |
|
1988 | - } |
|
1989 | - |
|
1990 | - //prepend slash if the URL has no slash in it |
|
1991 | - // "http://www.example" -> "http://www.example/" |
|
1992 | - if (strpos($url, '/', strpos($url, ':') + 3) === false) { |
|
1993 | - $url .= '/'; |
|
1994 | - } |
|
1995 | - |
|
1996 | - //convert IDNA hostname to punycode if possible |
|
1997 | - if (function_exists("idn_to_ascii")) { |
|
1998 | - $parts = parse_url($url); |
|
1999 | - if (mb_detect_encoding($parts['host']) != 'ASCII') |
|
2000 | - { |
|
2001 | - $parts['host'] = idn_to_ascii($parts['host']); |
|
2002 | - $url = build_url($parts); |
|
2003 | - } |
|
2004 | - } |
|
2005 | - |
|
2006 | - if ($url != "http:///") |
|
2007 | - return $url; |
|
2008 | - else |
|
2009 | - return ''; |
|
2010 | - } |
|
2011 | - |
|
2012 | - public static function add_feed_category($feed_cat, $parent_cat_id = false, $order_id = 0) { |
|
2013 | - |
|
2014 | - if (!$feed_cat) return false; |
|
2015 | - |
|
2016 | - $feed_cat = mb_substr($feed_cat, 0, 250); |
|
2017 | - if (!$parent_cat_id) $parent_cat_id = null; |
|
2018 | - |
|
2019 | - $pdo = Db::pdo(); |
|
2020 | - $tr_in_progress = false; |
|
2021 | - |
|
2022 | - try { |
|
2023 | - $pdo->beginTransaction(); |
|
2024 | - } catch (Exception $e) { |
|
2025 | - $tr_in_progress = true; |
|
2026 | - } |
|
2027 | - |
|
2028 | - $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories |
|
1928 | + } |
|
1929 | + |
|
1930 | + public static function get_feeds_from_html($url, $content) { |
|
1931 | + $url = Feeds::fix_url($url); |
|
1932 | + $baseUrl = substr($url, 0, strrpos($url, '/') + 1); |
|
1933 | + |
|
1934 | + $feedUrls = []; |
|
1935 | + |
|
1936 | + $doc = new DOMDocument(); |
|
1937 | + if ($doc->loadHTML($content)) { |
|
1938 | + $xpath = new DOMXPath($doc); |
|
1939 | + $entries = $xpath->query('/html/head/link[@rel="alternate" and '. |
|
1940 | + '(contains(@type,"rss") or contains(@type,"atom"))]|/html/head/link[@rel="feed"]'); |
|
1941 | + |
|
1942 | + foreach ($entries as $entry) { |
|
1943 | + if ($entry->hasAttribute('href')) { |
|
1944 | + $title = $entry->getAttribute('title'); |
|
1945 | + if ($title == '') { |
|
1946 | + $title = $entry->getAttribute('type'); |
|
1947 | + } |
|
1948 | + $feedUrl = rewrite_relative_url( |
|
1949 | + $baseUrl, $entry->getAttribute('href') |
|
1950 | + ); |
|
1951 | + $feedUrls[$feedUrl] = $title; |
|
1952 | + } |
|
1953 | + } |
|
1954 | + } |
|
1955 | + return $feedUrls; |
|
1956 | + } |
|
1957 | + |
|
1958 | + public static function is_html($content) { |
|
1959 | + return preg_match("/<html|DOCTYPE html/i", substr($content, 0, 8192)) !== 0; |
|
1960 | + } |
|
1961 | + |
|
1962 | + public static function validate_feed_url($url) { |
|
1963 | + $parts = parse_url($url); |
|
1964 | + |
|
1965 | + return ($parts['scheme'] == 'http' || $parts['scheme'] == 'feed' || $parts['scheme'] == 'https'); |
|
1966 | + } |
|
1967 | + |
|
1968 | + /** |
|
1969 | + * Fixes incomplete URLs by prepending "http://". |
|
1970 | + * Also replaces feed:// with http://, and |
|
1971 | + * prepends a trailing slash if the url is a domain name only. |
|
1972 | + * |
|
1973 | + * @param string $url Possibly incomplete URL |
|
1974 | + * |
|
1975 | + * @return string Fixed URL. |
|
1976 | + */ |
|
1977 | + public static function fix_url($url) { |
|
1978 | + |
|
1979 | + // support schema-less urls |
|
1980 | + if (strpos($url, '//') === 0) { |
|
1981 | + $url = 'https:' . $url; |
|
1982 | + } |
|
1983 | + |
|
1984 | + if (strpos($url, '://') === false) { |
|
1985 | + $url = 'http://' . $url; |
|
1986 | + } else if (substr($url, 0, 5) == 'feed:') { |
|
1987 | + $url = 'http:' . substr($url, 5); |
|
1988 | + } |
|
1989 | + |
|
1990 | + //prepend slash if the URL has no slash in it |
|
1991 | + // "http://www.example" -> "http://www.example/" |
|
1992 | + if (strpos($url, '/', strpos($url, ':') + 3) === false) { |
|
1993 | + $url .= '/'; |
|
1994 | + } |
|
1995 | + |
|
1996 | + //convert IDNA hostname to punycode if possible |
|
1997 | + if (function_exists("idn_to_ascii")) { |
|
1998 | + $parts = parse_url($url); |
|
1999 | + if (mb_detect_encoding($parts['host']) != 'ASCII') |
|
2000 | + { |
|
2001 | + $parts['host'] = idn_to_ascii($parts['host']); |
|
2002 | + $url = build_url($parts); |
|
2003 | + } |
|
2004 | + } |
|
2005 | + |
|
2006 | + if ($url != "http:///") |
|
2007 | + return $url; |
|
2008 | + else |
|
2009 | + return ''; |
|
2010 | + } |
|
2011 | + |
|
2012 | + public static function add_feed_category($feed_cat, $parent_cat_id = false, $order_id = 0) { |
|
2013 | + |
|
2014 | + if (!$feed_cat) return false; |
|
2015 | + |
|
2016 | + $feed_cat = mb_substr($feed_cat, 0, 250); |
|
2017 | + if (!$parent_cat_id) $parent_cat_id = null; |
|
2018 | + |
|
2019 | + $pdo = Db::pdo(); |
|
2020 | + $tr_in_progress = false; |
|
2021 | + |
|
2022 | + try { |
|
2023 | + $pdo->beginTransaction(); |
|
2024 | + } catch (Exception $e) { |
|
2025 | + $tr_in_progress = true; |
|
2026 | + } |
|
2027 | + |
|
2028 | + $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories |
|
2029 | 2029 | WHERE (parent_cat = :parent OR (:parent IS NULL AND parent_cat IS NULL)) |
2030 | 2030 | AND title = :title AND owner_uid = :uid"); |
2031 | - $sth->execute([':parent' => $parent_cat_id, ':title' => $feed_cat, ':uid' => $_SESSION['uid']]); |
|
2031 | + $sth->execute([':parent' => $parent_cat_id, ':title' => $feed_cat, ':uid' => $_SESSION['uid']]); |
|
2032 | 2032 | |
2033 | - if (!$sth->fetch()) { |
|
2033 | + if (!$sth->fetch()) { |
|
2034 | 2034 | |
2035 | - $sth = $pdo->prepare("INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat,order_id) |
|
2035 | + $sth = $pdo->prepare("INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat,order_id) |
|
2036 | 2036 | VALUES (?, ?, ?, ?)"); |
2037 | - $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int)$order_id]); |
|
2037 | + $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int)$order_id]); |
|
2038 | 2038 | |
2039 | - if (!$tr_in_progress) $pdo->commit(); |
|
2039 | + if (!$tr_in_progress) $pdo->commit(); |
|
2040 | 2040 | |
2041 | - return true; |
|
2042 | - } |
|
2041 | + return true; |
|
2042 | + } |
|
2043 | 2043 | |
2044 | - $pdo->commit(); |
|
2044 | + $pdo->commit(); |
|
2045 | 2045 | |
2046 | - return false; |
|
2047 | - } |
|
2046 | + return false; |
|
2047 | + } |
|
2048 | 2048 | |
2049 | - public static function get_feed_access_key($feed_id, $is_cat, $owner_uid = false) { |
|
2049 | + public static function get_feed_access_key($feed_id, $is_cat, $owner_uid = false) { |
|
2050 | 2050 | |
2051 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
2051 | + if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
2052 | 2052 | |
2053 | - $is_cat = bool_to_sql_bool($is_cat); |
|
2053 | + $is_cat = bool_to_sql_bool($is_cat); |
|
2054 | 2054 | |
2055 | - $pdo = Db::pdo(); |
|
2055 | + $pdo = Db::pdo(); |
|
2056 | 2056 | |
2057 | - $sth = $pdo->prepare("SELECT access_key FROM ttrss_access_keys |
|
2057 | + $sth = $pdo->prepare("SELECT access_key FROM ttrss_access_keys |
|
2058 | 2058 | WHERE feed_id = ? AND is_cat = ? |
2059 | 2059 | AND owner_uid = ?"); |
2060 | - $sth->execute([$feed_id, $is_cat, $owner_uid]); |
|
2060 | + $sth->execute([$feed_id, $is_cat, $owner_uid]); |
|
2061 | 2061 | |
2062 | - if ($row = $sth->fetch()) { |
|
2063 | - return $row["access_key"]; |
|
2064 | - } else { |
|
2065 | - $key = uniqid_short(); |
|
2062 | + if ($row = $sth->fetch()) { |
|
2063 | + return $row["access_key"]; |
|
2064 | + } else { |
|
2065 | + $key = uniqid_short(); |
|
2066 | 2066 | |
2067 | - $sth = $pdo->prepare("INSERT INTO ttrss_access_keys |
|
2067 | + $sth = $pdo->prepare("INSERT INTO ttrss_access_keys |
|
2068 | 2068 | (access_key, feed_id, is_cat, owner_uid) |
2069 | 2069 | VALUES (?, ?, ?, ?)"); |
2070 | 2070 | |
2071 | - $sth->execute([$key, $feed_id, $is_cat, $owner_uid]); |
|
2071 | + $sth->execute([$key, $feed_id, $is_cat, $owner_uid]); |
|
2072 | 2072 | |
2073 | - return $key; |
|
2074 | - } |
|
2075 | - } |
|
2073 | + return $key; |
|
2074 | + } |
|
2075 | + } |
|
2076 | 2076 | |
2077 | - /** |
|
2078 | - * Purge a feed old posts. |
|
2079 | - * |
|
2080 | - * @param mixed $link A database connection. |
|
2081 | - * @param mixed $feed_id The id of the purged feed. |
|
2082 | - * @param mixed $purge_interval Olderness of purged posts. |
|
2083 | - * @param boolean $debug Set to True to enable the debug. False by default. |
|
2084 | - * @access public |
|
2085 | - * @return void |
|
2086 | - */ |
|
2087 | - public static function purge_feed($feed_id, $purge_interval) { |
|
2077 | + /** |
|
2078 | + * Purge a feed old posts. |
|
2079 | + * |
|
2080 | + * @param mixed $link A database connection. |
|
2081 | + * @param mixed $feed_id The id of the purged feed. |
|
2082 | + * @param mixed $purge_interval Olderness of purged posts. |
|
2083 | + * @param boolean $debug Set to True to enable the debug. False by default. |
|
2084 | + * @access public |
|
2085 | + * @return void |
|
2086 | + */ |
|
2087 | + public static function purge_feed($feed_id, $purge_interval) { |
|
2088 | 2088 | |
2089 | - if (!$purge_interval) $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
2089 | + if (!$purge_interval) $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
2090 | 2090 | |
2091 | - $pdo = Db::pdo(); |
|
2091 | + $pdo = Db::pdo(); |
|
2092 | 2092 | |
2093 | - $sth = $pdo->prepare("SELECT owner_uid FROM ttrss_feeds WHERE id = ?"); |
|
2094 | - $sth->execute([$feed_id]); |
|
2093 | + $sth = $pdo->prepare("SELECT owner_uid FROM ttrss_feeds WHERE id = ?"); |
|
2094 | + $sth->execute([$feed_id]); |
|
2095 | 2095 | |
2096 | - $owner_uid = false; |
|
2096 | + $owner_uid = false; |
|
2097 | 2097 | |
2098 | - if ($row = $sth->fetch()) { |
|
2099 | - $owner_uid = $row["owner_uid"]; |
|
2100 | - } |
|
2098 | + if ($row = $sth->fetch()) { |
|
2099 | + $owner_uid = $row["owner_uid"]; |
|
2100 | + } |
|
2101 | 2101 | |
2102 | - if ($purge_interval == -1 || !$purge_interval) { |
|
2103 | - if ($owner_uid) { |
|
2104 | - CCache::update($feed_id, $owner_uid); |
|
2105 | - } |
|
2106 | - return; |
|
2107 | - } |
|
2102 | + if ($purge_interval == -1 || !$purge_interval) { |
|
2103 | + if ($owner_uid) { |
|
2104 | + CCache::update($feed_id, $owner_uid); |
|
2105 | + } |
|
2106 | + return; |
|
2107 | + } |
|
2108 | 2108 | |
2109 | - if (!$owner_uid) return; |
|
2109 | + if (!$owner_uid) return; |
|
2110 | 2110 | |
2111 | - if (FORCE_ARTICLE_PURGE == 0) { |
|
2112 | - $purge_unread = get_pref("PURGE_UNREAD_ARTICLES", |
|
2113 | - $owner_uid, false); |
|
2114 | - } else { |
|
2115 | - $purge_unread = true; |
|
2116 | - $purge_interval = FORCE_ARTICLE_PURGE; |
|
2117 | - } |
|
2111 | + if (FORCE_ARTICLE_PURGE == 0) { |
|
2112 | + $purge_unread = get_pref("PURGE_UNREAD_ARTICLES", |
|
2113 | + $owner_uid, false); |
|
2114 | + } else { |
|
2115 | + $purge_unread = true; |
|
2116 | + $purge_interval = FORCE_ARTICLE_PURGE; |
|
2117 | + } |
|
2118 | 2118 | |
2119 | - if (!$purge_unread) |
|
2120 | - $query_limit = " unread = false AND "; |
|
2121 | - else |
|
2122 | - $query_limit = ""; |
|
2119 | + if (!$purge_unread) |
|
2120 | + $query_limit = " unread = false AND "; |
|
2121 | + else |
|
2122 | + $query_limit = ""; |
|
2123 | 2123 | |
2124 | - $purge_interval = (int) $purge_interval; |
|
2124 | + $purge_interval = (int) $purge_interval; |
|
2125 | 2125 | |
2126 | - if (DB_TYPE == "pgsql") { |
|
2127 | - $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
2126 | + if (DB_TYPE == "pgsql") { |
|
2127 | + $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
2128 | 2128 | USING ttrss_entries |
2129 | 2129 | WHERE ttrss_entries.id = ref_id AND |
2130 | 2130 | marked = false AND |
2131 | 2131 | feed_id = ? AND |
2132 | 2132 | $query_limit |
2133 | 2133 | ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'"); |
2134 | - $sth->execute([$feed_id]); |
|
2134 | + $sth->execute([$feed_id]); |
|
2135 | 2135 | |
2136 | - } else { |
|
2137 | - $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
2136 | + } else { |
|
2137 | + $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
2138 | 2138 | USING ttrss_user_entries, ttrss_entries |
2139 | 2139 | WHERE ttrss_entries.id = ref_id AND |
2140 | 2140 | marked = false AND |
2141 | 2141 | feed_id = ? AND |
2142 | 2142 | $query_limit |
2143 | 2143 | ttrss_entries.date_updated < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)"); |
2144 | - $sth->execute([$feed_id]); |
|
2144 | + $sth->execute([$feed_id]); |
|
2145 | 2145 | |
2146 | - } |
|
2146 | + } |
|
2147 | 2147 | |
2148 | - $rows = $sth->rowCount(); |
|
2148 | + $rows = $sth->rowCount(); |
|
2149 | 2149 | |
2150 | - CCache::update($feed_id, $owner_uid); |
|
2150 | + CCache::update($feed_id, $owner_uid); |
|
2151 | 2151 | |
2152 | - Debug::log("Purged feed $feed_id ($purge_interval): deleted $rows articles"); |
|
2152 | + Debug::log("Purged feed $feed_id ($purge_interval): deleted $rows articles"); |
|
2153 | 2153 | |
2154 | - return $rows; |
|
2155 | - } |
|
2154 | + return $rows; |
|
2155 | + } |
|
2156 | 2156 | |
2157 | - public static function feed_purge_interval($feed_id) { |
|
2157 | + public static function feed_purge_interval($feed_id) { |
|
2158 | 2158 | |
2159 | - $pdo = DB::pdo(); |
|
2159 | + $pdo = DB::pdo(); |
|
2160 | 2160 | |
2161 | - $sth = $pdo->prepare("SELECT purge_interval, owner_uid FROM ttrss_feeds |
|
2161 | + $sth = $pdo->prepare("SELECT purge_interval, owner_uid FROM ttrss_feeds |
|
2162 | 2162 | WHERE id = ?"); |
2163 | - $sth->execute([$feed_id]); |
|
2164 | - |
|
2165 | - if ($row = $sth->fetch()) { |
|
2166 | - $purge_interval = $row["purge_interval"]; |
|
2167 | - $owner_uid = $row["owner_uid"]; |
|
2168 | - |
|
2169 | - if ($purge_interval == 0) $purge_interval = get_pref( |
|
2170 | - 'PURGE_OLD_DAYS', $owner_uid); |
|
2171 | - |
|
2172 | - return $purge_interval; |
|
2173 | - |
|
2174 | - } else { |
|
2175 | - return -1; |
|
2176 | - } |
|
2177 | - } |
|
2163 | + $sth->execute([$feed_id]); |
|
2178 | 2164 | |
2179 | - public static function search_to_sql($search, $search_language) { |
|
2165 | + if ($row = $sth->fetch()) { |
|
2166 | + $purge_interval = $row["purge_interval"]; |
|
2167 | + $owner_uid = $row["owner_uid"]; |
|
2180 | 2168 | |
2181 | - $keywords = str_getcsv(trim($search), " "); |
|
2182 | - $query_keywords = array(); |
|
2183 | - $search_words = array(); |
|
2184 | - $search_query_leftover = array(); |
|
2169 | + if ($purge_interval == 0) $purge_interval = get_pref( |
|
2170 | + 'PURGE_OLD_DAYS', $owner_uid); |
|
2185 | 2171 | |
2186 | - $pdo = Db::pdo(); |
|
2172 | + return $purge_interval; |
|
2187 | 2173 | |
2188 | - if ($search_language) |
|
2189 | - $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
2190 | - else |
|
2191 | - $search_language = $pdo->quote("english"); |
|
2192 | - |
|
2193 | - foreach ($keywords as $k) { |
|
2194 | - if (strpos($k, "-") === 0) { |
|
2195 | - $k = substr($k, 1); |
|
2196 | - $not = "NOT"; |
|
2197 | - } else { |
|
2198 | - $not = ""; |
|
2199 | - } |
|
2200 | - |
|
2201 | - $commandpair = explode(":", mb_strtolower($k), 2); |
|
2202 | - |
|
2203 | - switch ($commandpair[0]) { |
|
2204 | - case "title": |
|
2205 | - if ($commandpair[1]) { |
|
2206 | - array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
|
2207 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
2208 | - } else { |
|
2209 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2174 | + } else { |
|
2175 | + return -1; |
|
2176 | + } |
|
2177 | + } |
|
2178 | + |
|
2179 | + public static function search_to_sql($search, $search_language) { |
|
2180 | + |
|
2181 | + $keywords = str_getcsv(trim($search), " "); |
|
2182 | + $query_keywords = array(); |
|
2183 | + $search_words = array(); |
|
2184 | + $search_query_leftover = array(); |
|
2185 | + |
|
2186 | + $pdo = Db::pdo(); |
|
2187 | + |
|
2188 | + if ($search_language) |
|
2189 | + $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
2190 | + else |
|
2191 | + $search_language = $pdo->quote("english"); |
|
2192 | + |
|
2193 | + foreach ($keywords as $k) { |
|
2194 | + if (strpos($k, "-") === 0) { |
|
2195 | + $k = substr($k, 1); |
|
2196 | + $not = "NOT"; |
|
2197 | + } else { |
|
2198 | + $not = ""; |
|
2199 | + } |
|
2200 | + |
|
2201 | + $commandpair = explode(":", mb_strtolower($k), 2); |
|
2202 | + |
|
2203 | + switch ($commandpair[0]) { |
|
2204 | + case "title": |
|
2205 | + if ($commandpair[1]) { |
|
2206 | + array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
|
2207 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
2208 | + } else { |
|
2209 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2210 | 2210 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2211 | - array_push($search_words, $k); |
|
2212 | - } |
|
2213 | - break; |
|
2214 | - case "author": |
|
2215 | - if ($commandpair[1]) { |
|
2216 | - array_push($query_keywords, "($not (LOWER(author) LIKE ". |
|
2217 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2218 | - } else { |
|
2219 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2211 | + array_push($search_words, $k); |
|
2212 | + } |
|
2213 | + break; |
|
2214 | + case "author": |
|
2215 | + if ($commandpair[1]) { |
|
2216 | + array_push($query_keywords, "($not (LOWER(author) LIKE ". |
|
2217 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2218 | + } else { |
|
2219 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2220 | 2220 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2221 | - array_push($search_words, $k); |
|
2222 | - } |
|
2223 | - break; |
|
2224 | - case "note": |
|
2225 | - if ($commandpair[1]) { |
|
2226 | - if ($commandpair[1] == "true") |
|
2227 | - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2228 | - else if ($commandpair[1] == "false") |
|
2229 | - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2230 | - else |
|
2231 | - array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2232 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2233 | - } else { |
|
2234 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2221 | + array_push($search_words, $k); |
|
2222 | + } |
|
2223 | + break; |
|
2224 | + case "note": |
|
2225 | + if ($commandpair[1]) { |
|
2226 | + if ($commandpair[1] == "true") |
|
2227 | + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2228 | + else if ($commandpair[1] == "false") |
|
2229 | + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2230 | + else |
|
2231 | + array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2232 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
2233 | + } else { |
|
2234 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2235 | 2235 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2236 | - if (!$not) array_push($search_words, $k); |
|
2237 | - } |
|
2238 | - break; |
|
2239 | - case "star": |
|
2240 | - |
|
2241 | - if ($commandpair[1]) { |
|
2242 | - if ($commandpair[1] == "true") |
|
2243 | - array_push($query_keywords, "($not (marked = true))"); |
|
2244 | - else |
|
2245 | - array_push($query_keywords, "($not (marked = false))"); |
|
2246 | - } else { |
|
2247 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2236 | + if (!$not) array_push($search_words, $k); |
|
2237 | + } |
|
2238 | + break; |
|
2239 | + case "star": |
|
2240 | + |
|
2241 | + if ($commandpair[1]) { |
|
2242 | + if ($commandpair[1] == "true") |
|
2243 | + array_push($query_keywords, "($not (marked = true))"); |
|
2244 | + else |
|
2245 | + array_push($query_keywords, "($not (marked = false))"); |
|
2246 | + } else { |
|
2247 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2248 | 2248 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2249 | - if (!$not) array_push($search_words, $k); |
|
2250 | - } |
|
2251 | - break; |
|
2252 | - case "pub": |
|
2253 | - if ($commandpair[1]) { |
|
2254 | - if ($commandpair[1] == "true") |
|
2255 | - array_push($query_keywords, "($not (published = true))"); |
|
2256 | - else |
|
2257 | - array_push($query_keywords, "($not (published = false))"); |
|
2258 | - |
|
2259 | - } else { |
|
2260 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2249 | + if (!$not) array_push($search_words, $k); |
|
2250 | + } |
|
2251 | + break; |
|
2252 | + case "pub": |
|
2253 | + if ($commandpair[1]) { |
|
2254 | + if ($commandpair[1] == "true") |
|
2255 | + array_push($query_keywords, "($not (published = true))"); |
|
2256 | + else |
|
2257 | + array_push($query_keywords, "($not (published = false))"); |
|
2258 | + |
|
2259 | + } else { |
|
2260 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
2261 | 2261 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2262 | - if (!$not) array_push($search_words, $k); |
|
2263 | - } |
|
2264 | - break; |
|
2265 | - case "unread": |
|
2266 | - if ($commandpair[1]) { |
|
2267 | - if ($commandpair[1] == "true") |
|
2268 | - array_push($query_keywords, "($not (unread = true))"); |
|
2269 | - else |
|
2270 | - array_push($query_keywords, "($not (unread = false))"); |
|
2271 | - |
|
2272 | - } else { |
|
2273 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2262 | + if (!$not) array_push($search_words, $k); |
|
2263 | + } |
|
2264 | + break; |
|
2265 | + case "unread": |
|
2266 | + if ($commandpair[1]) { |
|
2267 | + if ($commandpair[1] == "true") |
|
2268 | + array_push($query_keywords, "($not (unread = true))"); |
|
2269 | + else |
|
2270 | + array_push($query_keywords, "($not (unread = false))"); |
|
2271 | + |
|
2272 | + } else { |
|
2273 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2274 | 2274 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2275 | - if (!$not) array_push($search_words, $k); |
|
2276 | - } |
|
2277 | - break; |
|
2278 | - default: |
|
2279 | - if (strpos($k, "@") === 0) { |
|
2280 | - |
|
2281 | - $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); |
|
2282 | - $orig_ts = strtotime(substr($k, 1)); |
|
2283 | - $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); |
|
2284 | - |
|
2285 | - //$k = date("Y-m-d", strtotime(substr($k, 1))); |
|
2286 | - |
|
2287 | - array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); |
|
2288 | - } else { |
|
2289 | - |
|
2290 | - if (DB_TYPE == "pgsql") { |
|
2291 | - $k = mb_strtolower($k); |
|
2292 | - array_push($search_query_leftover, $not ? "!$k" : $k); |
|
2293 | - } else { |
|
2294 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2275 | + if (!$not) array_push($search_words, $k); |
|
2276 | + } |
|
2277 | + break; |
|
2278 | + default: |
|
2279 | + if (strpos($k, "@") === 0) { |
|
2280 | + |
|
2281 | + $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); |
|
2282 | + $orig_ts = strtotime(substr($k, 1)); |
|
2283 | + $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); |
|
2284 | + |
|
2285 | + //$k = date("Y-m-d", strtotime(substr($k, 1))); |
|
2286 | + |
|
2287 | + array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); |
|
2288 | + } else { |
|
2289 | + |
|
2290 | + if (DB_TYPE == "pgsql") { |
|
2291 | + $k = mb_strtolower($k); |
|
2292 | + array_push($search_query_leftover, $not ? "!$k" : $k); |
|
2293 | + } else { |
|
2294 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
2295 | 2295 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2296 | - } |
|
2296 | + } |
|
2297 | 2297 | |
2298 | - if (!$not) array_push($search_words, $k); |
|
2299 | - } |
|
2300 | - } |
|
2301 | - } |
|
2298 | + if (!$not) array_push($search_words, $k); |
|
2299 | + } |
|
2300 | + } |
|
2301 | + } |
|
2302 | 2302 | |
2303 | - if (count($search_query_leftover) > 0) { |
|
2303 | + if (count($search_query_leftover) > 0) { |
|
2304 | 2304 | |
2305 | - if (DB_TYPE == "pgsql") { |
|
2305 | + if (DB_TYPE == "pgsql") { |
|
2306 | 2306 | |
2307 | - // if there's no joiners consider this a "simple" search and |
|
2308 | - // concatenate everything with &, otherwise don't try to mess with tsquery syntax |
|
2309 | - if (preg_match("/[&|]/", implode(" " , $search_query_leftover))) { |
|
2310 | - $tsquery = $pdo->quote(implode(" ", $search_query_leftover)); |
|
2311 | - } else { |
|
2312 | - $tsquery = $pdo->quote(implode(" & ", $search_query_leftover)); |
|
2313 | - } |
|
2307 | + // if there's no joiners consider this a "simple" search and |
|
2308 | + // concatenate everything with &, otherwise don't try to mess with tsquery syntax |
|
2309 | + if (preg_match("/[&|]/", implode(" " , $search_query_leftover))) { |
|
2310 | + $tsquery = $pdo->quote(implode(" ", $search_query_leftover)); |
|
2311 | + } else { |
|
2312 | + $tsquery = $pdo->quote(implode(" & ", $search_query_leftover)); |
|
2313 | + } |
|
2314 | 2314 | |
2315 | - array_push($query_keywords, |
|
2316 | - "(tsvector_combined @@ to_tsquery($search_language, $tsquery))"); |
|
2317 | - } |
|
2315 | + array_push($query_keywords, |
|
2316 | + "(tsvector_combined @@ to_tsquery($search_language, $tsquery))"); |
|
2317 | + } |
|
2318 | 2318 | |
2319 | - } |
|
2319 | + } |
|
2320 | 2320 | |
2321 | - $search_query_part = implode("AND", $query_keywords); |
|
2321 | + $search_query_part = implode("AND", $query_keywords); |
|
2322 | 2322 | |
2323 | - return array($search_query_part, $search_words); |
|
2324 | - } |
|
2323 | + return array($search_query_part, $search_words); |
|
2324 | + } |
|
2325 | 2325 | } |
2326 | 2326 |
@@ -17,7 +17,9 @@ discard block |
||
17 | 17 | $feed_id, $is_cat, $search, |
18 | 18 | $error, $feed_last_updated) { |
19 | 19 | |
20 | - if ($is_cat) $cat_q = "&is_cat=$is_cat"; |
|
20 | + if ($is_cat) { |
|
21 | + $cat_q = "&is_cat=$is_cat"; |
|
22 | + } |
|
21 | 23 | |
22 | 24 | if ($search) { |
23 | 25 | $search_q = "&q=$search"; |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | $reply .= strip_tags($feed_title); |
49 | 51 | } |
50 | 52 | |
51 | - if ($error) |
|
52 | - $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
53 | + if ($error) { |
|
54 | + $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
55 | + } |
|
53 | 56 | |
54 | 57 | $reply .= "</span>"; |
55 | 58 | $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
@@ -127,8 +130,12 @@ discard block |
||
127 | 130 | $rgba_cache = array(); |
128 | 131 | $topmost_article_ids = array(); |
129 | 132 | |
130 | - if (!$offset) $offset = 0; |
|
131 | - if ($method == "undefined") $method = ""; |
|
133 | + if (!$offset) { |
|
134 | + $offset = 0; |
|
135 | + } |
|
136 | + if ($method == "undefined") { |
|
137 | + $method = ""; |
|
138 | + } |
|
132 | 139 | |
133 | 140 | $method_split = explode(":", $method); |
134 | 141 | |
@@ -274,14 +281,17 @@ discard block |
||
274 | 281 | $label_cache = json_decode($label_cache, true); |
275 | 282 | |
276 | 283 | if ($label_cache) { |
277 | - if ($label_cache["no-labels"] == 1) |
|
278 | - $labels = array(); |
|
279 | - else |
|
280 | - $labels = $label_cache; |
|
284 | + if ($label_cache["no-labels"] == 1) { |
|
285 | + $labels = array(); |
|
286 | + } else { |
|
287 | + $labels = $label_cache; |
|
288 | + } |
|
281 | 289 | } |
282 | 290 | } |
283 | 291 | |
284 | - if (!is_array($labels)) $labels = Article::get_article_labels($id); |
|
292 | + if (!is_array($labels)) { |
|
293 | + $labels = Article::get_article_labels($id); |
|
294 | + } |
|
285 | 295 | |
286 | 296 | $labels_str = "<span class=\"HLLCTR-$id\">"; |
287 | 297 | $labels_str .= Article::format_article_labels($labels); |
@@ -293,7 +303,9 @@ discard block |
||
293 | 303 | array_push($topmost_article_ids, $id); |
294 | 304 | } |
295 | 305 | |
296 | - if (!$line["feed_title"]) $line["feed_title"] = ""; |
|
306 | + if (!$line["feed_title"]) { |
|
307 | + $line["feed_title"] = ""; |
|
308 | + } |
|
297 | 309 | |
298 | 310 | $line["buttons_left"] = ""; |
299 | 311 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
@@ -314,10 +326,11 @@ discard block |
||
314 | 326 | |
315 | 327 | $line['content'] = DiskCache::rewriteUrls($line['content']); |
316 | 328 | |
317 | - if ($line['note']) |
|
318 | - $line['note'] = Article::format_article_note($id, $line['note']); |
|
319 | - else |
|
320 | - $line['note'] = ""; |
|
329 | + if ($line['note']) { |
|
330 | + $line['note'] = Article::format_article_note($id, $line['note']); |
|
331 | + } else { |
|
332 | + $line['note'] = ""; |
|
333 | + } |
|
321 | 334 | |
322 | 335 | if (!get_pref("CDM_EXPANDED")) { |
323 | 336 | $line["cdm_excerpt"] = "<span class='collapse'> |
@@ -350,10 +363,11 @@ discard block |
||
350 | 363 | $line['imported'] = T_sprintf("Imported at %s", |
351 | 364 | make_local_datetime($line["date_entered"], false)); |
352 | 365 | |
353 | - if ($line["tag_cache"]) |
|
354 | - $tags = explode(",", $line["tag_cache"]); |
|
355 | - else |
|
356 | - $tags = false; |
|
366 | + if ($line["tag_cache"]) { |
|
367 | + $tags = explode(",", $line["tag_cache"]); |
|
368 | + } else { |
|
369 | + $tags = false; |
|
370 | + } |
|
357 | 371 | |
358 | 372 | $line["tags_str"] = Article::format_tags_string($tags); |
359 | 373 | |
@@ -383,8 +397,9 @@ discard block |
||
383 | 397 | /* we don't need those */ |
384 | 398 | |
385 | 399 | foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
386 | - "uuid", "label_cache", "yyiw"] as $k) |
|
387 | - unset($line[$k]); |
|
400 | + "uuid", "label_cache", "yyiw"] as $k) { |
|
401 | + unset($line[$k]); |
|
402 | + } |
|
388 | 403 | |
389 | 404 | array_push($reply['content'], $line); |
390 | 405 | } |
@@ -474,7 +489,9 @@ discard block |
||
474 | 489 | $order_by = $_REQUEST["order_by"]; |
475 | 490 | $check_first_id = $_REQUEST["fid"]; |
476 | 491 | |
477 | - if (is_numeric($feed)) $feed = (int) $feed; |
|
492 | + if (is_numeric($feed)) { |
|
493 | + $feed = (int) $feed; |
|
494 | + } |
|
478 | 495 | |
479 | 496 | /* Feed -5 is a special case: it is used to display auxiliary information |
480 | 497 | * when there's nothing to load - e.g. no stuff in fresh feed */ |
@@ -562,10 +579,11 @@ discard block |
||
562 | 579 | $disable_cache = $ret[3]; |
563 | 580 | $reply['headlines'] = $ret[4]; |
564 | 581 | |
565 | - if (!$next_unread_feed) |
|
566 | - $reply['headlines']['id'] = $feed; |
|
567 | - else |
|
568 | - $reply['headlines']['id'] = $next_unread_feed; |
|
582 | + if (!$next_unread_feed) { |
|
583 | + $reply['headlines']['id'] = $feed; |
|
584 | + } else { |
|
585 | + $reply['headlines']['id'] = $next_unread_feed; |
|
586 | + } |
|
569 | 587 | |
570 | 588 | $reply['headlines']['is_cat'] = (bool) $cat_view; |
571 | 589 | |
@@ -851,7 +869,9 @@ discard block |
||
851 | 869 | |
852 | 870 | public static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) { |
853 | 871 | |
854 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
872 | + if (!$owner_uid) { |
|
873 | + $owner_uid = $_SESSION['uid']; |
|
874 | + } |
|
855 | 875 | |
856 | 876 | $pdo = Db::pdo(); |
857 | 877 | |
@@ -1026,7 +1046,9 @@ discard block |
||
1026 | 1046 | |
1027 | 1047 | $pdo = Db::pdo(); |
1028 | 1048 | |
1029 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1049 | + if (!$owner_uid) { |
|
1050 | + $owner_uid = $_SESSION["uid"]; |
|
1051 | + } |
|
1030 | 1052 | |
1031 | 1053 | if ($unread_only) { |
1032 | 1054 | $unread_qpart = "unread = true"; |
@@ -1142,7 +1164,9 @@ discard block |
||
1142 | 1164 | |
1143 | 1165 | $url = Feeds::fix_url($url); |
1144 | 1166 | |
1145 | - if (!$url || !Feeds::validate_feed_url($url)) return array("code" => 2); |
|
1167 | + if (!$url || !Feeds::validate_feed_url($url)) { |
|
1168 | + return array("code" => 2); |
|
1169 | + } |
|
1146 | 1170 | |
1147 | 1171 | $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass); |
1148 | 1172 | |
@@ -1170,7 +1194,9 @@ discard block |
||
1170 | 1194 | $url = key($feedUrls); |
1171 | 1195 | } |
1172 | 1196 | |
1173 | - if (!$cat_id) $cat_id = null; |
|
1197 | + if (!$cat_id) { |
|
1198 | + $cat_id = null; |
|
1199 | + } |
|
1174 | 1200 | |
1175 | 1201 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
1176 | 1202 | WHERE feed_url = ? AND owner_uid = ?"); |
@@ -1287,13 +1313,17 @@ discard block |
||
1287 | 1313 | |
1288 | 1314 | public static function getCategoryUnread($cat, $owner_uid = false) { |
1289 | 1315 | |
1290 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1316 | + if (!$owner_uid) { |
|
1317 | + $owner_uid = $_SESSION["uid"]; |
|
1318 | + } |
|
1291 | 1319 | |
1292 | 1320 | $pdo = Db::pdo(); |
1293 | 1321 | |
1294 | 1322 | if ($cat >= 0) { |
1295 | 1323 | |
1296 | - if (!$cat) $cat = null; |
|
1324 | + if (!$cat) { |
|
1325 | + $cat = null; |
|
1326 | + } |
|
1297 | 1327 | |
1298 | 1328 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
1299 | 1329 | WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) |
@@ -1306,7 +1336,9 @@ discard block |
||
1306 | 1336 | array_push($cat_feeds, "feed_id = " . (int)$line["id"]); |
1307 | 1337 | } |
1308 | 1338 | |
1309 | - if (count($cat_feeds) == 0) return 0; |
|
1339 | + if (count($cat_feeds) == 0) { |
|
1340 | + return 0; |
|
1341 | + } |
|
1310 | 1342 | |
1311 | 1343 | $match_part = implode(" OR ", $cat_feeds); |
1312 | 1344 | |
@@ -1341,7 +1373,9 @@ discard block |
||
1341 | 1373 | |
1342 | 1374 | // only accepts real cats (>= 0) |
1343 | 1375 | public static function getCategoryChildrenUnread($cat, $owner_uid = false) { |
1344 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1376 | + if (!$owner_uid) { |
|
1377 | + $owner_uid = $_SESSION["uid"]; |
|
1378 | + } |
|
1345 | 1379 | |
1346 | 1380 | $pdo = Db::pdo(); |
1347 | 1381 | |
@@ -1361,7 +1395,9 @@ discard block |
||
1361 | 1395 | |
1362 | 1396 | public static function getGlobalUnread($user_id = false) { |
1363 | 1397 | |
1364 | - if (!$user_id) $user_id = $_SESSION["uid"]; |
|
1398 | + if (!$user_id) { |
|
1399 | + $user_id = $_SESSION["uid"]; |
|
1400 | + } |
|
1365 | 1401 | |
1366 | 1402 | $pdo = Db::pdo(); |
1367 | 1403 | |
@@ -1396,7 +1432,9 @@ discard block |
||
1396 | 1432 | } |
1397 | 1433 | |
1398 | 1434 | public static function getLabelUnread($label_id, $owner_uid = false) { |
1399 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1435 | + if (!$owner_uid) { |
|
1436 | + $owner_uid = $_SESSION["uid"]; |
|
1437 | + } |
|
1400 | 1438 | |
1401 | 1439 | $pdo = Db::pdo(); |
1402 | 1440 | |
@@ -1491,8 +1529,9 @@ discard block |
||
1491 | 1529 | |
1492 | 1530 | $unread = getFeedUnread($feed, $cat_view); |
1493 | 1531 | |
1494 | - if ($cat_view && $feed > 0 && $include_children) |
|
1495 | - $unread += Feeds::getCategoryChildrenUnread($feed); |
|
1532 | + if ($cat_view && $feed > 0 && $include_children) { |
|
1533 | + $unread += Feeds::getCategoryChildrenUnread($feed); |
|
1534 | + } |
|
1496 | 1535 | |
1497 | 1536 | if ($unread > 0) { |
1498 | 1537 | $view_query_part = " unread = true AND "; |
@@ -1604,7 +1643,9 @@ discard block |
||
1604 | 1643 | $allow_archived = true; |
1605 | 1644 | $ignore_vfeed_group = true; |
1606 | 1645 | |
1607 | - if (!$override_order) $override_order = "last_read DESC"; |
|
1646 | + if (!$override_order) { |
|
1647 | + $override_order = "last_read DESC"; |
|
1648 | + } |
|
1608 | 1649 | |
1609 | 1650 | } else if ($feed == -3) { // fresh virtual feed |
1610 | 1651 | $query_strategy_part = "unread = true AND score >= 0"; |
@@ -1715,13 +1756,16 @@ discard block |
||
1715 | 1756 | LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; |
1716 | 1757 | } |
1717 | 1758 | |
1718 | - if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,"; |
|
1759 | + if ($vfeed_query_part) { |
|
1760 | + $vfeed_query_part .= "favicon_avg_color,"; |
|
1761 | + } |
|
1719 | 1762 | |
1720 | 1763 | $first_id = 0; |
1721 | 1764 | $first_id_query_strategy_part = $query_strategy_part; |
1722 | 1765 | |
1723 | - if ($feed == -3) |
|
1724 | - $first_id_query_strategy_part = "true"; |
|
1766 | + if ($feed == -3) { |
|
1767 | + $first_id_query_strategy_part = "true"; |
|
1768 | + } |
|
1725 | 1769 | |
1726 | 1770 | if (DB_TYPE == "pgsql") { |
1727 | 1771 | $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND"; |
@@ -1853,7 +1897,9 @@ discard block |
||
1853 | 1897 | $query_strategy_part ORDER BY $order_by |
1854 | 1898 | $limit_query_part $offset_query_part"; |
1855 | 1899 | |
1856 | - if ($_REQUEST["debug"]) print $query; |
|
1900 | + if ($_REQUEST["debug"]) { |
|
1901 | + print $query; |
|
1902 | + } |
|
1857 | 1903 | |
1858 | 1904 | $res = $pdo->query($query); |
1859 | 1905 | } |
@@ -2003,18 +2049,23 @@ discard block |
||
2003 | 2049 | } |
2004 | 2050 | } |
2005 | 2051 | |
2006 | - if ($url != "http:///") |
|
2007 | - return $url; |
|
2008 | - else |
|
2009 | - return ''; |
|
2052 | + if ($url != "http:///") { |
|
2053 | + return $url; |
|
2054 | + } else { |
|
2055 | + return ''; |
|
2056 | + } |
|
2010 | 2057 | } |
2011 | 2058 | |
2012 | 2059 | public static function add_feed_category($feed_cat, $parent_cat_id = false, $order_id = 0) { |
2013 | 2060 | |
2014 | - if (!$feed_cat) return false; |
|
2061 | + if (!$feed_cat) { |
|
2062 | + return false; |
|
2063 | + } |
|
2015 | 2064 | |
2016 | 2065 | $feed_cat = mb_substr($feed_cat, 0, 250); |
2017 | - if (!$parent_cat_id) $parent_cat_id = null; |
|
2066 | + if (!$parent_cat_id) { |
|
2067 | + $parent_cat_id = null; |
|
2068 | + } |
|
2018 | 2069 | |
2019 | 2070 | $pdo = Db::pdo(); |
2020 | 2071 | $tr_in_progress = false; |
@@ -2036,7 +2087,9 @@ discard block |
||
2036 | 2087 | VALUES (?, ?, ?, ?)"); |
2037 | 2088 | $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int)$order_id]); |
2038 | 2089 | |
2039 | - if (!$tr_in_progress) $pdo->commit(); |
|
2090 | + if (!$tr_in_progress) { |
|
2091 | + $pdo->commit(); |
|
2092 | + } |
|
2040 | 2093 | |
2041 | 2094 | return true; |
2042 | 2095 | } |
@@ -2048,7 +2101,9 @@ discard block |
||
2048 | 2101 | |
2049 | 2102 | public static function get_feed_access_key($feed_id, $is_cat, $owner_uid = false) { |
2050 | 2103 | |
2051 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
2104 | + if (!$owner_uid) { |
|
2105 | + $owner_uid = $_SESSION["uid"]; |
|
2106 | + } |
|
2052 | 2107 | |
2053 | 2108 | $is_cat = bool_to_sql_bool($is_cat); |
2054 | 2109 | |
@@ -2086,7 +2141,9 @@ discard block |
||
2086 | 2141 | */ |
2087 | 2142 | public static function purge_feed($feed_id, $purge_interval) { |
2088 | 2143 | |
2089 | - if (!$purge_interval) $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
2144 | + if (!$purge_interval) { |
|
2145 | + $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
2146 | + } |
|
2090 | 2147 | |
2091 | 2148 | $pdo = Db::pdo(); |
2092 | 2149 | |
@@ -2106,7 +2163,9 @@ discard block |
||
2106 | 2163 | return; |
2107 | 2164 | } |
2108 | 2165 | |
2109 | - if (!$owner_uid) return; |
|
2166 | + if (!$owner_uid) { |
|
2167 | + return; |
|
2168 | + } |
|
2110 | 2169 | |
2111 | 2170 | if (FORCE_ARTICLE_PURGE == 0) { |
2112 | 2171 | $purge_unread = get_pref("PURGE_UNREAD_ARTICLES", |
@@ -2116,10 +2175,11 @@ discard block |
||
2116 | 2175 | $purge_interval = FORCE_ARTICLE_PURGE; |
2117 | 2176 | } |
2118 | 2177 | |
2119 | - if (!$purge_unread) |
|
2120 | - $query_limit = " unread = false AND "; |
|
2121 | - else |
|
2122 | - $query_limit = ""; |
|
2178 | + if (!$purge_unread) { |
|
2179 | + $query_limit = " unread = false AND "; |
|
2180 | + } else { |
|
2181 | + $query_limit = ""; |
|
2182 | + } |
|
2123 | 2183 | |
2124 | 2184 | $purge_interval = (int) $purge_interval; |
2125 | 2185 | |
@@ -2166,8 +2226,10 @@ discard block |
||
2166 | 2226 | $purge_interval = $row["purge_interval"]; |
2167 | 2227 | $owner_uid = $row["owner_uid"]; |
2168 | 2228 | |
2169 | - if ($purge_interval == 0) $purge_interval = get_pref( |
|
2229 | + if ($purge_interval == 0) { |
|
2230 | + $purge_interval = get_pref( |
|
2170 | 2231 | 'PURGE_OLD_DAYS', $owner_uid); |
2232 | + } |
|
2171 | 2233 | |
2172 | 2234 | return $purge_interval; |
2173 | 2235 | |
@@ -2185,10 +2247,11 @@ discard block |
||
2185 | 2247 | |
2186 | 2248 | $pdo = Db::pdo(); |
2187 | 2249 | |
2188 | - if ($search_language) |
|
2189 | - $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
2190 | - else |
|
2191 | - $search_language = $pdo->quote("english"); |
|
2250 | + if ($search_language) { |
|
2251 | + $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
2252 | + } else { |
|
2253 | + $search_language = $pdo->quote("english"); |
|
2254 | + } |
|
2192 | 2255 | |
2193 | 2256 | foreach ($keywords as $k) { |
2194 | 2257 | if (strpos($k, "-") === 0) { |
@@ -2223,56 +2286,68 @@ discard block |
||
2223 | 2286 | break; |
2224 | 2287 | case "note": |
2225 | 2288 | if ($commandpair[1]) { |
2226 | - if ($commandpair[1] == "true") |
|
2227 | - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2228 | - else if ($commandpair[1] == "false") |
|
2229 | - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2230 | - else |
|
2231 | - array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2289 | + if ($commandpair[1] == "true") { |
|
2290 | + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2291 | + } else if ($commandpair[1] == "false") { |
|
2292 | + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2293 | + } else { |
|
2294 | + array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2232 | 2295 | $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
2296 | + } |
|
2233 | 2297 | } else { |
2234 | 2298 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
2235 | 2299 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2236 | - if (!$not) array_push($search_words, $k); |
|
2300 | + if (!$not) { |
|
2301 | + array_push($search_words, $k); |
|
2302 | + } |
|
2237 | 2303 | } |
2238 | 2304 | break; |
2239 | 2305 | case "star": |
2240 | 2306 | |
2241 | 2307 | if ($commandpair[1]) { |
2242 | - if ($commandpair[1] == "true") |
|
2243 | - array_push($query_keywords, "($not (marked = true))"); |
|
2244 | - else |
|
2245 | - array_push($query_keywords, "($not (marked = false))"); |
|
2308 | + if ($commandpair[1] == "true") { |
|
2309 | + array_push($query_keywords, "($not (marked = true))"); |
|
2310 | + } else { |
|
2311 | + array_push($query_keywords, "($not (marked = false))"); |
|
2312 | + } |
|
2246 | 2313 | } else { |
2247 | 2314 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
2248 | 2315 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2249 | - if (!$not) array_push($search_words, $k); |
|
2316 | + if (!$not) { |
|
2317 | + array_push($search_words, $k); |
|
2318 | + } |
|
2250 | 2319 | } |
2251 | 2320 | break; |
2252 | 2321 | case "pub": |
2253 | 2322 | if ($commandpair[1]) { |
2254 | - if ($commandpair[1] == "true") |
|
2255 | - array_push($query_keywords, "($not (published = true))"); |
|
2256 | - else |
|
2257 | - array_push($query_keywords, "($not (published = false))"); |
|
2323 | + if ($commandpair[1] == "true") { |
|
2324 | + array_push($query_keywords, "($not (published = true))"); |
|
2325 | + } else { |
|
2326 | + array_push($query_keywords, "($not (published = false))"); |
|
2327 | + } |
|
2258 | 2328 | |
2259 | 2329 | } else { |
2260 | 2330 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
2261 | 2331 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2262 | - if (!$not) array_push($search_words, $k); |
|
2332 | + if (!$not) { |
|
2333 | + array_push($search_words, $k); |
|
2334 | + } |
|
2263 | 2335 | } |
2264 | 2336 | break; |
2265 | 2337 | case "unread": |
2266 | 2338 | if ($commandpair[1]) { |
2267 | - if ($commandpair[1] == "true") |
|
2268 | - array_push($query_keywords, "($not (unread = true))"); |
|
2269 | - else |
|
2270 | - array_push($query_keywords, "($not (unread = false))"); |
|
2339 | + if ($commandpair[1] == "true") { |
|
2340 | + array_push($query_keywords, "($not (unread = true))"); |
|
2341 | + } else { |
|
2342 | + array_push($query_keywords, "($not (unread = false))"); |
|
2343 | + } |
|
2271 | 2344 | |
2272 | 2345 | } else { |
2273 | 2346 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
2274 | 2347 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2275 | - if (!$not) array_push($search_words, $k); |
|
2348 | + if (!$not) { |
|
2349 | + array_push($search_words, $k); |
|
2350 | + } |
|
2276 | 2351 | } |
2277 | 2352 | break; |
2278 | 2353 | default: |
@@ -2295,7 +2370,9 @@ discard block |
||
2295 | 2370 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2296 | 2371 | } |
2297 | 2372 | |
2298 | - if (!$not) array_push($search_words, $k); |
|
2373 | + if (!$not) { |
|
2374 | + array_push($search_words, $k); |
|
2375 | + } |
|
2299 | 2376 | } |
2300 | 2377 | } |
2301 | 2378 | } |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | |
81 | 81 | if (strpos($feed_id, "CAT:") === 0) { |
82 | 82 | $cat_id = (int) substr($feed_id, 4); |
83 | - array_push($scope_inner_qparts, "cat_id = " . $this->pdo->quote($cat_id)); |
|
83 | + array_push($scope_inner_qparts, "cat_id = ".$this->pdo->quote($cat_id)); |
|
84 | 84 | } else if ($feed_id > 0) { |
85 | - array_push($scope_inner_qparts, "feed_id = " . $this->pdo->quote($feed_id)); |
|
85 | + array_push($scope_inner_qparts, "feed_id = ".$this->pdo->quote($feed_id)); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | 89 | if (count($scope_inner_qparts) > 0) { |
90 | - array_push($scope_qparts, "(" . implode(" OR ", $scope_inner_qparts) . ")"); |
|
90 | + array_push($scope_qparts, "(".implode(" OR ", $scope_inner_qparts).")"); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | array_push($filter["rules"], $rule); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | if (count($scope_qparts) == 0) $scope_qparts = ["true"]; |
102 | 102 | |
103 | - $glue = $filter['match_any_rule'] ? " OR " : " AND "; |
|
103 | + $glue = $filter['match_any_rule'] ? " OR " : " AND "; |
|
104 | 104 | $scope_qpart = join($glue, $scope_qparts); |
105 | 105 | |
106 | 106 | if (!$scope_qpart) $scope_qpart = "true"; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | |
147 | 147 | $content_preview = $line["content_preview"]; |
148 | 148 | |
149 | - $tmp = "<li><span class='title'>" . $line["title"] . "</span><br/>" . |
|
150 | - "<span class='feed'>" . $line['feed_title'] . "</span>, <span class='date'>" . mb_substr($line["date_entered"], 0, 16) . "</span>" . |
|
151 | - "<div class='preview text-muted'>" . $content_preview . "</div>" . |
|
149 | + $tmp = "<li><span class='title'>".$line["title"]."</span><br/>". |
|
150 | + "<span class='feed'>".$line['feed_title']."</span>, <span class='date'>".mb_substr($line["date_entered"], 0, 16)."</span>". |
|
151 | + "<div class='preview text-muted'>".$content_preview."</div>". |
|
152 | 152 | "</li>"; |
153 | 153 | |
154 | 154 | array_push($rv, $tmp); |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | foreach ($feeds as $feed_id) { |
204 | 204 | |
205 | 205 | if (strpos($feed_id, "CAT:") === 0) { |
206 | - $feed_id = (int)substr($feed_id, 4); |
|
206 | + $feed_id = (int) substr($feed_id, 4); |
|
207 | 207 | array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
208 | 208 | } else { |
209 | 209 | if ($feed_id) |
210 | - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
210 | + array_push($feeds_fmt, Feeds::getFeedTitle((int) $feed_id)); |
|
211 | 211 | else |
212 | 212 | array_push($feeds_fmt, __("All feeds")); |
213 | 213 | } |
@@ -218,8 +218,7 @@ discard block |
||
218 | 218 | } else { |
219 | 219 | |
220 | 220 | $where = $line["cat_filter"] ? |
221 | - Feeds::getCategoryTitle($line["cat_id"]) : |
|
222 | - ($line["feed_id"] ? |
|
221 | + Feeds::getCategoryTitle($line["cat_id"]) : ($line["feed_id"] ? |
|
223 | 222 | Feeds::getFeedTitle($line["feed_id"]) : __("All feeds")); |
224 | 223 | } |
225 | 224 | |
@@ -227,11 +226,11 @@ discard block |
||
227 | 226 | |
228 | 227 | $inverse = $line["inverse"] ? "inverse" : ""; |
229 | 228 | |
230 | - $rv .= "<li class='$inverse'>" . T_sprintf("%s on %s in %s %s", |
|
229 | + $rv .= "<li class='$inverse'>".T_sprintf("%s on %s in %s %s", |
|
231 | 230 | htmlspecialchars($line["reg_exp"]), |
232 | 231 | $line["field"], |
233 | 232 | $where, |
234 | - $line["inverse"] ? __("(inverse)") : "") . "</li>"; |
|
233 | + $line["inverse"] ? __("(inverse)") : "")."</li>"; |
|
235 | 234 | } |
236 | 235 | |
237 | 236 | return $rv; |
@@ -294,12 +293,12 @@ discard block |
||
294 | 293 | //$fg_color = $label_row["fg_color"]; |
295 | 294 | $bg_color = $label_row["bg_color"]; |
296 | 295 | |
297 | - $name[1] = "<i class=\"material-icons\" style='color : $bg_color; margin-right : 4px'>label</i>" . $name[1]; |
|
296 | + $name[1] = "<i class=\"material-icons\" style='color : $bg_color; margin-right : 4px'>label</i>".$name[1]; |
|
298 | 297 | } |
299 | 298 | } |
300 | 299 | |
301 | 300 | $filter = array(); |
302 | - $filter['id'] = 'FILTER:' . $line['id']; |
|
301 | + $filter['id'] = 'FILTER:'.$line['id']; |
|
303 | 302 | $filter['bare_id'] = $line['id']; |
304 | 303 | $filter['name'] = $name[0]; |
305 | 304 | $filter['param'] = $name[1]; |
@@ -357,7 +356,7 @@ discard block |
||
357 | 356 | print "<div dojoType=\"fox.Toolbar\">"; |
358 | 357 | |
359 | 358 | print "<div dojoType=\"fox.form.DropDownButton\">". |
360 | - "<span>" . __('Select')."</span>"; |
|
359 | + "<span>".__('Select')."</span>"; |
|
361 | 360 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
362 | 361 | print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\" |
363 | 362 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
@@ -384,12 +383,12 @@ discard block |
||
384 | 383 | $line["feed_id"] = json_decode($line["match_on"], true); |
385 | 384 | } else { |
386 | 385 | if ($line["cat_filter"]) { |
387 | - $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
386 | + $feed_id = "CAT:".(int) $line["cat_id"]; |
|
388 | 387 | } else { |
389 | - $feed_id = (int)$line["feed_id"]; |
|
388 | + $feed_id = (int) $line["feed_id"]; |
|
390 | 389 | } |
391 | 390 | |
392 | - $line["feed_id"] = ["" . $feed_id]; // set item type to string for in_array() |
|
391 | + $line["feed_id"] = ["".$feed_id]; // set item type to string for in_array() |
|
393 | 392 | } |
394 | 393 | |
395 | 394 | unset($line["cat_filter"]); |
@@ -417,7 +416,7 @@ discard block |
||
417 | 416 | print "<div dojoType=\"fox.Toolbar\">"; |
418 | 417 | |
419 | 418 | print "<div dojoType=\"fox.form.DropDownButton\">". |
420 | - "<span>" . __('Select')."</span>"; |
|
419 | + "<span>".__('Select')."</span>"; |
|
421 | 420 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
422 | 421 | print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\" |
423 | 422 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
@@ -528,11 +527,11 @@ discard block |
||
528 | 527 | foreach ($feeds as $feed_id) { |
529 | 528 | |
530 | 529 | if (strpos($feed_id, "CAT:") === 0) { |
531 | - $feed_id = (int)substr($feed_id, 4); |
|
530 | + $feed_id = (int) substr($feed_id, 4); |
|
532 | 531 | array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
533 | 532 | } else { |
534 | 533 | if ($feed_id) |
535 | - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
534 | + array_push($feeds_fmt, Feeds::getFeedTitle((int) $feed_id)); |
|
536 | 535 | else |
537 | 536 | array_push($feeds_fmt, __("All feeds")); |
538 | 537 | } |
@@ -542,7 +541,7 @@ discard block |
||
542 | 541 | |
543 | 542 | $sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_types |
544 | 543 | WHERE id = ?"); |
545 | - $sth->execute([(int)$rule["filter_type"]]); |
|
544 | + $sth->execute([(int) $rule["filter_type"]]); |
|
546 | 545 | |
547 | 546 | if ($row = $sth->fetch()) { |
548 | 547 | $filter_type = $row["description"]; |
@@ -552,9 +551,9 @@ discard block |
||
552 | 551 | |
553 | 552 | $inverse = isset($rule["inverse"]) ? "inverse" : ""; |
554 | 553 | |
555 | - return "<span class='filterRule $inverse'>" . |
|
554 | + return "<span class='filterRule $inverse'>". |
|
556 | 555 | T_sprintf("%s on %s in %s %s", htmlspecialchars($rule["reg_exp"]), |
557 | - $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "") . "</span>"; |
|
556 | + $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "")."</span>"; |
|
558 | 557 | } |
559 | 558 | |
560 | 559 | public function printRuleName() { |
@@ -564,7 +563,7 @@ discard block |
||
564 | 563 | private function getActionName($action) { |
565 | 564 | $sth = $this->pdo->prepare("SELECT description FROM |
566 | 565 | ttrss_filter_actions WHERE id = ?"); |
567 | - $sth->execute([(int)$action["action_id"]]); |
|
566 | + $sth->execute([(int) $action["action_id"]]); |
|
568 | 567 | |
569 | 568 | $title = ""; |
570 | 569 | |
@@ -574,7 +573,7 @@ discard block |
||
574 | 573 | |
575 | 574 | if ($action["action_id"] == 4 || $action["action_id"] == 6 || |
576 | 575 | $action["action_id"] == 7) |
577 | - $title .= ": " . $action["action_param"]; |
|
576 | + $title .= ": ".$action["action_param"]; |
|
578 | 577 | |
579 | 578 | if ($action["action_id"] == 9) { |
580 | 579 | list ($pfclass, $pfaction) = explode(":", $action["action_param"]); |
@@ -584,7 +583,7 @@ discard block |
||
584 | 583 | foreach ($filter_actions as $fclass => $factions) { |
585 | 584 | foreach ($factions as $faction) { |
586 | 585 | if ($pfaction == $faction["action"] && $pfclass == $fclass) { |
587 | - $title .= ": " . $fclass . ": " . $faction["description"]; |
|
586 | + $title .= ": ".$fclass.": ".$faction["description"]; |
|
588 | 587 | break; |
589 | 588 | } |
590 | 589 | } |
@@ -681,7 +680,7 @@ discard block |
||
681 | 680 | $reg_exp = trim($rule["reg_exp"]); |
682 | 681 | $inverse = isset($rule["inverse"]) ? 1 : 0; |
683 | 682 | |
684 | - $filter_type = (int)trim($rule["filter_type"]); |
|
683 | + $filter_type = (int) trim($rule["filter_type"]); |
|
685 | 684 | $match_on = json_encode($rule["feed_id"]); |
686 | 685 | |
687 | 686 | $rsth->execute([$filter_id, $reg_exp, $filter_type, $match_on, $inverse]); |
@@ -695,7 +694,7 @@ discard block |
||
695 | 694 | foreach ($actions as $action) { |
696 | 695 | if ($action) { |
697 | 696 | |
698 | - $action_id = (int)$action["action_id"]; |
|
697 | + $action_id = (int) $action["action_id"]; |
|
699 | 698 | $action_param = $action["action_param"]; |
700 | 699 | $action_param_label = $action["action_param_label"]; |
701 | 700 | |
@@ -704,7 +703,7 @@ discard block |
||
704 | 703 | } |
705 | 704 | |
706 | 705 | if ($action_id == 6) { |
707 | - $action_param = (int)str_replace("+", "", $action_param); |
|
706 | + $action_param = (int) str_replace("+", "", $action_param); |
|
708 | 707 | } |
709 | 708 | |
710 | 709 | $asth->execute([$filter_id, $action_id, $action_param]); |
@@ -773,7 +772,7 @@ discard block |
||
773 | 772 | </div>"; |
774 | 773 | |
775 | 774 | print "<div dojoType=\"fox.form.DropDownButton\">". |
776 | - "<span>" . __('Select')."</span>"; |
|
775 | + "<span>".__('Select')."</span>"; |
|
777 | 776 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
778 | 777 | print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\" |
779 | 778 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
@@ -859,7 +858,7 @@ discard block |
||
859 | 858 | print "<div dojoType='fox.Toolbar'>"; |
860 | 859 | |
861 | 860 | print "<div dojoType='fox.form.DropDownButton'>". |
862 | - "<span>" . __('Select')."</span>"; |
|
861 | + "<span>".__('Select')."</span>"; |
|
863 | 862 | print "<div dojoType='dijit.Menu' style='display: none'>"; |
864 | 863 | print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\" |
865 | 864 | dojoType='dijit.MenuItem'>".__('All')."</div>"; |
@@ -888,7 +887,7 @@ discard block |
||
888 | 887 | print "<div dojoType='fox.Toolbar'>"; |
889 | 888 | |
890 | 889 | print "<div dojoType='fox.form.DropDownButton'>". |
891 | - "<span>" . __('Select')."</span>"; |
|
890 | + "<span>".__('Select')."</span>"; |
|
892 | 891 | print "<div dojoType='dijit.Menu' style='display: none'>"; |
893 | 892 | print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\" |
894 | 893 | dojoType='dijit.MenuItem'>".__('All')."</div>"; |
@@ -992,10 +991,10 @@ discard block |
||
992 | 991 | print "</fieldset>"; |
993 | 992 | |
994 | 993 | print "<fieldset>"; |
995 | - print "<label style='display : inline'>". __("on field") . "</label> "; |
|
994 | + print "<label style='display : inline'>".__("on field")."</label> "; |
|
996 | 995 | print_select_hash("filter_type", $filter_type, $filter_types, |
997 | 996 | 'dojoType="fox.form.Select"'); |
998 | - print "<label style='padding-left : 10px; display : inline'>" . __("in") . "</label> "; |
|
997 | + print "<label style='padding-left : 10px; display : inline'>".__("in")."</label> "; |
|
999 | 998 | |
1000 | 999 | print "</fieldset>"; |
1001 | 1000 | |
@@ -1031,7 +1030,7 @@ discard block |
||
1031 | 1030 | |
1032 | 1031 | if ($action) { |
1033 | 1032 | $action_param = $action["action_param"]; |
1034 | - $action_id = (int)$action["action_id"]; |
|
1033 | + $action_id = (int) $action["action_id"]; |
|
1035 | 1034 | } else { |
1036 | 1035 | $action_param = ""; |
1037 | 1036 | $action_id = 0; |
@@ -1062,8 +1061,8 @@ discard block |
||
1062 | 1061 | $param_hidden = ($action_id == 4 || $action_id == 6) ? |
1063 | 1062 | "" : "display : none"; |
1064 | 1063 | |
1065 | - $label_param_hidden = ($action_id == 7) ? "" : "display : none"; |
|
1066 | - $plugin_param_hidden = ($action_id == 9) ? "" : "display : none"; |
|
1064 | + $label_param_hidden = ($action_id == 7) ? "" : "display : none"; |
|
1065 | + $plugin_param_hidden = ($action_id == 9) ? "" : "display : none"; |
|
1067 | 1066 | |
1068 | 1067 | print "<span id='filterDlg_paramBox' style=\"$param_box_hidden\">"; |
1069 | 1068 | print " "; |
@@ -1082,8 +1081,8 @@ discard block |
||
1082 | 1081 | foreach ($filter_actions as $fclass => $factions) { |
1083 | 1082 | foreach ($factions as $faction) { |
1084 | 1083 | |
1085 | - $filter_action_hash[$fclass . ":" . $faction["action"]] = |
|
1086 | - $fclass . ": " . $faction["description"]; |
|
1084 | + $filter_action_hash[$fclass.":".$faction["action"]] = |
|
1085 | + $fclass.": ".$faction["description"]; |
|
1087 | 1086 | } |
1088 | 1087 | } |
1089 | 1088 | |
@@ -1153,8 +1152,8 @@ discard block |
||
1153 | 1152 | $num_actions -= 1; |
1154 | 1153 | } |
1155 | 1154 | |
1156 | - if ($match_any_rule) $title .= " (" . __("matches any rule") . ")"; |
|
1157 | - if ($inverse) $title .= " (" . __("inverse") . ")"; |
|
1155 | + if ($match_any_rule) $title .= " (".__("matches any rule").")"; |
|
1156 | + if ($inverse) $title .= " (".__("inverse").")"; |
|
1158 | 1157 | |
1159 | 1158 | if ($num_actions > 0) |
1160 | 1159 | $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions); |
@@ -68,7 +68,7 @@ |
||
68 | 68 | $scope_qparts = array(); |
69 | 69 | |
70 | 70 | $rctr = 0; |
71 | - foreach (clean($_REQUEST["rule"]) AS $r) { |
|
71 | + foreach (clean($_REQUEST["rule"]) as $r) { |
|
72 | 72 | $rule = json_decode($r, true); |
73 | 73 | |
74 | 74 | if ($rule && $rctr < 5) { |
@@ -1,82 +1,82 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Pref_Filters extends Handler_Protected { |
3 | 3 | |
4 | - public function csrf_ignore($method) { |
|
5 | - $csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule", |
|
6 | - "newaction", "savefilterorder"); |
|
4 | + public function csrf_ignore($method) { |
|
5 | + $csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule", |
|
6 | + "newaction", "savefilterorder"); |
|
7 | 7 | |
8 | - return array_search($method, $csrf_ignored) !== false; |
|
9 | - } |
|
8 | + return array_search($method, $csrf_ignored) !== false; |
|
9 | + } |
|
10 | 10 | |
11 | - public function filtersortreset() { |
|
12 | - $sth = $this->pdo->prepare("UPDATE ttrss_filters2 |
|
11 | + public function filtersortreset() { |
|
12 | + $sth = $this->pdo->prepare("UPDATE ttrss_filters2 |
|
13 | 13 | SET order_id = 0 WHERE owner_uid = ?"); |
14 | - $sth->execute([$_SESSION['uid']]); |
|
15 | - return; |
|
16 | - } |
|
14 | + $sth->execute([$_SESSION['uid']]); |
|
15 | + return; |
|
16 | + } |
|
17 | 17 | |
18 | - public function savefilterorder() { |
|
19 | - $data = json_decode($_POST['payload'], true); |
|
18 | + public function savefilterorder() { |
|
19 | + $data = json_decode($_POST['payload'], true); |
|
20 | 20 | |
21 | - #file_put_contents("/tmp/saveorder.json", clean($_POST['payload'])); |
|
22 | - #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true); |
|
21 | + #file_put_contents("/tmp/saveorder.json", clean($_POST['payload'])); |
|
22 | + #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true); |
|
23 | 23 | |
24 | - if (!is_array($data['items'])) |
|
25 | - $data['items'] = json_decode($data['items'], true); |
|
24 | + if (!is_array($data['items'])) |
|
25 | + $data['items'] = json_decode($data['items'], true); |
|
26 | 26 | |
27 | - $index = 0; |
|
27 | + $index = 0; |
|
28 | 28 | |
29 | - if (is_array($data) && is_array($data['items'])) { |
|
29 | + if (is_array($data) && is_array($data['items'])) { |
|
30 | 30 | |
31 | - $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET |
|
31 | + $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET |
|
32 | 32 | order_id = ? WHERE id = ? AND |
33 | 33 | owner_uid = ?"); |
34 | 34 | |
35 | - foreach ($data['items'][0]['items'] as $item) { |
|
36 | - $filter_id = (int) str_replace("FILTER:", "", $item['_reference']); |
|
35 | + foreach ($data['items'][0]['items'] as $item) { |
|
36 | + $filter_id = (int) str_replace("FILTER:", "", $item['_reference']); |
|
37 | 37 | |
38 | - if ($filter_id > 0) { |
|
39 | - $sth->execute([$index, $filter_id, $_SESSION['uid']]); |
|
40 | - ++$index; |
|
41 | - } |
|
42 | - } |
|
43 | - } |
|
38 | + if ($filter_id > 0) { |
|
39 | + $sth->execute([$index, $filter_id, $_SESSION['uid']]); |
|
40 | + ++$index; |
|
41 | + } |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | - return; |
|
46 | - } |
|
45 | + return; |
|
46 | + } |
|
47 | 47 | |
48 | - public function testFilterDo() { |
|
49 | - $offset = (int) clean($_REQUEST["offset"]); |
|
50 | - $limit = (int) clean($_REQUEST["limit"]); |
|
48 | + public function testFilterDo() { |
|
49 | + $offset = (int) clean($_REQUEST["offset"]); |
|
50 | + $limit = (int) clean($_REQUEST["limit"]); |
|
51 | 51 | |
52 | - $filter = array(); |
|
52 | + $filter = array(); |
|
53 | 53 | |
54 | - $filter["enabled"] = true; |
|
55 | - $filter["match_any_rule"] = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); |
|
56 | - $filter["inverse"] = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); |
|
54 | + $filter["enabled"] = true; |
|
55 | + $filter["match_any_rule"] = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); |
|
56 | + $filter["inverse"] = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); |
|
57 | 57 | |
58 | - $filter["rules"] = array(); |
|
59 | - $filter["actions"] = array("dummy-action"); |
|
58 | + $filter["rules"] = array(); |
|
59 | + $filter["actions"] = array("dummy-action"); |
|
60 | 60 | |
61 | - $res = $this->pdo->query("SELECT id,name FROM ttrss_filter_types"); |
|
61 | + $res = $this->pdo->query("SELECT id,name FROM ttrss_filter_types"); |
|
62 | 62 | |
63 | - $filter_types = array(); |
|
64 | - while ($line = $res->fetch()) { |
|
65 | - $filter_types[$line["id"]] = $line["name"]; |
|
66 | - } |
|
63 | + $filter_types = array(); |
|
64 | + while ($line = $res->fetch()) { |
|
65 | + $filter_types[$line["id"]] = $line["name"]; |
|
66 | + } |
|
67 | 67 | |
68 | - $scope_qparts = array(); |
|
68 | + $scope_qparts = array(); |
|
69 | 69 | |
70 | - $rctr = 0; |
|
71 | - foreach (clean($_REQUEST["rule"]) AS $r) { |
|
72 | - $rule = json_decode($r, true); |
|
70 | + $rctr = 0; |
|
71 | + foreach (clean($_REQUEST["rule"]) AS $r) { |
|
72 | + $rule = json_decode($r, true); |
|
73 | 73 | |
74 | - if ($rule && $rctr < 5) { |
|
75 | - $rule["type"] = $filter_types[$rule["filter_type"]]; |
|
76 | - unset($rule["filter_type"]); |
|
74 | + if ($rule && $rctr < 5) { |
|
75 | + $rule["type"] = $filter_types[$rule["filter_type"]]; |
|
76 | + unset($rule["filter_type"]); |
|
77 | 77 | |
78 | - $scope_inner_qparts = []; |
|
79 | - foreach ($rule["feed_id"] as $feed_id) { |
|
78 | + $scope_inner_qparts = []; |
|
79 | + foreach ($rule["feed_id"] as $feed_id) { |
|
80 | 80 | |
81 | 81 | if (strpos($feed_id, "CAT:") === 0) { |
82 | 82 | $cat_id = (int) substr($feed_id, 4); |
@@ -87,29 +87,29 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | if (count($scope_inner_qparts) > 0) { |
90 | - array_push($scope_qparts, "(" . implode(" OR ", $scope_inner_qparts) . ")"); |
|
90 | + array_push($scope_qparts, "(" . implode(" OR ", $scope_inner_qparts) . ")"); |
|
91 | 91 | } |
92 | 92 | |
93 | - array_push($filter["rules"], $rule); |
|
93 | + array_push($filter["rules"], $rule); |
|
94 | 94 | |
95 | - ++$rctr; |
|
96 | - } else { |
|
97 | - break; |
|
98 | - } |
|
99 | - } |
|
95 | + ++$rctr; |
|
96 | + } else { |
|
97 | + break; |
|
98 | + } |
|
99 | + } |
|
100 | 100 | |
101 | - if (count($scope_qparts) == 0) $scope_qparts = ["true"]; |
|
101 | + if (count($scope_qparts) == 0) $scope_qparts = ["true"]; |
|
102 | 102 | |
103 | - $glue = $filter['match_any_rule'] ? " OR " : " AND "; |
|
104 | - $scope_qpart = join($glue, $scope_qparts); |
|
103 | + $glue = $filter['match_any_rule'] ? " OR " : " AND "; |
|
104 | + $scope_qpart = join($glue, $scope_qparts); |
|
105 | 105 | |
106 | - if (!$scope_qpart) $scope_qpart = "true"; |
|
106 | + if (!$scope_qpart) $scope_qpart = "true"; |
|
107 | 107 | |
108 | - $rv = array(); |
|
108 | + $rv = array(); |
|
109 | 109 | |
110 | - //while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) { |
|
110 | + //while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) { |
|
111 | 111 | |
112 | - $sth = $this->pdo->prepare("SELECT ttrss_entries.id, |
|
112 | + $sth = $this->pdo->prepare("SELECT ttrss_entries.id, |
|
113 | 113 | ttrss_entries.title, |
114 | 114 | ttrss_feeds.id AS feed_id, |
115 | 115 | ttrss_feeds.title AS feed_title, |
@@ -129,56 +129,56 @@ discard block |
||
129 | 129 | ttrss_user_entries.owner_uid = ? |
130 | 130 | ORDER BY date_entered DESC LIMIT $limit OFFSET $offset"); |
131 | 131 | |
132 | - $sth->execute([$_SESSION['uid']]); |
|
132 | + $sth->execute([$_SESSION['uid']]); |
|
133 | 133 | |
134 | - while ($line = $sth->fetch()) { |
|
134 | + while ($line = $sth->fetch()) { |
|
135 | 135 | |
136 | - $rc = RSSUtils::get_article_filters(array($filter), $line['title'], $line['content'], $line['link'], |
|
137 | - $line['author'], explode(",", $line['tag_cache'])); |
|
136 | + $rc = RSSUtils::get_article_filters(array($filter), $line['title'], $line['content'], $line['link'], |
|
137 | + $line['author'], explode(",", $line['tag_cache'])); |
|
138 | 138 | |
139 | - if (count($rc) > 0) { |
|
139 | + if (count($rc) > 0) { |
|
140 | 140 | |
141 | - $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '…'); |
|
141 | + $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '…'); |
|
142 | 142 | |
143 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
|
144 | - $line = $p->hook_query_headlines($line, 100); |
|
145 | - } |
|
143 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
|
144 | + $line = $p->hook_query_headlines($line, 100); |
|
145 | + } |
|
146 | 146 | |
147 | - $content_preview = $line["content_preview"]; |
|
147 | + $content_preview = $line["content_preview"]; |
|
148 | 148 | |
149 | - $tmp = "<li><span class='title'>" . $line["title"] . "</span><br/>" . |
|
150 | - "<span class='feed'>" . $line['feed_title'] . "</span>, <span class='date'>" . mb_substr($line["date_entered"], 0, 16) . "</span>" . |
|
151 | - "<div class='preview text-muted'>" . $content_preview . "</div>" . |
|
152 | - "</li>"; |
|
149 | + $tmp = "<li><span class='title'>" . $line["title"] . "</span><br/>" . |
|
150 | + "<span class='feed'>" . $line['feed_title'] . "</span>, <span class='date'>" . mb_substr($line["date_entered"], 0, 16) . "</span>" . |
|
151 | + "<div class='preview text-muted'>" . $content_preview . "</div>" . |
|
152 | + "</li>"; |
|
153 | 153 | |
154 | - array_push($rv, $tmp); |
|
154 | + array_push($rv, $tmp); |
|
155 | 155 | |
156 | - } |
|
157 | - } |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - print json_encode($rv); |
|
160 | - } |
|
159 | + print json_encode($rv); |
|
160 | + } |
|
161 | 161 | |
162 | - public function testFilter() { |
|
162 | + public function testFilter() { |
|
163 | 163 | |
164 | - if (isset($_REQUEST["offset"])) return $this->testFilterDo(); |
|
164 | + if (isset($_REQUEST["offset"])) return $this->testFilterDo(); |
|
165 | 165 | |
166 | - //print __("Articles matching this filter:"); |
|
166 | + //print __("Articles matching this filter:"); |
|
167 | 167 | |
168 | - print "<div><img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'> <span id='prefFilterProgressMsg'>Looking for articles...</span></div>"; |
|
168 | + print "<div><img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'> <span id='prefFilterProgressMsg'>Looking for articles...</span></div>"; |
|
169 | 169 | |
170 | - print "<ul class='panel panel-scrollable list list-unstyled' id='prefFilterTestResultList'>"; |
|
171 | - print "</ul>"; |
|
170 | + print "<ul class='panel panel-scrollable list list-unstyled' id='prefFilterTestResultList'>"; |
|
171 | + print "</ul>"; |
|
172 | 172 | |
173 | - print "<footer class='text-center'>"; |
|
174 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('filterTestDlg').hide()\">". |
|
175 | - __('Close this window')."</button>"; |
|
176 | - print "</footer>"; |
|
173 | + print "<footer class='text-center'>"; |
|
174 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('filterTestDlg').hide()\">". |
|
175 | + __('Close this window')."</button>"; |
|
176 | + print "</footer>"; |
|
177 | 177 | |
178 | - } |
|
178 | + } |
|
179 | 179 | |
180 | - private function getfilterrules_list($filter_id) { |
|
181 | - $sth = $this->pdo->prepare("SELECT reg_exp, |
|
180 | + private function getfilterrules_list($filter_id) { |
|
181 | + $sth = $this->pdo->prepare("SELECT reg_exp, |
|
182 | 182 | inverse, |
183 | 183 | match_on, |
184 | 184 | feed_id, |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | WHERE |
191 | 191 | filter_id = ? AND filter_type = ttrss_filter_types.id |
192 | 192 | ORDER BY reg_exp"); |
193 | - $sth->execute([$filter_id]); |
|
193 | + $sth->execute([$filter_id]); |
|
194 | 194 | |
195 | - $rv = ""; |
|
195 | + $rv = ""; |
|
196 | 196 | |
197 | - while ($line = $sth->fetch()) { |
|
197 | + while ($line = $sth->fetch()) { |
|
198 | 198 | |
199 | - if ($line["match_on"]) { |
|
200 | - $feeds = json_decode($line["match_on"], true); |
|
201 | - $feeds_fmt = []; |
|
199 | + if ($line["match_on"]) { |
|
200 | + $feeds = json_decode($line["match_on"], true); |
|
201 | + $feeds_fmt = []; |
|
202 | 202 | |
203 | 203 | foreach ($feeds as $feed_id) { |
204 | 204 | |
@@ -225,27 +225,27 @@ discard block |
||
225 | 225 | |
226 | 226 | # $where = $line["cat_id"] . "/" . $line["feed_id"]; |
227 | 227 | |
228 | - $inverse = $line["inverse"] ? "inverse" : ""; |
|
228 | + $inverse = $line["inverse"] ? "inverse" : ""; |
|
229 | 229 | |
230 | - $rv .= "<li class='$inverse'>" . T_sprintf("%s on %s in %s %s", |
|
231 | - htmlspecialchars($line["reg_exp"]), |
|
232 | - $line["field"], |
|
233 | - $where, |
|
234 | - $line["inverse"] ? __("(inverse)") : "") . "</li>"; |
|
235 | - } |
|
230 | + $rv .= "<li class='$inverse'>" . T_sprintf("%s on %s in %s %s", |
|
231 | + htmlspecialchars($line["reg_exp"]), |
|
232 | + $line["field"], |
|
233 | + $where, |
|
234 | + $line["inverse"] ? __("(inverse)") : "") . "</li>"; |
|
235 | + } |
|
236 | 236 | |
237 | - return $rv; |
|
238 | - } |
|
237 | + return $rv; |
|
238 | + } |
|
239 | 239 | |
240 | - public function getfiltertree() { |
|
241 | - $root = array(); |
|
242 | - $root['id'] = 'root'; |
|
243 | - $root['name'] = __('Filters'); |
|
244 | - $root['items'] = array(); |
|
240 | + public function getfiltertree() { |
|
241 | + $root = array(); |
|
242 | + $root['id'] = 'root'; |
|
243 | + $root['name'] = __('Filters'); |
|
244 | + $root['items'] = array(); |
|
245 | 245 | |
246 | - $filter_search = $_SESSION["prefs_filter_search"]; |
|
246 | + $filter_search = $_SESSION["prefs_filter_search"]; |
|
247 | 247 | |
248 | - $sth = $this->pdo->prepare("SELECT *, |
|
248 | + $sth = $this->pdo->prepare("SELECT *, |
|
249 | 249 | (SELECT action_param FROM ttrss_filters2_actions |
250 | 250 | WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS action_param, |
251 | 251 | (SELECT action_id FROM ttrss_filters2_actions |
@@ -257,275 +257,275 @@ discard block |
||
257 | 257 | WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS reg_exp |
258 | 258 | FROM ttrss_filters2 WHERE |
259 | 259 | owner_uid = ? ORDER BY order_id, title"); |
260 | - $sth->execute([$_SESSION['uid']]); |
|
260 | + $sth->execute([$_SESSION['uid']]); |
|
261 | 261 | |
262 | - $folder = array(); |
|
263 | - $folder['items'] = array(); |
|
262 | + $folder = array(); |
|
263 | + $folder['items'] = array(); |
|
264 | 264 | |
265 | - while ($line = $sth->fetch()) { |
|
265 | + while ($line = $sth->fetch()) { |
|
266 | 266 | |
267 | - $name = $this->getFilterName($line["id"]); |
|
267 | + $name = $this->getFilterName($line["id"]); |
|
268 | 268 | |
269 | - $match_ok = false; |
|
270 | - if ($filter_search) { |
|
271 | - if (mb_strpos($line['title'], $filter_search) !== false) { |
|
272 | - $match_ok = true; |
|
273 | - } |
|
269 | + $match_ok = false; |
|
270 | + if ($filter_search) { |
|
271 | + if (mb_strpos($line['title'], $filter_search) !== false) { |
|
272 | + $match_ok = true; |
|
273 | + } |
|
274 | 274 | |
275 | - $rules_sth = $this->pdo->prepare("SELECT reg_exp |
|
275 | + $rules_sth = $this->pdo->prepare("SELECT reg_exp |
|
276 | 276 | FROM ttrss_filters2_rules WHERE filter_id = ?"); |
277 | - $rules_sth->execute([$line['id']]); |
|
278 | - |
|
279 | - while ($rule_line = $rules_sth->fetch()) { |
|
280 | - if (mb_strpos($rule_line['reg_exp'], $filter_search) !== false) { |
|
281 | - $match_ok = true; |
|
282 | - break; |
|
283 | - } |
|
284 | - } |
|
285 | - } |
|
277 | + $rules_sth->execute([$line['id']]); |
|
278 | + |
|
279 | + while ($rule_line = $rules_sth->fetch()) { |
|
280 | + if (mb_strpos($rule_line['reg_exp'], $filter_search) !== false) { |
|
281 | + $match_ok = true; |
|
282 | + break; |
|
283 | + } |
|
284 | + } |
|
285 | + } |
|
286 | 286 | |
287 | - if ($line['action_id'] == 7) { |
|
288 | - $label_sth = $this->pdo->prepare("SELECT fg_color, bg_color |
|
287 | + if ($line['action_id'] == 7) { |
|
288 | + $label_sth = $this->pdo->prepare("SELECT fg_color, bg_color |
|
289 | 289 | FROM ttrss_labels2 WHERE caption = ? AND |
290 | 290 | owner_uid = ?"); |
291 | - $label_sth->execute([$line['action_param'], $_SESSION['uid']]); |
|
291 | + $label_sth->execute([$line['action_param'], $_SESSION['uid']]); |
|
292 | 292 | |
293 | - if ($label_row = $label_sth->fetch()) { |
|
294 | - //$fg_color = $label_row["fg_color"]; |
|
295 | - $bg_color = $label_row["bg_color"]; |
|
293 | + if ($label_row = $label_sth->fetch()) { |
|
294 | + //$fg_color = $label_row["fg_color"]; |
|
295 | + $bg_color = $label_row["bg_color"]; |
|
296 | 296 | |
297 | - $name[1] = "<i class=\"material-icons\" style='color : $bg_color; margin-right : 4px'>label</i>" . $name[1]; |
|
298 | - } |
|
299 | - } |
|
297 | + $name[1] = "<i class=\"material-icons\" style='color : $bg_color; margin-right : 4px'>label</i>" . $name[1]; |
|
298 | + } |
|
299 | + } |
|
300 | 300 | |
301 | - $filter = array(); |
|
302 | - $filter['id'] = 'FILTER:' . $line['id']; |
|
303 | - $filter['bare_id'] = $line['id']; |
|
304 | - $filter['name'] = $name[0]; |
|
305 | - $filter['param'] = $name[1]; |
|
306 | - $filter['checkbox'] = false; |
|
307 | - $filter['last_triggered'] = $line["last_triggered"] ? make_local_datetime($line["last_triggered"], false) : null; |
|
308 | - $filter['enabled'] = $line["enabled"]; |
|
309 | - $filter['rules'] = $this->getfilterrules_list($line['id']); |
|
310 | - |
|
311 | - if (!$filter_search || $match_ok) { |
|
312 | - array_push($folder['items'], $filter); |
|
313 | - } |
|
314 | - } |
|
301 | + $filter = array(); |
|
302 | + $filter['id'] = 'FILTER:' . $line['id']; |
|
303 | + $filter['bare_id'] = $line['id']; |
|
304 | + $filter['name'] = $name[0]; |
|
305 | + $filter['param'] = $name[1]; |
|
306 | + $filter['checkbox'] = false; |
|
307 | + $filter['last_triggered'] = $line["last_triggered"] ? make_local_datetime($line["last_triggered"], false) : null; |
|
308 | + $filter['enabled'] = $line["enabled"]; |
|
309 | + $filter['rules'] = $this->getfilterrules_list($line['id']); |
|
310 | + |
|
311 | + if (!$filter_search || $match_ok) { |
|
312 | + array_push($folder['items'], $filter); |
|
313 | + } |
|
314 | + } |
|
315 | 315 | |
316 | - $root['items'] = $folder['items']; |
|
316 | + $root['items'] = $folder['items']; |
|
317 | 317 | |
318 | - $fl = array(); |
|
319 | - $fl['identifier'] = 'id'; |
|
320 | - $fl['label'] = 'name'; |
|
321 | - $fl['items'] = array($root); |
|
318 | + $fl = array(); |
|
319 | + $fl['identifier'] = 'id'; |
|
320 | + $fl['label'] = 'name'; |
|
321 | + $fl['items'] = array($root); |
|
322 | 322 | |
323 | - print json_encode($fl); |
|
324 | - return; |
|
325 | - } |
|
323 | + print json_encode($fl); |
|
324 | + return; |
|
325 | + } |
|
326 | 326 | |
327 | - public function edit() { |
|
327 | + public function edit() { |
|
328 | 328 | |
329 | - $filter_id = clean($_REQUEST["id"]); |
|
329 | + $filter_id = clean($_REQUEST["id"]); |
|
330 | 330 | |
331 | - $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2 |
|
331 | + $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2 |
|
332 | 332 | WHERE id = ? AND owner_uid = ?"); |
333 | - $sth->execute([$filter_id, $_SESSION['uid']]); |
|
333 | + $sth->execute([$filter_id, $_SESSION['uid']]); |
|
334 | 334 | |
335 | - if ($row = $sth->fetch()) { |
|
335 | + if ($row = $sth->fetch()) { |
|
336 | 336 | |
337 | - $enabled = $row["enabled"]; |
|
338 | - $match_any_rule = $row["match_any_rule"]; |
|
339 | - $inverse = $row["inverse"]; |
|
340 | - $title = htmlspecialchars($row["title"]); |
|
337 | + $enabled = $row["enabled"]; |
|
338 | + $match_any_rule = $row["match_any_rule"]; |
|
339 | + $inverse = $row["inverse"]; |
|
340 | + $title = htmlspecialchars($row["title"]); |
|
341 | 341 | |
342 | - print "<form id='filter_edit_form' onsubmit='return false'>"; |
|
342 | + print "<form id='filter_edit_form' onsubmit='return false'>"; |
|
343 | 343 | |
344 | - print_hidden("op", "pref-filters"); |
|
345 | - print_hidden("id", "$filter_id"); |
|
346 | - print_hidden("method", "editSave"); |
|
347 | - print_hidden("csrf_token", $_SESSION['csrf_token']); |
|
344 | + print_hidden("op", "pref-filters"); |
|
345 | + print_hidden("id", "$filter_id"); |
|
346 | + print_hidden("method", "editSave"); |
|
347 | + print_hidden("csrf_token", $_SESSION['csrf_token']); |
|
348 | 348 | |
349 | - print "<header>".__("Caption")."</header>"; |
|
350 | - print "<section>"; |
|
351 | - print "<input required=\"true\" dojoType=\"dijit.form.ValidationTextBox\" style=\"width : 20em;\" name=\"title\" value=\"$title\">"; |
|
352 | - print "</section>"; |
|
349 | + print "<header>".__("Caption")."</header>"; |
|
350 | + print "<section>"; |
|
351 | + print "<input required=\"true\" dojoType=\"dijit.form.ValidationTextBox\" style=\"width : 20em;\" name=\"title\" value=\"$title\">"; |
|
352 | + print "</section>"; |
|
353 | 353 | |
354 | - print "<header class='horizontal'>".__("Match")."</header>"; |
|
355 | - print "<section>"; |
|
354 | + print "<header class='horizontal'>".__("Match")."</header>"; |
|
355 | + print "<section>"; |
|
356 | 356 | |
357 | - print "<div dojoType=\"fox.Toolbar\">"; |
|
357 | + print "<div dojoType=\"fox.Toolbar\">"; |
|
358 | 358 | |
359 | - print "<div dojoType=\"fox.form.DropDownButton\">". |
|
360 | - "<span>" . __('Select')."</span>"; |
|
361 | - print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
362 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\" |
|
359 | + print "<div dojoType=\"fox.form.DropDownButton\">". |
|
360 | + "<span>" . __('Select')."</span>"; |
|
361 | + print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
362 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\" |
|
363 | 363 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
364 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\" |
|
364 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\" |
|
365 | 365 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; |
366 | - print "</div></div>"; |
|
366 | + print "</div></div>"; |
|
367 | 367 | |
368 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addRule()\">". |
|
369 | - __('Add')."</button> "; |
|
368 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addRule()\">". |
|
369 | + __('Add')."</button> "; |
|
370 | 370 | |
371 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">". |
|
372 | - __('Delete')."</button> "; |
|
371 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">". |
|
372 | + __('Delete')."</button> "; |
|
373 | 373 | |
374 | - print "</div>"; |
|
374 | + print "</div>"; |
|
375 | 375 | |
376 | - print "<ul id='filterDlg_Matches'>"; |
|
376 | + print "<ul id='filterDlg_Matches'>"; |
|
377 | 377 | |
378 | - $rules_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules |
|
378 | + $rules_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules |
|
379 | 379 | WHERE filter_id = ? ORDER BY reg_exp, id"); |
380 | - $rules_sth->execute([$filter_id]); |
|
381 | - |
|
382 | - while ($line = $rules_sth->fetch()) { |
|
383 | - if ($line["match_on"]) { |
|
384 | - $line["feed_id"] = json_decode($line["match_on"], true); |
|
385 | - } else { |
|
386 | - if ($line["cat_filter"]) { |
|
387 | - $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
388 | - } else { |
|
389 | - $feed_id = (int)$line["feed_id"]; |
|
390 | - } |
|
391 | - |
|
392 | - $line["feed_id"] = ["" . $feed_id]; // set item type to string for in_array() |
|
393 | - } |
|
394 | - |
|
395 | - unset($line["cat_filter"]); |
|
396 | - unset($line["cat_id"]); |
|
397 | - unset($line["filter_id"]); |
|
398 | - unset($line["id"]); |
|
399 | - if (!$line["inverse"]) unset($line["inverse"]); |
|
400 | - unset($line["match_on"]); |
|
401 | - |
|
402 | - $data = htmlspecialchars(json_encode($line)); |
|
403 | - |
|
404 | - print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>". |
|
405 | - "<span onclick=\"dijit.byId('filterEditDlg').editRule(this)\">".$this->getRuleName($line)."</span>". |
|
406 | - "<input type='hidden' name='rule[]' value=\"$data\"/></li>"; |
|
407 | - } |
|
380 | + $rules_sth->execute([$filter_id]); |
|
381 | + |
|
382 | + while ($line = $rules_sth->fetch()) { |
|
383 | + if ($line["match_on"]) { |
|
384 | + $line["feed_id"] = json_decode($line["match_on"], true); |
|
385 | + } else { |
|
386 | + if ($line["cat_filter"]) { |
|
387 | + $feed_id = "CAT:" . (int)$line["cat_id"]; |
|
388 | + } else { |
|
389 | + $feed_id = (int)$line["feed_id"]; |
|
390 | + } |
|
391 | + |
|
392 | + $line["feed_id"] = ["" . $feed_id]; // set item type to string for in_array() |
|
393 | + } |
|
394 | + |
|
395 | + unset($line["cat_filter"]); |
|
396 | + unset($line["cat_id"]); |
|
397 | + unset($line["filter_id"]); |
|
398 | + unset($line["id"]); |
|
399 | + if (!$line["inverse"]) unset($line["inverse"]); |
|
400 | + unset($line["match_on"]); |
|
401 | + |
|
402 | + $data = htmlspecialchars(json_encode($line)); |
|
408 | 403 | |
409 | - print "</ul>"; |
|
404 | + print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>". |
|
405 | + "<span onclick=\"dijit.byId('filterEditDlg').editRule(this)\">".$this->getRuleName($line)."</span>". |
|
406 | + "<input type='hidden' name='rule[]' value=\"$data\"/></li>"; |
|
407 | + } |
|
408 | + |
|
409 | + print "</ul>"; |
|
410 | 410 | |
411 | - print "</section>"; |
|
411 | + print "</section>"; |
|
412 | 412 | |
413 | - print "<header class='horizontal'>".__("Apply actions")."</header>"; |
|
413 | + print "<header class='horizontal'>".__("Apply actions")."</header>"; |
|
414 | 414 | |
415 | - print "<section>"; |
|
415 | + print "<section>"; |
|
416 | 416 | |
417 | - print "<div dojoType=\"fox.Toolbar\">"; |
|
417 | + print "<div dojoType=\"fox.Toolbar\">"; |
|
418 | 418 | |
419 | - print "<div dojoType=\"fox.form.DropDownButton\">". |
|
420 | - "<span>" . __('Select')."</span>"; |
|
421 | - print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
422 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\" |
|
419 | + print "<div dojoType=\"fox.form.DropDownButton\">". |
|
420 | + "<span>" . __('Select')."</span>"; |
|
421 | + print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
422 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\" |
|
423 | 423 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
424 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\" |
|
424 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\" |
|
425 | 425 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; |
426 | - print "</div></div>"; |
|
426 | + print "</div></div>"; |
|
427 | 427 | |
428 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addAction()\">". |
|
429 | - __('Add')."</button> "; |
|
428 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addAction()\">". |
|
429 | + __('Add')."</button> "; |
|
430 | 430 | |
431 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">". |
|
432 | - __('Delete')."</button> "; |
|
431 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">". |
|
432 | + __('Delete')."</button> "; |
|
433 | 433 | |
434 | - print "</div>"; |
|
434 | + print "</div>"; |
|
435 | 435 | |
436 | - print "<ul id='filterDlg_Actions'>"; |
|
436 | + print "<ul id='filterDlg_Actions'>"; |
|
437 | 437 | |
438 | - $actions_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions |
|
438 | + $actions_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions |
|
439 | 439 | WHERE filter_id = ? ORDER BY id"); |
440 | - $actions_sth->execute([$filter_id]); |
|
440 | + $actions_sth->execute([$filter_id]); |
|
441 | 441 | |
442 | - while ($line = $actions_sth->fetch()) { |
|
443 | - $line["action_param_label"] = $line["action_param"]; |
|
442 | + while ($line = $actions_sth->fetch()) { |
|
443 | + $line["action_param_label"] = $line["action_param"]; |
|
444 | 444 | |
445 | - unset($line["filter_id"]); |
|
446 | - unset($line["id"]); |
|
445 | + unset($line["filter_id"]); |
|
446 | + unset($line["id"]); |
|
447 | 447 | |
448 | - $data = htmlspecialchars(json_encode($line)); |
|
448 | + $data = htmlspecialchars(json_encode($line)); |
|
449 | 449 | |
450 | - print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>". |
|
451 | - "<span onclick=\"dijit.byId('filterEditDlg').editAction(this)\">".$this->getActionName($line)."</span>". |
|
452 | - "<input type='hidden' name='action[]' value=\"$data\"/></li>"; |
|
453 | - } |
|
450 | + print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>". |
|
451 | + "<span onclick=\"dijit.byId('filterEditDlg').editAction(this)\">".$this->getActionName($line)."</span>". |
|
452 | + "<input type='hidden' name='action[]' value=\"$data\"/></li>"; |
|
453 | + } |
|
454 | 454 | |
455 | - print "</ul>"; |
|
455 | + print "</ul>"; |
|
456 | 456 | |
457 | - print "</section>"; |
|
457 | + print "</section>"; |
|
458 | 458 | |
459 | - print "<header>".__("Options")."</header>"; |
|
460 | - print "<section>"; |
|
459 | + print "<header>".__("Options")."</header>"; |
|
460 | + print "<section>"; |
|
461 | 461 | |
462 | - if ($enabled) { |
|
463 | - $checked = "checked=\"1\""; |
|
464 | - } else { |
|
465 | - $checked = ""; |
|
466 | - } |
|
462 | + if ($enabled) { |
|
463 | + $checked = "checked=\"1\""; |
|
464 | + } else { |
|
465 | + $checked = ""; |
|
466 | + } |
|
467 | 467 | |
468 | - print "<fieldset class='narrow'>"; |
|
469 | - print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked> |
|
468 | + print "<fieldset class='narrow'>"; |
|
469 | + print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked> |
|
470 | 470 | ".__('Enabled')."</label>"; |
471 | 471 | |
472 | - if ($match_any_rule) { |
|
473 | - $checked = "checked=\"1\""; |
|
474 | - } else { |
|
475 | - $checked = ""; |
|
476 | - } |
|
472 | + if ($match_any_rule) { |
|
473 | + $checked = "checked=\"1\""; |
|
474 | + } else { |
|
475 | + $checked = ""; |
|
476 | + } |
|
477 | 477 | |
478 | - print "</fieldset><fieldset class='narrow'>"; |
|
478 | + print "</fieldset><fieldset class='narrow'>"; |
|
479 | 479 | |
480 | - print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"match_any_rule\" id=\"match_any_rule\" $checked> |
|
480 | + print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"match_any_rule\" id=\"match_any_rule\" $checked> |
|
481 | 481 | ".__('Match any rule')."</label>"; |
482 | 482 | |
483 | - print "</fieldset><fieldset class='narrow'>"; |
|
483 | + print "</fieldset><fieldset class='narrow'>"; |
|
484 | 484 | |
485 | - if ($inverse) { |
|
486 | - $checked = "checked=\"1\""; |
|
487 | - } else { |
|
488 | - $checked = ""; |
|
489 | - } |
|
485 | + if ($inverse) { |
|
486 | + $checked = "checked=\"1\""; |
|
487 | + } else { |
|
488 | + $checked = ""; |
|
489 | + } |
|
490 | 490 | |
491 | - print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked> |
|
491 | + print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked> |
|
492 | 492 | ".__('Inverse matching')."</label>"; |
493 | 493 | |
494 | - print "</fieldset>"; |
|
494 | + print "</fieldset>"; |
|
495 | 495 | |
496 | - print "</section>"; |
|
496 | + print "</section>"; |
|
497 | 497 | |
498 | - print "<footer>"; |
|
498 | + print "<footer>"; |
|
499 | 499 | |
500 | - print "<div style=\"float : left\">"; |
|
501 | - print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return dijit.byId('filterEditDlg').removeFilter()\">". |
|
502 | - __('Remove')."</button>"; |
|
503 | - print "</div>"; |
|
500 | + print "<div style=\"float : left\">"; |
|
501 | + print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return dijit.byId('filterEditDlg').removeFilter()\">". |
|
502 | + __('Remove')."</button>"; |
|
503 | + print "</div>"; |
|
504 | 504 | |
505 | - print "<button dojoType=\"dijit.form.Button\" class=\"alt-info\" onclick=\"return dijit.byId('filterEditDlg').test()\">". |
|
506 | - __('Test')."</button> "; |
|
505 | + print "<button dojoType=\"dijit.form.Button\" class=\"alt-info\" onclick=\"return dijit.byId('filterEditDlg').test()\">". |
|
506 | + __('Test')."</button> "; |
|
507 | 507 | |
508 | - print "<button dojoType=\"dijit.form.Button\" type=\"submit\" class=\"alt-primary\" onclick=\"return dijit.byId('filterEditDlg').execute()\">". |
|
509 | - __('Save')."</button> "; |
|
508 | + print "<button dojoType=\"dijit.form.Button\" type=\"submit\" class=\"alt-primary\" onclick=\"return dijit.byId('filterEditDlg').execute()\">". |
|
509 | + __('Save')."</button> "; |
|
510 | 510 | |
511 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">". |
|
512 | - __('Cancel')."</button>"; |
|
511 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">". |
|
512 | + __('Cancel')."</button>"; |
|
513 | 513 | |
514 | - print "</footer>"; |
|
515 | - print "</form>"; |
|
514 | + print "</footer>"; |
|
515 | + print "</form>"; |
|
516 | 516 | |
517 | - } |
|
518 | - } |
|
517 | + } |
|
518 | + } |
|
519 | 519 | |
520 | - private function getRuleName($rule) { |
|
521 | - if (!$rule) $rule = json_decode(clean($_REQUEST["rule"]), true); |
|
520 | + private function getRuleName($rule) { |
|
521 | + if (!$rule) $rule = json_decode(clean($_REQUEST["rule"]), true); |
|
522 | 522 | |
523 | - $feeds = $rule["feed_id"]; |
|
524 | - $feeds_fmt = []; |
|
523 | + $feeds = $rule["feed_id"]; |
|
524 | + $feeds_fmt = []; |
|
525 | 525 | |
526 | - if (!is_array($feeds)) $feeds = [$feeds]; |
|
526 | + if (!is_array($feeds)) $feeds = [$feeds]; |
|
527 | 527 | |
528 | - foreach ($feeds as $feed_id) { |
|
528 | + foreach ($feeds as $feed_id) { |
|
529 | 529 | |
530 | 530 | if (strpos($feed_id, "CAT:") === 0) { |
531 | 531 | $feed_id = (int)substr($feed_id, 4); |
@@ -540,272 +540,272 @@ discard block |
||
540 | 540 | |
541 | 541 | $feed = implode(", ", $feeds_fmt); |
542 | 542 | |
543 | - $sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_types |
|
543 | + $sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_types |
|
544 | 544 | WHERE id = ?"); |
545 | - $sth->execute([(int)$rule["filter_type"]]); |
|
545 | + $sth->execute([(int)$rule["filter_type"]]); |
|
546 | 546 | |
547 | - if ($row = $sth->fetch()) { |
|
548 | - $filter_type = $row["description"]; |
|
549 | - } else { |
|
550 | - $filter_type = "?UNKNOWN?"; |
|
551 | - } |
|
547 | + if ($row = $sth->fetch()) { |
|
548 | + $filter_type = $row["description"]; |
|
549 | + } else { |
|
550 | + $filter_type = "?UNKNOWN?"; |
|
551 | + } |
|
552 | 552 | |
553 | - $inverse = isset($rule["inverse"]) ? "inverse" : ""; |
|
553 | + $inverse = isset($rule["inverse"]) ? "inverse" : ""; |
|
554 | 554 | |
555 | - return "<span class='filterRule $inverse'>" . |
|
556 | - T_sprintf("%s on %s in %s %s", htmlspecialchars($rule["reg_exp"]), |
|
557 | - $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "") . "</span>"; |
|
558 | - } |
|
555 | + return "<span class='filterRule $inverse'>" . |
|
556 | + T_sprintf("%s on %s in %s %s", htmlspecialchars($rule["reg_exp"]), |
|
557 | + $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "") . "</span>"; |
|
558 | + } |
|
559 | 559 | |
560 | - public function printRuleName() { |
|
561 | - print $this->getRuleName(json_decode(clean($_REQUEST["rule"]), true)); |
|
562 | - } |
|
560 | + public function printRuleName() { |
|
561 | + print $this->getRuleName(json_decode(clean($_REQUEST["rule"]), true)); |
|
562 | + } |
|
563 | 563 | |
564 | - private function getActionName($action) { |
|
565 | - $sth = $this->pdo->prepare("SELECT description FROM |
|
564 | + private function getActionName($action) { |
|
565 | + $sth = $this->pdo->prepare("SELECT description FROM |
|
566 | 566 | ttrss_filter_actions WHERE id = ?"); |
567 | - $sth->execute([(int)$action["action_id"]]); |
|
567 | + $sth->execute([(int)$action["action_id"]]); |
|
568 | 568 | |
569 | - $title = ""; |
|
569 | + $title = ""; |
|
570 | 570 | |
571 | - if ($row = $sth->fetch()) { |
|
571 | + if ($row = $sth->fetch()) { |
|
572 | 572 | |
573 | - $title = __($row["description"]); |
|
573 | + $title = __($row["description"]); |
|
574 | 574 | |
575 | - if ($action["action_id"] == 4 || $action["action_id"] == 6 || |
|
576 | - $action["action_id"] == 7) |
|
577 | - $title .= ": " . $action["action_param"]; |
|
575 | + if ($action["action_id"] == 4 || $action["action_id"] == 6 || |
|
576 | + $action["action_id"] == 7) |
|
577 | + $title .= ": " . $action["action_param"]; |
|
578 | 578 | |
579 | - if ($action["action_id"] == 9) { |
|
580 | - list ($pfclass, $pfaction) = explode(":", $action["action_param"]); |
|
579 | + if ($action["action_id"] == 9) { |
|
580 | + list ($pfclass, $pfaction) = explode(":", $action["action_param"]); |
|
581 | 581 | |
582 | - $filter_actions = PluginHost::getInstance()->get_filter_actions(); |
|
582 | + $filter_actions = PluginHost::getInstance()->get_filter_actions(); |
|
583 | 583 | |
584 | - foreach ($filter_actions as $fclass => $factions) { |
|
585 | - foreach ($factions as $faction) { |
|
586 | - if ($pfaction == $faction["action"] && $pfclass == $fclass) { |
|
587 | - $title .= ": " . $fclass . ": " . $faction["description"]; |
|
588 | - break; |
|
589 | - } |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
584 | + foreach ($filter_actions as $fclass => $factions) { |
|
585 | + foreach ($factions as $faction) { |
|
586 | + if ($pfaction == $faction["action"] && $pfclass == $fclass) { |
|
587 | + $title .= ": " . $fclass . ": " . $faction["description"]; |
|
588 | + break; |
|
589 | + } |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | 594 | |
595 | - return $title; |
|
596 | - } |
|
595 | + return $title; |
|
596 | + } |
|
597 | 597 | |
598 | - public function printActionName() { |
|
599 | - print $this->getActionName(json_decode(clean($_REQUEST["action"]), true)); |
|
600 | - } |
|
598 | + public function printActionName() { |
|
599 | + print $this->getActionName(json_decode(clean($_REQUEST["action"]), true)); |
|
600 | + } |
|
601 | 601 | |
602 | - public function editSave() { |
|
603 | - if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") { |
|
604 | - return $this->testFilter(); |
|
605 | - } |
|
602 | + public function editSave() { |
|
603 | + if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") { |
|
604 | + return $this->testFilter(); |
|
605 | + } |
|
606 | 606 | |
607 | - $filter_id = clean($_REQUEST["id"]); |
|
608 | - $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); |
|
609 | - $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); |
|
610 | - $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); |
|
611 | - $title = clean($_REQUEST["title"]); |
|
607 | + $filter_id = clean($_REQUEST["id"]); |
|
608 | + $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); |
|
609 | + $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); |
|
610 | + $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); |
|
611 | + $title = clean($_REQUEST["title"]); |
|
612 | 612 | |
613 | - $this->pdo->beginTransaction(); |
|
613 | + $this->pdo->beginTransaction(); |
|
614 | 614 | |
615 | - $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET enabled = ?, |
|
615 | + $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET enabled = ?, |
|
616 | 616 | match_any_rule = ?, |
617 | 617 | inverse = ?, |
618 | 618 | title = ? |
619 | 619 | WHERE id = ? AND owner_uid = ?"); |
620 | 620 | |
621 | - $sth->execute([$enabled, $match_any_rule, $inverse, $title, $filter_id, $_SESSION['uid']]); |
|
621 | + $sth->execute([$enabled, $match_any_rule, $inverse, $title, $filter_id, $_SESSION['uid']]); |
|
622 | 622 | |
623 | - $this->saveRulesAndActions($filter_id); |
|
623 | + $this->saveRulesAndActions($filter_id); |
|
624 | 624 | |
625 | - $this->pdo->commit(); |
|
626 | - } |
|
625 | + $this->pdo->commit(); |
|
626 | + } |
|
627 | 627 | |
628 | - public function remove() { |
|
628 | + public function remove() { |
|
629 | 629 | |
630 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
631 | - $ids_qmarks = arr_qmarks($ids); |
|
630 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
631 | + $ids_qmarks = arr_qmarks($ids); |
|
632 | 632 | |
633 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks) |
|
633 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks) |
|
634 | 634 | AND owner_uid = ?"); |
635 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
636 | - } |
|
635 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
636 | + } |
|
637 | 637 | |
638 | - private function saveRulesAndActions($filter_id) |
|
639 | - { |
|
638 | + private function saveRulesAndActions($filter_id) |
|
639 | + { |
|
640 | 640 | |
641 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?"); |
|
642 | - $sth->execute([$filter_id]); |
|
641 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?"); |
|
642 | + $sth->execute([$filter_id]); |
|
643 | 643 | |
644 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?"); |
|
645 | - $sth->execute([$filter_id]); |
|
644 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?"); |
|
645 | + $sth->execute([$filter_id]); |
|
646 | 646 | |
647 | - if (!is_array(clean($_REQUEST["rule"]))) $_REQUEST["rule"] = []; |
|
648 | - if (!is_array(clean($_REQUEST["action"]))) $_REQUEST["action"] = []; |
|
647 | + if (!is_array(clean($_REQUEST["rule"]))) $_REQUEST["rule"] = []; |
|
648 | + if (!is_array(clean($_REQUEST["action"]))) $_REQUEST["action"] = []; |
|
649 | 649 | |
650 | - if ($filter_id) { |
|
651 | - /* create rules */ |
|
650 | + if ($filter_id) { |
|
651 | + /* create rules */ |
|
652 | 652 | |
653 | - $rules = array(); |
|
654 | - $actions = array(); |
|
653 | + $rules = array(); |
|
654 | + $actions = array(); |
|
655 | 655 | |
656 | - foreach (clean($_REQUEST["rule"]) as $rule) { |
|
657 | - $rule = json_decode($rule, true); |
|
658 | - unset($rule["id"]); |
|
656 | + foreach (clean($_REQUEST["rule"]) as $rule) { |
|
657 | + $rule = json_decode($rule, true); |
|
658 | + unset($rule["id"]); |
|
659 | 659 | |
660 | - if (array_search($rule, $rules) === false) { |
|
661 | - array_push($rules, $rule); |
|
662 | - } |
|
663 | - } |
|
660 | + if (array_search($rule, $rules) === false) { |
|
661 | + array_push($rules, $rule); |
|
662 | + } |
|
663 | + } |
|
664 | 664 | |
665 | - foreach (clean($_REQUEST["action"]) as $action) { |
|
666 | - $action = json_decode($action, true); |
|
667 | - unset($action["id"]); |
|
665 | + foreach (clean($_REQUEST["action"]) as $action) { |
|
666 | + $action = json_decode($action, true); |
|
667 | + unset($action["id"]); |
|
668 | 668 | |
669 | - if (array_search($action, $actions) === false) { |
|
670 | - array_push($actions, $action); |
|
671 | - } |
|
672 | - } |
|
669 | + if (array_search($action, $actions) === false) { |
|
670 | + array_push($actions, $action); |
|
671 | + } |
|
672 | + } |
|
673 | 673 | |
674 | - $rsth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules |
|
674 | + $rsth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules |
|
675 | 675 | (filter_id, reg_exp,filter_type,feed_id,cat_id,match_on,inverse) VALUES |
676 | 676 | (?, ?, ?, NULL, NULL, ?, ?)"); |
677 | 677 | |
678 | - foreach ($rules as $rule) { |
|
679 | - if ($rule) { |
|
678 | + foreach ($rules as $rule) { |
|
679 | + if ($rule) { |
|
680 | 680 | |
681 | - $reg_exp = trim($rule["reg_exp"]); |
|
682 | - $inverse = isset($rule["inverse"]) ? 1 : 0; |
|
681 | + $reg_exp = trim($rule["reg_exp"]); |
|
682 | + $inverse = isset($rule["inverse"]) ? 1 : 0; |
|
683 | 683 | |
684 | - $filter_type = (int)trim($rule["filter_type"]); |
|
685 | - $match_on = json_encode($rule["feed_id"]); |
|
684 | + $filter_type = (int)trim($rule["filter_type"]); |
|
685 | + $match_on = json_encode($rule["feed_id"]); |
|
686 | 686 | |
687 | - $rsth->execute([$filter_id, $reg_exp, $filter_type, $match_on, $inverse]); |
|
688 | - } |
|
689 | - } |
|
687 | + $rsth->execute([$filter_id, $reg_exp, $filter_type, $match_on, $inverse]); |
|
688 | + } |
|
689 | + } |
|
690 | 690 | |
691 | - $asth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions |
|
691 | + $asth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions |
|
692 | 692 | (filter_id, action_id, action_param) VALUES |
693 | 693 | (?, ?, ?)"); |
694 | 694 | |
695 | - foreach ($actions as $action) { |
|
696 | - if ($action) { |
|
695 | + foreach ($actions as $action) { |
|
696 | + if ($action) { |
|
697 | 697 | |
698 | - $action_id = (int)$action["action_id"]; |
|
699 | - $action_param = $action["action_param"]; |
|
700 | - $action_param_label = $action["action_param_label"]; |
|
698 | + $action_id = (int)$action["action_id"]; |
|
699 | + $action_param = $action["action_param"]; |
|
700 | + $action_param_label = $action["action_param_label"]; |
|
701 | 701 | |
702 | - if ($action_id == 7) { |
|
703 | - $action_param = $action_param_label; |
|
704 | - } |
|
702 | + if ($action_id == 7) { |
|
703 | + $action_param = $action_param_label; |
|
704 | + } |
|
705 | 705 | |
706 | - if ($action_id == 6) { |
|
707 | - $action_param = (int)str_replace("+", "", $action_param); |
|
708 | - } |
|
706 | + if ($action_id == 6) { |
|
707 | + $action_param = (int)str_replace("+", "", $action_param); |
|
708 | + } |
|
709 | 709 | |
710 | - $asth->execute([$filter_id, $action_id, $action_param]); |
|
711 | - } |
|
712 | - } |
|
713 | - } |
|
714 | - } |
|
710 | + $asth->execute([$filter_id, $action_id, $action_param]); |
|
711 | + } |
|
712 | + } |
|
713 | + } |
|
714 | + } |
|
715 | 715 | |
716 | - public function add() { |
|
717 | - if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") { |
|
718 | - return $this->testFilter(); |
|
719 | - } |
|
716 | + public function add() { |
|
717 | + if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") { |
|
718 | + return $this->testFilter(); |
|
719 | + } |
|
720 | 720 | |
721 | - $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); |
|
722 | - $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); |
|
723 | - $title = clean($_REQUEST["title"]); |
|
724 | - $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); |
|
721 | + $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); |
|
722 | + $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); |
|
723 | + $title = clean($_REQUEST["title"]); |
|
724 | + $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"])); |
|
725 | 725 | |
726 | - $this->pdo->beginTransaction(); |
|
726 | + $this->pdo->beginTransaction(); |
|
727 | 727 | |
728 | - /* create base filter */ |
|
728 | + /* create base filter */ |
|
729 | 729 | |
730 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_filters2 |
|
730 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_filters2 |
|
731 | 731 | (owner_uid, match_any_rule, enabled, title, inverse) VALUES |
732 | 732 | (?, ?, ?, ?, ?)"); |
733 | 733 | |
734 | - $sth->execute([$_SESSION['uid'], $match_any_rule, $enabled, $title, $inverse]); |
|
734 | + $sth->execute([$_SESSION['uid'], $match_any_rule, $enabled, $title, $inverse]); |
|
735 | 735 | |
736 | - $sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2 |
|
736 | + $sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2 |
|
737 | 737 | WHERE owner_uid = ?"); |
738 | - $sth->execute([$_SESSION['uid']]); |
|
738 | + $sth->execute([$_SESSION['uid']]); |
|
739 | 739 | |
740 | - if ($row = $sth->fetch()) { |
|
741 | - $filter_id = $row['id']; |
|
742 | - $this->saveRulesAndActions($filter_id); |
|
743 | - } |
|
740 | + if ($row = $sth->fetch()) { |
|
741 | + $filter_id = $row['id']; |
|
742 | + $this->saveRulesAndActions($filter_id); |
|
743 | + } |
|
744 | 744 | |
745 | - $this->pdo->commit(); |
|
746 | - } |
|
745 | + $this->pdo->commit(); |
|
746 | + } |
|
747 | 747 | |
748 | - public function index() { |
|
748 | + public function index() { |
|
749 | 749 | |
750 | - $filter_search = clean($_REQUEST["search"]); |
|
750 | + $filter_search = clean($_REQUEST["search"]); |
|
751 | 751 | |
752 | - if (array_key_exists("search", $_REQUEST)) { |
|
753 | - $_SESSION["prefs_filter_search"] = $filter_search; |
|
754 | - } else { |
|
755 | - $filter_search = $_SESSION["prefs_filter_search"]; |
|
756 | - } |
|
752 | + if (array_key_exists("search", $_REQUEST)) { |
|
753 | + $_SESSION["prefs_filter_search"] = $filter_search; |
|
754 | + } else { |
|
755 | + $filter_search = $_SESSION["prefs_filter_search"]; |
|
756 | + } |
|
757 | 757 | |
758 | - print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>"; |
|
759 | - print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>"; |
|
760 | - print "<div dojoType='fox.Toolbar'>"; |
|
758 | + print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>"; |
|
759 | + print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>"; |
|
760 | + print "<div dojoType='fox.Toolbar'>"; |
|
761 | 761 | |
762 | - if (array_key_exists("search", $_REQUEST)) { |
|
763 | - $_SESSION["prefs_filter_search"] = $filter_search; |
|
764 | - } else { |
|
765 | - $filter_search = $_SESSION["prefs_filter_search"]; |
|
766 | - } |
|
762 | + if (array_key_exists("search", $_REQUEST)) { |
|
763 | + $_SESSION["prefs_filter_search"] = $filter_search; |
|
764 | + } else { |
|
765 | + $filter_search = $_SESSION["prefs_filter_search"]; |
|
766 | + } |
|
767 | 767 | |
768 | - print "<div style='float : right; padding-right : 4px;'> |
|
768 | + print "<div style='float : right; padding-right : 4px;'> |
|
769 | 769 | <input dojoType=\"dijit.form.TextBox\" id=\"filter_search\" size=\"20\" type=\"search\" |
770 | 770 | value=\"$filter_search\"> |
771 | 771 | <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('filterTree').reload()\">". |
772 | - __('Search')."</button> |
|
772 | + __('Search')."</button> |
|
773 | 773 | </div>"; |
774 | 774 | |
775 | - print "<div dojoType=\"fox.form.DropDownButton\">". |
|
776 | - "<span>" . __('Select')."</span>"; |
|
777 | - print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
778 | - print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\" |
|
775 | + print "<div dojoType=\"fox.form.DropDownButton\">". |
|
776 | + "<span>" . __('Select')."</span>"; |
|
777 | + print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
|
778 | + print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\" |
|
779 | 779 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; |
780 | - print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\" |
|
780 | + print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\" |
|
781 | 781 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; |
782 | - print "</div></div>"; |
|
782 | + print "</div></div>"; |
|
783 | 783 | |
784 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return Filters.quickAddFilter()\">". |
|
785 | - __('Create filter')."</button> "; |
|
784 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return Filters.quickAddFilter()\">". |
|
785 | + __('Create filter')."</button> "; |
|
786 | 786 | |
787 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').joinSelectedFilters()\">". |
|
788 | - __('Combine')."</button> "; |
|
787 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').joinSelectedFilters()\">". |
|
788 | + __('Combine')."</button> "; |
|
789 | 789 | |
790 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').editSelectedFilter()\">". |
|
791 | - __('Edit')."</button> "; |
|
790 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').editSelectedFilter()\">". |
|
791 | + __('Edit')."</button> "; |
|
792 | 792 | |
793 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').resetFilterOrder()\">". |
|
794 | - __('Reset sort order')."</button> "; |
|
793 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').resetFilterOrder()\">". |
|
794 | + __('Reset sort order')."</button> "; |
|
795 | 795 | |
796 | 796 | |
797 | - print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').removeSelectedFilters()\">". |
|
798 | - __('Remove')."</button> "; |
|
797 | + print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').removeSelectedFilters()\">". |
|
798 | + __('Remove')."</button> "; |
|
799 | 799 | |
800 | - print "</div>"; # toolbar |
|
801 | - print "</div>"; # toolbar-frame |
|
802 | - print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>"; |
|
800 | + print "</div>"; # toolbar |
|
801 | + print "</div>"; # toolbar-frame |
|
802 | + print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>"; |
|
803 | 803 | |
804 | - print "<div id='filterlistLoading'> |
|
804 | + print "<div id='filterlistLoading'> |
|
805 | 805 | <img src='images/indicator_tiny.gif'>". |
806 | - __("Loading, please wait...")."</div>"; |
|
806 | + __("Loading, please wait...")."</div>"; |
|
807 | 807 | |
808 | - print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\" |
|
808 | + print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\" |
|
809 | 809 | url=\"backend.php?op=pref-filters&method=getfiltertree\"> |
810 | 810 | </div> |
811 | 811 | <div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\" |
@@ -830,152 +830,152 @@ discard block |
||
830 | 830 | |
831 | 831 | </div>"; |
832 | 832 | |
833 | - print "</div>"; #pane |
|
833 | + print "</div>"; #pane |
|
834 | 834 | |
835 | - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
836 | - "hook_prefs_tab", "prefFilters"); |
|
835 | + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, |
|
836 | + "hook_prefs_tab", "prefFilters"); |
|
837 | 837 | |
838 | - print "</div>"; #container |
|
838 | + print "</div>"; #container |
|
839 | 839 | |
840 | - } |
|
840 | + } |
|
841 | 841 | |
842 | - public function newfilter() { |
|
842 | + public function newfilter() { |
|
843 | 843 | |
844 | - print "<form name='filter_new_form' id='filter_new_form' onsubmit='return false'>"; |
|
844 | + print "<form name='filter_new_form' id='filter_new_form' onsubmit='return false'>"; |
|
845 | 845 | |
846 | - print_hidden("op", "pref-filters"); |
|
847 | - print_hidden("method", "add"); |
|
848 | - print_hidden("csrf_token", $_SESSION['csrf_token']); |
|
846 | + print_hidden("op", "pref-filters"); |
|
847 | + print_hidden("method", "add"); |
|
848 | + print_hidden("csrf_token", $_SESSION['csrf_token']); |
|
849 | 849 | |
850 | - print "<header>".__("Caption")."</header>"; |
|
850 | + print "<header>".__("Caption")."</header>"; |
|
851 | 851 | |
852 | - print "<section>"; |
|
853 | - print "<input required='true' dojoType='dijit.form.ValidationTextBox' style='width : 20em;' name='title' value=''>"; |
|
854 | - print "</section>"; |
|
852 | + print "<section>"; |
|
853 | + print "<input required='true' dojoType='dijit.form.ValidationTextBox' style='width : 20em;' name='title' value=''>"; |
|
854 | + print "</section>"; |
|
855 | 855 | |
856 | - print "<header class='horizontal'>".__("Match")."</header >"; |
|
857 | - print "<section>"; |
|
856 | + print "<header class='horizontal'>".__("Match")."</header >"; |
|
857 | + print "<section>"; |
|
858 | 858 | |
859 | - print "<div dojoType='fox.Toolbar'>"; |
|
859 | + print "<div dojoType='fox.Toolbar'>"; |
|
860 | 860 | |
861 | - print "<div dojoType='fox.form.DropDownButton'>". |
|
862 | - "<span>" . __('Select')."</span>"; |
|
863 | - print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
864 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\" |
|
861 | + print "<div dojoType='fox.form.DropDownButton'>". |
|
862 | + "<span>" . __('Select')."</span>"; |
|
863 | + print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
864 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\" |
|
865 | 865 | dojoType='dijit.MenuItem'>".__('All')."</div>"; |
866 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\" |
|
866 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\" |
|
867 | 867 | dojoType='dijit.MenuItem'>".__('None')."</div>"; |
868 | - print "</div></div>"; |
|
868 | + print "</div></div>"; |
|
869 | 869 | |
870 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addRule()\">". |
|
871 | - __('Add')."</button> "; |
|
870 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addRule()\">". |
|
871 | + __('Add')."</button> "; |
|
872 | 872 | |
873 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">". |
|
874 | - __('Delete')."</button> "; |
|
873 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">". |
|
874 | + __('Delete')."</button> "; |
|
875 | 875 | |
876 | - print "</div>"; |
|
876 | + print "</div>"; |
|
877 | 877 | |
878 | - print "<ul id='filterDlg_Matches'>"; |
|
878 | + print "<ul id='filterDlg_Matches'>"; |
|
879 | 879 | # print "<li>No rules</li>"; |
880 | - print "</ul>"; |
|
880 | + print "</ul>"; |
|
881 | 881 | |
882 | - print "</section>"; |
|
882 | + print "</section>"; |
|
883 | 883 | |
884 | - print "<header class='horizontal'>".__("Apply actions")."</header>"; |
|
884 | + print "<header class='horizontal'>".__("Apply actions")."</header>"; |
|
885 | 885 | |
886 | - print "<section>"; |
|
886 | + print "<section>"; |
|
887 | 887 | |
888 | - print "<div dojoType='fox.Toolbar'>"; |
|
888 | + print "<div dojoType='fox.Toolbar'>"; |
|
889 | 889 | |
890 | - print "<div dojoType='fox.form.DropDownButton'>". |
|
891 | - "<span>" . __('Select')."</span>"; |
|
892 | - print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
893 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\" |
|
890 | + print "<div dojoType='fox.form.DropDownButton'>". |
|
891 | + "<span>" . __('Select')."</span>"; |
|
892 | + print "<div dojoType='dijit.Menu' style='display: none'>"; |
|
893 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\" |
|
894 | 894 | dojoType='dijit.MenuItem'>".__('All')."</div>"; |
895 | - print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\" |
|
895 | + print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\" |
|
896 | 896 | dojoType='dijit.MenuItem'>".__('None')."</div>"; |
897 | - print "</div></div>"; |
|
897 | + print "</div></div>"; |
|
898 | 898 | |
899 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addAction()\">". |
|
900 | - __('Add')."</button> "; |
|
899 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addAction()\">". |
|
900 | + __('Add')."</button> "; |
|
901 | 901 | |
902 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">". |
|
903 | - __('Delete')."</button> "; |
|
902 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">". |
|
903 | + __('Delete')."</button> "; |
|
904 | 904 | |
905 | - print "</div>"; |
|
905 | + print "</div>"; |
|
906 | 906 | |
907 | - print "<ul id='filterDlg_Actions'>"; |
|
907 | + print "<ul id='filterDlg_Actions'>"; |
|
908 | 908 | # print "<li>No actions</li>"; |
909 | - print "</ul>"; |
|
909 | + print "</ul>"; |
|
910 | 910 | |
911 | - print "</section>"; |
|
911 | + print "</section>"; |
|
912 | 912 | |
913 | - print "<header>".__("Options")."</header>"; |
|
913 | + print "<header>".__("Options")."</header>"; |
|
914 | 914 | |
915 | - print "<section>"; |
|
916 | - print "<fieldset class='narrow'>"; |
|
915 | + print "<section>"; |
|
916 | + print "<fieldset class='narrow'>"; |
|
917 | 917 | |
918 | - print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='enabled' id='enabled' checked='1'> |
|
918 | + print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='enabled' id='enabled' checked='1'> |
|
919 | 919 | ".__('Enabled')."</label>"; |
920 | 920 | |
921 | - print "</fieldset><fieldset class='narrow'>"; |
|
921 | + print "</fieldset><fieldset class='narrow'>"; |
|
922 | 922 | |
923 | - print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='match_any_rule' id='match_any_rule'> |
|
923 | + print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='match_any_rule' id='match_any_rule'> |
|
924 | 924 | ".__('Match any rule')."</label>"; |
925 | 925 | |
926 | - print "</fieldset><fieldset class='narrow'>"; |
|
926 | + print "</fieldset><fieldset class='narrow'>"; |
|
927 | 927 | |
928 | - print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='inverse' id='inverse'> |
|
928 | + print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='inverse' id='inverse'> |
|
929 | 929 | ".__('Inverse matching')."</label>"; |
930 | 930 | |
931 | - print "</fieldset>"; |
|
931 | + print "</fieldset>"; |
|
932 | 932 | |
933 | - print "</section>"; |
|
933 | + print "</section>"; |
|
934 | 934 | |
935 | - print "<footer>"; |
|
935 | + print "<footer>"; |
|
936 | 936 | |
937 | - print "<button dojoType='dijit.form.Button' class='alt-info' onclick=\"return dijit.byId('filterEditDlg').test()\">". |
|
938 | - __('Test')."</button> "; |
|
939 | - print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"return dijit.byId('filterEditDlg').execute()\">". |
|
940 | - __('Create')."</button> "; |
|
941 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').hide()\">". |
|
942 | - __('Cancel')."</button>"; |
|
937 | + print "<button dojoType='dijit.form.Button' class='alt-info' onclick=\"return dijit.byId('filterEditDlg').test()\">". |
|
938 | + __('Test')."</button> "; |
|
939 | + print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"return dijit.byId('filterEditDlg').execute()\">". |
|
940 | + __('Create')."</button> "; |
|
941 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').hide()\">". |
|
942 | + __('Cancel')."</button>"; |
|
943 | 943 | |
944 | - print "</footer>"; |
|
944 | + print "</footer>"; |
|
945 | 945 | |
946 | - } |
|
946 | + } |
|
947 | 947 | |
948 | - public function newrule() { |
|
949 | - $rule = json_decode(clean($_REQUEST["rule"]), true); |
|
948 | + public function newrule() { |
|
949 | + $rule = json_decode(clean($_REQUEST["rule"]), true); |
|
950 | 950 | |
951 | - if ($rule) { |
|
952 | - $reg_exp = htmlspecialchars($rule["reg_exp"]); |
|
953 | - $filter_type = $rule["filter_type"]; |
|
954 | - $feed_id = $rule["feed_id"]; |
|
955 | - $inverse_checked = isset($rule["inverse"]) ? "checked" : ""; |
|
956 | - } else { |
|
957 | - $reg_exp = ""; |
|
958 | - $filter_type = 1; |
|
959 | - $feed_id = ["0"]; |
|
960 | - $inverse_checked = ""; |
|
961 | - } |
|
951 | + if ($rule) { |
|
952 | + $reg_exp = htmlspecialchars($rule["reg_exp"]); |
|
953 | + $filter_type = $rule["filter_type"]; |
|
954 | + $feed_id = $rule["feed_id"]; |
|
955 | + $inverse_checked = isset($rule["inverse"]) ? "checked" : ""; |
|
956 | + } else { |
|
957 | + $reg_exp = ""; |
|
958 | + $filter_type = 1; |
|
959 | + $feed_id = ["0"]; |
|
960 | + $inverse_checked = ""; |
|
961 | + } |
|
962 | 962 | |
963 | - print "<form name='filter_new_rule_form' id='filter_new_rule_form' onsubmit='return false;'>"; |
|
963 | + print "<form name='filter_new_rule_form' id='filter_new_rule_form' onsubmit='return false;'>"; |
|
964 | 964 | |
965 | - $res = $this->pdo->query("SELECT id,description |
|
965 | + $res = $this->pdo->query("SELECT id,description |
|
966 | 966 | FROM ttrss_filter_types WHERE id != 5 ORDER BY description"); |
967 | 967 | |
968 | - $filter_types = array(); |
|
968 | + $filter_types = array(); |
|
969 | 969 | |
970 | - while ($line = $res->fetch()) { |
|
971 | - $filter_types[$line["id"]] = __($line["description"]); |
|
972 | - } |
|
970 | + while ($line = $res->fetch()) { |
|
971 | + $filter_types[$line["id"]] = __($line["description"]); |
|
972 | + } |
|
973 | 973 | |
974 | - print "<header>".__("Match")."</header>"; |
|
974 | + print "<header>".__("Match")."</header>"; |
|
975 | 975 | |
976 | - print "<section>"; |
|
976 | + print "<section>"; |
|
977 | 977 | |
978 | - print "<input dojoType=\"dijit.form.ValidationTextBox\" |
|
978 | + print "<input dojoType=\"dijit.form.ValidationTextBox\" |
|
979 | 979 | required=\"true\" id=\"filterDlg_regExp\" |
980 | 980 | onchange='Filters.filterDlgCheckRegExp(this)' |
981 | 981 | onblur='Filters.filterDlgCheckRegExp(this)' |
@@ -983,270 +983,270 @@ discard block |
||
983 | 983 | style=\"font-size : 16px; width : 500px\" |
984 | 984 | name=\"reg_exp\" value=\"$reg_exp\"/>"; |
985 | 985 | |
986 | - print "<div dojoType='dijit.Tooltip' id='filterDlg_regExp_tip' connectId='filterDlg_regExp' position='below'></div>"; |
|
986 | + print "<div dojoType='dijit.Tooltip' id='filterDlg_regExp_tip' connectId='filterDlg_regExp' position='below'></div>"; |
|
987 | 987 | |
988 | - print "<fieldset>"; |
|
989 | - print "<label class='checkbox'><input id=\"filterDlg_inverse\" dojoType=\"dijit.form.CheckBox\" |
|
988 | + print "<fieldset>"; |
|
989 | + print "<label class='checkbox'><input id=\"filterDlg_inverse\" dojoType=\"dijit.form.CheckBox\" |
|
990 | 990 | name=\"inverse\" $inverse_checked/> ". |
991 | - __("Inverse regular expression matching")."</label>"; |
|
992 | - print "</fieldset>"; |
|
991 | + __("Inverse regular expression matching")."</label>"; |
|
992 | + print "</fieldset>"; |
|
993 | 993 | |
994 | - print "<fieldset>"; |
|
995 | - print "<label style='display : inline'>". __("on field") . "</label> "; |
|
996 | - print_select_hash("filter_type", $filter_type, $filter_types, |
|
997 | - 'dojoType="fox.form.Select"'); |
|
998 | - print "<label style='padding-left : 10px; display : inline'>" . __("in") . "</label> "; |
|
994 | + print "<fieldset>"; |
|
995 | + print "<label style='display : inline'>". __("on field") . "</label> "; |
|
996 | + print_select_hash("filter_type", $filter_type, $filter_types, |
|
997 | + 'dojoType="fox.form.Select"'); |
|
998 | + print "<label style='padding-left : 10px; display : inline'>" . __("in") . "</label> "; |
|
999 | 999 | |
1000 | - print "</fieldset>"; |
|
1000 | + print "</fieldset>"; |
|
1001 | 1001 | |
1002 | - print "<fieldset>"; |
|
1003 | - print "<span id='filterDlg_feeds'>"; |
|
1004 | - print_feed_multi_select("feed_id", |
|
1005 | - $feed_id, |
|
1006 | - 'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"'); |
|
1007 | - print "</span>"; |
|
1002 | + print "<fieldset>"; |
|
1003 | + print "<span id='filterDlg_feeds'>"; |
|
1004 | + print_feed_multi_select("feed_id", |
|
1005 | + $feed_id, |
|
1006 | + 'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"'); |
|
1007 | + print "</span>"; |
|
1008 | 1008 | |
1009 | - print "</fieldset>"; |
|
1009 | + print "</fieldset>"; |
|
1010 | 1010 | |
1011 | - print "</section>"; |
|
1011 | + print "</section>"; |
|
1012 | 1012 | |
1013 | - print "<footer>"; |
|
1013 | + print "<footer>"; |
|
1014 | 1014 | |
1015 | - print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ContentFilters\")'> |
|
1015 | + print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ContentFilters\")'> |
|
1016 | 1016 | <i class='material-icons'>help</i> ".__("More info...")."</button>"; |
1017 | 1017 | |
1018 | - print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewRuleDlg').execute()\">". |
|
1019 | - ($rule ? __("Save rule") : __('Add rule'))."</button> "; |
|
1018 | + print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewRuleDlg').execute()\">". |
|
1019 | + ($rule ? __("Save rule") : __('Add rule'))."</button> "; |
|
1020 | 1020 | |
1021 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewRuleDlg').hide()\">". |
|
1022 | - __('Cancel')."</button>"; |
|
1021 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewRuleDlg').hide()\">". |
|
1022 | + __('Cancel')."</button>"; |
|
1023 | 1023 | |
1024 | - print "</footer>"; |
|
1024 | + print "</footer>"; |
|
1025 | 1025 | |
1026 | - print "</form>"; |
|
1027 | - } |
|
1026 | + print "</form>"; |
|
1027 | + } |
|
1028 | 1028 | |
1029 | - public function newaction() { |
|
1030 | - $action = json_decode(clean($_REQUEST["action"]), true); |
|
1029 | + public function newaction() { |
|
1030 | + $action = json_decode(clean($_REQUEST["action"]), true); |
|
1031 | 1031 | |
1032 | - if ($action) { |
|
1033 | - $action_param = $action["action_param"]; |
|
1034 | - $action_id = (int)$action["action_id"]; |
|
1035 | - } else { |
|
1036 | - $action_param = ""; |
|
1037 | - $action_id = 0; |
|
1038 | - } |
|
1032 | + if ($action) { |
|
1033 | + $action_param = $action["action_param"]; |
|
1034 | + $action_id = (int)$action["action_id"]; |
|
1035 | + } else { |
|
1036 | + $action_param = ""; |
|
1037 | + $action_id = 0; |
|
1038 | + } |
|
1039 | 1039 | |
1040 | - print "<form name='filter_new_action_form' id='filter_new_action_form' onsubmit='return false;'>"; |
|
1040 | + print "<form name='filter_new_action_form' id='filter_new_action_form' onsubmit='return false;'>"; |
|
1041 | 1041 | |
1042 | - print "<header>".__("Perform Action")."</header>"; |
|
1042 | + print "<header>".__("Perform Action")."</header>"; |
|
1043 | 1043 | |
1044 | - print "<section>"; |
|
1044 | + print "<section>"; |
|
1045 | 1045 | |
1046 | - print "<select name='action_id' dojoType='fox.form.Select' |
|
1046 | + print "<select name='action_id' dojoType='fox.form.Select' |
|
1047 | 1047 | onchange='Filters.filterDlgCheckAction(this)'>"; |
1048 | 1048 | |
1049 | - $res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions |
|
1049 | + $res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions |
|
1050 | 1050 | ORDER BY name"); |
1051 | 1051 | |
1052 | - while ($line = $res->fetch()) { |
|
1053 | - $is_selected = ($line["id"] == $action_id) ? "selected='1'" : ""; |
|
1054 | - printf("<option $is_selected value='%d'>%s</option>", $line["id"], __($line["description"])); |
|
1055 | - } |
|
1052 | + while ($line = $res->fetch()) { |
|
1053 | + $is_selected = ($line["id"] == $action_id) ? "selected='1'" : ""; |
|
1054 | + printf("<option $is_selected value='%d'>%s</option>", $line["id"], __($line["description"])); |
|
1055 | + } |
|
1056 | 1056 | |
1057 | - print "</select>"; |
|
1057 | + print "</select>"; |
|
1058 | 1058 | |
1059 | - $param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ? |
|
1060 | - "" : "display : none"; |
|
1059 | + $param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ? |
|
1060 | + "" : "display : none"; |
|
1061 | 1061 | |
1062 | - $param_hidden = ($action_id == 4 || $action_id == 6) ? |
|
1063 | - "" : "display : none"; |
|
1062 | + $param_hidden = ($action_id == 4 || $action_id == 6) ? |
|
1063 | + "" : "display : none"; |
|
1064 | 1064 | |
1065 | - $label_param_hidden = ($action_id == 7) ? "" : "display : none"; |
|
1066 | - $plugin_param_hidden = ($action_id == 9) ? "" : "display : none"; |
|
1065 | + $label_param_hidden = ($action_id == 7) ? "" : "display : none"; |
|
1066 | + $plugin_param_hidden = ($action_id == 9) ? "" : "display : none"; |
|
1067 | 1067 | |
1068 | - print "<span id='filterDlg_paramBox' style=\"$param_box_hidden\">"; |
|
1069 | - print " "; |
|
1070 | - //print " " . __("with parameters:") . " "; |
|
1071 | - print "<input dojoType='dijit.form.TextBox' |
|
1068 | + print "<span id='filterDlg_paramBox' style=\"$param_box_hidden\">"; |
|
1069 | + print " "; |
|
1070 | + //print " " . __("with parameters:") . " "; |
|
1071 | + print "<input dojoType='dijit.form.TextBox' |
|
1072 | 1072 | id='filterDlg_actionParam' style=\"$param_hidden\" |
1073 | 1073 | name='action_param' value=\"$action_param\">"; |
1074 | 1074 | |
1075 | - print_label_select("action_param_label", $action_param, |
|
1076 | - "id='filterDlg_actionParamLabel' style=\"$label_param_hidden\" |
|
1075 | + print_label_select("action_param_label", $action_param, |
|
1076 | + "id='filterDlg_actionParamLabel' style=\"$label_param_hidden\" |
|
1077 | 1077 | dojoType='fox.form.Select'"); |
1078 | 1078 | |
1079 | - $filter_actions = PluginHost::getInstance()->get_filter_actions(); |
|
1080 | - $filter_action_hash = array(); |
|
1079 | + $filter_actions = PluginHost::getInstance()->get_filter_actions(); |
|
1080 | + $filter_action_hash = array(); |
|
1081 | 1081 | |
1082 | - foreach ($filter_actions as $fclass => $factions) { |
|
1083 | - foreach ($factions as $faction) { |
|
1082 | + foreach ($filter_actions as $fclass => $factions) { |
|
1083 | + foreach ($factions as $faction) { |
|
1084 | 1084 | |
1085 | - $filter_action_hash[$fclass . ":" . $faction["action"]] = |
|
1086 | - $fclass . ": " . $faction["description"]; |
|
1087 | - } |
|
1088 | - } |
|
1085 | + $filter_action_hash[$fclass . ":" . $faction["action"]] = |
|
1086 | + $fclass . ": " . $faction["description"]; |
|
1087 | + } |
|
1088 | + } |
|
1089 | 1089 | |
1090 | - if (count($filter_action_hash) == 0) { |
|
1091 | - $filter_plugin_disabled = "disabled"; |
|
1090 | + if (count($filter_action_hash) == 0) { |
|
1091 | + $filter_plugin_disabled = "disabled"; |
|
1092 | 1092 | |
1093 | - $filter_action_hash["no-data"] = __("No actions available"); |
|
1093 | + $filter_action_hash["no-data"] = __("No actions available"); |
|
1094 | 1094 | |
1095 | - } else { |
|
1096 | - $filter_plugin_disabled = ""; |
|
1097 | - } |
|
1095 | + } else { |
|
1096 | + $filter_plugin_disabled = ""; |
|
1097 | + } |
|
1098 | 1098 | |
1099 | - print_select_hash("filterDlg_actionParamPlugin", $action_param, $filter_action_hash, |
|
1100 | - "style=\"$plugin_param_hidden\" dojoType='fox.form.Select' $filter_plugin_disabled", |
|
1101 | - "action_param_plugin"); |
|
1099 | + print_select_hash("filterDlg_actionParamPlugin", $action_param, $filter_action_hash, |
|
1100 | + "style=\"$plugin_param_hidden\" dojoType='fox.form.Select' $filter_plugin_disabled", |
|
1101 | + "action_param_plugin"); |
|
1102 | 1102 | |
1103 | - print "</span>"; |
|
1103 | + print "</span>"; |
|
1104 | 1104 | |
1105 | - print " "; // tiny layout hack |
|
1105 | + print " "; // tiny layout hack |
|
1106 | 1106 | |
1107 | - print "</section>"; |
|
1107 | + print "</section>"; |
|
1108 | 1108 | |
1109 | - print "<footer>"; |
|
1109 | + print "<footer>"; |
|
1110 | 1110 | |
1111 | - print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewActionDlg').execute()\">". |
|
1112 | - ($action ? __("Save action") : __('Add action'))."</button> "; |
|
1111 | + print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewActionDlg').execute()\">". |
|
1112 | + ($action ? __("Save action") : __('Add action'))."</button> "; |
|
1113 | 1113 | |
1114 | - print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewActionDlg').hide()\">". |
|
1115 | - __('Cancel')."</button>"; |
|
1114 | + print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewActionDlg').hide()\">". |
|
1115 | + __('Cancel')."</button>"; |
|
1116 | 1116 | |
1117 | - print "</footer>"; |
|
1117 | + print "</footer>"; |
|
1118 | 1118 | |
1119 | - print "</form>"; |
|
1120 | - } |
|
1119 | + print "</form>"; |
|
1120 | + } |
|
1121 | 1121 | |
1122 | - private function getFilterName($id) { |
|
1122 | + private function getFilterName($id) { |
|
1123 | 1123 | |
1124 | - $sth = $this->pdo->prepare( |
|
1125 | - "SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions |
|
1124 | + $sth = $this->pdo->prepare( |
|
1125 | + "SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions |
|
1126 | 1126 | FROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r |
1127 | 1127 | ON (r.filter_id = f.id) |
1128 | 1128 | LEFT JOIN ttrss_filters2_actions AS a |
1129 | 1129 | ON (a.filter_id = f.id) WHERE f.id = ? GROUP BY f.title, f.match_any_rule, f.inverse"); |
1130 | - $sth->execute([$id]); |
|
1130 | + $sth->execute([$id]); |
|
1131 | 1131 | |
1132 | - if ($row = $sth->fetch()) { |
|
1132 | + if ($row = $sth->fetch()) { |
|
1133 | 1133 | |
1134 | - $title = $row["title"]; |
|
1135 | - $num_rules = $row["num_rules"]; |
|
1136 | - $num_actions = $row["num_actions"]; |
|
1137 | - $match_any_rule = $row["match_any_rule"]; |
|
1138 | - $inverse = $row["inverse"]; |
|
1134 | + $title = $row["title"]; |
|
1135 | + $num_rules = $row["num_rules"]; |
|
1136 | + $num_actions = $row["num_actions"]; |
|
1137 | + $match_any_rule = $row["match_any_rule"]; |
|
1138 | + $inverse = $row["inverse"]; |
|
1139 | 1139 | |
1140 | - if (!$title) $title = __("[No caption]"); |
|
1140 | + if (!$title) $title = __("[No caption]"); |
|
1141 | 1141 | |
1142 | - $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", (int) $num_rules), $title, $num_rules); |
|
1142 | + $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", (int) $num_rules), $title, $num_rules); |
|
1143 | 1143 | |
1144 | - $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions |
|
1144 | + $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions |
|
1145 | 1145 | WHERE filter_id = ? ORDER BY id LIMIT 1"); |
1146 | - $sth->execute([$id]); |
|
1146 | + $sth->execute([$id]); |
|
1147 | 1147 | |
1148 | - $actions = ""; |
|
1148 | + $actions = ""; |
|
1149 | 1149 | |
1150 | - if ($line = $sth->fetch()) { |
|
1151 | - $actions = $this->getActionName($line); |
|
1150 | + if ($line = $sth->fetch()) { |
|
1151 | + $actions = $this->getActionName($line); |
|
1152 | 1152 | |
1153 | - $num_actions -= 1; |
|
1154 | - } |
|
1153 | + $num_actions -= 1; |
|
1154 | + } |
|
1155 | 1155 | |
1156 | - if ($match_any_rule) $title .= " (" . __("matches any rule") . ")"; |
|
1157 | - if ($inverse) $title .= " (" . __("inverse") . ")"; |
|
1156 | + if ($match_any_rule) $title .= " (" . __("matches any rule") . ")"; |
|
1157 | + if ($inverse) $title .= " (" . __("inverse") . ")"; |
|
1158 | 1158 | |
1159 | - if ($num_actions > 0) |
|
1160 | - $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions); |
|
1159 | + if ($num_actions > 0) |
|
1160 | + $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions); |
|
1161 | 1161 | |
1162 | - return [$title, $actions]; |
|
1163 | - } |
|
1162 | + return [$title, $actions]; |
|
1163 | + } |
|
1164 | 1164 | |
1165 | - return []; |
|
1166 | - } |
|
1165 | + return []; |
|
1166 | + } |
|
1167 | 1167 | |
1168 | - public function join() { |
|
1169 | - $ids = explode(",", clean($_REQUEST["ids"])); |
|
1168 | + public function join() { |
|
1169 | + $ids = explode(",", clean($_REQUEST["ids"])); |
|
1170 | 1170 | |
1171 | - if (count($ids) > 1) { |
|
1172 | - $base_id = array_shift($ids); |
|
1173 | - $ids_qmarks = arr_qmarks($ids); |
|
1171 | + if (count($ids) > 1) { |
|
1172 | + $base_id = array_shift($ids); |
|
1173 | + $ids_qmarks = arr_qmarks($ids); |
|
1174 | 1174 | |
1175 | - $this->pdo->beginTransaction(); |
|
1175 | + $this->pdo->beginTransaction(); |
|
1176 | 1176 | |
1177 | - $sth = $this->pdo->prepare("UPDATE ttrss_filters2_rules |
|
1177 | + $sth = $this->pdo->prepare("UPDATE ttrss_filters2_rules |
|
1178 | 1178 | SET filter_id = ? WHERE filter_id IN ($ids_qmarks)"); |
1179 | - $sth->execute(array_merge([$base_id], $ids)); |
|
1179 | + $sth->execute(array_merge([$base_id], $ids)); |
|
1180 | 1180 | |
1181 | - $sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions |
|
1181 | + $sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions |
|
1182 | 1182 | SET filter_id = ? WHERE filter_id IN ($ids_qmarks)"); |
1183 | - $sth->execute(array_merge([$base_id], $ids)); |
|
1183 | + $sth->execute(array_merge([$base_id], $ids)); |
|
1184 | 1184 | |
1185 | - $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks)"); |
|
1186 | - $sth->execute($ids); |
|
1185 | + $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks)"); |
|
1186 | + $sth->execute($ids); |
|
1187 | 1187 | |
1188 | - $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = ?"); |
|
1189 | - $sth->execute([$base_id]); |
|
1188 | + $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = ?"); |
|
1189 | + $sth->execute([$base_id]); |
|
1190 | 1190 | |
1191 | - $this->pdo->commit(); |
|
1191 | + $this->pdo->commit(); |
|
1192 | 1192 | |
1193 | - $this->optimizeFilter($base_id); |
|
1193 | + $this->optimizeFilter($base_id); |
|
1194 | 1194 | |
1195 | - } |
|
1196 | - } |
|
1195 | + } |
|
1196 | + } |
|
1197 | 1197 | |
1198 | - private function optimizeFilter($id) { |
|
1198 | + private function optimizeFilter($id) { |
|
1199 | 1199 | |
1200 | - $this->pdo->beginTransaction(); |
|
1200 | + $this->pdo->beginTransaction(); |
|
1201 | 1201 | |
1202 | - $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions |
|
1202 | + $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions |
|
1203 | 1203 | WHERE filter_id = ?"); |
1204 | - $sth->execute([$id]); |
|
1204 | + $sth->execute([$id]); |
|
1205 | 1205 | |
1206 | - $tmp = array(); |
|
1207 | - $dupe_ids = array(); |
|
1206 | + $tmp = array(); |
|
1207 | + $dupe_ids = array(); |
|
1208 | 1208 | |
1209 | - while ($line = $sth->fetch()) { |
|
1210 | - $id = $line["id"]; |
|
1211 | - unset($line["id"]); |
|
1209 | + while ($line = $sth->fetch()) { |
|
1210 | + $id = $line["id"]; |
|
1211 | + unset($line["id"]); |
|
1212 | 1212 | |
1213 | - if (array_search($line, $tmp) === false) { |
|
1214 | - array_push($tmp, $line); |
|
1215 | - } else { |
|
1216 | - array_push($dupe_ids, $id); |
|
1217 | - } |
|
1218 | - } |
|
1213 | + if (array_search($line, $tmp) === false) { |
|
1214 | + array_push($tmp, $line); |
|
1215 | + } else { |
|
1216 | + array_push($dupe_ids, $id); |
|
1217 | + } |
|
1218 | + } |
|
1219 | 1219 | |
1220 | - if (count($dupe_ids) > 0) { |
|
1221 | - $ids_str = join(",", $dupe_ids); |
|
1220 | + if (count($dupe_ids) > 0) { |
|
1221 | + $ids_str = join(",", $dupe_ids); |
|
1222 | 1222 | |
1223 | - $this->pdo->query("DELETE FROM ttrss_filters2_actions WHERE id IN ($ids_str)"); |
|
1224 | - } |
|
1223 | + $this->pdo->query("DELETE FROM ttrss_filters2_actions WHERE id IN ($ids_str)"); |
|
1224 | + } |
|
1225 | 1225 | |
1226 | - $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules |
|
1226 | + $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules |
|
1227 | 1227 | WHERE filter_id = ?"); |
1228 | - $sth->execute([$id]); |
|
1228 | + $sth->execute([$id]); |
|
1229 | 1229 | |
1230 | - $tmp = array(); |
|
1231 | - $dupe_ids = array(); |
|
1230 | + $tmp = array(); |
|
1231 | + $dupe_ids = array(); |
|
1232 | 1232 | |
1233 | - while ($line = $sth->fetch()) { |
|
1234 | - $id = $line["id"]; |
|
1235 | - unset($line["id"]); |
|
1233 | + while ($line = $sth->fetch()) { |
|
1234 | + $id = $line["id"]; |
|
1235 | + unset($line["id"]); |
|
1236 | 1236 | |
1237 | - if (array_search($line, $tmp) === false) { |
|
1238 | - array_push($tmp, $line); |
|
1239 | - } else { |
|
1240 | - array_push($dupe_ids, $id); |
|
1241 | - } |
|
1242 | - } |
|
1237 | + if (array_search($line, $tmp) === false) { |
|
1238 | + array_push($tmp, $line); |
|
1239 | + } else { |
|
1240 | + array_push($dupe_ids, $id); |
|
1241 | + } |
|
1242 | + } |
|
1243 | 1243 | |
1244 | - if (count($dupe_ids) > 0) { |
|
1245 | - $ids_str = join(",", $dupe_ids); |
|
1244 | + if (count($dupe_ids) > 0) { |
|
1245 | + $ids_str = join(",", $dupe_ids); |
|
1246 | 1246 | |
1247 | - $this->pdo->query("DELETE FROM ttrss_filters2_rules WHERE id IN ($ids_str)"); |
|
1248 | - } |
|
1247 | + $this->pdo->query("DELETE FROM ttrss_filters2_rules WHERE id IN ($ids_str)"); |
|
1248 | + } |
|
1249 | 1249 | |
1250 | - $this->pdo->commit(); |
|
1251 | - } |
|
1250 | + $this->pdo->commit(); |
|
1251 | + } |
|
1252 | 1252 | } |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | #file_put_contents("/tmp/saveorder.json", clean($_POST['payload'])); |
22 | 22 | #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true); |
23 | 23 | |
24 | - if (!is_array($data['items'])) |
|
25 | - $data['items'] = json_decode($data['items'], true); |
|
24 | + if (!is_array($data['items'])) { |
|
25 | + $data['items'] = json_decode($data['items'], true); |
|
26 | + } |
|
26 | 27 | |
27 | 28 | $index = 0; |
28 | 29 | |
@@ -98,12 +99,16 @@ discard block |
||
98 | 99 | } |
99 | 100 | } |
100 | 101 | |
101 | - if (count($scope_qparts) == 0) $scope_qparts = ["true"]; |
|
102 | + if (count($scope_qparts) == 0) { |
|
103 | + $scope_qparts = ["true"]; |
|
104 | + } |
|
102 | 105 | |
103 | 106 | $glue = $filter['match_any_rule'] ? " OR " : " AND "; |
104 | 107 | $scope_qpart = join($glue, $scope_qparts); |
105 | 108 | |
106 | - if (!$scope_qpart) $scope_qpart = "true"; |
|
109 | + if (!$scope_qpart) { |
|
110 | + $scope_qpart = "true"; |
|
111 | + } |
|
107 | 112 | |
108 | 113 | $rv = array(); |
109 | 114 | |
@@ -161,7 +166,9 @@ discard block |
||
161 | 166 | |
162 | 167 | public function testFilter() { |
163 | 168 | |
164 | - if (isset($_REQUEST["offset"])) return $this->testFilterDo(); |
|
169 | + if (isset($_REQUEST["offset"])) { |
|
170 | + return $this->testFilterDo(); |
|
171 | + } |
|
165 | 172 | |
166 | 173 | //print __("Articles matching this filter:"); |
167 | 174 | |
@@ -206,10 +213,11 @@ discard block |
||
206 | 213 | $feed_id = (int)substr($feed_id, 4); |
207 | 214 | array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
208 | 215 | } else { |
209 | - if ($feed_id) |
|
210 | - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
211 | - else |
|
212 | - array_push($feeds_fmt, __("All feeds")); |
|
216 | + if ($feed_id) { |
|
217 | + array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
218 | + } else { |
|
219 | + array_push($feeds_fmt, __("All feeds")); |
|
220 | + } |
|
213 | 221 | } |
214 | 222 | } |
215 | 223 | |
@@ -396,7 +404,9 @@ discard block |
||
396 | 404 | unset($line["cat_id"]); |
397 | 405 | unset($line["filter_id"]); |
398 | 406 | unset($line["id"]); |
399 | - if (!$line["inverse"]) unset($line["inverse"]); |
|
407 | + if (!$line["inverse"]) { |
|
408 | + unset($line["inverse"]); |
|
409 | + } |
|
400 | 410 | unset($line["match_on"]); |
401 | 411 | |
402 | 412 | $data = htmlspecialchars(json_encode($line)); |
@@ -518,12 +528,16 @@ discard block |
||
518 | 528 | } |
519 | 529 | |
520 | 530 | private function getRuleName($rule) { |
521 | - if (!$rule) $rule = json_decode(clean($_REQUEST["rule"]), true); |
|
531 | + if (!$rule) { |
|
532 | + $rule = json_decode(clean($_REQUEST["rule"]), true); |
|
533 | + } |
|
522 | 534 | |
523 | 535 | $feeds = $rule["feed_id"]; |
524 | 536 | $feeds_fmt = []; |
525 | 537 | |
526 | - if (!is_array($feeds)) $feeds = [$feeds]; |
|
538 | + if (!is_array($feeds)) { |
|
539 | + $feeds = [$feeds]; |
|
540 | + } |
|
527 | 541 | |
528 | 542 | foreach ($feeds as $feed_id) { |
529 | 543 | |
@@ -531,10 +545,11 @@ discard block |
||
531 | 545 | $feed_id = (int)substr($feed_id, 4); |
532 | 546 | array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
533 | 547 | } else { |
534 | - if ($feed_id) |
|
535 | - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
536 | - else |
|
537 | - array_push($feeds_fmt, __("All feeds")); |
|
548 | + if ($feed_id) { |
|
549 | + array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
550 | + } else { |
|
551 | + array_push($feeds_fmt, __("All feeds")); |
|
552 | + } |
|
538 | 553 | } |
539 | 554 | } |
540 | 555 | |
@@ -573,8 +588,9 @@ discard block |
||
573 | 588 | $title = __($row["description"]); |
574 | 589 | |
575 | 590 | if ($action["action_id"] == 4 || $action["action_id"] == 6 || |
576 | - $action["action_id"] == 7) |
|
577 | - $title .= ": " . $action["action_param"]; |
|
591 | + $action["action_id"] == 7) { |
|
592 | + $title .= ": " . $action["action_param"]; |
|
593 | + } |
|
578 | 594 | |
579 | 595 | if ($action["action_id"] == 9) { |
580 | 596 | list ($pfclass, $pfaction) = explode(":", $action["action_param"]); |
@@ -644,8 +660,12 @@ discard block |
||
644 | 660 | $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?"); |
645 | 661 | $sth->execute([$filter_id]); |
646 | 662 | |
647 | - if (!is_array(clean($_REQUEST["rule"]))) $_REQUEST["rule"] = []; |
|
648 | - if (!is_array(clean($_REQUEST["action"]))) $_REQUEST["action"] = []; |
|
663 | + if (!is_array(clean($_REQUEST["rule"]))) { |
|
664 | + $_REQUEST["rule"] = []; |
|
665 | + } |
|
666 | + if (!is_array(clean($_REQUEST["action"]))) { |
|
667 | + $_REQUEST["action"] = []; |
|
668 | + } |
|
649 | 669 | |
650 | 670 | if ($filter_id) { |
651 | 671 | /* create rules */ |
@@ -1137,7 +1157,9 @@ discard block |
||
1137 | 1157 | $match_any_rule = $row["match_any_rule"]; |
1138 | 1158 | $inverse = $row["inverse"]; |
1139 | 1159 | |
1140 | - if (!$title) $title = __("[No caption]"); |
|
1160 | + if (!$title) { |
|
1161 | + $title = __("[No caption]"); |
|
1162 | + } |
|
1141 | 1163 | |
1142 | 1164 | $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", (int) $num_rules), $title, $num_rules); |
1143 | 1165 | |
@@ -1153,11 +1175,16 @@ discard block |
||
1153 | 1175 | $num_actions -= 1; |
1154 | 1176 | } |
1155 | 1177 | |
1156 | - if ($match_any_rule) $title .= " (" . __("matches any rule") . ")"; |
|
1157 | - if ($inverse) $title .= " (" . __("inverse") . ")"; |
|
1178 | + if ($match_any_rule) { |
|
1179 | + $title .= " (" . __("matches any rule") . ")"; |
|
1180 | + } |
|
1181 | + if ($inverse) { |
|
1182 | + $title .= " (" . __("inverse") . ")"; |
|
1183 | + } |
|
1158 | 1184 | |
1159 | - if ($num_actions > 0) |
|
1160 | - $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions); |
|
1185 | + if ($num_actions > 0) { |
|
1186 | + $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions); |
|
1187 | + } |
|
1161 | 1188 | |
1162 | 1189 | return [$title, $actions]; |
1163 | 1190 | } |
@@ -52,14 +52,14 @@ |
||
52 | 52 | |
53 | 53 | public function __construct() { |
54 | 54 | switch (LOG_DESTINATION) { |
55 | - case "sql": |
|
56 | - $this->adapter = new Logger_SQL(); |
|
57 | - break; |
|
58 | - case "syslog": |
|
59 | - $this->adapter = new Logger_Syslog(); |
|
60 | - break; |
|
61 | - default: |
|
62 | - $this->adapter = false; |
|
55 | + case "sql": |
|
56 | + $this->adapter = new Logger_SQL(); |
|
57 | + break; |
|
58 | + case "syslog": |
|
59 | + $this->adapter = new Logger_Syslog(); |
|
60 | + break; |
|
61 | + default: |
|
62 | + $this->adapter = false; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | public function pubOPMLUrl() { |
39 | 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 | 43 | print "<section>"; |
44 | 44 | |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | if ($this->param == 1) { |
68 | 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 | 76 | if ($this->param == 3) { |
77 | 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 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $tags[$line["tag_name"]] = $line["count"]; |
109 | 109 | } |
110 | 110 | |
111 | - if(count($tags) == 0 ){ return; } |
|
111 | + if (count($tags) == 0) { return; } |
|
112 | 112 | |
113 | 113 | ksort($tags); |
114 | 114 | |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 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> '; |
|
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 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 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 | 168 | $feed_title = Feeds::getFeedTitle($feed_id, $is_cat); |
169 | 169 |
@@ -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 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - public static function get_all_labels($owner_uid) { |
|
40 | + public static function get_all_labels($owner_uid) { |
|
41 | 41 | $rv = array(); |
42 | 42 | |
43 | 43 | $pdo = Db::pdo(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | } |
72 | 72 | |
73 | - public static function clear_cache($id) { |
|
73 | + public static function clear_cache($id) { |
|
74 | 74 | |
75 | 75 | $pdo = Db::pdo(); |
76 | 76 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | Labels::clear_cache($id); |
99 | 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 | 103 | $label_id = Labels::find_id($label, $owner_uid); |
104 | 104 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if (!$tr_in_progress) $pdo->commit(); |
172 | 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 | 176 | if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
177 | 177 |
@@ -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 | } |
@@ -56,11 +56,13 @@ discard block |
||
56 | 56 | public static function update_cache($owner_uid, $id, $labels = false, $force = false) { |
57 | 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 | |
62 | - if (!$labels) |
|
63 | - $labels = Article::get_article_labels($id); |
|
63 | + if (!$labels) { |
|
64 | + $labels = Article::get_article_labels($id); |
|
65 | + } |
|
64 | 66 | |
65 | 67 | $labels = json_encode($labels); |
66 | 68 | |
@@ -84,7 +86,9 @@ discard block |
||
84 | 86 | |
85 | 87 | $label_id = Labels::find_id($label, $owner_uid); |
86 | 88 | |
87 | - if (!$label_id) return; |
|
89 | + if (!$label_id) { |
|
90 | + return; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $pdo = Db::pdo(); |
90 | 94 | |
@@ -102,7 +106,9 @@ discard block |
||
102 | 106 | |
103 | 107 | $label_id = Labels::find_id($label, $owner_uid); |
104 | 108 | |
105 | - if (!$label_id) return; |
|
109 | + if (!$label_id) { |
|
110 | + return; |
|
111 | + } |
|
106 | 112 | |
107 | 113 | $pdo = Db::pdo(); |
108 | 114 | |
@@ -128,7 +134,9 @@ discard block |
||
128 | 134 | } |
129 | 135 | |
130 | 136 | public static function remove($id, $owner_uid) { |
131 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
137 | + if (!$owner_uid) { |
|
138 | + $owner_uid = $_SESSION["uid"]; |
|
139 | + } |
|
132 | 140 | |
133 | 141 | $pdo = Db::pdo(); |
134 | 142 | $tr_in_progress = false; |
@@ -168,12 +176,16 @@ discard block |
||
168 | 176 | |
169 | 177 | } |
170 | 178 | |
171 | - if (!$tr_in_progress) $pdo->commit(); |
|
179 | + if (!$tr_in_progress) { |
|
180 | + $pdo->commit(); |
|
181 | + } |
|
172 | 182 | } |
173 | 183 | |
174 | 184 | public static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { |
175 | 185 | |
176 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
186 | + if (!$owner_uid) { |
|
187 | + $owner_uid = $_SESSION['uid']; |
|
188 | + } |
|
177 | 189 | |
178 | 190 | $pdo = Db::pdo(); |
179 | 191 | |
@@ -198,7 +210,9 @@ discard block |
||
198 | 210 | $result = $sth->rowCount(); |
199 | 211 | } |
200 | 212 | |
201 | - if (!$tr_in_progress) $pdo->commit(); |
|
213 | + if (!$tr_in_progress) { |
|
214 | + $pdo->commit(); |
|
215 | + } |
|
202 | 216 | |
203 | 217 | return $result; |
204 | 218 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | private $dir; |
4 | 4 | |
5 | 5 | public function __construct($dir) { |
6 | - $this->dir = CACHE_DIR . "/" . clean_filename($dir); |
|
6 | + $this->dir = CACHE_DIR."/".clean_filename($dir); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | public function getDir() { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function getFullPath($filename) { |
42 | 42 | $filename = clean_filename($filename); |
43 | 43 | |
44 | - return $this->dir . "/" . $filename; |
|
44 | + return $this->dir."/".$filename; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function put($filename, $data) { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | public function getUrl($filename) { |
76 | - return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . $filename; |
|
76 | + return get_self_url_prefix()."/public.php?op=cached_url&file=".basename($this->dir)."/".$filename; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | // check for locally cached (media) URLs and rewrite to local versions |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if (!$res) return ''; |
86 | 86 | |
87 | 87 | $doc = new DOMDocument(); |
88 | - if ($doc->loadHTML('<?xml encoding="UTF-8">' . $res)) { |
|
88 | + if ($doc->loadHTML('<?xml encoding="UTF-8">'.$res)) { |
|
89 | 89 | $xpath = new DOMXPath($doc); |
90 | 90 | $cache = new DiskCache("images"); |
91 | 91 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | public static function expire() { |
129 | - $dirs = array_filter(glob(CACHE_DIR . "/*"), "is_dir"); |
|
129 | + $dirs = array_filter(glob(CACHE_DIR."/*"), "is_dir"); |
|
130 | 130 | |
131 | 131 | foreach ($dirs as $cache_dir) { |
132 | 132 | $num_deleted = 0; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | if ($files) { |
138 | 138 | foreach ($files as $file) { |
139 | - if (time() - filemtime($file) > 86400*CACHE_MAX_DAYS) { |
|
139 | + if (time() - filemtime($file) > 86400 * CACHE_MAX_DAYS) { |
|
140 | 140 | unlink($file); |
141 | 141 | |
142 | 142 | ++$num_deleted; |
@@ -144,7 +144,7 @@ |
||
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - Debug::log("Expired $cache_dir: removed $num_deleted files."); |
|
147 | + Debug::log("expired $cache_dir: removed $num_deleted files."); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | } |
@@ -1,151 +1,151 @@ |
||
1 | 1 | <?php |
2 | 2 | class DiskCache { |
3 | - private $dir; |
|
4 | - |
|
5 | - public function __construct($dir) { |
|
6 | - $this->dir = CACHE_DIR . "/" . clean_filename($dir); |
|
7 | - } |
|
8 | - |
|
9 | - public function getDir() { |
|
10 | - return $this->dir; |
|
11 | - } |
|
12 | - |
|
13 | - public function makeDir() { |
|
14 | - if (!is_dir($this->dir)) { |
|
15 | - return mkdir($this->dir); |
|
16 | - } |
|
17 | - } |
|
18 | - |
|
19 | - public function isWritable($filename = "") { |
|
20 | - if ($filename) { |
|
21 | - if (file_exists($this->getFullPath($filename))) |
|
22 | - return is_writable($this->getFullPath($filename)); |
|
23 | - else |
|
24 | - return is_writable($this->dir); |
|
25 | - } else { |
|
26 | - return is_writable($this->dir); |
|
27 | - } |
|
28 | - } |
|
29 | - |
|
30 | - public function exists($filename) { |
|
31 | - return file_exists($this->getFullPath($filename)); |
|
32 | - } |
|
33 | - |
|
34 | - public function getSize($filename) { |
|
35 | - if ($this->exists($filename)) |
|
36 | - return filesize($this->getFullPath($filename)); |
|
37 | - else |
|
38 | - return -1; |
|
39 | - } |
|
40 | - |
|
41 | - public function getFullPath($filename) { |
|
42 | - $filename = clean_filename($filename); |
|
43 | - |
|
44 | - return $this->dir . "/" . $filename; |
|
45 | - } |
|
46 | - |
|
47 | - public function put($filename, $data) { |
|
48 | - return file_put_contents($this->getFullPath($filename), $data); |
|
49 | - } |
|
50 | - |
|
51 | - public function touch($filename) { |
|
52 | - return touch($this->getFullPath($filename)); |
|
53 | - } |
|
54 | - |
|
55 | - public function get($filename) { |
|
56 | - if ($this->exists($filename)) |
|
57 | - return file_get_contents($this->getFullPath($filename)); |
|
58 | - else |
|
59 | - return null; |
|
60 | - } |
|
61 | - |
|
62 | - public function getMimeType($filename) { |
|
63 | - if ($this->exists($filename)) |
|
64 | - return mime_content_type($this->getFullPath($filename)); |
|
65 | - else |
|
66 | - return null; |
|
67 | - } |
|
68 | - |
|
69 | - public function send($filename) { |
|
70 | - header("Content-Disposition: inline; filename=\"$filename\""); |
|
71 | - |
|
72 | - return send_local_file($this->getFullPath($filename)); |
|
73 | - } |
|
74 | - |
|
75 | - public function getUrl($filename) { |
|
76 | - return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . $filename; |
|
77 | - } |
|
78 | - |
|
79 | - // check for locally cached (media) URLs and rewrite to local versions |
|
80 | - // this is called separately after sanitize() and plugin render article hooks to allow |
|
81 | - // plugins work on original source URLs used before caching |
|
82 | - static public function rewriteUrls($str) |
|
83 | - { |
|
84 | - $res = trim($str); |
|
85 | - if (!$res) return ''; |
|
86 | - |
|
87 | - $doc = new DOMDocument(); |
|
88 | - if ($doc->loadHTML('<?xml encoding="UTF-8">' . $res)) { |
|
89 | - $xpath = new DOMXPath($doc); |
|
90 | - $cache = new DiskCache("images"); |
|
91 | - |
|
92 | - $entries = $xpath->query('(//img[@src]|//picture/source[@src]|//video[@poster]|//video/source[@src]|//audio/source[@src])'); |
|
93 | - |
|
94 | - $need_saving = false; |
|
95 | - |
|
96 | - foreach ($entries as $entry) { |
|
97 | - |
|
98 | - if ($entry->hasAttribute('src') || $entry->hasAttribute('poster')) { |
|
99 | - |
|
100 | - // should be already absolutized because this is called after sanitize() |
|
101 | - $src = $entry->hasAttribute('poster') ? $entry->getAttribute('poster') : $entry->getAttribute('src'); |
|
102 | - $cached_filename = sha1($src); |
|
103 | - |
|
104 | - if ($cache->exists($cached_filename)) { |
|
105 | - |
|
106 | - $src = $cache->getUrl(sha1($src)); |
|
107 | - |
|
108 | - if ($entry->hasAttribute('poster')) |
|
109 | - $entry->setAttribute('poster', $src); |
|
110 | - else { |
|
111 | - $entry->setAttribute('src', $src); |
|
112 | - $entry->removeAttribute("srcset"); |
|
113 | - } |
|
114 | - |
|
115 | - $need_saving = true; |
|
116 | - } |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - if ($need_saving) { |
|
121 | - $doc->removeChild($doc->firstChild); //remove doctype |
|
122 | - $res = $doc->saveHTML(); |
|
123 | - } |
|
124 | - } |
|
125 | - return $res; |
|
126 | - } |
|
127 | - |
|
128 | - public static function expire() { |
|
129 | - $dirs = array_filter(glob(CACHE_DIR . "/*"), "is_dir"); |
|
130 | - |
|
131 | - foreach ($dirs as $cache_dir) { |
|
132 | - $num_deleted = 0; |
|
133 | - |
|
134 | - if (is_writable($cache_dir) && !file_exists("$cache_dir/.no-auto-expiry")) { |
|
135 | - $files = glob("$cache_dir/*"); |
|
136 | - |
|
137 | - if ($files) { |
|
138 | - foreach ($files as $file) { |
|
139 | - if (time() - filemtime($file) > 86400*CACHE_MAX_DAYS) { |
|
140 | - unlink($file); |
|
141 | - |
|
142 | - ++$num_deleted; |
|
143 | - } |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - Debug::log("Expired $cache_dir: removed $num_deleted files."); |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
3 | + private $dir; |
|
4 | + |
|
5 | + public function __construct($dir) { |
|
6 | + $this->dir = CACHE_DIR . "/" . clean_filename($dir); |
|
7 | + } |
|
8 | + |
|
9 | + public function getDir() { |
|
10 | + return $this->dir; |
|
11 | + } |
|
12 | + |
|
13 | + public function makeDir() { |
|
14 | + if (!is_dir($this->dir)) { |
|
15 | + return mkdir($this->dir); |
|
16 | + } |
|
17 | + } |
|
18 | + |
|
19 | + public function isWritable($filename = "") { |
|
20 | + if ($filename) { |
|
21 | + if (file_exists($this->getFullPath($filename))) |
|
22 | + return is_writable($this->getFullPath($filename)); |
|
23 | + else |
|
24 | + return is_writable($this->dir); |
|
25 | + } else { |
|
26 | + return is_writable($this->dir); |
|
27 | + } |
|
28 | + } |
|
29 | + |
|
30 | + public function exists($filename) { |
|
31 | + return file_exists($this->getFullPath($filename)); |
|
32 | + } |
|
33 | + |
|
34 | + public function getSize($filename) { |
|
35 | + if ($this->exists($filename)) |
|
36 | + return filesize($this->getFullPath($filename)); |
|
37 | + else |
|
38 | + return -1; |
|
39 | + } |
|
40 | + |
|
41 | + public function getFullPath($filename) { |
|
42 | + $filename = clean_filename($filename); |
|
43 | + |
|
44 | + return $this->dir . "/" . $filename; |
|
45 | + } |
|
46 | + |
|
47 | + public function put($filename, $data) { |
|
48 | + return file_put_contents($this->getFullPath($filename), $data); |
|
49 | + } |
|
50 | + |
|
51 | + public function touch($filename) { |
|
52 | + return touch($this->getFullPath($filename)); |
|
53 | + } |
|
54 | + |
|
55 | + public function get($filename) { |
|
56 | + if ($this->exists($filename)) |
|
57 | + return file_get_contents($this->getFullPath($filename)); |
|
58 | + else |
|
59 | + return null; |
|
60 | + } |
|
61 | + |
|
62 | + public function getMimeType($filename) { |
|
63 | + if ($this->exists($filename)) |
|
64 | + return mime_content_type($this->getFullPath($filename)); |
|
65 | + else |
|
66 | + return null; |
|
67 | + } |
|
68 | + |
|
69 | + public function send($filename) { |
|
70 | + header("Content-Disposition: inline; filename=\"$filename\""); |
|
71 | + |
|
72 | + return send_local_file($this->getFullPath($filename)); |
|
73 | + } |
|
74 | + |
|
75 | + public function getUrl($filename) { |
|
76 | + return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . $filename; |
|
77 | + } |
|
78 | + |
|
79 | + // check for locally cached (media) URLs and rewrite to local versions |
|
80 | + // this is called separately after sanitize() and plugin render article hooks to allow |
|
81 | + // plugins work on original source URLs used before caching |
|
82 | + static public function rewriteUrls($str) |
|
83 | + { |
|
84 | + $res = trim($str); |
|
85 | + if (!$res) return ''; |
|
86 | + |
|
87 | + $doc = new DOMDocument(); |
|
88 | + if ($doc->loadHTML('<?xml encoding="UTF-8">' . $res)) { |
|
89 | + $xpath = new DOMXPath($doc); |
|
90 | + $cache = new DiskCache("images"); |
|
91 | + |
|
92 | + $entries = $xpath->query('(//img[@src]|//picture/source[@src]|//video[@poster]|//video/source[@src]|//audio/source[@src])'); |
|
93 | + |
|
94 | + $need_saving = false; |
|
95 | + |
|
96 | + foreach ($entries as $entry) { |
|
97 | + |
|
98 | + if ($entry->hasAttribute('src') || $entry->hasAttribute('poster')) { |
|
99 | + |
|
100 | + // should be already absolutized because this is called after sanitize() |
|
101 | + $src = $entry->hasAttribute('poster') ? $entry->getAttribute('poster') : $entry->getAttribute('src'); |
|
102 | + $cached_filename = sha1($src); |
|
103 | + |
|
104 | + if ($cache->exists($cached_filename)) { |
|
105 | + |
|
106 | + $src = $cache->getUrl(sha1($src)); |
|
107 | + |
|
108 | + if ($entry->hasAttribute('poster')) |
|
109 | + $entry->setAttribute('poster', $src); |
|
110 | + else { |
|
111 | + $entry->setAttribute('src', $src); |
|
112 | + $entry->removeAttribute("srcset"); |
|
113 | + } |
|
114 | + |
|
115 | + $need_saving = true; |
|
116 | + } |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + if ($need_saving) { |
|
121 | + $doc->removeChild($doc->firstChild); //remove doctype |
|
122 | + $res = $doc->saveHTML(); |
|
123 | + } |
|
124 | + } |
|
125 | + return $res; |
|
126 | + } |
|
127 | + |
|
128 | + public static function expire() { |
|
129 | + $dirs = array_filter(glob(CACHE_DIR . "/*"), "is_dir"); |
|
130 | + |
|
131 | + foreach ($dirs as $cache_dir) { |
|
132 | + $num_deleted = 0; |
|
133 | + |
|
134 | + if (is_writable($cache_dir) && !file_exists("$cache_dir/.no-auto-expiry")) { |
|
135 | + $files = glob("$cache_dir/*"); |
|
136 | + |
|
137 | + if ($files) { |
|
138 | + foreach ($files as $file) { |
|
139 | + if (time() - filemtime($file) > 86400*CACHE_MAX_DAYS) { |
|
140 | + unlink($file); |
|
141 | + |
|
142 | + ++$num_deleted; |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + Debug::log("Expired $cache_dir: removed $num_deleted files."); |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | 151 | } |
@@ -18,10 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | public function isWritable($filename = "") { |
20 | 20 | if ($filename) { |
21 | - if (file_exists($this->getFullPath($filename))) |
|
22 | - return is_writable($this->getFullPath($filename)); |
|
23 | - else |
|
24 | - return is_writable($this->dir); |
|
21 | + if (file_exists($this->getFullPath($filename))) { |
|
22 | + return is_writable($this->getFullPath($filename)); |
|
23 | + } else { |
|
24 | + return is_writable($this->dir); |
|
25 | + } |
|
25 | 26 | } else { |
26 | 27 | return is_writable($this->dir); |
27 | 28 | } |
@@ -32,10 +33,11 @@ discard block |
||
32 | 33 | } |
33 | 34 | |
34 | 35 | public function getSize($filename) { |
35 | - if ($this->exists($filename)) |
|
36 | - return filesize($this->getFullPath($filename)); |
|
37 | - else |
|
38 | - return -1; |
|
36 | + if ($this->exists($filename)) { |
|
37 | + return filesize($this->getFullPath($filename)); |
|
38 | + } else { |
|
39 | + return -1; |
|
40 | + } |
|
39 | 41 | } |
40 | 42 | |
41 | 43 | public function getFullPath($filename) { |
@@ -53,17 +55,19 @@ discard block |
||
53 | 55 | } |
54 | 56 | |
55 | 57 | public function get($filename) { |
56 | - if ($this->exists($filename)) |
|
57 | - return file_get_contents($this->getFullPath($filename)); |
|
58 | - else |
|
59 | - return null; |
|
58 | + if ($this->exists($filename)) { |
|
59 | + return file_get_contents($this->getFullPath($filename)); |
|
60 | + } else { |
|
61 | + return null; |
|
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | 65 | public function getMimeType($filename) { |
63 | - if ($this->exists($filename)) |
|
64 | - return mime_content_type($this->getFullPath($filename)); |
|
65 | - else |
|
66 | - return null; |
|
66 | + if ($this->exists($filename)) { |
|
67 | + return mime_content_type($this->getFullPath($filename)); |
|
68 | + } else { |
|
69 | + return null; |
|
70 | + } |
|
67 | 71 | } |
68 | 72 | |
69 | 73 | public function send($filename) { |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | static public function rewriteUrls($str) |
83 | 87 | { |
84 | 88 | $res = trim($str); |
85 | - if (!$res) return ''; |
|
89 | + if (!$res) { |
|
90 | + return ''; |
|
91 | + } |
|
86 | 92 | |
87 | 93 | $doc = new DOMDocument(); |
88 | 94 | if ($doc->loadHTML('<?xml encoding="UTF-8">' . $res)) { |
@@ -105,9 +111,9 @@ discard block |
||
105 | 111 | |
106 | 112 | $src = $cache->getUrl(sha1($src)); |
107 | 113 | |
108 | - if ($entry->hasAttribute('poster')) |
|
109 | - $entry->setAttribute('poster', $src); |
|
110 | - else { |
|
114 | + if ($entry->hasAttribute('poster')) { |
|
115 | + $entry->setAttribute('poster', $src); |
|
116 | + } else { |
|
111 | 117 | $entry->setAttribute('src', $src); |
112 | 118 | $entry->removeAttribute("srcset"); |
113 | 119 | } |