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.

take_delete_email.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. #declare(strict_types=1);
  3. enforce_login();
  4. authorize();
  5. if (!isset($_POST['emails']) || !is_array($_POST['emails'])) {
  6. error('Stop that.');
  7. }
  8. if (!apcu_exists('DBKEY')) {
  9. error(403);
  10. }
  11. $EncEmails = $_POST['emails'];
  12. $Reason = $_POST['reason'] ?? '';
  13. foreach ($EncEmails as $EncEmail) {
  14. $DB->query("
  15. SELECT
  16. `UserID`
  17. FROM
  18. `users_history_emails`
  19. WHERE
  20. `Email` = '".db_string($EncEmail)."'
  21. ");
  22. if (!$DB->has_results()) {
  23. error('Email not found');
  24. }
  25. list($UserID) = $DB->next_record();
  26. if (!check_perms('users_mod') && ($UserID !== $LoggedUser['ID'])) {
  27. error(403);
  28. }
  29. $DB->query("
  30. SELECT
  31. `Email`
  32. FROM
  33. `users_main`
  34. WHERE
  35. `ID` = '$UserID'
  36. ");
  37. if (!$DB->has_results()) {
  38. error(404);
  39. }
  40. list($Curr) = $DB->next_record();
  41. $Curr = Crypto::decrypt($Curr);
  42. if ($Curr === Crypto::decrypt($EncEmail)) {
  43. error("You can't delete your current email.");
  44. }
  45. }
  46. // Okay I think everything checks out.
  47. $DB->query("
  48. INSERT INTO `deletion_requests`(
  49. `UserID`,
  50. `Type`,
  51. `Value`,
  52. `Reason`,
  53. `Time`
  54. )
  55. VALUES(
  56. '$UserID',
  57. 'Email',
  58. '".db_string($EncEmails[0])."',
  59. '".db_string($Reason)."',
  60. NOW())
  61. ");
  62. $Cache->delete_value('num_deletion_requests');
  63. View::show_header('Email Deletion Request');
  64. ?>
  65. <div>
  66. <h2>Email Deletion Request</h2>
  67. <div class="box">
  68. <p>
  69. Your request has been sent.
  70. Please wait for it to be acknowledged.
  71. </p>
  72. <p>
  73. After it's accepted or denied by staff, you will receive a PM response.
  74. </p>
  75. <p>
  76. <a href="/index.php">Return</a>
  77. </p>
  78. </div>
  79. </div>
  80. <?php
  81. View::show_footer();