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.

disable_inactive_users.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. #declare(strict_types=1);
  3. $ENV = ENV::go();
  4. // The SQL query's lines below controls the notification clock
  5. // AND um.LastAccess < (NOW() - INTERVAL 110 DAY)
  6. // AND um.LastAccess > (NOW() - INTERVAL 111 DAY)
  7. if (apcu_exists('DBKEY')) {
  8. // Send email
  9. $DB->query("
  10. SELECT um.Username, um.Email
  11. FROM users_info AS ui
  12. JOIN users_main AS um ON um.ID = ui.UserID
  13. LEFT JOIN users_levels AS ul ON ul.UserID = um.ID AND ul.PermissionID = '".CELEB."'
  14. WHERE um.PermissionID IN ('".USER."', '".MEMBER ."')
  15. AND um.LastAccess < (NOW() - INTERVAL 355 DAY)
  16. AND um.LastAccess > (NOW() - INTERVAL 356 DAY)
  17. AND um.LastAccess IS NOT NULL
  18. AND ui.Donor = '0'
  19. AND um.Enabled != '2'
  20. AND ul.UserID IS NULL
  21. GROUP BY um.ID");
  22. while (list($Username, $Email) = $DB->next_record()) {
  23. $Email = Crypto::decrypt($Email);
  24. $Body = "Hi $Username,\n\nIt has been almost a year since you used your account at ".site_url().". This is an automated email to inform you that your account will be disabled in 10 days if you do not sign in.";
  25. Misc::send_email($Email, "Your $ENV->SITE_NAME account is about to be disabled", $Body);
  26. }
  27. # The actual deletion clock
  28. # AND um.LastAccess < (NOW() - INTERVAL 120 DAY)
  29. $DB->query("
  30. SELECT um.ID
  31. FROM users_info AS ui
  32. JOIN users_main AS um ON um.ID = ui.UserID
  33. LEFT JOIN users_levels AS ul ON ul.UserID = um.ID AND ul.PermissionID = '".CELEB."'
  34. WHERE um.PermissionID IN ('".USER."', '".MEMBER ."')
  35. AND um.LastAccess < (NOW() - INTERVAL 365 DAY)
  36. AND um.LastAccess IS NOT NULL
  37. AND ui.Donor = '0'
  38. AND um.Enabled != '2'
  39. AND ul.UserID IS NULL
  40. GROUP BY um.ID");
  41. if ($DB->has_results()) {
  42. Tools::disable_users($DB->collect('ID'), 'Disabled for inactivity.', 3);
  43. }
  44. }