Passed
Branch master (de5173)
by Cody
11:03
created
classes/logger/sql.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 
24 24
 			foreach ($server_params as $n => $p) {
25 25
 				if (isset($_SERVER[$p]))
26
-					$context .= "\n$n: " . $_SERVER[$p];
26
+					$context .= "\n$n: ".$_SERVER[$p];
27 27
 			}
28 28
 
29 29
 			// passed error message may contain invalid unicode characters, failing to insert an error here
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	function log_error($errno, $errstr, $file, $line, $context) {
7 7
 
8 8
 		// separate PDO connection object is used for logging
9
-		if (!$this->pdo) $this->pdo = Db::instance()->pdo_connect();
9
+		if (!$this->pdo) {
10
+			$this->pdo = Db::instance()->pdo_connect();
11
+		}
10 12
 
11 13
 		if ($this->pdo && get_schema_version() > 117) {
12 14
 
@@ -22,8 +24,9 @@  discard block
 block discarded – undo
22 24
 			];
23 25
 
24 26
 			foreach ($server_params as $n => $p) {
25
-				if (isset($_SERVER[$p]))
26
-					$context .= "\n$n: " . $_SERVER[$p];
27
+				if (isset($_SERVER[$p])) {
28
+									$context .= "\n$n: " . $_SERVER[$p];
29
+				}
27 30
 			}
28 31
 
29 32
 			// passed error message may contain invalid unicode characters, failing to insert an error here
Please login to merge, or discard this patch.
classes/rssutils.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -702,7 +702,7 @@
 block discarded – undo
702 702
 					$entry_plugin_data .= mb_strtolower(get_class($plugin)) . ",";
703 703
 				}
704 704
 
705
-                if (Debug::get_loglevel() >= 3) {
705
+				if (Debug::get_loglevel() >= 3) {
706 706
 					print "processed content: ";
707 707
 					print htmlspecialchars($article["content"]);
708 708
 					print "\n";
Please login to merge, or discard this patch.
Switch Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1349,35 +1349,35 @@
 block discarded – undo
1349 1349
 					continue;
1350 1350
 
1351 1351
 				switch ($rule["type"]) {
1352
-					case "title":
1353
-						$match = @preg_match("/$reg_exp/iu", $title);
1354
-						break;
1355
-					case "content":
1356
-						// we don't need to deal with multiline regexps
1357
-						$content = preg_replace("/[\r\n\t]/", "", $content);
1352
+				case "title":
1353
+					$match = @preg_match("/$reg_exp/iu", $title);
1354
+					break;
1355
+				case "content":
1356
+					// we don't need to deal with multiline regexps
1357
+					$content = preg_replace("/[\r\n\t]/", "", $content);
1358 1358
 
1359
-						$match = @preg_match("/$reg_exp/iu", $content);
1360
-						break;
1361
-					case "both":
1362
-						// we don't need to deal with multiline regexps
1363
-						$content = preg_replace("/[\r\n\t]/", "", $content);
1359
+					$match = @preg_match("/$reg_exp/iu", $content);
1360
+					break;
1361
+				case "both":
1362
+					// we don't need to deal with multiline regexps
1363
+					$content = preg_replace("/[\r\n\t]/", "", $content);
1364 1364
 
1365
-						$match = (@preg_match("/$reg_exp/iu", $title) || @preg_match("/$reg_exp/iu", $content));
1366
-						break;
1367
-					case "link":
1368
-						$match = @preg_match("/$reg_exp/iu", $link);
1369
-						break;
1370
-					case "author":
1371
-						$match = @preg_match("/$reg_exp/iu", $author);
1372
-						break;
1373
-					case "tag":
1374
-						foreach ($tags as $tag) {
1375
-							if (@preg_match("/$reg_exp/iu", $tag)) {
1376
-								$match = true;
1377
-								break;
1378
-							}
1365
+					$match = (@preg_match("/$reg_exp/iu", $title) || @preg_match("/$reg_exp/iu", $content));
1366
+					break;
1367
+				case "link":
1368
+					$match = @preg_match("/$reg_exp/iu", $link);
1369
+					break;
1370
+				case "author":
1371
+					$match = @preg_match("/$reg_exp/iu", $author);
1372
+					break;
1373
+				case "tag":
1374
+					foreach ($tags as $tag) {
1375
+						if (@preg_match("/$reg_exp/iu", $tag)) {
1376
+							$match = true;
1377
+							break;
1379 1378
 						}
1380
-						break;
1379
+					}
1380
+					break;
1381 1381
 				}
1382 1382
 
1383 1383
 				if ($rule_inverse) $match = !$match;
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
 			if ($k != "feed" && isset($v)) {
8 8
 				$x = strip_tags(is_array($v) ? implode(",", $v) : $v);
9 9
 
10
-				$tmp .= sha1("$k:" . sha1($x));
10
+				$tmp .= sha1("$k:".sha1($x));
11 11
 			}
12 12
 		}
13 13
 
14
-		return sha1(implode(",", $pluginhost->get_plugin_names()) . $tmp);
14
+		return sha1(implode(",", $pluginhost->get_plugin_names()).$tmp);
15 15
 	}
16 16
 
17 17
 	// Strips utf8mb4 characters (i.e. emoji) for mysql
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 			//update_rss_feed($line["id"], true);
138 138
 
139 139
 			if ($tline = $usth->fetch()) {
140
-				Debug::log(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]);
140
+				Debug::log(" => ".$tline["last_updated"].", ".$tline["id"]." ".$tline["owner_uid"]);
141 141
 
142 142
 				if (array_search($tline["owner_uid"], $batch_owners) === FALSE)
143 143
 					array_push($batch_owners, $tline["owner_uid"]);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
 		$date_feed_processed = date('Y-m-d H:i');
325 325
 
326
-		$cache_filename = CACHE_DIR . "/feeds/" . sha1($fetch_url) . ".xml";
326
+		$cache_filename = CACHE_DIR."/feeds/".sha1($fetch_url).".xml";
327 327
 
328 328
 		$pluginhost = new PluginHost();
329 329
 		$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		Debug::log("running HOOK_FETCH_FEED handlers...", Debug::$LOG_VERBOSE);
341 341
 
342 342
 		foreach ($pluginhost->get_hooks(PluginHost::HOOK_FETCH_FEED) as $plugin) {
343
-			Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE);
343
+			Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE);
344 344
 			$start = microtime(true);
345 345
 			$feed_data = $plugin->hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, 0, $auth_login, $auth_pass);
346 346
 			Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			$feed_data = trim($feed_data);
403 403
 
404 404
 			Debug::log("fetch done.", Debug::$LOG_VERBOSE);
405
-			Debug::log("source last modified: " . $fetch_last_modified, Debug::$LOG_VERBOSE);
405
+			Debug::log("source last modified: ".$fetch_last_modified, Debug::$LOG_VERBOSE);
406 406
 
407 407
 			if ($feed_data && $fetch_last_modified != $stored_last_modified) {
408 408
 				$sth = $pdo->prepare("UPDATE ttrss_feeds SET last_modified = ? WHERE id = ?");
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 
412 412
 			// cache vanilla feed data for re-use
413
-			if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR . "/feeds")) {
413
+			if ($feed_data && !$auth_pass && !$auth_login && is_writable(CACHE_DIR."/feeds")) {
414 414
 				$new_rss_hash = sha1($feed_data);
415 415
 
416 416
 				if ($new_rss_hash != $rss_hash) {
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		$feed_data_checksum = md5($feed_data);
446 446
 
447 447
 		foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) {
448
-			Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE);
448
+			Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE);
449 449
 			$start = microtime(true);
450 450
 			$feed_data = $plugin->hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed);
451 451
 			Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			// We use local pluginhost here because we need to load different per-user feed plugins
468 468
 
469 469
 			foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_PARSED) as $plugin) {
470
-				Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE);
470
+				Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE);
471 471
 				$start = microtime(true);
472 472
 				$plugin->hook_feed_parsed($rss);
473 473
 				Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE);
@@ -499,14 +499,14 @@  discard block
 block discarded – undo
499 499
 			$site_url = mb_substr(rewrite_relative_url($fetch_url, clean($rss->get_link())), 0, 245);
500 500
 
501 501
 			Debug::log("site_url: $site_url", Debug::$LOG_VERBOSE);
502
-			Debug::log("feed_title: " . clean($rss->get_title()), Debug::$LOG_VERBOSE);
502
+			Debug::log("feed_title: ".clean($rss->get_title()), Debug::$LOG_VERBOSE);
503 503
 
