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.

bonus_points.php 1.2KB

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