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