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.

bonus_points.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. #declare(strict_types=1);
  3. $getUsers = $DB->query("
  4. SELECT um.ID,
  5. um.BonusPoints,
  6. COUNT(DISTINCT x.fid) AS Torrents,
  7. SUM(t.Size) AS Size,
  8. SUM(xs.seedtime) AS Seedtime,
  9. SUM(t.Seeders) AS Seeders
  10. FROM users_main AS um
  11. LEFT JOIN users_info AS i on um.ID = i.UserID
  12. LEFT JOIN xbt_files_users AS x ON um.ID=x.uid
  13. LEFT JOIN torrents AS t ON t.ID=x.fid
  14. LEFT JOIN xbt_snatched AS xs ON x.uid=xs.uid AND x.fid=xs.fid
  15. WHERE
  16. um.Enabled = '1'
  17. AND i.DisablePoints = '0'
  18. AND x.active = 1
  19. AND x.completed = 0
  20. AND x.Remaining = 0
  21. GROUP BY um.ID");
  22. if ($DB->has_results()) {
  23. $QueryPart = '';
  24. while (list($UserID, $BonusPoints, $NumTorr, $TSize, $TTime, $TSeeds) = $DB->next_record()) {
  25. $Points = (0.5 + (0.55*($NumTorr * (sqrt(($TSize/$NumTorr)/1073741824) * pow(1.5, ($TTime/$NumTorr)/(24*365))))) / (max(1, sqrt(($TSeeds/$NumTorr)+4)/3)))**0.95;
  26. $Points = intval(max(min($Points, ($Points * 2) - ($BonusPoints/1440)), 0));
  27. if ($Points > 100000) {
  28. $Points = 0;
  29. }
  30. if ($Points > 0) {
  31. $QueryPart .= "WHEN $UserID THEN BonusPoints+$Points ";
  32. $Cache->delete_value('user_info_heavy_'.$UserID);
  33. }
  34. }
  35. $DB->query("
  36. UPDATE users_main
  37. SET BonusPoints = CASE ID "
  38. .$QueryPart.
  39. "ELSE BonusPoints END");
  40. }