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 19KB

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