if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('torrents_timeline')) { $DB->query(" SELECT DATE_FORMAT(Time,\"%b %Y\") AS Month, COUNT(ID) FROM log WHERE Message LIKE 'Torrent % was uploaded by %' GROUP BY Month ORDER BY Time DESC LIMIT 1, 12"); $TimelineIn = array_reverse($DB->to_array()); $DB->query(" SELECT DATE_FORMAT(Time,\"%b %Y\") AS Month, COUNT(ID) FROM log WHERE Message LIKE 'Torrent % was deleted %' GROUP BY Month ORDER BY Time DESC LIMIT 1, 12"); $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', 'chart'); ?>