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.

request.php 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <?php
  2. #declare(strict_types = 1);
  3. /*
  4. * This is the page that displays the request to the end user after being created.
  5. */
  6. if (empty($_GET['id']) || !is_number($_GET['id'])) {
  7. error(0);
  8. }
  9. $RequestID = $_GET['id'];
  10. // First things first, let's get the data for the request
  11. $Request = Requests::get_request($RequestID);
  12. if ($Request === false) {
  13. error(404);
  14. }
  15. // Convenience variables
  16. $IsFilled = !empty($Request['TorrentID']);
  17. $CanVote = !$IsFilled && check_perms('site_vote');
  18. if ($Request['CategoryID'] === '0') {
  19. $CategoryName = 'Unknown';
  20. } else {
  21. $CategoryName = $Categories[$Request['CategoryID'] - 1];
  22. }
  23. $Title = empty($Request['Title']) ? (empty($Request['Title2']) ? $Request['TitleJP'] : $Request['Title2']) : $Request['Title'];
  24. // Do we need to get artists?
  25. $ArtistForm = Requests::get_artists($RequestID);
  26. $ArtistName = Artists::display_artists($ArtistForm, false, true);
  27. $ArtistLink = Artists::display_artists($ArtistForm, true, true);
  28. if ($IsFilled) {
  29. $DisplayLink = "<a href='torrents.php?torrentid=$Request[TorrentID]' dir='ltr'>$Title</a>";
  30. #$DisplayLink = "$ArtistLink<a href='torrents.php?torrentid=$Request[TorrentID]' dir='ltr'>$Title</a>";
  31. } else {
  32. $DisplayLink = '<span dir="ltr">'.$Title."</span>";
  33. #$DisplayLink = $ArtistLink.'<span dir="ltr">'.$Title."</span>";
  34. }
  35. $Extra = "";
  36. if (!empty($Request['Title2']) && $Request['Title2'] != $Title) {
  37. $Extra .= '<br />' . $Request['Title2'];
  38. }
  39. if (!empty($Request['TitleJP']) && $Request['TitleJP'] != $Title) {
  40. $Extra .= '<br />' . $Request['TitleJP'];
  41. }
  42. if (!empty($Request['CatalogueNumber'])) {
  43. $Extra .= "<br />[$Request[CatalogueNumber]]";
  44. }
  45. $DisplayLink .= $Extra;
  46. // Votes time
  47. $RequestVotes = Requests::get_votes_array($RequestID);
  48. $VoteCount = count($RequestVotes['Voters']);
  49. $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && ($Request['CategoryID'] === '0' || ($CategoryName === 'Music' && $Request['Year'] === '0')));
  50. $UserCanEdit = (!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2);
  51. $CanEdit = ($UserCanEdit || $ProjectCanEdit || check_perms('site_moderate_requests'));
  52. // Comments (must be loaded before View::show_header so that subscriptions and quote notifications are handled properly)
  53. list($NumComments, $Page, $Thread, $LastRead) = Comments::load('requests', $RequestID);
  54. View::show_header(
  55. "View request: $Title",
  56. 'comments,requests,bbcode,subscriptions,vendor/easymde.min',
  57. 'vendor/easymde.min'
  58. );
  59. ?>
  60. <div>
  61. <div class="header">
  62. <h2><a href="requests.php">Requests</a> &rsaquo; <?=$CategoryName?> &rsaquo;
  63. <?=$DisplayLink?>
  64. </h2>
  65. <div class="linkbox">
  66. <?php if ($CanEdit) { ?>
  67. <a href="requests.php?action=edit&amp;id=<?=$RequestID?>"
  68. class="brackets">Edit</a>
  69. <?php }
  70. if ($UserCanEdit || check_perms('users_mod')) { //check_perms('site_moderate_requests')) {?>
  71. <a href="requests.php?action=delete&amp;id=<?=$RequestID?>"
  72. class="brackets">Delete</a>
  73. <?php }
  74. if (Bookmarks::has_bookmarked('request', $RequestID)) { ?>
  75. <a href="#" id="bookmarklink_request_<?=$RequestID?>"
  76. onclick="Unbookmark('request', <?=$RequestID?>, 'Bookmark'); return false;"
  77. class="brackets">Remove bookmark</a>
  78. <?php } else { ?>
  79. <a href="#" id="bookmarklink_request_<?=$RequestID?>"
  80. onclick="Bookmark('request', <?=$RequestID?>, 'Remove bookmark'); return false;"
  81. class="brackets">Bookmark</a>
  82. <?php } ?>
  83. <a href="#" id="subscribelink_requests<?=$RequestID?>"
  84. class="brackets"
  85. onclick="SubscribeComments('requests',<?=$RequestID?>);return false;"><?=Subscriptions::has_subscribed_comments('requests', $RequestID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
  86. <a href="reports.php?action=report&amp;type=request&amp;id=<?=$RequestID?>"
  87. class="brackets">Report request</a>
  88. <?php if (!$IsFilled) { ?>
  89. <a href="upload.php?requestid=<?=$RequestID?><?=($Request['GroupID'] ? "&amp;groupid=$Request[GroupID]" : '')?>"
  90. class="brackets">Upload request</a>
  91. <?php }
  92. if (!$IsFilled && ($Request['CategoryID'] === '0' || ($CategoryName === 'Music' && $Request['Year'] === '0'))) { ?>
  93. <a href="reports.php?action=report&amp;type=request_update&amp;id=<?=$RequestID?>"
  94. class="brackets">Request update</a>
  95. <?php } ?>
  96. <?php
  97. // Create a search URL to WorldCat and Google based on title
  98. $encoded_title = urlencode(preg_replace("/\([^\)]+\)/", '', $Request['Title']));
  99. $encoded_artist = substr(str_replace('&amp;', 'and', $ArtistName), 0, -3);
  100. $encoded_artist = str_ireplace('Performed By', '', $encoded_artist);
  101. $encoded_artist = preg_replace("/\([^\)]+\)/", '', $encoded_artist);
  102. $encoded_artist = urlencode($encoded_artist);
  103. ?>
  104. </div>
  105. </div>
  106. <div class="sidebar">
  107. <?php if ($Request['CategoryID'] !== '0') { ?>
  108. <div class="box box_image box_image_albumart box_albumart">
  109. <!-- .box_albumart deprecated -->
  110. <div class="head"><strong>Picture</strong></div>
  111. <div id="covers">
  112. <?php
  113. if (!empty($Request['Image'])) {
  114. ?>
  115. <img style="width: 100%;"
  116. src="<?=ImageTools::process($Request['Image'], 'thumb')?>"
  117. lightbox-img="<?=ImageTools::process($Request['Image'])?>"
  118. alt="<?=$Title?>" class="lightbox-init" />
  119. <?php
  120. } else { ?>
  121. <img style="width: 100%;"
  122. src="<?=STATIC_SERVER?>common/noartwork/music.png"
  123. alt="<?=$CategoryName?>" class="tooltip"
  124. title="<?=$CategoryName?>" height="220" border="0" />
  125. <?php } ?>
  126. </div>
  127. </div>
  128. <?php
  129. }
  130. $ArtistVariant = "Author(s)";
  131. /*
  132. switch ($CategoryName) {
  133. case "Movies":
  134. $ArtistVariant = "Idols";
  135. break;
  136. case "Anime":
  137. $ArtistVariant = "Studios";
  138. break;
  139. case "Manga":
  140. $ArtistVariant = "Artists";
  141. break;
  142. case "Games":
  143. $ArtistVariant = "Developers";
  144. break;
  145. case "Other":
  146. $ArtistVariant = "Creators";
  147. break;
  148. default:
  149. $ArtistVariant = "Artists";
  150. }
  151. */
  152. ?>
  153. <div class="box box_artists">
  154. <div class="head"><strong><?= $ArtistVariant ?></strong></div>
  155. <ul class="stats nobullet">
  156. <?php foreach ($ArtistForm as $Artist) { ?>
  157. <li class="artist">
  158. <?= Artists::display_artist($Artist) ?>
  159. </li>
  160. <?php } ?>
  161. </ul>
  162. </div>
  163. <div class="box box_tags">
  164. <div class="head"><strong>Tags</strong></div>
  165. <ul class="stats nobullet">
  166. <?php foreach ($Request['Tags'] as $TagID => $TagName) {
  167. $Split = Tags::get_name_and_class($TagName); ?>
  168. <li>
  169. <a class="<?= $Split['class']?>"
  170. href="torrents.php?taglist=<?=$TagName?>"><?=display_str($Split['name']) ?></a>
  171. <br style="clear: both;" />
  172. </li>
  173. <?php
  174. } ?>
  175. </ul>
  176. </div>
  177. <div class="box box_votes">
  178. <div class="head"><strong>Top Contributors</strong></div>
  179. <table class="layout" id="request_top_contrib">
  180. <?php
  181. $VoteMax = ($VoteCount < 5 ? $VoteCount : 5);
  182. $ViewerVote = false;
  183. for ($i = 0; $i < $VoteMax; $i++) {
  184. $User = array_shift($RequestVotes['Voters']);
  185. $Boldify = false;
  186. if ($User['UserID'] === $LoggedUser['ID']) {
  187. $ViewerVote = true;
  188. $Boldify = true;
  189. } ?>
  190. <tr>
  191. <td>
  192. <a
  193. href="user.php?id=<?= $User['UserID'] ?>"><?= ($Boldify ? '<strong>' : '') . display_str($User['Username']) . ($Boldify ? '</strong>' : '') ?></a>
  194. </td>
  195. <td class="number_column">
  196. <?= ($Boldify ? '<strong>' : '') . Format::get_size($User['Bounty']) . ($Boldify ? "</strong>\n" : "\n") ?>
  197. </td>
  198. </tr>
  199. <?php
  200. }
  201. reset($RequestVotes['Voters']);
  202. if (!$ViewerVote) {
  203. foreach ($RequestVotes['Voters'] as $User) {
  204. if ($User['UserID'] === $LoggedUser['ID']) { ?>
  205. <tr>
  206. <td>
  207. <a
  208. href="user.php?id=<?= $User['UserID'] ?>"><strong><?= display_str($User['Username']) ?></strong></a>
  209. </td>
  210. <td class="number_column">
  211. <strong><?= Format::get_size($User['Bounty']) ?></strong>
  212. </td>
  213. </tr>
  214. <?php }
  215. }
  216. }
  217. ?>
  218. </table>
  219. </div>
  220. </div>
  221. <div class="main_column">
  222. <div class="box">
  223. <div class="head"><strong>Info</strong></div>
  224. <div class="pad">
  225. <table class="layout request_form">
  226. <tr>
  227. <td class="label">Created</td>
  228. <td>
  229. <?= time_diff($Request['TimeAdded']) ?> by
  230. <strong><?= Users::format_username($Request['UserID'], false, false, false) ?></strong>
  231. </td>
  232. </tr>
  233. <?php if ($CategoryName == 'Movies') {
  234. if (!empty($Request['CatalogueNumber'])) { ?>
  235. <tr>
  236. <td class="label">Catalogue number</td>
  237. <td><?= $Request['CatalogueNumber'] ?>
  238. </td>
  239. </tr>
  240. <?php
  241. }
  242. }
  243. /*
  244. $Worldcat = '';
  245. $OCLC = str_replace(' ', '', $Request['OCLC']);
  246. if ($OCLC !== '') {
  247. $OCLCs = explode(',', $OCLC);
  248. for ($i = 0; $i < count($OCLCs); $i++) {
  249. if (!empty($Worldcat)) {
  250. $Worldcat .= ', <a href="https://www.worldcat.org/oclc/'.$OCLCs[$i].'">'.$OCLCs[$i].'</a>';
  251. } else {
  252. $Worldcat = '<a href="https://www.worldcat.org/oclc/'.$OCLCs[$i].'">'.$OCLCs[$i].'</a>';
  253. }
  254. }
  255. }
  256. if (!empty($Worldcat)) {
  257. ?>
  258. <tr>
  259. <td class="label">WorldCat (OCLC) ID</td>
  260. <td><?=$Worldcat?>
  261. </td>
  262. </tr>
  263. <?
  264. }
  265. */
  266. if ($Request['GroupID']) {
  267. ?>
  268. <tr>
  269. <td class="label">Torrent Group</td>
  270. <td><a
  271. href="torrents.php?id=<?= $Request['GroupID'] ?>">torrents.php?id=<?= $Request['GroupID'] ?></a></td>
  272. </tr>
  273. <?php
  274. } ?>
  275. <tr>
  276. <td class="label">Votes</td>
  277. <td>
  278. <span id="votecount"><?= number_format($VoteCount) ?></span>
  279. <?php if ($CanVote) { ?>
  280. &nbsp;&nbsp;<a href="javascript:Vote(0)" class="brackets"><strong>+</strong></a>
  281. <strong>Costs <?= Format::get_size($MinimumVote, 0) ?></strong>
  282. <?php } ?>
  283. </td>
  284. </tr>
  285. <?php if ($Request['LastVote'] > $Request['TimeAdded']) { ?>
  286. <tr>
  287. <td class="label">Last Voted</td>
  288. <td><?= time_diff($Request['LastVote']) ?>
  289. </td>
  290. </tr>
  291. <?php
  292. }
  293. if ($CanVote) {
  294. ?>
  295. <tr id="voting">
  296. <td class="label">Custom Vote</td>
  297. <td>
  298. These units are in base 2, not base 10, e.g., there are 1,024 MiB in 1 GiB.
  299. <strong>The system deducts <?= ($RequestTax * 100) ?>% as tax.</strong>
  300. <br />
  301. <input type="text" id="amount_box" size="8" onchange="Calculate();" />
  302. <select id="unit" name="unit" onchange="Calculate();">
  303. <option value="mb">MiB</option>
  304. <option value="gb">GiB</option>
  305. </select>
  306. <input type="button" value="Preview" onclick="Calculate();" />
  307. </td>
  308. </tr>
  309. <tr>
  310. <td class="label">New Stats</td>
  311. <td>
  312. <form class="add_form" name="request" action="requests.php" method="get" id="request_form">
  313. <input type="hidden" name="action" value="vote" />
  314. <input type="hidden" name="auth"
  315. value="<?=$LoggedUser['AuthKey']?>" />
  316. <input type="hidden" id="request_tax"
  317. value="<?=$RequestTax?>" />
  318. <input type="hidden" id="requestid" name="id"
  319. value="<?=$RequestID?>" />
  320. <input type="hidden" id="auth" name="auth"
  321. value="<?=$LoggedUser['AuthKey']?>" />
  322. <input type="hidden" id="amount" name="amount" value="0" />
  323. <input type="hidden" id="current_uploaded"
  324. value="<?=$LoggedUser['BytesUploaded']?>" />
  325. <input type="hidden" id="current_downloaded"
  326. value="<?=$LoggedUser['BytesDownloaded']?>" />
  327. <input type="hidden" id="current_rr"
  328. value="<?=(float)$LoggedUser['RequiredRatio']?>" />
  329. <input id="total_bounty" type="hidden"
  330. value="<?=$RequestVotes['TotalBounty']?>" />
  331. <ul>
  332. <!-- todo: Return this feature
  333. <li><strong>Bounty:</strong> <span id="bounty_after_tax">0.00 MiB</span></li> -->
  334. <li><strong>Uploaded:</strong> <span id="new_uploaded"><?= Format::get_size($LoggedUser['BytesUploaded']) ?></span>
  335. </li>
  336. <li><strong>Ratio:</strong> <span id="new_ratio"><?= Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded']) ?></span>
  337. </li>
  338. </ul>
  339. <input type="button" id="button" value="Vote!" disabled="disabled" onclick="Vote();" />
  340. </form>
  341. </td>
  342. </tr>
  343. <?php
  344. } ?>
  345. <tr id="bounty">
  346. <td class="label">Bounty</td>
  347. <td id="formatted_bounty"><?=Format::get_size($RequestVotes['TotalBounty'])?>
  348. </td>
  349. </tr>
  350. <?php
  351. if ($IsFilled) {
  352. $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18?>
  353. <tr>
  354. <td class="label">Filled</td>
  355. <td>
  356. <strong><a
  357. href="torrents.php?<?=(strtotime($Request['TimeFilled']) < $TimeCompare ? 'id=' : 'torrentid=') . $Request['TorrentID']?>">Yes</a></strong>,
  358. by user <?=($Request['AnonymousFill'] ? '<em>Anonymous</em>' : Users::format_username($Request['FillerID'], false, false, false))?>
  359. <?php if ($LoggedUser['ID'] == $Request['UserID'] || $LoggedUser['ID'] == $Request['FillerID'] || check_perms('site_moderate_requests')) { ?>
  360. <strong><a
  361. href="requests.php?action=unfill&amp;id=<?=$RequestID?>"
  362. class="brackets">Unfill</a></strong> Unfilling a request without a valid, nontrivial reason will
  363. result in a warning.
  364. <?php } ?>
  365. </td>
  366. </tr>
  367. <?php
  368. } else { ?>
  369. <tr>
  370. <td class="label" valign="top">Fill Request</td>
  371. <td>
  372. <form class="edit_form" name="request" action="" method="post">
  373. <div>
  374. <input type="hidden" name="action" value="takefill" />
  375. <input type="hidden" name="auth"
  376. value="<?=$LoggedUser['AuthKey']?>" />
  377. <input type="hidden" name="requestid"
  378. value="<?=$RequestID?>" />
  379. <input type="text" size="50" name="link" <?=(!empty($Link) ? " value='$Link'" : '')?>
  380. />
  381. <br />
  382. <strong>Should be the permalink [PL] of the torrent</strong>
  383. </div>
  384. <?php if (check_perms('site_moderate_requests')) { ?>
  385. <div>
  386. <strong>For User</strong> <input type="text" size="25" name="user" <?= (!empty($FillerUsername) ? " value='$FillerUsername'" : '') ?>
  387. />
  388. </div>
  389. <?php } ?>
  390. <div class="submit_div">
  391. <input type="submit" value="Fill" />
  392. </div>
  393. </form>
  394. </td>
  395. </tr>
  396. <?php } ?>
  397. </table>
  398. </div>
  399. </div>
  400. <div class="box box_request_desc">
  401. <div class="head"><strong>Description</strong></div>
  402. <div class="pad">
  403. <?= Text::full_format($Request['Description']);?>
  404. </div>
  405. </div>
  406. <div id="request_comments">
  407. <div class="linkbox">
  408. <a name="comments"></a>
  409. <?php
  410. $Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9, '#comments');
  411. echo $Pages;
  412. ?>
  413. </div>
  414. <?php
  415. //---------- Begin printing
  416. CommentsView::render_comments($Thread, $LastRead, "requests.php?action=view&amp;id=$RequestID");
  417. if ($Pages) { ?>
  418. <div class="linkbox pager"><?=$Pages?>
  419. </div>
  420. <?php
  421. }
  422. View::parse('generic/reply/quickreply.php', array(
  423. 'InputName' => 'pageid',
  424. 'InputID' => $RequestID,
  425. 'Action' => 'comments.php?page=requests',
  426. 'InputAction' => 'take_post',
  427. 'SubscribeBox' => true
  428. ));
  429. ?>
  430. </div>
  431. </div>
  432. </div>
  433. <?php View::show_footer();