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.

expire_tokens.php 954B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. #declare(strict_types=1);
  3. // Expire old FL tokens and clear cache where needed
  4. $DB->query("
  5. SELECT DISTINCT UserID
  6. FROM users_freeleeches
  7. WHERE Expired = FALSE
  8. AND Time < (NOW() - INTERVAL 4 DAY)");
  9. if ($DB->has_results()) {
  10. while (list($UserID) = $DB->next_record()) {
  11. $Cache->delete_value("users_tokens_$UserID");
  12. }
  13. $DB->query("
  14. SELECT uf.UserID, HEX(t.info_hash)
  15. FROM users_freeleeches AS uf
  16. JOIN torrents AS t ON uf.TorrentID = t.ID
  17. WHERE uf.Expired = FALSE
  18. AND uf.Time < (NOW() - INTERVAL 4 DAY)");
  19. while (list($UserID, $InfoHash) = $DB->next_record(MYSQLI_NUM, false)) {
  20. Tracker::update_tracker('remove_token', ['info_hash' => substr('%'.chunk_split($InfoHash, 2, '%'), 0, -1), 'userid' => $UserID]);
  21. }
  22. $DB->query("
  23. UPDATE users_freeleeches
  24. SET Expired = TRUE
  25. WHERE Time < (NOW() - INTERVAL 4 DAY)
  26. AND Expired = FALSE");
  27. }