browser.php 39 KB

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