PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Libraries / Browser / Browser.php

Browser.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at back/Libraries/Browser/Browser.php

1,844 lines 64.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Libraries\Browser;
4
5 /**
6 * Simplified and updated version by Acyba on November 2020, for AcyMailing use
7 *
8 * Author: Chris Schuld (https://chrisschuld.com)
9 * Original version: 1.9.6
10 * User Agents Sampled from: http://www.useragentstring.com
11 *
12 * This implementation is based on the original work from Gary White
13 */
14 class Browser
15 {
16 private $_agent = '';
17 private $_browser_name = '';
18 private $_version;
19 private $_platform = '';
20 private $_is_aol = false;
21 private $_is_mobile = false;
22 private $_is_tablet = false;
23 private $_is_robot = false;
24 private $_is_facebook = false;
25
26 const VERSION_UNKNOWN = 'unknown';
27
28 const BROWSER_OPERA = 'Opera'; // http://www.opera.com/
29 const BROWSER_OPERA_MINI = 'Opera Mini'; // http://www.opera.com/mini/
30 const BROWSER_WEBTV = 'WebTV'; // http://www.webtv.net/pc/
31 const BROWSER_EDGE = 'Microsoft Edge'; // https://www.microsoft.com/edge
32 const BROWSER_IE = 'Internet Explorer'; // http://www.microsoft.com/ie/
33 const BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
34 const BROWSER_KONQUEROR = 'Konqueror'; // http://www.konqueror.org/
35 const BROWSER_ICAB = 'iCab'; // http://www.icab.de/
36 const BROWSER_OMNIWEB = 'OmniWeb'; // http://www.omnigroup.com/applications/omniweb/
37 const BROWSER_FIREBIRD = 'Firebird'; // http://www.ibphoenix.com/
38 const BROWSER_FIREFOX = 'Firefox'; // https://www.mozilla.org/en-US/firefox/
39 const BROWSER_BRAVE = 'Brave'; // https://brave.com/
40 const BROWSER_PALEMOON = 'Palemoon'; // https://www.palemoon.org/
41 const BROWSER_ICEWEASEL = 'Iceweasel'; // http://www.geticeweasel.org/
42 const BROWSER_SHIRETOKO = 'Shiretoko'; // http://wiki.mozilla.org/Projects/shiretoko
43 const BROWSER_MOZILLA = 'Mozilla'; // http://www.mozilla.com/en-US/
44 const BROWSER_AMAYA = 'Amaya'; // http://www.w3.org/Amaya/
45 const BROWSER_LYNX = 'Lynx'; // http://en.wikipedia.org/wiki/Lynx
46 const BROWSER_SAFARI = 'Safari'; // http://apple.com
47 const BROWSER_IPHONE = 'iPhone'; // http://apple.com
48 const BROWSER_IPOD = 'iPod'; // http://apple.com
49 const BROWSER_IPAD = 'iPad'; // http://apple.com
50 const BROWSER_CHROME = 'Google Chrome'; // http://www.google.com/chrome
51 const BROWSER_ANDROID = 'Android'; // http://www.android.com/
52 const BROWSER_GOOGLEBOT = 'GoogleBot'; // http://en.wikipedia.org/wiki/Googlebot
53 const BROWSER_CURL = 'cURL'; // https://en.wikipedia.org/wiki/CURL
54 const BROWSER_WGET = 'Wget'; // https://en.wikipedia.org/wiki/Wget
55 const BROWSER_UCBROWSER = 'UCBrowser'; // https://www.ucweb.com/
56
57
58 const BROWSER_YANDEXBOT = 'YandexBot'; // http://yandex.com/bots
59 const BROWSER_YANDEXIMAGERESIZER_BOT = 'YandexImageResizer'; // http://yandex.com/bots
60 const BROWSER_YANDEXIMAGES_BOT = 'YandexImages'; // http://yandex.com/bots
61 const BROWSER_YANDEXVIDEO_BOT = 'YandexVideo'; // http://yandex.com/bots
62 const BROWSER_YANDEXMEDIA_BOT = 'YandexMedia'; // http://yandex.com/bots
63 const BROWSER_YANDEXBLOGS_BOT = 'YandexBlogs'; // http://yandex.com/bots
64 const BROWSER_YANDEXFAVICONS_BOT = 'YandexFavicons'; // http://yandex.com/bots
65 const BROWSER_YANDEXWEBMASTER_BOT = 'YandexWebmaster'; // http://yandex.com/bots
66 const BROWSER_YANDEXDIRECT_BOT = 'YandexDirect'; // http://yandex.com/bots
67 const BROWSER_YANDEXMETRIKA_BOT = 'YandexMetrika'; // http://yandex.com/bots
68 const BROWSER_YANDEXNEWS_BOT = 'YandexNews'; // http://yandex.com/bots
69 const BROWSER_YANDEXCATALOG_BOT = 'YandexCatalog'; // http://yandex.com/bots
70
71 const BROWSER_SLURP = 'Yahoo! Slurp'; // http://en.wikipedia.org/wiki/Yahoo!_Slurp
72 const BROWSER_W3CVALIDATOR = 'W3C Validator'; // http://validator.w3.org/
73 const BROWSER_BLACKBERRY = 'BlackBerry'; // http://www.blackberry.com/
74 const BROWSER_ICECAT = 'IceCat'; // http://en.wikipedia.org/wiki/GNU_IceCat
75 const BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // http://en.wikipedia.org/wiki/Web_Browser_for_S60
76 const BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
77 const BROWSER_MSN = 'MSN Browser'; // http://explorer.msn.com/
78 const BROWSER_MSNBOT = 'MSN Bot'; // http://search.msn.com/msnbot.htm
79 const BROWSER_BINGBOT = 'Bing Bot'; // http://en.wikipedia.org/wiki/Bingbot
80 const BROWSER_VIVALDI = 'Vivaldi'; // https://vivaldi.com/
81 const BROWSER_YANDEX = 'Yandex'; // https://browser.yandex.ua/
82
83 const BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // http://browser.netscape.com/ (DEPRECATED)
84 const BROWSER_GALEON = 'Galeon'; // http://galeon.sourceforge.net/ (DEPRECATED)
85 const BROWSER_NETPOSITIVE = 'NetPositive'; // http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
86 const BROWSER_PHOENIX = 'Phoenix'; // http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
87 const BROWSER_PLAYSTATION = 'PlayStation';
88 const BROWSER_SAMSUNG = 'SamsungBrowser';
89 const BROWSER_QQ = 'QQ Browser';
90 const BROWSER_SILK = 'Silk';
91 const BROWSER_I_FRAME = 'Iframely';
92 const BROWSER_COCOA = 'CocoaRestClient';
93
94 const PLATFORM_WINDOWS = 'Windows';
95 const PLATFORM_WINDOWS_CE = 'Windows CE';
96 const PLATFORM_APPLE = 'Apple';
97 const PLATFORM_LINUX = 'Linux';
98 const PLATFORM_OS2 = 'OS/2';
99 const PLATFORM_BEOS = 'BeOS';
100 const PLATFORM_IPHONE = 'iPhone';
101 const PLATFORM_IPOD = 'iPod';
102 const PLATFORM_IPAD = 'iPad';
103 const PLATFORM_BLACKBERRY = 'BlackBerry';
104 const PLATFORM_NOKIA = 'Nokia';
105 const PLATFORM_FREEBSD = 'FreeBSD';
106 const PLATFORM_OPENBSD = 'OpenBSD';
107 const PLATFORM_NETBSD = 'NetBSD';
108 const PLATFORM_SUNOS = 'SunOS';
109 const PLATFORM_OPENSOLARIS = 'OpenSolaris';
110 const PLATFORM_ANDROID = 'Android';
111 const PLATFORM_PLAYSTATION = 'Sony PlayStation';
112 const PLATFORM_ROKU = 'Roku';
113 const PLATFORM_APPLE_TV = 'Apple TV';
114 const PLATFORM_TERMINAL = 'Terminal';
115 const PLATFORM_FIRE_OS = 'Fire OS';
116 const PLATFORM_SMART_TV = 'SMART-TV';
117 const PLATFORM_CHROME_OS = 'Chrome OS';
118 const PLATFORM_JAVA_ANDROID = 'Java/Android';
119 const PLATFORM_POSTMAN = 'Postman';
120 const PLATFORM_I_FRAME = 'Iframely';
121
122 const MAIL_CLIENT_OUTLOOK = 'Outlook';
123 const MAIL_CLIENT_THUNDERBIRD = 'Thunderbird';
124 const MAIL_CLIENT_AIRMAIL = 'Airmail';
125 const MAIL_CLIENT_APPLE_MAIL = 'Apple Mail';
126 const MAIL_CLIENT_WINDOWS_10_MAIL = 'Windows 10 mail';
127 const MAIL_CLIENT_LOTUS = 'Lotus';
128
129 public function __construct($userAgent)
130 {
131 $this->_agent = $userAgent;
132
133 $this->checkPlatform();
134 $this->checkBrowsers();
135 $this->checkForAol();
136 }
137
138 /**
139 * The name of the browser. All return types are from the class contants
140 * @return string Name of the browser
141 */
142 public function getBrowser()
143 {
144 return $this->_browser_name;
145 }
146
147 /**
148 * The name of the platform. All return types are from the class contants
149 * @return string Name of the browser
150 */
151 public function getPlatform()
152 {
153 return $this->_platform;
154 }
155
156 /**
157 * The version of the browser.
158 * @return string version of the browser
159 */
160 public function getVersion()
161 {
162 return $this->_version;
163 }
164
165 /**
166 * Set the version of the browser
167 *
168 * @param string $version The version of the Browser
169 */
170 public function setVersion($version)
171 {
172 $this->_version = preg_replace('/[^0-9,.,a-z,A-Z-]/', '', $version);
173 }
174
175 /**
176 * Is the browser from AOL?
177 * @return boolean True if the browser is from AOL otherwise false
178 */
179 public function isAol()
180 {
181 return $this->_is_aol;
182 }
183
184 /**
185 * Is the browser from a mobile device?
186 * @return boolean True if the browser is from a mobile device otherwise false
187 */
188 public function isMobile()
189 {
190 return $this->_is_mobile;
191 }
192
193 /**
194 * Is the browser from a tablet device?
195 * @return boolean True if the browser is from a tablet device otherwise false
196 */
197 public function isTablet()
198 {
199 return $this->_is_tablet;
200 }
201
202 /**
203 * Is the browser from a robot (ex Slurp,GoogleBot)?
204 * @return boolean True if the browser is from a robot otherwise false
205 */
206 public function isRobot()
207 {
208 return $this->_is_robot;
209 }
210
211 /**
212 * Is the browser from facebook?
213 * @return boolean True if the browser is from facebook otherwise false
214 */
215 public function isFacebook()
216 {
217 return $this->_is_facebook;
218 }
219
220 /**
221 * Used to determine if the browser is actually "chromeframe"
222 * @return boolean True if the browser is using chromeframe
223 * @since 1.7
224 */
225 public function isChromeFrame()
226 {
227 return (strpos($this->_agent, 'chromeframe') !== false);
228 }
229
230 /**
231 * Protected routine to determine the browser type
232 * @return boolean True if the browser was detected otherwise false
233 */
234 protected function checkBrowsers()
235 {
236 // well-known, well-used
237 // Special Notes:
238 // (1) Opera must be checked before FireFox due to the odd
239 // user agents used in some older versions of Opera
240 // (2) WebTV is strapped onto Internet Explorer so we must
241 // check for WebTV before IE
242 // (3) (deprecated) Galeon is based on Firefox and needs to be
243 // tested before Firefox is tested
244 // (4) OmniWeb is based on Safari so OmniWeb check must occur
245 // before Safari
246 // (5) Netscape 9+ is based on Firefox so Netscape checks
247 // before FireFox are necessary
248 // (6) Vivaldi is UA contains both Firefox and Chrome so Vivaldi checks
249 // before Firefox and Chrome
250 // (7) Samsung browser must be tested before Chrome
251 // (8) Windows 10 Mail must be tested before Outlook
252
253 return (
254
255 // Standalone mail clients
256 $this->checkWindows10Mail() || $this->checkOutlook() || $this->checkThunderbird() || $this->checkAirmail() || $this->checkAppleMail() || $this->checkLotus() ||
257
258 // Special browsers
259 $this->checkBrowserSamsung() || $this->checkQQBrowser() ||
260
261 $this->checkBrowserWebTv() || $this->checkBrowserBrave() || $this->checkBrowserUCBrowser() || $this->checkBrowserEdge() || $this->checkBrowserInternetExplorer(
262 ) || $this->checkBrowserOpera() || $this->checkBrowserGaleon() || $this->checkBrowserNetscapeNavigator9Plus() || $this->checkBrowserVivaldi(
263 ) || $this->checkBrowserYandex() || $this->checkBrowserPalemoon() || $this->checkBrowserFirefox() || $this->checkBrowserChrome() || $this->checkBrowserOmniWeb() ||
264
265 // common mobile
266 $this->checkBrowserAndroid() || $this->checkBrowseriPad() || $this->checkBrowseriPod() || $this->checkBrowseriPhone() || $this->checkBrowserBlackBerry(
267 ) || $this->checkBrowserNokia() ||
268
269 // common bots
270 $this->checkBrowserGoogleBot() || $this->checkBrowserMSNBot() || $this->checkBrowserBingBot() || $this->checkBrowserSlurp() ||
271
272 // Yandex bots
273 $this->checkBrowserYandexBot() || $this->checkBrowserYandexImageResizerBot() || $this->checkBrowserYandexBlogsBot() || $this->checkBrowserYandexCatalogBot(
274 ) || $this->checkBrowserYandexDirectBot() || $this->checkBrowserYandexFaviconsBot() || $this->checkBrowserYandexImagesBot() || $this->checkBrowserYandexMediaBot(
275 ) || $this->checkBrowserYandexMetrikaBot() || $this->checkBrowserYandexNewsBot() || $this->checkBrowserYandexVideoBot() || $this->checkBrowserYandexWebmasterBot() ||
276
277 // check for facebook external hit when loading URL
278 $this->checkFacebookExternalHit() ||
279
280 // WebKit base check (post mobile and others)
281 $this->checkBrowserSilk() || $this->checkBrowserSafari() ||
282
283 // everyone else
284 $this->checkBrowserNetPositive() || $this->checkBrowserFirebird() || $this->checkBrowserKonqueror() || $this->checkBrowserIcab() || $this->checkBrowserPhoenix(
285 ) || $this->checkBrowserAmaya() || $this->checkBrowserLynx() || $this->checkBrowserShiretoko() || $this->checkBrowserIceCat() || $this->checkBrowserIceweasel(
286 ) || $this->checkBrowserW3CValidator() || $this->checkBrowserCurl() || $this->checkBrowserWget() || $this->checkBrowserPlayStation() || $this->checkBrowserIframely(
287 ) || $this->checkBrowserCocoa() || $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */);
288 }
289
290 protected function checkWindows10Mail()
291 {
292 if (stripos($this->_agent, 'compatible; ms-office; msoffice') !== false) {
293 $this->_browser_name = self::MAIL_CLIENT_WINDOWS_10_MAIL;
294
295 return true;
296 }
297
298 return false;
299 }
300
301 protected function checkOutlook()
302 {
303 if (stripos($this->_agent, 'outlook') !== false || stripos($this->_agent, 'ms-office') !== false) {
304 $this->_browser_name = self::MAIL_CLIENT_OUTLOOK;
305
306 return true;
307 }
308
309 return false;
310 }
311
312 protected function checkThunderbird()
313 {
314 if (stripos($this->_agent, 'thunderbird') !== false) {
315 $this->_browser_name = self::MAIL_CLIENT_THUNDERBIRD;
316
317 return true;
318 }
319
320 return false;
321 }
322
323 protected function checkAirmail()
324 {
325 if (stripos($this->_agent, 'Airmail') !== false) {
326 $this->_browser_name = self::MAIL_CLIENT_AIRMAIL;
327
328 return true;
329 }
330
331 return false;
332 }
333
334 protected function checkAppleMail()
335 {
336 if (stripos($this->_agent, 'AppleWebKit') !== false && stripos($this->_agent, 'chrome') === false && stripos($this->_agent, 'safari') === false) {
337 $this->_browser_name = self::MAIL_CLIENT_APPLE_MAIL;
338
339 return true;
340 }
341
342 return false;
343 }
344
345 protected function checkLotus()
346 {
347 if (stripos($this->_agent, 'lotus') !== false) {
348 $this->_browser_name = self::MAIL_CLIENT_LOTUS;
349
350 return true;
351 }
352
353 return false;
354 }
355
356 /**
357 * Determine if the user is using a BlackBerry (last updated 1.7)
358 * @return boolean True if the browser is the BlackBerry browser otherwise false
359 */
360 protected function checkBrowserBlackBerry()
361 {
362 if (stripos($this->_agent, 'blackberry') !== false) {
363 $aresult = explode('/', stristr($this->_agent, 'BlackBerry'));
364 if (isset($aresult[1])) {
365 $aversion = explode(' ', $aresult[1]);
366 $this->setVersion($aversion[0]);
367 $this->_browser_name = self::BROWSER_BLACKBERRY;
368 $this->_is_mobile = true;
369
370 return true;
371 }
372 }
373
374 return false;
375 }
376
377 /**
378 * Determine if the user is using an AOL User Agent (last updated 1.7)
379 * @return boolean True if the browser is from AOL otherwise false
380 */
381 protected function checkForAol()
382 {
383 $this->_is_aol = false;
384
385 if (stripos($this->_agent, 'aol') !== false) {
386 $aversion = explode(' ', stristr($this->_agent, 'AOL'));
387 if (isset($aversion[1])) {
388 $this->_is_aol = true;
389
390 return true;
391 }
392 }
393
394 return false;
395 }
396
397 /**
398 * Determine if the browser is the GoogleBot or not (last updated 1.7)
399 * @return boolean True if the browser is the GoogletBot otherwise false
400 */
401 protected function checkBrowserGoogleBot()
402 {
403 if (stripos($this->_agent, 'googlebot') !== false) {
404 $aresult = explode('/', stristr($this->_agent, 'googlebot'));
405 if (isset($aresult[1])) {
406 $aversion = explode(' ', $aresult[1]);
407 $this->setVersion(str_replace(';', '', $aversion[0]));
408 $this->_browser_name = self::BROWSER_GOOGLEBOT;
409 $this->_is_robot = true;
410
411 return true;
412 }
413 }
414
415 return false;
416 }
417
418 /**
419 * Determine if the browser is the YandexBot or not
420 * @return boolean True if the browser is the YandexBot otherwise false
421 */
422 protected function checkBrowserYandexBot()
423 {
424 if (stripos($this->_agent, 'YandexBot') !== false) {
425 $aresult = explode('/', stristr($this->_agent, 'YandexBot'));
426 if (isset($aresult[1])) {
427 $aversion = explode(' ', $aresult[1]);
428 $this->setVersion(str_replace(';', '', $aversion[0]));
429 $this->_browser_name = self::BROWSER_YANDEXBOT;
430 $this->_is_robot = true;
431
432 return true;
433 }
434 }
435
436 return false;
437 }
438
439 /**
440 * Determine if the browser is the YandexImageResizer or not
441 * @return boolean True if the browser is the YandexImageResizer otherwise false
442 */
443 protected function checkBrowserYandexImageResizerBot()
444 {
445 if (stripos($this->_agent, 'YandexImageResizer') !== false) {
446 $aresult = explode('/', stristr($this->_agent, 'YandexImageResizer'));
447 if (isset($aresult[1])) {
448 $aversion = explode(' ', $aresult[1]);
449 $this->setVersion(str_replace(';', '', $aversion[0]));
450 $this->_browser_name = self::BROWSER_YANDEXIMAGERESIZER_BOT;
451 $this->_is_robot = true;
452
453 return true;
454 }
455 }
456
457 return false;
458 }
459
460 /**
461 * Determine if the browser is the YandexCatalog or not
462 * @return boolean True if the browser is the YandexCatalog otherwise false
463 */
464 protected function checkBrowserYandexCatalogBot()
465 {
466 if (stripos($this->_agent, 'YandexCatalog') !== false) {
467 $aresult = explode('/', stristr($this->_agent, 'YandexCatalog'));
468 if (isset($aresult[1])) {
469 $aversion = explode(' ', $aresult[1]);
470 $this->setVersion(str_replace(';', '', $aversion[0]));
471 $this->_browser_name = self::BROWSER_YANDEXCATALOG_BOT;
472 $this->_is_robot = true;
473
474 return true;
475 }
476 }
477
478 return false;
479 }
480
481 /**
482 * Determine if the browser is the YandexNews or not
483 * @return boolean True if the browser is the YandexNews otherwise false
484 */
485 protected function checkBrowserYandexNewsBot()
486 {
487 if (stripos($this->_agent, 'YandexNews') !== false) {
488 $aresult = explode('/', stristr($this->_agent, 'YandexNews'));
489 if (isset($aresult[1])) {
490 $aversion = explode(' ', $aresult[1]);
491 $this->setVersion(str_replace(';', '', $aversion[0]));
492 $this->_browser_name = self::BROWSER_YANDEXNEWS_BOT;
493 $this->_is_robot = true;
494
495 return true;
496 }
497 }
498
499 return false;
500 }
501
502 /**
503 * Determine if the browser is the YandexMetrika or not
504 * @return boolean True if the browser is the YandexMetrika otherwise false
505 */
506 protected function checkBrowserYandexMetrikaBot()
507 {
508 if (stripos($this->_agent, 'YandexMetrika') !== false) {
509 $aresult = explode('/', stristr($this->_agent, 'YandexMetrika'));
510 if (isset($aresult[1])) {
511 $aversion = explode(' ', $aresult[1]);
512 $this->setVersion(str_replace(';', '', $aversion[0]));
513 $this->_browser_name = self::BROWSER_YANDEXMETRIKA_BOT;
514 $this->_is_robot = true;
515
516 return true;
517 }
518 }
519
520 return false;
521 }
522
523 /**
524 * Determine if the browser is the YandexDirect or not
525 * @return boolean True if the browser is the YandexDirect otherwise false
526 */
527 protected function checkBrowserYandexDirectBot()
528 {
529 if (stripos($this->_agent, 'YandexDirect') !== false) {
530 $aresult = explode('/', stristr($this->_agent, 'YandexDirect'));
531 if (isset($aresult[1])) {
532 $aversion = explode(' ', $aresult[1]);
533 $this->setVersion(str_replace(';', '', $aversion[0]));
534 $this->_browser_name = self::BROWSER_YANDEXDIRECT_BOT;
535 $this->_is_robot = true;
536
537 return true;
538 }
539 }
540
541 return false;
542 }
543
544 /**
545 * Determine if the browser is the YandexWebmaster or not
546 * @return boolean True if the browser is the YandexWebmaster otherwise false
547 */
548 protected function checkBrowserYandexWebmasterBot()
549 {
550 if (stripos($this->_agent, 'YandexWebmaster') !== false) {
551 $aresult = explode('/', stristr($this->_agent, 'YandexWebmaster'));
552 if (isset($aresult[1])) {
553 $aversion = explode(' ', $aresult[1]);
554 $this->setVersion(str_replace(';', '', $aversion[0]));
555 $this->_browser_name = self::BROWSER_YANDEXWEBMASTER_BOT;
556 $this->_is_robot = true;
557
558 return true;
559 }
560 }
561
562 return false;
563 }
564
565 /**
566 * Determine if the browser is the YandexFavicons or not
567 * @return boolean True if the browser is the YandexFavicons otherwise false
568 */
569 protected function checkBrowserYandexFaviconsBot()
570 {
571 if (stripos($this->_agent, 'YandexFavicons') !== false) {
572 $aresult = explode('/', stristr($this->_agent, 'YandexFavicons'));
573 if (isset($aresult[1])) {
574 $aversion = explode(' ', $aresult[1]);
575 $this->setVersion(str_replace(';', '', $aversion[0]));
576 $this->_browser_name = self::BROWSER_YANDEXFAVICONS_BOT;
577 $this->_is_robot = true;
578
579 return true;
580 }
581 }
582
583 return false;
584 }
585
586 /**
587 * Determine if the browser is the YandexBlogs or not
588 * @return boolean True if the browser is the YandexBlogs otherwise false
589 */
590 protected function checkBrowserYandexBlogsBot()
591 {
592 if (stripos($this->_agent, 'YandexBlogs') !== false) {
593 $aresult = explode('/', stristr($this->_agent, 'YandexBlogs'));
594 if (isset($aresult[1])) {
595 $aversion = explode(' ', $aresult[1]);
596 $this->setVersion(str_replace(';', '', $aversion[0]));
597 $this->_browser_name = self::BROWSER_YANDEXBLOGS_BOT;
598 $this->_is_robot = true;
599
600 return true;
601 }
602 }
603
604 return false;
605 }
606
607 /**
608 * Determine if the browser is the YandexMedia or not
609 * @return boolean True if the browser is the YandexMedia otherwise false
610 */
611 protected function checkBrowserYandexMediaBot()
612 {
613 if (stripos($this->_agent, 'YandexMedia') !== false) {
614 $aresult = explode('/', stristr($this->_agent, 'YandexMedia'));
615 if (isset($aresult[1])) {
616 $aversion = explode(' ', $aresult[1]);
617 $this->setVersion(str_replace(';', '', $aversion[0]));
618 $this->_browser_name = self::BROWSER_YANDEXMEDIA_BOT;
619 $this->_is_robot = true;
620
621 return true;
622 }
623 }
624
625 return false;
626 }
627
628 /**
629 * Determine if the browser is the YandexVideo or not
630 * @return boolean True if the browser is the YandexVideo otherwise false
631 */
632 protected function checkBrowserYandexVideoBot()
633 {
634 if (stripos($this->_agent, 'YandexVideo') !== false) {
635 $aresult = explode('/', stristr($this->_agent, 'YandexVideo'));
636 if (isset($aresult[1])) {
637 $aversion = explode(' ', $aresult[1]);
638 $this->setVersion(str_replace(';', '', $aversion[0]));
639 $this->_browser_name = self::BROWSER_YANDEXVIDEO_BOT;
640 $this->_is_robot = true;
641
642 return true;
643 }
644 }
645
646 return false;
647 }
648
649 /**
650 * Determine if the browser is the YandexImages or not
651 * @return boolean True if the browser is the YandexImages otherwise false
652 */
653 protected function checkBrowserYandexImagesBot()
654 {
655 if (stripos($this->_agent, 'YandexImages') !== false) {
656 $aresult = explode('/', stristr($this->_agent, 'YandexImages'));
657 if (isset($aresult[1])) {
658 $aversion = explode(' ', $aresult[1]);
659 $this->setVersion(str_replace(';', '', $aversion[0]));
660 $this->_browser_name = self::BROWSER_YANDEXIMAGES_BOT;
661 $this->_is_robot = true;
662
663 return true;
664 }
665 }
666
667 return false;
668 }
669
670 /**
671 * Determine if the browser is the MSNBot or not (last updated 1.9)
672 * @return boolean True if the browser is the MSNBot otherwise false
673 */
674 protected function checkBrowserMSNBot()
675 {
676 if (stripos($this->_agent, 'msnbot') !== false) {
677 $aresult = explode('/', stristr($this->_agent, 'msnbot'));
678 if (isset($aresult[1])) {
679 $aversion = explode(' ', $aresult[1]);
680 $this->setVersion(str_replace(';', '', $aversion[0]));
681 $this->_browser_name = self::BROWSER_MSNBOT;
682 $this->_is_robot = true;
683
684 return true;
685 }
686 }
687
688 return false;
689 }
690
691 /**
692 * Determine if the browser is the BingBot or not (last updated 1.9)
693 * @return boolean True if the browser is the BingBot otherwise false
694 */
695 protected function checkBrowserBingBot()
696 {
697 if (stripos($this->_agent, 'bingbot') !== false) {
698 $aresult = explode('/', stristr($this->_agent, 'bingbot'));
699 if (isset($aresult[1])) {
700 $aversion = explode(' ', $aresult[1]);
701 $this->setVersion(str_replace(';', '', $aversion[0]));
702 $this->_browser_name = self::BROWSER_BINGBOT;
703 $this->_is_robot = true;
704
705 return true;
706 }
707 }
708
709 return false;
710 }
711
712 /**
713 * Determine if the browser is the W3C Validator or not (last updated 1.7)
714 * @return boolean True if the browser is the W3C Validator otherwise false
715 */
716 protected function checkBrowserW3CValidator()
717 {
718 if (stripos($this->_agent, 'W3C-checklink') !== false) {
719 $aresult = explode('/', stristr($this->_agent, 'W3C-checklink'));
720 if (isset($aresult[1])) {
721 $aversion = explode(' ', $aresult[1]);
722 $this->setVersion($aversion[0]);
723 $this->_browser_name = self::BROWSER_W3CVALIDATOR;
724
725 return true;
726 }
727 } elseif (stripos($this->_agent, 'W3C_Validator') !== false) {
728 // Some of the Validator versions do not delineate w/ a slash - add it back in
729 $ua = str_replace('W3C_Validator ', 'W3C_Validator/', $this->_agent);
730 $aresult = explode('/', stristr($ua, 'W3C_Validator'));
731 if (isset($aresult[1])) {
732 $aversion = explode(' ', $aresult[1]);
733 $this->setVersion($aversion[0]);
734 $this->_browser_name = self::BROWSER_W3CVALIDATOR;
735
736 return true;
737 }
738 } elseif (stripos($this->_agent, 'W3C-mobileOK') !== false) {
739 $this->_browser_name = self::BROWSER_W3CVALIDATOR;
740 $this->_is_mobile = true;
741
742 return true;
743 }
744
745 return false;
746 }
747
748 /**
749 * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
750 * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
751 */
752 protected function checkBrowserSlurp()
753 {
754 if (stripos($this->_agent, 'slurp') !== false) {
755 $aresult = explode('/', stristr($this->_agent, 'Slurp'));
756 if (isset($aresult[1])) {
757 $aversion = explode(' ', $aresult[1]);
758 $this->setVersion($aversion[0]);
759 $this->_browser_name = self::BROWSER_SLURP;
760 $this->_is_robot = true;
761 $this->_is_mobile = false;
762
763 return true;
764 }
765 }
766
767 return false;
768 }
769
770 /**
771 * Determine if the browser is Brave or not
772 * @return boolean True if the browser is Brave otherwise false
773 */
774 protected function checkBrowserBrave()
775 {
776 if (stripos($this->_agent, 'Brave/') !== false) {
777 $aResult = explode('/', stristr($this->_agent, 'Brave'));
778 if (isset($aResult[1])) {
779 $aversion = explode(' ', $aResult[1]);
780 $this->setVersion($aversion[0]);
781 $this->_browser_name = self::BROWSER_BRAVE;
782
783 return true;
784 }
785 } elseif (stripos($this->_agent, ' Brave ') !== false) {
786 $this->_browser_name = self::BROWSER_BRAVE;
787 // this version of the UA did not ship with a version marker
788 // e.g. Mozilla/5.0 (Linux; Android 7.0; SM-G955F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/68.0.3440.91 Mobile Safari/537.36
789 $this->setVersion('');
790
791 return true;
792 }
793
794 return false;
795 }
796
797 /**
798 * Determine if the browser is Edge or not
799 * @return boolean True if the browser is Edge otherwise false
800 */
801 protected function checkBrowserEdge()
802 {
803 if ($name = (stripos($this->_agent, 'Edge/') !== false
804 ? 'Edge'
805 : ((stripos($this->_agent, 'Edg/') !== false || stripos(
806 $this->_agent,
807 'EdgA/'
808 ) !== false) ? 'Edg' : false))) {
809 $aresult = explode('/', stristr($this->_agent, $name));
810 if (isset($aresult[1])) {
811 $aversion = explode(' ', $aresult[1]);
812 $this->setVersion($aversion[0]);
813 $this->_browser_name = self::BROWSER_EDGE;
814 if (stripos($this->_agent, 'Windows Phone') !== false || stripos($this->_agent, 'Android') !== false) {
815 $this->_is_mobile = true;
816 }
817
818 return true;
819 }
820 }
821
822 return false;
823 }
824
825 /**
826 * Determine if the browser is Internet Explorer or not (last updated 1.7)
827 * @return boolean True if the browser is Internet Explorer otherwise false
828 */
829 protected function checkBrowserInternetExplorer()
830 {
831 // Test for IE11
832 if (stripos($this->_agent, 'Trident/7.0; rv:11.0') !== false) {
833 $this->_browser_name = self::BROWSER_IE;
834 $this->setVersion('11.0');
835
836 return true;
837 } // Test for v1 - v1.5 IE
838 elseif (stripos($this->_agent, 'microsoft internet explorer') !== false) {
839 $this->_browser_name = self::BROWSER_IE;
840 $this->setVersion('1.0');
841 $aresult = stristr($this->_agent, '/');
842 if (preg_match('/308|425|426|474|0b1/i', $aresult)) {
843 $this->setVersion('1.5');
844 }
845
846 return true;
847 } // Test for versions > 1.5
848 elseif (stripos($this->_agent, 'msie') !== false && stripos($this->_agent, 'opera') === false) {
849 // See if the browser is the odd MSN Explorer
850 if (stripos($this->_agent, 'msnb') !== false) {
851 $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'MSN'));
852 if (isset($aresult[1])) {
853 $this->_browser_name = self::BROWSER_MSN;
854 $this->setVersion(str_replace(['(', ')', ';'], '', $aresult[1]));
855
856 return true;
857 }
858 }
859 $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie'));
860 if (isset($aresult[1])) {
861 $this->_browser_name = self::BROWSER_IE;
862 $this->setVersion(str_replace(['(', ')', ';'], '', $aresult[1]));
863 if (stripos($this->_agent, 'IEMobile') !== false) {
864 $this->_browser_name = self::BROWSER_POCKET_IE;
865 $this->_is_mobile = true;
866 }
867
868 return true;
869 }
870 } // Test for versions > IE 10
871 elseif (stripos($this->_agent, 'trident') !== false) {
872 $this->_browser_name = self::BROWSER_IE;
873 $result = explode('rv:', $this->_agent);
874 if (isset($result[1])) {
875 $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1]));
876 $this->_agent = str_replace(['Mozilla', 'Gecko'], 'MSIE', $this->_agent);
877 }
878 } // Test for Pocket IE
879 elseif (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) {
880 $aresult = explode(' ', stristr($this->_agent, 'mspie'));
881 if (isset($aresult[1])) {
882 $this->_platform = self::PLATFORM_WINDOWS_CE;
883 $this->_browser_name = self::BROWSER_POCKET_IE;
884 $this->_is_mobile = true;
885
886 if (stripos($this->_agent, 'mspie') !== false) {
887 $this->setVersion($aresult[1]);
888 } else {
889 $aversion = explode('/', $this->_agent);
890 if (isset($aversion[1])) {
891 $this->setVersion($aversion[1]);
892 }
893 }
894
895 return true;
896 }
897 }
898
899 return false;
900 }
901
902 /**
903 * Determine if the browser is Opera or not (last updated 1.7)
904 * @return boolean True if the browser is Opera otherwise false
905 */
906 protected function checkBrowserOpera()
907 {
908 if (stripos($this->_agent, 'opera mini') !== false) {
909 $resultant = stristr($this->_agent, 'opera mini');
910 if (preg_match('/\//', $resultant)) {
911 $aresult = explode('/', $resultant);
912 if (isset($aresult[1])) {
913 $aversion = explode(' ', $aresult[1]);
914 $this->setVersion($aversion[0]);
915 }
916 } else {
917 $aversion = explode(' ', stristr($resultant, 'opera mini'));
918 if (isset($aversion[1])) {
919 $this->setVersion($aversion[1]);
920 }
921 }
922 $this->_browser_name = self::BROWSER_OPERA_MINI;
923 $this->_is_mobile = true;
924
925 return true;
926 } elseif (stripos($this->_agent, 'opera') !== false) {
927 $resultant = stristr($this->_agent, 'opera');
928 if (preg_match('/Version\/(1*.*)$/', $resultant, $matches)) {
929 $this->setVersion($matches[1]);
930 } elseif (preg_match('/\//', $resultant)) {
931 $aresult = explode('/', str_replace('(', ' ', $resultant));
932 if (isset($aresult[1])) {
933 $aversion = explode(' ', $aresult[1]);
934 $this->setVersion($aversion[0]);
935 }
936 } else {
937 $aversion = explode(' ', stristr($resultant, 'opera'));
938 $this->setVersion(isset($aversion[1]) ? $aversion[1] : '');
939 }
940 if (stripos($this->_agent, 'Opera Mobi') !== false) {
941 $this->_is_mobile = true;
942 }
943 $this->_browser_name = self::BROWSER_OPERA;
944
945 return true;
946 } elseif (stripos($this->_agent, 'OPR') !== false) {
947 $resultant = stristr($this->_agent, 'OPR');
948 if (preg_match('/\//', $resultant)) {
949 $aresult = explode('/', str_replace('(', ' ', $resultant));
950 if (isset($aresult[1])) {
951 $aversion = explode(' ', $aresult[1]);
952 $this->setVersion($aversion[0]);
953 }
954 }
955 if (stripos($this->_agent, 'Mobile') !== false) {
956 $this->_is_mobile = true;
957 }
958 $this->_browser_name = self::BROWSER_OPERA;
959
960 return true;
961 }
962
963 return false;
964 }
965
966 /**
967 * Determine if the browser is Chrome or not (last updated 1.7)
968 * @return boolean True if the browser is Chrome otherwise false
969 */
970 protected function checkBrowserChrome()
971 {
972 if (stripos($this->_agent, 'Chrome') !== false) {
973 $aresult = preg_split('/[\/;]+/', stristr($this->_agent, 'Chrome'));
974 if (isset($aresult[1])) {
975 $aversion = explode(' ', $aresult[1]);
976 $this->setVersion($aversion[0]);
977 $this->_browser_name = self::BROWSER_CHROME;
978 //Chrome on Android
979 if (stripos($this->_agent, 'Android') !== false) {
980 if (stripos($this->_agent, 'Mobile') !== false) {
981 $this->_is_mobile = true;
982 } else {
983 $this->_is_tablet = true;
984 }
985 }
986
987 return true;
988 }
989 }
990
991 return false;
992 }
993
994
995 /**
996 * Determine if the browser is WebTv or not (last updated 1.7)
997 * @return boolean True if the browser is WebTv otherwise false
998 */
999 protected function checkBrowserWebTv()
1000 {
1001 if (stripos($this->_agent, 'webtv') !== false) {
1002 $aresult = explode('/', stristr($this->_agent, 'webtv'));
1003 if (isset($aresult[1])) {
1004 $aversion = explode(' ', $aresult[1]);
1005 $this->setVersion($aversion[0]);
1006 $this->_browser_name = self::BROWSER_WEBTV;
1007
1008 return true;
1009 }
1010 }
1011
1012 return false;
1013 }
1014
1015 /**
1016 * Determine if the browser is NetPositive or not (last updated 1.7)
1017 * @return boolean True if the browser is NetPositive otherwise false
1018 */
1019 protected function checkBrowserNetPositive()
1020 {
1021 if (stripos($this->_agent, 'NetPositive') !== false) {
1022 $aresult = explode('/', stristr($this->_agent, 'NetPositive'));
1023 if (isset($aresult[1])) {
1024 $aversion = explode(' ', $aresult[1]);
1025 $this->setVersion(str_replace(['(', ')', ';'], '', $aversion[0]));
1026 $this->_browser_name = self::BROWSER_NETPOSITIVE;
1027
1028 return true;
1029 }
1030 }
1031
1032 return false;
1033 }
1034
1035 /**
1036 * Determine if the browser is Galeon or not (last updated 1.7)
1037 * @return boolean True if the browser is Galeon otherwise false
1038 */
1039 protected function checkBrowserGaleon()
1040 {
1041 if (stripos($this->_agent, 'galeon') !== false) {
1042 $aresult = explode(' ', stristr($this->_agent, 'galeon'));
1043 $aversion = explode('/', $aresult[0]);
1044 if (isset($aversion[1])) {
1045 $this->setVersion($aversion[1]);
1046 $this->_browser_name = self::BROWSER_GALEON;
1047
1048 return true;
1049 }
1050 }
1051
1052 return false;
1053 }
1054
1055 /**
1056 * Determine if the browser is Konqueror or not (last updated 1.7)
1057 * @return boolean True if the browser is Konqueror otherwise false
1058 */
1059 protected function checkBrowserKonqueror()
1060 {
1061 if (stripos($this->_agent, 'Konqueror') !== false) {
1062 $aresult = explode(' ', stristr($this->_agent, 'Konqueror'));
1063 $aversion = explode('/', $aresult[0]);
1064 if (isset($aversion[1])) {
1065 $this->setVersion($aversion[1]);
1066 $this->_browser_name = self::BROWSER_KONQUEROR;
1067
1068 return true;
1069 }
1070 }
1071
1072 return false;
1073 }
1074
1075 /**
1076 * Determine if the browser is iCab or not (last updated 1.7)
1077 * @return boolean True if the browser is iCab otherwise false
1078 */
1079 protected function checkBrowserIcab()
1080 {
1081 if (stripos($this->_agent, 'icab') !== false) {
1082 $aversion = explode(' ', stristr(str_replace('/', ' ', $this->_agent), 'icab'));
1083 if (isset($aversion[1])) {
1084 $this->setVersion($aversion[1]);
1085 $this->_browser_name = self::BROWSER_ICAB;
1086
1087 return true;
1088 }
1089 }
1090
1091 return false;
1092 }
1093
1094 /**
1095 * Determine if the browser is OmniWeb or not (last updated 1.7)
1096 * @return boolean True if the browser is OmniWeb otherwise false
1097 */
1098 protected function checkBrowserOmniWeb()
1099 {
1100 if (stripos($this->_agent, 'omniweb') !== false) {
1101 $aresult = explode('/', stristr($this->_agent, 'omniweb'));
1102 $aversion = explode(' ', isset($aresult[1]) ? $aresult[1] : '');
1103 $this->setVersion($aversion[0]);
1104 $this->_browser_name = self::BROWSER_OMNIWEB;
1105
1106 return true;
1107 }
1108
1109 return false;
1110 }
1111
1112 /**
1113 * Determine if the browser is Phoenix or not (last updated 1.7)
1114 * @return boolean True if the browser is Phoenix otherwise false
1115 */
1116 protected function checkBrowserPhoenix()
1117 {
1118 if (stripos($this->_agent, 'Phoenix') !== false) {
1119 $aversion = explode('/', stristr($this->_agent, 'Phoenix'));
1120 if (isset($aversion[1])) {
1121 $this->setVersion($aversion[1]);
1122 $this->_browser_name = self::BROWSER_PHOENIX;
1123
1124 return true;
1125 }
1126 }
1127
1128 return false;
1129 }
1130
1131 /**
1132 * Determine if the browser is Firebird or not (last updated 1.7)
1133 * @return boolean True if the browser is Firebird otherwise false
1134 */
1135 protected function checkBrowserFirebird()
1136 {
1137 if (stripos($this->_agent, 'Firebird') !== false) {
1138 $aversion = explode('/', stristr($this->_agent, 'Firebird'));
1139 if (isset($aversion[1])) {
1140 $this->setVersion($aversion[1]);
1141 $this->_browser_name = self::BROWSER_FIREBIRD;
1142
1143 return true;
1144 }
1145 }
1146
1147 return false;
1148 }
1149
1150 /**
1151 * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
1152 * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
1153 * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
1154 */
1155 protected function checkBrowserNetscapeNavigator9Plus()
1156 {
1157 if (stripos($this->_agent, 'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i', $this->_agent, $matches)) {
1158 $this->setVersion($matches[1]);
1159 $this->_browser_name = self::BROWSER_NETSCAPE_NAVIGATOR;
1160
1161 return true;
1162 } elseif (stripos($this->_agent, 'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i', $this->_agent, $matches)) {
1163 $this->setVersion($matches[1]);
1164 $this->_browser_name = self::BROWSER_NETSCAPE_NAVIGATOR;
1165
1166 return true;
1167 }
1168
1169 return false;
1170 }
1171
1172 /**
1173 * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
1174 * @return boolean True if the browser is Shiretoko otherwise false
1175 */
1176 protected function checkBrowserShiretoko()
1177 {
1178 if (stripos($this->_agent, 'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i', $this->_agent, $matches)) {
1179 $this->setVersion($matches[1]);
1180 $this->_browser_name = self::BROWSER_SHIRETOKO;
1181
1182 return true;
1183 }
1184
1185 return false;
1186 }
1187
1188 /**
1189 * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
1190 * @return boolean True if the browser is Ice Cat otherwise false
1191 */
1192 protected function checkBrowserIceCat()
1193 {
1194 if (stripos($this->_agent, 'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i', $this->_agent, $matches)) {
1195 $this->setVersion($matches[1]);
1196 $this->_browser_name = self::BROWSER_ICECAT;
1197
1198 return true;
1199 }
1200
1201 return false;
1202 }
1203
1204 /**
1205 * Determine if the browser is Nokia or not (last updated 1.7)
1206 * @return boolean True if the browser is Nokia otherwise false
1207 */
1208 protected function checkBrowserNokia()
1209 {
1210 if (preg_match('/Nokia([^\/]+)\/([^ SP]+)/i', $this->_agent, $matches)) {
1211 $this->setVersion($matches[2]);
1212 if (stripos($this->_agent, 'Series60') !== false || strpos($this->_agent, 'S60') !== false) {
1213 $this->_browser_name = self::BROWSER_NOKIA_S60;
1214 } else {
1215 $this->_browser_name = self::BROWSER_NOKIA;
1216 }
1217 $this->_is_mobile = true;
1218
1219 return true;
1220 }
1221
1222 return false;
1223 }
1224
1225 /**
1226 * Determine if the browser is Palemoon or not
1227 * @return boolean True if the browser is Palemoon otherwise false
1228 */
1229 protected function checkBrowserPalemoon()
1230 {
1231 if (stripos($this->_agent, 'safari') === false) {
1232 if (preg_match('/Palemoon[\/ \(]([^ ;\)]+)/i', $this->_agent, $matches)) {
1233 $this->setVersion($matches[1]);
1234 $this->_browser_name = self::BROWSER_PALEMOON;
1235
1236 return true;
1237 } elseif (preg_match('/Palemoon([0-9a-zA-Z\.]+)/i', $this->_agent, $matches)) {
1238 $this->setVersion($matches[1]);
1239 $this->_browser_name = self::BROWSER_PALEMOON;
1240
1241 return true;
1242 } elseif (preg_match('/Palemoon/i', $this->_agent, $matches)) {
1243 $this->setVersion('');
1244 $this->_browser_name = self::BROWSER_PALEMOON;
1245
1246 return true;
1247 }
1248 }
1249
1250 return false;
1251 }
1252
1253 /**
1254 * Determine if the browser is UCBrowser or not
1255 * @return boolean True if the browser is UCBrowser otherwise false
1256 */
1257 protected function checkBrowserUCBrowser()
1258 {
1259 if (preg_match('/UC ?Browser\/?([\d\.]+)/', $this->_agent, $matches)) {
1260 if (isset($matches[1])) {
1261 $this->setVersion($matches[1]);
1262 }
1263 if (stripos($this->_agent, 'Mobile') !== false) {
1264 $this->_is_mobile = true;
1265 } else {
1266 $this->_is_tablet = true;
1267 }
1268 $this->_browser_name = self::BROWSER_UCBROWSER;
1269
1270 return true;
1271 }
1272
1273 return false;
1274 }
1275
1276 /**
1277 * Determine if the browser is Firefox or not
1278 * @return boolean True if the browser is Firefox otherwise false
1279 */
1280 protected function checkBrowserFirefox()
1281 {
1282 if (stripos($this->_agent, 'safari') === false) {
1283 if (preg_match('/Firefox[\/ \(]([^ ;\)]+)/i', $this->_agent, $matches)) {
1284 $this->setVersion($matches[1]);
1285 $this->_browser_name = self::BROWSER_FIREFOX;
1286 //Firefox on Android
1287 if (stripos($this->_agent, 'Android') !== false || stripos($this->_agent, 'iPhone') !== false) {
1288 if (stripos($this->_agent, 'Mobile') !== false || stripos($this->_agent, 'Tablet') !== false) {
1289 $this->_is_mobile = true;
1290 } else {
1291 $this->_is_tablet = true;
1292 }
1293 }
1294
1295 return true;
1296 } elseif (preg_match('/Firefox([0-9a-zA-Z\.]+)/i', $this->_agent, $matches)) {
1297 $this->setVersion($matches[1]);
1298 $this->_browser_name = self::BROWSER_FIREFOX;
1299
1300 return true;
1301 } elseif (preg_match('/Firefox$/i', $this->_agent, $matches)) {
1302 $this->setVersion('');
1303 $this->_browser_name = self::BROWSER_FIREFOX;
1304
1305 return true;
1306 }
1307 } elseif (preg_match('/FxiOS[\/ \(]([^ ;\)]+)/i', $this->_agent, $matches)) {
1308 $this->setVersion($matches[1]);
1309 $this->_browser_name = self::BROWSER_FIREFOX;
1310 //Firefox on Android
1311 if (stripos($this->_agent, 'Android') !== false || stripos($this->_agent, 'iPhone') !== false) {
1312 if (stripos($this->_agent, 'Mobile') !== false || stripos($this->_agent, 'Tablet') !== false) {
1313 $this->_is_mobile = true;
1314 } else {
1315 $this->_is_tablet = true;
1316 }
1317 }
1318
1319 return true;
1320 }
1321
1322 return false;
1323 }
1324
1325 /**
1326 * Determine if the browser is Firefox or not (last updated 1.7)
1327 * @return boolean True if the browser is Firefox otherwise false
1328 */
1329 protected function checkBrowserIceweasel()
1330 {
1331 if (stripos($this->_agent, 'Iceweasel') !== false) {
1332 $aresult = explode('/', stristr($this->_agent, 'Iceweasel'));
1333 if (isset($aresult[1])) {
1334 $aversion = explode(' ', $aresult[1]);
1335 $this->setVersion($aversion[0]);
1336 $this->_browser_name = self::BROWSER_ICEWEASEL;
1337
1338 return true;
1339 }
1340 }
1341
1342 return false;
1343 }
1344
1345 /**
1346 * Determine if the browser is Mozilla or not (last updated 1.7)
1347 * @return boolean True if the browser is Mozilla otherwise false
1348 */
1349 protected function checkBrowserMozilla()
1350 {
1351 if (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) {
1352 $aversion = explode(' ', stristr($this->_agent, 'rv:'));
1353 preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion);
1354 $this->setVersion(str_replace('rv:', '', $aversion[0]));
1355 $this->_browser_name = self::BROWSER_MOZILLA;
1356
1357 return true;
1358 } elseif (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) {
1359 $aversion = explode('', stristr($this->_agent, 'rv:'));
1360 $this->setVersion(str_replace('rv:', '', $aversion[0]));
1361 $this->_browser_name = self::BROWSER_MOZILLA;
1362
1363 return true;
1364 } elseif (stripos($this->_agent, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', $this->_agent, $matches) && stripos($this->_agent, 'netscape') === false) {
1365 $this->setVersion($matches[1]);
1366 $this->_browser_name = self::BROWSER_MOZILLA;
1367
1368 return true;
1369 }
1370
1371 return false;
1372 }
1373
1374 /**
1375 * Determine if the browser is Lynx or not (last updated 1.7)
1376 * @return boolean True if the browser is Lynx otherwise false
1377 */
1378 protected function checkBrowserLynx()
1379 {
1380 if (stripos($this->_agent, 'lynx') !== false) {
1381 $aresult = explode('/', stristr($this->_agent, 'Lynx'));
1382 $aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : ''));
1383 $this->setVersion($aversion[0]);
1384 $this->_browser_name = self::BROWSER_LYNX;
1385
1386 return true;
1387 }
1388
1389 return false;
1390 }
1391
1392 /**
1393 * Determine if the browser is Amaya or not (last updated 1.7)
1394 * @return boolean True if the browser is Amaya otherwise false
1395 */
1396 protected function checkBrowserAmaya()
1397 {
1398 if (stripos($this->_agent, 'amaya') !== false) {
1399 $aresult = explode('/', stristr($this->_agent, 'Amaya'));
1400 if (isset($aresult[1])) {
1401 $aversion = explode(' ', $aresult[1]);
1402 $this->setVersion($aversion[0]);
1403 $this->_browser_name = self::BROWSER_AMAYA;
1404
1405 return true;
1406 }
1407 }
1408
1409 return false;
1410 }
1411
1412 /**
1413 * Determine if the browser is Safari or not (last updated 1.7)
1414 * @return boolean True if the browser is Safari otherwise false
1415 */
1416 protected function checkBrowserSafari()
1417 {
1418 if (stripos($this->_agent, 'Safari') !== false && stripos($this->_agent, 'iPhone') === false && stripos($this->_agent, 'iPod') === false) {
1419
1420 $aresult = explode('/', stristr($this->_agent, 'Version'));
1421 if (isset($aresult[1])) {
1422 $aversion = explode(' ', $aresult[1]);
1423 $this->setVersion($aversion[0]);
1424 } else {
1425 $this->setVersion(self::VERSION_UNKNOWN);
1426 }
1427 $this->_browser_name = self::BROWSER_SAFARI;
1428
1429 return true;
1430 }
1431
1432 return false;
1433 }
1434
1435 protected function checkBrowserSamsung()
1436 {
1437 if (stripos($this->_agent, 'SamsungBrowser') !== false) {
1438
1439 $aresult = explode('/', stristr($this->_agent, 'SamsungBrowser'));
1440 if (isset($aresult[1])) {
1441 $aversion = explode(' ', $aresult[1]);
1442 $this->setVersion($aversion[0]);
1443 } else {
1444 $this->setVersion(self::VERSION_UNKNOWN);
1445 }
1446 $this->_browser_name = self::BROWSER_SAMSUNG;
1447
1448 return true;
1449 }
1450
1451 return false;
1452 }
1453
1454 protected function checkQQBrowser()
1455 {
1456 if (stripos($this->_agent, 'qqbrowser') !== false) {
1457 $this->setVersion(self::VERSION_UNKNOWN);
1458 $this->_browser_name = self::BROWSER_QQ;
1459
1460 return true;
1461 }
1462
1463 return false;
1464 }
1465
1466 protected function checkBrowserSilk()
1467 {
1468 if (stripos($this->_agent, 'Silk') !== false) {
1469 $aresult = explode('/', stristr($this->_agent, 'Silk'));
1470 if (isset($aresult[1])) {
1471 $aversion = explode(' ', $aresult[1]);
1472 $this->setVersion($aversion[0]);
1473 } else {
1474 $this->setVersion(self::VERSION_UNKNOWN);
1475 }
1476 $this->_browser_name = self::BROWSER_SILK;
1477
1478 return true;
1479 }
1480
1481 return false;
1482 }
1483
1484 protected function checkBrowserIframely()
1485 {
1486 if (stripos($this->_agent, 'Iframely') !== false) {
1487 $aresult = explode('/', stristr($this->_agent, 'Iframely'));
1488 if (isset($aresult[1])) {
1489 $aversion = explode(' ', $aresult[1]);
1490 $this->setVersion($aversion[0]);
1491 } else {
1492 $this->setVersion(self::VERSION_UNKNOWN);
1493 }
1494 $this->_browser_name = self::BROWSER_I_FRAME;
1495
1496 return true;
1497 }
1498
1499 return false;
1500 }
1501
1502 protected function checkBrowserCocoa()
1503 {
1504 if (stripos($this->_agent, 'CocoaRestClient') !== false) {
1505 $aresult = explode('/', stristr($this->_agent, 'CocoaRestClient'));
1506 if (isset($aresult[1])) {
1507 $aversion = explode(' ', $aresult[1]);
1508 $this->setVersion($aversion[0]);
1509 } else {
1510 $this->setVersion(self::VERSION_UNKNOWN);
1511 }
1512 $this->_browser_name = self::BROWSER_COCOA;
1513
1514 return true;
1515 }
1516
1517 return false;
1518 }
1519
1520 /**
1521 * Detect if URL is loaded from FacebookExternalHit
1522 * @return boolean True if it detects FacebookExternalHit otherwise false
1523 */
1524 protected function checkFacebookExternalHit()
1525 {
1526 if (stristr($this->_agent, 'FacebookExternalHit')) {
1527 $this->_is_robot = true;
1528 $this->_is_facebook = true;
1529
1530 return true;
1531 }
1532
1533 return false;
1534 }
1535
1536 /**
1537 * Detect if URL is being loaded from internal Facebook browser
1538 * @return boolean True if it detects internal Facebook browser otherwise false
1539 */
1540 protected function checkForFacebookIos()
1541 {
1542 if (stristr($this->_agent, 'FBIOS')) {
1543 $this->_is_facebook = true;
1544
1545 return true;
1546 }
1547
1548 return false;
1549 }
1550
1551 /**
1552 * Detect Version for the Safari browser on iOS devices
1553 * @return boolean True if it detects the version correctly otherwise false
1554 */
1555 protected function getSafariVersionOnIos()
1556 {
1557 $aresult = explode('/', stristr($this->_agent, 'Version'));
1558 if (isset($aresult[1])) {
1559 $aversion = explode(' ', $aresult[1]);
1560 $this->setVersion($aversion[0]);
1561
1562 return true;
1563 }
1564
1565 return false;
1566 }
1567
1568 /**
1569 * Detect Version for the Chrome browser on iOS devices
1570 * @return boolean True if it detects the version correctly otherwise false
1571 */
1572 protected function getChromeVersionOnIos()
1573 {
1574 $aresult = explode('/', stristr($this->_agent, 'CriOS'));
1575 if (isset($aresult[1])) {
1576 $aversion = explode(' ', $aresult[1]);
1577 $this->setVersion($aversion[0]);
1578 $this->_browser_name = self::BROWSER_CHROME;
1579
1580 return true;
1581 }
1582
1583 return false;
1584 }
1585
1586 /**
1587 * Determine if the browser is iPhone or not (last updated 1.7)
1588 * @return boolean True if the browser is iPhone otherwise false
1589 */
1590 protected function checkBrowseriPhone()
1591 {
1592 if (stripos($this->_agent, 'iPhone') !== false) {
1593 $this->setVersion(self::VERSION_UNKNOWN);
1594 $this->_browser_name = self::BROWSER_IPHONE;
1595 $this->getSafariVersionOnIos();
1596 $this->getChromeVersionOnIos();
1597 $this->checkForFacebookIos();
1598 $this->_is_mobile = true;
1599
1600 return true;
1601 }
1602
1603 return false;
1604 }
1605
1606 /**
1607 * Determine if the browser is iPad or not (last updated 1.7)
1608 * @return boolean True if the browser is iPad otherwise false
1609 */
1610 protected function checkBrowseriPad()
1611 {
1612 if (stripos($this->_agent, 'iPad') !== false) {
1613 $this->setVersion(self::VERSION_UNKNOWN);
1614 $this->_browser_name = self::BROWSER_IPAD;
1615 $this->getSafariVersionOnIos();
1616 $this->getChromeVersionOnIos();
1617 $this->checkForFacebookIos();
1618 $this->_is_tablet = true;
1619
1620 return true;
1621 }
1622
1623 return false;
1624 }
1625
1626 /**
1627 * Determine if the browser is iPod or not (last updated 1.7)
1628 * @return boolean True if the browser is iPod otherwise false
1629 */
1630 protected function checkBrowseriPod()
1631 {
1632 if (stripos($this->_agent, 'iPod') !== false) {
1633 $this->setVersion(self::VERSION_UNKNOWN);
1634 $this->_browser_name = self::BROWSER_IPOD;
1635 $this->getSafariVersionOnIos();
1636 $this->getChromeVersionOnIos();
1637 $this->checkForFacebookIos();
1638 $this->_is_mobile = true;
1639
1640 return true;
1641 }
1642
1643 return false;
1644 }
1645
1646 /**
1647 * Determine if the browser is Android or not (last updated 1.7)
1648 * @return boolean True if the browser is Android otherwise false
1649 */
1650 protected function checkBrowserAndroid()
1651 {
1652 if (stripos($this->_agent, 'Android') !== false) {
1653 $aresult = explode(' ', stristr($this->_agent, 'Android'));
1654 if (isset($aresult[1])) {
1655 $aversion = explode(' ', $aresult[1]);
1656 $this->setVersion($aversion[0]);
1657 } else {
1658 $this->setVersion(self::VERSION_UNKNOWN);
1659 }
1660 if (stripos($this->_agent, 'Mobile') !== false) {
1661 $this->_is_mobile = true;
1662 } else {
1663 $this->_is_tablet = true;
1664 }
1665 $this->_browser_name = self::BROWSER_ANDROID;
1666
1667 return true;
1668 }
1669
1670 return false;
1671 }
1672
1673 /**
1674 * Determine if the browser is Vivaldi
1675 * @return boolean True if the browser is Vivaldi otherwise false
1676 */
1677 protected function checkBrowserVivaldi()
1678 {
1679 if (stripos($this->_agent, 'Vivaldi') !== false) {
1680 $aresult = explode('/', stristr($this->_agent, 'Vivaldi'));
1681 if (isset($aresult[1])) {
1682 $aversion = explode(' ', $aresult[1]);
1683 $this->setVersion($aversion[0]);
1684 $this->_browser_name = self::BROWSER_VIVALDI;
1685
1686 return true;
1687 }
1688 }
1689
1690 return false;
1691 }
1692
1693 /**
1694 * Determine if the browser is Yandex
1695 * @return boolean True if the browser is Yandex otherwise false
1696 */
1697 protected function checkBrowserYandex()
1698 {
1699 if (stripos($this->_agent, 'YaBrowser') !== false) {
1700 $aresult = explode('/', stristr($this->_agent, 'YaBrowser'));
1701 if (isset($aresult[1])) {
1702 $aversion = explode(' ', $aresult[1]);
1703 $this->setVersion($aversion[0]);
1704 $this->_browser_name = self::BROWSER_YANDEX;
1705
1706 if (stripos($this->_agent, 'iPad') !== false) {
1707 $this->_is_tablet = true;
1708 } elseif (stripos($this->_agent, 'Mobile') !== false) {
1709 $this->_is_mobile = true;
1710 } elseif (stripos($this->_agent, 'Android') !== false) {
1711 $this->_is_tablet = true;
1712 }
1713
1714 return true;
1715 }
1716 }
1717
1718 return false;
1719 }
1720
1721 /**
1722 * Determine if the browser is a PlayStation
1723 * @return boolean True if the browser is PlayStation otherwise false
1724 */
1725 protected function checkBrowserPlayStation()
1726 {
1727 if (stripos($this->_agent, 'PlayStation ') !== false) {
1728 $aresult = explode(' ', stristr($this->_agent, 'PlayStation '));
1729 $this->_browser_name = self::BROWSER_PLAYSTATION;
1730 if (isset($aresult[0])) {
1731 $aversion = explode(')', $aresult[2]);
1732 $this->setVersion($aversion[0]);
1733 if (stripos($this->_agent, 'Portable)') !== false || stripos($this->_agent, 'Vita') !== false) {
1734 $this->_is_mobile = true;
1735 }
1736
1737 return true;
1738 }
1739 }
1740
1741 return false;
1742 }
1743
1744 /**
1745 * Determine if the browser is Wget or not (last updated 1.7)
1746 * @return boolean True if the browser is Wget otherwise false
1747 */
1748 protected function checkBrowserWget()
1749 {
1750 if (preg_match('!^Wget/([^ ]+)!i', $this->_agent, $aresult)) {
1751 $this->setVersion($aresult[1]);
1752 $this->_browser_name = self::BROWSER_WGET;
1753
1754 return true;
1755 }
1756
1757 return false;
1758 }
1759
1760 /**
1761 * Determine if the browser is cURL or not (last updated 1.7)
1762 * @return boolean True if the browser is cURL otherwise false
1763 */
1764 protected function checkBrowserCurl()
1765 {
1766 if (strpos($this->_agent, 'curl') === 0) {
1767 $aresult = explode('/', stristr($this->_agent, 'curl'));
1768 if (isset($aresult[1])) {
1769 $aversion = explode(' ', $aresult[1]);
1770 $this->setVersion($aversion[0]);
1771 $this->_browser_name = self::BROWSER_CURL;
1772
1773 return true;
1774 }
1775 }
1776
1777 return false;
1778 }
1779
1780 /**
1781 * Determine the user's platform (last updated 2.0)
1782 */
1783 protected function checkPlatform()
1784 {
1785 if (stripos($this->_agent, 'windows') !== false) {
1786 $this->_platform = self::PLATFORM_WINDOWS;
1787 } elseif (stripos($this->_agent, 'iPad') !== false) {
1788 $this->_platform = self::PLATFORM_IPAD;
1789 } elseif (stripos($this->_agent, 'iPod') !== false) {
1790 $this->_platform = self::PLATFORM_IPOD;
1791 } elseif (stripos($this->_agent, 'iPhone') !== false) {
1792 $this->_platform = self::PLATFORM_IPHONE;
1793 } elseif (stripos($this->_agent, 'mac') !== false) {
1794 $this->_platform = self::PLATFORM_APPLE;
1795 } elseif (stripos($this->_agent, 'android') !== false) {
1796 $this->_platform = self::PLATFORM_ANDROID;
1797 } elseif (stripos($this->_agent, 'Silk') !== false) {
1798 $this->_platform = self::PLATFORM_FIRE_OS;
1799 } elseif (stripos($this->_agent, 'linux') !== false && stripos($this->_agent, 'SMART-TV') !== false) {
1800 $this->_platform = self::PLATFORM_LINUX.'/'.self::PLATFORM_SMART_TV;
1801 } elseif (stripos($this->_agent, 'linux') !== false) {
1802 $this->_platform = self::PLATFORM_LINUX;
1803 } elseif (stripos($this->_agent, 'Nokia') !== false) {
1804 $this->_platform = self::PLATFORM_NOKIA;
1805 } elseif (stripos($this->_agent, 'BlackBerry') !== false) {
1806 $this->_platform = self::PLATFORM_BLACKBERRY;
1807 } elseif (stripos($this->_agent, 'FreeBSD') !== false) {
1808 $this->_platform = self::PLATFORM_FREEBSD;
1809 } elseif (stripos($this->_agent, 'OpenBSD') !== false) {
1810 $this->_platform = self::PLATFORM_OPENBSD;
1811 } elseif (stripos($this->_agent, 'NetBSD') !== false) {
1812 $this->_platform = self::PLATFORM_NETBSD;
1813 } elseif (stripos($this->_agent, 'OpenSolaris') !== false) {
1814 $this->_platform = self::PLATFORM_OPENSOLARIS;
1815 } elseif (stripos($this->_agent, 'SunOS') !== false) {
1816 $this->_platform = self::PLATFORM_SUNOS;
1817 } elseif (stripos($this->_agent, 'OS\/2') !== false) {
1818 $this->_platform = self::PLATFORM_OS2;
1819 } elseif (stripos($this->_agent, 'BeOS') !== false) {
1820 $this->_platform = self::PLATFORM_BEOS;
1821 } elseif (stripos($this->_agent, 'win') !== false) {
1822 $this->_platform = self::PLATFORM_WINDOWS;
1823 } elseif (stripos($this->_agent, 'Playstation') !== false) {
1824 $this->_platform = self::PLATFORM_PLAYSTATION;
1825 } elseif (stripos($this->_agent, 'Roku') !== false) {
1826 $this->_platform = self::PLATFORM_ROKU;
1827 } elseif (stripos($this->_agent, 'iOS') !== false) {
1828 $this->_platform = self::PLATFORM_IPHONE.'/'.self::PLATFORM_IPAD;
1829 } elseif (stripos($this->_agent, 'tvOS') !== false) {
1830 $this->_platform = self::PLATFORM_APPLE_TV;
1831 } elseif (stripos($this->_agent, 'curl') !== false) {
1832 $this->_platform = self::PLATFORM_TERMINAL;
1833 } elseif (stripos($this->_agent, 'CrOS') !== false) {
1834 $this->_platform = self::PLATFORM_CHROME_OS;
1835 } elseif (stripos($this->_agent, 'okhttp') !== false) {
1836 $this->_platform = self::PLATFORM_JAVA_ANDROID;
1837 } elseif (stripos($this->_agent, 'PostmanRuntime') !== false) {
1838 $this->_platform = self::PLATFORM_POSTMAN;
1839 } elseif (stripos($this->_agent, 'Iframely') !== false) {
1840 $this->_platform = self::PLATFORM_I_FRAME;
1841 }
1842 }
1843 }
1844