Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

torrents.php 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?
  2. if (!list($Labels, $InFlow, $OutFlow, $NetFlow, $Max) = $Cache->get_value('torrents_timeline')) {
  3. $DB->query("
  4. SELECT DATE_FORMAT(Time,'%b \'%y') AS Month, COUNT(ID)
  5. FROM log
  6. WHERE Message LIKE 'Torrent % was uploaded by %'
  7. GROUP BY Month
  8. ORDER BY Time DESC
  9. LIMIT 1, 12");
  10. $TimelineIn = array_reverse($DB->to_array());
  11. $DB->query("
  12. SELECT DATE_FORMAT(Time,'%b \'%y') AS Month, COUNT(ID)
  13. FROM log
  14. WHERE Message LIKE 'Torrent % was deleted %'
  15. GROUP BY Month
  16. ORDER BY Time DESC
  17. LIMIT 1, 12");
  18. $TimelineOut = array_reverse($DB->to_array());
  19. $DB->query("
  20. SELECT DATE_FORMAT(Time,'%b \'%y') AS Month, COUNT(ID)
  21. FROM torrents
  22. GROUP BY Month
  23. ORDER BY Time DESC
  24. LIMIT 1, 12");
  25. $TimelineNet = array_reverse($DB->to_array());
  26. foreach ($TimelineIn as $Month) {
  27. list($Label, $Amount) = $Month;
  28. if ($Amount > $Max) {
  29. $Max = $Amount;
  30. }
  31. }
  32. foreach ($TimelineOut as $Month) {
  33. list($Label, $Amount) = $Month;
  34. if ($Amount > $Max) {
  35. $Max = $Amount;
  36. }
  37. }
  38. foreach ($TimelineNet as $Month) {
  39. list($Label, $Amount) = $Month;
  40. if ($Amount > $Max) {
  41. $Max = $Amount;
  42. }
  43. }
  44. foreach ($TimelineIn as $Month) {
  45. list($Label, $Amount) = $Month;
  46. $Labels[] = $Label;
  47. $InFlow[] = number_format(($Amount / $Max) * 100, 4);
  48. }
  49. foreach ($TimelineOut as $Month) {
  50. list($Label, $Amount) = $Month;
  51. $OutFlow[] = number_format(($Amount / $Max) * 100, 4);
  52. }
  53. foreach ($TimelineNet as $Month) {
  54. list($Label, $Amount) = $Month;
  55. $NetFlow[] = number_format(($Amount / $Max) * 100, 4);
  56. }
  57. $Cache->cache_value('torrents_timeline', array($Labels, $InFlow, $OutFlow, $NetFlow, $Max), mktime(0, 0, 0, date('n') + 1, 2)); //Tested: fine for dec -> jan
  58. }
  59. include_once(SERVER_ROOT.'/classes/charts.class.php');
  60. $DB->query("
  61. SELECT tg.CategoryID, COUNT(t.ID) AS Torrents
  62. FROM torrents AS t
  63. JOIN torrents_group AS tg ON tg.ID = t.GroupID
  64. GROUP BY tg.CategoryID
  65. ORDER BY Torrents DESC");
  66. $Groups = $DB->to_array();
  67. $Pie = new PIE_CHART(750, 400, array('Other' => 1, 'Percentage' => 1));
  68. foreach ($Groups as $Group) {
  69. list($CategoryID, $Torrents) = $Group;
  70. $CategoryName = $Categories[$CategoryID - 1];
  71. $Pie->add($CategoryName, $Torrents);
  72. }
  73. $Pie->transparent();
  74. $Pie->color('FF33CC');
  75. $Pie->generate();
  76. $Categories = $Pie->url();
  77. View::show_header('Detailed torrent statistics');
  78. ?>
  79. <div class="box pad center">
  80. <h1>Uploads by month</h1>
  81. <img src="https://chart.googleapis.com/chart?cht=lc&amp;chs=880x160&amp;chco=000D99,99000D,00990D&amp;chg=0,-1,1,1&amp;chxt=y,x&amp;chxs=0,h&amp;chxl=1:|<?=implode('|', $Labels)?>&amp;chxr=0,0,<?=$Max?>&amp;chd=t:<?=implode(',', $InFlow)?>|<?=implode(',', $OutFlow)?>|<?=implode(',', $NetFlow)?>&amp;chls=2,4,0&amp;chdl=Uploads|Deletions|Remaining&amp;chf=bg,s,FFFFFF00" alt="User Flow Chart" />
  82. </div>
  83. <div class="box pad center">
  84. <h1>Torrents by category</h1>
  85. <img src="<?=$Categories?>" alt="" />
  86. </div>
  87. <?
  88. View::show_footer();