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.

torrents.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <?
  2. $Where = [];
  3. if (!empty($_GET['advanced']) && check_perms('site_advanced_top10')) {
  4. $Details = 'all';
  5. $Limit = 10;
  6. if ($_GET['tags']) {
  7. $TagWhere = [];
  8. $Tags = explode(',', str_replace('.', '_', trim($_GET['tags'])));
  9. foreach ($Tags as $Tag) {
  10. $Tag = preg_replace('/[^a-z0-9_]/', '', $Tag);
  11. if ($Tag != '') {
  12. $TagWhere[] = "g.TagList REGEXP '[[:<:]]".db_string($Tag)."[[:>:]]'";
  13. }
  14. }
  15. if (!empty($TagWhere)) {
  16. if ($_GET['anyall'] == 'any') {
  17. $Where[] = '('.implode(' OR ', $TagWhere).')';
  18. } else {
  19. $Where[] = '('.implode(' AND ', $TagWhere).')';
  20. }
  21. }
  22. }
  23. if ($_GET['category']) {
  24. if (in_array($_GET['category'], $Categories)) {
  25. $Where[] = "g.CategoryID = '".(array_search($_GET['category'], $Categories)+1)."'";
  26. }
  27. }
  28. } else {
  29. // error out on invalid requests (before caching)
  30. if (isset($_GET['details'])) {
  31. if (in_array($_GET['details'], array('day', 'week', 'overall', 'snatched', 'data', 'seeded', 'month', 'year'))) {
  32. $Details = $_GET['details'];
  33. } else {
  34. error(404);
  35. }
  36. } else {
  37. $Details = 'all';
  38. }
  39. // defaults to 10 (duh)
  40. $Limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 10);
  41. $Limit = (in_array($Limit, array(10, 100, 250)) ? $Limit : 10);
  42. }
  43. $Filtered = !empty($Where);
  44. View::show_header("Top $Limit Torrents", 'browse');
  45. ?>
  46. <div class="thin">
  47. <div class="header">
  48. <h2>Top <?=$Limit?> Torrents</h2>
  49. <? Top10View::render_linkbox("torrents"); ?>
  50. </div>
  51. <?
  52. if (check_perms('site_advanced_top10')) {
  53. ?>
  54. <div class="box pad">
  55. <form class="search_form" name="torrents" action="" method="get">
  56. <input type="hidden" name="advanced" value="1" />
  57. <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
  58. <tr id="tagfilter">
  59. <td class="label">Tags (comma-separated):</td>
  60. <td class="ft_taglist">
  61. <input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
  62. <input type="radio" id="rdoAll" name="anyall" value="all"<?=((!isset($_GET['anyall'])||$_GET['anyall']!='any')?' checked="checked"':'')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
  63. <input type="radio" id="rdoAny" name="anyall" value="any"<?=((!isset($_GET['anyall'])||$_GET['anyall']=='any')?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
  64. </td>
  65. </tr>
  66. <tr>
  67. <td class="label">Category:</td>
  68. <td>
  69. <select name="category" style="width: auto;" class="ft_format">
  70. <option value="">Any</option>
  71. <? foreach ($Categories as $CategoryName) { ?>
  72. <option value="<?=display_str($CategoryName)?>"<?=(($CategoryName==($_GET['category']??false))?'selected="selected"':'')?>><?=display_str($CategoryName)?></option>
  73. <? } ?>
  74. </select>
  75. </td>
  76. </tr>
  77. <tr>
  78. <td colspan="2" class="center">
  79. <input type="submit" value="Filter torrents" />
  80. </td>
  81. </tr>
  82. </table>
  83. </form>
  84. </div>
  85. <?
  86. }
  87. // default setting to have them shown
  88. $DisableFreeTorrentTop10 = (isset($LoggedUser['DisableFreeTorrentTop10']) ? $LoggedUser['DisableFreeTorrentTop10'] : 0);
  89. // did they just toggle it?
  90. if (isset($_GET['freeleech'])) {
  91. // what did they choose?
  92. $NewPref = (($_GET['freeleech'] == 'hide') ? 1 : 0);
  93. // Pref id different
  94. if ($NewPref != $DisableFreeTorrentTop10) {
  95. $DisableFreeTorrentTop10 = $NewPref;
  96. Users::update_site_options($LoggedUser['ID'], array('DisableFreeTorrentTop10' => $DisableFreeTorrentTop10));
  97. }
  98. }
  99. // Modify the Where query
  100. if ($DisableFreeTorrentTop10) {
  101. $Where[] = "t.FreeTorrent='0'";
  102. }
  103. // The link should say the opposite of the current setting
  104. $FreeleechToggleName = ($DisableFreeTorrentTop10 ? 'show' : 'hide');
  105. $FreeleechToggleQuery = Format::get_url(array('freeleech', 'groups'));
  106. if (!empty($FreeleechToggleQuery))
  107. $FreeleechToggleQuery .= '&amp;';
  108. $FreeleechToggleQuery .= 'freeleech=' . $FreeleechToggleName;
  109. $GroupByToggleName = ((isset($_GET['groups']) && $_GET['groups'] == 'show') ? 'hide' : 'show');
  110. $GroupByToggleQuery = Format::get_url(array('freeleech', 'groups'));
  111. if (!empty($GroupByToggleQuery))
  112. $GroupByToggleQuery .= '&amp;';
  113. $GroupByToggleQuery .= 'groups=' . $GroupByToggleName;
  114. $GroupBySum = '';
  115. $GroupBy = '';
  116. if (isset($_GET['groups']) && $_GET['groups'] == 'show') {
  117. $GroupBy = ' GROUP BY g.ID ';
  118. $GroupBySum = md5($GroupBy);
  119. }
  120. ?>
  121. <div style="text-align: right;" class="linkbox">
  122. <a href="top10.php?<?=$FreeleechToggleQuery?>" class="brackets"><?=ucfirst($FreeleechToggleName)?> freeleech in Top 10</a>
  123. <? if (check_perms('users_mod')) { ?>
  124. <a href="top10.php?<?=$GroupByToggleQuery?>" class="brackets"><?=ucfirst($GroupByToggleName)?> top groups</a>
  125. <? } ?>
  126. </div>
  127. <?
  128. if (!empty($Where)) {
  129. $Where = '('.implode(' AND ', $Where).')';
  130. $WhereSum = md5($Where);
  131. } else {
  132. $WhereSum = '';
  133. }
  134. $BaseQuery = '
  135. SELECT
  136. t.ID,
  137. g.ID,
  138. g.Name,
  139. g.NameRJ,
  140. g.NameJP,
  141. g.CategoryID,
  142. g.WikiImage,
  143. g.TagList,
  144. t.Media,
  145. g.Year,
  146. t.Snatched,
  147. t.Seeders,
  148. t.Leechers,
  149. ((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data,
  150. t.Size
  151. FROM torrents AS t
  152. LEFT JOIN torrents_group AS g ON g.ID = t.GroupID';
  153. if ($Details == 'all' || $Details == 'day') {
  154. $TopTorrentsActiveLastDay = $Cache->get_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum);
  155. if ($TopTorrentsActiveLastDay === false) {
  156. if ($Cache->get_query_lock('top10')) {
  157. $DayAgo = time_minus(86400);
  158. $Query = $BaseQuery.' WHERE t.Seeders>0 AND ';
  159. if (!empty($Where)) {
  160. $Query .= $Where.' AND ';
  161. }
  162. $Query .= "
  163. t.Time>'$DayAgo'
  164. $GroupBy
  165. ORDER BY (t.Seeders + t.Leechers) DESC
  166. LIMIT $Limit;";
  167. $DB->query($Query);
  168. $TopTorrentsActiveLastDay = $DB->to_array(false, MYSQLI_NUM);
  169. $Cache->cache_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastDay, 3600 * 2);
  170. $Cache->clear_query_lock('top10');
  171. } else {
  172. $TopTorrentsActiveLastDay = false;
  173. }
  174. }
  175. generate_torrent_table('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit);
  176. }
  177. if ($Details == 'all' || $Details == 'week') {
  178. $TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum);
  179. if ($TopTorrentsActiveLastWeek === false) {
  180. if ($Cache->get_query_lock('top10')) {
  181. $WeekAgo = time_minus(604800);
  182. $Query = $BaseQuery.' WHERE ';
  183. if (!empty($Where)) {
  184. $Query .= $Where.' AND ';
  185. }
  186. $Query .= "
  187. t.Time>'$WeekAgo'
  188. $GroupBy
  189. ORDER BY (t.Seeders + t.Leechers) DESC
  190. LIMIT $Limit;";
  191. $DB->query($Query);
  192. $TopTorrentsActiveLastWeek = $DB->to_array(false, MYSQLI_NUM);
  193. $Cache->cache_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastWeek, 3600 * 6);
  194. $Cache->clear_query_lock('top10');
  195. } else {
  196. $TopTorrentsActiveLastWeek = false;
  197. }
  198. }
  199. generate_torrent_table('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit);
  200. }
  201. if ($Details == 'all' || $Details == 'month') {
  202. $TopTorrentsActiveLastMonth = $Cache->get_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum);
  203. if ($TopTorrentsActiveLastMonth === false) {
  204. if ($Cache->get_query_lock('top10')) {
  205. $Query = $BaseQuery.' WHERE ';
  206. if (!empty($Where)) {
  207. $Query .= $Where.' AND ';
  208. }
  209. $Query .= "
  210. t.Time > NOW() - INTERVAL 1 MONTH
  211. $GroupBy
  212. ORDER BY (t.Seeders + t.Leechers) DESC
  213. LIMIT $Limit;";
  214. $DB->query($Query);
  215. $TopTorrentsActiveLastMonth = $DB->to_array(false, MYSQLI_NUM);
  216. $Cache->cache_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastMonth, 3600 * 6);
  217. $Cache->clear_query_lock('top10');
  218. } else {
  219. $TopTorrentsActiveLastMonth = false;
  220. }
  221. }
  222. generate_torrent_table('Most Active Torrents Uploaded in the Past Month', 'month', $TopTorrentsActiveLastMonth, $Limit);
  223. }
  224. if ($Details == 'all' || $Details == 'year') {
  225. $TopTorrentsActiveLastYear = $Cache->get_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum);
  226. if ($TopTorrentsActiveLastYear === false) {
  227. if ($Cache->get_query_lock('top10')) {
  228. // IMPORTANT NOTE - we use WHERE t.Seeders>200 in order to speed up this query. You should remove it!
  229. $Query = $BaseQuery.' WHERE ';
  230. if ($Details == 'all' && !$Filtered) {
  231. // $Query .= 't.Seeders>=200 AND ';
  232. if (!empty($Where)) {
  233. $Query .= $Where.' AND ';
  234. }
  235. } elseif (!empty($Where)) {
  236. $Query .= $Where.' AND ';
  237. }
  238. $Query .= "
  239. t.Time > NOW() - INTERVAL 1 YEAR
  240. $GroupBy
  241. ORDER BY (t.Seeders + t.Leechers) DESC
  242. LIMIT $Limit;";
  243. $DB->query($Query);
  244. $TopTorrentsActiveLastYear = $DB->to_array(false, MYSQLI_NUM);
  245. $Cache->cache_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastYear, 3600 * 6);
  246. $Cache->clear_query_lock('top10');
  247. } else {
  248. $TopTorrentsActiveLastYear = false;
  249. }
  250. }
  251. generate_torrent_table('Most Active Torrents Uploaded in the Past Year', 'year', $TopTorrentsActiveLastYear, $Limit);
  252. }
  253. if ($Details == 'all' || $Details == 'overall') {
  254. $TopTorrentsActiveAllTime = $Cache->get_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum);
  255. if ($TopTorrentsActiveAllTime === false) {
  256. if ($Cache->get_query_lock('top10')) {
  257. // IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it!
  258. $Query = $BaseQuery;
  259. if ($Details=='all' && !$Filtered) {
  260. // $Query .= "t.Seeders>=500 ";
  261. if (!empty($Where)) {
  262. $Query .= ' WHERE '.$Where;
  263. }
  264. } elseif (!empty($Where)) {
  265. $Query .= ' WHERE '.$Where;
  266. }
  267. $Query .= "
  268. $GroupBy
  269. ORDER BY (t.Seeders + t.Leechers) DESC
  270. LIMIT $Limit;";
  271. $DB->query($Query);
  272. $TopTorrentsActiveAllTime = $DB->to_array(false, MYSQLI_NUM);
  273. $Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveAllTime, 3600 * 6);
  274. $Cache->clear_query_lock('top10');
  275. } else {
  276. $TopTorrentsActiveAllTime = false;
  277. }
  278. }
  279. generate_torrent_table('Most Active Torrents of All Time', 'overall', $TopTorrentsActiveAllTime, $Limit);
  280. }
  281. if (($Details == 'all' || $Details == 'snatched') && !$Filtered) {
  282. $TopTorrentsSnatched = $Cache->get_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum);
  283. if ($TopTorrentsSnatched === false) {
  284. if ($Cache->get_query_lock('top10')) {
  285. $Query = $BaseQuery;
  286. if (!empty($Where)) {
  287. $Query .= ' WHERE '.$Where;
  288. }
  289. $Query .= "
  290. $GroupBy
  291. ORDER BY t.Snatched DESC
  292. LIMIT $Limit;";
  293. $DB->query($Query);
  294. $TopTorrentsSnatched = $DB->to_array(false, MYSQLI_NUM);
  295. $Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSnatched, 3600 * 6);
  296. $Cache->clear_query_lock('top10');
  297. } else {
  298. $TopTorrentsSnatched = false;
  299. }
  300. }
  301. generate_torrent_table('Most Snatched Torrents', 'snatched', $TopTorrentsSnatched, $Limit);
  302. }
  303. if (($Details == 'all' || $Details == 'data') && !$Filtered) {
  304. $TopTorrentsTransferred = $Cache->get_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum);
  305. if ($TopTorrentsTransferred === false) {
  306. if ($Cache->get_query_lock('top10')) {
  307. // IMPORTANT NOTE - we use WHERE t.Snatched>100 in order to speed up this query. You should remove it!
  308. $Query = $BaseQuery;
  309. if ($Details=='all') {
  310. // $Query .= " WHERE t.Snatched>=100 ";
  311. if (!empty($Where)) {
  312. $Query .= ' WHERE '.$Where;
  313. }
  314. }
  315. $Query .= "
  316. $GroupBy
  317. ORDER BY Data DESC
  318. LIMIT $Limit;";
  319. $DB->query($Query);
  320. $TopTorrentsTransferred = $DB->to_array(false, MYSQLI_NUM);
  321. $Cache->cache_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsTransferred, 3600 * 6);
  322. $Cache->clear_query_lock('top10');
  323. } else {
  324. $TopTorrentsTransferred = false;
  325. }
  326. }
  327. generate_torrent_table('Most Data Transferred Torrents', 'data', $TopTorrentsTransferred, $Limit);
  328. }
  329. if (($Details == 'all' || $Details == 'seeded') && !$Filtered) {
  330. $TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum);
  331. if ($TopTorrentsSeeded === false) {
  332. if ($Cache->get_query_lock('top10')) {
  333. $Query = $BaseQuery;
  334. if (!empty($Where)) {
  335. $Query .= ' WHERE '.$Where;
  336. }
  337. $Query .= "
  338. $GroupBy
  339. ORDER BY t.Seeders DESC
  340. LIMIT $Limit;";
  341. $DB->query($Query);
  342. $TopTorrentsSeeded = $DB->to_array(false, MYSQLI_NUM);
  343. $Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSeeded, 3600 * 6);
  344. $Cache->clear_query_lock('top10');
  345. } else {
  346. $TopTorrentsSeeded = false;
  347. }
  348. }
  349. generate_torrent_table('Best Seeded Torrents', 'seeded', $TopTorrentsSeeded, $Limit);
  350. }
  351. ?>
  352. </div>
  353. <?
  354. View::show_footer();
  355. // generate a table based on data from most recent query to $DB
  356. function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
  357. global $LoggedUser, $Categories, $ReleaseTypes, $GroupBy;
  358. ?>
  359. <h3>Top <?="$Limit $Caption"?>
  360. <? if (empty($_GET['advanced'])) { ?>
  361. <small class="top10_quantity_links">
  362. <?
  363. switch ($Limit) {
  364. case 100: ?>
  365. - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
  366. - <span class="brackets">Top 100</span>
  367. - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
  368. <? break;
  369. case 250: ?>
  370. - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
  371. - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
  372. - <span class="brackets">Top 250</span>
  373. <? break;
  374. default: ?>
  375. - <span class="brackets">Top 10</span>
  376. - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
  377. - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
  378. <? } ?>
  379. </small>
  380. <? } ?>
  381. </h3>
  382. <table class="torrent_table cats numbering border">
  383. <tr class="colhead">
  384. <td class="center" style="width: 15px;"></td>
  385. <td class="cats_col"></td>
  386. <td>Name</td>
  387. <td style="text-align: right;">Size</td>
  388. <td style="text-align: right;">Data</td>
  389. <td style="text-align: right;" class="sign snatches"><svg width="15" height="15" fill="white" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98"><path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path></svg></td>
  390. <td style="text-align: right;" class="sign seeders"><svg width="11" height="15" fill="white" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg></td>
  391. <td style="text-align: right;" class="sign leechers"><svg width="11" height="15" fill="white" class="tooltip" alt="Leechers" title="Leechers"><polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon></svg></td>
  392. <td style="text-align: right;">Peers</td>
  393. </tr>
  394. <?
  395. // Server is already processing a top10 query. Starting another one will make things slow
  396. if ($Details === false) {
  397. ?>
  398. <tr class="row">
  399. <td colspan="9" class="center">
  400. Server is busy processing another top list request. Please try again in a minute.
  401. </td>
  402. </tr>
  403. </table><br />
  404. <?
  405. return;
  406. }
  407. // in the unlikely event that query finds 0 rows...
  408. if (empty($Details)) {
  409. ?>
  410. <tr class="row">
  411. <td colspan="9" class="center">
  412. Found no torrents matching the criteria.
  413. </td>
  414. </tr>
  415. </table><br />
  416. <?
  417. return;
  418. }
  419. $Rank = 0;
  420. foreach ($Details as $Detail) {
  421. $GroupIDs[] = $Detail[1];
  422. }
  423. $Artists = Artists::get_artists($GroupIDs);
  424. foreach ($Details as $Detail) {
  425. list($TorrentID, $GroupID, $GroupName, $GroupNameRJ, $GroupNameJP, $GroupCategoryID, $WikiImage, $TagsList,
  426. $Media, $Year, $Snatched, $Seeders, $Leechers, $Data, $Size) = $Detail;
  427. $IsBookmarked = Bookmarks::has_bookmarked('torrent', $GroupID);
  428. $IsSnatched = Torrents::has_snatched($TorrentID);
  429. $Rank++;
  430. // generate torrent's title
  431. $DisplayName = '';
  432. if (!empty($Artists[$GroupID])) {
  433. $DisplayName = Artists::display_artists($Artists[$GroupID], true, true);
  434. }
  435. $DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" class=\"tooltip\" title=\"View torrent\" ";
  436. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  437. $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
  438. }
  439. $Name = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
  440. $DisplayName .= "dir=\"ltr\">$Name</a>";
  441. // append extra info to torrent title
  442. $ExtraInfo = '';
  443. $AddExtra = '';
  444. if (empty($GroupBy)) {
  445. if ($Media) {
  446. $ExtraInfo .= $AddExtra.$Media;
  447. $AddExtra = ' / ';
  448. }
  449. if ($Year > 0) {
  450. $ExtraInfo .= $AddExtra.$Year;
  451. $AddExtra = ' ';
  452. }
  453. if ($IsSnatched) {
  454. if ($GroupCategoryID != 5) {
  455. $ExtraInfo .= ' / ';
  456. }
  457. $ExtraInfo .= Format::torrent_label('Snatched!');
  458. }
  459. if ($ExtraInfo != '') {
  460. $ExtraInfo = "- [$ExtraInfo]";
  461. }
  462. }
  463. $TorrentTags = new Tags($TagsList);
  464. //Get report info, use the cache if available, if not, add to it.
  465. $Reported = false;
  466. $Reports = Torrents::get_reports($TorrentID);
  467. if (count($Reports) > 0) {
  468. $Reported = true;
  469. }
  470. // print row
  471. ?>
  472. <tr class="torrent row<?=($IsBookmarked ? ' bookmarked' : '') . ($IsSnatched ? ' snatched_torrent' : '')?>">
  473. <td style="padding: 8px; text-align: center;"><strong><?=$Rank?></strong></td>
  474. <td class="center cats_col"><div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>"></div></td>
  475. <td class="big_info">
  476. <div class="group_info clear">
  477. <span><a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets tooltip">DL</a></span>
  478. <strong><?=$DisplayName?></strong> <?=$ExtraInfo?><? if ($Reported) { ?> - <strong class="torrent_label tl_reported">Reported</strong><? } ?>
  479. <?
  480. if ($IsBookmarked) {
  481. ?>
  482. <span class="remove_bookmark float_right">
  483. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  484. </span>
  485. <? } else { ?>
  486. <span class="add_bookmark float_right">
  487. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  488. </span>
  489. <? } ?>
  490. <div class="tags"><?=$TorrentTags->format()?></div>
  491. </div>
  492. </td>
  493. <td class="number_column nobr"><?=Format::get_size($Size)?></td>
  494. <td class="number_column nobr"><?=Format::get_size($Data)?></td>
  495. <td class="number_column"><?=number_format((double)$Snatched)?></td>
  496. <td class="number_column"><?=number_format((double)$Seeders)?></td>
  497. <td class="number_column"><?=number_format((double)$Leechers)?></td>
  498. <td class="number_column"><?=number_format($Seeders + $Leechers)?></td>
  499. </tr>
  500. <?
  501. } //foreach ($Details as $Detail)
  502. ?>
  503. </table><br />
  504. <?
  505. }
  506. ?>