504 504
 			if ($favicon_needs_check || $force_refetch) {
505 505
 
506 506
 				/* terrible hack: if we crash on floicon shit here, we won't check
507 507
 				 * the icon avgcolor again (unless the icon got updated) */
508 508
 
509
-				$favicon_file = ICONS_DIR . "/$feed.ico";
509
+				$favicon_file = ICONS_DIR."/$feed.ico";
510 510
 				$favicon_modified = @filemtime($favicon_file);
511 511
 
512 512
 				Debug::log("checking favicon...", Debug::$LOG_VERBOSE);
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 
528 528
 					$favicon_color = calculate_avg_color($favicon_file);
529 529
 
530
-					$favicon_colorstring = ",favicon_avg_color = " . $pdo->quote($favicon_color);
530
+					$favicon_colorstring = ",favicon_avg_color = ".$pdo->quote($favicon_color);
531 531
 
532 532
 				} else if ($favicon_avg_color == 'fail') {
533 533
 					Debug::log("floicon failed on this file, not trying to recalculate avg color", Debug::$LOG_VERBOSE);
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 				print_r($filters);
547 547
 			}
548 548
 
549
-			Debug::log("" . count($filters) . " filters loaded.", Debug::$LOG_VERBOSE);
549
+			Debug::log("".count($filters)." filters loaded.", Debug::$LOG_VERBOSE);
550 550
 
551 551
 			$items = $rss->get_items();
552 552
 
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
 
589 589
 				$entry_guid = "$owner_uid,$entry_guid";
590 590
 
591
-				$entry_guid_hashed = 'SHA1:' . sha1($entry_guid);
591
+				$entry_guid_hashed = 'SHA1:'.sha1($entry_guid);
592 592
 
593 593
 				Debug::log("guid $entry_guid / $entry_guid_hashed", Debug::$LOG_VERBOSE);
594 594
 
595
-				$entry_timestamp = (int)$item->get_date();
595
+				$entry_timestamp = (int) $item->get_date();
596 596
 
597
-				Debug::log("orig date: " . $item->get_date(), Debug::$LOG_VERBOSE);
597
+				Debug::log("orig date: ".$item->get_date(), Debug::$LOG_VERBOSE);
598 598
 
599 599
 				$entry_title = strip_tags($item->get_title());
600 600
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 				Debug::log("link $entry_link", Debug::$LOG_VERBOSE);
607 607
 				Debug::log("language $entry_language", Debug::$LOG_VERBOSE);
608 608
 
609
-				if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp);;
609
+				if (!$entry_title) $entry_title = date("Y-m-d H:i:s", $entry_timestamp); ;
610 610
 
611 611
 				$entry_content = $item->get_content();
612 612
 				if (!$entry_content) $entry_content = $item->get_description();
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 				Debug::log("looking for tags...", Debug::$LOG_VERBOSE);
628 628
 
629 629
 				$entry_tags = $item->get_categories();
630
-				Debug::log("tags found: " . join(", ", $entry_tags), Debug::$LOG_VERBOSE);
630
+				Debug::log("tags found: ".join(", ", $entry_tags), Debug::$LOG_VERBOSE);
631 631
 
632 632
 				Debug::log("done collecting data.", Debug::$LOG_VERBOSE);
633 633
 
@@ -692,14 +692,14 @@  discard block
 block discarded – undo
692 692
 				Debug::log("hash differs, applying plugin filters:", Debug::$LOG_VERBOSE);
693 693
 
694 694
 				foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) {
695
-					Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE);
695
+					Debug::log("... ".get_class($plugin), Debug::$LOG_VERBOSE);
696 696
 
697 697
 					$start = microtime(true);
698 698
 					$article = $plugin->hook_article_filter($article);
699 699
 
700 700
 					Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE);
701 701
 
702
-					$entry_plugin_data .= mb_strtolower(get_class($plugin)) . ",";
702
+					$entry_plugin_data .= mb_strtolower(get_class($plugin)).",";
703 703
 				}
704 704
 
