PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.8
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.8
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / Browser / Browser.php

Browser.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.8, at app/Services/Browser/Browser.php

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