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

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