Browser.php 43 KB

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