2011-03-28 14:21:28 +00:00
< ?
2013-05-02 08:00:23 +00:00
if ( ! check_perms ( 'site_view_flow' )) {
error ( 403 );
}
2011-03-28 14:21:28 +00:00
//Timeline generation
2013-05-02 08:00:23 +00:00
if ( ! isset ( $_GET [ 'page' ])) {
2011-03-28 14:21:28 +00:00
if ( ! list ( $Labels , $InFlow , $OutFlow , $Max ) = $Cache -> get_value ( 'users_timeline' )) {
2013-05-27 08:00:58 +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-27 08:00:58 +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-05-02 08:00:23 +00:00
foreach ( $TimelineIn as $Month ) {
2011-03-28 14:21:28 +00:00
list ( $Label , $Amount ) = $Month ;
if ( $Amount > $Max ) {
$Max = $Amount ;
}
}
2013-05-02 08:00:23 +00:00
foreach ( $TimelineOut as $Month ) {
2011-03-28 14:21:28 +00:00
list ( $Label , $Amount ) = $Month ;
if ( $Amount > $Max ) {
$Max = $Amount ;
}
}
2013-05-02 08:00:23 +00:00
foreach ( $TimelineIn as $Month ) {
2011-03-28 14:21:28 +00:00
list ( $Label , $Amount ) = $Month ;
$Labels [] = $Label ;
2013-05-02 08:00:23 +00:00
$InFlow [] = number_format (( $Amount / $Max ) * 100 , 4 );
2011-03-28 14:21:28 +00:00
}
2013-05-02 08:00:23 +00:00
foreach ( $TimelineOut as $Month ) {
2011-03-28 14:21:28 +00:00
list ( $Label , $Amount ) = $Month ;
2013-05-02 08:00:23 +00:00
$OutFlow [] = number_format (( $Amount / $Max ) * 100 , 4 );
2011-03-28 14:21:28 +00:00
}
2013-05-02 08:00:23 +00:00
$Cache -> cache_value ( 'users_timeline' , array ( $Labels , $InFlow , $OutFlow , $Max ), mktime ( 0 , 0 , 0 , date ( 'n' ) + 1 , 2 ));
2011-03-28 14:21:28 +00:00
}
}
//End timeline generation
define ( 'DAYS_PER_PAGE' , 100 );
2012-10-11 08:00:15 +00:00
list ( $Page , $Limit ) = Format :: page_limit ( DAYS_PER_PAGE );
2011-03-28 14:21:28 +00:00
2013-05-02 08:00:23 +00:00
$RS = $DB -> query ( "
SELECT
2013-05-27 08:00:58 +00:00
SQL_CALC_FOUND_ROWS
j . Date ,
DATE_FORMAT ( j . Date , '%Y-%m' ) AS Month ,
CASE ISNULL ( j . Flow )
WHEN 0 THEN j . Flow
ELSE '0'
END AS Joined ,
CASE ISNULL ( m . Flow )
WHEN 0 THEN m . Flow
ELSE '0'
END AS Manual ,
CASE ISNULL ( r . Flow )
WHEN 0 THEN r . Flow
ELSE '0'
END AS Ratio ,
CASE ISNULL ( i . Flow )
WHEN 0 THEN i . Flow
ELSE '0'
END AS Inactivity
2011-03-28 14:21:28 +00:00
FROM (
2013-05-27 08:00:58 +00:00
SELECT
DATE_FORMAT ( JoinDate , '%Y-%m-%d' ) AS Date ,
COUNT ( UserID ) AS Flow
FROM users_info
WHERE JoinDate != '0000-00-00 00:00:00'
GROUP BY Date
) AS j
LEFT JOIN (
SELECT
DATE_FORMAT ( BanDate , '%Y-%m-%d' ) AS Date ,
COUNT ( UserID ) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '1'
GROUP BY Date
) AS m ON j . Date = m . Date
LEFT JOIN (
SELECT
DATE_FORMAT ( BanDate , '%Y-%m-%d' ) AS Date ,
COUNT ( UserID ) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '2'
GROUP BY Date
) AS r ON j . Date = r . Date
LEFT JOIN (
SELECT
DATE_FORMAT ( BanDate , '%Y-%m-%d' ) AS Date ,
COUNT ( UserID ) AS Flow
FROM users_info
WHERE BanDate != '0000-00-00 00:00:00'
AND BanReason = '3'
GROUP BY Date
) AS i ON j . Date = i . Date
2011-03-28 14:21:28 +00:00
ORDER BY j . Date DESC
LIMIT $Limit " );
$DB -> query ( " SELECT FOUND_ROWS() " );
list ( $Results ) = $DB -> next_record ();
2012-10-11 08:00:15 +00:00
View :: show_header ( 'User Flow' );
2012-07-08 08:00:09 +00:00
$DB -> set_query_id ( $RS );
2011-03-28 14:21:28 +00:00
?>
< div class = " thin " >
2013-05-02 08:00:23 +00:00
< ? if ( ! isset ( $_GET [ 'page' ])) { ?>
2011-03-28 14:21:28 +00:00
< div class = " box pad " >
2013-02-06 08:00:17 +00:00
< img src = " http://chart.apis.google.com/chart?cht=lc&chs=820x160&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 vs. Time " />
2011-03-28 14:21:28 +00:00
</ div >
< ? } ?>
< div class = " linkbox " >
< ?
2013-05-15 08:00:54 +00:00
$Pages = Format :: get_pages ( $Page , $Results , DAYS_PER_PAGE , 11 ) ;
2011-03-28 14:21:28 +00:00
echo $Pages ;
?>
</ div >
< table width = " 100% " >
< tr class = " colhead " >
< td > Date </ td >
< td > ( + ) Joined </ td >
< td > ( - ) Manual </ td >
< td > ( - ) Ratio </ td >
2013-02-22 08:00:24 +00:00
< td > ( - ) Inactivity </ td >
2011-03-28 14:21:28 +00:00
< td > ( - ) Total </ td >
< td > Net Growth </ td >
</ tr >
< ?
2013-05-02 08:00:23 +00:00
while ( list ( $Date , $Month , $Joined , $Manual , $Ratio , $Inactivity ) = $DB -> next_record ()) {
2011-03-28 14:21:28 +00:00
$TotalOut = $Ratio + $Inactivity + $Manual ;
$TotalGrowth = $Joined - $TotalOut ;
?>
< tr class = " rowb " >
< td >< ? = $Date ?> </td>
< td >< ? = number_format ( $Joined ) ?> </td>
< td >< ? = number_format ( $Manual ) ?> </td>
< td >< ? = number_format (( double ) $Ratio ) ?> </td>
< td >< ? = number_format ( $Inactivity ) ?> </td>
< td >< ? = number_format ( $TotalOut ) ?> </td>
< td >< ? = number_format ( $TotalGrowth ) ?> </td>
</ tr >
< ? } ?>
</ table >
< div class = " linkbox " >
< ? = $Pages ?>
</ div >
</ div >
2012-10-11 08:00:15 +00:00
< ? View :: show_footer (); ?>