2011-03-28 14:21:28 +00:00
< ?
2013-07-02 08:01:37 +00:00
if ( ! list ( $Countries , $Rank , $CountryUsers , $CountryMax , $CountryMin , $LogIncrements ) = $Cache -> get_value ( 'geodistribution' )) {
2013-05-27 08:00:58 +00:00
include_once ( SERVER_ROOT . '/classes/charts.class.php' );
2013-07-02 08:01:37 +00:00
$DB -> query ( '
SELECT Code , Users
FROM users_geodistribution ' );
2011-03-28 14:21:28 +00:00
$Data = $DB -> to_array ();
2013-04-30 18:18:07 +00:00
$Count = $DB -> record_count () - 1 ;
2013-02-22 08:00:24 +00:00
2013-04-30 18:18:07 +00:00
if ( $Count < 30 ) {
2011-03-28 14:21:28 +00:00
$CountryMinThreshold = $Count ;
} else {
$CountryMinThreshold = 30 ;
}
2013-02-22 08:00:24 +00:00
2013-04-30 18:18:07 +00:00
$CountryMax = ceil ( log ( Max ( 1 , $Data [ 0 ][ 1 ])) / log ( 2 )) + 1 ;
$CountryMin = floor ( log ( Max ( 1 , $Data [ $CountryMinThreshold ][ 1 ])) / log ( 2 ));
2011-03-28 14:21:28 +00:00
2011-09-30 08:00:12 +00:00
$CountryRegions = array ( 'RS' => array ( 'RS-KM' )); // Count Kosovo as Serbia as it doesn't have a TLD
2011-03-28 14:21:28 +00:00
foreach ( $Data as $Key => $Item ) {
2013-07-02 08:01:37 +00:00
list ( $Country , $UserCount ) = $Item ;
2011-03-28 14:21:28 +00:00
$Countries [] = $Country ;
2013-04-30 18:18:07 +00:00
$CountryUsers [] = number_format (((( log ( $UserCount ) / log ( 2 )) - $CountryMin ) / ( $CountryMax - $CountryMin )) * 100 , 2 );
$Rank [] = round (( 1 - ( $Key / $Count )) * 100 );
2011-09-30 08:00:12 +00:00
2013-04-30 18:18:07 +00:00
if ( isset ( $CountryRegions [ $Country ])) {
foreach ( $CountryRegions [ $Country ] as $Region ) {
2011-09-30 08:00:12 +00:00
$Countries [] = $Region ;
$Rank [] = end ( $Rank );
}
}
2011-03-28 14:21:28 +00:00
}
2011-09-30 08:00:12 +00:00
reset ( $Rank );
2013-02-22 08:00:24 +00:00
2013-04-30 18:18:07 +00:00
for ( $i = $CountryMin ; $i <= $CountryMax ; $i ++ ) {
$LogIncrements [] = Format :: human_format ( pow ( 2 , $i ));
2011-03-28 14:21:28 +00:00
}
2013-07-02 08:01:37 +00:00
$Cache -> cache_value ( 'geodistribution' , array ( $Countries , $Rank , $CountryUsers , $CountryMax , $CountryMin , $LogIncrements ), 0 );
2011-03-28 14:21:28 +00:00
}
2013-04-30 18:18:07 +00:00
if ( ! $ClassDistribution = $Cache -> get_value ( 'class_distribution' )) {
2013-05-27 08:00:58 +00:00
include_once ( SERVER_ROOT . '/classes/charts.class.php' );
2013-05-07 08:00:23 +00:00
$DB -> query ( "
SELECT p . Name , COUNT ( m . ID ) AS Users
FROM users_main AS m
2013-07-02 08:01:37 +00:00
JOIN permissions AS p ON m . PermissionID = p . ID
WHERE m . Enabled = '1'
2013-05-07 08:00:23 +00:00
GROUP BY p . Name
ORDER BY Users DESC " );
2012-01-27 08:00:19 +00:00
$ClassSizes = $DB -> to_array ();
2013-07-02 08:01:37 +00:00
$Pie = new PIE_CHART ( 750 , 400 , array ( 'Other' => 1 , 'Percentage' => 1 ));
2013-04-30 18:18:07 +00:00
foreach ( $ClassSizes as $ClassSize ) {
list ( $Label , $Users ) = $ClassSize ;
$Pie -> add ( $Label , $Users );
2011-03-28 14:21:28 +00:00
}
$Pie -> transparent ();
$Pie -> color ( 'FF33CC' );
$Pie -> generate ();
$ClassDistribution = $Pie -> url ();
2013-05-07 08:00:23 +00:00
$Cache -> cache_value ( 'class_distribution' , $ClassDistribution , 3600 * 24 * 14 );
2011-03-28 14:21:28 +00:00
}
2013-04-30 18:18:07 +00:00
if ( ! $PlatformDistribution = $Cache -> get_value ( 'platform_distribution' )) {
2013-05-27 08:00:58 +00:00
include_once ( SERVER_ROOT . '/classes/charts.class.php' );
2013-05-16 16:15:57 +00:00
2013-05-07 08:00:23 +00:00
$DB -> query ( "
SELECT OperatingSystem , COUNT ( UserID ) AS Users
FROM users_sessions
GROUP BY OperatingSystem
ORDER BY Users DESC " );
2013-05-16 16:15:57 +00:00
2011-03-28 14:21:28 +00:00
$Platforms = $DB -> to_array ();
2013-07-02 08:01:37 +00:00
$Pie = new PIE_CHART ( 750 , 400 , array ( 'Other' => 1 , 'Percentage' => 1 ));
2013-04-30 18:18:07 +00:00
foreach ( $Platforms as $Platform ) {
2013-07-02 08:01:37 +00:00
list ( $Label , $Users ) = $Platform ;
$Pie -> add ( $Label , $Users );
2011-03-28 14:21:28 +00:00
}
$Pie -> transparent ();
$Pie -> color ( '8A00B8' );
$Pie -> generate ();
$PlatformDistribution = $Pie -> url ();
2013-05-07 08:00:23 +00:00
$Cache -> cache_value ( 'platform_distribution' , $PlatformDistribution , 3600 * 24 * 14 );
2011-03-28 14:21:28 +00:00
}
2013-04-30 18:18:07 +00:00
if ( ! $BrowserDistribution = $Cache -> get_value ( 'browser_distribution' )) {
2013-05-27 08:00:58 +00:00
include_once ( SERVER_ROOT . '/classes/charts.class.php' );
2013-05-16 16:15:57 +00:00
2013-05-07 08:00:23 +00:00
$DB -> query ( "
SELECT Browser , COUNT ( UserID ) AS Users
FROM users_sessions
GROUP BY Browser
ORDER BY Users DESC " );
2013-07-02 08:01:37 +00:00
2011-03-28 14:21:28 +00:00
$Browsers = $DB -> to_array ();
2013-07-02 08:01:37 +00:00
$Pie = new PIE_CHART ( 750 , 400 , array ( 'Other' => 1 , 'Percentage' => 1 ));
2013-04-30 18:18:07 +00:00
foreach ( $Browsers as $Browser ) {
2013-07-02 08:01:37 +00:00
list ( $Label , $Users ) = $Browser ;
$Pie -> add ( $Label , $Users );
2011-03-28 14:21:28 +00:00
}
$Pie -> transparent ();
$Pie -> color ( '008AB8' );
$Pie -> generate ();
$BrowserDistribution = $Pie -> url ();
2013-05-07 08:00:23 +00:00
$Cache -> cache_value ( 'browser_distribution' , $BrowserDistribution , 3600 * 24 * 14 );
2011-03-28 14:21:28 +00:00
}
//Timeline generation
2013-07-02 08:01:37 +00:00
if ( ! list ( $Labels , $InFlow , $OutFlow , $Max ) = $Cache -> get_value ( 'users_timeline' )) {
2013-05-07 08:00:23 +00:00
$DB -> query ( "
SELECT DATE_FORMAT ( JoinDate , '%b \\' % y ' ) AS Month , COUNT ( UserID )
FROM users_info
GROUP BY Month
ORDER BY JoinDate DESC
LIMIT 1 , 12 " );
2011-03-28 14:21:28 +00:00
$TimelineIn = array_reverse ( $DB -> to_array ());
2013-05-07 08:00:23 +00:00
$DB -> query ( "
SELECT DATE_FORMAT ( BanDate , '%b \\' % y ' ) AS Month , COUNT ( UserID )
FROM users_info
GROUP BY Month
ORDER BY BanDate DESC
LIMIT 1 , 12 " );
2011-03-28 14:21:28 +00:00
$TimelineOut = array_reverse ( $DB -> to_array ());
2013-04-30 18:18:07 +00:00
foreach ( $TimelineIn as $Month ) {
2013-07-02 08:01:37 +00:00
list ( $Label , $Amount ) = $Month ;
2011-03-28 14:21:28 +00:00
if ( $Amount > $Max ) {
$Max = $Amount ;
}
}
2013-04-30 18:18:07 +00:00
foreach ( $TimelineOut as $Month ) {
2013-07-02 08:01:37 +00:00
list ( $Label , $Amount ) = $Month ;
2011-03-28 14:21:28 +00:00
if ( $Amount > $Max ) {
$Max = $Amount ;
}
}
$Labels = array ();
2013-04-30 18:18:07 +00:00
foreach ( $TimelineIn as $Month ) {
2013-07-02 08:01:37 +00:00
list ( $Label , $Amount ) = $Month ;
2011-03-28 14:21:28 +00:00
$Labels [] = $Label ;
2013-04-30 18:18:07 +00:00
$InFlow [] = number_format (( $Amount / $Max ) * 100 , 4 );
2011-03-28 14:21:28 +00:00
}
2013-04-30 18:18:07 +00:00
foreach ( $TimelineOut as $Month ) {
2013-07-02 08:01:37 +00:00
list ( $Label , $Amount ) = $Month ;
2013-04-30 18:18:07 +00:00
$OutFlow [] = number_format (( $Amount / $Max ) * 100 , 4 );
2011-03-28 14:21:28 +00:00
}
2013-07-02 08:01:37 +00:00
$Cache -> cache_value ( 'users_timeline' , array ( $Labels , $InFlow , $OutFlow , $Max ), mktime ( 0 , 0 , 0 , date ( 'n' ) + 1 , 2 )); //Tested: fine for Dec -> Jan
2011-03-28 14:21:28 +00:00
}
//End timeline generation
2012-10-11 08:00:15 +00:00
View :: show_header ( 'Detailed User Statistics' );
2011-03-28 14:21:28 +00:00
?>
2012-12-27 08:00:27 +00:00
< h3 id = " User_Flow " >< a href = " #User_Flow " > User Flow </ a ></ h3 >
2011-03-28 14:21:28 +00:00
< div class = " box pad center " >
2013-07-02 08:01:37 +00:00
< img src = " https://chart.googleapis.com/chart?cht=lc&chs=880x160&chco=000D99,99000D&chg=0,-1,1,1&chxt=y,x&chxs=0,h&chxl=1:|<?=implode('|', $Labels )?>&chxr=0,0,<?= $Max ?>&chd=t:<?=implode(',', $InFlow )?>|<?=implode(',', $OutFlow )?>&chls=2,4,0&chdl=New+Registrations|Disabled+Users&chf=bg,s,FFFFFF00 " alt = " User Flow Chart " />
2011-03-28 14:21:28 +00:00
</ div >
< br />
2012-12-27 08:00:27 +00:00
< h3 id = " User_Classes " >< a href = " #User_Classes " > User Classes </ a ></ h3 >
2011-03-28 14:21:28 +00:00
< div class = " box pad center " >
2012-08-29 08:00:17 +00:00
< img src = " <?= $ClassDistribution ?> " alt = " User Class Distribution " />
2011-03-28 14:21:28 +00:00
</ div >
< br />
2012-12-27 08:00:27 +00:00
< h3 id = " User_Platforms " >< a href = " #User_Platforms " > User Platforms </ a ></ h3 >
2011-03-28 14:21:28 +00:00
< div class = " box pad center " >
2012-08-29 08:00:17 +00:00
< img src = " <?= $PlatformDistribution ?> " alt = " User Platform Distribution " />
2011-03-28 14:21:28 +00:00
</ div >
< br />
2012-12-27 08:00:27 +00:00
< h3 id = " User_Browsers " >< a href = " #User_Browsers " > User Browsers </ a ></ h3 >
2011-03-28 14:21:28 +00:00
< div class = " box pad center " >
2012-08-29 08:00:17 +00:00
< img src = " <?= $BrowserDistribution ?> " alt = " User Browsers Market Share " />
2011-03-28 14:21:28 +00:00
</ div >
< br />
2012-12-27 08:00:27 +00:00
< h3 id = " Geo_Dist_Map " >< a href = " #Geo_Dist_Map " > Geographical Distribution Map </ a ></ h3 >
2011-07-10 08:00:06 +00:00
< div class = " box center " >
2013-07-02 08:01:37 +00:00
< img src = " https://chart.googleapis.com/chart?cht=map:fixed=-55,-180,73,180&chs=440x220&chd=t:<?=implode(',', $Rank )?>&chco=FFFFFF,EDEDED,1F0066&chld=<?=implode('|', $Countries )?>&chf=bg,s,CCD6FF " alt = " Geographical Distribution Map - Worldwide " />
< img src = " https://chart.googleapis.com/chart?cht=map:fixed=37,-26,65,67&chs=440x220&chs=440x220&chd=t:<?=implode(',', $Rank )?>&chco=FFFFFF,EDEDED,1F0066&chld=<?=implode('|', $Countries )?>&chf=bg,s,CCD6FF " alt = " Geographical Distribution Map - Europe " />
2011-07-10 08:00:06 +00:00
< br />
2013-07-02 08:01:37 +00:00
< img src = " https://chart.googleapis.com/chart?cht=map:fixed=-46,-132,24,21.5&chs=440x220&chd=t:<?=implode(',', $Rank )?>&chco=FFFFFF,EDEDED,1F0066&chld=<?=implode('|', $Countries )?>&chf=bg,s,CCD6FF " alt = " Geographical Distribution Map - South America " />
< img src = " https://chart.googleapis.com/chart?cht=map:fixed=-11,22,50,160&chs=440x220&chd=t:<?=implode(',', $Rank )?>&chco=FFFFFF,EDEDED,1F0066&chld=<?=implode('|', $Countries )?>&chf=bg,s,CCD6FF " alt = " Geographical Distribution Map - Asia " />
2011-07-10 08:00:06 +00:00
< br />
2013-07-02 08:01:37 +00:00
< img src = " https://chart.googleapis.com/chart?cht=map:fixed=-36,-57,37,100&chs=440x220&chd=t:<?=implode(',', $Rank )?>&chco=FFFFFF,EDEDED,1F0066&chld=<?=implode('|', $Countries )?>&chf=bg,s,CCD6FF " alt = " Geographical Distribution Map - Africa " />
< img src = " https://chart.googleapis.com/chart?cht=map:fixed=14.8,15,45,86&chs=440x220&chd=t:<?=implode(',', $Rank )?>&chco=FFFFFF,EDEDED,1F0066&chld=<?=implode('|', $Countries )?>&chf=bg,s,CCD6FF " alt = " Geographical Distribution Map - Middle East " />
2011-07-10 08:00:06 +00:00
< br />
2013-07-02 08:01:37 +00:00
< img src = " https://chart.googleapis.com/chart?chxt=y,x&chg=0,-1,1,1&chxs=0,h&cht=bvs&chco=76A4FB&chs=880x300&chd=t:<?=implode(',', array_slice( $CountryUsers , 0, 31))?>&chxl=1:|<?=implode('|', array_slice( $Countries , 0, 31))?>|0:|<?=implode('|', $LogIncrements )?>&chf=bg,s,FFFFFF00 " alt = " Number of users by country " />
2011-07-10 08:00:06 +00:00
</ div >
2011-03-28 14:21:28 +00:00
< ?
2012-10-11 08:00:15 +00:00
View :: show_footer ();