Passed
Push — master ( 5a5c41...fade3b )
by Cody
04:50 queued 10s
created
classes/db/mysqli.php 1 patch
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,10 +4,11 @@  discard block
 block discarded – undo
4 4
 	private $last_error;
5 5
 
6 6
 	public function connect($host, $user, $pass, $db, $port) {
7
-		if ($port)
8
-			$this->link = mysqli_connect($host, $user, $pass, $db, $port);
9
-		else
10
-			$this->link = mysqli_connect($host, $user, $pass, $db);
7
+		if ($port) {
8
+					$this->link = mysqli_connect($host, $user, $pass, $db, $port);
9
+		} else {
10
+					$this->link = mysqli_connect($host, $user, $pass, $db);
11
+		}
11 12
 
12 13
 		if ($this->link) {
13 14
 			$this->init();
@@ -20,7 +21,9 @@  discard block
 block discarded – undo
20 21
 	}
21 22
 
22 23
 	public function escape_string($s, $strip_tags = true) {
23
-		if ($strip_tags) $s = strip_tags($s);
24
+		if ($strip_tags) {
25
+			$s = strip_tags($s);
26
+		}
24 27
 
25 28
 		return mysqli_real_escape_string($this->link, $s);
26 29
 	}
Please login to merge, or discard this patch.
classes/labels.php 1 patch
Braces   +24 added lines, -10 removed lines patch added patch discarded remove patch
@@ -56,11 +56,13 @@  discard block
 block discarded – undo
56 56
 	public static function update_cache($owner_uid, $id, $labels = false, $force = false) {
57 57
 		$pdo = Db::pdo();
58 58
 
59
-		if ($force)
60
-			Labels::clear_cache($id);
59
+		if ($force) {
60
+					Labels::clear_cache($id);
61
+		}
61 62
 
62
-		if (!$labels)
63
-			$labels = Article::get_article_labels($id);
63
+		if (!$labels) {
64
+					$labels = Article::get_article_labels($id);
65
+		}
64 66
 
65 67
 		$labels = json_encode($labels);
66 68
 
@@ -84,7 +86,9 @@  discard block
 block discarded – undo
84 86
 
85 87
 		$label_id = Labels::find_id($label, $owner_uid);
86 88
 
87
-		if (!$label_id) return;
89
+		if (!$label_id) {
90
+			return;
91
+		}
88 92
 
89 93
 		$pdo = Db::pdo();
90 94
 
@@ -102,7 +106,9 @@  discard block
 block discarded – undo
102 106
 
103 107
 		$label_id = Labels::find_id($label, $owner_uid);
104 108
 
105
-		if (!$label_id) return;
109
+		if (!$label_id) {
110
+			return;
111
+		}
106 112
 
107 113
 		$pdo = Db::pdo();
108 114
 
@@ -128,7 +134,9 @@  discard block
 block discarded – undo
128 134
 	}
129 135
 
130 136
 	public static function remove($id, $owner_uid) {
131
-		if (!$owner_uid) $owner_uid = $_SESSION["uid"];
137
+		if (!$owner_uid) {
138
+			$owner_uid = $_SESSION["uid"];
139
+		}
132 140
 
133 141
 		$pdo = Db::pdo();
134 142
 		$tr_in_progress = false;
@@ -168,12 +176,16 @@  discard block
 block discarded – undo
168 176
 
169 177
 		}
170 178
 
171
-		if (!$tr_in_progress) $pdo->commit();
179
+		if (!$tr_in_progress) {
180
+			$pdo->commit();
181
+		}
172 182
 	}
173 183
 
174 184
 	public static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false)	{
175 185
 
176
-		if (!$owner_uid) $owner_uid = $_SESSION['uid'];
186
+		if (!$owner_uid) {
187
+			$owner_uid = $_SESSION['uid'];
188
+		}
177 189
 
178 190
 		$pdo = Db::pdo();
179 191
 
@@ -198,7 +210,9 @@  discard block
 block discarded – undo
198 210
 			$result = $sth->rowCount();
199 211
 		}
200 212
 
201
-		if (!$tr_in_progress) $pdo->commit();
213
+		if (!$tr_in_progress) {
214
+			$pdo->commit();
215
+		}
202 216
 
203 217
 		return $result;
204 218
 	}
Please login to merge, or discard this patch.
classes/feeditem/common.php 1 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
 	public 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/pluginhost.php 1 patch
