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

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