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 15KB

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