Passed
Pull Request — master (#3805)
by
unknown
17:20
created
sources/BrowserDetector.class.php 1 patch
Braces   +85 added lines, -30 removed lines patch added patch discarded remove patch
@@ -88,16 +88,24 @@  discard block
 block discarded – undo
88 88
 
89 89
 		// One at a time, one at a time, and in this order too
90 90
 		if ($this->isOpera())
91
-			$this->_setupOpera();
91
+		{
92
+					$this->_setupOpera();
93
+		}
92 94
 		// Them webkits need to be set up too
93 95
 		elseif ($this->isWebkit())
94
-			$this->_setupWebkit();
96
+		{
97
+					$this->_setupWebkit();
98
+		}
95 99
 		// We may have work to do on Firefox...
96 100
 		elseif ($this->isFirefox())
97
-			$this->_setupFirefox();
101
+		{
102
+					$this->_setupFirefox();
103
+		}
98 104
 		// Old friend, old frenemy
99 105
 		elseif ($this->isIe())
100
-			$this->_setupIe();
106
+		{
107
+					$this->_setupIe();
108
+		}
101 109
 
102 110
 		// Just a few mobile checks
103 111
 		$this->isOperaMini();
@@ -120,7 +128,9 @@  discard block
 block discarded – undo
120 128
 	public function isOpera()
121 129
 	{
122 130
 		if (!isset($this->_browsers['is_opera']))
123
-			$this->_browsers['is_opera'] = strpos($this->_ua, 'Opera') !== false;
131
+		{
132
+					$this->_browsers['is_opera'] = strpos($this->_ua, 'Opera') !== false;
133
+		}
124 134
 
125 135
 		return $this->_browsers['is_opera'];
126 136
 	}
@@ -134,7 +144,9 @@  discard block
 block discarded – undo
134 144
 	{
135 145
 		// I'm IE, Yes I'm the real IE; All you other IEs are just imitating.
136 146
 		if (!isset($this->_browsers['is_ie']))
137
-			$this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && (preg_match('~Trident/\d+~', $this->_ua) === 1 || preg_match('~MSIE \d+~', $this->_ua) === 1);
147
+		{
148
+					$this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && (preg_match('~Trident/\d+~', $this->_ua) === 1 || preg_match('~MSIE \d+~', $this->_ua) === 1);
149
+		}
138 150
 
139 151
 		return $this->_browsers['is_ie'];
140 152
 	}
@@ -147,7 +159,9 @@  discard block
 block discarded – undo
147 159
 	public function isWebkit()
148 160
 	{
149 161
 		if (!isset($this->_browsers['is_webkit']))
150
-			$this->_browsers['is_webkit'] = strpos($this->_ua, 'AppleWebKit') !== false;
162
+		{
163
+					$this->_browsers['is_webkit'] = strpos($this->_ua, 'AppleWebKit') !== false;
164
+		}
151 165
 
152 166
 		return $this->_browsers['is_webkit'];
153 167
 	}
@@ -160,7 +174,9 @@  discard block
 block discarded – undo
160 174
 	public function isFirefox()
161 175
 	{
162 176
 		if (!isset($this->_browsers['is_firefox']))
163
-			$this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $this->_ua) === 1 && $this->isGecko();
177
+		{
178
+					$this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $this->_ua) === 1 && $this->isGecko();
179
+		}
164 180
 
165 181
 		return $this->_browsers['is_firefox'];
166 182
 	}
@@ -173,7 +189,9 @@  discard block
 block discarded – undo
173 189
 	public function isWebTv()
174 190
 	{
175 191
 		if (!isset($this->_browsers['is_web_tv']))
176
-			$this->_browsers['is_web_tv'] = strpos($this->_ua, 'WebTV') !== false;
192
+		{
193
+					$this->_browsers['is_web_tv'] = strpos($this->_ua, 'WebTV') !== false;
194
+		}
177 195
 
178 196
 		return $this->_browsers['is_web_tv'];
179 197
 	}
@@ -186,7 +204,9 @@  discard block
 block discarded – undo
186 204
 	public function isKonqueror()
