Passed
Push — master ( a3c0d0...678db7 )
by Cody
06:27 queued 03:12
created
plugins/af_comics/init.php 1 patch
Braces   +25 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	public function hook_prefs_tab($args) {
48
-		if ($args != "prefFeeds") return;
48
+		if ($args != "prefFeeds") {
49
+		    return;
50
+		}
49 51
 
50 52
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
51 53
 			title=\"<i class='material-icons'>photo</i> ".__('Feeds supported by af_comics')."\">";
@@ -77,8 +79,9 @@  discard block
 block discarded – undo
77 79
 
78 80
 	public function hook_article_filter($article) {
79 81
 		foreach ($this->filters as $f) {
80
-			if ($f->process($article))
81
-				break;
82
+			if ($f->process($article)) {
83
+							break;
84
+			}
82 85
 		}
83 86
 
84 87
 		return $article;
@@ -89,8 +92,9 @@  discard block
 block discarded – undo
89 92
 	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
90 93
 	 */
91 94
 	public function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) {
92
-		if ($auth_login || $auth_pass)
93
-			return $feed_data;
95
+		if ($auth_login || $auth_pass) {
96
+					return $feed_data;
97
+		}
94 98
 
95 99
 		if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) {
96 100
 			$site_url = 'https://www.gocomics.com/' . $comic[1];
@@ -153,29 +157,35 @@  discard block
 block discarded – undo
153 157
 
154 158
 			$tpl->addBlock('feed');
155 159
 
156
-			if ($tpl->generateOutputToString($tmp_data))
157
-				$feed_data = $tmp_data;
160
+			if ($tpl->generateOutputToString($tmp_data)) {
161
+							$feed_data = $tmp_data;
162
+			}
158 163
 		}
159 164
 
160 165
 		return $feed_data;
161 166
 	}
162 167
 
163 168
 	public function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) {
164
-		if ($auth_login || $auth_pass)
165
-			return $contents;
169
+		if ($auth_login || $auth_pass) {
170
+					return $contents;
171
+		}
166 172
 
167
-		if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url))
168
-			return '<?xml version="1.0" encoding="utf-8"?>'; // Get is_html() to return false.
173
+		if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) {
174
+					return '<?xml version="1.0" encoding="utf-8"?>';
175
+		}
176
+		// Get is_html() to return false.
169 177
 
170 178
 		return $contents;
171 179
 	}
172 180
 
173 181
 	public function hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed, $auth_login, $auth_pass) {
174
-		if ($auth_login || $auth_pass)
175
-			return $basic_info;
182
+		if ($auth_login || $auth_pass) {
183
+					return $basic_info;
184
+		}
176 185
 
177
-		if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches))
178
-			$basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]);
186
+		if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches)) {
187
+					$basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]);
188
+		}
179 189
 
180 190
 		return $basic_info;
181 191
 	}
Please login to merge, or discard this patch.
plugins/af_proxy_http/init.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -200,13 +200,17 @@
 block discarded – undo
200 200
 			}
201 201
 		}
202 202
 
203
-		if ($need_saving) $article["content"] = $doc->saveHTML();
203
+		if ($need_saving) {
204
+		    $article["content"] = $doc->saveHTML();
205
+		}
204 206
 
205 207
 		return $article;
206 208
 	}
207 209
 
208 210
 	public function hook_prefs_tab($args) {
209
-		if ($args != "prefFeeds") return;
211
+		if ($args != "prefFeeds") {
212
+		    return;
213
+		}
210 214
 
211 215
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
212 216
 			title=\"<i class='material-icons'>extension</i> ".__('Image proxy settings (af_proxy_http)')."\">";
Please login to merge, or discard this patch.
plugins/search_sphinx/sphinxapi.php 1 patch
Braces   +241 added lines, -134 removed lines patch added patch discarded remove patch
@@ -133,14 +133,16 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	// x32, int
136
-	if ( is_int($v) )
137
-		return pack ( "NN", $v < 0 ? -1 : 0, $v );
136
+	if ( is_int($v) ) {
137
+			return pack ( "NN", $v < 0 ? -1 : 0, $v );
138
+	}
138 139
 
139 140
 	// x32, bcmath
140 141
 	if ( function_exists("bcmul") )
141 142
 	{
142
-		if ( bccomp ( $v, 0 ) == -1 )
143
-			$v = bcadd ( "18446744073709551616", $v );
143
+		if ( bccomp ( $v, 0 ) == -1 ) {
144
+					$v = bcadd ( "18446744073709551616", $v );
145
+		}
144 146
 		$h = bcdiv ( $v, "4294967296", 0 );
145 147
 		$l = bcmod ( $v, "4294967296" );
146 148
 		return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit
@@ -158,9 +160,9 @@  discard block
 block discarded – undo
158 160
 
159 161
 	if ( $v<0 )
160 162
 	{
161
-		if ( $l==0 )
162
-			$h = 4294967296.0 - $h;
163
-		else
163
+		if ( $l==0 ) {
164
+					$h = 4294967296.0 - $h;
165
+		} else
164 166
 		{
165 167
 			$h = 4294967295.0 - $h;
166 168
 			$l = 4294967296.0 - $l;
@@ -180,8 +182,9 @@  discard block
 block discarded – undo
180 182
 		assert ( $v>=0 );
181 183
 
182 184
 		// x64, int
183
-		if ( is_int($v) )
184
-			return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
185
+		if ( is_int($v) ) {
186
+					return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
187
+		}
185 188
 
186 189
 		// x64, bcmath
187 190
 		if ( function_exists("bcmul") )
@@ -204,8 +207,9 @@  discard block
 block discarded – undo
204 207
 	}
205 208
 
206 209
 	// x32, int
207
-	if ( is_int($v) )
208
-		return pack ( "NN", 0, $v );
210
+	if ( is_int($v) ) {
211
+			return pack ( "NN", 0, $v );
212
+	}
209 213
 
210 214
 	// x32, bcmath
211 215
 	if ( function_exists("bcmul") )
@@ -235,16 +239,23 @@  discard block
 block discarded – undo
235 239
 
236 240
 	if ( PHP_INT_SIZE>=8 )
237 241
 	{
238
-		if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again
239
-		if ( $lo<0 ) $lo += (1<<32);
242
+		if ( $hi<0 ) {
243
+		    $hi += (1<<32);
244
+		}
245
+		// because php 5.2.2 to 5.2.5 is totally fucked up again
246
+		if ( $lo<0 ) {
247
+		    $lo += (1<<32);
248
+		}
240 249
 
241 250
 		// x64, int
242
-		if ( $hi<=2147483647 )
243
-			return ($hi<<32) + $lo;
251
+		if ( $hi<=2147483647 ) {
252
+					return ($hi<<32) + $lo;
253
+		}
244 254
 
245 255
 		// x64, bcmath
246
-		if ( function_exists("bcmul") )
247
-			return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
256
+		if ( function_exists("bcmul") ) {
257
+					return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
258
+		}
248 259
 
249 260
 		// x64, no-bcmath
250 261
 		$C = 100000;
@@ -256,16 +267,18 @@  discard block
 block discarded – undo
256 267
 			$l  = $l % $C;
257 268
 		}
258 269
 
259
-		if ( $h==0 )
260
-			return $l;
270
+		if ( $h==0 ) {
271
+					return $l;
272
+		}
261 273
 		return sprintf ( "%d%05d", $h, $l );
262 274
 	}
263 275
 
264 276
 	// x32, int
265 277
 	if ( $hi==0 )
266 278
 	{
267
-		if ( $lo>0 )
268
-			return $lo;
279
+		if ( $lo>0 ) {
280
+					return $lo;
281
+		}
269 282
 		return sprintf ( "%u", $lo );
270 283
 	}
271 284
 
@@ -273,8 +286,9 @@  discard block
 block discarded – undo
273 286
 	$lo = sprintf ( "%u", $lo );
274 287
 
275 288
 	// x32, bcmath
276
-	if ( function_exists("bcmul") )
277
-		return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
289
+	if ( function_exists("bcmul") ) {
290
+			return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
291
+	}
278 292
 
279 293
 	// x32, no-bcmath
280 294
 	$hi = (float)$hi;
@@ -289,8 +303,9 @@  discard block
 block discarded – undo
289 303
 
290 304
 	$h = sprintf ( "%.0f", $h );
291 305
 	$l = sprintf ( "%07.0f", $l );
292
-	if ( $h=="0" )
293
-		return sprintf( "%.0f", (float)$l );
306
+	if ( $h=="0" ) {
307
+			return sprintf( "%.0f", (float)$l );
308
+	}
294 309
 	return $h . $l;
295 310
 }
296 311
 
@@ -302,8 +317,13 @@  discard block
 block discarded – undo
302 317
 	// x64
303 318
 	if ( PHP_INT_SIZE>=8 )
304 319
 	{
305
-		if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again
306
-		if ( $lo<0 ) $lo += (1<<32);
320
+		if ( $hi<0 ) {
321
+		    $hi += (1<<32);
322
+		}
323
+		// because php 5.2.2 to 5.2.5 is totally fucked up again
324
+		if ( $lo<0 ) {
325
+		    $lo += (1<<32);
326
+		}
307 327
 
308 328
 		return ($hi<<32) + $lo;
309 329
 	}
@@ -311,15 +331,17 @@  discard block
 block discarded – undo
311 331
 	// x32, int
312 332
 	if ( $hi==0 )
313 333
 	{
314
-		if ( $lo>0 )
315
-			return $lo;
334
+		if ( $lo>0 ) {
335
+					return $lo;
336
+		}
316 337
 		return sprintf ( "%u", $lo );
317 338
 	}
318 339
 	// x32, int
319 340
 	elseif ( $hi==-1 )
320 341
 	{
321
-		if ( $lo<0 )
322
-			return $lo;
342
+		if ( $lo<0 ) {
343
+					return $lo;
344
+		}
323 345
 		return sprintf ( "%.0f", $lo - 4294967296.0 );
324 346
 	}
325 347
 
@@ -337,8 +359,9 @@  discard block
 block discarded – undo
337 359
 	$lo = sprintf ( "%u", $lo );
338 360
 
339 361
 	// x32, bcmath
340
-	if ( function_exists("bcmul") )
341
-		return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c );
362
+	if ( function_exists("bcmul") ) {
363
+			return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c );
364
+	}
342 365
 
