Browser

Modified to remove var Chris Christoff on 12/26/2012 Changes: Changes vars to publics.

Defined (1)

The class is defined in the following location(s).

/inc/ReduxFramework/ReduxCore/inc/browser.php  
  1. class Browser { 
  2. public $_agent = ''; 
  3. public $_browser_name = ''; 
  4. public $_version = ''; 
  5. public $_platform = ''; 
  6. public $_os = ''; 
  7. public $_is_aol = false; 
  8. public $_is_mobile = false; 
  9. public $_is_robot = false; 
  10. public $_aol_version = ''; 
  11.  
  12. public $BROWSER_UNKNOWN = 'unknown'; 
  13. public $VERSION_UNKNOWN = 'unknown'; 
  14.  
  15. public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/ 
  16. public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/ 
  17. public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/ 
  18. public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/ 
  19. public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile 
  20. public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/ 
  21. public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/ 
  22. public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/ 
  23. public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/ 
  24. public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html 
  25. public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/ 
  26. public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko 
  27. public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/ 
  28. public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/ 
  29. public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx 
  30. public $BROWSER_SAFARI = 'Safari'; // Http://apple.com 
  31. public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com 
  32. public $BROWSER_IPOD = 'iPod'; // Http://apple.com 
  33. public $BROWSER_IPAD = 'iPad'; // Http://apple.com 
  34. public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome 
  35. public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/ 
  36. public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot 
  37. public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp 
  38. public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/ 
  39. public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/ 
  40. public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat 
  41. public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60 
  42. public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform 
  43. public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/ 
  44. public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm 
  45. // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well) 
  46.  
  47. public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED) 
  48. public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED) 
  49. public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) 
  50. public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) 
  51.  
  52. public $PLATFORM_UNKNOWN = 'unknown'; 
  53. public $PLATFORM_WINDOWS = 'Windows'; 
  54. public $PLATFORM_WINDOWS_CE = 'Windows CE'; 
  55. public $PLATFORM_APPLE = 'Apple'; 
  56. public $PLATFORM_LINUX = 'Linux'; 
  57. public $PLATFORM_OS2 = 'OS/2'; 
  58. public $PLATFORM_BEOS = 'BeOS'; 
  59. public $PLATFORM_IPHONE = 'iPhone'; 
  60. public $PLATFORM_IPOD = 'iPod'; 
  61. public $PLATFORM_IPAD = 'iPad'; 
  62. public $PLATFORM_BLACKBERRY = 'BlackBerry'; 
  63. public $PLATFORM_NOKIA = 'Nokia'; 
  64. public $PLATFORM_FREEBSD = 'FreeBSD'; 
  65. public $PLATFORM_OPENBSD = 'OpenBSD'; 
  66. public $PLATFORM_NETBSD = 'NetBSD'; 
  67. public $PLATFORM_SUNOS = 'SunOS'; 
  68. public $PLATFORM_OPENSOLARIS = 'OpenSolaris'; 
  69. public $PLATFORM_ANDROID = 'Android'; 
  70.  
  71. public $OPERATING_SYSTEM_UNKNOWN = 'unknown'; 
  72.  
  73. function Browser( $useragent = '' ) { 
  74. $this->reset(); 
  75.  
  76. if ( $useragent != '' ) { 
  77. $this->setUserAgent( $useragent ); 
  78. } else { 
  79. $this->determine(); 
  80.  
  81. /** 
  82. * Reset all properties 
  83. */ 
  84. function reset() { 
  85. $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; 
  86. $this->_browser_name = $this->BROWSER_UNKNOWN; 
  87. $this->_version = $this->VERSION_UNKNOWN; 
  88. $this->_platform = $this->PLATFORM_UNKNOWN; 
  89. $this->_os = $this->OPERATING_SYSTEM_UNKNOWN; 
  90. $this->_is_aol = false; 
  91. $this->_is_mobile = false; 
  92. $this->_is_robot = false; 
  93. $this->_aol_version = $this->VERSION_UNKNOWN; 
  94.  
  95. /** 
  96. * Check to see if the specific browser is valid 
  97. * @param string $browserName 
  98. * @return True if the browser is the specified browser 
  99. */ 
  100. function isBrowser( $browserName ) { 
  101. return ( 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ) ); 
  102.  
  103. /** 
  104. * The name of the browser. All return types are from the class contants 
  105. * @return string Name of the browser 
  106. */ 
  107. function getBrowser() { 
  108. return $this->_browser_name; 
  109.  
  110. /** 
  111. * Set the name of the browser 
  112. * @param $browser The name of the Browser 
  113. */ 
  114. function setBrowser( $browser ) { 
  115. return $this->_browser_name = $browser; 
  116.  
  117. /** 
  118. * The name of the platform. All return types are from the class contants 
  119. * @return string Name of the browser 
  120. */ 
  121. function getPlatform() { 
  122. return $this->_platform; 
  123.  
  124. /** 
  125. * Set the name of the platform 
  126. * @param $platform The name of the Platform 
  127. */ 
  128. function setPlatform( $platform ) { 
  129. return $this->_platform = $platform; 
  130.  
  131. /** 
  132. * The version of the browser. 
  133. * @return string Version of the browser (will only contain alpha-numeric characters and a period) 
  134. */ 
  135. function getVersion() { 
  136. return $this->_version; 
  137.  
  138. /** 
  139. * Set the version of the browser 
  140. * @param $version The version of the Browser 
  141. */ 
  142. function setVersion( $version ) { 
  143. $this->_version = preg_replace( '/[^0-9, ., a-z, A-Z-]/', '', $version ); 
  144.  
  145. /** 
  146. * The version of AOL. 
  147. * @return string Version of AOL (will only contain alpha-numeric characters and a period) 
  148. */ 
  149. function getAolVersion() { 
  150. return $this->_aol_version; 
  151.  
  152. /** 
  153. * Set the version of AOL 
  154. * @param $version The version of AOL 
  155. */ 
  156. function setAolVersion( $version ) { 
  157. $this->_aol_version = preg_replace( '/[^0-9, ., a-z, A-Z]/', '', $version ); 
  158.  
  159. /** 
  160. * Is the browser from AOL? 
  161. * @return boolean True if the browser is from AOL otherwise false 
  162. */ 
  163. function isAol() { 
  164. return $this->_is_aol; 
  165.  
  166. /** 
  167. * Is the browser from a mobile device? 
  168. * @return boolean True if the browser is from a mobile device otherwise false 
  169. */ 
  170. function isMobile() { 
  171. return $this->_is_mobile; 
  172.  
  173. /** 
  174. * Is the browser from a robot (ex Slurp, GoogleBot)? 
  175. * @return boolean True if the browser is from a robot otherwise false 
  176. */ 
  177. function isRobot() { 
  178. return $this->_is_robot; 
  179.  
  180. /** 
  181. * Set the browser to be from AOL 
  182. * @param $isAol 
  183. */ 
  184. function setAol( $isAol ) { 
  185. $this->_is_aol = $isAol; 
  186.  
  187. /** 
  188. * Set the Browser to be mobile 
  189. * @param boolean $value is the browser a mobile brower or not 
  190. */ 
  191. function setMobile( $value = true ) { 
  192. $this->_is_mobile = $value; 
  193.  
  194. /** 
  195. * Set the Browser to be a robot 
  196. * @param boolean $value is the browser a robot or not 
  197. */ 
  198. function setRobot( $value = true ) { 
  199. $this->_is_robot = $value; 
  200.  
  201. /** 
  202. * Get the user agent value in use to determine the browser 
  203. * @return string The user agent from the HTTP header 
  204. */ 
  205. function getUserAgent() { 
  206. return $this->_agent; 
  207.  
  208. /** 
  209. * Set the user agent value (the construction will use the HTTP header value - this will overwrite it) 
  210. * @param $agent_string The value for the User Agent 
  211. */ 
  212. function setUserAgent( $agent_string ) { 
  213. $this->reset(); 
  214. $this->_agent = $agent_string; 
  215. $this->determine(); 
  216.  
  217. /** 
  218. * Used to determine if the browser is actually "chromeframe" 
  219. * @since 1.7 
  220. * @return boolean True if the browser is using chromeframe 
  221. */ 
  222. function isChromeFrame() { 
  223. return ( strpos( $this->_agent, 'chromeframe' ) !== false ); 
  224.  
  225. /** 
  226. * Returns a formatted string with a summary of the details of the browser. 
  227. * @return string formatted string with a summary of the browser 
  228. */ 
  229. function __toString() { 
  230. $text1 = $this->getUserAgent(); // Grabs the UA string 
  231. $UAline1 = substr( $text1, 0, 32 ); // The first line we print should only be the first 32 characters of the UA string 
  232. $text2 = $this->getUserAgent(); // Now we grab it again and save it to a string 
  233. $towrapUA = str_replace( $UAline1, '', $text2 ); // The rest of the printoff (other than first line) is equivalent 
  234. // to the whole string minus the part we printed off. IE 
  235. // User Agent: thefirst32charactersfromUAline1 
  236. // the rest of it is now stored in 
  237. // $text2 to be printed off 
  238. // But we need to add spaces before each line that is split other than line 1 
  239. $space = ''; 
  240. for ( $i = 0; $i < 25; $i ++ ) { 
  241. $space .= ' '; 
  242.  
  243. // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting 
  244. $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" ); 
  245.  
  246. return "Platform: {$this->getPlatform()} \n" . 
  247. "Browser Name: {$this->getBrowser()} \n" . 
  248. "Browser Version: {$this->getVersion()} \n" . 
  249. "User Agent String: $UAline1 \n\t\t\t " . 
  250. "$wordwrapped"; 
  251.  
  252. /** 
  253. * Protected routine to calculate and determine what the browser is in use (including platform) 
  254. */ 
  255. function determine() { 
  256. $this->checkPlatform(); 
  257. $this->checkBrowsers(); 
  258. $this->checkForAol(); 
  259.  
  260. /** 
  261. * Protected routine to determine the browser type 
  262. * @return boolean True if the browser was detected otherwise false 
  263. */ 
  264. function checkBrowsers() { 
  265. return ( 
  266. // Well-known, well-used 
  267. // Special Notes: 
  268. // (1) Opera must be checked before FireFox due to the odd 
  269. // user agents used in some older versions of Opera 
  270. // (2) WebTV is strapped onto Internet Explorer so we must 
  271. // check for WebTV before IE 
  272. // (3) (deprecated) Galeon is based on Firefox and needs to be 
  273. // tested before Firefox is tested 
  274. // (4) OmniWeb is based on Safari so OmniWeb check must occur 
  275. // before Safari 
  276. // (5) Netscape 9+ is based on Firefox so Netscape checks 
  277. // before FireFox are necessary 
  278. $this->checkBrowserWebTv() || 
  279. $this->checkBrowserInternetExplorer() || 
  280. $this->checkBrowserOpera() || 
  281. $this->checkBrowserGaleon() || 
  282. $this->checkBrowserNetscapeNavigator9Plus() || 
  283. $this->checkBrowserFirefox() || 
  284. $this->checkBrowserChrome() || 
  285. $this->checkBrowserOmniWeb() || 
  286.  
  287. // Common mobile 
  288. $this->checkBrowserAndroid() || 
  289. $this->checkBrowseriPad() || 
  290. $this->checkBrowseriPod() || 
  291. $this->checkBrowseriPhone() || 
  292. $this->checkBrowserBlackBerry() || 
  293. $this->checkBrowserNokia() || 
  294.  
  295. // Common bots 
  296. $this->checkBrowserGoogleBot() || 
  297. $this->checkBrowserMSNBot() || 
  298. $this->checkBrowserSlurp() || 
  299.  
  300. // WebKit base check (post mobile and others) 
  301. $this->checkBrowserSafari() || 
  302.  
  303. // Everyone else 
  304. $this->checkBrowserNetPositive() || 
  305. $this->checkBrowserFirebird() || 
  306. $this->checkBrowserKonqueror() || 
  307. $this->checkBrowserIcab() || 
  308. $this->checkBrowserPhoenix() || 
  309. $this->checkBrowserAmaya() || 
  310. $this->checkBrowserLynx() || 
  311.  
  312. $this->checkBrowserShiretoko() || 
  313. $this->checkBrowserIceCat() || 
  314. $this->checkBrowserW3CValidator() || 
  315. $this->checkBrowserMozilla() /** Mozilla is such an open standard that you must check it last */ 
  316. ); 
  317.  
  318. /** 
  319. * Determine if the user is using a BlackBerry (last updated 1.7) 
  320. * @return boolean True if the browser is the BlackBerry browser otherwise false 
  321. */ 
  322. function checkBrowserBlackBerry() { 
  323. if ( stripos( $this->_agent, 'blackberry' ) !== false ) { 
  324. $aresult = explode( "/", stristr( $this->_agent, "BlackBerry" ) ); 
  325. $aversion = explode( ' ', $aresult[1] ); 
  326. $this->setVersion( $aversion[0] ); 
  327. $this->_browser_name = $this->BROWSER_BLACKBERRY; 
  328. $this->setMobile( true ); 
  329.  
  330. return true; 
  331.  
  332. return false; 
  333.  
  334. /** 
  335. * Determine if the user is using an AOL User Agent (last updated 1.7) 
  336. * @return boolean True if the browser is from AOL otherwise false 
  337. */ 
  338. function checkForAol() { 
  339. $this->setAol( false ); 
  340. $this->setAolVersion( $this->VERSION_UNKNOWN ); 
  341.  
  342. if ( stripos( $this->_agent, 'aol' ) !== false ) { 
  343. $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) ); 
  344. $this->setAol( true ); 
  345. $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) ); 
  346.  
  347. return true; 
  348.  
  349. return false; 
  350.  
  351. /** 
  352. * Determine if the browser is the GoogleBot or not (last updated 1.7) 
  353. * @return boolean True if the browser is the GoogletBot otherwise false 
  354. */ 
  355. function checkBrowserGoogleBot() { 
  356. if ( stripos( $this->_agent, 'googlebot' ) !== false ) { 
  357. $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) ); 
  358. $aversion = explode( ' ', $aresult[1] ); 
  359. $this->setVersion( str_replace( ';', '', $aversion[0] ) ); 
  360. $this->_browser_name = $this->BROWSER_GOOGLEBOT; 
  361. $this->setRobot( true ); 
  362.  
  363. return true; 
  364.  
  365. return false; 
  366.  
  367. /** 
  368. * Determine if the browser is the MSNBot or not (last updated 1.9) 
  369. * @return boolean True if the browser is the MSNBot otherwise false 
  370. */ 
  371. function checkBrowserMSNBot() { 
  372. if ( stripos( $this->_agent, "msnbot" ) !== false ) { 
  373. $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) ); 
  374. $aversion = explode( " ", $aresult[1] ); 
  375. $this->setVersion( str_replace( ";", "", $aversion[0] ) ); 
  376. $this->_browser_name = $this->BROWSER_MSNBOT; 
  377. $this->setRobot( true ); 
  378.  
  379. return true; 
  380.  
  381. return false; 
  382.  
  383. /** 
  384. * Determine if the browser is the W3C Validator or not (last updated 1.7) 
  385. * @return boolean True if the browser is the W3C Validator otherwise false 
  386. */ 
  387. function checkBrowserW3CValidator() { 
  388. if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) { 
  389. $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) ); 
  390. $aversion = explode( ' ', $aresult[1] ); 
  391. $this->setVersion( $aversion[0] ); 
  392. $this->_browser_name = $this->BROWSER_W3CVALIDATOR; 
  393.  
  394. return true; 
  395. } else if ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) { 
  396. // Some of the Validator versions do not delineate w/ a slash - add it back in 
  397. $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent ); 
  398. $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) ); 
  399. $aversion = explode( ' ', $aresult[1] ); 
  400. $this->setVersion( $aversion[0] ); 
  401. $this->_browser_name = $this->BROWSER_W3CVALIDATOR; 
  402.  
  403. return true; 
  404.  
  405. return false; 
  406.  
  407. /** 
  408. * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7) 
  409. * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false 
  410. */ 
  411. function checkBrowserSlurp() { 
  412. if ( stripos( $this->_agent, 'slurp' ) !== false ) { 
  413. $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) ); 
  414. $aversion = explode( ' ', $aresult[1] ); 
  415. $this->setVersion( $aversion[0] ); 
  416. $this->_browser_name = $this->BROWSER_SLURP; 
  417. $this->setRobot( true ); 
  418. $this->setMobile( false ); 
  419.  
  420. return true; 
  421.  
  422. return false; 
  423.  
  424. /** 
  425. * Determine if the browser is Internet Explorer or not (last updated 1.7) 
  426. * @return boolean True if the browser is Internet Explorer otherwise false 
  427. */ 
  428. function checkBrowserInternetExplorer() { 
  429.  
  430. // Test for v1 - v1.5 IE 
  431. if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) { 
  432. $this->setBrowser( $this->BROWSER_IE ); 
  433. $this->setVersion( '1.0' ); 
  434. $aresult = stristr( $this->_agent, '/' ); 
  435. if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) { 
  436. $this->setVersion( '1.5' ); 
  437.  
  438. return true; 
  439. // Test for versions > 1.5 
  440. } else if ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) { 
  441. // See if the browser is the odd MSN Explorer 
  442. if ( stripos( $this->_agent, 'msnb' ) !== false ) { 
  443. $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) ); 
  444. $this->setBrowser( $this->BROWSER_MSN ); 
  445. $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); 
  446.  
  447. return true; 
  448. $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) ); 
  449. $this->setBrowser( $this->BROWSER_IE ); 
  450. $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) ); 
  451.  
  452. return true; 
  453. // Test for Pocket IE 
  454. } else if ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) { 
  455. $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) ); 
  456. $this->setPlatform( $this->PLATFORM_WINDOWS_CE ); 
  457. $this->setBrowser( $this->BROWSER_POCKET_IE ); 
  458. $this->setMobile( true ); 
  459.  
  460. if ( stripos( $this->_agent, 'mspie' ) !== false ) { 
  461. $this->setVersion( $aresult[1] ); 
  462. } else { 
  463. $aversion = explode( '/', $this->_agent ); 
  464. $this->setVersion( $aversion[1] ); 
  465.  
  466. return true; 
  467.  
  468. return false; 
  469.  
  470. /** 
  471. * Determine if the browser is Opera or not (last updated 1.7) 
  472. * @return boolean True if the browser is Opera otherwise false 
  473. */ 
  474. function checkBrowserOpera() { 
  475. if ( stripos( $this->_agent, 'opera mini' ) !== false ) { 
  476. $resultant = stristr( $this->_agent, 'opera mini' ); 
  477. if ( preg_match( '/\//', $resultant ) ) { 
  478. $aresult = explode( '/', $resultant ); 
  479. $aversion = explode( ' ', $aresult[1] ); 
  480. $this->setVersion( $aversion[0] ); 
  481. } else { 
  482. $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) ); 
  483. $this->setVersion( $aversion[1] ); 
  484. $this->_browser_name = $this->BROWSER_OPERA_MINI; 
  485. $this->setMobile( true ); 
  486.  
  487. return true; 
  488. } else if ( stripos( $this->_agent, 'opera' ) !== false ) { 
  489. $resultant = stristr( $this->_agent, 'opera' ); 
  490. if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) { 
  491. $this->setVersion( $matches[1] ); 
  492. } else if ( preg_match( '/\//', $resultant ) ) { 
  493. $aresult = explode( '/', str_replace( "(", " ", $resultant ) ); 
  494. $aversion = explode( ' ', $aresult[1] ); 
  495. $this->setVersion( $aversion[0] ); 
  496. } else { 
  497. $aversion = explode( ' ', stristr( $resultant, 'opera' ) ); 
  498. $this->setVersion( isset( $aversion[1] ) ? $aversion[1] : "" ); 
  499. $this->_browser_name = $this->BROWSER_OPERA; 
  500.  
  501. return true; 
  502.  
  503. return false; 
  504.  
  505. /** 
  506. * Determine if the browser is Chrome or not (last updated 1.7) 
  507. * @return boolean True if the browser is Chrome otherwise false 
  508. */ 
  509. function checkBrowserChrome() { 
  510. if ( stripos( $this->_agent, 'Chrome' ) !== false ) { 
  511. $aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) ); 
  512. $aversion = explode( ' ', $aresult[1] ); 
  513. $this->setVersion( $aversion[0] ); 
  514. $this->setBrowser( $this->BROWSER_CHROME ); 
  515.  
  516. return true; 
  517.  
  518. return false; 
  519.  
  520.  
  521. /** 
  522. * Determine if the browser is WebTv or not (last updated 1.7) 
  523. * @return boolean True if the browser is WebTv otherwise false 
  524. */ 
  525. function checkBrowserWebTv() { 
  526. if ( stripos( $this->_agent, 'webtv' ) !== false ) { 
  527. $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) ); 
  528. $aversion = explode( ' ', $aresult[1] ); 
  529. $this->setVersion( $aversion[0] ); 
  530. $this->setBrowser( $this->BROWSER_WEBTV ); 
  531.  
  532. return true; 
  533.  
  534. return false; 
  535.  
  536. /** 
  537. * Determine if the browser is NetPositive or not (last updated 1.7) 
  538. * @return boolean True if the browser is NetPositive otherwise false 
  539. */ 
  540. function checkBrowserNetPositive() { 
  541. if ( stripos( $this->_agent, 'NetPositive' ) !== false ) { 
  542. $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) ); 
  543. $aversion = explode( ' ', $aresult[1] ); 
  544. $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) ); 
  545. $this->setBrowser( $this->BROWSER_NETPOSITIVE ); 
  546.  
  547. return true; 
  548.  
  549. return false; 
  550.  
  551. /** 
  552. * Determine if the browser is Galeon or not (last updated 1.7) 
  553. * @return boolean True if the browser is Galeon otherwise false 
  554. */ 
  555. function checkBrowserGaleon() { 
  556. if ( stripos( $this->_agent, 'galeon' ) !== false ) { 
  557. $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) ); 
  558. $aversion = explode( '/', $aresult[0] ); 
  559. $this->setVersion( $aversion[1] ); 
  560. $this->setBrowser( $this->BROWSER_GALEON ); 
  561.  
  562. return true; 
  563.  
  564. return false; 
  565.  
  566. /** 
  567. * Determine if the browser is Konqueror or not (last updated 1.7) 
  568. * @return boolean True if the browser is Konqueror otherwise false 
  569. */ 
  570. function checkBrowserKonqueror() { 
  571. if ( stripos( $this->_agent, 'Konqueror' ) !== false ) { 
  572. $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) ); 
  573. $aversion = explode( '/', $aresult[0] ); 
  574. $this->setVersion( $aversion[1] ); 
  575. $this->setBrowser( $this->BROWSER_KONQUEROR ); 
  576.  
  577. return true; 
  578.  
  579. return false; 
  580.  
  581. /** 
  582. * Determine if the browser is iCab or not (last updated 1.7) 
  583. * @return boolean True if the browser is iCab otherwise false 
  584. */ 
  585. function checkBrowserIcab() { 
  586. if ( stripos( $this->_agent, 'icab' ) !== false ) { 
  587. $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) ); 
  588. $this->setVersion( $aversion[1] ); 
  589. $this->setBrowser( $this->BROWSER_ICAB ); 
  590.  
  591. return true; 
  592.  
  593. return false; 
  594.  
  595. /** 
  596. * Determine if the browser is OmniWeb or not (last updated 1.7) 
  597. * @return boolean True if the browser is OmniWeb otherwise false 
  598. */ 
  599. function checkBrowserOmniWeb() { 
  600. if ( stripos( $this->_agent, 'omniweb' ) !== false ) { 
  601. $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) ); 
  602. $aversion = explode( ' ', isset( $aresult[1] ) ? $aresult[1] : "" ); 
  603. $this->setVersion( $aversion[0] ); 
  604. $this->setBrowser( $this->BROWSER_OMNIWEB ); 
  605.  
  606. return true; 
  607.  
  608. return false; 
  609.  
  610. /** 
  611. * Determine if the browser is Phoenix or not (last updated 1.7) 
  612. * @return boolean True if the browser is Phoenix otherwise false 
  613. */ 
  614. function checkBrowserPhoenix() { 
  615. if ( stripos( $this->_agent, 'Phoenix' ) !== false ) { 
  616. $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) ); 
  617. $this->setVersion( $aversion[1] ); 
  618. $this->setBrowser( $this->BROWSER_PHOENIX ); 
  619.  
  620. return true; 
  621.  
  622. return false; 
  623.  
  624. /** 
  625. * Determine if the browser is Firebird or not (last updated 1.7) 
  626. * @return boolean True if the browser is Firebird otherwise false 
  627. */ 
  628. function checkBrowserFirebird() { 
  629. if ( stripos( $this->_agent, 'Firebird' ) !== false ) { 
  630. $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) ); 
  631. $this->setVersion( $aversion[1] ); 
  632. $this->setBrowser( $this->BROWSER_FIREBIRD ); 
  633.  
  634. return true; 
  635.  
  636. return false; 
  637.  
  638. /** 
  639. * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7) 
  640. * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008) 
  641. * @return boolean True if the browser is Netscape Navigator 9+ otherwise false 
  642. */ 
  643. function checkBrowserNetscapeNavigator9Plus() { 
  644. if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) { 
  645. $this->setVersion( $matches[1] ); 
  646. $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR ); 
  647.  
  648. return true; 
  649. } else if ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) { 
  650. $this->setVersion( $matches[1] ); 
  651. $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR ); 
  652.  
  653. return true; 
  654.  
  655. return false; 
  656.  
  657. /** 
  658. * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7) 
  659. * @return boolean True if the browser is Shiretoko otherwise false 
  660. */ 
  661. function checkBrowserShiretoko() { 
  662. if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) { 
  663. $this->setVersion( $matches[1] ); 
  664. $this->setBrowser( $this->BROWSER_SHIRETOKO ); 
  665.  
  666. return true; 
  667.  
  668. return false; 
  669.  
  670. /** 
  671. * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7) 
  672. * @return boolean True if the browser is Ice Cat otherwise false 
  673. */ 
  674. function checkBrowserIceCat() { 
  675. if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) { 
  676. $this->setVersion( $matches[1] ); 
  677. $this->setBrowser( $this->BROWSER_ICECAT ); 
  678.  
  679. return true; 
  680.  
  681. return false; 
  682.  
  683. /** 
  684. * Determine if the browser is Nokia or not (last updated 1.7) 
  685. * @return boolean True if the browser is Nokia otherwise false 
  686. */ 
  687. function checkBrowserNokia() { 
  688. if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) { 
  689. $this->setVersion( $matches[2] ); 
  690. if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) { 
  691. $this->setBrowser( $this->BROWSER_NOKIA_S60 ); 
  692. } else { 
  693. $this->setBrowser( $this->BROWSER_NOKIA ); 
  694. $this->setMobile( true ); 
  695.  
  696. return true; 
  697.  
  698. return false; 
  699.  
  700. /** 
  701. * Determine if the browser is Firefox or not (last updated 1.7) 
  702. * @return boolean True if the browser is Firefox otherwise false 
  703. */ 
  704. function checkBrowserFirefox() { 
  705. if ( stripos( $this->_agent, 'safari' ) === false ) { 
  706. if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) { 
  707. $this->setVersion( $matches[1] ); 
  708. $this->setBrowser( $this->BROWSER_FIREFOX ); 
  709.  
  710. return true; 
  711. } else if ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) { 
  712. $this->setVersion( "" ); 
  713. $this->setBrowser( $this->BROWSER_FIREFOX ); 
  714.  
  715. return true; 
  716.  
  717. return false; 
  718.  
  719. /** 
  720. * Determine if the browser is Firefox or not (last updated 1.7) 
  721. * @return boolean True if the browser is Firefox otherwise false 
  722. */ 
  723. function checkBrowserIceweasel() { 
  724. if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) { 
  725. $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) ); 
  726. $aversion = explode( ' ', $aresult[1] ); 
  727. $this->setVersion( $aversion[0] ); 
  728. $this->setBrowser( $this->BROWSER_ICEWEASEL ); 
  729.  
  730. return true; 
  731.  
  732. return false; 
  733.  
  734. /** 
  735. * Determine if the browser is Mozilla or not (last updated 1.7) 
  736. * @return boolean True if the browser is Mozilla otherwise false 
  737. */ 
  738. function checkBrowserMozilla() { 
  739. if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { 
  740. $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) ); 
  741. preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion ); 
  742. $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); 
  743. $this->setBrowser( $this->BROWSER_MOZILLA ); 
  744.  
  745. return true; 
  746. } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) { 
  747. $aversion = explode( '', stristr( $this->_agent, 'rv:' ) ); 
  748. $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) ); 
  749. $this->setBrowser( $this->BROWSER_MOZILLA ); 
  750.  
  751. return true; 
  752. } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) { 
  753. $this->setVersion( $matches[1] ); 
  754. $this->setBrowser( $this->BROWSER_MOZILLA ); 
  755.  
  756. return true; 
  757.  
  758. return false; 
  759.  
  760. /** 
  761. * Determine if the browser is Lynx or not (last updated 1.7) 
  762. * @return boolean True if the browser is Lynx otherwise false 
  763. */ 
  764. function checkBrowserLynx() { 
  765. if ( stripos( $this->_agent, 'lynx' ) !== false ) { 
  766. $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) ); 
  767. $aversion = explode( ' ', ( isset( $aresult[1] ) ? $aresult[1] : "" ) ); 
  768. $this->setVersion( $aversion[0] ); 
  769. $this->setBrowser( $this->BROWSER_LYNX ); 
  770.  
  771. return true; 
  772.  
  773. return false; 
  774.  
  775. /** 
  776. * Determine if the browser is Amaya or not (last updated 1.7) 
  777. * @return boolean True if the browser is Amaya otherwise false 
  778. */ 
  779. function checkBrowserAmaya() { 
  780. if ( stripos( $this->_agent, 'amaya' ) !== false ) { 
  781. $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) ); 
  782. $aversion = explode( ' ', $aresult[1] ); 
  783. $this->setVersion( $aversion[0] ); 
  784. $this->setBrowser( $this->BROWSER_AMAYA ); 
  785.  
  786. return true; 
  787.  
  788. return false; 
  789.  
  790. /** 
  791. * Determine if the browser is Safari or not (last updated 1.7) 
  792. * @return boolean True if the browser is Safari otherwise false 
  793. */ 
  794. function checkBrowserSafari() { 
  795. if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) { 
  796. $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); 
  797. if ( isset( $aresult[1] ) ) { 
  798. $aversion = explode( ' ', $aresult[1] ); 
  799. $this->setVersion( $aversion[0] ); 
  800. } else { 
  801. $this->setVersion( $this->VERSION_UNKNOWN ); 
  802. $this->setBrowser( $this->BROWSER_SAFARI ); 
  803.  
  804. return true; 
  805.  
  806. return false; 
  807.  
  808. /** 
  809. * Determine if the browser is iPhone or not (last updated 1.7) 
  810. * @return boolean True if the browser is iPhone otherwise false 
  811. */ 
  812. function checkBrowseriPhone() { 
  813. if ( stripos( $this->_agent, 'iPhone' ) !== false ) { 
  814. $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); 
  815. if ( isset( $aresult[1] ) ) { 
  816. $aversion = explode( ' ', $aresult[1] ); 
  817. $this->setVersion( $aversion[0] ); 
  818. } else { 
  819. $this->setVersion( $this->VERSION_UNKNOWN ); 
  820. $this->setMobile( true ); 
  821. $this->setBrowser( $this->BROWSER_IPHONE ); 
  822.  
  823. return true; 
  824.  
  825. return false; 
  826.  
  827. /** 
  828. * Determine if the browser is iPod or not (last updated 1.7) 
  829. * @return boolean True if the browser is iPod otherwise false 
  830. */ 
  831. function checkBrowseriPad() { 
  832. if ( stripos( $this->_agent, 'iPad' ) !== false ) { 
  833. $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); 
  834. if ( isset( $aresult[1] ) ) { 
  835. $aversion = explode( ' ', $aresult[1] ); 
  836. $this->setVersion( $aversion[0] ); 
  837. } else { 
  838. $this->setVersion( $this->VERSION_UNKNOWN ); 
  839. $this->setMobile( true ); 
  840. $this->setBrowser( $this->BROWSER_IPAD ); 
  841.  
  842. return true; 
  843.  
  844. return false; 
  845.  
  846. /** 
  847. * Determine if the browser is iPod or not (last updated 1.7) 
  848. * @return boolean True if the browser is iPod otherwise false 
  849. */ 
  850. function checkBrowseriPod() { 
  851. if ( stripos( $this->_agent, 'iPod' ) !== false ) { 
  852. $aresult = explode( '/', stristr( $this->_agent, 'Version' ) ); 
  853. if ( isset( $aresult[1] ) ) { 
  854. $aversion = explode( ' ', $aresult[1] ); 
  855. $this->setVersion( $aversion[0] ); 
  856. } else { 
  857. $this->setVersion( $this->VERSION_UNKNOWN ); 
  858. $this->setMobile( true ); 
  859. $this->setBrowser( $this->BROWSER_IPOD ); 
  860.  
  861. return true; 
  862.  
  863. return false; 
  864.  
  865. /** 
  866. * Determine if the browser is Android or not (last updated 1.7) 
  867. * @return boolean True if the browser is Android otherwise false 
  868. */ 
  869. function checkBrowserAndroid() { 
  870. if ( stripos( $this->_agent, 'Android' ) !== false ) { 
  871. $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) ); 
  872. if ( isset( $aresult[1] ) ) { 
  873. $aversion = explode( ' ', $aresult[1] ); 
  874. $this->setVersion( $aversion[0] ); 
  875. } else { 
  876. $this->setVersion( $this->VERSION_UNKNOWN ); 
  877. $this->setMobile( true ); 
  878. $this->setBrowser( $this->BROWSER_ANDROID ); 
  879.  
  880. return true; 
  881.  
  882. return false; 
  883.  
  884. /** 
  885. * Determine the user's platform (last updated 1.7) 
  886. */ 
  887. function checkPlatform() { 
  888. if ( stripos( $this->_agent, 'windows' ) !== false ) { 
  889. $this->_platform = $this->PLATFORM_WINDOWS; 
  890. } elseif ( stripos( $this->_agent, 'iPad' ) !== false ) { 
  891. $this->_platform = $this->PLATFORM_IPAD; 
  892. } elseif ( stripos( $this->_agent, 'iPod' ) !== false ) { 
  893. $this->_platform = $this->PLATFORM_IPOD; 
  894. } elseif ( stripos( $this->_agent, 'iPhone' ) !== false ) { 
  895. $this->_platform = $this->PLATFORM_IPHONE; 
  896. } elseif ( stripos( $this->_agent, 'mac' ) !== false ) { 
  897. $this->_platform = $this->PLATFORM_APPLE; 
  898. } elseif ( stripos( $this->_agent, 'android' ) !== false ) { 
  899. $this->_platform = $this->PLATFORM_ANDROID; 
  900. } elseif ( stripos( $this->_agent, 'linux' ) !== false ) { 
  901. $this->_platform = $this->PLATFORM_LINUX; 
  902. } elseif ( stripos( $this->_agent, 'Nokia' ) !== false ) { 
  903. $this->_platform = $this->PLATFORM_NOKIA; 
  904. } elseif ( stripos( $this->_agent, 'BlackBerry' ) !== false ) { 
  905. $this->_platform = $this->PLATFORM_BLACKBERRY; 
  906. } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) { 
  907. $this->_platform = $this->PLATFORM_FREEBSD; 
  908. } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) { 
  909. $this->_platform = $this->PLATFORM_OPENBSD; 
  910. } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) { 
  911. $this->_platform = $this->PLATFORM_NETBSD; 
  912. } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) { 
  913. $this->_platform = $this->PLATFORM_OPENSOLARIS; 
  914. } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) { 
  915. $this->_platform = $this->PLATFORM_SUNOS; 
  916. } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) { 
  917. $this->_platform = $this->PLATFORM_OS2; 
  918. } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) { 
  919. $this->_platform = $this->PLATFORM_BEOS; 
  920. } elseif ( stripos( $this->_agent, 'win' ) !== false ) { 
  921. $this->_platform = $this->PLATFORM_WINDOWS;