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.

lockedaccounts.class.php 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. #declare(strict_types=1);
  3. /**
  4. * Class to manage locked accounts
  5. */
  6. class LockedAccounts
  7. {
  8. /**
  9. * Lock an account
  10. *
  11. * @param int $UserID The ID of the user to lock
  12. * @param int $Type The lock type, should be a constant value
  13. * @param string $Message The message to write to user notes
  14. * @param string $Reason The reason for the lock
  15. * @param int $LockedByUserID The ID of the staff member that locked $UserID's account. 0 for system
  16. */
  17. public static function lock_account($UserID, $Type, $Message, $Reason, $LockedByUserID)
  18. {
  19. if ($LockedByUserID === 0) {
  20. $Username = "System";
  21. } else {
  22. G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $LockedByUserID . "'");
  23. list($Username) = G::$DB->next_record();
  24. }
  25. G::$DB->query("
  26. INSERT INTO locked_accounts (UserID, Type)
  27. VALUES ('" . $UserID . "', " . $Type . ")");
  28. Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n");
  29. G::$Cache->delete_value("user_info_$UserID");
  30. }
  31. /**
  32. * Unlock an account
  33. *
  34. * @param int $UserID The ID of the user to unlock
  35. * @param int $Type The lock type, should be a constant value. Used for database verification
  36. * to avoid deleting the wrong lock type
  37. * @param string $Reason The reason for unlock
  38. * @param int $UnlockedByUserID The ID of the staff member unlocking $UserID's account. 0 for system
  39. */
  40. public static function unlock_account($UserID, $Type, $Message, $Reason, $UnlockedByUserID)
  41. {
  42. if ($UnlockedByUserID === 0) {
  43. $Username = "System";
  44. } else {
  45. G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $UnlockedByUserID . "'");
  46. list($Username) = G::$DB->next_record();
  47. }
  48. G::$DB->query("DELETE FROM locked_accounts WHERE UserID = '$UserID' AND Type = '". $Type ."'");
  49. if (G::$DB->affected_rows() === 1) {
  50. G::$Cache->delete_value("user_info_$UserID");
  51. Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n");
  52. }
  53. }
  54. }