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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. $Changed = false;
  18. for ($i = 0; $i < count($ArtistNames); $i++) {
  19. $ArtistName = Artists::normalise_artist_name($ArtistNames[$i]);
  20. if (strlen($ArtistName) > 0) {
  21. $DB->query("
  22. SELECT ArtistID
  23. FROM artists_group
  24. WHERE Name = '".db_string($ArtistName)."'");
  25. if ($DB->has_results())
  26. list($ArtistID) = $DB->next_record(MYSQLI_NUM, false);
  27. if (!$ArtistID) {
  28. $ArtistName = db_string($ArtistName);
  29. $DB->query("
  30. INSERT INTO artists_group (Name)
  31. VALUES ('$ArtistName')");
  32. $ArtistID = $DB->inserted_id();
  33. }
  34. $DB->query("
  35. INSERT IGNORE INTO torrents_artists
  36. (GroupID, ArtistID, UserID)
  37. VALUES
  38. ('$GroupID', '$ArtistID', '$UserID')");
  39. if ($DB->affected_rows()) {
  40. $Changed = true;
  41. Misc::write_log("Artist $ArtistID ($ArtistName) was added to the group $GroupID ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
  42. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist $ArtistName", 0);
  43. }
  44. }
  45. }
  46. if ($Changed) {
  47. $Cache->delete_value("torrents_details_$GroupID");
  48. $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
  49. Torrents::update_hash($GroupID);
  50. }
  51. header('Location: '.$_SERVER['HTTP_REFERER']);
  52. ?>