Browser

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

Defined (2)

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

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