BioTorrents.de’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.

delete.php 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <?
  2. #declare(strict_types = 1);
  3. $TorrentID = $_GET['torrentid'];
  4. if (!$TorrentID || !is_number($TorrentID)) {
  5. error(404);
  6. }
  7. $DB->query("
  8. SELECT
  9. t.UserID,
  10. t.Time,
  11. COUNT(x.uid)
  12. FROM torrents AS t
  13. LEFT JOIN xbt_snatched AS x ON x.fid = t.ID
  14. WHERE t.ID = $TorrentID
  15. GROUP BY t.UserID");
  16. if (!$DB->has_results()) {
  17. error('Torrent already deleted.');
  18. }
  19. if ($Cache->get_value('torrent_'.$TorrentID.'_lock')) {
  20. error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
  21. }
  22. list($UserID, $Time, $Snatches) = $DB->next_record();
  23. if ($LoggedUser['ID'] != $UserID && !check_perms('torrents_delete')) {
  24. error(403);
  25. }
  26. if (isset($_SESSION['logged_user']['multi_delete']) && $_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
  27. error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.');
  28. }
  29. if (time_ago($Time) > 3600 * 24 * 7 && !check_perms('torrents_delete')) { // Should this be torrents_delete or torrents_delete_fast?
  30. error('You can no longer delete this torrent as it has been uploaded for over a week. If you now think there is a problem, please report the torrent instead.');
  31. }
  32. if ($Snatches > 4 && !check_perms('torrents_delete')) { // Should this be torrents_delete or torrents_delete_fast?
  33. error('You can no longer delete this torrent as it has been snatched by 5 or more users. If you believe there is a problem with this torrent, please report it instead.');
  34. }
  35. View::show_header('Delete torrent', 'reportsv2');
  36. ?>
  37. <div>
  38. <div class="box" style="width: 600px; margin-left: auto; margin-right: auto;">
  39. <div class="head colhead">
  40. Delete torrent
  41. </div>
  42. <div class="pad">
  43. <form class="delete_form" name="torrent" action="torrents.php" method="post">
  44. <input type="hidden" name="action" value="takedelete" />
  45. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  46. <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
  47. <div>
  48. <strong>Reason: </strong>
  49. <select name="reason">
  50. <option value="Dead">Dead</option>
  51. <option value="Dupe">Dupe</option>
  52. <option value="Trumped">Trumped</option>
  53. <option value="Rules Broken">Rules broken</option>
  54. <option value="" selected="selected">Other</option>
  55. </select>
  56. </div>
  57. <div>
  58. <strong>Extra info: </strong>
  59. <input type="text" name="extra" size="30" />
  60. <input value="Delete" type="submit" />
  61. </div>
  62. </form>
  63. </div>
  64. </div>
  65. </div>
  66. <?
  67. if (check_perms('admin_reports')) {
  68. ?>
  69. <div id="all_reports" style="width: 80%; margin-left: auto; margin-right: auto;">
  70. <?
  71. include(SERVER_ROOT.'/classes/reports.class.php');
  72. require(SERVER_ROOT.'/sections/reportsv2/array.php');
  73. $ReportID = 0;
  74. /*
  75. $DB->query("
  76. SELECT
  77. tg.Name,
  78. tg.ID,
  79. CASE COUNT(ta.GroupID)
  80. WHEN 1 THEN aa.ArtistID
  81. WHEN 0 THEN '0'
  82. ELSE '0'
  83. END AS ArtistID,
  84. CASE COUNT(ta.GroupID)
  85. WHEN 1 THEN aa.Name
  86. WHEN 0 THEN ''
  87. ELSE 'Various Artists'
  88. END AS ArtistName,
  89. tg.Year,
  90. tg.CategoryID,
  91. t.Time,
  92. t.Remastered,
  93. t.RemasterTitle,
  94. t.RemasterYear,
  95. t.Media,
  96. t.Format,
  97. t.Encoding,
  98. t.Size,
  99. t.HasLog,
  100. t.LogScore,
  101. t.UserID AS UploaderID,
  102. uploader.Username
  103. FROM torrents AS t
  104. LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
  105. LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID AND ta.Importance = '1'
  106. LEFT JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
  107. LEFT JOIN users_main AS uploader ON uploader.ID = t.UserID
  108. WHERE t.ID = $TorrentID");
  109. */
  110. $DB->query("
  111. SELECT
  112. tg.Name,
  113. tg.ID,
  114. CASE COUNT(ta.GroupID)
  115. WHEN 1 THEN ag.ArtistID
  116. WHEN 0 THEN '0'
  117. ELSE '0'
  118. END AS ArtistID,
  119. CASE COUNT(ta.GroupID)
  120. WHEN 1 THEN ag.Name
  121. WHEN 0 THEN ''
  122. ELSE 'Various Artists'
  123. END AS ArtistName,
  124. tg.Year,
  125. tg.CategoryID,
  126. t.Time,
  127. t.Media,
  128. t.Size,
  129. t.UserID AS UploaderID,
  130. uploader.Username
  131. FROM torrents AS t
  132. LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
  133. LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
  134. LEFT JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
  135. LEFT JOIN users_main AS uploader ON uploader.ID = t.UserID
  136. WHERE t.ID = $TorrentID");
  137. if (!$DB->has_results()) {
  138. error();
  139. }
  140. list($GroupName, $GroupID, $ArtistID, $ArtistName, $Year, $CategoryID, $Time,
  141. $Media, $Size, $UploaderID, $UploaderName) = $DB->next_record();
  142. $Type = 'dupe'; //hardcoded default
  143. if (array_key_exists($Type, $Types[$CategoryID])) {
  144. $ReportType = $Types[$CategoryID][$Type];
  145. } elseif (array_key_exists($Type,$Types['master'])) {
  146. $ReportType = $Types['master'][$Type];
  147. } else {
  148. //There was a type but it wasn't an option!
  149. $Type = 'other';
  150. $ReportType = $Types['master']['other'];
  151. }
  152. $RemasterDisplayString = Reports::format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear);
  153. if ($ArtistID == 0 && empty($ArtistName)) {
  154. $RawName = $GroupName.($Year ? " ($Year)" : '').($Format || $Encoding || $Media ? " [$Format/$Encoding/$Media]" : '') . $RemasterDisplayString . ($HasLog ? " ({$LogScore}%)" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  155. $LinkName = "<a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\">".($Format || $Encoding || $Media ? " [$Format/$Encoding/$Media]" : '') . "$RemasterDisplayString</a>" . ($HasLog ? " <a href=\"torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID\">(Log: {$LogScore}%)</a>" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  156. $BBName = "[url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]{$RemasterDisplayString}[/url] " . ($HasLog ? " [url=torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID](Log: {$LogScore}%)[/url]" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  157. } elseif ($ArtistID == 0 && $ArtistName == 'Various Artists') {
  158. $RawName = "Various Artists - $GroupName".($Year ? " ($Year)" : '')." [$Format/$Encoding/$Media]$RemasterDisplayString" . ($HasLog ? " ({$LogScore}%)" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  159. $LinkName = "Various Artists - <a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\"> [$Format/$Encoding/$Media]$RemasterDisplayString</a> ".($HasLog ? " <a href=\"torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID\">(Log: {$LogScore}%)</a>" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  160. $BBName = "Various Artists - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]{$RemasterDisplayString}[/url] ".($HasLog ? " [url=torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID](Log: {$LogScore}%)[/url]" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  161. } else {
  162. $RawName = "$ArtistName - $GroupName".($Year ? " ($Year)" : '')." [$Format/$Encoding/$Media]$RemasterDisplayString" . ($HasLog ? " ({$LogScore}%)" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  163. $LinkName = "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - <a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\"> [$Format/$Encoding/$Media]$RemasterDisplayString</a> ".($HasLog ? " <a href=\"torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID\">(Log: {$LogScore}%)</a>" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  164. $BBName = "[url=artist.php?id=$ArtistID]".$ArtistName."[/url] - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]{$RemasterDisplayString}[/url] " . ($HasLog ? " [url=torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID](Log: {$LogScore}%)[/url]" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
  165. }
  166. ?>
  167. <div id="report<?=$ReportID?>" class="report">
  168. <form class="create_form" name="report" id="reportform_<?=$ReportID?>" action="reports.php" method="post">
  169. <?
  170. /*
  171. * Some of these are for takeresolve, some for the JavaScript.
  172. */
  173. ?>
  174. <div>
  175. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  176. <input type="hidden" id="reportid<?=$ReportID?>" name="reportid" value="<?=$ReportID?>" />
  177. <input type="hidden" id="torrentid<?=$ReportID?>" name="torrentid" value="<?=$TorrentID?>" />
  178. <input type="hidden" id="uploader<?=$ReportID?>" name="uploader" value="<?=$UploaderName?>" />
  179. <input type="hidden" id="uploaderid<?=$ReportID?>" name="uploaderid" value="<?=$UploaderID?>" />
  180. <input type="hidden" id="reporterid<?=$ReportID?>" name="reporterid" value="<?=$ReporterID?>" />
  181. <input type="hidden" id="raw_name<?=$ReportID?>" name="raw_name" value="<?=$RawName?>" />
  182. <input type="hidden" id="type<?=$ReportID?>" name="type" value="<?=$Type?>" />
  183. <input type="hidden" id="categoryid<?=$ReportID?>" name="categoryid" value="<?=$CategoryID?>" />
  184. <input type="hidden" id="pm_type<?=$ReportID?>" name="pm_type" value="Uploader" />
  185. <input type="hidden" id="from_delete<?=$ReportID?>" name="from_delete" value="<?=$GroupID?>" />
  186. </div>
  187. <table cellpadding="5" class="box layout">
  188. <tr>
  189. <td class="label">Torrent:</td>
  190. <td colspan="3">
  191. <?php if (!$GroupID) { ?>
  192. <a href="log.php?search=Torrent+<?=$TorrentID?>"><?=$TorrentID?></a> (Deleted)
  193. <?php } else { ?>
  194. <?=$LinkName?>
  195. <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="brackets tooltip" title="Download">DL</a>
  196. uploaded by <a href="user.php?id=<?=$UploaderID?>"><?=$UploaderName?></a> <?=time_diff($Time)?>
  197. <br />
  198. <?php $DB->query("
  199. SELECT r.ID
  200. FROM reportsv2 AS r
  201. LEFT JOIN torrents AS t ON t.ID = r.TorrentID
  202. WHERE r.Status != 'Resolved'
  203. AND t.GroupID = $GroupID");
  204. $GroupOthers = ($DB->has_results());
  205. if ($GroupOthers > 0) { ?>
  206. <div style="text-align: right;">
  207. <a href="reportsv2.php?view=group&amp;id=<?=$GroupID?>">There <?=(($GroupOthers > 1) ? "are $GroupOthers reports" : "is 1 other report")?> for torrent(s) in this group</a>
  208. </div>
  209. <?php }
  210. $DB->query("
  211. SELECT t.UserID
  212. FROM reportsv2 AS r
  213. JOIN torrents AS t ON t.ID = r.TorrentID
  214. WHERE r.Status != 'Resolved'
  215. AND t.UserID = $UploaderID");
  216. $UploaderOthers = ($DB->has_results());
  217. if ($UploaderOthers > 0) { ?>
  218. <div style="text-align: right;">
  219. <a href="reportsv2.php?view=uploader&amp;id=<?=$UploaderID?>">There <?=(($UploaderOthers > 1) ? "are $UploaderOthers reports" : "is 1 other report")?> for torrent(s) uploaded by this user</a>
  220. </div>
  221. <?php }
  222. $DB->query("
  223. SELECT DISTINCT req.ID,
  224. req.FillerID,
  225. um.Username,
  226. req.TimeFilled
  227. FROM requests AS req
  228. JOIN users_main AS um ON um.ID = req.FillerID
  229. AND req.TorrentID = $TorrentID");
  230. $Requests = ($DB->has_results());
  231. if ($Requests > 0) {
  232. while (list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) {
  233. ?>
  234. <div style="text-align: right;">
  235. <strong class="important_text"><a href="user.php?id=<?=$FillerID?>"><?=$FillerName?></a> used this torrent to fill <a href="requests.php?action=viewrequest&amp;id=<?=$RequestID?>">this request</a> <?=time_diff($FilledTime)?></strong>
  236. </div>
  237. <?php }
  238. }
  239. }
  240. ?>
  241. </td>
  242. </tr>
  243. <?php // END REPORTED STUFF :|: BEGIN MOD STUFF ?>
  244. <tr>
  245. <td class="label">
  246. <a href="javascript:Load('<?=$ReportID?>')" class="tooltip" title="Click here to reset the resolution options to their default values.">Resolve:</a>
  247. </td>
  248. <td colspan="3">
  249. <select name="resolve_type" id="resolve_type<?=$ReportID?>" onchange="ChangeResolve(<?=$ReportID?>);">
  250. <?
  251. $TypeList = $Types['master'] + $Types[$CategoryID];
  252. $Priorities = [];
  253. foreach ($TypeList as $Key => $Value) {
  254. $Priorities[$Key] = $Value['priority'];
  255. }
  256. array_multisort($Priorities, SORT_ASC, $TypeList);
  257. foreach ($TypeList as $IType => $Data) {
  258. ?>
  259. <option value="<?=$IType?>"<?=(($Type == $IType) ? ' selected="selected"' : '')?>><?=$Data['title']?></option>
  260. <?
  261. }
  262. ?>
  263. </select>
  264. <span id="options<?=$ReportID?>">
  265. <span class="tooltip" title="Delete torrent?">
  266. <label for="delete<?=$ReportID?>"><strong>Delete</strong></label>
  267. <input type="checkbox" name="delete" id="delete<?=$ReportID?>"<?=($ReportType['resolve_options']['delete'] ? ' checked="checked"' : '')?> />
  268. </span>
  269. <span class="tooltip" title="Warning length in weeks">
  270. <label for="warning<?=$ReportID?>"><strong>Warning</strong></label>
  271. <select name="warning" id="warning<?=$ReportID?>">
  272. <?php for ($i = 0; $i < 9; $i++) { ?>
  273. <option value="<?=$i?>"<?=(($ReportType['resolve_options']['warn'] == $i) ? ' selected="selected"' : '')?>><?=$i?></option>
  274. <?php } ?>
  275. </select>
  276. </span>
  277. <span class="tooltip" title="Remove upload privileges?">
  278. <label for="upload<?=$ReportID?>"><strong>Remove upload privileges</strong></label>
  279. <input type="checkbox" name="upload" id="upload<?=$ReportID?>"<?=($ReportType['resolve_options']['upload'] ? ' checked="checked"' : '')?> />
  280. </span>
  281. </span>
  282. </td>
  283. </tr>
  284. <tr>
  285. <td class="label">PM uploader:</td>
  286. <td colspan="3">
  287. <span class="tooltip" title="Appended to the regular message unless using &quot;Send now&quot;.">
  288. <textarea name="uploader_pm" id="uploader_pm<?=$ReportID?>" cols="50" rows="1"></textarea>
  289. </span>
  290. <input type="button" value="Send now" onclick="SendPM(<?=$ReportID?>);" />
  291. </td>
  292. </tr>
  293. <tr>
  294. <td class="label"><strong>Extra</strong> log message:</td>
  295. <td>
  296. <input type="text" name="log_message" id="log_message<?=$ReportID?>" size="40" />
  297. </td>
  298. <td class="label"><strong>Extra</strong> staff notes:</td>
  299. <td>
  300. <input type="text" name="admin_message" id="admin_message<?=$ReportID?>" size="40" />
  301. </td>
  302. </tr>
  303. <tr>
  304. <td colspan="4" style="text-align: center;">
  305. <input type="button" value="Submit" onclick="TakeResolve(<?=$ReportID?>);" />
  306. </td>
  307. </tr>
  308. </table>
  309. </form>
  310. <br />
  311. </div>
  312. </div>
  313. <?
  314. }
  315. View::show_footer(); ?>