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.

torrents.php 22KB

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