Re: Detecting Browser Type/OS from HTTP_USER_AGENT
| From: | Patrick Teague | Date: | Sat, 06 Jul 2002 06:03:45 +0000 |
| Subject: | Re: Detecting Browser Type/OS from HTTP_USER_AGENT | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105811@lists.php.net to get a copy of this message | ||
Hey,
I ended up looking at using eregi to pull this information out of the
original HTTP_USER_AGENT as this is more accurate than the extra info from
browscap.ini. You have to list out all of the browsers & OSs. However, I'm
having problems detecting the Amaya browser...
$browser_string = getenv(HTTP_USER_AGENT);
......
$eregi_str = "((\; |\()" .
"(MSIE|IE|Netscape|Konqueror|Lynx|Links|Opera)|Gecko|Amaya)" .
"[ \\\/\-\.a-z0-9]*(\)|\;|libwww)?";
if( eregi( $eregi_str, $browser_string, $arrstring ) )
{
$browser_name = $arrstring[0];
$browser_name = eregi_replace( "(\;|\(|\))", "", $browser_name );
$browser_name = trim( $browser_name );
}
else if( $browser->parent )
{
$browser_name = $browser->parent;
}
else
{
$browser_name = "unknown";
}
Amaya displays as "amaya/V4.3.2 libwww/5.3.1" & when printing out
$browser_name, it equals "amaya/V4.3.2 libwww/5.3.1"
I've thought of using - eregi_replace( "libwww[\/\.a-z0-9]*", "",
$browser_name ); - but not sure if I really want to do it this way or not.
Any suggestions?
Patrick