Braces   +36 added lines, -17 removed lines patch added patch discarded remove patch
@@ -82,8 +82,9 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 
84 84
 	public static function getInstance() {
85
-		if (self::$instance == null)
86
-			self::$instance = new self();
85
+		if (self::$instance == null) {
86
+					self::$instance = new self();
87
+		}
87 88
 
88 89
 		return self::$instance;
89 90
 	}
@@ -191,7 +192,9 @@  discard block
 block discarded – undo
191 192
 			$class_file = strtolower(clean_filename($class));
192 193
 
193 194
 			if (!is_dir(__DIR__."/../plugins/$class_file") &&
194
-					!is_dir(__DIR__."/../plugins.local/$class_file")) continue;
195
+					!is_dir(__DIR__."/../plugins.local/$class_file")) {
196
+				continue;
197
+			}
195 198
 
196 199
 			// try system plugin directory first
197 200
 			$file = __DIR__ . "/../plugins/$class_file/init.php";
@@ -203,7 +206,9 @@  discard block
 block discarded – undo
203 206
 			}
204 207
 
205 208
 			if (!isset($this->plugins[$class])) {
206
-				if (file_exists($file)) require_once $file;
209
+				if (file_exists($file)) {
210
+					require_once $file;
211
+				}
207 212
 
208 213
 				if (class_exists($class) && is_subclass_of($class, "Plugin")) {
209 214
 
@@ -219,8 +224,9 @@  discard block
 block discarded – undo
219 224
 								if ($namespace && $class_name) {
220 225
 									$class_file = "$vendor_dir/$namespace/" . str_replace('\\', '/', $class_name) . ".php";
221 226
 
222
-									if (file_exists($class_file))
223
-										require_once $class_file;
227
+									if (file_exists($class_file)) {
228
+																			require_once $class_file;
229
+									}
224 230
 								}
225 231
 							}
226 232
 						});
@@ -245,18 +251,24 @@  discard block
 block discarded – undo
245 251
 					switch ($kind) {
246 252
 					case $this::KIND_SYSTEM:
247 253
 						if ($this->is_system($plugin)) {
248
-							if (!$skip_init) $plugin->init($this);
254
+							if (!$skip_init) {
255
+								$plugin->init($this);
256
+							}
249 257
 							$this->register_plugin($class, $plugin);
250 258
 						}
251 259
 						break;
252 260
 					case $this::KIND_USER:
253 261
 						if (!$this->is_system($plugin)) {
254
-							if (!$skip_init) $plugin->init($this);
262
+							if (!$skip_init) {
263
+								$plugin->init($this);
264
+							}
255 265
 							$this->register_plugin($class, $plugin);
256 266
 						}
257 267
 						break;
258 268
 					case $this::KIND_ALL:
259
-						if (!$skip_init) $plugin->init($this);
269
+						if (!$skip_init) {
270
+							$plugin->init($this);
271
+						}
260 272
 						$this->register_plugin($class, $plugin);
261 273
 						break;
262 274
 					}
@@ -367,8 +379,9 @@  discard block
 block discarded – undo
367 379
 				owner_uid= ? AND name = ?");
368 380
 			$sth->execute([$this->owner_uid, $plugin]);
369 381
 
370
-			if (!isset($this->storage[$plugin]))
371
-				$this->storage[$plugin] = array();
382
+			if (!isset($this->storage[$plugin])) {
383
+							$this->storage[$plugin] = array();
384
+			}
372 385
 
373 386
 			$content = serialize($this->storage[$plugin]);
374 387
 
@@ -391,12 +404,15 @@  discard block
 block discarded – undo
391 404
 	public function set($sender, $name, $value, $sync = true) {
392 405
 		$idx = get_class($sender);
393 406
 
394
-		if (!isset($this->storage[$idx]))
395
-			$this->storage[$idx] = array();
407
+		if (!isset($this->storage[$idx])) {
408
+					$this->storage[$idx] = array();
409
+		}
396 410
 
397 411
 		$this->storage[$idx][$name] = $value;
398 412
 
399
-		if ($sync) $this->save_data(get_class($sender));
413
+		if ($sync) {
414
+			$this->save_data(get_class($sender));
415
+		}
400 416
 	}
401 417
 
