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