Contributing back some bug fixes
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.

bprates.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?
  2. function bytesToGiB($bytes) {
  3. if ($bytes > 1048576) {
  4. $GiB = $bytes / 1073741824;
  5. } else {
  6. $GiB = 0;
  7. }
  8. return $GiB;
  9. }
  10. $Username = $LoggedUser['Username'];
  11. View::show_header($Username." &gt; Bonus Rates");
  12. $activeTorrents = array();
  13. $DB->query("
  14. SELECT x.timespent,
  15. t.GroupID,
  16. t.Media,
  17. t.Container,
  18. t.Codec,
  19. t.Resolution,
  20. t.AudioFormat,
  21. t.Size,
  22. t.Seeders,
  23. t.Recorded,
  24. us.SeedTime,
  25. (us.SeedTime/60/60) AS hours,
  26. (us.SeedTime/60/60/24) AS days,
  27. tg.Name AS Album,
  28. ag.Name AS Artist
  29. FROM xbt_files_users AS x
  30. LEFT JOIN torrents AS t ON t.ID=x.fid
  31. LEFT JOIN users_seedtime AS us ON x.fid=us.TorrentID AND x.uid=us.UserID
  32. LEFT JOIN torrents_group AS tg ON t.GroupID=tg.ID
  33. LEFT JOIN torrents_artists AS ta ON t.GroupID=ta.GroupID
  34. LEFT JOIN artists_group AS ag ON ta.ArtistID=ag.ArtistID
  35. WHERE x.uid = $UserID AND x.active=1 AND x.remaining=0
  36. GROUP BY x.fid, x.ip");
  37. while ($result = $DB->next_record()) {
  38. $activeTorrents[] = $result;
  39. }
  40. $totals = [
  41. 'torrents' => 0,
  42. 'size' => 0,
  43. 'points' => 0,
  44. ];
  45. ?>
  46. <div class="thin">
  47. <div class="header">
  48. <h2><?=Users::format_username($UserID, false, false, false)?> &gt; Bonus Rates</h2>
  49. </div>
  50. <div class="main_column" style="width: 100%; margin-top: 18px">
  51. <table class="box torrent_table cats no_grouping" id="torrent_table">
  52. <tr class="colhead">
  53. <td>Torrent</td>
  54. <td>Size</td>
  55. <td><svg width="11" height="15" fill="white" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg>
  56. </td>
  57. <td>Seed Time</td>
  58. <td>BP/hour</td>
  59. </tr>
  60. <?php foreach ($activeTorrents as $torrent) {
  61. $points = bytesToGiB($torrent['Size']) * ( 0.25 + ( 0.6 * log(1+$torrent['days']) / pow($torrent['Seeders'],0.6) ) );
  62. $totals['torrents']++;
  63. $totals['size'] = $totals['size'] + $torrent['Size'];
  64. $totals['points'] = $totals['points'] + $points;
  65. ?>
  66. <tr id="site_style_tr">
  67. <td><?=$torrent['Artist'].' - '.$torrent['Album'].' - '.$torrent['Recorded'].' | '.$torrent['Codec'].' / '.$torrent['Media'].' / '.$torrent['Container'].' / '.$torrent['Resolution'].' / '.$torrent['AudioFormat']; ?></td>
  68. <td><?=Format::get_size($torrent['Size'])?></td>
  69. <td><?php echo $torrent['Seeders']; ?></td>
  70. <td><?php echo round($torrent['days'], 2); ?> days</td>
  71. <td><?=round($points, 4)?></td>
  72. </tr>
  73. <?php } ?>
  74. </table>
  75. <br />
  76. <table class="box torrent_table cats no_grouping" id="torrent_table">
  77. <tr class="colhead">
  78. <td>Total Torrents</td>
  79. <td>Seeding Size</td>
  80. <td>BP/hour</td>
  81. <td>BP/day</td>
  82. <td>BP/month</td>
  83. </tr>
  84. <tr>
  85. <td><?=$totals['torrents']?></td>
  86. <td><?=Format::get_size($totals['size'])?></td>
  87. <td><?=round($totals['points'], 4)?></td>
  88. <td><?=round($totals['points']*24, 4)?></td>
  89. <td><?=round($totals['points']*24*30, 4)?></td>
  90. </tr>
  91. </table>
  92. </div>
  93. </div>
  94. <? View::show_footer(); ?>