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 | } |
b50f91ef |
230 | elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && |
231 | strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { |
bf78d3ed |
232 | $this->brand = 'Mozilla'; |
31733e08 |
233 | $this->version = $regs[1]; |
81e72a3e |
234 | $this->bot = false; |
31733e08 |
235 | } |
b50f91ef |
236 | elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) && |
237 | strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { |
09cd2756 |
238 | $this->brand = 'Mozilla'; |
239 | $this->version = 'M'.$regs[1]; |
240 | $this->bot = false; |
241 | } |
c18a4476 |
242 | elseif (preg_match('|Opera\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) { |
243 | $this->brand = 'Opera Mini'; |
244 | $this->version = $regs[1]; |
245 | $this->bot = false; |
246 | } |
247 | elseif (preg_match('/Opera\/[^\(]+ \(.*; Opera Mini\/([^;]+); /i', $this->uastring, $regs)) { |
248 | $this->brand = 'Opera Mini'; |
249 | $this->version = $regs[1]; |
250 | $this->bot = false; |
251 | } |
bf78d3ed |
252 | elseif (preg_match('|Opera[ /]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
253 | $this->brand = 'Opera'; |
31733e08 |
254 | $this->version = $regs[1]; |
81e72a3e |
255 | $this->bot = false; |
31733e08 |
256 | } |
c18a4476 |
257 | elseif (preg_match('|OmniWeb/([0-9a-zA-Z\.+-]+)|', $this->uastring, $regs)) { |
bf78d3ed |
258 | $this->brand = 'OmniWeb'; |
1defa974 |
259 | $this->version = $regs[1]; |
81e72a3e |
260 | $this->bot = false; |
1defa974 |
261 | } |
bf78d3ed |
262 | elseif (preg_match('|Konqueror/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
263 | $this->brand = 'Konqueror'; |
31733e08 |
264 | $this->version = $regs[1]; |
81e72a3e |
265 | $this->bot = false; |
31733e08 |
266 | } |
c18a4476 |
267 | elseif (preg_match('|Shiira/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
268 | $this->brand = 'Shiira'; |
269 | $this->version = $regs[1]; |
270 | $this->bot = false; |
271 | } |
bf78d3ed |
272 | elseif (preg_match('|Safari/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
273 | $this->brand = 'Safari'; |
1defa974 |
274 | $this->version = $regs[1]; |
81e72a3e |
275 | $this->bot = false; |
1defa974 |
276 | } |
bf78d3ed |
277 | elseif (preg_match('|AppleWebKit/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
278 | $this->brand = 'AppleWebKit'; |
1defa974 |
279 | $this->version = $regs[1]; |
81e72a3e |
280 | $this->bot = false; |
1defa974 |
281 | } |
bf78d3ed |
282 | elseif (preg_match('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
283 | $this->brand = 'Microsoft FrontPage'; |
f983aa36 |
284 | $this->version = $regs[1]; |
81e72a3e |
285 | $this->bot = false; |
f983aa36 |
286 | } |
bf78d3ed |
287 | elseif (preg_match('|iCab[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
288 | $this->brand = 'iCab'; |
a8464009 |
289 | $this->version = $regs[1]; |
81e72a3e |
290 | $this->bot = false; |
a8464009 |
291 | } |
bf78d3ed |
292 | elseif (preg_match('|IBrowse[/ ]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
293 | $this->brand = 'IBrowse'; |
a8464009 |
294 | $this->version = $regs[1]; |
81e72a3e |
295 | $this->bot = false; |
a8464009 |
296 | } |
c18a4476 |
297 | elseif (preg_match('|ICEbrowser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
298 | $this->brand = 'ICEbrowser'; |
299 | $this->version = $regs[1]; |
300 | $this->bot = false; |
301 | } |
302 | elseif (preg_match('|ICE Browser/v([0-9a-zA-Z\._+]+)|', $this->uastring, $regs)) { |
303 | $this->brand = 'ICEbrowser'; |
304 | $this->version = str_replace('_', '.', $regs[1]); |
305 | $this->bot = false; |
306 | } |
307 | elseif (preg_match('|NetPositive/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
308 | $this->brand = 'NetPositive'; |
309 | $this->version = $regs[1]; |
310 | $this->bot = false; |
311 | } |
312 | elseif (preg_match('|WebPro/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
313 | $this->brand = 'WebPro (Novarra)'; |
314 | $this->version = $regs[1]; |
315 | $this->bot = false; |
316 | } |
317 | elseif (preg_match('|; OffByOne;|', $this->uastring, $regs)) { |
318 | $this->brand = 'Off By One'; |
319 | $this->version = null; |
320 | $this->bot = false; |
321 | } |
322 | elseif (preg_match('|PSP \(PlayStation Portable\); ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
323 | $this->brand = 'PlayStation Portable'; |
324 | $this->version = $regs[1]; |
325 | $this->bot = false; |
326 | } |
b50f91ef |
327 | elseif (preg_match('|PLAYSTATION 3; ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
328 | $this->brand = 'PlayStation 3'; |
329 | $this->version = $regs[1]; |
330 | $this->bot = false; |
331 | } |
c18a4476 |
332 | elseif (preg_match('|NetFront/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
333 | $this->brand = 'NetFront'; |
a8464009 |
334 | $this->version = $regs[1]; |
81e72a3e |
335 | $this->bot = false; |
a8464009 |
336 | } |
6e783db6 |
337 | elseif (preg_match('|UP.Browser/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
338 | $this->brand = 'UP.Browser'; |
339 | $this->version = $regs[1]; |
81e72a3e |
340 | $this->bot = false; |
6e783db6 |
341 | } |
c18a4476 |
342 | elseif (preg_match('|UP.Link/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
343 | $this->brand = 'UP.Link'; |
344 | $this->version = $regs[1]; |
345 | $this->bot = false; |
346 | } |
347 | elseif (preg_match('|AU-MIC-([0-9A-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
348 | $this->brand = 'Obigo'; |
349 | $this->version = $regs[1]; |
350 | $this->bot = false; |
351 | } |
352 | elseif (preg_match('|Nokia([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
353 | $this->brand = 'Nokia'; |
354 | $this->version = $regs[1]; |
355 | $this->bot = false; |
356 | } |
357 | elseif (preg_match('|SonyEricsson([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
358 | $this->brand = 'SonyEricsson'; |
359 | $this->version = $regs[1]; |
360 | $this->bot = false; |
361 | } |
362 | elseif (preg_match('|SIE-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
363 | $this->brand = 'Siemens'; |
364 | $this->version = $regs[1]; |
365 | $this->bot = false; |
366 | } |
367 | elseif (preg_match('|MOT-([0-9a-zA-Z]+/[0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
368 | $this->brand = 'Motorola'; |
369 | $this->version = $regs[1]; |
370 | $this->bot = false; |
371 | } |
b50f91ef |
372 | elseif (preg_match('|IXI/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
373 | $this->brand = 'IXI'; |
374 | $this->version = $regs[1]; |
375 | $this->bot = false; |
376 | } |
c18a4476 |
377 | elseif (preg_match('|IBM-WebExplorer-DLL/v([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
378 | $this->brand = 'WebExplorer'; |
379 | $this->version = $regs[1]; |
380 | $this->bot = false; |
381 | } |
bf78d3ed |
382 | elseif (preg_match('|ELinks \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) { |
383 | $this->brand = 'ELinks'; |
a8464009 |
384 | $this->version = $regs[1]; |
81e72a3e |
385 | $this->bot = false; |
a8464009 |
386 | } |
6e783db6 |
387 | elseif (preg_match('|Links \(([0-9a-zA-Z\.+]+);|', $this->uastring, $regs)) { |
388 | $this->brand = 'Links'; |
389 | $this->version = $regs[1]; |
81e72a3e |
390 | $this->bot = false; |
6e783db6 |
391 | } |
392 | elseif (preg_match('|wget[/ ]([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { |
393 | $this->brand = 'wget'; |
394 | $this->version = $regs[1]; |
81e72a3e |
395 | $this->bot = false; |
6e783db6 |
396 | } |
b50f91ef |
397 | elseif (preg_match('|WinHttp.WinHttpRequest.([0-9\.]+)|i', $this->uastring, $regs)) { |
398 | $this->brand = 'WinHttpRequest'; |
399 | $this->version = $regs[1]; |
400 | $this->bot = false; |
401 | } |
402 | elseif (preg_match('|alpha[/ ]06; AmigaOS|i', $this->uastring, $regs)) { |
403 | $this->brand = 'Alpha 06'; |
404 | $this->version = null; |
405 | $this->bot = false; |
406 | } |
407 | elseif (preg_match('|; arexx[\);]|i', $this->uastring, $regs)) { |
c18a4476 |
408 | $this->brand = 'ARexx'; |
409 | $this->version = null; |
410 | $this->bot = false; |
411 | } |
b50f91ef |
412 | elseif (preg_match('|; Voyager; AmigaOS[\);]|i', $this->uastring, $regs)) { |
413 | $this->brand = 'AmigaVoyager'; |
414 | $this->version = null; |
415 | $this->bot = false; |
416 | } |
417 | elseif (preg_match('|AWEB ([0-9a-zA-Z\.+ ]+)|', $this->uastring, $regs)) { |
418 | $this->brand = 'AWEB'; |
419 | $this->version = $regs[1]; |
420 | $this->bot = false; |
421 | } |
422 | elseif (preg_match('|X ([0-9a-zA-Z\.+ ]+); Commodore 64|', $this->uastring, $regs)) { |
423 | $this->brand = 'X'; |
424 | $this->version = $regs[1]; |
425 | $this->bot = false; |
426 | } |
427 | elseif (preg_match('|DB Browse ([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { |
428 | $this->brand = 'DB Browse'; |
429 | $this->version = $regs[1]; |
430 | $this->bot = false; |
431 | } |
bf78d3ed |
432 | elseif (preg_match('|ZyBorg/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
433 | $this->brand = 'ZyBorg'; |
a8464009 |
434 | $this->version = $regs[1]; |
435 | $this->bot = true; |
436 | } |
bf78d3ed |
437 | elseif (preg_match('|Googlebot/?([0-9a-zA-Z\.+]+)?|', $this->uastring, $regs)) { |
438 | $this->brand = 'Googlebot'; |
a8464009 |
439 | $this->version = $regs[1]; |
440 | $this->bot = true; |
441 | } |
bf78d3ed |
442 | elseif (preg_match('|Ask Jeeves/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
443 | $this->brand = 'Ask Jeeves'; |
a8464009 |
444 | $this->version = $regs[1]; |
445 | $this->bot = true; |
446 | } |
4e8c44da |
447 | elseif (preg_match('|heritrix/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
448 | $this->brand = 'Heritrix'; |
449 | $this->version = $regs[1]; |
450 | $this->bot = true; |
451 | } |
b50f91ef |
452 | elseif (preg_match('|([0-9a-zA-Z\.+]+bot)/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { |
453 | $this->brand = $regs[1]; |
454 | $this->version = $regs[2]; |
455 | $this->bot = true; |
456 | } |
457 | elseif (preg_match('|VoilaBot ((BETA )?[0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { |
458 | $this->brand = 'VoilaBot'; |
459 | $this->version = $regs[1]; |
460 | $this->bot = true; |
461 | } |
c51ab9a2 |
462 | elseif (preg_match('|Slurp|', $this->uastring, $regs)) { |
bf78d3ed |
463 | $this->brand = 'Slurp'; |
c51ab9a2 |
464 | $this->version = null; |
a8464009 |
465 | $this->bot = true; |
466 | } |
b50f91ef |
467 | elseif (preg_match('|Check&Get ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
468 | $this->brand = 'Check&Get'; |
469 | $this->version = $regs[1]; |
470 | $this->bot = true; |
471 | } |
472 | elseif (preg_match('|WebCapture ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
473 | $this->brand = 'WebCapture'; |
474 | $this->version = $regs[1]; |
475 | $this->bot = true; |
476 | } |
477 | elseif (preg_match('|WebMon ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
478 | $this->brand = 'WebMon'; |
479 | $this->version = $regs[1]; |
480 | $this->bot = true; |
481 | } |
482 | elseif (preg_match('|Powermarks/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
483 | $this->brand = 'Powermarks'; |
484 | $this->version = $regs[1]; |
485 | $this->bot = true; |
486 | } |
bf78d3ed |
487 | elseif (preg_match('|Gulper Web Bot ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
488 | $this->brand = 'Gulper Web Bot'; |
a8464009 |
489 | $this->version = $regs[1]; |
490 | $this->bot = true; |
491 | } |
bf78d3ed |
492 | elseif (preg_match('|HTTrack ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
493 | $this->brand = 'HTTrack'; |
a8464009 |
494 | $this->version = $regs[1]; |
495 | $this->bot = true; |
496 | } |
b50f91ef |
497 | elseif (preg_match('|Twiceler-([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
498 | $this->brand = 'Twiceler'; |
499 | $this->version = $regs[1]; |
500 | $this->bot = true; |
501 | } |
5b8eba2a |
502 | elseif (preg_match('|Microsoft URL Control - ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
503 | $this->brand = 'Microsoft URL Control'; |
504 | $this->version = $regs[1]; |
505 | $this->bot = true; |
506 | } |
81e72a3e |
507 | elseif (preg_match('|([0-9a-zA-Z\.+]+)_AC-Plug|', $this->uastring, $regs)) { |
508 | $this->brand = 'AC-Plug'; |
509 | $this->version = $regs[1]; |
510 | $this->bot = true; |
511 | } |
bf78d3ed |
512 | elseif (preg_match('|^Internet Explorer 5.5|', $this->uastring)) { |
513 | $this->brand = 'Unknown bot (IE5.5)'; |
514 | $this->version = null; |
a8464009 |
515 | $this->bot = true; |
516 | } |
bf78d3ed |
517 | elseif (preg_match('|^Mozilla[\s ]*$|', $this->uastring)) { |
518 | $this->brand = 'Unknown bot (Mozilla)'; |
519 | $this->version = null; |
a8464009 |
520 | $this->bot = true; |
521 | } |
b50f91ef |
522 | elseif (preg_match('|http://www.livedir.net|', $this->uastring, $regs)) { |
523 | $this->brand = 'livedir.net'; |
524 | $this->version = null; |
525 | $this->bot = true; |
526 | } |
527 | elseif (preg_match('|WebClipping.com|', $this->uastring, $regs)) { |
528 | $this->brand = 'WebClipping.com'; |
529 | $this->version = null; |
530 | $this->bot = true; |
531 | } |
bf78d3ed |
532 | elseif (preg_match('|http://www.almaden.ibm.com/cs/crawler|', $this->uastring)) { |
533 | $this->brand = 'almaden crawler'; |
534 | $this->version = null; |
a8464009 |
535 | $this->bot = true; |
536 | } |
b50f91ef |
537 | elseif (preg_match('|B-l-i-t-z-B-O-T|', $this->uastring) || |
538 | preg_match('|B l i t z B O T @ t r i c u s . n e t|', $this->uastring)) { |
bf78d3ed |
539 | $this->brand = 'BlitzBOT'; |
540 | $this->version = null; |
a8464009 |
541 | $this->bot = true; |
542 | } |
bf78d3ed |
543 | elseif (preg_match('|sitecheck.internetseer.com|', $this->uastring)) { |
544 | $this->brand = 'internetseer'; |
545 | $this->version = null; |
a8464009 |
546 | $this->bot = true; |
547 | } |
b50f91ef |
548 | elseif (preg_match('|Really Gmane.org\'s favicon grabber|', $this->uastring)) { |
549 | $this->brand = 'Really Gmane.org\'s favicon grabber'; |
550 | $this->version = null; |
551 | $this->bot = true; |
552 | } |
bf78d3ed |
553 | elseif (preg_match('|Girafabot|', $this->uastring)) { |
554 | $this->brand = 'Girafabot'; |
555 | $this->version = null; |
a8464009 |
556 | $this->bot = true; |
557 | } |
b50f91ef |
558 | elseif (preg_match('|Arachmo|', $this->uastring)) { |
559 | $this->brand = 'Arachmo'; |
560 | $this->version = null; |
561 | $this->bot = true; |
562 | } |
563 | elseif (preg_match('|OsO|', $this->uastring)) { |
564 | $this->brand = 'OsO'; |
565 | $this->version = null; |
566 | $this->bot = true; |
567 | } |
568 | elseif (preg_match('|Yoono|', $this->uastring)) { |
569 | $this->brand = 'Yoono'; |
570 | $this->version = null; |
571 | $this->bot = true; |
572 | } |
bf78d3ed |
573 | elseif (preg_match('|efp@gmx.net|', $this->uastring)) { |
574 | $this->brand = 'efp'; |
575 | $this->version = null; |
a8464009 |
576 | $this->bot = true; |
577 | } |
81e72a3e |
578 | elseif (preg_match('|42_HAL|', $this->uastring)) { |
579 | $this->brand = '42_HAL'; |
580 | $this->version = null; |
581 | $this->bot = true; |
582 | } |
583 | elseif (preg_match('|Baiduspider|i', $this->uastring)) { |
584 | $this->brand = 'BaiDuSpider'; |
585 | $this->version = null; |
586 | $this->bot = true; |
587 | } |
588 | elseif (preg_match('|Indy Library|', $this->uastring)) { |
589 | $this->brand = 'Indy Library'; |
590 | $this->version = null; |
591 | $this->bot = true; |
592 | } |
b50f91ef |
593 | elseif (preg_match('|Linkman|', $this->uastring)) { |
594 | $this->brand = 'Linkman'; |
595 | $this->version = null; |
596 | $this->bot = true; |
597 | } |
598 | elseif (preg_match('|Sage|', $this->uastring, $regs)) { |
599 | $this->brand = 'Sage'; |
600 | $this->version = null; |
601 | $this->bot = true; |
602 | } |
603 | elseif (preg_match('|Google Desktop|', $this->uastring)) { |
604 | $this->brand = 'Google Desktop'; |
605 | $this->version = null; |
606 | $this->bot = true; |
607 | } |
bf78d3ed |
608 | elseif (preg_match('|^Firefly|', $this->uastring)) { |
609 | // comes here with correct value but would be detected as MSIE |
a8464009 |
610 | } |
81e72a3e |
611 | elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) { |
612 | $this->brand = 'Steganos Internet Anonym'; |
613 | $this->version = $regs[1]; |
614 | $this->bot = false; |
615 | } |
b50f91ef |
616 | elseif (preg_match('|Steganos Internet Anonym([0-9a-zA-Z\. +]*)|', $this->uastring, $regs)) { |
617 | $this->brand = 'Steganos Internet Anonym'; |
618 | $this->version = $regs[1]; |
619 | $this->bot = false; |
620 | } |
621 | elseif (preg_match('|BorderManager ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
622 | $this->brand = 'BorderManager'; |
623 | $this->version = $regs[1]; |
624 | $this->bot = false; |
625 | } |
626 | elseif (preg_match('|WebWasher ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
627 | $this->brand = 'WebWasher'; |
628 | $this->version = $regs[1]; |
629 | $this->bot = false; |
630 | } |
631 | elseif (preg_match('|SaferSurf|', $this->uastring, $regs)) { |
632 | $this->brand = 'SaferSurf'; |
633 | $this->version = null; |
634 | $this->bot = false; |
635 | } |
bf78d3ed |
636 | elseif (preg_match('|Avant Browser[^/]|', $this->uastring)) { |
637 | $this->brand = 'Avant Browser'; |
638 | $this->version = null; |
81e72a3e |
639 | $this->bot = false; |
a8464009 |
640 | } |
c18a4476 |
641 | elseif (preg_match('|Browser[^/]+(http://www.avantbrowser.com)|', $this->uastring)) { |
642 | $this->brand = 'Avant Browser'; |
643 | $this->version = null; |
644 | $this->bot = false; |
645 | } |
6e783db6 |
646 | elseif (preg_match('|Maxthon|', $this->uastring)) { |
647 | $this->brand = 'Maxthon'; |
648 | $this->version = null; |
81e72a3e |
649 | $this->bot = false; |
6e783db6 |
650 | } |
651 | elseif (preg_match('|MyIE2|', $this->uastring)) { |
652 | $this->brand = 'MyIE2'; |
653 | $this->version = null; |
81e72a3e |
654 | $this->bot = false; |
6e783db6 |
655 | } |
bf78d3ed |
656 | elseif (preg_match('|Crazy Browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
657 | $this->brand = 'Crazy Browser'; |
658 | $this->version = $regs[1]; |
81e72a3e |
659 | $this->bot = false; |
660 | } |
661 | elseif (preg_match('|AvantGo ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
662 | $this->brand = 'AvantGo'; |
663 | $this->version = $regs[1]; |
664 | $this->bot = false; |
a8464009 |
665 | } |
bf78d3ed |
666 | elseif (preg_match('|MSN ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
667 | $this->brand = 'MSN'; |
668 | $this->version = $regs[1]; |
81e72a3e |
669 | $this->bot = false; |
a8464009 |
670 | } |
c18a4476 |
671 | elseif (preg_match('|America Online Browser [0-9a-zA-Z\.+]+; rev([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
672 | $this->brand = 'AOL Browser'; |
673 | $this->version = $regs[1]; |
674 | $this->bot = false; |
675 | } |
bf78d3ed |
676 | elseif (preg_match('|MS FrontPage ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
677 | $this->brand = 'Microsoft FrontPage'; |
678 | $this->version = $regs[1]; |
81e72a3e |
679 | $this->bot = false; |
a8464009 |
680 | } |
c18a4476 |
681 | elseif (preg_match('|Microsoft Internet Explorer/4.0b1|', $this->uastring, $regs)) { |
682 | $this->brand = 'Microsoft Internet Explorer'; |
683 | $this->version = '1.0'; |
684 | $this->bot = false; |
685 | } |
bf78d3ed |
686 | elseif (preg_match('|MSIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
687 | $this->brand = 'Microsoft Internet Explorer'; |
31733e08 |
688 | $this->version = $regs[1]; |
81e72a3e |
689 | $this->bot = false; |
31733e08 |
690 | } |
c18a4476 |
691 | elseif (preg_match('|MSPIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
692 | $this->brand = 'Microsoft Pocket Internet Explorer'; |
693 | $this->version = $regs[1]; |
694 | $this->bot = false; |
695 | } |
b50f91ef |
696 | elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && |
697 | (strpos($this->uastring, 'compatible') === false) && (strpos($this->uastring, 'Gecko/') === false) && |
698 | (intval($regs[1]) < 5)) { |
bf78d3ed |
699 | $this->brand = 'Netscape'; |
1defa974 |
700 | $this->version = $regs[1]; |
bf78d3ed |
701 | if (intval($this->version) == 4) { $this->brand .= ' Communicator'; } |
81e72a3e |
702 | $this->bot = false; |
703 | } |
b50f91ef |
704 | elseif (preg_match('|Mozilla/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { |
705 | $this->brand = (strpos($this->uastring, 'compatible') !== false)?'Mozilla-compatible (unknown)':'Mozilla (unknown)'; |
81e72a3e |
706 | $this->version = null; |
707 | $this->bot = false; |
1defa974 |
708 | } |
a8464009 |
709 | |
81e72a3e |
710 | $botArray = array('Scooter','Spinne','Vagabondo','Firefly','Scrubby','NG','Pompos','Szukacz','ASPseek', |
711 | 'NetResearchServer','LinkWalker','Zeus','W3C_Validator','ZyBorg','Ask Jeeves','ia_archiver', |
712 | 'PingALink Monitoring Services','IlTrovatore-Setaccio','Nutch','Mercator','search.ch', |
713 | 'appie','larbin','NutchCVS','ObjectsSearch','Webchat','Mediapartners-Google','Schmozilla', |
5b8eba2a |
714 | 'FavOrg','findlinks','DataCha0s','ichiro','Francis','','','','','','',''); |
a8464009 |
715 | |
716 | if (in_array($this->brand, $botArray)) { |
717 | $this->bot = true; |
718 | } |
31733e08 |
719 | } |
720 | |
3077a4f6 |
721 | public function getBrand() { return $this->brand; } |
722 | public function getVersion() { return $this->version; } |
4210e7b0 |
723 | |
3077a4f6 |
724 | public function getAcceptLanguages() { |
4210e7b0 |
725 | if (!isset($this->uadata['accept-languages'])) { |
726 | $headers = getAllHeaders(); |
727 | $accLcomp = explode(',', $headers['Accept-Language']); |
728 | $accLang = array(); |
729 | foreach ($accLcomp as $lcomp) { |
730 | if (strlen($lcomp)) { |
731 | $ldef = explode(';', $lcomp); |
437e1c91 |
732 | $accLang[$ldef[0]] = (float)((strpos(@$ldef[1],'q=')===0)?substr($ldef[1],2):1); |
4210e7b0 |
733 | } |
734 | } |
735 | $this->uadata['accept-languages'] = $accLang; |
736 | } |
737 | return $this->uadata['accept-languages']; |
738 | } |
739 | |
3077a4f6 |
740 | public function getUAString() { return $this->uastring; } |
23585ba2 |
741 | |
3077a4f6 |
742 | public function getEngine() { |
b50f91ef |
743 | // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|icestorm|netfront|unknown |
bf78d3ed |
744 | if (!isset($this->uadata['engine'])) { |
ac9220c2 |
745 | $this->uadata['engine'] = 'unknown'; |
bf78d3ed |
746 | $this->uadata['geckodate'] = null; |
747 | if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs)) { |
748 | $this->uadata['engine'] = 'gecko'; |
749 | $this->uadata['geckodate'] = $regs[1]; |
750 | } |
751 | elseif ((strpos($this->brand, 'Internet Explorer') !== false) || (strpos($this->brand, 'FrontPage') !== false)) { |
6e783db6 |
752 | if ((strpos(strtolower($this->uastring), 'mac') !== false) && (intval($this->getVersion()) >= 5)) { |
bf78d3ed |
753 | $this->uadata['engine'] = 'tasman'; |
754 | } |
755 | else { |
756 | $this->uadata['engine'] = 'trident'; |
757 | } |
758 | } |
c18a4476 |
759 | elseif ((strpos($this->brand, 'Konqueror') !== false) || (strpos($this->brand, 'Safari') !== false) || |
760 | (strpos($this->brand, 'Shiira') !== false) || |
761 | (strpos($this->brand, 'AppleWebKit') !== false) || (strpos($this->brand, 'OmniWeb') !== false)) { |
bf78d3ed |
762 | $this->uadata['engine'] = 'khtml'; |
763 | } |
81e72a3e |
764 | elseif (strpos($this->brand, 'Netscape') !== false) { |
765 | // non-Gecko Netscape browsers |
766 | if (intval($this->version) <= 4) { |
767 | $this->uadata['engine'] = 'nscp'; |
768 | } |
769 | elseif (strpos($this->uastring, 'MSIE') !== false) { |
770 | $this->uadata['engine'] = 'trident'; |
771 | } |
bf78d3ed |
772 | } |
773 | elseif (strpos($this->brand, 'Opera') !== false) { |
774 | $this->uadata['engine'] = 'presto'; |
775 | } |
776 | elseif (strpos($this->brand, 'Dillo') !== false) { |
777 | $this->uadata['engine'] = 'gzilla'; |
778 | } |
779 | elseif ((strpos($this->brand, 'ELinks') !== false) || (strpos($this->brand, 'Links') !== false)) { |
780 | $this->uadata['engine'] = 'links'; |
781 | } |
c18a4476 |
782 | elseif ((strpos($this->brand, 'ICEbrowser') !== false) || (strpos($this->brand, 'ICE Browser') !== false)) { |
783 | $this->uadata['engine'] = 'icestorm'; |
784 | } |
b50f91ef |
785 | elseif ((strpos($this->brand, 'PlayStation') !== false) || (strpos($this->brand, 'NetFront') !== false)) { |
786 | $this->uadata['engine'] = 'netfront'; |
787 | } |
6e783db6 |
788 | elseif ((strpos($this->brand, 'Avant') !== false) || (strpos($this->brand, 'Crazy Browser') !== false) || |
789 | (strpos($this->brand, 'AOL') !== false) || (strpos($this->brand, 'MSN') !== false) || |
790 | (strpos($this->brand, 'MyIE2') !== false) || (strpos($this->brand, 'Maxthon') !== false)) { |
bf78d3ed |
791 | $this->uadata['engine'] = 'trident'; |
792 | } |
793 | elseif (strpos($this->brand, 'Galeon') !== false) { |
794 | $this->uadata['engine'] = 'gecko'; |
31733e08 |
795 | } |
c18a4476 |
796 | elseif (strpos($this->brand, 'WebPro') !== false) { |
797 | $this->uadata['engine'] = 'nscp'; |
798 | } |
31733e08 |
799 | } |
bf78d3ed |
800 | return $this->uadata['engine']; |
31733e08 |
801 | } |
802 | |
3077a4f6 |
803 | public function hasEngine($rnd_engine) { return ($this->getEngine() == $rnd_engine); } |
bf78d3ed |
804 | |
3077a4f6 |
805 | public function getEngineVersion() { |
bf78d3ed |
806 | if (!isset($this->uadata['eng_version'])) { |
807 | $this->uadata['eng_version'] = null; |
808 | // getOS() should get the date for us |
809 | $this->getOS(); |
31733e08 |
810 | } |
bf78d3ed |
811 | return $this->uadata['eng_version']; |
31733e08 |
812 | } |
813 | |
3077a4f6 |
814 | public function getOS() { |
bf78d3ed |
815 | if (!isset($this->uadata['os'])) { |
816 | $this->uadata['os'] = null; |
817 | if ($this->hasEngine('gecko')) { |
81e72a3e |
818 | if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { |
bf78d3ed |
819 | $this->uadata['os'] = $regs[2]; |
f9a0c27d |
820 | $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null; |
bf78d3ed |
821 | $this->uadata['eng_version'] = $regs[4]; |
822 | } |
81e72a3e |
823 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { |
824 | $this->uadata['os'] = $regs[2]; |
825 | $this->uadata['lang'] = null; |
826 | $this->uadata['eng_version'] = $regs[3]; |
827 | } |
6e783db6 |
828 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { |
bf78d3ed |
829 | $this->uadata['os'] = $regs[2]; |
830 | $this->uadata['lang'] = $regs[3]; |
831 | $this->uadata['eng_version'] = 'M'.$regs[4]; |
832 | } |
09cd2756 |
833 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { |
834 | $this->uadata['os'] = $regs[1]; |
835 | $this->uadata['lang'] = $regs[2]; |
836 | $this->uadata['eng_version'] = 'M'.$regs[3]; |
837 | } |
6e783db6 |
838 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) { |
839 | $this->uadata['os'] = $regs[2]; |
840 | $this->uadata['lang'] = $regs[3]; |
841 | $this->uadata['eng_version'] = null; |
842 | } |
f9a0c27d |
843 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) { |
844 | $this->uadata['os'] = $regs[2]; |
845 | $this->uadata['lang'] = null; |
846 | $this->uadata['eng_version'] = $regs[3]; |
847 | } |
6e783db6 |
848 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^\);]+)\)|', $this->uastring, $regs)) { |
bf78d3ed |
849 | $this->uadata['os'] = $regs[2]; |
850 | $this->uadata['lang'] = null; |
851 | $this->uadata['eng_version'] = null; |
852 | } |
853 | elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) { |
854 | $this->uadata['os'] = $regs[2]; |
855 | $this->uadata['lang'] = null; |
856 | $this->uadata['eng_version'] = null; |
857 | } |
858 | elseif (preg_match('|Debian/|', $this->uastring, $regs)) { |
859 | $this->uadata['os'] = 'Debian Linux'; |
860 | $this->uadata['lang'] = null; |
861 | $this->uadata['eng_version'] = null; |
862 | } |
863 | } |
6e783db6 |
864 | elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) { |
c18a4476 |
865 | if (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) { |
866 | $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:$regs[1]; |
bf78d3ed |
867 | $this->uadata['os'] = $regs[2]; |
868 | $this->uadata['lang'] = null; |
869 | } |
81e72a3e |
870 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) { |
bf78d3ed |
871 | $this->uadata['eng_version'] = $regs[1]; |
872 | $this->uadata['os'] = null; |
873 | $this->uadata['lang'] = null; |
874 | } |
c18a4476 |
875 | elseif (preg_match('/Microsoft Internet Explorer\/[^\s]+ \(((?:Mac|Win)[^;\)]+)\)/i', $this->uastring, $regs)) { |
876 | $this->uadata['eng_version'] = $this->getVersion(); |
877 | $this->uadata['os'] = $regs[1]; |
878 | $this->uadata['lang'] = null; |
879 | } |
880 | elseif (preg_match('/Microsoft Pocket Internet Explorer\/[^\s]+/i', $this->uastring, $regs)) { |
881 | $this->uadata['eng_version'] = null; |
882 | $this->uadata['os'] = 'Windows CE'; |
883 | $this->uadata['lang'] = null; |
884 | } |
31733e08 |
885 | } |
bf78d3ed |
886 | elseif ($this->hasEngine('khtml')) { |
6e783db6 |
887 | if (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^;]+); ([^;]+); ([^;]+); ([^\);]+)\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) { |
888 | $this->uadata['eng_version'] = strlen($regs[6])?$regs[6]:$regs[1]; |
bf78d3ed |
889 | $this->uadata['os'] = $regs[2]; |
890 | $this->uadata['lang'] = $regs[5]; |
891 | } |
6e783db6 |
892 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^\);]+)[^\)]*\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) { |
893 | $this->uadata['eng_version'] = strlen($regs[3])?$regs[3]:$regs[1]; |
bf78d3ed |
894 | $this->uadata['os'] = $regs[2]; |
895 | $this->uadata['lang'] = null; |
896 | } |
897 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) { |
898 | $this->uadata['os'] = $regs[2]; |
899 | $this->uadata['lang'] = $regs[3]; |
900 | $this->uadata['eng_version'] = null; |
901 | } |
c18a4476 |
902 | elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^\);]+)\)|', $this->uastring, $regs)) { |
903 | $this->uadata['os'] = $regs[1]; |
904 | $this->uadata['lang'] = $regs[2]; |
905 | $this->uadata['eng_version'] = null; |
906 | } |
bf78d3ed |
907 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^\);]+)\)/i', $this->uastring, $regs)) { |
908 | $this->uadata['os'] = $regs[1]; |
909 | $this->uadata['lang'] = null; |
910 | $this->uadata['eng_version'] = null; |
911 | } |
912 | } |
913 | elseif ($this->hasEngine('presto')) { |
c18a4476 |
914 | // Opera < 8 |
f9a0c27d |
915 | if (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) { |
bf78d3ed |
916 | $this->uadata['eng_version'] = $this->getVersion(); |
917 | $this->uadata['os'] = $regs[1]; |
918 | $this->uadata['lang'] = $regs[2]; |
919 | } |
f9a0c27d |
920 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;\)]+)[^\)]*\) Opera [^ ]+ +\[([a-z_-]+)\]/i', $this->uastring, $regs)) { |
6e783db6 |
921 | $this->uadata['eng_version'] = $this->getVersion(); |
922 | $this->uadata['os'] = $regs[1]; |
923 | $this->uadata['lang'] = $regs[2]; |
924 | } |
f9a0c27d |
925 | elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) { |
6e783db6 |
926 | $this->uadata['eng_version'] = $this->getVersion(); |
927 | $this->uadata['os'] = $regs[1]; |
928 | $this->uadata['lang'] = $regs[2]; |
929 | } |
c18a4476 |
930 | // Opera mini |
931 | elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini; ([a-z_-]+); /i', $this->uastring, $regs)) { |
932 | $this->uadata['eng_version'] = null; |
933 | $this->uadata['os'] = $regs[2]; |
934 | $this->uadata['lang'] = $regs[3]; |
935 | } |
936 | elseif (preg_match('/Opera\/([^\(]+) \((?:X11; )?([^;]+); Opera Mini\/[^;]+; ([a-z_-]+); /i', $this->uastring, $regs)) { |
937 | $this->uadata['eng_version'] = $regs[1]; |
938 | $this->uadata['os'] = $regs[2]; |
939 | $this->uadata['lang'] = $regs[3]; |
940 | } |
941 | // Opera >= 8 |
f9a0c27d |
942 | elseif (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) { |
bf78d3ed |
943 | $this->uadata['eng_version'] = $this->getVersion(); |
944 | $this->uadata['os'] = $regs[1]; |
945 | $this->uadata['lang'] = $regs[2]; |
946 | } |
f9a0c27d |
947 | elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { |
6e783db6 |
948 | $this->uadata['eng_version'] = $this->getVersion(); |
949 | $this->uadata['os'] = $regs[1]; |
950 | $this->uadata['lang'] = $regs[2]; |
951 | } |
f9a0c27d |
952 | elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { |
bf78d3ed |
953 | $this->uadata['eng_version'] = $this->getVersion(); |
954 | $this->uadata['os'] = $regs[1]; |
955 | $this->uadata['lang'] = $regs[2]; |
956 | } |
957 | } |
958 | elseif ($this->hasEngine('nscp')) { |
f9a0c27d |
959 | if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) { |
960 | $this->uadata['eng_version'] = $regs[1]; |
961 | $this->uadata['os'] = $regs[3]; |
962 | $this->uadata['lang'] = $regs[2]; |
963 | } |
964 | elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) { |
bf78d3ed |
965 | $this->uadata['eng_version'] = $regs[1]; |
966 | $this->uadata['os'] = $regs[3]; |
967 | $this->uadata['lang'] = $regs[2]; |
968 | } |
c18a4476 |
969 | elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+)[^\(]+\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) { |
970 | $this->uadata['eng_version'] = $regs[1]; |
971 | $this->uadata['os'] = $regs[2]; |
972 | $this->uadata['lang'] = null; |
973 | } |
bf78d3ed |
974 | } |
975 | elseif ($this->hasEngine('gzilla')) { |
976 | $this->uadata['eng_version'] = $this->getVersion(); |
977 | $this->uadata['os'] = null; |
978 | $this->uadata['lang'] = null; |
979 | } |
980 | elseif ($this->hasEngine('links')) { |
6e783db6 |
981 | if (preg_match('/E?Links[^\(]+\([^;]+; ([^;]+)[^\)]+\)/i', $this->uastring, $regs)) { |
bf78d3ed |
982 | $this->uadata['eng_version'] = null; |
983 | $this->uadata['os'] = $regs[1]; |
984 | $this->uadata['lang'] = null; |
985 | } |
986 | } |
c18a4476 |
987 | elseif ($this->hasEngine('icestorm')) { |
988 | if (preg_match('/ICE Browser\/v?([0-9a-zA-Z\._+]+) \(Java [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) { |
989 | $this->uadata['eng_version'] = str_replace('_', '.', $regs[1]); |
990 | $this->uadata['os'] = $regs[2]; |
991 | $this->uadata['lang'] = null; |
992 | } |
993 | elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\).* ICEbrowser\/([0-9a-zA-Z\._+]+)/i', $this->uastring, $regs)) { |
994 | $this->uadata['eng_version'] = $regs[3]; |
995 | $this->uadata['os'] = $regs[1]; |
996 | $this->uadata['lang'] = $regs[2]; |
997 | } |
998 | } |
bf78d3ed |
999 | else { |
1000 | $this->uadata['eng_version'] = null; |
1001 | $this->uadata['lang'] = null; |
1002 | if (preg_match('/AmigaOS/i', $this->uastring, $regs)) { |
1003 | $this->uadata['os'] = 'AmigaOS'; |
1004 | } |
b50f91ef |
1005 | if (preg_match('/Commodore 64/i', $this->uastring, $regs)) { |
1006 | $this->uadata['os'] = 'Commodore 64'; |
1007 | } |
bf78d3ed |
1008 | elseif (preg_match('/curl\/[^\(]+\(([^\);]+)/i', $this->uastring, $regs)) { |
1009 | $this->uadata['os'] = $regs[1]; |
1010 | } |
6e783db6 |
1011 | elseif (preg_match('/NCSA[_ ]Mosaic\/[^\(]+\((?:.*;)?([^\);]+)/i', $this->uastring, $regs)) { |
1012 | $this->uadata['os'] = trim($regs[1]); |
1013 | } |
1014 | elseif (preg_match('/iCab.*(Mac[^\);]+).*?\)/i', $this->uastring, $regs)) { |
1015 | $this->uadata['os'] = trim($regs[1]); |
1016 | } |
c51ab9a2 |
1017 | elseif (preg_match('/SymbianOS\/([^ ]+)/i', $this->uastring, $regs)) { |
1018 | $this->uadata['os'] = 'SymbianOS '.$regs[1]; |
1019 | } |
bf78d3ed |
1020 | } |
1021 | if ($this->uadata['os'] == 'Win 9x 4.90') { $this->uadata['os'] = 'Windows ME'; } |
804fe4f1 |
1022 | elseif ($this->uadata['os'] == 'WinNT4.0') { $this->uadata['os'] = 'Windows NT 4.0'; } |
bf78d3ed |
1023 | elseif ($this->uadata['os'] == 'Windows NT 5.0') { $this->uadata['os'] = 'Windows 2000'; } |
1024 | elseif ($this->uadata['os'] == 'Windows NT 5.1') { $this->uadata['os'] = 'Windows XP'; } |
1025 | elseif ($this->uadata['os'] == 'Windows NT 5.2') { $this->uadata['os'] = 'Windows 2003'; } |
55020829 |
1026 | elseif ($this->uadata['os'] == 'Windows NT 5.2 x64') { $this->uadata['os'] = 'Windows 2003 (64bit)'; } |
1027 | elseif ($this->uadata['os'] == 'Windows NT 6.0') { $this->uadata['os'] = 'Windows Vista'; } |
bf78d3ed |
1028 | elseif ($this->uadata['os'] == 'Win95') { $this->uadata['os'] = 'Windows 95'; } |
1029 | elseif ($this->uadata['os'] == 'Win98') { $this->uadata['os'] = 'Windows 98'; } |
55020829 |
1030 | elseif ($this->uadata['os'] == 'WinNT') { $this->uadata['os'] = 'Windows NT'; } |
1031 | elseif ($this->uadata['os'] == 'Win32') { $this->uadata['os'] = 'Windows (32bit)'; } |
1032 | elseif ($this->uadata['os'] == 'Win64') { $this->uadata['os'] = 'Windows (64bit)'; } |
bf78d3ed |
1033 | elseif (preg_match('/Mac ?OS ?X/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; } |
1034 | elseif (preg_match('/Mac_P(ower|)PC/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; } |
1035 | elseif (strpos($this->uadata['os'], 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } |
6e783db6 |
1036 | elseif (strpos($this->uadata['os'], 'Darwin') !== false) { $this->uadata['os'] = 'MacOS X'; } |
bf78d3ed |
1037 | elseif (strpos($this->uadata['os'], 'apple') !== false) { $this->uadata['os'] = 'MacOS'; } |
6e783db6 |
1038 | elseif (strpos($this->uadata['os'], 'Macintosh') !== false) { $this->uadata['os'] = 'MacOS'; } |
bf78d3ed |
1039 | elseif (strpos($this->uadata['os'], 'linux') !== false) { $this->uadata['os'] = 'Linux'; } |
1040 | |
6e783db6 |
1041 | if (strpos($this->uadata['os'], 'Win') !== false) { $this->uadata['platform'] = 'Windows'; } |
1042 | elseif (strpos($this->uadata['os'], 'Mac') !== false) { $this->uadata['platform'] = 'Macintosh'; } |
1043 | elseif (strpos($this->uadata['os'], 'Linux') !== false) { $this->uadata['platform'] = 'Linux'; } |
1044 | elseif (strpos($this->uadata['os'], 'Solaris') !== false) { $this->uadata['platform'] = 'Solaris'; } |
1045 | elseif (strpos($this->uadata['os'], 'SunOS') !== false) { $this->uadata['platform'] = 'Solaris'; } |
1046 | elseif (strpos($this->uadata['os'], 'BeOS') !== false) { $this->uadata['platform'] = 'BeOS'; } |
1047 | elseif (strpos($this->uadata['os'], 'FreeBSD') !== false) { $this->uadata['platform'] = 'FreeBSD'; } |
1048 | elseif (strpos($this->uadata['os'], 'OpenBSD') !== false) { $this->uadata['platform'] = 'OpenBSD'; } |
1049 | elseif (strpos($this->uadata['os'], 'NetBSD') !== false) { $this->uadata['platform'] = 'NetBSD'; } |
1050 | elseif (strpos($this->uadata['os'], 'AIX') !== false) { $this->uadata['platform'] = 'AIX'; } |
1051 | elseif (strpos($this->uadata['os'], 'IRIX') !== false) { $this->uadata['platform'] = 'IRIX'; } |
1052 | elseif (strpos($this->uadata['os'], 'HP-UX') !== false) { $this->uadata['platform'] = 'HP-UX'; } |
1053 | elseif (strpos($this->uadata['os'], 'AmigaOS') !== false) { $this->uadata['platform'] = 'Amiga'; } |
b50f91ef |
1054 | elseif (strpos($this->uadata['os'], 'Commodore 64') !== false) { $this->uadata['platform'] = 'C64'; } |
6e783db6 |
1055 | elseif (strpos($this->uadata['os'], 'OpenVMS') !== false) { $this->uadata['platform'] = 'OpenVMS'; } |
1056 | elseif (strpos($this->uadata['os'], 'Warp') !== false) { $this->uadata['platform'] = 'OS/2'; } |
c51ab9a2 |
1057 | elseif (strpos($this->uadata['os'], 'SymbianOS') !== false) { $this->uadata['platform'] = 'SymbianOS'; } |
6e783db6 |
1058 | elseif (strpos($this->uadata['os'], 'CYGWIN') !== false) { $this->uadata['platform'] = 'Windows'; } |
1059 | else { $this->uadata['platform'] = $this->uadata['os']; } |
bf78d3ed |
1060 | |
1061 | $this->uadata['lang'] = str_replace('_', '-', $this->uadata['lang']); |
31733e08 |
1062 | } |
bf78d3ed |
1063 | return $this->uadata['os']; |
31733e08 |
1064 | } |
1065 | |
3077a4f6 |
1066 | public function getPlatform() { |
bf78d3ed |
1067 | if (!isset($this->uadata['platform'])) { |
1068 | $this->uadata['platform'] = null; |
1069 | // getOS() should get the date for us |
1070 | $this->getOS(); |
31733e08 |
1071 | } |
bf78d3ed |
1072 | return $this->uadata['platform']; |
31733e08 |
1073 | } |
1074 | |
3077a4f6 |
1075 | public function getLanguage() { |
bf78d3ed |
1076 | if (!isset($this->uadata['lang'])) { |
1077 | $this->uadata['lang'] = null; |
1078 | // getOS() should get the date for us |
1079 | $this->getOS(); |
31733e08 |
1080 | } |
bf78d3ed |
1081 | return $this->uadata['lang']; |
31733e08 |
1082 | } |
1defa974 |
1083 | |
3077a4f6 |
1084 | public function getGeckoDate() { |
bf78d3ed |
1085 | if (!isset($this->uadata['geckodate'])) { |
1086 | $this->uadata['geckodate'] = null; |
1087 | // getEngine() should get the date for us |
1088 | $this->getEngine(); |
1defa974 |
1089 | } |
bf78d3ed |
1090 | return $this->uadata['geckodate']; |
1defa974 |
1091 | } |
bf78d3ed |
1092 | |
3077a4f6 |
1093 | public function isBot() { return $this->bot; } |
1094 | |
1095 | public function isns() { |
1096 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
1097 | return (strpos($this->brand, 'Netscape') !== false); |
1098 | } |
1099 | public function isns4() { |
1100 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
1101 | return ((strpos($this->brand, 'Netscape') !== false) && (intval($this->version) == 4)); |
1102 | } |
1103 | public function isie() { |
1104 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
1105 | return $this->hasEngine('trident'); |
1106 | } |
1107 | public function geckodate() { |
1108 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
1109 | return (!is_null($this->getGeckoDate())?$this->getGeckoDate():0); |
1110 | } |
1111 | public function geckobased() { |
1112 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
1113 | return $this->hasEngine('gecko'); |
1114 | } |
1115 | public function khtmlbased() { |
1116 | trigger_error(__CLASS__.'::'.__FUNCTION__.' is a deprecated function', E_USER_NOTICE); |
1117 | return $this->hasEngine('khtml'); |
1118 | } |
31733e08 |
1119 | } |
23585ba2 |
1120 | ?> |