705 705
                 if (Debug::get_loglevel() >= 3) {
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 					Debug::log("applying plugin filter actions...", Debug::$LOG_VERBOSE);
773 773
 
774 774
 					foreach ($plugin_filter_names as $pfn) {
775
-						list($pfclass,$pfaction) = explode(":", $pfn["param"]);
775
+						list($pfclass, $pfaction) = explode(":", $pfn["param"]);
776 776
 
777 777
 						if (isset($plugin_filter_actions[$pfclass])) {
778 778
 							$plugin = $pluginhost->get_plugin($pfclass);
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 							$entry_current_hash,
868 868
 							$date_feed_processed,
869 869
 							$entry_comments,
870
-							(int)$num_comments,
870
+							(int) $num_comments,
871 871
 							$entry_plugin_data,
872 872
 							"$entry_language",
873 873
 							"$entry_author"]);
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 						":content" => "$entry_content",
980 980
 						":content_hash" => $entry_current_hash,
981 981
 						":updated" => $entry_timestamp_fmt,
982
-						":num_comments" => (int)$num_comments,
982
+						":num_comments" => (int) $num_comments,
983 983
 						":plugin_data" => $entry_plugin_data,
984 984
 						":author" => "$entry_author",
985 985
 						":lang" => $entry_language,
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 
988 988
 					if (DB_TYPE == "pgsql") {
989 989
 						$params[":ts_lang"] = $feed_language;
990
-						$params[":ts_content"] = mb_substr(strip_tags($entry_title . " " . $entry_content), 0, 900000);
990
+						$params[":ts_content"] = mb_substr(strip_tags($entry_title." ".$entry_content), 0, 900000);
991 991
 					}
992 992
 
993 993
 					$sth->execute($params);
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 				foreach ($enclosures as $enc) {
1068 1068
 					$enc_url = $enc[0];
1069 1069
 					$enc_type = $enc[1];
1070
-					$enc_dur = (int)$enc[2];
1070
+					$enc_dur = (int) $enc[2];
1071 1071
 					$enc_title = $enc[3];
1072 1072
 					$enc_width = intval($enc[4]);
1073 1073
 					$enc_height = intval($enc[5]);
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 					$esth->execute([$enc_url, $enc_type, $entry_ref_id]);
1076 1076
 
1077 1077
 					if (!$esth->fetch()) {
1078
-						$usth->execute([$enc_url, $enc_type, (string)$enc_title, $enc_dur, $entry_ref_id, $enc_width, $enc_height]);
1078
+						$usth->execute([$enc_url, $enc_type, (string) $enc_title, $enc_dur, $entry_ref_id, $enc_width, $enc_height]);
1079 1079
 					}
1080 1080
 				}
1081 1081
 
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 				$filtered_tags = array_unique($filtered_tags);
1110 1110
 
1111 1111
 				if (Debug::get_loglevel() >= Debug::$LOG_VERBOSE) {
1112
-					Debug::log("filtered tags: " . implode(", ", $filtered_tags), Debug::$LOG_VERBOSE);
1112
+					Debug::log("filtered tags: ".implode(", ", $filtered_tags), Debug::$LOG_VERBOSE);
1113 1113
 
1114 1114
 				}
1115 1115
 
@@ -1297,11 +1297,11 @@  discard block
 block discarded – undo
1297 1297
 		$num_deleted = 0;
1298 1298
 
1299 1299
 		if (is_writable(LOCK_DIRECTORY)) {
1300
-			$files = glob(LOCK_DIRECTORY . "/*.lock");
1300
+			$files = glob(LOCK_DIRECTORY."/*.lock");
1301 1301
 
1302 1302
 			if ($files) {
1303 1303
 				foreach ($files as $file) {
1304
-					if (!file_is_locked(basename($file)) && time() - filemtime($file) > 86400*2) {
1304
+					if (!file_is_locked(basename($file)) && time() - filemtime($file) > 86400 * 2) {
1305 1305
 						unlink($file);
1306 1306
 						++$num_deleted;
1307 1307
 					}
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 	static function check_feed_favicon($site_url, $feed) {
1517 1517
 		#		print "FAVICON [$site_url]: $favicon_url\n";
1518 1518
 
1519
-		$icon_file = ICONS_DIR . "/$feed.ico";
1519
+		$icon_file = ICONS_DIR."/$feed.ico";
1520 1520
 
1521 1521
 		if (!file_exists($icon_file)) {
1522 1522
 			$favicon_url = RSSUtils::get_favicon_url($site_url);
@@ -1570,14 +1570,14 @@  discard block
 block discarded – undo
1570 1570
 
1571 1571
 	static function is_gzipped($feed_data) {
1572 1572
 		return strpos(substr($feed_data, 0, 3),
1573
-				"\x1f" . "\x8b" . "\x08", 0) === 0;
1573
+				"\x1f"."\x8b"."\x08", 0) === 0;
1574 1574
 	}
1575 1575
 
1576 1576
 	static function load_filters($feed_id, $owner_uid) {
1577 1577
 		$filters = array();
1578 1578
 
1579 1579
 		$feed_id = (int) $feed_id;
1580
-		$cat_id = (int)Feeds::getFeedCategory($feed_id);
1580
+		$cat_id = (int) Feeds::getFeedCategory($feed_id);
1581 1581
 
1582 1582
 		if ($cat_id == 0)
1583 1583
 			$null_cat_qpart = "cat_id IS NULL OR";
Please login to merge, or discard this patch.
Braces   +73 added lines, -46 removed lines patch added patch discarded remove patch
@@ -80,7 +80,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
classes/digest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 					time() - $preferred_ts <= 7200
38 38
 				) {
39 39
 
40
-					Debug::log("Sending digest for UID:" . $line['id'] . " - " . $line["email"]);
40
+					Debug::log("Sending digest for UID:".$line['id']." - ".$line["email"]);
41 41
 
42 42
 					$do_catchup = get_pref('DIGEST_CATCHUP', $line['id'], false);
43 43
 
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 
124 124
 		$sth = $pdo->prepare("SELECT ttrss_entries.title,
125 125
 				ttrss_feeds.title AS feed_title,
126
-				COALESCE(ttrss_feed_categories.title, '" . __('Uncategorized') . "') AS cat_title,
126
+				COALESCE(ttrss_feed_categories.title, '" . __('Uncategorized')."') AS cat_title,
127 127
 				date_updated,
128 128
 				ttrss_user_entries.ref_id,
129 129
 				link,
130 130
 				score,
131 131
 				content,
132
-				" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated
132
+				" . SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
133 133
 			FROM
134 134
 				ttrss_user_entries,ttrss_entries,ttrss_feeds
135 135
 			LEFT JOIN
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				$user_id);
166 166
 
167 167
 			if (get_pref('ENABLE_FEED_CATS', $user_id)) {
168
-				$line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title'];
168
+				$line['feed_title'] = $line['cat_title']." / ".$line['feed_title'];
169 169
 			}
170 170
 
171 171
 			$article_labels = Article::get_article_labels($line["ref_id"], $user_id);
Please login to merge, or discard this patch.
classes/ccache.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				$sth->execute([":uid" => $owner_uid, ":cat" => $feed_id]);
136 136
 
137 137
 				while ($line = $sth->fetch()) {
138
-					CCache::update((int)$line["id"], $owner_uid, false, false);
138
+					CCache::update((int) $line["id"], $owner_uid, false, false);
139 139
 				}
140 140
 			}
141 141
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 					$sth->execute([$owner_uid, $feed_id]);
198 198
 
199 199
 					if ($row = $sth->fetch()) {
200
-						CCache::update((int)$row["cat_id"], $owner_uid, true, true, true);
200
+						CCache::update((int) $row["cat_id"], $owner_uid, true, true, true);
201 201
 					}
202 202
 				}
203 203
 			}
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,8 +66,9 @@  discard block
 block discarded – undo
66 66
 
67 67
 		// "" (null) is valid and should be cast to 0 (uncategorized)
68 68
 		// everything else i.e. tags are not
69
-		if (!is_numeric($feed_id) && $feed_id)
70
-			return;
69
+		if (!is_numeric($feed_id) && $feed_id) {
70
+					return;
71
+		}
71 72
 
72 73
 		$feed_id = (int) $feed_id;
73 74
 
@@ -102,8 +103,9 @@  discard block
 block discarded – undo
102 103
 
103 104
 		// "" (null) is valid and should be cast to 0 (uncategorized)
104 105
 		// everything else i.e. tags are not
105
-		if (!is_numeric($feed_id) && $feed_id)
106
-			return;
106
+		if (!is_numeric($feed_id) && $feed_id) {
107
+					return;
108
+		}
107 109
 
108 110
 		$feed_id = (int) $feed_id;
109 111
 
@@ -182,7 +184,9 @@  discard block
 block discarded – undo
182 184
 			$sth->execute([$feed_id, $unread, $owner_uid]);
183 185
 		}
184 186
 
185
-		if (!$tr_in_progress) $pdo->commit();
187
+		if (!$tr_in_progress) {
188
+			$pdo->commit();
189
+		}
186 190
 
187 191
 		if ($feed_id > 0 && $prev_unread != $unread) {
188 192
 
Please login to merge, or discard this patch.
classes/feeditem/common.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@
 block discarded – undo
175 175
 
176 176
 			// we don't support numeric tags
177 177
 			if (is_numeric($cat))
178
-				$cat = 't:' . $cat;
178
+				$cat = 't:'.$cat;
179 179
 
180 180
 			$cat = preg_replace('/[,\'\"]/', "", $cat);
181 181
 
Please login to merge, or discard this patch.
Braces   +30 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 			$source = $elem->getElementsByTagName("source")->item(0);
15 15
 
16 16
 			// we don't need <source> element
17
-			if ($source)
18
-				$elem->removeChild($source);
17
+			if ($source) {
18
+							$elem->removeChild($source);
19
+			}
19 20
 		} catch (DOMException $e) {
20 21
 			//
21 22
 		}
@@ -31,14 +32,19 @@  discard block
 block discarded – undo
31 32
 		if ($author) {
32 33
 			$name = $author->getElementsByTagName("name")->item(0);
33 34
 
34
-			if ($name) return clean($name->nodeValue);
35
+			if ($name) {
36
+				return clean($name->nodeValue);
37
+			}
35 38
 
36 39
 			$email = $author->getElementsByTagName("email")->item(0);
37 40
 
38
-			if ($email) return clean($email->nodeValue);
41
+			if ($email) {
42
+				return clean($email->nodeValue);
43
+			}
39 44
 
40
-			if ($author->nodeValue)
41
-				return clean($author->nodeValue);
45
+			if ($author->nodeValue) {
46
+							return clean($author->nodeValue);
47
+			}
42 48
 		}
43 49
 
44 50
 		$author_elems = $this->xpath->query("dc:creator", $this->elem);
@@ -56,15 +62,17 @@  discard block
 block discarded – undo
56 62
 		//might give a wrong result if a default namespace was declared (possible with XPath 2.0)
57 63
 		$com_url = $this->xpath->query("comments", $this->elem)->item(0);
58 64
 
59
-		if ($com_url)
60
-			return clean($com_url->nodeValue);
65
+		if ($com_url) {
66
+					return clean($com_url->nodeValue);
67
+		}
61 68
 
62 69
 		//Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common.
63 70
 		//'text/html' for type is too restrictive?
64 71
 		$com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0);
65 72
 
66
-		if ($com_url)
67
-			return clean($com_url->nodeValue);
73
+		if ($com_url) {
74
+					return clean($com_url->nodeValue);
75
+		}
68 76
 	}
69 77
 
70 78
 	function get_comments_count() {
@@ -98,7 +106,9 @@  discard block
 block discarded – undo
98 106
 			}
99 107
 
100 108
 			$desc = $this->xpath->query("media:description", $enclosure)->item(0);
101
-			if ($desc) $enc->title = clean($desc->nodeValue);
109
+			if ($desc) {
110
+				$enc->title = clean($desc->nodeValue);
111
+			}
102 112
 
103 113
 			array_push($encs, $enc);
104 114
 		}
@@ -127,7 +137,9 @@  discard block
 block discarded – undo
127 137
 					$enc->title = clean($desc->nodeValue);
128 138
 				} else {
129 139
 					$desc = $this->xpath->query("media:description", $enclosure)->item(0);
130
-					if ($desc) $enc->title = clean($desc->nodeValue);
140
+					if ($desc) {
141
+						$enc->title = clean($desc->nodeValue);
142
+					}
131 143
 				}
132 144
 
133 145
 				array_push($encs, $enc);
@@ -174,8 +186,9 @@  discard block
 block discarded – undo
174 186
 			$cat = clean(trim(mb_strtolower($srccat)));
175 187
 
176 188
 			// we don't support numeric tags
177
-			if (is_numeric($cat))
178
-				$cat = 't:' . $cat;
189
+			if (is_numeric($cat)) {
190
+							$cat = 't:' . $cat;
191
+			}
179 192
 
180 193
 			$cat = preg_replace('/[,\'\"]/', "", $cat);
181 194
 
@@ -183,8 +196,9 @@  discard block
 block discarded – undo
183 196
 				$cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat);
184 197
 			}
185 198
 
186
-			if (mb_strlen($cat) > 250)
187
-				$cat = mb_substr($cat, 0, 250);
199
+			if (mb_strlen($cat) > 250) {
200
+							$cat = mb_substr($cat, 0, 250);
201
+			}
188 202
 
