Browser Information:
User Agent = $userAgent
";
// checks for Macs and Windows
// strstr is used to search the userAgent for specific text, in this case the browser type.
// strpos then gets the position of the first character in the browser name. We then add the length of the browser
// name to the position number (plus 1 for a blank space or a "/"
// substr gets a substring containing the browser version, based on the position of the browser name.
// it only gets 3 characters.
$url = "/browsers/";
if(strstr($userAgent, "Windows")){
$os = "Windows";
if(strstr($userAgent, "MSIE")){
$pos = strpos($userAgent, "MSIE") + 5;
$version = substr($userAgent, $pos, 3);
if($version < 5.0)
echo "";
$browser = "MSIE - $version
";
}elseif(strstr($userAgent, "Opera")){
$pos = strpos($userAgent, "Opera") + 6;
$version = substr($userAgent, $pos, 3);
$browser = "Opera - $version
";
}elseif(strstr($userAgent, "Netscape")){
$pos = strpos($userAgent, "Netscape") + 9;
$version = substr($userAgent, $pos, 3);
if($version < 7.1)
echo "";
$browser = "Netscape - $version
";
}elseif(strstr($userAgent, "Firefox")){
$pos = strpos($userAgent, "Firefox") + 8;
$version = substr($userAgent, $pos, 3);
$browser = "Firefox - $version
";
}elseif(strstr($userAgent, "Mozilla")){
$pos = strpos($userAgent, "Mozilla") + 8;
$version = substr($userAgent, $pos, 3);
if($version < 5.0)
echo "";
$browser = "Mozilla - $version
";
}else{
echo "";
}
}elseif(strstr($userAgent, "Macintosh") || strstr($userAgent, "Mac_PowerPC")){
$os = "Macintosh";
if(strstr($userAgent, "MSIE")){
$pos = strpos($userAgent, "MSIE") + 5;
$version = substr($userAgent, $pos, 3);
if($version < 5.0)
echo "";
$browser = "MSIE - $version
";
}elseif(strstr($userAgent, "Opera")){
$pos = strpos($userAgent, "Opera") + 6;
$version = substr($userAgent, $pos, 3);
$browser = "Opera - $version
";
}elseif(strstr($userAgent, "Netscape")){
$pos = strpos($userAgent, "Netscape") + 9;
$version = substr($userAgent, $pos, 3);
if($version < 7.1 || strstr($userAgent, "Mac OS 9"))
echo "";
$browser = "Netscape - $version
";
}elseif(strstr($userAgent, "Firefox")){
$pos = strpos($userAgent, "Firefox") + 8;
$version = substr($userAgent, $pos, 3);
$browser = "Firefox - $version
";
}elseif(strstr($userAgent, "Safari")){
$pos = strpos($userAgent, "Safari") + 7;
$version = substr($userAgent, $pos, 6);
$browser = "Safari - $version
";
}elseif(strstr($userAgent, "Mozilla")){
$pos = strpos($userAgent, "Mozilla") + 8;
$version = substr($userAgent, $pos, 3);
if($version < 5.0)
echo "";
$browser = "Mozilla - $version
";
}else{
echo "";
}
}
//echo $os . " " . $browser;
?>