PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.9.6
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.9.6
3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 194 releases
convertkit / lib / browser.php

browser.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 1.9.6, at lib/browser.php

1,124 lines 38.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Adapted for ConvertKit from Easy Digital Downloads
10 * https://github.com/easydigitaldownloads/easy-digital-downloads
11 *
12 * Modified to remove var
13 * Chris Christoff on 12/26/2012
14 * Changes: Changes vars to publics
15 *
16 * Modified to work for EDD by
17 * Chris Christoff on 12/23/2012
18 * Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
19 *
20 * Modified to add formatted User Agent string for EDD System Info by
21 * Chris Christoff on 12/23/2012
22 * Changes: Split user string and add formatting so we can print a nicely
23 * formatted user agent string on the EDD System Info
24 *
25 * File: Browser.php
26 * Author: Chris Schuld (http://chrisschuld.com/)
27 * Last Modified: August 20th, 2010
28 *
29 * @version 1.9
30 * @package PegasusPHP
31 *
32 * Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
33 *
34 * This program is free software; you can redistribute it and/or
35 * modify it under the terms of the GNU General Public License as
36 * published by the Free Software Foundation; either version 2 of
37 * the License, or (at your option) any later version.
38 *
39 * This program is distributed in the hope that it will be useful,
40 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 * GNU General Public License for more details at:
43 * http://www.gnu.org/copyleft/gpl.html
44 *
45 *
46 * Typical Usage:
47 *
48 * $browser = new Browser();
49 * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
50 * echo 'You have FireFox version 2 or greater';
51 * }
52 *
53 * User Agents Sampled from: http://www.useragentstring.com/
54 *
55 * This implementation is based on the original work from Gary White
56 * http://apptools.com/phptools/browser/
57 *
58 * UPDATES:
59 *
60 * 2010-08-20 (v1.9):
61 * + Added MSN Explorer Browser (legacy)
62 * + Added Bing/MSN Robot (Thanks Rob MacDonald)
63 * + Added the Android Platform (PLATFORM_ANDROID)
64 * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
65 *
66 * 2010-04-27 (v1.8):
67 * + Added iPad Support
68 *
69 * 2010-03-07 (v1.7):
70 * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
71 * + Almost allof Gary's original code has been replaced
72 * + Large PHPUNIT testing environment created to validate new releases and additions
73 * + Added FreeBSD Platform
74 * + Added OpenBSD Platform
75 * + Added NetBSD Platform
76 * + Added SunOS Platform
77 * + Added OpenSolaris Platform
78 * + Added support of the Iceweazel Browser
79 * + Added isChromeFrame() call to check if chromeframe is in use
80 * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
81 * + Added the __toString() method (Thanks Deano)
82 *
83 * 2009-11-15:
84 * + Updated the checkes for Firefox
85 * + Added the NOKIA platform
86 * + Added Checks for the NOKIA brower(s)
87 *
88 * 2009-11-08:
89 * + PHP 5.3 Support
90 * + Added support for BlackBerry OS and BlackBerry browser
91 * + Added support for the Opera Mini browser
92 * + Added additional documenation
93 * + Added support for isRobot() and isMobile()
94 * + Added support for Opera version 10
95 * + Added support for deprecated Netscape Navigator version 9
96 * + Added support for IceCat
97 * + Added support for Shiretoko
98 *
99 * 2010-04-27 (v1.8):
100 * + Added iPad Support
101 *
102 * 2009-08-18:
103 * + Updated to support PHP 5.3 - removed all deprecated function calls
104 * + Updated to remove all double quotes (") -- converted to single quotes (')
105 *
106 * 2009-04-27:
107 * + Updated the IE check to remove a typo and bug (thanks John)
108 *
109 * 2009-04-22:
110 * + Added detection for GoogleBot
111 * + Added detection for the W3C Validator.
112 * + Added detection for Yahoo! Slurp
113 *
114 * 2009-03-14:
115 * + Added detection for iPods.
116 * + Added Platform detection for iPhones
117 * + Added Platform detection for iPods
118 *
119 * 2009-02-16: (Rick Hale)
120 * + Added version detection for Android phones.
121 *
122 * 2008-12-09:
123 * + Removed unused constant
124 *
125 * 2008-11-07:
126 * + Added Google's Chrome to the detection list
127 * + Added isBrowser(string) to the list of functions special thanks to
128 * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
129 *
130 *
131 * Gary White noted: "Since browser detection is so unreliable, I am
132 * no longer maintaining this script. You are free to use and or
133 * modify/update it as you want, however the author assumes no
134 * responsibility for the accuracy of the detected values."
135 *
136 * Anyone experienced with Gary's script might be interested in these notes:
137 *
138 * Added class constants
139 * Added detection and version detection for Google's Chrome
140 * Updated the version detection for Amaya
141 * Updated the version detection for Firefox
142 * Updated the version detection for Lynx
143 * Updated the version detection for WebTV
144 * Updated the version detection for NetPositive
145 * Updated the version detection for IE
146 * Updated the version detection for OmniWeb
147 * Updated the version detection for iCab
148 * Updated the version detection for Safari
149 * Updated Safari to remove mobile devices (iPhone)
150 * Added detection for iPhone
151 * Added detection for robots
152 * Added detection for mobile devices
153 * Added detection for BlackBerry
154 * Removed Netscape checks (matches heavily with firefox & mozilla)
155 */
156
157 class Browser {
158 public $_agent = '';
159 public $_browser_name = '';
160 public $_version = '';
161 public $_platform = '';
162 public $_os = '';
163 public $_is_aol = false;
164 public $_is_mobile = false;
165 public $_is_robot = false;
166 public $_aol_version = '';
167
168 public $BROWSER_UNKNOWN = 'unknown';
169 public $VERSION_UNKNOWN = 'unknown';
170
171 public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
172 public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
173 public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
174 public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
175 public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
176 public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
177 public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
178 public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
179 public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
180 public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
181 public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
182 public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
183 public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
184 public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
185 public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
186 public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
187 public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
188 public $BROWSER_IPOD = 'iPod'; // Http://apple.com
189 public $BROWSER_IPAD = 'iPad'; // Http://apple.com
190 public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
191 public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
192 public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
193 public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
194 public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
195 public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
196 public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
197 public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
198 public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
199 public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
200 public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
201 // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
202
203 public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
204 public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
205 public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
206 public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
207
208 public $PLATFORM_UNKNOWN = 'unknown';
209 public $PLATFORM_WINDOWS = 'Windows';
210 public $PLATFORM_WINDOWS_CE = 'Windows CE';
211 public $PLATFORM_APPLE = 'Apple';
212 public $PLATFORM_LINUX = 'Linux';
213 public $PLATFORM_OS2 = 'OS/2';
214 public $PLATFORM_BEOS = 'BeOS';
215 public $PLATFORM_IPHONE = 'iPhone';
216 public $PLATFORM_IPOD = 'iPod';
217 public $PLATFORM_IPAD = 'iPad';
218 public $PLATFORM_BLACKBERRY = 'BlackBerry';
219 public $PLATFORM_NOKIA = 'Nokia';
220 public $PLATFORM_FREEBSD = 'FreeBSD';
221 public $PLATFORM_OPENBSD = 'OpenBSD';
222 public $PLATFORM_NETBSD = 'NetBSD';
223 public $PLATFORM_SUNOS = 'SunOS';
224 public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
225 public $PLATFORM_ANDROID = 'Android';
226
227 public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
228
229 function __construct( $useragent = '' ) {
230 $this->reset();
231 if ( $useragent != '' ) {
232 $this->setUserAgent( $useragent );
233 } else {
234 $this->determine();
235 }
236 }
237
238 /**
239 * Reset all properties
240 */
241 function reset() {
242 $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
243 $this->_browser_name = $this->BROWSER_UNKNOWN;
244 $this->_version = $this->VERSION_UNKNOWN;
245 $this->_platform = $this->PLATFORM_UNKNOWN;
246 $this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
247 $this->_is_aol = false;
248 $this->_is_mobile = false;
249 $this->_is_robot = false;
250 $this->_aol_version = $this->VERSION_UNKNOWN;
251 }
252
253 /**
254 * Check to see if the specific browser is valid
255 *
256 * @param string $browserName
257 * @return True if the browser is the specified browser
258 */
259 function isBrowser( $browserName ) {
260 return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); }
261
262 /**
263 * The name of the browser. All return types are from the class contants
264 *
265 * @return string Name of the browser
266 */
267 function getBrowser() {
268 return $this->_browser_name; }
269 /**
270 * Set the name of the browser
271 *
272 * @param unknown $browser The name of the Browser
273 */
274 function setBrowser( $browser ) {
275 return $this->_browser_name = $browser; }
276 /**
277 * The name of the platform. All return types are from the class contants
278 *
279 * @return string Name of the browser
280 */
281 function getPlatform() {
282 return $this->_platform; }
283 /**
284 * Set the name of the platform
285 *
286 * @param unknown $platform The name of the Platform
287 */
288 function setPlatform( $platform ) {
289 return $this->_platform = $platform; }
290 /**
291 * The version of the browser.
292 *
293 * @return string Version of the browser (will only contain alpha-numeric characters and a period)
294 */
295 function getVersion() {
296 return $this->_version; }
297 /**
298 * Set the version of the browser
299 *
300 * @param unknown $version The version of the Browser
301 */
302 function setVersion( $version ) {
303 $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); }
304 /**
305 * The version of AOL.
306 *
307 * @return string Version of AOL (will only contain alpha-numeric characters and a period)
308 */
309 function getAolVersion() {
310 return $this->_aol_version; }
311 /**
312 * Set the version of AOL
313 *
314 * @param unknown $version The version of AOL
315 */
316 function setAolVersion( $version ) {
317 $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); }
318 /**
319 * Is the browser from AOL?
320 *
321 * @return boolean True if the browser is from AOL otherwise false
322 */
323 function isAol() {
324 return $this->_is_aol; }
325 /**
326 * Is the browser from a mobile device?
327 *
328 * @return boolean True if the browser is from a mobile device otherwise false
329 */
330 function isMobile() {
331 return $this->_is_mobile; }
332 /**
333 * Is the browser from a robot (ex Slurp,GoogleBot)?
334 *
335 * @return boolean True if the browser is from a robot otherwise false
336 */
337 function isRobot() {
338 return $this->_is_robot; }
339 /**
340 * Set the browser to be from AOL
341 *
342 * @param unknown $isAol
343 */
344 function setAol( $isAol ) {
345 $this->_is_aol = $isAol; }
346 /**
347 * Set the Browser to be mobile
348 *
349 * @param boolean $value is the browser a mobile brower or not
350 */
351 function setMobile( $value = true ) {
352 $this->_is_mobile = $value; }
353 /**
354 * Set the Browser to be a robot
355 *
356 * @param boolean $value is the browser a robot or not
357 */
358 function setRobot( $value = true ) {
359 $this->_is_robot = $value; }
360 /**
361 * Get the user agent value in use to determine the browser
362 *
363 * @return string The user agent from the HTTP header
364 */
365 function getUserAgent() {
366 return $this->_agent; }
367 /**
368 * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
369 *
370 * @param unknown $agent_string The value for the User Agent
371 */
372 function setUserAgent( $agent_string ) {
373 $this->reset();
374 $this->_agent = $agent_string;
375 $this->determine();
376 }
377 /**
378 * Used to determine if the browser is actually "chromeframe"
379 *
380 * @since 1.7
381 * @return boolean True if the browser is using chromeframe
382 */
383 function isChromeFrame() {
384 return strpos( $this->_agent, 'chromeframe' ) !== false;
385 }
386 /**
387 * Returns a formatted string with a summary of the details of the browser.
388 *
389 * @return string formatted string with a summary of the browser
390 */
391 function __toString() {
392 $text1 = $this->getUserAgent(); // grabs the UA (user agent) string
393 $UAline1 = substr( $text1, 0, 32 ); // the first line we print should only be the first 32 characters of the UA string
394 $text2 = $this->getUserAgent();// now we grab it again and save it to a string
395 $towrapUA = str_replace( $UAline1, '', $text2 );// the rest of the printoff (other than first line) is equivolent
396 // To the whole string minus the part we printed off. IE
397 // User Agent: thefirst32charactersfromUAline1
398 // the rest of it is now stored in
399 // $text2 to be printed off
400 // But we need to add spaces before each line that is split other than line 1
401 $space = '';
402 for ( $i = 0; $i < 25; $i++ ) {
403 $space .= ' ';
404 }
405 // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
406 $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" );
407 return "Platform: {$this->getPlatform()} \n" .
408 "Browser Name: {$this->getBrowser()} \n" .
409 "Browser Version: {$this->getVersion()} \n" .
410 "User Agent String: $UAline1 \n\t\t\t " .
411 "$wordwrapped";
412 }
413 /**
414 * Protected routine to calculate and determine what the browser is in use (including platform)
415 */
416 function determine() {
417 $this->checkPlatform();
418 $this->checkBrowsers();
419 $this->checkForAol();
420 }
421 /**
422 * Protected routine to determine the browser type
423 *
424 * @return boolean True if the browser was detected otherwise false
425 */
426 function checkBrowsers() {
427 return (
428 // Well-known, well-used
429 // Special Notes:
430 // (1) Opera must be checked before FireFox due to the odd
431 // user agents used in some older versions of Opera
432 // (2) WebTV is strapped onto Internet Explorer so we must
433 // check for WebTV before IE
434 // (3) (deprecated) Galeon is based on Firefox and needs to be
435 // tested before Firefox is tested
436 // (4) OmniWeb is based on Safari so OmniWeb check must occur
437 // before Safari
438 // (5) Netscape 9+ is based on Firefox so Netscape checks
439 // before FireFox are necessary
440 $this->checkBrowserWebTv() ||
441 $this->checkBrowserInternetExplorer() ||
442 $this->checkBrowserOpera() ||
443 $this->checkBrowserGaleon() ||
444 $this->checkBrowserNetscapeNavigator9Plus() ||
445 $this->checkBrowserFirefox() ||
446 $this->checkBrowserChrome() ||
447 $this->checkBrowserOmniWeb() ||
448
449 // Common mobile
450 $this->checkBrowserAndroid() ||
451 $this->checkBrowseriPad() ||
452 $this->checkBrowseriPod() ||
453 $this->checkBrowseriPhone() ||
454 $this->checkBrowserBlackBerry() ||
455 $this->checkBrowserNokia() ||
456
457 // Common bots
458 $this->checkBrowserGoogleBot() ||
459 $this->checkBrowserMSNBot() ||
460 $this->checkBrowserSlurp() ||
461
462 // WebKit base check (post mobile and others)
463 $this->checkBrowserSafari() ||
464
465 // Everyone else
466 $this->checkBrowserNetPositive() ||
467 $this->checkBrowserFirebird() ||
468 $this->checkBrowserKonqueror() ||
469 $this->checkBrowserIcab() ||
470 $this->checkBrowserPhoenix() ||
471 $this->checkBrowserAmaya() ||
472 $this->checkBrowserLynx() ||
473
474 $this->checkBrowserShiretoko() ||
475 $this->checkBrowserIceCat() ||
476 $this->checkBrowserW3CValidator() ||
477 $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
478 );
479 }
480
481 /**
482 * Determine if the user is using a BlackBerry (last updated 1.7)
483 *
484 * @return boolean True if the browser is the BlackBerry browser otherwise false
485 */
486 function checkBrowserBlackBerry() {
487 if ( stripos( $this->_agent, 'blackberry' ) !== false ) {
488 $aresult = explode( '/', stristr( $this->_agent, 'BlackBerry' ) );
489 $aversion = explode( ' ', $aresult[1] );
490 $this->setVersion( $aversion[0] );
491 $this->_browser_name = $this->BROWSER_BLACKBERRY;
492 $this->setMobile( true );
493 return true;
494 }
495 return false;
496 }
497
498 /**
499 * Determine if the user is using an AOL User Agent (last updated 1.7)
500 *
501 * @return boolean True if the browser is from AOL otherwise false
502 */
503 function checkForAol() {
504 $this->setAol( false );
505 $this->setAolVersion( $this->VERSION_UNKNOWN );
506
507 if ( stripos( $this->_agent, 'aol' ) !== false ) {
508 $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) );
509 $this->setAol( true );
510 $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) );
511 return true;
512 }
513 return false;
514 }
515
516 /**
517 * Determine if the browser is the GoogleBot or not (last updated 1.7)
518 *
519 * @return boolean True if the browser is the GoogletBot otherwise false
520 */
521 function checkBrowserGoogleBot() {
522 if ( stripos( $this->_agent, 'googlebot' ) !== false ) {
523 $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) );
524 $aversion = explode( ' ', $aresult[1] );
525 $this->setVersion( str_replace( ';', '', $aversion[0] ) );
526 $this->_browser_name = $this->BROWSER_GOOGLEBOT;
527 $this->setRobot( true );
528 return true;
529 }
530 return false;
531 }
532
533 /**
534 * Determine if the browser is the MSNBot or not (last updated 1.9)
535 *
536 * @return boolean True if the browser is the MSNBot otherwise false
537 */
538 function checkBrowserMSNBot() {
539 if ( stripos( $this->_agent, 'msnbot' ) !== false ) {
540 $aresult = explode( '/', stristr( $this->_agent, 'msnbot' ) );
541 $aversion = explode( ' ', $aresult[1] );
542 $this->setVersion( str_replace( ';', '', $aversion[0] ) );
543 $this->_browser_name = $this->BROWSER_MSNBOT;
544 $this->setRobot( true );
545 return true;
546 }
547 return false;
548 }
549
550 /**
551 * Determine if the browser is the W3C Validator or not (last updated 1.7)
552 *
553 * @return boolean True if the browser is the W3C Validator otherwise false
554 */
555 function checkBrowserW3CValidator() {
556 if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) {
557 $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) );
558 $aversion = explode( ' ', $aresult[1] );
559 $this->setVersion( $aversion[0] );
560 $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
561 return true;
562 } elseif ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) {
563 // Some of the Validator versions do not delineate w/ a slash - add it back in
564 $ua = str_replace( 'W3C_Validator ', 'W3C_Validator/', $this->_agent );
565 $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) );
566 $aversion = explode( ' ', $aresult[1] );
567 $this->setVersion( $aversion[0] );
568 $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
569 return true;
570 }
571 return false;
572 }
573
574 /**
575 * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
576 *
577 * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
578 */
579 function checkBrowserSlurp() {
580 if ( stripos( $this->_agent, 'slurp' ) !== false ) {
581 $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) );
582 $aversion = explode( ' ', $aresult[1] );
583 $this->setVersion( $aversion[0] );
584 $this->_browser_name = $this->BROWSER_SLURP;
585 $this->setRobot( true );
586 $this->setMobile( false );
587 return true;
588 }
589 return false;
590 }
591
592 /**
593 * Determine if the browser is Internet Explorer or not (last updated 1.7)
594 *
595 * @return boolean True if the browser is Internet Explorer otherwise false
596 */
597 function checkBrowserInternetExplorer() {
598
599 // Test for v1 - v1.5 IE
600 if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) {
601 $this->setBrowser( $this->BROWSER_IE );
602 $this->setVersion( '1.0' );
603 $aresult = stristr( $this->_agent, '/' );
604 if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) {
605 $this->setVersion( '1.5' );
606 }
607 return true;
608 }
609 // Test for versions > 1.5
610 elseif ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) {
611 // See if the browser is the odd MSN Explorer
612 if ( stripos( $this->_agent, 'msnb' ) !== false ) {
613 $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) );
614 $this->setBrowser( $this->BROWSER_MSN );
615 $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
616 return true;
617 }
618 $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) );
619 $this->setBrowser( $this->BROWSER_IE );
620 $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
621 return true;
622 }
623 // Test for Pocket IE
624 elseif ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) {
625 $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) );
626 $this->setPlatform( $this->PLATFORM_WINDOWS_CE );
627 $this->setBrowser( $this->BROWSER_POCKET_IE );
628 $this->setMobile( true );
629
630 if ( stripos( $this->_agent, 'mspie' ) !== false ) {
631 $this->setVersion( $aresult[1] );
632 } else {
633 $aversion = explode( '/', $this->_agent );
634 $this->setVersion( $aversion[1] );
635 }
636 return true;
637 }
638 return false;
639 }
640
641 /**
642 * Determine if the browser is Opera or not (last updated 1.7)
643 *
644 * @return boolean True if the browser is Opera otherwise false
645 */
646 function checkBrowserOpera() {
647 if ( stripos( $this->_agent, 'opera mini' ) !== false ) {
648 $resultant = stristr( $this->_agent, 'opera mini' );
649 if ( preg_match( '/\//', $resultant ) ) {
650 $aresult = explode( '/', $resultant );
651 $aversion = explode( ' ', $aresult[1] );
652 $this->setVersion( $aversion[0] );
653 } else {
654 $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) );
655 $this->setVersion( $aversion[1] );
656 }
657 $this->_browser_name = $this->BROWSER_OPERA_MINI;
658 $this->setMobile( true );
659 return true;
660 } elseif ( stripos( $this->_agent, 'opera' ) !== false ) {
661 $resultant = stristr( $this->_agent, 'opera' );
662 if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) {
663 $this->setVersion( $matches[1] );
664 } elseif ( preg_match( '/\//', $resultant ) ) {
665 $aresult = explode( '/', str_replace( '(', ' ', $resultant ) );
666 $aversion = explode( ' ', $aresult[1] );
667 $this->setVersion( $aversion[0] );
668 } else {
669 $aversion = explode( ' ', stristr( $resultant, 'opera' ) );
670 $this->setVersion( isset( $aversion[1] ) ? $aversion[1] : '' );
671 }
672 $this->_browser_name = $this->BROWSER_OPERA;
673 return true;
674 }
675 return false;
676 }
677
678 /**
679 * Determine if the browser is Chrome or not (last updated 1.7)
680 *
681 * @return boolean True if the browser is Chrome otherwise false
682 */
683 function checkBrowserChrome() {
684 if ( stripos( $this->_agent, 'Chrome' ) !== false ) {
685 $aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) );
686 $aversion = explode( ' ', $aresult[1] );
687 $this->setVersion( $aversion[0] );
688 $this->setBrowser( $this->BROWSER_CHROME );
689 return true;
690 }
691 return false;
692 }
693
694
695 /**
696 * Determine if the browser is WebTv or not (last updated 1.7)
697 *
698 * @return boolean True if the browser is WebTv otherwise false
699 */
700 function checkBrowserWebTv() {
701 if ( stripos( $this->_agent, 'webtv' ) !== false ) {
702 $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) );
703 $aversion = explode( ' ', $aresult[1] );
704 $this->setVersion( $aversion[0] );
705 $this->setBrowser( $this->BROWSER_WEBTV );
706 return true;
707 }
708 return false;
709 }
710
711 /**
712 * Determine if the browser is NetPositive or not (last updated 1.7)
713 *
714 * @return boolean True if the browser is NetPositive otherwise false
715 */
716 function checkBrowserNetPositive() {
717 if ( stripos( $this->_agent, 'NetPositive' ) !== false ) {
718 $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) );
719 $aversion = explode( ' ', $aresult[1] );
720 $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) );
721 $this->setBrowser( $this->BROWSER_NETPOSITIVE );
722 return true;
723 }
724 return false;
725 }
726
727 /**
728 * Determine if the browser is Galeon or not (last updated 1.7)
729 *
730 * @return boolean True if the browser is Galeon otherwise false
731 */
732 function checkBrowserGaleon() {
733 if ( stripos( $this->_agent, 'galeon' ) !== false ) {
734 $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) );
735 $aversion = explode( '/', $aresult[0] );
736 $this->setVersion( $aversion[1] );
737 $this->setBrowser( $this->BROWSER_GALEON );
738 return true;
739 }
740 return false;
741 }
742
743 /**
744 * Determine if the browser is Konqueror or not (last updated 1.7)
745 *
746 * @return boolean True if the browser is Konqueror otherwise false
747 */
748 function checkBrowserKonqueror() {
749 if ( stripos( $this->_agent, 'Konqueror' ) !== false ) {
750 $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) );
751 $aversion = explode( '/', $aresult[0] );
752 $this->setVersion( $aversion[1] );
753 $this->setBrowser( $this->BROWSER_KONQUEROR );
754 return true;
755 }
756 return false;
757 }
758
759 /**
760 * Determine if the browser is iCab or not (last updated 1.7)
761 *
762 * @return boolean True if the browser is iCab otherwise false
763 */
764 function checkBrowserIcab() {
765 if ( stripos( $this->_agent, 'icab' ) !== false ) {
766 $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) );
767 $this->setVersion( $aversion[1] );
768 $this->setBrowser( $this->BROWSER_ICAB );
769 return true;
770 }
771 return false;
772 }
773
774 /**
775 * Determine if the browser is OmniWeb or not (last updated 1.7)
776 *
777 * @return boolean True if the browser is OmniWeb otherwise false
778 */
779 function checkBrowserOmniWeb() {
780 if ( stripos( $this->_agent, 'omniweb' ) !== false ) {
781 $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) );
782 $aversion = explode( ' ', isset( $aresult[1] ) ? $aresult[1] : '' );
783 $this->setVersion( $aversion[0] );
784 $this->setBrowser( $this->BROWSER_OMNIWEB );
785 return true;
786 }
787 return false;
788 }
789
790 /**
791 * Determine if the browser is Phoenix or not (last updated 1.7)
792 *
793 * @return boolean True if the browser is Phoenix otherwise false
794 */
795 function checkBrowserPhoenix() {
796 if ( stripos( $this->_agent, 'Phoenix' ) !== false ) {
797 $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) );
798 $this->setVersion( $aversion[1] );
799 $this->setBrowser( $this->BROWSER_PHOENIX );
800 return true;
801 }
802 return false;
803 }
804
805 /**
806 * Determine if the browser is Firebird or not (last updated 1.7)
807 *
808 * @return boolean True if the browser is Firebird otherwise false
809 */
810 function checkBrowserFirebird() {
811 if ( stripos( $this->_agent, 'Firebird' ) !== false ) {
812 $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) );
813 $this->setVersion( $aversion[1] );
814 $this->setBrowser( $this->BROWSER_FIREBIRD );
815 return true;
816 }
817 return false;
818 }
819
820 /**
821 * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
822 * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
823 *
824 * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
825 */
826 function checkBrowserNetscapeNavigator9Plus() {
827 if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) {
828 $this->setVersion( $matches[1] );
829 $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
830 return true;
831 } elseif ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) {
832 $this->setVersion( $matches[1] );
833 $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
834 return true;
835 }
836 return false;
837 }
838
839 /**
840 * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
841 *
842 * @return boolean True if the browser is Shiretoko otherwise false
843 */
844 function checkBrowserShiretoko() {
845 if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) {
846 $this->setVersion( $matches[1] );
847 $this->setBrowser( $this->BROWSER_SHIRETOKO );
848 return true;
849 }
850 return false;
851 }
852
853 /**
854 * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
855 *
856 * @return boolean True if the browser is Ice Cat otherwise false
857 */
858 function checkBrowserIceCat() {
859 if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) {
860 $this->setVersion( $matches[1] );
861 $this->setBrowser( $this->BROWSER_ICECAT );
862 return true;
863 }
864 return false;
865 }
866
867 /**
868 * Determine if the browser is Nokia or not (last updated 1.7)
869 *
870 * @return boolean True if the browser is Nokia otherwise false
871 */
872 function checkBrowserNokia() {
873 if ( preg_match( '/Nokia([^\/]+)\/([^ SP]+)/i', $this->_agent, $matches ) ) {
874 $this->setVersion( $matches[2] );
875 if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) {
876 $this->setBrowser( $this->BROWSER_NOKIA_S60 );
877 } else {
878 $this->setBrowser( $this->BROWSER_NOKIA );
879 }
880 $this->setMobile( true );
881 return true;
882 }
883 return false;
884 }
885
886 /**
887 * Determine if the browser is Firefox or not (last updated 1.7)
888 *
889 * @return boolean True if the browser is Firefox otherwise false
890 */
891 function checkBrowserFirefox() {
892 if ( stripos( $this->_agent, 'safari' ) === false ) {
893 if ( preg_match( '/Firefox[\/ \(]([^ ;\)]+)/i', $this->_agent, $matches ) ) {
894 $this->setVersion( $matches[1] );
895 $this->setBrowser( $this->BROWSER_FIREFOX );
896 return true;
897 } elseif ( preg_match( '/Firefox$/i', $this->_agent, $matches ) ) {
898 $this->setVersion( '' );
899 $this->setBrowser( $this->BROWSER_FIREFOX );
900 return true;
901 }
902 }
903 return false;
904 }
905
906 /**
907 * Determine if the browser is Firefox or not (last updated 1.7)
908 *
909 * @return boolean True if the browser is Firefox otherwise false
910 */
911 function checkBrowserIceweasel() {
912 if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) {
913 $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) );
914 $aversion = explode( ' ', $aresult[1] );
915 $this->setVersion( $aversion[0] );
916 $this->setBrowser( $this->BROWSER_ICEWEASEL );
917 return true;
918 }
919 return false;
920 }
921 /**
922 * Determine if the browser is Mozilla or not (last updated 1.7)
923 *
924 * @return boolean True if the browser is Mozilla otherwise false
925 */
926 function checkBrowserMozilla() {
927 if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
928 $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) );
929 preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion );
930 $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
931 $this->setBrowser( $this->BROWSER_MOZILLA );
932 return true;
933 } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
934 $aversion = explode( '', stristr( $this->_agent, 'rv:' ) );
935 $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
936 $this->setBrowser( $this->BROWSER_MOZILLA );
937 return true;
938 } elseif ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) {
939 $this->setVersion( $matches[1] );
940 $this->setBrowser( $this->BROWSER_MOZILLA );
941 return true;
942 }
943 return false;
944 }
945
946 /**
947 * Determine if the browser is Lynx or not (last updated 1.7)
948 *
949 * @return boolean True if the browser is Lynx otherwise false
950 */
951 function checkBrowserLynx() {
952 if ( stripos( $this->_agent, 'lynx' ) !== false ) {
953 $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) );
954 $aversion = explode( ' ', ( isset( $aresult[1] ) ? $aresult[1] : '' ) );
955 $this->setVersion( $aversion[0] );
956 $this->setBrowser( $this->BROWSER_LYNX );
957 return true;
958 }
959 return false;
960 }
961
962 /**
963 * Determine if the browser is Amaya or not (last updated 1.7)
964 *
965 * @return boolean True if the browser is Amaya otherwise false
966 */
967 function checkBrowserAmaya() {
968 if ( stripos( $this->_agent, 'amaya' ) !== false ) {
969 $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) );
970 $aversion = explode( ' ', $aresult[1] );
971 $this->setVersion( $aversion[0] );
972 $this->setBrowser( $this->BROWSER_AMAYA );
973 return true;
974 }
975 return false;
976 }
977
978 /**
979 * Determine if the browser is Safari or not (last updated 1.7)
980 *
981 * @return boolean True if the browser is Safari otherwise false
982 */
983 function checkBrowserSafari() {
984 if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) {
985 $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
986 if ( isset( $aresult[1] ) ) {
987 $aversion = explode( ' ', $aresult[1] );
988 $this->setVersion( $aversion[0] );
989 } else {
990 $this->setVersion( $this->VERSION_UNKNOWN );
991 }
992 $this->setBrowser( $this->BROWSER_SAFARI );
993 return true;
994 }
995 return false;
996 }
997
998 /**
999 * Determine if the browser is iPhone or not (last updated 1.7)
1000 *
1001 * @return boolean True if the browser is iPhone otherwise false
1002 */
1003 function checkBrowseriPhone() {
1004 if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
1005 $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1006 if ( isset( $aresult[1] ) ) {
1007 $aversion = explode( ' ', $aresult[1] );
1008 $this->setVersion( $aversion[0] );
1009 } else {
1010 $this->setVersion( $this->VERSION_UNKNOWN );
1011 }
1012 $this->setMobile( true );
1013 $this->setBrowser( $this->BROWSER_IPHONE );
1014 return true;
1015 }
1016 return false;
1017 }
1018
1019 /**
1020 * Determine if the browser is iPod or not (last updated 1.7)
1021 *
1022 * @return boolean True if the browser is iPod otherwise false
1023 */
1024 function checkBrowseriPad() {
1025 if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1026 $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1027 if ( isset( $aresult[1] ) ) {
1028 $aversion = explode( ' ', $aresult[1] );
1029 $this->setVersion( $aversion[0] );
1030 } else {
1031 $this->setVersion( $this->VERSION_UNKNOWN );
1032 }
1033 $this->setMobile( true );
1034 $this->setBrowser( $this->BROWSER_IPAD );
1035 return true;
1036 }
1037 return false;
1038 }
1039
1040 /**
1041 * Determine if the browser is iPod or not (last updated 1.7)
1042 *
1043 * @return boolean True if the browser is iPod otherwise false
1044 */
1045 function checkBrowseriPod() {
1046 if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1047 $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1048 if ( isset( $aresult[1] ) ) {
1049 $aversion = explode( ' ', $aresult[1] );
1050 $this->setVersion( $aversion[0] );
1051 } else {
1052 $this->setVersion( $this->VERSION_UNKNOWN );
1053 }
1054 $this->setMobile( true );
1055 $this->setBrowser( $this->BROWSER_IPOD );
1056 return true;
1057 }
1058 return false;
1059 }
1060
1061 /**
1062 * Determine if the browser is Android or not (last updated 1.7)
1063 *
1064 * @return boolean True if the browser is Android otherwise false
1065 */
1066 function checkBrowserAndroid() {
1067 if ( stripos( $this->_agent, 'Android' ) !== false ) {
1068 $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) );
1069 if ( isset( $aresult[1] ) ) {
1070 $aversion = explode( ' ', $aresult[1] );
1071 $this->setVersion( $aversion[0] );
1072 } else {
1073 $this->setVersion( $this->VERSION_UNKNOWN );
1074 }
1075 $this->setMobile( true );
1076 $this->setBrowser( $this->BROWSER_ANDROID );
1077 return true;
1078 }
1079 return false;
1080 }
1081
1082 /**
1083 * Determine the user's platform (last updated 1.7)
1084 */
1085 function checkPlatform() {
1086 if ( stripos( $this->_agent, 'windows' ) !== false ) {
1087 $this->_platform = $this->PLATFORM_WINDOWS;
1088 } elseif ( stripos( $this->_agent, 'iPad' ) !== false ) {
1089 $this->_platform = $this->PLATFORM_IPAD;
1090 } elseif ( stripos( $this->_agent, 'iPod' ) !== false ) {
1091 $this->_platform = $this->PLATFORM_IPOD;
1092 } elseif ( stripos( $this->_agent, 'iPhone' ) !== false ) {
1093 $this->_platform = $this->PLATFORM_IPHONE;
1094 } elseif ( stripos( $this->_agent, 'mac' ) !== false ) {
1095 $this->_platform = $this->PLATFORM_APPLE;
1096 } elseif ( stripos( $this->_agent, 'android' ) !== false ) {
1097 $this->_platform = $this->PLATFORM_ANDROID;
1098 } elseif ( stripos( $this->_agent, 'linux' ) !== false ) {
1099 $this->_platform = $this->PLATFORM_LINUX;
1100 } elseif ( stripos( $this->_agent, 'Nokia' ) !== false ) {
1101 $this->_platform = $this->PLATFORM_NOKIA;
1102 } elseif ( stripos( $this->_agent, 'BlackBerry' ) !== false ) {
1103 $this->_platform = $this->PLATFORM_BLACKBERRY;
1104 } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) {
1105 $this->_platform = $this->PLATFORM_FREEBSD;
1106 } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) {
1107 $this->_platform = $this->PLATFORM_OPENBSD;
1108 } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) {
1109 $this->_platform = $this->PLATFORM_NETBSD;
1110 } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) {
1111 $this->_platform = $this->PLATFORM_OPENSOLARIS;
1112 } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) {
1113 $this->_platform = $this->PLATFORM_SUNOS;
1114 } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) {
1115 $this->_platform = $this->PLATFORM_OS2;
1116 } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) {
1117 $this->_platform = $this->PLATFORM_BEOS;
1118 } elseif ( stripos( $this->_agent, 'win' ) !== false ) {
1119 $this->_platform = $this->PLATFORM_WINDOWS;
1120 }
1121
1122 }
1123 }
1124