189 203
 			return $cat;
190 204
 		}, $tmp);
Please login to merge, or discard this patch.
classes/feeditem/atom.php 1 patch
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,10 +43,11 @@  discard block
 block discarded – undo
43 43
 					|| $link->getAttribute("rel") == "standout")) {
44 44
 				$base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link);
45 45
 
46
-				if ($base)
47
-					return rewrite_relative_url($base, clean(trim($link->getAttribute("href"))));
48
-				else
49
-					return clean(trim($link->getAttribute("href")));
46
+				if ($base) {
47
+									return rewrite_relative_url($base, clean(trim($link->getAttribute("href"))));
48
+				} else {
49
+									return clean(trim($link->getAttribute("href")));
50
+				}
50 51
 
51 52
 			}
52 53
 		}
@@ -106,8 +107,9 @@  discard block
 block discarded – undo
106 107
 		$cats = [];
107 108
 
108 109
 		foreach ($categories as $cat) {
109
-			if ($cat->hasAttribute("term"))
110
-				array_push($cats, $cat->getAttribute("term"));
110
+			if ($cat->hasAttribute("term")) {
111
+							array_push($cats, $cat->getAttribute("term"));
112
+			}
111 113
 		}
112 114
 
113 115
 		$categories = $this->xpath->query("dc:subject", $this->elem);
Please login to merge, or discard this patch.
classes/handler/public.php 4 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 
286 286
 				array_push($rv, [ "label" => $title, "value" => $id ]);
287 287
 			}
288
-	    }
288
+		}
289 289
 
290 290
 		print json_encode($rv);
291 291
 	}
@@ -358,37 +358,37 @@  discard block
 block discarded – undo
358 358
 
359 359
 			$enclosures = Article::get_article_enclosures($line["id"]);
360 360
 
361
-            header("Content-Type: text/html");
361
+			header("Content-Type: text/html");
362 362
 
363
-            $rv .= "<!DOCTYPE html>
363
+			$rv .= "<!DOCTYPE html>
364 364
                     <html><head>
365 365
                     <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
366 366
                     <title>".$line["title"]."</title>".
367
-                    stylesheet_tag("css/default.css")."
367
+					stylesheet_tag("css/default.css")."
368 368
                     <link rel='shortcut icon' type='image/png' href='images/favicon.png'>
369 369
                     <link rel='icon' type='image/png' sizes='72x72' href='images/favicon-72px.png'>";
370 370
 
371
-            $rv .= "<meta property='og:title' content=\"".htmlspecialchars(html_entity_decode($line["title"], ENT_NOQUOTES | ENT_HTML401))."\"/>\n";
372
-            $rv .= "<meta property='og:description' content=\"".
373
-                htmlspecialchars(
374
-                	truncate_string(
375
-                		preg_replace("/[\r\n\t]/", "",
371
+			$rv .= "<meta property='og:title' content=\"".htmlspecialchars(html_entity_decode($line["title"], ENT_NOQUOTES | ENT_HTML401))."\"/>\n";
372
+			$rv .= "<meta property='og:description' content=\"".
373
+				htmlspecialchars(
374
+					truncate_string(
375
+						preg_replace("/[\r\n\t]/", "",
376 376
 							preg_replace("/ {1,}/", " ",
377 377
 								strip_tags(html_entity_decode($line["content"], ENT_NOQUOTES | ENT_HTML401))
378 378
 							)
379 379
 					), 500, "...")
380 380
 				)."\"/>\n";
381 381
 
382
-            $rv .= "</head>";
382
+			$rv .= "</head>";
383 383
 
384
-            list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $line["site_url"]);
384
+			list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $line["site_url"]);
385 385
 
386
-            if ($og_image) {
387
-                $rv .= "<meta property='og:image' content=\"" . htmlspecialchars($og_image) . "\"/>";
388
-            }
386
+			if ($og_image) {
387
+				$rv .= "<meta property='og:image' content=\"" . htmlspecialchars($og_image) . "\"/>";
388
+			}
389 389
 
390
-            $rv .= "<body class='flat ttrss_utility ttrss_zoom'>";
391
-            $rv .= "<div class='container'>";
390
+			$rv .= "<body class='flat ttrss_utility ttrss_zoom'>";
391
+			$rv .= "<div class='container'>";
392 392
 
393 393
 			if ($line["link"]) {
394 394
 				$rv .= "<h1><a target='_blank' rel='noopener noreferrer'
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 				$owner_uid, true);
411 411
 
412 412
 			$rv .= "<div>".$line['author']."</div>";
413
-            $rv .= "<div>$parsed_updated</div>";
413
+			$rv .= "<div>$parsed_updated</div>";
414 414
 
415 415
 			$rv .= "</div>"; # row
416 416
 
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
 
426 426
 			$rv .= $line["content"];
427 427
 
428
-            $rv .= Article::format_article_enclosures($id,
429
-                $line["always_display_enclosures"],
430
-                $line["content"],
431
-                $line["hide_images"]);
428
+			$rv .= Article::format_article_enclosures($id,
429
+				$line["always_display_enclosures"],
430
+				$line["content"],
431
+				$line["hide_images"]);
432 432
 
433 433
 			$rv .= "</div>"; # content
434 434
 
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
 					if ($sth->fetch()) {
676 676
 						$_SESSION["profile"] = $profile;
677 677
  					} else {
678
-					    $_SESSION["profile"] = null;
679
-                    }
678
+						$_SESSION["profile"] = null;
679
+					}
680 680
 				}
