Browser.php 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387
  1. <?php
  2. namespace WhichBrowser\Analyser\Header\Useragent;
  3. use WhichBrowser\Constants;
  4. use WhichBrowser\Data;
  5. use WhichBrowser\Model\Family;
  6. use WhichBrowser\Model\Using;
  7. use WhichBrowser\Model\Version;
  8. trait Browser
  9. {
  10. private function &detectBrowser($ua)
  11. {
  12. /* Detect major browsers */
  13. $this->detectSafari($ua);
  14. $this->detectExplorer($ua);
  15. $this->detectFirefox($ua);
  16. $this->detectChrome($ua);
  17. $this->detectEdge($ua);
  18. $this->detectOpera($ua);
  19. /* Detect WAP browsers */
  20. $this->detectWapBrowsers($ua);
  21. /* Detect other various mobile browsers */
  22. $this->detectNokiaBrowser($ua);
  23. $this->detectSilk($ua);
  24. $this->detectSailfishBrowser($ua);
  25. $this->detectWebOSBrowser($ua);
  26. $this->detectDolfin($ua);
  27. $this->detectIris($ua);
  28. /* Detect other browsers */
  29. $this->detectUC($ua);
  30. $this->detectObigo($ua);
  31. $this->detectNetfront($ua);
  32. /* Detect other specific desktop browsers */
  33. $this->detectSeamonkey($ua);
  34. $this->detectModernNetscape($ua);
  35. $this->detectMosaic($ua);
  36. $this->detectKonqueror($ua);
  37. $this->detectOmniWeb($ua);
  38. /* Detect other various television browsers */
  39. $this->detectEspial($ua);
  40. $this->detectMachBlue($ua);
  41. $this->detectAnt($ua);
  42. $this->detectSraf($ua);
  43. /* Detect other browsers */
  44. $this->detectDesktopBrowsers($ua);
  45. $this->detectMobileBrowsers($ua);
  46. $this->detectTelevisionBrowsers($ua);
  47. $this->detectRemainingBrowsers($ua);
  48. return $this;
  49. }
  50. private function &refineBrowser($ua)
  51. {
  52. $this->detectUCEngine($ua);
  53. $this->detectLegacyNetscape($ua);
  54. return $this;
  55. }
  56. /* Safari */
  57. private function detectSafari($ua)
  58. {
  59. if (preg_match('/Safari/u', $ua)) {
  60. $falsepositive = false;
  61. if (preg_match('/Qt/u', $ua)) {
  62. $falsepositive = true;
  63. }
  64. if (!$falsepositive) {
  65. if (isset($this->data->os->name) && $this->data->os->name == 'iOS') {
  66. $this->data->browser->name = 'Safari';
  67. $this->data->browser->type = Constants\BrowserType::BROWSER;
  68. $this->data->browser->version = null;
  69. $this->data->browser->stock = true;
  70. if (preg_match('/Version\/([0-9\.]+)/u', $ua, $match)) {
  71. $this->data->browser->version = new Version([ 'value' => $match[1], 'hidden' => true ]);
  72. }
  73. }
  74. if (isset($this->data->os->name) && ($this->data->os->name == 'OS X' || $this->data->os->name == 'Windows')) {
  75. $this->data->browser->name = 'Safari';
  76. $this->data->browser->type = Constants\BrowserType::BROWSER;
  77. $this->data->browser->stock = $this->data->os->name == 'OS X';
  78. if (preg_match('/Version\/([0-9\.]+)/u', $ua, $match)) {
  79. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  80. }
  81. if (preg_match('/AppleWebKit\/[0-9\.]+\+/u', $ua)) {
  82. $this->data->browser->name = 'WebKit Nightly Build';
  83. $this->data->browser->version = null;
  84. }
  85. }
  86. }
  87. }
  88. if (preg_match('/(?:Apple-PubSub|AppleSyndication)\//u', $ua)) {
  89. $this->data->browser->name = 'Safari RSS';
  90. $this->data->browser->type = Constants\BrowserType::APP_FEEDREADER;
  91. $this->data->browser->version = null;
  92. $this->data->browser->stock = true;
  93. $this->data->os->name = 'OS X';
  94. $this->data->os->version = null;
  95. $this->data->device->type = Constants\DeviceType::DESKTOP;
  96. }
  97. }
  98. /* Chrome */
  99. private function detectChrome($ua)
  100. {
  101. if (preg_match('/(?:Chrome|CrMo|CriOS)\/[0-9]/u', $ua) || preg_match('/Browser\/Chrome[0-9]/u', $ua)) {
  102. $this->data->browser->name = 'Chrome';
  103. $this->data->browser->type = Constants\BrowserType::BROWSER;
  104. $this->data->browser->stock = false;
  105. $version = '';
  106. if (preg_match('/(?:Chrome|CrMo|CriOS)\/([0-9.]*)/u', $ua, $match)) {
  107. $version = $match[1];
  108. }
  109. if (preg_match('/Browser\/Chrome([0-9.]*)/u', $ua, $match)) {
  110. $version = $match[1];
  111. }
  112. $this->data->browser->version = new Version([ 'value' => $version ]);
  113. if (isset($this->data->os->name) && $this->data->os->name == 'Android') {
  114. $channel = Data\Chrome::getChannel('mobile', $this->data->browser->version->value);
  115. if ($channel == 'stable') {
  116. $this->data->browser->version->details = 1;
  117. } elseif ($channel == 'beta') {
  118. $this->data->browser->channel = 'Beta';
  119. } else {
  120. $this->data->browser->channel = 'Dev';
  121. }
  122. /* Webview for Android 4.4 and higher */
  123. if (implode('.', array_slice(explode('.', $version), 1, 2)) == '0.0' && (preg_match('/Version\//u', $ua) || preg_match('/Release\//u', $ua))) {
  124. $this->data->browser->using = new Using([ 'name' => 'Chromium WebView', 'version' => new Version([ 'value' => explode('.', $version)[0] ]) ]);
  125. $this->data->browser->type = Constants\BrowserType::UNKNOWN;
  126. $this->data->browser->stock = true;
  127. $this->data->browser->name = null;
  128. $this->data->browser->version = null;
  129. $this->data->browser->channel = null;
  130. }
  131. /* Webview for Android 5 */
  132. if (preg_match('/; wv\)/u', $ua)) {
  133. $this->data->browser->using = new Using([ 'name' => 'Chromium WebView', 'version' => new Version([ 'value' => explode('.', $version)[0] ]) ]);
  134. $this->data->browser->type = Constants\BrowserType::UNKNOWN;
  135. $this->data->browser->stock = true;
  136. $this->data->browser->name = null;
  137. $this->data->browser->version = null;
  138. $this->data->browser->channel = null;
  139. }
  140. /* LG Chromium based browsers */
  141. if (isset($this->data->device->manufacturer) && $this->data->device->manufacturer == 'LG') {
  142. if (in_array($version, [ '30.0.1599.103', '34.0.1847.118', '38.0.2125.0', '38.0.2125.102' ]) && preg_match('/Version\/4/u', $ua) && !preg_match('/; wv\)/u', $ua)) {
  143. $this->data->browser->name = "LG Browser";
  144. $this->data->browser->channel = null;
  145. $this->data->browser->stock = true;
  146. $this->data->browser->version = null;
  147. }
  148. }
  149. /* Samsung Chromium based browsers */
  150. if (isset($this->data->device->manufacturer) && $this->data->device->manufacturer == 'Samsung') {
  151. /* Version 1.0 */
  152. if ($version == '18.0.1025.308' && preg_match('/Version\/1.0/u', $ua)) {
  153. $this->data->browser->name = "Samsung Internet";
  154. $this->data->browser->channel = null;
  155. $this->data->browser->stock = true;
  156. $this->data->browser->version = new Version([ 'value' => '1.0' ]);
  157. }
  158. /* Version 1.5 */
  159. if ($version == '28.0.1500.94' && preg_match('/Version\/1.5/u', $ua)) {
  160. $this->data->browser->name = "Samsung Internet";
  161. $this->data->browser->channel = null;
  162. $this->data->browser->stock = true;
  163. $this->data->browser->version = new Version([ 'value' => '1.5' ]);
  164. }
  165. /* Version 1.6 */
  166. if ($version == '28.0.1500.94' && preg_match('/Version\/1.6/u', $ua)) {
  167. $this->data->browser->name = "Samsung Internet";
  168. $this->data->browser->channel = null;
  169. $this->data->browser->stock = true;
  170. $this->data->browser->version = new Version([ 'value' => '1.6' ]);
  171. }
  172. /* Version 2.0 */
  173. if ($version == '34.0.1847.76' && preg_match('/Version\/2.0/u', $ua)) {
  174. $this->data->browser->name = "Samsung Internet";
  175. $this->data->browser->channel = null;
  176. $this->data->browser->stock = true;
  177. $this->data->browser->version = new Version([ 'value' => '2.0' ]);
  178. }
  179. /* Version 2.1 */
  180. if ($version == '34.0.1847.76' && preg_match('/Version\/2.1/u', $ua)) {
  181. $this->data->browser->name = "Samsung Internet";
  182. $this->data->browser->channel = null;
  183. $this->data->browser->stock = true;
  184. $this->data->browser->version = new Version([ 'value' => '2.1' ]);
  185. }
  186. }
  187. /* Samsung Chromium based browsers */
  188. if (preg_match('/SamsungBrowser\/([0-9.]*)/u', $ua, $match)) {
  189. $this->data->browser->name = "Samsung Internet";
  190. $this->data->browser->channel = null;
  191. $this->data->browser->stock = true;
  192. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  193. if (preg_match('/Mobile VR/', $ua)) {
  194. $this->data->device->manufacturer = 'Samsung';
  195. $this->data->device->model = 'Gear VR';
  196. $this->data->device->type = Constants\DeviceType::HEADSET;
  197. }
  198. }
  199. /* Oculus Chromium based browsers */
  200. if (preg_match('/OculusBrowser\/([0-9.]*)/u', $ua, $match)) {
  201. $this->data->browser->name = "Oculus Internet";
  202. $this->data->browser->channel = null;
  203. $this->data->browser->stock = true;
  204. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  205. if (preg_match('/Mobile VR/', $ua)) {
  206. $this->data->device->manufacturer = 'Samsung';
  207. $this->data->device->model = 'Gear VR';
  208. $this->data->device->type = Constants\DeviceType::HEADSET;
  209. }
  210. }
  211. } elseif (isset($this->data->os->name) && $this->data->os->name == 'Linux' && preg_match('/SamsungBrowser\/([0-9.]*)/u', $ua, $match)) {
  212. $this->data->browser->name = "Samsung Internet";
  213. $this->data->browser->channel = null;
  214. $this->data->browser->stock = true;
  215. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  216. $this->data->os->name = 'Android';
  217. $this->data->os->version = null;
  218. $this->data->device->manufacturer = 'Samsung';
  219. $this->data->device->model = 'DeX';
  220. $this->data->device->identifier = '';
  221. $this->data->device->type = Constants\DeviceType::DESKTOP;
  222. } else {
  223. $channel = Data\Chrome::getChannel('desktop', $version);
  224. if ($channel == 'stable') {
  225. if (explode('.', $version)[1] == '0') {
  226. $this->data->browser->version->details = 1;
  227. } else {
  228. $this->data->browser->version->details = 2;
  229. }
  230. } elseif ($channel == 'beta') {
  231. $this->data->browser->channel = 'Beta';
  232. } else {
  233. $this->data->browser->channel = 'Dev';
  234. }
  235. }
  236. if ($this->data->device->type == '') {
  237. $this->data->device->type = Constants\DeviceType::DESKTOP;
  238. }
  239. }
  240. /* Google Chromium */
  241. if (preg_match('/Chromium/u', $ua)) {
  242. $this->data->browser->stock = false;
  243. $this->data->browser->channel = '';
  244. $this->data->browser->name = 'Chromium';
  245. $this->data->browser->type = Constants\BrowserType::BROWSER;
  246. if (preg_match('/Chromium\/([0-9.]*)/u', $ua, $match)) {
  247. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  248. }
  249. if ($this->data->device->type == '') {
  250. $this->data->device->type = Constants\DeviceType::DESKTOP;
  251. }
  252. }
  253. /* Chrome Content Shell */
  254. if (preg_match('/Chrome\/[0-9]+\.77\.34\.5/u', $ua)) {
  255. $this->data->browser->using = new Using([ 'name' => 'Chrome Content Shell' ]);
  256. $this->data->browser->type = Constants\BrowserType::UNKNOWN;
  257. $this->data->browser->stock = false;
  258. $this->data->browser->name = null;
  259. $this->data->browser->version = null;
  260. $this->data->browser->channel = null;
  261. }
  262. /* Chromium WebView by Amazon */
  263. if (preg_match('/AmazonWebAppPlatform\//u', $ua)) {
  264. $this->data->browser->using = new Using([ 'name' => 'Amazon WebView' ]);
  265. $this->data->browser->type = Constants\BrowserType::UNKNOWN;
  266. $this->data->browser->stock = false;
  267. $this->data->browser->name = null;
  268. $this->data->browser->version = null;
  269. $this->data->browser->channel = null;
  270. }
  271. /* Chromium WebView by Crosswalk */
  272. if (preg_match('/Crosswalk\/([0-9.]*)/u', $ua, $match)) {
  273. $this->data->browser->using = new Using([ 'name' => 'Crosswalk WebView', 'version' => new Version([ 'value' => $match[1], 'details' => 1 ]) ]);
  274. $this->data->browser->type = Constants\BrowserType::UNKNOWN;
  275. $this->data->browser->stock = false;
  276. $this->data->browser->name = null;
  277. $this->data->browser->version = null;
  278. $this->data->browser->channel = null;
  279. }
  280. /* Set the browser family */
  281. if ($this->data->isBrowser('Chrome') || $this->data->isBrowser('Chromium')) {
  282. $this->data->browser->family = new Family([
  283. 'name' => 'Chrome',
  284. 'version' => !empty($this->data->browser->version) ? new Version([ 'value' => $this->data->browser->version->getMajor() ]) : null
  285. ]);
  286. }
  287. }
  288. /* Internet Explorer */
  289. private function detectExplorer($ua)
  290. {
  291. if (preg_match('/\(IE ([0-9.]*)/u', $ua, $match)) {
  292. $this->data->browser->name = 'Internet Explorer';
  293. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  294. $this->data->browser->type = Constants\BrowserType::BROWSER;
  295. }
  296. if (preg_match('/Browser\/IE([0-9.]*)/u', $ua, $match)) {
  297. $this->data->browser->name = 'Internet Explorer';
  298. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  299. $this->data->browser->type = Constants\BrowserType::BROWSER;
  300. }
  301. if (preg_match('/MSIE/u', $ua)) {
  302. $this->data->browser->name = 'Internet Explorer';
  303. $this->data->browser->type = Constants\BrowserType::BROWSER;
  304. if (preg_match('/IEMobile/u', $ua) || preg_match('/Windows CE/u', $ua) || preg_match('/Windows Phone/u', $ua) || preg_match('/WP7/u', $ua) || preg_match('/WPDesktop/u', $ua)) {
  305. $this->data->browser->name = 'Mobile Internet Explorer';
  306. if (isset($this->data->device->model) && ($this->data->device->model == 'Xbox 360' || $this->data->device->model == 'Xbox One')) {
  307. $this->data->browser->name = 'Internet Explorer';
  308. }
  309. }
  310. if (preg_match('/MSIE ([0-9.]*)/u', $ua, $match)) {
  311. $this->data->browser->version = new Version([ 'value' => preg_replace("/\.([0-9])([0-9])/", '.$1.$2', $match[1]) ]);
  312. }
  313. if (preg_match('/Mac_/u', $ua)) {
  314. $this->data->os->name = 'Mac OS';
  315. $this->data->engine->name = 'Tasman';
  316. $this->data->device->type = Constants\DeviceType::DESKTOP;
  317. if (!empty($this->data->browser->version)) {
  318. if ($this->data->browser->version->is('>=', '5.1.1') && $this->data->browser->version->is('<=', '5.1.3')) {
  319. $this->data->os->name = 'OS X';
  320. }
  321. if ($this->data->browser->version->is('>=', '5.2')) {
  322. $this->data->os->name = 'OS X';
  323. }
  324. }
  325. }
  326. }
  327. if (preg_match('/Trident\/[789][^\)]+; rv:([0-9.]*)\)/u', $ua, $match)) {
  328. $this->data->browser->name = 'Internet Explorer';
  329. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  330. $this->data->browser->type = Constants\BrowserType::BROWSER;
  331. }
  332. if (preg_match('/Trident\/[789][^\)]+; Touch; rv:([0-9.]*);\s+IEMobile\//u', $ua, $match)) {
  333. $this->data->browser->name = 'Mobile Internet Explorer';
  334. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  335. $this->data->browser->type = Constants\BrowserType::BROWSER;
  336. }
  337. if (preg_match('/Trident\/[789][^\)]+; Touch; rv:([0-9.]*); WPDesktop/u', $ua, $match)) {
  338. $this->data->browser->mode = 'desktop';
  339. $this->data->browser->name = 'Mobile Internet Explorer';
  340. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  341. $this->data->browser->type = Constants\BrowserType::BROWSER;
  342. }
  343. /* Old versions of Pocket Internet Explorer */
  344. if ($this->data->isBrowser('Mobile Internet Explorer', '<', 6)) {
  345. $this->data->browser->name = 'Pocket Internet Explorer';
  346. }
  347. if (preg_match('/Microsoft Pocket Internet Explorer\//u', $ua)) {
  348. $this->data->browser->name = 'Pocket Internet Explorer';
  349. $this->data->browser->version = new Version([ 'value' => '1.0' ]);
  350. $this->data->browser->type = Constants\BrowserType::BROWSER;
  351. $this->data->device->type = Constants\DeviceType::MOBILE;
  352. }
  353. if (preg_match('/MSPIE ([0-9.]*)/u', $ua, $match)) {
  354. $this->data->browser->name = 'Pocket Internet Explorer2';
  355. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  356. $this->data->browser->type = Constants\BrowserType::BROWSER;
  357. $this->data->device->type = Constants\DeviceType::MOBILE;
  358. }
  359. /* Microsoft Mobile Explorer */
  360. if (preg_match('/MMEF([0-9])([0-9])/u', $ua, $match)) {
  361. $this->data->browser->name = 'Microsoft Mobile Explorer';
  362. $this->data->browser->version = new Version([ 'value' => $match[1] . '.' . $match[2] ]);
  363. $this->data->browser->type = Constants\BrowserType::BROWSER;
  364. $this->data->device->type = Constants\DeviceType::MOBILE;
  365. if (preg_match('/MMEF[0-9]+; ([^;]+); ([^\)\/]+)/u', $ua, $match)) {
  366. $device = Data\DeviceModels::identify('feature', $match[1] == 'CellPhone' ? $match[2] : $match[1] . ' ' . $match[2]);
  367. if ($device->identified) {
  368. $device->identified |= $this->data->device->identified;
  369. $this->data->device = $device;
  370. }
  371. }
  372. }
  373. /* Set the browser family */
  374. if ($this->data->isBrowser('Internet Explorer') || $this->data->isBrowser('Mobile Internet Explorer') || $this->data->isBrowser('Pocket Internet Explorer')) {
  375. unset($this->data->browser->family);
  376. }
  377. }
  378. /* Edge */
  379. private function detectEdge($ua)
  380. {
  381. if (preg_match('/Edge\/([0-9]+)/u', $ua, $match)) {
  382. $this->data->browser->name = 'Edge';
  383. $this->data->browser->type = Constants\BrowserType::BROWSER;
  384. $this->data->browser->channel = '';
  385. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 1 ]);
  386. }
  387. /* Set the browser family */
  388. if ($this->data->isBrowser('Edge')) {
  389. unset($this->data->browser->family);
  390. }
  391. }
  392. /* Opera */
  393. private function detectOpera($ua)
  394. {
  395. if (!preg_match('/(OPR|OMI|Opera|OPiOS|Coast|Oupeng)/ui', $ua)) {
  396. return;
  397. }
  398. if (preg_match('/OPR\/([0-9.]*)/u', $ua, $match)) {
  399. $this->data->browser->stock = false;
  400. $this->data->browser->channel = '';
  401. $this->data->browser->name = 'Opera';
  402. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  403. $this->data->browser->type = Constants\BrowserType::BROWSER;
  404. if (preg_match('/Edition Developer/iu', $ua)) {
  405. $this->data->browser->channel = 'Developer';
  406. }
  407. if (preg_match('/Edition Next/iu', $ua)) {
  408. $this->data->browser->channel = 'Next';
  409. }
  410. if (preg_match('/Edition Beta/iu', $ua)) {
  411. $this->data->browser->channel = 'Beta';
  412. }
  413. if ($this->data->device->type == Constants\DeviceType::MOBILE) {
  414. $this->data->browser->name = 'Opera Mobile';
  415. }
  416. }
  417. if (preg_match('/OMI\/([0-9]+\.[0-9]+)/u', $ua, $match)) {
  418. $this->data->browser->name = 'Opera Devices';
  419. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  420. $this->data->browser->type = Constants\BrowserType::BROWSER;
  421. $this->data->device->type = Constants\DeviceType::TELEVISION;
  422. if (!$this->data->isOs('Android')) {
  423. unset($this->data->os->name);
  424. unset($this->data->os->version);
  425. }
  426. }
  427. if ((preg_match('/Opera[\/\-\s]/iu', $ua) || preg_match('/Browser\/Opera/iu', $ua)) && !preg_match('/Opera Software/iu', $ua)) {
  428. $this->data->browser->stock = false;
  429. $this->data->browser->name = 'Opera';
  430. $this->data->browser->type = Constants\BrowserType::BROWSER;
  431. if (preg_match('/Opera[\/| ]?([0-9.]+)/u', $ua, $match)) {
  432. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  433. }
  434. if (preg_match('/Version\/([0-9.]+)/u', $ua, $match)) {
  435. if (floatval($match[1]) >= 10) {
  436. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  437. }
  438. }
  439. if (isset($this->data->browser->version) && preg_match('/Edition Labs/u', $ua)) {
  440. $this->data->browser->channel = 'Labs';
  441. }
  442. if (isset($this->data->browser->version) && preg_match('/Edition Next/u', $ua)) {
  443. $this->data->browser->channel = 'Next';
  444. }
  445. if (preg_match('/Opera Tablet/u', $ua)) {
  446. $this->data->browser->name = 'Opera Mobile';
  447. $this->data->device->type = Constants\DeviceType::TABLET;
  448. }
  449. if (preg_match('/Opera Mobi/u', $ua)) {
  450. $this->data->browser->name = 'Opera Mobile';
  451. $this->data->device->type = Constants\DeviceType::MOBILE;
  452. }
  453. if (preg_match('/Opera Mini;/u', $ua)) {
  454. $this->data->browser->name = 'Opera Mini';
  455. $this->data->browser->version = null;
  456. $this->data->browser->mode = 'proxy';
  457. $this->data->device->type = Constants\DeviceType::MOBILE;
  458. }
  459. if (preg_match('/Opera Mini\/(?:att\/)?([0-9.]+)/u', $ua, $match)) {
  460. $this->data->browser->name = 'Opera Mini';
  461. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => (intval(substr(strrchr($match[1], '.'), 1)) > 99 ? -1 : null) ]);
  462. $this->data->browser->mode = 'proxy';
  463. $this->data->device->type = Constants\DeviceType::MOBILE;
  464. }
  465. if ($this->data->browser->name == 'Opera' && $this->data->device->type == Constants\DeviceType::MOBILE) {
  466. $this->data->browser->name = 'Opera Mobile';
  467. }
  468. if (preg_match('/InettvBrowser/u', $ua)) {
  469. $this->data->device->type = Constants\DeviceType::TELEVISION;
  470. }
  471. if (preg_match('/Opera[ -]TV/u', $ua)) {
  472. $this->data->browser->name = 'Opera';
  473. $this->data->device->type = Constants\DeviceType::TELEVISION;
  474. }
  475. if (preg_match('/Linux zbov/u', $ua)) {
  476. $this->data->browser->name = 'Opera Mobile';
  477. $this->data->browser->mode = 'desktop';
  478. $this->data->device->type = Constants\DeviceType::MOBILE;
  479. $this->data->os->name = null;
  480. $this->data->os->version = null;
  481. }
  482. if (preg_match('/Linux zvav/u', $ua)) {
  483. $this->data->browser->name = 'Opera Mini';
  484. $this->data->browser->version = null;
  485. $this->data->browser->mode = 'desktop';
  486. $this->data->device->type = Constants\DeviceType::MOBILE;
  487. $this->data->os->name = null;
  488. $this->data->os->version = null;
  489. }
  490. if ($this->data->device->type == '') {
  491. $this->data->device->type = Constants\DeviceType::DESKTOP;
  492. }
  493. if (isset($this->data->browser->family)) {
  494. unset($this->data->browser->family);
  495. }
  496. }
  497. if (preg_match('/OPiOS\/([0-9.]*)/u', $ua, $match)) {
  498. $this->data->browser->stock = false;
  499. $this->data->browser->name = 'Opera Mini';
  500. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  501. $this->data->browser->type = Constants\BrowserType::BROWSER;
  502. }
  503. if (preg_match('/Coast\/([0-9.]*)/u', $ua, $match)) {
  504. $this->data->browser->stock = false;
  505. $this->data->browser->name = 'Coast by Opera';
  506. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  507. $this->data->browser->type = Constants\BrowserType::BROWSER;
  508. }
  509. if (preg_match('/Oupeng(?:HD)?[\/-]([0-9.]*)/u', $ua, $match)) {
  510. $this->data->browser->stock = false;
  511. $this->data->browser->name = 'Opera Oupeng';
  512. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  513. $this->data->browser->type = Constants\BrowserType::BROWSER;
  514. }
  515. }
  516. /* Firefox */
  517. private function detectFirefox($ua)
  518. {
  519. if (!preg_match('/(Firefox|GranParadiso|Namoroka|Shiretoko|Minefield|BonEcho|Fennec|Phoenix|Firebird|Minimo|FxiOS)/ui', $ua)) {
  520. return;
  521. }
  522. if (preg_match('/Firefox/u', $ua)) {
  523. $this->data->browser->stock = false;
  524. $this->data->browser->name = 'Firefox';
  525. $this->data->browser->type = Constants\BrowserType::BROWSER;
  526. if (preg_match('/Firefox\/([0-9ab.]*)/u', $ua, $match)) {
  527. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  528. if (preg_match('/a/u', $match[1])) {
  529. $this->data->browser->channel = 'Aurora';
  530. }
  531. if (preg_match('/b/u', $match[1])) {
  532. $this->data->browser->channel = 'Beta';
  533. }
  534. }
  535. if (preg_match('/Aurora\/([0-9ab.]*)/u', $ua, $match)) {
  536. $this->data->browser->channel = 'Aurora';
  537. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  538. }
  539. if (preg_match('/Fennec/u', $ua)) {
  540. $this->data->device->type = Constants\DeviceType::MOBILE;
  541. }
  542. if (preg_match('/Mobile;(?: ([^;]+);)? rv/u', $ua, $match)) {
  543. $this->data->device->type = Constants\DeviceType::MOBILE;
  544. if (isset($match[1])) {
  545. $device = Data\DeviceModels::identify('firefoxos', $match[1]);
  546. if ($device->identified) {
  547. $device->identified |= $this->data->device->identified;
  548. $this->data->os->reset([ 'name' => 'Firefox OS' ]);
  549. $this->data->device = $device;
  550. }
  551. }
  552. }
  553. if (preg_match('/Tablet;(?: ([^;]+);)? rv/u', $ua, $match)) {
  554. $this->data->device->type = Constants\DeviceType::TABLET;
  555. }
  556. if (preg_match('/Viera;(?: ([^;]+);)? rv/u', $ua, $match)) {
  557. $this->data->device->type = Constants\DeviceType::TELEVISION;
  558. $this->data->os->reset([ 'name' => 'Firefox OS' ]);
  559. }
  560. if ($this->data->device->type == Constants\DeviceType::MOBILE || $this->data->device->type == Constants\DeviceType::TABLET) {
  561. $this->data->browser->name = 'Firefox Mobile';
  562. }
  563. if ($this->data->device->type == '') {
  564. $this->data->device->type = Constants\DeviceType::DESKTOP;
  565. }
  566. }
  567. if (preg_match('/(GranParadiso|Namoroka|Shiretoko|Minefield|BonEcho)/u', $ua, $match)) {
  568. $this->data->browser->stock = false;
  569. $this->data->browser->name = 'Firefox';
  570. $this->data->browser->channel = str_replace('GranParadiso', 'Gran Paradiso', $match[1]);
  571. $this->data->browser->type = Constants\BrowserType::BROWSER;
  572. if (preg_match('/' . $match[1] . '\/([0-9ab.]*)/u', $ua, $match)) {
  573. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  574. }
  575. }
  576. if (preg_match('/Fennec/u', $ua)) {
  577. $this->data->browser->stock = false;
  578. $this->data->browser->name = 'Firefox Mobile';
  579. $this->data->browser->type = Constants\BrowserType::BROWSER;
  580. if (preg_match('/Fennec\/([0-9ab.]*)/u', $ua, $match)) {
  581. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  582. }
  583. $this->data->browser->channel = 'Fennec';
  584. }
  585. if (preg_match('/(Phoenix|Firebird|Minimo)/u', $ua, $match)) {
  586. $this->data->browser->stock = false;
  587. $this->data->browser->name = $match[1];
  588. $this->data->browser->type = Constants\BrowserType::BROWSER;
  589. if (preg_match('/' . $match[1] . '\/([0-9ab.]*)/u', $ua, $match)) {
  590. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  591. }
  592. }
  593. if (preg_match('/FxiOS\/([0-9.]*)/u', $ua, $match)) {
  594. $this->data->browser->name = 'Firefox';
  595. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  596. $this->data->browser->type = Constants\BrowserType::BROWSER;
  597. }
  598. if (preg_match('/Servo\/1.0 Firefox\/37.0/u', $ua)) {
  599. $this->data->browser->name = 'Servo Nightly Build';
  600. $this->data->browser->version = null;
  601. }
  602. /* Set the browser family */
  603. if ($this->data->isBrowser('Firefox') || $this->data->isBrowser('Firefox Mobile') || $this->data->isBrowser('Firebird')) {
  604. $this->data->browser->family = new Family([ 'name' => 'Firefox', 'version' => $this->data->browser->version ]);
  605. }
  606. if ($this->data->isBrowser('Minimo')) {
  607. $this->data->browser->family = new Family([ 'name' => 'Firefox' ]);
  608. }
  609. }
  610. /* Seamonkey */
  611. private function detectSeamonkey($ua)
  612. {
  613. if (preg_match('/SeaMonkey/u', $ua)) {
  614. $this->data->browser->stock = false;
  615. $this->data->browser->name = 'SeaMonkey';
  616. $this->data->browser->type = Constants\BrowserType::BROWSER;
  617. if (preg_match('/SeaMonkey\/([0-9ab.]*)/u', $ua, $match)) {
  618. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  619. }
  620. }
  621. if (preg_match('/PmWFx\/([0-9ab.]*)/u', $ua, $match)) {
  622. $this->data->browser->stock = false;
  623. $this->data->browser->name = 'SeaMonkey';
  624. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  625. $this->data->browser->type = Constants\BrowserType::BROWSER;
  626. }
  627. }
  628. /* Netscape */
  629. private function detectLegacyNetscape($ua)
  630. {
  631. if ($this->data->device->type == Constants\DeviceType::DESKTOP && $this->data->browser->getName() == '') {
  632. if (!preg_match('/compatible;/u', $ua)) {
  633. if (preg_match('/Mozilla\/([123].[0-9]+)/u', $ua, $match)) {
  634. $this->data->browser->name = 'Netscape Navigator';
  635. $this->data->browser->version = new Version([ 'value' => preg_replace("/([0-9])([0-9])/", '$1.$2', $match[1]) ]);
  636. $this->data->browser->type = Constants\BrowserType::BROWSER;
  637. }
  638. if (preg_match('/Mozilla\/(4.[0-9]+)/u', $ua, $match)) {
  639. $this->data->browser->name = 'Netscape Communicator';
  640. $this->data->browser->version = new Version([ 'value' => preg_replace("/([0-9])([0-9])/", '$1.$2', $match[1]) ]);
  641. $this->data->browser->type = Constants\BrowserType::BROWSER;
  642. if (preg_match('/Nav\)/u', $ua)) {
  643. $this->data->browser->name = 'Netscape Navigator';
  644. }
  645. }
  646. }
  647. }
  648. }
  649. private function detectModernNetscape($ua)
  650. {
  651. if (preg_match('/Netscape/u', $ua)) {
  652. $this->data->browser->stock = false;
  653. $this->data->browser->name = 'Netscape';
  654. $this->data->browser->type = Constants\BrowserType::BROWSER;
  655. if (preg_match('/Netscape[0-9]?\/([0-9.]*)/u', $ua, $match)) {
  656. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  657. }
  658. }
  659. if (preg_match('/ Navigator\/(9\.[0-9.]*)/u', $ua, $match)) {
  660. $this->data->browser->stock = false;
  661. $this->data->browser->name = 'Netscape Navigator';
  662. $this->data->browser->type = Constants\BrowserType::BROWSER;
  663. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  664. }
  665. }
  666. /* Mosaic */
  667. private function detectMosaic($ua)
  668. {
  669. if (!preg_match('/Mosaic/ui', $ua)) {
  670. return;
  671. }
  672. if (preg_match('/(?:NCSA[ _])?Mosaic(?:\(tm\))?(?: for the X Window System| for Windows)?\/(?:Version )?([0-9.]*)/u', $ua, $match)) {
  673. $this->data->browser->name = 'NCSA Mosaic';
  674. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  675. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  676. $this->data->browser->type = Constants\BrowserType::BROWSER;
  677. $this->data->browser->stock = false;
  678. }
  679. if (preg_match('/AIR_Mosaic(?:\(16bit\))?\/v([0-9.]*)/u', $ua, $match)) {
  680. $this->data->browser->name = 'AIR Mosaic';
  681. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  682. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  683. $this->data->browser->type = Constants\BrowserType::BROWSER;
  684. $this->data->browser->stock = false;
  685. }
  686. if (preg_match('/(?:MosaicView|Spyglass[ _]Mosaic)\/([0-9.]*)/u', $ua, $match)) {
  687. $this->data->browser->name = 'Spyglass Mosaic';
  688. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  689. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  690. $this->data->browser->type = Constants\BrowserType::BROWSER;
  691. $this->data->browser->stock = false;
  692. }
  693. if (preg_match('/SPRY_Mosaic(?:\(16bit\))?\/v([0-9.]*)/u', $ua, $match)) {
  694. $this->data->browser->name = 'SPRY Mosaic';
  695. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  696. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  697. $this->data->browser->type = Constants\BrowserType::BROWSER;
  698. $this->data->browser->stock = false;
  699. }
  700. if (preg_match('/DCL SuperMosaic\/([0-9.]*)/u', $ua, $match)) {
  701. $this->data->browser->name = 'SuperMosaic';
  702. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  703. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  704. $this->data->browser->type = Constants\BrowserType::BROWSER;
  705. $this->data->browser->stock = false;
  706. }
  707. if (preg_match('/VMS_Mosaic\/([0-9.]*)/u', $ua, $match)) {
  708. $this->data->browser->name = 'VMS Mosaic';
  709. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  710. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  711. $this->data->browser->type = Constants\BrowserType::BROWSER;
  712. $this->data->browser->stock = false;
  713. }
  714. if (preg_match('/mMosaic\/([0-9.]*)/u', $ua, $match)) {
  715. $this->data->browser->name = 'mMosaic';
  716. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  717. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  718. $this->data->browser->type = Constants\BrowserType::BROWSER;
  719. $this->data->browser->stock = false;
  720. }
  721. if (preg_match('/Quarterdeck Mosaic Version ([0-9.]*)/u', $ua, $match)) {
  722. $this->data->browser->name = 'Quarterdeck Mosaic';
  723. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  724. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  725. $this->data->browser->type = Constants\BrowserType::BROWSER;
  726. $this->data->browser->stock = false;
  727. }
  728. if (preg_match('/WinMosaic\/Version ([0-9.]*)/u', $ua, $match)) {
  729. $this->data->browser->name = 'WinMosaic';
  730. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  731. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  732. $this->data->browser->type = Constants\BrowserType::BROWSER;
  733. $this->data->browser->stock = false;
  734. }
  735. if (preg_match('/Device Mosaic ([0-9.]*)/u', $ua, $match)) {
  736. $this->data->browser->name = 'Device Mosaic';
  737. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  738. $this->data->browser->family = new Family([ 'name' => 'Mosaic' ]);
  739. $this->data->browser->type = Constants\BrowserType::BROWSER;
  740. $this->data->browser->stock = false;
  741. $this->data->device->type = Constants\DeviceType::TELEVISION;
  742. }
  743. }
  744. /* UC Browser */
  745. private function detectUC($ua)
  746. {
  747. if (!preg_match('/(UC|UBrowser)/ui', $ua)) {
  748. return;
  749. }
  750. if (preg_match('/UCWEB/u', $ua)) {
  751. $this->data->browser->stock = false;
  752. $this->data->browser->name = 'UC Browser';
  753. $this->data->browser->type = Constants\BrowserType::BROWSER;
  754. unset($this->data->browser->channel);
  755. if (preg_match('/UCWEB\/?([0-9]*[.][0-9]*)/u', $ua, $match)) {
  756. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  757. }
  758. if (!$this->data->device->type) {
  759. $this->data->device->type = Constants\DeviceType::MOBILE;
  760. }
  761. if (isset($this->data->os->name) && $this->data->os->name == 'Linux') {
  762. $this->data->os->reset();
  763. }
  764. if (preg_match('/^IUC ?\(U; ?iOS ([0-9\._]+);/u', $ua, $match)) {
  765. $this->data->os->name = 'iOS';
  766. $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]) ]);
  767. }
  768. if (preg_match('/^JUC ?\(Linux; ?U; ?(?:Android)? ?([0-9\.]+)[^;]*; ?[^;]+; ?([^;]*[^\s])\s*; ?[0-9]+\*[0-9]+;?\)/u', $ua, $match)) {
  769. $this->data->os->name = 'Android';
  770. $this->data->os->version = new Version([ 'value' => $match[1] ]);
  771. $this->data->device = Data\DeviceModels::identify('android', $match[2]);
  772. }
  773. if (preg_match('/\(MIDP-2.0; U; [^;]+; ([^;]*[^\s])\)/u', $ua, $match)) {
  774. $this->data->os->name = 'Android';
  775. $this->data->device->model = $match[1];
  776. $this->data->device->identified |= Constants\Id::PATTERN;
  777. $device = Data\DeviceModels::identify('android', $match[1]);
  778. if ($device->identified) {
  779. $device->identified |= $this->data->device->identified;
  780. $this->data->device = $device;
  781. }
  782. }
  783. if (preg_match('/\((?:Linux|MIDP-2.0); U; Adr ([0-9\.]+)(?:-update[0-9])?; [^;]+; ([^;]*[^\s])\)/u', $ua, $match)) {
  784. $this->data->os->name = 'Android';
  785. $this->data->os->version = new Version([ 'value' => $match[1] ]);
  786. $this->data->device->model = $match[2];
  787. $this->data->device->identified |= Constants\Id::PATTERN;
  788. $device = Data\DeviceModels::identify('android', $match[2]);
  789. if ($device->identified) {
  790. $device->identified |= $this->data->device->identified;
  791. $this->data->device = $device;
  792. }
  793. }
  794. if (preg_match('/\((?:iOS|iPhone);/u', $ua)) {
  795. $this->data->os->name = 'iOS';
  796. $this->data->os->version = new Version([ 'value' => '1.0' ]);
  797. if (preg_match('/OS[_ ]([0-9_]*);/u', $ua, $match)) {
  798. $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]) ]);
  799. }
  800. if (preg_match('/; ([^;]+)\)/u', $ua, $match)) {
  801. $device = Data\DeviceModels::identify('ios', $match[1]);
  802. if ($device->identified) {
  803. $device->identified |= $this->data->device->identified;
  804. $this->data->device = $device;
  805. }
  806. }
  807. }
  808. if (preg_match('/\(Symbian;/u', $ua)) {
  809. $this->data->os->name = 'Series60';
  810. $this->data->os->version = null;
  811. $this->data->os->family = new Family([ 'name' => 'Symbian' ]);
  812. if (preg_match('/S60 V([0-9])/u', $ua, $match)) {
  813. $this->data->os->version = new Version([ 'value' => $match[1] ]);
  814. }
  815. if (preg_match('/; Nokia([^;]+)\)/iu', $ua, $match)) {
  816. $this->data->device->model = $match[1];
  817. $this->data->device->identified |= Constants\Id::PATTERN;
  818. $device = Data\DeviceModels::identify('symbian', $match[1]);
  819. if ($device->identified) {
  820. $device->identified |= $this->data->device->identified;
  821. $this->data->device = $device;
  822. }
  823. }
  824. }
  825. if (preg_match('/\(Windows;/u', $ua)) {
  826. $this->data->os->name = 'Windows Phone';
  827. $this->data->os->version = null;
  828. if (preg_match('/wds ([0-9]+\.[0-9])/u', $ua, $match)) {
  829. switch ($match[1]) {
  830. case '7.1':
  831. $this->data->os->version = new Version([ 'value' => '7.5' ]);
  832. break;
  833. case '8.0':
  834. $this->data->os->version = new Version([ 'value' => '8.0' ]);
  835. break;
  836. case '8.1':
  837. $this->data->os->version = new Version([ 'value' => '8.1' ]);
  838. break;
  839. case '10.0':
  840. $this->data->os->version = new Version([ 'value' => '10.0' ]);
  841. break;
  842. }
  843. }
  844. if (preg_match('/; ([^;]+); ([^;]+)\)/u', $ua, $match)) {
  845. $this->data->device->manufacturer = $match[1];
  846. $this->data->device->model = $match[2];
  847. $this->data->device->identified |= Constants\Id::PATTERN;
  848. $device = Data\DeviceModels::identify('wp', $match[2]);
  849. if ($device->identified) {
  850. $device->identified |= $this->data->device->identified;
  851. $this->data->device = $device;
  852. }
  853. }
  854. }
  855. }
  856. if (preg_match('/Ucweb\/([0-9]*[.][0-9]*)/u', $ua, $match)) {
  857. $this->data->browser->stock = false;
  858. $this->data->browser->name = 'UC Browser';
  859. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  860. $this->data->browser->type = Constants\BrowserType::BROWSER;
  861. }
  862. if (preg_match('/ucweb-squid/u', $ua)) {
  863. $this->data->browser->stock = false;
  864. $this->data->browser->name = 'UC Browser';
  865. $this->data->browser->type = Constants\BrowserType::BROWSER;
  866. unset($this->data->browser->channel);
  867. }
  868. if (preg_match('/\) ?UC /u', $ua)) {
  869. $this->data->browser->stock = false;
  870. $this->data->browser->name = 'UC Browser';
  871. $this->data->browser->type = Constants\BrowserType::BROWSER;
  872. unset($this->data->browser->version);
  873. unset($this->data->browser->channel);
  874. unset($this->data->browser->mode);
  875. if ($this->data->device->type == Constants\DeviceType::DESKTOP) {
  876. $this->data->device->type = Constants\DeviceType::MOBILE;
  877. $this->data->browser->mode = 'desktop';
  878. }
  879. }
  880. if (preg_match('/UC ?Browser\/?([0-9.]*)/u', $ua, $match)) {
  881. $this->data->browser->stock = false;
  882. $this->data->browser->name = 'UC Browser';
  883. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  884. $this->data->browser->type = Constants\BrowserType::BROWSER;
  885. unset($this->data->browser->channel);
  886. if (!$this->data->device->type) {
  887. $this->data->device->type = Constants\DeviceType::MOBILE;
  888. }
  889. }
  890. if (preg_match('/UBrowser\/?([0-9.]*)/u', $ua, $match)) {
  891. $this->data->browser->stock = false;
  892. $this->data->browser->name = 'UC Browser';
  893. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  894. $this->data->browser->type = Constants\BrowserType::BROWSER;
  895. unset($this->data->browser->channel);
  896. }
  897. /* U2 is the Proxy service used by UC Browser on low-end phones */
  898. if (preg_match('/U2\//u', $ua)) {
  899. $this->data->browser->stock = false;
  900. $this->data->browser->name = 'UC Browser';
  901. $this->data->browser->mode = 'proxy';
  902. $this->data->engine->name = 'Gecko';
  903. /* UC Browser running on Windows 8 is identifing itself as U2, but instead its a Trident Webview */
  904. if (isset($this->data->os->name) && isset($this->data->os->version)) {
  905. if ($this->data->os->name == 'Windows Phone' && $this->data->os->version->toFloat() >= 8) {
  906. $this->data->engine->name = 'Trident';
  907. $this->data->browser->mode = '';
  908. }
  909. }
  910. if ($this->data->device->identified < Constants\Id::MATCH_UA && preg_match('/; ([^;]*)\) U2\//u', $ua, $match)) {
  911. $device = Data\DeviceModels::identify('android', $match[1]);
  912. if ($device->identified) {
  913. $device->identified |= $this->data->device->identified;
  914. $this->data->device = $device;
  915. if (!isset($this->data->os->name) || ($this->data->os->name != 'Android' && (!isset($this->data->os->family) || $this->data->os->family->getName() != 'Android'))) {
  916. $this->data->os->name = 'Android';
  917. }
  918. }
  919. }
  920. }
  921. /* U3 is the Webkit based Webview used on Android phones */
  922. if (preg_match('/U3\//u', $ua)) {
  923. $this->data->engine->name = 'Webkit';
  924. }
  925. }
  926. private function detectUCEngine($ua)
  927. {
  928. if (isset($this->data->browser->name)) {
  929. if ($this->data->browser->name == 'UC Browser') {
  930. if (!preg_match("/UBrowser\//", $ua) && ($this->data->device->type == 'desktop' || (isset($this->data->os->name) && ($this->data->os->name == 'Windows' || $this->data->os->name == 'OS X')))) {
  931. $this->data->device->type = Constants\DeviceType::MOBILE;
  932. $this->data->browser->mode = 'desktop';
  933. $this->data->engine->reset();
  934. $this->data->os->reset();
  935. } elseif (!isset($this->data->os->name) || ($this->data->os->name != 'iOS' && $this->data->os->name != 'Windows Phone' && $this->data->os->name != 'Windows' && $this->data->os->name != 'Android' && (!isset($this->data->os->family) || $this->data->os->family->getName() != 'Android'))) {
  936. $this->data->engine->name = 'Gecko';
  937. unset($this->data->engine->version);
  938. $this->data->browser->mode = 'proxy';
  939. }
  940. if (isset($this->data->engine->name) && $this->data->engine->name == 'Presto') {
  941. $this->data->engine->name = 'Webkit';
  942. unset($this->data->engine->version);
  943. }
  944. }
  945. }
  946. }
  947. /* Netfront */
  948. private function detectNetfront($ua)
  949. {
  950. if (!preg_match('/(CNF|NF|NetFront|NX|Ave|COM2)/ui', $ua)) {
  951. return;
  952. }
  953. /* Compact NetFront */
  954. if (preg_match('/CNF\/([0-9.]*)/u', $ua, $match)) {
  955. $this->data->browser->name = 'Compact NetFront';
  956. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  957. $this->data->browser->type = Constants\BrowserType::BROWSER;
  958. $this->data->device->type = Constants\DeviceType::MOBILE;
  959. }
  960. /* NetFront */
  961. if (preg_match('/Net[fF]ront/u', $ua) && !preg_match('/NetFrontNX/u', $ua)) {
  962. $this->data->browser->name = 'NetFront';
  963. $this->data->browser->type = Constants\BrowserType::BROWSER;
  964. unset($this->data->browser->channel);
  965. if (preg_match('/NetFront[ \/]?([0-9.]*)/ui', $ua, $match)) {
  966. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  967. }
  968. /* Detect device type based on NetFront identifier */
  969. if (preg_match('/MobilePhone/u', $ua)) {
  970. $this->data->device->type = Constants\DeviceType::MOBILE;
  971. }
  972. if (preg_match('/DigitalMediaPlayer/u', $ua)) {
  973. $this->data->device->type = Constants\DeviceType::MEDIA;
  974. }
  975. if (preg_match('/PDA/u', $ua)) {
  976. $this->data->device->type = Constants\DeviceType::PDA;
  977. }
  978. if (preg_match('/MFP/u', $ua)) {
  979. $this->data->device->type = Constants\DeviceType::PRINTER;
  980. }
  981. if (preg_match('/(InettvBrowser|HbbTV|DTV|NetworkAVTV|BDPlayer)/u', $ua)) {
  982. $this->data->device->type = Constants\DeviceType::TELEVISION;
  983. }
  984. if (preg_match('/VCC/u', $ua)) {
  985. $this->data->device->type = Constants\DeviceType::CAR;
  986. }
  987. if (preg_match('/Kindle/u', $ua)) {
  988. $this->data->device->type = Constants\DeviceType::EREADER;
  989. }
  990. if (empty($this->data->device->type)) {
  991. $this->data->device->type = Constants\DeviceType::MOBILE;
  992. }
  993. /* Detect OS based on NetFront identifier */
  994. if (preg_match('/NF[0-9][0-9](?:WMPRO|PPC)\//ui', $ua, $match)) {
  995. if (!$this->data->isOs('Windows Mobile')) {
  996. $this->data->os->reset([
  997. 'name' => 'Windows Mobile'
  998. ]);
  999. }
  1000. }
  1001. }
  1002. if (preg_match('/(?:Browser\/(?:NF|NetFr?ont-)|NF-Browser\/|ACS-NF\/|NetFront FullBrowser\/)([0-9.]*)/ui', $ua, $match)) {
  1003. $this->data->browser->name = 'NetFront';
  1004. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1005. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1006. unset($this->data->browser->channel);
  1007. $this->data->device->type = Constants\DeviceType::MOBILE;
  1008. }
  1009. /* AVE-Front */
  1010. if (preg_match('/(?:AVE-Front|AveFront)\/([0-9.]*)/u', $ua, $match)) {
  1011. $this->data->browser->name = 'NetFront';
  1012. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1013. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1014. if (preg_match('/Category=([^\);]+)[\);]/u', $ua, $match)) {
  1015. switch ($match[1]) {
  1016. case 'WebPhone':
  1017. $this->data->device->type = Constants\DeviceType::MOBILE;
  1018. $this->data->device->subtype = Constants\DeviceSubType::DESKTOP;
  1019. break;
  1020. case 'WP':
  1021. case 'Home Mail Tool':
  1022. case 'PDA':
  1023. $this->data->device->type = Constants\DeviceType::PDA;
  1024. break;
  1025. case 'STB':
  1026. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1027. break;
  1028. case 'GAME':
  1029. $this->data->device->type = Constants\DeviceType::GAMING;
  1030. $this->data->device->subtype = Constants\DeviceSubType::CONSOLE;
  1031. break;
  1032. }
  1033. }
  1034. if (preg_match('/Product=([^\);]+)[\);]/u', $ua, $match)) {
  1035. if (in_array($match[1], [ 'ACCESS/NFPS', 'SUNSOFT/EnjoyMagic' ])) {
  1036. $this->data->device->setIdentification([
  1037. 'manufacturer' => 'Sony',
  1038. 'model' => 'Playstation 2',
  1039. 'type' => Constants\DeviceType::GAMING,
  1040. 'subtype' => Constants\DeviceSubType::CONSOLE
  1041. ]);
  1042. }
  1043. }
  1044. }
  1045. /* Netfront NX */
  1046. if (preg_match('/NX\/([0-9.]*)/u', $ua, $match)) {
  1047. $this->data->browser->name = 'NetFront NX';
  1048. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1049. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1050. unset($this->data->browser->channel);
  1051. if (empty($this->data->device->type) || $this->data->isType('desktop')) {
  1052. if (preg_match('/(DTV|HbbTV)/iu', $ua)) {
  1053. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1054. } else {
  1055. $this->data->device->type = Constants\DeviceType::DESKTOP;
  1056. }
  1057. }
  1058. $this->data->os->reset();
  1059. }
  1060. /* The Sony Mylo 2 identifies as Firefox 2, but is NetFront */
  1061. if (preg_match('/Sony\/COM2/u', $ua, $match)) {
  1062. $this->data->browser->reset([
  1063. 'name' => 'NetFront',
  1064. 'type' => Constants\BrowserType::BROWSER
  1065. ]);
  1066. }
  1067. }
  1068. /* Obigo */
  1069. private function detectObigo($ua)
  1070. {
  1071. $processObigoVersion = function ($version) {
  1072. $result = [
  1073. 'value' => $version
  1074. ];
  1075. if (preg_match('/[0-9.]+/', $version, $match)) {
  1076. $result['details'] = 2;
  1077. }
  1078. if (preg_match('/([0-9])[A-Z]/', $version, $match)) {
  1079. $result['value'] = intval($match[1]);
  1080. $result['alias'] = $version;
  1081. }
  1082. return $result;
  1083. };
  1084. if (preg_match('/(?:Obigo|Teleca|AU-MIC|MIC\/)/ui', $ua)) {
  1085. $this->data->browser->name = 'Obigo';
  1086. $this->data->browser->version = null;
  1087. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1088. if (preg_match('/Obigo\/0?([0-9.]+)/iu', $ua, $match)) {
  1089. $this->data->browser->version = new Version($processObigoVersion($match[1]));
  1090. } elseif (preg_match('/(?:MIC|TelecaBrowser)\/(WAP|[A-Z])?0?([0-9.]+[A-Z]?)/iu', $ua, $match)) {
  1091. $this->data->browser->version = new Version($processObigoVersion($match[2]));
  1092. if (!empty($match[1])) {
  1093. $this->data->browser->name = 'Obigo ' . strtoupper($match[1]);
  1094. }
  1095. } elseif (preg_match('/(?:Obigo(?:InternetBrowser|[- ]Browser)?|Teleca)\/(WAP|[A-Z])?[0O]?([0-9.]+[A-Z]?)/ui', $ua, $match)) {
  1096. $this->data->browser->version = new Version($processObigoVersion($match[2]));
  1097. if (!empty($match[1])) {
  1098. $this->data->browser->name = 'Obigo ' . strtoupper($match[1]);
  1099. }
  1100. } elseif (preg_match('/(?:Obigo|Teleca)[- ]([WAP|[A-Z])?0?([0-9.]+[A-Z]?)(?:[0-9])?(?:[\/;]|$)/ui', $ua, $match)) {
  1101. $this->data->browser->version = new Version($processObigoVersion($match[2]));
  1102. if (!empty($match[1])) {
  1103. $this->data->browser->name = 'Obigo ' . strtoupper($match[1]);
  1104. }
  1105. } elseif (preg_match('/Browser\/(?:Obigo|Teleca)[_-]?(?:Browser\/)?(WAP|[A-Z])?0?([0-9.]+[A-Z]?)/ui', $ua, $match)) {
  1106. $this->data->browser->version = new Version($processObigoVersion($match[2]));
  1107. if (!empty($match[1])) {
  1108. $this->data->browser->name = 'Obigo ' . strtoupper($match[1]);
  1109. }
  1110. } elseif (preg_match('/Obigo Browser (WAP|[A-Z])?0?([0-9.]+[A-Z]?)/ui', $ua, $match)) {
  1111. $this->data->browser->version = new Version($processObigoVersion($match[2]));
  1112. if (!empty($match[1])) {
  1113. $this->data->browser->name = 'Obigo ' . strtoupper($match[1]);
  1114. }
  1115. }
  1116. }
  1117. if (preg_match('/(Q)0?([0-9][A-Z])/u', $ua, $match)) {
  1118. $this->data->browser->name = 'Obigo ' . $match[1];
  1119. $this->data->browser->version = new Version($processObigoVersion($match[2]));
  1120. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1121. }
  1122. }
  1123. /* ANT Galio and ANT Fresco */
  1124. private function detectAnt($ua)
  1125. {
  1126. if (preg_match('/ANTFresco\/([0-9.]+)/iu', $ua, $match)) {
  1127. $this->data->browser->name = 'ANT Fresco';
  1128. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1129. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1130. }
  1131. if (preg_match('/ANTGalio\/([0-9.]+)/iu', $ua, $match)) {
  1132. $this->data->browser->name = 'ANT Galio';
  1133. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1134. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1135. }
  1136. }
  1137. /* Seraphic Sraf */
  1138. private function detectSraf($ua)
  1139. {
  1140. if (preg_match('/sraf_tv_browser/u', $ua)) {
  1141. $this->data->browser->name = 'Seraphic Sraf';
  1142. $this->data->browser->version = null;
  1143. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1144. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1145. }
  1146. if (preg_match('/SRAF\/([0-9.]+)/iu', $ua, $match)) {
  1147. $this->data->browser->name = 'Seraphic Sraf';
  1148. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1149. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1150. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1151. }
  1152. }
  1153. /* MachBlue */
  1154. private function detectMachBlue($ua)
  1155. {
  1156. if (preg_match('/mbxtWebKit\/([0-9.]*)/u', $ua, $match)) {
  1157. $this->data->os->name = '';
  1158. $this->data->browser->name = 'MachBlue XT';
  1159. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1160. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1161. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1162. }
  1163. if ($ua == 'MachBlue') {
  1164. $this->data->os->name = '';
  1165. $this->data->browser->name = 'MachBlue XT';
  1166. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1167. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1168. }
  1169. }
  1170. /* Espial */
  1171. private function detectEspial($ua)
  1172. {
  1173. if (preg_match('/Espial/u', $ua)) {
  1174. $this->data->browser->name = 'Espial';
  1175. $this->data->browser->channel = null;
  1176. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1177. $this->data->os->name = '';
  1178. $this->data->os->version = null;
  1179. if ($this->data->device->type != Constants\DeviceType::TELEVISION) {
  1180. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1181. $this->data->device->manufacturer = null;
  1182. $this->data->device->model = null;
  1183. }
  1184. if (preg_match('/Espial(?: Browser|TVBrowser)?\/(?:sig)?([0-9.]*)/u', $ua, $match)) {
  1185. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1186. }
  1187. if (preg_match('/;(L6200|L7200)/u', $ua, $match)) {
  1188. $this->data->device->manufacturer = 'Toshiba';
  1189. $this->data->device->model = 'Regza ' . $match[1];
  1190. $this->data->device->series = 'Smart TV';
  1191. $this->data->device->identified |= Constants\Id::MATCH_UA;
  1192. $this->data->device->generic = false;
  1193. }
  1194. }
  1195. }
  1196. /* Iris */
  1197. private function detectIris($ua)
  1198. {
  1199. if (preg_match('/Iris\//u', $ua)) {
  1200. $this->data->browser->name = 'Iris';
  1201. $this->data->browser->hidden = false;
  1202. $this->data->browser->stock = false;
  1203. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1204. if (preg_match('/Iris\/([0-9.]*)/u', $ua, $match)) {
  1205. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1206. }
  1207. if (preg_match('/ WM([0-9]) /u', $ua, $match)) {
  1208. $this->data->device->reset();
  1209. $this->data->device->type = Constants\DeviceType::MOBILE;
  1210. $this->data->os->reset();
  1211. $this->data->os->name = 'Windows Mobile';
  1212. $this->data->os->version = new Version([ 'value' => $match[1] . '.0' ]);
  1213. }
  1214. if (preg_match('/Windows NT/u', $ua, $match)) {
  1215. $this->data->browser->mode = 'desktop';
  1216. $this->data->device->reset();
  1217. $this->data->device->type = Constants\DeviceType::MOBILE;
  1218. $this->data->os->reset();
  1219. $this->data->os->name = 'Windows Mobile';
  1220. }
  1221. }
  1222. }
  1223. /* Dolfin */
  1224. private function detectDolfin($ua)
  1225. {
  1226. if (preg_match('/(Dolfin|Jasmine)/u', $ua)) {
  1227. $this->data->browser->name = 'Dolfin';
  1228. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1229. if (preg_match('/(?:Dolfin|Jasmine)\/([0-9.]*)/u', $ua, $match)) {
  1230. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1231. }
  1232. if (preg_match('/Browser\/Dolfin([0-9.]*)/u', $ua, $match)) {
  1233. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1234. }
  1235. }
  1236. }
  1237. /* WebOS */
  1238. private function detectWebOSBrowser($ua)
  1239. {
  1240. if (preg_match('/wOSBrowser/u', $ua)) {
  1241. $this->data->browser->name = 'webOS Browser';
  1242. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1243. if ($this->data->os->name != 'webOS') {
  1244. $this->data->os->name = 'webOS';
  1245. }
  1246. if (isset($this->data->device->manufacturer) && $this->data->device->manufacturer == 'Apple') {
  1247. unset($this->data->device->manufacturer);
  1248. unset($this->data->device->model);
  1249. unset($this->data->device->identifier);
  1250. $this->data->device->identified = Constants\Id::NONE;
  1251. }
  1252. }
  1253. }
  1254. /* Sailfish */
  1255. private function detectSailfishBrowser($ua)
  1256. {
  1257. if (preg_match('/Sailfish ?Browser/u', $ua)) {
  1258. $this->data->browser->name = 'Sailfish Browser';
  1259. $this->data->browser->stock = true;
  1260. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1261. if (preg_match('/Sailfish ?Browser\/([0-9.]*)/u', $ua, $match)) {
  1262. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1263. }
  1264. }
  1265. }
  1266. /* Silk */
  1267. private function detectSilk($ua)
  1268. {
  1269. if (preg_match('/Silk/u', $ua)) {
  1270. if (preg_match('/Silk-Accelerated/u', $ua) || !preg_match('/PlayStation/u', $ua)) {
  1271. $this->data->browser->name = 'Silk';
  1272. $this->data->browser->channel = null;
  1273. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1274. if (preg_match('/Silk\/([0-9.]*)/u', $ua, $match)) {
  1275. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1276. }
  1277. if (preg_match('/; ([^;]*[^;\s])\s+Build/u', $ua, $match)) {
  1278. $this->data->device = Data\DeviceModels::identify('android', $match[1]);
  1279. }
  1280. if (!$this->data->device->identified) {
  1281. $this->data->device->manufacturer = 'Amazon';
  1282. $this->data->device->model = 'Kindle Fire';
  1283. $this->data->device->type = Constants\DeviceType::TABLET;
  1284. $this->data->device->identified |= Constants\Id::INFER;
  1285. if (isset($this->data->os->name) && ($this->data->os->name != 'Android' || $this->data->os->name != 'FireOS')) {
  1286. $this->data->os->name = 'FireOS';
  1287. $this->data->os->family = new Family([ 'name' => 'Android' ]);
  1288. $this->data->os->alias = null;
  1289. $this->data->os->version = null;
  1290. }
  1291. }
  1292. }
  1293. }
  1294. }
  1295. /* Nokia */
  1296. private function detectNokiaBrowser($ua)
  1297. {
  1298. if (!preg_match('/(BrowserNG|Nokia|OSRE|Ovi|Maemo)/ui', $ua)) {
  1299. return;
  1300. }
  1301. /* Nokia Browser */
  1302. if (preg_match('/BrowserNG/u', $ua)) {
  1303. $this->data->browser->name = 'Nokia Browser';
  1304. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1305. if (preg_match('/BrowserNG\/([0-9.]*)/u', $ua, $match)) {
  1306. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3, 'builds' => false ]);
  1307. }
  1308. }
  1309. if (preg_match('/NokiaBrowser/u', $ua)) {
  1310. $this->data->browser->name = 'Nokia Browser';
  1311. $this->data->browser->channel = null;
  1312. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1313. if (preg_match('/NokiaBrowser\/([0-9.]*)/u', $ua, $match)) {
  1314. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1315. }
  1316. }
  1317. if (preg_match('/Nokia-Communicator-WWW-Browser/u', $ua)) {
  1318. $this->data->browser->name = 'Nokia Browser';
  1319. $this->data->browser->channel = null;
  1320. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1321. if (preg_match('/Nokia-Communicator-WWW-Browser\/([0-9.]*)/u', $ua, $match)) {
  1322. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1323. }
  1324. }
  1325. /* Nokia Xpress for S30+, S40 and Windows Phone */
  1326. if (preg_match('/OSRE/u', $ua)) {
  1327. $this->data->browser->name = 'Nokia Xpress';
  1328. $this->data->browser->mode = 'proxy';
  1329. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1330. $this->data->device->type = Constants\DeviceType::MOBILE;
  1331. $this->data->os->name = null;
  1332. $this->data->os->version = null;
  1333. }
  1334. if (preg_match('/S40OviBrowser/u', $ua)) {
  1335. $this->data->browser->name = 'Nokia Xpress';
  1336. $this->data->browser->mode = 'proxy';
  1337. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1338. if (preg_match('/S40OviBrowser\/([0-9.]*)/u', $ua, $match)) {
  1339. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1340. }
  1341. if (preg_match('/Nokia([^\/]+)\//u', $ua, $match)) {
  1342. $this->data->device->manufacturer = 'Nokia';
  1343. $this->data->device->model = $match[1];
  1344. $this->data->device->identified |= Constants\Id::PATTERN;
  1345. if (isset($this->data->device->model)) {
  1346. $device = Data\DeviceModels::identify('s40', $this->data->device->model);
  1347. if ($device->identified) {
  1348. $device->identified |= $this->data->device->identified;
  1349. $this->data->device = $device;
  1350. }
  1351. }
  1352. if (isset($this->data->device->model)) {
  1353. $device = Data\DeviceModels::identify('asha', $this->data->device->model);
  1354. if ($device->identified) {
  1355. $device->identified |= $this->data->device->identified;
  1356. $this->data->os->name = 'Nokia Asha Platform';
  1357. $this->data->os->version = new Version([ 'value' => '1.0' ]);
  1358. $this->data->device = $device;
  1359. if (preg_match('/java_runtime_version=Nokia_Asha_([0-9_]+);/u', $ua, $match)) {
  1360. $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]) ]);
  1361. }
  1362. }
  1363. }
  1364. }
  1365. if (preg_match('/NOKIALumia([0-9]+)/u', $ua, $match)) {
  1366. $this->data->device->manufacturer = 'Nokia';
  1367. $this->data->device->model = $match[1];
  1368. $this->data->device->identified |= Constants\Id::PATTERN;
  1369. $device = Data\DeviceModels::identify('wp', $this->data->device->model);
  1370. if ($device->identified) {
  1371. $device->identified |= $this->data->device->identified;
  1372. $this->data->device = $device;
  1373. $this->data->os->name = 'Windows Phone';
  1374. }
  1375. }
  1376. }
  1377. /* MicroB - the default browser for maemo */
  1378. if (preg_match('/Maemo[ |_]Browser/u', $ua)) {
  1379. $this->data->browser->name = 'MicroB';
  1380. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1381. if (preg_match('/Maemo[ |_]Browser[ |_]([0-9.]*)/u', $ua, $match)) {
  1382. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1383. }
  1384. }
  1385. }
  1386. /* Konqueror */
  1387. private function detectKonqueror($ua)
  1388. {
  1389. if (preg_match('/[k|K]onqueror\//u', $ua)) {
  1390. $this->data->browser->name = 'Konqueror';
  1391. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1392. if (preg_match('/[k|K]onqueror\/([0-9.]*)/u', $ua, $match)) {
  1393. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1394. }
  1395. if ($this->data->device->type == '') {
  1396. $this->data->device->type = Constants\DeviceType::DESKTOP;
  1397. }
  1398. }
  1399. }
  1400. /* OmniWeb */
  1401. private function detectOmniWeb($ua)
  1402. {
  1403. if (preg_match('/OmniWeb/u', $ua)) {
  1404. $this->data->browser->name = 'OmniWeb';
  1405. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1406. $this->data->browser->version = null;
  1407. if (preg_match('/OmniWeb\/v?([0-9])[0-9][0-9]/u', $ua, $match)) {
  1408. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 1 ]);
  1409. }
  1410. if (preg_match('/OmniWeb\/([0-9]\.[0-9\.]+)/u', $ua, $match)) {
  1411. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1412. }
  1413. $this->data->device->reset([
  1414. 'type' => Constants\DeviceType::DESKTOP
  1415. ]);
  1416. if (!empty($this->data->browser->version)) {
  1417. if ($this->data->browser->version->is('<', 3)) {
  1418. $this->data->os->name = 'NextStep';
  1419. $this->data->os->version = null;
  1420. }
  1421. if ($this->data->browser->version->is('>=', 4)) {
  1422. if (empty($this->data->os->name) || $this->data->os->name != 'OS X') {
  1423. $this->data->os->name = 'OS X';
  1424. $this->data->os->version = null;
  1425. }
  1426. }
  1427. }
  1428. }
  1429. }
  1430. /* Other browsers */
  1431. private function detectDesktopBrowsers($ua)
  1432. {
  1433. if (!preg_match('/(WebPositive|WebExplorer|WorldWideweb|Midori|Maxthon|Browse)/ui', $ua)) {
  1434. return;
  1435. }
  1436. /* WebPositive */
  1437. if (preg_match('/WebPositive/u', $ua, $match)) {
  1438. $this->data->browser->name = 'WebPositive';
  1439. $this->data->browser->channel = '';
  1440. $this->data->browser->version = null;
  1441. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1442. if (preg_match('/WebPositive\/([0-9]\.[0-9.]+)/u', $ua, $match)) {
  1443. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1444. }
  1445. }
  1446. /* IBM WebExplorer */
  1447. if (preg_match('/IBM[- ]WebExplorer[ -]?(DLL ?|Window API ?)?/u', $ua)) {
  1448. $this->data->browser->name = 'IBM WebExplorer';
  1449. $this->data->browser->channel = '';
  1450. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1451. if (preg_match('/IBM[- ]WebExplorer[ -]?(?:DLL ?|Window API ?)?\/v([0-9]\.[0-9\.]+)/u', $ua, $match)) {
  1452. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1453. }
  1454. $this->data->os->name = 'OS/2';
  1455. $this->data->device->type = 'desktop';
  1456. }
  1457. /* WorldWideweb */
  1458. if (preg_match('/WorldWideweb \(NEXT\)/u', $ua, $match)) {
  1459. $this->data->browser->name = 'WorldWideWeb';
  1460. $this->data->browser->channel = '';
  1461. $this->data->browser->version = null;
  1462. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1463. $this->data->os->name = 'NextStep';
  1464. $this->data->device->type = 'desktop';
  1465. }
  1466. /* Midori */
  1467. if (preg_match('/Midori\/([0-9.]*)/u', $ua, $match)) {
  1468. $this->data->browser->name = 'Midori';
  1469. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1470. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1471. $this->data->device->manufacturer = null;
  1472. $this->data->device->model = null;
  1473. $this->data->device->type = Constants\DeviceType::DESKTOP;
  1474. if (isset($this->data->os->name) && $this->data->os->name == 'OS X') {
  1475. $this->data->os->name = null;
  1476. $this->data->os->version = null;
  1477. }
  1478. }
  1479. if (preg_match('/midori(?:\/[0-9.]*)?$/u', $ua)) {
  1480. $this->data->browser->name = 'Midori';
  1481. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1482. $this->data->device->type = Constants\DeviceType::DESKTOP;
  1483. if (preg_match('/midori\/([0-9.]*)$/u', $ua, $match)) {
  1484. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1485. }
  1486. }
  1487. /* Maxthon */
  1488. if (preg_match('/Maxthon/iu', $ua, $match)) {
  1489. $this->data->browser->name = 'Maxthon';
  1490. $this->data->browser->channel = '';
  1491. $this->data->browser->version = null;
  1492. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1493. if (preg_match('/Maxthon[\/\' ]\(?([0-9.]*)\)?/iu', $ua, $match)) {
  1494. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1495. }
  1496. if (isset($this->data->os->name) && $this->data->browser->version && $this->data->os->name == 'Windows' && $this->data->browser->version->toFloat() < 4) {
  1497. $this->data->browser->version->details = 1;
  1498. }
  1499. }
  1500. /* Browse for Remix OS */
  1501. if (preg_match('/^Browse\/([0-9.]+)/u', $ua, $match)) {
  1502. $this->data->browser->name = 'Browse';
  1503. $this->data->browser->channel = '';
  1504. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1505. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1506. }
  1507. }
  1508. private function detectMobileBrowsers($ua)
  1509. {
  1510. if (!preg_match('/(Ninesky|Skyfire|Dolphin|QQ|360|QHBrowser|Mercury|iBrowser|Puffin|MiniB|MxNitro|Sogou|Xiino|Palmscape|WebPro|Vision)/ui', $ua)) {
  1511. return;
  1512. }
  1513. /* NineSky */
  1514. if (preg_match('/Ninesky(?:-android-mobile(?:-cn)?)?\/([0-9.]*)/u', $ua, $match)) {
  1515. $this->data->browser->reset();
  1516. $this->data->browser->name = 'NineSky';
  1517. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1518. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1519. if (isset($this->data->device->manufacturer) && $this->data->device->manufacturer == 'Apple') {
  1520. $this->data->device->reset();
  1521. }
  1522. if (!$this->data->os->isFamily('Android')) {
  1523. $this->data->os->reset();
  1524. $this->data->os->name = 'Android';
  1525. }
  1526. $this->data->device->type = Constants\DeviceType::MOBILE;
  1527. }
  1528. /* Skyfire */
  1529. if (preg_match('/Skyfire\/([0-9.]*)/u', $ua, $match)) {
  1530. $this->data->browser->name = 'Skyfire';
  1531. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1532. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1533. $this->data->device->type = Constants\DeviceType::MOBILE;
  1534. $this->data->os->name = 'Android';
  1535. $this->data->os->version = null;
  1536. }
  1537. /* Dolphin HD */
  1538. if (preg_match('/Dolphin(?:HDCN)?\/(?:INT|CN)?-?([0-9.]*)/u', $ua, $match)) {
  1539. $this->data->browser->name = 'Dolphin';
  1540. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1541. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1542. $this->data->device->type = Constants\DeviceType::MOBILE;
  1543. }
  1544. /* QQ Browser */
  1545. if (preg_match('/(M?QQBrowser)\/([0-9.]*)/u', $ua, $match)) {
  1546. $this->data->browser->name = 'QQ Browser';
  1547. $version = $match[2];
  1548. if (preg_match('/^[0-9][0-9]$/u', $version)) {
  1549. $version = $version[0] . '.' . $version[1];
  1550. }
  1551. $this->data->browser->version = new Version([ 'value' => $version, 'details' => 2 ]);
  1552. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1553. $this->data->browser->channel = '';
  1554. if (!isset($this->data->os->name) && $match[1] == 'QQBrowser') {
  1555. $this->data->os->name = 'Windows';
  1556. }
  1557. if (preg_match('/MQQBrowser\/[0-9\.]+\/Adr \(Linux; U; ([0-9\.]+); [^;]+; (.+) Build/u', $ua, $match)) {
  1558. $this->data->os->reset([
  1559. 'name' => 'Android',
  1560. 'version' => new Version([ 'value' => $match[1] ])
  1561. ]);
  1562. $this->data->device->type = Constants\DeviceType::MOBILE;
  1563. $this->data->device->model = $match[2];
  1564. $this->data->device->identified |= Constants\Id::PATTERN;
  1565. $device = Data\DeviceModels::identify('android', $match[2]);
  1566. if ($device->identified) {
  1567. $device->identified |= $this->data->device->identified;
  1568. $this->data->device = $device;
  1569. }
  1570. }
  1571. if (preg_match('/MQQBrowser\/[0-9\.]+\/WP7 \([^;]+;WPOS:([0-9]\.[0-9])[0-9\.]*;([^;]+); ([^\)]+)\)/u', $ua, $match)) {
  1572. $this->data->os->reset([
  1573. 'name' => 'Windows Phone',
  1574. 'version' => new Version([ 'value' => $match[1] ])
  1575. ]);
  1576. $this->data->device->type = Constants\DeviceType::MOBILE;
  1577. $this->data->device->manufacturer = $match[2];
  1578. $this->data->device->model = $match[3];
  1579. $this->data->device->identified |= Constants\Id::PATTERN;
  1580. $device = Data\DeviceModels::identify('wp', $match[3]);
  1581. if ($device->identified) {
  1582. $device->identified |= $this->data->device->identified;
  1583. $this->data->device = $device;
  1584. }
  1585. }
  1586. }
  1587. if (preg_match('/MQQBrowser\/Mini([0-9.]*)/u', $ua, $match)) {
  1588. $this->data->browser->name = 'QQ Browser Mini';
  1589. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1590. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1591. $this->data->browser->channel = '';
  1592. }
  1593. if (preg_match('/QQ\/([0-9.]*)/u', $ua, $match)) {
  1594. $this->data->browser->name = 'QQ Browser';
  1595. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1596. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1597. $this->data->browser->channel = '';
  1598. }
  1599. /* 360 Phone Browser */
  1600. if (preg_match('/360 (?:Aphone|Android Phone) Browser \((?:Version |V)?([0-9.]*)(?:beta)?\)/u', $ua, $match)) {
  1601. $this->data->browser->name = 'Qihoo 360 Browser';
  1602. $this->data->browser->family = null;
  1603. $this->data->browser->channel = '';
  1604. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1605. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1606. if (!$this->data->os->isFamily('Android')) {
  1607. $this->data->device->type = Constants\DeviceType::MOBILE;
  1608. $this->data->os->reset([
  1609. 'name' => 'Android'
  1610. ]);
  1611. }
  1612. }
  1613. if (preg_match('/360%20(?:Browser|Lite)\/([0-9\.]+)/u', $ua, $match)) {
  1614. $this->data->browser->name = 'Qihoo 360 Browser';
  1615. $this->data->browser->family = null;
  1616. $this->data->browser->channel = '';
  1617. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1618. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1619. }
  1620. if (preg_match('/QHBrowser\/([0-9\.]+)/u', $ua, $match)) {
  1621. $version = $match[1];
  1622. if (preg_match('/^[0-9][0-9][0-9]$/u', $version)) {
  1623. $version = $version[0] . '.' . $version[1] . '.' . $version[2];
  1624. }
  1625. $this->data->browser->name = 'Qihoo 360 Browser';
  1626. $this->data->browser->channel = '';
  1627. $this->data->browser->version = new Version([ 'value' => $version ]);
  1628. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1629. if (!$this->data->isOs('iOS')) {
  1630. $this->data->device->type = Constants\DeviceType::MOBILE;
  1631. $this->data->os->reset([
  1632. 'name' => 'iOS'
  1633. ]);
  1634. }
  1635. }
  1636. /* Mercury */
  1637. if (preg_match('/(?:^| )Mercury\/([0-9\.]+)/u', $ua, $match)) {
  1638. $version = $match[1];
  1639. if (preg_match('/^[0-9][0-9][0-9]$/u', $version)) {
  1640. $version = $version[0] . '.' . $version[1] . '.' . $version[2];
  1641. }
  1642. $this->data->browser->name = 'Mercury Browser';
  1643. $this->data->browser->channel = '';
  1644. $this->data->browser->version = new Version([ 'value' => $version ]);
  1645. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1646. }
  1647. /* iBrowser */
  1648. if (preg_match('/(?:^| )iBrowser\/([0-9.]*)/u', $ua, $match)) {
  1649. $this->data->browser->name = 'iBrowser';
  1650. $version = $match[1];
  1651. if (preg_match('/^[0-9][0-9]$/u', $version)) {
  1652. $version = $version[0] . '.' . $version[1];
  1653. }
  1654. $this->data->browser->version = new Version([ 'value' => $version, 'details' => 2 ]);
  1655. $this->data->browser->channel = '';
  1656. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1657. }
  1658. if (preg_match('/iBrowser\/Mini([0-9.]*)/u', $ua, $match)) {
  1659. $this->data->browser->name = 'iBrowser Mini';
  1660. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1661. $this->data->browser->channel = '';
  1662. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1663. }
  1664. /* Puffin */
  1665. if (preg_match('/Puffin\/([0-9.]+)([IA])?([PT])?/u', $ua, $match)) {
  1666. $this->data->browser->name = 'Puffin';
  1667. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => (intval(substr(strrchr($match[1], '.'), 1)) > 99 ? -1 : null) ]);
  1668. $this->data->browser->mode = 'proxy';
  1669. $this->data->browser->channel = '';
  1670. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1671. if (isset($match[2])) {
  1672. switch ($match[2]) {
  1673. case 'A':
  1674. if (!$this->data->isOs('Android')) {
  1675. $this->data->os->reset([ 'name' => 'Android' ]);
  1676. }
  1677. break;
  1678. case 'I':
  1679. if (!$this->data->isOs('iOS')) {
  1680. $this->data->os->reset([ 'name' => 'iOS' ]);
  1681. }
  1682. break;
  1683. }
  1684. }
  1685. if (isset($match[3])) {
  1686. switch ($match[3]) {
  1687. case 'P':
  1688. $this->data->device->type = Constants\DeviceType::MOBILE;
  1689. if ($this->data->os->name == 'iOS' && empty($this->data->device->model)) {
  1690. $this->data->device->manufacturer = 'Apple';
  1691. $this->data->device->model = 'iPhone';
  1692. $this->data->device->identified = Constants\Id::MATCH_UA;
  1693. }
  1694. break;
  1695. case 'T':
  1696. $this->data->device->type = Constants\DeviceType::TABLET;
  1697. if ($this->data->os->name == 'iOS' && empty($this->data->device->model)) {
  1698. $this->data->device->manufacturer = 'Apple';
  1699. $this->data->device->model = 'iPad';
  1700. $this->data->device->identified = Constants\Id::MATCH_UA;
  1701. }
  1702. break;
  1703. }
  1704. }
  1705. }
  1706. /* MiniBrowser Mobile */
  1707. if (preg_match('/MiniBr?owserM(?:obile)?\/([0-9.]*)/u', $ua, $match)) {
  1708. $this->data->browser->name = 'MiniBrowser';
  1709. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1710. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1711. $this->data->device->type = Constants\DeviceType::MOBILE;
  1712. if (!$this->data->isOs('Series60')) {
  1713. $this->data->os->name = 'Series60';
  1714. $this->data->os->version = null;
  1715. }
  1716. }
  1717. /* Maxthon */
  1718. if (preg_match('/MxNitro/iu', $ua, $match)) {
  1719. $this->data->browser->name = 'Maxthon Nitro';
  1720. $this->data->browser->channel = '';
  1721. $this->data->browser->version = null;
  1722. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1723. if (preg_match('/MxNitro\/([0-9.]*)/iu', $ua, $match)) {
  1724. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 3 ]);
  1725. }
  1726. }
  1727. /* Sogou Mobile */
  1728. if (preg_match('/SogouAndroidBrowser\/([0-9.]*)/u', $ua, $match)) {
  1729. $this->data->browser->name = 'Sogou Mobile';
  1730. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1731. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1732. if (isset($this->data->device->manufacturer) && $this->data->device->manufacturer == 'Apple') {
  1733. unset($this->data->device->manufacturer);
  1734. unset($this->data->device->model);
  1735. unset($this->data->device->identifier);
  1736. $this->data->device->identified = Constants\Id::NONE;
  1737. }
  1738. }
  1739. /* Xiino */
  1740. if (preg_match('/Xiino\/([0-9.]+)/u', $ua, $match)) {
  1741. $this->data->browser->name = 'Xiino';
  1742. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1743. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1744. $this->data->device->type = Constants\DeviceType::PDA;
  1745. $this->data->os->name = 'Palm OS';
  1746. if (preg_match('/\(v. ([0-9.]+)/u', $ua, $match)) {
  1747. $this->data->os->version = new Version([ 'value' => $match[1] ]);
  1748. }
  1749. }
  1750. /* Palmscape */
  1751. if (preg_match('/Palmscape\/(?:PR)?([0-9.]+)/u', $ua, $match)) {
  1752. $this->data->browser->name = 'Palmscape';
  1753. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1754. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1755. $this->data->device->type = Constants\DeviceType::PDA;
  1756. $this->data->os->name = 'Palm OS';
  1757. if (preg_match('/\(v. ([0-9.]+)/u', $ua, $match)) {
  1758. $this->data->os->version = new Version([ 'value' => $match[1] ]);
  1759. }
  1760. }
  1761. /* Novarra WebPro */
  1762. if (preg_match('/WebPro/u', $ua) && preg_match('/PalmOS/u', $ua)) {
  1763. $this->data->browser->name = 'WebPro';
  1764. $this->data->browser->version = null;
  1765. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1766. if (preg_match('/WebPro\/?([0-9.]*)/u', $ua, $match)) {
  1767. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1768. }
  1769. }
  1770. /* Novarra Vision */
  1771. if (preg_match('/(?:Vision-Browser|Novarra-Vision)\/?([0-9.]*)/u', $ua, $match)) {
  1772. $this->data->browser->name = 'Novarra Vision';
  1773. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1774. $this->data->browser->family = null;
  1775. $this->data->browser->mode = 'proxy';
  1776. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1777. if ($this->data->device->type != Constants\DeviceType::MOBILE) {
  1778. $this->data->os->reset();
  1779. $this->data->device->type = Constants\DeviceType::MOBILE;
  1780. }
  1781. }
  1782. }
  1783. private function detectTelevisionBrowsers($ua)
  1784. {
  1785. if (!preg_match('/(Roku|LG Browser|NetCast|SonyBrowserCore|Dream|Planetweb)/ui', $ua)) {
  1786. return;
  1787. }
  1788. /* Web on Roku */
  1789. if (preg_match('/Roku/u', $ua) && preg_match('/Web\/([0-9.]+)/u', $ua, $match)) {
  1790. $this->data->browser->name = 'Web';
  1791. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1792. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1793. }
  1794. /* LG Browser */
  1795. if (preg_match('/LG Browser\/([0-9.]*)/u', $ua, $match)) {
  1796. $this->data->browser->name = 'LG Browser';
  1797. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1798. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1799. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1800. }
  1801. if (preg_match('/NetCast/u', $ua) && preg_match('/SmartTV\//u', $ua)) {
  1802. unset($this->data->browser->name);
  1803. unset($this->data->browser->version);
  1804. }
  1805. /* Sony Browser */
  1806. if (preg_match('/SonyBrowserCore\/([0-9.]*)/u', $ua, $match)) {
  1807. unset($this->data->browser->name);
  1808. unset($this->data->browser->version);
  1809. $this->data->device->type = Constants\DeviceType::TELEVISION;
  1810. }
  1811. /* Dreamkey */
  1812. if (preg_match('/DreamKey\/([0-9.]*)/u', $ua, $match)) {
  1813. $this->data->browser->name = 'Dreamkey';
  1814. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1815. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1816. $this->data->device->setIdentification([
  1817. 'manufacturer' => 'Sega',
  1818. 'model' => 'Dreamcast',
  1819. 'type' => Constants\DeviceType::GAMING,
  1820. 'subtype' => Constants\DeviceSubType::CONSOLE
  1821. ]);
  1822. }
  1823. /* Dream Passport */
  1824. if (preg_match('/DreamPassport\/([0-9.]*)/u', $ua, $match)) {
  1825. $this->data->browser->name = 'Dream Passport';
  1826. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1827. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1828. $this->data->device->setIdentification([
  1829. 'manufacturer' => 'Sega',
  1830. 'model' => 'Dreamcast',
  1831. 'type' => Constants\DeviceType::GAMING,
  1832. 'subtype' => Constants\DeviceSubType::CONSOLE
  1833. ]);
  1834. }
  1835. /* Planetweb */
  1836. if (preg_match('/Planetweb\/v?([0-9.]*)/u', $ua, $match)) {
  1837. $this->data->browser->name = 'Planetweb';
  1838. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1839. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1840. if (preg_match('/Dreamcast/u', $ua, $match)) {
  1841. $this->data->device->setIdentification([
  1842. 'manufacturer' => 'Sega',
  1843. 'model' => 'Dreamcast',
  1844. 'type' => Constants\DeviceType::GAMING,
  1845. 'subtype' => Constants\DeviceSubType::CONSOLE
  1846. ]);
  1847. }
  1848. if (preg_match('/SPS/u', $ua, $match)) {
  1849. $this->data->device->setIdentification([
  1850. 'manufacturer' => 'Sony',
  1851. 'model' => 'Playstation 2',
  1852. 'type' => Constants\DeviceType::GAMING,
  1853. 'subtype' => Constants\DeviceSubType::CONSOLE
  1854. ]);
  1855. }
  1856. }
  1857. }
  1858. private function detectRemainingBrowsers($ua)
  1859. {
  1860. if ($data = Data\Applications::identifyBrowser($ua)) {
  1861. $this->data->browser->set($data['browser']);
  1862. if (!empty($data['device'])) {
  1863. $this->data->device->set($data['device']);
  1864. }
  1865. }
  1866. }
  1867. private function detectWapBrowsers($ua)
  1868. {
  1869. if (!preg_match('/(Dorado|MAUI)/ui', $ua, $match)) {
  1870. return;
  1871. }
  1872. if (preg_match('/Browser\/Dorado([0-9.]*)/ui', $ua, $match)) {
  1873. $this->data->browser->name = 'Dorado WAP';
  1874. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1875. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1876. }
  1877. if (preg_match('/Dorado WAP-Browser\/([0-9.]*)/ui', $ua, $match)) {
  1878. $this->data->browser->name = 'Dorado WAP';
  1879. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1880. $this->data->browser->version = new Version([ 'value' => $match[1], 'details' => 2 ]);
  1881. }
  1882. if (preg_match('/MAUI[ _]WAP[ _]Browser(?:\/([0-9.]*))?/ui', $ua, $match)) {
  1883. $this->data->browser->name = 'MAUI WAP';
  1884. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1885. if (isset($match[1])) {
  1886. $this->data->browser->version = new Version([ 'value' => $match[1] ]);
  1887. }
  1888. }
  1889. if (preg_match('/WAP Browser\/MAUI/ui', $ua, $match)) {
  1890. $this->data->browser->name = 'MAUI WAP';
  1891. $this->data->browser->type = Constants\BrowserType::BROWSER;
  1892. }
  1893. }
  1894. }