PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.2
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Libraries / Browser / BrowserDetection.php

BrowserDetection.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.2, at back/Libraries/Browser/BrowserDetection.php

1,893 lines 87.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Libraries\Browser;
4
5 /**
6 * Simplified and updated version by Acyba on January 2025, for use in AcyMailing
7 *
8 * The MIT License (MIT)
9 *
10 * Copyright (c) 2020-2024 Artem Murugov <[email protected]>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy of
13 * this software and associated documentation files (the "Software"), to deal in
14 * the Software without restriction, including without limitation the rights to
15 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16 * the Software, and to permit persons to whom the Software is furnished to do so,
17 * subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in all
20 * copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * @version 2.8
30 * @last-modified September 3, 2024
31 * @link https://github.com/foroco/php-browser-detection
32 */
33 class BrowserDetection
34 {
35 const LEGACY_PLATFORMS_DESKTOP = [
36 'windows',
37 'macintosh',
38 'linux',
39 ];
40
41 const PLATFORMS_DESKTOP = [
42 'Windows',
43 'MacOS',
44 'Ubuntu',
45 'Kubuntu',
46 'Linux Mint',
47 'Linux',
48 'Chrome OS',
49 'Arch Linux',
50 'Elementary',
51 'RISC OS',
52 'AmigaOS',
53 'Haiku',
54 'BeOS',
55 'Firefox OS',
56 'RemixOS',
57 ];
58
59 const LEGACY_PLATFORMS_MOBILE = [
60 'bada',
61 'ubuntu; mobile',
62 'ubuntu; tablet',
63 'tizen',
64 'palm os',
65 'meego',
66 'symbian',
67 'symbos',
68 'blackberry',
69 'windows ce',
70 'windows mobile',
71 'windows phone',
72 'iphone',
73 'ipad',
74 'ipod',
75 'android',
76 ];
77
78 const PLATFORMS_MOBILE = [
79 'Android',
80 'iOS',
81 'Windows Phone',
82 'Windows Mobile',
83 'Windows CE',
84 'BlackBerry',
85 'Tizen',
86 'Bada',
87 'Fire OS',
88 'Symbian',
89 'KaiOS',
90 'Sailfish OS',
91 'LiveArea',
92 'PalmOS',
93 'Maemo',
94 'WebOS',
95 ];
96
97 const LEGACY_OPENED_WITH_MAP = [
98 'Windows 10 mail' => 'Outlook',
99 'Microsoft Edge' => 'Edge',
100 'Pocket Internet Explorer' => 'Internet Explorer Mobile',
101 'Mozilla' => '',
102 'iPhone' => 'Safari',
103 'iPod' => 'Safari',
104 'iPad' => 'Safari',
105 'Google Chrome' => 'Chrome',
106 'Android' => 'Chrome',
107 'UCBrowser' => 'UC Browser',
108 'YandexBot' => 'Yandex App',
109 'YandexImageResizer' => 'Yandex App',
110 'YandexImages' => 'Yandex App',
111 'YandexVideo' => 'Yandex App',
112 'YandexMedia' => 'Yandex App',
113 'YandexBlogs' => 'Yandex App',
114 'YandexFavicons' => 'Yandex App',
115 'YandexWebmaster' => 'Yandex App',
116 'YandexDirect' => 'Yandex App',
117 'YandexMetrika' => 'Yandex App',
118 'YandexNews' => 'Yandex App',
119 'YandexCatalog' => 'Yandex App',
120 'Yandex' => 'Yandex Browser',
121 'BlackBerry' => '',
122 'Bing Bot' => 'Bing App',
123 'Phoenix' => 'Phoenix Browser',
124 'PlayStation' => 'Playstation Browser',
125 'SamsungBrowser' => 'Samsung Browser',
126 ];
127
128 public $useragent;
129 private $get_mode;
130 private $touch_support_mode;
131 private $real_os_name;
132 private $macos_version_minor;
133 private $result_ios;
134 private $result_mobile;
135 private $result_os_type;
136 private $result_os_family;
137 private $result_os_name;
138 private $result_os_version;
139 private $result_os_title;
140 private $result_device_type;
141 private $result_browser_name;
142 private $result_browser_version;
143 private $result_browser_title;
144 private $result_browser_chromium_version;
145 private $result_browser_gecko_version;
146 private $result_browser_webkit_version;
147 private $result_browser_chrome_original;
148 private $result_browser_firefox_original;
149 private $result_browser_safari_original;
150 private $result_browser_android_webview;
151 private $result_browser_ios_webview;
152 private $result_browser_desktop_mode;
153 private $result_64bits_mode;
154
155 /**
156 * Reset all common defined properties method
157 *
158 * @return null
159 */
160
161 private function resetProperties()
162 {
163 $this->real_os_name = '';
164 $this->result_ios = false;
165 $this->result_mobile = 0;
166 $this->macos_version_minor = 0;
167 $this->result_os_type = 'unknown';
168 $this->result_os_family = 'unknown';
169 $this->result_os_name = 'unknown';
170 $this->result_os_version = 0;
171 $this->result_os_title = 'unknown';
172 $this->result_device_type = 'unknown';
173 $this->result_browser_name = 'unknown';
174 $this->result_browser_version = 0;
175 $this->result_browser_title = 'unknown';
176 $this->result_browser_chromium_version = 0;
177 $this->result_browser_gecko_version = 0;
178 $this->result_browser_webkit_version = 0;
179 $this->result_browser_chrome_original = 0;
180 $this->result_browser_firefox_original = 0;
181 $this->result_browser_safari_original = 0;
182 $this->result_browser_android_webview = 0;
183 $this->result_browser_ios_webview = 0;
184 $this->result_browser_desktop_mode = 0;
185 $this->result_64bits_mode = 0;
186
187 return null;
188 }
189
190 /**
191 * Common User-Agent matching
192 *
193 * @param string $data The string to data search for
194 * @param boolean $case_s Determines if we do a case-sensitive search (false) or a case insensitive (true)
195 *
196 * @return boolean Returns true if $data found in $useragent property, false otherwise.
197 */
198
199 private function match_ua($data, $case_s = false)
200 {
201 if (empty($data)) return false;
202
203 if (substr($data, 0, 1) === '/' && substr($data, -1) === '/') {
204 if ($case_s == true) $data = $data.'i';
205 if (preg_match($data, $this->useragent, $matches)) {
206 if (!isset($matches[0])) $matches[0] = 0;
207 if (!isset($matches[1])) $matches[1] = 0;
208 if (!isset($matches[2])) $matches[2] = 0;
209
210 return $matches;
211 } else {
212 return false;
213 }
214 } else {
215 $data_a = explode('|', $data);
216 foreach ($data_a as $v) {
217 if ($case_s == false) {
218 if (strpos($this->useragent, $v) !== false) return true;
219 } else {
220 if (stripos($this->useragent, $v) !== false) return true;
221 }
222 }
223 }
224
225 return false;
226 }
227
228 /**
229 * Method to call User-Agent matching method if matching data is case insensitive
230 *
231 * @param string $data The string to data search for
232 *
233 * @return boolean Returns true if case insensitive $data found in $useragent property, false otherwise.
234 */
235
236 private function matchi_ua($data)
237 {
238 return $this->match_ua($data, true);
239 }
240
241 /**
242 * Detect iOS
243 * The method will try to recognize iOS signs from $useragent property and will placed true in result_ios property if iOS found, false otherwise. Also returns true if iOS
244 * found, false otherwise
245 *
246 * @return bool
247 */
248
249 private function match_ios()
250 {
251 if ($this->match_ua('iPhone|iphone|iPad;|iPod') && !$this->match_ua('x86_64|i386')) {
252 $this->result_ios = true;
253
254 return true;
255 }
256
257 return false;
258 }
259
260 /**
261 * Detect mobile OS
262 * The method will try to recognize mobile OS signs from $useragent property and will placed true in result_mobile property if mobile OS found, false otherwise.
263 *
264 * @return null
265 */
266
267 private function match_mobile()
268 {
269 // Match 64 bits Windows Desktop OS
270
271 if ($this->match_ua('WOW64|Win64')) {
272 $this->result_64bits_mode = 1;
273
274 return null;
275 }
276
277 // Match Windows Desktop OS
278
279 if ($this->match_ua('Windows NT')) return null;
280
281 // Match Qt embedded system
282
283 if ($this->match_ua('QtEmbedded;')) return null;
284
285 // Match Android OS
286
287 if ($this->match_ua('Android')) {
288 $this->result_mobile = 1;
289
290 return null;
291 }
292
293 // Match iOS
294
295 if ($this->match_ios()) {
296 $this->result_mobile = 1;
297
298 return null;
299 }
300
301 // Match iOS browsers in Desktop Mode
302
303 if ($this->match_ua('Mac OS X')) {
304 if ($this->match_ua('/Mac\sOS\sX.*iOS/')) $this->result_mobile = 1;
305
306 return null;
307 }
308
309 // Match Android browsers in Desktop Mode
310
311 if ($this->match_ua('/X11\;(?:[U\;\s]+)?\sLinux/') && $this->match_ua('Version/4.0 Chrome/|SamsungBrowser|Miui|XiaoMi|EdgA|Puffin|UCBrowser|JioPages|Ecosia android')) {
312 $this->result_mobile = 1;
313
314 return null;
315 }
316
317 // Match other mobile signs
318
319 if ($this->matchi_ua('mobile|tablet') || $this->match_ua(
320 'BlackBerry|BB10;|MIDP|PlayBook|Windows Phone|Windows Mobile|Windows CE|IEMobile|Opera Mini|OPiOS|Opera Mobi|CrKey armv|Kindle|Silk/|Bada|Tizen|Lumia|Symbian|SymbOS|(Series|PalmOS|PalmSource|Dolfin|Crosswalk|Obigo|MQQBrowser|CriOS|WhatsApp/'
321 ) || $this->matchi_ua('nokia|playstation|watch')) {
322 $this->result_mobile = 1;
323 }
324
325 return null;
326 }
327
328 /**
329 * Convert MacOS numeric version to MacOS codename
330 *
331 * @param int $version The given MacOS version
332 *
333 * @return string Returns MacOS codename string
334 */
335
336 private function macos_codename($version)
337 {
338 switch ($version) {
339 case 0:
340 $result_codename = 'Cheetah';
341 break;
342 case 1:
343 $result_codename = 'Puma';
344 break;
345 case 2:
346 $result_codename = 'Jaguar';
347 break;
348 case 3:
349 $result_codename = 'Panther';
350 break;
351 case 4:
352 $result_codename = 'Tiger';
353 break;
354 case 5:
355 $result_codename = 'Leopard';
356 break;
357 case 6:
358 $result_codename = 'Snow Leopard';
359 break;
360 case 7:
361 $result_codename = 'Lion';
362 break;
363 case 8:
364 $result_codename = 'Mountain Lion';
365 break;
366 case 9:
367 $result_codename = 'Mavericks';
368 break;
369 case 10:
370 $result_codename = 'Yosemite';
371 break;
372 case 11:
373 $result_codename = 'El Capitan';
374 break;
375 case 12:
376 $result_codename = 'Sierra';
377 break;
378 case 13:
379 $result_codename = 'High Sierra';
380 break;
381 case 14:
382 $result_codename = 'Mojave';
383 break;
384 case 15:
385 $result_codename = 'Catalina';
386 break;
387 case 16:
388 $result_codename = 'Big Sur';
389 break;
390 case 17:
391 $result_codename = 'Monterey';
392 break;
393 case 18:
394 $result_codename = 'Ventura';
395 break;
396 default:
397 $result_codename = 'New';
398 break;
399 }
400
401 return $result_codename;
402 }
403
404 /**
405 * Common User-Agent parsing
406 * The method will try to recognize environment data from $useragent property and will placed it in defined properties.
407 *
408 * @return null
409 */
410
411 private function getResult()
412 {
413 if ($this->useragent === 'Mozilla/5.0') {
414 $this->result_os_name = 'unknown';
415 $this->result_browser_name = 'Apple Mail';
416
417 return;
418 }
419
420 if (strpos($this->useragent, 'GoogleImageProxy') !== false) {
421 $this->result_os_name = 'unknown';
422 $this->result_browser_name = 'Gmail';
423
424 return;
425 }
426
427 if (strpos($this->useragent, 'OneOutlook') !== false) {
428 $this->result_os_name = 'Windows';
429 $this->result_browser_name = 'Outlook';
430
431 return;
432 }
433
434 // Detect mobile device
435
436 $this->match_mobile();
437
438 // Detect mobile browser Desktop Mode
439
440 if ($this->touch_support_mode == true) {
441 // Android Desktop Mode
442
443 if ($this->match_ua('X11; Linux x86_64|X11; Linux aarch64|X11; U; U; Linux x86_64|X11; Linux; U;|X11; Linux zbov') && !$this->match_ua(
444 'kded/|kioclient|queror|Goanna|Epiphany|Brick|Iceweasel|SeaMonkey|Thunderbird|Qt|Arora|Ubuntu|Debian|Fedora|Linux Mint|elementary|Raspbian|Slackware|ArchLinux|Gentoo'
445 )) {
446 $this->real_os_name = 'Android';
447 $this->result_mobile = 1;
448 $this->result_browser_desktop_mode = 1;
449 }
450
451 // iOS Desktop Mode
452
453 if ($this->match_ua('Intel Mac OS X')) {
454 $this->real_os_name = 'iOS';
455 $this->result_mobile = 1;
456 $this->result_browser_desktop_mode = 1;
457 }
458 }
459
460 // Windows Phone Desktop Mode
461
462 if ($this->match_ua('WPDesktop;')) {
463 $this->real_os_name = 'Windows Phone';
464 $this->result_mobile = 1;
465 $this->result_browser_desktop_mode = 1;
466 }
467
468 // Android Desktop Mode without touch support check
469
470 if ($this->result_mobile == 1 && $this->result_os_type === 'unknown') {
471 if ($this->match_ua('/X11\;(?:[U\;\s]+)?\sLinux/') && $this->match_ua('Version/4.0 Chrome/|SamsungBrowser|Miui|XiaoMi|EdgA|Puffin|UCBrowser|JioPages|Ecosia android')) {
472 $this->real_os_name = 'Android';
473 $this->result_browser_desktop_mode = 1;
474 }
475 }
476
477 // iOS Desktop Mode without touch support check
478
479 if ($this->result_mobile == 1 && $this->result_ios == false && $this->result_os_type === 'unknown') {
480 if ($this->match_ua('/Mac\sOS\sX.*iOS/')) {
481 $this->real_os_name = 'iOS';
482 $this->result_browser_desktop_mode = 1;
483 }
484 }
485
486 /*
487 --------------
488 OS DETECTION
489 --------------
490
491 --------------
492 Mixed OS(es)
493 --------------
494 */
495
496 $os_need_continue = true;
497
498 // Windows OS
499
500 if ($this->get_mode !== 'browser' && $this->match_ua('Windows|Win32') && !$this->match_ua('Windows Phone|Windows Mobile|Windows CE|WPDesktop')) {
501 $this->result_os_name = 'Windows';
502 $matches = $this->match_ua('/Windows ([ .a-zA-Z0-9]+)[;\\)]/');
503 $version = is_array($matches) ? $matches[1] : 0;
504 if ($version === 'NT 11.0') $this->result_os_version = '11';
505 if ($version === 'NT 10.1') $this->result_os_version = '11';
506 if ($version === 'NT 10.0') $this->result_os_version = '10';
507 if ($version === 'NT 6.4') $this->result_os_version = '10';
508 if ($version === 'NT 6.3') $this->result_os_version = '8.1';
509 if ($version === 'NT 6.2') $this->result_os_version = '8';
510 if ($version === 'NT 6.1') $this->result_os_version = '7';
511 if ($version === 'NT 6.0') $this->result_os_version = 'Vista';
512 if ($version === 'NT 6') $this->result_os_version = 'NT';
513 if ($version === 'NT 5.2') $this->result_os_version = 'XP';
514 if ($version === 'NT 5.1') $this->result_os_version = 'XP';
515 if ($version === 'NT 5.01') $this->result_os_version = '2000';
516 if ($version === 'NT 5.0') $this->result_os_version = '2000';
517 if ($version === 'NT 5') $this->result_os_version = '2000';
518 if ($version === 'NT 4.0') $this->result_os_version = 'NT 4.0';
519 if ($version === 'NT4.0') $this->result_os_version = 'NT 4.0';
520 if ($version === 'NT') $this->result_os_version = 'NT';
521 if ($version === '98') $this->result_os_version = '98';
522 if ($version === '95') $this->result_os_version = '95';
523 if ($version === 'ME') $this->result_os_version = 'ME';
524 if (empty($this->result_os_version)) {
525 if ($this->match_ua('/Win16/')) $this->result_os_version = '3.1';
526 if ($this->match_ua('/(Windows\s95|Win95|Windows_95)/')) $this->result_os_version = '95';
527 if ($this->match_ua('/(Windows\s98|Win98)/')) $this->result_os_version = '98';
528 if ($this->match_ua('/Windows\s2000/')) $this->result_os_version = '2000';
529 if ($this->match_ua('/Win\sNT\s5\.0/')) $this->result_os_version = '2000';
530 if ($this->match_ua('/Windows\sXP/')) $this->result_os_version = 'XP';
531 if ($this->match_ua('/WinNT4\.0/')) $this->result_os_version = 'NT 4.0';
532 if ($this->match_ua('/Windows\sVista/')) $this->result_os_version = 'Vista';
533 if ($this->match_ua('/Windows\s7/')) $this->result_os_version = '7';
534 if ($this->match_ua('/Windows\s8/')) $this->result_os_version = '8';
535 if ($this->match_ua('/Windows\s8.1/')) $this->result_os_version = '8.1';
536 if ($this->match_ua('/Windows\s10/')) $this->result_os_version = '10';
537 if ($this->match_ua('/Windows\s11/')) $this->result_os_version = '11';
538 }
539 if (!empty($this->result_os_version)) {
540 $this->result_os_title = 'Windows '.$this->result_os_version;
541 } else $this->result_os_title = 'Windows (unknown version)';
542 if (intval($this->result_os_version) < 7 || intval($this->result_os_version) > 10) {
543 $this->result_os_type = 'desktop';
544 } else $this->result_os_type = 'mixed';
545 $this->result_os_family = 'windows';
546 $os_need_continue = false;
547 }
548
549 /*
550 -------------
551 Desktop OS
552 -------------
553 */
554
555 if ($this->get_mode !== 'browser' && $this->result_mobile == 0) {
556 $this->result_os_type = 'desktop';
557
558 // Mac OS (X) / macOS
559
560 if ($os_need_continue && $this->match_ua('Mac OS X|Mac_PowerPC|Macintosh|Mac_68K') && !$this->match_ua('AmigaOS')) {
561 $this->result_os_version = 0;
562 $this->result_os_name = 'MacOS';
563 if ($this->match_ua('Mac OS X')) {
564 $matches = $this->match_ua('/Mac OS X (\d+)[_.](\d+)(?:[_.](\d+)|)/');
565
566 $version = isset($matches[1]) ? $matches[1] : 0;
567 $version_minor = isset($matches[2]) ? $matches[2] : 0;
568 $version_revision = isset($matches[3]) ? $matches[3] : -1;
569
570 // macOS version to minor version conversion (needs since Big Sur)
571 if ($version == 10 && $version_minor == 0) $version_minor = 16;
572 if ($version == 11) $version_minor = 16;
573 if ($version == 12) $version_minor = 17;
574
575 // macOS with a particular major/minor/revision version structure (needs since Big Sur)
576 if ($version == 10 && $version_minor == 15 && $version_revision == 7) $version_minor = 16;
577 if ($version == 10 && $version_minor == 16 && $version_revision == 0) $version_minor = 17;
578
579 if (!empty($version_minor)) {
580 if ($version >= 10) $this->result_os_version = $this->macos_codename($version_minor);
581 $this->macos_version_minor = $version_minor;
582 }
583
584 if (!empty($this->result_os_version)) {
585 $this->result_os_title = 'MacOS '.$this->result_os_version;
586 } else $this->result_os_title = 'MacOS (unknown version)';
587 } else {
588 $this->result_os_title = 'MacOS';
589 }
590 $this->result_os_family = 'macintosh';
591 $os_need_continue = false;
592 }
593
594 // Linux family OS(es)
595
596 if ($os_need_continue) {
597 $os_list[] = ['Ubuntu' => '/Ubuntu(?: )?(?:\/)?([0-9]+\.[0-9]+)/'];
598 $os_list[] = ['Kubuntu' => '/Kubuntu(?: )?(?:\/)?([0-9]+\.[0-9]+)/'];
599 $os_list[] = ['Linux Mint' => '/Linux Mint\/([.0-9]+)/'];
600 $os_list[] = ['CentOS' => '/CentOS\/([0-9]+\.[0-9]+)/'];
601 $os_list[] = ['OpenSUSE' => '/SUSE\/([0-9]+\.[0-9]+)/'];
602 $os_list[] = ['Red Hat' => '/Red\sHat\/([0-9]+\.[0-9]+)/'];
603
604 foreach ($os_list as $os_list_va) {
605 $k = key($os_list_va);
606 $v = $os_list_va[$k];
607
608 $matches = $this->match_ua($v);
609 if ($matches) {
610 $this->result_os_family = 'linux';
611 $this->result_os_name = $k;
612 $this->result_os_version = is_array($matches) ? (float)$matches[1] : 0;
613 $os_need_continue = false;
614 break;
615 }
616 }
617 $os_list = null;
618 }
619
620 // Other Desktop OS(es)
621
622 if ($os_need_continue) {
623 $other_os = [];
624
625 $other_os[] = ['Chrome OS' => 'CrOS'];
626 $other_os[] = ['Chrome OS' => 'Chromium OS'];
627 $other_os[] = ['Linux Mint' => 'Linux Mint'];
628 $other_os[] = ['Kubuntu' => 'Kubuntu'];
629 $other_os[] = ['Ubuntu' => 'Ubuntu'];
630 $other_os[] = ['Ubuntu' => 'ubuntu'];
631 $other_os[] = ['Debian' => 'Debian'];
632 $other_os[] = ['CentOS' => 'CentOS'];
633 $other_os[] = ['Fedora' => 'Fedora'];
634 $other_os[] = ['Arch Linux' => 'ArchLinux'];
635 $other_os[] = ['OpenSUSE' => 'SUSE'];
636 $other_os[] = ['Red Hat' => 'Red Hat'];
637 $other_os[] = ['Elementary' => ' elementary'];
638 $other_os[] = ['OpenBSD' => 'OpenBSD'];
639 $other_os[] = ['NetBSD' => 'NetBSD'];
640 $other_os[] = ['FreeBSD' => 'FreeBSD'];
641 $other_os[] = ['SunOS' => 'SunOS'];
642 $other_os[] = ['RISC OS' => 'RISC OS'];
643 $other_os[] = ['Linux' => 'Linux'];
644 $other_os[] = ['Linux' => 'X11;'];
645 $other_os[] = ['Linux' => 'Mozilla/5.0 (x86_64)'];
646 $other_os[] = ['Linux' => 'Mozilla/5.0 (i686)'];
647 $other_os[] = ['Linux' => 'U; NETFLIX'];
648 $other_os[] = ['Linux' => 'GNU; '];
649 $other_os[] = ['Linux' => 'QtEmbedded; U; Linux;'];
650 $other_os[] = ['AmigaOS' => 'AmigaOS'];
651 $other_os[] = ['Haiku' => 'Haiku'];
652 $other_os[] = ['Roku OS' => 'Roku/'];
653 $other_os[] = ['BeOS' => 'BeOS'];
654
655 foreach ($other_os as $other_os_va) {
656 $k = key($other_os_va);
657 $v = $other_os_va[$k];
658
659 if ($this->match_ua($v)) {
660 $this->result_os_family = 'linux';
661 if ($k === 'AmigaOS') $this->result_os_family = 'amiga';
662 if ($k === 'Haiku' || $k === 'BeOS') $this->result_os_family = 'beos';
663 if ($k === 'OpenBSD' || $k === 'NetBSD' || $k === 'FreeBSD' || $k === 'SunOS' || $k === 'RISC OS') $this->result_os_family = 'unix';
664 $this->result_os_version = 0;
665 $this->result_os_name = $k;
666 $this->result_os_title = $k;
667 $os_need_continue = false;
668 break;
669 }
670 }
671 $other_os = null;
672 }
673 // End of desktop OS detection
674 }
675
676 /*
677 -------------
678 Mobile OS
679 -------------
680 */
681
682 if ($this->result_mobile == 1) {
683 if ($this->result_os_type === 'unknown') $this->result_os_type = 'mobile';
684
685 // Desktop Mode on generic mobile OS
686
687 // Android Desktop Mode
688
689 if ($os_need_continue && $this->result_browser_desktop_mode == 1 && $this->real_os_name === 'Android') {
690 $this->result_os_version = 0;
691 $this->result_os_name = 'Android';
692 $this->result_os_family = 'android';
693 $os_need_continue = false;
694 }
695
696 // iOS Desktop Mode
697
698 if ($os_need_continue && $this->result_browser_desktop_mode == 1 && $this->real_os_name === 'iOS') {
699 $this->result_os_version = 0;
700 $this->result_os_name = 'iOS';
701 $this->result_os_family = 'macintosh';
702 $os_need_continue = false;
703 }
704
705 // WP Desktop Mode
706
707 if ($os_need_continue && $this->result_browser_desktop_mode == 1 && $this->real_os_name === 'Windows Phone') {
708 $this->result_os_version = 0;
709 $this->result_os_name = 'Windows Phone';
710 $this->result_os_family = 'windows';
711 $os_need_continue = false;
712 }
713
714 // Android OS
715
716 if ($os_need_continue && $this->match_ua('Android') && !$this->match_ua('Windows Phone|Windows Mobile|Tizen')) {
717 $this->result_os_version = 0;
718 $this->result_os_name = 'Android';
719 $matches = $this->match_ua('/Android(?: |\-)([0-9]+\.[0-9]+)/');
720 $this->result_os_version = is_array($matches) ? (float)$matches[1] : 0;
721 if (empty($this->result_os_version)) {
722 $matches = $this->match_ua('/Android(?: |\-)(\d+)/');
723 $this->result_os_version = is_array($matches) ? (float)$matches[1] : 0;
724 }
725 $this->result_os_family = 'android';
726 $os_need_continue = false;
727 }
728
729 // iOS OS
730
731 if ($os_need_continue && $this->result_ios != false && !$this->match_ua('Windows Phone|Windows Mobile')) {
732 $this->result_os_version = 0;
733 $this->result_os_name = 'iOS';
734 $matches = $this->match_ua('/\sOS\s(\d+)[_.](\d+)/');
735 $version = is_array($matches) ? $matches[1] : 0;
736 $version_minor = is_array($matches) ? $matches[2] : 0;
737 if (!empty($version)) $this->result_os_version = floatval($version.'.'.$version_minor);
738 $this->result_os_family = 'macintosh';
739 $os_need_continue = false;
740 }
741
742 // WhatsApp Android / iOS
743
744 if ($os_need_continue && $this->match_ua('WhatsApp/')) {
745 $matches = $this->match_ua('/WhatsApp\/([.0-9]+)\s(A|i)$/');
746 $os_match = is_array($matches) ? $matches[2] : 0;
747
748 if ($os_match === 'A') {
749 $this->result_os_name = 'Android';
750 $this->result_os_family = 'android';
751 }
752
753 if ($os_match === 'i') {
754 $this->result_os_name = 'iOS';
755 $this->result_os_family = 'macintosh';
756 }
757 }
758
759 // Windows Phone OS, Tizen OS, Bada OS, Kindle OS, FIre OS, Java Platform
760
761 if ($os_need_continue) {
762 $os_list[] = ['Windows Phone' => '/Phone(?: OS)? ([.0-9]+)/'];
763 $os_list[] = ['Windows Mobile' => '/Windows Mobile ([.0-9]+)/'];
764 $os_list[] = ['Windows Mobile' => 'Windows Mobile'];
765 $os_list[] = ['Windows CE' => 'Windows CE'];
766 $os_list[] = ['Firefox OS' => '/Mozilla\/5\.0\s\((?:Mobile|Tablet);(?:.*;)?\srv:[.0-9]+\)\sGecko\/[.0-9]+\sFirefox\/[.0-9]+$/'];
767 $os_list[] = ['Tizen' => '/Tizen[\/\s]([.0-9]+)/'];
768 $os_list[] = ['Bada' => '/Bada[;\/]([.0-9]+)/'];
769 $os_list[] = ['Kindle' => '/Kindle\/([0-9]+\.[0-9]+)/'];
770 $os_list[] = ['Fire OS' => 'KFJW|Silk/'];
771 $os_list[] = ['Java Platform' => '/MIDP\-([0-9]+\.[0-9]+)/'];
772 $os_list[] = ['Java Platform' => '/MIDP/'];
773 $os_list[] = ['MAUI Platform' => '/MAUI\s|\sMAUI/'];
774
775 foreach ($os_list as $os_list_va) {
776 $k = key($os_list_va);
777 $v = $os_list_va[$k];
778
779 $matches = $this->match_ua($v);
780 if ($matches) {
781 $this->result_os_family = 'linux';
782 if (strpos($k, 'Windows') !== false) $this->result_os_family = 'windows';
783 $this->result_os_name = $k;
784 $this->result_os_version = is_array($matches) ? (float)$matches[1] : 0;
785 $os_need_continue = false;
786
787 // J2ME/MIDP or MAUI
788
789 if (strpos($k, 'Java Platform') !== false || strpos($k, 'MAUI Platform') !== false) {
790 $this->result_os_family = 'unknown';
791 $os_need_continue = true;
792 }
793 break;
794 }
795 }
796 $os_list = null;
797 }
798
799 // Other Mobile OS(es)
800
801 if ($os_need_continue) {
802 $other_os = [];
803
804 $other_os[] = ['Android' => 'CrKey armv'];
805 $other_os[] = ['Android' => 'SpreadTrum;'];
806 $other_os[] = ['BlackBerry' => 'BlackBerry'];
807 $other_os[] = ['BlackBerry' => 'BB10;'];
808 $other_os[] = ['BlackBerry' => 'RIM Tablet'];
809 $other_os[] = ['Symbian' => 'Symbian'];
810 $other_os[] = ['Symbian' => '(Series'];
811 $other_os[] = ['Symbian' => 'SymbOS'];
812 $other_os[] = ['WatchOS' => 'Watch'];
813 $other_os[] = ['KaiOS' => 'KAIOS'];
814 $other_os[] = ['RemixOS' => 'Remix Mini'];
815 $other_os[] = ['RemixOS' => 'RemixOS'];
816 $other_os[] = ['Sailfish OS' => 'Sailfish'];
817 $other_os[] = ['LiveArea' => 'PlayStation Vita'];
818 $other_os[] = ['PalmOS' => 'PalmOS'];
819 $other_os[] = ['PalmOS' => 'PalmSource'];
820 $other_os[] = ['Maemo' => 'Maemo'];
821 $other_os[] = ['PlayStation Platform' => 'PlayStation'];
822 $other_os[] = ['PlayStation Platform' => 'PLAYSTATION'];
823
824 foreach ($other_os as $other_os_va) {
825 $k = key($other_os_va);
826 $v = $other_os_va[$k];
827
828 if ($this->match_ua($v)) {
829 if ($k === 'Android') $this->result_os_family = 'android';
830 if ($k === 'BlackBerry') $this->result_os_family = 'blackberry';
831 if ($k === 'Symbian') $this->result_os_family = 'symbian';
832 if ($k === 'WatchOS') $this->result_os_family = 'macintosh';
833 if ($k === 'Sailfish OS' || $k === 'KaiOS' || $k === 'Maemo') $this->result_os_family = 'linux';
834 if ($k === 'RemixOS') $this->result_os_family = 'android';
835 if ($k === 'LiveArea') $this->result_os_family = 'livearea';
836 if ($k === 'PalmOS') $this->result_os_family = 'palm';
837 if ($k === 'PlayStation Platform') $this->result_os_family = 'unix';
838 $this->result_os_version = 0;
839 $this->result_os_name = $k;
840 $this->result_os_title = $k;
841 $os_need_continue = false;
842 break;
843 }
844 }
845
846 $other_os = null;
847 }
848 // End of mobile OS detection
849 }
850
851 // Other mixed-type linux-family OS(es)
852
853 if ($this->get_mode !== 'browser' && ($this->result_os_family === 'linux' || $this->result_os_family === 'unknown')) {
854 $other_os = [];
855
856 $other_os[] = ['WebOS' => 'hpwOS'];
857 $other_os[] = ['WebOS' => 'Web0S'];
858 $other_os[] = ['WebOS' => 'WebOS'];
859 $other_os[] = ['WebOS' => 'webOS'];
860
861 foreach ($other_os as $other_os_va) {
862 $k = key($other_os_va);
863 $v = $other_os_va[$k];
864
865 if ($this->match_ua($v)) {
866 $this->result_os_family = 'linux';
867 $this->result_os_type = 'mixed';
868 $this->result_os_version = 0;
869 $this->result_os_name = $k;
870 $this->result_os_title = $k;
871 break;
872 }
873 }
874 $other_os = null;
875 }
876
877 // Darwin (MacOS and iOS)
878
879 if ($os_need_continue && $this->match_ua(' Darwin') && !$this->match_ua('X11;')) {
880 $this->result_os_family = 'macintosh';
881
882 if ($this->match_ua('x86_64|i386|Mac')) {
883 $this->result_os_type = 'desktop';
884 $this->result_os_name = 'MacOS';
885 } else {
886 $this->result_os_type = 'mobile';
887 $this->result_mobile = 1;
888 $this->result_os_name = 'iOS';
889 $this->result_ios = true;
890 }
891
892 $this->result_os_version = 0;
893 $darwin_os_version = 0;
894
895 $matches = $this->match_ua('/\sDarwin(\s|\/)([0-9]+\.[0-9]+)/');
896 if (!empty($matches[2])) $darwin_os_version = (float)$matches[2];
897
898 $darwin_macos_map = [
899 '1.3' => '0',
900 '1.4' => '1',
901 '5.1' => '1',
902 '5.5' => '1',
903 '6.0' => '2',
904 '6.8' => '2',
905 '7.0' => '3',
906 '7.9' => '3',
907 '8.0' => '4',
908 '8.1' => '4',
909 '9.0' => '5',
910 '9.8' => '5',
911 '10.0' => '6',
912 '10.8' => '6',
913 '11.0' => '7',
914 '11.4' => '7',
915 '12.0' => '8',
916 '12.6' => '8',
917 '13.0' => '9',
918 '13.4' => '9',
919 '14.0' => '10',
920 '14.5' => '10',
921 '15.0' => '11',
922 '15.6' => '11',
923 '16.0' => '12',
924 '16.6' => '12',
925 '17.0' => '13',
926 '17.7' => '13',
927 '18.0' => '14',
928 '18.2' => '14',
929 '19.0' => '15',
930 '19.6' => '15',
931 '20.0' => '16',
932 '20.6' => '16',
933 '21.0' => '17',
934 '21.6' => '17',
935 '22.0' => '18',
936 '22.3' => '18',
937 ];
938 $darwin_ios_map = [
939 '9.0' => '1',
940 '9.8' => '1',
941 '10.0' => '4',
942 '10.8' => '4',
943 '11.0' => '5',
944 '11.4' => '5',
945 '12.0' => '6',
946 '13.0' => '7',
947 '14.0' => '8',
948 '15.0' => '9',
949 '15.6' => '9',
950 '16.0' => '10',
951 '16.6' => '10',
952 '17.0' => '11',
953 '17.7' => '11',
954 '18.0' => '12',
955 '18.2' => '12',
956 '19.0' => '13',
957 '19.6' => '13',
958 '20.0' => '14',
959 '20.6' => '14',
960 '21.0' => '15',
961 '21.6' => '15',
962 '22.0' => '16',
963 '22.3' => '16',
964 ];
965
966 if ($this->result_os_name === 'MacOS') {
967 $darwin_map = $darwin_macos_map;
968 } else $darwin_map = $darwin_ios_map;
969
970 foreach ($darwin_map as $k => $v) {
971 $darwin_map_min[$k] = abs($k - $darwin_os_version);
972 }
973
974 asort($darwin_map_min);
975 $darwin_map_key = key($darwin_map_min);
976 $this->result_os_version = $darwin_map[$darwin_map_key];
977
978 if ($this->result_os_name === 'MacOS') {
979 $this->result_os_version = $this->macos_codename($darwin_map[$darwin_map_key]);
980 if (!empty($this->result_os_version)) {
981 $this->result_os_title = 'MacOS '.$this->result_os_version;
982 } else $this->result_os_title = 'MacOS';
983 }
984
985 $darwin_map = null;
986 $darwin_map_min = null;
987 $darwin_macos_map = null;
988 $darwin_ios_map = null;
989 $os_need_continue = false;
990 }
991
992 // Set OS title and type
993
994 if ($this->get_mode !== 'browser' && $this->result_os_name !== 'MacOS') {
995 if (!empty($this->result_os_version)) {
996 $this->result_os_title = $this->result_os_name.' '.$this->result_os_version;
997 } else {
998 if ($this->result_os_name !== 'Windows') {
999 $this->result_os_title = $this->result_os_name;
1000 } else $this->result_os_title = $this->result_os_name.' (unknown version)';
1001 }
1002 if (strpos($this->result_os_name, 'unknown') !== false) $this->result_os_type = 'unknown';
1003 if ($this->result_os_version == null) $this->result_os_version = 0;
1004 }
1005
1006 /*
1007 ---------------------
1008 Detect 64bits mode
1009 ---------------------
1010 */
1011
1012 if ($this->result_os_name === 'iOS' && $this->result_os_version >= 11) $this->result_64bits_mode = 1;
1013 if ($this->result_os_name === 'MacOS' && $this->macos_version_minor >= 8) $this->result_64bits_mode = 1;
1014
1015 if ($this->result_64bits_mode == 0) {
1016 if ($this->match_ua('64') && $this->match_ua('x64;|x86_64|x86-64|arm64|arm_64|aarch64|Linux x64|mips64|amd64|AMD64|ia64|IRIX64|ppc64|sparc64|x64_64')) {
1017 $this->result_64bits_mode = 1;
1018 }
1019 }
1020
1021 if ($this->result_os_name === 'Android' && $this->result_browser_desktop_mode == 1) $this->result_64bits_mode = 0;
1022 if ($this->result_64bits_mode == 1 && $this->match_ua('86') && $this->match_ua('i386|i686')) $this->result_64bits_mode = 0;
1023
1024 // If mode 'os' only
1025
1026 if ($this->get_mode === 'os') return null;
1027
1028 /*
1029 -------------------
1030 BROWSER DETECTION
1031 -------------------
1032
1033 ---------------------
1034 Mixed-type Browsers
1035 ---------------------
1036 */
1037
1038 $browser_need_continue = true;
1039 if ($this->get_mode === 'device') $browser_need_continue = false;
1040
1041 // Chrome / Chromium
1042
1043 if ($browser_need_continue && $this->match_ua('Chrome/|Chromium/|CriOS/|CrMo/')) {
1044 $this->result_browser_version = 0;
1045 $matches = $this->match_ua('/(Chrome|Chromium|CriOS|CrMo)\/([0-9]+)\.?/');
1046 $this->result_browser_name = 'Chrome';
1047 if (!empty($matches[1]) && $matches[1] === 'Chromium') $this->result_browser_name = 'Chromium';
1048 if (!empty($matches[2])) $this->result_browser_version = (int)$matches[2];
1049 $this->result_browser_chromium_version = $this->result_browser_version;
1050 if ($this->match_ua('CriOS/')) $this->result_browser_chromium_version = 0;
1051 if ($this->match_ua('/Gecko\)\s(Chrome|CrMo)\/(\d+\.\d+\.\d+\.\d+)\s(?:Mobile)?(?:\/[.0-9A-Za-z]+\s|\s)?Safari\/[.0-9]+$/') && !$this->match_ua(
1052 'SalamWeb| Valve | GOST'
1053 )) {
1054 $this->result_browser_chrome_original = 1;
1055 }
1056 }
1057
1058 // Firefox
1059
1060 if ($browser_need_continue && $this->result_browser_chromium_version == 0 && $this->match_ua('Firefox/') && !$this->match_ua('Focus/|FxiOS|Waterfox|Ghostery:')) {
1061 $this->result_browser_version = 0;
1062 $matches = $this->match_ua('/Firefox\/([0-9]+)\./');
1063 $this->result_browser_name = 'Firefox';
1064 if (!empty($matches[1])) $this->result_browser_version = (int)$matches[1];
1065 if ($this->match_ua('/\)\sGecko\/[.0-9]+\sFirefox\/[.0-9]+$/')) $this->result_browser_firefox_original = 1;
1066 }
1067
1068 // Cross-device browsers (Yandex, Edge, Firefox, Opera, Puffin, Vivaldi, QQ Browser, Whale, Brave etc)
1069
1070 if ($browser_need_continue && $this->result_browser_chrome_original == 0 && $this->result_browser_firefox_original == 0) {
1071 $browser_list[] = ['Yandex Browser', 'YaBrowser', '/YaBrowser\/([0-9]+\.[0-9]+)/', '1', 'YaApp_'];
1072 $browser_list[] = ['Edge', 'Edg', '/Edg(|e|A|iOS)\/([0-9]+)\./', '2', ''];
1073 $browser_list[] = ['Opera', ' OPR/', '/OPR\/(\d+)/', '1', 'Opera Mini|OPiOS|OPT/|OPRGX/|AlohaBrowser'];
1074 $browser_list[] = ['Opera', 'Opera', '/Opera.*Version\/([0-9]+\.[0-9]+)/', '1', 'Opera Mini|OPiOS|OPT/|InettvBrowser/'];
1075 $browser_list[] = ['Opera', 'Opera', '/Opera(\s|\/)([0-9]+\.[0-9]+)/', '2', 'Opera Mini|OPiOS|OPT/|InettvBrowser/'];
1076 $browser_list[] = ['UC Browser', 'UBrowser|UCBrowser|UCMini', '/(UBrowser|UCBrowser|UCMini)\/([0-9]+\.[0-9]+)/', '2', 'UCTurbo|AliApp'];
1077 $browser_list[] = ['UC Browser Turbo', 'UCTurbo/', '/UCTurbo\/([0-9]+\.[0-9]+)/', '1', ''];
1078 $browser_list[] = ['Puffin', 'Puffin/', '/Puffin\/([0-9]+\.[0-9]+)/', '1', ''];
1079 $browser_list[] = ['Vivaldi', 'Vivaldi/', '/Vivaldi\/([0-9]+\.[0-9]+)/', '1', ''];
1080 $browser_list[] = ['QQ Browser', 'QQBrowser/', '/QQBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1081 $browser_list[] = ['Coc Coc', 'coc_coc_browser', '/coc_coc_browser\/([0-9]+)/', '1', ''];
1082 $browser_list[] = ['Whale', 'Whale/', '/Whale\/([0-9]+\.[0-9]+)/', '1', 'NAVER(inapp;'];
1083 $browser_list[] = ['Brave', 'Brave', '/Brave(?: Chrome)?\/([0-9]+)/', '1', ''];
1084 $browser_list[] = ['Maxthon', 'Maxthon/', '/Maxthon\/([0-9]+\.[0-9]+)/', '1', ''];
1085 $browser_list[] = ['Maxthon', 'MxBrowser/', '/MxBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1086 $browser_list[] = ['2345 Explorer', '2345Explorer|2345Browser', '/(2345Explorer|2345Browser)(?: |\/)?([0-9]+\.[0-9]+)/', '2', ''];
1087 $browser_list[] = ['IceCat', 'IceCat/', '/IceCat\/([0-9]+)/', '1', ''];
1088 $browser_list[] = ['Lunascape', 'Lunascape', '/Lunascape(?: |\/)?([0-9]+\.[0-9]+)/', '1', ''];
1089 $browser_list[] = ['Seznam Browser', 'Seznam.cz/|SznProhlizec/', '/(Seznam\.cz|SznProhlizec)\/([0-9]+\.[0-9]+)/', '2', ''];
1090 $browser_list[] = ['Sleipnir', 'Sleipnir/', '/Sleipnir\/([0-9]+\.[0-9]+)/', '1', ''];
1091 $browser_list[] = ['Sputnik', 'SputnikBrowser/', '/SputnikBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1092 $browser_list[] = ['Oculus Browser', 'OculusBrowser/', '/OculusBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1093 $browser_list[] = ['PaleMoon', 'PaleMoon', '/PaleMoon\/([0-9]+\.[0-9]+)/', '1', ''];
1094 $browser_list[] = ['SalamWeb', 'SalamWeb|Salam Browser', '/SalamWeb\/([0-9]+\.[0-9]+)/', '1', ''];
1095 $browser_list[] = ['Swing', 'Swing/|Swing(And)/', '/Swing(?:\(And\))?\/([0-9]+\.[0-9]+)/', '1', ''];
1096 $browser_list[] = ['Safe Exam Browser', 'SEB/', '/SEB\/([0-9]+\.[0-9]+)/', '1', ''];
1097 $browser_list[] = ['Colibri', 'Colibri/', '/Colibri\/([0-9]+\.[0-9]+)/', '1', ''];
1098 $browser_list[] = ['Opera GX', 'OPRGX', '/OPRGX\/([0-9]+)/', '1', ''];
1099 $browser_list[] = ['Opera GX', 'OPX/', '/OPX\/([0-9]+\.[0-9]+)/', '1', ''];
1100 $browser_list[] = ['Xvast', 'Xvast/', '/Xvast\/([0-9]+\.[0-9]+)/', '1', ''];
1101 $browser_list[] = ['Atom', 'Atom/', '/Atom\/([0-9]+\.[0-9]+)/', '1', ''];
1102 $browser_list[] = ['NetCast', 'SmartTV/', '/SmartTV\/([0-9]+)/', '1', ''];
1103 $browser_list[] = ['LG Browser', ' LG Browser/', '/\sLG\sBrowser\/([0-9]+)/', '1', ''];
1104 $browser_list[] = ['Ghostery Browser', 'Ghostery:', '/Ghostery\:([0-9]+\.[0-9]+)/', '1', ''];
1105 $browser_list[] = ['Aloha Browser', 'AlohaBrowser/', '/AlohaBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1106 $browser_list[] = ['Lenovo Browser', 'SLBrowser/', '/SLBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1107 $browser_list[] = ['Samsung Browser TV', '/SamsungBrowser\/[.0-9]+\sTV\s/', '/SamsungBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1108 $browser_list[] = ['WeChat App', 'MicroMessenger/', '/MicroMessenger\/([0-9]+\.[0-9]+)/', '1', ''];
1109 $browser_list[] = ['WKWebView', '/Intel\sMac\sOS\sX\s\d+.*\)\sAppleWebKit\/[.0-9]+.*Gecko\)$/', 'AppleWebKit', '1', ''];
1110 $browser_list[] = ['Sber Browser', 'SberBrowser/', '/SberBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1111
1112 foreach ($browser_list as $browser_list_va) {
1113 $match = $browser_list_va[1];
1114 $match_exclude = $browser_list_va[4];
1115
1116 if ($this->match_ua($match) && !$this->match_ua($match_exclude)) {
1117 $this->result_browser_version = 0;
1118 $this->result_browser_name = $browser_list_va[0];
1119 $matches = $this->match_ua($browser_list_va[2]);
1120 $matches_n = intval($browser_list_va[3]);
1121 $this->result_browser_version = is_array($matches) ? (float)$matches[$matches_n] : 0;
1122 if (!empty($this->result_browser_version)) {
1123 $browser_need_continue = false;
1124 break;
1125 }
1126 }
1127 }
1128
1129 $browser_list = null;
1130 }
1131
1132 // Gecko engine detection
1133
1134 if ($this->get_mode !== 'device' && $this->result_browser_chromium_version == 0 && $this->match_ua('Gecko/|ArtisBrowser/') && ($this->match_ua(
1135 '/\srv:[.0-9a-z]+(?:\;\s.*|)\)\sGecko\/[.0-9]+\s/'
1136 ) || $this->match_ua('QwantMobile/|ArtisBrowser/'))) {
1137 $this->result_browser_gecko_version = 0;
1138 $match = $this->match_ua('/\srv:([0-9]+\.[0-9]+)(?:[.0-9a-z]+)?(?:\;\s.*|)\)\sGecko\/[.0-9]+\s/');
1139
1140 if (is_array($match)) {
1141 if ($match[1] >= 5) {
1142 $match[1] = intval($match[1]);
1143 } else $match[1] = (float)$match[1];
1144 }
1145
1146 if (!empty($match[1])) {
1147 $this->result_browser_gecko_version = $match[1];
1148 } else {
1149 $match = $this->match_ua('/\sGecko\/([.0-9]+)\s.*QwantMobile\/[.0-9]+$/');
1150 if (!empty($match[1])) {
1151 $this->result_browser_gecko_version = intval($match[1]);
1152 } else {
1153 $match = $this->match_ua('/\srv:([0-9]+\.[0-9]+)\)\s.*ArtisBrowser\/[.0-9]+$/');
1154 if (!empty($match[1])) $this->result_browser_gecko_version = intval($match[1]);
1155 }
1156 }
1157
1158 // Gecko >= 109 issue
1159
1160 if ($this->result_browser_gecko_version >= 109 && $this->result_browser_gecko_version < 120) {
1161 $match = $this->match_ua('/\srv:[.0-9a-z]+(?:\;\s.*|)\)\sGecko\/[.0-9]+\s.*(?:Firefox|MaxBrowser)\/([0-9]+)\./');
1162 if (!empty($match[1])) $this->result_browser_gecko_version = intval($match[1]);
1163 }
1164 }
1165
1166 // WebKit engine detection
1167
1168 if ($this->get_mode !== 'device' && $this->result_browser_chromium_version == 0 && $this->result_browser_gecko_version == 0 && $this->matchi_ua('AppleWebKit/')) {
1169 $this->result_browser_webkit_version = 0;
1170 $match = $this->matchi_ua('/AppleWebKit\/([0-9]+\.[0-9]+)/');
1171 if (!empty($match[1])) $this->result_browser_webkit_version = (float)$match[1];
1172 }
1173
1174 /*
1175 ------------------
1176 Desktop Browsers
1177 ------------------
1178 */
1179
1180 if ($browser_need_continue && $this->result_browser_chrome_original == 0 && $this->result_browser_firefox_original == 0 && $this->result_mobile == 0) {
1181 // Safari
1182
1183 $browser_list[] = ['Safari', '/AppleWebKit\/[.0-9]+.*Gecko\)\sSafari\/[.0-9A-Za-z]+$/', '/Safari\/(\d+)/', '1', 'Version/'];
1184 $browser_list[] = ['Safari', '/Version\/([0-9]+\.[0-9]+).*Safari/', '/Version\/([0-9]+\.[0-9]+).*Safari/', '1', 'Epiphany|Arora/|Midori|midori|SlimBoat|Roccat'];
1185
1186 // IE
1187
1188 $browser_list[] = ['Internet Explorer', 'MSIE', '/MSIE(?:\s|)([0-9]+)/', '1', 'Opera|IEMobile|Trident/'];
1189 $browser_list[] = ['Internet Explorer', 'Trident/', '/Trident\/([0-9]+)/', '1', 'Opera|IEMobile'];
1190
1191 // Chromium based browsers
1192
1193 $browser_list[] = ['Avast Browser', 'Avast/', '/Avast\/([0-9]+)/', '1', ''];
1194 $browser_list[] = ['AVG Browser', 'AVG/', '/AVG\/([0-9]+)/', '1', ''];
1195 $browser_list[] = ['CCleaner Browser', 'CCleaner/', '/CCleaner\/([0-9]+)/', '1', ''];
1196 $browser_list[] = ['Comodo Dragon', 'Dragon/', '/Dragon\/([0-9]+)/', '1', 'IceDragon'];
1197 $browser_list[] = ['Iridium', 'Iridium/', '/Iridium\/.*Safari.*Chrome\/([0-9]+)/', '1', ''];
1198 $browser_list[] = ['Maxthon Nitro', 'MxNitro|mxnitro', '/(MxNitro|mxnitro)\/([0-9]+\.[0-9]+)/', '2', ''];
1199 $browser_list[] = ['Iron', ' Iron ', '/Chrome\/([0-9]+)/', '1', ''];
1200 $browser_list[] = ['Iron', 'Iron/', '/Iron\/([0-9]+)/', '1', ''];
1201 $browser_list[] = ['Hola Browser', 'Hola/', '/Hola\/([0-9]+\.[0-9]+)/', '1', ''];
1202 $browser_list[] = ['Sogou Explorer', '/Chrome.*Safari.*SE\s.*MetaSr/', '/Chrome\/([0-9]+)/', '1', ''];
1203 $browser_list[] = ['360 browser', 'QIHU 360', '/Chrome\/([0-9]+)/', '1', ''];
1204 $browser_list[] = ['Slimjet', 'Slimjet/', '/Slimjet\/([0-9]+)/', '1', ''];
1205 $browser_list[] = ['FreeU', 'FreeU|Freeu', '/(FreeU|Freeu)\/([0-9]+)/', '2', ''];
1206 $browser_list[] = ['Kinza', 'Kinza/', '/Kinza\/([0-9]+\.[0-9]+)/', '1', ''];
1207 $browser_list[] = ['Station', 'Station/', '/Station\/([0-9]+\.[0-9]+)/', '1', ''];
1208 $browser_list[] = ['Superbird', 'Superbird|SuperBird', '/(Superbird|SuperBird)\/([0-9]+)/', '2', ''];
1209 $browser_list[] = ['Polypane', 'Polypane/', '/Polypane\/([0-9]+\.[0-9]+)/', '1', ''];
1210 $browser_list[] = ['OhHai Browser', 'OhHaiBrowser/', '/OhHaiBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1211 $browser_list[] = ['Sizzy', 'Sizzy', '/Sizzy\/([0-9]+\.[0-9]+)/', '1', ''];
1212 $browser_list[] = ['AOL Desktop', 'ADG/', '/ADG\/([0-9]+\.[0-9]+)/', '1', ''];
1213 $browser_list[] = ['Elements Browser', 'Elements Browser', '/Elements\sBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1214 $browser_list[] = ['115 Browser', '115Browser', '/115Browser\/([0-9]+\.[0-9]+)/', '1', ''];
1215 $browser_list[] = ['Falkon', 'Falkon/', '/Falkon\/([0-9]+\.[0-9]+)/', '1', ''];
1216 $browser_list[] = ['AOL Shield Pro', 'AOLShield', '/AOLShield\/([0-9]+)/', '1', ''];
1217 $browser_list[] = ['Google Earth', 'Google Earth', '/Google Earth(?:|\sPro)\/([0-9]+\.[0-9]+)/', '1', ''];
1218 $browser_list[] = ['Chedot', 'Chedot/', '/Chedot\/([0-9]+\.[0-9]+)/', '1', ''];
1219 $browser_list[] = ['SlimBoat', 'SlimBoat/', '/SlimBoat\/([0-9]+\.[0-9]+)/', '1', ''];
1220 $browser_list[] = ['Rambler Browser', 'Nichrome/', '/Chrome\/([0-9]+)/', '1', ''];
1221 $browser_list[] = ['Beaker Browser', 'BeakerBrowser/', '/BeakerBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1222 $browser_list[] = ['Amigo', 'Amigo/', '/Amigo\/([0-9]+\.[0-9]+)/', '1', ''];
1223 $browser_list[] = ['Opera Neon', ' MMS/', '/\sMMS\/([0-9]+\.[0-9]+)/', '1', ''];
1224 $browser_list[] = ['SmartTV Browser', 'Thano/', '/Thano\/([0-9]+\.[0-9]+)/', '1', ''];
1225 $browser_list[] = ['Biscuit', 'Biscuit/', '/Biscuit\/([0-9]+\.[0-9]+)/', '1', ''];
1226 $browser_list[] = ['Chromium GOST', 'Chromium GOST', '/Chrome\/([0-9]+\.[0-9]+)/', '1', ''];
1227 $browser_list[] = ['Dashob', 'Dashob/', '/Dashob\/([0-9]+\.[0-9]+)/', '1', ''];
1228 $browser_list[] = ['Dezor', 'Dezor/', '/Dezor\/([0-9]+\.[0-9]+)/', '1', ''];
1229 $browser_list[] = ['Duoyu Browser', 'duoyu_business/', '/duoyu_business\/([0-9]+\.[0-9]+)/', '1', ''];
1230 $browser_list[] = ['iTop Browser', ' iTop', '/Chrome\/([0-9]+\.[0-9]+)*.+\siTop$/', '1', ''];
1231 $browser_list[] = ['Polarity', 'Polarity/', '/Polarity\/([0-9]+\.[0-9]+)/', '1', ''];
1232 $browser_list[] = ['Sielo', 'Sielo/', '/Sielo\/([0-9]+\.[0-9]+)/', '1', ''];
1233 $browser_list[] = ['Norton Browser', 'Norton/', '/Norton\/([0-9]+)/', '1', ''];
1234 $browser_list[] = ['Avira Browser', 'Avira/', '/Avira\/([0-9]+)/', '1', ''];
1235
1236 // Webkit, Gecko and other engine based browsers
1237
1238 $browser_list[] = ['Cyberfox', 'Cyberfox/', '/Cyberfox\/([0-9]+)/', '1', ''];
1239 $browser_list[] = ['SeaMonkey', 'SeaMonkey/', '/SeaMonkey\/([0-9]+\.[0-9]+)/', '1', ''];
1240 $browser_list[] = ['K-Meleon', 'K-Meleon', '/K\-Meleon\/([0-9]+\.[0-9]+)/', '1', ''];
1241 $browser_list[] = ['Iceweasel', '/[iI]ce[wW]easel/', '/[iI]ce[wW]easel/', '1', ''];
1242 $browser_list[] = ['IceApe', 'Iceape/', '/Iceape\/([0-9]+\.[0-9]+)/', '1', ''];
1243 $browser_list[] = ['Comodo Ice Dragon', 'IceDragon/', '/IceDragon\/([0-9]+\.[0-9]+)/', '1', ''];
1244 $browser_list[] = ['QtWeb', 'QtWeb Internet Browser/', '/QtWeb\sInternet\sBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1245 $browser_list[] = ['QtWebEngine', 'QtWebEngine', '/QtWebEngine\/([0-9]+\.[0-9]+)/', '1', 'Konqueror'];
1246 $browser_list[] = ['Qt', 'Qt/', '/Qt\/([0-9]+\.[0-9]+)/', '1', ''];
1247 $browser_list[] = ['WebKitGTK', 'WebKitGTK+/', '/WebKitGTK\+\/([0-9]+\.[0-9]+)/', '1', ''];
1248 $browser_list[] = ['Konqueror', 'Konqueror', '/Konqueror\/([0-9]+\.[0-9]+)/', '1', 'QtWebEngine'];
1249 $browser_list[] = ['Konqueror', 'konqueror', '/konqueror\/([0-9]+\.[0-9]+)/', '1', 'QtWebEngine'];
1250 $browser_list[] = ['Konqueror', 'Konqueror', '/\sQtWebEngine\/([0-9]+\.[0-9]+)(|[.0-9]+)\sChrome\/[.0-9]+.*\sSafari\/[.0-9]+.*Konqueror\s/', '1', ''];
1251 $browser_list[] = ['Epiphany', 'Epiphany', '/Epiphany\/([0-9]+\.[0-9]+)/', '1', ''];
1252 $browser_list[] = ['OmniWeb', 'OmniWeb/', '/OmniWeb\//', '1', ''];
1253 $browser_list[] = ['iCab', 'iCab', '/iCab(\s|\/)([0-9]+\.[0-9]+)/', '2', ''];
1254 $browser_list[] = ['Camino', 'Camino/', '/Camino\/([0-9]+\.[0-9]+)/', '1', ''];
1255 $browser_list[] = ['Midori', 'Midori|midori', '/Midori\/([.0-9]+)/', '1', ''];
1256 $browser_list[] = ['Otter', 'Otter/', '/Otter\/([0-9]+\.[0-9]+)/', '1', ''];
1257 $browser_list[] = ['Kazehakase', 'Kazehakase/', '/Kazehakase\/([0-9]+\.[0-9]+)/', '1', ''];
1258 $browser_list[] = ['QupZilla', 'QupZilla/', '/QupZilla\/([0-9]+\.[0-9]+)/', '1', ''];
1259 $browser_list[] = ['Waterfox', 'Waterfox/', '/Waterfox\/([0-9]+)/', '1', ''];
1260 $browser_list[] = ['Waterfox', 'Waterfox', '/Firefox\/([0-9]+)/', '1', ''];
1261 $browser_list[] = ['Basilisk', 'Basilisk/', '/\srv:([0-9]+\.[0-9]+)/', '1', ''];
1262 $browser_list[] = ['Dooble', 'Dooble/', '/Dooble\/([0-9]+\.[0-9]+)/', '1', ''];
1263 $browser_list[] = ['Fluid', 'Fluid/', '/Fluid\/([0-9]+\.[0-9]+)/', '1', ''];
1264 $browser_list[] = ['Arora', 'Arora/', '/Arora\/([0-9]+\.[0-9]+)/', '1', ''];
1265 $browser_list[] = ['Artis Browser', 'ArtisBrowser/', '/ArtisBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1266 $browser_list[] = ['Steam Client', ' Valve ', '/Valve\s(|Steam\s)Client/', '1', 'Tenfoot'];
1267 $browser_list[] = ['Steam Overlay', ' Valve ', '/Valve\sSteam\sGameOverlay/', '1', 'Tenfoot|Client/'];
1268 $browser_list[] = ['Rekonq', ' rekonq', '/rekonq\/([0-9]+\.[0-9]+)/', '1', ''];
1269 $browser_list[] = ['Odyssey Web Browser', 'Odyssey Web Browser', '/OWB\/([0-9]+\.[0-9]+)/', '1', ''];
1270 $browser_list[] = ['Safari SDK', '/^Safari\/[.0-9]+\sCFNetwork\/[.0-9]+\sDarwin\/[.0-9]+/', '/Safari\//', '1', ''];
1271 $browser_list[] = ['Internet TV Browser', 'InettvBrowser/', '/InettvBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1272 $browser_list[] = ['Firefox', 'BonEcho/', '/BonEcho\/([0-9]+)/', '1', ''];
1273 $browser_list[] = ['Firefox', 'GranParadiso/', '/GranParadiso\/([0-9]+)/', '1', ''];
1274 $browser_list[] = ['Firefox', 'Shiretoko/', '/Shiretoko\/([0-9]+)/', '1', ''];
1275 $browser_list[] = ['Firefox', 'Namoroka/', '/Namoroka\/([0-9]+)/', '1', ''];
1276 $browser_list[] = ['iTunes App', 'iTunes/', '/iTunes\/([0-9]+\.[0-9]+)/', '1', ''];
1277 $browser_list[] = ['Mypal Browser', 'Mypal/', '/Mypal\/([0-9]+\.[0-9]+)/', '1', ''];
1278 $browser_list[] = ['Mercury', 'Mercury/', '/Firefox\/([0-9]+\.[0-9]+)/', '1', ''];
1279 $browser_list[] = ['Arctic Fox', 'ArcticFox/', '/ArcticFox\/([0-9]+\.[0-9]+)/', '1', ''];
1280 $browser_list[] = ['Roccat', ' Roccat/', '/Roccat\/([0-9]+\.[0-9]+)/', '1', ''];
1281 $browser_list[] = ['Lunascape', ' lswebkit ', ' lswebkit ', '1', ''];
1282
1283 foreach ($browser_list as $browser_list_va) {
1284 $match = $browser_list_va[1];
1285 $match_exclude = $browser_list_va[4];
1286
1287 if ($this->match_ua($match) && !$this->match_ua($match_exclude)) {
1288 $this->result_browser_version = 0;
1289 $this->result_browser_name = $browser_list_va[0];
1290 $matches = $this->match_ua($browser_list_va[2]);
1291 $matches_n = intval($browser_list_va[3]);
1292 $this->result_browser_version = is_array($matches) ? (float)$matches[$matches_n] : 0;
1293
1294 // Gnome Web browser detection on Linux/Unix OS
1295
1296 if ($this->result_browser_name === 'Safari' && ($this->result_os_family === 'linux' || $this->result_os_family === 'unix')) {
1297 $this->result_browser_name = 'Gnome Web';
1298 }
1299
1300 // Safari old version conversion
1301
1302 if ($match === '/AppleWebKit\/[.0-9]+.*Gecko\)\sSafari\/[.0-9A-Za-z]+$/') {
1303 $ev = intval($this->result_browser_version);
1304 if (!empty($ev)) $this->result_browser_version = 1;
1305 if ($ev > 400) $this->result_browser_version = 2;
1306 if ($ev > 500) $this->result_browser_version = 3;
1307 if ($ev > 527) $this->result_browser_version = 4;
1308 if ($ev > 532) $this->result_browser_version = 5;
1309 if ($ev > 535) $this->result_browser_version = 6;
1310 $this->result_browser_safari_original = 1;
1311 }
1312
1313 // IE Trident engine version conversion
1314
1315 if ($match === 'Trident/') {
1316 if ($this->result_browser_version == 4) $this->result_browser_version = 8;
1317 if ($this->result_browser_version == 5) $this->result_browser_version = 9;
1318 if ($this->result_browser_version == 6) $this->result_browser_version = 10;
1319 if ($this->result_browser_version == 7) $this->result_browser_version = 11;
1320 }
1321
1322 if (!empty($this->result_browser_version)) {
1323 $browser_need_continue = false;
1324 break;
1325 }
1326 }
1327 }
1328
1329 $browser_list = null;
1330 // End of desktop browsers detection
1331 }
1332
1333 /*
1334 -----------------
1335 Mobile Browsers
1336 -----------------
1337 */
1338
1339 if ($browser_need_continue && $this->result_browser_chrome_original == 0 && $this->result_browser_firefox_original == 0 && $this->result_mobile == 1) {
1340 // Mobile browsers with detectable versions
1341
1342 $browser_list[] = [
1343 'Safari Mobile',
1344 '/(iPhone|iphone|iPad;|iPod).*AppleWebKit\/[.0-9]+\s\(KHTML,\slike\sGecko\)\s.*Version\/[.,0-9]+\sMobile\//',
1345 '/Version\/([0-9]+\.[0-9]+)(|\.[0-9]+|\,[0-9]+)\sMobile\//',
1346 '1',
1347 'RDDocuments|AlohaBrowser|DuckDuckGo|MiuiBrowser|Snapchat|NAVER(inapp;|1Password|OPT/|Ddg/',
1348 ];
1349 $browser_list[] = [
1350 'Safari Mobile',
1351 '/(Intel\sMac\sOS\sX).*AppleWebKit\/.*Version\/[.,0-9]+\s(?:|Mobile\/\w+\s)Safari\/[.0-9A-Za-z]+(|\/[0-9]+|\s\(.*\))+$/',
1352 '/Version\/([0-9]+\.[0-9]+)(|\.[0-9]+|\,[0-9]+)/',
1353 '1',
1354 'CriOS|RDDocuments|AlohaBrowser|DuckDuckGo|MiuiBrowser|Snapchat|NAVER(inapp;|1Password|OPT/|Ddg/',
1355 ];
1356 $browser_list[] = ['Android Browser', '/Android.*Version\/[.0-9]+\s(?:Mobile\s)?Safari\/[.0-9]+(|\-[0-9]+)$/', '/Android.*Version\/([0-9]+\.[0-9]+)/', '1', 'Chrome/'];
1357 $browser_list[] = ['Android Browser', 'Dalvik/', '/Dalvik\/([.0-9]+)\s\(Linux;\sU;\sAndroid\s/', '2', 'Chrome/'];
1358 $browser_list[] = ['Samsung Browser', 'SamsungBrowser', '/SamsungBrowser\/([0-9]+\.[0-9]+)/', '1', 'CrossApp'];
1359 $browser_list[] = ['Firefox Focus', 'Focus/', '/Focus\/([0-9]+\.[0-9]+)/', '1', ''];
1360 $browser_list[] = ['Firefox iOS', 'FxiOS', '/FxiOS\/([0-9]*[.]?[0-9]+)/', '1', ''];
1361 $browser_list[] = ['Opera Mini', 'Opera Mini|OPiOS', '/(Opera Mini|OPiOS)\/([0-9]+\.[0-9]+)/', '2', ''];
1362 $browser_list[] = ['Opera Touch', 'OPT/', '/OPT\/([0-9]+\.[0-9]+)/', '1', ''];
1363 $browser_list[] = ['Huawei Browser', 'HuaweiBrowser/', '/HuaweiBrowser\/([0-9]+)/', '1', ''];
1364 $browser_list[] = ['DuckDuckGo', 'DuckDuckGo/', '/DuckDuckGo\/([0-9]+)/', '1', ''];
1365 $browser_list[] = ['DuckDuckGo', 'Ddg/', '/Ddg\/([0-9]+\.[0-9]+)/', '1', ''];
1366 $browser_list[] = ['Mi Browser', 'MiuiBrowser/', '/MiuiBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1367 $browser_list[] = ['Mint Browser', 'Mint Browser/', '/Mint\sBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1368 $browser_list[] = ['Avast Browser', 'AvastSecureBrowser/', '/AvastSecureBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1369 $browser_list[] = ['Google App', '/(iPhone|iphone|iPad;|iPod).*\)\sGSA\/([0-9]+)/', '/(iPhone|iphone|iPad;|iPod).*\)\sGSA\/([0-9]+)/', '2', ''];
1370 $browser_list[] = ['Google App', '/\sGSA\//', '/\sGSA\/([0-9]+)/', '1', ''];
1371 $browser_list[] = ['Facebook App', 'FBAV/|FBSV/', '/(FBAV|FBSV)\/([0-9]+)\./', '2', 'FBAN/Messenger|FB_IAB/MESSENGER'];
1372 $browser_list[] = ['Instagram App', 'Instagram', '/Instagram\s([0-9]+)\./', '1', ''];
1373 $browser_list[] = ['Facebook Messenger', 'FBAN/Messenger|FB_IAB/MESSENGER', '/(FBAV|FBSV)\/([0-9]+)\./', '2', ''];
1374 $browser_list[] = ['Snapchat', 'Snapchat', '/\sSnapchat\/([0-9]+\.[0-9]+)/', '1', ''];
1375 $browser_list[] = ['WhatsApp', 'WhatsApp', '/WhatsApp\/([0-9]+\.[0-9]+)/', '1', ''];
1376 $browser_list[] = ['Viber', 'Viber/', '/Viber\/([0-9]+\.[0-9]+)/', '1', ''];
1377 $browser_list[] = ['Yandex App', 'YaApp_', '/YaApp_(Android|iOS)\/([0-9]+\.[0-9]+)/', '2', ''];
1378 $browser_list[] = ['Yandex App', 'YandexSearch/', '/YandexSearch\/([0-9]+\.[0-9]+)/', '1', ''];
1379 $browser_list[] = ['Yandex App', 'YaSearchBrowser/', '/YaSearchBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1380 $browser_list[] = ['Dolfin', 'Dolfin/', '/Dolfin\/([0-9]+\.[0-9]+)/', '1', ''];
1381 $browser_list[] = ['Flipboard App', 'Flipboard/', '/Flipboard\/([0-9]+\.[0-9]+)/', '1', ''];
1382 $browser_list[] = ['FreeU', 'FreeU|Freeu', '/(FreeU|Freeu)\/([0-9]+\.[0-9]+)/', '2', ''];
1383 $browser_list[] = ['Iron', 'Iron Safari|MobileIron', '/Chrome\/([0-9]+)/', '1', ''];
1384 $browser_list[] = ['Sogou Mobile Browser', 'SogouMobileBrowser/', '/SogouMobileBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1385 $browser_list[] = ['Meizu Browser', 'MZBrowser/', '/MZBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1386 $browser_list[] = ['360 Mobile Browser', '360 Aphone', '/360\sAphone\sBrowser\s\(([0-9]+\.[0-9]+)/', '1', ''];
1387 $browser_list[] = ['Adblock Browser', 'ABB/', '/ABB\/([0-9]+\.[0-9]+)/', '1', ''];
1388 $browser_list[] = ['Ecosia Browser', 'Ecosia', '/Chrome\/([0-9]+)/', '1', ''];
1389 $browser_list[] = ['HeyTap Browser', 'HeyTapBrowser/', '/HeyTapBrowser\/([0-9]+)/', '1', ''];
1390 $browser_list[] = ['Oppo Browser', 'OppoBrowser/', '/OppoBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1391 $browser_list[] = ['Silk', 'Silk/', '/Silk\/([0-9]+\.[0-9]+)/', '1', ''];
1392 $browser_list[] = ['Surf Browser', 'SurfBrowser/', '/SurfBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1393 $browser_list[] = ['Phoenix Browser', 'PHX/', '/PHX\/([0-9]+\.[0-9]+)/', '1', ''];
1394 $browser_list[] = ['CM Mobile', 'ACHEETAHI', '/Chrome\/([0-9]+)/', '1', ''];
1395 $browser_list[] = ['Bing App', ' BingWeb', '/BingWeb\/([0-9]+\.[0-9]+)/', '1', ''];
1396 $browser_list[] = ['Firefox Klar', 'Klar/', '/Klar\/([0-9]+\.[0-9]+)/', '1', ''];
1397 $browser_list[] = ['Super Fast Browser', 'SFBrowser|tssomas', '/(SFBrowser|tssomas)\/([0-9]+\.[0-9]+)/', '2', ''];
1398 $browser_list[] = ['Tenta Browser', 'Tenta/', '/Tenta\/([0-9]+\.[0-9]+)/', '1', ''];
1399 $browser_list[] = ['Kiwi Browser', 'Kiwi Chrome/', '/Kiwi\sChrome\/([0-9]+)/', '1', ''];
1400 $browser_list[] = ['JioPages', 'JioBrowser/', '/JioBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1401 $browser_list[] = ['JioPages', 'JioPages/', '/JioPages\/([0-9]+\.[0-9]+)/', '1', ''];
1402 $browser_list[] = ['Qwant Mobile', 'QwantBrowser', '/QwantBrowser\/([0-9]+)/', '1', ''];
1403 $browser_list[] = ['Qwant Mobile', 'QwantMobile', '/QwantMobile\/([0-9]+\.[0-9]+)/', '1', ''];
1404 $browser_list[] = ['Cake Browser', '; Cake) ', '/\;\sCake\).*AppleWebKit.*Version\/([0-9]+\.[0-9]+)/', '1', ''];
1405 $browser_list[] = ['DU Browser', 'bdbrowser', '/bdbrowser(|_i18n)\/([0-9]+\.[0-9]+)/', '2', ''];
1406 $browser_list[] = ['DU Browser', 'baidubrowser', '/baidubrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1407 $browser_list[] = ['Baidu Search App', 'baiduboxapp/', '/baiduboxapp\/([0-9]+\.[0-9]+)/', '1', ''];
1408 $browser_list[] = ['DU Browser HD', 'BaiduHD/', '/BaiduHD\/([0-9]+\.[0-9]+)/', '1', ''];
1409 $browser_list[] = ['Hi Browser', 'HiBrowser/', '/HiBrowser\/?(?:v)?([0-9]+\.[0-9]+)/', '1', ''];
1410 $browser_list[] = ['VmWare Browser', 'AirWatch Browser', '/AirWatch\sBrowser\sv([0-9]+\.[0-9]+)/', '1', ''];
1411 $browser_list[] = ['Iron Mobile', 'MobileIron/', '/MobileIron\/([0-9]+\.[0-9]+)/', '1', ''];
1412 $browser_list[] = ['NineSky', 'Ninesky-android-mobile/', '/Ninesky\-android\-mobile\/([0-9]+\.[0-9]+)/', '1', ''];
1413 $browser_list[] = ['Realme Browser', 'RealmeBrowser/', '/RealmeBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1414 $browser_list[] = ['Vivo Browser', 'VivoBrowser/', '/VivoBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1415 $browser_list[] = ['Web Explorer', 'Web Explorer/', '/Web\sExplorer\/([0-9]+\.[0-9]+)/', '1', ''];
1416 $browser_list[] = ['NTENT Browser', 'NTENTBrowser/', '/NTENTBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1417 $browser_list[] = ['Nox Browser', 'NoxBrowser/', '/NoxBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1418 $browser_list[] = ['Quark Browser', 'Quark/', '/Quark\/([0-9]+\.[0-9]+)/', '1', ''];
1419 $browser_list[] = ['Yaani Browser', 'YaaniBrowser', '/YaaniBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1420 $browser_list[] = [
1421 'Tizen Browser',
1422 '/Tizen(?: )?(?:\/)?[.0-9]+.*AppleWebKit\/.*(Version|SLP Browser|Tizen Browser|TizenBrowser)\/([0-9]+\.[0-9]+)/',
1423 '/Tizen(?: )?(?:\/)?[.0-9]+.*AppleWebKit\/.*(Version|SLP Browser|Tizen Browser|TizenBrowser)\/([0-9]+\.[0-9]+)/',
1424 '2',
1425 '',
1426 ];
1427 $browser_list[] = ['Internet Explorer Mobile', 'IEMobile', '/IEMobile(?: )?(?:\/)?([0-9]+)/', '1', ''];
1428 $browser_list[] = ['Internet Explorer Mobile', 'Trident/', '/Trident\/[.0-9].*Touch;*.rv\:([0-9]+)/', '1', ''];
1429 $browser_list[] = ['ZetaKey', 'Zetakey/', '/Zetakey\/([0-9]+\.[0-9]+)/', '1', ''];
1430 $browser_list[] = ['Nokia Browser', 'NokiaBrowser/', '/NokiaBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1431 $browser_list[] = ['NetFront', 'NetFront/', '/NetFront\/([0-9]+\.[0-9]+)/', '1', ''];
1432 $browser_list[] = [
1433 'BlackBerry Browser',
1434 '/(BB10;|BlackBerry|PlayBook).*AppleWebKit.*Version\/([0-9]+\.[0-9]+)/',
1435 '/(BB10;|BlackBerry|PlayBook).*AppleWebKit.*Version\/([0-9]+\.[0-9]+)/',
1436 '2',
1437 '',
1438 ];
1439 $browser_list[] = ['ONE Browser', 'OneBrowser/', '/OneBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1440 $browser_list[] = ['Web Explorer', 'webexplorer/', '/webexplorer\/([0-9]+)/', '1', ''];
1441 $browser_list[] = ['Start Internet Browser', 'Start/', '/Start\/([0-9]+)/', '1', ''];
1442 $browser_list[] = ['EUI Browser', 'EUI Browser', '/EUI\sBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1443 $browser_list[] = ['iCab Mobile', 'iCabMobile', '/iCabMobile(\s|\/)([0-9]+\.[0-9]+)/', '2', ''];
1444 $browser_list[] = ['Mercury', 'Mercury/', '/Mercury\/([0-9]+\.[0-9]+)/', '1', ''];
1445 $browser_list[] = [
1446 'Samsung Browser',
1447 '; SAMSUNG S|; SAMSUNG G',
1448 '/\;\sSAMSUNG\s(S|G)+.*\sBuild\/.*\)\sAppleWebKit\/.*Version\/([0-9]+\.[0-9]+)\sChrome\/[.0-9]+.*\sSafari\/[.0-9]+$/',
1449 '2',
1450 'SamsungBrowser',
1451 ];
1452 $browser_list[] = ['Documents App', 'RDDocuments/', '/RDDocuments\/([0-9]+\.[0-9]+)/', '1', ''];
1453 $browser_list[] = ['Opera Coast', 'Coast/', '/Coast\/([0-9]+)/', '1', ''];
1454 $browser_list[] = [
1455 'Android Browser',
1456 '/Android.*Version\/[.0-9]+\s(?:Mobile\s)?Safari(|\/[.0-9]+\sCyanogenMod.*)+$/',
1457 '/Android.*Version\/([0-9]+\.[0-9]+)/',
1458 '1',
1459 'Chrome/',
1460 ];
1461 $browser_list[] = ['Playstation Browser', '/(PlayStation\s|PLAYSTATION\s)/', '/(PlayStation\s|PLAYSTATION\s)/', '1', ''];
1462 $browser_list[] = ['Naver App', 'NAVER(inapp;', '/NAVER\(inapp;\ssearch;\s\d+;\s([0-9]+\.[0-9]+)/', '1', ''];
1463 $browser_list[] = ['Line App', ' Line/', '/\sLine\/([0-9]+\.[0-9]+)/', '1', ''];
1464 $browser_list[] = ['QQ App', ' QQ/', '/\sQQ\/([0-9]+\.[0-9]+)/', '1', ''];
1465 $browser_list[] = ['GNews App', ' GNews ', '/\sGNews\s.*\/([0-9]+\.[0-9]+)/', '1', ''];
1466 $browser_list[] = ['1Password App', '1Password', '/\s1Password\/([0-9]+\.[0-9]+)/', '1', ''];
1467 $browser_list[] = ['Pinterest App', 'Pinterest', '/Pinterest/', '1', ''];
1468 $browser_list[] = ['Twitter App', ' Twitter', '/Twitter/', '1', ''];
1469 $browser_list[] = ['Ali App', ' AliApp', '/\sAliApp/', '1', ''];
1470 $browser_list[] = ['Alipay', 'AlipayClient', '/AlipayClient\/([0-9]+\.[0-9]+)/', '1', ''];
1471 $browser_list[] = ['Samsung CrossApp', 'CrossApp/', '/CrossApp\/([0-9]+\.[0-9]+)/', '1', ''];
1472 $browser_list[] = ['Diigo', 'DiigoBrowser', '/DiigoBrowser/', '1', ''];
1473 $browser_list[] = ['Stargon', 'Stargon/', '/Stargon\/([0-9]+\.[0-9]+)/', '1', ''];
1474 $browser_list[] = ['You Browser', 'YouBrowser/', '/YouBrowser\/([0-9]+\.[0-9]+)/', '1', ''];
1475 $browser_list[] = ['Max Browser', 'MaxBrowser/', '/MaxBrowser\/([0-9]+)/', '1', ''];
1476 $browser_list[] = ['Soul Browser', 'Soul/', '/Soul\/([0-9]+)/', '1', ''];
1477
1478 foreach ($browser_list as $browser_list_va) {
1479 $match = $browser_list_va[1];
1480 $match_exclude = $browser_list_va[4];
1481
1482 // Some OS specified browsers matching optimization
1483
1484 $current_browser_continue = true;
1485 if ($this->get_mode !== 'browser') {
1486 $current_browser = $browser_list_va[0];
1487
1488 // Some iOS specified browsers matching optimization
1489
1490 if ($current_browser === 'Safari Mobile' || $current_browser === 'Firefox iOS') {
1491 if ($this->result_os_name !== 'iOS') $current_browser_continue = false;
1492 }
1493
1494 // Some Android specified browsers matching optimization
1495
1496 if ($current_browser === 'Android Browser' || $current_browser === 'Samsung Browser' || $current_browser === 'Huawei Browser') {
1497 if ($this->result_os_name !== 'Android') $current_browser_continue = false;
1498 }
1499
1500 // WP specified browser matching optimization
1501
1502 if ($current_browser === 'Internet Explorer Mobile' && $this->result_os_name !== 'Windows Phone' && $this->result_os_name !== 'Windows Mobile') $current_browser_continue = false;
1503
1504 // Tizen specified browser matching optimization
1505
1506 if ($current_browser === 'Tizen Browser' && $this->result_os_name !== 'Tizen') $current_browser_continue = false;
1507
1508 // BlackBerry specified browser matching optimization
1509
1510 if ($current_browser === 'BlackBerry Browser' && $this->result_os_name !== 'BlackBerry') $current_browser_continue = false;
1511
1512 // Google App matching optimization
1513
1514 if ($current_browser === 'Google App' && !$this->match_ua(' GSA/')) $current_browser_continue = false;
1515 }
1516
1517 if ($current_browser_continue == true && $this->match_ua($match) && !$this->match_ua($match_exclude)) {
1518 $this->result_browser_version = 0;
1519 $this->result_browser_name = $browser_list_va[0];
1520 $matches = $this->match_ua($browser_list_va[2]);
1521 $matches_n = intval($browser_list_va[3]);
1522
1523 if (is_array($matches)) {
1524 if ($this->result_browser_name === 'Safari Mobile' && strpos($matches[$matches_n], '_') !== false) {
1525 $matches[$matches_n] = str_replace(
1526 '_',
1527 '.',
1528 $matches[$matches_n]
1529 );
1530 }
1531 $this->result_browser_version = (float)$matches[$matches_n];
1532 } else {
1533 $this->result_browser_version = 0;
1534 }
1535
1536 if (!empty($this->result_browser_version)) {
1537 $browser_need_continue = false;
1538 break;
1539 }
1540 }
1541 }
1542
1543 $browser_list = null;
1544 // End of mobile browsers detection
1545 }
1546
1547 // Other browsers without version specified
1548
1549 if ($browser_need_continue) {
1550 $other_bsr = [];
1551
1552 $other_bsr[] = ['Maple' => 'Maple'];
1553 $other_bsr[] = ['Espial' => 'Espial'];
1554
1555 foreach ($other_bsr as $other_bsr_va) {
1556 $k = key($other_bsr_va);
1557 $v = $other_bsr_va[$k];
1558
1559 if ($this->match_ua($v)) {
1560 $this->result_browser_version = 0;
1561 $this->result_browser_name = $k;
1562 $this->result_browser_title = $k;
1563 break;
1564 }
1565 }
1566 $other_bsr = null;
1567 }
1568
1569 // MacOS and iOS Apps
1570
1571 if ($this->result_browser_name === 'unknown' && $this->match_ua('CFNetwork/') && $this->match_ua('Darwin/') && !$this->match_ua('Safari/')) {
1572 $matches = $this->match_ua('/^(.*)(\/[.0-9]+|\s\(unknown\sversion\))(.*)\sCFNetwork\/[.0-9]+\sDarwin\/[.0-9]+/');
1573 if (!empty($matches[1])) {
1574 $matches[1] = str_replace('%20', ' ', $matches[1]);
1575 $matches[1] = str_replace('com.apple.Safari.', '', $matches[1]);
1576 $matches[1] = str_replace('com.apple.WebKit.', '', $matches[1]);
1577 $matches[1] = str_replace('com.apple.Notes.', '', $matches[1]);
1578 $matches[1] = str_replace('com.apple.mobilenotes.', '', $matches[1]);
1579 $this->result_browser_name = $matches[1].' App';
1580 if ($this->result_browser_name === 'Browser App') $this->result_browser_name = 'Darwin Browser';
1581 $darwin_app = true;
1582 }
1583 }
1584
1585 /*
1586 -------------------
1587 WebView detection
1588 -------------------
1589 */
1590
1591 if ($this->result_mobile == 1) {
1592 // Android WebView
1593
1594 if ($this->result_os_name === 'Android') {
1595 if ($this->match_ua('; wv|;FB|FB_IAB|OKApp|DuckDuckGo')) $this->result_browser_android_webview = 1;
1596 if ($this->result_browser_chrome_original == 0 && $this->result_browser_chromium_version != 0 && $this->match_ua(
1597 '/like\sGecko\)\sVersion\/[.0-9]+\sChrome\/[.0-9]+\s/'
1598 )) {
1599 $this->result_browser_android_webview = 1;
1600 }
1601 }
1602
1603 // WKWebView
1604
1605 if ($this->result_ios) {
1606 $webkit_webview = false;
1607
1608 if ($this->match_ua(
1609 '/\s\((iPhone|iphone|iPad|iPod);.*\)\sAppleWebKit\/[.0-9]+\s\(KHTML\,\slike Gecko\)\s(?!CriOS|FxiOS|OPiOS|EdgiOS)(?!Version).*Mobile\/([0-9A-Z]+)/'
1610 )) {
1611 $webkit_webview = true;
1612 }
1613 if ($this->result_browser_name === 'unknown' && $this->match_ua('MobileSafari/') && $this->match_ua('CFNetwork/')) $webkit_webview = true;
1614
1615 if ($webkit_webview) {
1616 $this->result_browser_ios_webview = 1;
1617
1618 if ($this->result_browser_name === 'unknown') {
1619 $this->result_browser_name = 'WKWebView';
1620 $this->result_browser_version = 0;
1621 }
1622 }
1623 }
1624 }
1625
1626 /*
1627 -------------------------
1628 Detect Safari original
1629 -------------------------
1630 */
1631
1632 if ($this->result_browser_name === 'Safari' || $this->result_browser_name === 'Safari Mobile') {
1633 if ($this->match_ua('/AppleWebKit\/[.0-9]+.*Gecko\)\sVersion\/[.0-9].*Safari\/[.0-9A-Za-z]+$/')) $this->result_browser_safari_original = 1;
1634 }
1635
1636 // Check and correct browser version anomaly
1637
1638 if (intval($this->result_browser_version) > 200 && !$this->match_ua('FBAV/|FBSV/|GSA/|Instagram')) $this->result_browser_version = 0;
1639
1640 // Set Browser title
1641
1642 if (!empty($this->result_browser_version)) {
1643 $this->result_browser_title = $this->result_browser_name.' '.$this->result_browser_version;
1644 } else {
1645 $this->result_browser_title = $this->result_browser_name.' (unknown version)';
1646
1647 $browsers_without_versions = [];
1648 $browsers_without_versions[] = 'Android Browser';
1649 $browsers_without_versions[] = 'WKWebView';
1650 $browsers_without_versions[] = 'Safari SDK';
1651 $browsers_without_versions[] = 'Playstation Browser';
1652 $browsers_without_versions[] = 'OmniWeb';
1653 $browsers_without_versions[] = 'Steam Client';
1654 $browsers_without_versions[] = 'Steam Overlay';
1655 $browsers_without_versions[] = 'Maple';
1656 $browsers_without_versions[] = 'Espial';
1657 $browsers_without_versions[] = 'Diigo Browser';
1658 $browsers_without_versions[] = 'IceWeasel';
1659 $browsers_without_versions[] = 'Iceweasel';
1660 $browsers_without_versions[] = 'Facebook App';
1661 $browsers_without_versions[] = 'Twitter App';
1662 $browsers_without_versions[] = 'Bing App';
1663 $browsers_without_versions[] = 'Pinterest App';
1664 $browsers_without_versions[] = 'Ali App';
1665 $browsers_without_versions[] = 'Alipay App';
1666 $browsers_without_versions[] = 'Lunascape';
1667
1668 if (in_array($this->result_browser_name, $browsers_without_versions) || isset($darwin_app)) {
1669 $this->result_browser_title = $this->result_browser_name;
1670 }
1671
1672 $browsers_without_versions = null;
1673 }
1674
1675 if (strpos($this->result_browser_name, 'unknown') !== false) $this->result_browser_title = 'unknown';
1676 if ($this->result_browser_version == null) $this->result_browser_version = 0;
1677
1678 // EdgeHTML browser should not be detected as a Chromium engine
1679 if ($this->result_browser_name === 'Edge' && $this->result_browser_version >= 12 && $this->result_browser_version <= 18) $this->result_browser_chromium_version = 0;
1680
1681 if ($this->get_mode === 'browser') return null;
1682
1683 /*
1684 ---------------------
1685 Detect device types
1686 ---------------------
1687 */
1688
1689 // Desktop
1690
1691 if ($this->result_os_family !== 'unknown' && $this->result_os_type !== 'mixed') $this->result_device_type = 'desktop';
1692
1693 // Mobile
1694
1695 if ($this->result_mobile == 1) $this->result_device_type = 'mobile';
1696
1697 // TV
1698
1699 if ($this->match_ua(
1700 'TV|HDMI|CrKey| Escape |Kylo/|SmartLabs|SC/IHD|Viera|BRAVIA|NetCast|Roku/DVP| Roku |Maple|DuneHD|CE-HTML|EIS iPanel|Sunniwell; Resolution|Freebox|Netbox|Netgem|AFTT|AFTM|AFTB|DLNADOC| iconBIT |olleh tv|stbapp |; MIBOX|ABOX-I|; H96 |; X96|HX S905|; M8S |MINIM8S|MXIII-|; NEO-X|; NEO-U| Nexus Player |TPM171E|; V88 |MXQPRO|NEXBOX-|; Leelbox|ZIDOO|; A95X| Beelink |; T95Z|; TX3 '
1701 ) && !$this->match_ua('BTV-')) {
1702 $this->result_device_type = 'tv';
1703 }
1704
1705 // Console
1706
1707 if ($this->matchi_ua('playstation') || $this->match_ua('Xbox|GAMEPAD|Nintendo|OUYA|; SHIELD Build')) $this->result_device_type = 'console';
1708
1709 // MediaPlayer
1710
1711 if ($this->match_ua('iPod|AlexaMediaPlayer|AppleCoreMedia')) $this->result_device_type = 'mediaplayer';
1712
1713 // Car
1714
1715 if ($this->match_ua('CarBrowser|Tesla/')) $this->result_device_type = 'car';
1716
1717 // Watch
1718
1719 if ($this->matchi_ua('watch') && !$this->match_ua('AirWatch')) $this->result_device_type = 'watch';
1720
1721 if ($this->get_mode === 'device') return null;
1722
1723 /*
1724 ---------------------------------------------
1725 Detect 64bits mode (browser + OS specified)
1726 ---------------------------------------------
1727 */
1728
1729 if ($this->result_os_name === 'MacOS' && $this->macos_version_minor >= 6) {
1730 if ($this->result_browser_name === 'Safari' || $this->result_browser_name === 'Safari SDK') $this->result_64bits_mode = 1;
1731 }
1732
1733 /*
1734 ---------------------------------------------------------
1735 MacOS Big Sur + Firefox version > 86 detection feature
1736 ---------------------------------------------------------
1737 */
1738
1739 if ($this->result_os_name === 'MacOS' && $this->macos_version_minor == 15 && $this->result_browser_name === 'Firefox' && $this->result_browser_version > 86) {
1740 $this->result_os_version = 'Big Sur';
1741 $this->result_os_title = 'MacOS '.$this->result_os_version;
1742 }
1743
1744 return null;
1745 }
1746
1747 /**
1748 * The method returns all possible environment data from User-Agent
1749 *
1750 * @param string $ua The User-Agent string
1751 * @param string $result_format If specified, method returns result as JSON
1752 *
1753 * @return mixed Returns User-Agent parsing result as array or JSON string (optional)
1754 */
1755
1756 public function getAll($ua, $result_format = '')
1757 {
1758 $this->useragent = trim($ua);
1759 $this->get_mode = 'all';
1760 $this->resetProperties();
1761 $this->getResult();
1762 $result = [
1763 'os_type' => $this->result_os_type,
1764 'os_family' => $this->result_os_family,
1765 'os_name' => $this->result_os_name,
1766 'os_version' => $this->result_os_version,
1767 'os_title' => $this->result_os_title,
1768 'device_type' => $this->result_device_type,
1769 'browser_name' => $this->result_browser_name,
1770 'browser_version' => $this->result_browser_version,
1771 'browser_title' => $this->result_browser_title,
1772 'browser_chrome_original' => $this->result_browser_chrome_original,
1773 'browser_firefox_original' => $this->result_browser_firefox_original,
1774 'browser_safari_original' => $this->result_browser_safari_original,
1775 'browser_chromium_version' => $this->result_browser_chromium_version,
1776 'browser_gecko_version' => $this->result_browser_gecko_version,
1777 'browser_webkit_version' => $this->result_browser_webkit_version,
1778 'browser_android_webview' => $this->result_browser_android_webview,
1779 'browser_ios_webview' => $this->result_browser_ios_webview,
1780 'browser_desktop_mode' => $this->result_browser_desktop_mode,
1781 '64bits_mode' => $this->result_64bits_mode,
1782 ];
1783
1784 if (strtolower($result_format) === 'json') $result = json_encode($result);
1785 $this->touch_support_mode = false;
1786
1787 return $result;
1788 }
1789
1790 /**
1791 * The method returns OS data from User-Agent
1792 *
1793 * @param string $ua The User-Agent string
1794 * @param string $result_format If specified, method returns result as JSON
1795 *
1796 * @return mixed Returns User-Agent parsing result as array or JSON string (optional)
1797 */
1798
1799 public function getOS($ua, $result_format = '')
1800 {
1801 $this->useragent = trim($ua);
1802 $this->get_mode = 'os';
1803 $this->resetProperties();
1804 $this->getResult();
1805 $result = [
1806 'os_type' => $this->result_os_type,
1807 'os_family' => $this->result_os_family,
1808 'os_name' => $this->result_os_name,
1809 'os_version' => $this->result_os_version,
1810 'os_title' => $this->result_os_title,
1811 '64bits_mode' => $this->result_64bits_mode,
1812 ];
1813
1814 if (strtolower($result_format) === 'json') $result = json_encode($result);
1815 $this->touch_support_mode = false;
1816
1817 return $result;
1818 }
1819
1820 /**
1821 * The method returns Browser data from User-Agent
1822 *
1823 * @param string $ua The User-Agent string
1824 * @param string $result_format If specified, method returns result as JSON
1825 *
1826 * @return mixed Returns User-Agent parsing result as array or JSON string (optional)
1827 */
1828
1829 public function getBrowser($ua, $result_format = '')
1830 {
1831 $this->useragent = trim($ua);
1832 $this->get_mode = 'browser';
1833 $this->resetProperties();
1834 $this->getResult();
1835 $result = [
1836 'browser_name' => $this->result_browser_name,
1837 'browser_version' => $this->result_browser_version,
1838 'browser_title' => $this->result_browser_title,
1839 'browser_chrome_original' => $this->result_browser_chrome_original,
1840 'browser_firefox_original' => $this->result_browser_firefox_original,
1841 'browser_safari_original' => $this->result_browser_safari_original,
1842 'browser_chromium_version' => $this->result_browser_chromium_version,
1843 'browser_gecko_version' => $this->result_browser_gecko_version,
1844 'browser_webkit_version' => $this->result_browser_webkit_version,
1845 'browser_android_webview' => $this->result_browser_android_webview,
1846 'browser_ios_webview' => $this->result_browser_ios_webview,
1847 'browser_desktop_mode' => $this->result_browser_desktop_mode,
1848 ];
1849
1850 if (strtolower($result_format) === 'json') $result = json_encode($result);
1851 $this->touch_support_mode = false;
1852
1853 return $result;
1854 }
1855
1856 /**
1857 * The method returns Device Type data from User-Agent
1858 *
1859 * @param string $ua The User-Agent string
1860 * @param string $result_format If specified, method returns result as JSON
1861 *
1862 * @return mixed Returns User-Agent parsing result as array or JSON string (optional)
1863 */
1864
1865 public function getDevice($ua, $result_format = '')
1866 {
1867 $this->useragent = trim($ua);
1868 $this->get_mode = 'device';
1869 $this->resetProperties();
1870 $this->getResult();
1871 $result = ['device_type' => $this->result_device_type];
1872
1873 if (strtolower($result_format) === 'json') $result = json_encode($result);
1874 $this->touch_support_mode = false;
1875
1876 return $result;
1877 }
1878
1879 /**
1880 * This method is needed to detect mobile browsers in Desktop Mode (Android and iOS)
1881 * The method should call if browser supports Touch events (client-side JS detection is necessary)
1882 *
1883 * @return null
1884 */
1885
1886 public function setTouchSupport()
1887 {
1888 $this->touch_support_mode = true;
1889
1890 return null;
1891 }
1892 }
1893