402 418
 	public function get($sender, $name, $default_value = false) {
@@ -433,7 +449,9 @@  discard block
 block discarded – undo
433 449
 
434 450
 	// cat_id: only -1 is supported (Special)
435 451
 	public function add_feed($cat_id, $title, $icon, $sender) {
436
-		if (!$this->feeds[$cat_id]) $this->feeds[$cat_id] = array();
452
+		if (!$this->feeds[$cat_id]) {
453
+			$this->feeds[$cat_id] = array();
454
+		}
437 455
 
438 456
 		$id = count($this->feeds[$cat_id]);
439 457
 
@@ -479,8 +497,9 @@  discard block
 block discarded – undo
479 497
 	public function add_filter_action($sender, $action_name, $action_desc) {
480 498
 		$sender_class = get_class($sender);
481 499
 
482
-		if (!isset($this->plugin_actions[$sender_class]))
483
-			$this->plugin_actions[$sender_class] = array();
500
+		if (!isset($this->plugin_actions[$sender_class])) {
501
+					$this->plugin_actions[$sender_class] = array();
502
+		}
484 503
 
485 504
 		array_push($this->plugin_actions[$sender_class],
486 505
 			array("action" => $action_name, "description" => $action_desc, "sender" => $sender));
Please login to merge, or discard this patch.
classes/opml.php 1 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
 	public 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
 	public 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.
include/colors.php 1 patch
Braces   +51 added lines, -31 removed lines patch added patch discarded remove patch
@@ -157,11 +157,12 @@  discard block
 block discarded – undo
157 157
 
158 158
     $color = strtolower($color);
159 159
 
160
-    if (isset($htmlcolors[$color]))
161
-        return $htmlcolors[$color];
162
-    else
163
-        return $color;
164
-}
160
+    if (isset($htmlcolors[$color])) {
161
+            return $htmlcolors[$color];
162
+    } else {
163
+            return $color;
164
+    }
165
+    }
165 166
 
166 167
 ### RGB >> HSL
167 168
 function _color_rgb2hsl($rgb) {
@@ -173,9 +174,15 @@  discard block
 block discarded – undo
173 174
     }
174 175
     $h = 0;
175 176
     if ($delta > 0) {
176
-        if ($max == $r && $max != $g) $h += ($g - $b) / $delta;
177
-        if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta);
178
-        if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta);
177
+        if ($max == $r && $max != $g) {
178
+        	$h += ($g - $b) / $delta;
179
+        }
180
+        if ($max == $g && $max != $b) {
181
+        	$h += (2 + ($b - $r) / $delta);
182
+        }
183
+        if ($max == $b && $max != $r) {
184
+        	$h += (4 + ($r - $g) / $delta);
185
+        }
179 186
         $h /= 6;
180 187
     } return array($h, $s, $l);
181 188
 }
@@ -193,19 +200,26 @@  discard block
 block discarded – undo
193 200
 ### Helper function for _color_hsl2rgb().
194 201
 function _color_hue2rgb($m1, $m2, $h) {
195 202
     $h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h);
196
-    if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6;
197
-    if ($h * 2 < 1) return $m2;
198
-    if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
203
+    if ($h * 6 < 1) {
204
+    	return $m1 + ($m2 - $m1) * $h * 6;
205
+    }
206
+    if ($h * 2 < 1) {
207
+    	return $m2;
208
+    }
209
+    if ($h * 3 < 2) {
210
+    	return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
211
+    }
199 212
     return $m1;
200 213
 }
201 214
 
202 215
 ### Convert a hex color into an RGB triplet.
