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.

request.php 15KB

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