PluginProbe
Yatra – Travel Booking & Tour Operator Software / 2.2.10
Yatra – Travel Booking & Tour Operator Software v2.2.10
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / core / Libraries / browser.php

browser.php in Yatra – Travel Booking & Tour Operator Software 2.2.10, at core/Libraries/browser.php

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