203 216
 function _color_unpack($hex, $normalize = false) {
204 217
 
205
-    if (strpos($hex, '#') !== 0)
206
-        $hex = _resolve_htmlcolor($hex);
207
-    else
208
-        $hex = substr($hex, 1);
218
+    if (strpos($hex, '#') !== 0) {
219
+            $hex = _resolve_htmlcolor($hex);
220
+    } else {
221
+            $hex = substr($hex, 1);
222
+    }
209 223
 
210 224
     if (strlen($hex) == 4) {
211 225
         $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
@@ -248,12 +262,20 @@  discard block
 block discarded – undo
248 262
         $del_G = ((($var_Max - $var_G ) / 6 ) + ($del_Max / 2 ) ) / $del_Max;
249 263
         $del_B = ((($var_Max - $var_B ) / 6 ) + ($del_Max / 2 ) ) / $del_Max;
250 264
 
251
-        if      ($var_R == $var_Max) $h = $del_B - $del_G;
252
-        else if ($var_G == $var_Max) $h = (1 / 3 ) + $del_R - $del_B;
253
-        else if ($var_B == $var_Max) $h = (2 / 3 ) + $del_G - $del_R;
265
+        if      ($var_R == $var_Max) {
266
+        	$h = $del_B - $del_G;
267
+        } else if ($var_G == $var_Max) {
268
+        	$h = (1 / 3 ) + $del_R - $del_B;
269
+        } else if ($var_B == $var_Max) {
270
+        	$h = (2 / 3 ) + $del_G - $del_R;
271
+        }
254 272
 
255
-        if ($h < 0) $h++;
256
-        if ($h > 1) $h--;
273
+        if ($h < 0) {
274
+        	$h++;
275
+        }
276
+        if ($h > 1) {
277
+        	$h--;
278
+        }
257 279
     }
258 280
 
259 281
     return array($h, $s, $v);
@@ -273,12 +295,7 @@  discard block
 block discarded – undo
273 295
         $var_2 = $v * (1 - $s * ($var_H - $var_i ) );
274 296
         $var_3 = $v * (1 - $s * (1 - ($var_H - $var_i ) ) );
275 297
 
276
-        if       ($var_i == 0) { $var_R = $v     ; $var_G = $var_3  ; $var_B = $var_1 ; }
277
-        else if  ($var_i == 1) { $var_R = $var_2 ; $var_G = $v      ; $var_B = $var_1 ; }
278
-        else if  ($var_i == 2) { $var_R = $var_1 ; $var_G = $v      ; $var_B = $var_3 ; }
279
-        else if  ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2  ; $var_B = $v     ; }
280
-        else if  ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1  ; $var_B = $v     ; }
281
-        else                   { $var_R = $v     ; $var_G = $var_1  ; $var_B = $var_2 ; }
298
+        if       ($var_i == 0) { $var_R = $v     ; $var_G = $var_3  ; $var_B = $var_1 ; } else if  ($var_i == 1) { $var_R = $var_2 ; $var_G = $v      ; $var_B = $var_1 ; } else if  ($var_i == 2) { $var_R = $var_1 ; $var_G = $v      ; $var_B = $var_3 ; } else if  ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2  ; $var_B = $v     ; } else if  ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1  ; $var_B = $v     ; } else                   { $var_R = $v     ; $var_G = $var_1  ; $var_B = $var_2 ; }
282 299
 
283 300
         $r = $var_R * 255;
284 301
         $g = $var_G * 255;
@@ -301,10 +318,11 @@  discard block
 block discarded – undo
301 318
             $ico = new floIcon();
302 319
             @$ico->readICO($imageFile);
303 320
 
304
-            if(count($ico->images)==0)
305
-                return false;
306
-            else
307
-                $img = @$ico->images[count($ico->images)-1]->getImageResource();
321
+            if(count($ico->images)==0) {
322
+                            return false;
323
+            } else {
324
+                            $img = @$ico->images[count($ico->images)-1]->getImageResource();
325
+            }
308 326
 
309 327
         } else {
310 328
             return false;
@@ -314,7 +332,9 @@  discard block
 block discarded – undo
314 332
         $img = @imagecreatefromstring(file_get_contents($imageFile));
315 333
     }
316 334
 
317
-    if (!$img) return false;
335
+    if (!$img) {
336
+    	return false;
337
+    }
318 338
 
