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 BrowserDetector.php |
34
|
|
|
* |
35
|
|
|
* The browser 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\Browser; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Class BrowserDetector |
54
|
|
|
* @package Platine\UserAgent\Detector |
55
|
|
|
*/ |
56
|
|
|
class BrowserDetector extends AbstractDetector |
57
|
|
|
{ |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
|
|
public function __construct() |
63
|
|
|
{ |
64
|
|
|
parent::__construct(); |
65
|
|
|
|
66
|
|
|
$this->entity = new Browser(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
|
|
public function maps(): array |
73
|
|
|
{ |
74
|
|
|
return [ |
75
|
|
|
'oldsafari' => [ |
76
|
|
|
'version' => [ |
77
|
|
|
'1.0' => '/8', |
78
|
|
|
'1.2' => '/1', |
79
|
|
|
'1.3' => '/3', |
80
|
|
|
'2.0' => '/412', |
81
|
|
|
'2.0.2' => '/416', |
82
|
|
|
'2.0.3' => '/417', |
83
|
|
|
'2.0.4' => '/419', |
84
|
|
|
'?' => '/' |
85
|
|
|
] |
86
|
|
|
] |
87
|
|
|
]; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritdoc} |
92
|
|
|
*/ |
93
|
|
|
public function regex(): array |
94
|
|
|
{ |
95
|
|
|
return [ |
96
|
|
|
[ |
97
|
|
|
|
98
|
|
|
// Presto based |
99
|
|
|
'/(opera\smini)\/([\w\.-]+)/i', // Opera Mini |
100
|
|
|
'/(opera\s[mobiletab]+).+version\/([\w\.-]+)/i', // Opera Mobi/Tablet |
101
|
|
|
'/(opera).+version\/([\w\.]+)/i', // Opera > 9.80 |
102
|
|
|
'/(opera)[\/\s]+([\w\.]+)/i' // Opera < 9.80 |
103
|
|
|
], [self::NAME, self::VERSION], [ |
104
|
|
|
|
105
|
|
|
'/(opios)[\/\s]+([\w\.]+)/i' // Opera mini on iphone >= 8.0 |
106
|
|
|
], [[self::NAME, 'Opera Mini'], self::VERSION], [ |
107
|
|
|
|
108
|
|
|
'/\s(opr)\/([\w\.]+)/i' // Opera Webkit |
109
|
|
|
], [[self::NAME, 'Opera'], self::VERSION], [ |
110
|
|
|
|
111
|
|
|
// Mixed |
112
|
|
|
'/(kindle)\/([\w\.]+)/i', // Kindle |
113
|
|
|
'/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i', |
114
|
|
|
// Lunascape/Maxthon/Netfront/Jasmine/Blazer |
115
|
|
|
|
116
|
|
|
// Trident based |
117
|
|
|
'/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?([\w\.]*)/i', |
118
|
|
|
// Avant/IEMobile/SlimBrowser/Baidu |
119
|
|
|
'/(?:ms|\()(ie)\s([\w\.]+)/i', // Internet Explorer |
120
|
|
|
|
121
|
|
|
// Webkit/KHTML based |
122
|
|
|
'/(rekonq)\/([\w\.]*)/i', // Rekonq |
123
|
|
|
'/(Instagram)\s([\w\.]+)/i', // Instagram inApp Browser |
124
|
|
|
'/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i' |
125
|
|
|
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon |
126
|
|
|
], [self::NAME, self::VERSION], [ |
127
|
|
|
|
128
|
|
|
'/(konqueror)\/([\w\.]+)/i' // Konqueror |
129
|
|
|
], [[self::NAME, 'Konqueror'], self::VERSION], [ |
130
|
|
|
|
131
|
|
|
'/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i' // IE11 |
132
|
|
|
], [[self::NAME, 'IE'], self::VERSION], [ |
133
|
|
|
|
134
|
|
|
'/(edge|edgios|edga|edg)\/((\d+)?[\w\.]+)/i' // Microsoft Edge |
135
|
|
|
], [[self::NAME, 'Edge'], self::VERSION], [ |
136
|
|
|
|
137
|
|
|
'/(yabrowser)\/([\w\.]+)/i' // Yandex |
138
|
|
|
], [[self::NAME, 'Yandex'], self::VERSION], [ |
139
|
|
|
|
140
|
|
|
'/(puffin)\/([\w\.]+)/i' // Puffin |
141
|
|
|
], [[self::NAME, 'Puffin'], self::VERSION], [ |
142
|
|
|
|
143
|
|
|
'/(focus)\/([\w\.]+)/i' // Firefox Focus |
144
|
|
|
], [[self::NAME, 'Firefox Focus'], self::VERSION], [ |
145
|
|
|
|
146
|
|
|
'/(opt)\/([\w\.]+)/i' // Opera Touch |
147
|
|
|
], [[self::NAME, 'Opera Touch'], self::VERSION], [ |
148
|
|
|
|
149
|
|
|
'/((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i' // UCBrowser |
150
|
|
|
], [[self::NAME, 'UCBrowser'], self::VERSION], [ |
151
|
|
|
|
152
|
|
|
'/(comodo_dragon)\/([\w\.]+)/i' // Comodo Dragon |
153
|
|
|
], [[self::NAME, '/_/g', ' '], self::VERSION], [ |
154
|
|
|
|
155
|
|
|
'/(windowswechat qbcore)\/([\w\.]+)/i' // WeChat Desktop for Windows Built-in Browser |
156
|
|
|
], [[self::NAME, 'WeChat(Win) Desktop'], self::VERSION], [ |
157
|
|
|
|
158
|
|
|
'/(micromessenger)\/([\w\.]+)/i' // WeChat |
159
|
|
|
], [[self::NAME, 'WeChat'], self::VERSION], [ |
160
|
|
|
|
161
|
|
|
'/(brave)\/([\w\.]+)/i' // Brave browser |
162
|
|
|
], [[self::NAME, 'Brave'], self::VERSION], [ |
163
|
|
|
|
164
|
|
|
'/(qqbrowserlite)\/([\w\.]+)/i' // QQBrowserLite |
165
|
|
|
], [self::NAME, self::VERSION], [ |
166
|
|
|
|
167
|
|
|
'/(QQ)\/([\d\.]+)/i' // QQ, aka ShouQ |
168
|
|
|
], [self::NAME, self::VERSION], [ |
169
|
|
|
|
170
|
|
|
'/m?(qqbrowser)[\/\s]?([\w\.]+)/i' // QQBrowser |
171
|
|
|
], [self::NAME, self::VERSION], [ |
172
|
|
|
|
173
|
|
|
'/(BIDUBrowser)[\/\s]?([\w\.]+)/i' // Baidu Browser |
174
|
|
|
], [self::NAME, self::VERSION], [ |
175
|
|
|
|
176
|
|
|
'/(2345Explorer)[\/\s]?([\w\.]+)/i' // 2345 Browser |
177
|
|
|
], [self::NAME, self::VERSION], [ |
178
|
|
|
|
179
|
|
|
'/(MetaSr)[\/\s]?([\w\.]+)/i' // SouGouBrowser |
180
|
|
|
], [self::NAME], [ |
181
|
|
|
|
182
|
|
|
'/(LBBROWSER)/i' // LieBao Browser |
183
|
|
|
], [self::NAME], [ |
184
|
|
|
|
185
|
|
|
'/xiaomi\/miuibrowser\/([\w\.]+)/i' // MIUI Browser |
186
|
|
|
], [self::VERSION, [self::NAME, 'MIUI Browser']], [ |
187
|
|
|
|
188
|
|
|
'/;(fbav)\/([\w\.]+);/i' // Facebook App for iOS & Android |
189
|
|
|
], [[self::NAME, 'Facebook'], self::VERSION], [ |
190
|
|
|
|
191
|
|
|
'/safari\s(line)\/([\w\.]+)/i', // Line App for iOS |
192
|
|
|
'/android.+(line)\/([\w\.]+)\/iab/i' // Line App for Android |
193
|
|
|
], [self::NAME, self::VERSION], [ |
194
|
|
|
|
195
|
|
|
'/headlesschrome(?:\/([\w\.]+)|\s)/i' // Chrome Headless |
196
|
|
|
], [self::VERSION, [self::NAME, 'Chrome Headless']], [ |
197
|
|
|
|
198
|
|
|
'/\swv\).+(chrome)\/([\w\.]+)/i' // Chrome WebView |
199
|
|
|
], [[self::NAME, '/(.+)/', '$1 WebView'], self::VERSION], [ |
200
|
|
|
|
201
|
|
|
'/((?:oculus|samsung)browser)\/([\w\.]+)/i' |
202
|
|
|
], [[self::NAME, "/(.+(?:g|us))(.+)/", '$1 $2'], self::VERSION], [ // Oculus / Samsung Browser |
203
|
|
|
|
204
|
|
|
'/android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i' // Android Browser |
205
|
|
|
], [self::VERSION, [self::NAME, 'Android Browser']], [ |
206
|
|
|
|
207
|
|
|
'/(sailfishbrowser)\/([\w\.]+)/i' // Sailfish Browser |
208
|
|
|
], [[self::NAME, 'Sailfish Browser'], self::VERSION], [ |
209
|
|
|
|
210
|
|
|
'/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i' |
211
|
|
|
// Chrome/OmniWeb/Arora/Tizen/Nokia |
212
|
|
|
], [self::NAME, self::VERSION], [ |
213
|
|
|
|
214
|
|
|
'/(dolfin)\/([\w\.]+)/i' // Dolphin |
215
|
|
|
], [[self::NAME, 'Dolphin'], self::VERSION], [ |
216
|
|
|
|
217
|
|
|
'/((?:android.+)crmo|crios)\/([\w\.]+)/i' // Chrome for Android/iOS |
218
|
|
|
], [[self::NAME, 'Chrome'], self::VERSION], [ |
219
|
|
|
|
220
|
|
|
'/(coast)\/([\w\.]+)/i' // Opera Coast |
221
|
|
|
], [[self::NAME, 'Opera Coast'], self::VERSION], [ |
222
|
|
|
|
223
|
|
|
'/fxios\/([\w\.-]+)/i' // Firefox for iOS |
224
|
|
|
], [self::VERSION, [self::NAME, 'Firefox']], [ |
225
|
|
|
|
226
|
|
|
'/version\/([\w\.]+).+?mobile\/\w+\s(safari)/i' // Mobile Safari |
227
|
|
|
], [self::VERSION, [self::NAME, 'Mobile Safari']], [ |
228
|
|
|
|
229
|
|
|
'/version\/([\w\.]+).+?(mobile\s?safari|safari)/i' // Safari & Safari Mobile |
230
|
|
|
], [self::VERSION, self::NAME], [ |
231
|
|
|
|
232
|
|
|
'/webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i' // Google Search Appliance on iOS |
233
|
|
|
], [[self::NAME, 'GSA'], self::VERSION], [ |
234
|
|
|
|
235
|
|
|
'/webkit.+?(mobile\s?safari|safari)(\/[\w]+)/i' // Safari < 3.0 |
236
|
|
|
], [self::NAME, [self::VERSION, '__str', 'oldsafari.version']], [ |
237
|
|
|
|
238
|
|
|
'/(webkit|khtml)\/([\w\.]+)/i' |
239
|
|
|
], [self::NAME, self::VERSION], [ |
240
|
|
|
|
241
|
|
|
// Gecko based |
242
|
|
|
'/(navigator|netscape)\/([\w\.-]+)/i' // Netscape |
243
|
|
|
], [[self::NAME, 'Netscape'], self::VERSION], [ |
244
|
|
|
'/(swiftfox)/i', // Swiftfox |
245
|
|
|
'/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i', |
246
|
|
|
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror |
247
|
|
|
'/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i', |
248
|
|
|
|
249
|
|
|
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix |
250
|
|
|
'/(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i', // Mozilla |
251
|
|
|
|
252
|
|
|
// Other |
253
|
|
|
'/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i', |
254
|
|
|
// Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir |
255
|
|
|
'/(links)\s\(([\w\.]+)/i', // Links |
256
|
|
|
'/(gobrowser)\/?([\w\.]*)/i', // GoBrowser |
257
|
|
|
'/(ice\s?browser)\/v?([\w\._]+)/i', // ICE Browser |
258
|
|
|
'/(mosaic)[\/\s]([\w\.]+)/i' // Mosaic |
259
|
|
|
], [self::NAME, self::VERSION], |
260
|
|
|
]; |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
|