Ave,
I'm working on a Guestbook for a site and I'm trying to identify Browser &
Operating System of the user and eventually I'll display the Icon matching
the Browser/OS in the entry.
I'm able to identify and use an If Conditional statement for the Browser,
but I can't seem to identify the OS.
This is what I'm using to identify the Browser:
function browser_detection( $which_test ) {
// initialize the variables
$browser = '';
$dom_browser = '';
// set to lower case to avoid errors, check to see if http_user_agent is set
$navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ?
strtolower( $_SERVER['HTTP_USER_AGENT'] ) : '';
// run through the main browser possibilities, assign them to the main
$browser variable
if (stristr($navigator_user_agent, "opera"))
{
$browser = 'opera';
$dom_browser = true;
}
elseif (stristr($navigator_user_agent, "msie 4"))
{
$browser = 'msie4';
$dom_browser = false;
}
elseif (stristr($navigator_user_agent, "msie"))
{
$browser = 'msie';
$dom_browser = true;
}
elseif ((stristr($navigator_user_agent, "konqueror")) ||
(stristr($navigator_user_agent, "safari")))
{
$browser = 'safari';
$dom_browser = true;
}
elseif (stristr($navigator_user_agent, "gecko"))
{
$browser = 'mozilla';
$dom_browser = true;
}
elseif (stristr($navigator_user_agent, "mozilla/4"))
{
$browser = 'ns4';
$dom_browser = false;
}
else
{
$dom_browser = false;
$browser = false;
}
// return the test result you want
if ( $which_test == 'browser' )
{
return $browser;
}
elseif ( $which_test == 'dom' )
{
return $dom_browser;
// note: $dom_browser is a boolean value, true/false, so you can just test
if
// it's true or not.
}
}
$user_browser = browser_detection('browser');
echo "$user_browser";
if ( $user_browser == 'opera' )
{
echo "OPERA";
}
else {
echo "SOMETHING ELSE";
}
?>
Any suggestions on getting the OS ?
Thanks,
Rahul S. Johari
Coordinator, Internet & Administration
Informed Marketing Services Inc.
251 River Street
Troy, NY 12180
Tel: (518) 266-0909 x154
Fax: (518) 266-0909
Email: [EMAIL PROTECTED]
http://www.informed-sources.com