BioTorrents.de’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.

torrent_stats.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. #declare(strict_types=1);
  3. if (!check_perms('site_view_flow')) {
  4. error(403);
  5. }
  6. View::show_header('Torrents');
  7. if (!$TorrentStats = $Cache->get_value('new_torrent_stats')) {
  8. $DB->prepared_query("
  9. SELECT COUNT(ID), SUM(Size), SUM(FileCount)
  10. FROM torrents");
  11. list($TorrentCount, $TotalSize, $TotalFiles) = $DB->next_record();
  12. $DB->prepared_query("
  13. SELECT COUNT(ID)
  14. FROM users_main
  15. WHERE Enabled = '1'");
  16. list($NumUsers) = $DB->next_record();
  17. $DB->prepared_query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents WHERE Time > SUBDATE(NOW(), INTERVAL 1 DAY)");
  18. list($DayNum, $DaySize, $DayFiles) = $DB->next_record();
  19. $DB->prepared_query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents WHERE Time > SUBDATE(NOW(), INTERVAL 7 DAY)");
  20. list($WeekNum, $WeekSize, $WeekFiles) = $DB->next_record();
  21. $DB->prepared_query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents WHERE Time > SUBDATE(NOW(), INTERVAL 30 DAY)");
  22. list($MonthNum, $MonthSize, $MonthFiles) = $DB->next_record();
  23. $Cache->cache_value('new_torrent_stats', array($TorrentCount, $TotalSize, $TotalFiles,
  24. $NumUsers, $DayNum, $DaySize, $DayFiles,
  25. $WeekNum, $WeekSize, $WeekFiles, $MonthNum,
  26. $MonthSize, $MonthFiles), 3600);
  27. } else {
  28. list($TorrentCount, $TotalSize, $TotalFiles, $NumUsers, $DayNum, $DaySize, $DayFiles,
  29. $WeekNum, $WeekSize, $WeekFiles, $MonthNum, $MonthSize, $MonthFiles) = $TorrentStats;
  30. }
  31. ?>
  32. <div>
  33. <div class="box">
  34. <div class="head">Overall stats</div>
  35. <div class="pad">
  36. <ul class="stats nobullet">
  37. <li>
  38. <strong>Total torrents:</strong>
  39. <?=number_format($TorrentCount)?>
  40. </li>
  41. <li>
  42. <strong>Total size:</strong>
  43. <?=Format::get_size($TotalSize)?>
  44. </li>
  45. <li>
  46. <strong>Total files:</strong>
  47. <?=number_format($TotalFiles)?>
  48. </li>
  49. <br />
  50. <li>
  51. <strong>Mean torrents per user:</strong>
  52. <?=number_format($TorrentCount / $NumUsers)?>
  53. </li>
  54. <li>
  55. <strong>Mean torrent size:</strong>
  56. <?=Format::get_size($TotalSize / $TorrentCount)?>
  57. </li>
  58. <li>
  59. <strong>Mean files per torrent:</strong>
  60. <?=number_format($TotalFiles / $TorrentCount)?>
  61. </li>
  62. <li>
  63. <strong>Mean filesize:</strong>
  64. <?=Format::get_size($TotalSize / $TotalFiles)?>
  65. </li>
  66. </ul>
  67. </div>
  68. </div>
  69. <br />
  70. <div class="box">
  71. <div class="head">Upload frequency</div>
  72. <div class="pad">
  73. <ul class="stats nobullet">
  74. <li>
  75. <strong>Torrents today:</strong>
  76. <?=number_format($DayNum)?>
  77. </li>
  78. <li>
  79. <strong>Size today:</strong>
  80. <?=Format::get_size($DaySize)?>
  81. </li>
  82. <li>
  83. <strong>Files today:</strong>
  84. <?=number_format($DayFiles)?>
  85. </li>
  86. <br />
  87. <li>
  88. <strong>Torrents this week:</strong>
  89. <?=number_format($WeekNum)?>
  90. </li>
  91. <li>
  92. <strong>Size this week:</strong>
  93. <?=Format::get_size($WeekSize)?>
  94. </li>
  95. <li>
  96. <strong>Files this week:</strong>
  97. <?=number_format($WeekFiles)?>
  98. </li>
  99. <br />
  100. <li>
  101. <strong>Torrents per day this week:</strong>
  102. <?=number_format($WeekNum / 7)?>
  103. </li>
  104. <li>
  105. <strong>Size per day this week:</strong>
  106. <?=Format::get_size($WeekSize / 7)?>
  107. </li>
  108. <li>
  109. <strong>Files per day this week:</strong>
  110. <?=number_format($WeekFiles / 7)?>
  111. </li>
  112. <br />
  113. <li>
  114. <strong>Torrents this month:</strong>
  115. <?=number_format($MonthNum)?>
  116. </li>
  117. <li>
  118. <strong>Size this month:</strong>
  119. <?=Format::get_size($MonthSize)?>
  120. </li>
  121. <li>
  122. <strong>Files this month:</strong>
  123. <?=number_format($MonthFiles)?>
  124. </li>
  125. <br />
  126. <li>
  127. <strong>Torrents per day this month:</strong>
  128. <?=number_format($MonthNum / 30)?>
  129. </li>
  130. <li>
  131. <strong>Size per day this month:</strong>
  132. <?=Format::get_size($MonthSize / 30)?>
  133. </li>
  134. <li>
  135. <strong>Files per day this month:</strong>
  136. <?=number_format($MonthFiles / 30)?>
  137. </li>
  138. </ul>
  139. </div>
  140. </div>
  141. </div>
  142. <?php
  143. View::show_footer();