681 681
 			} else {
682 682
 
Please login to merge, or discard this patch.
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -760,24 +760,24 @@
 block discarded – undo
760 760
 				$feed_urls = false;
761 761
 
762 762
 				switch ($rc['code']) {
763
-					case 0:
764
-						print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
765
-						break;
766
-					case 1:
767
-						print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
768
-						break;
769
-					case 2:
770
-						print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
771
-						break;
772
-					case 3:
773
-						print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
774
-						break;
775
-					case 4:
776
-						$feed_urls = $rc["feeds"];
777
-						break;
778
-					case 5:
779
-						print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
780
-						break;
763
+				case 0:
764
+					print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
765
+					break;
766
+				case 1:
767
+					print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
768
+					break;
769
+				case 2:
770
+					print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
771
+					break;
772
+				case 3:
773
+					print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
774
+					break;
775
+				case 4:
776
+					$feed_urls = $rc["feeds"];
777
+					break;
778
+				case 5:
779
+					print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
780
+					break;
781 781
 				}
782 782
 
783 783
 				if ($feed_urls) {
Please login to merge, or discard this patch.
Spacing   +28 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 		require_once "lib/MiniTemplator.class.php";
9 9
 
10
-		$note_style = 	"background-color : #fff7d5;
10
+		$note_style = "background-color : #fff7d5;
11 11
 			border-width : 1px; ".
12 12
 			"padding : 5px; border-style : dashed; border-color : #e7d796;".
13 13
 			"margin-bottom : 1em; color : #9a8c59;";
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 		$feed_site_url = $qfh_ret[2];
74 74
 		/* $last_error = $qfh_ret[3]; */
75 75
 
76
-		$feed_self_url = get_self_url_prefix() .
77
-			"/public.php?op=rss&id=$feed&key=" .
76
+		$feed_self_url = get_self_url_prefix().
77
+			"/public.php?op=rss&id=$feed&key=".
78 78
 			Feeds::get_feed_access_key($feed, false, $owner_uid);
79 79
 
80 80
 		if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
@@ -102,8 +102,7 @@  discard block
 block discarded – undo
102 102
 				}
103 103
 
104 104
 				$tpl->setVariable('ARTICLE_ID',
105
-					htmlspecialchars($orig_guid ? $line['link'] :
106
-							$this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
105
+					htmlspecialchars($orig_guid ? $line['link'] : $this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
107 106
 				$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
108 107
 				$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
109 108
 				$tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
@@ -112,7 +111,7 @@  discard block
 block discarded – undo
112 111
 					$feed_site_url, false, $line["id"]);
113 112
 
114 113
 				if ($line['note']) {
115
-					$content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
114
+					$content = "<div style=\"$note_style\">Article note: ".$line['note']."</div>".
116 115
 						$content;
117 116
 					$tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
118 117
 				}
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
 				$article = array();
202 201
 
203 202
 				$article['id'] = $line['link'];
204
-				$article['link']	= $line['link'];
203
+				$article['link'] = $line['link'];
205 204
 				$article['title'] = $line['title'];
206 205
 				$article['excerpt'] = $line["content_preview"];
207 206
 				$article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
@@ -277,13 +276,13 @@  discard block
 block discarded – undo
277 276
 			WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = ? ORDER BY title");
278 277
 			$sth->execute([$login]);
279 278
 
280
-			$rv = [ [ "value" => 0, "label" => __("Default profile") ] ];
279
+			$rv = [["value" => 0, "label" => __("Default profile")]];
281 280
 
282 281
 			while ($line = $sth->fetch()) {
283 282
 				$id = $line["id"];
284 283
 				$title = $line["title"];
285 284
 
286
-				array_push($rv, [ "label" => $title, "value" => $id ]);
285
+				array_push($rv, ["label" => $title, "value" => $id]);
287 286
 			}
288 287
 	    }
289 288
 
@@ -384,7 +383,7 @@  discard block
 block discarded – undo
384 383
             list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $line["site_url"]);
385 384
 
386 385
             if ($og_image) {
387
-                $rv .= "<meta property='og:image' content=\"" . htmlspecialchars($og_image) . "\"/>";
386
+                $rv .= "<meta property='og:image' content=\"".htmlspecialchars($og_image)."\"/>";
388 387
             }
389 388
 
390 389
             $rv .= "<body class='flat ttrss_utility ttrss_zoom'>";
@@ -393,9 +392,9 @@  discard block
 block discarded – undo
393 392
 			if ($line["link"]) {
394 393
 				$rv .= "<h1><a target='_blank' rel='noopener noreferrer'
395 394
 					title=\"".htmlspecialchars($line['title'])."\"
396
-					href=\"" .htmlspecialchars($line["link"]) . "\">" .	$line["title"] . "</a></h1>";
395
+					href=\"" .htmlspecialchars($line["link"])."\">".$line["title"]."</a></h1>";
397 396
 			} else {
398
-				$rv .= "<h1>" . $line["title"] . "</h1>";
397
+				$rv .= "<h1>".$line["title"]."</h1>";
399 398
 			}
400 399
 
401 400
 			$rv .= "<div class='content post'>";
@@ -448,8 +447,8 @@  discard block
 block discarded – undo
448 447
 		$feed = clean($_REQUEST["id"]);
449 448
 		$key = clean($_REQUEST["key"]);
450 449
 		$is_cat = clean($_REQUEST["is_cat"]);
451
-		$limit = (int)clean($_REQUEST["limit"]);
452
-		$offset = (int)clean($_REQUEST["offset"]);
450
+		$limit = (int) clean($_REQUEST["limit"]);
451
+		$offset = (int) clean($_REQUEST["offset"]);
453 452
 
454 453
 		$search = clean($_REQUEST["q"]);
455 454
 		$view_mode = clean($_REQUEST["view-mode"]);
@@ -692,9 +691,9 @@  discard block
 block discarded – undo
692 691
 			$return = clean($_REQUEST['return']);
693 692
 
694 693
 			if ($_REQUEST['return'] && mb_strpos($return, SELF_URL_PATH) === 0) {
695
-				header("Location: " . clean($_REQUEST['return']));
694
+				header("Location: ".clean($_REQUEST['return']));
696 695
 			} else {
697
-				header("Location: " . get_self_url_prefix());
696
+				header("Location: ".get_self_url_prefix());
698 697
 			}
699 698
 		}
700 699
 	}
@@ -786,7 +785,7 @@  discard block
 block discarded – undo
786 785
 					print "<input type='hidden' name='op' value='subscribe'>";
787 786
 
788 787
 					print "<fieldset>";
789
-					print "<label style='display : inline'>" . __("Multiple feed URLs found:") . "</label>";
788
+					print "<label style='display : inline'>".__("Multiple feed URLs found:")."</label>";
790 789
 					print "<select name='feed_url' dojoType='dijit.form.Select'>";
791 790
 
792 791
 					foreach ($feed_urls as $url => $name) {
@@ -805,9 +804,9 @@  discard block
 block discarded – undo
805 804
 					print "</form>";
806 805
 				}
807 806
 
808
-				$tp_uri = get_self_url_prefix() . "/prefs.php";
807
+				$tp_uri = get_self_url_prefix()."/prefs.php";
809 808
 
