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 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. //print_r($activeTorrents); die();
  46. ?>
  47. <div class="thin">
  48. <div class="header">
  49. <h2><?=Users::format_username($UserID, false, false, false)?> &gt; Bonus Rates</h2>
  50. </div>
  51. <div class="main_column" style="width: 100%; margin-top: 18px">
  52. <table class="box torrent_table cats no_grouping" id="torrent_table">
  53. <tr class="colhead">
  54. <td>Torrent</td>
  55. <td>Size</td>
  56. <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>
  57. </td>
  58. <td>Seed Time</td>
  59. <td>BP/hour</td>
  60. </tr>
  61. <?php foreach ($activeTorrents as $torrent) {
  62. $points = bytesToGiB($torrent['Size']) * ( 0.25 + ( 0.6 * log(1+$torrent['days']) / pow($torrent['Seeders'],0.6) ) );
  63. $totals['torrents']++;
  64. $totals['size'] = $totals['size'] + $torrent['Size'];
  65. $totals['points'] = $totals['points'] + $points;
  66. ?>
  67. <tr id="site_style_tr">
  68. <td><?=$torrent['Artist'].' - '.$torrent['Album'].' - '.$torrent['Recorded'].' | '.$torrent['Codec'].' / '.$torrent['Media'].' / '.$torrent['Container'].' / '.$torrent['Resolution'].' / '.$torrent['AudioFormat']; ?></td>
  69. <td><?=Format::get_size($torrent['Size'])?></td>
  70. <td><?php echo $torrent['Seeders']; ?></td>
  71. <td><?php echo round($torrent['days'], 2); ?> days</td>
  72. <td><?=round($points, 4)?></td>
  73. </tr>
  74. <?php } ?>
  75. </table>
  76. <br />
  77. <table class="box torrent_table cats no_grouping" id="torrent_table">
  78. <tr class="colhead">
  79. <td>Total Torrents</td>
  80. <td>Seeding Size</td>
  81. <td>BP/hour</td>
  82. <td>BP/day</td>
  83. <td>BP/month</td>
  84. </tr>
  85. <tr>
  86. <td><?=$totals['torrents']?></td>
  87. <td><?=Format::get_size($totals['size'])?></td>
  88. <td><?=round($totals['points'], 4)?></td>
  89. <td><?=round($totals['points']*24, 4)?></td>
  90. <td><?=round($totals['points']*24*30, 4)?></td>
  91. </tr>
  92. </table>
  93. </div>
  94. </div>
  95. <? View::show_footer(); ?>