Oppaitime'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.

badges.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?
  2. //----------- Award Automated Badges -----------------------//
  3. $GiB = 1024*1024*1024;
  4. $ModifiedIDs = array();
  5. // Download Badges
  6. foreach (AUTOMATED_BADGE_IDS['DL'] as $DL=>$Badge) {
  7. $DB->query("
  8. SELECT ID
  9. FROM users_main
  10. WHERE Downloaded >= ".($DL*$GiB)."
  11. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = $Badge)");
  12. if ($DB->has_results()) {
  13. $IDs = $DB->collect('ID');
  14. foreach ($IDs as $ID) {
  15. if (Badges::award_badge($ID, $Badge)) {
  16. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading ".$DL."GiB of data.\n\nIt can be enabled from your user settings.");
  17. }
  18. }
  19. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  20. }
  21. }
  22. // Upload Badges
  23. foreach (AUTOMATED_BADGE_IDS['UL'] as $UL=>$Badge) {
  24. $DB->query("
  25. SELECT ID
  26. FROM users_main
  27. WHERE Uploaded >= ".($UL*$GiB)."
  28. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = $Badge)");
  29. if ($DB->has_results()) {
  30. $IDs = $DB->collect('ID');
  31. foreach ($IDs as $ID) {
  32. if (Badges::award_badge($ID, $Badge)) {
  33. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for uploading ".$UL."GiB of data.\n\nIt can be enabled from your user settings.");
  34. }
  35. }
  36. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  37. }
  38. }
  39. // Tag Badges
  40. foreach (AUTOMATED_BADGE_IDS['Tags'] as $Tag=>$Badge) {
  41. $DB->query("
  42. SELECT DISTINCT x.uid
  43. FROM xbt_snatched AS x
  44. JOIN torrents AS t ON t.ID = x.fid
  45. JOIN torrents_group AS tg ON t.GroupID = tg.ID
  46. WHERE tg.TagList LIKE '%" . $Tag . "%'");
  47. if ($DB->has_results()) {
  48. $IDs = $DB->collect('uid');
  49. foreach ($IDs as $ID) {
  50. if (Badges::award_badge($ID, $Badge)) {
  51. Misc::send_pm($ID, 0, 'You have recieved a badge!', "You have received a badge for mysterious reasons.\n\nIt can be enabled from your user settings.");
  52. }
  53. }
  54. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  55. }
  56. }
  57. foreach (array_unique($ModifiedIDs) as $ID) {
  58. $Cache->delete_value('user_badges_'.$ID);
  59. }
  60. ?>