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.

expunge_requests.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. #declare(strict_types=1);
  3. if (!check_perms('users_mod')) {
  4. error(403);
  5. }
  6. $QueryID = $DB->query("
  7. SELECT SQL_CALC_FOUND_ROWS *
  8. FROM deletion_requests");
  9. $DB->query("SELECT FOUND_ROWS()");
  10. list($NumResults) = $DB->next_record();
  11. $DB->set_query_id($QueryID);
  12. $Requests = $DB->to_array();
  13. if (isset($_GET['deny']) && isset($_GET['type']) && isset($_GET['value'])) {
  14. authorize();
  15. $Deny = ($_GET['deny'] == 'true');
  16. $Type = $_GET['type'] == 'email' ? 'Email' : ($_GET['type'] == 'ip' ? 'IP' : '');
  17. $Value = db_string($_GET['value']);
  18. $DB->query("
  19. DELETE FROM deletion_requests
  20. WHERE Value = '$Value'");
  21. $DB->query("
  22. SELECT UserID
  23. FROM users_history_".strtolower($Type)."s
  24. WHERE $Type = '$Value'");
  25. if ($DB->has_results()) {
  26. list($UserID) = $DB->next_record();
  27. if ($UserID != $_GET['userid']) {
  28. $Err = "The specified UserID is incorrect.";
  29. }
  30. } else {
  31. $Err = "That $Type doesn't exist.";
  32. }
  33. if (empty($Err)) {
  34. if (!$Deny) {
  35. $DB->query("
  36. SELECT $Type
  37. FROM users_history_".strtolower($Type)."s
  38. WHERE UserID = '$UserID'");
  39. $ToDelete = [];
  40. while (list($EncValue) = $DB->next_record()) {
  41. if (Crypto::decrypt($Value) == Crypto::decrypt($EncValue)) {
  42. $ToDelete[] = $EncValue;
  43. }
  44. }
  45. forEach ($ToDelete as $DelValue) {
  46. $DB->query("
  47. DELETE FROM users_history_".strtolower($Type)."s
  48. WHERE UserID = $UserID
  49. AND $Type = '$DelValue'");
  50. }
  51. $Succ = "$Type deleted.";
  52. Misc::send_pm($UserID, 0, "$Type Deletion Request Accepted.", "Your deletion request has been accepted. What $Type? I don't know! We don't have it anymore!");
  53. } else {
  54. $Succ = "Request denied.";
  55. Misc::send_pm($UserID, 0, "$Type Deletion Request Denied.", "Your deletion request has been denied.\n\nIf you wish to discuss this matter further, please create a staff PM, or join ".HELP_CHAN." on IRC to speak with a staff member.");
  56. }
  57. }
  58. $Cache->delete_value('num_deletion_requests');
  59. }
  60. View::show_header("Expunge Requests");
  61. ?>
  62. <div class="header">
  63. <h2>Expunge Requests</h2>
  64. </div>
  65. <? if (isset($Err)) { ?>
  66. <span>Error: <?=$Err?></span>
  67. <? } elseif (isset($Succ)) { ?>
  68. <span>Success: <?=$Succ?></span>
  69. <? } ?>
  70. <div>
  71. <table width="100%">
  72. <tr class="colhead">
  73. <td>User</td>
  74. <td>Type</td>
  75. <td>Value</td>
  76. <td>Reason</td>
  77. <td>Accept</td>
  78. <td>Deny</td>
  79. </tr>
  80. <? foreach ($Requests as $Request) { ?>
  81. <tr>
  82. <td><?=Users::format_username($Request['UserID'])?></td>
  83. <td><?=$Request['Type']?></td>
  84. <td><?=Crypto::decrypt($Request['Value'])?></td>
  85. <td><?=display_str($Request['Reason'])?></td>
  86. <td><a href="tools.php?action=expunge_requests&auth=<?=$LoggedUser['AuthKey']?>&type=<?=strtolower($Request['Type'])?>&value=<?=urlencode($Request['Value'])?>&userid=<?=$Request['UserID']?>&deny=false" class="brackets">Accept</a></td>
  87. <td><a href="tools.php?action=expunge_requests&auth=<?=$LoggedUser['AuthKey']?>&type=<?=strtolower($Request['Type'])?>&value=<?=urlencode($Request['Value'])?>&userid=<?=$Request['UserID']?>&deny=true" class="brackets">Deny</a></td>
  88. </tr>
  89. <? } ?>
  90. </table>
  91. </div>
  92. <? View::show_footer(); ?>