PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 1.8.0
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v1.8.0
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.8.0, at lib/browser.php

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