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