319 339
     for($x = 0; $x < $size[0]; $x += $granularity) {
320 340
         for($y = 0; $y < $size[1]; $y += $granularity) {
Please login to merge, or discard this patch.
include/functions.php 1 patch
Braces   +128 added lines, -65 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 libxml_use_internal_errors(true);
19 19
 
20 20
 // separate test because this is included before sanity checks
21
-if (function_exists("mb_internal_encoding")) mb_internal_encoding("UTF-8");
21
+if (function_exists("mb_internal_encoding")) {
22
+	mb_internal_encoding("UTF-8");
23
+}
22 24
 
23 25
 date_default_timezone_set('UTC');
24 26
 if (defined('E_DEPRECATED')) {
@@ -195,8 +197,9 @@  discard block
 block discarded – undo
195 197
     $fetch_last_modified = "";
196 198
     $fetch_effective_url = "";
197 199
 
198
-    if (!is_array($fetch_domain_hits))
199
-        $fetch_domain_hits = [];
200
+    if (!is_array($fetch_domain_hits)) {
201
+            $fetch_domain_hits = [];
202
+    }
200 203
 
201 204
     if (!is_array($options)) {
202 205
 
@@ -227,8 +230,9 @@  discard block
 block discarded – undo
227 230
     $url = ltrim($url, ' ');
228 231
     $url = str_replace(' ', '%20', $url);
229 232
 
230
-    if (strpos($url, "//") === 0)
231
-        $url = 'http:' . $url;
233
+    if (strpos($url, "//") === 0) {
234
+            $url = 'http:' . $url;
235
+    }
232 236
 
233 237
     $url_host = parse_url($url, PHP_URL_HOST);
234 238
     $fetch_domain_hits[$url_host] += 1;
@@ -246,14 +250,17 @@  discard block
 block discarded – undo
246 250
 
247 251
         $curl_http_headers = [];
248 252
 
249
-        if ($last_modified && !$post_query)
250
-            array_push($curl_http_headers, "If-Modified-Since: $last_modified");
253
+        if ($last_modified && !$post_query) {
254
+                    array_push($curl_http_headers, "If-Modified-Since: $last_modified");
255
+        }
251 256
 
252
-        if ($http_accept)
253
-            array_push($curl_http_headers, "Accept: " . $http_accept);
257
+        if ($http_accept) {
258
+                    array_push($curl_http_headers, "Accept: " . $http_accept);
259
+        }
254 260
 
255
-        if (count($curl_http_headers) > 0)
256
-            curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers);
261
+        if (count($curl_http_headers) > 0) {
262
+                    curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers);
263
+        }
257 264
 
258 265
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT);
259 266
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT);
@@ -267,8 +274,9 @@  discard block
 block discarded – undo
267 274
             SELF_USER_AGENT);
268 275
         curl_setopt($ch, CURLOPT_ENCODING, "");
269 276
 
270
-        if  ($http_referrer)
271
-            curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
277
+        if  ($http_referrer) {
278
+                    curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
279
+        }
272 280
 
273 281
         if ($max_size) {
274 282
             curl_setopt($ch, CURLOPT_NOPROGRESS, false);
@@ -297,8 +305,9 @@  discard block
 block discarded – undo
297 305
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query);
298 306
         }
299 307
 
300
-        if ($login && $pass)
301
-            curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass");
308
+        if ($login && $pass) {
309
+                    curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass");
310
+        }
302 311
 
303 312
         $ret = @curl_exec($ch);
304 313
 
@@ -357,7 +366,9 @@  discard block
 block discarded – undo
357 366
         if ($is_gzipped) {
358 367
             $tmp = @gzdecode($contents);
359 368
 
360
-            if ($tmp) $contents = $tmp;
369
+            if ($tmp) {
370
+            	$contents = $tmp;
371
+            }
361 372
         }
362 373
 
363 374
         return $contents;
@@ -390,14 +401,17 @@  discard block
 block discarded – undo
390 401
                     'protocol_version'=> 1.1)
391 402
               );
392 403
 
393
-        if (!$post_query && $last_modified)
394
-            array_push($context_options['http']['header'], "If-Modified-Since: $last_modified");
404
+        if (!$post_query && $last_modified) {
405
+                    array_push($context_options['http']['header'], "If-Modified-Since: $last_modified");
406
+        }
395 407
 
396
-        if ($http_accept)
397
-            array_push($context_options['http']['header'], "Accept: $http_accept");
408
+        if ($http_accept) {
409
+                    array_push($context_options['http']['header'], "Accept: $http_accept");
410
+        }
398 411
 
399
-        if ($http_referrer)
400
-            array_push($context_options['http']['header'], "Referer: $http_referrer");
412
+        if ($http_referrer) {
413
+                    array_push($context_options['http']['header'], "Referer: $http_referrer");
414
+        }
401 415
 
