@@ -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 | } |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | public static function log($message, $level = 0) { |
38 | 38 | |
39 | - if (!Debug::$enabled || Debug::$loglevel < $level) return false; |
|
39 | + if (!Debug::$enabled || Debug::$loglevel < $level) { |
|
40 | + return false; |
|
41 | + } |
|
40 | 42 | |
41 | 43 | $ts = strftime("%H:%M:%S", time()); |
42 | 44 | if (function_exists('posix_getpid')) { |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | |
74 | 76 | fclose($fp); |
75 | 77 | |
76 | - if (Debug::$quiet) |
|
77 | - return; |
|
78 | + if (Debug::$quiet) { |
|
79 | + return; |
|
80 | + } |
|
78 | 81 | |
79 | 82 | } else { |
80 | 83 | user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); |
@@ -14,7 +14,9 @@ |
||
14 | 14 | if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
15 | 15 | $user_id = $this->find_user_by_login($login); |
16 | 16 | |
17 | - if (!$password) $password = make_password(); |
|
17 | + if (!$password) { |
|
18 | + $password = make_password(); |
|
19 | + } |
|
18 | 20 | |
19 | 21 | if (!$user_id) { |
20 | 22 | $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | $source = $elem->getElementsByTagName("source")->item(0); |
15 | 15 | |
16 | 16 | // we don't need <source> element |
17 | - if ($source) |
|
18 | - $elem->removeChild($source); |
|
17 | + if ($source) { |
|
18 | + $elem->removeChild($source); |
|
19 | + } |
|
19 | 20 | } catch (DOMException $e) { |
20 | 21 | // |
21 | 22 | } |
@@ -31,14 +32,19 @@ discard block |
||
31 | 32 | if ($author) { |
32 | 33 | $name = $author->getElementsByTagName("name")->item(0); |
33 | 34 | |
34 | - if ($name) return clean($name->nodeValue); |
|
35 | + if ($name) { |
|
36 | + return clean($name->nodeValue); |
|
37 | + } |
|
35 | 38 | |
36 | 39 | $email = $author->getElementsByTagName("email")->item(0); |
37 | 40 | |
38 | - if ($email) return clean($email->nodeValue); |
|
41 | + if ($email) { |
|
42 | + return clean($email->nodeValue); |
|
43 | + } |
|
39 | 44 | |
40 | - if ($author->nodeValue) |
|
41 | - return clean($author->nodeValue); |
|
45 | + if ($author->nodeValue) { |
|
46 | + return clean($author->nodeValue); |
|
47 | + } |
|
42 | 48 | } |
43 | 49 | |
44 | 50 | $author_elems = $this->xpath->query("dc:creator", $this->elem); |
@@ -56,15 +62,17 @@ discard block |
||
56 | 62 | //might give a wrong result if a default namespace was declared (possible with XPath 2.0) |
57 | 63 | $com_url = $this->xpath->query("comments", $this->elem)->item(0); |
58 | 64 | |
59 | - if ($com_url) |
|
60 | - return clean($com_url->nodeValue); |
|
65 | + if ($com_url) { |
|
66 | + return clean($com_url->nodeValue); |
|
67 | + } |
|
61 | 68 | |
62 | 69 | //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common. |
63 | 70 | //'text/html' for type is too restrictive? |
64 | 71 | $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0); |
65 | 72 | |
66 | - if ($com_url) |
|
67 | - return clean($com_url->nodeValue); |
|
73 | + if ($com_url) { |
|
74 | + return clean($com_url->nodeValue); |
|
75 | + } |
|
68 | 76 | } |
69 | 77 | |
70 | 78 | public function get_comments_count() { |
@@ -98,7 +106,9 @@ discard block |
||
98 | 106 | } |
99 | 107 | |
100 | 108 | $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
101 | - if ($desc) $enc->title = clean($desc->nodeValue); |
|
109 | + if ($desc) { |
|
110 | + $enc->title = clean($desc->nodeValue); |
|
111 | + } |
|
102 | 112 | |
103 | 113 | array_push($encs, $enc); |
104 | 114 | } |
@@ -127,7 +137,9 @@ discard block |
||
127 | 137 | $enc->title = clean($desc->nodeValue); |
128 | 138 | } else { |
129 | 139 | $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
130 | - if ($desc) $enc->title = clean($desc->nodeValue); |
|
140 | + if ($desc) { |
|
141 | + $enc->title = clean($desc->nodeValue); |
|
142 | + } |
|
131 | 143 | } |
132 | 144 | |
133 | 145 | array_push($encs, $enc); |
@@ -174,8 +186,9 @@ discard block |
||
174 | 186 | $cat = clean(trim(mb_strtolower($srccat))); |
175 | 187 | |
176 | 188 | // we don't support numeric tags |
177 | - if (is_numeric($cat)) |
|
178 | - $cat = 't:' . $cat; |
|
189 | + if (is_numeric($cat)) { |
|
190 | + $cat = 't:' . $cat; |
|
191 | + } |
|
179 | 192 | |
180 | 193 | $cat = preg_replace('/[,\'\"]/', "", $cat); |
181 | 194 | |
@@ -183,8 +196,9 @@ discard block |
||
183 | 196 | $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat); |
184 | 197 | } |
185 | 198 | |
186 | - if (mb_strlen($cat) > 250) |
|
187 | - $cat = mb_substr($cat, 0, 250); |
|
199 | + if (mb_strlen($cat) > 250) { |
|
200 | + $cat = mb_substr($cat, 0, 250); |
|
201 | + } |
|
188 | 202 | |
189 | 203 | return $cat; |
190 | 204 | }, $tmp); |
@@ -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 | } |
@@ -80,7 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | // Update the least recently updated feeds first |
82 | 82 | $query_order = "ORDER BY last_updated"; |
83 | - if (DB_TYPE == "pgsql") $query_order .= " NULLS FIRST"; |
|
83 | + if (DB_TYPE == "pgsql") { |
|
84 | + $query_order .= " NULLS FIRST"; |
|
85 | + } |
|
84 | 86 | |
85 | 87 | $query = "SELECT DISTINCT ttrss_feeds.feed_url, ttrss_feeds.last_updated |
86 | 88 | FROM |
@@ -139,8 +141,9 @@ discard block |
||
139 | 141 | if ($tline = $usth->fetch()) { |
140 | 142 | Debug::log(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]); |
141 | 143 | |
142 | - if (array_search($tline["owner_uid"], $batch_owners) === FALSE) |
|
143 | - array_push($batch_owners, $tline["owner_uid"]); |
|
144 | + if (array_search($tline["owner_uid"], $batch_owners) === FALSE) { |
|
145 | + array_push($batch_owners, $tline["owner_uid"]); |
|
146 | + } |
|
144 | 147 | |
145 | 148 | $fstarted = microtime(true); |
146 | 149 | |
@@ -311,11 +314,13 @@ discard block |
||
311 | 314 | |
312 | 315 | $feed_language = mb_strtolower($row["feed_language"]); |
313 | 316 | |
314 | - if (!$feed_language) |
|
315 | - $feed_language = mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid)); |
|
317 | + if (!$feed_language) { |
|
318 | + $feed_language = mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid)); |
|
319 | + } |
|
316 | 320 | |
317 | - if (!$feed_language) |
|
318 | - $feed_language = 'simple'; |
|
321 | + if (!$feed_language) { |
|
322 | + $feed_language = 'simple'; |
|
323 | + } |
|
319 | 324 | |
320 | 325 | } else { |
321 | 326 | return false; |
@@ -514,8 +519,9 @@ discard block |
||
514 | 519 | RSSUtils::check_feed_favicon($site_url, $feed); |
515 | 520 | $favicon_modified_new = @filemtime($favicon_file); |
516 | 521 | |
517 | - if ($favicon_modified_new > $favicon_modified) |
|
518 | - $favicon_avg_color = ''; |
|
522 | + if ($favicon_modified_new > $favicon_modified) { |
|
523 | + $favicon_avg_color = ''; |
|
524 | + } |
|
519 | 525 | |
520 | 526 | $favicon_colorstring = ""; |
521 | 527 | if (file_exists($favicon_file) && function_exists("imagecreatefromstring") && $favicon_avg_color == '') { |
@@ -578,8 +584,12 @@ discard block |
||
578 | 584 | } |
579 | 585 | |
580 | 586 | $entry_guid = strip_tags($item->get_id()); |
581 | - if (!$entry_guid) $entry_guid = strip_tags($item->get_link()); |
|
582 | - if (!$entry_guid) $entry_guid = RSSUtils::make_guid_from_title($item->get_title()); |
|
587 | + if (!$entry_guid) { |
|
588 | + $entry_guid = strip_tags($item->get_link()); |
|
589 | + } |
|
590 | + if (!$entry_guid) { |
|
591 | + $entry_guid = RSSUtils::make_guid_from_title($item->get_title()); |
|
592 | + } |
|
583 | 593 | |
584 | 594 | if (!$entry_guid) { |
585 | 595 | $pdo->commit(); |
@@ -606,10 +616,15 @@ discard block |
||
606 | 616 | Debug::log("link $entry_link", Debug::$LOG_VERBOSE); |
607 | 617 | Debug::log("language $entry_language", Debug::$LOG_VERBOSE); |
608 | 618 | |
609 | - if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp);; |
|
619 | + if (!$entry_title) { |
|
620 | + $entry_title = date("Y-m-d H:i:s", $entry_timestamp); |
|
621 | + } |
|
622 | + ; |
|
610 | 623 | |
611 | 624 | $entry_content = $item->get_content(); |
612 | - if (!$entry_content) $entry_content = $item->get_description(); |
|
625 | + if (!$entry_content) { |
|
626 | + $entry_content = $item->get_description(); |
|
627 | + } |
|
613 | 628 | |
614 | 629 | if (Debug::get_loglevel() >= 3) { |
615 | 630 | print "content: "; |
@@ -824,8 +839,9 @@ discard block |
||
824 | 839 | |
825 | 840 | Debug::log("force catchup: $entry_force_catchup", Debug::$LOG_VERBOSE); |
826 | 841 | |
827 | - if ($cache_images) |
|
828 | - RSSUtils::cache_media($entry_content, $site_url); |
|
842 | + if ($cache_images) { |
|
843 | + RSSUtils::cache_media($entry_content, $site_url); |
|
844 | + } |
|
829 | 845 | |
830 | 846 | $csth = $pdo->prepare("SELECT id FROM ttrss_entries |
831 | 847 | WHERE guid = ? OR guid = ?"); |
@@ -951,16 +967,18 @@ discard block |
||
951 | 967 | |
952 | 968 | $sth->execute([$ref_id, $owner_uid, $feed]); |
953 | 969 | |
954 | - if ($row = $sth->fetch()) |
|
955 | - $entry_int_id = $row['int_id']; |
|
970 | + if ($row = $sth->fetch()) { |
|
971 | + $entry_int_id = $row['int_id']; |
|
972 | + } |
|
956 | 973 | } |
957 | 974 | |
958 | 975 | Debug::log("resulting RID: $entry_ref_id, IID: $entry_int_id", Debug::$LOG_VERBOSE); |
959 | 976 | |
960 | - if (DB_TYPE == "pgsql") |
|
961 | - $tsvector_qpart = "tsvector_combined = to_tsvector(:ts_lang, :ts_content),"; |
|
962 | - else |
|
963 | - $tsvector_qpart = ""; |
|
977 | + if (DB_TYPE == "pgsql") { |
|
978 | + $tsvector_qpart = "tsvector_combined = to_tsvector(:ts_lang, :ts_content),"; |
|
979 | + } else { |
|
980 | + $tsvector_qpart = ""; |
|
981 | + } |
|
964 | 982 | |
965 | 983 | $sth = $pdo->prepare("UPDATE ttrss_entries |
966 | 984 | SET title = :title, |
@@ -1049,8 +1067,9 @@ discard block |
||
1049 | 1067 | } |
1050 | 1068 | } |
1051 | 1069 | |
1052 | - if ($cache_images) |
|
1053 | - RSSUtils::cache_enclosures($enclosures, $site_url); |
|
1070 | + if ($cache_images) { |
|
1071 | + RSSUtils::cache_enclosures($enclosures, $site_url); |
|
1072 | + } |
|
1054 | 1073 | |
1055 | 1074 | if (Debug::get_loglevel() >= Debug::$LOG_EXTENDED) { |
1056 | 1075 | Debug::log("article enclosures:", Debug::$LOG_VERBOSE); |
@@ -1345,8 +1364,9 @@ discard block |
||
1345 | 1364 | $reg_exp = str_replace('/', '\/', $rule["reg_exp"]); |
1346 | 1365 | $rule_inverse = $rule["inverse"]; |
1347 | 1366 | |
1348 | - if (!$reg_exp) |
|
1349 | - continue; |
|
1367 | + if (!$reg_exp) { |
|
1368 | + continue; |
|
1369 | + } |
|
1350 | 1370 | |
1351 | 1371 | switch ($rule["type"]) { |
1352 | 1372 | case "title": |
@@ -1380,7 +1400,9 @@ discard block |
||
1380 | 1400 | break; |
1381 | 1401 | } |
1382 | 1402 | |
1383 | - if ($rule_inverse) $match = !$match; |
|
1403 | + if ($rule_inverse) { |
|
1404 | + $match = !$match; |
|
1405 | + } |
|
1384 | 1406 | |
1385 | 1407 | if ($match_any_rule) { |
1386 | 1408 | if ($match) { |
@@ -1395,17 +1417,25 @@ discard block |
||
1395 | 1417 | } |
1396 | 1418 | } |
1397 | 1419 | |
1398 | - if ($inverse) $filter_match = !$filter_match; |
|
1420 | + if ($inverse) { |
|
1421 | + $filter_match = !$filter_match; |
|
1422 | + } |
|
1399 | 1423 | |
1400 | 1424 | if ($filter_match) { |
1401 | - if (is_array($matched_rules)) array_push($matched_rules, $rule); |
|
1402 | - if (is_array($matched_filters)) array_push($matched_filters, $filter); |
|
1425 | + if (is_array($matched_rules)) { |
|
1426 | + array_push($matched_rules, $rule); |
|
1427 | + } |
|
1428 | + if (is_array($matched_filters)) { |
|
1429 | + array_push($matched_filters, $filter); |
|
1430 | + } |
|
1403 | 1431 | |
1404 | 1432 | foreach ($filter["actions"] AS $action) { |
1405 | 1433 | array_push($matches, $action); |
1406 | 1434 | |
1407 | 1435 | // if Stop action encountered, perform no further processing |
1408 | - if (isset($action["type"]) && $action["type"] == "stop") return $matches; |
|
1436 | + if (isset($action["type"]) && $action["type"] == "stop") { |
|
1437 | + return $matches; |
|
1438 | + } |
|
1409 | 1439 | } |
1410 | 1440 | } |
1411 | 1441 | } |
@@ -1531,24 +1561,19 @@ discard block |
||
1531 | 1561 | if (preg_match('/^\x00\x00\x01\x00/', $contents)) { |
1532 | 1562 | // 0 string \000\000\001\000 MS Windows icon resource |
1533 | 1563 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa MS Windows icon resource"); |
1534 | - } |
|
1535 | - elseif (preg_match('/^GIF8/', $contents)) { |
|
1564 | + } elseif (preg_match('/^GIF8/', $contents)) { |
|
1536 | 1565 | // 0 string GIF8 GIF image data |
1537 | 1566 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa GIF image"); |
1538 | - } |
|
1539 | - elseif (preg_match('/^\x89PNG\x0d\x0a\x1a\x0a/', $contents)) { |
|
1567 | + } elseif (preg_match('/^\x89PNG\x0d\x0a\x1a\x0a/', $contents)) { |
|
1540 | 1568 | // 0 string \x89PNG\x0d\x0a\x1a\x0a PNG image data |
1541 | 1569 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa PNG image"); |
1542 | - } |
|
1543 | - elseif (preg_match('/^\xff\xd8/', $contents)) { |
|
1570 | + } elseif (preg_match('/^\xff\xd8/', $contents)) { |
|
1544 | 1571 | // 0 beshort 0xffd8 JPEG image data |
1545 | 1572 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa JPG image"); |
1546 | - } |
|
1547 | - elseif (preg_match('/^BM/', $contents)) { |
|
1573 | + } elseif (preg_match('/^BM/', $contents)) { |
|
1548 | 1574 | // 0 string BM PC bitmap (OS2, Windows BMP files) |
1549 | 1575 | //error_log("check_feed_favicon, favicon_url=$favicon_url isa BMP image"); |
1550 | - } |
|
1551 | - else { |
|
1576 | + } else { |
|
1552 | 1577 | //error_log("check_feed_favicon: favicon_url=$favicon_url isa UNKNOWN type"); |
1553 | 1578 | $contents = ""; |
1554 | 1579 | } |
@@ -1579,10 +1604,11 @@ discard block |
||
1579 | 1604 | $feed_id = (int) $feed_id; |
1580 | 1605 | $cat_id = (int)Feeds::getFeedCategory($feed_id); |
1581 | 1606 | |
1582 | - if ($cat_id == 0) |
|
1583 | - $null_cat_qpart = "cat_id IS NULL OR"; |
|
1584 | - else |
|
1585 | - $null_cat_qpart = ""; |
|
1607 | + if ($cat_id == 0) { |
|
1608 | + $null_cat_qpart = "cat_id IS NULL OR"; |
|
1609 | + } else { |
|
1610 | + $null_cat_qpart = ""; |
|
1611 | + } |
|
1586 | 1612 | |
1587 | 1613 | $pdo = Db::pdo(); |
1588 | 1614 | |
@@ -1718,8 +1744,9 @@ discard block |
||
1718 | 1744 | } |
1719 | 1745 | } |
1720 | 1746 | |
1721 | - if (!$favicon_url) |
|
1722 | - $favicon_url = rewrite_relative_url($url, "/favicon.ico"); |
|
1747 | + if (!$favicon_url) { |
|
1748 | + $favicon_url = rewrite_relative_url($url, "/favicon.ico"); |
|
1749 | + } |
|
1723 | 1750 | |
1724 | 1751 | return $favicon_url; |
1725 | 1752 | } |
@@ -82,8 +82,9 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | public static function getInstance() { |
85 | - if (self::$instance == null) |
|
86 | - self::$instance = new self(); |
|
85 | + if (self::$instance == null) { |
|
86 | + self::$instance = new self(); |
|
87 | + } |
|
87 | 88 | |
88 | 89 | return self::$instance; |
89 | 90 | } |
@@ -191,7 +192,9 @@ discard block |
||
191 | 192 | $class_file = strtolower(clean_filename($class)); |
192 | 193 | |
193 | 194 | if (!is_dir(__DIR__."/../plugins/$class_file") && |
194 | - !is_dir(__DIR__."/../plugins.local/$class_file")) continue; |
|
195 | + !is_dir(__DIR__."/../plugins.local/$class_file")) { |
|
196 | + continue; |
|
197 | + } |
|
195 | 198 | |
196 | 199 | // try system plugin directory first |
197 | 200 | $file = __DIR__ . "/../plugins/$class_file/init.php"; |
@@ -203,7 +206,9 @@ discard block |
||
203 | 206 | } |
204 | 207 | |
205 | 208 | if (!isset($this->plugins[$class])) { |
206 | - if (file_exists($file)) require_once $file; |
|
209 | + if (file_exists($file)) { |
|
210 | + require_once $file; |
|
211 | + } |
|
207 | 212 | |
208 | 213 | if (class_exists($class) && is_subclass_of($class, "Plugin")) { |
209 | 214 | |
@@ -219,8 +224,9 @@ discard block |
||
219 | 224 | if ($namespace && $class_name) { |
220 | 225 | $class_file = "$vendor_dir/$namespace/" . str_replace('\\', '/', $class_name) . ".php"; |
221 | 226 | |
222 | - if (file_exists($class_file)) |
|
223 | - require_once $class_file; |
|
227 | + if (file_exists($class_file)) { |
|
228 | + require_once $class_file; |
|
229 | + } |
|
224 | 230 | } |
225 | 231 | } |
226 | 232 | }); |
@@ -245,18 +251,24 @@ discard block |
||
245 | 251 | switch ($kind) { |
246 | 252 | case $this::KIND_SYSTEM: |
247 | 253 | if ($this->is_system($plugin)) { |
248 | - if (!$skip_init) $plugin->init($this); |
|
254 | + if (!$skip_init) { |
|
255 | + $plugin->init($this); |
|
256 | + } |
|
249 | 257 | $this->register_plugin($class, $plugin); |
250 | 258 | } |
251 | 259 | break; |
252 | 260 | case $this::KIND_USER: |
253 | 261 | if (!$this->is_system($plugin)) { |
254 | - if (!$skip_init) $plugin->init($this); |
|
262 | + if (!$skip_init) { |
|
263 | + $plugin->init($this); |
|
264 | + } |
|
255 | 265 | $this->register_plugin($class, $plugin); |
256 | 266 | } |
257 | 267 | break; |
258 | 268 | case $this::KIND_ALL: |
259 | - if (!$skip_init) $plugin->init($this); |
|
269 | + if (!$skip_init) { |
|
270 | + $plugin->init($this); |
|
271 | + } |
|
260 | 272 | $this->register_plugin($class, $plugin); |
261 | 273 | break; |
262 | 274 | } |
@@ -367,8 +379,9 @@ discard block |
||
367 | 379 | owner_uid= ? AND name = ?"); |
368 | 380 | $sth->execute([$this->owner_uid, $plugin]); |
369 | 381 | |
370 | - if (!isset($this->storage[$plugin])) |
|
371 | - $this->storage[$plugin] = array(); |
|
382 | + if (!isset($this->storage[$plugin])) { |
|
383 | + $this->storage[$plugin] = array(); |
|
384 | + } |
|
372 | 385 | |
373 | 386 | $content = serialize($this->storage[$plugin]); |
374 | 387 | |
@@ -391,12 +404,15 @@ discard block |
||
391 | 404 | public function set($sender, $name, $value, $sync = true) { |
392 | 405 | $idx = get_class($sender); |
393 | 406 | |
394 | - if (!isset($this->storage[$idx])) |
|
395 | - $this->storage[$idx] = array(); |
|
407 | + if (!isset($this->storage[$idx])) { |
|
408 | + $this->storage[$idx] = array(); |
|
409 | + } |
|
396 | 410 | |
397 | 411 | $this->storage[$idx][$name] = $value; |
398 | 412 | |
399 | - if ($sync) $this->save_data(get_class($sender)); |
|
413 | + if ($sync) { |
|
414 | + $this->save_data(get_class($sender)); |
|
415 | + } |
|
400 | 416 | } |
401 | 417 | |
402 | 418 | public function get($sender, $name, $default_value = false) { |
@@ -433,7 +449,9 @@ discard block |
||
433 | 449 | |
434 | 450 | // cat_id: only -1 is supported (Special) |
435 | 451 | public function add_feed($cat_id, $title, $icon, $sender) { |
436 | - if (!$this->feeds[$cat_id]) $this->feeds[$cat_id] = array(); |
|
452 | + if (!$this->feeds[$cat_id]) { |
|
453 | + $this->feeds[$cat_id] = array(); |
|
454 | + } |
|
437 | 455 | |
438 | 456 | $id = count($this->feeds[$cat_id]); |
439 | 457 | |
@@ -479,8 +497,9 @@ discard block |
||
479 | 497 | public function add_filter_action($sender, $action_name, $action_desc) { |
480 | 498 | $sender_class = get_class($sender); |
481 | 499 | |
482 | - if (!isset($this->plugin_actions[$sender_class])) |
|
483 | - $this->plugin_actions[$sender_class] = array(); |
|
500 | + if (!isset($this->plugin_actions[$sender_class])) { |
|
501 | + $this->plugin_actions[$sender_class] = array(); |
|
502 | + } |
|
484 | 503 | |
485 | 504 | array_push($this->plugin_actions[$sender_class], |
486 | 505 | array("action" => $action_name, "description" => $action_desc, "sender" => $sender)); |
@@ -52,10 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | $cat_id = (int) $cat_id; |
54 | 54 | |
55 | - if ($hide_private_feeds) |
|
56 | - $hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')"; |
|
57 | - else |
|
58 | - $hide_qpart = "true"; |
|
55 | + if ($hide_private_feeds) { |
|
56 | + $hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')"; |
|
57 | + } else { |
|
58 | + $hide_qpart = "true"; |
|
59 | + } |
|
59 | 60 | |
60 | 61 | $out = ""; |
61 | 62 | |
@@ -77,7 +78,9 @@ discard block |
||
77 | 78 | $cat_title = ""; |
78 | 79 | } |
79 | 80 | |
80 | - if ($cat_title) $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n"; |
|
81 | + if ($cat_title) { |
|
82 | + $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n"; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | $sth = $this->pdo->prepare("SELECT id,title |
83 | 86 | FROM ttrss_feed_categories WHERE |
@@ -120,13 +123,17 @@ discard block |
||
120 | 123 | $out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $ttrss_specific_qpart $html_url_qpart/>\n"; |
121 | 124 | } |
122 | 125 | |
123 | - if ($cat_title) $out .= "</outline>\n"; |
|
126 | + if ($cat_title) { |
|
127 | + $out .= "</outline>\n"; |
|
128 | + } |
|
124 | 129 | |
125 | 130 | return $out; |
126 | 131 | } |
127 | 132 | |
128 | 133 | public function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) { |
129 | - if (!$owner_uid) return; |
|
134 | + if (!$owner_uid) { |
|
135 | + return; |
|
136 | + } |
|
130 | 137 | |
131 | 138 | if (!isset($_REQUEST["debug"])) { |
132 | 139 | header("Content-type: application/xml+opml"); |
@@ -275,8 +282,9 @@ discard block |
||
275 | 282 | |
276 | 283 | // cleanup empty categories |
277 | 284 | foreach ($outlines as $node) { |
278 | - if ($node->getElementsByTagName('outline')->length == 0) |
|
279 | - $node->parentNode->removeChild($node); |
|
285 | + if ($node->getElementsByTagName('outline')->length == 0) { |
|
286 | + $node->parentNode->removeChild($node); |
|
287 | + } |
|
280 | 288 | } |
281 | 289 | |
282 | 290 | $res = $doc->saveXML(); |
@@ -297,10 +305,14 @@ discard block |
||
297 | 305 | $attrs = $node->attributes; |
298 | 306 | |
299 | 307 | $feed_title = mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250); |
300 | - if (!$feed_title) $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250); |
|
308 | + if (!$feed_title) { |
|
309 | + $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250); |
|
310 | + } |
|
301 | 311 | |
302 | 312 | $feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue; |
303 | - if (!$feed_url) $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue; |
|
313 | + if (!$feed_url) { |
|
314 | + $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue; |
|
315 | + } |
|
304 | 316 | |
305 | 317 | $site_url = mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250); |
306 | 318 | |
@@ -309,19 +321,27 @@ discard block |
||
309 | 321 | feed_url = ? AND owner_uid = ?"); |
310 | 322 | $sth->execute([$feed_url, $owner_uid]); |
311 | 323 | |
312 | - if (!$feed_title) $feed_title = '[Unknown]'; |
|
324 | + if (!$feed_title) { |
|
325 | + $feed_title = '[Unknown]'; |
|
326 | + } |
|
313 | 327 | |
314 | 328 | if (!$sth->fetch()) { |
315 | 329 | #$this->opml_notice("[FEED] [$feed_title/$feed_url] dst_CAT=$cat_id"); |
316 | 330 | $this->opml_notice(T_sprintf("Adding feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title)); |
317 | 331 | |
318 | - if (!$cat_id) $cat_id = null; |
|
332 | + if (!$cat_id) { |
|
333 | + $cat_id = null; |
|
334 | + } |
|
319 | 335 | |
320 | 336 | $update_interval = (int) $attrs->getNamedItem('ttrssUpdateInterval')->nodeValue; |
321 | - if (!$update_interval) $update_interval = 0; |
|
337 | + if (!$update_interval) { |
|
338 | + $update_interval = 0; |
|
339 | + } |
|
322 | 340 | |
323 | 341 | $order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue; |
324 | - if (!$order_id) $order_id = 0; |
|
342 | + if (!$order_id) { |
|
343 | + $order_id = 0; |
|
344 | + } |
|
325 | 345 | |
326 | 346 | $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
327 | 347 | (title, feed_url, owner_uid, cat_id, site_url, order_id, update_interval) VALUES |
@@ -505,15 +525,18 @@ discard block |
||
505 | 525 | if ($root_node) { |
506 | 526 | $cat_title = mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250); |
507 | 527 | |
508 | - if (!$cat_title) |
|
509 | - $cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250); |
|
528 | + if (!$cat_title) { |
|
529 | + $cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250); |
|
530 | + } |
|
510 | 531 | |
511 | 532 | if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) { |
512 | 533 | $cat_id = $this->get_feed_category($cat_title, $parent_id); |
513 | 534 | |
514 | 535 | if ($cat_id === false) { |
515 | 536 | $order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue; |
516 | - if (!$order_id) $order_id = 0; |
|
537 | + if (!$order_id) { |
|
538 | + $order_id = 0; |
|
539 | + } |
|
517 | 540 | |
518 | 541 | Feeds::add_feed_category($cat_title, $parent_id, $order_id); |
519 | 542 | $cat_id = $this->get_feed_category($cat_title, $parent_id); |
@@ -540,8 +563,9 @@ discard block |
||
540 | 563 | $attrs = $node->attributes; |
541 | 564 | $node_cat_title = $attrs->getNamedItem('text')->nodeValue; |
542 | 565 | |
543 | - if (!$node_cat_title) |
|
544 | - $node_cat_title = $attrs->getNamedItem('title')->nodeValue; |
|
566 | + if (!$node_cat_title) { |
|
567 | + $node_cat_title = $attrs->getNamedItem('title')->nodeValue; |
|
568 | + } |
|
545 | 569 | |
546 | 570 | $node_feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue; |
547 | 571 | |
@@ -574,7 +598,9 @@ discard block |
||
574 | 598 | } |
575 | 599 | |
576 | 600 | public function opml_import($owner_uid) { |
577 | - if (!$owner_uid) return; |
|
601 | + if (!$owner_uid) { |
|
602 | + return; |
|
603 | + } |
|
578 | 604 | |
579 | 605 | $doc = false; |
580 | 606 |
@@ -5,10 +5,11 @@ discard block |
||
5 | 5 | $op = $_REQUEST["op"]; |
6 | 6 | @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
7 | 7 | |
8 | - if (!$method) |
|
9 | - $method = 'index'; |
|
10 | - else |
|
11 | - $method = strtolower($method); |
|
8 | + if (!$method) { |
|
9 | + $method = 'index'; |
|
10 | + } else { |
|
11 | + $method = strtolower($method); |
|
12 | + } |
|
12 | 13 | |
13 | 14 | /* Public calls compatibility shim */ |
14 | 15 | |
@@ -33,7 +34,9 @@ discard block |
||
33 | 34 | |
34 | 35 | $script_started = microtime(true); |
35 | 36 | |
36 | - if (!init_plugins()) return; |
|
37 | + if (!init_plugins()) { |
|
38 | + return; |
|
39 | + } |
|
37 | 40 | |
38 | 41 | header("Content-Type: text/json; charset=utf-8"); |
39 | 42 |