PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Browser.php/shimansky.biz/lib/Browser.php

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