tags:

views:

77

answers:

5

Okay, take this user agent for example:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625

Curious as to what all of it means. I can figure out a few things, obviously, such as Mozilla == Firefox, and Windows NT 5.1 == Windows XP. But what is the rv:1.9.2.6, and What is Gecko? and U?

And also, I'm working on setting up a script that puts various pieces of it into separate variables, such as the Mozilla, and the Windows NT 5.1, but how would I go about using RegEx to extract that, if most (if not all) of the other sections in the User Agent would by dynamic based on each user?

+2  A: 

I recommending to examine this PHP script - http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/

Māris Kiseļovs
+1  A: 

For the specific Mozilla string you mention, see the user-agent string documentation. The U stands for "strong (encryption) security"; rv/xyz is the version number and date of the Gecko rendering engine.

If you're not doing this for the learning process, there are several good libraries out there for browser detection, including PHP's native get_browser().

Pekka
I'm not really doing it for the learning process, just something that needs to be done for my script, but I would like to o about the learning process anyway.
Rob
get_browser() works well, but it is extremely slow.
Zsolti
@Zsolti, you have an alternative?
Rob
It is slow because the browscap.ini is almost 300KB, and parsing it lasts a few seconds. If you have access on this file you can edit it and reduce its length. This should boost this function.
Zsolti
It's not *seconds*, rather milliseconds. But it is indeed not the fastest function.
Pekka
A: 

Maybe you should take a look at get_browser.

fabrik
+1  A: 

I recommend http://user-agent-string.info/ which has both online API and downloadable libraries for UA analysis.

Karman Kertesz
+2  A: 

Let's see: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625

  • Mozilla/5.0 - meaningless artifact from the era of the dinosaurs; nowadays, almost every browser identifies as Mozilla (even IE, Chrome, and Opera).
  • Windows - OS
  • U - strong security available (N would stand for "no security" and I for "weak security")
  • Windows NT 5.1 - OS version. 5.1 is Windows XP, 6.0 is Vista, 6.1 is Windows "It's Not Vista SP" 7
  • en-US - browser locale - in this case, English - American
  • rv:1.9.2.6 - version of the Gecko renderer
  • Gecko/20100625 - renderer build date: 2010-06-25

Anyway, this header is essentially meaningless, as several browsers provide ways of spoofing it (at least Firefox and Opera).

Piskvor