@@ -17,7 +17,9 @@ discard block |
||
17 | 17 | $feed_id, $is_cat, $search, |
18 | 18 | $error, $feed_last_updated) { |
19 | 19 | |
20 | - if ($is_cat) $cat_q = "&is_cat=$is_cat"; |
|
20 | + if ($is_cat) { |
|
21 | + $cat_q = "&is_cat=$is_cat"; |
|
22 | + } |
|
21 | 23 | |
22 | 24 | if ($search) { |
23 | 25 | $search_q = "&q=$search"; |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | $reply .= strip_tags($feed_title); |
49 | 51 | } |
50 | 52 | |
51 | - if ($error) |
|
52 | - $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
53 | + if ($error) { |
|
54 | + $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
55 | + } |
|
53 | 56 | |
54 | 57 | $reply .= "</span>"; |
55 | 58 | $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
@@ -127,8 +130,12 @@ discard block |
||
127 | 130 | $rgba_cache = array(); |
128 | 131 | $topmost_article_ids = array(); |
129 | 132 | |
130 | - if (!$offset) $offset = 0; |
|
131 | - if ($method == "undefined") $method = ""; |
|
133 | + if (!$offset) { |
|
134 | + $offset = 0; |
|
135 | + } |
|
136 | + if ($method == "undefined") { |
|
137 | + $method = ""; |
|
138 | + } |
|
132 | 139 | |
133 | 140 | $method_split = explode(":", $method); |
134 | 141 | |
@@ -274,14 +281,17 @@ discard block |
||
274 | 281 | $label_cache = json_decode($label_cache, true); |
275 | 282 | |
276 | 283 | if ($label_cache) { |
277 | - if ($label_cache["no-labels"] == 1) |
|
278 | - $labels = array(); |
|
279 | - else |
|
280 | - $labels = $label_cache; |
|
284 | + if ($label_cache["no-labels"] == 1) { |
|
285 | + $labels = array(); |
|
286 | + } else { |
|
287 | + $labels = $label_cache; |
|
288 | + } |
|
281 | 289 | } |
282 | 290 | } |
283 | 291 | |
284 | - if (!is_array($labels)) $labels = Article::get_article_labels($id); |
|
292 | + if (!is_array($labels)) { |
|
293 | + $labels = Article::get_article_labels($id); |
|
294 | + } |
|
285 | 295 | |
286 | 296 | $labels_str = "<span class=\"HLLCTR-$id\">"; |
287 | 297 | $labels_str .= Article::format_article_labels($labels); |
@@ -293,7 +303,9 @@ discard block |
||
293 | 303 | array_push($topmost_article_ids, $id); |
294 | 304 | } |
295 | 305 | |
296 | - if (!$line["feed_title"]) $line["feed_title"] = ""; |
|
306 | + if (!$line["feed_title"]) { |
|
307 | + $line["feed_title"] = ""; |
|
308 | + } |
|
297 | 309 | |
298 | 310 | $line["buttons_left"] = ""; |
299 | 311 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
@@ -314,10 +326,11 @@ discard block |
||
314 | 326 | |
315 | 327 | $line['content'] = DiskCache::rewriteUrls($line['content']); |
316 | 328 | |
317 | - if ($line['note']) |
|
318 | - $line['note'] = Article::format_article_note($id, $line['note']); |
|
319 | - else |
|
320 | - $line['note'] = ""; |
|
329 | + if ($line['note']) { |
|
330 | + $line['note'] = Article::format_article_note($id, $line['note']); |
|
331 | + } else { |
|
332 | + $line['note'] = ""; |
|
333 | + } |
|
321 | 334 | |
322 | 335 | if (!get_pref("CDM_EXPANDED")) { |
323 | 336 | $line["cdm_excerpt"] = "<span class='collapse'> |
@@ -350,10 +363,11 @@ discard block |
||
350 | 363 | $line['imported'] = T_sprintf("Imported at %s", |
351 | 364 | make_local_datetime($line["date_entered"], false)); |
352 | 365 | |
353 | - if ($line["tag_cache"]) |
|
354 | - $tags = explode(",", $line["tag_cache"]); |
|
355 | - else |
|
356 | - $tags = false; |
|
366 | + if ($line["tag_cache"]) { |
|
367 | + $tags = explode(",", $line["tag_cache"]); |
|
368 | + } else { |
|
369 | + $tags = false; |
|
370 | + } |
|
357 | 371 | |
358 | 372 | $line["tags_str"] = Article::format_tags_string($tags, $id); |
359 | 373 | |
@@ -383,8 +397,9 @@ discard block |
||
383 | 397 | /* we don't need those */ |
384 | 398 | |
385 | 399 | foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
386 | - "uuid", "label_cache", "yyiw"] as $k) |
|
387 | - unset($line[$k]); |
|
400 | + "uuid", "label_cache", "yyiw"] as $k) { |
|
401 | + unset($line[$k]); |
|
402 | + } |
|
388 | 403 | |
389 | 404 | array_push($reply['content'], $line); |
390 | 405 | } |
@@ -474,7 +489,9 @@ discard block |
||
474 | 489 | $order_by = $_REQUEST["order_by"]; |
475 | 490 | $check_first_id = $_REQUEST["fid"]; |
476 | 491 | |
477 | - if (is_numeric($feed)) $feed = (int) $feed; |
|
492 | + if (is_numeric($feed)) { |
|
493 | + $feed = (int) $feed; |
|
494 | + } |
|
478 | 495 | |
479 | 496 | /* Feed -5 is a special case: it is used to display auxiliary information |
480 | 497 | * when there's nothing to load - e.g. no stuff in fresh feed */ |
@@ -562,10 +579,11 @@ discard block |
||
562 | 579 | $disable_cache = $ret[3]; |
563 | 580 | $reply['headlines'] = $ret[4]; |
564 | 581 | |
565 | - if (!$next_unread_feed) |
|
566 | - $reply['headlines']['id'] = $feed; |
|
567 | - else |
|
568 | - $reply['headlines']['id'] = $next_unread_feed; |
|
582 | + if (!$next_unread_feed) { |
|
583 | + $reply['headlines']['id'] = $feed; |
|
584 | + } else { |
|
585 | + $reply['headlines']['id'] = $next_unread_feed; |
|
586 | + } |
|
569 | 587 | |
570 | 588 | $reply['headlines']['is_cat'] = (bool) $cat_view; |
571 | 589 | |
@@ -851,7 +869,9 @@ discard block |
||
851 | 869 | |
852 | 870 | static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) { |
853 | 871 | |
854 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
872 | + if (!$owner_uid) { |
|
873 | + $owner_uid = $_SESSION['uid']; |
|
874 | + } |
|
855 | 875 | |
856 | 876 | $pdo = Db::pdo(); |
857 | 877 | |
@@ -1026,7 +1046,9 @@ discard block |
||
1026 | 1046 | |
1027 | 1047 | $pdo = Db::pdo(); |
1028 | 1048 | |
1029 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1049 | + if (!$owner_uid) { |
|
1050 | + $owner_uid = $_SESSION["uid"]; |
|
1051 | + } |
|
1030 | 1052 | |
1031 | 1053 | if ($unread_only) { |
1032 | 1054 | $unread_qpart = "unread = true"; |
@@ -1142,7 +1164,9 @@ discard block |
||
1142 | 1164 | |
1143 | 1165 | $url = Feeds::fix_url($url); |
1144 | 1166 | |
1145 | - if (!$url || !Feeds::validate_feed_url($url)) return array("code" => 2); |
|
1167 | + if (!$url || !Feeds::validate_feed_url($url)) { |
|
1168 | + return array("code" => 2); |
|
1169 | + } |
|
1146 | 1170 | |
1147 | 1171 | $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass); |
1148 | 1172 | |
@@ -1170,7 +1194,9 @@ discard block |
||
1170 | 1194 | $url = key($feedUrls); |
1171 | 1195 | } |
1172 | 1196 | |
1173 | - if (!$cat_id) $cat_id = null; |
|
1197 | + if (!$cat_id) { |
|
1198 | + $cat_id = null; |
|
1199 | + } |
|
1174 | 1200 | |
1175 | 1201 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
1176 | 1202 | WHERE feed_url = ? AND owner_uid = ?"); |
@@ -1294,13 +1320,17 @@ discard block |
||
1294 | 1320 | |
1295 | 1321 | static function getCategoryUnread($cat, $owner_uid = false) { |
1296 | 1322 | |
1297 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1323 | + if (!$owner_uid) { |
|
1324 | + $owner_uid = $_SESSION["uid"]; |
|
1325 | + } |
|
1298 | 1326 | |
1299 | 1327 | $pdo = Db::pdo(); |
1300 | 1328 | |
1301 | 1329 | if ($cat >= 0) { |
1302 | 1330 | |
1303 | - if (!$cat) $cat = null; |
|
1331 | + if (!$cat) { |
|
1332 | + $cat = null; |
|
1333 | + } |
|
1304 | 1334 | |
1305 | 1335 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
1306 | 1336 | WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) |
@@ -1313,7 +1343,9 @@ discard block |
||
1313 | 1343 | array_push($cat_feeds, "feed_id = " . (int)$line["id"]); |
1314 | 1344 | } |
1315 | 1345 | |
1316 | - if (count($cat_feeds) == 0) return 0; |
|
1346 | + if (count($cat_feeds) == 0) { |
|
1347 | + return 0; |
|
1348 | + } |
|
1317 | 1349 | |
1318 | 1350 | $match_part = implode(" OR ", $cat_feeds); |
1319 | 1351 | |
@@ -1348,7 +1380,9 @@ discard block |
||
1348 | 1380 | |
1349 | 1381 | // only accepts real cats (>= 0) |
1350 | 1382 | static function getCategoryChildrenUnread($cat, $owner_uid = false) { |
1351 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1383 | + if (!$owner_uid) { |
|
1384 | + $owner_uid = $_SESSION["uid"]; |
|
1385 | + } |
|
1352 | 1386 | |
1353 | 1387 | $pdo = Db::pdo(); |
1354 | 1388 | |
@@ -1368,7 +1402,9 @@ discard block |
||
1368 | 1402 | |
1369 | 1403 | static function getGlobalUnread($user_id = false) { |
1370 | 1404 | |
1371 | - if (!$user_id) $user_id = $_SESSION["uid"]; |
|
1405 | + if (!$user_id) { |
|
1406 | + $user_id = $_SESSION["uid"]; |
|
1407 | + } |
|
1372 | 1408 | |
1373 | 1409 | $pdo = Db::pdo(); |
1374 | 1410 | |
@@ -1403,7 +1439,9 @@ discard block |
||
1403 | 1439 | } |
1404 | 1440 | |
1405 | 1441 | static function getLabelUnread($label_id, $owner_uid = false) { |
1406 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
1442 | + if (!$owner_uid) { |
|
1443 | + $owner_uid = $_SESSION["uid"]; |
|
1444 | + } |
|
1407 | 1445 | |
1408 | 1446 | $pdo = Db::pdo(); |
1409 | 1447 | |
@@ -1498,8 +1536,9 @@ discard block |
||
1498 | 1536 | |
1499 | 1537 | $unread = getFeedUnread($feed, $cat_view); |
1500 | 1538 | |
1501 | - if ($cat_view && $feed > 0 && $include_children) |
|
1502 | - $unread += Feeds::getCategoryChildrenUnread($feed); |
|
1539 | + if ($cat_view && $feed > 0 && $include_children) { |
|
1540 | + $unread += Feeds::getCategoryChildrenUnread($feed); |
|
1541 | + } |
|
1503 | 1542 | |
1504 | 1543 | if ($unread > 0) { |
1505 | 1544 | $view_query_part = " unread = true AND "; |
@@ -1611,7 +1650,9 @@ discard block |
||
1611 | 1650 | $allow_archived = true; |
1612 | 1651 | $ignore_vfeed_group = true; |
1613 | 1652 | |
1614 | - if (!$override_order) $override_order = "last_read DESC"; |
|
1653 | + if (!$override_order) { |
|
1654 | + $override_order = "last_read DESC"; |
|
1655 | + } |
|
1615 | 1656 | |
1616 | 1657 | } else if ($feed == -3) { // fresh virtual feed |
1617 | 1658 | $query_strategy_part = "unread = true AND score >= 0"; |
@@ -1722,13 +1763,16 @@ discard block |
||
1722 | 1763 | LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; |
1723 | 1764 | } |
1724 | 1765 | |
1725 | - if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,"; |
|
1766 | + if ($vfeed_query_part) { |
|
1767 | + $vfeed_query_part .= "favicon_avg_color,"; |
|
1768 | + } |
|
1726 | 1769 | |
1727 | 1770 | $first_id = 0; |
1728 | 1771 | $first_id_query_strategy_part = $query_strategy_part; |
1729 | 1772 | |
1730 | - if ($feed == -3) |
|
1731 | - $first_id_query_strategy_part = "true"; |
|
1773 | + if ($feed == -3) { |
|
1774 | + $first_id_query_strategy_part = "true"; |
|
1775 | + } |
|
1732 | 1776 | |
1733 | 1777 | if (DB_TYPE == "pgsql") { |
1734 | 1778 | $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND"; |
@@ -1860,7 +1904,9 @@ discard block |
||
1860 | 1904 | $query_strategy_part ORDER BY $order_by |
1861 | 1905 | $limit_query_part $offset_query_part"; |
1862 | 1906 | |
1863 | - if ($_REQUEST["debug"]) print $query; |
|
1907 | + if ($_REQUEST["debug"]) { |
|
1908 | + print $query; |
|
1909 | + } |
|
1864 | 1910 | |
1865 | 1911 | $res = $pdo->query($query); |
1866 | 1912 | } |
@@ -2010,18 +2056,23 @@ discard block |
||
2010 | 2056 | } |
2011 | 2057 | } |
2012 | 2058 | |
2013 | - if ($url != "http:///") |
|
2014 | - return $url; |
|
2015 | - else |
|
2016 | - return ''; |
|
2059 | + if ($url != "http:///") { |
|
2060 | + return $url; |
|
2061 | + } else { |
|
2062 | + return ''; |
|
2063 | + } |
|
2017 | 2064 | } |
2018 | 2065 | |
2019 | 2066 | static function add_feed_category($feed_cat, $parent_cat_id = false, $order_id = 0) { |
2020 | 2067 | |
2021 | - if (!$feed_cat) return false; |
|
2068 | + if (!$feed_cat) { |
|
2069 | + return false; |
|
2070 | + } |
|
2022 | 2071 | |
2023 | 2072 | $feed_cat = mb_substr($feed_cat, 0, 250); |
2024 | - if (!$parent_cat_id) $parent_cat_id = null; |
|
2073 | + if (!$parent_cat_id) { |
|
2074 | + $parent_cat_id = null; |
|
2075 | + } |
|
2025 | 2076 | |
2026 | 2077 | $pdo = Db::pdo(); |
2027 | 2078 | $tr_in_progress = false; |
@@ -2043,7 +2094,9 @@ discard block |
||
2043 | 2094 | VALUES (?, ?, ?, ?)"); |
2044 | 2095 | $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int)$order_id]); |
2045 | 2096 | |
2046 | - if (!$tr_in_progress) $pdo->commit(); |
|
2097 | + if (!$tr_in_progress) { |
|
2098 | + $pdo->commit(); |
|
2099 | + } |
|
2047 | 2100 | |
2048 | 2101 | return true; |
2049 | 2102 | } |
@@ -2055,7 +2108,9 @@ discard block |
||
2055 | 2108 | |
2056 | 2109 | static function get_feed_access_key($feed_id, $is_cat, $owner_uid = false) { |
2057 | 2110 | |
2058 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
2111 | + if (!$owner_uid) { |
|
2112 | + $owner_uid = $_SESSION["uid"]; |
|
2113 | + } |
|
2059 | 2114 | |
2060 | 2115 | $is_cat = bool_to_sql_bool($is_cat); |
2061 | 2116 | |
@@ -2093,7 +2148,9 @@ discard block |
||
2093 | 2148 | */ |
2094 | 2149 | static function purge_feed($feed_id, $purge_interval) { |
2095 | 2150 | |
2096 | - if (!$purge_interval) $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
2151 | + if (!$purge_interval) { |
|
2152 | + $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
2153 | + } |
|
2097 | 2154 | |
2098 | 2155 | $pdo = Db::pdo(); |
2099 | 2156 | |
@@ -2113,7 +2170,9 @@ discard block |
||
2113 | 2170 | return; |
2114 | 2171 | } |
2115 | 2172 | |
2116 | - if (!$owner_uid) return; |
|
2173 | + if (!$owner_uid) { |
|
2174 | + return; |
|
2175 | + } |
|
2117 | 2176 | |
2118 | 2177 | if (FORCE_ARTICLE_PURGE == 0) { |
2119 | 2178 | $purge_unread = get_pref("PURGE_UNREAD_ARTICLES", |
@@ -2123,10 +2182,11 @@ discard block |
||
2123 | 2182 | $purge_interval = FORCE_ARTICLE_PURGE; |
2124 | 2183 | } |
2125 | 2184 | |
2126 | - if (!$purge_unread) |
|
2127 | - $query_limit = " unread = false AND "; |
|
2128 | - else |
|
2129 | - $query_limit = ""; |
|
2185 | + if (!$purge_unread) { |
|
2186 | + $query_limit = " unread = false AND "; |
|
2187 | + } else { |
|
2188 | + $query_limit = ""; |
|
2189 | + } |
|
2130 | 2190 | |
2131 | 2191 | $purge_interval = (int) $purge_interval; |
2132 | 2192 | |
@@ -2173,8 +2233,10 @@ discard block |
||
2173 | 2233 | $purge_interval = $row["purge_interval"]; |
2174 | 2234 | $owner_uid = $row["owner_uid"]; |
2175 | 2235 | |
2176 | - if ($purge_interval == 0) $purge_interval = get_pref( |
|
2236 | + if ($purge_interval == 0) { |
|
2237 | + $purge_interval = get_pref( |
|
2177 | 2238 | 'PURGE_OLD_DAYS', $owner_uid); |
2239 | + } |
|
2178 | 2240 | |
2179 | 2241 | return $purge_interval; |
2180 | 2242 | |
@@ -2192,10 +2254,11 @@ discard block |
||
2192 | 2254 | |
2193 | 2255 | $pdo = Db::pdo(); |
2194 | 2256 | |
2195 | - if ($search_language) |
|
2196 | - $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
2197 | - else |
|
2198 | - $search_language = $pdo->quote("english"); |
|
2257 | + if ($search_language) { |
|
2258 | + $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
2259 | + } else { |
|
2260 | + $search_language = $pdo->quote("english"); |
|
2261 | + } |
|
2199 | 2262 | |
2200 | 2263 | foreach ($keywords as $k) { |
2201 | 2264 | if (strpos($k, "-") === 0) { |
@@ -2230,56 +2293,68 @@ discard block |
||
2230 | 2293 | break; |
2231 | 2294 | case "note": |
2232 | 2295 | if ($commandpair[1]) { |
2233 | - if ($commandpair[1] == "true") |
|
2234 | - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2235 | - else if ($commandpair[1] == "false") |
|
2236 | - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2237 | - else |
|
2238 | - array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2296 | + if ($commandpair[1] == "true") { |
|
2297 | + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
2298 | + } else if ($commandpair[1] == "false") { |
|
2299 | + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
2300 | + } else { |
|
2301 | + array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
2239 | 2302 | $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
2303 | + } |
|
2240 | 2304 | } else { |
2241 | 2305 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
2242 | 2306 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2243 | - if (!$not) array_push($search_words, $k); |
|
2307 | + if (!$not) { |
|
2308 | + array_push($search_words, $k); |
|
2309 | + } |
|
2244 | 2310 | } |
2245 | 2311 | break; |
2246 | 2312 | case "star": |
2247 | 2313 | |
2248 | 2314 | if ($commandpair[1]) { |
2249 | - if ($commandpair[1] == "true") |
|
2250 | - array_push($query_keywords, "($not (marked = true))"); |
|
2251 | - else |
|
2252 | - array_push($query_keywords, "($not (marked = false))"); |
|
2315 | + if ($commandpair[1] == "true") { |
|
2316 | + array_push($query_keywords, "($not (marked = true))"); |
|
2317 | + } else { |
|
2318 | + array_push($query_keywords, "($not (marked = false))"); |
|
2319 | + } |
|
2253 | 2320 | } else { |
2254 | 2321 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
2255 | 2322 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2256 | - if (!$not) array_push($search_words, $k); |
|
2323 | + if (!$not) { |
|
2324 | + array_push($search_words, $k); |
|
2325 | + } |
|
2257 | 2326 | } |
2258 | 2327 | break; |
2259 | 2328 | case "pub": |
2260 | 2329 | if ($commandpair[1]) { |
2261 | - if ($commandpair[1] == "true") |
|
2262 | - array_push($query_keywords, "($not (published = true))"); |
|
2263 | - else |
|
2264 | - array_push($query_keywords, "($not (published = false))"); |
|
2330 | + if ($commandpair[1] == "true") { |
|
2331 | + array_push($query_keywords, "($not (published = true))"); |
|
2332 | + } else { |
|
2333 | + array_push($query_keywords, "($not (published = false))"); |
|
2334 | + } |
|
2265 | 2335 | |
2266 | 2336 | } else { |
2267 | 2337 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
2268 | 2338 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2269 | - if (!$not) array_push($search_words, $k); |
|
2339 | + if (!$not) { |
|
2340 | + array_push($search_words, $k); |
|
2341 | + } |
|
2270 | 2342 | } |
2271 | 2343 | break; |
2272 | 2344 | case "unread": |
2273 | 2345 | if ($commandpair[1]) { |
2274 | - if ($commandpair[1] == "true") |
|
2275 | - array_push($query_keywords, "($not (unread = true))"); |
|
2276 | - else |
|
2277 | - array_push($query_keywords, "($not (unread = false))"); |
|
2346 | + if ($commandpair[1] == "true") { |
|
2347 | + array_push($query_keywords, "($not (unread = true))"); |
|
2348 | + } else { |
|
2349 | + array_push($query_keywords, "($not (unread = false))"); |
|
2350 | + } |
|
2278 | 2351 | |
2279 | 2352 | } else { |
2280 | 2353 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
2281 | 2354 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2282 | - if (!$not) array_push($search_words, $k); |
|
2355 | + if (!$not) { |
|
2356 | + array_push($search_words, $k); |
|
2357 | + } |
|
2283 | 2358 | } |
2284 | 2359 | break; |
2285 | 2360 | default: |
@@ -2302,7 +2377,9 @@ discard block |
||
2302 | 2377 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
2303 | 2378 | } |
2304 | 2379 | |
2305 | - if (!$not) array_push($search_words, $k); |
|
2380 | + if (!$not) { |
|
2381 | + array_push($search_words, $k); |
|
2382 | + } |
|
2306 | 2383 | } |
2307 | 2384 | } |
2308 | 2385 | } |
@@ -43,10 +43,11 @@ |
||
43 | 43 | foreach ($lines as $line) { |
44 | 44 | if (strpos($line, "--") !== 0 && $line) { |
45 | 45 | |
46 | - if ($html_output) |
|
47 | - print "<pre>$line</pre>"; |
|
48 | - else |
|
49 | - Debug::log("> $line"); |
|
46 | + if ($html_output) { |
|
47 | + print "<pre>$line</pre>"; |
|
48 | + } else { |
|
49 | + Debug::log("> $line"); |
|
50 | + } |
|
50 | 51 | |
51 | 52 | try { |
52 | 53 | $this->pdo->query($line); // PDO returns errors as exceptions now |
@@ -28,7 +28,9 @@ |
||
28 | 28 | if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
29 | 29 | $user_id = $this->find_user_by_login($login); |
30 | 30 | |
31 | - if (!$password) $password = make_password(); |
|
31 | + if (!$password) { |
|
32 | + $password = make_password(); |
|
33 | + } |
|
32 | 34 | |
33 | 35 | if (!$user_id) { |
34 | 36 | $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
@@ -17,7 +17,9 @@ |
||
17 | 17 | |
18 | 18 | $timestamp = filemtime($filename); |
19 | 19 | |
20 | - if ($query) $timestamp .= "&$query"; |
|
20 | + if ($query) { |
|
21 | + $timestamp .= "&$query"; |
|
22 | + } |
|
21 | 23 | |
22 | 24 | return "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n"; |
23 | 25 | } |
@@ -10,7 +10,9 @@ |
||
10 | 10 | require_once "db.php"; |
11 | 11 | require_once "db-prefs.php"; |
12 | 12 | |
13 | - if (!init_plugins()) return; |
|
13 | + if (!init_plugins()) { |
|
14 | + return; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | $op = $_REQUEST['op']; |
16 | 18 |
@@ -175,7 +175,9 @@ discard block |
||
175 | 175 | if (!$this->readFileIntoString($fileName,$s)) { |
176 | 176 | $this->triggerError ("Error while reading template file " . $fileName . "."); |
177 | 177 | return false; } |
178 | - if (!$this->setTemplateString($s)) return false; |
|
178 | + if (!$this->setTemplateString($s)) { |
|
179 | + return false; |
|
180 | + } |
|
179 | 181 | return true; } |
180 | 182 | |
181 | 183 | /** |
@@ -187,7 +189,9 @@ discard block |
||
187 | 189 | function setTemplateString ($templateString) { |
188 | 190 | $this->templateValid = false; |
189 | 191 | $this->template = $templateString; |
190 | - if (!$this->parseTemplate()) return false; |
|
192 | + if (!$this->parseTemplate()) { |
|
193 | + return false; |
|
194 | + } |
|
191 | 195 | $this->reset(); |
192 | 196 | $this->templateValid = true; |
193 | 197 | return true; } |
@@ -214,10 +218,16 @@ discard block |
||
214 | 218 | function parseTemplate() { |
215 | 219 | $this->initParsing(); |
216 | 220 | $this->beginMainBlock(); |
217 | - if (!$this->parseTemplateCommands()) return false; |
|
221 | + if (!$this->parseTemplateCommands()) { |
|
222 | + return false; |
|
223 | + } |
|
218 | 224 | $this->endMainBlock(); |
219 | - if (!$this->checkBlockDefinitionsComplete()) return false; |
|
220 | - if (!$this->parseTemplateVariables()) return false; |
|
225 | + if (!$this->checkBlockDefinitionsComplete()) { |
|
226 | + return false; |
|
227 | + } |
|
228 | + if (!$this->parseTemplateVariables()) { |
|
229 | + return false; |
|
230 | + } |
|
221 | 231 | $this->associateVariablesWithBlocks(); |
222 | 232 | return true; } |
223 | 233 | |
@@ -272,16 +282,22 @@ discard block |
||
272 | 282 | $p = 0; |
273 | 283 | while (true) { |
274 | 284 | $p0 = strpos($this->template,'<!--',$p); |
275 | - if ($p0 === false) break; |
|
285 | + if ($p0 === false) { |
|
286 | + break; |
|
287 | + } |
|
276 | 288 | $p = strpos($this->template,'-->',$p0); |
277 | 289 | if ($p === false) { |
278 | 290 | $this->triggerError ("Invalid HTML comment in template at offset $p0."); |
279 | 291 | return false; } |
280 | 292 | $p += 3; |
281 | 293 | $cmdL = substr($this->template,$p0+4,$p-$p0-7); |
282 | - if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart)) |
|
283 | - return false; |
|
284 | - if ($resumeFromStart) $p = $p0; } |
|
294 | + if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart)) { |
|
295 | + return false; |
|
296 | + } |
|
297 | + if ($resumeFromStart) { |
|
298 | + $p = $p0; |
|
299 | + } |
|
300 | + } |
|
285 | 301 | return true; } |
286 | 302 | |
287 | 303 | /** |
@@ -292,20 +308,25 @@ discard block |
||
292 | 308 | $resumeFromStart = false; |
293 | 309 | $p = 0; |
294 | 310 | $cmd = ''; |
295 | - if (!$this->parseWord($cmdL,$p,$cmd)) return true; |
|
311 | + if (!$this->parseWord($cmdL,$p,$cmd)) { |
|
312 | + return true; |
|
313 | + } |
|
296 | 314 | $parms = substr($cmdL,$p); |
297 | 315 | switch (strtoupper($cmd)) { |
298 | 316 | case '$BEGINBLOCK': |
299 | - if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
300 | - return false; |
|
317 | + if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) { |
|
318 | + return false; |
|
319 | + } |
|
301 | 320 | break; |
302 | 321 | case '$ENDBLOCK': |
303 | - if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
304 | - return false; |
|
322 | + if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) { |
|
323 | + return false; |
|
324 | + } |
|
305 | 325 | break; |
306 | 326 | case '$INCLUDE': |
307 | - if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) |
|
308 | - return false; |
|
327 | + if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) { |
|
328 | + return false; |
|
329 | + } |
|
309 | 330 | $resumeFromStart = true; |
310 | 331 | break; |
311 | 332 | default: |
@@ -377,8 +398,9 @@ discard block |
||
377 | 398 | $btr =& $this->blockTab[$blockNo]; |
378 | 399 | $btr = array(); |
379 | 400 | $btr['blockName'] = $blockName; |
380 | - if (!$this->lookupBlockName($blockName,$btr['nextWithSameName'])) |
|
381 | - $btr['nextWithSameName'] = -1; |
|
401 | + if (!$this->lookupBlockName($blockName,$btr['nextWithSameName'])) { |
|
402 | + $btr['nextWithSameName'] = -1; |
|
403 | + } |
|
382 | 404 | $btr['definitionIsOpen'] = true; |
383 | 405 | $btr['instances'] = 0; |
384 | 406 | $btr['firstBlockInstNo'] = -1; |
@@ -428,7 +450,9 @@ discard block |
||
428 | 450 | if (strlen($this->template) > $this->maxInclTemplateSize) { |
429 | 451 | $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters."); |
430 | 452 | return false; } |
431 | - if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false; |
|
453 | + if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) { |
|
454 | + return false; |
|
455 | + } |
|
432 | 456 | // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator, |
433 | 457 | // a table could be used that contains references to the string fragments.) |
434 | 458 | $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2); |
@@ -443,7 +467,9 @@ discard block |
||
443 | 467 | $p = 0; |
444 | 468 | while (true) { |
445 | 469 | $p = strpos($this->template, '${', $p); |
446 | - if ($p === false) break; |
|
470 | + if ($p === false) { |
|
471 | + break; |
|
472 | + } |
|
447 | 473 | $p0 = $p; |
448 | 474 | $p = strpos($this->template, '}', $p); |
449 | 475 | if ($p === false) { |
@@ -461,8 +487,9 @@ discard block |
||
461 | 487 | * @access private |
462 | 488 | */ |
463 | 489 | function registerVariableReference ($varName, $tPosBegin, $tPosEnd) { |
464 | - if (!$this->lookupVariableName($varName,$varNo)) |
|
465 | - $this->registerVariable($varName,$varNo); |
|
490 | + if (!$this->lookupVariableName($varName,$varNo)) { |
|
491 | + $this->registerVariable($varName,$varNo); |
|
492 | + } |
|
466 | 493 | $varRefNo = $this->varRefTabCnt++; |
467 | 494 | $vrtr =& $this->varRefTab[$varRefNo]; |
468 | 495 | $vrtr = array(); |
@@ -502,12 +529,14 @@ discard block |
||
502 | 529 | $nextBlockNo += 1; |
503 | 530 | continue; }} |
504 | 531 | $btr =& $this->blockTab[$activeBlockNo]; |
505 | - if ($varRefTPos < $btr['tPosBegin']) |
|
506 | - $this->programLogicError(1); |
|
532 | + if ($varRefTPos < $btr['tPosBegin']) { |
|
533 | + $this->programLogicError(1); |
|
534 | + } |
|
507 | 535 | $blockVarNo = $btr['blockVarCnt']++; |
508 | 536 | $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo; |
509 | - if ($btr['firstVarRefNo'] == -1) |
|
510 | - $btr['firstVarRefNo'] = $varRefNo; |
|
537 | + if ($btr['firstVarRefNo'] == -1) { |
|
538 | + $btr['firstVarRefNo'] = $varRefNo; |
|
539 | + } |
|
511 | 540 | $vrtr['blockNo'] = $activeBlockNo; |
512 | 541 | $vrtr['blockVarNo'] = $blockVarNo; |
513 | 542 | $varRefNo += 1; }} |
@@ -523,8 +552,9 @@ discard block |
||
523 | 552 | * @access public |
524 | 553 | */ |
525 | 554 | function reset() { |
526 | - for ($varNo=0; $varNo<$this->varTabCnt; $varNo++) |
|
527 | - $this->varTab[$varNo]['varValue'] = ''; |
|
555 | + for ($varNo=0; $varNo<$this->varTabCnt; $varNo++) { |
|
556 | + $this->varTab[$varNo]['varValue'] = ''; |
|
557 | + } |
|
528 | 558 | for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) { |
529 | 559 | $btr =& $this->blockTab[$blockNo]; |
530 | 560 | $btr['instances'] = 0; |
@@ -551,7 +581,9 @@ discard block |
||
551 | 581 | function setVariable ($variableName, $variableValue, $isOptional=false) { |
552 | 582 | if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; } |
553 | 583 | if (!$this->lookupVariableName($variableName,$varNo)) { |
554 | - if ($isOptional) return true; |
|
584 | + if ($isOptional) { |
|
585 | + return true; |
|
586 | + } |
|
555 | 587 | $this->triggerError ("Variable \"$variableName\" not defined in template."); |
556 | 588 | return false; } |
557 | 589 | $this->varTab[$varNo]['varValue'] = $variableValue; |
@@ -619,20 +651,23 @@ discard block |
||
619 | 651 | $btr =& $this->blockTab[$blockNo]; |
620 | 652 | $this->registerBlockInstance ($blockInstNo); |
621 | 653 | $bitr =& $this->blockInstTab[$blockInstNo]; |
622 | - if ($btr['firstBlockInstNo'] == -1) |
|
623 | - $btr['firstBlockInstNo'] = $blockInstNo; |
|
624 | - if ($btr['lastBlockInstNo'] != -1) |
|
625 | - $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo; |
|
654 | + if ($btr['firstBlockInstNo'] == -1) { |
|
655 | + $btr['firstBlockInstNo'] = $blockInstNo; |
|
656 | + } |
|
657 | + if ($btr['lastBlockInstNo'] != -1) { |
|
658 | + $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo; |
|
659 | + } |
|
626 | 660 | // set forward pointer of chain |
627 | 661 | $btr['lastBlockInstNo'] = $blockInstNo; |
628 | 662 | $parentBlockNo = $btr['parentBlockNo']; |
629 | 663 | $blockVarCnt = $btr['blockVarCnt']; |
630 | 664 | $bitr['blockNo'] = $blockNo; |
631 | 665 | $bitr['instanceLevel'] = $btr['instances']++; |
632 | - if ($parentBlockNo == -1) |
|
633 | - $bitr['parentInstLevel'] = -1; |
|
634 | - else |
|
635 | - $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances']; |
|
666 | + if ($parentBlockNo == -1) { |
|
667 | + $bitr['parentInstLevel'] = -1; |
|
668 | + } else { |
|
669 | + $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances']; |
|
670 | + } |
|
636 | 671 | $bitr['nextBlockInstNo'] = -1; |
637 | 672 | $bitr['blockVarTab'] = array(); |
638 | 673 | // copy instance variables for this block |
@@ -666,7 +701,9 @@ discard block |
||
666 | 701 | */ |
667 | 702 | function generateOutput () { |
668 | 703 | $this->outputMode = 0; |
669 | - if (!$this->generateOutputPage()) return false; |
|
704 | + if (!$this->generateOutputPage()) { |
|
705 | + return false; |
|
706 | + } |
|
670 | 707 | return true; } |
671 | 708 | |
672 | 709 | /** |
@@ -677,7 +714,9 @@ discard block |
||
677 | 714 | */ |
678 | 715 | function generateOutputToFile ($fileName) { |
679 | 716 | $fh = fopen($fileName,"wb"); |
680 | - if ($fh === false) return false; |
|
717 | + if ($fh === false) { |
|
718 | + return false; |
|
719 | + } |
|
681 | 720 | $this->outputMode = 1; |
682 | 721 | $this->outputFileHandle = $fh; |
683 | 722 | $ok = $this->generateOutputPage(); |
@@ -695,7 +734,9 @@ discard block |
||
695 | 734 | $outputString = "Error"; |
696 | 735 | $this->outputMode = 2; |
697 | 736 | $this->outputString = ""; |
698 | - if (!$this->generateOutputPage()) return false; |
|
737 | + if (!$this->generateOutputPage()) { |
|
738 | + return false; |
|
739 | + } |
|
699 | 740 | $outputString = $this->outputString; |
700 | 741 | return true; } |
701 | 742 | |
@@ -705,14 +746,18 @@ discard block |
||
705 | 746 | */ |
706 | 747 | function generateOutputPage() { |
707 | 748 | if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; } |
708 | - if ($this->blockTab[0]['instances'] == 0) |
|
709 | - $this->addBlockByNo (0); // add main block |
|
749 | + if ($this->blockTab[0]['instances'] == 0) { |
|
750 | + $this->addBlockByNo (0); |
|
751 | + } |
|
752 | + // add main block |
|
710 | 753 | for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) { |
711 | 754 | $btr =& $this->blockTab[$blockNo]; |
712 | 755 | $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; } |
713 | 756 | $this->outputError = false; |
714 | 757 | $this->writeBlockInstances (0, -1); |
715 | - if ($this->outputError) return false; |
|
758 | + if ($this->outputError) { |
|
759 | + return false; |
|
760 | + } |
|
716 | 761 | return true; } |
717 | 762 | |
718 | 763 | /** |
@@ -725,11 +770,16 @@ discard block |
||
725 | 770 | $btr =& $this->blockTab[$blockNo]; |
726 | 771 | while (!$this->outputError) { |
727 | 772 | $blockInstNo = $btr['currBlockInstNo']; |
728 | - if ($blockInstNo == -1) break; |
|
773 | + if ($blockInstNo == -1) { |
|
774 | + break; |
|
775 | + } |
|
729 | 776 | $bitr =& $this->blockInstTab[$blockInstNo]; |
730 | - if ($bitr['parentInstLevel'] < $parentInstLevel) |
|
731 | - $this->programLogicError (2); |
|
732 | - if ($bitr['parentInstLevel'] > $parentInstLevel) break; |
|
777 | + if ($bitr['parentInstLevel'] < $parentInstLevel) { |
|
778 | + $this->programLogicError (2); |
|
779 | + } |
|
780 | + if ($bitr['parentInstLevel'] > $parentInstLevel) { |
|
781 | + break; |
|
782 | + } |
|
733 | 783 | $this->writeBlockInstance ($blockInstNo); |
734 | 784 | $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }} |
735 | 785 | |
@@ -762,15 +812,17 @@ discard block |
||
762 | 812 | if ($subBtr['tPosBegin'] < $tPos2) { |
763 | 813 | $tPos2 = $subBtr['tPosBegin']; |
764 | 814 | $kind = 2; }} |
765 | - if ($tPos2 > $tPos) |
|
766 | - $this->writeString (substr($this->template,$tPos,$tPos2-$tPos)); |
|
815 | + if ($tPos2 > $tPos) { |
|
816 | + $this->writeString (substr($this->template,$tPos,$tPos2-$tPos)); |
|
817 | + } |
|
767 | 818 | switch ($kind) { |
768 | 819 | case 0: // end of block |
769 | 820 | return; |
770 | 821 | case 1: // variable |
771 | 822 | $vrtr =& $this->varRefTab[$varRefNo]; |
772 | - if ($vrtr['blockNo'] != $blockNo) |
|
773 | - $this->programLogicError (4); |
|
823 | + if ($vrtr['blockNo'] != $blockNo) { |
|
824 | + $this->programLogicError (4); |
|
825 | + } |
|
774 | 826 | $variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']]; |
775 | 827 | $this->writeString ($variableValue); |
776 | 828 | $tPos = $vrtr['tPosEnd']; |
@@ -778,8 +830,9 @@ discard block |
||
778 | 830 | break; |
779 | 831 | case 2: // sub block |
780 | 832 | $subBtr =& $this->blockTab[$subBlockNo]; |
781 | - if ($subBtr['parentBlockNo'] != $blockNo) |
|
782 | - $this->programLogicError (3); |
|
833 | + if ($subBtr['parentBlockNo'] != $blockNo) { |
|
834 | + $this->programLogicError (3); |
|
835 | + } |
|
783 | 836 | $this->writeBlockInstances ($subBlockNo, $bitr['instanceLevel']); // recursive call |
784 | 837 | $tPos = $subBtr['tPosEnd']; |
785 | 838 | $subBlockNo += 1; |
@@ -789,15 +842,20 @@ discard block |
||
789 | 842 | * @access private |
790 | 843 | */ |
791 | 844 | function writeString ($s) { |
792 | - if ($this->outputError) return; |
|
845 | + if ($this->outputError) { |
|
846 | + return; |
|
847 | + } |
|
793 | 848 | switch ($this->outputMode) { |
794 | 849 | case 0: // output to PHP output stream |
795 | - if (!print($s)) |
|
796 | - $this->outputError = true; |
|
850 | + if (!print($s)) { |
|
851 | + $this->outputError = true; |
|
852 | + } |
|
797 | 853 | break; |
798 | 854 | case 1: // output to file |
799 | 855 | $rc = fwrite($this->outputFileHandle, $s); |
800 | - if ($rc === false) $this->outputError = true; |
|
856 | + if ($rc === false) { |
|
857 | + $this->outputError = true; |
|
858 | + } |
|
801 | 859 | break; |
802 | 860 | case 2: // output to string |
803 | 861 | $this->outputString .= $s; |
@@ -812,7 +870,9 @@ discard block |
||
812 | 870 | */ |
813 | 871 | function lookupVariableName ($varName, &$varNo) { |
814 | 872 | $x =& $this->varNameToNoMap[strtoupper($varName)]; |
815 | - if (!isset($x)) return false; |
|
873 | + if (!isset($x)) { |
|
874 | + return false; |
|
875 | + } |
|
816 | 876 | $varNo = $x; |
817 | 877 | return true; } |
818 | 878 | |
@@ -825,7 +885,9 @@ discard block |
||
825 | 885 | */ |
826 | 886 | function lookupBlockName ($blockName, &$blockNo) { |
827 | 887 | $x =& $this->blockNameToNoMap[strtoupper($blockName)]; |
828 | - if (!isset($x)) return false; |
|
888 | + if (!isset($x)) { |
|
889 | + return false; |
|
890 | + } |
|
829 | 891 | $blockNo = $x; |
830 | 892 | return true; } |
831 | 893 | |
@@ -839,15 +901,21 @@ discard block |
||
839 | 901 | function readFileIntoString ($fileName, &$s) { |
840 | 902 | if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) { |
841 | 903 | $s = file_get_contents($fileName); |
842 | - if ($s === false) return false; |
|
904 | + if ($s === false) { |
|
905 | + return false; |
|
906 | + } |
|
843 | 907 | return true; } |
844 | 908 | $fh = fopen($fileName,"rb"); |
845 | - if ($fh === false) return false; |
|
909 | + if ($fh === false) { |
|
910 | + return false; |
|
911 | + } |
|
846 | 912 | $fileSize = filesize($fileName); |
847 | 913 | if ($fileSize === false) {fclose ($fh); return false; } |
848 | 914 | $s = fread($fh,$fileSize); |
849 | 915 | fclose ($fh); |
850 | - if (strlen($s) != $fileSize) return false; |
|
916 | + if (strlen($s) != $fileSize) { |
|
917 | + return false; |
|
918 | + } |
|
851 | 919 | return true; } |
852 | 920 | |
853 | 921 | /** |
@@ -856,10 +924,16 @@ discard block |
||
856 | 924 | */ |
857 | 925 | function parseWord ($s, &$p, &$w) { |
858 | 926 | $sLen = strlen($s); |
859 | - while ($p < $sLen && ord($s{$p}) <= 32) $p++; |
|
860 | - if ($p >= $sLen) return false; |
|
927 | + while ($p < $sLen && ord($s{$p}) <= 32) { |
|
928 | + $p++; |
|
929 | + } |
|
930 | + if ($p >= $sLen) { |
|
931 | + return false; |
|
932 | + } |
|
861 | 933 | $p0 = $p; |
862 | - while ($p < $sLen && ord($s{$p}) > 32) $p++; |
|
934 | + while ($p < $sLen && ord($s{$p}) > 32) { |
|
935 | + $p++; |
|
936 | + } |
|
863 | 937 | $w = substr($s, $p0, $p - $p0); |
864 | 938 | return true; } |
865 | 939 | |
@@ -869,12 +943,22 @@ discard block |
||
869 | 943 | */ |
870 | 944 | function parseQuotedString ($s, &$p, &$w) { |
871 | 945 | $sLen = strlen($s); |
872 | - while ($p < $sLen && ord($s{$p}) <= 32) $p++; |
|
873 | - if ($p >= $sLen) return false; |
|
874 | - if (substr($s,$p,1) != '"') return false; |
|
946 | + while ($p < $sLen && ord($s{$p}) <= 32) { |
|
947 | + $p++; |
|
948 | + } |
|
949 | + if ($p >= $sLen) { |
|
950 | + return false; |
|
951 | + } |
|
952 | + if (substr($s,$p,1) != '"') { |
|
953 | + return false; |
|
954 | + } |
|
875 | 955 | $p++; $p0 = $p; |
876 | - while ($p < $sLen && $s{$p} != '"') $p++; |
|
877 | - if ($p >= $sLen) return false; |
|
956 | + while ($p < $sLen && $s{$p} != '"') { |
|
957 | + $p++; |
|
958 | + } |
|
959 | + if ($p >= $sLen) { |
|
960 | + return false; |
|
961 | + } |
|
878 | 962 | $w = substr($s, $p0, $p - $p0); |
879 | 963 | $p++; |
880 | 964 | return true; } |
@@ -885,25 +969,36 @@ discard block |
||
885 | 969 | */ |
886 | 970 | function parseWordOrQuotedString ($s, &$p, &$w) { |
887 | 971 | $sLen = strlen($s); |
888 | - while ($p < $sLen && ord($s{$p}) <= 32) $p++; |
|
889 | - if ($p >= $sLen) return false; |
|
890 | - if (substr($s,$p,1) == '"') |
|
891 | - return $this->parseQuotedString($s,$p,$w); |
|
892 | - else |
|
893 | - return $this->parseWord($s,$p,$w); } |
|
972 | + while ($p < $sLen && ord($s{$p}) <= 32) { |
|
973 | + $p++; |
|
974 | + } |
|
975 | + if ($p >= $sLen) { |
|
976 | + return false; |
|
977 | + } |
|
978 | + if (substr($s,$p,1) == '"') { |
|
979 | + return $this->parseQuotedString($s,$p,$w); |
|
980 | + } else { |
|
981 | + return $this->parseWord($s,$p,$w); |
|
982 | + } |
|
983 | + } |
|
894 | 984 | |
895 | 985 | /** |
896 | 986 | * Combine two file system paths. |
897 | 987 | * @access private |
898 | 988 | */ |
899 | 989 | function combineFileSystemPath ($path1, $path2) { |
900 | - if ($path1 == '' || $path2 == '') return $path2; |
|
990 | + if ($path1 == '' || $path2 == '') { |
|
991 | + return $path2; |
|
992 | + } |
|
901 | 993 | $s = $path1; |
902 | - if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/"; |
|
903 | - if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/') |
|
904 | - $s = $s . substr($path2,1); |
|
905 | - else |
|
906 | - $s = $s . $path2; |
|
994 | + if (substr($s,-1) != '\\' && substr($s,-1) != '/') { |
|
995 | + $s = $s . "/"; |
|
996 | + } |
|
997 | + if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/') { |
|
998 | + $s = $s . substr($path2,1); |
|
999 | + } else { |
|
1000 | + $s = $s . $path2; |
|
1001 | + } |
|
907 | 1002 | return $s; } |
908 | 1003 | |
909 | 1004 | /** |
@@ -24,13 +24,15 @@ discard block |
||
24 | 24 | $r = ord($str[2]); |
25 | 25 | if (strlen($str) > 3) { |
26 | 26 | $a = 127 - (ord($str[3]) / 2); |
27 | - if ($a != 0 && $a != 127) |
|
28 | - $this->had_alpha = 1; |
|
27 | + if ($a != 0 && $a != 127) { |
|
28 | + $this->had_alpha = 1; |
|
29 | + } |
|
29 | 30 | } else { |
30 | 31 | $a = 0; |
31 | 32 | } |
32 | - if ($a != 127) |
|
33 | - $this->all_transaprent = 0; |
|
33 | + if ($a != 127) { |
|
34 | + $this->all_transaprent = 0; |
|
35 | + } |
|
34 | 36 | return imagecolorallocatealpha($img, $r, $g, $b, $a); |
35 | 37 | } |
36 | 38 | |
@@ -65,8 +67,9 @@ discard block |
||
65 | 67 | $most_pixels = 0; |
66 | 68 | for ($i = 0; $i < $h["num"]; $i++) { |
67 | 69 | $entry = substr($ico, 6 + 16 * $i, 16); |
68 | - if (!$entry || strlen($entry) < 16) |
|
69 | - continue; |
|
70 | + if (!$entry || strlen($entry) < 16) { |
|
71 | + continue; |
|
72 | + } |
|
70 | 73 | $e = unpack("Cwidth/" . |
71 | 74 | "Cheight/" . |
72 | 75 | "Ccolors/" . |
@@ -76,10 +79,12 @@ discard block |
||
76 | 79 | "Vsize/" . |
77 | 80 | "Voffset/", |
78 | 81 | $entry); |
79 | - if ($e["width"] == 0) |
|
80 | - $e["width"] = 256; |
|
81 | - if ($e["height"] == 0) |
|
82 | - $e["height"] = 256; |
|
82 | + if ($e["width"] == 0) { |
|
83 | + $e["width"] = 256; |
|
84 | + } |
|
85 | + if ($e["height"] == 0) { |
|
86 | + $e["height"] = 256; |
|
87 | + } |
|
83 | 88 | if ($e["zero"] != 0) { |
84 | 89 | $this->error = "nonzero reserved field"; |
85 | 90 | return false; |
@@ -226,8 +231,9 @@ discard block |
||
226 | 231 | } |
227 | 232 | } |
228 | 233 | // End of row padding |
229 | - while ($offset & 3) |
|
230 | - $offset++; |
|
234 | + while ($offset & 3) { |
|
235 | + $offset++; |
|
236 | + } |
|
231 | 237 | } |
232 | 238 | |
233 | 239 | // Now the "AND" image, which is 1 bit per pixel. Ignore |
@@ -261,8 +267,9 @@ discard block |
||
261 | 267 | } |
262 | 268 | |
263 | 269 | // End of row padding |
264 | - while ($offset & 3) |
|
265 | - $offset++; |
|
270 | + while ($offset & 3) { |
|
271 | + $offset++; |
|
272 | + } |
|
266 | 273 | } |
267 | 274 | return $img; |
268 | 275 | } |
@@ -108,13 +108,15 @@ discard block |
||
108 | 108 | //---------------------------------------------------------------------- |
109 | 109 | public function appendNum($bits, $num) |
110 | 110 | { |
111 | - if ($bits == 0) |
|
112 | - return 0; |
|
111 | + if ($bits == 0) { |
|
112 | + return 0; |
|
113 | + } |
|
113 | 114 | |
114 | 115 | $b = QRbitstream::newFromNum($bits, $num); |
115 | 116 | |
116 | - if(is_null($b)) |
|
117 | - return -1; |
|
117 | + if(is_null($b)) { |
|
118 | + return -1; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | $ret = $this->append($b); |
120 | 122 | unset($b); |
@@ -125,13 +127,15 @@ discard block |
||
125 | 127 | //---------------------------------------------------------------------- |
126 | 128 | public function appendBytes($size, $data) |
127 | 129 | { |
128 | - if ($size == 0) |
|
129 | - return 0; |
|
130 | + if ($size == 0) { |
|
131 | + return 0; |
|
132 | + } |
|
130 | 133 | |
131 | 134 | $b = QRbitstream::newFromBytes($size, $data); |
132 | 135 | |
133 | - if(is_null($b)) |
|
134 | - return -1; |
|
136 | + if(is_null($b)) { |
|
137 | + return -1; |
|
138 | + } |
|
135 | 139 | |
136 | 140 | $ret = $this->append($b); |
137 | 141 | unset($b); |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | //---------------------------------------------------------------------- |
48 | 48 | public static function isdigitat($str, $pos) |
49 | 49 | { |
50 | - if ($pos >= strlen($str)) |
|
51 | - return false; |
|
50 | + if ($pos >= strlen($str)) { |
|
51 | + return false; |
|
52 | + } |
|
52 | 53 | |
53 | 54 | return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); |
54 | 55 | } |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | //---------------------------------------------------------------------- |
57 | 58 | public static function isalnumat($str, $pos) |
58 | 59 | { |
59 | - if ($pos >= strlen($str)) |
|
60 | - return false; |
|
60 | + if ($pos >= strlen($str)) { |
|
61 | + return false; |
|
62 | + } |
|
61 | 63 | |
62 | 64 | return (QRinput::lookAnTable(ord($str[$pos])) >= 0); |
63 | 65 | } |
@@ -65,8 +67,9 @@ discard block |
||
65 | 67 | //---------------------------------------------------------------------- |
66 | 68 | public function identifyMode($pos) |
67 | 69 | { |
68 | - if ($pos >= strlen($this->dataStr)) |
|
69 | - return QR_MODE_NUL; |
|
70 | + if ($pos >= strlen($this->dataStr)) { |
|
71 | + return QR_MODE_NUL; |
|
72 | + } |
|
70 | 73 | |
71 | 74 | $c = $this->dataStr[$pos]; |
72 | 75 | |
@@ -120,8 +123,9 @@ discard block |
||
120 | 123 | } |
121 | 124 | |
122 | 125 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
123 | - if($ret < 0) |
|
124 | - return -1; |
|
126 | + if($ret < 0) { |
|
127 | + return -1; |
|
128 | + } |
|
125 | 129 | |
126 | 130 | return $run; |
127 | 131 | } |
@@ -167,8 +171,9 @@ discard block |
||
167 | 171 | } |
168 | 172 | |
169 | 173 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
170 | - if($ret < 0) |
|
171 | - return -1; |
|
174 | + if($ret < 0) { |
|
175 | + return -1; |
|
176 | + } |
|
172 | 177 | |
173 | 178 | return $run; |
174 | 179 | } |
@@ -183,8 +188,9 @@ discard block |
||
183 | 188 | } |
184 | 189 | |
185 | 190 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
186 | - if($ret < 0) |
|
187 | - return -1; |
|
191 | + if($ret < 0) { |
|
192 | + return -1; |
|
193 | + } |
|
188 | 194 | |
189 | 195 | return $ret; |
190 | 196 | } |
@@ -238,8 +244,9 @@ discard block |
||
238 | 244 | $run = $p; |
239 | 245 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
240 | 246 | |
241 | - if($ret < 0) |
|
242 | - return -1; |
|
247 | + if($ret < 0) { |
|
248 | + return -1; |
|
249 | + } |
|
243 | 250 | |
244 | 251 | return $run; |
245 | 252 | } |
@@ -249,8 +256,9 @@ discard block |
||
249 | 256 | { |
250 | 257 | while (strlen($this->dataStr) > 0) |
251 | 258 | { |
252 | - if($this->dataStr == '') |
|
253 | - return 0; |
|
259 | + if($this->dataStr == '') { |
|
260 | + return 0; |
|
261 | + } |
|
254 | 262 | |
255 | 263 | $mode = $this->identifyMode(0); |
256 | 264 | |
@@ -258,16 +266,22 @@ discard block |
||
258 | 266 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
259 | 267 | case QR_MODE_AN: $length = $this->eatAn(); break; |
260 | 268 | case QR_MODE_KANJI: |
261 | - if ($this->modeHint == QR_MODE_KANJI) |
|
262 | - $length = $this->eatKanji(); |
|
263 | - else $length = $this->eat8(); |
|
269 | + if ($this->modeHint == QR_MODE_KANJI) { |
|
270 | + $length = $this->eatKanji(); |
|
271 | + } else { |
|
272 | + $length = $this->eat8(); |
|
273 | + } |
|
264 | 274 | break; |
265 | 275 | default: $length = $this->eat8(); break; |
266 | 276 | |
267 | 277 | } |
268 | 278 | |
269 | - if($length == 0) return 0; |
|
270 | - if($length < 0) return -1; |
|
279 | + if($length == 0) { |
|
280 | + return 0; |
|
281 | + } |
|
282 | + if($length < 0) { |
|
283 | + return -1; |
|
284 | + } |
|
271 | 285 | |
272 | 286 | $this->dataStr = substr($this->dataStr, $length); |
273 | 287 | } |
@@ -303,8 +317,9 @@ discard block |
||
303 | 317 | |
304 | 318 | $split = new QRsplit($string, $input, $modeHint); |
305 | 319 | |
306 | - if(!$casesensitive) |
|
307 | - $split->toUpper(); |
|
320 | + if(!$casesensitive) { |
|
321 | + $split->toUpper(); |
|
322 | + } |
|
308 | 323 | |
309 | 324 | return $split->splitString(); |
310 | 325 | } |