|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Platine User Agent |
|
5
|
|
|
* |
|
6
|
|
|
* Platine User Agent is a lightweight library for detecting |
|
7
|
|
|
* user browser, device, OS, CPU |
|
8
|
|
|
* |
|
9
|
|
|
* This content is released under the MIT License (MIT) |
|
10
|
|
|
* |
|
11
|
|
|
* Copyright (c) 2020 Platine User Agent |
|
12
|
|
|
* |
|
13
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
14
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
15
|
|
|
* in the Software without restriction, including without limitation the rights |
|
16
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
17
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
18
|
|
|
* furnished to do so, subject to the following conditions: |
|
19
|
|
|
* |
|
20
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
21
|
|
|
* copies or substantial portions of the Software. |
|
22
|
|
|
* |
|
23
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
24
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
25
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
26
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
27
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
28
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
29
|
|
|
* SOFTWARE. |
|
30
|
|
|
*/ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @file OsDetector.php |
|
34
|
|
|
* |
|
35
|
|
|
* The Operating System detector class |
|
36
|
|
|
* |
|
37
|
|
|
* @package Platine\UserAgent\Detector |
|
38
|
|
|
* @author Platine Developers Team |
|
39
|
|
|
* @copyright Copyright (c) 2020 |
|
40
|
|
|
* @license http://opensource.org/licenses/MIT MIT License |
|
41
|
|
|
* @link http://www.iacademy.cf |
|
42
|
|
|
* @version 1.0.0 |
|
43
|
|
|
* @filesource |
|
44
|
|
|
*/ |
|
45
|
|
|
|
|
46
|
|
|
declare(strict_types=1); |
|
47
|
|
|
|
|
48
|
|
|
namespace Platine\UserAgent\Detector; |
|
49
|
|
|
|
|
50
|
|
|
use Platine\UserAgent\Entity\Os; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Class OsDetector |
|
54
|
|
|
* @package Platine\UserAgent\Detector |
|
55
|
|
|
*/ |
|
56
|
|
|
class OsDetector extends AbstractDetector |
|
57
|
|
|
{ |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
|
|
public function __construct() |
|
63
|
|
|
{ |
|
64
|
|
|
parent::__construct(); |
|
65
|
|
|
|
|
66
|
|
|
$this->entity = new Os(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* {@inheritdoc} |
|
72
|
|
|
*/ |
|
73
|
|
|
public function maps(): array |
|
74
|
|
|
{ |
|
75
|
|
|
return [ |
|
76
|
|
|
'windows' => [ |
|
77
|
|
|
'versions' => [ |
|
78
|
|
|
'ME' => '4.90', |
|
79
|
|
|
'NT 3.11' => 'NT3.51', |
|
80
|
|
|
'NT 4.0' => 'NT4.0', |
|
81
|
|
|
'2000' => 'NT 5.0', |
|
82
|
|
|
'XP' => ['NT 5.1', 'NT 5.2'], |
|
83
|
|
|
'Vista' => 'NT 6.0', |
|
84
|
|
|
'7' => 'NT 6.1', |
|
85
|
|
|
'8' => 'NT 6.2', |
|
86
|
|
|
'8.1' => 'NT 6.3', |
|
87
|
|
|
'10' => ['NT 6.4', 'NT 10.0'], |
|
88
|
|
|
'RT' => 'ARM' |
|
89
|
|
|
] |
|
90
|
|
|
] |
|
91
|
|
|
]; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* {@inheritdoc} |
|
96
|
|
|
*/ |
|
97
|
|
|
public function regex(): array |
|
98
|
|
|
{ |
|
99
|
|
|
return [ |
|
100
|
|
|
[ |
|
101
|
|
|
|
|
102
|
|
|
// Windows based |
|
103
|
|
|
'/microsoft\s(windows)\s(vista|xp)/i' // Windows (iTunes) |
|
104
|
|
|
], [self::NAME, self::VERSION], [ |
|
105
|
|
|
'/(windows)\snt\s6\.2;\s(arm)/i', // Windows RT |
|
106
|
|
|
'/(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i', // Windows Phone |
|
107
|
|
|
'/(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i' |
|
108
|
|
|
], [self::NAME, [self::VERSION, '__str', 'windows.versions']], [ |
|
109
|
|
|
'/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i' |
|
110
|
|
|
], [[self::NAME, 'Windows'], [self::VERSION, '__str', 'windows.version']], [ |
|
111
|
|
|
|
|
112
|
|
|
// Mobile/Embedded OS |
|
113
|
|
|
'/\((bb)(10);/i' // BlackBerry 10 |
|
114
|
|
|
], [[self::NAME, 'BlackBerry'], self::VERSION], [ |
|
115
|
|
|
'/(blackberry)\w*\/?([\w\.]*)/i', // Blackberry |
|
116
|
|
|
'/(tizen)[\/\s]([\w\.]+)/i', // Tizen |
|
117
|
|
|
'/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|sailfish|contiki)[\/\s-]?([\w\.]*)/i' |
|
118
|
|
|
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki/Sailfish OS |
|
119
|
|
|
], [self::NAME, self::VERSION], [ |
|
120
|
|
|
'/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i' // Symbian |
|
121
|
|
|
], [[self::NAME, 'Symbian'], self::VERSION], [ |
|
122
|
|
|
'/\((series40);/i' // Series 40 |
|
123
|
|
|
], [self::NAME], [ |
|
124
|
|
|
'/mozilla.+\(mobile;.+gecko.+firefox/i' // Firefox OS |
|
125
|
|
|
], [[self::NAME, 'Firefox OS'], self::VERSION], [ |
|
126
|
|
|
|
|
127
|
|
|
// Console |
|
128
|
|
|
'/(nintendo|playstation)\s([wids34portablevu]+)/i', // Nintendo/Playstation |
|
129
|
|
|
|
|
130
|
|
|
// GNU/Linux based |
|
131
|
|
|
'/(mint)[\/\s\(]?(\w*)/i', // Mint |
|
132
|
|
|
'/(mageia|vectorlinux)[;\s]/i', // Mageia/VectorLinux |
|
133
|
|
|
'/(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i', |
|
134
|
|
|
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware |
|
135
|
|
|
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus |
|
136
|
|
|
'/(hurd|linux)\s?([\w\.]*)/i', // Hurd/Linux |
|
137
|
|
|
'/(gnu)\s?([\w\.]*)/i' // GNU |
|
138
|
|
|
], [self::NAME, self::VERSION], [ |
|
139
|
|
|
|
|
140
|
|
|
'/(cros)\s[\w]+\s([\w\.]+\w)/i' // Chromium OS |
|
141
|
|
|
], [[self::NAME, 'Chromium OS'], self::VERSION], [ |
|
142
|
|
|
|
|
143
|
|
|
// Solaris |
|
144
|
|
|
'/(sunos)\s?([\w\.\d]*)/i' // Solaris |
|
145
|
|
|
], [[self::NAME, 'Solaris'], self::VERSION], [ |
|
146
|
|
|
|
|
147
|
|
|
// BSD based |
|
148
|
|
|
'/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i' // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly |
|
149
|
|
|
], [self::NAME, self::VERSION], [ |
|
150
|
|
|
|
|
151
|
|
|
'/(haiku)\s(\w+)/i' // Haiku |
|
152
|
|
|
], [self::NAME, self::VERSION], [ |
|
153
|
|
|
|
|
154
|
|
|
'/cfnetwork\/.+darwin/i', |
|
155
|
|
|
'/ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i' // iOS |
|
156
|
|
|
], [[self::VERSION, '/_/', '.'], [self::NAME, 'iOS']], [ |
|
157
|
|
|
|
|
158
|
|
|
'/(mac\sos\sx)\s?([\w\s\.]*)/i', |
|
159
|
|
|
'/(macintosh|mac(?=_powerpc)\s)/i' // Mac OS |
|
160
|
|
|
], [[self::NAME, 'Mac OS'], [self::VERSION, '/_/', '.']], [ |
|
161
|
|
|
|
|
162
|
|
|
// Other |
|
163
|
|
|
'/((?:open)?solaris)[\/\s-]?([\w\.]*)/i', // Solaris |
|
164
|
|
|
'/(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i', // AIX |
|
165
|
|
|
'/(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms|fuchsia)/i', |
|
166
|
|
|
// Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS/Fuchsia |
|
167
|
|
|
'/(unix)\s?([\w\.]*)/i' // UNIX |
|
168
|
|
|
], [self::NAME, self::VERSION] |
|
169
|
|
|
]; |
|
170
|
|
|
} |
|
171
|
|
|
} |
|
172
|
|
|
|