402 416
         if (defined('_HTTP_PROXY')) {
403 417
             $context_options['http']['request_fulluri'] = true;
@@ -454,7 +468,9 @@  discard block
 block discarded – undo
454 468
         if ($is_gzipped) {
455 469
             $tmp = @gzdecode($data);
456 470
 
457
-            if ($tmp) $data = $tmp;
471
+            if ($tmp) {
472
+            	$data = $tmp;
473
+            }
458 474
         }
459 475
 
460 476
         return $data;
@@ -464,7 +480,9 @@  discard block
 block discarded – undo
464 480
 
465 481
 function initialize_user_prefs($uid, $profile = false) {
466 482
 
467
-    if (get_schema_version() < 63) $profile_qpart = "";
483
+    if (get_schema_version() < 63) {
484
+    	$profile_qpart = "";
485
+    }
468 486
 
469 487
     $pdo = DB::pdo();
470 488
     $in_nested_tr = false;
@@ -477,7 +495,9 @@  discard block
 block discarded – undo
477 495
 
478 496
     $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs");
479 497
 
480
-    if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
498
+    if (!is_numeric($profile) || !$profile || get_schema_version() < 63) {
499
+    	$profile = null;
500
+    }
481 501
 
482 502
     $u_sth = $pdo->prepare("SELECT pref_name
483 503
         FROM ttrss_user_prefs WHERE owner_uid = :uid AND
@@ -510,7 +530,9 @@  discard block
 block discarded – undo
510 530
         }
511 531
     }
512 532
 
513
-    if (!$in_nested_tr) $pdo->commit();
533
+    if (!$in_nested_tr) {
534
+    	$pdo->commit();
535
+    }
514 536
 
515 537
 }
516 538
 
@@ -670,7 +692,9 @@  discard block
 block discarded – undo
670 692
 
671 693
 function load_user_plugins($owner_uid, $pluginhost = false) {
672 694
 
673
-    if (!$pluginhost) $pluginhost = PluginHost::getInstance();
695
+    if (!$pluginhost) {
696
+    	$pluginhost = PluginHost::getInstance();
697
+    }
674 698
 
675 699
     if ($owner_uid && SCHEMA_VERSION >= 100) {
676 700
         $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
@@ -692,7 +716,9 @@  discard block
 block discarded – undo
692 716
         startup_gettext();
693 717
         load_user_plugins($_SESSION["uid"]);
694 718
     } else {
695
-        if (!validate_session()) $_SESSION["uid"] = false;
719
+        if (!validate_session()) {
720
+        	$_SESSION["uid"] = false;
721
+        }
696 722
 
697 723
         if (!$_SESSION["uid"]) {
698 724
 
@@ -787,13 +813,19 @@  discard block
 block discarded – undo
787 813
 function make_local_datetime($timestamp, $long, $owner_uid = false,
788 814
                 $no_smart_dt = false, $eta_min = false) {
789 815
 
790
-    if (!$owner_uid) $owner_uid = $_SESSION['uid'];
791
-    if (!$timestamp) $timestamp = '1970-01-01 0:00';
816
+    if (!$owner_uid) {
817
+    	$owner_uid = $_SESSION['uid'];
818
+    }
819
+    if (!$timestamp) {
820
+    	$timestamp = '1970-01-01 0:00';
821
+    }
792 822
 
793 823
     global $utc_tz;
794 824
     global $user_tz;
795 825
 
796
-    if (!$utc_tz) $utc_tz = new DateTimeZone('UTC');
826
+    if (!$utc_tz) {
827
+    	$utc_tz = new DateTimeZone('UTC');
828
+    }
797 829
 
798 830
     $timestamp = substr($timestamp, 0, 19);
799 831
 
@@ -805,7 +837,9 @@  discard block
 block discarded – undo
805 837
     if ($user_tz_string != 'Automatic') {
806 838
 
807 839
         try {
808
-            if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string);
840
+            if (!$user_tz) {
841
+            	$user_tz = new DateTimeZone($user_tz_string);
842
+            }
809 843
         } catch (Exception $e) {
810 844
             $user_tz = $utc_tz;
811 845
         }
@@ -821,26 +855,30 @@  discard block
 block discarded – undo
821 855
         return smart_date_time($user_timestamp,
822 856
             $tz_offset, $owner_uid, $eta_min);
823 857
     } else {
824
-        if ($long)
825
-            $format = get_pref('LONG_DATE_FORMAT', $owner_uid);
826
-        else
827
-            $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
858
+        if ($long) {
859
+                    $format = get_pref('LONG_DATE_FORMAT', $owner_uid);
860
+        } else {
861
+                    $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
862
+        }
828 863
 
829 864
         return date($format, $user_timestamp);
830 865
     }
831 866
 }
832 867
 
833 868
 function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) {
834
-    if (!$owner_uid) $owner_uid = $_SESSION['uid'];
869
+    if (!$owner_uid) {
870
+    	$owner_uid = $_SESSION['uid'];
871
+    }
835 872
 
836 873
     if ($eta_min && time() + $tz_offset - $timestamp < 3600) {
837 874
         return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp));
838 875
     } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) {
839 876
         $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
840
-        if (strpos((strtolower($format)), "a") === false)
841
-            return date("G:i", $timestamp);
842
-        else
843
-            return date("g:i a", $timestamp);
877
+        if (strpos((strtolower($format)), "a") === false) {
878
+                    return date("G:i", $timestamp);
879
+        } else {
880
+                    return date("g:i a", $timestamp);
881
+        }
844 882
     } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) {
845 883
         $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
846 884
         return date($format, $timestamp);
@@ -1250,8 +1288,9 @@  discard block
 block discarded – undo
1250 1288
 
1251 1289
     if ($src) {
1252 1290
         foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) {
1253
-            if ($plugin->hook_iframe_whitelisted($src))
1254
-                return true;
1291
+            if ($plugin->hook_iframe_whitelisted($src)) {
1292
+                            return true;
1293
+            }
1255 1294
         }
1256 1295
     }
