2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is KaiRo's userAgent detection.
17 * The Initial Developer of the Original Code is
18 * KaiRo - Robert Kaiser.
19 * Portions created by the Initial Developer are Copyright (C) 2003
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s): Robert Kaiser <kairo@kairo.at>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 // userAgent PHP class
40 // get user agent and tell us what Browser is accessing
42 // function userAgent([$ua_string])
43 // CONSTRUCTOR; reads UA string (or takes the optional given UA string) and gets info from that into our variables.
46 // the plain User Agent string
48 // the User Agent brand name
50 // the User Agent version
52 // bool: true if this agent is a bot
54 // array of static user agent data (static vars in functions are set for all objects of this class!)
56 // function getBrand()
57 // returns the User Agent Brand Name
59 // function getVersion()
60 // returns the User Agent version
62 // function getAcceptLanguages()
63 // returns an associated array with the accepted languages of this UA
64 // keys are language codes, values are q factors (weights)
66 // function getUAString()
67 // returns the full User Agent string
69 // function getEngine()
70 // returns a string telling the detected rendering engine, null if we can't detect
71 // one of gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|unkown
73 // function hasEngine($rnd_engine)
74 // returns true if the given rendering engine was detected
76 // function getEngineVersion()
77 // returns a the version number for the rendering engine
78 // this may be the same as getVersion() for many engines, or null if we don't know
81 // returns a string telling the detected operating system, null if we can't detect
82 // might be very verbose, uses no abbreviations for most names
84 // function getPlatform()
85 // returns a string telling the detected OS platform, null if we can't detect
86 // one of windows|linux|mac|solaris|unkown
88 // function getLanguage() {
89 // returns a string telling the detected browser UI language, null if we can't detect
90 // should be an ISO code
93 // returns true if User Agent seems to be a bot
95 // *** functions that only return useable info for some agents ***
97 // function getGeckoDate()
98 // returns the Gecko date for Gecko-based browsers, null for others
100 // *** functions for compat to older versions of this class ***
103 // returns true if User Agent seems to be Netscape brand, false if not
105 // returns true if User Agent seems to be Netscape Communicator 4.x, false if not
107 // returns true if User Agent seems to be a version of Internet Exploder, false if not
108 // function geckobased()
109 // returns true if User Agent seems to be a Gecko-based browser, false if not
110 // function geckodate()
111 // returns the Gecko date when it's a Gecko-based browser, 0 if not
112 // function khtmlbased()
113 // returns true if User Agent seems to be a KHTML-based browser, false if not
115 // collection of some known User Agent Strings:
116 // *** see testbed/ua_list_raw.txt ***
117 // *** see also http://www.pgts.com.au/pgtsj/pgtsj0208c.html ***
123 var $uadata = array();
125 function userAgent($ua_string = '') {
126 // *** constructor ***
127 if (strlen($ua_string)) {
128 $this->uastring = $ua_string;
131 // read raw UA string
132 $this->uastring = $_SERVER['HTTP_USER_AGENT'];
135 // get UA brand and version
136 $this->brand = 'Unknown'; $this->version = null;
137 // find reasonable defaults
138 if (preg_match('|([0-9a-zA-Z\.()_ -]+)/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
139 $this->brand = trim($regs[1]);
140 $this->version = $regs[2];
142 elseif (preg_match('|^([a-zA-Z\._ -]+)[_ -][vV]?([0-9][0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
143 $this->brand = trim($regs[1]);
144 $this->version = $regs[2];
146 elseif (preg_match('|^([a-zA-Z\._ -]+)|', $this->uastring, $regs)) {
147 $this->brand = trim($regs[1]);
148 $this->version = null;
150 // search for any real and/or special UAs
151 if (preg_match('|Netscape6/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
152 $this->brand = 'Netscape';
153 $this->version = $regs[1];
155 elseif (preg_match('|Netscape/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
156 $this->brand = 'Netscape';
157 $this->version = $regs[1];
159 elseif (preg_match('|Chimera/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
160 $this->brand = 'Chimera';
161 $this->version = $regs[1];
163 elseif (preg_match('|Camino/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
164 $this->brand = 'Camino';
165 $this->version = $regs[1];
167 elseif (preg_match('|Phoenix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
168 $this->brand = 'Phoenix';
169 $this->version = $regs[1];
171 elseif (preg_match('|Mozilla Firebird/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
172 $this->brand = 'Mozilla Firebird';
173 $this->version = $regs[1];
175 elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
176 $this->brand = 'Firefox';
177 $this->version = $regs[1];
179 elseif (preg_match('|Galeon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
180 $this->brand = 'Galeon';
181 $this->version = $regs[1];
183 elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) {
184 $this->brand = 'Mozilla';
185 $this->version = $regs[1];
187 elseif (preg_match('|Opera[ /]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
188 $this->brand = 'Opera';
189 $this->version = $regs[1];
191 elseif (preg_match('|OmniWeb/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
192 $this->brand = 'OmniWeb';
193 $this->version = $regs[1];
195 elseif (preg_match('|Konqueror/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
196 $this->brand = 'Konqueror';
197 $this->version = $regs[1];
199 elseif (preg_match('|Safari/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
200 $this->brand = 'Safari';
201 $this->version = $regs[1];
203 elseif (preg_match('|AppleWebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
204 $this->brand = 'AppleWebKit';
205 $this->version = $regs[1];
207 elseif (preg_match('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
208 $this->brand = 'Microsoft FrontPage';
209 $this->version = $regs[1];
211 elseif (preg_match('|iCab[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
212 $this->brand = 'iCab';
213 $this->version = $regs[1];
215 elseif (preg_match('|IBrowse[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
216 $this->brand = 'IBrowse';
217 $this->version = $regs[1];
219 elseif (preg_match('|Configuration/CLDC-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
220 $this->brand = 'CLDC';
221 $this->version = $regs[1];
223 elseif (preg_match('|ELinks \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) {
224 $this->brand = 'ELinks';
225 $this->version = $regs[1];
227 elseif (preg_match('|ZyBorg/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
228 $this->brand = 'ZyBorg';
229 $this->version = $regs[1];
232 elseif (preg_match('|Googlebot/?([0-9a-zA-Z\.+]+)?|', $this->uastring, $regs)) {
233 $this->brand = 'Googlebot';
234 $this->version = $regs[1];
237 elseif (preg_match('|Ask Jeeves/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
238 $this->brand = 'Ask Jeeves';
239 $this->version = $regs[1];
242 elseif (preg_match('|Slurp/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
243 $this->brand = 'Slurp';
244 $this->version = $regs[1];
247 elseif (preg_match('|Gulper Web Bot ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
248 $this->brand = 'Gulper Web Bot';
249 $this->version = $regs[1];
252 elseif (preg_match('|HTTrack ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
253 $this->brand = 'HTTrack';
254 $this->version = $regs[1];
257 elseif (preg_match('|^Internet Explorer 5.5|', $this->uastring)) {
258 $this->brand = 'Unknown bot (IE5.5)';
259 $this->version = null;
262 elseif (preg_match('|^Mozilla[\s ]*$|', $this->uastring)) {
263 $this->brand = 'Unknown bot (Mozilla)';
264 $this->version = null;
267 elseif (preg_match('|http://www.almaden.ibm.com/cs/crawler|', $this->uastring)) {
268 $this->brand = 'almaden crawler';
269 $this->version = null;
272 elseif (preg_match('|B-l-i-t-z-B-O-T|', $this->uastring) || preg_match('|B l i t z B O T @ t r i c u s . n e t|', $this->uastring)) {
273 $this->brand = 'BlitzBOT';
274 $this->version = null;
277 elseif (preg_match('|sitecheck.internetseer.com|', $this->uastring)) {
278 $this->brand = 'internetseer';
279 $this->version = null;
282 elseif (preg_match('|Girafabot|', $this->uastring)) {
283 $this->brand = 'Girafabot';
284 $this->version = null;
287 elseif (preg_match('|efp@gmx.net|', $this->uastring)) {
288 $this->brand = 'efp';
289 $this->version = null;
292 elseif (preg_match('|^Firefly|', $this->uastring)) {
293 // comes here with correct value but would be detected as MSIE
295 elseif (preg_match('|Avant Browser[^/]|', $this->uastring)) {
296 $this->brand = 'Avant Browser';
297 $this->version = null;
299 elseif (preg_match('|Crazy Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
300 $this->brand = 'Crazy Browser';
301 $this->version = $regs[1];
303 elseif (preg_match('|AOL ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
304 $this->brand = 'AOL';
305 $this->version = $regs[1];
307 elseif (preg_match('|MSN ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
308 $this->brand = 'MSN';
309 $this->version = $regs[1];
311 elseif (preg_match('|MS FrontPage ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
312 $this->brand = 'Microsoft FrontPage';
313 $this->version = $regs[1];
315 elseif (preg_match('|MSIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) {
316 $this->brand = 'Microsoft Internet Explorer';
317 $this->version = $regs[1];
319 elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && !strstr($this->uastring, "compatible;") && !strstr($this->uastring, "Gecko/")) {
320 $this->brand = 'Netscape';
321 $this->version = $regs[1];
322 if (intval($this->version) == 4) { $this->brand .= ' Communicator'; }
325 $botArray = array('Scooter','Spinne','Vagabondo','TurnitinBot','FAST-WebCrawler','Firefly','Googlebot',
326 'Scrubby','psbot','NG','URL_Spider_Pro','Pompos','Szukacz','ASPseek','NPBot-1',
327 'dloader(NaverRobot)','NetResearchServer','HeinrichderMiragoRobot','LinkWalker',
328 'Openbot','W3C_Validator','ZyBorg','Ask Jeeves','dumbBot','BaiDuSpider','ia_archiver',
329 'PingALink Monitoring Services','IlTrovatore-Setaccio','Nutch','Mercator','OWR_Crawler',
330 'search.ch','WebFilter Robot','appie','larbin','','','','','','','','');
332 if (in_array($this->brand, $botArray)) {
337 function getBrand() { return $this->brand; }
338 function getVersion() { return $this->version; }
340 function getAcceptLanguages() {
341 if (!isset($this->uadata['accept-languages'])) {
342 $headers = getAllHeaders();
343 $accLcomp = explode(',', $headers['Accept-Language']);
345 foreach ($accLcomp as $lcomp) {
346 if (strlen($lcomp)) {
347 $ldef = explode(';', $lcomp);
348 $accLang[$ldef[0]] = (float)((strpos($ldef[1],'q=')===0)?substr($ldef[1],2):1);
351 $this->uadata['accept-languages'] = $accLang;
353 return $this->uadata['accept-languages'];
356 function getUAString() { return $this->uastring; }
358 function getEngine() {
359 // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|unkown
360 if (!isset($this->uadata['engine'])) {
361 $this->uadata['engine'] = 'unkown';
362 $this->uadata['geckodate'] = null;
363 if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs)) {
364 $this->uadata['engine'] = 'gecko';
365 $this->uadata['geckodate'] = $regs[1];
367 elseif ((strpos($this->brand, 'Internet Explorer') !== false) || (strpos($this->brand, 'FrontPage') !== false)) {
368 if (($this->uadata['platform'] == 'mac') && (intval($this->version) >= 5)) {
369 $this->uadata['engine'] = 'tasman';
372 $this->uadata['engine'] = 'trident';
375 elseif ((strpos($this->brand, 'Konqueror') !== false) || (strpos($this->brand, 'Safari') !== false) || (strpos($this->brand, 'AppleWebKit') !== false) || (strpos($this->brand, 'OmniWeb') !== false)) {
376 $this->uadata['engine'] = 'khtml';
378 elseif ((strpos($this->brand, 'Netscape') !== false) && (intval($this->version) <= 4)) {
379 $this->uadata['engine'] = 'nscp';
381 elseif (strpos($this->brand, 'Opera') !== false) {
382 $this->uadata['engine'] = 'presto';
384 elseif (strpos($this->brand, 'Dillo') !== false) {
385 $this->uadata['engine'] = 'gzilla';
387 elseif ((strpos($this->brand, 'ELinks') !== false) || (strpos($this->brand, 'Links') !== false)) {
388 $this->uadata['engine'] = 'links';
390 elseif ((strpos($this->brand, 'Avant') !== false) || (strpos($this->brand, 'Crazy Browser') !== false) || (strpos($this->brand, 'AOL') !== false) || (strpos($this->brand, 'MSN') !== false)) {
391 $this->uadata['engine'] = 'trident';
393 elseif (strpos($this->brand, 'Galeon') !== false) {
394 $this->uadata['engine'] = 'gecko';
397 return $this->uadata['engine'];
400 function hasEngine($rnd_engine) { return ($this->getEngine() == $rnd_engine); }
402 function getEngineVersion() {
403 if (!isset($this->uadata['eng_version'])) {
404 $this->uadata['eng_version'] = null;
405 // getOS() should get the date for us
408 return $this->uadata['eng_version'];
412 if (!isset($this->uadata['os'])) {
413 $this->uadata['os'] = null;
414 if ($this->hasEngine('gecko')) {
415 if (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
416 $this->uadata['os'] = $regs[2];
417 $this->uadata['lang'] = $regs[3];
418 $this->uadata['eng_version'] = $regs[4];
420 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
421 $this->uadata['os'] = $regs[2];
422 $this->uadata['lang'] = $regs[3];
423 $this->uadata['eng_version'] = 'M'.$regs[4];
425 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) {
426 $this->uadata['os'] = $regs[2];
427 $this->uadata['lang'] = null;
428 $this->uadata['eng_version'] = null;
430 elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) {
431 $this->uadata['os'] = $regs[2];
432 $this->uadata['lang'] = null;
433 $this->uadata['eng_version'] = null;
435 elseif (preg_match('|Debian/|', $this->uastring, $regs)) {
436 $this->uadata['os'] = 'Debian Linux';
437 $this->uadata['lang'] = null;
438 $this->uadata['eng_version'] = null;
441 elseif ($this->hasEngine('trident')) {
442 if (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE ([^;]+); [^\)]*((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
443 $this->uadata['eng_version'] = $regs[1];
444 $this->uadata['os'] = $regs[2];
445 $this->uadata['lang'] = null;
447 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
448 $this->uadata['eng_version'] = $regs[1];
449 $this->uadata['os'] = null;
450 $this->uadata['lang'] = null;
453 elseif ($this->hasEngine('khtml')) {
454 if (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^;]+); ([^;]+); ([^;]+); ([^\);]+)\)/i', $this->uastring, $regs)) {
455 $this->uadata['eng_version'] = $regs[1];
456 $this->uadata['os'] = $regs[2];
457 $this->uadata['lang'] = $regs[5];
459 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^\);]+)([^\)]+)\)/i', $this->uastring, $regs)) {
460 $this->uadata['eng_version'] = $regs[1];
461 $this->uadata['os'] = $regs[2];
462 $this->uadata['lang'] = null;
464 elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
465 $this->uadata['os'] = $regs[2];
466 $this->uadata['lang'] = $regs[3];
467 $this->uadata['eng_version'] = null;
469 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^\);]+)\)/i', $this->uastring, $regs)) {
470 $this->uadata['os'] = $regs[1];
471 $this->uadata['lang'] = null;
472 $this->uadata['eng_version'] = null;
475 elseif ($this->hasEngine('presto')) {
476 if (preg_match('/Opera\/[^\(]+ \(([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
477 $this->uadata['eng_version'] = $this->getVersion();
478 $this->uadata['os'] = $regs[1];
479 $this->uadata['lang'] = $regs[2];
481 elseif (preg_match('/Opera\/[^\(]+ \(([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) {
482 $this->uadata['eng_version'] = $this->getVersion();
483 $this->uadata['os'] = $regs[1];
484 $this->uadata['lang'] = $regs[2];
486 elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^;]+)\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) {
487 $this->uadata['eng_version'] = $this->getVersion();
488 $this->uadata['os'] = $regs[1];
489 $this->uadata['lang'] = $regs[2];
492 elseif ($this->hasEngine('nscp')) {
493 if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) \[([a-z_-]+)\] \(([^;]+); [^\)]+\)/i', $this->uastring, $regs)) {
494 $this->uadata['eng_version'] = $regs[1];
495 $this->uadata['os'] = $regs[3];
496 $this->uadata['lang'] = $regs[2];
499 elseif ($this->hasEngine('gzilla')) {
500 $this->uadata['eng_version'] = $this->getVersion();
501 $this->uadata['os'] = null;
502 $this->uadata['lang'] = null;
504 elseif ($this->hasEngine('links')) {
505 if (preg_match('/ELinks[^\(]+\([^;]+; ([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
506 $this->uadata['eng_version'] = null;
507 $this->uadata['os'] = $regs[1];
508 $this->uadata['lang'] = null;
512 $this->uadata['eng_version'] = null;
513 $this->uadata['lang'] = null;
514 if (preg_match('/AmigaOS/i', $this->uastring, $regs)) {
515 $this->uadata['os'] = 'AmigaOS';
517 elseif (preg_match('/curl\/[^\(]+\(([^\);]+)/i', $this->uastring, $regs)) {
518 $this->uadata['os'] = $regs[1];
521 if ($this->uadata['os'] == 'Win 9x 4.90') { $this->uadata['os'] = 'Windows ME'; }
522 elseif ($this->uadata['os'] == 'WinNT4.0') { $this->uadata['os'] = 'Windows ME'; }
523 elseif ($this->uadata['os'] == 'Windows NT 5.0') { $this->uadata['os'] = 'Windows 2000'; }
524 elseif ($this->uadata['os'] == 'Windows NT 5.1') { $this->uadata['os'] = 'Windows XP'; }
525 elseif ($this->uadata['os'] == 'Windows NT 5.2') { $this->uadata['os'] = 'Windows 2003'; }
526 elseif ($this->uadata['os'] == 'Win95') { $this->uadata['os'] = 'Windows 95'; }
527 elseif ($this->uadata['os'] == 'Win98') { $this->uadata['os'] = 'Windows 98'; }
528 elseif (preg_match('/Mac ?OS ?X/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; }
529 elseif (preg_match('/Mac_P(ower|)PC/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; }
530 elseif (strpos($this->uadata['os'], 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }
531 elseif (strpos($this->uadata['os'], 'apple') !== false) { $this->uadata['os'] = 'MacOS'; }
532 elseif (strpos($this->uadata['os'], 'linux') !== false) { $this->uadata['os'] = 'Linux'; }
534 if (strpos($this->uadata['os'], 'Win') !== false) { $this->uadata['platform'] = 'windows'; }
535 elseif (strpos($this->uadata['os'], 'Mac') !== false) { $this->uadata['platform'] = 'mac'; }
536 elseif (strpos($this->uadata['os'], 'Linux') !== false) { $this->uadata['platform'] = 'linux'; }
537 elseif (strpos($this->uadata['os'], 'Solaris') !== false) { $this->uadata['platform'] = 'solaris'; }
538 elseif (strpos($this->uadata['os'], 'FreeBSD') !== false) { $this->uadata['platform'] = 'freebsd'; }
539 elseif (strpos($this->uadata['os'], 'AmigaOS') !== false) { $this->uadata['platform'] = 'amiga'; }
540 else { $this->uadata['platform'] = null; }
542 $this->uadata['lang'] = str_replace('_', '-', $this->uadata['lang']);
544 return $this->uadata['os'];
547 function getPlatform() {
548 if (!isset($this->uadata['platform'])) {
549 $this->uadata['platform'] = null;
550 // getOS() should get the date for us
553 return $this->uadata['platform'];
556 function getLanguage() {
557 if (!isset($this->uadata['lang'])) {
558 $this->uadata['lang'] = null;
559 // getOS() should get the date for us
562 return $this->uadata['lang'];
565 function getGeckoDate() {
566 if (!isset($this->uadata['geckodate'])) {
567 $this->uadata['geckodate'] = null;
568 // getEngine() should get the date for us
571 return $this->uadata['geckodate'];
574 function isbot() { return $this->bot; }
575 function isns() { return (strpos($this->brand, 'Netscape') !== false); }
576 function isns4() { return ((strpos($this->brand, 'Netscape') !== false) && (intval($this->version) == 4)); }
577 function isie() { return $this->hasEngine('trident'); }
578 function geckodate() { return (!is_null($this->getGeckoDate())?$this->getGeckoDate():0); }
579 function geckobased() { return $this->hasEngine('gecko'); }
580 function khtmlbased() { return $this->hasEngine('khtml'); }