Gazelle/sections/artist/notifyremove.php

50 lines
1.2 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
2013-04-13 08:00:19 +00:00
if (!check_perms('site_torrents_notify')) {
error(403);
}
2011-03-28 14:21:28 +00:00
$ArtistID = $_GET['artistid'];
2013-04-13 08:00:19 +00:00
if (!is_number($ArtistID)) {
error(0);
}
2011-03-28 14:21:28 +00:00
2013-04-13 08:00:19 +00:00
if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) {
2013-07-13 08:00:46 +00:00
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
WHERE Label = 'Artist notifications'
AND UserID = '$LoggedUser[ID]'
ORDER BY ID
LIMIT 1");
2011-03-28 14:21:28 +00:00
} else {
2013-07-13 08:00:46 +00:00
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
WHERE ID = '$Notify[ID]'");
2011-03-28 14:21:28 +00:00
}
2013-07-13 08:00:46 +00:00
list($ID, $Artists) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("
SELECT Name
FROM artists_alias
WHERE ArtistID = '$ArtistID'
AND Redirect = 0");
while (list($Alias) = $DB->next_record(MYSQLI_NUM, false)) {
while (stripos($Artists, "|$Alias|") !== false) {
$Artists = str_ireplace("|$Alias|", '|', $Artists);
2011-03-28 14:21:28 +00:00
}
}
2013-04-13 08:00:19 +00:00
if ($Artists == '|') {
2013-07-13 08:00:46 +00:00
$DB->query("
DELETE FROM users_notify_filters
WHERE ID = $ID");
2011-03-28 14:21:28 +00:00
} else {
2013-07-13 08:00:46 +00:00
$DB->query("
UPDATE users_notify_filters
SET Artists = '".db_string($Artists)."'
WHERE ID = '$ID'");
2011-03-28 14:21:28 +00:00
}
$Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
$Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
header('Location: '.$_SERVER['HTTP_REFERER']);
?>