1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sinergi\BrowserDetector; |
4
|
|
|
|
5
|
|
|
class BrowserDetector implements DetectorInterface |
6
|
|
|
{ |
7
|
|
|
const FUNC_PREFIX = 'checkBrowser'; |
8
|
|
|
|
9
|
|
|
protected static $userAgentString; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var Browser |
13
|
|
|
*/ |
14
|
|
|
protected static $browser; |
15
|
|
|
|
16
|
|
|
protected static $browsersList = array( |
17
|
|
|
// well-known, well-used |
18
|
|
|
// Special Notes: |
19
|
|
|
// (1) Opera must be checked before FireFox due to the odd |
20
|
|
|
// user agents used in some older versions of Opera |
21
|
|
|
// (2) WebTV is strapped onto Internet Explorer so we must |
22
|
|
|
// check for WebTV before IE |
23
|
|
|
// (3) Because of Internet Explorer 11 using |
24
|
|
|
// "Mozilla/5.0 ([...] Trident/7.0; rv:11.0) like Gecko" |
25
|
|
|
// as user agent, tests for IE must be run before any |
26
|
|
|
// tests checking for "Mozilla" |
27
|
|
|
// (4) (deprecated) Galeon is based on Firefox and needs to be |
28
|
|
|
// tested before Firefox is tested |
29
|
|
|
// (5) OmniWeb is based on Safari so OmniWeb check must occur |
30
|
|
|
// before Safari |
31
|
|
|
// (6) Netscape 9+ is based on Firefox so Netscape checks |
32
|
|
|
// before FireFox are necessary |
33
|
|
|
// (7) Microsoft Edge must be checked before Chrome and Safari |
34
|
|
|
// (7) Vivaldi must be checked before Chrome |
35
|
|
|
'WebTv', |
36
|
|
|
'InternetExplorer', |
37
|
|
|
'Edge', |
38
|
|
|
'Opera', |
39
|
|
|
'Vivaldi', |
40
|
|
|
'Dragon', |
41
|
|
|
'Galeon', |
42
|
|
|
'NetscapeNavigator9Plus', |
43
|
|
|
'SeaMonkey', |
44
|
|
|
'Firefox', |
45
|
|
|
'Yandex', |
46
|
|
|
'Samsung', |
47
|
|
|
'Chrome', |
48
|
|
|
'OmniWeb', |
49
|
|
|
// common mobile |
50
|
|
|
'Android', |
51
|
|
|
'BlackBerry', |
52
|
|
|
'Nokia', |
53
|
|
|
'Gsa', |
54
|
|
|
// common bots |
55
|
|
|
'Robot', |
56
|
|
|
// wkhtmltopdf before Safari |
57
|
|
|
'Wkhtmltopdf', |
58
|
|
|
// WebKit base check (post mobile and others) |
59
|
|
|
'Safari', |
60
|
|
|
// everyone else |
61
|
|
|
'NetPositive', |
62
|
|
|
'Firebird', |
63
|
|
|
'Konqueror', |
64
|
|
|
'Icab', |
65
|
|
|
'Phoenix', |
66
|
|
|
'Amaya', |
67
|
|
|
'Lynx', |
68
|
|
|
'Shiretoko', |
69
|
|
|
'IceCat', |
70
|
|
|
'Iceweasel', |
71
|
|
|
'Mozilla', /* Mozilla is such an open standard that you must check it last */ |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Routine to determine the browser type. |
76
|
|
|
* |
77
|
|
|
* @param Browser $browser |
78
|
|
|
* @param UserAgent $userAgent |
79
|
|
|
* |
80
|
|
|
* @return bool |
81
|
|
|
*/ |
82
|
8 |
|
public static function detect(Browser $browser, UserAgent $userAgent = null) |
83
|
|
|
{ |
84
|
8 |
|
self::$browser = $browser; |
85
|
8 |
|
if (is_null($userAgent)) { |
86
|
|
|
$userAgent = self::$browser->getUserAgent(); |
87
|
|
|
} |
88
|
8 |
|
self::$userAgentString = $userAgent->getUserAgentString(); |
89
|
|
|
|
90
|
8 |
|
self::$browser->setName(Browser::UNKNOWN); |
91
|
8 |
|
self::$browser->setVersion(Browser::VERSION_UNKNOWN); |
92
|
|
|
|
93
|
8 |
|
self::checkChromeFrame(); |
94
|
8 |
|
self::checkFacebookWebView(); |
95
|
|
|
|
96
|
8 |
|
foreach (self::$browsersList as $browserName) { |
97
|
8 |
|
$funcName = self::FUNC_PREFIX . $browserName; |
98
|
|
|
|
99
|
8 |
|
if (self::$funcName()) { |
100
|
7 |
|
return true; |
101
|
|
|
} |
102
|
8 |
|
} |
103
|
|
|
|
104
|
1 |
|
return false; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Determine if the user is using Chrome Frame. |
109
|
|
|
* |
110
|
|
|
* @return bool |
111
|
|
|
*/ |
112
|
8 |
|
public static function checkChromeFrame() |
113
|
|
|
{ |
114
|
8 |
|
if (strpos(self::$userAgentString, 'chromeframe') !== false) { |
115
|
|
|
self::$browser->setIsChromeFrame(true); |
116
|
|
|
|
117
|
|
|
return true; |
118
|
|
|
} |
119
|
|
|
|
120
|
8 |
|
return false; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Determine if the user is using Facebook. |
125
|
|
|
* |
126
|
|
|
* @return bool |
127
|
|
|
*/ |
128
|
8 |
|
public static function checkFacebookWebView() |
129
|
|
|
{ |
130
|
8 |
|
if (strpos(self::$userAgentString, 'FBAV') !== false) { |
131
|
1 |
|
self::$browser->setIsFacebookWebView(true); |
132
|
|
|
|
133
|
1 |
|
return true; |
134
|
|
|
} |
135
|
|
|
|
136
|
7 |
|
return false; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Determine if the user is using a BlackBerry. |
141
|
|
|
* |
142
|
|
|
* @return bool |
143
|
|
|
*/ |
144
|
3 |
|
public static function checkBrowserBlackBerry() |
145
|
|
|
{ |
146
|
3 |
|
if (stripos(self::$userAgentString, 'blackberry') !== false) { |
147
|
2 |
|
if (stripos(self::$userAgentString, 'Version/') !== false) { |
148
|
1 |
|
$aresult = explode('Version/', self::$userAgentString); |
149
|
1 |
|
if (isset($aresult[1])) { |
150
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
151
|
1 |
|
self::$browser->setVersion($aversion[0]); |
152
|
1 |
|
} |
153
|
1 |
|
} else { |
154
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'BlackBerry')); |
155
|
1 |
|
if (isset($aresult[1])) { |
156
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
157
|
1 |
|
self::$browser->setVersion($aversion[0]); |
158
|
1 |
|
} |
159
|
|
|
} |
160
|
2 |
|
self::$browser->setName(Browser::BLACKBERRY); |
161
|
|
|
|
162
|
2 |
|
return true; |
163
|
2 |
|
} elseif (stripos(self::$userAgentString, 'BB10') !== false) { |
164
|
1 |
|
$aresult = explode('Version/10.', self::$userAgentString); |
165
|
1 |
|
if (isset($aresult[1])) { |
166
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
167
|
1 |
|
self::$browser->setVersion('10.' . $aversion[0]); |
168
|
1 |
|
} |
169
|
1 |
|
self::$browser->setName(Browser::BLACKBERRY); |
170
|
1 |
|
return true; |
171
|
|
|
} |
172
|
|
|
|
173
|
2 |
|
return false; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Determine if the browser is a robot. |
178
|
|
|
* |
179
|
|
|
* @return bool |
180
|
|
|
*/ |
181
|
2 |
|
public static function checkBrowserRobot() |
182
|
|
|
{ |
183
|
2 |
|
if (stripos(self::$userAgentString, 'bot') !== false || |
184
|
2 |
|
stripos(self::$userAgentString, 'spider') !== false || |
185
|
2 |
|
stripos(self::$userAgentString, 'crawler') !== false |
186
|
2 |
|
) { |
187
|
|
|
self::$browser->setIsRobot(true); |
188
|
|
|
|
189
|
|
|
return true; |
190
|
|
|
} |
191
|
|
|
|
192
|
2 |
|
return false; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Determine if the browser is Internet Explorer. |
197
|
|
|
* |
198
|
|
|
* @return bool |
199
|
|
|
*/ |
200
|
8 |
|
public static function checkBrowserInternetExplorer() |
201
|
|
|
{ |
202
|
|
|
// Test for v1 - v1.5 IE |
203
|
8 |
|
if (stripos(self::$userAgentString, 'microsoft internet explorer') !== false) { |
204
|
|
|
self::$browser->setName(Browser::IE); |
205
|
|
|
self::$browser->setVersion('1.0'); |
206
|
|
|
$aresult = stristr(self::$userAgentString, '/'); |
207
|
|
|
if (preg_match('/308|425|426|474|0b1/i', $aresult)) { |
208
|
|
|
self::$browser->setVersion('1.5'); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
return true; |
212
|
|
|
} // Test for versions > 1.5 and < 11 and some cases of 11 |
213
|
|
|
else { |
214
|
8 |
|
if (stripos(self::$userAgentString, 'msie') !== false && stripos(self::$userAgentString, 'opera') === false |
215
|
8 |
|
) { |
216
|
|
|
// See if the browser is the odd MSN Explorer |
217
|
2 |
View Code Duplication |
if (stripos(self::$userAgentString, 'msnb') !== false) { |
|
|
|
|
218
|
|
|
$aresult = explode(' ', stristr(str_replace(';', '; ', self::$userAgentString), 'MSN')); |
219
|
|
|
self::$browser->setName(Browser::MSN); |
220
|
|
|
if (isset($aresult[1])) { |
221
|
|
|
self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
return true; |
225
|
|
|
} |
226
|
2 |
|
$aresult = explode(' ', stristr(str_replace(';', '; ', self::$userAgentString), 'msie')); |
227
|
2 |
|
self::$browser->setName(Browser::IE); |
228
|
2 |
|
if (isset($aresult[1])) { |
229
|
2 |
|
self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
230
|
2 |
|
} |
231
|
|
|
// See https://msdn.microsoft.com/en-us/library/ie/hh869301%28v=vs.85%29.aspx |
232
|
|
|
// Might be 11, anyway ! |
233
|
2 |
|
if (stripos(self::$userAgentString, 'trident') !== false) { |
234
|
2 |
|
preg_match('/rv:(\d+\.\d+)/', self::$userAgentString, $matches); |
235
|
2 |
|
if (isset($matches[1])) { |
236
|
1 |
|
self::$browser->setVersion($matches[1]); |
237
|
1 |
|
} |
238
|
|
|
|
239
|
|
|
// At this poing in the method, we know the MSIE and Trident |
240
|
|
|
// strings are present in the $userAgentString. If we're in |
241
|
|
|
// compatibility mode, we need to determine the true version. |
242
|
|
|
// If the MSIE version is 7.0, we can look at the Trident |
243
|
|
|
// version to *approximate* the true IE version. If we don't |
244
|
|
|
// find a matching pair, ( e.g. MSIE 7.0 && Trident/7.0 ) |
245
|
|
|
// we're *not* in compatibility mode and the browser really |
246
|
|
|
// is version 7.0. |
247
|
2 |
|
if (stripos(self::$userAgentString, 'MSIE 7.0;')) { |
248
|
1 |
|
if (stripos(self::$userAgentString, 'Trident/7.0;')) { |
249
|
|
|
// IE11 in compatibility mode |
250
|
1 |
|
self::$browser->setVersion('11.0'); |
251
|
1 |
|
self::$browser->setIsCompatibilityMode(true); |
252
|
1 |
|
} elseif (stripos(self::$userAgentString, 'Trident/6.0;')) { |
253
|
|
|
// IE10 in compatibility mode |
254
|
1 |
|
self::$browser->setVersion('10.0'); |
255
|
1 |
|
self::$browser->setIsCompatibilityMode(true); |
256
|
1 |
|
} elseif (stripos(self::$userAgentString, 'Trident/5.0;')) { |
257
|
|
|
// IE9 in compatibility mode |
258
|
1 |
|
self::$browser->setVersion('9.0'); |
259
|
1 |
|
self::$browser->setIsCompatibilityMode(true); |
260
|
1 |
|
} elseif (stripos(self::$userAgentString, 'Trident/4.0;')) { |
261
|
|
|
// IE8 in compatibility mode |
262
|
1 |
|
self::$browser->setVersion('8.0'); |
263
|
1 |
|
self::$browser->setIsCompatibilityMode(true); |
264
|
1 |
|
} |
265
|
1 |
|
} |
266
|
2 |
|
} |
267
|
|
|
|
268
|
2 |
|
return true; |
269
|
|
|
} // Test for versions >= 11 |
270
|
|
|
else { |
271
|
8 |
|
if (stripos(self::$userAgentString, 'trident') !== false) { |
272
|
1 |
|
self::$browser->setName(Browser::IE); |
273
|
|
|
|
274
|
1 |
|
preg_match('/rv:(\d+\.\d+)/', self::$userAgentString, $matches); |
275
|
1 |
|
if (isset($matches[1])) { |
276
|
1 |
|
self::$browser->setVersion($matches[1]); |
277
|
|
|
|
278
|
1 |
|
return true; |
279
|
|
|
} else { |
280
|
|
|
return false; |
281
|
|
|
} |
282
|
|
|
} // Test for Pocket IE |
283
|
|
|
else { |
284
|
7 |
|
if (stripos(self::$userAgentString, 'mspie') !== false || |
285
|
7 |
|
stripos( |
286
|
7 |
|
self::$userAgentString, |
287
|
|
|
'pocket' |
288
|
7 |
|
) !== false |
289
|
7 |
|
) { |
290
|
|
|
$aresult = explode(' ', stristr(self::$userAgentString, 'mspie')); |
291
|
|
|
self::$browser->setName(Browser::POCKET_IE); |
292
|
|
|
|
293
|
|
|
if (stripos(self::$userAgentString, 'mspie') !== false) { |
294
|
|
|
if (isset($aresult[1])) { |
295
|
|
|
self::$browser->setVersion($aresult[1]); |
296
|
|
|
} |
297
|
|
|
} else { |
298
|
|
|
$aversion = explode('/', self::$userAgentString); |
299
|
|
|
if (isset($aversion[1])) { |
300
|
|
|
self::$browser->setVersion($aversion[1]); |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
return true; |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
|
310
|
7 |
|
return false; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* Determine if the browser is Opera. |
315
|
|
|
* |
316
|
|
|
* @return bool |
317
|
|
|
*/ |
318
|
7 |
|
public static function checkBrowserOpera() |
319
|
|
|
{ |
320
|
7 |
|
if (stripos(self::$userAgentString, 'opera mini') !== false) { |
321
|
|
|
$resultant = stristr(self::$userAgentString, 'opera mini'); |
322
|
|
|
if (preg_match('/\//', $resultant)) { |
323
|
|
|
$aresult = explode('/', $resultant); |
324
|
|
|
if (isset($aresult[1])) { |
325
|
|
|
$aversion = explode(' ', $aresult[1]); |
326
|
|
|
self::$browser->setVersion($aversion[0]); |
327
|
|
|
} |
328
|
|
|
} else { |
329
|
|
|
$aversion = explode(' ', stristr($resultant, 'opera mini')); |
330
|
|
|
if (isset($aversion[1])) { |
331
|
|
|
self::$browser->setVersion($aversion[1]); |
332
|
|
|
} |
333
|
|
|
} |
334
|
|
|
self::$browser->setName(Browser::OPERA_MINI); |
335
|
|
|
|
336
|
|
|
return true; |
337
|
7 |
|
} elseif (stripos(self::$userAgentString, 'OPiOS') !== false) { |
338
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'OPiOS')); |
339
|
1 |
|
if (isset($aresult[1])) { |
340
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
341
|
1 |
|
self::$browser->setVersion($aversion[0]); |
342
|
1 |
|
} |
343
|
1 |
|
self::$browser->setName(Browser::OPERA_MINI); |
344
|
|
|
|
345
|
1 |
|
return true; |
346
|
7 |
|
} elseif (stripos(self::$userAgentString, 'opera') !== false) { |
347
|
1 |
|
$resultant = stristr(self::$userAgentString, 'opera'); |
348
|
1 |
|
if (preg_match('/Version\/(1[0-2].*)$/', $resultant, $matches)) { |
349
|
1 |
|
if (isset($matches[1])) { |
350
|
1 |
|
self::$browser->setVersion($matches[1]); |
351
|
1 |
|
} |
352
|
1 |
|
} elseif (preg_match('/\//', $resultant)) { |
353
|
|
|
$aresult = explode('/', str_replace('(', ' ', $resultant)); |
354
|
|
|
if (isset($aresult[1])) { |
355
|
|
|
$aversion = explode(' ', $aresult[1]); |
356
|
|
|
self::$browser->setVersion($aversion[0]); |
357
|
|
|
} |
358
|
|
|
} else { |
359
|
1 |
|
$aversion = explode(' ', stristr($resultant, 'opera')); |
360
|
1 |
|
self::$browser->setVersion(isset($aversion[1]) ? $aversion[1] : ''); |
361
|
|
|
} |
362
|
1 |
|
self::$browser->setName(Browser::OPERA); |
363
|
|
|
|
364
|
1 |
|
return true; |
365
|
6 |
|
} elseif (stripos(self::$userAgentString, ' OPR/') !== false) { |
366
|
1 |
|
self::$browser->setName(Browser::OPERA); |
367
|
1 |
|
if (preg_match('/OPR\/([\d\.]*)/', self::$userAgentString, $matches)) { |
368
|
1 |
|
if (isset($matches[1])) { |
369
|
1 |
|
self::$browser->setVersion($matches[1]); |
370
|
1 |
|
} |
371
|
1 |
|
} |
372
|
|
|
|
373
|
1 |
|
return true; |
374
|
|
|
} |
375
|
|
|
|
376
|
6 |
|
return false; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Determine if the browser is Samsung. |
381
|
|
|
* |
382
|
|
|
* @return bool |
383
|
|
|
*/ |
384
|
4 |
View Code Duplication |
public static function checkBrowserSamsung() |
|
|
|
|
385
|
|
|
{ |
386
|
4 |
|
if (stripos(self::$userAgentString, 'SamsungBrowser') !== false) { |
387
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'SamsungBrowser')); |
388
|
1 |
|
if (isset($aresult[1])) { |
389
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
390
|
1 |
|
self::$browser->setVersion($aversion[0]); |
391
|
1 |
|
} |
392
|
1 |
|
self::$browser->setName(Browser::SAMSUNG_BROWSER); |
393
|
|
|
|
394
|
1 |
|
return true; |
395
|
|
|
} |
396
|
|
|
|
397
|
4 |
|
return false; |
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
/** |
401
|
|
|
* Determine if the browser is Chrome. |
402
|
|
|
* |
403
|
|
|
* @return bool |
404
|
|
|
*/ |
405
|
4 |
|
public static function checkBrowserChrome() |
406
|
|
|
{ |
407
|
4 |
|
if (stripos(self::$userAgentString, 'Chrome') !== false) { |
408
|
2 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'Chrome')); |
409
|
2 |
|
if (isset($aresult[1])) { |
410
|
2 |
|
$aversion = explode(' ', $aresult[1]); |
411
|
2 |
|
self::$browser->setVersion($aversion[0]); |
412
|
2 |
|
} |
413
|
2 |
|
self::$browser->setName(Browser::CHROME); |
414
|
|
|
|
415
|
2 |
|
return true; |
416
|
3 |
|
} elseif (stripos(self::$userAgentString, 'CriOS') !== false) { |
417
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'CriOS')); |
418
|
1 |
|
if (isset($aresult[1])) { |
419
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
420
|
1 |
|
self::$browser->setVersion($aversion[0]); |
421
|
1 |
|
} |
422
|
1 |
|
self::$browser->setName(Browser::CHROME); |
423
|
|
|
|
424
|
1 |
|
return true; |
425
|
|
|
} |
426
|
|
|
|
427
|
3 |
|
return false; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* Determine if the browser is Vivaldi. |
432
|
|
|
* |
433
|
|
|
* @return bool |
434
|
|
|
*/ |
435
|
6 |
View Code Duplication |
public static function checkBrowserVivaldi() |
|
|
|
|
436
|
|
|
{ |
437
|
6 |
|
if (stripos(self::$userAgentString, 'Vivaldi') !== false) { |
438
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'Vivaldi')); |
439
|
1 |
|
if (isset($aresult[1])) { |
440
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
441
|
1 |
|
self::$browser->setVersion($aversion[0]); |
442
|
1 |
|
} |
443
|
1 |
|
self::$browser->setName(Browser::VIVALDI); |
444
|
|
|
|
445
|
1 |
|
return true; |
446
|
|
|
} |
447
|
|
|
|
448
|
6 |
|
return false; |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* Determine if the browser is Microsoft Edge. |
453
|
|
|
* |
454
|
|
|
* @return bool |
455
|
|
|
*/ |
456
|
7 |
|
public static function checkBrowserEdge() |
457
|
|
|
{ |
458
|
7 |
|
if (stripos(self::$userAgentString, 'Edge') !== false) { |
459
|
1 |
|
$version = explode('Edge/', self::$userAgentString); |
460
|
1 |
|
if (isset($version[1])) { |
461
|
1 |
|
self::$browser->setVersion((float)$version[1]); |
462
|
1 |
|
} |
463
|
1 |
|
self::$browser->setName(Browser::EDGE); |
464
|
|
|
|
465
|
1 |
|
return true; |
466
|
|
|
} |
467
|
|
|
|
468
|
7 |
|
return false; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Determine if the browser is Google Search Appliance. |
473
|
|
|
* |
474
|
|
|
* @return bool |
475
|
|
|
*/ |
476
|
2 |
View Code Duplication |
public static function checkBrowserGsa() |
|
|
|
|
477
|
|
|
{ |
478
|
2 |
|
if (stripos(self::$userAgentString, 'GSA') !== false) { |
479
|
|
|
$aresult = explode('/', stristr(self::$userAgentString, 'GSA')); |
480
|
|
|
if (isset($aresult[1])) { |
481
|
|
|
$aversion = explode(' ', $aresult[1]); |
482
|
|
|
self::$browser->setVersion($aversion[0]); |
483
|
|
|
} |
484
|
|
|
self::$browser->setName(Browser::GSA); |
485
|
|
|
|
486
|
|
|
return true; |
487
|
|
|
} |
488
|
|
|
|
489
|
2 |
|
return false; |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* Determine if the browser is WebTv. |
494
|
|
|
* |
495
|
|
|
* @return bool |
496
|
|
|
*/ |
497
|
8 |
View Code Duplication |
public static function checkBrowserWebTv() |
|
|
|
|
498
|
|
|
{ |
499
|
8 |
|
if (stripos(self::$userAgentString, 'webtv') !== false) { |
500
|
|
|
$aresult = explode('/', stristr(self::$userAgentString, 'webtv')); |
501
|
|
|
if (isset($aresult[1])) { |
502
|
|
|
$aversion = explode(' ', $aresult[1]); |
503
|
|
|
self::$browser->setVersion($aversion[0]); |
504
|
|
|
} |
505
|
|
|
self::$browser->setName(Browser::WEBTV); |
506
|
|
|
|
507
|
|
|
return true; |
508
|
|
|
} |
509
|
|
|
|
510
|
8 |
|
return false; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
/** |
514
|
|
|
* Determine if the browser is NetPositive. |
515
|
|
|
* |
516
|
|
|
* @return bool |
517
|
|
|
*/ |
518
|
1 |
|
public static function checkBrowserNetPositive() |
519
|
|
|
{ |
520
|
1 |
View Code Duplication |
if (stripos(self::$userAgentString, 'NetPositive') !== false) { |
|
|
|
|
521
|
|
|
$aresult = explode('/', stristr(self::$userAgentString, 'NetPositive')); |
522
|
|
|
if (isset($aresult[1])) { |
523
|
|
|
$aversion = explode(' ', $aresult[1]); |
524
|
|
|
self::$browser->setVersion(str_replace(array('(', ')', ';'), '', $aversion[0])); |
525
|
|
|
} |
526
|
|
|
self::$browser->setName(Browser::NETPOSITIVE); |
527
|
|
|
|
528
|
|
|
return true; |
529
|
|
|
} |
530
|
|
|
|
531
|
1 |
|
return false; |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* Determine if the browser is Galeon. |
536
|
|
|
* |
537
|
|
|
* @return bool |
538
|
|
|
*/ |
539
|
6 |
View Code Duplication |
public static function checkBrowserGaleon() |
|
|
|
|
540
|
|
|
{ |
541
|
6 |
|
if (stripos(self::$userAgentString, 'galeon') !== false) { |
542
|
|
|
$aresult = explode(' ', stristr(self::$userAgentString, 'galeon')); |
543
|
|
|
$aversion = explode('/', $aresult[0]); |
544
|
|
|
if (isset($aversion[1])) { |
545
|
|
|
self::$browser->setVersion($aversion[1]); |
546
|
|
|
} |
547
|
|
|
self::$browser->setName(Browser::GALEON); |
548
|
|
|
|
549
|
|
|
return true; |
550
|
|
|
} |
551
|
|
|
|
552
|
6 |
|
return false; |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* Determine if the browser is Konqueror. |
557
|
|
|
* |
558
|
|
|
* @return bool |
559
|
|
|
*/ |
560
|
1 |
View Code Duplication |
public static function checkBrowserKonqueror() |
|
|
|
|
561
|
|
|
{ |
562
|
1 |
|
if (stripos(self::$userAgentString, 'Konqueror') !== false) { |
563
|
|
|
$aresult = explode(' ', stristr(self::$userAgentString, 'Konqueror')); |
564
|
|
|
$aversion = explode('/', $aresult[0]); |
565
|
|
|
if (isset($aversion[1])) { |
566
|
|
|
self::$browser->setVersion($aversion[1]); |
567
|
|
|
} |
568
|
|
|
self::$browser->setName(Browser::KONQUEROR); |
569
|
|
|
|
570
|
|
|
return true; |
571
|
|
|
} |
572
|
|
|
|
573
|
1 |
|
return false; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* Determine if the browser is iCab. |
578
|
|
|
* |
579
|
|
|
* @return bool |
580
|
|
|
*/ |
581
|
1 |
View Code Duplication |
public static function checkBrowserIcab() |
|
|
|
|
582
|
|
|
{ |
583
|
1 |
|
if (stripos(self::$userAgentString, 'icab') !== false) { |
584
|
|
|
$aversion = explode(' ', stristr(str_replace('/', ' ', self::$userAgentString), 'icab')); |
585
|
|
|
if (isset($aversion[1])) { |
586
|
|
|
self::$browser->setVersion($aversion[1]); |
587
|
|
|
} |
588
|
|
|
self::$browser->setName(Browser::ICAB); |
589
|
|
|
|
590
|
|
|
return true; |
591
|
|
|
} |
592
|
|
|
|
593
|
1 |
|
return false; |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
/** |
597
|
|
|
* Determine if the browser is OmniWeb. |
598
|
|
|
* |
599
|
|
|
* @return bool |
600
|
|
|
*/ |
601
|
3 |
View Code Duplication |
public static function checkBrowserOmniWeb() |
|
|
|
|
602
|
|
|
{ |
603
|
3 |
|
if (stripos(self::$userAgentString, 'omniweb') !== false) { |
604
|
|
|
$aresult = explode('/', stristr(self::$userAgentString, 'omniweb')); |
605
|
|
|
$aversion = explode(' ', isset($aresult[1]) ? $aresult[1] : ''); |
606
|
|
|
self::$browser->setVersion($aversion[0]); |
607
|
|
|
self::$browser->setName(Browser::OMNIWEB); |
608
|
|
|
|
609
|
|
|
return true; |
610
|
|
|
} |
611
|
|
|
|
612
|
3 |
|
return false; |
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
/** |
616
|
|
|
* Determine if the browser is Phoenix. |
617
|
|
|
* |
618
|
|
|
* @return bool |
619
|
|
|
*/ |
620
|
1 |
|
public static function checkBrowserPhoenix() |
621
|
|
|
{ |
622
|
1 |
|
if (stripos(self::$userAgentString, 'Phoenix') !== false) { |
623
|
|
|
$aversion = explode('/', stristr(self::$userAgentString, 'Phoenix')); |
624
|
|
|
if (isset($aversion[1])) { |
625
|
|
|
self::$browser->setVersion($aversion[1]); |
626
|
|
|
} |
627
|
|
|
self::$browser->setName(Browser::PHOENIX); |
628
|
|
|
|
629
|
|
|
return true; |
630
|
|
|
} |
631
|
|
|
|
632
|
1 |
|
return false; |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
/** |
636
|
|
|
* Determine if the browser is Firebird. |
637
|
|
|
* |
638
|
|
|
* @return bool |
639
|
|
|
*/ |
640
|
1 |
|
public static function checkBrowserFirebird() |
641
|
|
|
{ |
642
|
1 |
|
if (stripos(self::$userAgentString, 'Firebird') !== false) { |
643
|
|
|
$aversion = explode('/', stristr(self::$userAgentString, 'Firebird')); |
644
|
|
|
if (isset($aversion[1])) { |
645
|
|
|
self::$browser->setVersion($aversion[1]); |
646
|
|
|
} |
647
|
|
|
self::$browser->setName(Browser::FIREBIRD); |
648
|
|
|
|
649
|
|
|
return true; |
650
|
|
|
} |
651
|
|
|
|
652
|
1 |
|
return false; |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
/** |
656
|
|
|
* Determine if the browser is Netscape Navigator 9+. |
657
|
|
|
* |
658
|
|
|
* @return bool |
659
|
|
|
*/ |
660
|
6 |
|
public static function checkBrowserNetscapeNavigator9Plus() |
661
|
|
|
{ |
662
|
6 |
|
if (stripos(self::$userAgentString, 'Firefox') !== false && |
663
|
2 |
|
preg_match('/Navigator\/([^ ]*)/i', self::$userAgentString, $matches) |
664
|
6 |
|
) { |
665
|
|
|
if (isset($matches[1])) { |
666
|
|
|
self::$browser->setVersion($matches[1]); |
667
|
|
|
} |
668
|
|
|
self::$browser->setName(Browser::NETSCAPE_NAVIGATOR); |
669
|
|
|
|
670
|
|
|
return true; |
671
|
6 |
|
} elseif (stripos(self::$userAgentString, 'Firefox') === false && |
672
|
5 |
|
preg_match('/Netscape6?\/([^ ]*)/i', self::$userAgentString, $matches) |
673
|
6 |
|
) { |
674
|
|
|
if (isset($matches[1])) { |
675
|
|
|
self::$browser->setVersion($matches[1]); |
676
|
|
|
} |
677
|
|
|
self::$browser->setName(Browser::NETSCAPE_NAVIGATOR); |
678
|
|
|
|
679
|
|
|
return true; |
680
|
|
|
} |
681
|
|
|
|
682
|
6 |
|
return false; |
683
|
|
|
} |
684
|
|
|
|
685
|
|
|
/** |
686
|
|
|
* Determine if the browser is Shiretoko. |
687
|
|
|
* |
688
|
|
|
* @return bool |
689
|
|
|
*/ |
690
|
1 |
|
public static function checkBrowserShiretoko() |
691
|
|
|
{ |
692
|
1 |
|
if (stripos(self::$userAgentString, 'Mozilla') !== false && |
693
|
|
|
preg_match('/Shiretoko\/([^ ]*)/i', self::$userAgentString, $matches) |
694
|
1 |
|
) { |
695
|
|
|
if (isset($matches[1])) { |
696
|
|
|
self::$browser->setVersion($matches[1]); |
697
|
|
|
} |
698
|
|
|
self::$browser->setName(Browser::SHIRETOKO); |
699
|
|
|
|
700
|
|
|
return true; |
701
|
|
|
} |
702
|
|
|
|
703
|
1 |
|
return false; |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* Determine if the browser is Ice Cat. |
708
|
|
|
* |
709
|
|
|
* @return bool |
710
|
|
|
*/ |
711
|
1 |
|
public static function checkBrowserIceCat() |
712
|
|
|
{ |
713
|
1 |
|
if (stripos(self::$userAgentString, 'Mozilla') !== false && |
714
|
|
|
preg_match('/IceCat\/([^ ]*)/i', self::$userAgentString, $matches) |
715
|
1 |
|
) { |
716
|
|
|
if (isset($matches[1])) { |
717
|
|
|
self::$browser->setVersion($matches[1]); |
718
|
|
|
} |
719
|
|
|
self::$browser->setName(Browser::ICECAT); |
720
|
|
|
|
721
|
|
|
return true; |
722
|
|
|
} |
723
|
|
|
|
724
|
1 |
|
return false; |
725
|
|
|
} |
726
|
|
|
|
727
|
|
|
/** |
728
|
|
|
* Determine if the browser is Nokia. |
729
|
|
|
* |
730
|
|
|
* @return bool |
731
|
|
|
*/ |
732
|
2 |
|
public static function checkBrowserNokia() |
733
|
|
|
{ |
734
|
2 |
|
if (preg_match("/Nokia([^\/]+)\/([^ SP]+)/i", self::$userAgentString, $matches)) { |
735
|
|
|
self::$browser->setVersion($matches[2]); |
736
|
|
|
if (stripos(self::$userAgentString, 'Series60') !== false || |
737
|
|
|
strpos(self::$userAgentString, 'S60') !== false |
738
|
|
|
) { |
739
|
|
|
self::$browser->setName(Browser::NOKIA_S60); |
740
|
|
|
} else { |
741
|
|
|
self::$browser->setName(Browser::NOKIA); |
742
|
|
|
} |
743
|
|
|
|
744
|
|
|
return true; |
745
|
|
|
} |
746
|
|
|
|
747
|
2 |
|
return false; |
748
|
|
|
} |
749
|
|
|
|
750
|
|
|
/** |
751
|
|
|
* Determine if the browser is Firefox. |
752
|
|
|
* |
753
|
|
|
* @return bool |
754
|
|
|
*/ |
755
|
5 |
View Code Duplication |
public static function checkBrowserFirefox() |
|
|
|
|
756
|
|
|
{ |
757
|
5 |
|
if (stripos(self::$userAgentString, 'safari') === false) { |
758
|
4 |
|
if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", self::$userAgentString, $matches)) { |
759
|
2 |
|
if (isset($matches[1])) { |
760
|
2 |
|
self::$browser->setVersion($matches[1]); |
761
|
2 |
|
} |
762
|
2 |
|
self::$browser->setName(Browser::FIREFOX); |
763
|
|
|
|
764
|
2 |
|
return true; |
765
|
2 |
|
} elseif (preg_match('/Firefox$/i', self::$userAgentString, $matches)) { |
766
|
|
|
self::$browser->setVersion(''); |
767
|
|
|
self::$browser->setName(Browser::FIREFOX); |
768
|
|
|
|
769
|
|
|
return true; |
770
|
|
|
} |
771
|
2 |
|
} |
772
|
|
|
|
773
|
4 |
|
return false; |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
/** |
777
|
|
|
* Determine if the browser is SeaMonkey. |
778
|
|
|
* |
779
|
|
|
* @return bool |
780
|
|
|
*/ |
781
|
6 |
View Code Duplication |
public static function checkBrowserSeaMonkey() |
|
|
|
|
782
|
|
|
{ |
783
|
6 |
|
if (stripos(self::$userAgentString, 'safari') === false) { |
784
|
5 |
|
if (preg_match("/SeaMonkey[\/ \(]([^ ;\)]+)/i", self::$userAgentString, $matches)) { |
785
|
1 |
|
if (isset($matches[1])) { |
786
|
1 |
|
self::$browser->setVersion($matches[1]); |
787
|
1 |
|
} |
788
|
1 |
|
self::$browser->setName(Browser::SEAMONKEY); |
789
|
|
|
|
790
|
1 |
|
return true; |
791
|
4 |
|
} elseif (preg_match('/SeaMonkey$/i', self::$userAgentString, $matches)) { |
792
|
|
|
self::$browser->setVersion(''); |
793
|
|
|
self::$browser->setName(Browser::SEAMONKEY); |
794
|
|
|
|
795
|
|
|
return true; |
796
|
|
|
} |
797
|
4 |
|
} |
798
|
|
|
|
799
|
5 |
|
return false; |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
/** |
803
|
|
|
* Determine if the browser is Iceweasel. |
804
|
|
|
* |
805
|
|
|
* @return bool |
806
|
|
|
*/ |
807
|
1 |
View Code Duplication |
public static function checkBrowserIceweasel() |
|
|
|
|
808
|
|
|
{ |
809
|
1 |
|
if (stripos(self::$userAgentString, 'Iceweasel') !== false) { |
810
|
|
|
$aresult = explode('/', stristr(self::$userAgentString, 'Iceweasel')); |
811
|
|
|
if (isset($aresult[1])) { |
812
|
|
|
$aversion = explode(' ', $aresult[1]); |
813
|
|
|
self::$browser->setVersion($aversion[0]); |
814
|
|
|
} |
815
|
|
|
self::$browser->setName(Browser::ICEWEASEL); |
816
|
|
|
|
817
|
|
|
return true; |
818
|
|
|
} |
819
|
|
|
|
820
|
1 |
|
return false; |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
/** |
824
|
|
|
* Determine if the browser is Mozilla. |
825
|
|
|
* |
826
|
|
|
* @return bool |
827
|
|
|
*/ |
828
|
1 |
|
public static function checkBrowserMozilla() |
829
|
|
|
{ |
830
|
1 |
|
if (stripos(self::$userAgentString, 'mozilla') !== false && |
831
|
1 |
|
preg_match('/rv:[0-9].[0-9][a-b]?/i', self::$userAgentString) && |
832
|
|
|
stripos(self::$userAgentString, 'netscape') === false |
833
|
1 |
|
) { |
834
|
|
|
$aversion = explode(' ', stristr(self::$userAgentString, 'rv:')); |
835
|
|
|
preg_match('/rv:[0-9].[0-9][a-b]?/i', self::$userAgentString, $aversion); |
836
|
|
|
self::$browser->setVersion(str_replace('rv:', '', $aversion[0])); |
837
|
|
|
self::$browser->setName(Browser::MOZILLA); |
838
|
|
|
|
839
|
|
|
return true; |
840
|
1 |
|
} elseif (stripos(self::$userAgentString, 'mozilla') !== false && |
841
|
1 |
|
preg_match('/rv:[0-9]\.[0-9]/i', self::$userAgentString) && |
842
|
|
|
stripos(self::$userAgentString, 'netscape') === false |
843
|
1 |
|
) { |
844
|
|
|
$aversion = explode('', stristr(self::$userAgentString, 'rv:')); |
845
|
|
|
self::$browser->setVersion(str_replace('rv:', '', $aversion[0])); |
846
|
|
|
self::$browser->setName(Browser::MOZILLA); |
847
|
|
|
|
848
|
|
|
return true; |
849
|
1 |
|
} elseif (stripos(self::$userAgentString, 'mozilla') !== false && |
850
|
1 |
|
preg_match('/mozilla\/([^ ]*)/i', self::$userAgentString, $matches) && |
851
|
|
|
stripos(self::$userAgentString, 'netscape') === false |
852
|
1 |
|
) { |
853
|
|
|
if (isset($matches[1])) { |
854
|
|
|
self::$browser->setVersion($matches[1]); |
855
|
|
|
} |
856
|
|
|
self::$browser->setName(Browser::MOZILLA); |
857
|
|
|
|
858
|
|
|
return true; |
859
|
|
|
} |
860
|
|
|
|
861
|
1 |
|
return false; |
862
|
|
|
} |
863
|
|
|
|
864
|
|
|
/** |
865
|
|
|
* Determine if the browser is Lynx. |
866
|
|
|
* |
867
|
|
|
* @return bool |
868
|
|
|
*/ |
869
|
1 |
View Code Duplication |
public static function checkBrowserLynx() |
|
|
|
|
870
|
|
|
{ |
871
|
1 |
|
if (stripos(self::$userAgentString, 'lynx') !== false) { |
872
|
|
|
$aresult = explode('/', stristr(self::$userAgentString, 'Lynx')); |
873
|
|
|
$aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : '')); |
874
|
|
|
self::$browser->setVersion($aversion[0]); |
875
|
|
|
self::$browser->setName(Browser::LYNX); |
876
|
|
|
|
877
|
|
|
return true; |
878
|
|
|
} |
879
|
|
|
|
880
|
1 |
|
return false; |
881
|
|
|
} |
882
|
|
|
|
883
|
|
|
/** |
884
|
|
|
* Determine if the browser is Amaya. |
885
|
|
|
* |
886
|
|
|
* @return bool |
887
|
|
|
*/ |
888
|
1 |
View Code Duplication |
public static function checkBrowserAmaya() |
|
|
|
|
889
|
|
|
{ |
890
|
1 |
|
if (stripos(self::$userAgentString, 'amaya') !== false) { |
891
|
|
|
$aresult = explode('/', stristr(self::$userAgentString, 'Amaya')); |
892
|
|
|
if (isset($aresult[1])) { |
893
|
|
|
$aversion = explode(' ', $aresult[1]); |
894
|
|
|
self::$browser->setVersion($aversion[0]); |
895
|
|
|
} |
896
|
|
|
self::$browser->setName(Browser::AMAYA); |
897
|
|
|
|
898
|
|
|
return true; |
899
|
|
|
} |
900
|
|
|
|
901
|
1 |
|
return false; |
902
|
|
|
} |
903
|
|
|
|
904
|
|
|
/** |
905
|
|
|
* Determine if the browser is Safari. |
906
|
|
|
* |
907
|
|
|
* @return bool |
908
|
|
|
*/ |
909
|
2 |
|
public static function checkBrowserWkhtmltopdf() |
910
|
|
|
{ |
911
|
2 |
|
if (stripos(self::$userAgentString, 'wkhtmltopdf') !== false) { |
912
|
1 |
|
self::$browser->setName(Browser::WKHTMLTOPDF); |
913
|
1 |
|
return true; |
914
|
|
|
} |
915
|
|
|
|
916
|
2 |
|
return false; |
917
|
|
|
} |
918
|
|
|
/** |
919
|
|
|
* Determine if the browser is Safari. |
920
|
|
|
* |
921
|
|
|
* @return bool |
922
|
|
|
*/ |
923
|
2 |
|
public static function checkBrowserSafari() |
924
|
|
|
{ |
925
|
2 |
|
if (stripos(self::$userAgentString, 'Safari') !== false) { |
926
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'Version')); |
927
|
1 |
|
if (isset($aresult[1])) { |
928
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
929
|
1 |
|
self::$browser->setVersion($aversion[0]); |
930
|
1 |
|
} else { |
931
|
|
|
self::$browser->setVersion(Browser::VERSION_UNKNOWN); |
932
|
|
|
} |
933
|
1 |
|
self::$browser->setName(Browser::SAFARI); |
934
|
|
|
|
935
|
1 |
|
return true; |
936
|
|
|
} |
937
|
|
|
|
938
|
1 |
|
return false; |
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
/** |
942
|
|
|
* Determine if the browser is Yandex. |
943
|
|
|
* |
944
|
|
|
* @return bool |
945
|
|
|
*/ |
946
|
4 |
View Code Duplication |
public static function checkBrowserYandex() |
|
|
|
|
947
|
|
|
{ |
948
|
4 |
|
if (stripos(self::$userAgentString, 'YaBrowser') !== false) { |
949
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'YaBrowser')); |
950
|
1 |
|
if (isset($aresult[1])) { |
951
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
952
|
1 |
|
self::$browser->setVersion($aversion[0]); |
953
|
1 |
|
} |
954
|
1 |
|
self::$browser->setName(Browser::YANDEX); |
955
|
|
|
|
956
|
1 |
|
return true; |
957
|
|
|
} |
958
|
|
|
|
959
|
4 |
|
return false; |
960
|
|
|
} |
961
|
|
|
|
962
|
|
|
/** |
963
|
|
|
* Determine if the browser is Comodo Dragon / Ice Dragon / Chromodo. |
964
|
|
|
* |
965
|
|
|
* @return bool |
966
|
|
|
*/ |
967
|
6 |
View Code Duplication |
public static function checkBrowserDragon() |
|
|
|
|
968
|
|
|
{ |
969
|
6 |
|
if (stripos(self::$userAgentString, 'Dragon') !== false) { |
970
|
1 |
|
$aresult = explode('/', stristr(self::$userAgentString, 'Dragon')); |
971
|
1 |
|
if (isset($aresult[1])) { |
972
|
1 |
|
$aversion = explode(' ', $aresult[1]); |
973
|
1 |
|
self::$browser->setVersion($aversion[0]); |
974
|
1 |
|
} |
975
|
1 |
|
self::$browser->setName(Browser::DRAGON); |
976
|
|
|
|
977
|
1 |
|
return true; |
978
|
|
|
} |
979
|
|
|
|
980
|
6 |
|
return false; |
981
|
|
|
} |
982
|
|
|
|
983
|
|
|
/** |
984
|
|
|
* Determine if the browser is Android. |
985
|
|
|
* |
986
|
|
|
* @return bool |
987
|
|
|
*/ |
988
|
3 |
|
public static function checkBrowserAndroid() |
989
|
|
|
{ |
990
|
|
|
// Navigator |
991
|
3 |
|
if (stripos(self::$userAgentString, 'Android') !== false) { |
992
|
|
|
if (preg_match('/Version\/([\d\.]*)/i', self::$userAgentString, $matches)) { |
993
|
|
|
if (isset($matches[1])) { |
994
|
|
|
self::$browser->setVersion($matches[1]); |
995
|
|
|
} |
996
|
|
|
} else { |
997
|
|
|
self::$browser->setVersion(Browser::VERSION_UNKNOWN); |
998
|
|
|
} |
999
|
|
|
self::$browser->setName(Browser::NAVIGATOR); |
1000
|
|
|
|
1001
|
|
|
return true; |
1002
|
|
|
} |
1003
|
|
|
|
1004
|
3 |
|
return false; |
1005
|
|
|
} |
1006
|
|
|
} |
1007
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.