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.

remove.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. #declare(strict_types=1);
  3. authorize();
  4. if (!Bookmarks::can_bookmark($_GET['type'])) {
  5. error(404);
  6. }
  7. $Type = $_GET['type'];
  8. list($Table, $Col) = Bookmarks::bookmark_schema($Type);
  9. if (!is_number($_GET['id'])) {
  10. error(0);
  11. }
  12. $PageID = $_GET['id'];
  13. $DB->query("
  14. DELETE FROM $Table
  15. WHERE UserID = $LoggedUser[ID]
  16. AND $Col = $PageID");
  17. $Cache->delete_value("bookmarks_{$Type}_$UserID");
  18. if ($DB->affected_rows()) {
  19. if ($Type === 'torrent') {
  20. $Cache->delete_value("bookmarks_group_ids_$UserID");
  21. } elseif ($Type === 'request') {
  22. $DB->query("
  23. SELECT UserID
  24. FROM $Table
  25. WHERE $Col = $PageID");
  26. if ($DB->record_count() < 100) {
  27. // Sphinx doesn't like huge MVA updates. Update sphinx_requests_delta
  28. // and live with the <= 1 minute delay if we have more than 100 bookmarkers
  29. $Bookmarkers = implode(',', $DB->collect('UserID'));
  30. $SphQL = new SphinxqlQuery();
  31. $SphQL->raw_query("UPDATE requests, requests_delta SET bookmarker = ($Bookmarkers) WHERE id = $PageID");
  32. } else {
  33. Requests::update_sphinx_requests($PageID);
  34. }
  35. }
  36. }