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.8KB

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