2013-05-28 08:01:02 +00:00
|
|
|
<?php
|
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'])) {
|
2013-05-28 08:01:02 +00:00
|
|
|
if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('users_timeline')) {
|
2013-05-27 08:00:58 +00:00
|
|
|
$DB->query("
|
2013-07-13 08:00:46 +00:00
|
|
|
SELECT DATE_FORMAT(JoinDate, '%b \'%y') AS Month, COUNT(UserID)
|
2013-05-27 08:00:58 +00:00
|
|
|
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("
|
2013-07-13 08:00:46 +00:00
|
|
|
SELECT DATE_FORMAT(BanDate, '%b \'%y') AS Month, COUNT(UserID)
|
2013-05-27 08:00:58 +00:00
|
|
|
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) {
|
2013-07-10 00:08:53 +00:00
|
|
|
list($Label, $Amount) = $Month;
|
2011-03-28 14:21:28 +00:00
|
|
|
if ($Amount > $Max) {
|
|
|
|
$Max = $Amount;
|
|
|
|
}
|
|
|
|
}
|
2013-05-02 08:00:23 +00:00
|
|
|
foreach ($TimelineOut as $Month) {
|
2013-07-10 00:08:53 +00:00
|
|
|
list($Label, $Amount) = $Month;
|
2011-03-28 14:21:28 +00:00
|
|
|
if ($Amount > $Max) {
|
|
|
|
$Max = $Amount;
|
|
|
|
}
|
|
|
|
}
|
2013-05-02 08:00:23 +00:00
|
|
|
foreach ($TimelineIn as $Month) {
|
2013-07-10 00:08:53 +00:00
|
|
|
list($Label, $Amount) = $Month;
|
2011-03-28 14:21:28 +00:00
|
|
|
$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) {
|
2013-07-10 00:08:53 +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-28 08:01:02 +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);
|
2013-05-28 08:01:02 +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,
|
2013-07-13 08:00:46 +00:00
|
|
|
DATE_FORMAT(j.Date, '%Y-%m') AS Month,
|
2013-05-27 08:00:58 +00:00
|
|
|
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
|
2013-07-13 08:00:46 +00:00
|
|
|
DATE_FORMAT(JoinDate, '%Y-%m-%d') AS Date,
|
2013-05-27 08:00:58 +00:00
|
|
|
COUNT(UserID) AS Flow
|
2013-07-13 08:00:46 +00:00
|
|
|
FROM users_info
|
2013-07-24 08:00:46 +00:00
|
|
|
WHERE JoinDate != '0000-00-00 00:00:00'
|
2013-07-13 08:00:46 +00:00
|
|
|
GROUP BY Date
|
2013-05-27 08:00:58 +00:00
|
|
|
) AS j
|
|
|
|
LEFT JOIN (
|
|
|
|
SELECT
|
2013-07-13 08:00:46 +00:00
|
|
|
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
|
2013-07-24 08:00:46 +00:00
|
|
|
COUNT(UserID) AS Flow
|
|
|
|
FROM users_info
|
|
|
|
WHERE BanDate != '0000-00-00 00:00:00'
|
|
|
|
AND BanReason = '1'
|
|
|
|
GROUP BY Date
|
2013-07-13 08:00:46 +00:00
|
|
|
) AS m ON j.Date = m.Date
|
2013-05-27 08:00:58 +00:00
|
|
|
LEFT JOIN (
|
|
|
|
SELECT
|
2013-07-13 08:00:46 +00:00
|
|
|
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
|
2013-07-24 08:00:46 +00:00
|
|
|
COUNT(UserID) AS Flow
|
2013-07-13 08:00:46 +00:00
|
|
|
FROM users_info
|
|
|
|
WHERE BanDate != '0000-00-00 00:00:00'
|
2013-07-24 08:00:46 +00:00
|
|
|
AND BanReason = '2'
|
|
|
|
GROUP BY Date
|
2013-07-13 08:00:46 +00:00
|
|
|
) AS r ON j.Date = r.Date
|
2013-05-27 08:00:58 +00:00
|
|
|
LEFT JOIN (
|
|
|
|
SELECT
|
2013-07-13 08:00:46 +00:00
|
|
|
DATE_FORMAT(BanDate, '%Y-%m-%d') AS Date,
|
2013-07-24 08:00:46 +00:00
|
|
|
COUNT(UserID) AS Flow
|
|
|
|
FROM users_info
|
|
|
|
WHERE BanDate != '0000-00-00 00:00:00'
|
|
|
|
AND BanReason = '3'
|
|
|
|
GROUP BY Date
|
2013-07-13 08:00:46 +00:00
|
|
|
) AS i ON j.Date = i.Date
|
2011-03-28 14:21:28 +00:00
|
|
|
ORDER BY j.Date DESC
|
|
|
|
LIMIT $Limit");
|
2013-07-13 08:00:46 +00:00
|
|
|
$DB->query('SELECT FOUND_ROWS()');
|
2011-03-28 14:21:28 +00:00
|
|
|
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-07-02 08:01:37 +00:00
|
|
|
<? if (!isset($_GET['page'])) { ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
<div class="box pad">
|
2013-07-02 08:01:37 +00:00
|
|
|
<img src="https://chart.googleapis.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>
|
2013-07-02 08:01:37 +00:00
|
|
|
<? } ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
<div class="linkbox">
|
|
|
|
<?
|
2013-05-28 08:01:02 +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()) {
|
2013-07-13 08:00:46 +00:00
|
|
|
$TotalOut = $Ratio + $Inactivity + $Manual;
|
|
|
|
$TotalGrowth = $Joined - $TotalOut;
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
|
|
|
<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(); ?>
|