remove a debug line that disturbs output
[php-utility-classes.git] / include / classes / useragent.php-class
... / ...
CommitLineData
1<?php
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
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/
9 *
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
13 * License.
14 *
15 * The Original Code is KaiRo's userAgent detection.
16 *
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.
21 *
22 * Contributor(s): Robert Kaiser <kairo@kairo.at>
23 *
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.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38class userAgent {
39 // userAgent PHP class
40 // get user agent and tell us what Browser is accessing
41 //
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.
44 //
45 // private $uastring
46 // the plain User Agent string
47 // private $brand
48 // the User Agent brand name
49 // private $version
50 // the User Agent version
51 // private $bot
52 // bool: true if this agent is a bot
53 // private $uadata
54 // array of static user agent data (static vars in functions are set for all objects of this class!)
55 //
56 // public function getBrand()
57 // returns the User Agent Brand Name
58 //
59 // public function getVersion()
60 // returns the User Agent version
61 //
62 // public function getAcceptLanguages()
63 // returns an associated array with the accepted languages of this UA
64 // keys are language codes, values are q factors (weights)
65 //
66 // public function getUAString()
67 // returns the full User Agent string
68 //
69 // public function getEngine()
70 // returns a string telling the detected rendering engine, null if we can't detect
71 // one of gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|unknown
72 //
73 // public function hasEngine($rnd_engine)
74 // returns true if the given rendering engine was detected
75 //
76 // public function getEngineVersion()
77 // returns a the version number for the rendering engine
78 // this may be the same as getVersion() for many engines, or null if we don't know
79 //
80 // public function getOS()
81 // returns a string telling the detected operating system, null if we can't detect
82 // might be very verbose, uses no abbreviations for most names
83 //
84 // public function getPlatform()
85 // returns a string telling the detected OS platform, null if we can't detect
86 // one of windows|linux|mac|solaris|unknown
87 //
88 // public function getLanguage() {
89 // returns a string telling the detected browser UI language, null if we can't detect
90 // should be an ISO code
91 //
92 // public function isBot()
93 // returns true if User Agent seems to be a bot
94 //
95 // *** functions that only return useable info for some agents ***
96 //
97 // public function getGeckoDate()
98 // returns the Gecko date for Gecko-based browsers, null for others
99 //
100 // public function getGeckoTime()
101 // returns the Gecko build date/time as a unix epoch time number for Gecko-based browsers, null for others
102 //
103 // *** functions for compat to older versions of this class ***
104 //
105 // public function isns()
106 // returns true if User Agent seems to be Netscape brand, false if not
107 // public function isns4()
108 // returns true if User Agent seems to be Netscape Communicator 4.x, false if not
109 // public function isie()
110 // returns true if User Agent seems to be a version of Internet Exploder, false if not
111 // public function geckobased()
112 // returns true if User Agent seems to be a Gecko-based browser, false if not
113 // public function geckodate()
114 // returns the Gecko date when it's a Gecko-based browser, 0 if not
115 // public function khtmlbased()
116 // returns true if User Agent seems to be a KHTML-based browser, false if not
117
118 // collection of some known User Agent Strings:
119 // *** see testbed/ua_list_raw.txt ***
120 // *** see also http://www.pgts.com.au/pgtsj/pgtsj0208c.html ***
121
122 private $uastring;
123 private $brand;
124 private $version;
125 private $bot = false;
126 private $uadata = array();
127
128 function __construct($ua_string = '') {
129 // *** constructor ***
130 if (strlen($ua_string)) {
131 $this->uastring = $ua_string;
132 }
133 else {
134 // read raw UA string
135 $this->uastring = $_SERVER['HTTP_USER_AGENT'];
136 }
137
138 // get UA brand and version
139 $this->brand = 'Unknown'; $this->version = null;
140 // find reasonable defaults
141 if (preg_match('|([0-9a-zA-Z\.:()_ -]+)/(\d[0-9a-zA-Z\._+-]*)|', $this->uastring, $regs)) {
142 $this->brand = trim($regs[1]);
143 $this->version = $regs[2];
144 }
145 elseif (preg_match('|^([a-zA-Z\._ -]+)[_ -][vV]?(\d[0-9a-zA-Z\.+]*)|', $this->uastring, $regs)) {
146 $this->brand = trim($regs[1]);
147 $this->version = $regs[2];
148 }
149 elseif (preg_match('|^([0-9a-zA-Z\._ -]+)|', $this->uastring, $regs)) {
150 $this->brand = trim($regs[1]);
151 $this->version = null;
152 }
153 $this->bot = (strpos(strtolower($this->brand), 'bot') !== false)
154 || (strpos(strtolower($this->brand), 'crawler') !== false)
155 || (strpos(strtolower($this->brand), 'spider') !== false)
156 || (strpos(strtolower($this->brand), 'search') !== false)
157 || (strpos(strtolower($this->brand), 'seek') !== false);
158
159 // search for any real and/or special UAs
160 if (preg_match('|Netscape6/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
161 $this->brand = 'Netscape';
162 $this->version = $regs[1];
163 $this->bot = false;
164 }
165 elseif (preg_match('|Netscape/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
166 $this->brand = 'Netscape';
167 $this->version = $regs[1];
168 $this->bot = false;
169 }
170 elseif (preg_match('|Navigator/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
171 $this->brand = 'Netscape';
172 $this->version = $regs[1];
173 $this->bot = false;
174 }
175 elseif (preg_match('|Chimera/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
176 $this->brand = 'Chimera';
177 $this->version = $regs[1];
178 $this->bot = false;
179 }
180 elseif (preg_match('|Camino/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
181 $this->brand = 'Camino';
182 $this->version = $regs[1];
183 $this->bot = false;
184 }
185 elseif (preg_match('|Phoenix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
186 $this->brand = 'Phoenix';
187 $this->version = $regs[1];
188 $this->bot = false;
189 }
190 elseif (preg_match('|Mozilla Firebird/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
191 $this->brand = 'Mozilla Firebird';
192 $this->version = $regs[1];
193 $this->bot = false;
194 }
195 elseif (preg_match('|Flock/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
196 $this->brand = 'Flock';
197 $this->version = $regs[1];
198 $this->bot = false;
199 }
200 elseif (preg_match('|SeaMonkey/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
201 $this->brand = 'SeaMonkey';
202 $this->version = $regs[1];
203 $this->bot = false;
204 }
205 elseif (preg_match('|Iceape/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
206 $this->brand = 'IceApe'; // Debian-rebranded SeaMonkey
207 $this->version = $regs[1];
208 $this->bot = false;
209 }
210 elseif (preg_match('|Iceweasel/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
211 $this->brand = 'IceWeasel'; // Debian-rebranded Firefox
212 $this->version = $regs[1];
213 $this->bot = false;
214 }
215 elseif (preg_match('|Icedove/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
216 $this->brand = 'IceDove'; // Debian-rebranded Thunderbird
217 $this->version = $regs[1];
218 $this->bot = false;
219 }
220 elseif (preg_match('|BonEcho/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
221 $this->brand = 'Bon Echo'; // Firefox 2.0 code name
222 $this->version = $regs[1];
223 $this->bot = false;
224 }
225 elseif (preg_match('|GranParadiso/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
226 $this->brand = 'Gran Paradiso'; // Firefox 3.0 code name
227 $this->version = $regs[1];
228 $this->bot = false;
229 }
230 elseif (preg_match('|Shiretoko/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
231 $this->brand = 'Shiretoko'; // Firefox 3.5 code name
232 $this->version = $regs[1];
233 $this->bot = false;
234 }
235 elseif (preg_match('|Namoroka/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
236 $this->brand = 'Namoroka'; // Firefox 3.6 code name
237 $this->version = $regs[1];
238 $this->bot = false;
239 }
240 elseif (preg_match('|Lorentz/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
241 $this->brand = 'Lorentz'; // Firefox 3.6 (with OOPP) code name
242 $this->version = $regs[1];
243 $this->bot = false;
244 }
245 elseif (preg_match('|Minefield/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
246 $this->brand = 'Minefield'; // Firefox development nightly code name
247 $this->version = $regs[1];
248 $this->bot = false;
249 }
250 elseif (preg_match('|PmWFx/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
251 $this->brand = 'PmW-Firefox';
252 $this->version = $regs[1];
253 $this->bot = false;
254 }
255 elseif (preg_match('|BeZillaBrowser/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
256 $this->brand = 'BeZillaBrowser';
257 $this->version = $regs[1];
258 $this->bot = false;
259 }
260 elseif (preg_match('|Songbird/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
261 $this->brand = 'Songbird';
262 $this->version = $regs[1];
263 $this->bot = false;
264 }
265 elseif (preg_match('|Lanikai/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
266 $this->brand = 'Lanikai'; // Thunderbird 3.1 code name
267 $this->version = $regs[1];
268 $this->bot = false;
269 }
270 elseif (preg_match('|Shredder/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
271 $this->brand = 'Shredder'; // Thunderbird development nightly code name
272 $this->version = $regs[1];
273 $this->bot = false;
274 }
275 elseif (preg_match('|prism/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
276 $this->brand = 'Prism';
277 $this->version = $regs[1];
278 $this->bot = false;
279 }
280 elseif (preg_match('|Minimo/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
281 $this->brand = 'Minimo';
282 $this->version = $regs[1];
283 $this->bot = false;
284 }
285 elseif (preg_match('|Fennec/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
286 $this->brand = 'Fennec'; // Firefox mobile code name
287 $this->version = $regs[1];
288 $this->bot = false;
289 }
290 elseif (preg_match('|Galeon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
291 $this->brand = 'Galeon';
292 $this->version = $regs[1];
293 $this->bot = false;
294 }
295 elseif (preg_match('|Epiphany/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
296 $this->brand = 'Epiphany';
297 $this->version = $regs[1];
298 $this->bot = false;
299 }
300 elseif (preg_match('|K-Meleon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
301 $this->brand = 'K-Meleon';
302 $this->version = $regs[1];
303 $this->bot = false;
304 }
305 elseif (preg_match('|AOL[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
306 $this->brand = 'AOL';
307 $this->version = $regs[1];
308 $this->bot = false;
309 }
310 elseif (preg_match('|Tablet browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
311 $this->brand = 'microB';
312 $this->version = $regs[1];
313 $this->bot = false;
314 }
315 elseif (preg_match('|Maemo Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
316 $this->brand = 'microB';
317 $this->version = $regs[1];
318 $this->bot = false;
319 }
320 elseif (preg_match('|Opera\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) {
321 $this->brand = 'Opera Mini';
322 $this->version = $regs[1];
323 $this->bot = false;
324 }
325 elseif (preg_match('/Opera\/[^\(]+ \(.*; Opera Mini\/([^;]+); /i', $this->uastring, $regs)) {
326 $this->brand = 'Opera Mini';
327 $this->version = $regs[1];
328 $this->bot = false;
329 }
330 elseif (preg_match('|Opera[ /]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
331 $this->brand = 'Opera';
332 $this->version = $regs[1];
333 $this->bot = false;
334 }
335 elseif (preg_match('|OmniWeb/([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) {
336 $this->brand = 'OmniWeb';
337 $this->version = $regs[1];
338 $this->bot = false;
339 }
340 elseif (preg_match('|Konqueror/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
341 $this->brand = 'Konqueror';
342 $this->version = $regs[1];
343 $this->bot = false;
344 }
345 elseif (preg_match('|Shiira/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
346 $this->brand = 'Shiira';
347 $this->version = $regs[1];
348 $this->bot = false;
349 }
350 elseif (preg_match('|Chrome/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
351 $this->brand = 'Chrome';
352 $this->version = $regs[1];
353 $this->bot = false;
354 }
355 elseif (preg_match('|NokiaBrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
356 $this->brand = 'NokiaBrowser';
357 $this->version = $regs[1];
358 $this->bot = false;
359 }
360 elseif (preg_match('|wOSBrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
361 $this->brand = 'webOS Browser';
362 $this->version = $regs[1];
363 $this->bot = false;
364 }
365 elseif (preg_match('|Silk/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
366 $this->brand = 'Silk';
367 $this->version = $regs[1];
368 $this->bot = false;
369 }
370 elseif (preg_match('|Kindle/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
371 $this->brand = 'Kindle';
372 $this->version = $regs[1];
373 $this->bot = false;
374 }
375 elseif (preg_match('|Pre/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
376 $this->brand = 'Pre';
377 $this->version = $regs[1];
378 $this->bot = false;
379 }
380 elseif (preg_match('|BOLT/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
381 $this->brand = 'BOLT';
382 $this->version = $regs[1];
383 $this->bot = false;
384 }
385 elseif (preg_match('|Safari/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
386 if (preg_match('| Mobile(/[0-9a-zA-Z\.+]+)? Safari/|', $this->uastring)) {
387 $this->brand = 'Mobile Safari';
388 }
389 else {
390 $this->brand = 'Safari';
391 }
392 if (preg_match('|Version/([0-9a-zA-Z\.+]+)|', $this->uastring, $vregs)) {
393 $this->version = $vregs[1];
394 }
395 else {
396 $this->version = '('.$regs[1].')';
397 }
398 $this->bot = false;
399 }
400 elseif (preg_match('|AppleWebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
401 $this->brand = 'AppleWebKit';
402 $this->version = $regs[1];
403 $this->bot = false;
404 }
405 elseif (preg_match('|Spinn3r ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
406 $this->brand = 'Spinn3r';
407 $this->version = $regs[1];
408 $this->bot = true;
409 }
410 elseif (preg_match('|Butterfly/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
411 $this->brand = 'Butterfly';
412 $this->version = $regs[1];
413 $this->bot = true;
414 }
415 elseif (preg_match('|Googlebot/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
416 $this->brand = 'Googlebot';
417 $this->version = $regs[1];
418 $this->bot = true;
419 }
420 elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
421 $this->brand = 'Firefox';
422 $this->version = $regs[1];
423 $this->bot = false;
424 }
425 elseif (preg_match('|Thunderbird/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
426 $this->brand = 'Thunderbird';
427 $this->version = $regs[1];
428 $this->bot = false;
429 }
430 elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) &&
431 strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) {
432 $this->brand = 'Mozilla';
433 $this->version = $regs[1];
434 $this->bot = false;
435 }
436 elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) &&
437 strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) {
438 $this->brand = 'Mozilla';
439 $this->version = 'M'.$regs[1];
440 $this->bot = false;
441 }
442 elseif (preg_match('|Baiduspider|i', $this->uastring)) {
443 $this->brand = 'BaiDuSpider';
444 $this->version = null;
445 $this->bot = true;
446 }
447 elseif (preg_match('|YodaoBot-Mobile/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
448 $this->brand = 'YodaoBot-Mobile';
449 $this->version = $regs[1];
450 $this->bot = true;
451 }
452 elseif (preg_match('|Googlebot-Mobile/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
453 $this->brand = 'Googlebot-Mobile';
454 $this->version = $regs[1];
455 $this->bot = true;
456 }
457 elseif (preg_match('|FASTMobileCrawl/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { /* looks like Gecko! */
458 $this->brand = 'FASTMobileCrawl';
459 $this->version = $regs[1];
460 $this->bot = true;
461 }
462 elseif (preg_match('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
463 $this->brand = 'Microsoft FrontPage';
464 $this->version = $regs[1];
465 $this->bot = false;
466 }
467 elseif (preg_match('|iCab[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
468 $this->brand = 'iCab';
469 $this->version = $regs[1];
470 $this->bot = false;
471 }
472 elseif (preg_match('|IBrowse[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
473 $this->brand = 'IBrowse';
474 $this->version = $regs[1];
475 $this->bot = false;
476 }
477 elseif (preg_match('|ICEbrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
478 $this->brand = 'ICEbrowser';
479 $this->version = $regs[1];
480 $this->bot = false;
481 }
482 elseif (preg_match('|ICE Browser/v([0-9a-zA-Z\._+]+)|', $this->uastring, $regs)) {
483 $this->brand = 'ICEbrowser';
484 $this->version = str_replace('_', '.', $regs[1]);
485 $this->bot = false;
486 }
487 elseif (preg_match('|NetPositive/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
488 $this->brand = 'NetPositive';
489 $this->version = $regs[1];
490 $this->bot = false;
491 }
492 elseif (preg_match('|WebPro/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
493 $this->brand = 'WebPro (Novarra)';
494 $this->version = $regs[1];
495 $this->bot = false;
496 }
497 elseif (preg_match('|; OffByOne;|', $this->uastring, $regs)) {
498 $this->brand = 'Off By One';
499 $this->version = null;
500 $this->bot = false;
501 }
502 elseif (preg_match('|PSP \(PlayStation Portable\); ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
503 $this->brand = 'PlayStation Portable';
504 $this->version = $regs[1];
505 $this->bot = false;
506 }
507 elseif (preg_match('|PLAYSTATION 3; ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
508 $this->brand = 'PlayStation 3';
509 $this->version = $regs[1];
510 $this->bot = false;
511 }
512 elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
513 $this->brand = 'NetFront';
514 $this->version = $regs[1];
515 $this->bot = false;
516 }
517 elseif (preg_match('|UP.Browser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
518 $this->brand = 'UP.Browser';
519 $this->version = $regs[1];
520 $this->bot = false;
521 }
522 elseif (preg_match('|UP.Link/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
523 $this->brand = 'UP.Link';
524 $this->version = $regs[1];
525 $this->bot = false;
526 }
527 elseif (preg_match('|AU-MIC-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
528 $this->brand = 'Obigo';
529 $this->version = $regs[1];
530 $this->bot = false;
531 }
532 elseif (preg_match('|Browser/Obigo-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
533 $this->brand = 'Obigo';
534 $this->version = $regs[1];
535 $this->bot = false;
536 }
537 elseif (preg_match('|Nokia([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
538 $this->brand = 'Nokia';
539 $this->version = $regs[1];
540 $this->bot = false;
541 }
542 elseif (preg_match('|SonyEricsson([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
543 $this->brand = 'SonyEricsson';
544 $this->version = $regs[1];
545 $this->bot = false;
546 }
547 elseif (preg_match('|SIE-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
548 $this->brand = 'Siemens';
549 $this->version = $regs[1];
550 $this->bot = false;
551 }
552 elseif (preg_match('|MOT-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
553 $this->brand = 'Motorola';
554 $this->version = $regs[1];
555 $this->bot = false;
556 }
557 elseif (preg_match('|IXI/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
558 $this->brand = 'IXI';
559 $this->version = $regs[1];
560 $this->bot = false;
561 }
562 elseif (preg_match('|NewsFox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
563 $this->brand = 'NewsFox';
564 $this->version = $regs[1];
565 $this->bot = false;
566 }
567 elseif (preg_match('|rdfbot/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
568 $this->brand = 'rdfbot';
569 $this->version = $regs[1];
570 $this->bot = false;
571 }
572 elseif (preg_match('|IBM-WebExplorer-DLL/v([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
573 $this->brand = 'WebExplorer';
574 $this->version = $regs[1];
575 $this->bot = false;
576 }
577 elseif (preg_match('|ELinks \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) {
578 $this->brand = 'ELinks';
579 $this->version = $regs[1];
580 $this->bot = false;
581 }
582 elseif (preg_match('|Links \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) {
583 $this->brand = 'Links';
584 $this->version = $regs[1];
585 $this->bot = false;
586 }
587 elseif (preg_match('|WinHttp.WinHttpRequest.([0-9\.]+)|i', $this->uastring, $regs)) {
588 $this->brand = 'WinHttpRequest';
589 $this->version = $regs[1];
590 $this->bot = false;
591 }
592 elseif (preg_match('|alpha[/ ]06; AmigaOS|i', $this->uastring, $regs)) {
593 $this->brand = 'Alpha 06';
594 $this->version = null;
595 $this->bot = false;
596 }
597 elseif (preg_match('|; arexx[\);]|i', $this->uastring, $regs)) {
598 $this->brand = 'ARexx';
599 $this->version = null;
600 $this->bot = false;
601 }
602 elseif (preg_match('|; Voyager; AmigaOS[\);]|i', $this->uastring, $regs)) {
603 $this->brand = 'AmigaVoyager';
604 $this->version = null;
605 $this->bot = false;
606 }
607 elseif (preg_match('|AWEB ([0-9a-zA-Z\.+ ]+)|', $this->uastring, $regs)) {
608 $this->brand = 'AWEB';
609 $this->version = $regs[1];
610 $this->bot = false;
611 }
612 elseif (preg_match('|X ([0-9a-zA-Z\.+ ]+); Commodore 64|', $this->uastring, $regs)) {
613 $this->brand = 'X';
614 $this->version = $regs[1];
615 $this->bot = false;
616 }
617 elseif (preg_match('|DB Browse ([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
618 $this->brand = 'DB Browse';
619 $this->version = $regs[1];
620 $this->bot = false;
621 }
622 elseif (preg_match('|ZyBorg/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
623 $this->brand = 'ZyBorg';
624 $this->version = $regs[1];
625 $this->bot = true;
626 }
627 elseif (preg_match('|Ask Jeeves/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
628 $this->brand = 'Ask Jeeves';
629 $this->version = $regs[1];
630 $this->bot = true;
631 }
632 elseif (preg_match('|heritrix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
633 $this->brand = 'Heritrix';
634 $this->version = $regs[1];
635 $this->bot = true;
636 }
637 elseif (preg_match('|heritrix([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) {
638 $this->brand = 'Heritrix';
639 $this->version = str_replace('-', '.', $regs[1]);
640 $this->bot = true;
641 }
642 elseif (preg_match('|SBSearch/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
643 $this->brand = 'SBSearch';
644 $this->version = $regs[1];
645 $this->bot = true;
646 }
647 elseif (preg_match('|Powermarks/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
648 $this->brand = 'Powermarks';
649 $this->version = $regs[1];
650 $this->bot = true;
651 }
652 elseif (preg_match('|TopBlogsInfo/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
653 $this->brand = 'TopBlogsInfo';
654 $this->version = $regs[1];
655 $this->bot = true;
656 }
657 elseif (preg_match('|picmole/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
658 $this->brand = 'picmole';
659 $this->version = $regs[1];
660 $this->bot = true;
661 }
662 elseif (preg_match('|([0-9a-zA-Z\._+-]+bot)/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
663 $this->brand = $regs[1];
664 $this->version = $regs[2];
665 $this->bot = true;
666 }
667 elseif (preg_match('|VoilaBot ((BETA )?[0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) {
668 $this->brand = 'VoilaBot';
669 $this->version = $regs[1];
670 $this->bot = true;
671 }
672 elseif (preg_match('|Slurp|', $this->uastring, $regs)) {
673 $this->brand = 'Slurp';
674 $this->version = null;
675 $this->bot = true;
676 }
677 elseif (preg_match('|Check&amp;Get ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
678 $this->brand = 'Check&Get';
679 $this->version = $regs[1];
680 $this->bot = true;
681 }
682 elseif (preg_match('|WebCapture ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
683 $this->brand = 'WebCapture';
684 $this->version = $regs[1];
685 $this->bot = true;
686 }
687 elseif (preg_match('|WebMon ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
688 $this->brand = 'WebMon';
689 $this->version = $regs[1];
690 $this->bot = true;
691 }
692 elseif (preg_match('|Gulper Web Bot ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
693 $this->brand = 'Gulper Web Bot';
694 $this->version = $regs[1];
695 $this->bot = true;
696 }
697 elseif (preg_match('|HTTrack ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
698 $this->brand = 'HTTrack';
699 $this->version = $regs[1];
700 $this->bot = true;
701 }
702 elseif (preg_match('|Advista Crawler ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
703 $this->brand = 'HTTrack';
704 $this->version = $regs[1];
705 $this->bot = true;
706 }
707 elseif (preg_match('|Seznam screenshot-generator ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
708 $this->brand = 'Seznam screenshot-generator';
709 $this->version = $regs[1];
710 $this->bot = true;
711 }
712 elseif (preg_match('|Yahoo! SearchMonkey ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
713 $this->brand = 'Yahoo! SearchMonkey';
714 $this->version = $regs[1];
715 $this->bot = true;
716 }
717 elseif (preg_match('|Yahoo Pipes ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
718 $this->brand = 'Yahoo! Pipes';
719 $this->version = $regs[1];
720 $this->bot = true;
721 }
722 elseif (preg_match('|Firebat ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
723 $this->brand = 'Firebat';
724 $this->version = $regs[1];
725 $this->bot = true;
726 }
727 elseif (preg_match('|Twiceler-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
728 $this->brand = 'Twiceler';
729 $this->version = $regs[1];
730 $this->bot = true;
731 }
732 elseif (preg_match('|Nu_?tch-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
733 $this->brand = 'Nutch';
734 $this->version = $regs[1];
735 $this->bot = true;
736 }
737 elseif (preg_match('|Microsoft URL Control - ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
738 $this->brand = 'Microsoft URL Control';
739 $this->version = $regs[1];
740 $this->bot = true;
741 }
742 elseif (preg_match('|([0-9a-zA-Z\.+]+)_AC-Plug|', $this->uastring, $regs)) {
743 $this->brand = 'AC-Plug';
744 $this->version = $regs[1];
745 $this->bot = true;
746 }
747 elseif (preg_match('|^Internet Explorer 5.5|', $this->uastring)) {
748 $this->brand = 'Unknown bot (IE5.5)';
749 $this->version = null;
750 $this->bot = true;
751 }
752 elseif (preg_match('|^Mozilla[\s ]*$|', $this->uastring)) {
753 $this->brand = 'Unknown bot (Mozilla)';
754 $this->version = null;
755 $this->bot = true;
756 }
757 elseif (preg_match('|ICCrawler|i', $this->uastring, $regs)) {
758 $this->brand = 'ICCrawler';
759 $this->version = null;
760 $this->bot = true;
761 }
762 elseif (preg_match('|KaloogaBot|', $this->uastring, $regs)) {
763 $this->brand = 'KaloogaBot';
764 $this->version = null;
765 $this->bot = true;
766 }
767 elseif (preg_match('|ScoutJet|', $this->uastring, $regs)) {
768 $this->brand = 'ScoutJet';
769 $this->version = null;
770 $this->bot = true;
771 }
772 elseif (preg_match('|http://www.livedir.net|', $this->uastring, $regs)) {
773 $this->brand = 'livedir.net';
774 $this->version = null;
775 $this->bot = true;
776 }
777 elseif (preg_match('|WebClipping.com|', $this->uastring, $regs)) {
778 $this->brand = 'WebClipping.com';
779 $this->version = null;
780 $this->bot = true;
781 }
782 elseif (preg_match('|newstin.com|', $this->uastring, $regs)) {
783 $this->brand = 'newstin.com';
784 $this->version = null;
785 $this->bot = true;
786 }
787 elseif (preg_match('|http://www.almaden.ibm.com/cs/crawler|', $this->uastring)) {
788 $this->brand = 'almaden crawler';
789 $this->version = null;
790 $this->bot = true;
791 }
792 elseif (preg_match('|B-l-i-t-z-B-O-T|', $this->uastring) ||
793 preg_match('|B l i t z B O T @ t r i c u s . n e t|', $this->uastring)) {
794 $this->brand = 'BlitzBOT';
795 $this->version = null;
796 $this->bot = true;
797 }
798 elseif (preg_match('|Really Gmane.org\'s favicon grabber|', $this->uastring)) {
799 $this->brand = 'Really Gmane.org\'s favicon grabber';
800 $this->version = null;
801 $this->bot = true;
802 }
803 elseif (preg_match('|Girafabot|', $this->uastring)) {
804 $this->brand = 'Girafabot';
805 $this->version = null;
806 $this->bot = true;
807 }
808 elseif (preg_match('|Arachmo|', $this->uastring)) {
809 $this->brand = 'Arachmo';
810 $this->version = null;
811 $this->bot = true;
812 }
813 elseif (preg_match('|OsO|', $this->uastring)) {
814 $this->brand = 'OsO';
815 $this->version = null;
816 $this->bot = true;
817 }
818 elseif (preg_match('|Yoono|', $this->uastring)) {
819 $this->brand = 'Yoono';
820 $this->version = null;
821 $this->bot = true;
822 }
823 elseif (preg_match('|efp@gmx.net|', $this->uastring)) {
824 $this->brand = 'efp';
825 $this->version = null;
826 $this->bot = true;
827 }
828 elseif (preg_match('|Indy Library|', $this->uastring)) {
829 $this->brand = 'Indy Library';
830 $this->version = null;
831 $this->bot = true;
832 }
833 elseif (preg_match('|Linkman|', $this->uastring)) {
834 $this->brand = 'Linkman';
835 $this->version = null;
836 $this->bot = true;
837 }
838 elseif (preg_match('|Sage|', $this->uastring, $regs)) {
839 $this->brand = 'Sage';
840 $this->version = null;
841 $this->bot = true;
842 }
843 elseif (preg_match('|Google Desktop|', $this->uastring)) {
844 $this->brand = 'Google Desktop';
845 $this->version = null;
846 $this->bot = true;
847 }
848 elseif (preg_match('|^Firefly|', $this->uastring)) {
849 // comes here with correct value but would be detected as MSIE
850 }
851 elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) {
852 $this->brand = 'Steganos Internet Anonym';
853 $this->version = $regs[1];
854 $this->bot = false;
855 }
856 elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) {
857 $this->brand = 'Steganos Internet Anonym';
858 $this->version = $regs[1];
859 $this->bot = false;
860 }
861 elseif (preg_match('|BorderManager ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
862 $this->brand = 'BorderManager';
863 $this->version = $regs[1];
864 $this->bot = false;
865 }
866 elseif (preg_match('|WebWasher ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
867 $this->brand = 'WebWasher';
868 $this->version = $regs[1];
869 $this->bot = false;
870 }
871 elseif (preg_match('|SaferSurf|', $this->uastring, $regs)) {
872 $this->brand = 'SaferSurf';
873 $this->version = null;
874 $this->bot = false;
875 }
876 elseif (preg_match('|Avant Browser[^/]|', $this->uastring)) {
877 $this->brand = 'Avant Browser';
878 $this->version = null;
879 $this->bot = false;
880 }
881 elseif (preg_match('|Browser[^/]+(http://www.avantbrowser.com)|', $this->uastring)) {
882 $this->brand = 'Avant Browser';
883 $this->version = null;
884 $this->bot = false;
885 }
886 elseif (preg_match('|Maxthon|', $this->uastring)) {
887 $this->brand = 'Maxthon';
888 $this->version = null;
889 $this->bot = false;
890 }
891 elseif (preg_match('|MyIE2|', $this->uastring)) {
892 $this->brand = 'MyIE2';
893 $this->version = null;
894 $this->bot = false;
895 }
896 elseif (preg_match('|Crazy Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
897 $this->brand = 'Crazy Browser';
898 $this->version = $regs[1];
899 $this->bot = false;
900 }
901 elseif (preg_match('|AvantGo ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
902 $this->brand = 'AvantGo';
903 $this->version = $regs[1];
904 $this->bot = false;
905 }
906 elseif (preg_match('|MSN ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
907 $this->brand = 'MSN';
908 $this->version = $regs[1];
909 $this->bot = false;
910 }
911 elseif (preg_match('|America Online Browser [0-9a-zA-Z\.+]+; rev([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
912 $this->brand = 'AOL Browser';
913 $this->version = $regs[1];
914 $this->bot = false;
915 }
916 elseif (preg_match('|MS FrontPage ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
917 $this->brand = 'Microsoft FrontPage';
918 $this->version = $regs[1];
919 $this->bot = false;
920 }
921 elseif (preg_match('|Microsoft Internet Explorer/4.0b1|', $this->uastring, $regs)) {
922 $this->brand = 'Microsoft Internet Explorer';
923 $this->version = '1.0';
924 $this->bot = false;
925 }
926 elseif (preg_match('|MSIE 7\.0.+Trident/4.0|', $this->uastring, $regs)) {
927 $this->brand = 'Microsoft Internet Explorer';
928 $this->version = "8.0";
929 $this->bot = false;
930 }
931 elseif (preg_match('|MSIE 7\.0.+Trident/5.0|', $this->uastring, $regs)) {
932 $this->brand = 'Microsoft Internet Explorer';
933 $this->version = "9.0";
934 $this->bot = false;
935 }
936 elseif (preg_match('|MSIE 7\.0.+Trident/6.0|', $this->uastring, $regs)) {
937 $this->brand = 'Microsoft Internet Explorer';
938 $this->version = "10.0";
939 $this->bot = false;
940 }
941 elseif (preg_match('|MSIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
942 $this->brand = 'Microsoft Internet Explorer';
943 $this->version = $regs[1];
944 $this->bot = false;
945 }
946 elseif (preg_match('|MSPIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
947 $this->brand = 'Microsoft Pocket Internet Explorer';
948 $this->version = $regs[1];
949 $this->bot = false;
950 }
951 elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) &&
952 (strpos($this->uastring, 'compatible') === false) && (strpos($this->uastring, 'Gecko/') === false) &&
953 (intval($regs[1]) < 5)) {
954 $this->brand = 'Netscape';
955 $this->version = $regs[1];
956 if (intval($this->version) == 4) { $this->brand .= ' Communicator'; }
957 $this->bot = false;
958 }
959 elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
960 $this->brand = (strpos($this->uastring, 'compatible') !== false)?'Mozilla-compatible (unknown)':'Mozilla (unknown)';
961 $this->version = null;
962 $this->bot = false;
963 }
964
965 $botArray = array('Scooter','Spinne','Vagabondo','Firefly','Scrubby','NG','Pompos','Szukacz','Schmozilla','42_HAL',
966 'NetResearchServer','LinkWalker','Zeus','W3C_Validator','ZyBorg','Ask Jeeves','ia_archiver',
967 'PingALink Monitoring Services','IlTrovatore-Setaccio','Nutch','Mercator','search.ch',
968 'appie','larbin','NutchCVS','Webchat','Mediapartners-Google','sitecheck.internetseer.com',
969 'FavOrg','findlinks','DataCha0s','ichiro','Francis','CoralWebPrx','DoCoMo','Ocelli','Sogou Video',
970 'Yandex','Yeti','Austronaut-URL-Checker');
971
972 if (in_array($this->brand, $botArray)) {
973 $this->bot = true;
974 }
975 }
976
977 public function getBrand() { return $this->brand; }
978 public function getVersion() { return $this->version; }
979
980 public function getAcceptLanguages() {
981 if (!isset($this->uadata['accept-languages'])) {
982 $headers = getAllHeaders();
983 $accLcomp = explode(',', $headers['Accept-Language']);
984 $accLang = array();
985 foreach ($accLcomp as $lcomp) {
986 if (strlen($lcomp)) {
987 $ldef = explode(';', $lcomp);
988 $accLang[$ldef[0]] = (float)((strpos(@$ldef[1],'q=')===0)?substr($ldef[1],2):1);
989 }
990 }
991 $this->uadata['accept-languages'] = $accLang;
992 }
993 return $this->uadata['accept-languages'];
994 }
995
996 public function getUAString() { return $this->uastring; }
997
998 public function getEngine() {
999 // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|netfront|unknown
1000 if (!isset($this->uadata['engine'])) {
1001 $this->uadata['engine'] = 'unknown';
1002 $this->uadata['geckodate'] = null;
1003 if (!$this->bot) {
1004 if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs) && (strpos($this->brand, 'Opera') === false)) {
1005 $this->uadata['engine'] = 'gecko';
1006 // If it looks like a version number, i.e. shorter than 4 chars or has a . in it, it's no date.
1007 $this->uadata['geckodate'] = ((strlen($regs[1]) > 4) && (strpos($regs[1], '.') === false))?$regs[1]:null;
1008 }
1009 elseif ((strpos($this->brand, 'Internet Explorer') !== false) || (strpos($this->brand, 'FrontPage') !== false)) {
1010 if ((strpos(strtolower($this->uastring), 'mac') !== false) && (intval($this->getVersion()) >= 5)) {
1011 $this->uadata['engine'] = 'tasman';
1012 }
1013 else {
1014 $this->uadata['engine'] = 'trident';
1015 }
1016 }
1017 elseif (preg_match('|WebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
1018 $this->uadata['engine'] = 'webkit';
1019 $this->uadata['eng_version'] = $regs[1];
1020 }
1021 elseif ((strpos($this->brand, 'Konqueror') !== false) || (strpos($this->brand, 'OmniWeb') !== false)) {
1022 $this->uadata['engine'] = 'khtml';
1023 }
1024 elseif (strpos($this->brand, 'Netscape') !== false) {
1025 // non-Gecko Netscape browsers
1026 if (intval($this->version) <= 4) {
1027 $this->uadata['engine'] = 'nscp';
1028 }
1029 elseif (strpos($this->uastring, 'MSIE') !== false) {
1030 $this->uadata['engine'] = 'trident';
1031 }
1032 }
1033 elseif (strpos($this->brand, 'Opera') !== false) {
1034 $this->uadata['engine'] = 'presto';
1035 }
1036 elseif ((strpos($this->brand, 'iTunes') !== false) || (strpos($this->brand, 'nook browser') !== false)) {
1037 $this->uadata['engine'] = 'webkit';
1038 }
1039 elseif (strpos($this->brand, 'Dillo') !== false) {
1040 $this->uadata['engine'] = 'gzilla';
1041 }
1042 elseif ((strpos($this->brand, 'ELinks') !== false) || (strpos($this->brand, 'Links') !== false)) {
1043 $this->uadata['engine'] = 'links';
1044 }
1045 elseif ((strpos($this->brand, 'Lynx') !== false)) {
1046 $this->uadata['engine'] = 'lynx';
1047 }
1048 elseif ((strpos($this->brand, 'ICEbrowser') !== false) || (strpos($this->brand, 'ICE Browser') !== false)) {
1049 $this->uadata['engine'] = 'icestorm';
1050 }
1051 elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
1052 $this->uadata['engine'] = 'netfront';
1053 $this->uadata['eng_version'] = $regs[1];
1054 }
1055 elseif ((strpos($this->brand, 'PlayStation') !== false) || (strpos($this->brand, 'NetFront') !== false)) {
1056 $this->uadata['engine'] = 'netfront';
1057 }
1058 elseif ((strpos($this->brand, 'Avant') !== false) || (strpos($this->brand, 'Crazy Browser') !== false) ||
1059 (strpos($this->brand, 'AOL') !== false) || (strpos($this->brand, 'MSN') !== false) ||
1060 (strpos($this->brand, 'MyIE2') !== false) || (strpos($this->brand, 'Maxthon') !== false)) {
1061 $this->uadata['engine'] = 'trident';
1062 }
1063 elseif (strpos($this->brand, 'Galeon') !== false) {
1064 $this->uadata['engine'] = 'gecko';
1065 }
1066 elseif (strpos($this->brand, 'WebPro') !== false) {
1067 $this->uadata['engine'] = 'nscp';
1068 }
1069 }
1070 }
1071 return $this->uadata['engine'];
1072 }
1073
1074 public function hasEngine($rnd_engine) { return ($this->getEngine() == $rnd_engine); }
1075
1076 public function getEngineVersion() {
1077 if (!isset($this->uadata['eng_version'])) {
1078 $this->uadata['eng_version'] = null;
1079 // getOS() should get the date for us
1080 $this->getOS();
1081 }
1082 return $this->uadata['eng_version'];
1083 }
1084
1085 public function getOS() {
1086 if (!isset($this->uadata['os'])) {
1087 $this->uadata['os'] = null;
1088 if (!$this->bot) {
1089 if ($this->hasEngine('gecko')) {
1090 if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1091 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1092 $this->uadata['lang'] = (strpos($regs[4],'chrome://')===false)?$regs[4]:null;
1093 $this->uadata['eng_version'] = $regs[5];
1094 }
1095 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1096 $this->uadata['os'] = $regs[2];
1097 $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null;
1098 $this->uadata['eng_version'] = $regs[4];
1099 }
1100 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1101 $this->uadata['os'] = $regs[2];
1102 $this->uadata['lang'] = null;
1103 $this->uadata['eng_version'] = $regs[3];
1104 }
1105 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); x64; rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1106 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1107 $this->uadata['lang'] = null;
1108 $this->uadata['eng_version'] = $regs[3];
1109 }
1110 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) {
1111 $this->uadata['os'] = $regs[2];
1112 $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null;
1113 $this->uadata['eng_version'] = $regs[4];
1114 }
1115 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
1116 $this->uadata['os'] = $regs[2];
1117 $this->uadata['lang'] = $regs[3];
1118 $this->uadata['eng_version'] = 'M'.$regs[4];
1119 }
1120 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
1121 $this->uadata['os'] = $regs[1];
1122 $this->uadata['lang'] = $regs[2];
1123 $this->uadata['eng_version'] = 'M'.$regs[3];
1124 }
1125 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1126 $this->uadata['os'] = $regs[2];
1127 $this->uadata['lang'] = $regs[3];
1128 $this->uadata['eng_version'] = null;
1129 }
1130 elseif (preg_match('#Mozilla/5.0 \(([^;]+); (WOW64|Mobile|Tablet); rv:([^\);]+)\)#', $this->uastring, $regs)) {
1131 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1132 $this->uadata['lang'] = null;
1133 $this->uadata['eng_version'] = $regs[3];
1134 }
1135 elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
1136 if ((strpos($regs[2], 'Linux') !== false) && ($regs[1] != 'X11')) {
1137 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1138 }
1139 else {
1140 $this->uadata['os'] = $regs[2];
1141 }
1142 $this->uadata['lang'] = null;
1143 $this->uadata['eng_version'] = $regs[3];
1144 }
1145 elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^\);]+)\)|', $this->uastring, $regs)) {
1146 $this->uadata['os'] = $regs[2];
1147 $this->uadata['lang'] = null;
1148 $this->uadata['eng_version'] = null;
1149 }
1150 elseif (preg_match('|Mozilla/5.0 \(([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
1151 $this->uadata['os'] = $regs[1];
1152 $this->uadata['lang'] = null;
1153 $this->uadata['eng_version'] = $regs[2];
1154 }
1155 elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) {
1156 $this->uadata['os'] = $regs[2];
1157 $this->uadata['lang'] = null;
1158 $this->uadata['eng_version'] = null;
1159 }
1160 elseif (preg_match('|Debian/|', $this->uastring, $regs)) {
1161 $this->uadata['os'] = 'Debian Linux';
1162 $this->uadata['lang'] = null;
1163 $this->uadata['eng_version'] = null;
1164 }
1165 }
1166 elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) {
1167 if (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) {
1168 $this->uadata['eng_version'] = $regs[3];
1169 $this->uadata['os'] = $regs[1].' ('.$regs[2].')';
1170 $this->uadata['lang'] = null;
1171 }
1172 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) {
1173 $this->uadata['eng_version'] = $regs[2];
1174 $this->uadata['os'] = $regs[1];
1175 $this->uadata['lang'] = null;
1176 }
1177 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*\)/i', $this->uastring, $regs)) {
1178 $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$regs[1];
1179 $this->uadata['os'] = $regs[2].' ('.$regs[3].')';
1180 $this->uadata['lang'] = null;
1181 }
1182 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
1183 $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$regs[1];
1184 $this->uadata['os'] = $regs[2];
1185 $this->uadata['lang'] = null;
1186 }
1187 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
1188 $this->uadata['eng_version'] = "ie".$regs[1];
1189 $this->uadata['os'] = null;
1190 $this->uadata['lang'] = null;
1191 }
1192 elseif (preg_match('/Microsoft Internet Explorer\/[^\s]+ \(((?:Mac|Win)[^;\)]+)\)/i', $this->uastring, $regs)) {
1193 $this->uadata['eng_version'] = "ie".$this->getVersion();
1194 $this->uadata['os'] = $regs[1];
1195 $this->uadata['lang'] = null;
1196 }
1197 elseif (preg_match('/Microsoft Pocket Internet Explorer\/[^\s]+/i', $this->uastring, $regs)) {
1198 $this->uadata['eng_version'] = null;
1199 $this->uadata['os'] = 'Windows CE';
1200 $this->uadata['lang'] = null;
1201 }
1202 }
1203 elseif ($this->hasEngine('khtml')) {
1204 if (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^;]+); ([^;]+); ([^;]+); ([^\);]+)\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
1205 $this->uadata['eng_version'] = strlen($regs[6])?$regs[6]:$regs[1];
1206 $this->uadata['os'] = $regs[2];
1207 $this->uadata['lang'] = $regs[5];
1208 }
1209 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^\);]+)[^\)]*\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
1210 $this->uadata['eng_version'] = strlen($regs[3])?$regs[3]:$regs[1];
1211 $this->uadata['os'] = $regs[2];
1212 $this->uadata['lang'] = null;
1213 }
1214 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^\);]+)\)/i', $this->uastring, $regs)) {
1215 $this->uadata['os'] = $regs[1];
1216 $this->uadata['lang'] = null;
1217 $this->uadata['eng_version'] = null;
1218 }
1219 }
1220 elseif ($this->hasEngine('webkit')) {
1221 if (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+); ([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1222 $this->uadata['os'] = $regs[2];
1223 $this->uadata['lang'] = $regs[3];
1224 }
1225 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1226 if (strpos($regs[3], '/') !== false) {
1227 $this->uadata['os'] = $regs[1];
1228 $this->uadata['lang'] = null;
1229 }
1230 else {
1231 $this->uadata['os'] = $regs[2];
1232 $this->uadata['lang'] = $regs[3];
1233 }
1234 }
1235 elseif (preg_match('|Mozilla/5.0 \(([^;]+); Linux; ([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) {
1236 $this->uadata['os'] = $regs[2];
1237 $this->uadata['lang'] = $regs[3];
1238 }
1239 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) {
1240 $this->uadata['os'] = $regs[1];
1241 $this->uadata['lang'] = $regs[2];
1242 }
1243 elseif (preg_match('|Mozilla/5.0 \(Linux; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1244 // (Chrome for) Android - $regs[2] is device
1245 $this->uadata['os'] = $regs[1];
1246 $this->uadata['lang'] = null;
1247 }
1248 elseif (preg_match('|Mozilla/5.0 \(([^\);]+); ([^\);]+)\)|', $this->uastring, $regs)) {
1249 if (($regs[1] == 'X11') || ($regs[1] == 'Macintosh') || ($regs[1] == 'iPhone')) {
1250 $this->uadata['os'] = $regs[2];
1251 }
1252 else {
1253 $this->uadata['os'] = $regs[1];
1254 if ($regs[2] == 'NokiaN9') {
1255 $this->uadata['os'] .= ' Harmattan';
1256 }
1257 }
1258 $this->uadata['lang'] = null;
1259 }
1260 elseif (preg_match('|Mozilla/5.0 \(([^\);]+)\)|', $this->uastring, $regs)) {
1261 $this->uadata['os'] = $regs[1];
1262 $this->uadata['lang'] = null;
1263 }
1264 elseif (preg_match('|Midori/[^\(]+ \((?:X11; )?([^;]+); U; ([^\)]+)\)|i', $this->uastring, $regs)) {
1265 $this->uadata['os'] = $regs[1];
1266 $this->uadata['lang'] = $regs[2];
1267 }
1268 if ($this->brand == 'Silk') {
1269 // For some reason, Amazon spoofs us and tells us it's on MacOS X!
1270 $this->uadata['os'] = 'Android';
1271 }
1272 }
1273 elseif ($this->hasEngine('presto')) {
1274 // Opera < 8
1275 if (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1276 $this->uadata['eng_version'] = $this->getVersion();
1277 $this->uadata['os'] = $regs[1];
1278 $this->uadata['lang'] = $regs[2];
1279 }
1280 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;\)]+)[^\)]*\) Opera [^ ]+\s+\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1281 $this->uadata['eng_version'] = $this->getVersion();
1282 $this->uadata['os'] = $regs[1];
1283 $this->uadata['lang'] = $regs[2];
1284 }
1285 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+\) Opera [^ ]+\s+\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
1286 $this->uadata['eng_version'] = $this->getVersion();
1287 $this->uadata['os'] = $regs[1];
1288 $this->uadata['lang'] = $regs[2];
1289 }
1290 // Opera mini
1291 elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini; ([a-z_-]+); /i', $this->uastring, $regs)) {
1292 $this->uadata['eng_version'] = null;
1293 $this->uadata['os'] = $regs[2];
1294 $this->uadata['lang'] = $regs[3];
1295 }
1296 elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini\/[^;]+; ([a-z_-]+); /i', $this->uastring, $regs)) {
1297 $this->uadata['eng_version'] = $regs[1];
1298 $this->uadata['os'] = $regs[2];
1299 $this->uadata['lang'] = $regs[3];
1300 }
1301 // Opera >= 8
1302 elseif (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) {
1303 $this->uadata['eng_version'] = $this->getVersion();
1304 $this->uadata['os'] = $regs[1];
1305 $this->uadata['lang'] = $regs[2];
1306 }
1307 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
1308 $this->uadata['eng_version'] = $this->getVersion();
1309 $this->uadata['os'] = $regs[1];
1310 $this->uadata['lang'] = $regs[2];
1311 }
1312 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
1313 $this->uadata['eng_version'] = $this->getVersion();
1314 $this->uadata['os'] = $regs[1];
1315 $this->uadata['lang'] = $regs[2];
1316 }
1317 // Opera 9 Firefox-spoofing
1318 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+); rv:([^\);]+)\) Gecko\/\d+ Firefox\/[0-9a-zA-Z\.+]+ Opera [^ ]+/i', $this->uastring, $regs)) {
1319 $this->uadata['eng_version'] = $this->getVersion();
1320 $this->uadata['os'] = $regs[1];
1321 $this->uadata['lang'] = $regs[2];
1322 }
1323 }
1324 elseif ($this->hasEngine('nscp')) {
1325 if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {
1326 $this->uadata['eng_version'] = $regs[1];
1327 $this->uadata['os'] = $regs[3];
1328 $this->uadata['lang'] = $regs[2];
1329 }
1330 elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
1331 $this->uadata['eng_version'] = $regs[1];
1332 $this->uadata['os'] = $regs[3];
1333 $this->uadata['lang'] = $regs[2];
1334 }
1335 elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+)[^\(]+\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
1336 $this->uadata['eng_version'] = $regs[1];
1337 $this->uadata['os'] = $regs[2];
1338 $this->uadata['lang'] = null;
1339 }
1340 }
1341 elseif ($this->hasEngine('gzilla')) {
1342 $this->uadata['eng_version'] = $this->getVersion();
1343 $this->uadata['os'] = null;
1344 $this->uadata['lang'] = null;
1345 }
1346 elseif ($this->hasEngine('links')) {
1347 if (preg_match('/E?Links[^\(]+\([^;]+; ([^;]+)[^\)]+\)/i', $this->uastring, $regs)) {
1348 $this->uadata['eng_version'] = null;
1349 $this->uadata['os'] = $regs[1];
1350 $this->uadata['lang'] = null;
1351 }
1352 }
1353 elseif ($this->hasEngine('lynx')) {
1354 $this->uadata['eng_version'] = $this->getVersion();
1355 $this->uadata['os'] = null;
1356 $this->uadata['lang'] = null;
1357 }
1358 elseif ($this->hasEngine('icestorm')) {
1359 if (preg_match('/ICE Browser\/v?([0-9a-zA-Z\._+]+) \(Java [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) {
1360 $this->uadata['eng_version'] = str_replace('_', '.', $regs[1]);
1361 $this->uadata['os'] = $regs[2];
1362 $this->uadata['lang'] = null;
1363 }
1364 elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\).* ICEbrowser\/([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) {
1365 $this->uadata['eng_version'] = $regs[3];
1366 $this->uadata['os'] = $regs[1];
1367 $this->uadata['lang'] = $regs[2];
1368 }
1369 }
1370 else {
1371 $this->uadata['eng_version'] = null;
1372 $this->uadata['lang'] = null;
1373 if (preg_match('/AmigaOS/i', $this->uastring, $regs)) {
1374 $this->uadata['os'] = 'AmigaOS';
1375 }
1376 if (preg_match('/Commodore 64/i', $this->uastring, $regs)) {
1377 $this->uadata['os'] = 'Commodore 64';
1378 }
1379 elseif (preg_match('/curl\/[^\(]+\(([^\);]+)/i', $this->uastring, $regs)) {
1380 $this->uadata['os'] = $regs[1];
1381 }
1382 elseif (preg_match('/NCSA[_ ]Mosaic\/[^\(]+\((?:.*;)?([^\);]+)/i', $this->uastring, $regs)) {
1383 $this->uadata['os'] = trim($regs[1]);
1384 }
1385 elseif (preg_match('/iCab.*(Mac[^\);]+).*?\)/i', $this->uastring, $regs)) {
1386 $this->uadata['os'] = trim($regs[1]);
1387 }
1388 elseif (preg_match('/SymbianOS\/([^ ]+)/i', $this->uastring, $regs)) {
1389 $this->uadata['os'] = 'SymbianOS '.$regs[1];
1390 }
1391 }
1392 if ($this->uadata['os'] == 'Win 9x 4.90') { $this->uadata['os'] = 'Windows ME'; }
1393 elseif ($this->uadata['os'] == 'WinNT4.0') { $this->uadata['os'] = 'Windows NT 4.0'; }
1394 elseif ($this->uadata['os'] == 'Windows NT 5.0') { $this->uadata['os'] = 'Windows 2000'; }
1395 elseif ($this->uadata['os'] == 'Windows NT 5.1') { $this->uadata['os'] = 'Windows XP'; }
1396 elseif ($this->uadata['os'] == 'Windows NT 5.1 (Win64)') { $this->uadata['os'] = 'Windows XP (64bit)'; }
1397 elseif ($this->uadata['os'] == 'Windows NT 5.1 (WOW64)') { $this->uadata['os'] = 'Windows XP (64bit)'; }
1398 elseif ($this->uadata['os'] == 'Windows NT 5.2') { $this->uadata['os'] = 'Windows 2003'; }
1399 elseif ($this->uadata['os'] == 'Windows NT 5.2 x64') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1400 elseif ($this->uadata['os'] == 'Windows NT 5.2 (Win64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1401 elseif ($this->uadata['os'] == 'Windows NT 5.2 (WOW64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; }
1402 elseif ($this->uadata['os'] == 'Windows NT 6.0') { $this->uadata['os'] = 'Windows Vista'; }
1403 elseif ($this->uadata['os'] == 'Windows NT 6.0 (Win64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; }
1404 elseif ($this->uadata['os'] == 'Windows NT 6.0 (WOW64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; }
1405 elseif ($this->uadata['os'] == 'Windows NT 6.1') { $this->uadata['os'] = 'Windows 7'; }
1406 elseif ($this->uadata['os'] == 'Windows NT 6.1 (Win64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; }
1407 elseif ($this->uadata['os'] == 'Windows NT 6.1 (WOW64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; }
1408 elseif ($this->uadata['os'] == 'Windows NT 6.2') { $this->uadata['os'] = 'Windows 8'; }
1409 elseif ($this->uadata['os'] == 'Windows NT 6.2 (Win64)') { $this->uadata['os'] = 'Windows 8 (64bit)'; }
1410 elseif ($this->uadata['os'] == 'Windows NT 6.2 (WOW64)') { $this->uadata['os'] = 'Windows 8 (64bit)'; }
1411 elseif ($this->uadata['os'] == 'Win95') { $this->uadata['os'] = 'Windows 95'; }
1412 elseif ($this->uadata['os'] == 'Win98') { $this->uadata['os'] = 'Windows 98'; }
1413 elseif ($this->uadata['os'] == 'WinNT') { $this->uadata['os'] = 'Windows NT'; }
1414 elseif ($this->uadata['os'] == 'Win32') { $this->uadata['os'] = 'Windows (32bit)'; }
1415 elseif ($this->uadata['os'] == 'Win64') { $this->uadata['os'] = 'Windows (64bit)'; }
1416 elseif (preg_match('/iPhone OS ([\d_]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'iOS '.str_replace('_', '.', $regs[1]); }
1417 elseif (preg_match('/Mac ?OS ?X/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; }
1418 elseif (preg_match('/Mac_P(ower|)PC/i', $this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; }
1419 elseif (strpos($this->uadata['os'], 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }
1420 elseif (strpos($this->uadata['os'], 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }
1421 elseif (strpos($this->uadata['os'], 'apple') !== false) { $this->uadata['os'] = 'MacOS'; }
1422 elseif (strpos($this->uadata['os'], 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; }
1423 elseif (preg_match('/(?:web|hpw)OS\/([0-9a-zA-Z\._+]+)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'webOS '.$regs[1]; }
1424 elseif (preg_match('/Android \(Linux (.+)\)/i', $this->uadata['os'], $regs)) { $this->uadata['os'] = 'Android '.$regs[1]; }
1425 elseif (strpos($this->uadata['os'], 'linux') !== false) { $this->uadata['os'] = 'Linux'; }
1426 elseif (preg_match('/SymbianOS[\/ ]([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) { $this->uadata['os'] = 'SymbianOS '.$regs[1]; }
1427 elseif (preg_match('/Symbian ?OS/i', $this->uadata['os'])) { $this->uadata['os'] = 'SymbianOS'; }
1428
1429 if (strpos($this->uadata['os'], 'Win') !== false) { $this->uadata['platform'] = 'Windows'; }
1430 elseif (strpos($this->uadata['os'], 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; }
1431 elseif (strpos($this->uadata['os'], 'iOS') !== false) { $this->uadata['platform'] = 'Macintosh'; }
1432 elseif (strpos($this->uadata['os'], 'Linux') !== false) { $this->uadata['platform'] = 'Linux'; }
1433 elseif (strpos($this->uadata['os'], 'MeeGo') !== false) { $this->uadata['platform'] = 'Linux'; }
1434 elseif (strpos($this->uadata['os'], 'webOS') !== false) { $this->uadata['platform'] = 'Linux'; }
1435 elseif (strpos($this->uadata['os'], 'Android') !== false) { $this->uadata['platform'] = 'Android'; }
1436 elseif (strpos($this->uadata['os'], 'Solaris') !== false) { $this->uadata['platform'] = 'Solaris'; }
1437 elseif (strpos($this->uadata['os'], 'SunOS') !== false) { $this->uadata['platform'] = 'Solaris'; }
1438 elseif (strpos($this->uadata['os'], 'BeOS') !== false) { $this->uadata['platform'] = 'BeOS'; }
1439 elseif (strpos($this->uadata['os'], 'BePC') !== false) { $this->uadata['platform'] = 'BeOS'; }
1440 elseif (strpos($this->uadata['os'], 'FreeBSD') !== false) { $this->uadata['platform'] = 'FreeBSD'; }
1441 elseif (strpos($this->uadata['os'], 'OpenBSD') !== false) { $this->uadata['platform'] = 'OpenBSD'; }
1442 elseif (strpos($this->uadata['os'], 'NetBSD') !== false) { $this->uadata['platform'] = 'NetBSD'; }
1443 elseif (strpos($this->uadata['os'], 'AIX') !== false) { $this->uadata['platform'] = 'AIX'; }
1444 elseif (strpos($this->uadata['os'], 'IRIX') !== false) { $this->uadata['platform'] = 'IRIX'; }
1445 elseif (strpos($this->uadata['os'], 'HP-UX') !== false) { $this->uadata['platform'] = 'HP-UX'; }
1446 elseif (strpos($this->uadata['os'], 'AmigaOS') !== false) { $this->uadata['platform'] = 'Amiga'; }
1447 elseif (strpos($this->uadata['os'], 'webOS') !== false) { $this->uadata['platform'] = 'webOS'; }
1448 elseif (strpos($this->uadata['os'], 'Commodore 64') !== false) { $this->uadata['platform'] = 'C64'; }
1449 elseif (strpos($this->uadata['os'], 'OpenVMS') !== false) { $this->uadata['platform'] = 'OpenVMS'; }
1450 elseif (strpos($this->uadata['os'], 'Warp') !== false) { $this->uadata['platform'] = 'OS/2'; }
1451 elseif (strpos($this->uadata['os'], 'OS/2') !== false) { $this->uadata['platform'] = 'OS/2'; }
1452 elseif (strpos($this->uadata['os'], 'SymbianOS') !== false) { $this->uadata['platform'] = 'SymbianOS'; }
1453 elseif (strpos($this->uadata['os'], 'BlackBerry') !== false) { $this->uadata['platform'] = 'BlackBerry'; }
1454 elseif (strpos($this->uadata['os'], 'Gameboy') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1455 elseif (strpos($this->uadata['os'], 'Wii') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1456 elseif (strpos($this->uadata['os'], 'Nintendo') !== false) { $this->uadata['platform'] = 'Nintendo'; }
1457 elseif (strpos($this->uadata['os'], 'J2ME') !== false) { $this->uadata['platform'] = 'Java'; }
1458 elseif (strpos($this->uadata['os'], 'CYGWIN') !== false) { $this->uadata['platform'] = 'Windows'; }
1459 elseif (strpos($this->uadata['os'], 'mingw') !== false) { $this->uadata['platform'] = 'Windows'; }
1460 else { $this->uadata['platform'] = $this->uadata['os']; }
1461
1462 $this->uadata['lang'] = str_replace('_', '-', $this->uadata['lang']);
1463 }
1464 }
1465 return $this->uadata['os'];
1466 }
1467
1468 public function getPlatform() {
1469 if (!isset($this->uadata['platform'])) {
1470 $this->uadata['platform'] = null;
1471 // getOS() should get the date for us
1472 $this->getOS();
1473 }
1474 return $this->uadata['platform'];
1475 }
1476
1477 public function getLanguage() {
1478 if (!isset($this->uadata['lang'])) {
1479 $this->uadata['lang'] = null;
1480 // getOS() should get the date for us
1481 $this->getOS();
1482 }
1483 return $this->uadata['lang'];
1484 }
1485
1486 public function getGeckoDate() {
1487 if (!isset($this->uadata['geckodate'])) {
1488 $this->uadata['geckodate'] = null;
1489 // getEngine() should get the date for us
1490 $this->getEngine();
1491 }
1492 return $this->uadata['geckodate'];
1493 }
1494
1495 public function getGeckoTime() {
1496 if (!isset($this->uadata['geckotime'])) {
1497 $this->uadata['geckotime'] = null;
1498 if (!is_null($this->getGeckoDate())) {
1499 $use_time = (strlen($this->getGeckoDate()) > 8);
1500 $gd_str = substr($this->getGeckoDate(),0,4).'-'.substr($this->getGeckoDate(),4,2).'-'.substr($this->getGeckoDate(),6,2);
1501 if ($use_time) {
1502 $gd_str .= substr($this->getGeckoDate(),8,2).':00';
1503 $old_tz = date_default_timezone_get();
1504 date_default_timezone_set("America/Los_Angeles");
1505 }
1506 $this->uadata['geckotime'] = strtotime($gd_str);
1507 if ($use_time) { date_default_timezone_set($old_tz); }
1508 }
1509 }
1510 return $this->uadata['geckotime'];
1511 }
1512
1513 public function isBot() { return $this->bot; }
1514
1515 public function isns() {
1516 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1517 return (strpos($this->brand, 'Netscape') !== false);
1518 }
1519 public function isns4() {
1520 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1521 return ((strpos($this->brand, 'Netscape') !== false) && (intval($this->version) == 4));
1522 }
1523 public function isie() {
1524 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1525 return $this->hasEngine('trident');
1526 }
1527 public function geckodate() {
1528 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1529 return (!is_null($this->getGeckoDate())?$this->getGeckoDate():0);
1530 }
1531 public function geckobased() {
1532 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1533 return $this->hasEngine('gecko');
1534 }
1535 public function khtmlbased() {
1536 trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE);
1537 return $this->hasEngine('khtml');
1538 }
1539}
1540?>