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-05-27 08:00:58 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT GROUP_CONCAT(Name SEPARATOR '|')
|
|
|
|
FROM artists_alias
|
|
|
|
WHERE ArtistID = '$ArtistID'
|
|
|
|
AND Redirect = 0
|
|
|
|
GROUP BY ArtistID");
|
2011-03-28 14:21:28 +00:00
|
|
|
list($ArtistAliases) = $DB->next_record(MYSQLI_NUM, FALSE);
|
|
|
|
|
|
|
|
$Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID']);
|
2013-04-13 08:00:19 +00:00
|
|
|
if (empty($Notify)) {
|
2013-05-27 08:00:58 +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-05-27 08:00:58 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT ID, Artists
|
|
|
|
FROM users_notify_filters
|
|
|
|
WHERE ID='$Notify[ID]'");
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-04-13 08:00:19 +00:00
|
|
|
if (empty($Notify) && $DB->record_count() == 0) {
|
2013-05-27 08:00:58 +00:00
|
|
|
$DB->query("
|
|
|
|
INSERT INTO users_notify_filters (UserID, Label, Artists)
|
|
|
|
VALUES ('$LoggedUser[ID]', 'Artist notifications', '|".db_string($ArtistAliases)."|')");
|
2011-03-28 14:21:28 +00:00
|
|
|
$FilterID = $DB->inserted_id();
|
|
|
|
$Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
|
|
|
|
$Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
|
|
|
|
} else {
|
|
|
|
list($ID, $ArtistNames) = $DB->next_record(MYSQLI_NUM, FALSE);
|
2013-04-13 08:00:19 +00:00
|
|
|
if (stripos($ArtistNames,$ArtistAliases) === false) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$ArtistNames.=$ArtistAliases.'|';
|
2013-05-27 08:00:58 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE users_notify_filters
|
|
|
|
SET Artists='".db_string($ArtistNames)."'
|
|
|
|
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']);
|
|
|
|
?>
|