343 366
 	// x32, no-bcmath
344 367
 	$hi = (float)$hi;
@@ -358,8 +381,9 @@  discard block
 block discarded – undo
358 381
 
359 382
 	$h = sprintf ( "%.0f", $h );
360 383
 	$l = sprintf ( "%07.0f", $l );
361
-	if ( $h=="0" )
362
-		return $neg . sprintf( "%.0f", (float)$l );
384
+	if ( $h=="0" ) {
385
+			return $neg . sprintf( "%.0f", (float)$l );
386
+	}
363 387
 	return $neg . $h . $l;
364 388
 }
365 389
 
@@ -369,10 +393,11 @@  discard block
 block discarded – undo
369 393
 	if ( PHP_INT_SIZE>=8 )
370 394
 	{
371 395
 		// x64 route, workaround broken unpack() in 5.2.2+
372
-		if ( $value<0 ) $value += (1<<32);
396
+		if ( $value<0 ) {
397
+		    $value += (1<<32);
398
+		}
373 399
 		return $value;
374
-	}
375
-	else
400
+	} else
376 401
 	{
377 402
 		// x32 route, workaround php signed/unsigned braindamage
378 403
 		return sprintf ( "%u", $value );
@@ -470,8 +495,9 @@  discard block
 block discarded – undo
470 495
 
471 496
 	public function __destruct()
472 497
 	{
473
-		if ( $this->_socket !== false )
474
-			fclose ( $this->_socket );
498
+		if ( $this->_socket !== false ) {
499
+					fclose ( $this->_socket );
500
+		}
475 501
 	}
476 502
 
477 503
 	/// get last error message (string)
@@ -549,8 +575,9 @@  discard block
 block discarded – undo
549 575
 	/// leave mbstring workaround mode
550 576
 	public function _MBPop ()
551 577
 	{
552
-		if ( $this->_mbenc )
553
-			mb_internal_encoding ( $this->_mbenc );
578
+		if ( $this->_mbenc ) {
579
+					mb_internal_encoding ( $this->_mbenc );
580
+		}
554 581
 	}
555 582
 
556 583
 	/// connect to searchd server
@@ -560,8 +587,9 @@  discard block
 block discarded – undo
560 587
 		{
561 588
 			// we are in persistent connection mode, so we have a socket
562 589
 			// however, need to check whether it's still alive
563
-			if ( !@feof ( $this->_socket ) )
564
-				return $this->_socket;
590
+			if ( !@feof ( $this->_socket ) ) {
591
+							return $this->_socket;
592
+			}
565 593
 
566 594
 			// force reopen
567 595
 			$this->_socket = false;
@@ -575,24 +603,25 @@  discard block
 block discarded – undo
575 603
 		{
576 604
 			$host = $this->_path;
577 605
 			$port = 0;
578
-		}
579
-		else
606
+		} else
580 607
 		{
581 608
 			$host = $this->_host;
582 609
 			$port = $this->_port;
583 610
 		}
584 611
 
585
-		if ( $this->_timeout<=0 )
586
-			$fp = @fsockopen ( $host, $port, $errno, $errstr );
587
-		else
588
-			$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
612
+		if ( $this->_timeout<=0 ) {
613
+					$fp = @fsockopen ( $host, $port, $errno, $errstr );
614
+		} else {
615
+					$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
616
+		}
589 617
 
590 618
 		if ( !$fp )
591 619
 		{
592
-			if ( $this->_path )
593
-				$location = $this->_path;
594
-			else
595
-				$location = "{$this->_host}:{$this->_port}";
620
+			if ( $this->_path ) {
621
+							$location = $this->_path;
622
+			} else {
623
+							$location = "{$this->_host}:{$this->_port}";
624
+			}
596 625
 
597 626
 			$errstr = trim ( $errstr );
598 627
 			$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
@@ -645,8 +674,9 @@  discard block
 block discarded – undo
645 674
 				}
646 675
 			}
