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. |
19 | * Portions created by the Initial Developer are Copyright (C) 2003 |
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 | // |
100 | // *** functions for compat to older versions of this class *** |
101 | // |
3077a4f6 |
102 | // public function isns() |
31733e08 |
103 | // returns true if User Agent seems to be Netscape brand, false if not |
3077a4f6 |
104 | // public function isns4() |
31733e08 |
105 | // returns true if User Agent seems to be Netscape Communicator 4.x, false if not |
3077a4f6 |
106 | // public function isie() |
31733e08 |
107 | // returns true if User Agent seems to be a version of Internet Exploder, false if not |
3077a4f6 |
108 | // public function geckobased() |
31733e08 |
109 | // returns true if User Agent seems to be a Gecko-based browser, false if not |
3077a4f6 |
110 | // public function geckodate() |
31733e08 |
111 | // returns the Gecko date when it's a Gecko-based browser, 0 if not |
3077a4f6 |
112 | // public function khtmlbased() |
1defa974 |
113 | // returns true if User Agent seems to be a KHTML-based browser, false if not |
114 | |
115 | // collection of some known User Agent Strings: |
bf78d3ed |
116 | // *** see testbed/ua_list_raw.txt *** |
117 | // *** see also http://www.pgts.com.au/pgtsj/pgtsj0208c.html *** |
31733e08 |
118 | |
3077a4f6 |
119 | private $uastring; |
120 | private $brand; |
121 | private $version; |
122 | private $bot = false; |
123 | private $uadata = array(); |
31733e08 |
124 | |
3077a4f6 |
125 | function __construct($ua_string = '') { |
31733e08 |
126 | // *** constructor *** |
1defa974 |
127 | if (strlen($ua_string)) { |
128 | $this->uastring = $ua_string; |
129 | } |
130 | else { |
131 | // read raw UA string |
4210e7b0 |
132 | $this->uastring = $_SERVER['HTTP_USER_AGENT']; |
1defa974 |
133 | } |
31733e08 |
134 | |
135 | // get UA brand and version |
bf78d3ed |
136 | $this->brand = 'Unknown'; $this->version = null; |
137 | // find reasonable defaults |
6e783db6 |
138 | if (preg_match('|([0-9a-zA-Z\.:()_ -]+)/([0-9a-zA-Z\._+-]+)|', $this->uastring, $regs)) { |
bf78d3ed |
139 | $this->brand = trim($regs[1]); |
140 | $this->version = $regs[2]; |
141 | } |
142 | elseif (preg_match('|^([a-zA-Z\._ -]+)[_ -][vV]?([0-9][0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
143 | $this->brand = trim($regs[1]); |
144 | $this->version = $regs[2]; |
145 | } |
146 | elseif (preg_match('|^([a-zA-Z\._ -]+)|', $this->uastring, $regs)) { |
147 | $this->brand = trim($regs[1]); |
148 | $this->version = null; |
149 | } |
81e72a3e |
150 | $this->bot = (strpos(strtolower($this->brand), 'bot') !== false) |
151 | || (strpos(strtolower($this->brand), 'crawler') !== false) |
152 | || (strpos(strtolower($this->brand), 'spider') !== false); |
153 | |
bf78d3ed |
154 | // search for any real and/or special UAs |
155 | if (preg_match('|Netscape6/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
156 | $this->brand = 'Netscape'; |
31733e08 |
157 | $this->version = $regs[1]; |
81e72a3e |
158 | $this->bot = false; |
31733e08 |
159 | } |
bf78d3ed |
160 | elseif (preg_match('|Netscape/([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('|Chimera/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
166 | $this->brand = 'Chimera'; |
1defa974 |
167 | $this->version = $regs[1]; |
81e72a3e |
168 | $this->bot = false; |
1defa974 |
169 | } |
bf78d3ed |
170 | elseif (preg_match('|Camino/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
171 | $this->brand = 'Camino'; |
a5813ca3 |
172 | $this->version = $regs[1]; |
81e72a3e |
173 | $this->bot = false; |
a5813ca3 |
174 | } |
bf78d3ed |
175 | elseif (preg_match('|Phoenix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
176 | $this->brand = 'Phoenix'; |
1defa974 |
177 | $this->version = $regs[1]; |
81e72a3e |
178 | $this->bot = false; |
1defa974 |
179 | } |
bf78d3ed |
180 | elseif (preg_match('|Mozilla Firebird/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
181 | $this->brand = 'Mozilla Firebird'; |
23585ba2 |
182 | $this->version = $regs[1]; |
81e72a3e |
183 | $this->bot = false; |
23585ba2 |
184 | } |
c18a4476 |
185 | elseif (preg_match('|Flock/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
186 | $this->brand = 'Flock'; |
187 | $this->version = $regs[1]; |
188 | $this->bot = false; |
189 | } |
bf78d3ed |
190 | elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
191 | $this->brand = 'Firefox'; |
a5813ca3 |
192 | $this->version = $regs[1]; |
81e72a3e |
193 | $this->bot = false; |
a5813ca3 |
194 | } |
b24eb888 |
195 | elseif (preg_match('|SeaMonkey/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
196 | $this->brand = 'SeaMonkey'; |
197 | $this->version = $regs[1]; |
81e72a3e |
198 | $this->bot = false; |
b24eb888 |
199 | } |
c18a4476 |
200 | elseif (preg_match('|Iceape/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { |
201 | $this->brand = 'IceApe'; |
202 | $this->version = $regs[1]; |
203 | $this->bot = false; |
204 | } |
205 | elseif (preg_match('|Iceweasel/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { |
206 | $this->brand = 'IceWeasel'; |
207 | $this->version = $regs[1]; |
208 | $this->bot = false; |
209 | } |
bf78d3ed |
210 | elseif (preg_match('|Galeon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
211 | $this->brand = 'Galeon'; |
31733e08 |
212 | $this->version = $regs[1]; |
81e72a3e |
213 | $this->bot = false; |
31733e08 |
214 | } |
6e783db6 |
215 | elseif (preg_match('|Epiphany/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
216 | $this->brand = 'Epiphany'; |
217 | $this->version = $regs[1]; |
81e72a3e |
218 | $this->bot = false; |
6e783db6 |
219 | } |
220 | elseif (preg_match('|K-Meleon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
221 | $this->brand = 'K-Meleon'; |
222 | $this->version = $regs[1]; |
81e72a3e |
223 | $this->bot = false; |
6e783db6 |
224 | } |
225 | elseif (preg_match('|AOL[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
226 | $this->brand = 'AOL'; |
227 | $this->version = $regs[1]; |
81e72a3e |
228 | $this->bot = false; |
6e783db6 |
229 | } |
bf78d3ed |
230 | elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { |
231 | $this->brand = 'Mozilla'; |
31733e08 |
232 | $this->version = $regs[1]; |
81e72a3e |
233 | $this->bot = false; |
31733e08 |
234 | } |
09cd2756 |
235 | elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) && strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { |
236 | $this->brand = 'Mozilla'; |
237 | $this->version = 'M'.$regs[1]; |
238 | $this->bot = false; |
239 | } |
c18a4476 |
240 | elseif (preg_match('|Opera\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) { |
241 | $this->brand = 'Opera Mini'; |
242 | $this->version = $regs[1]; |
243 | $this->bot = false; |
244 | } |
245 | elseif (preg_match('/Opera\/[^\(]+ \(.*; Opera Mini\/([^;]+); /i', $this->uastring, $regs)) { |
246 | $this->brand = 'Opera Mini'; |
247 | $this->version = $regs[1]; |
248 | $this->bot = false; |
249 | } |
bf78d3ed |
250 | elseif (preg_match('|Opera[ /]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
251 | $this->brand = 'Opera'; |
31733e08 |
252 | $this->version = $regs[1]; |
81e72a3e |
253 | $this->bot = false; |
31733e08 |
254 | } |
c18a4476 |
255 | elseif (preg_match('|OmniWeb/([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) { |
bf78d3ed |
256 | $this->brand = 'OmniWeb'; |
1defa974 |
257 | $this->version = $regs[1]; |
81e72a3e |
258 | $this->bot = false; |
1defa974 |
259 | } |
bf78d3ed |
260 | elseif (preg_match('|Konqueror/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
261 | $this->brand = 'Konqueror'; |
31733e08 |
262 | $this->version = $regs[1]; |
81e72a3e |
263 | $this->bot = false; |
31733e08 |
264 | } |
c18a4476 |
265 | elseif (preg_match('|Shiira/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
266 | $this->brand = 'Shiira'; |
267 | $this->version = $regs[1]; |
268 | $this->bot = false; |
269 | } |
bf78d3ed |
270 | elseif (preg_match('|Safari/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
271 | $this->brand = 'Safari'; |
1defa974 |
272 | $this->version = $regs[1]; |
81e72a3e |
273 | $this->bot = false; |
1defa974 |
274 | } |
bf78d3ed |
275 | elseif (preg_match('|AppleWebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
276 | $this->brand = 'AppleWebKit'; |
1defa974 |
277 | $this->version = $regs[1]; |
81e72a3e |
278 | $this->bot = false; |
1defa974 |
279 | } |
bf78d3ed |
280 | elseif (preg_match('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
281 | $this->brand = 'Microsoft FrontPage'; |
f983aa36 |
282 | $this->version = $regs[1]; |
81e72a3e |
283 | $this->bot = false; |
f983aa36 |
284 | } |
bf78d3ed |
285 | elseif (preg_match('|iCab[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
286 | $this->brand = 'iCab'; |
a8464009 |
287 | $this->version = $regs[1]; |
81e72a3e |
288 | $this->bot = false; |
a8464009 |
289 | } |
bf78d3ed |
290 | elseif (preg_match('|IBrowse[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
291 | $this->brand = 'IBrowse'; |
a8464009 |
292 | $this->version = $regs[1]; |
81e72a3e |
293 | $this->bot = false; |
a8464009 |
294 | } |
c18a4476 |
295 | elseif (preg_match('|ICEbrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
296 | $this->brand = 'ICEbrowser'; |
297 | $this->version = $regs[1]; |
298 | $this->bot = false; |
299 | } |
300 | elseif (preg_match('|ICE Browser/v([0-9a-zA-Z\._+]+)|', $this->uastring, $regs)) { |
301 | $this->brand = 'ICEbrowser'; |
302 | $this->version = str_replace('_', '.', $regs[1]); |
303 | $this->bot = false; |
304 | } |
305 | elseif (preg_match('|NetPositive/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
306 | $this->brand = 'NetPositive'; |
307 | $this->version = $regs[1]; |
308 | $this->bot = false; |
309 | } |
310 | elseif (preg_match('|WebPro/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
311 | $this->brand = 'WebPro (Novarra)'; |
312 | $this->version = $regs[1]; |
313 | $this->bot = false; |
314 | } |
315 | elseif (preg_match('|; OffByOne;|', $this->uastring, $regs)) { |
316 | $this->brand = 'Off By One'; |
317 | $this->version = null; |
318 | $this->bot = false; |
319 | } |
320 | elseif (preg_match('|PSP \(PlayStation Portable\); ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
321 | $this->brand = 'PlayStation Portable'; |
322 | $this->version = $regs[1]; |
323 | $this->bot = false; |
324 | } |
325 | elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
326 | $this->brand = 'NetFront'; |
a8464009 |
327 | $this->version = $regs[1]; |
81e72a3e |
328 | $this->bot = false; |
a8464009 |
329 | } |
6e783db6 |
330 | elseif (preg_match('|UP.Browser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
331 | $this->brand = 'UP.Browser'; |
332 | $this->version = $regs[1]; |
81e72a3e |
333 | $this->bot = false; |
6e783db6 |
334 | } |
c18a4476 |
335 | elseif (preg_match('|UP.Link/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
336 | $this->brand = 'UP.Link'; |
337 | $this->version = $regs[1]; |
338 | $this->bot = false; |
339 | } |
340 | elseif (preg_match('|AU-MIC-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
341 | $this->brand = 'Obigo'; |
342 | $this->version = $regs[1]; |
343 | $this->bot = false; |
344 | } |
345 | elseif (preg_match('|Nokia([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
346 | $this->brand = 'Nokia'; |
347 | $this->version = $regs[1]; |
348 | $this->bot = false; |
349 | } |
350 | elseif (preg_match('|SonyEricsson([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
351 | $this->brand = 'SonyEricsson'; |
352 | $this->version = $regs[1]; |
353 | $this->bot = false; |
354 | } |
355 | elseif (preg_match('|SIE-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
356 | $this->brand = 'Siemens'; |
357 | $this->version = $regs[1]; |
358 | $this->bot = false; |
359 | } |
360 | elseif (preg_match('|MOT-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
361 | $this->brand = 'Motorola'; |
362 | $this->version = $regs[1]; |
363 | $this->bot = false; |
364 | } |
365 | elseif (preg_match('|IBM-WebExplorer-DLL/v([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
366 | $this->brand = 'WebExplorer'; |
367 | $this->version = $regs[1]; |
368 | $this->bot = false; |
369 | } |
bf78d3ed |
370 | elseif (preg_match('|ELinks \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) { |
371 | $this->brand = 'ELinks'; |
a8464009 |
372 | $this->version = $regs[1]; |
81e72a3e |
373 | $this->bot = false; |
a8464009 |
374 | } |
6e783db6 |
375 | elseif (preg_match('|Links \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) { |
376 | $this->brand = 'Links'; |
377 | $this->version = $regs[1]; |
81e72a3e |
378 | $this->bot = false; |
6e783db6 |
379 | } |
380 | elseif (preg_match('|wget[/ ]([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { |
381 | $this->brand = 'wget'; |
382 | $this->version = $regs[1]; |
81e72a3e |
383 | $this->bot = false; |
6e783db6 |
384 | } |
c18a4476 |
385 | elseif (preg_match('|; arexx\)|i', $this->uastring, $regs)) { |
386 | $this->brand = 'ARexx'; |
387 | $this->version = null; |
388 | $this->bot = false; |
389 | } |
bf78d3ed |
390 | elseif (preg_match('|ZyBorg/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
391 | $this->brand = 'ZyBorg'; |
a8464009 |
392 | $this->version = $regs[1]; |
393 | $this->bot = true; |
394 | } |
bf78d3ed |
395 | elseif (preg_match('|Googlebot/?([0-9a-zA-Z\.+]+)?|', $this->uastring, $regs)) { |
396 | $this->brand = 'Googlebot'; |
a8464009 |
397 | $this->version = $regs[1]; |
398 | $this->bot = true; |
399 | } |
bf78d3ed |
400 | elseif (preg_match('|Ask Jeeves/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
401 | $this->brand = 'Ask Jeeves'; |
a8464009 |
402 | $this->version = $regs[1]; |
403 | $this->bot = true; |
404 | } |
c51ab9a2 |
405 | elseif (preg_match('|Slurp|', $this->uastring, $regs)) { |
bf78d3ed |
406 | $this->brand = 'Slurp'; |
c51ab9a2 |
407 | $this->version = null; |
a8464009 |
408 | $this->bot = true; |
409 | } |
bf78d3ed |
410 | elseif (preg_match('|Gulper Web Bot ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
411 | $this->brand = 'Gulper Web Bot'; |
a8464009 |
412 | $this->version = $regs[1]; |
413 | $this->bot = true; |
414 | } |
bf78d3ed |
415 | elseif (preg_match('|HTTrack ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
416 | $this->brand = 'HTTrack'; |
a8464009 |
417 | $this->version = $regs[1]; |
418 | $this->bot = true; |
419 | } |
5b8eba2a |
420 | elseif (preg_match('|Microsoft URL Control - ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
421 | $this->brand = 'Microsoft URL Control'; |
422 | $this->version = $regs[1]; |
423 | $this->bot = true; |
424 | } |
81e72a3e |
425 | elseif (preg_match('|([0-9a-zA-Z\.+]+)_AC-Plug|', $this->uastring, $regs)) { |
426 | $this->brand = 'AC-Plug'; |
427 | $this->version = $regs[1]; |
428 | $this->bot = true; |
429 | } |
bf78d3ed |
430 | elseif (preg_match('|^Internet Explorer 5.5|', $this->uastring)) { |
431 | $this->brand = 'Unknown bot (IE5.5)'; |
432 | $this->version = null; |
a8464009 |
433 | $this->bot = true; |
434 | } |
bf78d3ed |
435 | elseif (preg_match('|^Mozilla[\s ]*$|', $this->uastring)) { |
436 | $this->brand = 'Unknown bot (Mozilla)'; |
437 | $this->version = null; |
a8464009 |
438 | $this->bot = true; |
439 | } |
bf78d3ed |
440 | elseif (preg_match('|http://www.almaden.ibm.com/cs/crawler|', $this->uastring)) { |
441 | $this->brand = 'almaden crawler'; |
442 | $this->version = null; |
a8464009 |
443 | $this->bot = true; |
444 | } |
bf78d3ed |
445 | elseif (preg_match('|B-l-i-t-z-B-O-T|', $this->uastring) || preg_match('|B l i t z B O T @ t r i c u s . n e t|', $this->uastring)) { |
446 | $this->brand = 'BlitzBOT'; |
447 | $this->version = null; |
a8464009 |
448 | $this->bot = true; |
449 | } |
bf78d3ed |
450 | elseif (preg_match('|sitecheck.internetseer.com|', $this->uastring)) { |
451 | $this->brand = 'internetseer'; |
452 | $this->version = null; |
a8464009 |
453 | $this->bot = true; |
454 | } |
bf78d3ed |
455 | elseif (preg_match('|Girafabot|', $this->uastring)) { |
456 | $this->brand = 'Girafabot'; |
457 | $this->version = null; |
a8464009 |
458 | $this->bot = true; |
459 | } |
bf78d3ed |
460 | elseif (preg_match('|efp@gmx.net|', $this->uastring)) { |
461 | $this->brand = 'efp'; |
462 | $this->version = null; |
a8464009 |
463 | $this->bot = true; |
464 | } |
81e72a3e |
465 | elseif (preg_match('|42_HAL|', $this->uastring)) { |
466 | $this->brand = '42_HAL'; |
467 | $this->version = null; |
468 | $this->bot = true; |
469 | } |
470 | elseif (preg_match('|Baiduspider|i', $this->uastring)) { |
471 | $this->brand = 'BaiDuSpider'; |
472 | $this->version = null; |
473 | $this->bot = true; |
474 | } |
475 | elseif (preg_match('|Indy Library|', $this->uastring)) { |
476 | $this->brand = 'Indy Library'; |
477 | $this->version = null; |
478 | $this->bot = true; |
479 | } |
bf78d3ed |
480 | elseif (preg_match('|^Firefly|', $this->uastring)) { |
481 | // comes here with correct value but would be detected as MSIE |
a8464009 |
482 | } |
81e72a3e |
483 | elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) { |
484 | $this->brand = 'Steganos Internet Anonym'; |
485 | $this->version = $regs[1]; |
486 | $this->bot = false; |
487 | } |
bf78d3ed |
488 | elseif (preg_match('|Avant Browser[^/]|', $this->uastring)) { |
489 | $this->brand = 'Avant Browser'; |
490 | $this->version = null; |
81e72a3e |
491 | $this->bot = false; |
a8464009 |
492 | } |
c18a4476 |
493 | elseif (preg_match('|Browser[^/]+(http://www.avantbrowser.com)|', $this->uastring)) { |
494 | $this->brand = 'Avant Browser'; |
495 | $this->version = null; |
496 | $this->bot = false; |
497 | } |
6e783db6 |
498 | elseif (preg_match('|Maxthon|', $this->uastring)) { |
499 | $this->brand = 'Maxthon'; |
500 | $this->version = null; |
81e72a3e |
501 | $this->bot = false; |
6e783db6 |
502 | } |
503 | elseif (preg_match('|MyIE2|', $this->uastring)) { |
504 | $this->brand = 'MyIE2'; |
505 | $this->version = null; |
81e72a3e |
506 | $this->bot = false; |
6e783db6 |
507 | } |
bf78d3ed |
508 | elseif (preg_match('|Crazy Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
509 | $this->brand = 'Crazy Browser'; |
510 | $this->version = $regs[1]; |
81e72a3e |
511 | $this->bot = false; |
512 | } |
513 | elseif (preg_match('|AvantGo ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
514 | $this->brand = 'AvantGo'; |
515 | $this->version = $regs[1]; |
516 | $this->bot = false; |
a8464009 |
517 | } |
bf78d3ed |
518 | elseif (preg_match('|MSN ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
519 | $this->brand = 'MSN'; |
520 | $this->version = $regs[1]; |
81e72a3e |
521 | $this->bot = false; |
a8464009 |
522 | } |
c18a4476 |
523 | elseif (preg_match('|America Online Browser [0-9a-zA-Z\.+]+; rev([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
524 | $this->brand = 'AOL Browser'; |
525 | $this->version = $regs[1]; |
526 | $this->bot = false; |
527 | } |
bf78d3ed |
528 | elseif (preg_match('|MS FrontPage ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
529 | $this->brand = 'Microsoft FrontPage'; |
530 | $this->version = $regs[1]; |
81e72a3e |
531 | $this->bot = false; |
a8464009 |
532 | } |
c18a4476 |
533 | elseif (preg_match('|Microsoft Internet Explorer/4.0b1|', $this->uastring, $regs)) { |
534 | $this->brand = 'Microsoft Internet Explorer'; |
535 | $this->version = '1.0'; |
536 | $this->bot = false; |
537 | } |
bf78d3ed |
538 | elseif (preg_match('|MSIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
539 | $this->brand = 'Microsoft Internet Explorer'; |
31733e08 |
540 | $this->version = $regs[1]; |
81e72a3e |
541 | $this->bot = false; |
31733e08 |
542 | } |
c18a4476 |
543 | elseif (preg_match('|MSPIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
544 | $this->brand = 'Microsoft Pocket Internet Explorer'; |
545 | $this->version = $regs[1]; |
546 | $this->bot = false; |
547 | } |
81e72a3e |
548 | elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && (strpos($this->uastring, 'compatible;') === false) && (strpos($this->uastring, 'Gecko/') === false)) { |
bf78d3ed |
549 | $this->brand = 'Netscape'; |
1defa974 |
550 | $this->version = $regs[1]; |
bf78d3ed |
551 | if (intval($this->version) == 4) { $this->brand .= ' Communicator'; } |
81e72a3e |
552 | $this->bot = false; |
553 | } |
554 | elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && (strpos($this->uastring, 'compatible;') !== false)) { |
555 | $this->brand = 'Mozilla-compatible (unknown)'; |
556 | $this->version = null; |
557 | $this->bot = false; |
1defa974 |
558 | } |
a8464009 |
559 | |
81e72a3e |
560 | $botArray = array('Scooter','Spinne','Vagabondo','Firefly','Scrubby','NG','Pompos','Szukacz','ASPseek', |
561 | 'NetResearchServer','LinkWalker','Zeus','W3C_Validator','ZyBorg','Ask Jeeves','ia_archiver', |
562 | 'PingALink Monitoring Services','IlTrovatore-Setaccio','Nutch','Mercator','search.ch', |
563 | 'appie','larbin','NutchCVS','ObjectsSearch','Webchat','Mediapartners-Google','Schmozilla', |
5b8eba2a |
564 | 'FavOrg','findlinks','DataCha0s','ichiro','Francis','','','','','','',''); |
a8464009 |
565 | |
566 | if (in_array($this->brand, $botArray)) { |
567 | $this->bot = true; |
568 | } |
31733e08 |
569 | } |
570 | |
3077a4f6 |
571 | public function getBrand() { return $this->brand; } |
572 | public function getVersion() { return $this->version; } |
4210e7b0 |
573 | |
3077a4f6 |
574 | public function getAcceptLanguages() { |
4210e7b0 |
575 | if (!isset($this->uadata['accept-languages'])) { |
576 | $headers = getAllHeaders(); |
577 | $accLcomp = explode(',', $headers['Accept-Language']); |
578 | $accLang = array(); |
579 | foreach ($accLcomp as $lcomp) { |
580 | if (strlen($lcomp)) { |
581 | $ldef = explode(';', $lcomp); |
437e1c91 |
582 | $accLang[$ldef[0]] = (float)((strpos(@$ldef[1],'q=')===0)?substr($ldef[1],2):1); |
4210e7b0 |
583 | } |
584 | } |
585 | $this->uadata['accept-languages'] = $accLang; |
586 | } |
587 | return $this->uadata['accept-languages']; |
588 | } |
589 | |
3077a4f6 |
590 | public function getUAString() { return $this->uastring; } |
23585ba2 |
591 | |
3077a4f6 |
592 | public function getEngine() { |
c18a4476 |
593 | // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|unknown |
bf78d3ed |
594 | if (!isset($this->uadata['engine'])) { |
ac9220c2 |
595 | $this->uadata['engine'] = 'unknown'; |
bf78d3ed |
596 | $this->uadata['geckodate'] = null; |
597 | if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs)) { |
598 | $this->uadata['engine'] = 'gecko'; |
599 | $this->uadata['geckodate'] = $regs[1]; |
600 | } |
601 | elseif ((strpos($this->brand, 'Internet Explorer') !== false) || (strpos($this->brand, 'FrontPage') !== false)) { |
6e783db6 |
602 | if ((strpos(strtolower($this->uastring), 'mac') !== false) && (intval($this->getVersion()) >= 5)) { |
bf78d3ed |
603 | $this->uadata['engine'] = 'tasman'; |
604 | } |
605 | else { |
606 | $this->uadata['engine'] = 'trident'; |
607 | } |
608 | } |
c18a4476 |
609 | elseif ((strpos($this->brand, 'Konqueror') !== false) || (strpos($this->brand, 'Safari') !== false) || |
610 | (strpos($this->brand, 'Shiira') !== false) || |
611 | (strpos($this->brand, 'AppleWebKit') !== false) || (strpos($this->brand, 'OmniWeb') !== false)) { |
bf78d3ed |
612 | $this->uadata['engine'] = 'khtml'; |
613 | } |
81e72a3e |
614 | elseif (strpos($this->brand, 'Netscape') !== false) { |
615 | // non-Gecko Netscape browsers |
616 | if (intval($this->version) <= 4) { |
617 | $this->uadata['engine'] = 'nscp'; |
618 | } |
619 | elseif (strpos($this->uastring, 'MSIE') !== false) { |
620 | $this->uadata['engine'] = 'trident'; |
621 | } |
bf78d3ed |
622 | } |
623 | elseif (strpos($this->brand, 'Opera') !== false) { |
624 | $this->uadata['engine'] = 'presto'; |
625 | } |
626 | elseif (strpos($this->brand, 'Dillo') !== false) { |
627 | $this->uadata['engine'] = 'gzilla'; |
628 | } |
629 | elseif ((strpos($this->brand, 'ELinks') !== false) || (strpos($this->brand, 'Links') !== false)) { |
630 | $this->uadata['engine'] = 'links'; |
631 | } |
c18a4476 |
632 | elseif ((strpos($this->brand, 'ICEbrowser') !== false) || (strpos($this->brand, 'ICE Browser') !== false)) { |
633 | $this->uadata['engine'] = 'icestorm'; |
634 | } |
6e783db6 |
635 | elseif ((strpos($this->brand, 'Avant') !== false) || (strpos($this->brand, 'Crazy Browser') !== false) || |
636 | (strpos($this->brand, 'AOL') !== false) || (strpos($this->brand, 'MSN') !== false) || |
637 | (strpos($this->brand, 'MyIE2') !== false) || (strpos($this->brand, 'Maxthon') !== false)) { |
bf78d3ed |
638 | $this->uadata['engine'] = 'trident'; |
639 | } |
640 | elseif (strpos($this->brand, 'Galeon') !== false) { |
641 | $this->uadata['engine'] = 'gecko'; |
31733e08 |
642 | } |
c18a4476 |
643 | elseif (strpos($this->brand, 'WebPro') !== false) { |
644 | $this->uadata['engine'] = 'nscp'; |
645 | } |
31733e08 |
646 | } |
bf78d3ed |
647 | return $this->uadata['engine']; |
31733e08 |
648 | } |
649 | |
3077a4f6 |
650 | public function hasEngine($rnd_engine) { return ($this->getEngine() == $rnd_engine); } |
bf78d3ed |
651 | |
3077a4f6 |
652 | public function getEngineVersion() { |
bf78d3ed |
653 | if (!isset($this->uadata['eng_version'])) { |
654 | $this->uadata['eng_version'] = null; |
655 | // getOS() should get the date for us |
656 | $this->getOS(); |
31733e08 |
657 | } |
bf78d3ed |
658 | return $this->uadata['eng_version']; |
31733e08 |
659 | } |
660 | |
3077a4f6 |
661 | public function getOS() { |
bf78d3ed |
662 | if (!isset($this->uadata['os'])) { |
663 | $this->uadata['os'] = null; |
664 | if ($this->hasEngine('gecko')) { |
81e72a3e |
665 | if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { |
bf78d3ed |
666 | $this->uadata['os'] = $regs[2]; |
f9a0c27d |
667 | $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null; |
bf78d3ed |
668 | $this->uadata['eng_version'] = $regs[4]; |
669 | } |
81e72a3e |
670 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { |
671 | $this->uadata['os'] = $regs[2]; |
672 | $this->uadata['lang'] = null; |
673 | $this->uadata['eng_version'] = $regs[3]; |
674 | } |
6e783db6 |
675 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { |
bf78d3ed |
676 | $this->uadata['os'] = $regs[2]; |
677 | $this->uadata['lang'] = $regs[3]; |
678 | $this->uadata['eng_version'] = 'M'.$regs[4]; |
679 | } |
09cd2756 |
680 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { |
681 | $this->uadata['os'] = $regs[1]; |
682 | $this->uadata['lang'] = $regs[2]; |
683 | $this->uadata['eng_version'] = 'M'.$regs[3]; |
684 | } |
6e783db6 |
685 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) { |
686 | $this->uadata['os'] = $regs[2]; |
687 | $this->uadata['lang'] = $regs[3]; |
688 | $this->uadata['eng_version'] = null; |
689 | } |
f9a0c27d |
690 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) { |
691 | $this->uadata['os'] = $regs[2]; |
692 | $this->uadata['lang'] = null; |
693 | $this->uadata['eng_version'] = $regs[3]; |
694 | } |
6e783db6 |
695 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^\);]+)\)|', $this->uastring, $regs)) { |
bf78d3ed |
696 | $this->uadata['os'] = $regs[2]; |
697 | $this->uadata['lang'] = null; |
698 | $this->uadata['eng_version'] = null; |
699 | } |
700 | elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) { |
701 | $this->uadata['os'] = $regs[2]; |
702 | $this->uadata['lang'] = null; |
703 | $this->uadata['eng_version'] = null; |
704 | } |
705 | elseif (preg_match('|Debian/|', $this->uastring, $regs)) { |
706 | $this->uadata['os'] = 'Debian Linux'; |
707 | $this->uadata['lang'] = null; |
708 | $this->uadata['eng_version'] = null; |
709 | } |
710 | } |
6e783db6 |
711 | elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) { |
c18a4476 |
712 | if (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) { |
713 | $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:$regs[1]; |
bf78d3ed |
714 | $this->uadata['os'] = $regs[2]; |
715 | $this->uadata['lang'] = null; |
716 | } |
81e72a3e |
717 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) { |
bf78d3ed |
718 | $this->uadata['eng_version'] = $regs[1]; |
719 | $this->uadata['os'] = null; |
720 | $this->uadata['lang'] = null; |
721 | } |
c18a4476 |
722 | elseif (preg_match('/Microsoft Internet Explorer\/[^\s]+ \(((?:Mac|Win)[^;\)]+)\)/i', $this->uastring, $regs)) { |
723 | $this->uadata['eng_version'] = $this->getVersion(); |
724 | $this->uadata['os'] = $regs[1]; |
725 | $this->uadata['lang'] = null; |
726 | } |
727 | elseif (preg_match('/Microsoft Pocket Internet Explorer\/[^\s]+/i', $this->uastring, $regs)) { |
728 | $this->uadata['eng_version'] = null; |
729 | $this->uadata['os'] = 'Windows CE'; |
730 | $this->uadata['lang'] = null; |
731 | } |
31733e08 |
732 | } |
bf78d3ed |
733 | elseif ($this->hasEngine('khtml')) { |
6e783db6 |
734 | if (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^;]+); ([^;]+); ([^;]+); ([^\);]+)\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) { |
735 | $this->uadata['eng_version'] = strlen($regs[6])?$regs[6]:$regs[1]; |
bf78d3ed |
736 | $this->uadata['os'] = $regs[2]; |
737 | $this->uadata['lang'] = $regs[5]; |
738 | } |
6e783db6 |
739 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^\);]+)[^\)]*\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) { |
740 | $this->uadata['eng_version'] = strlen($regs[3])?$regs[3]:$regs[1]; |
bf78d3ed |
741 | $this->uadata['os'] = $regs[2]; |
742 | $this->uadata['lang'] = null; |
743 | } |
744 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) { |
745 | $this->uadata['os'] = $regs[2]; |
746 | $this->uadata['lang'] = $regs[3]; |
747 | $this->uadata['eng_version'] = null; |
748 | } |
c18a4476 |
749 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) { |
750 | $this->uadata['os'] = $regs[1]; |
751 | $this->uadata['lang'] = $regs[2]; |
752 | $this->uadata['eng_version'] = null; |
753 | } |
bf78d3ed |
754 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^\);]+)\)/i', $this->uastring, $regs)) { |
755 | $this->uadata['os'] = $regs[1]; |
756 | $this->uadata['lang'] = null; |
757 | $this->uadata['eng_version'] = null; |
758 | } |
759 | } |
760 | elseif ($this->hasEngine('presto')) { |
c18a4476 |
761 | // Opera < 8 |
f9a0c27d |
762 | if (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) { |
bf78d3ed |
763 | $this->uadata['eng_version'] = $this->getVersion(); |
764 | $this->uadata['os'] = $regs[1]; |
765 | $this->uadata['lang'] = $regs[2]; |
766 | } |
f9a0c27d |
767 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;\)]+)[^\)]*\) Opera [^ ]+ +\[([a-z_-]+)\]/i', $this->uastring, $regs)) { |
6e783db6 |
768 | $this->uadata['eng_version'] = $this->getVersion(); |
769 | $this->uadata['os'] = $regs[1]; |
770 | $this->uadata['lang'] = $regs[2]; |
771 | } |
f9a0c27d |
772 | elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) { |
6e783db6 |
773 | $this->uadata['eng_version'] = $this->getVersion(); |
774 | $this->uadata['os'] = $regs[1]; |
775 | $this->uadata['lang'] = $regs[2]; |
776 | } |
c18a4476 |
777 | // Opera mini |
778 | elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini; ([a-z_-]+); /i', $this->uastring, $regs)) { |
779 | $this->uadata['eng_version'] = null; |
780 | $this->uadata['os'] = $regs[2]; |
781 | $this->uadata['lang'] = $regs[3]; |
782 | } |
783 | elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini\/[^;]+; ([a-z_-]+); /i', $this->uastring, $regs)) { |
784 | $this->uadata['eng_version'] = $regs[1]; |
785 | $this->uadata['os'] = $regs[2]; |
786 | $this->uadata['lang'] = $regs[3]; |
787 | } |
788 | // Opera >= 8 |
f9a0c27d |
789 | elseif (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) { |
bf78d3ed |
790 | $this->uadata['eng_version'] = $this->getVersion(); |
791 | $this->uadata['os'] = $regs[1]; |
792 | $this->uadata['lang'] = $regs[2]; |
793 | } |
f9a0c27d |
794 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { |
6e783db6 |
795 | $this->uadata['eng_version'] = $this->getVersion(); |
796 | $this->uadata['os'] = $regs[1]; |
797 | $this->uadata['lang'] = $regs[2]; |
798 | } |
f9a0c27d |
799 | elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { |
bf78d3ed |
800 | $this->uadata['eng_version'] = $this->getVersion(); |
801 | $this->uadata['os'] = $regs[1]; |
802 | $this->uadata['lang'] = $regs[2]; |
803 | } |
804 | } |
805 | elseif ($this->hasEngine('nscp')) { |
f9a0c27d |
806 | if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) { |
807 | $this->uadata['eng_version'] = $regs[1]; |
808 | $this->uadata['os'] = $regs[3]; |
809 | $this->uadata['lang'] = $regs[2]; |
810 | } |
811 | elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) { |
bf78d3ed |
812 | $this->uadata['eng_version'] = $regs[1]; |
813 | $this->uadata['os'] = $regs[3]; |
814 | $this->uadata['lang'] = $regs[2]; |
815 | } |
c18a4476 |
816 | elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+)[^\(]+\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) { |
817 | $this->uadata['eng_version'] = $regs[1]; |
818 | $this->uadata['os'] = $regs[2]; |
819 | $this->uadata['lang'] = null; |
820 | } |
bf78d3ed |
821 | } |
822 | elseif ($this->hasEngine('gzilla')) { |
823 | $this->uadata['eng_version'] = $this->getVersion(); |
824 | $this->uadata['os'] = null; |
825 | $this->uadata['lang'] = null; |
826 | } |
827 | elseif ($this->hasEngine('links')) { |
6e783db6 |
828 | if (preg_match('/E?Links[^\(]+\([^;]+; ([^;]+)[^\)]+\)/i', $this->uastring, $regs)) { |
bf78d3ed |
829 | $this->uadata['eng_version'] = null; |
830 | $this->uadata['os'] = $regs[1]; |
831 | $this->uadata['lang'] = null; |
832 | } |
833 | } |
c18a4476 |
834 | elseif ($this->hasEngine('icestorm')) { |
835 | if (preg_match('/ICE Browser\/v?([0-9a-zA-Z\._+]+) \(Java [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) { |
836 | $this->uadata['eng_version'] = str_replace('_', '.', $regs[1]); |
837 | $this->uadata['os'] = $regs[2]; |
838 | $this->uadata['lang'] = null; |
839 | } |
840 | elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\).* ICEbrowser\/([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) { |
841 | $this->uadata['eng_version'] = $regs[3]; |
842 | $this->uadata['os'] = $regs[1]; |
843 | $this->uadata['lang'] = $regs[2]; |
844 | } |
845 | } |
bf78d3ed |
846 | else { |
847 | $this->uadata['eng_version'] = null; |
848 | $this->uadata['lang'] = null; |
849 | if (preg_match('/AmigaOS/i', $this->uastring, $regs)) { |
850 | $this->uadata['os'] = 'AmigaOS'; |
851 | } |
852 | elseif (preg_match('/curl\/[^\(]+\(([^\);]+)/i', $this->uastring, $regs)) { |
853 | $this->uadata['os'] = $regs[1]; |
854 | } |
6e783db6 |
855 | elseif (preg_match('/NCSA[_ ]Mosaic\/[^\(]+\((?:.*;)?([^\);]+)/i', $this->uastring, $regs)) { |
856 | $this->uadata['os'] = trim($regs[1]); |
857 | } |
858 | elseif (preg_match('/iCab.*(Mac[^\);]+).*?\)/i', $this->uastring, $regs)) { |
859 | $this->uadata['os'] = trim($regs[1]); |
860 | } |
c51ab9a2 |
861 | elseif (preg_match('/SymbianOS\/([^ ]+)/i', $this->uastring, $regs)) { |
862 | $this->uadata['os'] = 'SymbianOS '.$regs[1]; |
863 | } |
bf78d3ed |
864 | } |
865 | if ($this->uadata['os'] == 'Win 9x 4.90') { $this->uadata['os'] = 'Windows ME'; } |
804fe4f1 |
866 | elseif ($this->uadata['os'] == 'WinNT4.0') { $this->uadata['os'] = 'Windows NT 4.0'; } |
bf78d3ed |
867 | elseif ($this->uadata['os'] == 'Windows NT 5.0') { $this->uadata['os'] = 'Windows 2000'; } |
868 | elseif ($this->uadata['os'] == 'Windows NT 5.1') { $this->uadata['os'] = 'Windows XP'; } |
869 | elseif ($this->uadata['os'] == 'Windows NT 5.2') { $this->uadata['os'] = 'Windows 2003'; } |
55020829 |
870 | elseif ($this->uadata['os'] == 'Windows NT 5.2 x64') { $this->uadata['os'] = 'Windows 2003 (64bit)'; } |
871 | elseif ($this->uadata['os'] == 'Windows NT 6.0') { $this->uadata['os'] = 'Windows Vista'; } |
bf78d3ed |
872 | elseif ($this->uadata['os'] == 'Win95') { $this->uadata['os'] = 'Windows 95'; } |
873 | elseif ($this->uadata['os'] == 'Win98') { $this->uadata['os'] = 'Windows 98'; } |
55020829 |
874 | elseif ($this->uadata['os'] == 'WinNT') { $this->uadata['os'] = 'Windows NT'; } |
875 | elseif ($this->uadata['os'] == 'Win32') { $this->uadata['os'] = 'Windows (32bit)'; } |
876 | elseif ($this->uadata['os'] == 'Win64') { $this->uadata['os'] = 'Windows (64bit)'; } |
bf78d3ed |
877 | elseif (preg_match('/Mac ?OS ?X/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; } |
878 | elseif (preg_match('/Mac_P(ower|)PC/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; } |
879 | elseif (strpos($this->uadata['os'], 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } |
6e783db6 |
880 | elseif (strpos($this->uadata['os'], 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } |
bf78d3ed |
881 | elseif (strpos($this->uadata['os'], 'apple') !== false) { $this->uadata['os'] = 'MacOS'; } |
6e783db6 |
882 | elseif (strpos($this->uadata['os'], 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; } |
bf78d3ed |
883 | elseif (strpos($this->uadata['os'], 'linux') !== false) { $this->uadata['os'] = 'Linux'; } |
884 | |
6e783db6 |
885 | if (strpos($this->uadata['os'], 'Win') !== false) { $this->uadata['platform'] = 'Windows'; } |
886 | elseif (strpos($this->uadata['os'], 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; } |
887 | elseif (strpos($this->uadata['os'], 'Linux') !== false) { $this->uadata['platform'] = 'Linux'; } |
888 | elseif (strpos($this->uadata['os'], 'Solaris') !== false) { $this->uadata['platform'] = 'Solaris'; } |
889 | elseif (strpos($this->uadata['os'], 'SunOS') !== false) { $this->uadata['platform'] = 'Solaris'; } |
890 | elseif (strpos($this->uadata['os'], 'BeOS') !== false) { $this->uadata['platform'] = 'BeOS'; } |
891 | elseif (strpos($this->uadata['os'], 'FreeBSD') !== false) { $this->uadata['platform'] = 'FreeBSD'; } |
892 | elseif (strpos($this->uadata['os'], 'OpenBSD') !== false) { $this->uadata['platform'] = 'OpenBSD'; } |
893 | elseif (strpos($this->uadata['os'], 'NetBSD') !== false) { $this->uadata['platform'] = 'NetBSD'; } |
894 | elseif (strpos($this->uadata['os'], 'AIX') !== false) { $this->uadata['platform'] = 'AIX'; } |
895 | elseif (strpos($this->uadata['os'], 'IRIX') !== false) { $this->uadata['platform'] = 'IRIX'; } |
896 | elseif (strpos($this->uadata['os'], 'HP-UX') !== false) { $this->uadata['platform'] = 'HP-UX'; } |
897 | elseif (strpos($this->uadata['os'], 'AmigaOS') !== false) { $this->uadata['platform'] = 'Amiga'; } |
898 | elseif (strpos($this->uadata['os'], 'OpenVMS') !== false) { $this->uadata['platform'] = 'OpenVMS'; } |
899 | elseif (strpos($this->uadata['os'], 'Warp') !== false) { $this->uadata['platform'] = 'OS/2'; } |
c51ab9a2 |
900 | elseif (strpos($this->uadata['os'], 'SymbianOS') !== false) { $this->uadata['platform'] = 'SymbianOS'; } |
6e783db6 |
901 | elseif (strpos($this->uadata['os'], 'CYGWIN') !== false) { $this->uadata['platform'] = 'Windows'; } |
902 | else { $this->uadata['platform'] = $this->uadata['os']; } |
bf78d3ed |
903 | |
904 | $this->uadata['lang'] = str_replace('_', '-', $this->uadata['lang']); |
31733e08 |
905 | } |
bf78d3ed |
906 | return $this->uadata['os']; |
31733e08 |
907 | } |
908 | |
3077a4f6 |
909 | public function getPlatform() { |
bf78d3ed |
910 | if (!isset($this->uadata['platform'])) { |
911 | $this->uadata['platform'] = null; |
912 | // getOS() should get the date for us |
913 | $this->getOS(); |
31733e08 |
914 | } |
bf78d3ed |
915 | return $this->uadata['platform']; |
31733e08 |
916 | } |
917 | |
3077a4f6 |
918 | public function getLanguage() { |
bf78d3ed |
919 | if (!isset($this->uadata['lang'])) { |
920 | $this->uadata['lang'] = null; |
921 | // getOS() should get the date for us |
922 | $this->getOS(); |
31733e08 |
923 | } |
bf78d3ed |
924 | return $this->uadata['lang']; |
31733e08 |
925 | } |
1defa974 |
926 | |
3077a4f6 |
927 | public function getGeckoDate() { |
bf78d3ed |
928 | if (!isset($this->uadata['geckodate'])) { |
929 | $this->uadata['geckodate'] = null; |
930 | // getEngine() should get the date for us |
931 | $this->getEngine(); |
1defa974 |
932 | } |
bf78d3ed |
933 | return $this->uadata['geckodate']; |
1defa974 |
934 | } |
bf78d3ed |
935 | |
3077a4f6 |
936 | public function isBot() { return $this->bot; } |
937 | |
938 | public function isns() { |
939 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
940 | return (strpos($this->brand, 'Netscape') !== false); |
941 | } |
942 | public function isns4() { |
943 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
944 | return ((strpos($this->brand, 'Netscape') !== false) && (intval($this->version) == 4)); |
945 | } |
946 | public function isie() { |
947 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
948 | return $this->hasEngine('trident'); |
949 | } |
950 | public function geckodate() { |
951 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
952 | return (!is_null($this->getGeckoDate())?$this->getGeckoDate():0); |
953 | } |
954 | public function geckobased() { |
955 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
956 | return $this->hasEngine('gecko'); |
957 | } |
958 | public function khtmlbased() { |
959 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
960 | return $this->hasEngine('khtml'); |
961 | } |
31733e08 |
962 | } |
23585ba2 |
963 | ?> |