Forum Moderators: coopster

Message Too Old, No Replies

Parsing HTTP_USER_AGENT

Obtaining OS + Version & Browser + Version

         

Jeremy_H

3:59 am on Jun 1, 2006 (gmt 0)

10+ Year Member



Hello,

I'm trying to parse the HTTP_USER_Agent to get the user's operating system, operating system version, browser, and browser version.

I know no solution will be a hundred percent perfect, but I'm trying to improve my poor system I use know that only gives my half of what I want only some of the time.

$agt=$_SERVER["HTTP_USER_AGENT"];

if(strpos($agt,"MSIE")>0)$bsr="Internet Explorer";
elseif(strpos($agt,"Firefox")>0)$bsr="Firefox";
elseif(strpos($agt,"Safari")>0)$bsr="Safari";
elseif(strpos($agt,"Camino")>0)$bsr="Camino";
elseif(strpos($agt,"Opera")>0)$bsr="Opera";

if(strpos($agt," Mac")>0)$os="Macintosh";
elseif(strpos($agt," Win")>0)$os="Windows";

Any ideas on how one might be able to get the rest of the information.

For reference I pasted a couple of User Agents at the bottom of the post.

Thanks for any help

-------

Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC)
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; H010818; T312461; .NET CLR 1.1.4322)
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 2.8)
Mozilla/4.0 (compatible; Powermarks/3.5; Windows 95/98/2000/NT)
Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/412 (KHTML, like Gecko) Safari/412_Adobe
Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.12) Gecko/20050919 Firefox/1.0.7

adb64

6:21 am on Jun 1, 2006 (gmt 0)

10+ Year Member



You may want to take a look at the get_browser [php.net] function. I never used it, but it may provide the information you are looking for.