get_value('torrents_timeline')) { $DB->query(" SELECT DATE_FORMAT(`Time`, '%b %Y') AS Month, COUNT(`ID`) FROM `log` WHERE `Message` LIKE 'Torrent % uploaded %' GROUP BY `Month` ORDER BY `Time` DESC "); $TimelineIn = array_reverse($DB->to_array()); $DB->query(" SELECT DATE_FORMAT(`Time`, '%b %Y') AS Month, COUNT(`ID`) FROM `log` WHERE `Message` LIKE 'Torrent % deleted %' GROUP BY `Month` ORDER BY `Time` DESC "); $TimelineOut = array_reverse($DB->to_array()); foreach ($TimelineIn as $Month) { list($Labels[], $InFlow[]) = $Month; } foreach ($TimelineOut as $Month) { list(, $OutFlow[]) = $Month; } $Cache->cache_value('torrents_timeline', array($Labels, $InFlow, $OutFlow, $Max), mktime(0, 0, 0, date('n') + 1, 2)); //Tested: fine for dec -> jan } if (!$CategoryDistribution = $Cache->get_value('category_distribution')) { $DB->query(" SELECT tg.`CategoryID`, COUNT(t.`ID`) AS Torrents FROM `torrents` AS t JOIN `torrents_group` AS tg ON tg.`ID` = t.`GroupID` GROUP BY tg.`CategoryID` ORDER BY `Torrents` DESC "); $CategoryDistribution = $DB->to_array(); $Cache->cache_value('category_distribution', $CategoryDistribution, 3600 * 24 * 14); } foreach ($CategoryDistribution as $i => $Category) { list($CategoryID, $Torrents) = $Category; $CategoryDistribution[$i]['CategoryID'] = $Categories[$CategoryID - 1]; } View::show_header('Detailed torrent statistics', 'vendor/chart.min'); ?>