rendered paste body<?php
if (!defined('in_tt-admin')) {
die ("Hacking Attempt!");
}
?>
<div class="page-block">
<div class="header">
<h2>Site Analytics</h2>
</div>
<div class="contents">
<?php
$total = 0;
$os = array( 'Linux' => 0, 'Windows' => 0, 'BSD' => 0 );
$ua = array( 'MSIE 7' => 0, 'MSIE 6' => 0, 'MSIE 5' => 0, 'Firefox' => 0, 'Opera' => 0, 'Konqueror' => 0, 'Safari' => 0 );
// Acquire the total
if( $r = $db->query( "SELECT COUNT(*) AS num FROM `" . $config->database[ 'prefix' ] . "browsers`" ) ) {
$r = mysql_fetch_array( $r );
$total = intval( $r[0] );
}
foreach( $os as $k => $v ) {
if( $r = $db->query( "SELECT COUNT(*) AS num FROM `" . $config->database[ 'prefix' ] . "browsers` WHERE agent LIKE '%" . $k . "%'" ) ) {
$r = mysql_fetch_array( $r );
$os[ $k ] = intval( $r[0] );
}
}
foreach( $ua as $k => $v ) {
if( $r = $db->query( "SELECT COUNT(*) AS num FROM `" . $config->database[ 'prefix' ] . "browsers` WHERE agent LIKE '%" . $k . "%'" ) ) {
$r = mysql_fetch_array( $r );
$ua[ $k ] = intval( $r[0] );
}
}
function percent( $p_total, $p_part ) {
return( round( ( floatval( $p_part ) / floatval( $p_total ) ) * 100, 3 ) . '%' );
}
// Print the above statistics.
print( $total.'<br />' );
?>
<?php print percent($total, $os['Linux']); ?> of users are using Linux<br />
<?php print percent($total, $os['Windows']); ?> of users are using Windows<br />
<?php print percent($total, $os['BSD']); ?> of users are using BSD<br />
<?php print percent($total, array_sum($os)); ?> of users are using Unknown<br />
<br />
<?php print percent($total, ($ua['MSIE 7']+$ua['MSIE 6']+$ua['MSIE 5'])); ?> of users are running Microsoft Internet Explorer<br />
<?php print percent($total, $ua['Firefox']); ?> of users are running Mozilla Firefox<br />
<?php print percent($total, $ua['Opera']); ?> of users are running Opera<br />
<?php print percent($total, $ua['Konqueror']); ?> of users are running Konqueror<br />
<?php print percent($total, $ua['Safari']); ?> of users are running Safari<br />
<?php print percent($total, array_sum($ua)); ?> of users are running Unknown<br />
</div>
</div>