Keine Beschreibung

browser.php 39KB

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