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.

notify.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. #declare(strict_types=1);
  3. authorize();
  4. if (!check_perms('site_torrents_notify')) {
  5. error(403);
  6. }
  7. $ArtistID = $_GET['artistid'];
  8. if (!is_number($ArtistID)) {
  9. error(0);
  10. }
  11. /*
  12. $DB->query("
  13. SELECT GROUP_CONCAT(Name SEPARATOR '|')
  14. FROM artists_alias
  15. WHERE ArtistID = '$ArtistID'
  16. AND Redirect = 0
  17. GROUP BY ArtistID");
  18. list($ArtistAliases) = $DB->next_record(MYSQLI_NUM, FALSE);
  19. */
  20. $DB->query("
  21. SELECT Name
  22. FROM artists_group
  23. WHERE ArtistID = '$ArtistID'");
  24. list($ArtistAliases) = $DB->next_record(MYSQLI_NUM, false);
  25. $Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID']);
  26. if (empty($Notify)) {
  27. $DB->query("
  28. SELECT ID, Artists
  29. FROM users_notify_filters
  30. WHERE Label = 'Artist notifications'
  31. AND UserID = '$LoggedUser[ID]'
  32. ORDER BY ID
  33. LIMIT 1");
  34. } else {
  35. $DB->query("
  36. SELECT ID, Artists
  37. FROM users_notify_filters
  38. WHERE ID = '$Notify[ID]'");
  39. }
  40. if (empty($Notify) && !$DB->has_results()) {
  41. $DB->query("
  42. INSERT INTO users_notify_filters
  43. (UserID, Label, Artists)
  44. VALUES
  45. ('$LoggedUser[ID]', 'Artist notifications', '|".db_string($ArtistAliases)."|')");
  46. $FilterID = $DB->inserted_id();
  47. $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
  48. $Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
  49. } else {
  50. list($ID, $ArtistNames) = $DB->next_record(MYSQLI_NUM, false);
  51. if (stripos($ArtistNames, "|$ArtistAliases|") === false) {
  52. $ArtistNames .= "$ArtistAliases|";
  53. $DB->query("
  54. UPDATE users_notify_filters
  55. SET Artists = '".db_string($ArtistNames)."'
  56. WHERE ID = '$ID'");
  57. $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
  58. $Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
  59. }
  60. }
  61. header('Location: '.$_SERVER['HTTP_REFERER']);