647 676
 		}
648
-		if ( $this->_socket === false )
649
-			fclose ( $fp );
677
+		if ( $this->_socket === false ) {
678
+					fclose ( $fp );
679
+		}
650 680
 
651 681
 		// check response
652 682
 		$read = strlen ( $response );
@@ -706,10 +736,12 @@  discard block
 block discarded – undo
706 736
 		assert ( $max>=0 );
707 737
 		$this->_offset = $offset;
708 738
 		$this->_limit = $limit;
709
-		if ( $max>0 )
710
-			$this->_maxmatches = $max;
711
-		if ( $cutoff>0 )
712
-			$this->_cutoff = $cutoff;
739
+		if ( $max>0 ) {
740
+					$this->_maxmatches = $max;
741
+		}
742
+		if ( $cutoff>0 ) {
743
+					$this->_cutoff = $cutoff;
744
+		}
713 745
 	}
714 746
 
715 747
 	/// set maximum query time, in milliseconds, per-index
@@ -763,8 +795,9 @@  discard block
 block discarded – undo
763 795
 	public function SetWeights ( $weights )
764 796
 	{
765 797
 		assert ( is_array($weights) );
766
-		foreach ( $weights as $weight )
767
-			assert ( is_int($weight) );
798
+		foreach ( $weights as $weight ) {
799
+					assert ( is_int($weight) );
800
+		}
768 801
 
769 802
 		$this->_weights = $weights;
770 803
 	}
@@ -814,8 +847,9 @@  discard block
 block discarded – undo
814 847
 
815 848
 		if ( is_array($values) && count($values) )
816 849
 		{
817
-			foreach ( $values as $value )
818
-				assert ( is_numeric($value) );
850
+			foreach ( $values as $value ) {
851
+							assert ( is_numeric($value) );
852
+			}
819 853
 
820 854
 			$this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values );
821 855
 		}
@@ -954,15 +988,18 @@  discard block
 block discarded – undo
954 988
 		$results = $this->RunQueries ();
955 989
 		$this->_reqs = array (); // just in case it failed too early
956 990
 
957
-		if ( !is_array($results) )
958
-			return false; // probably network error; error message should be already filled
991
+		if ( !is_array($results) ) {
992
+					return false;
993
+		}
994
+		// probably network error; error message should be already filled
959 995
 
960 996
 		$this->_error = $results[0]["error"];
961 997
 		$this->_warning = $results[0]["warning"];
962
-		if ( $results[0]["status"]==SEARCHD_ERROR )
963
-			return false;
964
-		else
965
-			return $results[0];
998
+		if ( $results[0]["status"]==SEARCHD_ERROR ) {
999
+					return false;
1000
+		} else {
1001
+					return $results[0];
1002
+		}
966 1003
 	}
967 1004
 
968 1005
 	/// helper to pack floats in network byte order
@@ -989,8 +1026,9 @@  discard block
 block discarded – undo
989 1026
 		$req .= pack ( "N", strlen($this->_sortby) ) . $this->_sortby;
990 1027
 		$req .= pack ( "N", strlen($query) ) . $query; // query itself
991 1028
 		$req .= pack ( "N", count($this->_weights) ); // weights
992
-		foreach ( $this->_weights as $weight )
993
-			$req .= pack ( "N", (int)$weight );
1029
+		foreach ( $this->_weights as $weight ) {
1030
+					$req .= pack ( "N", (int)$weight );
1031
+		}
994 1032
 		$req .= pack ( "N", strlen($index) ) . $index; // indexes
995 1033
 		$req .= pack ( "N", 1 ); // id64 range marker
996 1034
 		$req .= sphPackU64 ( $this->_min_id ) . sphPackU64 ( $this->_max_id ); // id64 range
@@ -1005,8 +1043,9 @@  discard block
 block discarded – undo
1005 1043
 			{
1006 1044
 				case SPH_FILTER_VALUES:
1007 1045
 					$req .= pack ( "N", count($filter["values"]) );
1008
-					foreach ( $filter["values"] as $value )
1009
-						$req .= sphPackI64 ( $value );
1046
+					foreach ( $filter["values"] as $value ) {
1047
+											$req .= sphPackI64 ( $value );
1048
+					}
1010 1049
 					break;
1011 1050
 
1012 1051
 				case SPH_FILTER_RANGE:
@@ -1045,16 +1084,18 @@  discard block
 block discarded – undo
1045 1084
 
1046 1085
 		// per-index weights
1047 1086
 		$req .= pack ( "N", count($this->_indexweights) );
1048
-		foreach ( $this->_indexweights as $idx=>$weight )
1049
-			$req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight );
1087
+		foreach ( $this->_indexweights as $idx=>$weight ) {
1088
+					$req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight );
1089
+		}
1050 1090
 
1051 1091
 		// max query time
1052 1092
 		$req .= pack ( "N", $this->_maxquerytime );
1053 1093
 
1054 1094
 		// per-field weights
1055 1095
 		$req .= pack ( "N", count($this->_fieldweights) );
1056
-		foreach ( $this->_fieldweights as $field=>$weight )
1057
-			$req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight );
1096
+		foreach ( $this->_fieldweights as $field=>$weight ) {
1097
+					$req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight );
1098
+		}
1058 1099
 
1059 1100
 		// comment
1060 1101
 		$req .= pack ( "N", strlen($comment) ) . $comment;
@@ -1200,8 +1241,7 @@  discard block
 block discarded – undo
1200 1241
 				{
1201 1242
 					$doc = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8;
1202 1243
 					list(,$weight) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
1203
-				}
1204
-				else
1244
+				} else
1205 1245
 				{
1206 1246
 					list ( $doc, $weight ) = array_values ( unpack ( "N*N*",
1207 1247
 						substr ( $response, $p, 8 ) ) );
@@ -1211,10 +1251,11 @@  discard block
 block discarded – undo
1211 1251
 				$weight = sprintf ( "%u", $weight );
1212 1252
 
1213 1253
 				// create match entry
1214
-				if ( $this->_arrayresult )
1215
-					$result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight );
1216
-				else
1217
-					$result["matches"][$doc]["weight"] = $weight;
1254
+				if ( $this->_arrayresult ) {
1255
+									$result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight );
1256
+				} else {
1257
+									$result["matches"][$doc]["weight"] = $weight;
1258
+				}
1218 1259
 
1219 1260
 				// parse and create attributes
1220 1261
 				$attrvals = array ();
@@ -1257,10 +1298,11 @@  discard block
 block discarded – undo
