query("SELECT * FROM `".$config->database['prefix']."browsers` ORDER BY id"); // Query.
$total = mysql_num_rows($result); // Total rows.
/******************************
Browser Statistics
******************************/
// Define some variables that will do a lot of the math.
$msie = 0;
$firefox = 0;
$opera = 0;
$other = 0;
// Other string variables
$msie7_string = "MSIE 7";
$msie6_string = "MSIE 6";
$msie5_string = "MSIE 5";
$firefox_string = "Firefox";
$opera_string = "Opera";
/******************************
Operating System Statistics
******************************/
// Define some variables that will do a lot of the math.
$windows = 0;
$linux = 0;
$bsd = 0;
$otheros = 0;
// Other string variables
$windows_string = "Windows";
$linux_string = "Linux";
$bsd_string = "BSD";
// Here we go ... gotta count up the tally!
while($user = mysql_fetch_array($result)) {
$check = strpos($user['agent'], $msie7_string);
$check = strpos($user['agent'], $msie6_string);
$check = strpos($user['agent'], $msie5_string);
if ($check !== false) {
$msie++;
} else {
$check = strpos($user['agent'], $firefox_string);
if ($check !== false) {
$firefox++;
} else {
$check = strpos($user['agent'], $opera_string);
if ($check !== false){
$opera++;
} else {
$other++;
}
}
}
//browser tally
$check = strpos($user['agent'], $windows_string);
if ($check !== false) {
$windows++;
} else {
$check = strpos($user['agent'], $linux_string);
if ($check !== false) {
$linux++;
} else {
$check = strpos($user['agent'], $bsd_string);
if ($check !== false){
$bsd++;
} else {
$otheros++;
}
}
}
}
// Now we do some tough mathmatical calculations.
$msiefinal = ceil($msie/$total*100);
$firefoxfinal = ceil($firefox/$total*100);
$operafinal = ceil($opera/$total*100);
$otherfinal = ceil($other/$total*100);
// Now we echo the data!
echo "".$msiefinal."% of visitors are using Microsoft Internet Explorer (".$msie." out of ".$total." visitors)
";
echo "".$firefoxfinal."% of visitors are using Mozilla Firefox (".$firefox." out of ".$total." visitors)
";
echo "".$operafinal."% of visitors are using Opera (".$opera." out of ".$total." visitors)
";
echo "".$otherfinal."% of visitors are using other browsers (".$other." out of ".$total." visitors)";
echo "
";
// Now we do some tough mathmatical calculations.
$windowsfinal = ceil($windows/$total*100);
$linuxfinal = ceil($linux/$total*100);
$bsdfinal = ceil($bsd/$total*100);
$otherosfinal = ceil($otheros/$total*100);
// Now we echo the data!
echo "".$windowsfinal."% of visitors are using Microsoft Windows (".$windows." out of ".$total." visitors)
";
echo "".$linuxfinal."% of visitors are using Linux (".$linux." out of ".$total." visitors)
";
echo "".$bsdfinal."% of visitors are using BSD/Unix (".$bsd." out of ".$total." visitors)
";
echo "".$otherosfinal."% of visitors are using other operating systems (".$otheros." out of ".$total." visitors)";
?>