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.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?
  2. include(SERVER_ROOT.'/classes/feed.class.php'); // RSS feeds
  3. authorize();
  4. if (!Bookmarks::can_bookmark($_GET['type'])) {
  5. error(404);
  6. }
  7. $Feed = new FEED;
  8. $Type = $_GET['type'];
  9. list($Table, $Col) = Bookmarks::bookmark_schema($Type);
  10. if (!is_number($_GET['id'])) {
  11. error(0);
  12. }
  13. $PageID = $_GET['id'];
  14. $DB->query("
  15. SELECT UserID
  16. FROM $Table
  17. WHERE UserID = '$LoggedUser[ID]'
  18. AND $Col = $PageID");
  19. if (!$DB->has_results()) {
  20. if ($Type === 'torrent') {
  21. $DB->query("
  22. SELECT MAX(Sort)
  23. FROM `bookmarks_torrents`
  24. WHERE UserID = $LoggedUser[ID]");
  25. list($Sort) = $DB->next_record();
  26. if (!$Sort) {
  27. $Sort = 0;
  28. }
  29. $Sort += 1;
  30. $DB->query("
  31. INSERT IGNORE INTO $Table (UserID, $Col, Time, Sort)
  32. VALUES ('$LoggedUser[ID]', $PageID, '".sqltime()."', $Sort)");
  33. } else {
  34. $DB->query("
  35. INSERT IGNORE INTO $Table (UserID, $Col, Time)
  36. VALUES ('$LoggedUser[ID]', $PageID, '".sqltime()."')");
  37. }
  38. $Cache->delete_value('bookmarks_'.$Type.'_'.$LoggedUser['ID']);
  39. if ($Type == 'torrent') {
  40. $Cache->delete_value("bookmarks_group_ids_$UserID");
  41. $DB->query("
  42. SELECT Name, Year, WikiBody, TagList
  43. FROM torrents_group
  44. WHERE ID = $PageID");
  45. list($GroupTitle, $Year, $Body, $TagList) = $DB->next_record();
  46. $TagList = str_replace('_', '.', $TagList);
  47. /*
  48. $DB->query("
  49. SELECT ID, Format, Encoding, HasLog, HasCue, LogScore, Media, Scene, FreeTorrent, UserID
  50. FROM torrents
  51. WHERE GroupID = $PageID");
  52. */
  53. $DB->query("
  54. SELECT ID, Media, FreeTorrent, UserID
  55. FROM torrents
  56. WHERE GroupID = $PageID");
  57. // RSS feed stuff
  58. while ($Torrent = $DB->next_record()) {
  59. $Title = $GroupTitle;
  60. list($TorrentID, $Media, $Freeleech, $UploaderID) = $Torrent;
  61. $Title .= " [$Year] - ";
  62. $Title .= "$Format / $Bitrate";
  63. if ($HasLog == "'1'") {
  64. $Title .= ' / Log';
  65. }
  66. if ($HasLog) {
  67. $Title .= " / $LogScore%";
  68. }
  69. if ($HasCue == "'1'") {
  70. $Title .= ' / Cue';
  71. }
  72. $Title .= ' / '.trim($Media);
  73. if ($Scene == '1') {
  74. $Title .= ' / Scene';
  75. }
  76. if ($Freeleech == '1') {
  77. $Title .= ' / Freeleech!';
  78. }
  79. if ($Freeleech == '2') {
  80. $Title .= ' / Neutral leech!';
  81. }
  82. $UploaderInfo = Users::user_info($UploaderID);
  83. $Item = $Feed->item($Title,
  84. Text::strip_bbcode($Body),
  85. 'torrents.php?action=download&amp;authkey=[[AUTHKEY]]&amp;torrent_pass=[[PASSKEY]]&amp;id='.$TorrentID,
  86. $UploaderInfo['Username'],
  87. "torrents.php?id=$PageID",
  88. trim($TagList));
  89. $Feed->populate('torrents_bookmarks_t_'.$LoggedUser['torrent_pass'], $Item);
  90. }
  91. } elseif ($Type == 'request') {
  92. $DB->query("
  93. SELECT UserID
  94. FROM $Table
  95. WHERE $Col = '".db_string($PageID)."'");
  96. if ($DB->record_count() < 100) {
  97. // Sphinx doesn't like huge MVA updates. Update sphinx_requests_delta
  98. // and live with the <= 1 minute delay if we have more than 100 bookmarkers
  99. $Bookmarkers = implode(',', $DB->collect('UserID'));
  100. $SphQL = new SphinxqlQuery();
  101. $SphQL->raw_query("UPDATE requests, requests_delta SET bookmarker = ($Bookmarkers) WHERE id = $PageID");
  102. } else {
  103. Requests::update_sphinx_requests($PageID);
  104. }
  105. }
  106. }