1257 1296
 
@@ -1259,9 +1298,13 @@  discard block
 block discarded – undo
1259 1298
 }
1260 1299
 
1261 1300
 function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) {
1262
-    if (!$owner) $owner = $_SESSION["uid"];
1301
+    if (!$owner) {
1302
+    	$owner = $_SESSION["uid"];
1303
+    }
1263 1304
 
1264
-    $res = trim($str); if (!$res) return '';
1305
+    $res = trim($str); if (!$res) {
1306
+    	return '';
1307
+    }
1265 1308
 
1266 1309
     $doc = new DOMDocument();
1267 1310
     $doc->loadHTML('<?xml encoding="UTF-8">' . $res);
@@ -1323,13 +1366,15 @@  discard block
 block discarded – undo
1323 1366
 
1324 1367
             if ($entry->nodeName == 'source') {
1325 1368
 
1326
-                if ($entry->parentNode && $entry->parentNode->parentNode)
1327
-                    $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode);
1369
+                if ($entry->parentNode && $entry->parentNode->parentNode) {
1370
+                                    $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode);
1371
+                }
1328 1372
 
1329 1373
             } else if ($entry->nodeName == 'img') {
1330 1374
 
1331
-                if ($entry->parentNode)
1332
-                    $entry->parentNode->replaceChild($p, $entry);
1375
+                if ($entry->parentNode) {
1376
+                                    $entry->parentNode->replaceChild($p, $entry);
1377
+                }
1333 1378
 
1334 1379
             }
1335 1380
         }
@@ -1365,7 +1410,9 @@  discard block
 block discarded – undo
1365 1410
         'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time',
1366 1411
         'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' );
1367 1412
 
1368
-    if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe';
1413
+    if ($_SESSION['hasSandbox']) {
1414
+    	$allowed_elements[] = 'iframe';
1415
+    }
1369 1416
 
1370 1417
     $disallowed_attributes = array('id', 'style', 'class');
1371 1418
 
@@ -1405,7 +1452,9 @@  discard block
 block discarded – undo
1405 1452
                     $text = mb_substr($text, $pos + mb_strlen($word));
1406 1453
                 }
1407 1454
 
1408
-                if (!empty($text)) $fragment->appendChild(new DomText($text));
1455
+                if (!empty($text)) {
1456
+                	$fragment->appendChild(new DomText($text));
1457
+                }
1409 1458
 
1410 1459
                 $child->parentNode->replaceChild($fragment, $child);
1411 1460
             }
@@ -1596,8 +1645,9 @@  discard block
 block discarded – undo
1596 1645
     } else {
1597 1646
         $output = "";
1598 1647
 
1599
-        for ($i = 0; $i < $length; $i++)
1600
-            $output .= chr(mt_rand(0, 255));
1648
+        for ($i = 0; $i < $length; $i++) {
1649
+                    $output .= chr(mt_rand(0, 255));
1650
+        }
1601 1651
 
1602 1652
         return $output;
1603 1653
     }
