@@ -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 | } |
@@ -57,10 +57,16 @@ discard block |
||
57 | 57 | |
58 | 58 | $rc = false; |
59 | 59 | |
60 | - if (!$title) $title = $url; |
|
61 | - if (!$title && !$url) return false; |
|
60 | + if (!$title) { |
|
61 | + $title = $url; |
|
62 | + } |
|
63 | + if (!$title && !$url) { |
|
64 | + return false; |
|
65 | + } |
|
62 | 66 | |
63 | - if (filter_var($url, FILTER_VALIDATE_URL) === false) return false; |
|
67 | + if (filter_var($url, FILTER_VALIDATE_URL) === false) { |
|
68 | + return false; |
|
69 | + } |
|
64 | 70 | |
65 | 71 | $pdo = Db::pdo(); |
66 | 72 | |
@@ -271,7 +277,9 @@ discard block |
||
271 | 277 | $tags_str = $this->format_tags_string($tags); |
272 | 278 | $tags_str_full = join(", ", $tags); |
273 | 279 | |
274 | - if (!$tags_str_full) $tags_str_full = __("no tags"); |
|
280 | + if (!$tags_str_full) { |
|
281 | + $tags_str_full = __("no tags"); |
|
282 | + } |
|
275 | 283 | |
276 | 284 | print json_encode([ |
277 | 285 | "id" => (int) $id, |
@@ -320,10 +328,11 @@ discard block |
||
320 | 328 | |
321 | 329 | foreach ($ids as $id) { |
322 | 330 | |
323 | - if ($assign) |
|
324 | - Labels::add_article($id, $label, $_SESSION["uid"]); |
|
325 | - else |
|
326 | - Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
331 | + if ($assign) { |
|
332 | + Labels::add_article($id, $label, $_SESSION["uid"]); |
|
333 | + } else { |
|
334 | + Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
335 | + } |
|
327 | 336 | |
328 | 337 | $labels = $this->get_article_labels($id, $_SESSION["uid"]); |
329 | 338 | |
@@ -384,14 +393,18 @@ discard block |
||
384 | 393 | $width = $line["width"]; |
385 | 394 | $height = $line["height"]; |
386 | 395 | |
387 | - if (!$ctype) $ctype = __("unknown type"); |
|
396 | + if (!$ctype) { |
|
397 | + $ctype = __("unknown type"); |
|
398 | + } |
|
388 | 399 | |
389 | 400 | //$filename = substr($url, strrpos($url, "/")+1); |
390 | 401 | $filename = basename($url); |
391 | 402 | |
392 | 403 | $player = format_inline_player($url, $ctype); |
393 | 404 | |
394 | - if ($player) array_push($entries_inline, $player); |
|
405 | + if ($player) { |
|
406 | + array_push($entries_inline, $player); |
|
407 | + } |
|
395 | 408 | |
396 | 409 | # $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" . |
397 | 410 | # $filename . " (" . $ctype . ")" . "</a>"; |
@@ -419,8 +432,9 @@ discard block |
||
419 | 432 | |
420 | 433 | foreach ($entries as $entry) { |
421 | 434 | |
422 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) |
|
423 | - $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
435 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) { |
|
436 | + $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
437 | + } |
|
424 | 438 | |
425 | 439 | |
426 | 440 | if ($retval) { |
@@ -431,10 +445,12 @@ discard block |
||
431 | 445 | |
432 | 446 | if (!$hide_images) { |
433 | 447 | $encsize = ''; |
434 | - if ($entry['height'] > 0) |
|
435 | - $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
436 | - if ($entry['width'] > 0) |
|
437 | - $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
448 | + if ($entry['height'] > 0) { |
|
449 | + $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
450 | + } |
|
451 | + if ($entry['width'] > 0) { |
|
452 | + $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
453 | + } |
|
438 | 454 | $rv .= "<p><img |
439 | 455 | alt=\"".htmlspecialchars($entry["filename"])."\" |
440 | 456 | src=\"" .htmlspecialchars($entry["url"]) . "\" |
@@ -466,15 +482,17 @@ discard block |
||
466 | 482 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
467 | 483 | |
468 | 484 | foreach ($entries as $entry) { |
469 | - if ($entry["title"]) |
|
470 | - $title = " — " . truncate_string($entry["title"], 30); |
|
471 | - else |
|
472 | - $title = ""; |
|
485 | + if ($entry["title"]) { |
|
486 | + $title = " — " . truncate_string($entry["title"], 30); |
|
487 | + } else { |
|
488 | + $title = ""; |
|
489 | + } |
|
473 | 490 | |
474 | - if ($entry["filename"]) |
|
475 | - $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
476 | - else |
|
477 | - $filename = ""; |
|
491 | + if ($entry["filename"]) { |
|
492 | + $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
493 | + } else { |
|
494 | + $filename = ""; |
|
495 | + } |
|
478 | 496 | |
479 | 497 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
480 | 498 | dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; |
@@ -492,7 +510,9 @@ discard block |
||
492 | 510 | |
493 | 511 | $a_id = $id; |
494 | 512 | |
495 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
513 | + if (!$owner_uid) { |
|
514 | + $owner_uid = $_SESSION["uid"]; |
|
515 | + } |
|
496 | 516 | |
497 | 517 | $pdo = Db::pdo(); |
498 | 518 | |
@@ -510,7 +530,9 @@ discard block |
||
510 | 530 | WHERE ref_id = ? AND owner_uid = ?"); |
511 | 531 | $csth->execute([$id, $owner_uid]); |
512 | 532 | |
513 | - if ($row = $csth->fetch()) $tag_cache = $row["tag_cache"]; |
|
533 | + if ($row = $csth->fetch()) { |
|
534 | + $tag_cache = $row["tag_cache"]; |
|
535 | + } |
|
514 | 536 | } |
515 | 537 | |
516 | 538 | if ($tag_cache) { |
@@ -551,8 +573,9 @@ discard block |
||
551 | 573 | |
552 | 574 | $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
553 | 575 | |
554 | - if (count($tags) > $maxtags) |
|
555 | - $tags_str .= ", …"; |
|
576 | + if (count($tags) > $maxtags) { |
|
577 | + $tags_str .= ", …"; |
|
578 | + } |
|
556 | 579 | |
557 | 580 | return $tags_str; |
558 | 581 | } |
@@ -560,7 +583,9 @@ discard block |
||
560 | 583 | |
561 | 584 | public static function format_article_labels($labels) { |
562 | 585 | |
563 | - if (!is_array($labels)) return ''; |
|
586 | + if (!is_array($labels)) { |
|
587 | + return ''; |
|
588 | + } |
|
564 | 589 | |
565 | 590 | $labels_str = ""; |
566 | 591 | |
@@ -618,10 +643,11 @@ discard block |
||
618 | 643 | |
619 | 644 | // purge orphaned posts in main content table |
620 | 645 | |
621 | - if (DB_TYPE == "mysql") |
|
622 | - $limit_qpart = "LIMIT 5000"; |
|
623 | - else |
|
624 | - $limit_qpart = ""; |
|
646 | + if (DB_TYPE == "mysql") { |
|
647 | + $limit_qpart = "LIMIT 5000"; |
|
648 | + } else { |
|
649 | + $limit_qpart = ""; |
|
650 | + } |
|
625 | 651 | |
626 | 652 | $pdo = Db::pdo(); |
627 | 653 | $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
@@ -635,7 +661,9 @@ discard block |
||
635 | 661 | |
636 | 662 | public static function catchupArticlesById($ids, $cmode, $owner_uid = false) { |
637 | 663 | |
638 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
664 | + if (!$owner_uid) { |
|
665 | + $owner_uid = $_SESSION["uid"]; |
|
666 | + } |
|
639 | 667 | |
640 | 668 | $pdo = Db::pdo(); |
641 | 669 | |
@@ -685,7 +713,9 @@ discard block |
||
685 | 713 | public static function get_article_labels($id, $owner_uid = false) { |
686 | 714 | $rv = array(); |
687 | 715 | |
688 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
716 | + if (!$owner_uid) { |
|
717 | + $owner_uid = $_SESSION["uid"]; |
|
718 | + } |
|
689 | 719 | |
690 | 720 | $pdo = Db::pdo(); |
691 | 721 | |
@@ -699,10 +729,11 @@ discard block |
||
699 | 729 | if ($label_cache) { |
700 | 730 | $tmp = json_decode($label_cache, true); |
701 | 731 | |
702 | - if (!$tmp || $tmp["no-labels"] == 1) |
|
703 | - return $rv; |
|
704 | - else |
|
705 | - return $tmp; |
|
732 | + if (!$tmp || $tmp["no-labels"] == 1) { |
|
733 | + return $rv; |
|
734 | + } else { |
|
735 | + return $tmp; |
|
736 | + } |
|
706 | 737 | } |
707 | 738 | } |
708 | 739 | |
@@ -721,10 +752,11 @@ discard block |
||
721 | 752 | array_push($rv, $rk); |
722 | 753 | } |
723 | 754 | |
724 | - if (count($rv) > 0) |
|
725 | - Labels::update_cache($owner_uid, $id, $rv); |
|
726 | - else |
|
727 | - Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
755 | + if (count($rv) > 0) { |
|
756 | + Labels::update_cache($owner_uid, $id, $rv); |
|
757 | + } else { |
|
758 | + Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
759 | + } |
|
728 | 760 | |
729 | 761 | return $rv; |
730 | 762 | } |
@@ -772,28 +804,33 @@ discard block |
||
772 | 804 | } |
773 | 805 | } |
774 | 806 | |
775 | - if (!$article_image) |
|
776 | - foreach ($enclosures as $enc) { |
|
807 | + if (!$article_image) { |
|
808 | + foreach ($enclosures as $enc) { |
|
777 | 809 | if (strpos($enc["content_type"], "image/") !== false) { |
778 | 810 | $article_image = $enc["content_url"]; |
811 | + } |
|
779 | 812 | break; |
780 | 813 | } |
781 | 814 | } |
782 | 815 | |
783 | - if ($article_image) |
|
784 | - $article_image = rewrite_relative_url($site_url, $article_image); |
|
816 | + if ($article_image) { |
|
817 | + $article_image = rewrite_relative_url($site_url, $article_image); |
|
818 | + } |
|
785 | 819 | |
786 | - if ($article_stream) |
|
787 | - $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
820 | + if ($article_stream) { |
|
821 | + $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
822 | + } |
|
788 | 823 | } |
789 | 824 | |
790 | 825 | $cache = new DiskCache("images"); |
791 | 826 | |
792 | - if ($article_image && $cache->exists(sha1($article_image))) |
|
793 | - $article_image = $cache->getUrl(sha1($article_image)); |
|
827 | + if ($article_image && $cache->exists(sha1($article_image))) { |
|
828 | + $article_image = $cache->getUrl(sha1($article_image)); |
|
829 | + } |
|
794 | 830 | |
795 | - if ($article_stream && $cache->exists(sha1($article_stream))) |
|
796 | - $article_stream = $cache->getUrl(sha1($article_stream)); |
|
831 | + if ($article_stream && $cache->exists(sha1($article_stream))) { |
|
832 | + $article_stream = $cache->getUrl(sha1($article_stream)); |
|
833 | + } |
|
797 | 834 | |
798 | 835 | return [$article_image, $article_stream]; |
799 | 836 | } |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | public function hook_prefs_tab($args) { |
50 | - if ($args != "prefFeeds") return; |
|
50 | + if ($args != "prefFeeds") { |
|
51 | + return; |
|
52 | + } |
|
51 | 53 | |
52 | 54 | print "<div dojoType='dijit.layout.AccordionPane' |
53 | 55 | title=\"<i class='material-icons'>extension</i> ".__('Readability settings (af_readability)')."\">"; |
@@ -93,7 +95,9 @@ discard block |
||
93 | 95 | print "</form>"; |
94 | 96 | |
95 | 97 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
96 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
98 | + if (!is_array($enabled_feeds)) { |
|
99 | + $enabled_feeds = array(); |
|
100 | + } |
|
97 | 101 | |
98 | 102 | $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); |
99 | 103 | $this->host->set($this, "enabled_feeds", $enabled_feeds); |
@@ -120,7 +124,9 @@ discard block |
||
120 | 124 | print "<section>"; |
121 | 125 | |
122 | 126 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
123 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
127 | + if (!is_array($enabled_feeds)) { |
|
128 | + $enabled_feeds = array(); |
|
129 | + } |
|
124 | 130 | |
125 | 131 | $key = array_search($feed_id, $enabled_feeds); |
126 | 132 | $checked = $key !== false ? "checked" : ""; |
@@ -137,7 +143,9 @@ discard block |
||
137 | 143 | |
138 | 144 | public function hook_prefs_save_feed($feed_id) { |
139 | 145 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
140 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
146 | + if (!is_array($enabled_feeds)) { |
|
147 | + $enabled_feeds = array(); |
|
148 | + } |
|
141 | 149 | |
142 | 150 | $enable = checkbox_to_sql_bool($_POST["af_readability_enabled"]); |
143 | 151 | $key = array_search($feed_id, $enabled_feeds); |
@@ -174,8 +182,9 @@ discard block |
||
174 | 182 | if ($tmp && mb_strlen($tmp) < 1024 * 500) { |
175 | 183 | $tmpdoc = new DOMDocument("1.0", "UTF-8"); |
176 | 184 | |
177 | - if (!@$tmpdoc->loadHTML($tmp)) |
|
178 | - return false; |
|
185 | + if (!@$tmpdoc->loadHTML($tmp)) { |
|
186 | + return false; |
|
187 | + } |
|
179 | 188 | |
180 | 189 | // this is the worst hack yet :( |
181 | 190 | if (strtolower($tmpdoc->encoding) != 'utf-8') { |
@@ -237,10 +246,14 @@ discard block |
||
237 | 246 | public function hook_article_filter($article) { |
238 | 247 | |
239 | 248 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
240 | - if (!is_array($enabled_feeds)) return $article; |
|
249 | + if (!is_array($enabled_feeds)) { |
|
250 | + return $article; |
|
251 | + } |
|
241 | 252 | |
242 | 253 | $key = array_search($article["feed"]["id"], $enabled_feeds); |
243 | - if ($key === false) return $article; |
|
254 | + if ($key === false) { |
|
255 | + return $article; |
|
256 | + } |
|
244 | 257 | |
245 | 258 | return $this->process_article($article); |
246 | 259 |
@@ -15,10 +15,16 @@ discard block |
||
15 | 15 | $min_title_length = (int) $_POST["min_title_length"]; |
16 | 16 | $enable_globally = checkbox_to_sql_bool($_POST["enable_globally"]); |
17 | 17 | |
18 | - if ($similarity < 0) $similarity = 0; |
|
19 | - if ($similarity > 1) $similarity = 1; |
|
18 | + if ($similarity < 0) { |
|
19 | + $similarity = 0; |
|
20 | + } |
|
21 | + if ($similarity > 1) { |
|
22 | + $similarity = 1; |
|
23 | + } |
|
20 | 24 | |
21 | - if ($min_title_length < 0) $min_title_length = 0; |
|
25 | + if ($min_title_length < 0) { |
|
26 | + $min_title_length = 0; |
|
27 | + } |
|
22 | 28 | |
23 | 29 | $similarity = sprintf("%.2f", $similarity); |
24 | 30 | |
@@ -121,7 +127,9 @@ discard block |
||
121 | 127 | } |
122 | 128 | |
123 | 129 | public function hook_prefs_tab($args) { |
124 | - if ($args != "prefFeeds") return; |
|
130 | + if ($args != "prefFeeds") { |
|
131 | + return; |
|
132 | + } |
|
125 | 133 | |
126 | 134 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
127 | 135 | title=\"<i class='material-icons'>extension</i> ".__('Mark similar articles as read')."\">"; |
@@ -140,8 +148,12 @@ discard block |
||
140 | 148 | $min_title_length = $this->host->get($this, "min_title_length"); |
141 | 149 | $enable_globally = $this->host->get($this, "enable_globally"); |
142 | 150 | |
143 | - if (!$similarity) $similarity = '0.75'; |
|
144 | - if (!$min_title_length) $min_title_length = '32'; |
|
151 | + if (!$similarity) { |
|
152 | + $similarity = '0.75'; |
|
153 | + } |
|
154 | + if (!$min_title_length) { |
|
155 | + $min_title_length = '32'; |
|
156 | + } |
|
145 | 157 | |
146 | 158 | print "<form dojoType=\"dijit.form.Form\">"; |
147 | 159 | |
@@ -198,7 +210,9 @@ discard block |
||
198 | 210 | print "</form>"; |
199 | 211 | |
200 | 212 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
201 | - if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
213 | + if (!array($enabled_feeds)) { |
|
214 | + $enabled_feeds = array(); |
|
215 | + } |
|
202 | 216 | |
203 | 217 | $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds); |
204 | 218 | $this->host->set($this, "enabled_feeds", $enabled_feeds); |
@@ -225,7 +239,9 @@ discard block |
||
225 | 239 | print "<section>"; |
226 | 240 | |
227 | 241 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
228 | - if (!array($enabled_feeds)) $enabled_feeds = array(); |
|
242 | + if (!array($enabled_feeds)) { |
|
243 | + $enabled_feeds = array(); |
|
244 | + } |
|
229 | 245 | |
230 | 246 | $key = array_search($feed_id, $enabled_feeds); |
231 | 247 | $checked = $key !== false ? "checked" : ""; |
@@ -242,7 +258,9 @@ discard block |
||
242 | 258 | |
243 | 259 | public function hook_prefs_save_feed($feed_id) { |
244 | 260 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
245 | - if (!is_array($enabled_feeds)) $enabled_feeds = array(); |
|
261 | + if (!is_array($enabled_feeds)) { |
|
262 | + $enabled_feeds = array(); |
|
263 | + } |
|
246 | 264 | |
247 | 265 | $enable = checkbox_to_sql_bool($_POST["trgm_similarity_enabled"]); |
248 | 266 | $key = array_search($feed_id, $enabled_feeds); |
@@ -262,24 +280,34 @@ discard block |
||
262 | 280 | |
263 | 281 | public function hook_article_filter($article) { |
264 | 282 | |
265 | - if (DB_TYPE != "pgsql") return $article; |
|
283 | + if (DB_TYPE != "pgsql") { |
|
284 | + return $article; |
|
285 | + } |
|
266 | 286 | |
267 | 287 | $res = $this->pdo->query("select 'similarity'::regproc"); |
268 | - if (!$res->fetch()) return $article; |
|
288 | + if (!$res->fetch()) { |
|
289 | + return $article; |
|
290 | + } |
|
269 | 291 | |
270 | 292 | $enable_globally = $this->host->get($this, "enable_globally"); |
271 | 293 | |
272 | 294 | if (!$enable_globally) { |
273 | 295 | $enabled_feeds = $this->host->get($this, "enabled_feeds"); |
274 | 296 | $key = array_search($article["feed"]["id"], $enabled_feeds); |
275 | - if ($key === false) return $article; |
|
297 | + if ($key === false) { |
|
298 | + return $article; |
|
299 | + } |
|
276 | 300 | } |
277 | 301 | |
278 | 302 | $similarity = (float) $this->host->get($this, "similarity"); |
279 | - if ($similarity < 0.01) return $article; |
|
303 | + if ($similarity < 0.01) { |
|
304 | + return $article; |
|
305 | + } |
|
280 | 306 | |
281 | 307 | $min_title_length = (int) $this->host->get($this, "min_title_length"); |
282 | - if (mb_strlen($article["title"]) < $min_title_length) return $article; |
|
308 | + if (mb_strlen($article["title"]) < $min_title_length) { |
|
309 | + return $article; |
|
310 | + } |
|
283 | 311 | |
284 | 312 | $owner_uid = $article["owner_uid"]; |
285 | 313 | $entry_guid = $article["guid_hashed"]; |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | public function hook_article_filter($article) { |
22 | 22 | $owner_uid = $article["owner_uid"]; |
23 | 23 | |
24 | - if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) |
|
25 | - return $article; |
|
24 | + if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) { |
|
25 | + return $article; |
|
26 | + } |
|
26 | 27 | |
27 | 28 | if ((strpos($article["link"], "feedproxy.google.com") !== false || |
28 | 29 | strpos($article["link"], "/~r/") !== false || |
@@ -57,7 +58,9 @@ discard block |
||
57 | 58 | parse_str($query, $args); |
58 | 59 | |
59 | 60 | foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) { |
60 | - if (isset($args[$param])) unset($args[$param]); |
|
61 | + if (isset($args[$param])) { |
|
62 | + unset($args[$param]); |
|
63 | + } |
|
61 | 64 | } |
62 | 65 | |
63 | 66 | $new_query = http_build_query($args); |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | public function hook_prefs_tab($args) { |
25 | - if ($args != "prefFeeds") return; |
|
25 | + if ($args != "prefFeeds") { |
|
26 | + return; |
|
27 | + } |
|
26 | 28 | |
27 | 29 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
28 | 30 | title=\"<i class='material-icons'>extension</i> ".__('Reddit content settings (af_redditimgur)')."\">"; |
@@ -173,8 +175,7 @@ discard block |
||
173 | 175 | if ($child["data"]["url"] == $matches[0]) { |
174 | 176 | try { |
175 | 177 | $source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"]; |
176 | - } |
|
177 | - catch (Exception $e) { |
|
178 | + } catch (Exception $e) { |
|
178 | 179 | } |
179 | 180 | break 2; |
180 | 181 | } |
@@ -230,8 +231,9 @@ discard block |
||
230 | 231 | |
231 | 232 | $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href")); |
232 | 233 | |
233 | - if (strpos($source_stream, "imgur.com") !== false) |
|
234 | - $poster_url = str_replace(".mp4", "h.jpg", $source_stream); |
|
234 | + if (strpos($source_stream, "imgur.com") !== false) { |
|
235 | + $poster_url = str_replace(".mp4", "h.jpg", $source_stream); |
|
236 | + } |
|
235 | 237 | |
236 | 238 | $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
237 | 239 | |
@@ -426,7 +428,9 @@ discard block |
||
426 | 428 | if ($row = $sth->fetch()) { |
427 | 429 | $num_found = $row['cid']; |
428 | 430 | |
429 | - if ($num_found > 0) $article["force_catchup"] = true; |
|
431 | + if ($num_found > 0) { |
|
432 | + $article["force_catchup"] = true; |
|
433 | + } |
|
430 | 434 | } |
431 | 435 | } |
432 | 436 | } |
@@ -458,7 +462,9 @@ discard block |
||
458 | 462 | $video->setAttribute("controls", "1"); |
459 | 463 | $video->setAttribute("loop", "1"); |
460 | 464 | |
461 | - if ($poster_url) $video->setAttribute("poster", $poster_url); |
|
465 | + if ($poster_url) { |
|
466 | + $video->setAttribute("poster", $poster_url); |
|
467 | + } |
|
462 | 468 | |
463 | 469 | $source = $doc->createElement('source'); |
464 | 470 | $source->setAttribute("src", $source_stream); |
@@ -104,14 +104,17 @@ discard block |
||
104 | 104 | $blockNo++; |
105 | 105 | } |
106 | 106 | |
107 | - if(QRspec::rsBlockNum2($spec) == 0) |
|
108 | - return 0; |
|
107 | + if(QRspec::rsBlockNum2($spec) == 0) { |
|
108 | + return 0; |
|
109 | + } |
|
109 | 110 | |
110 | 111 | $dl = QRspec::rsDataCodes2($spec); |
111 | 112 | $el = QRspec::rsEccCodes2($spec); |
112 | 113 | $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); |
113 | 114 | |
114 | - if($rs == null) return -1; |
|
115 | + if($rs == null) { |
|
116 | + return -1; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) { |
117 | 120 | $ecc = array_slice($this->ecccode,$eccPos); |
@@ -249,7 +252,9 @@ discard block |
||
249 | 252 | } |
250 | 253 | |
251 | 254 | $input = new QRinput($version, $level); |
252 | - if($input == null) return null; |
|
255 | + if($input == null) { |
|
256 | + return null; |
|
257 | + } |
|
253 | 258 | |
254 | 259 | $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string)); |
255 | 260 | if($ret < 0) { |
@@ -269,7 +274,9 @@ discard block |
||
269 | 274 | } |
270 | 275 | |
271 | 276 | $input = new QRinput($version, $level); |
272 | - if($input == null) return null; |
|
277 | + if($input == null) { |
|
278 | + return null; |
|
279 | + } |
|
273 | 280 | |
274 | 281 | $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); |
275 | 282 | if($ret < 0) { |
@@ -379,7 +386,9 @@ discard block |
||
379 | 386 | } |
380 | 387 | } |
381 | 388 | } |
382 | - if($x < 0 || $y < 0) return null; |
|
389 | + if($x < 0 || $y < 0) { |
|
390 | + return null; |
|
391 | + } |
|
383 | 392 | |
384 | 393 | $this->x = $x; |
385 | 394 | $this->y = $y; |
@@ -486,8 +495,9 @@ discard block |
||
486 | 495 | $err = ob_get_contents(); |
487 | 496 | ob_end_clean(); |
488 | 497 | |
489 | - if ($err != '') |
|
490 | - QRtools::log($outfile, $err); |
|
498 | + if ($err != '') { |
|
499 | + QRtools::log($outfile, $err); |
|
500 | + } |
|
491 | 501 | |
492 | 502 | $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin)); |
493 | 503 |
@@ -176,8 +176,9 @@ discard block |
||
176 | 176 | { |
177 | 177 | $barcode_array = array(); |
178 | 178 | |
179 | - if (!is_array($mode)) |
|
180 | - $mode = explode(',', $mode); |
|
179 | + if (!is_array($mode)) { |
|
180 | + $mode = explode(',', $mode); |
|
181 | + } |
|
181 | 182 | |
182 | 183 | $eccLevel = 'L'; |
183 | 184 | |
@@ -194,8 +195,9 @@ discard block |
||
194 | 195 | |
195 | 196 | foreach ($qrTab as $line) { |
196 | 197 | $arrAdd = array(); |
197 | - foreach(str_split($line) as $char) |
|
198 | - $arrAdd[] = ($char=='1')?1:0; |
|
198 | + foreach(str_split($line) as $char) { |
|
199 | + $arrAdd[] = ($char=='1')?1:0; |
|
200 | + } |
|
199 | 201 | $barcode_array['bcode'][] = $arrAdd; |
200 | 202 | } |
201 | 203 | |
@@ -223,8 +225,9 @@ discard block |
||
223 | 225 | |
224 | 226 | $width = count($frame); |
225 | 227 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
226 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
227 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
228 | + for ($maskNo=0; $maskNo<8; $maskNo++) { |
|
229 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
230 | + } |
|
228 | 231 | } |
229 | 232 | |
230 | 233 | QRtools::markTime('after_build_cache'); |
@@ -261,8 +264,9 @@ discard block |
||
261 | 264 | list($usec, $sec) = explode(" ", microtime()); |
262 | 265 | $time = ((float)$usec + (float)$sec); |
263 | 266 | |
264 | - if (!isset($GLOBALS['qr_time_bench'])) |
|
265 | - $GLOBALS['qr_time_bench'] = array(); |
|
267 | + if (!isset($GLOBALS['qr_time_bench'])) { |
|
268 | + $GLOBALS['qr_time_bench'] = array(); |
|
269 | + } |
|
266 | 270 | |
267 | 271 | $GLOBALS['qr_time_bench'][$markerId] = $time; |
268 | 272 | } |
@@ -427,8 +431,9 @@ discard block |
||
427 | 431 | |
428 | 432 | for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) { |
429 | 433 | $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level]; |
430 | - if($words >= $size) |
|
431 | - return $i; |
|
434 | + if($words >= $size) { |
|
435 | + return $i; |
|
436 | + } |
|
432 | 437 | } |
433 | 438 | |
434 | 439 | return -1; |
@@ -446,8 +451,9 @@ discard block |
||
446 | 451 | //---------------------------------------------------------------------- |
447 | 452 | public static function lengthIndicator($mode, $version) |
448 | 453 | { |
449 | - if ($mode == QR_MODE_STRUCTURE) |
|
450 | - return 0; |
|
454 | + if ($mode == QR_MODE_STRUCTURE) { |
|
455 | + return 0; |
|
456 | + } |
|
451 | 457 | |
452 | 458 | if ($version <= 9) { |
453 | 459 | $l = 0; |
@@ -463,8 +469,9 @@ discard block |
||
463 | 469 | //---------------------------------------------------------------------- |
464 | 470 | public static function maximumWords($mode, $version) |
465 | 471 | { |
466 | - if($mode == QR_MODE_STRUCTURE) |
|
467 | - return 3; |
|
472 | + if($mode == QR_MODE_STRUCTURE) { |
|
473 | + return 3; |
|
474 | + } |
|
468 | 475 | |
469 | 476 | if($version <= 9) { |
470 | 477 | $l = 0; |
@@ -610,8 +617,9 @@ discard block |
||
610 | 617 | //---------------------------------------------------------------------- |
611 | 618 | public static function putAlignmentPattern($version, &$frame, $width) |
612 | 619 | { |
613 | - if($version < 2) |
|
614 | - return; |
|
620 | + if($version < 2) { |
|
621 | + return; |
|
622 | + } |
|
615 | 623 | |
616 | 624 | $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0]; |
617 | 625 | if($d < 0) { |
@@ -663,8 +671,9 @@ discard block |
||
663 | 671 | //---------------------------------------------------------------------- |
664 | 672 | public static function getVersionPattern($version) |
665 | 673 | { |
666 | - if($version < 7 || $version > QRSPEC_VERSION_MAX) |
|
667 | - return 0; |
|
674 | + if($version < 7 || $version > QRSPEC_VERSION_MAX) { |
|
675 | + return 0; |
|
676 | + } |
|
668 | 677 | |
669 | 678 | return self::$versionPattern[$version -7]; |
670 | 679 | } |
@@ -681,11 +690,13 @@ discard block |
||
681 | 690 | |
682 | 691 | public static function getFormatInfo($mask, $level) |
683 | 692 | { |
684 | - if($mask < 0 || $mask > 7) |
|
685 | - return 0; |
|
693 | + if($mask < 0 || $mask > 7) { |
|
694 | + return 0; |
|
695 | + } |
|
686 | 696 | |
687 | - if($level < 0 || $level > 3) |
|
688 | - return 0; |
|
697 | + if($level < 0 || $level > 3) { |
|
698 | + return 0; |
|
699 | + } |
|
689 | 700 | |
690 | 701 | return self::$formatInfo[$level][$mask]; |
691 | 702 | } |
@@ -865,8 +876,9 @@ discard block |
||
865 | 876 | //---------------------------------------------------------------------- |
866 | 877 | public static function newFrame($version) |
867 | 878 | { |
868 | - if($version < 1 || $version > QRSPEC_VERSION_MAX) |
|
869 | - return null; |
|
879 | + if($version < 1 || $version > QRSPEC_VERSION_MAX) { |
|
880 | + return null; |
|
881 | + } |
|
870 | 882 | |
871 | 883 | if(!isset(self::$frames[$version])) { |
872 | 884 | |
@@ -884,8 +896,9 @@ discard block |
||
884 | 896 | } |
885 | 897 | } |
886 | 898 | |
887 | - if(is_null(self::$frames[$version])) |
|
888 | - return null; |
|
899 | + if(is_null(self::$frames[$version])) { |
|
900 | + return null; |
|
901 | + } |
|
889 | 902 | |
890 | 903 | return self::$frames[$version]; |
891 | 904 | } |
@@ -950,7 +963,7 @@ discard block |
||
950 | 963 | ImagePng($image, $filename); |
951 | 964 | header("Content-type: image/png"); |
952 | 965 | ImagePng($image); |
953 | - }else{ |
|
966 | + } else{ |
|
954 | 967 | ImagePng($image, $filename); |
955 | 968 | } |
956 | 969 | } |
@@ -1210,8 +1223,9 @@ discard block |
||
1210 | 1223 | { |
1211 | 1224 | $bits = 0; |
1212 | 1225 | |
1213 | - if($version == 0) |
|
1214 | - $version = 1; |
|
1226 | + if($version == 0) { |
|
1227 | + $version = 1; |
|
1228 | + } |
|
1215 | 1229 | |
1216 | 1230 | switch($this->mode) { |
1217 | 1231 | case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break; |
@@ -1270,8 +1284,9 @@ discard block |
||
1270 | 1284 | break; |
1271 | 1285 | } |
1272 | 1286 | |
1273 | - if($ret < 0) |
|
1274 | - return -1; |
|
1287 | + if($ret < 0) { |
|
1288 | + return -1; |
|
1289 | + } |
|
1275 | 1290 | } |
1276 | 1291 | |
1277 | 1292 | return $this->bstream->size(); |
@@ -1488,8 +1503,9 @@ discard block |
||
1488 | 1503 | //---------------------------------------------------------------------- |
1489 | 1504 | public static function checkModeKanji($size, $data) |
1490 | 1505 | { |
1491 | - if($size & 1) |
|
1492 | - return false; |
|
1506 | + if($size & 1) { |
|
1507 | + return false; |
|
1508 | + } |
|
1493 | 1509 | |
1494 | 1510 | for($i=0; $i<$size; $i+=2) { |
1495 | 1511 | $val = (ord($data[$i]) << 8) | ord($data[$i+1]); |
@@ -1509,8 +1525,9 @@ discard block |
||
1509 | 1525 | |
1510 | 1526 | public static function check($mode, $size, $data) |
1511 | 1527 | { |
1512 | - if($size <= 0) |
|
1513 | - return false; |
|
1528 | + if($size <= 0) { |
|
1529 | + return false; |
|
1530 | + } |
|
1514 | 1531 | |
1515 | 1532 | switch($mode) { |
1516 | 1533 | case QR_MODE_NUM: return self::checkModeNum($size, $data); break; |
@@ -1575,8 +1592,9 @@ discard block |
||
1575 | 1592 | $chunks = (int)($payload / 11); |
1576 | 1593 | $remain = $payload - $chunks * 11; |
1577 | 1594 | $size = $chunks * 2; |
1578 | - if($remain >= 6) |
|
1579 | - $size++; |
|
1595 | + if($remain >= 6) { |
|
1596 | + $size++; |
|
1597 | + } |
|
1580 | 1598 | break; |
1581 | 1599 | case QR_MODE_8: |
1582 | 1600 | $size = (int)($payload / 8); |
@@ -1593,8 +1611,12 @@ discard block |
||
1593 | 1611 | } |
1594 | 1612 | |
1595 | 1613 | $maxsize = QRspec::maximumWords($mode, $version); |
1596 | - if($size < 0) $size = 0; |
|
1597 | - if($size > $maxsize) $size = $maxsize; |
|
1614 | + if($size < 0) { |
|
1615 | + $size = 0; |
|
1616 | + } |
|
1617 | + if($size > $maxsize) { |
|
1618 | + $size = $maxsize; |
|
1619 | + } |
|
1598 | 1620 | |
1599 | 1621 | return $size; |
1600 | 1622 | } |
@@ -1607,8 +1629,9 @@ discard block |
||
1607 | 1629 | foreach($this->items as $item) { |
1608 | 1630 | $bits = $item->encodeBitStream($this->version); |
1609 | 1631 | |
1610 | - if($bits < 0) |
|
1611 | - return -1; |
|
1632 | + if($bits < 0) { |
|
1633 | + return -1; |
|
1634 | + } |
|
1612 | 1635 | |
1613 | 1636 | $total += $bits; |
1614 | 1637 | } |
@@ -1627,8 +1650,9 @@ discard block |
||
1627 | 1650 | for(;;) { |
1628 | 1651 | $bits = $this->createBitStream(); |
1629 | 1652 | |
1630 | - if($bits < 0) |
|
1631 | - return -1; |
|
1653 | + if($bits < 0) { |
|
1654 | + return -1; |
|
1655 | + } |
|
1632 | 1656 | |
1633 | 1657 | $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
1634 | 1658 | if($ver < 0) { |
@@ -1665,8 +1689,9 @@ discard block |
||
1665 | 1689 | $padding = new QRbitstream(); |
1666 | 1690 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
1667 | 1691 | |
1668 | - if($ret < 0) |
|
1669 | - return $ret; |
|
1692 | + if($ret < 0) { |
|
1693 | + return $ret; |
|
1694 | + } |
|
1670 | 1695 | |
1671 | 1696 | $padlen = $maxwords - $words; |
1672 | 1697 | |
@@ -1679,8 +1704,9 @@ discard block |
||
1679 | 1704 | |
1680 | 1705 | $ret = $padding->appendBytes($padlen, $padbuf); |
1681 | 1706 | |
1682 | - if($ret < 0) |
|
1683 | - return $ret; |
|
1707 | + if($ret < 0) { |
|
1708 | + return $ret; |
|
1709 | + } |
|
1684 | 1710 | |
1685 | 1711 | } |
1686 | 1712 | |
@@ -1857,13 +1883,15 @@ discard block |
||
1857 | 1883 | //---------------------------------------------------------------------- |
1858 | 1884 | public function appendNum($bits, $num) |
1859 | 1885 | { |
1860 | - if ($bits == 0) |
|
1861 | - return 0; |
|
1886 | + if ($bits == 0) { |
|
1887 | + return 0; |
|
1888 | + } |
|
1862 | 1889 | |
1863 | 1890 | $b = QRbitstream::newFromNum($bits, $num); |
1864 | 1891 | |
1865 | - if(is_null($b)) |
|
1866 | - return -1; |
|
1892 | + if(is_null($b)) { |
|
1893 | + return -1; |
|
1894 | + } |
|
1867 | 1895 | |
1868 | 1896 | $ret = $this->append($b); |
1869 | 1897 | unset($b); |
@@ -1874,13 +1902,15 @@ discard block |
||
1874 | 1902 | //---------------------------------------------------------------------- |
1875 | 1903 | public function appendBytes($size, $data) |
1876 | 1904 | { |
1877 | - if ($size == 0) |
|
1878 | - return 0; |
|
1905 | + if ($size == 0) { |
|
1906 | + return 0; |
|
1907 | + } |
|
1879 | 1908 | |
1880 | 1909 | $b = QRbitstream::newFromBytes($size, $data); |
1881 | 1910 | |
1882 | - if(is_null($b)) |
|
1883 | - return -1; |
|
1911 | + if(is_null($b)) { |
|
1912 | + return -1; |
|
1913 | + } |
|
1884 | 1914 | |
1885 | 1915 | $ret = $this->append($b); |
1886 | 1916 | unset($b); |
@@ -1984,8 +2014,9 @@ discard block |
||
1984 | 2014 | //---------------------------------------------------------------------- |
1985 | 2015 | public static function isdigitat($str, $pos) |
1986 | 2016 | { |
1987 | - if ($pos >= strlen($str)) |
|
1988 | - return false; |
|
2017 | + if ($pos >= strlen($str)) { |
|
2018 | + return false; |
|
2019 | + } |
|
1989 | 2020 | |
1990 | 2021 | return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); |
1991 | 2022 | } |
@@ -1993,8 +2024,9 @@ discard block |
||
1993 | 2024 | //---------------------------------------------------------------------- |
1994 | 2025 | public static function isalnumat($str, $pos) |
1995 | 2026 | { |
1996 | - if ($pos >= strlen($str)) |
|
1997 | - return false; |
|
2027 | + if ($pos >= strlen($str)) { |
|
2028 | + return false; |
|
2029 | + } |
|
1998 | 2030 | |
1999 | 2031 | return (QRinput::lookAnTable(ord($str[$pos])) >= 0); |
2000 | 2032 | } |
@@ -2002,8 +2034,9 @@ discard block |
||
2002 | 2034 | //---------------------------------------------------------------------- |
2003 | 2035 | public function identifyMode($pos) |
2004 | 2036 | { |
2005 | - if ($pos >= strlen($this->dataStr)) |
|
2006 | - return QR_MODE_NUL; |
|
2037 | + if ($pos >= strlen($this->dataStr)) { |
|
2038 | + return QR_MODE_NUL; |
|
2039 | + } |
|
2007 | 2040 | |
2008 | 2041 | $c = $this->dataStr[$pos]; |
2009 | 2042 | |
@@ -2057,8 +2090,9 @@ discard block |
||
2057 | 2090 | } |
2058 | 2091 | |
2059 | 2092 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
2060 | - if($ret < 0) |
|
2061 | - return -1; |
|
2093 | + if($ret < 0) { |
|
2094 | + return -1; |
|
2095 | + } |
|
2062 | 2096 | |
2063 | 2097 | return $run; |
2064 | 2098 | } |
@@ -2104,8 +2138,9 @@ discard block |
||
2104 | 2138 | } |
2105 | 2139 | |
2106 | 2140 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
2107 | - if($ret < 0) |
|
2108 | - return -1; |
|
2141 | + if($ret < 0) { |
|
2142 | + return -1; |
|
2143 | + } |
|
2109 | 2144 | |
2110 | 2145 | return $run; |
2111 | 2146 | } |
@@ -2120,8 +2155,9 @@ discard block |
||
2120 | 2155 | } |
2121 | 2156 | |
2122 | 2157 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
2123 | - if($ret < 0) |
|
2124 | - return -1; |
|
2158 | + if($ret < 0) { |
|
2159 | + return -1; |
|
2160 | + } |
|
2125 | 2161 | |
2126 | 2162 | return $run; |
2127 | 2163 | } |
@@ -2175,8 +2211,9 @@ discard block |
||
2175 | 2211 | $run = $p; |
2176 | 2212 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
2177 | 2213 | |
2178 | - if($ret < 0) |
|
2179 | - return -1; |
|
2214 | + if($ret < 0) { |
|
2215 | + return -1; |
|
2216 | + } |
|
2180 | 2217 | |
2181 | 2218 | return $run; |
2182 | 2219 | } |
@@ -2186,8 +2223,9 @@ discard block |
||
2186 | 2223 | { |
2187 | 2224 | while (strlen($this->dataStr) > 0) |
2188 | 2225 | { |
2189 | - if($this->dataStr == '') |
|
2190 | - return 0; |
|
2226 | + if($this->dataStr == '') { |
|
2227 | + return 0; |
|
2228 | + } |
|
2191 | 2229 | |
2192 | 2230 | $mode = $this->identifyMode(0); |
2193 | 2231 | |
@@ -2195,16 +2233,22 @@ discard block |
||
2195 | 2233 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
2196 | 2234 | case QR_MODE_AN: $length = $this->eatAn(); break; |
2197 | 2235 | case QR_MODE_KANJI: |
2198 | - if ($this->modeHint == QR_MODE_KANJI) |
|
2199 | - $length = $this->eatKanji(); |
|
2200 | - else $length = $this->eat8(); |
|
2236 | + if ($this->modeHint == QR_MODE_KANJI) { |
|
2237 | + $length = $this->eatKanji(); |
|
2238 | + } else { |
|
2239 | + $length = $this->eat8(); |
|
2240 | + } |
|
2201 | 2241 | break; |
2202 | 2242 | default: $length = $this->eat8(); break; |
2203 | 2243 | |
2204 | 2244 | } |
2205 | 2245 | |
2206 | - if($length == 0) return 0; |
|
2207 | - if($length < 0) return -1; |
|
2246 | + if($length == 0) { |
|
2247 | + return 0; |
|
2248 | + } |
|
2249 | + if($length < 0) { |
|
2250 | + return -1; |
|
2251 | + } |
|
2208 | 2252 | |
2209 | 2253 | $this->dataStr = substr($this->dataStr, $length); |
2210 | 2254 | } |
@@ -2240,8 +2284,9 @@ discard block |
||
2240 | 2284 | |
2241 | 2285 | $split = new QRsplit($string, $input, $modeHint); |
2242 | 2286 | |
2243 | - if(!$casesensitive) |
|
2244 | - $split->toUpper(); |
|
2287 | + if(!$casesensitive) { |
|
2288 | + $split->toUpper(); |
|
2289 | + } |
|
2245 | 2290 | |
2246 | 2291 | return $split->splitString(); |
2247 | 2292 | } |
@@ -2318,11 +2363,23 @@ discard block |
||
2318 | 2363 | $rs = null; |
2319 | 2364 | |
2320 | 2365 | // Check parameter ranges |
2321 | - if($symsize < 0 || $symsize > 8) return $rs; |
|
2322 | - if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs; |
|
2323 | - if($prim <= 0 || $prim >= (1<<$symsize)) return $rs; |
|
2324 | - if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values! |
|
2325 | - if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding |
|
2366 | + if($symsize < 0 || $symsize > 8) { |
|
2367 | + return $rs; |
|
2368 | + } |
|
2369 | + if($fcr < 0 || $fcr >= (1<<$symsize)) { |
|
2370 | + return $rs; |
|
2371 | + } |
|
2372 | + if($prim <= 0 || $prim >= (1<<$symsize)) { |
|
2373 | + return $rs; |
|
2374 | + } |
|
2375 | + if($nroots < 0 || $nroots >= (1<<$symsize)) { |
|
2376 | + return $rs; |
|
2377 | + } |
|
2378 | + // Can't have more roots than symbol values! |
|
2379 | + if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) { |
|
2380 | + return $rs; |
|
2381 | + } |
|
2382 | + // Too much padding |
|
2326 | 2383 | |
2327 | 2384 | $rs = new QRrsItem(); |
2328 | 2385 | $rs->mm = $symsize; |
@@ -2388,8 +2445,9 @@ discard block |
||
2388 | 2445 | } |
2389 | 2446 | |
2390 | 2447 | // convert rs->genpoly[] to index form for quicker encoding |
2391 | - for ($i = 0; $i <= $nroots; $i++) |
|
2392 | - $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
2448 | + for ($i = 0; $i <= $nroots; $i++) { |
|
2449 | + $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
2450 | + } |
|
2393 | 2451 | |
2394 | 2452 | return $rs; |
2395 | 2453 | } |
@@ -2447,12 +2505,24 @@ discard block |
||
2447 | 2505 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
2448 | 2506 | { |
2449 | 2507 | foreach(self::$items as $rs) { |
2450 | - if($rs->pad != $pad) continue; |
|
2451 | - if($rs->nroots != $nroots) continue; |
|
2452 | - if($rs->mm != $symsize) continue; |
|
2453 | - if($rs->gfpoly != $gfpoly) continue; |
|
2454 | - if($rs->fcr != $fcr) continue; |
|
2455 | - if($rs->prim != $prim) continue; |
|
2508 | + if($rs->pad != $pad) { |
|
2509 | + continue; |
|
2510 | + } |
|
2511 | + if($rs->nroots != $nroots) { |
|
2512 | + continue; |
|
2513 | + } |
|
2514 | + if($rs->mm != $symsize) { |
|
2515 | + continue; |
|
2516 | + } |
|
2517 | + if($rs->gfpoly != $gfpoly) { |
|
2518 | + continue; |
|
2519 | + } |
|
2520 | + if($rs->fcr != $fcr) { |
|
2521 | + continue; |
|
2522 | + } |
|
2523 | + if($rs->prim != $prim) { |
|
2524 | + continue; |
|
2525 | + } |
|
2456 | 2526 | |
2457 | 2527 | return $rs; |
2458 | 2528 | } |
@@ -2591,8 +2661,9 @@ discard block |
||
2591 | 2661 | { |
2592 | 2662 | $codeArr = array(); |
2593 | 2663 | |
2594 | - foreach ($bitFrame as $line) |
|
2595 | - $codeArr[] = join('', $line); |
|
2664 | + foreach ($bitFrame as $line) { |
|
2665 | + $codeArr[] = join('', $line); |
|
2666 | + } |
|
2596 | 2667 | |
2597 | 2668 | return gzcompress(join("\n", $codeArr), 9); |
2598 | 2669 | } |
@@ -2603,8 +2674,9 @@ discard block |
||
2603 | 2674 | $codeArr = array(); |
2604 | 2675 | |
2605 | 2676 | $codeLines = explode("\n", gzuncompress($code)); |
2606 | - foreach ($codeLines as $line) |
|
2607 | - $codeArr[] = str_split($line); |
|
2677 | + foreach ($codeLines as $line) { |
|
2678 | + $codeArr[] = str_split($line); |
|
2679 | + } |
|
2608 | 2680 | |
2609 | 2681 | return $codeArr; |
2610 | 2682 | } |
@@ -2622,16 +2694,18 @@ discard block |
||
2622 | 2694 | $bitMask = self::unserial(file_get_contents($fileName)); |
2623 | 2695 | } else { |
2624 | 2696 | $bitMask = $this->generateMaskNo($maskNo, $width, $s); |
2625 | - if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) |
|
2626 | - mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
2697 | + if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) { |
|
2698 | + mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
2699 | + } |
|
2627 | 2700 | file_put_contents($fileName, self::serial($bitMask)); |
2628 | 2701 | } |
2629 | 2702 | } else { |
2630 | 2703 | $bitMask = $this->generateMaskNo($maskNo, $width, $s); |
2631 | 2704 | } |
2632 | 2705 | |
2633 | - if ($maskGenOnly) |
|
2634 | - return; |
|
2706 | + if ($maskGenOnly) { |
|
2707 | + return; |
|
2708 | + } |
|
2635 | 2709 | |
2636 | 2710 | $d = $s; |
2637 | 2711 | |
@@ -2698,8 +2772,9 @@ discard block |
||
2698 | 2772 | |
2699 | 2773 | $frameY = $frame[$y]; |
2700 | 2774 | |
2701 | - if ($y>0) |
|
2702 | - $frameYM = $frame[$y-1]; |
|
2775 | + if ($y>0) { |
|
2776 | + $frameYM = $frame[$y-1]; |
|
2777 | + } |
|
2703 | 2778 | |
2704 | 2779 | for($x=0; $x<$width; $x++) { |
2705 | 2780 | if(($x > 0) && ($y > 0)) { |
@@ -2912,14 +2987,17 @@ discard block |
||
2912 | 2987 | $blockNo++; |
2913 | 2988 | } |
2914 | 2989 | |
2915 | - if(QRspec::rsBlockNum2($spec) == 0) |
|
2916 | - return 0; |
|
2990 | + if(QRspec::rsBlockNum2($spec) == 0) { |
|
2991 | + return 0; |
|
2992 | + } |
|
2917 | 2993 | |
2918 | 2994 | $dl = QRspec::rsDataCodes2($spec); |
2919 | 2995 | $el = QRspec::rsEccCodes2($spec); |
2920 | 2996 | $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); |
2921 | 2997 | |
2922 | - if($rs == null) return -1; |
|
2998 | + if($rs == null) { |
|
2999 | + return -1; |
|
3000 | + } |
|
2923 | 3001 | |
2924 | 3002 | for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) { |
2925 | 3003 | $ecc = array_slice($this->ecccode,$eccPos); |
@@ -3057,7 +3135,9 @@ discard block |
||
3057 | 3135 | } |
3058 | 3136 | |
3059 | 3137 | $input = new QRinput($version, $level); |
3060 | - if($input == null) return null; |
|
3138 | + if($input == null) { |
|
3139 | + return null; |
|
3140 | + } |
|
3061 | 3141 | |
3062 | 3142 | $ret = $input->append(QR_MODE_8, strlen($string), str_split($string)); |
3063 | 3143 | if($ret < 0) { |
@@ -3077,7 +3157,9 @@ discard block |
||
3077 | 3157 | } |
3078 | 3158 | |
3079 | 3159 | $input = new QRinput($version, $level); |
3080 | - if($input == null) return null; |
|
3160 | + if($input == null) { |
|
3161 | + return null; |
|
3162 | + } |
|
3081 | 3163 | |
3082 | 3164 | $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); |
3083 | 3165 | if($ret < 0) { |
@@ -3187,7 +3269,9 @@ discard block |
||
3187 | 3269 | } |
3188 | 3270 | } |
3189 | 3271 | } |
3190 | - if($x < 0 || $y < 0) return null; |
|
3272 | + if($x < 0 || $y < 0) { |
|
3273 | + return null; |
|
3274 | + } |
|
3191 | 3275 | |
3192 | 3276 | $this->x = $x; |
3193 | 3277 | $this->y = $y; |
@@ -3294,8 +3378,9 @@ discard block |
||
3294 | 3378 | $err = ob_get_contents(); |
3295 | 3379 | ob_end_clean(); |
3296 | 3380 | |
3297 | - if ($err != '') |
|
3298 | - QRtools::log($outfile, $err); |
|
3381 | + if ($err != '') { |
|
3382 | + QRtools::log($outfile, $err); |
|
3383 | + } |
|
3299 | 3384 | |
3300 | 3385 | $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin)); |
3301 | 3386 |
@@ -5,8 +5,9 @@ discard block |
||
5 | 5 | $namespace = ''; |
6 | 6 | $class_name = $class; |
7 | 7 | |
8 | - if (strpos($class, '\\') !== false) |
|
9 | - list ($namespace, $class_name) = explode('\\', $class, 2); |
|
8 | + if (strpos($class, '\\') !== false) { |
|
9 | + list ($namespace, $class_name) = explode('\\', $class, 2); |
|
10 | + } |
|
10 | 11 | |
11 | 12 | $root_dir = dirname(__DIR__); // we're in tt-rss/include |
12 | 13 | |
@@ -20,7 +21,8 @@ discard block |
||
20 | 21 | $class_file = "$root_dir/classes/" . str_replace("_", "/", strtolower($class)) . ".php"; |
21 | 22 | } |
22 | 23 | |
23 | - if (file_exists($class_file)) |
|
24 | - include $class_file; |
|
24 | + if (file_exists($class_file)) { |
|
25 | + include $class_file; |
|
26 | + } |
|
25 | 27 | |
26 | 28 | }); |