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.

browse.php 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <?
  2. include(SERVER_ROOT.'/sections/torrents/functions.php');
  3. // The "order by x" links on columns headers
  4. function header_link($SortKey, $DefaultWay = 'desc') {
  5. global $OrderBy, $OrderWay;
  6. if ($SortKey == $OrderBy) {
  7. if ($OrderWay == 'desc') {
  8. $NewWay = 'asc';
  9. } else {
  10. $NewWay = 'desc';
  11. }
  12. } else {
  13. $NewWay = $DefaultWay;
  14. }
  15. return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(array('order_way', 'order_by'));
  16. }
  17. if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
  18. if (!empty($_GET['searchstr'])) {
  19. $InfoHash = $_GET['searchstr'];
  20. } else {
  21. $InfoHash = $_GET['groupname'];
  22. }
  23. // Search by infohash
  24. if ($InfoHash = is_valid_torrenthash($InfoHash)) {
  25. $InfoHash = db_string(pack('H*', $InfoHash));
  26. $DB->query("
  27. SELECT ID, GroupID
  28. FROM torrents
  29. WHERE info_hash = '$InfoHash'");
  30. if ($DB->has_results()) {
  31. list($ID, $GroupID) = $DB->next_record();
  32. header("Location: torrents.php?id=$GroupID&torrentid=$ID");
  33. die();
  34. }
  35. }
  36. }
  37. // Setting default search options
  38. if (!empty($_GET['setdefault'])) {
  39. $UnsetList = array('page', 'setdefault');
  40. $UnsetRegexp = '/(&|^)('.implode('|', $UnsetList).')=.*?(&|$)/i';
  41. $DB->query("
  42. SELECT SiteOptions
  43. FROM users_info
  44. WHERE UserID = '".db_string($LoggedUser['ID'])."'");
  45. list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
  46. if (!empty($SiteOptions)) {
  47. $SiteOptions = unserialize($SiteOptions);
  48. } else {
  49. $SiteOptions = array();
  50. }
  51. $SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
  52. $DB->query("
  53. UPDATE users_info
  54. SET SiteOptions = '".db_string(serialize($SiteOptions))."'
  55. WHERE UserID = '".db_string($LoggedUser['ID'])."'");
  56. $Cache->begin_transaction("user_info_heavy_$UserID");
  57. $Cache->update_row(false, array('DefaultSearch' => $SiteOptions['DefaultSearch']));
  58. $Cache->commit_transaction(0);
  59. // Clearing default search options
  60. } elseif (!empty($_GET['cleardefault'])) {
  61. $DB->query("
  62. SELECT SiteOptions
  63. FROM users_info
  64. WHERE UserID = '".db_string($LoggedUser['ID'])."'");
  65. list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
  66. $SiteOptions = unserialize($SiteOptions);
  67. $SiteOptions['DefaultSearch'] = '';
  68. $DB->query("
  69. UPDATE users_info
  70. SET SiteOptions = '".db_string(serialize($SiteOptions))."'
  71. WHERE UserID = '".db_string($LoggedUser['ID'])."'");
  72. $Cache->begin_transaction("user_info_heavy_$UserID");
  73. $Cache->update_row(false, array('DefaultSearch' => ''));
  74. $Cache->commit_transaction(0);
  75. // Use default search options
  76. } elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) === 1 && isset($_GET['page']))) {
  77. if (!empty($LoggedUser['DefaultSearch'])) {
  78. if (!empty($_GET['page'])) {
  79. $Page = $_GET['page'];
  80. parse_str($LoggedUser['DefaultSearch'], $_GET);
  81. $_GET['page'] = $Page;
  82. } else {
  83. parse_str($LoggedUser['DefaultSearch'], $_GET);
  84. }
  85. }
  86. }
  87. // Terms were not submitted via the search form
  88. if (isset($_GET['searchsubmit'])) {
  89. $GroupResults = !empty($_GET['group_results']);
  90. } else {
  91. $GroupResults = !$LoggedUser['DisableGrouping2'];
  92. }
  93. if (!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
  94. $OrderWay = 'asc';
  95. } else {
  96. $OrderWay = 'desc';
  97. }
  98. if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_by']])) {
  99. $OrderBy = 'time'; // For header links
  100. } else {
  101. $OrderBy = $_GET['order_by'];
  102. }
  103. $Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
  104. $Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
  105. if (isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] == 1) {
  106. $Search->insert_hidden_tags('!lolicon !shotacon !toddlercon');
  107. }
  108. if (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] == 1) {
  109. $Search->insert_hidden_tags('!scat');
  110. }
  111. if (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] == 1) {
  112. $Search->insert_hidden_tags('!snuff');
  113. }
  114. $Results = $Search->query($_GET);
  115. $Groups = $Search->get_groups();
  116. $NumResults = $Search->record_count();
  117. $HideFilter = isset($LoggedUser['ShowTorFilter']) && $LoggedUser['ShowTorFilter'] == 0;
  118. // This is kinda ugly, but the enormous if paragraph was really hard to read
  119. $AdvancedSearch = !empty($_GET['action']) && $_GET['action'] == 'advanced';
  120. $AdvancedSearch |= !empty($LoggedUser['SearchType']) && (empty($_GET['action']) || $_GET['action'] == 'advanced');
  121. $AdvancedSearch &= check_perms('site_advanced_search');
  122. if ($AdvancedSearch) {
  123. $Action = 'action=advanced';
  124. $HideBasic = ' hidden';
  125. $HideAdvanced = '';
  126. } else {
  127. $Action = 'action=basic';
  128. $HideBasic = '';
  129. $HideAdvanced = ' hidden';
  130. }
  131. View::show_header('Browse Torrents', 'browse');
  132. ?>
  133. <div class="thin widethin">
  134. <div class="header">
  135. <h2>Torrents</h2>
  136. </div>
  137. <form class="search_form" name="torrents" method="get" action="" onsubmit="$(this).disableUnset();">
  138. <div class="box filter_torrents">
  139. <div class="head">
  140. <strong>
  141. <span id="ft_basic_text" class="<?=$HideBasic?>">Basic /</span>
  142. <span id="ft_basic_link" class="<?=$HideAdvanced?>"><a href="#" onclick="return toggleTorrentSearch('basic');">Basic</a> /</span>
  143. <span id="ft_advanced_text" class="<?=$HideAdvanced?>">Advanced</span>
  144. <span id="ft_advanced_link" class="<?=$HideBasic?>"><a href="#" onclick="return toggleTorrentSearch('advanced');">Advanced</a></span>
  145. Search
  146. </strong>
  147. <span style="float: right;">
  148. <a href="#" onclick="return toggleTorrentSearch(0);" id="ft_toggle" class="brackets"><?=$HideFilter ? 'Show' : 'Hide'?></a>
  149. </span>
  150. </div>
  151. <div id="ft_container" class="pad<?=$HideFilter ? ' hidden' : ''?>">
  152. <? if((isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] == 1)
  153. || (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] == 1)
  154. || (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] == 1)
  155. ) { ?>
  156. <svg title="Your profile settings exclude some results" class="search_warning tooltip" width="10" height="15"><rect x=3 width="4" height="10" rx="2" ry="2"/><circle cx="5" cy="13" r="2"/></svg>
  157. <? } ?>
  158. <table class="layout">
  159. <tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
  160. <td class="label"><!--Artist name:--></td>
  161. <td colspan="3" class="ft_artistname">
  162. <input type="search" spellcheck="false" size="65" name="artistname" class="inputtext smaller fti_advanced" placeholder="Artist name" value="<?Format::form('artistname')?>" />
  163. </td>
  164. </tr>
  165. <tr id="album_torrent_name" class="ftr_advanced<?=$HideAdvanced?>">
  166. <td class="label"><!--Torrent name:--></td>
  167. <td colspan="3" class="ft_groupname">
  168. <input type="search" spellcheck="false" size="65" name="groupname" class="inputtext smaller fti_advanced" placeholder="Torrent name" value="<?Format::form('groupname')?>" />
  169. </td>
  170. </tr>
  171. <tr id="catalogue_number" class="ftr_advanced<?=$HideAdvanced?>">
  172. <td class="label"><!--Catalogue number:--></td>
  173. <td class="ft_cataloguenumber">
  174. <input type="search" size="19" name="cataloguenumber" class="inputtext smallest fti_advanced" placeholder="Catalogue number" value="<?Format::form('cataloguenumber')?>" />
  175. </td>
  176. </tr>
  177. <tr id="dlsiteid" class="ftr_advanced<?=$HideAdvanced?>">
  178. <td class="label"><!--DLSite ID:--></td>
  179. <td class="ft_dlsiteid">
  180. <input type="search" size="12" name="dlsiteid" class="inputtext smallest fti_advanced" placeholder="DLSite ID" value="<?Format::form('dlsiteid')?>" />
  181. </td>
  182. </tr>
  183. <tr id="year" class="ftr_advanced<?=$HideAdvanced?>">
  184. <td class="label"><!--Year:--></td>
  185. <td class="ft_year">
  186. <input type="search" name="year" class="inputtext smallest fti_advanced" placeholder="Year" value="<?Format::form('year')?>" size="12" />
  187. </td>
  188. </tr>
  189. <tr id="file_list" class="ftr_advanced<?=$HideAdvanced?>">
  190. <td class="label"><!--File list:--></td>
  191. <td colspan="3" class="ft_filelist">
  192. <input type="search" spellcheck="false" size="65" name="filelist" class="inputtext fti_advanced" placeholder="File list" value="<?Format::form('filelist')?>" />
  193. </td>
  194. </tr>
  195. <tr id="torrent_description" class="ftr_advanced<?=$HideAdvanced?>">
  196. <td class="label"><!--<span title="Search torrent descriptions (not group information)" class="tooltip">Torrent description:</span>--></td>
  197. <td colspan="3" class="ft_description">
  198. <input type="search" spellcheck="false" size="65" name="description" class="inputtext fti_advanced tooltip_left" placeholder="Torrent description" title="Search torrent descriptions (not group information)" value="<?Format::form('description')?>" />
  199. </td>
  200. </tr>
  201. <tr id="rip_specifics" class="ftr_advanced<?=$HideAdvanced?>">
  202. <td class="label">Release specifics:</td>
  203. <td class="nobr ft_ripspecifics" colspan="3">
  204. <select id="container" name="container" class="ft_container fti_advanced">
  205. <option value="">Container</option>
  206. <? foreach ($Containers as $Container) { ?>
  207. <option value="<?=display_str($Container);?>" <?Format::selected('container', $Container)?>><?=display_str($Container);?></option>
  208. <? } ?>
  209. <? foreach ($ContainersGames as $Container) { ?>
  210. <option value="<?=display_str($Container);?>" <?Format::selected('container', $Container)?>><?=display_str($Container);?></option>
  211. <? } ?>
  212. </select>
  213. <select name="codec" class="ft_codec fti_advanced">
  214. <option value="">Codec</option>
  215. <? foreach ($Codecs as $Codec) { ?>
  216. <option value="<?=display_str($Codec); ?>"<?Format::selected('codec', $Codec)?>><?=display_str($Codec); ?></option>
  217. <? } ?>
  218. </select>
  219. <select name="audioformat" class="ft_audioformat fti_advanced">
  220. <option value="">AudioFormat</option>
  221. <? foreach ($AudioFormats as $AudioFormat) { ?>
  222. <option value="<?=display_str($AudioFormat); ?>"<?Format::selected('audioformat', $AudioFormat)?>><?=display_str($AudioFormat); ?></option>
  223. <? } ?>
  224. </select>
  225. <select name="media" class="ft_media fti_advanced">
  226. <option value="">Media</option>
  227. <? foreach ($Media as $MediaName) { ?>
  228. <option value="<?=display_str($MediaName); ?>"<?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?></option>
  229. <? } ?>
  230. </select>
  231. <select name="resolution" class="ft_resolution fti_advanced">
  232. <option value="">Resolution</option>
  233. <? foreach ($Resolutions as $Resolution) { ?>
  234. <option value="<?=display_str($Resolution); ?>"<?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?></option>
  235. <? } ?>
  236. </select>
  237. <select name="language" class="ft_language fti_advanced">
  238. <option value="">Language</option>
  239. <? foreach ($Languages as $Language) { ?>
  240. <option value="<?=display_str($Language); ?>"<?Format::selected('language', $Language)?>><?=display_str($Language); ?></option>
  241. <? } ?>
  242. </select>
  243. <select name="subbing" class="ft_subbing fti_advanced">
  244. <option value="">Subs</option>
  245. <? foreach ($Subbing as $Sub) { ?>
  246. <option value="<?=display_str($Sub); ?>"<?Format::selected('subbing', $Sub)?>><?=display_str($Sub); ?></option>
  247. <? } ?>
  248. </select>
  249. </td>
  250. </tr>
  251. <tr id="subber" class="ftr_advanced<?=$HideAdvanced?>">
  252. <td class="label"><!--Translation Group:--></td>
  253. <td colspan="3" class="ft_subber">
  254. <input type="search" spellcheck="false" size="65" name="subber" class="inputtext smaller fti_advanced" placeholder="Translation Group" value="<?Format::form('subber')?>" />
  255. </td>
  256. </tr>
  257. <tr id="misc" class="ftr_advanced<?=$HideAdvanced?>">
  258. <td class="label">Misc:</td>
  259. <td class="nobr ft_misc" colspan="3">
  260. <select name="freetorrent" class="ft_freetorrent fti_advanced">
  261. <option value="">Leech Status</option>
  262. <option value="1"<?Format::selected('freetorrent', 1)?>>Freeleech</option>
  263. <option value="2"<?Format::selected('freetorrent', 2)?>>Neutral Leech</option>
  264. <option value="3"<?Format::selected('freetorrent', 3)?>>Either</option>
  265. <option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
  266. </select>
  267. <select name="censored" class="ft_censored fti_advanced">
  268. <option value="">Censored?</option>
  269. <option value="1"<?Format::selected('censored', 1)?>>Censored</option>
  270. <option value="0"<?Format::selected('censored', 0)?>>Uncensored</option>
  271. </select>
  272. </select>
  273. </td>
  274. </tr>
  275. <tr id="search_terms" class="ftr_basic<?=$HideBasic?>">
  276. <td class="label"><!--Search terms:--></td>
  277. <td colspan="3" class="ftb_searchstr">
  278. <input type="search" spellcheck="false" size="48" name="searchstr" class="inputtext fti_basic" placeholder="Search terms" value="<?Format::form('searchstr')?>" />
  279. </td>
  280. </tr>
  281. <tr id="tagfilter">
  282. <td class="label"><!--<span title="Use !tag to exclude tag" class="tooltip">Tags (comma-separated):</span>--></td>
  283. <td colspan="3" class="ft_taglist">
  284. <input type="search" size="37" id="tags" name="taglist" class="inputtext smaller tooltip_left" title="Use !tag to exclude tag" placeholder="Tags (comma separated)" value="<?=display_str($Search->get_terms('taglist'))?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
  285. <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
  286. <input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
  287. </td>
  288. </tr>
  289. <tr id="order">
  290. <td class="label">Order by:</td>
  291. <td colspan="3" class="ft_order">
  292. <select name="order_by" style="width: auto;" class="ft_order_by">
  293. <option value="time"<?Format::selected('order_by', 'time')?>>Time added</option>
  294. <option value="year"<?Format::selected('order_by', 'year')?>>Year</option>
  295. <option value="size"<?Format::selected('order_by', 'size')?>>Size</option>
  296. <option value="snatched"<?Format::selected('order_by', 'snatched')?>>Snatched</option>
  297. <option value="seeders"<?Format::selected('order_by', 'seeders')?>>Seeders</option>
  298. <option value="leechers"<?Format::selected('order_by', 'leechers')?>>Leechers</option>
  299. <option value="random"<?Format::selected('order_by', 'random')?>>Random</option>
  300. </select>
  301. <select name="order_way" class="ft_order_way">
  302. <option value="desc"<?Format::selected('order_way', 'desc')?>>Descending</option>
  303. <option value="asc"<?Format::selected('order_way', 'asc')?>>Ascending</option>
  304. </select>
  305. </td>
  306. </tr>
  307. <tr id="search_group_results">
  308. <td class="label">
  309. <label for="group_results">Group by release:</label>
  310. </td>
  311. <td colspan="3" class="ft_group_results">
  312. <input type="checkbox" value="1" name="group_results" id="group_results"<?=$GroupResults ? ' checked="checked"' : ''?> />
  313. </td>
  314. </tr>
  315. </table>
  316. <table class="layout cat_list ft_cat_list">
  317. <?
  318. $x = 0;
  319. reset($Categories);
  320. foreach ($Categories as $CatKey => $CatName) {
  321. if ($x % 7 == 0) {
  322. if ($x > 0) {
  323. ?>
  324. </tr>
  325. <? } ?>
  326. <tr>
  327. <?
  328. }
  329. $x++;
  330. ?>
  331. <td>
  332. <input type="checkbox" name="filter_cat[<?=($CatKey + 1)?>]" id="cat_<?=($CatKey + 1)?>" value="1"<? if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<? } ?> />
  333. <label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
  334. </td>
  335. <?
  336. }
  337. ?>
  338. </tr>
  339. </table>
  340. <table class="layout cat_list<? if (empty($LoggedUser['ShowTags'])) { ?> hidden<? } ?>" id="taglist">
  341. <tr>
  342. <?
  343. $GenreTags = $Cache->get_value('genre_tags');
  344. if (!$GenreTags) {
  345. $DB->query('
  346. SELECT Name
  347. FROM tags
  348. WHERE TagType = \'genre\'
  349. ORDER BY Name');
  350. $GenreTags = $DB->collect('Name');
  351. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  352. }
  353. $x = 0;
  354. foreach ($GenreTags as $Tag) {
  355. ?>
  356. <td width="12.5%"><a href="#" onclick="add_tag('<?=$Tag?>'); return false;"><?=$Tag?></a></td>
  357. <?
  358. $x++;
  359. if ($x % 7 == 0) {
  360. ?>
  361. </tr>
  362. <tr>
  363. <?
  364. }
  365. }
  366. if ($x % 7 != 0) { // Padding
  367. ?>
  368. <td colspan="<?=(7 - ($x % 7))?>"> </td>
  369. <? } ?>
  370. </tr>
  371. </table>
  372. <table class="layout cat_list" width="100%">
  373. <tr>
  374. <td class="label">
  375. <a class="brackets" href="#" onclick="$('#taglist').gtoggle(); if (this.innerHTML == 'View tags') { this.innerHTML = 'Hide tags'; } else { this.innerHTML = 'View tags'; }; return false;"><?=(empty($LoggedUser['ShowTags']) ? 'View tags' : 'Hide tags')?></a>
  376. </td>
  377. </tr>
  378. </table>
  379. <div class="submit ft_submit">
  380. <span style="float: left;"><?=number_format($NumResults)?> Results</span>
  381. <input type="submit" value="Filter torrents" />
  382. <input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
  383. <input type="hidden" name="searchsubmit" value="1" />
  384. <input type="button" value="Reset" onclick="location.href = 'torrents.php<? if (isset($_GET['action']) && $_GET['action'] === 'advanced') { ?>?action=advanced<? } ?>'" />
  385. &nbsp;&nbsp;
  386. <? if ($Search->has_filters()) { ?>
  387. <input type="submit" name="setdefault" value="Make default" />
  388. <? }
  389. if (!empty($LoggedUser['DefaultSearch'])) { ?>
  390. <input type="submit" name="cleardefault" value="Clear default" />
  391. <? } ?>
  392. </div>
  393. </div>
  394. </div>
  395. </form>
  396. <? if ($NumResults == 0) { ?>
  397. <div class="torrents_nomatch box pad" align="center">
  398. <h2>Your search did not match anything.</h2>
  399. <p>Make sure all names are spelled correctly, or try making your search less specific.</p>
  400. </div>
  401. </div>
  402. <? View::show_footer();die();
  403. }
  404. if ($NumResults < ($Page - 1) * TORRENTS_PER_PAGE + 1) {
  405. $LastPage = ceil($NumResults / TORRENTS_PER_PAGE);
  406. $Pages = Format::get_pages(0, $NumResults, TORRENTS_PER_PAGE);
  407. ?>
  408. <div class="torrents_nomatch box pad" align="center">
  409. <h2>The requested page contains no matches.</h2>
  410. <p>You are requesting page <?=$Page?>, but the search returned only <?=number_format($LastPage) ?> pages.</p>
  411. </div>
  412. <div class="linkbox">Go to page <?=$Pages?></div>
  413. </div>
  414. <?
  415. View::show_footer();die();
  416. }
  417. // List of pages
  418. $Pages = Format::get_pages($Page, $NumResults, TORRENTS_PER_PAGE);
  419. $Bookmarks = Bookmarks::all_bookmarks('torrent');
  420. ?>
  421. <div class="linkbox"><?=$Pages?></div>
  422. <div class="box">
  423. <table class="torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>" id="torrent_table">
  424. <tr class="colhead">
  425. <? if ($GroupResults) { ?>
  426. <td class="small"></td>
  427. <? } ?>
  428. <td class="small cats_col"></td>
  429. <td width="100%">Name / <a href="<?=header_link('year')?>">Year</a></td>
  430. <td>Files</td>
  431. <td><a href="<?=header_link('time')?>">Time</a></td>
  432. <td><a href="<?=header_link('size')?>">Size</a></td>
  433. <td class="sign snatches">
  434. <a href="<?=header_link('snatched')?>">
  435. <img src="static/styles/<?=$LoggedUser['StyleName']?>/images/snatched.png" class="tooltip" alt="Snatches" title="Snatches" />
  436. </a>
  437. </td>
  438. <td class="sign seeders">
  439. <a href="<?=header_link('seeders')?>">
  440. <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>
  441. </a>
  442. </td>
  443. <td class="sign leechers">
  444. <a href="<?=header_link('leechers')?>">
  445. <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>
  446. </a>
  447. </td>
  448. </tr>
  449. <?
  450. // Start printing torrent list
  451. foreach ($Results as $Key => $GroupID) {
  452. $GroupInfo = $Groups[$GroupID];
  453. if (empty($GroupInfo['Torrents'])) {
  454. continue;
  455. }
  456. $CategoryID = $GroupInfo['CategoryID'];
  457. $GroupYear = $GroupInfo['Year'];
  458. $Artists = $GroupInfo['Artists'];
  459. $GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
  460. $GroupPages = $GroupInfo['Pages'];
  461. $GroupStudio = $GroupInfo['Studio'];
  462. $GroupDLsiteID = $GroupInfo['DLSiteID'];
  463. $GroupName = $GroupInfo['Name'];
  464. if ($GroupResults) {
  465. $Torrents = $GroupInfo['Torrents'];
  466. $GroupTime = $MaxSize = $TotalLeechers = $TotalSeeders = $TotalSnatched = 0;
  467. foreach ($Torrents as $T) {
  468. $GroupTime = max($GroupTime, strtotime($T['Time']));
  469. $MaxSize = max($MaxSize, $T['Size']);
  470. $TotalLeechers += $T['Leechers'];
  471. $TotalSeeders += $T['Seeders'];
  472. $TotalSnatched += $T['Snatched'];
  473. }
  474. } else {
  475. $TorrentID = $Key;
  476. $Torrents = array($TorrentID => $GroupInfo['Torrents'][$TorrentID]);
  477. }
  478. $TorrentTags = new Tags($GroupInfo['TagList']);
  479. if (isset($Artists)) {
  480. $DisplayName = '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
  481. } else {
  482. $DisplayName = '';
  483. }
  484. $SnatchedGroupClass = $GroupInfo['Flags']['IsSnatched'] ? ' snatched_group' : '';
  485. if ($GroupResults && (count($Torrents) > 1 && isset($GroupedCategories[$CategoryID - 1]))) {
  486. // These torrents are in a group
  487. $CoverArt = $GroupInfo['WikiImage'];
  488. $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
  489. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  490. $DisplayName .= "onmouseover=\"getCover(event)\" cover=\"".ImageTools::process($CoverArt)."\" onmouseleave=\"ungetCover(event)\" ";
  491. }
  492. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  493. if ($GroupYear) {
  494. $DisplayName .= " [$GroupYear]";
  495. }
  496. if ($GroupStudio) {
  497. $DisplayName .= " [$GroupStudio]";
  498. }
  499. if ($GroupCatalogueNumber) {
  500. $DisplayName .= " [$GroupCatalogueNumber]";
  501. }
  502. if ($GroupPages) {
  503. $DisplayName .= " [{$GroupPages}p]";
  504. }
  505. if ($GroupDLsiteID) {
  506. $DisplayName .= " [$GroupDLsiteID]";
  507. }
  508. ?>
  509. <tr class="group<?=$SnatchedGroupClass?>">
  510. <?
  511. $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
  512. ?>
  513. <td class="center">
  514. <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
  515. <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
  516. </div>
  517. </td>
  518. <td class="center cats_col">
  519. <div title="<?=Format::pretty_category($CategoryID)?>" class="tooltip <?=Format::css_category($CategoryID)?>">
  520. </div>
  521. </td>
  522. <td colspan="2" class="big_info">
  523. <div class="group_info clear">
  524. <?=$DisplayName?>
  525. <? if (in_array($GroupID, $Bookmarks)) { ?>
  526. <span class="remove_bookmark float_right">
  527. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  528. </span>
  529. <? } else { ?>
  530. <span class="add_bookmark float_right">
  531. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  532. </span>
  533. <? } ?>
  534. <br />
  535. <div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?></div>
  536. </div>
  537. </td>
  538. <td class="nobr"><?=time_diff($GroupTime, 1)?></td>
  539. <td class="number_column nobr"><?=Format::get_size($MaxSize)?> (Max)</td>
  540. <td class="number_column"><?=number_format($TotalSnatched)?></td>
  541. <td class="number_column<?=($TotalSeeders == 0 ? ' r00' : '')?>"><?=number_format($TotalSeeders)?></td>
  542. <td class="number_column"><?=number_format($TotalLeechers)?></td>
  543. </tr>
  544. <?
  545. foreach ($Torrents as $TorrentID => $Data) {
  546. $Data['CategoryID'] = $CategoryID;
  547. // All of the individual torrents in the group
  548. //Get report info for each torrent, use the cache if available, if not, add to it.
  549. $Reported = false;
  550. $Reports = Torrents::get_reports($TorrentID);
  551. if (count($Reports) > 0) {
  552. $Reported = true;
  553. }
  554. $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
  555. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  556. if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
  557. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  558. $Tor = new BencodeTorrent($TorrentFile);
  559. $TorrentFileName = $Tor->Dec['info']['name'];
  560. $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
  561. }
  562. $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$Data['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;','%26',$TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=",ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Data['Size'];
  563. ?>
  564. <tr class="group_torrent groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
  565. <td colspan="3">
  566. <span>
  567. [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
  568. | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
  569. <? if (Torrents::can_use_token($Data)) { ?>
  570. | <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  571. <? } ?>
  572. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  573. </span>
  574. &raquo; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Data)?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported">Reported</strong><? } ?></a>
  575. </td>
  576. <td class="number_column"><?=$Data['FileCount']?></td>
  577. <td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
  578. <td class="number_column nobr"><?=Format::get_size($Data['Size'])?></td>
  579. <td class="number_column"><?=number_format($Data['Snatched'])?></td>
  580. <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
  581. <td class="number_column"><?=number_format($Data['Leechers'])?></td>
  582. </tr>
  583. <?
  584. }
  585. } else {
  586. // Viewing a type that does not require grouping
  587. list($TorrentID, $Data) = each($Torrents);
  588. $Reported = false;
  589. $Reports = Torrents::get_reports($TorrentID);
  590. if (count($Reports) > 0) {
  591. $Reported = true;
  592. }
  593. $Data['CategoryID'] = $CategoryID;
  594. $CoverArt = $GroupInfo['WikiImage'];
  595. $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
  596. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  597. $DisplayName .= "onmouseover=\"getCover(event)\" cover=\"".ImageTools::process($CoverArt)."\" onmouseleave=\"ungetCover(event)\" ";
  598. }
  599. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  600. if (isset($GroupedCategories[$CategoryID - 1])) {
  601. if ($GroupYear) {
  602. $DisplayName .= " [$GroupYear]";
  603. }
  604. if ($GroupStudio) {
  605. $DisplayName .= " [$GroupStudio]";
  606. }
  607. if ($GroupCatalogueNumber) {
  608. $DisplayName .= " [$GroupCatalogueNumber]";
  609. }
  610. if ($GroupPages) {
  611. $DisplayName .= " [{$GroupPages}p]";
  612. }
  613. if ($GroupDLsiteID) {
  614. $DisplayName .= " [$GroupDLsiteID]";
  615. }
  616. $ExtraInfo = Torrents::torrent_info($Data, true, true);
  617. } elseif ($Data['IsSnatched']) {
  618. $ExtraInfo = Format::torrent_label('Snatched!');
  619. } else {
  620. $ExtraInfo = '';
  621. }
  622. $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
  623. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  624. if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
  625. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  626. $Tor = new BencodeTorrent($TorrentFile);
  627. $TorrentFileName = $Tor->Dec['info']['name'];
  628. $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
  629. }
  630. $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$Data['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;','%26',$TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=",ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Data['Size'];
  631. ?>
  632. <tr class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
  633. <? if ($GroupResults) { ?>
  634. <td></td>
  635. <? } ?>
  636. <td class="center cats_col">
  637. <div title="<?=Format::pretty_category($CategoryID)?>" class="tooltip <?=Format::css_category($CategoryID)?>"></div>
  638. </td>
  639. <td class="big_info">
  640. <div class="group_info clear">
  641. <div class="float_right">
  642. <span>
  643. [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download">DL</a>
  644. | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
  645. <? if (Torrents::can_use_token($Data)) { ?>
  646. | <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  647. <? } ?>
  648. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  649. </span>
  650. <br />
  651. <? if (in_array($GroupID, $Bookmarks)) { ?>
  652. <span class="remove_bookmark float_right">
  653. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  654. </span>
  655. <? } else { ?>
  656. <span class="add_bookmark float_right">
  657. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  658. </span>
  659. <? } ?>
  660. </div>
  661. <?=$DisplayName?>
  662. <br />
  663. <div style="display: inline;" class="torrent_info"><?=$ExtraInfo?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported">Reported</strong><? } ?></div>
  664. <div class="tags"><?=$TorrentTags->format("torrents.php?$Action&amp;taglist=")?></div>
  665. </div>
  666. </td>
  667. <td class="number_column"><?=$Data['FileCount']?></td>
  668. <td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
  669. <td class="number_column nobr"><?=Format::get_size($Data['Size'])?></td>
  670. <td class="number_column"><?=number_format($Data['Snatched'])?></td>
  671. <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
  672. <td class="number_column"><?=number_format($Data['Leechers'])?></td>
  673. </tr>
  674. <?
  675. }
  676. }
  677. ?>
  678. </table>
  679. </div>
  680. <div class="linkbox"><?=$Pages?></div>
  681. </div>
  682. <? View::show_footer(); ?>