@@ -110,17 +110,19 @@ discard block |
||
110 | 110 | |
111 | 111 | while ($line = $sth->fetch()) { |
112 | 112 | |
113 | - for ($i = 0; $i < $nest_level; $i++) |
|
114 | - $line["title"] = " - ".$line["title"]; |
|
113 | + for ($i = 0; $i < $nest_level; $i++) { |
|
114 | + $line["title"] = " - ".$line["title"]; |
|
115 | + } |
|
115 | 116 | |
116 | 117 | $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
117 | 118 | |
118 | 119 | printf("<option $is_selected value='CAT:%d'>%s</option>", |
119 | 120 | $line["id"], htmlspecialchars($line["title"])); |
120 | 121 | |
121 | - if ($line["num_children"] > 0) |
|
122 | - print_feed_multi_select($id, $default_ids, $attributes, |
|
122 | + if ($line["num_children"] > 0) { |
|
123 | + print_feed_multi_select($id, $default_ids, $attributes, |
|
123 | 124 | $include_all_feeds, $line["id"], $nest_level + 1); |
125 | + } |
|
124 | 126 | |
125 | 127 | $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
126 | 128 | WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); |
@@ -132,8 +134,9 @@ discard block |
||
132 | 134 | |
133 | 135 | $fline["title"] = " + ".$fline["title"]; |
134 | 136 | |
135 | - for ($i = 0; $i < $nest_level; $i++) |
|
136 | - $fline["title"] = " - ".$fline["title"]; |
|
137 | + for ($i = 0; $i < $nest_level; $i++) { |
|
138 | + $fline["title"] = " - ".$fline["title"]; |
|
139 | + } |
|
137 | 140 | |
138 | 141 | printf("<option $is_selected value='%d'>%s</option>", |
139 | 142 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -155,8 +158,9 @@ discard block |
||
155 | 158 | |
156 | 159 | $fline["title"] = " + ".$fline["title"]; |
157 | 160 | |
158 | - for ($i = 0; $i < $nest_level; $i++) |
|
159 | - $fline["title"] = " - ".$fline["title"]; |
|
161 | + for ($i = 0; $i < $nest_level; $i++) { |
|
162 | + $fline["title"] = " - ".$fline["title"]; |
|
163 | + } |
|
160 | 164 | |
161 | 165 | printf("<option $is_selected value='%d'>%s</option>", |
162 | 166 | $fline["id"], htmlspecialchars($fline["title"])); |
@@ -214,16 +218,19 @@ discard block |
||
214 | 218 | $is_selected = ""; |
215 | 219 | } |
216 | 220 | |
217 | - for ($i = 0; $i < $nest_level; $i++) |
|
218 | - $line["title"] = " - ".$line["title"]; |
|
221 | + for ($i = 0; $i < $nest_level; $i++) { |
|
222 | + $line["title"] = " - ".$line["title"]; |
|
223 | + } |
|
219 | 224 | |
220 | - if ($line["title"]) |
|
221 | - printf("<option $is_selected value='%d'>%s</option>", |
|
225 | + if ($line["title"]) { |
|
226 | + printf("<option $is_selected value='%d'>%s</option>", |
|
222 | 227 | $line["id"], htmlspecialchars($line["title"])); |
228 | + } |
|
223 | 229 | |
224 | - if ($line["num_children"] > 0) |
|
225 | - print_feed_cat_select($id, $default_id, $attributes, |
|
230 | + if ($line["num_children"] > 0) { |
|
231 | + print_feed_cat_select($id, $default_id, $attributes, |
|
226 | 232 | $include_all_cats, $line["id"], $nest_level + 1); |
233 | + } |
|
227 | 234 | } |
228 | 235 | |
229 | 236 | if (!$root_id) { |
@@ -312,8 +319,10 @@ discard block |
||
312 | 319 | |
313 | 320 | } |
314 | 321 | |
315 | - if ($entry) $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
322 | + if ($entry) { |
|
323 | + $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
|
316 | 324 | href=\"$url\">".basename($url)."</a>"; |
325 | + } |
|
317 | 326 | |
318 | 327 | $entry .= "</div>"; |
319 | 328 |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | if (!is_array($options)) { |
204 | 204 | |
205 | 205 | // falling back on compatibility shim |
206 | - $option_names = [ "url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent" ]; |
|
206 | + $option_names = ["url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent"]; |
|
207 | 207 | $tmp = []; |
208 | 208 | |
209 | 209 | for ($i = 0; $i < func_num_args(); $i++) { |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | $url = str_replace(' ', '%20', $url); |
231 | 231 | |
232 | 232 | if (strpos($url, "//") === 0) |
233 | - $url = 'http:' . $url; |
|
233 | + $url = 'http:'.$url; |
|
234 | 234 | |
235 | 235 | $url_host = parse_url($url, PHP_URL_HOST); |
236 | 236 | $fetch_domain_hits[$url_host] += 1; |
237 | 237 | |
238 | 238 | if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) { |
239 | - user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING); |
|
239 | + user_error("Exceeded fetch request quota for $url_host: ".$fetch_domain_hits[$url_host], E_USER_WARNING); |
|
240 | 240 | #return false; |
241 | 241 | } |
242 | 242 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | array_push($curl_http_headers, "If-Modified-Since: $last_modified"); |
253 | 253 | |
254 | 254 | if ($http_accept) |
255 | - array_push($curl_http_headers, "Accept: " . $http_accept); |
|
255 | + array_push($curl_http_headers, "Accept: ".$http_accept); |
|
256 | 256 | |
257 | 257 | if (count($curl_http_headers) > 0) |
258 | 258 | curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); |
@@ -265,11 +265,10 @@ discard block |
||
265 | 265 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
266 | 266 | curl_setopt($ch, CURLOPT_HEADER, true); |
267 | 267 | curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
268 | - curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : |
|
269 | - SELF_USER_AGENT); |
|
268 | + curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : SELF_USER_AGENT); |
|
270 | 269 | curl_setopt($ch, CURLOPT_ENCODING, ""); |
271 | 270 | |
272 | - if ($http_referrer) |
|
271 | + if ($http_referrer) |
|
273 | 272 | curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
274 | 273 | |
275 | 274 | if ($max_size) { |
@@ -278,7 +277,7 @@ discard block |
||
278 | 277 | |
279 | 278 | // holy shit closures in php |
280 | 279 | // download & upload are *expected* sizes respectively, could be zero |
281 | - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use( &$max_size) { |
|
280 | + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use(&$max_size) { |
|
282 | 281 | Debug::log("[curl progressfunction] $downloaded $max_size", Debug::$LOG_EXTENDED); |
283 | 282 | |
284 | 283 | return ($downloaded > $max_size) ? 1 : 0; // if max size is set, abort when exceeding it |
@@ -338,7 +337,7 @@ discard block |
||
338 | 337 | if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) { |
339 | 338 | |
340 | 339 | if (curl_errno($ch) != 0) { |
341 | - $fetch_last_error .= "; " . curl_errno($ch) . " " . curl_error($ch); |
|
340 | + $fetch_last_error .= "; ".curl_errno($ch)." ".curl_error($ch); |
|
342 | 341 | } |
343 | 342 | |
344 | 343 | $fetch_last_error_content = $contents; |
@@ -347,7 +346,7 @@ discard block |
||
347 | 346 | } |
348 | 347 | |
349 | 348 | if (!$contents) { |
350 | - $fetch_last_error = curl_errno($ch) . " " . curl_error($ch); |
|
349 | + $fetch_last_error = curl_errno($ch)." ".curl_error($ch); |
|
351 | 350 | curl_close($ch); |
352 | 351 | return false; |
353 | 352 | } |
@@ -367,7 +366,7 @@ discard block |
||
367 | 366 | |
368 | 367 | $fetch_curl_used = false; |
369 | 368 | |
370 | - if ($login && $pass){ |
|
369 | + if ($login && $pass) { |
|
371 | 370 | $url_parts = array(); |
372 | 371 | |
373 | 372 | preg_match("/(^[^:]*):\/\/(.*)/", $url, $url_parts); |
@@ -375,7 +374,7 @@ discard block |
||
375 | 374 | $pass = urlencode($pass); |
376 | 375 | |
377 | 376 | if ($url_parts[1] && $url_parts[2]) { |
378 | - $url = $url_parts[1] . "://$login:$pass@" . $url_parts[2]; |
|
377 | + $url = $url_parts[1]."://$login:$pass@".$url_parts[2]; |
|
379 | 378 | } |
380 | 379 | } |
381 | 380 | |
@@ -443,7 +442,7 @@ discard block |
||
443 | 442 | $error = error_get_last(); |
444 | 443 | |
445 | 444 | if ($error['message'] != $old_error['message']) { |
446 | - $fetch_last_error .= "; " . $error["message"]; |
|
445 | + $fetch_last_error .= "; ".$error["message"]; |
|
447 | 446 | } |
448 | 447 | |
449 | 448 | $fetch_last_error_content = $data; |
@@ -518,15 +517,15 @@ discard block |
||
518 | 517 | |
519 | 518 | function get_ssl_certificate_id() { |
520 | 519 | if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) { |
521 | - return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] . |
|
522 | - $_SERVER["REDIRECT_SSL_CLIENT_V_START"] . |
|
523 | - $_SERVER["REDIRECT_SSL_CLIENT_V_END"] . |
|
520 | + return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]. |
|
521 | + $_SERVER["REDIRECT_SSL_CLIENT_V_START"]. |
|
522 | + $_SERVER["REDIRECT_SSL_CLIENT_V_END"]. |
|
524 | 523 | $_SERVER["REDIRECT_SSL_CLIENT_S_DN"]); |
525 | 524 | } |
526 | 525 | if ($_SERVER["SSL_CLIENT_M_SERIAL"]) { |
527 | - return sha1($_SERVER["SSL_CLIENT_M_SERIAL"] . |
|
528 | - $_SERVER["SSL_CLIENT_V_START"] . |
|
529 | - $_SERVER["SSL_CLIENT_V_END"] . |
|
526 | + return sha1($_SERVER["SSL_CLIENT_M_SERIAL"]. |
|
527 | + $_SERVER["SSL_CLIENT_V_START"]. |
|
528 | + $_SERVER["SSL_CLIENT_V_END"]. |
|
530 | 529 | $_SERVER["SSL_CLIENT_S_DN"]); |
531 | 530 | } |
532 | 531 | return ""; |
@@ -661,7 +660,7 @@ discard block |
||
661 | 660 | function logout_user() { |
662 | 661 | @session_destroy(); |
663 | 662 | if (isset($_COOKIE[session_name()])) { |
664 | - setcookie(session_name(), '', time()-42000, '/'); |
|
663 | + setcookie(session_name(), '', time() - 42000, '/'); |
|
665 | 664 | } |
666 | 665 | session_commit(); |
667 | 666 | } |
@@ -745,7 +744,7 @@ discard block |
||
745 | 744 | |
746 | 745 | function truncate_string($str, $max_len, $suffix = '…') { |
747 | 746 | if (mb_strlen($str, "utf-8") > $max_len) { |
748 | - return mb_substr($str, 0, $max_len, "utf-8") . $suffix; |
|
747 | + return mb_substr($str, 0, $max_len, "utf-8").$suffix; |
|
749 | 748 | } else { |
750 | 749 | return $str; |
751 | 750 | } |
@@ -755,7 +754,7 @@ discard block |
||
755 | 754 | $startString = mb_substr($original, 0, $position, "UTF-8"); |
756 | 755 | $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8"); |
757 | 756 | |
758 | - $out = $startString . $replacement . $endString; |
|
757 | + $out = $startString.$replacement.$endString; |
|
759 | 758 | |
760 | 759 | return $out; |
761 | 760 | } |
@@ -893,9 +892,9 @@ discard block |
||
893 | 892 | } |
894 | 893 | |
895 | 894 | function file_is_locked($filename) { |
896 | - if (file_exists(LOCK_DIRECTORY . "/$filename")) { |
|
895 | + if (file_exists(LOCK_DIRECTORY."/$filename")) { |
|
897 | 896 | if (function_exists('flock')) { |
898 | - $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r"); |
|
897 | + $fp = @fopen(LOCK_DIRECTORY."/$filename", "r"); |
|
899 | 898 | if ($fp) { |
900 | 899 | if (flock($fp, LOCK_EX | LOCK_NB)) { |
901 | 900 | flock($fp, LOCK_UN); |
@@ -916,11 +915,11 @@ discard block |
||
916 | 915 | |
917 | 916 | |
918 | 917 | function make_lockfile($filename) { |
919 | - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); |
|
918 | + $fp = fopen(LOCK_DIRECTORY."/$filename", "w"); |
|
920 | 919 | |
921 | 920 | if ($fp && flock($fp, LOCK_EX | LOCK_NB)) { |
922 | 921 | $stat_h = fstat($fp); |
923 | - $stat_f = stat(LOCK_DIRECTORY . "/$filename"); |
|
922 | + $stat_f = stat(LOCK_DIRECTORY."/$filename"); |
|
924 | 923 | |
925 | 924 | if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { |
926 | 925 | if ($stat_h["ino"] != $stat_f["ino"] || |
@@ -931,7 +930,7 @@ discard block |
||
931 | 930 | } |
932 | 931 | |
933 | 932 | if (function_exists('posix_getpid')) { |
934 | - fwrite($fp, posix_getpid() . "\n"); |
|
933 | + fwrite($fp, posix_getpid()."\n"); |
|
935 | 934 | } |
936 | 935 | return $fp; |
937 | 936 | } else { |
@@ -940,10 +939,10 @@ discard block |
||
940 | 939 | } |
941 | 940 | |
942 | 941 | function make_stampfile($filename) { |
943 | - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); |
|
942 | + $fp = fopen(LOCK_DIRECTORY."/$filename", "w"); |
|
944 | 943 | |
945 | 944 | if (flock($fp, LOCK_EX | LOCK_NB)) { |
946 | - fwrite($fp, time() . "\n"); |
|
945 | + fwrite($fp, time()."\n"); |
|
947 | 946 | flock($fp, LOCK_UN); |
948 | 947 | fclose($fp); |
949 | 948 | return true; |
@@ -993,7 +992,7 @@ discard block |
||
993 | 992 | $params["is_default_pw"] = Pref_Prefs::isdefaultpassword(); |
994 | 993 | $params["label_base_index"] = (int) LABEL_BASE_INDEX; |
995 | 994 | |
996 | - $theme = get_pref( "USER_CSS_THEME", false, false); |
|
995 | + $theme = get_pref("USER_CSS_THEME", false, false); |
|
997 | 996 | $params["theme"] = theme_exists($theme) ? $theme : ""; |
998 | 997 | |
999 | 998 | $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names()); |
@@ -1217,13 +1216,13 @@ discard block |
||
1217 | 1216 | } |
1218 | 1217 | } |
1219 | 1218 | |
1220 | - if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { |
|
1219 | + if (file_exists(LOCK_DIRECTORY."/update_daemon.lock")) { |
|
1221 | 1220 | |
1222 | 1221 | $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); |
1223 | 1222 | |
1224 | 1223 | if (time() - $_SESSION["daemon_stamp_check"] > 30) { |
1225 | 1224 | |
1226 | - $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); |
|
1225 | + $stamp = (int) @file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp"); |
|
1227 | 1226 | |
1228 | 1227 | if ($stamp) { |
1229 | 1228 | $stamp_delta = time() - $stamp; |
@@ -1266,7 +1265,7 @@ discard block |
||
1266 | 1265 | $res = trim($str); if (!$res) return ''; |
1267 | 1266 | |
1268 | 1267 | $doc = new DOMDocument(); |
1269 | - $doc->loadHTML('<?xml encoding="UTF-8">' . $res); |
|
1268 | + $doc->loadHTML('<?xml encoding="UTF-8">'.$res); |
|
1270 | 1269 | $xpath = new DOMXPath($doc); |
1271 | 1270 | |
1272 | 1271 | $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix(); |
@@ -1365,7 +1364,7 @@ discard block |
||
1365 | 1364 | 'ol', 'p', 'picture', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section', |
1366 | 1365 | 'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary', |
1367 | 1366 | 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', |
1368 | - 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); |
|
1367 | + 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace'); |
|
1369 | 1368 | |
1370 | 1369 | if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; |
1371 | 1370 | |
@@ -1500,8 +1499,8 @@ discard block |
||
1500 | 1499 | |
1501 | 1500 | // this returns SELF_URL_PATH sans ending slash |
1502 | 1501 | function get_self_url_prefix() { |
1503 | - if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH)-1) { |
|
1504 | - return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH)-1); |
|
1502 | + if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH) - 1) { |
|
1503 | + return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH) - 1); |
|
1505 | 1504 | } else { |
1506 | 1505 | return SELF_URL_PATH; |
1507 | 1506 | } |
@@ -1510,11 +1509,11 @@ discard block |
||
1510 | 1509 | /* TODO: This needs to use bcrypt */ |
1511 | 1510 | function encrypt_password($pass, $salt = '', $mode2 = false) { |
1512 | 1511 | if ($salt && $mode2) { |
1513 | - return "MODE2:" . hash('sha256', $salt . $pass); |
|
1512 | + return "MODE2:".hash('sha256', $salt.$pass); |
|
1514 | 1513 | } else if ($salt) { |
1515 | - return "SHA1X:" . sha1("$salt:$pass"); |
|
1514 | + return "SHA1X:".sha1("$salt:$pass"); |
|
1516 | 1515 | } else { |
1517 | - return "SHA1:" . sha1($pass); |
|
1516 | + return "SHA1:".sha1($pass); |
|
1518 | 1517 | } |
1519 | 1518 | } |
1520 | 1519 | |
@@ -1525,7 +1524,7 @@ discard block |
||
1525 | 1524 | } |
1526 | 1525 | |
1527 | 1526 | function build_url($parts) { |
1528 | - return $parts['scheme'] . "://" . $parts['host'] . $parts['path']; |
|
1527 | + return $parts['scheme']."://".$parts['host'].$parts['path']; |
|
1529 | 1528 | } |
1530 | 1529 | |
1531 | 1530 | function cleanup_url_path($path) { |
@@ -1569,7 +1568,7 @@ discard block |
||
1569 | 1568 | $dir = dirname($parts['path']); |
1570 | 1569 | $dir !== '/' && $dir .= '/'; |
1571 | 1570 | } |
1572 | - $parts['path'] = $dir . $rel_url; |
|
1571 | + $parts['path'] = $dir.$rel_url; |
|
1573 | 1572 | $parts['path'] = cleanup_url_path($parts['path']); |
1574 | 1573 | |
1575 | 1574 | return build_url($parts); |
@@ -1656,12 +1655,12 @@ discard block |
||
1656 | 1655 | |
1657 | 1656 | for ($i = 0; $i < $l10n->total; $i++) { |
1658 | 1657 | $orig = $l10n->get_original_string($i); |
1659 | - if(strpos($orig, "\000") !== FALSE) { // Plural forms |
|
1658 | + if (strpos($orig, "\000") !== FALSE) { // Plural forms |
|
1660 | 1659 | $key = explode(chr(0), $orig); |
1661 | 1660 | print T_js_decl($key[0], _ngettext($key[0], $key[1], 1)); // Singular |
1662 | 1661 | print T_js_decl($key[1], _ngettext($key[0], $key[1], 2)); // Plural |
1663 | 1662 | } else { |
1664 | - $translation = _dgettext($domain,$orig); |
|
1663 | + $translation = _dgettext($domain, $orig); |
|
1665 | 1664 | print T_js_decl($orig, $translation); |
1666 | 1665 | } |
1667 | 1666 | } |
@@ -1717,7 +1716,7 @@ discard block |
||
1717 | 1716 | if (file_exists($filename)) { |
1718 | 1717 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
1719 | 1718 | |
1720 | - return "data:image/$ext;base64," . base64_encode(file_get_contents($filename)); |
|
1719 | + return "data:image/$ext;base64,".base64_encode(file_get_contents($filename)); |
|
1721 | 1720 | } else { |
1722 | 1721 | return ""; |
1723 | 1722 | } |
@@ -1754,7 +1753,7 @@ discard block |
||
1754 | 1753 | |
1755 | 1754 | header("Content-type: $mimetype"); |
1756 | 1755 | |
1757 | - $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT"; |
|
1756 | + $stamp = gmdate("D, d M Y H:i:s", filemtime($filename))." GMT"; |
|
1758 | 1757 | header("Last-Modified: $stamp", true); |
1759 | 1758 | |
1760 | 1759 | return readfile($filename); |
@@ -1764,7 +1763,7 @@ discard block |
||
1764 | 1763 | } |
1765 | 1764 | |
1766 | 1765 | function arr_qmarks($arr) { |
1767 | - return str_repeat('?,', count($arr) - 1) . '?'; |
|
1766 | + return str_repeat('?,', count($arr) - 1).'?'; |
|
1768 | 1767 | } |
1769 | 1768 | |
1770 | 1769 | function get_scripts_timestamp() { |
@@ -1799,7 +1798,7 @@ discard block |
||
1799 | 1798 | } else if (PHP_OS === "Darwin") { |
1800 | 1799 | $ttrss_version = "UNKNOWN (Unsupported, Darwin)"; |
1801 | 1800 | } else if (file_exists("$root_dir/version_static.txt")) { |
1802 | - $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; |
|
1801 | + $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt"))." (Unsupported)"; |
|
1803 | 1802 | } else if (is_dir("$root_dir/.git")) { |
1804 | 1803 | $rc = 0; |
1805 | 1804 | $output = []; |
@@ -1817,10 +1816,10 @@ discard block |
||
1817 | 1816 | $git_commit = $commit; |
1818 | 1817 | $git_timestamp = $timestamp; |
1819 | 1818 | |
1820 | - $ttrss_version = strftime("%y.%m", $timestamp) . "-$commit"; |
|
1819 | + $ttrss_version = strftime("%y.%m", $timestamp)."-$commit"; |
|
1821 | 1820 | } |
1822 | 1821 | } else { |
1823 | - user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING); |
|
1822 | + user_error("Unable to determine version (using $root_dir): ".implode("\n", $output), E_USER_WARNING); |
|
1824 | 1823 | } |
1825 | 1824 | } |
1826 | 1825 |
@@ -197,8 +197,9 @@ discard block |
||
197 | 197 | $fetch_last_modified = ""; |
198 | 198 | $fetch_effective_url = ""; |
199 | 199 | |
200 | - if (!is_array($fetch_domain_hits)) |
|
201 | - $fetch_domain_hits = []; |
|
200 | + if (!is_array($fetch_domain_hits)) { |
|
201 | + $fetch_domain_hits = []; |
|
202 | + } |
|
202 | 203 | |
203 | 204 | if (!is_array($options)) { |
204 | 205 | |
@@ -229,8 +230,9 @@ discard block |
||
229 | 230 | $url = ltrim($url, ' '); |
230 | 231 | $url = str_replace(' ', '%20', $url); |
231 | 232 | |
232 | - if (strpos($url, "//") === 0) |
|
233 | - $url = 'http:' . $url; |
|
233 | + if (strpos($url, "//") === 0) { |
|
234 | + $url = 'http:' . $url; |
|
235 | + } |
|
234 | 236 | |
235 | 237 | $url_host = parse_url($url, PHP_URL_HOST); |
236 | 238 | $fetch_domain_hits[$url_host] += 1; |
@@ -248,14 +250,17 @@ discard block |
||
248 | 250 | |
249 | 251 | $curl_http_headers = []; |
250 | 252 | |
251 | - if ($last_modified && !$post_query) |
|
252 | - 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 | + } |
|
253 | 256 | |
254 | - if ($http_accept) |
|
255 | - array_push($curl_http_headers, "Accept: " . $http_accept); |
|
257 | + if ($http_accept) { |
|
258 | + array_push($curl_http_headers, "Accept: " . $http_accept); |
|
259 | + } |
|
256 | 260 | |
257 | - if (count($curl_http_headers) > 0) |
|
258 | - 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 | + } |
|
259 | 264 | |
260 | 265 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); |
261 | 266 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); |
@@ -269,8 +274,9 @@ discard block |
||
269 | 274 | SELF_USER_AGENT); |
270 | 275 | curl_setopt($ch, CURLOPT_ENCODING, ""); |
271 | 276 | |
272 | - if ($http_referrer) |
|
273 | - curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
277 | + if ($http_referrer) { |
|
278 | + curl_setopt($ch, CURLOPT_REFERER, $http_referrer); |
|
279 | + } |
|
274 | 280 | |
275 | 281 | if ($max_size) { |
276 | 282 | curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
@@ -299,8 +305,9 @@ discard block |
||
299 | 305 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query); |
300 | 306 | } |
301 | 307 | |
302 | - if ($login && $pass) |
|
303 | - curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
308 | + if ($login && $pass) { |
|
309 | + curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); |
|
310 | + } |
|
304 | 311 | |
305 | 312 | $ret = @curl_exec($ch); |
306 | 313 | |
@@ -359,7 +366,9 @@ discard block |
||
359 | 366 | if ($is_gzipped) { |
360 | 367 | $tmp = @gzdecode($contents); |
361 | 368 | |
362 | - if ($tmp) $contents = $tmp; |
|
369 | + if ($tmp) { |
|
370 | + $contents = $tmp; |
|
371 | + } |
|
363 | 372 | } |
364 | 373 | |
365 | 374 | return $contents; |
@@ -392,14 +401,17 @@ discard block |
||
392 | 401 | 'protocol_version'=> 1.1) |
393 | 402 | ); |
394 | 403 | |
395 | - if (!$post_query && $last_modified) |
|
396 | - 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 | + } |
|
397 | 407 | |
398 | - if ($http_accept) |
|
399 | - array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
408 | + if ($http_accept) { |
|
409 | + array_push($context_options['http']['header'], "Accept: $http_accept"); |
|
410 | + } |
|
400 | 411 | |
401 | - if ($http_referrer) |
|
402 | - array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
412 | + if ($http_referrer) { |
|
413 | + array_push($context_options['http']['header'], "Referer: $http_referrer"); |
|
414 | + } |
|
403 | 415 | |
404 | 416 | if (defined('_HTTP_PROXY')) { |
405 | 417 | $context_options['http']['request_fulluri'] = true; |
@@ -456,7 +468,9 @@ discard block |
||
456 | 468 | if ($is_gzipped) { |
457 | 469 | $tmp = @gzdecode($data); |
458 | 470 | |
459 | - if ($tmp) $data = $tmp; |
|
471 | + if ($tmp) { |
|
472 | + $data = $tmp; |
|
473 | + } |
|
460 | 474 | } |
461 | 475 | |
462 | 476 | return $data; |
@@ -466,7 +480,9 @@ discard block |
||
466 | 480 | |
467 | 481 | function initialize_user_prefs($uid, $profile = false) { |
468 | 482 | |
469 | - if (get_schema_version() < 63) $profile_qpart = ""; |
|
483 | + if (get_schema_version() < 63) { |
|
484 | + $profile_qpart = ""; |
|
485 | + } |
|
470 | 486 | |
471 | 487 | $pdo = DB::pdo(); |
472 | 488 | $in_nested_tr = false; |
@@ -479,7 +495,9 @@ discard block |
||
479 | 495 | |
480 | 496 | $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs"); |
481 | 497 | |
482 | - 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 | + } |
|
483 | 501 | |
484 | 502 | $u_sth = $pdo->prepare("SELECT pref_name |
485 | 503 | FROM ttrss_user_prefs WHERE owner_uid = :uid AND |
@@ -512,7 +530,9 @@ discard block |
||
512 | 530 | } |
513 | 531 | } |
514 | 532 | |
515 | - if (!$in_nested_tr) $pdo->commit(); |
|
533 | + if (!$in_nested_tr) { |
|
534 | + $pdo->commit(); |
|
535 | + } |
|
516 | 536 | |
517 | 537 | } |
518 | 538 | |
@@ -672,7 +692,9 @@ discard block |
||
672 | 692 | |
673 | 693 | function load_user_plugins($owner_uid, $pluginhost = false) { |
674 | 694 | |
675 | - if (!$pluginhost) $pluginhost = PluginHost::getInstance(); |
|
695 | + if (!$pluginhost) { |
|
696 | + $pluginhost = PluginHost::getInstance(); |
|
697 | + } |
|
676 | 698 | |
677 | 699 | if ($owner_uid && SCHEMA_VERSION >= 100) { |
678 | 700 | $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); |
@@ -694,7 +716,9 @@ discard block |
||
694 | 716 | startup_gettext(); |
695 | 717 | load_user_plugins($_SESSION["uid"]); |
696 | 718 | } else { |
697 | - if (!validate_session()) $_SESSION["uid"] = false; |
|
719 | + if (!validate_session()) { |
|
720 | + $_SESSION["uid"] = false; |
|
721 | + } |
|
698 | 722 | |
699 | 723 | if (!$_SESSION["uid"]) { |
700 | 724 | |
@@ -789,13 +813,19 @@ discard block |
||
789 | 813 | function make_local_datetime($timestamp, $long, $owner_uid = false, |
790 | 814 | $no_smart_dt = false, $eta_min = false) { |
791 | 815 | |
792 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
793 | - 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 | + } |
|
794 | 822 | |
795 | 823 | global $utc_tz; |
796 | 824 | global $user_tz; |
797 | 825 | |
798 | - if (!$utc_tz) $utc_tz = new DateTimeZone('UTC'); |
|
826 | + if (!$utc_tz) { |
|
827 | + $utc_tz = new DateTimeZone('UTC'); |
|
828 | + } |
|
799 | 829 | |
800 | 830 | $timestamp = substr($timestamp, 0, 19); |
801 | 831 | |
@@ -807,7 +837,9 @@ discard block |
||
807 | 837 | if ($user_tz_string != 'Automatic') { |
808 | 838 | |
809 | 839 | try { |
810 | - if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); |
|
840 | + if (!$user_tz) { |
|
841 | + $user_tz = new DateTimeZone($user_tz_string); |
|
842 | + } |
|
811 | 843 | } catch (Exception $e) { |
812 | 844 | $user_tz = $utc_tz; |
813 | 845 | } |
@@ -823,26 +855,30 @@ discard block |
||
823 | 855 | return smart_date_time($user_timestamp, |
824 | 856 | $tz_offset, $owner_uid, $eta_min); |
825 | 857 | } else { |
826 | - if ($long) |
|
827 | - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); |
|
828 | - else |
|
829 | - $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 | + } |
|
830 | 863 | |
831 | 864 | return date($format, $user_timestamp); |
832 | 865 | } |
833 | 866 | } |
834 | 867 | |
835 | 868 | function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { |
836 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
869 | + if (!$owner_uid) { |
|
870 | + $owner_uid = $_SESSION['uid']; |
|
871 | + } |
|
837 | 872 | |
838 | 873 | if ($eta_min && time() + $tz_offset - $timestamp < 3600) { |
839 | 874 | return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); |
840 | 875 | } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { |
841 | 876 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
842 | - if (strpos((strtolower($format)), "a") === false) |
|
843 | - return date("G:i", $timestamp); |
|
844 | - else |
|
845 | - 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 | + } |
|
846 | 882 | } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { |
847 | 883 | $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); |
848 | 884 | return date($format, $timestamp); |
@@ -1252,8 +1288,9 @@ discard block |
||
1252 | 1288 | |
1253 | 1289 | if ($src) { |
1254 | 1290 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) { |
1255 | - if ($plugin->hook_iframe_whitelisted($src)) |
|
1256 | - return true; |
|
1291 | + if ($plugin->hook_iframe_whitelisted($src)) { |
|
1292 | + return true; |
|
1293 | + } |
|
1257 | 1294 | } |
1258 | 1295 | } |
1259 | 1296 | |
@@ -1261,9 +1298,13 @@ discard block |
||
1261 | 1298 | } |
1262 | 1299 | |
1263 | 1300 | function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { |
1264 | - if (!$owner) $owner = $_SESSION["uid"]; |
|
1301 | + if (!$owner) { |
|
1302 | + $owner = $_SESSION["uid"]; |
|
1303 | + } |
|
1265 | 1304 | |
1266 | - $res = trim($str); if (!$res) return ''; |
|
1305 | + $res = trim($str); if (!$res) { |
|
1306 | + return ''; |
|
1307 | + } |
|
1267 | 1308 | |
1268 | 1309 | $doc = new DOMDocument(); |
1269 | 1310 | $doc->loadHTML('<?xml encoding="UTF-8">' . $res); |
@@ -1325,13 +1366,15 @@ discard block |
||
1325 | 1366 | |
1326 | 1367 | if ($entry->nodeName == 'source') { |
1327 | 1368 | |
1328 | - if ($entry->parentNode && $entry->parentNode->parentNode) |
|
1329 | - $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
1369 | + if ($entry->parentNode && $entry->parentNode->parentNode) { |
|
1370 | + $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); |
|
1371 | + } |
|
1330 | 1372 | |
1331 | 1373 | } else if ($entry->nodeName == 'img') { |
1332 | 1374 | |
1333 | - if ($entry->parentNode) |
|
1334 | - $entry->parentNode->replaceChild($p, $entry); |
|
1375 | + if ($entry->parentNode) { |
|
1376 | + $entry->parentNode->replaceChild($p, $entry); |
|
1377 | + } |
|
1335 | 1378 | |
1336 | 1379 | } |
1337 | 1380 | } |
@@ -1367,7 +1410,9 @@ discard block |
||
1367 | 1410 | 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', |
1368 | 1411 | 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); |
1369 | 1412 | |
1370 | - if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; |
|
1413 | + if ($_SESSION['hasSandbox']) { |
|
1414 | + $allowed_elements[] = 'iframe'; |
|
1415 | + } |
|
1371 | 1416 | |
1372 | 1417 | $disallowed_attributes = array('id', 'style', 'class'); |
1373 | 1418 | |
@@ -1407,7 +1452,9 @@ discard block |
||
1407 | 1452 | $text = mb_substr($text, $pos + mb_strlen($word)); |
1408 | 1453 | } |
1409 | 1454 | |
1410 | - if (!empty($text)) $fragment->appendChild(new DomText($text)); |
|
1455 | + if (!empty($text)) { |
|
1456 | + $fragment->appendChild(new DomText($text)); |
|
1457 | + } |
|
1411 | 1458 | |
1412 | 1459 | $child->parentNode->replaceChild($fragment, $child); |
1413 | 1460 | } |
@@ -1598,8 +1645,9 @@ discard block |
||
1598 | 1645 | } else { |
1599 | 1646 | $output = ""; |
1600 | 1647 | |
1601 | - for ($i = 0; $i < $length; $i++) |
|
1602 | - $output .= chr(mt_rand(0, 255)); |
|
1648 | + for ($i = 0; $i < $length; $i++) { |
|
1649 | + $output .= chr(mt_rand(0, 255)); |
|
1650 | + } |
|
1603 | 1651 | |
1604 | 1652 | return $output; |
1605 | 1653 | } |
@@ -1669,15 +1717,20 @@ discard block |
||
1669 | 1717 | } |
1670 | 1718 | |
1671 | 1719 | function get_theme_path($theme) { |
1672 | - if ($theme == "default.php") |
|
1673 | - return "css/default.css"; |
|
1720 | + if ($theme == "default.php") { |
|
1721 | + return "css/default.css"; |
|
1722 | + } |
|
1674 | 1723 | |
1675 | 1724 | $check = "themes/$theme"; |
1676 | - if (file_exists($check)) return $check; |
|
1725 | + if (file_exists($check)) { |
|
1726 | + return $check; |
|
1727 | + } |
|
1677 | 1728 | |
1678 | 1729 | $check = "themes.local/$theme"; |
1679 | - if (file_exists($check)) return $check; |
|
1680 | -} |
|
1730 | + if (file_exists($check)) { |
|
1731 | + return $check; |
|
1732 | + } |
|
1733 | + } |
|
1681 | 1734 | |
1682 | 1735 | function theme_exists($theme) { |
1683 | 1736 | return file_exists("themes/$theme") || file_exists("themes.local/$theme"); |
@@ -1733,7 +1786,9 @@ discard block |
||
1733 | 1786 | function send_local_file($filename) { |
1734 | 1787 | if (file_exists($filename)) { |
1735 | 1788 | |
1736 | - if (is_writable($filename)) touch($filename); |
|
1789 | + if (is_writable($filename)) { |
|
1790 | + touch($filename); |
|
1791 | + } |
|
1737 | 1792 | |
1738 | 1793 | $tmppluginhost = new PluginHost(); |
1739 | 1794 | |
@@ -1741,7 +1796,9 @@ discard block |
||
1741 | 1796 | $tmppluginhost->load_data(); |
1742 | 1797 | |
1743 | 1798 | foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) { |
1744 | - if ($plugin->hook_send_local_file($filename)) return true; |
|
1799 | + if ($plugin->hook_send_local_file($filename)) { |
|
1800 | + return true; |
|
1801 | + } |
|
1745 | 1802 | } |
1746 | 1803 | |
1747 | 1804 | $mimetype = mime_content_type($filename); |
@@ -1749,8 +1806,9 @@ discard block |
||
1749 | 1806 | // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4 |
1750 | 1807 | // video files are detected as octet-stream by mime_content_type() |
1751 | 1808 | |
1752 | - if ($mimetype == "application/octet-stream") |
|
1753 | - $mimetype = "video/mp4"; |
|
1809 | + if ($mimetype == "application/octet-stream") { |
|
1810 | + $mimetype = "video/mp4"; |
|
1811 | + } |
|
1754 | 1812 | |
1755 | 1813 | header("Content-type: $mimetype"); |
1756 | 1814 | |
@@ -1773,7 +1831,9 @@ discard block |
||
1773 | 1831 | |
1774 | 1832 | foreach ($files as $file) { |
1775 | 1833 | $file_ts = filemtime($file); |
1776 | - if ($file_ts > $ts) $ts = $file_ts; |
|
1834 | + if ($file_ts > $ts) { |
|
1835 | + $ts = $file_ts; |
|
1836 | + } |
|
1777 | 1837 | } |
1778 | 1838 | |
1779 | 1839 | return $ts; |
@@ -1786,8 +1846,9 @@ discard block |
||
1786 | 1846 | function get_version(&$git_commit = false, &$git_timestamp = false) { |
1787 | 1847 | global $ttrss_version; |
1788 | 1848 | |
1789 | - if (isset($ttrss_version)) |
|
1790 | - return $ttrss_version; |
|
1849 | + if (isset($ttrss_version)) { |
|
1850 | + return $ttrss_version; |
|
1851 | + } |
|
1791 | 1852 | |
1792 | 1853 | $ttrss_version = "UNKNOWN (Unsupported)"; |
1793 | 1854 |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | return true; |
79 | 79 | } |
80 | 80 | |
81 | -function ttrss_open () { |
|
81 | +function ttrss_open() { |
|
82 | 82 | return true; |
83 | 83 | } |
84 | 84 | |
85 | -function ttrss_read ($id){ |
|
85 | +function ttrss_read($id) { |
|
86 | 86 | global $session_expire; |
87 | 87 | |
88 | 88 | $sth = Db::pdo()->prepare("SELECT data FROM ttrss_sessions WHERE id=?"); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | -function ttrss_write ($id, $data) { |
|
104 | +function ttrss_write($id, $data) { |
|
105 | 105 | global $session_expire; |
106 | 106 | |
107 | 107 | $data = base64_encode($data); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return true; |
122 | 122 | } |
123 | 123 | |
124 | -function ttrss_close () { |
|
124 | +function ttrss_close() { |
|
125 | 125 | return true; |
126 | 126 | } |
127 | 127 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | |
135 | -function ttrss_gc () { |
|
136 | - Db::pdo()->query("DELETE FROM ttrss_sessions WHERE expire < " . time()); |
|
135 | +function ttrss_gc() { |
|
136 | + Db::pdo()->query("DELETE FROM ttrss_sessions WHERE expire < ".time()); |
|
137 | 137 | |
138 | 138 | return true; |
139 | 139 | } |
@@ -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"] = |
@@ -121,36 +121,36 @@ |
||
121 | 121 | $contentScore = 0; |
122 | 122 | |
123 | 123 | switch ($this->nodeName) { |
124 | - case 'div': |
|
125 | - $contentScore += 5; |
|
126 | - break; |
|
127 | - |
|
128 | - case 'pre': |
|
129 | - case 'td': |
|
130 | - case 'blockquote': |
|
131 | - $contentScore += 3; |
|
132 | - break; |
|
133 | - |
|
134 | - case 'address': |
|
135 | - case 'ol': |
|
136 | - case 'ul': |
|
137 | - case 'dl': |
|
138 | - case 'dd': |
|
139 | - case 'dt': |
|
140 | - case 'li': |
|
141 | - case 'form': |
|
142 | - $contentScore -= 3; |
|
143 | - break; |
|
144 | - |
|
145 | - case 'h1': |
|
146 | - case 'h2': |
|
147 | - case 'h3': |
|
148 | - case 'h4': |
|
149 | - case 'h5': |
|
150 | - case 'h6': |
|
151 | - case 'th': |
|
152 | - $contentScore -= 5; |
|
153 | - break; |
|
124 | + case 'div': |
|
125 | + $contentScore += 5; |
|
126 | + break; |
|
127 | + |
|
128 | + case 'pre': |
|
129 | + case 'td': |
|
130 | + case 'blockquote': |
|
131 | + $contentScore += 3; |
|
132 | + break; |
|
133 | + |
|
134 | + case 'address': |
|
135 | + case 'ol': |
|
136 | + case 'ul': |
|
137 | + case 'dl': |
|
138 | + case 'dd': |
|
139 | + case 'dt': |
|
140 | + case 'li': |
|
141 | + case 'form': |
|
142 | + $contentScore -= 3; |
|
143 | + break; |
|
144 | + |
|
145 | + case 'h1': |
|
146 | + case 'h2': |
|
147 | + case 'h3': |
|
148 | + case 'h4': |
|
149 | + case 'h5': |
|
150 | + case 'h6': |
|
151 | + case 'th': |
|
152 | + $contentScore -= 5; |
|
153 | + break; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | $this->contentScore = $contentScore + ($weightClasses ? $this->getClassWeight() : 0); |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $ret = iterator_to_array($this->childNodes); |
329 | 329 | if ($filterEmptyDOMText) { |
330 | 330 | // Array values is used to discard the key order. Needs to be 0 to whatever without skipping any number |
331 | - $ret = array_values(array_filter($ret, function ($node) { |
|
331 | + $ret = array_values(array_filter($ret, function($node) { |
|
332 | 332 | return $node->nodeName !== '#text' || mb_strlen(trim($node->nodeValue)); |
333 | 333 | })); |
334 | 334 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | } |
428 | 428 | |
429 | 429 | // And there should be no text nodes with real content |
430 | - return array_reduce(iterator_to_array($children), function ($carry, $child) { |
|
430 | + return array_reduce(iterator_to_array($children), function($carry, $child) { |
|
431 | 431 | if (!$carry === false) { |
432 | 432 | return false; |
433 | 433 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * are dealing with (And at this point we know they are empty or are just whitespace, because of the |
481 | 481 | * mb_strlen in this chain of checks). |
482 | 482 | */ |
483 | - + count(array_filter(iterator_to_array($this->childNodes), function ($child) { |
|
483 | + + count(array_filter(iterator_to_array($this->childNodes), function($child) { |
|
484 | 484 | return $child instanceof DOMText; |
485 | 485 | })) |
486 | 486 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | return $this->nodeType === XML_TEXT_NODE || in_array($this->nodeName, $this->phrasing_elems) !== false || |
499 | 499 | (!is_null($this->childNodes) && |
500 | 500 | ($this->nodeName === 'a' || $this->nodeName === 'del' || $this->nodeName === 'ins') && |
501 | - array_reduce(iterator_to_array($this->childNodes), function ($carry, $node) { |
|
501 | + array_reduce(iterator_to_array($this->childNodes), function($carry, $node) { |
|
502 | 502 | return $node->isPhrasingContent() && $carry; |
503 | 503 | }, true) |
504 | 504 | ); |
@@ -32,10 +32,10 @@ |
||
32 | 32 | public function __get($name) |
33 | 33 | { |
34 | 34 | switch ($name) { |
35 | - case 'length': |
|
36 | - return $this->length; |
|
37 | - default: |
|
38 | - trigger_error(sprintf('Undefined property: %s::%s', static::class, $name)); |
|
35 | + case 'length': |
|
36 | + return $this->length; |
|
37 | + default: |
|
38 | + trigger_error(sprintf('Undefined property: %s::%s', static::class, $name)); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $this->attempts[] = ['articleContent' => $result, 'textLength' => $length]; |
195 | 195 | |
196 | 196 | // No luck after removing flags, just return the longest text we found during the different loops |
197 | - usort($this->attempts, function ($a, $b) { |
|
197 | + usort($this->attempts, function($a, $b) { |
|
198 | 198 | return $a['textLength'] < $b['textLength']; |
199 | 199 | }); |
200 | 200 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | // Prepend the XML tag to avoid having issues with special characters. Should be harmless. |
276 | - $dom->loadHTML('<?xml encoding="UTF-8">' . $html); |
|
276 | + $dom->loadHTML('<?xml encoding="UTF-8">'.$html); |
|
277 | 277 | $dom->encoding = 'UTF-8'; |
278 | 278 | |
279 | 279 | $this->removeScripts($dom); |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * I can assure you it works properly if you let the code run. |
492 | 492 | */ |
493 | 493 | if (preg_match('/ [\|\-\\\\\/>»] /i', $curTitle)) { |
494 | - $titleHadHierarchicalSeparators = (bool)preg_match('/ [\\\\\/>»] /', $curTitle); |
|
494 | + $titleHadHierarchicalSeparators = (bool) preg_match('/ [\\\\\/>»] /', $curTitle); |
|
495 | 495 | $curTitle = preg_replace('/(.*)[\|\-\\\\\/>»] .*/i', '$1', $originalTitle); |
496 | 496 | |
497 | 497 | $this->logger->info(sprintf('[Metadata] Found hierarchical separators in title, new title is: \'%s\'', $curTitle)); |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | // could assume it's the full title. |
508 | 508 | $match = false; |
509 | 509 | for ($i = 1; $i <= 2; $i++) { |
510 | - foreach ($this->dom->getElementsByTagName('h' . $i) as $hTag) { |
|
510 | + foreach ($this->dom->getElementsByTagName('h'.$i) as $hTag) { |
|
511 | 511 | // Trim texts to avoid having false negatives when the title is surrounded by spaces or tabs |
512 | 512 | if (trim($hTag->nodeValue) === trim($curTitle)) { |
513 | 513 | $match = true; |
@@ -579,17 +579,17 @@ discard block |
||
579 | 579 | |
580 | 580 | // Scheme-rooted relative URI. |
581 | 581 | if (substr($uri, 0, 2) === '//') { |
582 | - return $scheme . '://' . substr($uri, 2); |
|
582 | + return $scheme.'://'.substr($uri, 2); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | // Prepath-rooted relative URI. |
586 | 586 | if (substr($uri, 0, 1) === '/') { |
587 | - return $prePath . $uri; |
|
587 | + return $prePath.$uri; |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | // Dotslash relative URI. |
591 | 591 | if (strpos($uri, './') === 0) { |
592 | - return $pathBase . substr($uri, 2); |
|
592 | + return $pathBase.substr($uri, 2); |
|
593 | 593 | } |
594 | 594 | // Ignore hash URIs: |
595 | 595 | if (substr($uri, 0, 1) === '#') { |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | |
599 | 599 | // Standard relative URI; add entire path. pathBase already includes a |
600 | 600 | // trailing "/". |
601 | - return $pathBase . $uri; |
|
601 | + return $pathBase.$uri; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
@@ -614,17 +614,17 @@ discard block |
||
614 | 614 | if ($this->dom->baseURI !== null) { |
615 | 615 | if (substr($this->dom->baseURI, 0, 1) === '/') { |
616 | 616 | // URLs starting with '/' override completely the URL defined in the link |
617 | - $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . $this->dom->baseURI; |
|
617 | + $pathBase = parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).$this->dom->baseURI; |
|
618 | 618 | } else { |
619 | 619 | // Otherwise just prepend the base to the actual path |
620 | - $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . dirname(parse_url($url, PHP_URL_PATH)) . '/' . rtrim($this->dom->baseURI, '/') . '/'; |
|
620 | + $pathBase = parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).dirname(parse_url($url, PHP_URL_PATH)).'/'.rtrim($this->dom->baseURI, '/').'/'; |
|
621 | 621 | } |
622 | 622 | } else { |
623 | - $pathBase = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . dirname(parse_url($url, PHP_URL_PATH)) . '/'; |
|
623 | + $pathBase = parse_url($url, PHP_URL_SCHEME).'://'.parse_url($url, PHP_URL_HOST).dirname(parse_url($url, PHP_URL_PATH)).'/'; |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | $scheme = parse_url($pathBase, PHP_URL_SCHEME); |
627 | - $prePath = $scheme . '://' . parse_url($pathBase, PHP_URL_HOST); |
|
627 | + $prePath = $scheme.'://'.parse_url($pathBase, PHP_URL_HOST); |
|
628 | 628 | |
629 | 629 | return [$pathBase, $scheme, $prePath]; |
630 | 630 | } |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | continue; |
659 | 659 | } |
660 | 660 | |
661 | - $matchString = $node->getAttribute('class') . ' ' . $node->getAttribute('id'); |
|
661 | + $matchString = $node->getAttribute('class').' '.$node->getAttribute('id'); |
|
662 | 662 | |
663 | 663 | if (!$node->isProbablyVisible()) { |
664 | 664 | $this->logger->debug(sprintf('[Get Nodes] Removing hidden node... Match string was: \'%s\'', $matchString)); |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | while ($parentOfTopCandidate->nodeName !== 'body' && $parentOfTopCandidate->nodeType === XML_ELEMENT_NODE) { |
1050 | 1050 | $listsContainingThisAncestor = 0; |
1051 | 1051 | for ($ancestorIndex = 0; $ancestorIndex < count($alternativeCandidateAncestors) && $listsContainingThisAncestor < $MINIMUM_TOPCANDIDATES; $ancestorIndex++) { |
1052 | - $listsContainingThisAncestor += (int)in_array($parentOfTopCandidate, $alternativeCandidateAncestors[$ancestorIndex]); |
|
1052 | + $listsContainingThisAncestor += (int) in_array($parentOfTopCandidate, $alternativeCandidateAncestors[$ancestorIndex]); |
|
1053 | 1053 | } |
1054 | 1054 | if ($listsContainingThisAncestor >= $MINIMUM_TOPCANDIDATES) { |
1055 | 1055 | $topCandidate = $parentOfTopCandidate; |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | $row = $tbody->getFirstElementChild(); |
1286 | 1286 | if ($row->hasSingleTagInsideElement('td')) { |
1287 | 1287 | $cell = $row->getFirstElementChild(); |
1288 | - $cell = NodeUtility::setNodeTag($cell, (array_reduce(iterator_to_array($cell->childNodes), function ($carry, $node) { |
|
1288 | + $cell = NodeUtility::setNodeTag($cell, (array_reduce(iterator_to_array($cell->childNodes), function($carry, $node) { |
|
1289 | 1289 | return $node->isPhrasingContent() && $carry; |
1290 | 1290 | }, true)) ? 'p' : 'div'); |
1291 | 1291 | $table->parentNode->replaceChild($cell, $table); |
@@ -1465,7 +1465,7 @@ discard block |
||
1465 | 1465 | $node = $DOMNodeList->item($length - 1 - $i); |
1466 | 1466 | |
1467 | 1467 | // First check if we're in a data table, in which case don't remove us. |
1468 | - if ($node->hasAncestorTag('table', -1, function ($node) { |
|
1468 | + if ($node->hasAncestorTag('table', -1, function($node) { |
|
1469 | 1469 | return $node->isReadabilityDataTable(); |
1470 | 1470 | })) { |
1471 | 1471 | continue; |
@@ -1577,7 +1577,7 @@ discard block |
||
1577 | 1577 | public function _cleanHeaders(DOMDocument $article) |
1578 | 1578 | { |
1579 | 1579 | for ($headerIndex = 1; $headerIndex < 3; $headerIndex++) { |
1580 | - $headers = $article->getElementsByTagName('h' . $headerIndex); |
|
1580 | + $headers = $article->getElementsByTagName('h'.$headerIndex); |
|
1581 | 1581 | /** @var $header DOMElement */ |
1582 | 1582 | foreach ($headers as $header) { |
1583 | 1583 | $weight = 0; |
@@ -54,7 +54,7 @@ |
||
54 | 54 | while ($line = $sth->fetch()) { |
55 | 55 | |
56 | 56 | if (!$subject) { |
57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
57 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
@@ -162,31 +162,31 @@ |
||
162 | 162 | |
163 | 163 | Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); |
164 | 164 | |
165 | - if ($this->cache->exists($status_filename)) { |
|
166 | - $status = json_decode($this->cache->get($status_filename), true); |
|
167 | - } else { |
|
168 | - $status = []; |
|
169 | - } |
|
165 | + if ($this->cache->exists($status_filename)) { |
|
166 | + $status = json_decode($this->cache->get($status_filename), true); |
|
167 | + } else { |
|
168 | + $status = []; |
|
169 | + } |
|
170 | 170 | |
171 | - $status["attempt"] += 1; |
|
171 | + $status["attempt"] += 1; |
|
172 | 172 | |
173 | - // only allow several download attempts for article |
|
174 | - if ($status["attempt"] > $this->max_cache_attempts) { |
|
175 | - Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE); |
|
176 | - return false; |
|
177 | - } |
|
173 | + // only allow several download attempts for article |
|
174 | + if ($status["attempt"] > $this->max_cache_attempts) { |
|
175 | + Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE); |
|
176 | + return false; |
|
177 | + } |
|
178 | 178 | |
179 | - if (!$this->cache->put($status_filename, json_encode($status))) { |
|
180 | - user_error("unable to write status file: $status_filename", E_USER_WARNING); |
|
181 | - return false; |
|
182 | - } |
|
179 | + if (!$this->cache->put($status_filename, json_encode($status))) { |
|
180 | + user_error("unable to write status file: $status_filename", E_USER_WARNING); |
|
181 | + return false; |
|
182 | + } |
|
183 | 183 | |
184 | 184 | $doc = new DOMDocument(); |
185 | 185 | |
186 | 186 | $has_images = false; |
187 | 187 | $success = false; |
188 | 188 | |
189 | - if ($doc->loadHTML('<?xml encoding="UTF-8">'.$content)) { |
|
189 | + if ($doc->loadHTML('<?xml encoding="UTF-8">'.$content)) { |
|
190 | 190 | $xpath = new DOMXPath($doc); |
191 | 191 | $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
192 | 192 |
@@ -124,8 +124,9 @@ |
||
124 | 124 | |
125 | 125 | while ($line = $sth->fetch()) { |
126 | 126 | |
127 | - if (!$subject) |
|
128 | - $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
127 | + if (!$subject) { |
|
128 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
129 | + } |
|
129 | 130 | |
130 | 131 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
131 | 132 | $tnote = strip_tags($line["note"]); |