187 205
 	{
188 206
 		if (!isset($this->_browsers['is_konqueror']))
189
-			$this->_browsers['is_konqueror'] = strpos($this->_ua, 'Konqueror') !== false;
207
+		{
208
+					$this->_browsers['is_konqueror'] = strpos($this->_ua, 'Konqueror') !== false;
209
+		}
190 210
 
191 211
 		return $this->_browsers['is_konqueror'];
192 212
 	}
@@ -199,7 +219,9 @@  discard block
 block discarded – undo
199 219
 	public function isGecko()
200 220
 	{
201 221
 		if (!isset($this->_browsers['is_gecko']))
202
-			$this->_browsers['is_gecko'] = strpos($this->_ua, 'Gecko') !== false && strpos($this->_ua, 'like Gecko') === false && !$this->isWebkit() && !$this->isKonqueror();
222
+		{
223
+					$this->_browsers['is_gecko'] = strpos($this->_ua, 'Gecko') !== false && strpos($this->_ua, 'like Gecko') === false && !$this->isWebkit() && !$this->isKonqueror();
224
+		}
203 225
 
204 226
 		return $this->_browsers['is_gecko'];
205 227
 	}
@@ -212,9 +234,13 @@  discard block
 block discarded – undo
212 234
 	public function isOperaMini()
213 235
 	{
214 236
 		if (!isset($this->_browsers['is_opera_mini']))
215
-			$this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($this->_ua, 'opera mini') !== false);
237
+		{
238
+					$this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($this->_ua, 'opera mini') !== false);
239
+		}
216 240
 		if ($this->_browsers['is_opera_mini'])
217
-			$this->_is_mobile = true;
241
+		{
242
+					$this->_is_mobile = true;
243
+		}
218 244
 
219 245
 		return $this->_browsers['is_opera_mini'];
220 246
 	}
@@ -227,9 +253,13 @@  discard block
 block discarded – undo
227 253
 	public function isOperaMobi()
228 254
 	{
229 255
 		if (!isset($this->_browsers['is_opera_mobi']))
230
-			$this->_browsers['is_opera_mobi'] = stripos($this->_ua, 'opera mobi') !== false;
256
+		{
257
+					$this->_browsers['is_opera_mobi'] = stripos($this->_ua, 'opera mobi') !== false;
258
+		}
231 259
 		if ($this->_browsers['is_opera_mobi'])
232
-			$this->_is_mobile = true;
260
+		{
261
+					$this->_is_mobile = true;
262
+		}
233 263
 
234 264
 		return $this->_browsers['is_opera_mini'];
235 265
 	}
@@ -246,16 +276,20 @@  discard block
 block discarded – undo
246 276
 		// Be you robot or human?
247 277
 		if (!isset($this->_browsers['possibly_robot']))
248 278
 		{
249
-			if (isset($user_info['possibly_robot'])) {
279
+			if (isset($user_info['possibly_robot']))
280
+			{
250 281
 				// This isn't meant to be reliable, it's just meant to catch most bots to prevent PHPSESSID from showing up.
251 282
 				$this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']);
252 283
 
253 284
 				// Robots shouldn't be logging in or registering.  So, they aren't a bot.  Better to be wrong than sorry (or people won't be able to log in!), anyway.
254 285
 				if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register'))) || !$user_info['is_guest'])
255
-					$this->_browsers['possibly_robot'] = false;
286
+				{
287
+									$this->_browsers['possibly_robot'] = false;
288
+				}
289
+			}
290
+			else {
291
+							$this->_browsers['possibly_robot'] = false;
256 292
 			}
257
-			else
258
-				$this->_browsers['possibly_robot'] = false;
259 293
 		}
260 294
 
261 295
 		return $this->_browsers['possibly_robot'];
@@ -281,12 +315,16 @@  discard block
 block discarded – undo
281 315
 
282 316
 		// blackberry, playbook, iphone, nokia, android and ipods set a mobile flag
283 317
 		if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia'])
284
-			$this->_is_mobile = true;
318
+		{
319
+					$this->_is_mobile = true;
320
+		}
285 321
 
286 322
 		// iPad and droid tablets get a tablet flag
287 323
 		$this->_browsers['is_android_tablet'] = $this->_browsers['is_android'] && strpos($this->_ua, 'Mobile') === false;
288 324
 		if ($this->_browsers['is_ipad'] || $this->_browsers['is_android_tablet'])
289
-			$this->_is_tablet = true;
325
+		{
326
+					$this->_is_tablet = true;
327
+		}
290 328
 
291 329
 		// Prevent some repetition here
292 330
 		$_chrome = strpos($this->_ua, 'Chrome');
@@ -312,27 +350,36 @@  discard block
 block discarded – undo
312 350
 		if ($this->_browsers['is_chrome'])
313 351
 		{
314 352
 			if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $this->_ua, $match) === 1)
