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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?
  2. //----------- Award Automated Badges -----------------------//
  3. global $AutomatedBadgeIDs;
  4. $GiB = 1024*1024*1024;
  5. $ModifiedIDs = array();
  6. // Download Badges
  7. // 8GiB DL
  8. $DB->query("
  9. SELECT ID
  10. FROM users_main
  11. WHERE Downloaded >= ".(8*$GiB)."
  12. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['8'].")");
  13. if ($DB->has_results()) {
  14. $IDs = $DB->collect('ID');
  15. foreach ($IDs as $ID) {
  16. $DB->query("
  17. INSERT INTO users_badges
  18. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['8'].", 0)");
  19. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 8GiB of data.\n\nIt can be enabled from your user settings.");
  20. }
  21. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  22. }
  23. // 16GiB DL
  24. $DB->query("
  25. SELECT ID
  26. FROM users_main
  27. WHERE Downloaded >= ".(16*$GiB)."
  28. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['16'].")");
  29. if ($DB->has_results()) {
  30. $IDs = $DB->collect('ID');
  31. foreach ($IDs as $ID) {
  32. $DB->query("
  33. INSERT INTO users_badges
  34. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['16'].", 0)");
  35. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 16GiB of data.\n\nIt can be enabled from your user settings.");
  36. }
  37. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  38. }
  39. // 32GiB DL
  40. $DB->query("
  41. SELECT ID
  42. FROM users_main
  43. WHERE Downloaded >= ".(32*$GiB)."
  44. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['32'].")");
  45. if ($DB->has_results()) {
  46. $IDs = $DB->collect('ID');
  47. foreach ($IDs as $ID) {
  48. $DB->query("
  49. INSERT INTO users_badges
  50. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['32'].", 0)");
  51. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 32GiB of data.\n\nIt can be enabled from your user settings.");
  52. }
  53. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  54. }
  55. // 64GiB DL
  56. $DB->query("
  57. SELECT ID
  58. FROM users_main
  59. WHERE Downloaded >= ".(64*$GiB)."
  60. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['64'].")");
  61. if ($DB->has_results()) {
  62. $IDs = $DB->collect('ID');
  63. foreach ($IDs as $ID) {
  64. $DB->query("
  65. INSERT INTO users_badges
  66. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['64'].", 0)");
  67. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 64GiB of data.\n\nIt can be enabled from your user settings.");
  68. }
  69. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  70. }
  71. // 128GiB DL
  72. $DB->query("
  73. SELECT ID
  74. FROM users_main
  75. WHERE Downloaded >= ".(128*$GiB)."
  76. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['128'].")");
  77. if ($DB->has_results()) {
  78. $IDs = $DB->collect('ID');
  79. foreach ($IDs as $ID) {
  80. $DB->query("
  81. INSERT INTO users_badges
  82. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['128'].", 0)");
  83. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 128GiB of data.\n\nIt can be enabled from your user settings.");
  84. }
  85. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  86. }
  87. // 256GiB DL
  88. $DB->query("
  89. SELECT ID
  90. FROM users_main
  91. WHERE Downloaded >= ".(256*$GiB)."
  92. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['256'].")");
  93. if ($DB->has_results()) {
  94. $IDs = $DB->collect('ID');
  95. foreach ($IDs as $ID) {
  96. $DB->query("
  97. INSERT INTO users_badges
  98. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['256'].", 0)");
  99. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 256GiB of data.\n\nIt can be enabled from your user settings.");
  100. }
  101. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  102. }
  103. // 512GiB DL
  104. $DB->query("
  105. SELECT ID
  106. FROM users_main
  107. WHERE Downloaded >= ".(512*$GiB)."
  108. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['512'].")");
  109. if ($DB->has_results()) {
  110. $IDs = $DB->collect('ID');
  111. foreach ($IDs as $ID) {
  112. $DB->query("
  113. INSERT INTO users_badges
  114. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['512'].", 0)");
  115. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 512GiB of data.\n\nIt can be enabled from your user settings.");
  116. }
  117. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  118. }
  119. // 1024GiB DL
  120. $DB->query("
  121. SELECT ID
  122. FROM users_main
  123. WHERE Downloaded >= ".(1024*$GiB)."
  124. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['1024'].")");
  125. if ($DB->has_results()) {
  126. $IDs = $DB->collect('ID');
  127. foreach ($IDs as $ID) {
  128. $DB->query("
  129. INSERT INTO users_badges
  130. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['1024'].", 0)");
  131. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 1024GiB of data.\n\nIt can be enabled from your user settings.");
  132. }
  133. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  134. }
  135. // 2048GiB DL
  136. $DB->query("
  137. SELECT ID
  138. FROM users_main
  139. WHERE Downloaded >= ".(2048*$GiB)."
  140. AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['2048'].")");
  141. if ($DB->has_results()) {
  142. $IDs = $DB->collect('ID');
  143. foreach ($IDs as $ID) {
  144. $DB->query("
  145. INSERT INTO users_badges
  146. VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['2048'].", 0)");
  147. Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 2048GiB of data.\n\nIt can be enabled from your user settings.");
  148. }
  149. $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
  150. }
  151. foreach (array_unique($ModifiedIDs) as $ID) {
  152. $Cache->delete_value('user_badges_'.$ID);
  153. }
  154. ?>