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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. $DB->query("
  16. INSERT INTO users_badges
  17. VALUES ($ID, $Badge, 0)");
  18. 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.");
  19. }
  20. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  21. }
  22. }
  23. // Upload Badges
  24. foreach (AUTOMATED_BADGE_IDS['UL'] as $UL=>$Badge) {
  25. $DB->query("
  26. SELECT ID
  27. FROM users_main
  28. WHERE Uploaded >= ".($UL*$GiB)."
  29. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = $Badge)");
  30. if ($DB->has_results()) {
  31. $IDs = $DB->collect('ID');
  32. foreach ($IDs as $ID) {
  33. $DB->query("
  34. INSERT INTO users_badges
  35. VALUES ($ID, $Badge, 0)");
  36. 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.");
  37. }
  38. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  39. }
  40. }
  41. foreach (array_unique($ModifiedIDs) as $ID) {
  42. $Cache->delete_value('user_badges_'.$ID);
  43. }
  44. ?>