Oppaitime'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.

add_alias.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?
  2. authorize();
  3. $UserID = $LoggedUser['ID'];
  4. $GroupID = db_string($_POST['groupid']);
  5. $ArtistNames = $_POST['artistname'];
  6. if (!is_number($GroupID) || !$GroupID) {
  7. error(0);
  8. }
  9. $DB->query("
  10. SELECT Name
  11. FROM torrents_group
  12. WHERE ID = $GroupID");
  13. if (!$DB->has_results()) {
  14. error(404);
  15. }
  16. list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
  17. for ($i = 0; $i < count($ArtistNames); $i++) {
  18. $ArtistName = Artists::normalise_artist_name($ArtistNames[$i]);
  19. if (strlen($ArtistName) > 0) {
  20. $DB->query("
  21. SELECT ArtistID
  22. FROM artists_group
  23. WHERE Name = ?", $ArtistName);
  24. if ($DB->has_results())
  25. list($ArtistID) = $DB->next_record(MYSQLI_NUM, false);
  26. if (!$ArtistID) {
  27. $ArtistName = db_string($ArtistName);
  28. $DB->query("
  29. INSERT INTO artists_group (Name)
  30. VALUES ( ? )", $ArtistName);
  31. $ArtistID = $DB->inserted_id();
  32. }
  33. $DB->query("
  34. INSERT IGNORE INTO torrents_artists
  35. (GroupID, ArtistID, UserID)
  36. VALUES
  37. ('$GroupID', '$ArtistID', '$UserID')");
  38. if ($DB->affected_rows()) {
  39. Misc::write_log("Artist $ArtistID ($ArtistName) was added to the group $GroupID ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
  40. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist $ArtistName", 0);
  41. $Cache->delete_value("torrents_details_$GroupID");
  42. $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
  43. $Cache->delete_value("artist_groups_$ArtistID"); // Delete artist group cache
  44. Torrents::update_hash($GroupID);
  45. }
  46. }
  47. }
  48. header('Location: '.$_SERVER['HTTP_REFERER']);
  49. ?>