315
-				$this->_browsers['is_chrome' . (int) $match[1]] = true;
353
+			{
354
+							$this->_browsers['is_chrome' . (int) $match[1]] = true;
355
+			}
316 356
 		}
317 357
 		elseif ($this->_browsers['is_edge'])
318 358
 		{
319 359
 			$this->_browsers['is_webkit'] = false;
320 360
 			if (preg_match('~edge[/]([0-9][0-9]?[.])~i', $this->_ua, $match) === 1)
321
-				$this->_browsers['is_edge' . (int) $match[1]] = true;
361
+			{
362
+							$this->_browsers['is_edge' . (int) $match[1]] = true;
363
+			}
322 364
 		}
323 365
 		elseif ($this->_browsers['is_safari'])
324 366
 		{
325 367
 			if (preg_match('~version/?(.*)safari.*~i', $this->_ua, $match) === 1)
326
-				$this->_browsers['is_safari' . (int) trim($match[1])] = true;
368
+			{
369
+							$this->_browsers['is_safari' . (int) trim($match[1])] = true;
370
+			}
327 371
 		}
328 372
 		elseif ($this->_browsers['is_opera'])
329 373
 		{
330
-			if (preg_match('~OPR[/]([0-9][0-9]?[.])~i', $this->_ua, $match) === 1) {
374
+			if (preg_match('~OPR[/]([0-9][0-9]?[.])~i', $this->_ua, $match) === 1)
375
+			{
331 376
 				$this->_browsers['is_opera' . (int) trim($match[1])] = true;
332 377
 
333 378
 				// Since opera >= 15 wants to look like chrome, set the body to do just that
334 379
 				if (trim($match[1]) >= 15)
335
-					$this->_browsers['is_chrome'] = true;
380
+				{
381
+									$this->_browsers['is_chrome'] = true;
382
+				}
336 383
 			}
337 384
 		}
338 385
 	}
@@ -366,7 +413,9 @@  discard block
 block discarded – undo
366 413
 
367 414
 			// If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view
368 415
 			if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4))
369
-				$this->_browsers['is_ie_compat_view'] = true;
416
+			{
417
+							$this->_browsers['is_ie_compat_view'] = true;
418
+			}
370 419
 		}
371 420
 
372 421
 		// IE mobile, ... shucks why not
@@ -395,7 +444,9 @@  discard block
 block discarded – undo
395 444
 	private function _setupFirefox()
396 445
 	{
397 446
 		if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $this->_ua, $match) === 1)
398
-			$this->_browsers['is_firefox' . (int) $match[1]] = true;
447
+		{
448
+					$this->_browsers['is_firefox' . (int) $match[1]] = true;
449
+		}
399 450
 
400 451
 		// Firefox mobile
401 452
 		if (strpos($this->_ua, 'Android; Mobile;') !== false)
@@ -424,10 +475,14 @@  discard block
 block discarded – undo
424 475
 	{
425 476
 		// Opera 10+ uses the version tag at the end of the string
426 477
 		if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $this->_ua, $match))
427
-			$this->_browsers['is_opera' . (int) $match[1]] = true;
478
+		{
479
+					$this->_browsers['is_opera' . (int) $match[1]] = true;
480
+		}
428 481
 		// Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers
429 482
 		elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $this->_ua, $match))
430
-			$this->_browsers['is_opera' . (int) $match[1]] = true;
483
+		{
484
+					$this->_browsers['is_opera' . (int) $match[1]] = true;
485
+		}
431 486
 	}
432 487
 
433 488
 	/**
Please login to merge, or discard this patch.