1257 1298
 					}
1258 1299
 				}
1259 1300
 
1260
-				if ( $this->_arrayresult )
1261
-					$result["matches"][$idx]["attrs"] = $attrvals;
1262
-				else
1263
-					$result["matches"][$doc]["attrs"] = $attrvals;
1301
+				if ( $this->_arrayresult ) {
1302
+									$result["matches"][$idx]["attrs"] = $attrvals;
1303
+				} else {
1304
+									$result["matches"][$doc]["attrs"] = $attrvals;
1305
+				}
1264 1306
 			}
1265 1307
 
1266 1308
 			list ( $total, $total_found, $msecs, $words ) =
@@ -1311,25 +1353,63 @@  discard block
 block discarded – undo
1311 1353
 		// fixup options
1312 1354
 		/////////////////
1313 1355
 
1314
-		if ( !isset($opts["before_match"]) )		$opts["before_match"] = "<b>";
1315
-		if ( !isset($opts["after_match"]) )			$opts["after_match"] = "</b>";
1316
-		if ( !isset($opts["chunk_separator"]) )		$opts["chunk_separator"] = " ... ";
1317
-		if ( !isset($opts["limit"]) )				$opts["limit"] = 256;
1318
-		if ( !isset($opts["limit_passages"]) )		$opts["limit_passages"] = 0;
1319
-		if ( !isset($opts["limit_words"]) )			$opts["limit_words"] = 0;
1320
-		if ( !isset($opts["around"]) )				$opts["around"] = 5;
1321
-		if ( !isset($opts["exact_phrase"]) )		$opts["exact_phrase"] = false;
1322
-		if ( !isset($opts["single_passage"]) )		$opts["single_passage"] = false;
1323
-		if ( !isset($opts["use_boundaries"]) )		$opts["use_boundaries"] = false;
1324
-		if ( !isset($opts["weight_order"]) )		$opts["weight_order"] = false;
1325
-		if ( !isset($opts["query_mode"]) )			$opts["query_mode"] = false;
1326
-		if ( !isset($opts["force_all_words"]) )		$opts["force_all_words"] = false;
1327
-		if ( !isset($opts["start_passage_id"]) )	$opts["start_passage_id"] = 1;
1328
-		if ( !isset($opts["load_files"]) )			$opts["load_files"] = false;
1329
-		if ( !isset($opts["html_strip_mode"]) )		$opts["html_strip_mode"] = "index";
1330
-		if ( !isset($opts["allow_empty"]) )			$opts["allow_empty"] = false;
1331
-		if ( !isset($opts["passage_boundary"]) )	$opts["passage_boundary"] = "none";
1332
-		if ( !isset($opts["emit_zones"]) )			$opts["emit_zones"] = false;
1356
+		if ( !isset($opts["before_match"]) ) {
1357
+		    $opts["before_match"] = "<b>";
1358
+		}
1359
+		if ( !isset($opts["after_match"]) ) {
1360
+		    $opts["after_match"] = "</b>";
1361
+		}
1362
+		if ( !isset($opts["chunk_separator"]) ) {
1363
+		    $opts["chunk_separator"] = " ... ";
1364
+		}
1365
+		if ( !isset($opts["limit"]) ) {
1366
+		    $opts["limit"] = 256;
1367
+		}
1368
+		if ( !isset($opts["limit_passages"]) ) {
1369
+		    $opts["limit_passages"] = 0;
1370
+		}
1371
+		if ( !isset($opts["limit_words"]) ) {
1372
+		    $opts["limit_words"] = 0;
1373
+		}
1374
+		if ( !isset($opts["around"]) ) {
1375
+		    $opts["around"] = 5;
1376
+		}
1377
+		if ( !isset($opts["exact_phrase"]) ) {
1378
+		    $opts["exact_phrase"] = false;
1379
+		}
1380
+		if ( !isset($opts["single_passage"]) ) {
1381
+		    $opts["single_passage"] = false;
1382
+		}
1383
+		if ( !isset($opts["use_boundaries"]) ) {
1384
+		    $opts["use_boundaries"] = false;
1385
+		}
1386
+		if ( !isset($opts["weight_order"]) ) {
1387
+		    $opts["weight_order"] = false;
1388
+		}
1389
+		if ( !isset($opts["query_mode"]) ) {
1390
+		    $opts["query_mode"] = false;
1391
+		}
1392
+		if ( !isset($opts["force_all_words"]) ) {
1393
+		    $opts["force_all_words"] = false;
1394
+		}
1395
+		if ( !isset($opts["start_passage_id"]) ) {
1396
+		    $opts["start_passage_id"] = 1;
1397
+		}
1398
+		if ( !isset($opts["load_files"]) ) {
1399
+		    $opts["load_files"] = false;
1400
+		}
1401
+		if ( !isset($opts["html_strip_mode"]) ) {
1402
+		    $opts["html_strip_mode"] = "index";
1403
+		}
1404
+		if ( !isset($opts["allow_empty"]) ) {
1405
+		    $opts["allow_empty"] = false;
1406
+		}
1407
+		if ( !isset($opts["passage_boundary"]) ) {
1408
+		    $opts["passage_boundary"] = "none";
1409
+		}
1410
+		if ( !isset($opts["emit_zones"]) ) {
1411
+		    $opts["emit_zones"] = false;
1412
+		}
1333 1413
 
1334 1414
 		/////////////////
1335 1415
 		// build request
@@ -1337,15 +1417,33 @@  discard block
 block discarded – undo
1337 1417
 
1338 1418
 		// v.1.2 req
1339 1419
 		$flags = 1; // remove spaces
1340
-		if ( $opts["exact_phrase"] )	$flags |= 2;
1341
-		if ( $opts["single_passage"] )	$flags |= 4;
1342
-		if ( $opts["use_boundaries"] )	$flags |= 8;
1343
-		if ( $opts["weight_order"] )	$flags |= 16;
1344
-		if ( $opts["query_mode"] )		$flags |= 32;
1345
-		if ( $opts["force_all_words"] )	$flags |= 64;
1346
-		if ( $opts["load_files"] )		$flags |= 128;
1347
-		if ( $opts["allow_empty"] )		$flags |= 256;
1348
-		if ( $opts["emit_zones"] )		$flags |= 512;
1420
+		if ( $opts["exact_phrase"] ) {
1421
+		    $flags |= 2;
1422
+		}
1423
+		if ( $opts["single_passage"] ) {
1424
+		    $flags |= 4;
1425
+		}
1426
+		if ( $opts["use_boundaries"] ) {
1427
+		    $flags |= 8;
1428
+		}
1429
+		if ( $opts["weight_order"] ) {
1430
+		    $flags |= 16;
1431
+		}
1432
+		if ( $opts["query_mode"] ) {
1433
+		    $flags |= 32;
1434
+		}
1435
+		if ( $opts["force_all_words"] ) {
1436
+		    $flags |= 64;
1437
+		}
1438
+		if ( $opts["load_files"] ) {
1439
+		    $flags |= 128;
1440
+		}
1441
+		if ( $opts["allow_empty"] ) {
1442
+		    $flags |= 256;
1443
+		}
1444
+		if ( $opts["emit_zones"] ) {
1445
+		    $flags |= 512;
1446
+		}
1349 1447
 		$req = pack ( "NN", 0, $flags ); // mode=0, flags=$flags
