@@ -1,14 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function print_select($id, $default, $values, $attributes = "", $name = "") { |
4 | - if (!$name) $name = $id; |
|
4 | + if (!$name) { |
|
5 | + $name = $id; |
|
6 | + } |
|
5 | 7 | |
6 | 8 | print "<select name=\"$name\" id=\"$id\" $attributes>"; |
7 | 9 | foreach ($values as $v) { |
8 | - if ($v == $default) |
|
9 | - $sel = "selected=\"1\""; |
|
10 | - else |
|
11 | - $sel = ""; |
|
10 | + if ($v == $default) { |
|
11 | + $sel = "selected=\"1\""; |
|
12 | + } else { |
|
13 | + $sel = ""; |
|
14 | + } |
|
12 | 15 | |
13 | 16 | $v = trim($v); |
14 | 17 | |
@@ -18,14 +21,17 @@ discard block |
||
18 | 21 | } |
19 | 22 | |
20 | 23 | function print_select_hash($id, $default, $values, $attributes = "", $name = "") { |
21 | - if (!$name) $name = $id; |
|
24 | + if (!$name) { |
|
25 | + $name = $id; |
|
26 | + } |
|
22 | 27 | |
23 | 28 | print "<select name=\"$name\" id='$id' $attributes>"; |
24 | 29 | foreach (array_keys($values) as $v) { |
25 | - if ($v == $default) |
|
26 | - $sel = 'selected="selected"'; |
|
27 | - else |
|
28 | - $sel = ""; |
|
30 | + if ($v == $default) { |
|
31 | + $sel = 'selected="selected"'; |
|
32 | + } else { |
|
33 | + $sel = ""; |
|
34 | + } |
|
29 | 35 | |
30 | 36 | $v = trim($v); |
31 | 37 | |
@@ -53,10 +59,11 @@ discard block |
||
53 | 59 | function print_radio($id, $default, $true_is, $values, $attributes = "") { |
54 | 60 | foreach ($values as $v) { |
55 | 61 | |
56 | - if ($v == $default) |
|
57 | - $sel = "checked"; |
|
58 | - else |
|
59 | - $sel = ""; |
|
62 | + if ($v == $default) { |
|
63 | + $sel = "checked"; |
|
64 | + } else { |
|
65 | + $sel = ""; |
|
66 | + } |
|
60 | 67 | |
61 | 68 | if ($v == $true_is) { |
62 | 69 | $sel .= " value=\"1\""; |
@@ -88,7 +95,9 @@ discard block |
||
88 | 95 | |
89 | 96 | if (get_pref('ENABLE_FEED_CATS')) { |
90 | 97 | |
91 | - if (!$root_id) $root_id = null; |
|
98 | + if (!$root_id) { |
|
99 | + $root_id = null; |
|
100 | + } |
|
92 | 101 | |
93 | 102 | $sth = $pdo->prepare("SELECT id,title, |
94 | 103 | (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
@@ -101,17 +110,19 @@ discard block |
||
101 | 110 | |
102 | 111 | while ($line = $sth->fetch()) { |
103 | 112 | |
104 | - for ($i = 0; $i < $nest_level; $i++) |
|
105 | - $line["title"] = " - " . $line["title"]; |
|
113 | + for ($i = 0; $i < $nest_level; $i++) { |
|
114 | + $line["title"] = " - " . $line["title"]; |
|
115 | + } |
|
106 | 116 | |
107 | 117 | $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
108 | 118 | |
109 | 119 | printf("<option $is_selected value='CAT:%d'>%s</option>", |
110 | 120 | $line["id"], htmlspecialchars($line["title"])); |
111 | 121 | |
112 | - if ($line["num_children"] > 0) |
|
113 | - print_feed_multi_select($id, $default_ids, $attributes, |
|
122 | + if ($line["num_children"] > 0) { |
|
123 | + print_feed_multi_select($id, $default_ids, $attributes, |
|
114 | 124 | $include_all_feeds, $line["id"], $nest_level+1); |
125 | + } |
|
115 | 126 | |
116 | 127 | $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
117 | 128 | WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); |
@@ -123,8 +134,9 @@ discard block |
||
123 | 134 | |
124 | 135 | $fline["title"] = " + " . $fline["title"]; |
125 | 136 | |
126 | - for ($i = 0; $i < $nest_level; $i++) |
|
127 | - $fline["title"] = " - " . $fline["title"]; |
|
137 | + for ($i = 0; $i < $nest_level; $i++) { |
|
138 | + $fline["title"] = " - " . $fline["title"]; |
|
139 | + } |
|
128 | 140 | |
129 | 141 | printf("<option $is_selected value='%d'>%s</option>", |
130 | 142 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -146,8 +158,9 @@ discard block |
||
146 | 158 | |
147 | 159 | $fline["title"] = " + " . $fline["title"]; |
148 | 160 | |
149 | - for ($i = 0; $i < $nest_level; $i++) |
|
150 | - $fline["title"] = " - " . $fline["title"]; |
|
161 | + for ($i = 0; $i < $nest_level; $i++) { |
|
162 | + $fline["title"] = " - " . $fline["title"]; |
|
163 | + } |
|
151 | 164 | |
152 | 165 | printf("<option $is_selected value='%d'>%s</option>", |
153 | 166 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -182,7 +195,9 @@ discard block |
||
182 | 195 | |
183 | 196 | $pdo = DB::pdo(); |
184 | 197 | |
185 | - if (!$root_id) $root_id = null; |
|
198 | + if (!$root_id) { |
|
199 | + $root_id = null; |
|
200 | + } |
|
186 | 201 | |
187 | 202 | $sth = $pdo->prepare("SELECT id,title, |
188 | 203 | (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
@@ -203,16 +218,19 @@ discard block |
||
203 | 218 | $is_selected = ""; |
204 | 219 | } |
205 | 220 | |
206 | - for ($i = 0; $i < $nest_level; $i++) |
|
207 | - $line["title"] = " - " . $line["title"]; |
|
221 | + for ($i = 0; $i < $nest_level; $i++) { |
|
222 | + $line["title"] = " - " . $line["title"]; |
|
223 | + } |
|
208 | 224 | |
209 | - if ($line["title"]) |
|
210 | - printf("<option $is_selected value='%d'>%s</option>", |
|
225 | + if ($line["title"]) { |
|
226 | + printf("<option $is_selected value='%d'>%s</option>", |
|
211 | 227 | $line["id"], htmlspecialchars($line["title"])); |
228 | + } |
|
212 | 229 | |
213 | - if ($line["num_children"] > 0) |
|
214 | - print_feed_cat_select($id, $default_id, $attributes, |
|
230 | + if ($line["num_children"] > 0) { |
|
231 | + print_feed_cat_select($id, $default_id, $attributes, |
|
215 | 232 | $include_all_cats, $line["id"], $nest_level+1); |
233 | + } |
|
216 | 234 | } |
217 | 235 | |
218 | 236 | if (!$root_id) { |
@@ -251,7 +269,9 @@ discard block |
||
251 | 269 | |
252 | 270 | $timestamp = filemtime($filename); |
253 | 271 | |
254 | - if ($query) $timestamp .= "&$query"; |
|
272 | + if ($query) { |
|
273 | + $timestamp .= "&$query"; |
|
274 | + } |
|
255 | 275 | |
256 | 276 | return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
257 | 277 | } |
@@ -299,8 +319,10 @@ discard block |
||
299 | 319 | |
300 | 320 | } |
301 | 321 | |
302 | - if ($entry) $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
322 | + if ($entry) { |
|
323 | + $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
303 | 324 | href=\"$url\">" . basename($url) . "</a>"; |
325 | + } |
|
304 | 326 | |
305 | 327 | $entry .= "</div>"; |
306 | 328 |
@@ -32,16 +32,19 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | function ttrss_error_handler($errno, $errstr, $file, $line, $context) { |
35 | - if (error_reporting() == 0 || !$errno) return false; |
|
35 | + if (error_reporting() == 0 || !$errno) { |
|
36 | + return false; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
38 | 40 | |
39 | 41 | $context = format_backtrace(debug_backtrace()); |
40 | 42 | $errstr = truncate_middle($errstr, 16384, " (...) "); |
41 | 43 | |
42 | - if (class_exists("Logger")) |
|
43 | - return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
44 | -} |
|
44 | + if (class_exists("Logger")) { |
|
45 | + return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
46 | + } |
|
47 | + } |
|
45 | 48 | |
46 | 49 | function ttrss_fatal_handler() { |
47 | 50 | global $last_query; |
@@ -54,16 +57,21 @@ discard block |
||
54 | 57 | $line = $error["line"]; |
55 | 58 | $errstr = $error["message"]; |
56 | 59 | |
57 | - if (!$errno) return false; |
|
60 | + if (!$errno) { |
|
61 | + return false; |
|
62 | + } |
|
58 | 63 | |
59 | 64 | $context = format_backtrace(debug_backtrace()); |
60 | 65 | |
61 | 66 | $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1); |
62 | 67 | |
63 | - if ($last_query) $errstr .= " [Last query: $last_query]"; |
|
68 | + if ($last_query) { |
|
69 | + $errstr .= " [Last query: $last_query]"; |
|
70 | + } |
|
64 | 71 | |
65 | - if (class_exists("Logger")) |
|
66 | - return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
72 | + if (class_exists("Logger")) { |
|
73 | + return Logger::get()->log_error($errno, $errstr, $file, $line, $context); |
|
74 | + } |
|
67 | 75 | } |
68 | 76 | |
69 | 77 | return false; |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | libxml_use_internal_errors(true); |
19 | 19 | |
20 | 20 | // separate test because this is included before sanity checks |
21 | -if (function_exists("mb_internal_encoding")) mb_internal_encoding("UTF-8"); |
|
21 | +if (function_exists("mb_internal_encoding")) { |
|
22 | + mb_internal_encoding("UTF-8"); |
|
23 | +} |
|
22 | 24 | |
23 | 25 | date_default_timezone_set('UTC'); |
24 | 26 | if (defined('E_DEPRECATED')) { |
@@ -195,8 +197,9 @@ discard block |
||
195 | 197 | $fetch_last_modified = ""; |
196 | 198 | $fetch_effective_url = ""; |
197 | 199 | |
198 | - if (!is_array($fetch_domain_hits)) |
|
199 | - $fetch_domain_hits = []; |
|
200 | + if (!is_array($fetch_domain_hits)) { |
|
201 | + $fetch_domain_hits = []; |
|
202 | + } |
|
200 | 203 | |
201 | 204 | if (!is_array($options)) { |
202 | 205 | |
@@ -227,8 +230,9 @@ discard block |
||
227 | 230 | $url = ltrim($url, ' '); |
228 | 231 | $url = str_replace(' ', '%20', $url); |
229 | 232 | |
230 | - if (strpos($url, "//") === 0) |
|
231 | - $url = 'http:' . $url; |
|
233 | + if (strpos($url, "//") === 0) { |
|
234 | + $url = 'http:' . $url; |
|
235 | + } |
|
232 | 236 | |
233 | 237 | $url_host = parse_url($url, PHP_URL_HOST); |
234 | 238 | $fetch_domain_hits[$url_host] += 1; |
@@ -246,14 +250,17 @@ discard block |
||
246 | 250 | |
247 | 251 | $curl_http_headers = []; |
248 | 252 | |
249 | - if ($last_modified && !$post_query) |
|
250 | - array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
|
253 | + if ($last_modified && !$post_query) { |
|
254 | + array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
|
255 | + } |
|
251 | 256 | |
252 | - if ($http_accept) |
|
253 | - array_push($curl_http_headers, "Accept: " . $http_accept); |
|
257 | + if ($http_accept) { |
|
258 | + array_push($curl_http_headers, "Accept: " . $http_accept); |
|
259 | + } |
|
254 | 260 | |
255 | - if (count($curl_http_headers) > 0) |
|
256 | - curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
|
261 | + if (count($curl_http_headers) > 0) { |
|
262 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
|
263 | + } |
|
257 | 264 | |
258 | 265 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); |
259 | 266 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); |
@@ -267,8 +274,9 @@ discard block |
||
267 | 274 | SELF_USER_AGENT); |
268 | 275 | curl_setopt($ch, CURLOPT_ENCODING, ""); |
269 | 276 | |
270 | - if ($http_referrer) |
|
271 | - curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
277 | + if ($http_referrer) { |
|
278 | + curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
279 | + } |
|
272 | 280 | |
273 | 281 | if ($max_size) { |
274 | 282 | curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
@@ -297,8 +305,9 @@ discard block |
||
297 | 305 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query); |
298 | 306 | } |
299 | 307 | |
300 | - if ($login && $pass) |
|
301 | - curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
308 | + if ($login && $pass) { |
|
309 | + curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
310 | + } |
|
302 | 311 | |
303 | 312 | $ret = @curl_exec($ch); |
304 | 313 | |
@@ -357,7 +366,9 @@ discard block |
||
357 | 366 | if ($is_gzipped) { |
358 | 367 | $tmp = @gzdecode($contents); |
359 | 368 | |
360 | - if ($tmp) $contents = $tmp; |
|
369 | + if ($tmp) { |
|
370 | + $contents = $tmp; |
|
371 | + } |
|
361 | 372 | } |
362 | 373 | |
363 | 374 | return $contents; |
@@ -390,14 +401,17 @@ discard block |
||
390 | 401 | 'protocol_version'=> 1.1) |
391 | 402 | ); |
392 | 403 | |
393 | - if (!$post_query && $last_modified) |
|
394 | - array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
|
404 | + if (!$post_query && $last_modified) { |
|
405 | + array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); |
|
406 | + } |
|
395 | 407 | |
396 | - if ($http_accept) |
|
397 | - array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
408 | + if ($http_accept) { |
|
409 | + array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
410 | + } |
|
398 | 411 | |
399 | - if ($http_referrer) |
|
400 | - array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
412 | + if ($http_referrer) { |
|
413 | + array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
414 | + } |
|
401 | 415 | |
402 | 416 | if (defined('_HTTP_PROXY')) { |
403 | 417 | $context_options['http']['request_fulluri'] = true; |
@@ -454,7 +468,9 @@ discard block |
||
454 | 468 | if ($is_gzipped) { |
455 | 469 | $tmp = @gzdecode($data); |
456 | 470 | |
457 | - if ($tmp) $data = $tmp; |
|
471 | + if ($tmp) { |
|
472 | + $data = $tmp; |
|
473 | + } |
|
458 | 474 | } |
459 | 475 | |
460 | 476 | return $data; |
@@ -464,7 +480,9 @@ discard block |
||
464 | 480 | |
465 | 481 | function initialize_user_prefs($uid, $profile = false) { |
466 | 482 | |
467 | - if (get_schema_version() < 63) $profile_qpart = ""; |
|
483 | + if (get_schema_version() < 63) { |
|
484 | + $profile_qpart = ""; |
|
485 | + } |
|
468 | 486 | |
469 | 487 | $pdo = DB::pdo(); |
470 | 488 | $in_nested_tr = false; |
@@ -477,7 +495,9 @@ discard block |
||
477 | 495 | |
478 | 496 | $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs"); |
479 | 497 | |
480 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
498 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
499 | + $profile = null; |
|
500 | + } |
|
481 | 501 | |
482 | 502 | $u_sth = $pdo->prepare("SELECT pref_name |
483 | 503 | FROM ttrss_user_prefs WHERE owner_uid = :uid AND |
@@ -510,7 +530,9 @@ discard block |
||
510 | 530 | } |
511 | 531 | } |
512 | 532 | |
513 | - if (!$in_nested_tr) $pdo->commit(); |
|
533 | + if (!$in_nested_tr) { |
|
534 | + $pdo->commit(); |
|
535 | + } |
|
514 | 536 | |
515 | 537 | } |
516 | 538 | |
@@ -670,7 +692,9 @@ discard block |
||
670 | 692 | |
671 | 693 | function load_user_plugins($owner_uid, $pluginhost = false) { |
672 | 694 | |
673 | - if (!$pluginhost) $pluginhost = PluginHost::getInstance(); |
|
695 | + if (!$pluginhost) { |
|
696 | + $pluginhost = PluginHost::getInstance(); |
|
697 | + } |
|
674 | 698 | |
675 | 699 | if ($owner_uid && SCHEMA_VERSION >= 100) { |
676 | 700 | $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); |
@@ -692,7 +716,9 @@ discard block |
||
692 | 716 | startup_gettext(); |
693 | 717 | load_user_plugins($_SESSION["uid"]); |
694 | 718 | } else { |
695 | - if (!validate_session()) $_SESSION["uid"] = false; |
|
719 | + if (!validate_session()) { |
|
720 | + $_SESSION["uid"] = false; |
|
721 | + } |
|
696 | 722 | |
697 | 723 | if (!$_SESSION["uid"]) { |
698 | 724 | |
@@ -787,13 +813,19 @@ discard block |
||
787 | 813 | function make_local_datetime($timestamp, $long, $owner_uid = false, |
788 | 814 | $no_smart_dt = false, $eta_min = false) { |
789 | 815 | |
790 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
791 | - if (!$timestamp) $timestamp = '1970-01-01 0:00'; |
|
816 | + if (!$owner_uid) { |
|
817 | + $owner_uid = $_SESSION['uid']; |
|
818 | + } |
|
819 | + if (!$timestamp) { |
|
820 | + $timestamp = '1970-01-01 0:00'; |
|
821 | + } |
|
792 | 822 | |
793 | 823 | global $utc_tz; |
794 | 824 | global $user_tz; |
795 | 825 | |
796 | - if (!$utc_tz) $utc_tz = new DateTimeZone('UTC'); |
|
826 | + if (!$utc_tz) { |
|
827 | + $utc_tz = new DateTimeZone('UTC'); |
|
828 | + } |
|
797 | 829 | |
798 | 830 | $timestamp = substr($timestamp, 0, 19); |
799 | 831 | |
@@ -805,7 +837,9 @@ discard block |
||
805 | 837 | if ($user_tz_string != 'Automatic') { |
806 | 838 | |
807 | 839 | try { |
808 | - if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); |
|
840 | + if (!$user_tz) { |
|
841 | + $user_tz = new DateTimeZone($user_tz_string); |
|
842 | + } |
|
809 | 843 | } catch (Exception $e) { |
810 | 844 | $user_tz = $utc_tz; |
811 | 845 | } |
@@ -821,26 +855,30 @@ discard block |
||
821 | 855 | return smart_date_time($user_timestamp, |
822 | 856 | $tz_offset, $owner_uid, $eta_min); |
823 | 857 | } else { |
824 | - if ($long) |
|
825 | - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); |
|
826 | - else |
|
827 | - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
|
858 | + if ($long) { |
|
859 | + $format = get_pref('LONG_DATE_FORMAT', $owner_uid); |
|
860 | + } else { |
|
861 | + $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
|
862 | + } |
|
828 | 863 | |
829 | 864 | return date($format, $user_timestamp); |
830 | 865 | } |
831 | 866 | } |
832 | 867 | |
833 | 868 | function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { |
834 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
869 | + if (!$owner_uid) { |
|
870 | + $owner_uid = $_SESSION['uid']; |
|
871 | + } |
|
835 | 872 | |
836 | 873 | if ($eta_min && time() + $tz_offset - $timestamp < 3600) { |
837 | 874 | return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); |
838 | 875 | } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { |
839 | 876 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
840 | - if (strpos((strtolower($format)), "a") === false) |
|
841 | - return date("G:i", $timestamp); |
|
842 | - else |
|
843 | - return date("g:i a", $timestamp); |
|
877 | + if (strpos((strtolower($format)), "a") === false) { |
|
878 | + return date("G:i", $timestamp); |
|
879 | + } else { |
|
880 | + return date("g:i a", $timestamp); |
|
881 | + } |
|
844 | 882 | } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { |
845 | 883 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
846 | 884 | return date($format, $timestamp); |
@@ -1250,8 +1288,9 @@ discard block |
||
1250 | 1288 | |
1251 | 1289 | if ($src) { |
1252 | 1290 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) { |
1253 | - if ($plugin->hook_iframe_whitelisted($src)) |
|
1254 | - return true; |
|
1291 | + if ($plugin->hook_iframe_whitelisted($src)) { |
|
1292 | + return true; |
|
1293 | + } |
|
1255 | 1294 | } |
1256 | 1295 | } |
1257 | 1296 | |
@@ -1259,9 +1298,13 @@ discard block |
||
1259 | 1298 | } |
1260 | 1299 | |
1261 | 1300 | function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { |
1262 | - if (!$owner) $owner = $_SESSION["uid"]; |
|
1301 | + if (!$owner) { |
|
1302 | + $owner = $_SESSION["uid"]; |
|
1303 | + } |
|
1263 | 1304 | |
1264 | - $res = trim($str); if (!$res) return ''; |
|
1305 | + $res = trim($str); if (!$res) { |
|
1306 | + return ''; |
|
1307 | + } |
|
1265 | 1308 | |
1266 | 1309 | $doc = new DOMDocument(); |
1267 | 1310 | $doc->loadHTML('<?xml encoding="UTF-8">' . $res); |
@@ -1323,13 +1366,15 @@ discard block |
||
1323 | 1366 | |
1324 | 1367 | if ($entry->nodeName == 'source') { |
1325 | 1368 | |
1326 | - if ($entry->parentNode && $entry->parentNode->parentNode) |
|
1327 | - $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
1369 | + if ($entry->parentNode && $entry->parentNode->parentNode) { |
|
1370 | + $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
1371 | + } |
|
1328 | 1372 | |
1329 | 1373 | } else if ($entry->nodeName == 'img') { |
1330 | 1374 | |
1331 | - if ($entry->parentNode) |
|
1332 | - $entry->parentNode->replaceChild($p, $entry); |
|
1375 | + if ($entry->parentNode) { |
|
1376 | + $entry->parentNode->replaceChild($p, $entry); |
|
1377 | + } |
|
1333 | 1378 | |
1334 | 1379 | } |
1335 | 1380 | } |
@@ -1365,7 +1410,9 @@ discard block |
||
1365 | 1410 | 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', |
1366 | 1411 | 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); |
1367 | 1412 | |
1368 | - if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; |
|
1413 | + if ($_SESSION['hasSandbox']) { |
|
1414 | + $allowed_elements[] = 'iframe'; |
|
1415 | + } |
|
1369 | 1416 | |
1370 | 1417 | $disallowed_attributes = array('id', 'style', 'class'); |
1371 | 1418 | |
@@ -1405,7 +1452,9 @@ discard block |
||
1405 | 1452 | $text = mb_substr($text, $pos + mb_strlen($word)); |
1406 | 1453 | } |
1407 | 1454 | |
1408 | - if (!empty($text)) $fragment->appendChild(new DomText($text)); |
|
1455 | + if (!empty($text)) { |
|
1456 | + $fragment->appendChild(new DomText($text)); |
|
1457 | + } |
|
1409 | 1458 | |
1410 | 1459 | $child->parentNode->replaceChild($fragment, $child); |
1411 | 1460 | } |
@@ -1596,8 +1645,9 @@ discard block |
||
1596 | 1645 | } else { |
1597 | 1646 | $output = ""; |
1598 | 1647 | |
1599 | - for ($i = 0; $i < $length; $i++) |
|
1600 | - $output .= chr(mt_rand(0, 255)); |
|
1648 | + for ($i = 0; $i < $length; $i++) { |
|
1649 | + $output .= chr(mt_rand(0, 255)); |
|
1650 | + } |
|
1601 | 1651 | |
1602 | 1652 | return $output; |
1603 | 1653 | } |
@@ -1667,15 +1717,20 @@ discard block |
||
1667 | 1717 | } |
1668 | 1718 | |
1669 | 1719 | function get_theme_path($theme) { |
1670 | - if ($theme == "default.php") |
|
1671 | - return "css/default.css"; |
|
1720 | + if ($theme == "default.php") { |
|
1721 | + return "css/default.css"; |
|
1722 | + } |
|
1672 | 1723 | |
1673 | 1724 | $check = "themes/$theme"; |
1674 | - if (file_exists($check)) return $check; |
|
1725 | + if (file_exists($check)) { |
|
1726 | + return $check; |
|
1727 | + } |
|
1675 | 1728 | |
1676 | 1729 | $check = "themes.local/$theme"; |
1677 | - if (file_exists($check)) return $check; |
|
1678 | -} |
|
1730 | + if (file_exists($check)) { |
|
1731 | + return $check; |
|
1732 | + } |
|
1733 | + } |
|
1679 | 1734 | |
1680 | 1735 | function theme_exists($theme) { |
1681 | 1736 | return file_exists("themes/$theme") || file_exists("themes.local/$theme"); |
@@ -1731,7 +1786,9 @@ discard block |
||
1731 | 1786 | function send_local_file($filename) { |
1732 | 1787 | if (file_exists($filename)) { |
1733 | 1788 | |
1734 | - if (is_writable($filename)) touch($filename); |
|
1789 | + if (is_writable($filename)) { |
|
1790 | + touch($filename); |
|
1791 | + } |
|
1735 | 1792 | |
1736 | 1793 | $tmppluginhost = new PluginHost(); |
1737 | 1794 | |
@@ -1739,7 +1796,9 @@ discard block |
||
1739 | 1796 | $tmppluginhost->load_data(); |
1740 | 1797 | |
1741 | 1798 | foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) { |
1742 | - if ($plugin->hook_send_local_file($filename)) return true; |
|
1799 | + if ($plugin->hook_send_local_file($filename)) { |
|
1800 | + return true; |
|
1801 | + } |
|
1743 | 1802 | } |
1744 | 1803 | |
1745 | 1804 | $mimetype = mime_content_type($filename); |
@@ -1747,8 +1806,9 @@ discard block |
||
1747 | 1806 | // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4 |
1748 | 1807 | // video files are detected as octet-stream by mime_content_type() |
1749 | 1808 | |
1750 | - if ($mimetype == "application/octet-stream") |
|
1751 | - $mimetype = "video/mp4"; |
|
1809 | + if ($mimetype == "application/octet-stream") { |
|
1810 | + $mimetype = "video/mp4"; |
|
1811 | + } |
|
1752 | 1812 | |
1753 | 1813 | header("Content-type: $mimetype"); |
1754 | 1814 | |
@@ -1771,7 +1831,9 @@ discard block |
||
1771 | 1831 | |
1772 | 1832 | foreach ($files as $file) { |
1773 | 1833 | $file_ts = filemtime($file); |
1774 | - if ($file_ts > $ts) $ts = $file_ts; |
|
1834 | + if ($file_ts > $ts) { |
|
1835 | + $ts = $file_ts; |
|
1836 | + } |
|
1775 | 1837 | } |
1776 | 1838 | |
1777 | 1839 | return $ts; |
@@ -1784,8 +1846,9 @@ discard block |
||
1784 | 1846 | function get_version(&$git_commit = false, &$git_timestamp = false) { |
1785 | 1847 | global $ttrss_version; |
1786 | 1848 | |
1787 | - if (isset($ttrss_version)) |
|
1788 | - return $ttrss_version; |
|
1849 | + if (isset($ttrss_version)) { |
|
1850 | + return $ttrss_version; |
|
1851 | + } |
|
1789 | 1852 | |
1790 | 1853 | $ttrss_version = "UNKNOWN (Unsupported)"; |
1791 | 1854 |
@@ -35,7 +35,9 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | function validate_session() { |
38 | - if (SINGLE_USER_MODE) return true; |
|
38 | + if (SINGLE_USER_MODE) { |
|
39 | + return true; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | if (isset($_SESSION["ref_schema_version"]) && $_SESSION["ref_schema_version"] != session_get_schema_version()) { |
41 | 43 | $_SESSION["login_error_msg"] = |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | return $tags_deleted; |
60 | 60 | } |
61 | 61 | |
62 | - if (!defined('PHP_EXECUTABLE')) |
|
63 | - define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
62 | + if (!defined('PHP_EXECUTABLE')) { |
|
63 | + define('PHP_EXECUTABLE', '/usr/bin/php'); |
|
64 | + } |
|
64 | 65 | |
65 | 66 | $pdo = Db::pdo(); |
66 | 67 | |
@@ -249,8 +250,9 @@ discard block |
||
249 | 250 | |
250 | 251 | RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); |
251 | 252 | |
252 | - if (!isset($options["pidlock"]) || $options["task"] == 0) |
|
253 | - RSSUtils::housekeeping_common(true); |
|
253 | + if (!isset($options["pidlock"]) || $options["task"] == 0) { |
|
254 | + RSSUtils::housekeeping_common(true); |
|
255 | + } |
|
254 | 256 | |
255 | 257 | PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); |
256 | 258 | } |
@@ -264,8 +266,9 @@ discard block |
||
264 | 266 | Debug::log("PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING!"); |
265 | 267 | Debug::log("Type 'yes' to continue."); |
266 | 268 | |
267 | - if (read_stdin() != 'yes') |
|
268 | - exit; |
|
269 | + if (read_stdin() != 'yes') { |
|
270 | + exit; |
|
271 | + } |
|
269 | 272 | |
270 | 273 | Debug::log("clearing existing indexes..."); |
271 | 274 | |
@@ -319,8 +322,9 @@ discard block |
||
319 | 322 | Debug::log("WARNING: this will remove all existing type2 filters."); |
320 | 323 | Debug::log("Type 'yes' to continue."); |
321 | 324 | |
322 | - if (read_stdin() != 'yes') |
|
323 | - exit; |
|
325 | + if (read_stdin() != 'yes') { |
|
326 | + exit; |
|
327 | + } |
|
324 | 328 | |
325 | 329 | Debug::log("converting filters..."); |
326 | 330 | |
@@ -374,16 +378,18 @@ discard block |
||
374 | 378 | if ($updater->isUpdateRequired()) { |
375 | 379 | Debug::log("Schema update required, version " . $updater->getSchemaVersion() . " to " . SCHEMA_VERSION); |
376 | 380 | |
377 | - if (DB_TYPE == "mysql") |
|
378 | - Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
381 | + if (DB_TYPE == "mysql") { |
|
382 | + Debug::Log("READ THIS: Due to MySQL limitations, your database is not completely protected while updating.\n". |
|
379 | 383 | "Errors may put it in an inconsistent state requiring manual rollback.\nBACKUP YOUR DATABASE BEFORE CONTINUING."); |
380 | - else |
|
381 | - Debug::log("WARNING: please backup your database before continuing."); |
|
384 | + } else { |
|
385 | + Debug::log("WARNING: please backup your database before continuing."); |
|
386 | + } |
|
382 | 387 | |
383 | 388 | Debug::log("Type 'yes' to continue."); |
384 | 389 | |
385 | - if (read_stdin() != 'yes') |
|
386 | - exit; |
|
390 | + if (read_stdin() != 'yes') { |
|
391 | + exit; |
|
392 | + } |
|
387 | 393 | |
388 | 394 | Debug::log("Performing updates to version " . SCHEMA_VERSION); |
389 | 395 | |
@@ -456,7 +462,9 @@ discard block |
||
456 | 462 | |
457 | 463 | $status = $about[3] ? "system" : "user"; |
458 | 464 | |
459 | - if (in_array($name, $enabled)) $name .= "*"; |
|
465 | + if (in_array($name, $enabled)) { |
|
466 | + $name .= "*"; |
|
467 | + } |
|
460 | 468 | |
461 | 469 | printf("%-50s %-10s v%.2f (by %s)\n%s\n\n", |
462 | 470 | $name, $status, $about[0], $about[2], $about[1]); |
@@ -469,8 +477,12 @@ discard block |
||
469 | 477 | if (isset($options["debug-feed"])) { |
470 | 478 | $feed = $options["debug-feed"]; |
471 | 479 | |
472 | - if (isset($options["force-refetch"])) $_REQUEST["force_refetch"] = true; |
|
473 | - if (isset($options["force-rehash"])) $_REQUEST["force_rehash"] = true; |
|
480 | + if (isset($options["force-refetch"])) { |
|
481 | + $_REQUEST["force_refetch"] = true; |
|
482 | + } |
|
483 | + if (isset($options["force-rehash"])) { |
|
484 | + $_REQUEST["force_rehash"] = true; |
|
485 | + } |
|
474 | 486 | |
475 | 487 | Debug::set_loglevel(Debug::$LOG_EXTENDED); |
476 | 488 | |
@@ -485,7 +497,8 @@ discard block |
||
485 | 497 | |
486 | 498 | PluginHost::getInstance()->run_commands($options); |
487 | 499 | |
488 | - if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |
|
489 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
500 | + if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) { |
|
501 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
490 | 502 | fclose($lock_handle); |
503 | + } |
|
491 | 504 | unlink(LOCK_DIRECTORY . "/$lock_filename"); |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | // fallback on HTTP parameters |
39 | 39 | if ($input) { |
40 | 40 | $input = json_decode($input, true); |
41 | - if ($input) $_REQUEST = $input; |
|
41 | + if ($input) { |
|
42 | + $_REQUEST = $input; |
|
43 | + } |
|
42 | 44 | } |
43 | 45 | } else { |
44 | 46 | // Accept JSON only |
@@ -55,7 +57,9 @@ discard block |
||
55 | 57 | |
56 | 58 | startup_gettext(); |
57 | 59 | |
58 | -if (!init_plugins()) return; |
|
60 | +if (!init_plugins()) { |
|
61 | + return; |
|
62 | +} |
|
59 | 63 | |
60 | 64 | if ($_SESSION["uid"]) { |
61 | 65 | if (!validate_session()) { |
@@ -14,7 +14,9 @@ |
||
14 | 14 | |
15 | 15 | $script_started = microtime(true); |
16 | 16 | |
17 | - if (!init_plugins()) return; |
|
17 | + if (!init_plugins()) { |
|
18 | + return; |
|
19 | + } |
|
18 | 20 | |
19 | 21 | if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
20 | 22 | ob_start("ob_gzhandler"); |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | |
19 | 19 | $action = $_REQUEST["action"]; |
20 | 20 | |
21 | - if (!init_plugins()) return; |
|
21 | + if (!init_plugins()) { |
|
22 | + return; |
|
23 | + } |
|
22 | 24 | |
23 | 25 | if ($_REQUEST["format"] == "feed") { |
24 | 26 | header("Content-Type: text/xml"); |
@@ -35,7 +37,9 @@ discard block |
||
35 | 37 | $num_users = db_fetch_result($result, 0, "cu"); |
36 | 38 | |
37 | 39 | $num_users = REG_MAX_USERS - $num_users; |
38 | - if ($num_users < 0) $num_users = 0; |
|
40 | + if ($num_users < 0) { |
|
41 | + $num_users = 0; |
|
42 | + } |
|
39 | 43 | $reg_suffix = "enabled"; |
40 | 44 | } else { |
41 | 45 | $num_users = 0; |
@@ -310,7 +314,9 @@ discard block |
||
310 | 314 | "subject" => "Registration information for Tiny Tiny RSS", |
311 | 315 | "message" => $reg_text]); |
312 | 316 | |
313 | - if (!$rc) print_error($mailer->error()); |
|
317 | + if (!$rc) { |
|
318 | + print_error($mailer->error()); |
|
319 | + } |
|
314 | 320 | |
315 | 321 | $reg_text = "Hi!\n". |
316 | 322 | "\n". |
@@ -324,7 +330,9 @@ discard block |
||
324 | 330 | "subject" => "Registration notice for Tiny Tiny RSS", |
325 | 331 | "message" => $reg_text]); |
326 | 332 | |
327 | - if (!$rc) print_error($mailer->error()); |
|
333 | + if (!$rc) { |
|
334 | + print_error($mailer->error()); |
|
335 | + } |
|
328 | 336 | |
329 | 337 | print_notice(__("Account created successfully.")); |
330 | 338 |
@@ -10,7 +10,9 @@ |
||
10 | 10 | require_once "db.php"; |
11 | 11 | require_once "db-prefs.php"; |
12 | 12 | |
13 | - if (!init_plugins()) return; |
|
13 | + if (!init_plugins()) { |
|
14 | + return; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | $op = $_REQUEST['op']; |
16 | 18 |