2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
8 // get user agent and tell us what Browser is accessing
10 // function __construct([$ua_string])
11 // CONSTRUCTOR; reads UA string (or takes the optional given UA string) and gets info from that into our variables.
14 // the plain User Agent string
16 // the User Agent brand name
18 // the User Agent version
20 // bool: true if this agent is a bot
22 // bool: true if this agent is a mobile phone
24 // array of static user agent data (static vars in functions are set for all objects of this class!)
26 // public function getBrand()
27 // returns the User Agent Brand Name
29 // public function getVersion()
30 // returns the User Agent version
32 // public function getAcceptLanguages()
33 // returns an associated array with the accepted languages of this UA
34 // keys are language codes, values are q factors (weights)
36 // public function getUAString()
37 // returns the full User Agent string
39 // public function getEngine()
40 // returns a string telling the detected rendering engine, null if we can't detect
41 // one of gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|unknown
43 // public function hasEngine($rnd_engine)
44 // returns true if the given rendering engine was detected
46 // public function getEngineVersion()
47 // returns a the version number for the rendering engine
48 // this may be the same as getVersion() for many engines, or null if we don't know
50 // public function getOS()
51 // returns a string telling the detected operating system, null if we can't detect
52 // might be very verbose, uses no abbreviations for most names
54 // public function getPlatform()
55 // returns a string telling the detected OS platform, null if we can't detect
56 // one of windows|linux|mac|solaris|unknown
58 // public function getLanguage() {
59 // returns a string telling the detected browser UI language, null if we can't detect
60 // should be an ISO code
62 // public function isBot()
63 // returns true if User Agent seems to be a bot
65 // public function isMobile()
66 // returns true if User Agent seems to be a mobile phone
68 // *** functions that only return useable info for some agents ***
70 // public function getGeckoDate()
71 // returns the Gecko date for Gecko-based browsers, null for others
73 // public function getGeckoTime()
74 // returns the Gecko build date/time as a unix epoch time number for Gecko-based browsers, null for others
76 // *** functions for compat to older versions of this class ***
78 // public function isns()
79 // returns true if User Agent seems to be Netscape brand, false if not
80 // public function isns4()
81 // returns true if User Agent seems to be Netscape Communicator 4.x, false if not
82 // public function isie()
83 // returns true if User Agent seems to be a version of Internet Exploder, false if not
84 // public function geckobased()
85 // returns true if User Agent seems to be a Gecko-based browser, false if not
86 // public function geckodate()
87 // returns the Gecko date when it's a Gecko-based browser, 0 if not
88 // public function khtmlbased()
89 // returns true if User Agent seems to be a KHTML-based browser, false if not
91 // collection of some known User Agent Strings:
92 // *** see testbed/ua_list_raw.txt ***
93 // *** see also http://www.pgts.com.au/pgtsj/pgtsj0208c.html ***
99 private $mobile = false;
100 private $uadata = [];
102 function __construct($ua_string = '') {
103 // *** constructor ***
104 if (strlen($ua_string)) {
105 $this->uastring = $ua_string;
108 // read raw UA string
109 $this->uastring = $_SERVER['HTTP_USER_AGENT'];
112 // get UA brand and version
113 $this->brand = 'Unknown'; $this->version = null;
114 // find reasonable defaults
115 if (preg_match('|([0-9a-zA-Z\.:()_ -]+)/(\d[0-9a-zA-Z\._+-]*)|', $this->uastring, $regs)) {
116 $this->brand = trim($regs[1]);
117 $this->version = $regs[2];
119 elseif (preg_match('|^([a-zA-Z\._ -]+)[_ -][vV]?(\d[0-9a-zA-Z\.+]*)|', $this->uastring, $regs)) {
120 $this->brand = trim($regs[1]);
121 $this->version = $regs[2];
123 elseif (preg_match('|^([0-9a-zA-Z\._ -]+)|', $this->uastring, $regs)) {
124 $this->brand = trim($regs[1]);
125 $this->version = null;
127 $this->bot = (strpos(strtolower($this->brand), 'bot') !== false)
128 || (strpos(strtolower($this->brand), 'crawler') !== false)
129 || (strpos(strtolower($this->brand), 'spider') !== false)
130 || (strpos(strtolower($this->brand), 'search') !== false)
131 || (strpos(strtolower($this->brand), 'seek') !== false);
133 // search for any real and/or special UAs
134 if (preg_match('|Netscape6/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
135 $this->brand = 'Netscape';
136 $this->version = $regs[1];
139 elseif (preg_match('|Netscape/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
140 $this->brand = 'Netscape';
141 $this->version = $regs[1];
144 elseif (preg_match('|Navigator/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
145 $this->brand = 'Netscape';
146 $this->version = $regs[1];
149 elseif (preg_match('|Chimera/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
150 $this->brand = 'Chimera';
151 $this->version = $regs[1];
154 elseif (preg_match('|Camino/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
155 $this->brand = 'Camino';
156 $this->version = $regs[1];
159 elseif (preg_match('|Phoenix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
160 $this->brand = 'Phoenix';
161 $this->version = $regs[1];
164 elseif (preg_match('|Mozilla Firebird/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
165 $this->brand = 'Mozilla Firebird';
166 $this->version = $regs[1];
169 elseif (preg_match('|Flock/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
170 $this->brand = 'Flock';
171 $this->version = $regs[1];
174 elseif (preg_match('|SeaMonkey/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
175 $this->brand = 'SeaMonkey';
176 $this->version = $regs[1];
179 elseif (preg_match('|Iceape/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
180 $this->brand = 'IceApe'; // Debian-rebranded SeaMonkey
181 $this->version = $regs[1];
184 elseif (preg_match('|Iceweasel/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
185 $this->brand = 'IceWeasel'; // Debian-rebranded Firefox
186 $this->version = $regs[1];
189 elseif (preg_match('|Icedove/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
190 $this->brand = 'IceDove'; // Debian-rebranded Thunderbird
191 $this->version = $regs[1];
194 elseif (preg_match('|BonEcho/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
195 $this->brand = 'Bon Echo'; // Firefox 2.0 code name
196 $this->version = $regs[1];
199 elseif (preg_match('|GranParadiso/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
200 $this->brand = 'Gran Paradiso'; // Firefox 3.0 code name
201 $this->version = $regs[1];
204 elseif (preg_match('|Shiretoko/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
205 $this->brand = 'Shiretoko'; // Firefox 3.5 code name
206 $this->version = $regs[1];
209 elseif (preg_match('|Namoroka/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
210 $this->brand = 'Namoroka'; // Firefox 3.6 code name
211 $this->version = $regs[1];
214 elseif (preg_match('|Lorentz/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
215 $this->brand = 'Lorentz'; // Firefox 3.6 (with OOPP) code name
216 $this->version = $regs[1];
219 elseif (preg_match('|Minefield/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
220 $this->brand = 'Minefield'; // Firefox development nightly code name
221 $this->version = $regs[1];
224 elseif (preg_match('|PmWFx/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
225 $this->brand = 'PmW-Firefox';
226 $this->version = $regs[1];
229 elseif (preg_match('|BeZillaBrowser/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
230 $this->brand = 'BeZillaBrowser';
231 $this->version = $regs[1];
234 elseif (preg_match('|Songbird/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
235 $this->brand = 'Songbird';
236 $this->version = $regs[1];
239 elseif (preg_match('|Lanikai/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
240 $this->brand = 'Lanikai'; // Thunderbird 3.1 code name
241 $this->version = $regs[1];
244 elseif (preg_match('|Shredder/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
245 $this->brand = 'Shredder'; // Thunderbird development nightly code name
246 $this->version = $regs[1];
249 elseif (preg_match('|prism/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
250 $this->brand = 'Prism';
251 $this->version = $regs[1];
254 elseif (preg_match('|Minimo/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
255 $this->brand = 'Minimo';
256 $this->version = $regs[1];
258 $this->mobile = true;
260 elseif (preg_match('|Fennec/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
261 $this->brand = 'Fennec'; // Firefox mobile code name
262 $this->version = $regs[1];
264 $this->mobile = true;
266 elseif (preg_match('|Galeon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
267 $this->brand = 'Galeon';
268 $this->version = $regs[1];
271 elseif (preg_match('|Epiphany/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
272 $this->brand = 'Epiphany';
273 $this->version = $regs[1];
276 elseif (preg_match('|K-Meleon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
277 $this->brand = 'K-Meleon';
278 $this->version = $regs[1];
281 elseif (preg_match('|AOL[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
282 $this->brand = 'AOL';
283 $this->version = $regs[1];
286 elseif (preg_match('|Tablet browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
287 $this->brand = 'microB';
288 $this->version = $regs[1];
290 $this->mobile = true;
292 elseif (preg_match('|Maemo Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
293 $this->brand = 'microB';
294 $this->version = $regs[1];
296 $this->mobile = true;
298 elseif (preg_match('|Opera\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) {
299 $this->brand = 'Opera Mini';
300 $this->version = $regs[1];
302 $this->mobile = true;
304 elseif (preg_match('/Opera\/[^\(]+ \(.*; Opera Mini\/([^;]+); /i', $this->uastring, $regs)) {
305 $this->brand = 'Opera Mini';
306 $this->version = $regs[1];
308 $this->mobile = true;
310 elseif (preg_match('|Opera[ /]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
311 $this->brand = 'Opera';
312 $this->version = $regs[1];
315 elseif (preg_match('|OmniWeb/([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) {
316 $this->brand = 'OmniWeb';
317 $this->version = $regs[1];
320 elseif (preg_match('|Konqueror/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
321 $this->brand = 'Konqueror';
322 $this->version = $regs[1];
325 elseif (preg_match('|Shiira/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
326 $this->brand = 'Shiira';
327 $this->version = $regs[1];
330 elseif (preg_match('|Edge/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
331 $this->brand = 'Edge';
332 $this->version = $regs[1];
334 $this->mobile = preg_match('| Mobile |', $this->uastring);
336 elseif (preg_match('|Chromium/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
337 $this->brand = 'Chromium';
338 $this->version = $regs[1];
341 elseif (preg_match('|Chrome/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
342 $this->brand = 'Chrome';
343 $this->version = $regs[1];
346 elseif (preg_match('|NokiaBrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
347 $this->brand = 'NokiaBrowser';
348 $this->version = $regs[1];
351 elseif (preg_match('|wOSBrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
352 $this->brand = 'webOS Browser';
353 $this->version = $regs[1];
356 elseif (preg_match('|Silk/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
357 $this->brand = 'Silk';
358 $this->version = $regs[1];
361 elseif (preg_match('|Kindle/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
362 $this->brand = 'Kindle';
363 $this->version = $regs[1];
366 elseif (preg_match('|Pre/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
367 $this->brand = 'Pre';
368 $this->version = $regs[1];
371 elseif (preg_match('|BOLT/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
372 $this->brand = 'BOLT';
373 $this->version = $regs[1];
376 elseif (preg_match('|Googlebot-Mobile/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Webkit! */
377 $this->brand = 'Googlebot-Mobile';
378 $this->version = $regs[1];
380 $this->mobile = true;
382 elseif (preg_match('|FxiOS/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
383 $this->brand = 'Firefox for iOS';
384 $this->version = $regs[1];
386 $this->mobile = true;
388 elseif (preg_match('|Safari/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
389 if (preg_match('| Mobile(/[0-9a-zA-Z\.+]+)? ?Safari/|', $this->uastring)) {
390 $this->brand = 'Mobile Safari';
391 $this->mobile = true;
394 $this->brand = 'Safari';
396 if (preg_match('|Version/([0-9a-zA-Z\.+]+)|', $this->uastring, $vregs)) {
397 $this->version = $vregs[1];
400 $this->version = '('.$regs[1].')';
404 elseif (preg_match('|AppleWebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
405 $this->brand = 'AppleWebKit';
406 $this->version = $regs[1];
409 elseif (preg_match('|Spinn3r ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
410 $this->brand = 'Spinn3r';
411 $this->version = $regs[1];
414 elseif (preg_match('|Butterfly/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
415 $this->brand = 'Butterfly';
416 $this->version = $regs[1];
419 elseif (preg_match('|Googlebot/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
420 $this->brand = 'Googlebot';
421 $this->version = $regs[1];
424 elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
425 $this->brand = 'Firefox';
426 $this->version = $regs[1];
429 elseif (preg_match('|Thunderbird/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
430 $this->brand = 'Thunderbird';
431 $this->version = $regs[1];
434 elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) &&
435 strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) {
436 $this->brand = 'Mozilla';
437 $this->version = $regs[1];
440 elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) &&
441 strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) {
442 $this->brand = 'Mozilla';
443 $this->version = 'M'.$regs[1];
446 elseif (preg_match('|Baiduspider|i', $this->uastring)) {
447 $this->brand = 'BaiDuSpider';
448 $this->version = null;
451 elseif (preg_match('|YodaoBot-Mobile/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
452 $this->brand = 'YodaoBot-Mobile';
453 $this->version = $regs[1];
455 $this->mobile = true;
457 elseif (preg_match('|FASTMobileCrawl/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
458 $this->brand = 'FASTMobileCrawl';
459 $this->version = $regs[1];
461 $this->mobile = true;
463 elseif (preg_match('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
464 $this->brand = 'Microsoft FrontPage';
465 $this->version = $regs[1];
468 elseif (preg_match('|iCab[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
469 $this->brand = 'iCab';
470 $this->version = $regs[1];
473 elseif (preg_match('|IBrowse[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
474 $this->brand = 'IBrowse';
475 $this->version = $regs[1];
478 elseif (preg_match('|ICEbrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
479 $this->brand = 'ICEbrowser';
480 $this->version = $regs[1];
483 elseif (preg_match('|ICE Browser/v([0-9a-zA-Z\._+]+)|', $this->uastring, $regs)) {
484 $this->brand = 'ICEbrowser';
485 $this->version = str_replace('_', '.', $regs[1]);
488 elseif (preg_match('|NetPositive/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
489 $this->brand = 'NetPositive';
490 $this->version = $regs[1];
493 elseif (preg_match('|WebPro/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
494 $this->brand = 'WebPro (Novarra)';
495 $this->version = $regs[1];
498 elseif (preg_match('|; OffByOne;|', $this->uastring, $regs)) {
499 $this->brand = 'Off By One';
500 $this->version = null;
503 elseif (preg_match('|PSP \(PlayStation Portable\); ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
504 $this->brand = 'PlayStation Portable';
505 $this->version = $regs[1];
507 $this->mobile = true;
509 elseif (preg_match('|PLAYSTATION 3; ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
510 $this->brand = 'PlayStation 3';
511 $this->version = $regs[1];
514 elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
515 $this->brand = 'NetFront';
516 $this->version = $regs[1];
518 $this->mobile = true;
520 elseif (preg_match('|UP.Browser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
521 $this->brand = 'UP.Browser';
522 $this->version = $regs[1];
524 $this->mobile = true;
526 elseif (preg_match('|UP.Link/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
527 $this->brand = 'UP.Link';
528 $this->version = $regs[1];
530 $this->mobile = true;
532 elseif (preg_match('|AU-MIC-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
533 $this->brand = 'Obigo';
534 $this->version = $regs[1];
536 $this->mobile = true;
538 elseif (preg_match('|Browser/Obigo-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
539 $this->brand = 'Obigo';
540 $this->version = $regs[1];
542 $this->mobile = true;
544 elseif (preg_match('|Nokia([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
545 $this->brand = 'Nokia';
546 $this->version = $regs[1];
548 $this->mobile = true;
550 elseif (preg_match('|SonyEricsson([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
551 $this->brand = 'SonyEricsson';
552 $this->version = $regs[1];
554 $this->mobile = true;
556 elseif (preg_match('|SIE-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
557 $this->brand = 'Siemens';
558 $this->version = $regs[1];
560 $this->mobile = true;
562 elseif (preg_match('|MOT-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
563 $this->brand = 'Motorola';
564 $this->version = $regs[1];
566 $this->mobile = true;
568 elseif (preg_match('|IXI/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
569 $this->brand = 'IXI';
570 $this->version = $regs[1];
572 $this->mobile = true;
574 elseif (preg_match('|NewsFox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
575 $this->brand = 'NewsFox';
576 $this->version = $regs[1];
579 elseif (preg_match('|rdfbot/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
580 $this->brand = 'rdfbot';
581 $this->version = $regs[1];
584 elseif (preg_match('|IBM-WebExplorer-DLL/v([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
585 $this->brand = 'WebExplorer';
586 $this->version = $regs[1];
589 elseif (preg_match('|ELinks \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) {
590 $this->brand = 'ELinks';
591 $this->version = $regs[1];
594 elseif (preg_match('|Links \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) {
595 $this->brand = 'Links';
596 $this->version = $regs[1];
599 elseif (preg_match('|WinHttp.WinHttpRequest.([0-9\.]+)|i', $this->uastring, $regs)) {
600 $this->brand = 'WinHttpRequest';
601 $this->version = $regs[1];
604 elseif (preg_match('|alpha[/ ]06; AmigaOS|i', $this->uastring, $regs)) {
605 $this->brand = 'Alpha 06';
606 $this->version = null;
609 elseif (preg_match('|; arexx[\);]|i', $this->uastring, $regs)) {
610 $this->brand = 'ARexx';
611 $this->version = null;
614 elseif (preg_match('|; Voyager; AmigaOS[\);]|i', $this->uastring, $regs)) {
615 $this->brand = 'AmigaVoyager';
616 $this->version = null;
619 elseif (preg_match('|AWEB ([0-9a-zA-Z\.+ ]+)|', $this->uastring, $regs)) {
620 $this->brand = 'AWEB';
621 $this->version = $regs[1];
624 elseif (preg_match('|X ([0-9a-zA-Z\.+ ]+); Commodore 64|', $this->uastring, $regs)) {
626 $this->version = $regs[1];
629 elseif (preg_match('|DB Browse ([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
630 $this->brand = 'DB Browse';
631 $this->version = $regs[1];
634 elseif (preg_match('|ZyBorg/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
635 $this->brand = 'ZyBorg';
636 $this->version = $regs[1];
639 elseif (preg_match('|Ask Jeeves/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
640 $this->brand = 'Ask Jeeves';
641 $this->version = $regs[1];
644 elseif (preg_match('|heritrix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
645 $this->brand = 'Heritrix';
646 $this->version = $regs[1];
649 elseif (preg_match('|heritrix([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) {
650 $this->brand = 'Heritrix';
651 $this->version = str_replace('-', '.', $regs[1]);
654 elseif (preg_match('|SBSearch/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
655 $this->brand = 'SBSearch';
656 $this->version = $regs[1];
659 elseif (preg_match('|Powermarks/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
660 $this->brand = 'Powermarks';
661 $this->version = $regs[1];
664 elseif (preg_match('|TopBlogsInfo/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
665 $this->brand = 'TopBlogsInfo';
666 $this->version = $regs[1];
669 elseif (preg_match('|picmole/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
670 $this->brand = 'picmole';
671 $this->version = $regs[1];
674 elseif (preg_match('|([0-9a-zA-Z\._+-]+bot)/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
675 $this->brand = $regs[1];
676 $this->version = $regs[2];
679 elseif (preg_match('|VoilaBot ((BETA )?[0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
680 $this->brand = 'VoilaBot';
681 $this->version = $regs[1];
684 elseif (preg_match('|Slurp|', $this->uastring, $regs)) {
685 $this->brand = 'Slurp';
686 $this->version = null;
689 elseif (preg_match('|Check&Get ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
690 $this->brand = 'Check&Get';
691 $this->version = $regs[1];
694 elseif (preg_match('|WebCapture ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
695 $this->brand = 'WebCapture';
696 $this->version = $regs[1];
699 elseif (preg_match('|WebMon ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
700 $this->brand = 'WebMon';
701 $this->version = $regs[1];
704 elseif (preg_match('|Gulper Web Bot ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
705 $this->brand = 'Gulper Web Bot';
706 $this->version = $regs[1];
709 elseif (preg_match('|HTTrack ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
710 $this->brand = 'HTTrack';
711 $this->version = $regs[1];
714 elseif (preg_match('|Advista Crawler ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
715 $this->brand = 'HTTrack';
716 $this->version = $regs[1];
719 elseif (preg_match('|Seznam screenshot-generator ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
720 $this->brand = 'Seznam screenshot-generator';
721 $this->version = $regs[1];
724 elseif (preg_match('|Yahoo! SearchMonkey ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
725 $this->brand = 'Yahoo! SearchMonkey';
726 $this->version = $regs[1];
729 elseif (preg_match('|Yahoo Pipes ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
730 $this->brand = 'Yahoo! Pipes';
731 $this->version = $regs[1];
734 elseif (preg_match('|Firebat ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
735 $this->brand = 'Firebat';
736 $this->version = $regs[1];
739 elseif (preg_match('|Twiceler-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
740 $this->brand = 'Twiceler';
741 $this->version = $regs[1];
744 elseif (preg_match('|Nu_?tch-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
745 $this->brand = 'Nutch';
746 $this->version = $regs[1];
749 elseif (preg_match('|Microsoft URL Control - ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
750 $this->brand = 'Microsoft URL Control';
751 $this->version = $regs[1];
754 elseif (preg_match('|([0-9a-zA-Z\.+]+)_AC-Plug|', $this->uastring, $regs)) {
755 $this->brand = 'AC-Plug';
756 $this->version = $regs[1];
759 elseif (preg_match('|^Internet Explorer 5.5|', $this->uastring)) {
760 $this->brand = 'Unknown bot (IE5.5)';
761 $this->version = null;
764 elseif (preg_match('|^Mozilla[\s ]*$|', $this->uastring)) {
765 $this->brand = 'Unknown bot (Mozilla)';
766 $this->version = null;
769 elseif (preg_match('|ICCrawler|i', $this->uastring, $regs)) {
770 $this->brand = 'ICCrawler';
771 $this->version = null;
774 elseif (preg_match('|KaloogaBot|', $this->uastring, $regs)) {
775 $this->brand = 'KaloogaBot';
776 $this->version = null;
779 elseif (preg_match('|ScoutJet|', $this->uastring, $regs)) {
780 $this->brand = 'ScoutJet';
781 $this->version = null;
784 elseif (preg_match('|http://www.livedir.net|', $this->uastring, $regs)) {
785 $this->brand = 'livedir.net';
786 $this->version = null;
789 elseif (preg_match('|WebClipping.com|', $this->uastring, $regs)) {
790 $this->brand = 'WebClipping.com';
791 $this->version = null;
794 elseif (preg_match('|newstin.com|', $this->uastring, $regs)) {
795 $this->brand = 'newstin.com';
796 $this->version = null;
799 elseif (preg_match('|http://www.almaden.ibm.com/cs/crawler|', $this->uastring)) {
800 $this->brand = 'almaden crawler';
801 $this->version = null;
804 elseif (preg_match('|B-l-i-t-z-B-O-T|', $this->uastring) ||
805 preg_match('|B l i t z B O T @ t r i c u s . n e t|', $this->uastring)) {
806 $this->brand = 'BlitzBOT';
807 $this->version = null;
810 elseif (preg_match('|Really Gmane.org\'s favicon grabber|', $this->uastring)) {
811 $this->brand = 'Really Gmane.org\'s favicon grabber';
812 $this->version = null;
815 elseif (preg_match('|Girafabot|', $this->uastring)) {
816 $this->brand = 'Girafabot';
817 $this->version = null;
820 elseif (preg_match('|Arachmo|', $this->uastring)) {
821 $this->brand = 'Arachmo';
822 $this->version = null;
825 elseif (preg_match('|OsO|', $this->uastring)) {
826 $this->brand = 'OsO';
827 $this->version = null;
830 elseif (preg_match('|Yoono|', $this->uastring)) {
831 $this->brand = 'Yoono';
832 $this->version = null;
835 elseif (preg_match('|efp@gmx.net|', $this->uastring)) {
836 $this->brand = 'efp';
837 $this->version = null;
840 elseif (preg_match('|Indy Library|', $this->uastring)) {
841 $this->brand = 'Indy Library';
842 $this->version = null;
845 elseif (preg_match('|Linkman|', $this->uastring)) {
846 $this->brand = 'Linkman';
847 $this->version = null;
850 elseif (preg_match('|Sage|', $this->uastring, $regs)) {
851 $this->brand = 'Sage';
852 $this->version = null;
855 elseif (preg_match('|Google Desktop|', $this->uastring)) {
856 $this->brand = 'Google Desktop';
857 $this->version = null;
860 elseif (preg_match('|^Firefly|', $this->uastring)) {
861 // comes here with correct value but would be detected as MSIE
863 elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) {
864 $this->brand = 'Steganos Internet Anonym';
865 $this->version = $regs[1];
868 elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) {
869 $this->brand = 'Steganos Internet Anonym';
870 $this->version = $regs[1];
873 elseif (preg_match('|BorderManager ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
874 $this->brand = 'BorderManager';
875 $this->version = $regs[1];
878 elseif (preg_match('|WebWasher ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
879 $this->brand = 'WebWasher';
880 $this->version = $regs[1];
883 elseif (preg_match('|SaferSurf|', $this->uastring, $regs)) {
884 $this->brand = 'SaferSurf';
885 $this->version = null;
888 elseif (preg_match('|Avant Browser[^/]|', $this->uastring)) {
889 $this->brand = 'Avant Browser';
890 $this->version = null;
893 elseif (preg_match('|Browser[^/]+(http://www.avantbrowser.com)|', $this->uastring)) {
894 $this->brand = 'Avant Browser';
895 $this->version = null;
898 elseif (preg_match('|Maxthon|', $this->uastring)) {
899 $this->brand = 'Maxthon';
900 $this->version = null;
903 elseif (preg_match('|MyIE2|', $this->uastring)) {
904 $this->brand = 'MyIE2';
905 $this->version = null;
908 elseif (preg_match('|Crazy Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
909 $this->brand = 'Crazy Browser';
910 $this->version = $regs[1];
913 elseif (preg_match('|AvantGo ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
914 $this->brand = 'AvantGo';
915 $this->version = $regs[1];
918 elseif (preg_match('|MSN ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
919 $this->brand = 'MSN';
920 $this->version = $regs[1];
923 elseif (preg_match('|America Online Browser [0-9a-zA-Z\.+]+; rev([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
924 $this->brand = 'AOL Browser';
925 $this->version = $regs[1];
928 elseif (preg_match('|MS FrontPage ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
929 $this->brand = 'Microsoft FrontPage';
930 $this->version = $regs[1];
933 elseif (preg_match('|Microsoft Internet Explorer/4.0b1|', $this->uastring, $regs)) {
934 $this->brand = 'Microsoft Internet Explorer';
935 $this->version = '1.0';
938 elseif (preg_match('|MSIE 7\.0.+Trident/4.0|', $this->uastring, $regs)) {
939 $this->brand = 'Microsoft Internet Explorer';
940 $this->version = "8.0";
943 elseif (preg_match('|MSIE 7\.0.+Trident/5.0|', $this->uastring, $regs)) {
944 $this->brand = 'Microsoft Internet Explorer';
945 $this->version = "9.0";
948 elseif (preg_match('|MSIE 7\.0.+Trident/6.0|', $this->uastring, $regs)) {
949 $this->brand = 'Microsoft Internet Explorer';
950 $this->version = "10.0";
953 elseif (preg_match('|Trident\/[0-9a-zA-Z\.+]+; ([^\)]+; )?rv:([0-9\.+]+)|', $this->uastring, $regs)) {
954 $this->brand = 'Microsoft Internet Explorer';
955 $this->version = $regs[2];
958 elseif (preg_match('|MSIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
959 $this->brand = 'Microsoft Internet Explorer';
960 $this->version = $regs[1];
963 elseif (preg_match('|MSPIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
964 $this->brand = 'Microsoft Pocket Internet Explorer';
965 $this->version = $regs[1];
967 $this->mobile = true;
969 elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) &&
970 (strpos($this->uastring, 'compatible') === false) && (strpos($this->uastring, 'Gecko/') === false) &&
971 (intval($regs[1]) < 5)) {
972 $this->brand = 'Netscape';
973 $this->version = $regs[1];
974 if (intval($this->version) == 4) { $this->brand .= ' Communicator'; }
977 elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
978 $this->brand = (strpos($this->uastring, 'compatible') !== false)?'Mozilla-compatible (unknown)':'Mozilla (unknown)';
979 $this->version = null;
984 'Scooter', 'Spinne', 'Vagabondo', 'Firefly', 'Scrubby', 'NG', 'Pompos', 'Szukacz', 'Schmozilla', '42_HAL',
985 'NetResearchServer', 'LinkWalker', 'Zeus', 'W3C_Validator', 'ZyBorg', 'Ask Jeeves', 'ia_archiver', 'ichiro',
986 'PingALink Monitoring Services', 'IlTrovatore-Setaccio', 'Nutch', 'Mercator', 'search.ch', 'appie', 'larbin',
987 'NutchCVS', 'Webchat', 'Mediapartners-Google', 'sitecheck.internetseer.com', 'FavOrg', 'findlinks', 'DataCha0s',
988 'Francis', 'CoralWebPrx', 'DoCoMo', 'Ocelli', 'Sogou Video', 'Yandex', 'Yeti', 'SEO Scanner', 'Feedbin feed-id',
989 'Austronaut-URL-Checker', 'check_ssl_cert', 'check_http', 'vdirsyncer', 'FreshRSS', 'UniversalFeedParser',
990 'Cloudflare Custom Hostname Verification', 'Scoop.it',
993 if (in_array($this->brand, $botArray)) {
997 if (($this->brand == 'Microsoft Pocket Internet Explorer') ||
998 (strpos($this->brand, 'BlackBerry') !== false)) {
999 $this->mobile = true;
1003 public function getBrand() {
1004 return $this->brand;
1007 public function getVersion() {
1008 return $this->version;
1011 public function getAcceptLanguages() {
1012 if (!isset($this->uadata['accept-languages'])) {
1013 $headers = getAllHeaders();
1014 $accLcomp = explode(',', ($headers['Accept-Language'] ?? ''));
1016 foreach ($accLcomp as $lcomp) {
1017 if (strlen($lcomp)) {
1018 $ldef = explode(';', $lcomp);
1019 if (count($ldef) > 1 && strpos($ldef[1], 'q=') === 0) {
1020 $accLang[$ldef[0]] = substr($ldef[1], 2);
1023 $accLang[$ldef[0]] = 1;
1027 $this->uadata['accept-languages'] = $accLang;
1029 return $this->uadata['accept-languages'];
1032 public function getUAString() {
1033 return $this->uastring;
1036 public function getEngine() {
1037 // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|netfront|unknown
1038 if (!isset($this->uadata['engine'])) {
1039 $this->uadata['engine'] = 'unknown';
1040 $this->uadata['geckodate'] = null;
1042 if (preg_match('|Gecko/([0-9\.]+)|', $this->uastring, $regs) && (strpos($this->brand, 'Opera') === false)) {
1043 $this->uadata['engine'] = 'gecko';
1044 // If it looks like a version number, i.e. shorter than 4 chars or has a . in it, it's no date.
1045 if ((strlen($regs[1]) > 4) && (strpos($regs[1], '.') === false)) {
1046 $this->uadata['geckodate'] = $regs[1];
1049 $this->uadata['geckodate'] = null;
1050 $this->uadata['eng_version'] = $regs[1];
1053 elseif (preg_match('|Edge/([0-9\.]+)|', $this->uastring, $regs)) {
1054 $this->uadata['engine'] = 'edgehtml';
1055 $this->uadata['eng_version'] = $regs[1];
1057 elseif ((strpos($this->brand, 'Internet Explorer') !== false) || (strpos($this->brand, 'FrontPage') !== false)) {
1058 if ((strpos(strtolower($this->uastring), 'mac') !== false) && (intval($this->getVersion()) >= 5)) {
1059 $this->uadata['engine'] = 'tasman';
1062 $this->uadata['engine'] = 'trident';
1065 elseif (preg_match('|WebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
1066 $this->uadata['engine'] = 'webkit';
1067 $this->uadata['eng_version'] = $regs[1];
1069 elseif ((strpos($this->brand, 'Konqueror') !== false) || (strpos($this->brand, 'OmniWeb') !== false)) {
1070 $this->uadata['engine'] = 'khtml';
1072 elseif (strpos($this->brand, 'Netscape') !== false) {
1073 // non-Gecko Netscape browsers
1074 if (intval($this->version) <= 4) {
1075 $this->uadata['engine'] = 'nscp';
1077 elseif (strpos($this->uastring, 'MSIE') !== false) {
1078 $this->uadata['engine'] = 'trident';
1081 elseif (strpos($this->brand, 'Opera') !== false) {
1082 $this->uadata['engine'] = 'presto';
1084 elseif ((strpos($this->brand, 'iTunes') !== false) || (strpos($this->brand, 'nook browser') !== false)) {
1085 $this->uadata['engine'] = 'webkit';
1087 elseif (strpos($this->brand, 'Dillo') !== false) {
1088 $this->uadata['engine'] = 'gzilla';
1090 elseif ((strpos($this->brand, 'ELinks') !== false) || (strpos($this->brand, 'Links') !== false)) {
1091 $this->uadata['engine'] = 'links';
1093 elseif ((strpos($this->brand, 'Lynx') !== false)) {
1094 $this->uadata['engine'] = 'lynx';
1096 elseif ((strpos($this->brand, 'ICEbrowser') !== false) || (strpos($this->brand, 'ICE Browser') !== false)) {
1097 $this->uadata['engine'] = 'icestorm';
1099 elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
1100 $this->uadata['engine'] = 'netfront';
1101 $this->uadata['eng_version'] = $regs[1];
1103 elseif ((strpos($this->brand, 'PlayStation') !== false) || (strpos($this->brand, 'NetFront') !== false)) {
1104 $this->uadata['engine'] = 'netfront';
1106 elseif ((strpos($this->brand, 'Avant') !== false) || (strpos($this->brand, 'Crazy Browser') !== false) ||
1107 (strpos($this->brand, 'AOL') !== false) || (strpos($this->brand, 'MSN') !== false) ||
1108 (strpos($this->brand, 'MyIE2') !== false) || (strpos($this->brand, 'Maxthon') !== false)) {
1109 $this->uadata['engine'] = 'trident';
1111 elseif (strpos($this->brand, 'Galeon') !== false) {
1112 $this->uadata['engine'] = 'gecko';
1114 elseif (strpos($this->brand, 'WebPro') !== false) {
1115 $this->uadata['engine'] = 'nscp';
1119 return $this->uadata['engine'];
1122 public function hasEngine($rnd_engine) {
1123 return ($this->getEngine() == $rnd_engine);
1126 public function getEngineVersion() {
1127 if (!isset($this->uadata['eng_version'])) {
1128 $this->uadata['eng_version'] = null;
1129 // getOS() should get the date for us
1132 return $this->uadata['eng_version'];
1135 public function getOS() {
1136 if (!isset($this->uadata['os'])) {
1137 $this->uadata['os'] = null;
1139 if ($this->hasEngine('gecko')) {
1140 if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1141 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1142 $this->uadata['lang'] = (strpos($regs[4],'chrome://')===false)?$regs[4]:null;
1143 $this->uadata['eng_version'] = $regs[5];
1145 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1146 $this->uadata['os'] = $regs[2];
1147 $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null;
1148 $this->uadata['eng_version'] = $regs[4];
1150 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1151 $this->uadata['os'] = $regs[2];
1152 $this->uadata['lang'] = null;
1153 $this->uadata['eng_version'] = $regs[3];
1155 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); x64; rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1156 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1157 $this->uadata['lang'] = null;
1158 $this->uadata['eng_version'] = $regs[3];
1160 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1161 $this->uadata['os'] = $regs[2];
1162 $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null;
1163 $this->uadata['eng_version'] = $regs[4];
1165 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
1166 $this->uadata['os'] = $regs[2];
1167 $this->uadata['lang'] = $regs[3];
1168 $this->uadata['eng_version'] = 'M'.$regs[4];
1170 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
1171 $this->uadata['os'] = $regs[1];
1172 $this->uadata['lang'] = $regs[2];
1173 $this->uadata['eng_version'] = 'M'.$regs[3];
1175 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1176 $this->uadata['os'] = $regs[2];
1177 $this->uadata['lang'] = $regs[3];
1178 $this->uadata['eng_version'] = null;
1180 elseif (preg_match('#Mozilla/5.0 \(([^;]+); (WOW64|Mobile|Tablet); rv:([^\);]+)\)#', $this->uastring, $regs)) {
1181 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1182 $this->uadata['lang'] = null;
1183 $this->uadata['eng_version'] = $regs[3];
1184 $this->mobile = ($regs[2] == 'Mobile');
1186 elseif (preg_match('#Mozilla/5.0 \((Mobile|Tablet); [^;]+; rv:([^\);]+)\)#', $this->uastring, $regs)) {
1187 $this->uadata['os'] = 'Firefox OS ('.$regs[1].')';
1188 $this->uadata['lang'] = null;
1189 $this->uadata['eng_version'] = $regs[2];
1190 $this->mobile = ($regs[1] == 'Mobile');
1192 elseif (preg_match('#Mozilla/5.0 \(([^;]+); Viera; rv:([^\);]+)\)#', $this->uastring, $regs)) {
1193 $this->uadata['os'] = 'Firefox OS (TV, '.$regs[1].')';
1194 $this->uadata['lang'] = null;
1195 $this->uadata['eng_version'] = $regs[2];
1197 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
1198 if ((strpos($regs[2], 'Linux') !== false) && ($regs[1] != 'X11')) {
1199 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1202 $this->uadata['os'] = $regs[2];
1204 $this->uadata['lang'] = null;
1205 $this->uadata['eng_version'] = $regs[3];
1207 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^\);]+)\)|', $this->uastring, $regs)) {
1208 $this->uadata['os'] = $regs[2];
1209 $this->uadata['lang'] = null;
1210 $this->uadata['eng_version'] = null;
1212 elseif (preg_match('#Mozilla/5.0 \((Mobile|Tablet); rv:([^\);]+)\)#', $this->uastring, $regs)) {
1213 $this->uadata['os'] = 'Firefox OS ('.$regs[1].')';
1214 $this->uadata['lang'] = null;
1215 $this->uadata['eng_version'] = $regs[2];
1216 $this->mobile = ($regs[1] == 'Mobile');
1218 elseif (preg_match('|Mozilla/5.0 \(([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
1219 $this->uadata['os'] = $regs[1];
1220 $this->uadata['lang'] = null;
1221 $this->uadata['eng_version'] = $regs[2];
1223 elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) {
1224 $this->uadata['os'] = $regs[2];
1225 $this->uadata['lang'] = null;
1226 $this->uadata['eng_version'] = null;
1228 elseif (preg_match('|Debian/|', $this->uastring, $regs)) {
1229 $this->uadata['os'] = 'Debian Linux';
1230 $this->uadata['lang'] = null;
1231 $this->uadata['eng_version'] = null;
1233 if (($this->brand == 'Firefox') && (intval($this->version) >= 110)) {
1234 $this->uadata['eng_version'] = $this->version;
1237 elseif ($this->hasEngine('edgehtml')) {
1238 if (preg_match('#Mozilla/5.0 \(([^;]+); (WOW64|Win64); ([^\);]+)\)#', $this->uastring, $regs)) {
1239 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1241 elseif (preg_match('#Mozilla/5.0 \(([^;]+Phone[^;]+); [^\)]+\)#i', $this->uastring, $regs)) {
1242 $this->uadata['os'] = $regs[1];
1245 elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) {
1246 if (preg_match('/Mozilla\/[^\(]+ \((IE [^;]+[^\)]*; )?((?:Mac|Win)[^;]+); ?(Win64|WOW64); ?Trident\/([^;\)]+);/i', $this->uastring, $regs)) {
1247 $this->uadata['eng_version'] = $regs[4];
1248 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1249 $this->uadata['lang'] = null;
1251 elseif (preg_match('/Mozilla\/[^\(]+ \((IE [^;]+[^\)]*; )?((?:Mac|Win)[^;]+); ?Trident\/([^;\)]+);/i', $this->uastring, $regs)) {
1252 $this->uadata['eng_version'] = $regs[3];
1253 $this->uadata['os'] = $regs[2];
1254 $this->uadata['lang'] = null;
1256 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) {
1257 $this->uadata['eng_version'] = $regs[3];
1258 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1259 $this->uadata['lang'] = null;
1261 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) {
1262 $this->uadata['eng_version'] = $regs[2];
1263 $this->uadata['os'] = $regs[1];
1264 $this->uadata['lang'] = null;
1266 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*\)/i', $this->uastring, $regs)) {
1267 $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$regs[1];
1268 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1269 $this->uadata['lang'] = null;
1270 $this->mobile = (strpos($this->uastring,'MSPIE') !== false);
1272 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
1273 $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$regs[1];
1274 $this->uadata['os'] = $regs[2];
1275 $this->uadata['lang'] = null;
1276 $this->mobile = (strpos($this->uastring,'MSPIE') !== false);
1278 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
1279 $this->uadata['eng_version'] = "ie".$regs[1];
1280 $this->uadata['os'] = null;
1281 $this->uadata['lang'] = null;
1283 elseif (preg_match('/Microsoft Internet Explorer\/[^\s]+ \(((?:Mac|Win)[^;\)]+)\)/i', $this->uastring, $regs)) {
1284 $this->uadata['eng_version'] = "ie".$this->getVersion();
1285 $this->uadata['os'] = $regs[1];
1286 $this->uadata['lang'] = null;
1288 elseif (preg_match('/Microsoft Pocket Internet Explorer\/[^\s]+/i', $this->uastring, $regs)) {
1289 $this->uadata['eng_version'] = null;
1290 $this->uadata['os'] = 'Windows CE';
1291 $this->uadata['lang'] = null;
1294 elseif ($this->hasEngine('khtml')) {
1295 if (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^;]+); ([^;]+); ([^;]+); ([^\);]+)\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
1296 $this->uadata['eng_version'] = strlen($regs[6])?$regs[6]:$regs[1];
1297 $this->uadata['os'] = $regs[2];
1298 $this->uadata['lang'] = $regs[5];
1300 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^\);]+)[^\)]*\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
1301 $this->uadata['eng_version'] = strlen($regs[3])?$regs[3]:$regs[1];
1302 $this->uadata['os'] = $regs[2];
1303 $this->uadata['lang'] = null;
1305 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^\);]+)\)/i', $this->uastring, $regs)) {
1306 $this->uadata['os'] = $regs[1];
1307 $this->uadata['lang'] = null;
1308 $this->uadata['eng_version'] = null;
1311 elseif ($this->hasEngine('webkit')) {
1312 if (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+); ([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1313 $this->uadata['os'] = $regs[2];
1314 $this->uadata['lang'] = $regs[3];
1316 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1317 if (strpos($regs[3], '/') !== false) {
1318 $this->uadata['os'] = $regs[1];
1319 $this->uadata['lang'] = null;
1322 $this->uadata['os'] = $regs[2];
1323 $this->uadata['lang'] = $regs[3];
1326 elseif (preg_match('|Mozilla/5.0 \(([^;]+); Linux; ([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) {
1327 $this->uadata['os'] = $regs[2];
1328 $this->uadata['lang'] = $regs[3];
1330 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) {
1331 $this->uadata['os'] = $regs[1];
1332 $this->uadata['lang'] = $regs[2];
1334 elseif (preg_match('|Mozilla/5.0 \(Linux; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1335 // (Chrome for) Android - $regs[2] is device
1336 $this->uadata['os'] = $regs[1];
1337 $this->uadata['lang'] = null;
1339 elseif (preg_match('|Mozilla/5.0 \(([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1340 if (($regs[1] == 'X11') || ($regs[1] == 'Macintosh') || ($regs[1] == 'iPhone')) {
1341 $this->uadata['os'] = $regs[2];
1344 $this->uadata['os'] = $regs[1];
1345 if ($regs[2] == 'NokiaN9') {
1346 $this->uadata['os'] .= ' Harmattan';
1349 $this->uadata['lang'] = null;
1351 elseif (preg_match('|Mozilla/5.0 \(([^\);]+)\)|', $this->uastring, $regs)) {
1352 $this->uadata['os'] = $regs[1];
1353 $this->uadata['lang'] = null;
1355 elseif (preg_match('|Midori/[^\(]+ \((?:X11; )?([^;]+); U; ([^\)]+)\)|i', $this->uastring, $regs)) {
1356 $this->uadata['os'] = $regs[1];
1357 $this->uadata['lang'] = $regs[2];
1359 if ($this->brand == 'Silk') {
1360 // For some reason, Amazon spoofs us and tells us it's on MacOS X!
1361 $this->uadata['os'] = 'Android';
1363 if (preg_match('| Mobile |', $this->uastring)) {
1364 $this->mobile = true;
1367 elseif ($this->hasEngine('presto')) {
1369 if (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1370 $this->uadata['eng_version'] = $this->getVersion();
1371 $this->uadata['os'] = $regs[1];
1372 $this->uadata['lang'] = $regs[2];
1374 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;\)]+)[^\)]*\) Opera [^ ]+\s+\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1375 $this->uadata['eng_version'] = $this->getVersion();
1376 $this->uadata['os'] = $regs[1];
1377 $this->uadata['lang'] = $regs[2];
1379 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+\) Opera [^ ]+\s+\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1380 $this->uadata['eng_version'] = $this->getVersion();
1381 $this->uadata['os'] = $regs[1];
1382 $this->uadata['lang'] = $regs[2];
1385 elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini; ([a-z_-]+); /i', $this->uastring, $regs)) {
1386 $this->uadata['eng_version'] = null;
1387 $this->uadata['os'] = $regs[2];
1388 $this->uadata['lang'] = $regs[3];
1390 elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini\/[^;]+; ([a-z_-]+); /i', $this->uastring, $regs)) {
1391 $this->uadata['eng_version'] = $regs[1];
1392 $this->uadata['os'] = $regs[2];
1393 $this->uadata['lang'] = $regs[3];
1396 elseif (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) {
1397 $this->uadata['eng_version'] = $this->getVersion();
1398 $this->uadata['os'] = $regs[1];
1399 $this->uadata['lang'] = $regs[2];
1401 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
1402 $this->uadata['eng_version'] = $this->getVersion();
1403 $this->uadata['os'] = $regs[1];
1404 $this->uadata['lang'] = $regs[2];
1406 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
1407 $this->uadata['eng_version'] = $this->getVersion();
1408 $this->uadata['os'] = $regs[1];
1409 $this->uadata['lang'] = $regs[2];
1411 // Opera 9 Firefox-spoofing
1412 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+); rv:([^\);]+)\) Gecko\/\d+ Firefox\/[0-9a-zA-Z\.+]+ Opera [^ ]+/i', $this->uastring, $regs)) {
1413 $this->uadata['eng_version'] = $this->getVersion();
1414 $this->uadata['os'] = $regs[1];
1415 $this->uadata['lang'] = $regs[2];
1417 if (preg_match('| Mobi|', $this->uastring)) {
1418 $this->mobile = true;
1421 elseif ($this->hasEngine('nscp')) {
1422 if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {
1423 $this->uadata['eng_version'] = $regs[1];
1424 $this->uadata['os'] = $regs[3];
1425 $this->uadata['lang'] = $regs[2];
1427 elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
1428 $this->uadata['eng_version'] = $regs[1];
1429 $this->uadata['os'] = $regs[3];
1430 $this->uadata['lang'] = $regs[2];
1432 elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+)[^\(]+\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
1433 $this->uadata['eng_version'] = $regs[1];
1434 $this->uadata['os'] = $regs[2];
1435 $this->uadata['lang'] = null;
1438 elseif ($this->hasEngine('gzilla')) {
1439 $this->uadata['eng_version'] = $this->getVersion();
1440 $this->uadata['os'] = null;
1441 $this->uadata['lang'] = null;
1443 elseif ($this->hasEngine('links')) {
1444 if (preg_match('/E?Links[^\(]+\([^;]+; ([^;]+)[^\)]+\)/i', $this->uastring, $regs)) {
1445 $this->uadata['eng_version'] = null;
1446 $this->uadata['os'] = $regs[1];
1447 $this->uadata['lang'] = null;
1450 elseif ($this->hasEngine('lynx')) {
1451 $this->uadata['eng_version'] = $this->getVersion();
1452 $this->uadata['os'] = null;
1453 $this->uadata['lang'] = null;
1455 elseif ($this->hasEngine('icestorm')) {
1456 if (preg_match('/ICE Browser\/v?([0-9a-zA-Z\._+]+) \(Java [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {
1457 $this->uadata['eng_version'] = str_replace('_', '.', $regs[1]);
1458 $this->uadata['os'] = $regs[2];
1459 $this->uadata['lang'] = null;
1461 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\).* ICEbrowser\/([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) {
1462 $this->uadata['eng_version'] = $regs[3];
1463 $this->uadata['os'] = $regs[1];
1464 $this->uadata['lang'] = $regs[2];
1468 $this->uadata['eng_version'] = null;
1469 $this->uadata['lang'] = null;
1470 if (preg_match('/AmigaOS/i', $this->uastring, $regs)) {
1471 $this->uadata['os'] = 'AmigaOS';
1473 if (preg_match('/Commodore 64/i', $this->uastring, $regs)) {
1474 $this->uadata['os'] = 'Commodore 64';
1476 elseif (preg_match('/curl\/[^\(]+\(([^\);]+)/i', $this->uastring, $regs)) {
1477 $this->uadata['os'] = $regs[1];
1479 elseif (preg_match('/NCSA[_ ]Mosaic\/[^\(]+\((?:.*;)?([^\);]+)/i', $this->uastring, $regs)) {
1480 $this->uadata['os'] = trim($regs[1]);
1482 elseif (preg_match('/iCab.*(Mac[^\);]+).*?\)/i', $this->uastring, $regs)) {
1483 $this->uadata['os'] = trim($regs[1]);
1485 elseif (preg_match('/SymbianOS\/([^ ]+)/i', $this->uastring, $regs)) {
1486 $this->uadata['os'] = 'SymbianOS '.$regs[1];
1489 if ($this->uadata['os'] == 'Win 9x 4.90') { $this->uadata['os'] = 'Windows ME'; }
1490 elseif ($this->uadata['os'] == 'WinNT4.0') { $this->uadata['os'] = 'Windows NT 4.0'; }
1491 elseif ($this->uadata['os'] == 'Windows NT 5.0') { $this->uadata['os'] = 'Windows 2000'; }
1492 elseif ($this->uadata['os'] == 'Windows NT 5.1') { $this->uadata['os'] = 'Windows XP'; }
1493 elseif ($this->uadata['os'] == 'Windows NT 5.1 (Win64)') { $this->uadata['os'] = 'Windows XP (64bit)'; }
1494 elseif ($this->uadata['os'] == 'Windows NT 5.1 (WOW64)') { $this->uadata['os'] = 'Windows XP (64bit)'; }
1495 elseif ($this->uadata['os'] == 'Windows NT 5.2') { $this->uadata['os'] = 'Windows 2003'; }
1496 elseif ($this->uadata['os'] == 'Windows NT 5.2 x64') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1497 elseif ($this->uadata['os'] == 'Windows NT 5.2 (Win64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1498 elseif ($this->uadata['os'] == 'Windows NT 5.2 (WOW64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1499 elseif ($this->uadata['os'] == 'Windows NT 6.0') { $this->uadata['os'] = 'Windows Vista'; }
1500 elseif ($this->uadata['os'] == 'Windows NT 6.0 (Win64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; }
1501 elseif ($this->uadata['os'] == 'Windows NT 6.0 (WOW64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; }
1502 elseif ($this->uadata['os'] == 'Windows NT 6.1') { $this->uadata['os'] = 'Windows 7'; }
1503 elseif ($this->uadata['os'] == 'Windows NT 6.1 (Win64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; }
1504 elseif ($this->uadata['os'] == 'Windows NT 6.1 (WOW64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; }
1505 elseif ($this->uadata['os'] == 'Windows NT 6.2') { $this->uadata['os'] = 'Windows 8'; }
1506 elseif ($this->uadata['os'] == 'Windows NT 6.2 (Win64)') { $this->uadata['os'] = 'Windows 8 (64bit)'; }
1507 elseif ($this->uadata['os'] == 'Windows NT 6.2 (WOW64)') { $this->uadata['os'] = 'Windows 8 (64bit)'; }
1508 elseif ($this->uadata['os'] == 'Windows NT 6.3') { $this->uadata['os'] = 'Windows 8.1'; }
1509 elseif ($this->uadata['os'] == 'Windows NT 6.3 (Win64)') { $this->uadata['os'] = 'Windows 8.1 (64bit)'; }
1510 elseif ($this->uadata['os'] == 'Windows NT 6.3 (WOW64)') { $this->uadata['os'] = 'Windows 8.1 (64bit)'; }
1511 elseif ($this->uadata['os'] == 'Windows NT 6.4') { $this->uadata['os'] = 'Windows 10'; }
1512 elseif ($this->uadata['os'] == 'Windows NT 6.4 (Win64)') { $this->uadata['os'] = 'Windows 10 (64bit)'; }
1513 elseif ($this->uadata['os'] == 'Windows NT 6.4 (WOW64)') { $this->uadata['os'] = 'Windows 10 (64bit)'; }
1514 elseif ($this->uadata['os'] == 'Windows NT 10.0') { $this->uadata['os'] = 'Windows 10'; }
1515 elseif ($this->uadata['os'] == 'Windows NT 10.0 (Win64)') { $this->uadata['os'] = 'Windows 10 (64bit)'; }
1516 elseif ($this->uadata['os'] == 'Windows NT 10.0 (WOW64)') { $this->uadata['os'] = 'Windows 10 (64bit)'; }
1517 elseif ($this->uadata['os'] == 'Win95') { $this->uadata['os'] = 'Windows 95'; }
1518 elseif ($this->uadata['os'] == 'Win98') { $this->uadata['os'] = 'Windows 98'; }
1519 elseif ($this->uadata['os'] == 'WinNT') { $this->uadata['os'] = 'Windows NT'; }
1520 elseif ($this->uadata['os'] == 'Win32') { $this->uadata['os'] = 'Windows (32bit)'; }
1521 elseif ($this->uadata['os'] == 'Win64') { $this->uadata['os'] = 'Windows (64bit)'; }
1522 elseif (preg_match('/iPhone OS ([\d_]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'iOS '.str_replace('_', '.', $regs[1]); }
1523 elseif (preg_match('/Mac ?OS ?X/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; }
1524 elseif (preg_match('/Mac_P(ower|)PC/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; }
1525 elseif (strpos($this->uadata['os'] ?? '', 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }
1526 elseif (strpos($this->uadata['os'] ?? '', 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }
1527 elseif (strpos($this->uadata['os'] ?? '', 'apple') !== false) { $this->uadata['os'] = 'MacOS'; }
1528 elseif (strpos($this->uadata['os'] ?? '', 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; }
1529 elseif (preg_match('/(?:web|hpw)OS\/([0-9a-zA-Z\._+]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'webOS '.$regs[1]; }
1530 elseif (preg_match('/Android \(Linux (.+)\)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'Android '.$regs[1]; }
1531 elseif (strpos($this->uadata['os'] ?? '', 'linux') !== false) { $this->uadata['os'] = 'Linux'; }
1532 elseif (preg_match('/SymbianOS[\/ ]([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) { $this->uadata['os'] = 'SymbianOS '.$regs[1]; }
1533 elseif (preg_match('/Symbian ?OS/i', $this->uadata['os'])) { $this->uadata['os'] = 'SymbianOS'; }
1535 if (strpos($this->uadata['os'] ?? '', 'Win') !== false) { $this->uadata['platform'] = 'Windows'; }
1536 elseif (strpos($this->uadata['os'] ?? '', 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; }
1537 elseif (strpos($this->uadata['os'] ?? '', 'iOS') !== false) { $this->uadata['platform'] = 'Macintosh'; }
1538 elseif (strpos($this->uadata['os'] ?? '', 'Linux') !== false) { $this->uadata['platform'] = 'Linux'; }
1539 elseif (strpos($this->uadata['os'] ?? '', 'MeeGo') !== false) { $this->uadata['platform'] = 'Linux'; }
1540 elseif (strpos($this->uadata['os'] ?? '', 'webOS') !== false) { $this->uadata['platform'] = 'Linux'; }
1541 elseif (strpos($this->uadata['os'] ?? '', 'Android') !== false) { $this->uadata['platform'] = 'Android'; }
1542 elseif (strpos($this->uadata['os'] ?? '', 'Firefox OS') !== false) { $this->uadata['platform'] = 'Firefox OS'; }
1543 elseif (strpos($this->uadata['os'] ?? '', 'Solaris') !== false) { $this->uadata['platform'] = 'Solaris'; }
1544 elseif (strpos($this->uadata['os'] ?? '', 'SunOS') !== false) { $this->uadata['platform'] = 'Solaris'; }
1545 elseif (strpos($this->uadata['os'] ?? '', 'BeOS') !== false) { $this->uadata['platform'] = 'BeOS'; }
1546 elseif (strpos($this->uadata['os'] ?? '', 'BePC') !== false) { $this->uadata['platform'] = 'BeOS'; }
1547 elseif (strpos($this->uadata['os'] ?? '', 'FreeBSD') !== false) { $this->uadata['platform'] = 'FreeBSD'; }
1548 elseif (strpos($this->uadata['os'] ?? '', 'OpenBSD') !== false) { $this->uadata['platform'] = 'OpenBSD'; }
1549 elseif (strpos($this->uadata['os'] ?? '', 'NetBSD') !== false) { $this->uadata['platform'] = 'NetBSD'; }
1550 elseif (strpos($this->uadata['os'] ?? '', 'AIX') !== false) { $this->uadata['platform'] = 'AIX'; }
1551 elseif (strpos($this->uadata['os'] ?? '', 'IRIX') !== false) { $this->uadata['platform'] = 'IRIX'; }
1552 elseif (strpos($this->uadata['os'] ?? '', 'HP-UX') !== false) { $this->uadata['platform'] = 'HP-UX'; }
1553 elseif (strpos($this->uadata['os'] ?? '', 'AmigaOS') !== false) { $this->uadata['platform'] = 'Amiga'; }
1554 elseif (strpos($this->uadata['os'] ?? '', 'webOS') !== false) { $this->uadata['platform'] = 'webOS'; }
1555 elseif (strpos($this->uadata['os'] ?? '', 'Commodore 64') !== false) { $this->uadata['platform'] = 'C64'; }
1556 elseif (strpos($this->uadata['os'] ?? '', 'OpenVMS') !== false) { $this->uadata['platform'] = 'OpenVMS'; }
1557 elseif (strpos($this->uadata['os'] ?? '', 'Warp') !== false) { $this->uadata['platform'] = 'OS/2'; }
1558 elseif (strpos($this->uadata['os'] ?? '', 'OS/2') !== false) { $this->uadata['platform'] = 'OS/2'; }
1559 elseif (strpos($this->uadata['os'] ?? '', 'SymbianOS') !== false) { $this->uadata['platform'] = 'SymbianOS'; }
1560 elseif (strpos($this->uadata['os'] ?? '', 'BlackBerry') !== false) { $this->uadata['platform'] = 'BlackBerry'; }
1561 elseif (strpos($this->uadata['os'] ?? '', 'Gameboy') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1562 elseif (strpos($this->uadata['os'] ?? '', 'Wii') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1563 elseif (strpos($this->uadata['os'] ?? '', 'Nintendo') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1564 elseif (strpos($this->uadata['os'] ?? '', 'J2ME') !== false) { $this->uadata['platform'] = 'Java'; }
1565 elseif (strpos($this->uadata['os'] ?? '', 'CYGWIN') !== false) { $this->uadata['platform'] = 'Windows'; }
1566 elseif (strpos($this->uadata['os'] ?? '', 'mingw') !== false) { $this->uadata['platform'] = 'Windows'; }
1567 else { $this->uadata['platform'] = $this->uadata['os']; }
1569 if (strpos($this->uadata['os'] ?? '', 'Windows Phone OS') !== false) { $this->mobile = true; }
1570 elseif (strpos($this->uadata['os'] ?? '', 'Gameboy') !== false) { $this->mobile = true; }
1572 $this->uadata['lang'] = str_replace('_', '-', ($this->uadata['lang'] ?? ''));
1575 return $this->uadata['os'];
1578 public function getPlatform() {
1579 if (!isset($this->uadata['platform'])) {
1580 $this->uadata['platform'] = null;
1581 // getOS() should get the date for us
1584 return $this->uadata['platform'];
1587 public function getLanguage() {
1588 if (!isset($this->uadata['lang'])) {
1589 $this->uadata['lang'] = null;
1590 // getOS() should get the date for us
1593 return $this->uadata['lang'];
1596 public function getGeckoDate() {
1597 if (!isset($this->uadata['geckodate'])) {
1598 $this->uadata['geckodate'] = null;
1599 // getEngine() should get the date for us
1602 return $this->uadata['geckodate'];
1605 public function getGeckoTime() {
1606 if (!isset($this->uadata['geckotime'])) {
1607 $this->uadata['geckotime'] = null;
1608 if (!is_null($this->getGeckoDate())) {
1609 $use_time = (strlen($this->getGeckoDate()) > 8);
1610 $gd_str = substr($this->getGeckoDate(),0,4).'-'.substr($this->getGeckoDate(),4,2).'-'.substr($this->getGeckoDate(),6,2);
1612 $gd_str .= substr($this->getGeckoDate(),8,2).':00';
1613 $old_tz = date_default_timezone_get();
1614 date_default_timezone_set("America/Los_Angeles");
1616 $this->uadata['geckotime'] = strtotime($gd_str);
1617 if ($use_time) { date_default_timezone_set($old_tz); }
1620 return $this->uadata['geckotime'];
1623 public function isBot() {
1627 public function isMobile() {
1628 if (!isset($this->uadata['os'])) {
1629 // getOS() makes sure that also the mobile tag is set correctly
1632 return $this->mobile;
1635 public function isns() {
1636 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1637 return (strpos($this->brand, 'Netscape') !== false);
1639 public function isns4() {
1640 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1641 return ((strpos($this->brand, 'Netscape') !== false) && (intval($this->version) == 4));
1643 public function isie() {
1644 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1645 return $this->hasEngine('trident');
1647 public function geckodate() {
1648 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1649 return (!is_null($this->getGeckoDate())?$this->getGeckoDate():0);
1651 public function geckobased() {
1652 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1653 return $this->hasEngine('gecko');
1655 public function khtmlbased() {
1656 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1657 return $this->hasEngine('khtml');