1350 1448
 		$req .= pack ( "N", strlen($index) ) . $index; // req index
1351 1449
 		$req .= pack ( "N", strlen($words) ) . $words; // req words
@@ -1512,8 +1610,9 @@  discard block
 block discarded – undo
1512 1610
 		assert ( is_bool($mva) );
1513 1611
 
1514 1612
 		assert ( is_array($attrs) );
1515
-		foreach ( $attrs as $attr )
1516
-			assert ( is_string($attr) );
1613
+		foreach ( $attrs as $attr ) {
1614
+					assert ( is_string($attr) );
1615
+		}
1517 1616
 
1518 1617
 		assert ( is_array($values) );
1519 1618
 		foreach ( $values as $id=>$entry )
@@ -1526,10 +1625,12 @@  discard block
 block discarded – undo
1526 1625
 				if ( $mva )
1527 1626
 				{
1528 1627
 					assert ( is_array($v) );
1529
-					foreach ( $v as $vv )
1530
-						assert ( is_int($vv) );
1531
-				} else
1532
-					assert ( is_int($v) );
1628
+					foreach ( $v as $vv ) {
1629
+											assert ( is_int($vv) );
1630
+					}
1631
+				} else {
1632
+									assert ( is_int($v) );
1633
+				}
1533 1634
 			}
1534 1635
 		}
1535 1636
 
@@ -1551,9 +1652,10 @@  discard block
 block discarded – undo
1551 1652
 			foreach ( $entry as $v )
1552 1653
 			{
1553 1654
 				$req .= pack ( "N", $mva ? count($v) : $v );
1554
-				if ( $mva )
1555
-					foreach ( $v as $vv )
1655
+				if ( $mva ) {
1656
+									foreach ( $v as $vv )
1556 1657
 						$req .= pack ( "N", $vv );
1658
+				}
1557 1659
 			}
1558 1660
 		}
1559 1661
 
@@ -1595,13 +1697,15 @@  discard block
 block discarded – undo
1595 1697
 			$this->_error = 'already connected';
1596 1698
 			return false;
1597 1699
 		}
1598
-		if ( !$fp = $this->_Connect() )
1599
-			return false;
1700
+		if ( !$fp = $this->_Connect() ) {
1701
+					return false;
1702
+		}
1600 1703
 
1601 1704
 		// command, command version = 0, body length = 4, body = 1
