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