810
-				if ($rc['code'] <= 2){
809
+				if ($rc['code'] <= 2) {
811 810
 					$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
812 811
 					feed_url = ? AND owner_uid = ?");
813 812
 					$sth->execute([$feed_url, $_SESSION['uid']]);
@@ -895,7 +894,7 @@  discard block
 block discarded – undo
895 894
 					list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
896 895
 
897 896
 					if ($timestamp && $resetpass_token &&
898
-						$timestamp >= time() - 15*60*60 &&
897
+						$timestamp >= time() - 15 * 60 * 60 &&
899 898
 						$resetpass_token == $hash) {
900 899
 
901 900
 							$sth = $this->pdo->prepare("UPDATE ttrss_users SET resetpass_token = NULL
@@ -935,8 +934,8 @@  discard block
 block discarded – undo
935 934
 				<input dojoType='dijit.form.TextBox' type='email' name='email' value='' required>
936 935
 				</fieldset>";
937 936
 
938
-			$_SESSION["pwdreset:testvalue1"] = rand(1,10);
939
-			$_SESSION["pwdreset:testvalue2"] = rand(1,10);
937
+			$_SESSION["pwdreset:testvalue1"] = rand(1, 10);
938
+			$_SESSION["pwdreset:testvalue2"] = rand(1, 10);
940 939
 
941 940
 			print "<fieldset>
942 941
 				<label>".T_sprintf("How much is %d + %d:", $_SESSION["pwdreset:testvalue1"], $_SESSION["pwdreset:testvalue2"])."</label>
@@ -981,8 +980,8 @@  discard block
 block discarded – undo
981 980
 
982 981
 					if ($id) {
983 982
 						$resetpass_token = sha1(get_random_bytes(128));
984
-						$resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
985
-							"&login=" . urlencode($login);
983
+						$resetpass_link = get_self_url_prefix()."/public.php?op=forgotpass&hash=".$resetpass_token.
984
+							"&login=".urlencode($login);
986 985
 
987 986
 						require_once "lib/MiniTemplator.class.php";
988 987
 
@@ -1009,7 +1008,7 @@  discard block
 block discarded – undo
1009 1008
 
1010 1009
 						if (!$rc) print_error($mailer->error());
1011 1010
 
1012
-						$resetpass_token_full = time() . ":" . $resetpass_token;
1011
+						$resetpass_token_full = time().":".$resetpass_token;
1013 1012
 
1014 1013
 						$sth = $this->pdo->prepare("UPDATE ttrss_users
1015 1014
 							SET resetpass_token = ?
@@ -1099,12 +1098,12 @@  discard block
 block discarded – undo
1099 1098
 				if ($op == "performupdate") {
1100 1099
 					if ($updater->isUpdateRequired()) {
1101 1100
 
1102
-						print "<h2>" . T_sprintf("Performing updates to version %d", SCHEMA_VERSION) . "</h2>";
1101
+						print "<h2>".T_sprintf("Performing updates to version %d", SCHEMA_VERSION)."</h2>";
1103 1102
 
1104 1103
 						for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
1105 1104
 							print "<ul>";
1106 1105
 
1107
-							print "<li class='text-info'>" . T_sprintf("Updating to version %d", $i) . "</li>";
1106
+							print "<li class='text-info'>".T_sprintf("Updating to version %d", $i)."</li>";
1108 1107
 
1109 1108
 							print "<li>";
1110 1109
 							$result = $updater->performUpdateTo($i, true);
@@ -1123,7 +1122,7 @@  discard block
 block discarded – undo
1123 1122
 
1124 1123
 								return;
1125 1124
 							} else {
1126
-								print "<li class='text-success'>" . __("Completed.") . "</li>";
1125
+								print "<li class='text-success'>".__("Completed.")."</li>";
1127 1126
 								print "</ul>";
1128 1127
 							}
1129 1128
 						}
@@ -1191,7 +1190,7 @@  discard block
 block discarded – undo
1191 1190
 
1192 1191
 		$timestamp = date("Y-m-d", strtotime($timestamp));
1193 1192
 
1194
-		return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST) . ",$timestamp:/$id";
1193
+		return "tag:".parse_url(get_self_url_prefix(), PHP_URL_HOST).",$timestamp:/$id";
1195 1194
 	}
1196 1195
 
1197 1196
 	// this should be used very carefully because this endpoint is exposed to unauthenticated users
Please login to merge, or discard this patch.
Braces   +24 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 			"padding : 5px; border-style : dashed; border-color : #e7d796;".
13 13
 			"margin-bottom : 1em; color : #9a8c59;";
14 14
 
15
-		if (!$limit) $limit = 60;
15
+		if (!$limit) {
16
+			$limit = 60;
17
+		}
16 18
 
17 19
 		$date_sort_field = "date_entered DESC, updated DESC";
18 20
 
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
 			"/public.php?op=rss&id=$feed&key=" .
78 80
 			Feeds::get_feed_access_key($feed, false, $owner_uid);
79 81
 
80
-		if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
82
+		if (!$feed_site_url) {
83
+			$feed_site_url = get_self_url_prefix();
84
+		}
81 85
 
82 86
 		if ($format == 'atom') {
83 87
 			$tpl = new MiniTemplator;
@@ -207,8 +211,12 @@  discard block
 block discarded – undo
207 211
 				$article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
208 212
 				$article['updated'] = date('c', strtotime($line["updated"]));
209 213
 
210
-				if ($line['note']) $article['note'] = $line['note'];
211
-				if ($article['author']) $article['author'] = $line['author'];
214
+				if ($line['note']) {
215
+					$article['note'] = $line['note'];
216
+				}
217
+				if ($article['author']) {
218
+					$article['author'] = $line['author'];
219
+				}
212 220
 
213 221
 				$tags = Article::get_article_tags($line["id"], $owner_uid);
214 222
 
@@ -459,7 +467,9 @@  discard block
 block discarded – undo
459 467
 		$format = clean($_REQUEST['format']);
460 468
 		$orig_guid = clean($_REQUEST["orig_guid"]);
461 469
 
462
-		if (!$format) $format = 'atom';
470
+		if (!$format) {
471
+			$format = 'atom';
472
+		}
463 473
 
464 474
 		if (SINGLE_USER_MODE) {
465 475
 			authenticate_user("admin", null);
@@ -472,8 +482,9 @@  discard block
 block discarded – undo
472 482
 				ttrss_access_keys WHERE access_key = ? AND feed_id = ?");
473 483
 			$sth->execute([$key, $feed]);
474 484
 
475
-			if ($row = $sth->fetch())
476
-				$owner_id = $row["owner_uid"];
485
+			if ($row = $sth->fetch()) {
486
+							$owner_id = $row["owner_uid"];
487
+			}
477 488
 		}
478 489
 
479 490
 		if ($owner_id) {
@@ -683,8 +694,9 @@  discard block
 block discarded – undo
683 694
 				// start an empty session to deliver login error message
684 695
 				@session_start();
685 696
 
686
-				if (!isset($_SESSION["login_error_msg"]))
687
-					$_SESSION["login_error_msg"] = __("Incorrect username or password");
697
+				if (!isset($_SESSION["login_error_msg"])) {
698
+									$_SESSION["login_error_msg"] = __("Incorrect username or password");
699
+				}
688 700
 
689 701
 				user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
690 702
 			}
@@ -1007,7 +1019,9 @@  discard block
 block discarded – undo
1007 1019
 							"subject" => __("[tt-rss] Password reset request"),
1008 1020
 							"message" => $message]);
1009 1021
 
1010
-						if (!$rc) print_error($mailer->error());
1022
+						if (!$rc) {
1023
+							print_error($mailer->error());
1024
+						}
1011 1025
 
1012 1026
 						$resetpass_token_full = time() . ":" . $resetpass_token;
1013 1027
 
Please login to merge, or discard this patch.
classes/feedparser.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		if ($error) {
27 27
 			foreach (libxml_get_errors() as $error) {
28 28
 				if ($error->level == LIBXML_ERR_FATAL) {
29
-					if(!isset($this->error)) //currently only the first error is reported
29
+					if (!isset($this->error)) //currently only the first error is reported
30 30
 						$this->error = $this->format_error($error);
31 31
 					$this->libxml_errors [] = $this->format_error($error);
32 32
 				}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 					$this->type = $this::FEED_ATOM;
70 70
 					break;
71 71
 				default:
72
-					if( !isset($this->error) ){
72
+					if (!isset($this->error)) {
73 73
 						$this->error = "Unknown/unsupported feed type";
74 74
 					}
75 75
 					return;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 			if ($this->link) $this->link = trim($this->link);
167 167
 
168 168
 		} else {
169
-			if( !isset($this->error) ){
169
+			if (!isset($this->error)) {
170 170
 				$this->error = "Unknown/unsupported feed type";
171 171
 			}
172 172
 			return;
Please login to merge, or discard this patch.
Braces   +29 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,8 +26,10 @@  discard block
 block discarded – undo
26 26
 		if ($error) {
27 27
 			foreach (libxml_get_errors() as $error) {
28 28
 				if ($error->level == LIBXML_ERR_FATAL) {
29
-					if(!isset($this->error)) //currently only the first error is reported
29
+					if(!isset($this->error)) {
30
+						//currently only the first error is reported
30 31
 						$this->error = $this->format_error($error);
32
+					}
31 33
 					$this->libxml_errors [] = $this->format_error($error);
32 34
 				}
33 35
 			}
@@ -81,8 +83,9 @@  discard block
 block discarded – undo
81 83
 
82 84
 				$title = $xpath->query("//atom:feed/atom:title")->item(0);
83 85
 
84
-				if (!$title)
85
-					$title = $xpath->query("//atom03:feed/atom03:title")->item(0);
86
+				if (!$title) {
87
+									$title = $xpath->query("//atom03:feed/atom03:title")->item(0);
88
+				}
86 89
 
87 90
 
88 91
 				if ($title) {
@@ -91,14 +94,17 @@  discard block
 block discarded – undo
91 94
 
92 95
 				$link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
93 96
 
94
-				if (!$link)
95
-					$link = $xpath->query("//atom:feed/atom:link[@rel='alternate']")->item(0);
97
+				if (!$link) {
98
+									$link = $xpath->query("//atom:feed/atom:link[@rel='alternate']")->item(0);
99
+				}
96 100
 
97
-				if (!$link)
98
-					$link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
101
+				if (!$link) {
102
+									$link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
103
+				}
99 104
 
100
-				if (!$link)
101
-					$link = $xpath->query("//atom03:feed/atom03:link[@rel='alternate']")->item(0);
105
+				if (!$link) {
106
+									$link = $xpath->query("//atom03:feed/atom03:link[@rel='alternate']")->item(0);
107
+				}
102 108
 
103 109
 				if ($link && $link->hasAttributes()) {
104 110
 					$this->link = $link->getAttribute("href");
@@ -106,8 +112,9 @@  discard block
 block discarded – undo
106 112
 
107 113
 				$articles = $xpath->query("//atom:entry");
108 114
 
109
-				if (!$articles || $articles->length == 0)
110
-					$articles = $xpath->query("//atom03:entry");
115
+				if (!$articles || $articles->length == 0) {
116
+									$articles = $xpath->query("//atom03:entry");
117
+				}
111 118
 
112 119
 				foreach ($articles as $article) {
113 120
 					array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
@@ -124,10 +131,11 @@  discard block
 block discarded – undo
124 131
 				$link = $xpath->query("//channel/link")->item(0);
125 132
 
126 133
 				if ($link) {
127
-					if ($link->getAttribute("href"))
128
-						$this->link = $link->getAttribute("href");
129
-					else if ($link->nodeValue)
130
-						$this->link = $link->nodeValue;
134
+					if ($link->getAttribute("href")) {
135
+											$this->link = $link->getAttribute("href");
136
+					} else if ($link->nodeValue) {
137
+											$this->link = $link->nodeValue;
138
+					}
131 139
 				}
132 140
 
133 141
 				$articles = $xpath->query("//channel/item");
@@ -162,8 +170,12 @@  discard block
 block discarded – undo
162 170
 
163 171
 			}
164 172
 
165
-			if ($this->title) $this->title = trim($this->title);
166
-			if ($this->link) $this->link = trim($this->link);
173
+			if ($this->title) {
174
+				$this->title = trim($this->title);
175
+			}
176
+			if ($this->link) {
177
+				$this->link = trim($this->link);
178
+			}
167 179
 
168 180
 		} else {
169 181
 			if( !isset($this->error) ){
Please login to merge, or discard this patch.
classes/opml.php 3 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -202,36 +202,36 @@  discard block
 block discarded – undo
202 202
 					$cat_filter = $tmp_line["cat_filter"];
203 203
 
204 204
 					if (!$tmp_line["match_on"]) {
205
-                        if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
206
-                            $tmp_line["feed"] = Feeds::getFeedTitle(
207
-                                $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
208
-                                $cat_filter);
209
-                        } else {
210
-                            $tmp_line["feed"] = "";
211
-                        }
212
-                    } else {
213
-					    $match = [];
214
-					    foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
215
-
216
-                            if (strpos($feed_id, "CAT:") === 0) {
217
-                                $feed_id = (int)substr($feed_id, 4);
218
-                                if ($feed_id) {
219
-                                    array_push($match, [Feeds::getCategoryTitle($feed_id), true, false]);
220
-                                } else {
221
-                                    array_push($match, [0, true, true]);
222
-                                }
223
-                            } else {
224
-                                if ($feed_id) {
225
-                                    array_push($match, [Feeds::getFeedTitle((int)$feed_id), false, false]);
226
-                                } else {
227
-                                    array_push($match, [0, false, true]);
228
-                                }
229
-                            }
230
-                        }
231
-
232
-                        $tmp_line["match"] = $match;
233
-					    unset($tmp_line["match_on"]);
234
-                    }
205
+						if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
206
+							$tmp_line["feed"] = Feeds::getFeedTitle(
207
+								$cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
208
+								$cat_filter);
209
+						} else {
210
+							$tmp_line["feed"] = "";
211
+						}
212
+					} else {
213
+						$match = [];
214
+						foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
215
+
216
+							if (strpos($feed_id, "CAT:") === 0) {
217
+								$feed_id = (int)substr($feed_id, 4);
218
+								if ($feed_id) {
219
+									array_push($match, [Feeds::getCategoryTitle($feed_id), true, false]);
220
+								} else {
221
+									array_push($match, [0, true, true]);
222
+								}
223
+							} else {
224
+								if ($feed_id) {
225
+									array_push($match, [Feeds::getFeedTitle((int)$feed_id), false, false]);
226
+								} else {
227
+									array_push($match, [0, false, true]);
228
+								}
229
+							}
230
+						}
231
+
232
+						$tmp_line["match"] = $match;
233
+						unset($tmp_line["match_on"]);
234
+					}
235 235
 
236 236
 					unset($tmp_line["feed_id"]);
237 237
 					unset($tmp_line["cat_id"]);
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
 
404 404
 						if ($rule["match"]) {
405 405
 
406
-                            $match_on = [];
406
+							$match_on = [];
407 407
 
408
-						    foreach ($rule["match"] as $match) {
409
-						        list ($name, $is_cat, $is_id) = $match;
408
+							foreach ($rule["match"] as $match) {
409
+								list ($name, $is_cat, $is_id) = $match;
410 410
 
411
-						        if ($is_id) {
412
-						            array_push($match_on, ($is_cat ? "CAT:" : "") . $name);
413
-                                } else {
411
+								if ($is_id) {
412
+									array_push($match_on, ($is_cat ? "CAT:" : "") . $name);
413
+								} else {
414 414
 
415
-                                    if (!$is_cat) {
416
-                                        $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
415
+									if (!$is_cat) {
416
+										$tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
417 417
                                     		WHERE title = ? AND owner_uid = ?");
418 418
 
419
-                                        $tsth->execute([$name, $_SESSION['uid']]);
419
+										$tsth->execute([$name, $_SESSION['uid']]);
420 420
 
421
-                                        if ($row = $tsth->fetch()) {
422
-                                            $match_id = $row['id'];
421
+										if ($row = $tsth->fetch()) {
422
+											$match_id = $row['id'];
423 423
 
424 424
 											array_push($match_on, $match_id);
425
-                                        }
426
-                                    } else {
427
-                                        $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
425
+										}
426
+									} else {
427
+										$tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
428 428
                                     		WHERE title = ? AND owner_uid = ?");
429 429
 										$tsth->execute([$name, $_SESSION['uid']]);
430 430
 
@@ -433,33 +433,33 @@  discard block
 block discarded – undo
433 433
 
434 434
 											array_push($match_on, "CAT:$match_id");
435 435
 										}
436
-                                    }
437
-                                }
438
-                            }
436
+									}
437
+								}
438
+							}
439 439
 
440
-                            $reg_exp = $rule["reg_exp"];
441
-                            $filter_type = (int)$rule["filter_type"];
442
-                            $inverse = bool_to_sql_bool($rule["inverse"]);
443
-                            $match_on = json_encode($match_on);
440
+							$reg_exp = $rule["reg_exp"];
441
+							$filter_type = (int)$rule["filter_type"];
442
+							$inverse = bool_to_sql_bool($rule["inverse"]);
443
+							$match_on = json_encode($match_on);
444 444
 
445
-                            $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
445
+							$usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
446 446
 								(feed_id,cat_id,match_on,filter_id,filter_type,reg_exp,cat_filter,inverse)
447 447
                                 VALUES
448 448
                                 (NULL, NULL, ?, ?, ?, ?, false, ?)");
449
-                            $usth->execute([$match_on, $filter_id, $filter_type, $reg_exp, $inverse]);
449
+							$usth->execute([$match_on, $filter_id, $filter_type, $reg_exp, $inverse]);
450 450
 
451
-                        } else {
451
+						} else {
452 452
 
453
-                            if (!$rule["cat_filter"]) {
454
-                                $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
453
+							if (!$rule["cat_filter"]) {
454
+								$tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
455 455
                                     WHERE title = ? AND owner_uid = ?");
456 456
 
457
-                                $tsth->execute([$rule['feed'], $_SESSION['uid']]);
457
+								$tsth->execute([$rule['feed'], $_SESSION['uid']]);
458 458
 
459
-                                if ($row = $tsth->fetch()) {
460
-                                    $feed_id = $row['id'];
461
-                                }
462
-                            } else {
459
+								if ($row = $tsth->fetch()) {
460
+									$feed_id = $row['id'];
461
+								}
462
+							} else {
463 463
 								$tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
464 464
                                     WHERE title = ? AND owner_uid = ?");
465 465
 
@@ -468,19 +468,19 @@  discard block
 block discarded – undo
468 468
 								if ($row = $tsth->fetch()) {
469 469
 									$feed_id = $row['id'];
470 470
 								}
471
-                            }
471
+							}
472 472
 
473
-                            $cat_filter = bool_to_sql_bool($rule["cat_filter"]);
474
-                            $reg_exp = $rule["reg_exp"];
475
-                            $filter_type = (int)$rule["filter_type"];
476
-                            $inverse = bool_to_sql_bool($rule["inverse"]);
473
+							$cat_filter = bool_to_sql_bool($rule["cat_filter"]);
474
+							$reg_exp = $rule["reg_exp"];
475
+							$filter_type = (int)$rule["filter_type"];
476
+							$inverse = bool_to_sql_bool($rule["inverse"]);
477 477
 
478
-                            $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
478
+							$usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
479 479
 								(feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter,inverse)
480 480
                                 VALUES
481 481
                                 (?, ?, ?, ?, ?, ?, ?)");
482
-                            $usth->execute([$feed_id, $cat_id, $filter_id, $filter_type, $reg_exp, $cat_filter, $inverse]);
483
-                        }
482
+							$usth->execute([$feed_id, $cat_id, $filter_id, $filter_type, $reg_exp, $cat_filter, $inverse]);
483
+						}
484 484
 					}
485 485
 
486 486
 					foreach ($filter["actions"] as $action) {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			$cat_title = htmlspecialchars($row['title']);
71 71
 
72 72
 			if ($include_settings) {
73
-				$order_id = (int)$row["order_id"];
73
+				$order_id = (int) $row["order_id"];
74 74
 				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\"";
75 75
 			}
76 76
 		} else {
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 			$site_url = htmlspecialchars($fline["site_url"]);
104 104
 
105 105
 			if ($include_settings) {
106
-				$update_interval = (int)$fline["update_interval"];
107
-				$order_id = (int)$fline["order_id"];
106
+				$update_interval = (int) $fline["update_interval"];
107
+				$order_id = (int) $fline["order_id"];
108 108
 
109 109
 				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssUpdateInterval=\"$update_interval\"";
110 110
 			} else {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 		if (!isset($_REQUEST["debug"])) {
132 132
 			header("Content-type: application/xml+opml");
133
-			header("Content-Disposition: attachment; filename=" . $name );
133
+			header("Content-Disposition: attachment; filename=".$name);
134 134
 		} else {
135 135
 			header("Content-type: text/xml");
136 136
 		}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$out .= "<opml version=\"1.0\">";
141 141
 		$out .= "<head>
142
-			<dateCreated>" . date("r", time()) . "</dateCreated>
142
+			<dateCreated>" . date("r", time())."</dateCreated>
143 143
 			<title>Tiny Tiny RSS Feed Export</title>
144 144
 		</head>";
145 145
 		$out .= "<body>";
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 					    foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
215 215
 
216 216
                             if (strpos($feed_id, "CAT:") === 0) {
217
-                                $feed_id = (int)substr($feed_id, 4);
217
+                                $feed_id = (int) substr($feed_id, 4);
218 218
                                 if ($feed_id) {
219 219
                                     array_push($match, [Feeds::getCategoryTitle($feed_id), true, false]);
220 220
                                 } else {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                                 }
223 223
                             } else {
224 224
                                 if ($feed_id) {
225
-                                    array_push($match, [Feeds::getFeedTitle((int)$feed_id), false, false]);
225
+                                    array_push($match, [Feeds::getFeedTitle((int) $feed_id), false, false]);
226 226
                                 } else {
227 227
                                     array_push($match, [0, false, true]);
228 228
                                 }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 						        list ($name, $is_cat, $is_id) = $match;
410 410
 
411 411
 						        if ($is_id) {
412
-						            array_push($match_on, ($is_cat ? "CAT:" : "") . $name);
412
+						            array_push($match_on, ($is_cat ? "CAT:" : "").$name);
413 413
                                 } else {
414 414
 
415 415
                                     if (!$is_cat) {
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
                             }
439 439
 
440 440
                             $reg_exp = $rule["reg_exp"];
441
-                            $filter_type = (int)$rule["filter_type"];
441
+                            $filter_type = (int) $rule["filter_type"];
442 442
                             $inverse = bool_to_sql_bool($rule["inverse"]);
443 443
                             $match_on = json_encode($match_on);
444 444
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 
473 473
                             $cat_filter = bool_to_sql_bool($rule["cat_filter"]);
474 474
                             $reg_exp = $rule["reg_exp"];
475
-                            $filter_type = (int)$rule["filter_type"];
475
+                            $filter_type = (int) $rule["filter_type"];
476 476
                             $inverse = bool_to_sql_bool($rule["inverse"]);
477 477
 
478 478
                             $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 
486 486
 					foreach ($filter["actions"] as $action) {
487 487
 
488
-						$action_id = (int)$action["action_id"];
488
+						$action_id = (int) $action["action_id"];
489 489
 						$action_param = $action["action_param"];
490 490
 
491 491
 						$usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 		}
586 586
 
587 587
 		if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
588
-			$tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
588
+			$tmp_file = tempnam(CACHE_DIR.'/upload', 'opml');
589 589
 
590 590
 			$result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
591 591
 				$tmp_file);
@@ -623,10 +623,10 @@  discard block
 block discarded – undo
623 623
 		print "$msg<br/>";
624 624
 	}
625 625
 
626
-	static function opml_publish_url(){
626
+	static function opml_publish_url() {
627 627
 
628 628
 		$url_path = get_self_url_prefix();
629
-		$url_path .= "/opml.php?op=publish&key=" .
629
+		$url_path .= "/opml.php?op=publish&key=".
630 630
 			Feeds::get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
631 631
 
632 632
 		return $url_path;
Please login to merge, or discard this patch.
Braces   +47 added lines, -21 removed lines patch added patch discarded remove patch
@@ -52,10 +52,11 @@  discard block
 block discarded – undo
52 52
 
53 53
 		$cat_id = (int) $cat_id;
54 54
 
55
-		if ($hide_private_feeds)
56
-			$hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
-		else
58
-			$hide_qpart = "true";
55
+		if ($hide_private_feeds) {
56
+					$hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
+		} else {
58
+					$hide_qpart = "true";
59
+		}
59 60
 
60 61
 		$out = "";
61 62
 
@@ -77,7 +78,9 @@  discard block
 block discarded – undo
77 78
 			$cat_title = "";
78 79
 		}
79 80
 
80
-		if ($cat_title) $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
81
+		if ($cat_title) {
82
+			$out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
83
+		}
81 84
 
82 85
 		$sth = $this->pdo->prepare("SELECT id,title
83 86
 			FROM ttrss_feed_categories WHERE
@@ -120,13 +123,17 @@  discard block
 block discarded – undo
120 123
 			$out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $ttrss_specific_qpart $html_url_qpart/>\n";
121 124
 		}
122 125
 
123
-		if ($cat_title) $out .= "</outline>\n";
126
+		if ($cat_title) {
127
+			$out .= "</outline>\n";
128
+		}
124 129
 
125 130
 		return $out;
126 131
 	}
127 132
 
128 133
 	function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) {
129
-		if (!$owner_uid) return;
134
+		if (!$owner_uid) {
135
+			return;
136
+		}
130 137
 
131 138
 		if (!isset($_REQUEST["debug"])) {
132 139
 			header("Content-type: application/xml+opml");
@@ -275,8 +282,9 @@  discard block
 block discarded – undo
275 282
 
276 283
 		// cleanup empty categories
277 284
 		foreach ($outlines as $node) {
278
-			if ($node->getElementsByTagName('outline')->length == 0)
279
-				$node->parentNode->removeChild($node);
285
+			if ($node->getElementsByTagName('outline')->length == 0) {
286
+							$node->parentNode->removeChild($node);
287
+			}
280 288
 		}
281 289
 
282 290
 		$res = $doc->saveXML();
@@ -297,10 +305,14 @@  discard block
 block discarded – undo
297 305
 		$attrs = $node->attributes;
298 306
 
299 307
 		$feed_title = mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250);
300
-		if (!$feed_title) $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
308
+		if (!$feed_title) {
309
+			$feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
310
+		}
301 311
 
302 312
 		$feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
303
-		if (!$feed_url) $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
313
+		if (!$feed_url) {
314
+			$feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
315
+		}
304 316
 
305 317
 		$site_url = mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250);
306 318
 
@@ -309,19 +321,27 @@  discard block
 block discarded – undo
309 321
 				feed_url = ? AND owner_uid = ?");
310 322
 			$sth->execute([$feed_url, $owner_uid]);
311 323
 
312
-			if (!$feed_title) $feed_title = '[Unknown]';
324
+			if (!$feed_title) {
325
+				$feed_title = '[Unknown]';
326
+			}
313 327
 
314 328
 			if (!$sth->fetch()) {
315 329
 				#$this->opml_notice("[FEED] [$feed_title/$feed_url] dst_CAT=$cat_id");
316 330
 				$this->opml_notice(T_sprintf("Adding feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
317 331
 
318
-				if (!$cat_id) $cat_id = null;
332
+				if (!$cat_id) {
333
+					$cat_id = null;
334
+				}
319 335
 
320 336
 				$update_interval = (int) $attrs->getNamedItem('ttrssUpdateInterval')->nodeValue;
321
-				if (!$update_interval) $update_interval = 0;
337
+				if (!$update_interval) {
338
+					$update_interval = 0;
339
+				}
322 340
 
323 341
 				$order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue;
324
-				if (!$order_id) $order_id = 0;
342
+				if (!$order_id) {
343
+					$order_id = 0;
344
+				}
325 345
 
326 346
 				$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
327 347
 					(title, feed_url, owner_uid, cat_id, site_url, order_id, update_interval) VALUES
@@ -505,15 +525,18 @@  discard block
 block discarded – undo
505 525
 		if ($root_node) {
506 526
 			$cat_title = mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250);
507 527
 
508
-			if (!$cat_title)
509
-				$cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
528
+			if (!$cat_title) {
529
+							$cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
530
+			}
510 531
 
511 532
 			if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
512 533
 				$cat_id = $this->get_feed_category($cat_title, $parent_id);
513 534
 
514 535
 				if ($cat_id === false) {
515 536
 					$order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue;
516
-					if (!$order_id) $order_id = 0;
537
+					if (!$order_id) {
538
+						$order_id = 0;
539
+					}
517 540
 
518 541
 					Feeds::add_feed_category($cat_title, $parent_id, $order_id);
519 542
 					$cat_id = $this->get_feed_category($cat_title, $parent_id);
@@ -540,8 +563,9 @@  discard block
 block discarded – undo
540 563
 				$attrs = $node->attributes;
541 564
 				$node_cat_title = $attrs->getNamedItem('text')->nodeValue;
542 565
 
543
-				if (!$node_cat_title)
544
-					$node_cat_title = $attrs->getNamedItem('title')->nodeValue;
566
+				if (!$node_cat_title) {
567
+									$node_cat_title = $attrs->getNamedItem('title')->nodeValue;
568
+				}
545 569
 
546 570
 				$node_feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
547 571
 
@@ -574,7 +598,9 @@  discard block
 block discarded – undo
574 598
 	}
575 599
 
576 600
 	function opml_import($owner_uid) {
577
-		if (!$owner_uid) return;
601
+		if (!$owner_uid) {
602
+			return;
603
+		}
578 604
 
579 605
 		$doc = false;
580 606
 
Please login to merge, or discard this patch.