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