1602 1705
 		$req = pack ( "nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1 );
1603
-		if ( !$this->_Send ( $fp, $req, 12 ) )
1604
-			return false;
1706
+		if ( !$this->_Send ( $fp, $req, 12 ) ) {
1707
+					return false;
1708
+		}
1605 1709
 
1606 1710
 		$this->_socket = $fp;
1607 1711
 		return true;
@@ -1647,8 +1751,10 @@  discard block
 block discarded – undo
1647 1751
 		list ( $rows, $cols ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8;
1648 1752
 
1649 1753
 		$res = array();
1650
-		for ( $i=0; $i<$rows; $i++ )
1651
-			for ( $j=0; $j<$cols; $j++ )
1754
+		for ( $i=0; $i<$rows; $i++ ) {
1755
+					for ( $j=0;
1756
+		}
1757
+		$j<$cols; $j++ )
1652 1758
 		{
1653 1759
 			list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
1654 1760
 			$res[$i][] = substr ( $response, $p, $len ); $p += $len;
@@ -1680,10 +1786,11 @@  discard block
 block discarded – undo
1680 1786
 		}
1681 1787
 
1682 1788
 		$tag = -1;
1683
-		if ( strlen($response)==4 )
1684
-			list(,$tag) = unpack ( "N*", $response );
1685
-		else
1686
-			$this->_error = "unexpected response length";
1789
+		if ( strlen($response)==4 ) {
1790
+					list(,$tag) = unpack ( "N*", $response );
1791
+		} else {
1792
+					$this->_error = "unexpected response length";
1793
+		}
1687 1794
 
1688 1795
 		$this->_MBPop ();
1689 1796
 		return $tag;
Please login to merge, or discard this patch.
classes/rssutils.php 1 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/article.php 1 patch
Braces   +90 added lines, -53 removed lines patch added patch discarded remove patch
@@ -57,10 +57,16 @@  discard block
 block discarded – undo
57 57
 
58 58
 		$rc = false;
59 59
 
60
-		if (!$title) $title = $url;
61
-		if (!$title && !$url) return false;
60
+		if (!$title) {
61
+		    $title = $url;
62
+		}
63
+		if (!$title && !$url) {
64
+		    return false;
65
+		}
62 66
 
63
-		if (filter_var($url, FILTER_VALIDATE_URL) === false) return false;
67
+		if (filter_var($url, FILTER_VALIDATE_URL) === false) {
68
+		    return false;
69
+		}
64 70
 
65 71
 		$pdo = Db::pdo();
66 72
 
@@ -271,7 +277,9 @@  discard block
 block discarded – undo
271 277
 		$tags_str = $this->format_tags_string($tags);
272 278
 		$tags_str_full = join(", ", $tags);
273 279
 
274
-		if (!$tags_str_full) $tags_str_full = __("no tags");
280
+		if (!$tags_str_full) {
281
+		    $tags_str_full = __("no tags");
282
+		}
275 283
 
276 284
 		print json_encode([
277 285
 			"id" => (int) $id,
@@ -320,10 +328,11 @@  discard block
 block discarded – undo
320 328
 
321 329
 			foreach ($ids as $id) {
322 330
 
323
-				if ($assign)
324
-					Labels::add_article($id, $label, $_SESSION["uid"]);
325
-				else
326
-					Labels::remove_article($id, $label, $_SESSION["uid"]);
331
+				if ($assign) {
332
+									Labels::add_article($id, $label, $_SESSION["uid"]);
333
+				} else {
334
+									Labels::remove_article($id, $label, $_SESSION["uid"]);
335
+				}
327 336
 
328 337
 				$labels = $this->get_article_labels($id, $_SESSION["uid"]);
329 338
 
@@ -384,14 +393,18 @@  discard block
 block discarded – undo
384 393
 				$width = $line["width"];
385 394
 				$height = $line["height"];
386 395
 
387
-				if (!$ctype) $ctype = __("unknown type");
396
+				if (!$ctype) {
397
+				    $ctype = __("unknown type");
398
+				}
388 399
 
389 400
 				//$filename = substr($url, strrpos($url, "/")+1);
390 401
 				$filename = basename($url);
391 402
 
392 403
 				$player = format_inline_player($url, $ctype);
393 404
 
394
-				if ($player) array_push($entries_inline, $player);
405
+				if ($player) {
406
+				    array_push($entries_inline, $player);
407
+				}
395 408
 
396 409
 #				$entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" .
397 410
 #					$filename . " (" . $ctype . ")" . "</a>";
@@ -419,8 +432,9 @@  discard block
 block discarded – undo
419 432
 
420 433
 					foreach ($entries as $entry) {
421 434
 
422
-						foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin)
423
-							$retval = $plugin->hook_render_enclosure($entry, $hide_images);
435
+						foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) {
436
+													$retval = $plugin->hook_render_enclosure($entry, $hide_images);
437
+						}
424 438
 
425 439
 
426 440
 						if ($retval) {
@@ -431,10 +445,12 @@  discard block
 block discarded – undo
431 445
 
432 446
 								if (!$hide_images) {
433 447
 									$encsize = '';
434
-									if ($entry['height'] > 0)
435
-										$encsize .= ' height="' . intval($entry['height']) . '"';
436
-									if ($entry['width'] > 0)
437
-										$encsize .= ' width="' . intval($entry['width']) . '"';
448
+									if ($entry['height'] > 0) {
449
+																			$encsize .= ' height="' . intval($entry['height']) . '"';
450
+									}
451
+									if ($entry['width'] > 0) {
452
+																			$encsize .= ' width="' . intval($entry['width']) . '"';
453
+									}
438 454
 									$rv .= "<p><img
439 455
 										alt=\"".htmlspecialchars($entry["filename"])."\"
440 456
 										src=\"" .htmlspecialchars($entry["url"]) . "\"
@@ -466,15 +482,17 @@  discard block
 block discarded – undo
466 482
 			$rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
467 483
 
468 484
 			foreach ($entries as $entry) {
469
-				if ($entry["title"])
470
-					$title = " &mdash; " . truncate_string($entry["title"], 30);
471
-				else
472
-					$title = "";
485
+				if ($entry["title"]) {
486
+									$title = " &mdash; " . truncate_string($entry["title"], 30);
487
+				} else {
488
+									$title = "";
489
+				}
473 490
 
474
-				if ($entry["filename"])
475
-					$filename = truncate_middle(htmlspecialchars($entry["filename"]), 60);
476
-				else
477
-					$filename = "";
491
+				if ($entry["filename"]) {
492
+									$filename = truncate_middle(htmlspecialchars($entry["filename"]), 60);
493
+				} else {
494
+									$filename = "";
495
+				}
478 496
 
479 497
 				$rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")'
480 498
 					dojoType=\"dijit.MenuItem\">".$filename . $title."</div>";
@@ -492,7 +510,9 @@  discard block
 block discarded – undo
492 510
 
493 511
 		$a_id = $id;
494 512
 
495
-		if (!$owner_uid) $owner_uid = $_SESSION["uid"];
513
+		if (!$owner_uid) {
514
+		    $owner_uid = $_SESSION["uid"];
515
+		}
496 516
 
497 517
 		$pdo = Db::pdo();
498 518
 
@@ -510,7 +530,9 @@  discard block
 block discarded – undo
510 530
 				WHERE ref_id = ? AND owner_uid = ?");
511 531
 			$csth->execute([$id, $owner_uid]);
512 532
 
513
-			if ($row = $csth->fetch()) $tag_cache = $row["tag_cache"];
533
+			if ($row = $csth->fetch()) {
534
+			    $tag_cache = $row["tag_cache"];
535
+			}
514 536
 		}
515 537
 
516 538
 		if ($tag_cache) {
@@ -551,8 +573,9 @@  discard block
 block discarded – undo
551 573
 
552 574
 			$tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2);
553 575
 
554
-			if (count($tags) > $maxtags)
555
-				$tags_str .= ", &hellip;";
576
+			if (count($tags) > $maxtags) {
577
+							$tags_str .= ", &hellip;";
578
+			}
556 579
 
557 580
 			return $tags_str;
558 581
 		}
@@ -560,7 +583,9 @@  discard block
 block discarded – undo
560 583
 
561 584
 	public static function format_article_labels($labels) {
562 585
 
563
-		if (!is_array($labels)) return '';
586
+		if (!is_array($labels)) {
587
+		    return '';
588
+		}
564 589
 
565 590
 		$labels_str = "";
566 591
 
@@ -618,10 +643,11 @@  discard block
 block discarded – undo
618 643
 
619 644
         // purge orphaned posts in main content table
620 645
 
621
-        if (DB_TYPE == "mysql")
622
-            $limit_qpart = "LIMIT 5000";
623
-        else
624
-            $limit_qpart = "";
646
+        if (DB_TYPE == "mysql") {
647
+                    $limit_qpart = "LIMIT 5000";
648
+        } else {
649
+                    $limit_qpart = "";
650
+        }
625 651
 
626 652
         $pdo = Db::pdo();
627 653
         $res = $pdo->query("DELETE FROM ttrss_entries WHERE
@@ -635,7 +661,9 @@  discard block
 block discarded – undo
635 661
 
636 662
 	public static function catchupArticlesById($ids, $cmode, $owner_uid = false) {
637 663
 
638
-		if (!$owner_uid) $owner_uid = $_SESSION["uid"];
664
+		if (!$owner_uid) {
665
+		    $owner_uid = $_SESSION["uid"];
666
+		}
639 667
 
640 668
 		$pdo = Db::pdo();
641 669
 
@@ -685,7 +713,9 @@  discard block
 block discarded – undo
685 713
 	public static function get_article_labels($id, $owner_uid = false) {
686 714
 		$rv = array();
687 715
 
688
-		if (!$owner_uid) $owner_uid = $_SESSION["uid"];
716
+		if (!$owner_uid) {
717
+		    $owner_uid = $_SESSION["uid"];
718
+		}
689 719
 
690 720
 		$pdo = Db::pdo();
691 721
 
@@ -699,10 +729,11 @@  discard block
 block discarded – undo
699 729
 			if ($label_cache) {
700 730
 				$tmp = json_decode($label_cache, true);
701 731
 
702
-				if (!$tmp || $tmp["no-labels"] == 1)
703
-					return $rv;
704
-				else
705
-					return $tmp;
732
+				if (!$tmp || $tmp["no-labels"] == 1) {
733
+									return $rv;
734
+				} else {
735
+									return $tmp;
736
+				}
706 737
 			}
707 738
 		}
708 739
 
@@ -721,10 +752,11 @@  discard block
 block discarded – undo
721 752
 			array_push($rv, $rk);
722 753
 		}
723 754
 
724
-		if (count($rv) > 0)
725
-			Labels::update_cache($owner_uid, $id, $rv);
726
-		else
727
-			Labels::update_cache($owner_uid, $id, array("no-labels" => 1));
755
+		if (count($rv) > 0) {
756
+					Labels::update_cache($owner_uid, $id, $rv);
757
+		} else {
758
+					Labels::update_cache($owner_uid, $id, array("no-labels" => 1));
759
+		}
728 760
 
729 761
 		return $rv;
730 762
 	}
@@ -772,28 +804,33 @@  discard block
 block discarded – undo
772 804
 				}
773 805
 			}
774 806
 
775
-			if (!$article_image)
776
-				foreach ($enclosures as $enc) {
807
+			if (!$article_image) {
808
+							foreach ($enclosures as $enc) {
777 809
 					if (strpos($enc["content_type"], "image/") !== false) {
778 810
 						$article_image = $enc["content_url"];
811
+			}
779 812
 						break;
780 813
 					}
781 814
 				}
782 815
 
783
-			if ($article_image)
784
-				$article_image = rewrite_relative_url($site_url, $article_image);
816
+			if ($article_image) {
817
+							$article_image = rewrite_relative_url($site_url, $article_image);
818
+			}
785 819
 
786
-			if ($article_stream)
787
-				$article_stream = rewrite_relative_url($site_url, $article_stream);
820
+			if ($article_stream) {
821
+							$article_stream = rewrite_relative_url($site_url, $article_stream);
822
+			}
788 823
 		}
789 824
 
790 825
 		$cache = new DiskCache("images");
791 826
 
792
-		if ($article_image && $cache->exists(sha1($article_image)))
793
-			$article_image = $cache->getUrl(sha1($article_image));
827
+		if ($article_image && $cache->exists(sha1($article_image))) {
828
+					$article_image = $cache->getUrl(sha1($article_image));
829
+		}
794 830
 
795
-		if ($article_stream && $cache->exists(sha1($article_stream)))
796
-			$article_stream = $cache->getUrl(sha1($article_stream));
831
+		if ($article_stream && $cache->exists(sha1($article_stream))) {
832
+					$article_stream = $cache->getUrl(sha1($article_stream));
833
+		}
797 834
 
798 835
 		return [$article_image, $article_stream];
799 836
 	}
Please login to merge, or discard this patch.
plugins/af_readability/init.php 1 patch
Braces   +21 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	public function hook_prefs_tab($args) {
50
-		if ($args != "prefFeeds") return;
50
+		if ($args != "prefFeeds") {
51
+		    return;
52
+		}
51 53
 
52 54
 		print "<div dojoType='dijit.layout.AccordionPane'
53 55
 			title=\"<i class='material-icons'>extension</i> ".__('Readability settings (af_readability)')."\">";
@@ -93,7 +95,9 @@  discard block
 block discarded – undo
93 95
 			print "</form>";
94 96
 
95 97
 			$enabled_feeds = $this->host->get($this, "enabled_feeds");
96
-			if (!is_array($enabled_feeds)) $enabled_feeds = array();
98
+			if (!is_array($enabled_feeds)) {
99
+			    $enabled_feeds = array();
100
+			}
97 101
 
98 102
 			$enabled_feeds = $this->filter_unknown_feeds($enabled_feeds);
99 103
 			$this->host->set($this, "enabled_feeds", $enabled_feeds);
@@ -120,7 +124,9 @@  discard block
 block discarded – undo
120 124
 		print "<section>";
121 125
 
122 126
 		$enabled_feeds = $this->host->get($this, "enabled_feeds");
123
-		if (!is_array($enabled_feeds)) $enabled_feeds = array();
127
+		if (!is_array($enabled_feeds)) {
128
+		    $enabled_feeds = array();
129
+		}
124 130
 
125 131
 		$key = array_search($feed_id, $enabled_feeds);
126 132
 		$checked = $key !== false ? "checked" : "";
@@ -137,7 +143,9 @@  discard block
 block discarded – undo
137 143
 
138 144
 	public function hook_prefs_save_feed($feed_id) {
139 145
 		$enabled_feeds = $this->host->get($this, "enabled_feeds");
140
-		if (!is_array($enabled_feeds)) $enabled_feeds = array();
146
+		if (!is_array($enabled_feeds)) {
147
+		    $enabled_feeds = array();
148
+		}
141 149
 
142 150
 		$enable = checkbox_to_sql_bool($_POST["af_readability_enabled"]);
143 151
 		$key = array_search($feed_id, $enabled_feeds);
@@ -174,8 +182,9 @@  discard block
 block discarded – undo
174 182
 		if ($tmp && mb_strlen($tmp) < 1024 * 500) {
175 183
 			$tmpdoc = new DOMDocument("1.0", "UTF-8");
176 184
 
177
-			if (!@$tmpdoc->loadHTML($tmp))
178
-				return false;
185
+			if (!@$tmpdoc->loadHTML($tmp)) {
186
+							return false;
187
+			}
179 188
 
180 189
 			// this is the worst hack yet :(
181 190
 			if (strtolower($tmpdoc->encoding) != 'utf-8') {
@@ -237,10 +246,14 @@  discard block
 block discarded – undo
237 246
 	public function hook_article_filter($article) {
238 247
 
239 248
 		$enabled_feeds = $this->host->get($this, "enabled_feeds");
240
-		if (!is_array($enabled_feeds)) return $article;
249
+		if (!is_array($enabled_feeds)) {
250
+		    return $article;
251
+		}
241 252
 
242 253
 		$key = array_search($article["feed"]["id"], $enabled_feeds);
243
-		if ($key === false) return $article;
254
+		if ($key === false) {
255
+		    return $article;
256
+		}
244 257
 
245 258
 		return $this->process_article($article);
246 259
 
Please login to merge, or discard this patch.
plugins/af_psql_trgm/init.php 1 patch
Braces   +42 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,10 +15,16 @@  discard block
 block discarded – undo
15 15
 		$min_title_length = (int) $_POST["min_title_length"];
16 16
 		$enable_globally = checkbox_to_sql_bool($_POST["enable_globally"]);
17 17
 
18
-		if ($similarity < 0) $similarity = 0;
19
-		if ($similarity > 1) $similarity = 1;
18
+		if ($similarity < 0) {
19
+		    $similarity = 0;
20
+		}
21
+		if ($similarity > 1) {
22
+		    $similarity = 1;
23
+		}
20 24
 
21
-		if ($min_title_length < 0) $min_title_length = 0;
25
+		if ($min_title_length < 0) {
26
+		    $min_title_length = 0;
27
+		}
22 28
 
23 29
 		$similarity = sprintf("%.2f", $similarity);
24 30
 
@@ -121,7 +127,9 @@  discard block
 block discarded – undo
121 127
 	}
122 128
 
123 129
 	public function hook_prefs_tab($args) {
124
-		if ($args != "prefFeeds") return;
130
+		if ($args != "prefFeeds") {
131
+		    return;
132
+		}
125 133
 
126 134
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
127 135
 			title=\"<i class='material-icons'>extension</i> ".__('Mark similar articles as read')."\">";
@@ -140,8 +148,12 @@  discard block
 block discarded – undo
140 148
 			$min_title_length = $this->host->get($this, "min_title_length");
141 149
 			$enable_globally = $this->host->get($this, "enable_globally");
142 150
 
143
-			if (!$similarity) $similarity = '0.75';
144
-			if (!$min_title_length) $min_title_length = '32';
151
+			if (!$similarity) {
152
+			    $similarity = '0.75';
153
+			}
154
+			if (!$min_title_length) {
155
+			    $min_title_length = '32';
156
+			}
145 157
 
146 158
 			print "<form dojoType=\"dijit.form.Form\">";
147 159
 
@@ -198,7 +210,9 @@  discard block
 block discarded – undo
198 210
 			print "</form>";
199 211
 
200 212
 			$enabled_feeds = $this->host->get($this, "enabled_feeds");
201
-			if (!array($enabled_feeds)) $enabled_feeds = array();
213
+			if (!array($enabled_feeds)) {
214
+			    $enabled_feeds = array();
215
+			}
202 216
 
203 217
 			$enabled_feeds = $this->filter_unknown_feeds($enabled_feeds);
204 218
 			$this->host->set($this, "enabled_feeds", $enabled_feeds);
@@ -225,7 +239,9 @@  discard block
 block discarded – undo
225 239
 		print "<section>";
226 240
 
227 241
 		$enabled_feeds = $this->host->get($this, "enabled_feeds");
228
-		if (!array($enabled_feeds)) $enabled_feeds = array();
242
+		if (!array($enabled_feeds)) {
243
+		    $enabled_feeds = array();
244
+		}
229 245
 
230 246
 		$key = array_search($feed_id, $enabled_feeds);
231 247
 		$checked = $key !== false ? "checked" : "";
@@ -242,7 +258,9 @@  discard block
 block discarded – undo
242 258
 
243 259
 	public function hook_prefs_save_feed($feed_id) {
244 260
 		$enabled_feeds = $this->host->get($this, "enabled_feeds");
245
-		if (!is_array($enabled_feeds)) $enabled_feeds = array();
261
+		if (!is_array($enabled_feeds)) {
262
+		    $enabled_feeds = array();
263
+		}
246 264
 
247 265
 		$enable = checkbox_to_sql_bool($_POST["trgm_similarity_enabled"]);
248 266
 		$key = array_search($feed_id, $enabled_feeds);
@@ -262,24 +280,34 @@  discard block
 block discarded – undo
262 280
 
263 281
 	public function hook_article_filter($article) {
264 282
 
265
-		if (DB_TYPE != "pgsql") return $article;
283
+		if (DB_TYPE != "pgsql") {
284
+		    return $article;
285
+		}
266 286
 
267 287
 		$res = $this->pdo->query("select 'similarity'::regproc");
268
-		if (!$res->fetch()) return $article;
288
+		if (!$res->fetch()) {
289
+		    return $article;
290
+		}
269 291
 
270 292
 		$enable_globally = $this->host->get($this, "enable_globally");
271 293
 
272 294
 		if (!$enable_globally) {
273 295
 			$enabled_feeds = $this->host->get($this, "enabled_feeds");
274 296
 			$key = array_search($article["feed"]["id"], $enabled_feeds);
275
-			if ($key === false) return $article;
297
+			if ($key === false) {
298
+			    return $article;
299
+			}
276 300
 		}
277 301
 
278 302
 		$similarity = (float) $this->host->get($this, "similarity");
279
-		if ($similarity < 0.01) return $article;
303
+		if ($similarity < 0.01) {
304
+		    return $article;
305
+		}
280 306
 
281 307
 		$min_title_length = (int) $this->host->get($this, "min_title_length");
282
-		if (mb_strlen($article["title"]) < $min_title_length) return $article;
308
+		if (mb_strlen($article["title"]) < $min_title_length) {
309
+		    return $article;
310
+		}
283 311
 
284 312
 		$owner_uid = $article["owner_uid"];
285 313
 		$entry_guid = $article["guid_hashed"];
Please login to merge, or discard this patch.
plugins/af_unburn/init.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  discard block
 block discarded – undo
21 21
 	public function hook_article_filter($article) {
22 22
 		$owner_uid = $article["owner_uid"];
23 23
 
24
-		if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir"))
25
-			return $article;
24
+		if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) {
25
+					return $article;
26
+		}
26 27
 
27 28
 		if ((strpos($article["link"], "feedproxy.google.com") !== false ||
28 29
 		  		strpos($article["link"], "/~r/") !== false ||
@@ -57,7 +58,9 @@  discard block
 block discarded – undo
57 58
 						parse_str($query, $args);
58 59
 
59 60
 						foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) {
60
-							if (isset($args[$param])) unset($args[$param]);
61
+							if (isset($args[$param])) {
62
+							    unset($args[$param]);
63
+							}
61 64
 						}
62 65
 
63 66
 						$new_query = http_build_query($args);
Please login to merge, or discard this patch.
plugins/af_redditimgur/init.php 1 patch
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 	}
23 23
 
24 24
 	public function hook_prefs_tab($args) {
25
-		if ($args != "prefFeeds") return;
25
+		if ($args != "prefFeeds") {
26
+		    return;
27
+		}
26 28
 
27 29
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
28 30
 			title=\"<i class='material-icons'>extension</i> ".__('Reddit content settings (af_redditimgur)')."\">";
@@ -173,8 +175,7 @@  discard block
 block discarded – undo
173 175
 									if ($child["data"]["url"] == $matches[0]) {
174 176
 										try {
175 177
 											$source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"];
176
-										}
177
-										catch (Exception $e) {
178
+										} catch (Exception $e) {
178 179
 										}
179 180
 										break 2;
180 181
 									}
@@ -230,8 +231,9 @@  discard block
 block discarded – undo
230 231
 
231 232
 					$source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
232 233
 
233
-					if (strpos($source_stream, "imgur.com") !== false)
234
-						$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
234
+					if (strpos($source_stream, "imgur.com") !== false) {
235
+											$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
236
+					}
235 237
 
236 238
 					$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
237 239
 
@@ -426,7 +428,9 @@  discard block
 block discarded – undo
426 428
 					if ($row = $sth->fetch()) {
427 429
 						$num_found = $row['cid'];
428 430
 
429
-						if ($num_found > 0) $article["force_catchup"] = true;
431
+						if ($num_found > 0) {
432
+						    $article["force_catchup"] = true;
433
+						}
430 434
 					}
431 435
 				}
432 436
 			}
@@ -458,7 +462,9 @@  discard block
 block discarded – undo
458 462
 		$video->setAttribute("controls", "1");
459 463
 		$video->setAttribute("loop", "1");
460 464
 
461
-		if ($poster_url) $video->setAttribute("poster", $poster_url);
465
+		if ($poster_url) {
466
+		    $video->setAttribute("poster", $poster_url);
467
+		}
462 468
 
463 469
 		$source = $doc->createElement('source');
464 470
 		$source->setAttribute("src", $source_stream);
Please login to merge, or discard this patch.