$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());
$DB->query("SELECT DATE_FORMAT(Time,'%b \'%y') AS Month, COUNT(ID) FROM torrents GROUP BY Month ORDER BY Time DESC LIMIT 1, 12");
$TimelineNet=array_reverse($DB->to_array());
foreach($TimelineInas$Month){
list($Label,$Amount)=$Month;
if($Amount>$Max){
$Max=$Amount;
}
}
foreach($TimelineOutas$Month){
list($Label,$Amount)=$Month;
if($Amount>$Max){
$Max=$Amount;
}
}
foreach($TimelineNetas$Month){
list($Label,$Amount)=$Month;
if($Amount>$Max){
$Max=$Amount;
}
}
foreach($TimelineInas$Month){
list($Label,$Amount)=$Month;
$Labels[]=$Label;
$InFlow[]=number_format(($Amount/$Max)*100,4);
}
foreach($TimelineOutas$Month){
list($Label,$Amount)=$Month;
$OutFlow[]=number_format(($Amount/$Max)*100,4);
}
foreach($TimelineNetas$Month){
list($Label,$Amount)=$Month;
$NetFlow[]=number_format(($Amount/$Max)*100,4);
}
$Cache->cache_value('torrents_timeline',array($Labels,$InFlow,$OutFlow,$NetFlow,$Max),mktime(0,0,0,date('n')+1,2));//Tested: fine for dec -> jan
$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");