@@ -1667,15 +1717,20 @@  discard block
 block discarded – undo
1667 1717
 }
1668 1718
 
1669 1719
 function get_theme_path($theme) {
1670
-    if ($theme == "default.php")
1671
-        return "css/default.css";
1720
+    if ($theme == "default.php") {
1721
+            return "css/default.css";
1722
+    }
1672 1723
 
1673 1724
     $check = "themes/$theme";
1674
-    if (file_exists($check)) return $check;
1725
+    if (file_exists($check)) {
1726
+    	return $check;
1727
+    }
1675 1728
 
1676 1729
     $check = "themes.local/$theme";
1677
-    if (file_exists($check)) return $check;
1678
-}
1730
+    if (file_exists($check)) {
1731
+    	return $check;
1732
+    }
1733
+    }
1679 1734
 
1680 1735
 function theme_exists($theme) {
1681 1736
     return file_exists("themes/$theme") || file_exists("themes.local/$theme");
@@ -1731,7 +1786,9 @@  discard block
 block discarded – undo
1731 1786
 function send_local_file($filename) {
1732 1787
     if (file_exists($filename)) {
1733 1788
 
1734
-        if (is_writable($filename)) touch($filename);
1789
+        if (is_writable($filename)) {
1790
+        	touch($filename);
1791
+        }
1735 1792
 
1736 1793
         $tmppluginhost = new PluginHost();
1737 1794
 
@@ -1739,7 +1796,9 @@  discard block
 block discarded – undo
1739 1796
         $tmppluginhost->load_data();
1740 1797
 
1741 1798
         foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) {
1742
-            if ($plugin->hook_send_local_file($filename)) return true;
1799
+            if ($plugin->hook_send_local_file($filename)) {
1800
+            	return true;
1801
+            }
1743 1802
         }
1744 1803
 
1745 1804
         $mimetype = mime_content_type($filename);
@@ -1747,8 +1806,9 @@  discard block
 block discarded – undo
1747 1806
         // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4
1748 1807
         // video files are detected as octet-stream by mime_content_type()
1749 1808
 
1750
-        if ($mimetype == "application/octet-stream")
1751
-            $mimetype = "video/mp4";
1809
+        if ($mimetype == "application/octet-stream") {
1810
+                    $mimetype = "video/mp4";
1811
+        }
1752 1812
 
1753 1813
         header("Content-type: $mimetype");
1754 1814
 
@@ -1771,7 +1831,9 @@  discard block
 block discarded – undo
1771 1831
 
1772 1832
     foreach ($files as $file) {
1773 1833
         $file_ts = filemtime($file);
1774
-        if ($file_ts > $ts) $ts = $file_ts;
1834
+        if ($file_ts > $ts) {
1835
+        	$ts = $file_ts;
1836
+        }
1775 1837
     }
1776 1838
 
1777 1839
     return $ts;
@@ -1784,8 +1846,9 @@  discard block
 block discarded – undo
1784 1846
 function get_version(&$git_commit = false, &$git_timestamp = false) {
1785 1847
     global $ttrss_version;
1786 1848
 
1787
-    if (isset($ttrss_version))
1788
-        return $ttrss_version;
1849
+    if (isset($ttrss_version)) {
1850
+            return $ttrss_version;
1851
+    }
1789 1852
 
1790 1853
     $ttrss_version = "UNKNOWN (Unsupported)";
1791 1854
 
Please login to merge, or discard this patch.
include/sessions.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@
 block discarded – undo
35 35
 }
36 36
 
37 37
 function validate_session() {
38
-    if (SINGLE_USER_MODE) return true;
38
+    if (SINGLE_USER_MODE) {
39
+    	return true;
40
+    }
39 41
 
40 42
     if (isset($_SESSION["ref_schema_version"]) && $_SESSION["ref_schema_version"] != session_get_schema_version()) {
41 43
         $_SESSION["login_error_msg"] =
Please login to merge, or discard this patch.
plugins/nsfw/init.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	public function hook_prefs_tab($args) {
50
-		if ($args != "prefPrefs") return;
50
+		if ($args != "prefPrefs") {
51
+			return;
52
+		}
51 53
 
52 54
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
53 55
 			title=\"<i class='material-icons'>extension</i> ".__("NSFW Plugin")."\">";
Please login to merge, or discard this patch.