2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is KaiRo's userAgent detection.
17 * The Initial Developer of the Original Code is
18 * KaiRo - Robert Kaiser.
19 * Portions created by the Initial Developer are Copyright (C) 2003-2007
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s): Robert Kaiser <kairo@kairo.at>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 // userAgent PHP class
40 // get user agent and tell us what Browser is accessing
42 // function __construct([$ua_string])
43 // CONSTRUCTOR; reads UA string (or takes the optional given UA string) and gets info from that into our variables.
46 // the plain User Agent string
48 // the User Agent brand name
50 // the User Agent version
52 // bool: true if this agent is a bot
54 // bool: true if this agent is a mobile phone
56 // array of static user agent data (static vars in functions are set for all objects of this class!)
58 // public function getBrand()
59 // returns the User Agent Brand Name
61 // public function getVersion()
62 // returns the User Agent version
64 // public function getAcceptLanguages()
65 // returns an associated array with the accepted languages of this UA
66 // keys are language codes, values are q factors (weights)
68 // public function getUAString()
69 // returns the full User Agent string
71 // public function getEngine()
72 // returns a string telling the detected rendering engine, null if we can't detect
73 // one of gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|unknown
75 // public function hasEngine($rnd_engine)
76 // returns true if the given rendering engine was detected
78 // public function getEngineVersion()
79 // returns a the version number for the rendering engine
80 // this may be the same as getVersion() for many engines, or null if we don't know
82 // public function getOS()
83 // returns a string telling the detected operating system, null if we can't detect
84 // might be very verbose, uses no abbreviations for most names
86 // public function getPlatform()
87 // returns a string telling the detected OS platform, null if we can't detect
88 // one of windows|linux|mac|solaris|unknown
90 // public function getLanguage() {
91 // returns a string telling the detected browser UI language, null if we can't detect
92 // should be an ISO code
94 // public function isBot()
95 // returns true if User Agent seems to be a bot
97 // public function isMobile()
98 // returns true if User Agent seems to be a mobile phone
100 // *** functions that only return useable info for some agents ***
102 // public function getGeckoDate()
103 // returns the Gecko date for Gecko-based browsers, null for others
105 // public function getGeckoTime()
106 // returns the Gecko build date/time as a unix epoch time number for Gecko-based browsers, null for others
108 // *** functions for compat to older versions of this class ***
110 // public function isns()
111 // returns true if User Agent seems to be Netscape brand, false if not
112 // public function isns4()
113 // returns true if User Agent seems to be Netscape Communicator 4.x, false if not
114 // public function isie()
115 // returns true if User Agent seems to be a version of Internet Exploder, false if not
116 // public function geckobased()
117 // returns true if User Agent seems to be a Gecko-based browser, false if not
118 // public function geckodate()
119 // returns the Gecko date when it's a Gecko-based browser, 0 if not
120 // public function khtmlbased()
121 // returns true if User Agent seems to be a KHTML-based browser, false if not
123 // collection of some known User Agent Strings:
124 // *** see testbed/ua_list_raw.txt ***
125 // *** see also http://www.pgts.com.au/pgtsj/pgtsj0208c.html ***
130 private $bot = false;
131 private $mobile = false;
132 private $uadata = array();
134 function __construct($ua_string = '') {
135 // *** constructor ***
136 if (strlen($ua_string)) {
137 $this->uastring = $ua_string;
140 // read raw UA string
141 $this->uastring = $_SERVER['HTTP_USER_AGENT'];
144 // get UA brand and version
145 $this->brand = 'Unknown'; $this->version = null;
146 // find reasonable defaults
147 if (preg_match('|([0-9a-zA-Z\.:()_ -]+)/(\d[0-9a-zA-Z\._+-]*)|', $this->uastring, $regs)) {
148 $this->brand = trim($regs[1]);
149 $this->version = $regs[2];
151 elseif (preg_match('|^([a-zA-Z\._ -]+)[_ -][vV]?(\d[0-9a-zA-Z\.+]*)|', $this->uastring, $regs)) {
152 $this->brand = trim($regs[1]);
153 $this->version = $regs[2];
155 elseif (preg_match('|^([0-9a-zA-Z\._ -]+)|', $this->uastring, $regs)) {
156 $this->brand = trim($regs[1]);
157 $this->version = null;
159 $this->bot = (strpos(strtolower($this->brand), 'bot') !== false)
160 || (strpos(strtolower($this->brand), 'crawler') !== false)
161 || (strpos(strtolower($this->brand), 'spider') !== false)
162 || (strpos(strtolower($this->brand), 'search') !== false)
163 || (strpos(strtolower($this->brand), 'seek') !== false);
165 // search for any real and/or special UAs
166 if (preg_match('|Netscape6/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
167 $this->brand = 'Netscape';
168 $this->version = $regs[1];
171 elseif (preg_match('|Netscape/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
172 $this->brand = 'Netscape';
173 $this->version = $regs[1];
176 elseif (preg_match('|Navigator/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
177 $this->brand = 'Netscape';
178 $this->version = $regs[1];
181 elseif (preg_match('|Chimera/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
182 $this->brand = 'Chimera';
183 $this->version = $regs[1];
186 elseif (preg_match('|Camino/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
187 $this->brand = 'Camino';
188 $this->version = $regs[1];
191 elseif (preg_match('|Phoenix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
192 $this->brand = 'Phoenix';
193 $this->version = $regs[1];
196 elseif (preg_match('|Mozilla Firebird/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
197 $this->brand = 'Mozilla Firebird';
198 $this->version = $regs[1];
201 elseif (preg_match('|Flock/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
202 $this->brand = 'Flock';
203 $this->version = $regs[1];
206 elseif (preg_match('|SeaMonkey/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
207 $this->brand = 'SeaMonkey';
208 $this->version = $regs[1];
211 elseif (preg_match('|Iceape/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
212 $this->brand = 'IceApe'; // Debian-rebranded SeaMonkey
213 $this->version = $regs[1];
216 elseif (preg_match('|Iceweasel/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
217 $this->brand = 'IceWeasel'; // Debian-rebranded Firefox
218 $this->version = $regs[1];
221 elseif (preg_match('|Icedove/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
222 $this->brand = 'IceDove'; // Debian-rebranded Thunderbird
223 $this->version = $regs[1];
226 elseif (preg_match('|BonEcho/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
227 $this->brand = 'Bon Echo'; // Firefox 2.0 code name
228 $this->version = $regs[1];
231 elseif (preg_match('|GranParadiso/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
232 $this->brand = 'Gran Paradiso'; // Firefox 3.0 code name
233 $this->version = $regs[1];
236 elseif (preg_match('|Shiretoko/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
237 $this->brand = 'Shiretoko'; // Firefox 3.5 code name
238 $this->version = $regs[1];
241 elseif (preg_match('|Namoroka/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
242 $this->brand = 'Namoroka'; // Firefox 3.6 code name
243 $this->version = $regs[1];
246 elseif (preg_match('|Lorentz/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
247 $this->brand = 'Lorentz'; // Firefox 3.6 (with OOPP) code name
248 $this->version = $regs[1];
251 elseif (preg_match('|Minefield/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
252 $this->brand = 'Minefield'; // Firefox development nightly code name
253 $this->version = $regs[1];
256 elseif (preg_match('|PmWFx/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
257 $this->brand = 'PmW-Firefox';
258 $this->version = $regs[1];
261 elseif (preg_match('|BeZillaBrowser/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
262 $this->brand = 'BeZillaBrowser';
263 $this->version = $regs[1];
266 elseif (preg_match('|Songbird/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
267 $this->brand = 'Songbird';
268 $this->version = $regs[1];
271 elseif (preg_match('|Lanikai/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
272 $this->brand = 'Lanikai'; // Thunderbird 3.1 code name
273 $this->version = $regs[1];
276 elseif (preg_match('|Shredder/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
277 $this->brand = 'Shredder'; // Thunderbird development nightly code name
278 $this->version = $regs[1];
281 elseif (preg_match('|prism/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
282 $this->brand = 'Prism';
283 $this->version = $regs[1];
286 elseif (preg_match('|Minimo/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
287 $this->brand = 'Minimo';
288 $this->version = $regs[1];
290 $this->mobile = true;
292 elseif (preg_match('|Fennec/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
293 $this->brand = 'Fennec'; // Firefox mobile code name
294 $this->version = $regs[1];
296 $this->mobile = true;
298 elseif (preg_match('|Galeon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
299 $this->brand = 'Galeon';
300 $this->version = $regs[1];
303 elseif (preg_match('|Epiphany/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
304 $this->brand = 'Epiphany';
305 $this->version = $regs[1];
308 elseif (preg_match('|K-Meleon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
309 $this->brand = 'K-Meleon';
310 $this->version = $regs[1];
313 elseif (preg_match('|AOL[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
314 $this->brand = 'AOL';
315 $this->version = $regs[1];
318 elseif (preg_match('|Tablet browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
319 $this->brand = 'microB';
320 $this->version = $regs[1];
322 $this->mobile = true;
324 elseif (preg_match('|Maemo Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
325 $this->brand = 'microB';
326 $this->version = $regs[1];
328 $this->mobile = true;
330 elseif (preg_match('|Opera\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) {
331 $this->brand = 'Opera Mini';
332 $this->version = $regs[1];
334 $this->mobile = true;
336 elseif (preg_match('/Opera\/[^\(]+ \(.*; Opera Mini\/([^;]+); /i', $this->uastring, $regs)) {
337 $this->brand = 'Opera Mini';
338 $this->version = $regs[1];
340 $this->mobile = true;
342 elseif (preg_match('|Opera[ /]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
343 $this->brand = 'Opera';
344 $this->version = $regs[1];
347 elseif (preg_match('|OmniWeb/([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) {
348 $this->brand = 'OmniWeb';
349 $this->version = $regs[1];
352 elseif (preg_match('|Konqueror/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
353 $this->brand = 'Konqueror';
354 $this->version = $regs[1];
357 elseif (preg_match('|Shiira/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
358 $this->brand = 'Shiira';
359 $this->version = $regs[1];
362 elseif (preg_match('|Chrome/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
363 $this->brand = 'Chrome';
364 $this->version = $regs[1];
367 elseif (preg_match('|NokiaBrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
368 $this->brand = 'NokiaBrowser';
369 $this->version = $regs[1];
372 elseif (preg_match('|wOSBrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
373 $this->brand = 'webOS Browser';
374 $this->version = $regs[1];
377 elseif (preg_match('|Silk/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
378 $this->brand = 'Silk';
379 $this->version = $regs[1];
382 elseif (preg_match('|Kindle/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
383 $this->brand = 'Kindle';
384 $this->version = $regs[1];
387 elseif (preg_match('|Pre/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
388 $this->brand = 'Pre';
389 $this->version = $regs[1];
392 elseif (preg_match('|BOLT/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
393 $this->brand = 'BOLT';
394 $this->version = $regs[1];
397 elseif (preg_match('|Safari/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
398 if (preg_match('| Mobile(/[0-9a-zA-Z\.+]+)? ?Safari/|', $this->uastring)) {
399 $this->brand = 'Mobile Safari';
400 $this->mobile = true;
403 $this->brand = 'Safari';
405 if (preg_match('|Version/([0-9a-zA-Z\.+]+)|', $this->uastring, $vregs)) {
406 $this->version = $vregs[1];
409 $this->version = '('.$regs[1].')';
413 elseif (preg_match('|AppleWebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
414 $this->brand = 'AppleWebKit';
415 $this->version = $regs[1];
418 elseif (preg_match('|Spinn3r ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
419 $this->brand = 'Spinn3r';
420 $this->version = $regs[1];
423 elseif (preg_match('|Butterfly/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
424 $this->brand = 'Butterfly';
425 $this->version = $regs[1];
428 elseif (preg_match('|Googlebot/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
429 $this->brand = 'Googlebot';
430 $this->version = $regs[1];
433 elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
434 $this->brand = 'Firefox';
435 $this->version = $regs[1];
438 elseif (preg_match('|Thunderbird/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
439 $this->brand = 'Thunderbird';
440 $this->version = $regs[1];
443 elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) &&
444 strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) {
445 $this->brand = 'Mozilla';
446 $this->version = $regs[1];
449 elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) &&
450 strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) {
451 $this->brand = 'Mozilla';
452 $this->version = 'M'.$regs[1];
455 elseif (preg_match('|Baiduspider|i', $this->uastring)) {
456 $this->brand = 'BaiDuSpider';
457 $this->version = null;
460 elseif (preg_match('|YodaoBot-Mobile/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
461 $this->brand = 'YodaoBot-Mobile';
462 $this->version = $regs[1];
464 $this->mobile = true;
466 elseif (preg_match('|Googlebot-Mobile/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
467 $this->brand = 'Googlebot-Mobile';
468 $this->version = $regs[1];
470 $this->mobile = true;
472 elseif (preg_match('|FASTMobileCrawl/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
473 $this->brand = 'FASTMobileCrawl';
474 $this->version = $regs[1];
476 $this->mobile = true;
478 elseif (preg_match('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
479 $this->brand = 'Microsoft FrontPage';
480 $this->version = $regs[1];
483 elseif (preg_match('|iCab[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
484 $this->brand = 'iCab';
485 $this->version = $regs[1];
488 elseif (preg_match('|IBrowse[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
489 $this->brand = 'IBrowse';
490 $this->version = $regs[1];
493 elseif (preg_match('|ICEbrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
494 $this->brand = 'ICEbrowser';
495 $this->version = $regs[1];
498 elseif (preg_match('|ICE Browser/v([0-9a-zA-Z\._+]+)|', $this->uastring, $regs)) {
499 $this->brand = 'ICEbrowser';
500 $this->version = str_replace('_', '.', $regs[1]);
503 elseif (preg_match('|NetPositive/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
504 $this->brand = 'NetPositive';
505 $this->version = $regs[1];
508 elseif (preg_match('|WebPro/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
509 $this->brand = 'WebPro (Novarra)';
510 $this->version = $regs[1];
513 elseif (preg_match('|; OffByOne;|', $this->uastring, $regs)) {
514 $this->brand = 'Off By One';
515 $this->version = null;
518 elseif (preg_match('|PSP \(PlayStation Portable\); ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
519 $this->brand = 'PlayStation Portable';
520 $this->version = $regs[1];
522 $this->mobile = true;
524 elseif (preg_match('|PLAYSTATION 3; ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
525 $this->brand = 'PlayStation 3';
526 $this->version = $regs[1];
529 elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
530 $this->brand = 'NetFront';
531 $this->version = $regs[1];
533 $this->mobile = true;
535 elseif (preg_match('|UP.Browser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
536 $this->brand = 'UP.Browser';
537 $this->version = $regs[1];
539 $this->mobile = true;
541 elseif (preg_match('|UP.Link/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
542 $this->brand = 'UP.Link';
543 $this->version = $regs[1];
545 $this->mobile = true;
547 elseif (preg_match('|AU-MIC-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
548 $this->brand = 'Obigo';
549 $this->version = $regs[1];
551 $this->mobile = true;
553 elseif (preg_match('|Browser/Obigo-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
554 $this->brand = 'Obigo';
555 $this->version = $regs[1];
557 $this->mobile = true;
559 elseif (preg_match('|Nokia([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
560 $this->brand = 'Nokia';
561 $this->version = $regs[1];
563 $this->mobile = true;
565 elseif (preg_match('|SonyEricsson([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
566 $this->brand = 'SonyEricsson';
567 $this->version = $regs[1];
569 $this->mobile = true;
571 elseif (preg_match('|SIE-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
572 $this->brand = 'Siemens';
573 $this->version = $regs[1];
575 $this->mobile = true;
577 elseif (preg_match('|MOT-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
578 $this->brand = 'Motorola';
579 $this->version = $regs[1];
581 $this->mobile = true;
583 elseif (preg_match('|IXI/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
584 $this->brand = 'IXI';
585 $this->version = $regs[1];
587 $this->mobile = true;
589 elseif (preg_match('|NewsFox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
590 $this->brand = 'NewsFox';
591 $this->version = $regs[1];
594 elseif (preg_match('|rdfbot/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
595 $this->brand = 'rdfbot';
596 $this->version = $regs[1];
599 elseif (preg_match('|IBM-WebExplorer-DLL/v([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
600 $this->brand = 'WebExplorer';
601 $this->version = $regs[1];
604 elseif (preg_match('|ELinks \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) {
605 $this->brand = 'ELinks';
606 $this->version = $regs[1];
609 elseif (preg_match('|Links \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) {
610 $this->brand = 'Links';
611 $this->version = $regs[1];
614 elseif (preg_match('|WinHttp.WinHttpRequest.([0-9\.]+)|i', $this->uastring, $regs)) {
615 $this->brand = 'WinHttpRequest';
616 $this->version = $regs[1];
619 elseif (preg_match('|alpha[/ ]06; AmigaOS|i', $this->uastring, $regs)) {
620 $this->brand = 'Alpha 06';
621 $this->version = null;
624 elseif (preg_match('|; arexx[\);]|i', $this->uastring, $regs)) {
625 $this->brand = 'ARexx';
626 $this->version = null;
629 elseif (preg_match('|; Voyager; AmigaOS[\);]|i', $this->uastring, $regs)) {
630 $this->brand = 'AmigaVoyager';
631 $this->version = null;
634 elseif (preg_match('|AWEB ([0-9a-zA-Z\.+ ]+)|', $this->uastring, $regs)) {
635 $this->brand = 'AWEB';
636 $this->version = $regs[1];
639 elseif (preg_match('|X ([0-9a-zA-Z\.+ ]+); Commodore 64|', $this->uastring, $regs)) {
641 $this->version = $regs[1];
644 elseif (preg_match('|DB Browse ([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
645 $this->brand = 'DB Browse';
646 $this->version = $regs[1];
649 elseif (preg_match('|ZyBorg/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
650 $this->brand = 'ZyBorg';
651 $this->version = $regs[1];
654 elseif (preg_match('|Ask Jeeves/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
655 $this->brand = 'Ask Jeeves';
656 $this->version = $regs[1];
659 elseif (preg_match('|heritrix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
660 $this->brand = 'Heritrix';
661 $this->version = $regs[1];
664 elseif (preg_match('|heritrix([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) {
665 $this->brand = 'Heritrix';
666 $this->version = str_replace('-', '.', $regs[1]);
669 elseif (preg_match('|SBSearch/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
670 $this->brand = 'SBSearch';
671 $this->version = $regs[1];
674 elseif (preg_match('|Powermarks/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
675 $this->brand = 'Powermarks';
676 $this->version = $regs[1];
679 elseif (preg_match('|TopBlogsInfo/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
680 $this->brand = 'TopBlogsInfo';
681 $this->version = $regs[1];
684 elseif (preg_match('|picmole/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
685 $this->brand = 'picmole';
686 $this->version = $regs[1];
689 elseif (preg_match('|([0-9a-zA-Z\._+-]+bot)/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
690 $this->brand = $regs[1];
691 $this->version = $regs[2];
694 elseif (preg_match('|VoilaBot ((BETA )?[0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
695 $this->brand = 'VoilaBot';
696 $this->version = $regs[1];
699 elseif (preg_match('|Slurp|', $this->uastring, $regs)) {
700 $this->brand = 'Slurp';
701 $this->version = null;
704 elseif (preg_match('|Check&Get ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
705 $this->brand = 'Check&Get';
706 $this->version = $regs[1];
709 elseif (preg_match('|WebCapture ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
710 $this->brand = 'WebCapture';
711 $this->version = $regs[1];
714 elseif (preg_match('|WebMon ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
715 $this->brand = 'WebMon';
716 $this->version = $regs[1];
719 elseif (preg_match('|Gulper Web Bot ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
720 $this->brand = 'Gulper Web Bot';
721 $this->version = $regs[1];
724 elseif (preg_match('|HTTrack ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
725 $this->brand = 'HTTrack';
726 $this->version = $regs[1];
729 elseif (preg_match('|Advista Crawler ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
730 $this->brand = 'HTTrack';
731 $this->version = $regs[1];
734 elseif (preg_match('|Seznam screenshot-generator ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
735 $this->brand = 'Seznam screenshot-generator';
736 $this->version = $regs[1];
739 elseif (preg_match('|Yahoo! SearchMonkey ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
740 $this->brand = 'Yahoo! SearchMonkey';
741 $this->version = $regs[1];
744 elseif (preg_match('|Yahoo Pipes ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
745 $this->brand = 'Yahoo! Pipes';
746 $this->version = $regs[1];
749 elseif (preg_match('|Firebat ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
750 $this->brand = 'Firebat';
751 $this->version = $regs[1];
754 elseif (preg_match('|Twiceler-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
755 $this->brand = 'Twiceler';
756 $this->version = $regs[1];
759 elseif (preg_match('|Nu_?tch-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
760 $this->brand = 'Nutch';
761 $this->version = $regs[1];
764 elseif (preg_match('|Microsoft URL Control - ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
765 $this->brand = 'Microsoft URL Control';
766 $this->version = $regs[1];
769 elseif (preg_match('|([0-9a-zA-Z\.+]+)_AC-Plug|', $this->uastring, $regs)) {
770 $this->brand = 'AC-Plug';
771 $this->version = $regs[1];
774 elseif (preg_match('|^Internet Explorer 5.5|', $this->uastring)) {
775 $this->brand = 'Unknown bot (IE5.5)';
776 $this->version = null;
779 elseif (preg_match('|^Mozilla[\s ]*$|', $this->uastring)) {
780 $this->brand = 'Unknown bot (Mozilla)';
781 $this->version = null;
784 elseif (preg_match('|ICCrawler|i', $this->uastring, $regs)) {
785 $this->brand = 'ICCrawler';
786 $this->version = null;
789 elseif (preg_match('|KaloogaBot|', $this->uastring, $regs)) {
790 $this->brand = 'KaloogaBot';
791 $this->version = null;
794 elseif (preg_match('|ScoutJet|', $this->uastring, $regs)) {
795 $this->brand = 'ScoutJet';
796 $this->version = null;
799 elseif (preg_match('|http://www.livedir.net|', $this->uastring, $regs)) {
800 $this->brand = 'livedir.net';
801 $this->version = null;
804 elseif (preg_match('|WebClipping.com|', $this->uastring, $regs)) {
805 $this->brand = 'WebClipping.com';
806 $this->version = null;
809 elseif (preg_match('|newstin.com|', $this->uastring, $regs)) {
810 $this->brand = 'newstin.com';
811 $this->version = null;
814 elseif (preg_match('|http://www.almaden.ibm.com/cs/crawler|', $this->uastring)) {
815 $this->brand = 'almaden crawler';
816 $this->version = null;
819 elseif (preg_match('|B-l-i-t-z-B-O-T|', $this->uastring) ||
820 preg_match('|B l i t z B O T @ t r i c u s . n e t|', $this->uastring)) {
821 $this->brand = 'BlitzBOT';
822 $this->version = null;
825 elseif (preg_match('|Really Gmane.org\'s favicon grabber|', $this->uastring)) {
826 $this->brand = 'Really Gmane.org\'s favicon grabber';
827 $this->version = null;
830 elseif (preg_match('|Girafabot|', $this->uastring)) {
831 $this->brand = 'Girafabot';
832 $this->version = null;
835 elseif (preg_match('|Arachmo|', $this->uastring)) {
836 $this->brand = 'Arachmo';
837 $this->version = null;
840 elseif (preg_match('|OsO|', $this->uastring)) {
841 $this->brand = 'OsO';
842 $this->version = null;
845 elseif (preg_match('|Yoono|', $this->uastring)) {
846 $this->brand = 'Yoono';
847 $this->version = null;
850 elseif (preg_match('|efp@gmx.net|', $this->uastring)) {
851 $this->brand = 'efp';
852 $this->version = null;
855 elseif (preg_match('|Indy Library|', $this->uastring)) {
856 $this->brand = 'Indy Library';
857 $this->version = null;
860 elseif (preg_match('|Linkman|', $this->uastring)) {
861 $this->brand = 'Linkman';
862 $this->version = null;
865 elseif (preg_match('|Sage|', $this->uastring, $regs)) {
866 $this->brand = 'Sage';
867 $this->version = null;
870 elseif (preg_match('|Google Desktop|', $this->uastring)) {
871 $this->brand = 'Google Desktop';
872 $this->version = null;
875 elseif (preg_match('|^Firefly|', $this->uastring)) {
876 // comes here with correct value but would be detected as MSIE
878 elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) {
879 $this->brand = 'Steganos Internet Anonym';
880 $this->version = $regs[1];
883 elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) {
884 $this->brand = 'Steganos Internet Anonym';
885 $this->version = $regs[1];
888 elseif (preg_match('|BorderManager ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
889 $this->brand = 'BorderManager';
890 $this->version = $regs[1];
893 elseif (preg_match('|WebWasher ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
894 $this->brand = 'WebWasher';
895 $this->version = $regs[1];
898 elseif (preg_match('|SaferSurf|', $this->uastring, $regs)) {
899 $this->brand = 'SaferSurf';
900 $this->version = null;
903 elseif (preg_match('|Avant Browser[^/]|', $this->uastring)) {
904 $this->brand = 'Avant Browser';
905 $this->version = null;
908 elseif (preg_match('|Browser[^/]+(http://www.avantbrowser.com)|', $this->uastring)) {
909 $this->brand = 'Avant Browser';
910 $this->version = null;
913 elseif (preg_match('|Maxthon|', $this->uastring)) {
914 $this->brand = 'Maxthon';
915 $this->version = null;
918 elseif (preg_match('|MyIE2|', $this->uastring)) {
919 $this->brand = 'MyIE2';
920 $this->version = null;
923 elseif (preg_match('|Crazy Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
924 $this->brand = 'Crazy Browser';
925 $this->version = $regs[1];
928 elseif (preg_match('|AvantGo ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
929 $this->brand = 'AvantGo';
930 $this->version = $regs[1];
933 elseif (preg_match('|MSN ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
934 $this->brand = 'MSN';
935 $this->version = $regs[1];
938 elseif (preg_match('|America Online Browser [0-9a-zA-Z\.+]+; rev([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
939 $this->brand = 'AOL Browser';
940 $this->version = $regs[1];
943 elseif (preg_match('|MS FrontPage ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
944 $this->brand = 'Microsoft FrontPage';
945 $this->version = $regs[1];
948 elseif (preg_match('|Microsoft Internet Explorer/4.0b1|', $this->uastring, $regs)) {
949 $this->brand = 'Microsoft Internet Explorer';
950 $this->version = '1.0';
953 elseif (preg_match('|MSIE 7\.0.+Trident/4.0|', $this->uastring, $regs)) {
954 $this->brand = 'Microsoft Internet Explorer';
955 $this->version = "8.0";
958 elseif (preg_match('|MSIE 7\.0.+Trident/5.0|', $this->uastring, $regs)) {
959 $this->brand = 'Microsoft Internet Explorer';
960 $this->version = "9.0";
963 elseif (preg_match('|MSIE 7\.0.+Trident/6.0|', $this->uastring, $regs)) {
964 $this->brand = 'Microsoft Internet Explorer';
965 $this->version = "10.0";
968 elseif (preg_match('|Trident\/[0-9a-zA-Z\.+]+; ([^\)]+; )?rv:([0-9\.+]+)|', $this->uastring, $regs)) {
969 $this->brand = 'Microsoft Internet Explorer';
970 $this->version = $regs[2];
973 elseif (preg_match('|MSIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
974 $this->brand = 'Microsoft Internet Explorer';
975 $this->version = $regs[1];
978 elseif (preg_match('|MSPIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
979 $this->brand = 'Microsoft Pocket Internet Explorer';
980 $this->version = $regs[1];
982 $this->mobile = true;
984 elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) &&
985 (strpos($this->uastring, 'compatible') === false) && (strpos($this->uastring, 'Gecko/') === false) &&
986 (intval($regs[1]) < 5)) {
987 $this->brand = 'Netscape';
988 $this->version = $regs[1];
989 if (intval($this->version) == 4) { $this->brand .= ' Communicator'; }
992 elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
993 $this->brand = (strpos($this->uastring, 'compatible') !== false)?'Mozilla-compatible (unknown)':'Mozilla (unknown)';
994 $this->version = null;
998 $botArray = array('Scooter','Spinne','Vagabondo','Firefly','Scrubby','NG','Pompos','Szukacz','Schmozilla','42_HAL',
999 'NetResearchServer','LinkWalker','Zeus','W3C_Validator','ZyBorg','Ask Jeeves','ia_archiver',
1000 'PingALink Monitoring Services','IlTrovatore-Setaccio','Nutch','Mercator','search.ch',
1001 'appie','larbin','NutchCVS','Webchat','Mediapartners-Google','sitecheck.internetseer.com',
1002 'FavOrg','findlinks','DataCha0s','ichiro','Francis','CoralWebPrx','DoCoMo','Ocelli','Sogou Video',
1003 'Yandex','Yeti','Austronaut-URL-Checker');
1005 if (in_array($this->brand, $botArray)) {
1009 if (($this->brand == 'Microsoft Pocket Internet Explorer') ||
1010 (strpos($this->brand, 'BlackBerry') !== false)) {
1011 $this->mobile = true;
1015 public function getBrand() { return $this->brand; }
1016 public function getVersion() { return $this->version; }
1018 public function getAcceptLanguages() {
1019 if (!isset($this->uadata['accept-languages'])) {
1020 $headers = getAllHeaders();
1021 $accLcomp = explode(',', $headers['Accept-Language']);
1023 foreach ($accLcomp as $lcomp) {
1024 if (strlen($lcomp)) {
1025 $ldef = explode(';', $lcomp);
1026 $accLang[$ldef[0]] = (float)((strpos(@$ldef[1],'q=')===0)?substr($ldef[1],2):1);
1029 $this->uadata['accept-languages'] = $accLang;
1031 return $this->uadata['accept-languages'];
1034 public function getUAString() { 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 ((strpos($this->brand, 'Internet Explorer') !== false) || (strpos($this->brand, 'FrontPage') !== false)) {
1054 if ((strpos(strtolower($this->uastring), 'mac') !== false) && (intval($this->getVersion()) >= 5)) {
1055 $this->uadata['engine'] = 'tasman';
1058 $this->uadata['engine'] = 'trident';
1061 elseif (preg_match('|WebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
1062 $this->uadata['engine'] = 'webkit';
1063 $this->uadata['eng_version'] = $regs[1];
1065 elseif ((strpos($this->brand, 'Konqueror') !== false) || (strpos($this->brand, 'OmniWeb') !== false)) {
1066 $this->uadata['engine'] = 'khtml';
1068 elseif (strpos($this->brand, 'Netscape') !== false) {
1069 // non-Gecko Netscape browsers
1070 if (intval($this->version) <= 4) {
1071 $this->uadata['engine'] = 'nscp';
1073 elseif (strpos($this->uastring, 'MSIE') !== false) {
1074 $this->uadata['engine'] = 'trident';
1077 elseif (strpos($this->brand, 'Opera') !== false) {
1078 $this->uadata['engine'] = 'presto';
1080 elseif ((strpos($this->brand, 'iTunes') !== false) || (strpos($this->brand, 'nook browser') !== false)) {
1081 $this->uadata['engine'] = 'webkit';
1083 elseif (strpos($this->brand, 'Dillo') !== false) {
1084 $this->uadata['engine'] = 'gzilla';
1086 elseif ((strpos($this->brand, 'ELinks') !== false) || (strpos($this->brand, 'Links') !== false)) {
1087 $this->uadata['engine'] = 'links';
1089 elseif ((strpos($this->brand, 'Lynx') !== false)) {
1090 $this->uadata['engine'] = 'lynx';
1092 elseif ((strpos($this->brand, 'ICEbrowser') !== false) || (strpos($this->brand, 'ICE Browser') !== false)) {
1093 $this->uadata['engine'] = 'icestorm';
1095 elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
1096 $this->uadata['engine'] = 'netfront';
1097 $this->uadata['eng_version'] = $regs[1];
1099 elseif ((strpos($this->brand, 'PlayStation') !== false) || (strpos($this->brand, 'NetFront') !== false)) {
1100 $this->uadata['engine'] = 'netfront';
1102 elseif ((strpos($this->brand, 'Avant') !== false) || (strpos($this->brand, 'Crazy Browser') !== false) ||
1103 (strpos($this->brand, 'AOL') !== false) || (strpos($this->brand, 'MSN') !== false) ||
1104 (strpos($this->brand, 'MyIE2') !== false) || (strpos($this->brand, 'Maxthon') !== false)) {
1105 $this->uadata['engine'] = 'trident';
1107 elseif (strpos($this->brand, 'Galeon') !== false) {
1108 $this->uadata['engine'] = 'gecko';
1110 elseif (strpos($this->brand, 'WebPro') !== false) {
1111 $this->uadata['engine'] = 'nscp';
1115 return $this->uadata['engine'];
1118 public function hasEngine($rnd_engine) { return ($this->getEngine() == $rnd_engine); }
1120 public function getEngineVersion() {
1121 if (!isset($this->uadata['eng_version'])) {
1122 $this->uadata['eng_version'] = null;
1123 // getOS() should get the date for us
1126 return $this->uadata['eng_version'];
1129 public function getOS() {
1130 if (!isset($this->uadata['os'])) {
1131 $this->uadata['os'] = null;
1133 if ($this->hasEngine('gecko')) {
1134 if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1135 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1136 $this->uadata['lang'] = (strpos($regs[4],'chrome://')===false)?$regs[4]:null;
1137 $this->uadata['eng_version'] = $regs[5];
1139 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1140 $this->uadata['os'] = $regs[2];
1141 $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null;
1142 $this->uadata['eng_version'] = $regs[4];
1144 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1145 $this->uadata['os'] = $regs[2];
1146 $this->uadata['lang'] = null;
1147 $this->uadata['eng_version'] = $regs[3];
1149 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); x64; rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1150 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1151 $this->uadata['lang'] = null;
1152 $this->uadata['eng_version'] = $regs[3];
1154 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1155 $this->uadata['os'] = $regs[2];
1156 $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null;
1157 $this->uadata['eng_version'] = $regs[4];
1159 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
1160 $this->uadata['os'] = $regs[2];
1161 $this->uadata['lang'] = $regs[3];
1162 $this->uadata['eng_version'] = 'M'.$regs[4];
1164 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
1165 $this->uadata['os'] = $regs[1];
1166 $this->uadata['lang'] = $regs[2];
1167 $this->uadata['eng_version'] = 'M'.$regs[3];
1169 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1170 $this->uadata['os'] = $regs[2];
1171 $this->uadata['lang'] = $regs[3];
1172 $this->uadata['eng_version'] = null;
1174 elseif (preg_match('#Mozilla/5.0 \(([^;]+); (WOW64|Mobile|Tablet); rv:([^\);]+)\)#', $this->uastring, $regs)) {
1175 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1176 $this->uadata['lang'] = null;
1177 $this->uadata['eng_version'] = $regs[3];
1178 $this->mobile = ($regs[2] == 'Mobile');
1180 elseif (preg_match('#Mozilla/5.0 \((Mobile|Tablet); [^;]+; rv:([^\);]+)\)#', $this->uastring, $regs)) {
1181 $this->uadata['os'] = 'Firefox OS';
1182 $this->uadata['lang'] = null;
1183 $this->uadata['eng_version'] = $regs[2];
1184 $this->mobile = ($regs[1] == 'Mobile');
1186 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
1187 if ((strpos($regs[2], 'Linux') !== false) && ($regs[1] != 'X11')) {
1188 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1191 $this->uadata['os'] = $regs[2];
1193 $this->uadata['lang'] = null;
1194 $this->uadata['eng_version'] = $regs[3];
1196 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^\);]+)\)|', $this->uastring, $regs)) {
1197 $this->uadata['os'] = $regs[2];
1198 $this->uadata['lang'] = null;
1199 $this->uadata['eng_version'] = null;
1201 elseif (preg_match('#Mozilla/5.0 \((Mobile|Tablet); rv:([^\);]+)\)#', $this->uastring, $regs)) {
1202 $this->uadata['os'] = 'Firefox OS';
1203 $this->uadata['lang'] = null;
1204 $this->uadata['eng_version'] = $regs[2];
1205 $this->mobile = ($regs[1] == 'Mobile');
1207 elseif (preg_match('|Mozilla/5.0 \(([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
1208 $this->uadata['os'] = $regs[1];
1209 $this->uadata['lang'] = null;
1210 $this->uadata['eng_version'] = $regs[2];
1212 elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) {
1213 $this->uadata['os'] = $regs[2];
1214 $this->uadata['lang'] = null;
1215 $this->uadata['eng_version'] = null;
1217 elseif (preg_match('|Debian/|', $this->uastring, $regs)) {
1218 $this->uadata['os'] = 'Debian Linux';
1219 $this->uadata['lang'] = null;
1220 $this->uadata['eng_version'] = null;
1223 elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) {
1224 if (preg_match('/Mozilla\/[^\(]+ \((IE [^;]+[^\)]*; )?((?:Mac|Win)[^;]+); ?(Win64|WOW64); ?Trident\/([^;\)]+);/i', $this->uastring, $regs)) {
1225 $this->uadata['eng_version'] = $regs[4];
1226 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1227 $this->uadata['lang'] = null;
1229 elseif (preg_match('/Mozilla\/[^\(]+ \((IE [^;]+[^\)]*; )?((?:Mac|Win)[^;]+); ?Trident\/([^;\)]+);/i', $this->uastring, $regs)) {
1230 $this->uadata['eng_version'] = $regs[3];
1231 $this->uadata['os'] = $regs[2];
1232 $this->uadata['lang'] = null;
1234 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) {
1235 $this->uadata['eng_version'] = $regs[3];
1236 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1237 $this->uadata['lang'] = null;
1239 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) {
1240 $this->uadata['eng_version'] = $regs[2];
1241 $this->uadata['os'] = $regs[1];
1242 $this->uadata['lang'] = null;
1244 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*\)/i', $this->uastring, $regs)) {
1245 $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$regs[1];
1246 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1247 $this->uadata['lang'] = null;
1248 $this->mobile = (strpos($this->uastring,'MSPIE') !== false);
1250 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
1251 $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$regs[1];
1252 $this->uadata['os'] = $regs[2];
1253 $this->uadata['lang'] = null;
1254 $this->mobile = (strpos($this->uastring,'MSPIE') !== false);
1256 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
1257 $this->uadata['eng_version'] = "ie".$regs[1];
1258 $this->uadata['os'] = null;
1259 $this->uadata['lang'] = null;
1261 elseif (preg_match('/Microsoft Internet Explorer\/[^\s]+ \(((?:Mac|Win)[^;\)]+)\)/i', $this->uastring, $regs)) {
1262 $this->uadata['eng_version'] = "ie".$this->getVersion();
1263 $this->uadata['os'] = $regs[1];
1264 $this->uadata['lang'] = null;
1266 elseif (preg_match('/Microsoft Pocket Internet Explorer\/[^\s]+/i', $this->uastring, $regs)) {
1267 $this->uadata['eng_version'] = null;
1268 $this->uadata['os'] = 'Windows CE';
1269 $this->uadata['lang'] = null;
1272 elseif ($this->hasEngine('khtml')) {
1273 if (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^;]+); ([^;]+); ([^;]+); ([^\);]+)\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
1274 $this->uadata['eng_version'] = strlen($regs[6])?$regs[6]:$regs[1];
1275 $this->uadata['os'] = $regs[2];
1276 $this->uadata['lang'] = $regs[5];
1278 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^\);]+)[^\)]*\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
1279 $this->uadata['eng_version'] = strlen($regs[3])?$regs[3]:$regs[1];
1280 $this->uadata['os'] = $regs[2];
1281 $this->uadata['lang'] = null;
1283 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^\);]+)\)/i', $this->uastring, $regs)) {
1284 $this->uadata['os'] = $regs[1];
1285 $this->uadata['lang'] = null;
1286 $this->uadata['eng_version'] = null;
1289 elseif ($this->hasEngine('webkit')) {
1290 if (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+); ([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1291 $this->uadata['os'] = $regs[2];
1292 $this->uadata['lang'] = $regs[3];
1294 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1295 if (strpos($regs[3], '/') !== false) {
1296 $this->uadata['os'] = $regs[1];
1297 $this->uadata['lang'] = null;
1300 $this->uadata['os'] = $regs[2];
1301 $this->uadata['lang'] = $regs[3];
1304 elseif (preg_match('|Mozilla/5.0 \(([^;]+); Linux; ([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) {
1305 $this->uadata['os'] = $regs[2];
1306 $this->uadata['lang'] = $regs[3];
1308 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) {
1309 $this->uadata['os'] = $regs[1];
1310 $this->uadata['lang'] = $regs[2];
1312 elseif (preg_match('|Mozilla/5.0 \(Linux; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1313 // (Chrome for) Android - $regs[2] is device
1314 $this->uadata['os'] = $regs[1];
1315 $this->uadata['lang'] = null;
1317 elseif (preg_match('|Mozilla/5.0 \(([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1318 if (($regs[1] == 'X11') || ($regs[1] == 'Macintosh') || ($regs[1] == 'iPhone')) {
1319 $this->uadata['os'] = $regs[2];
1322 $this->uadata['os'] = $regs[1];
1323 if ($regs[2] == 'NokiaN9') {
1324 $this->uadata['os'] .= ' Harmattan';
1327 $this->uadata['lang'] = null;
1329 elseif (preg_match('|Mozilla/5.0 \(([^\);]+)\)|', $this->uastring, $regs)) {
1330 $this->uadata['os'] = $regs[1];
1331 $this->uadata['lang'] = null;
1333 elseif (preg_match('|Midori/[^\(]+ \((?:X11; )?([^;]+); U; ([^\)]+)\)|i', $this->uastring, $regs)) {
1334 $this->uadata['os'] = $regs[1];
1335 $this->uadata['lang'] = $regs[2];
1337 if ($this->brand == 'Silk') {
1338 // For some reason, Amazon spoofs us and tells us it's on MacOS X!
1339 $this->uadata['os'] = 'Android';
1341 if (preg_match('| Mobile |', $this->uastring)) {
1342 $this->mobile = true;
1345 elseif ($this->hasEngine('presto')) {
1347 if (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1348 $this->uadata['eng_version'] = $this->getVersion();
1349 $this->uadata['os'] = $regs[1];
1350 $this->uadata['lang'] = $regs[2];
1352 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;\)]+)[^\)]*\) Opera [^ ]+\s+\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1353 $this->uadata['eng_version'] = $this->getVersion();
1354 $this->uadata['os'] = $regs[1];
1355 $this->uadata['lang'] = $regs[2];
1357 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+\) Opera [^ ]+\s+\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1358 $this->uadata['eng_version'] = $this->getVersion();
1359 $this->uadata['os'] = $regs[1];
1360 $this->uadata['lang'] = $regs[2];
1363 elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini; ([a-z_-]+); /i', $this->uastring, $regs)) {
1364 $this->uadata['eng_version'] = null;
1365 $this->uadata['os'] = $regs[2];
1366 $this->uadata['lang'] = $regs[3];
1368 elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini\/[^;]+; ([a-z_-]+); /i', $this->uastring, $regs)) {
1369 $this->uadata['eng_version'] = $regs[1];
1370 $this->uadata['os'] = $regs[2];
1371 $this->uadata['lang'] = $regs[3];
1374 elseif (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+); [^\)]+; ([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\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
1380 $this->uadata['eng_version'] = $this->getVersion();
1381 $this->uadata['os'] = $regs[1];
1382 $this->uadata['lang'] = $regs[2];
1384 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
1385 $this->uadata['eng_version'] = $this->getVersion();
1386 $this->uadata['os'] = $regs[1];
1387 $this->uadata['lang'] = $regs[2];
1389 // Opera 9 Firefox-spoofing
1390 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+); rv:([^\);]+)\) Gecko\/\d+ Firefox\/[0-9a-zA-Z\.+]+ Opera [^ ]+/i', $this->uastring, $regs)) {
1391 $this->uadata['eng_version'] = $this->getVersion();
1392 $this->uadata['os'] = $regs[1];
1393 $this->uadata['lang'] = $regs[2];
1395 if (preg_match('| Mobi|', $this->uastring)) {
1396 $this->mobile = true;
1399 elseif ($this->hasEngine('nscp')) {
1400 if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {
1401 $this->uadata['eng_version'] = $regs[1];
1402 $this->uadata['os'] = $regs[3];
1403 $this->uadata['lang'] = $regs[2];
1405 elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
1406 $this->uadata['eng_version'] = $regs[1];
1407 $this->uadata['os'] = $regs[3];
1408 $this->uadata['lang'] = $regs[2];
1410 elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+)[^\(]+\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
1411 $this->uadata['eng_version'] = $regs[1];
1412 $this->uadata['os'] = $regs[2];
1413 $this->uadata['lang'] = null;
1416 elseif ($this->hasEngine('gzilla')) {
1417 $this->uadata['eng_version'] = $this->getVersion();
1418 $this->uadata['os'] = null;
1419 $this->uadata['lang'] = null;
1421 elseif ($this->hasEngine('links')) {
1422 if (preg_match('/E?Links[^\(]+\([^;]+; ([^;]+)[^\)]+\)/i', $this->uastring, $regs)) {
1423 $this->uadata['eng_version'] = null;
1424 $this->uadata['os'] = $regs[1];
1425 $this->uadata['lang'] = null;
1428 elseif ($this->hasEngine('lynx')) {
1429 $this->uadata['eng_version'] = $this->getVersion();
1430 $this->uadata['os'] = null;
1431 $this->uadata['lang'] = null;
1433 elseif ($this->hasEngine('icestorm')) {
1434 if (preg_match('/ICE Browser\/v?([0-9a-zA-Z\._+]+) \(Java [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {
1435 $this->uadata['eng_version'] = str_replace('_', '.', $regs[1]);
1436 $this->uadata['os'] = $regs[2];
1437 $this->uadata['lang'] = null;
1439 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\).* ICEbrowser\/([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) {
1440 $this->uadata['eng_version'] = $regs[3];
1441 $this->uadata['os'] = $regs[1];
1442 $this->uadata['lang'] = $regs[2];
1446 $this->uadata['eng_version'] = null;
1447 $this->uadata['lang'] = null;
1448 if (preg_match('/AmigaOS/i', $this->uastring, $regs)) {
1449 $this->uadata['os'] = 'AmigaOS';
1451 if (preg_match('/Commodore 64/i', $this->uastring, $regs)) {
1452 $this->uadata['os'] = 'Commodore 64';
1454 elseif (preg_match('/curl\/[^\(]+\(([^\);]+)/i', $this->uastring, $regs)) {
1455 $this->uadata['os'] = $regs[1];
1457 elseif (preg_match('/NCSA[_ ]Mosaic\/[^\(]+\((?:.*;)?([^\);]+)/i', $this->uastring, $regs)) {
1458 $this->uadata['os'] = trim($regs[1]);
1460 elseif (preg_match('/iCab.*(Mac[^\);]+).*?\)/i', $this->uastring, $regs)) {
1461 $this->uadata['os'] = trim($regs[1]);
1463 elseif (preg_match('/SymbianOS\/([^ ]+)/i', $this->uastring, $regs)) {
1464 $this->uadata['os'] = 'SymbianOS '.$regs[1];
1467 if ($this->uadata['os'] == 'Win 9x 4.90') { $this->uadata['os'] = 'Windows ME'; }
1468 elseif ($this->uadata['os'] == 'WinNT4.0') { $this->uadata['os'] = 'Windows NT 4.0'; }
1469 elseif ($this->uadata['os'] == 'Windows NT 5.0') { $this->uadata['os'] = 'Windows 2000'; }
1470 elseif ($this->uadata['os'] == 'Windows NT 5.1') { $this->uadata['os'] = 'Windows XP'; }
1471 elseif ($this->uadata['os'] == 'Windows NT 5.1 (Win64)') { $this->uadata['os'] = 'Windows XP (64bit)'; }
1472 elseif ($this->uadata['os'] == 'Windows NT 5.1 (WOW64)') { $this->uadata['os'] = 'Windows XP (64bit)'; }
1473 elseif ($this->uadata['os'] == 'Windows NT 5.2') { $this->uadata['os'] = 'Windows 2003'; }
1474 elseif ($this->uadata['os'] == 'Windows NT 5.2 x64') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1475 elseif ($this->uadata['os'] == 'Windows NT 5.2 (Win64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1476 elseif ($this->uadata['os'] == 'Windows NT 5.2 (WOW64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1477 elseif ($this->uadata['os'] == 'Windows NT 6.0') { $this->uadata['os'] = 'Windows Vista'; }
1478 elseif ($this->uadata['os'] == 'Windows NT 6.0 (Win64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; }
1479 elseif ($this->uadata['os'] == 'Windows NT 6.0 (WOW64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; }
1480 elseif ($this->uadata['os'] == 'Windows NT 6.1') { $this->uadata['os'] = 'Windows 7'; }
1481 elseif ($this->uadata['os'] == 'Windows NT 6.1 (Win64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; }
1482 elseif ($this->uadata['os'] == 'Windows NT 6.1 (WOW64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; }
1483 elseif ($this->uadata['os'] == 'Windows NT 6.2') { $this->uadata['os'] = 'Windows 8'; }
1484 elseif ($this->uadata['os'] == 'Windows NT 6.2 (Win64)') { $this->uadata['os'] = 'Windows 8 (64bit)'; }
1485 elseif ($this->uadata['os'] == 'Windows NT 6.2 (WOW64)') { $this->uadata['os'] = 'Windows 8 (64bit)'; }
1486 elseif ($this->uadata['os'] == 'Windows NT 6.3') { $this->uadata['os'] = 'Windows 8.1'; }
1487 elseif ($this->uadata['os'] == 'Windows NT 6.3 (Win64)') { $this->uadata['os'] = 'Windows 8.1 (64bit)'; }
1488 elseif ($this->uadata['os'] == 'Windows NT 6.3 (WOW64)') { $this->uadata['os'] = 'Windows 8.1 (64bit)'; }
1489 elseif ($this->uadata['os'] == 'Win95') { $this->uadata['os'] = 'Windows 95'; }
1490 elseif ($this->uadata['os'] == 'Win98') { $this->uadata['os'] = 'Windows 98'; }
1491 elseif ($this->uadata['os'] == 'WinNT') { $this->uadata['os'] = 'Windows NT'; }
1492 elseif ($this->uadata['os'] == 'Win32') { $this->uadata['os'] = 'Windows (32bit)'; }
1493 elseif ($this->uadata['os'] == 'Win64') { $this->uadata['os'] = 'Windows (64bit)'; }
1494 elseif (preg_match('/iPhone OS ([\d_]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'iOS '.str_replace('_', '.', $regs[1]); }
1495 elseif (preg_match('/Mac ?OS ?X/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; }
1496 elseif (preg_match('/Mac_P(ower|)PC/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; }
1497 elseif (strpos($this->uadata['os'], 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }
1498 elseif (strpos($this->uadata['os'], 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }
1499 elseif (strpos($this->uadata['os'], 'apple') !== false) { $this->uadata['os'] = 'MacOS'; }
1500 elseif (strpos($this->uadata['os'], 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; }
1501 elseif (preg_match('/(?:web|hpw)OS\/([0-9a-zA-Z\._+]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'webOS '.$regs[1]; }
1502 elseif (preg_match('/Android \(Linux (.+)\)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'Android '.$regs[1]; }
1503 elseif (strpos($this->uadata['os'], 'linux') !== false) { $this->uadata['os'] = 'Linux'; }
1504 elseif (preg_match('/SymbianOS[\/ ]([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) { $this->uadata['os'] = 'SymbianOS '.$regs[1]; }
1505 elseif (preg_match('/Symbian ?OS/i', $this->uadata['os'])) { $this->uadata['os'] = 'SymbianOS'; }
1507 if (strpos($this->uadata['os'], 'Win') !== false) { $this->uadata['platform'] = 'Windows'; }
1508 elseif (strpos($this->uadata['os'], 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; }
1509 elseif (strpos($this->uadata['os'], 'iOS') !== false) { $this->uadata['platform'] = 'Macintosh'; }
1510 elseif (strpos($this->uadata['os'], 'Linux') !== false) { $this->uadata['platform'] = 'Linux'; }
1511 elseif (strpos($this->uadata['os'], 'MeeGo') !== false) { $this->uadata['platform'] = 'Linux'; }
1512 elseif (strpos($this->uadata['os'], 'webOS') !== false) { $this->uadata['platform'] = 'Linux'; }
1513 elseif (strpos($this->uadata['os'], 'Android') !== false) { $this->uadata['platform'] = 'Android'; }
1514 elseif (strpos($this->uadata['os'], 'Solaris') !== false) { $this->uadata['platform'] = 'Solaris'; }
1515 elseif (strpos($this->uadata['os'], 'SunOS') !== false) { $this->uadata['platform'] = 'Solaris'; }
1516 elseif (strpos($this->uadata['os'], 'BeOS') !== false) { $this->uadata['platform'] = 'BeOS'; }
1517 elseif (strpos($this->uadata['os'], 'BePC') !== false) { $this->uadata['platform'] = 'BeOS'; }
1518 elseif (strpos($this->uadata['os'], 'FreeBSD') !== false) { $this->uadata['platform'] = 'FreeBSD'; }
1519 elseif (strpos($this->uadata['os'], 'OpenBSD') !== false) { $this->uadata['platform'] = 'OpenBSD'; }
1520 elseif (strpos($this->uadata['os'], 'NetBSD') !== false) { $this->uadata['platform'] = 'NetBSD'; }
1521 elseif (strpos($this->uadata['os'], 'AIX') !== false) { $this->uadata['platform'] = 'AIX'; }
1522 elseif (strpos($this->uadata['os'], 'IRIX') !== false) { $this->uadata['platform'] = 'IRIX'; }
1523 elseif (strpos($this->uadata['os'], 'HP-UX') !== false) { $this->uadata['platform'] = 'HP-UX'; }
1524 elseif (strpos($this->uadata['os'], 'AmigaOS') !== false) { $this->uadata['platform'] = 'Amiga'; }
1525 elseif (strpos($this->uadata['os'], 'webOS') !== false) { $this->uadata['platform'] = 'webOS'; }
1526 elseif (strpos($this->uadata['os'], 'Commodore 64') !== false) { $this->uadata['platform'] = 'C64'; }
1527 elseif (strpos($this->uadata['os'], 'OpenVMS') !== false) { $this->uadata['platform'] = 'OpenVMS'; }
1528 elseif (strpos($this->uadata['os'], 'Warp') !== false) { $this->uadata['platform'] = 'OS/2'; }
1529 elseif (strpos($this->uadata['os'], 'OS/2') !== false) { $this->uadata['platform'] = 'OS/2'; }
1530 elseif (strpos($this->uadata['os'], 'SymbianOS') !== false) { $this->uadata['platform'] = 'SymbianOS'; }
1531 elseif (strpos($this->uadata['os'], 'BlackBerry') !== false) { $this->uadata['platform'] = 'BlackBerry'; }
1532 elseif (strpos($this->uadata['os'], 'Gameboy') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1533 elseif (strpos($this->uadata['os'], 'Wii') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1534 elseif (strpos($this->uadata['os'], 'Nintendo') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1535 elseif (strpos($this->uadata['os'], 'J2ME') !== false) { $this->uadata['platform'] = 'Java'; }
1536 elseif (strpos($this->uadata['os'], 'CYGWIN') !== false) { $this->uadata['platform'] = 'Windows'; }
1537 elseif (strpos($this->uadata['os'], 'mingw') !== false) { $this->uadata['platform'] = 'Windows'; }
1538 else { $this->uadata['platform'] = $this->uadata['os']; }
1540 if (strpos($this->uadata['os'], 'Windows Phone OS') !== false) { $this->mobile = true; }
1541 elseif (strpos($this->uadata['os'], 'Gameboy') !== false) { $this->mobile = true; }
1543 $this->uadata['lang'] = str_replace('_', '-', @$this->uadata['lang']);
1546 return $this->uadata['os'];
1549 public function getPlatform() {
1550 if (!isset($this->uadata['platform'])) {
1551 $this->uadata['platform'] = null;
1552 // getOS() should get the date for us
1555 return $this->uadata['platform'];
1558 public function getLanguage() {
1559 if (!isset($this->uadata['lang'])) {
1560 $this->uadata['lang'] = null;
1561 // getOS() should get the date for us
1564 return $this->uadata['lang'];
1567 public function getGeckoDate() {
1568 if (!isset($this->uadata['geckodate'])) {
1569 $this->uadata['geckodate'] = null;
1570 // getEngine() should get the date for us
1573 return $this->uadata['geckodate'];
1576 public function getGeckoTime() {
1577 if (!isset($this->uadata['geckotime'])) {
1578 $this->uadata['geckotime'] = null;
1579 if (!is_null($this->getGeckoDate())) {
1580 $use_time = (strlen($this->getGeckoDate()) > 8);
1581 $gd_str = substr($this->getGeckoDate(),0,4).'-'.substr($this->getGeckoDate(),4,2).'-'.substr($this->getGeckoDate(),6,2);
1583 $gd_str .= substr($this->getGeckoDate(),8,2).':00';
1584 $old_tz = date_default_timezone_get();
1585 date_default_timezone_set("America/Los_Angeles");
1587 $this->uadata['geckotime'] = strtotime($gd_str);
1588 if ($use_time) { date_default_timezone_set($old_tz); }
1591 return $this->uadata['geckotime'];
1594 public function isBot() { return $this->bot; }
1596 public function isMobile() {
1597 if (!isset($this->uadata['os'])) {
1598 // getOS() makes sure that also the mobile tag is set correctly
1601 return $this->mobile;
1604 public function isns() {
1605 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1606 return (strpos($this->brand, 'Netscape') !== false);
1608 public function isns4() {
1609 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1610 return ((strpos($this->brand, 'Netscape') !== false) && (intval($this->version) == 4));
1612 public function isie() {
1613 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1614 return $this->hasEngine('trident');
1616 public function geckodate() {
1617 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1618 return (!is_null($this->getGeckoDate())?$this->getGeckoDate():0);
1620 public function geckobased() {
1621 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1622 return $this->hasEngine('gecko');
1624 public function khtmlbased() {
1625 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1626 return $this->hasEngine('khtml');