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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. $Split = Tags::get_name_and_class($TagName);
  145. ?>
  146. <li>
  147. <a class="<?=$Split['class']?>" href="torrents.php?taglist=<?=$TagName?>"><?=display_str($Split['name'])?></a>
  148. <br style="clear: both;" />
  149. </li>
  150. <? } ?>
  151. </ul>
  152. </div>
  153. <div class="box box_votes">
  154. <div class="head"><strong>Top Contributors</strong></div>
  155. <table class="layout" id="request_top_contrib">
  156. <?
  157. $VoteMax = ($VoteCount < 5 ? $VoteCount : 5);
  158. $ViewerVote = false;
  159. for ($i = 0; $i < $VoteMax; $i++) {
  160. $User = array_shift($RequestVotes['Voters']);
  161. $Boldify = false;
  162. if ($User['UserID'] === $LoggedUser['ID']) {
  163. $ViewerVote = true;
  164. $Boldify = true;
  165. }
  166. ?>
  167. <tr>
  168. <td>
  169. <a href="user.php?id=<?=$User['UserID']?>"><?=($Boldify ? '<strong>' : '') . display_str($User['Username']) . ($Boldify ? '</strong>' : '')?></a>
  170. </td>
  171. <td class="number_column">
  172. <?=($Boldify ? '<strong>' : '') . Format::get_size($User['Bounty']) . ($Boldify ? "</strong>\n" : "\n")?>
  173. </td>
  174. </tr>
  175. <? }
  176. reset($RequestVotes['Voters']);
  177. if (!$ViewerVote) {
  178. foreach ($RequestVotes['Voters'] as $User) {
  179. if ($User['UserID'] === $LoggedUser['ID']) { ?>
  180. <tr>
  181. <td>
  182. <a href="user.php?id=<?=$User['UserID']?>"><strong><?=display_str($User['Username'])?></strong></a>
  183. </td>
  184. <td class="number_column">
  185. <strong><?=Format::get_size($User['Bounty'])?></strong>
  186. </td>
  187. </tr>
  188. <? }
  189. }
  190. }
  191. ?>
  192. </table>
  193. </div>
  194. </div>
  195. <div class="main_column">
  196. <div class="box">
  197. <div class="head"><strong>Information</strong></div>
  198. <div class="pad">
  199. <table class="layout">
  200. <tr>
  201. <td class="label">Created</td>
  202. <td>
  203. <?=time_diff($Request['TimeAdded'])?> by <strong><?=Users::format_username($Request['UserID'], false, false, false)?></strong>
  204. </td>
  205. </tr>
  206. <? if ($CategoryName == 'Movies') {
  207. if (!empty($Request['CatalogueNumber'])) { ?>
  208. <tr>
  209. <td class="label">Catalogue number</td>
  210. <td><?=$Request['CatalogueNumber']?></td>
  211. </tr>
  212. <?
  213. }
  214. } elseif ($CategoryName == 'Games') {
  215. if (!empty($Request['DLSiteID'])) { ?>
  216. <tr>
  217. <td class="label">DLSite ID</td>
  218. <td><?=$Request['DLSiteID']?></td>
  219. </tr>
  220. <? }
  221. }
  222. /*
  223. $Worldcat = '';
  224. $OCLC = str_replace(' ', '', $Request['OCLC']);
  225. if ($OCLC !== '') {
  226. $OCLCs = explode(',', $OCLC);
  227. for ($i = 0; $i < count($OCLCs); $i++) {
  228. if (!empty($Worldcat)) {
  229. $Worldcat .= ', <a href="https://www.worldcat.org/oclc/'.$OCLCs[$i].'">'.$OCLCs[$i].'</a>';
  230. } else {
  231. $Worldcat = '<a href="https://www.worldcat.org/oclc/'.$OCLCs[$i].'">'.$OCLCs[$i].'</a>';
  232. }
  233. }
  234. }
  235. if (!empty($Worldcat)) {
  236. ?>
  237. <tr>
  238. <td class="label">WorldCat (OCLC) ID</td>
  239. <td><?=$Worldcat?></td>
  240. </tr>
  241. <?
  242. }
  243. */
  244. if ($Request['GroupID']) {
  245. ?>
  246. <tr>
  247. <td class="label">Torrent group</td>
  248. <td><a href="torrents.php?id=<?=$Request['GroupID']?>">torrents.php?id=<?=$Request['GroupID']?></a></td>
  249. </tr>
  250. <? } ?>
  251. <tr>
  252. <td class="label">Votes</td>
  253. <td>
  254. <span id="votecount"><?=number_format($VoteCount)?></span>
  255. <? if ($CanVote) { ?>
  256. &nbsp;&nbsp;<a href="javascript:Vote(0)" class="brackets"><strong>+</strong></a>
  257. <strong>Costs <?=Format::get_size($MinimumVote, 0)?></strong>
  258. <? } ?>
  259. </td>
  260. </tr>
  261. <? if ($Request['LastVote'] > $Request['TimeAdded']) { ?>
  262. <tr>
  263. <td class="label">Last voted</td>
  264. <td><?=time_diff($Request['LastVote'])?></td>
  265. </tr>
  266. <?
  267. }
  268. if ($CanVote) {
  269. ?>
  270. <tr id="voting">
  271. <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>
  272. <td>
  273. <input type="text" id="amount_box" size="8" onchange="Calculate();" />
  274. <select id="unit" name="unit" onchange="Calculate();">
  275. <option value="mb">MiB</option>
  276. <option value="gb">GiB</option>
  277. </select>
  278. <input type="button" value="Preview" onclick="Calculate();" />
  279. <strong><?=($RequestTax * 100)?>% of this is deducted as tax by the system.</strong>
  280. </td>
  281. </tr>
  282. <tr>
  283. <td class="label">Post vote information</td>
  284. <td>
  285. <form class="add_form" name="request" action="requests.php" method="get" id="request_form">
  286. <input type="hidden" name="action" value="vote" />
  287. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  288. <input type="hidden" id="request_tax" value="<?=$RequestTax?>" />
  289. <input type="hidden" id="requestid" name="id" value="<?=$RequestID?>" />
  290. <input type="hidden" id="auth" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  291. <input type="hidden" id="amount" name="amount" value="0" />
  292. <input type="hidden" id="current_uploaded" value="<?=$LoggedUser['BytesUploaded']?>" />
  293. <input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
  294. <input type="hidden" id="current_rr" value="<?=(float)$LoggedUser['RequiredRatio']?>" />
  295. <input id="total_bounty" type="hidden" value="<?=$RequestVotes['TotalBounty']?>" />
  296. Bounty after tax: <strong><span id="bounty_after_tax">0.00 MiB</span></strong><br />
  297. If you add the entered <strong><span id="new_bounty">0.00 MiB</span></strong> of bounty, your new stats will be: <br />
  298. Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
  299. Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'],$LoggedUser['BytesDownloaded'])?></span>
  300. <input type="button" id="button" value="Vote!" disabled="disabled" onclick="Vote();" />
  301. </form>
  302. </td>
  303. </tr>
  304. <? } ?>
  305. <tr id="bounty">
  306. <td class="label">Bounty</td>
  307. <td id="formatted_bounty"><?=Format::get_size($RequestVotes['TotalBounty'])?></td>
  308. </tr>
  309. <?
  310. if ($IsFilled) {
  311. $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
  312. ?>
  313. <tr>
  314. <td class="label">Filled</td>
  315. <td>
  316. <strong><a href="torrents.php?<?=(strtotime($Request['TimeFilled']) < $TimeCompare ? 'id=' : 'torrentid=') . $Request['TorrentID']?>">Yes</a></strong>,
  317. by user <?=Users::format_username($Request['FillerID'], false, false, false)?>
  318. <? if ($LoggedUser['ID'] == $Request['UserID'] || $LoggedUser['ID'] == $Request['FillerID'] || check_perms('site_moderate_requests')) { ?>
  319. <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.
  320. <? } ?>
  321. </td>
  322. </tr>
  323. <? } else { ?>
  324. <tr>
  325. <td class="label" valign="top">Fill request</td>
  326. <td>
  327. <form class="edit_form" name="request" action="" method="post">
  328. <div class="field_div">
  329. <input type="hidden" name="action" value="takefill" />
  330. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  331. <input type="hidden" name="requestid" value="<?=$RequestID?>" />
  332. <input type="text" size="50" name="link"<?=(!empty($Link) ? " value=\"$Link\"" : '')?> />
  333. <br />
  334. <strong>Should be the permalink (PL) to the torrent (e.g. <?=site_url()?>torrents.php?torrentid=xxxx).</strong>
  335. </div>
  336. <? if (check_perms('site_moderate_requests')) { ?>
  337. <div class="field_div">
  338. For user: <input type="text" size="25" name="user"<?=(!empty($FillerUsername) ? " value=\"$FillerUsername\"" : '')?> />
  339. </div>
  340. <? } ?>
  341. <div class="submit_div">
  342. <input type="submit" value="Fill request" />
  343. </div>
  344. </form>
  345. </td>
  346. </tr>
  347. <? } ?>
  348. </table>
  349. </div>
  350. </div>
  351. <div class="box box2 box_request_desc">
  352. <div class="head"><strong>Description</strong></div>
  353. <div class="pad">
  354. <?= Text::full_format($Request['Description']);?>
  355. </div>
  356. </div>
  357. <div id="request_comments">
  358. <div class="linkbox">
  359. <a name="comments"></a>
  360. <?
  361. $Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9, '#comments');
  362. echo $Pages;
  363. ?>
  364. </div>
  365. <?
  366. //---------- Begin printing
  367. CommentsView::render_comments($Thread, $LastRead, "requests.php?action=view&amp;id=$RequestID");
  368. if ($Pages) { ?>
  369. <div class="linkbox pager"><?=$Pages?></div>
  370. <?
  371. }
  372. View::parse('generic/reply/quickreply.php', array(
  373. 'InputName' => 'pageid',
  374. 'InputID' => $RequestID,
  375. 'Action' => 'comments.php?page=requests',
  376. 'InputAction' => 'take_post',
  377. 'SubscribeBox' => true
  378. ));
  379. ?>
  380. </div>
  381. </div>
  382. </div>
  383. <? View::show_footer(); ?>