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