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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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(['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 = ['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 = [];
  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, ['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, ['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" 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 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 class="ft_groupname">
  168. <input type="search" spellcheck="false" size="65" name="advgroupname" class="inputtext smaller fti_advanced" placeholder="Torrent name" value="<?Format::form('advgroupname')?>" />
  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 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 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">
  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 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="size" class="ftr_advanced<?=$HideAdvanced?>">
  258. <td class="label">Size:</td>
  259. <td class="ft_size">
  260. <input type="size_min" spellcheck="false" size="6" name="size_min" class="inputtext smaller fti_advanced" placeholder="Min" value="<?Format::form('size_min')?>" /> -
  261. <input type="size_max" spellcheck="false" size="6" name="size_max" class="inputtext smaller fti_advanced" placeholder="Max" value="<?Format::form('size_max')?>" />
  262. <select name="size_unit" class="ft_size fti_advanced">
  263. <option value="">Unit</option>
  264. <option value="0"<?Format::selected('size_unit', 0)?>>B</option>
  265. <option value="1"<?Format::selected('size_unit', 1)?>>KiB</option>
  266. <option value="2"<?Format::selected('size_unit', 2)?>>MiB</option>
  267. <option value="3"<?Format::selected('size_unit', 3)?>>GiB</option>
  268. <option value="4"<?Format::selected('size_unit', 4)?>>TiB</option>
  269. </select>
  270. </td>
  271. </tr>
  272. <tr id="misc" class="ftr_advanced<?=$HideAdvanced?>">
  273. <td class="label">Misc:</td>
  274. <td class="nobr ft_misc">
  275. <select name="freetorrent" class="ft_freetorrent fti_advanced">
  276. <option value="">Leech Status</option>
  277. <option value="1"<?Format::selected('freetorrent', 1)?>>Freeleech</option>
  278. <option value="2"<?Format::selected('freetorrent', 2)?>>Neutral Leech</option>
  279. <option value="3"<?Format::selected('freetorrent', 3)?>>Either</option>
  280. <option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
  281. </select>
  282. <select name="censored" class="ft_censored fti_advanced">
  283. <option value="">Censored?</option>
  284. <option value="1"<?Format::selected('censored', 1)?>>Censored</option>
  285. <option value="0"<?Format::selected('censored', 0)?>>Uncensored</option>
  286. </select>
  287. </td>
  288. </tr>
  289. <tr id="search_terms" class="ftr_basic<?=$HideBasic?>">
  290. <td class="label"><!--Search terms:--></td>
  291. <td class="ftb_searchstr">
  292. <input type="search" spellcheck="false" size="48" name="searchstr" class="inputtext fti_basic" placeholder="Search terms" value="<?Format::form('searchstr')?>" />
  293. </td>
  294. </tr>
  295. <tr id="tagfilter">
  296. <td class="label"><!--<span title="Use !tag to exclude tag" class="tooltip">Tags (comma-separated):</span>--></td>
  297. <td class="ft_taglist">
  298. <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;
  299. <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;
  300. <input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
  301. </td>
  302. </tr>
  303. <tr id="order">
  304. <td class="label">Order by:</td>
  305. <td class="ft_order">
  306. <select name="order_by" style="width: auto;" class="ft_order_by">
  307. <option value="time"<?Format::selected('order_by', 'time')?>>Time added</option>
  308. <option value="year"<?Format::selected('order_by', 'year')?>>Year</option>
  309. <option value="size"<?Format::selected('order_by', 'size')?>>Size</option>
  310. <option value="snatched"<?Format::selected('order_by', 'snatched')?>>Snatched</option>
  311. <option value="seeders"<?Format::selected('order_by', 'seeders')?>>Seeders</option>
  312. <option value="leechers"<?Format::selected('order_by', 'leechers')?>>Leechers</option>
  313. <option value="cataloguenumber"<?Format::selected('order_by', 'cataloguenumber')?>>Catalogue Number</option>
  314. <option value="random"<?Format::selected('order_by', 'random')?>>Random</option>
  315. </select>
  316. <select name="order_way" class="ft_order_way">
  317. <option value="desc"<?Format::selected('order_way', 'desc')?>>Descending</option>
  318. <option value="asc"<?Format::selected('order_way', 'asc')?>>Ascending</option>
  319. </select>
  320. </td>
  321. </tr>
  322. <tr id="search_group_results">
  323. <td class="label">
  324. <label for="group_results">Group by release:</label>
  325. </td>
  326. <td class="ft_group_results">
  327. <input type="checkbox" value="1" name="group_results" id="group_results"<?=$GroupResults ? ' checked="checked"' : ''?> />
  328. </td>
  329. </tr>
  330. </table>
  331. <table class="layout cat_list ft_cat_list">
  332. <?
  333. $x = 0;
  334. reset($Categories);
  335. foreach ($Categories as $CatKey => $CatName) {
  336. if ($x % 7 == 0) {
  337. if ($x > 0) {
  338. ?>
  339. </tr>
  340. <? } ?>
  341. <tr>
  342. <?
  343. }
  344. $x++;
  345. ?>
  346. <td>
  347. <input type="checkbox" name="filter_cat[<?=($CatKey + 1)?>]" id="cat_<?=($CatKey + 1)?>" value="1"<? if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<? } ?> />
  348. <label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
  349. </td>
  350. <?
  351. }
  352. ?>
  353. </tr>
  354. </table>
  355. <table class="layout cat_list<? if (empty($LoggedUser['ShowTags'])) { ?> hidden<? } ?>" id="taglist">
  356. <tr>
  357. <?
  358. $GenreTags = $Cache->get_value('genre_tags');
  359. if (!$GenreTags) {
  360. $DB->query('
  361. SELECT Name
  362. FROM tags
  363. WHERE TagType = \'genre\'
  364. ORDER BY Name');
  365. $GenreTags = $DB->collect('Name');
  366. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  367. }
  368. $x = 0;
  369. foreach ($GenreTags as $Tag) {
  370. ?>
  371. <td><a href="#" onclick="add_tag('<?=$Tag?>'); return false;"><?=$Tag?></a></td>
  372. <?
  373. $x++;
  374. if ($x % 7 == 0) {
  375. ?>
  376. </tr>
  377. <tr>
  378. <?
  379. }
  380. }
  381. if ($x % 7 != 0) { // Padding
  382. ?>
  383. <td colspan="<?=(7 - ($x % 7))?>"> </td>
  384. <? } ?>
  385. </tr>
  386. </table>
  387. <table class="layout cat_list">
  388. <tr>
  389. <td class="label">
  390. <a class="brackets" data-toggle-target="#taglist" data-toggle-replace="<?=(empty($LoggedUser['ShowTags']) ? 'Hide tags' : 'View tags')?>"><?=(empty($LoggedUser['ShowTags']) ? 'View tags' : 'Hide tags')?></a>
  391. </td>
  392. </tr>
  393. </table>
  394. <div class="submit ft_submit">
  395. <span style="float: left;"><?=number_format($NumResults)?> Results</span>
  396. <input type="submit" value="Filter torrents" />
  397. <input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
  398. <input type="hidden" name="searchsubmit" value="1" />
  399. <input type="button" value="Reset" onclick="location.href = 'torrents.php<? if (isset($_GET['action']) && $_GET['action'] === 'advanced') { ?>?action=advanced<? } ?>'" />
  400. &nbsp;&nbsp;
  401. <? if ($Search->has_filters()) { ?>
  402. <input type="submit" name="setdefault" value="Make default" />
  403. <? }
  404. if (!empty($LoggedUser['DefaultSearch'])) { ?>
  405. <input type="submit" name="cleardefault" value="Clear default" />
  406. <? } ?>
  407. </div>
  408. </div>
  409. </div>
  410. </form>
  411. <? if ($NumResults == 0) { ?>
  412. <div class="torrents_nomatch box pad" align="center">
  413. <h2>Your search did not match anything.</h2>
  414. <p>Make sure all names are spelled correctly, or try making your search less specific.</p>
  415. </div>
  416. </div>
  417. <? View::show_footer();die();
  418. }
  419. if ($NumResults < ($Page - 1) * TORRENTS_PER_PAGE + 1) {
  420. $LastPage = ceil($NumResults / TORRENTS_PER_PAGE);
  421. $Pages = Format::get_pages(0, $NumResults, TORRENTS_PER_PAGE);
  422. ?>
  423. <div class="torrents_nomatch box pad" align="center">
  424. <h2>The requested page contains no matches.</h2>
  425. <p>You are requesting page <?=$Page?>, but the search returned only <?=number_format($LastPage) ?> pages.</p>
  426. </div>
  427. <div class="linkbox">Go to page <?=$Pages?></div>
  428. </div>
  429. <?
  430. View::show_footer();die();
  431. }
  432. // List of pages
  433. $Pages = Format::get_pages($Page, $NumResults, TORRENTS_PER_PAGE);
  434. $Bookmarks = Bookmarks::all_bookmarks('torrent');
  435. ?>
  436. <div class="linkbox"><?=$Pages?></div>
  437. <div class="box">
  438. <table class="torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>" id="torrent_table">
  439. <tr class="colhead">
  440. <? if ($GroupResults) { ?>
  441. <td class="small"></td>
  442. <? } ?>
  443. <td class="small cats_col"></td>
  444. <td>Name / <a href="<?=header_link('year')?>">Year</a></td>
  445. <td>Files</td>
  446. <td><a href="<?=header_link('time')?>">Time</a></td>
  447. <td><a href="<?=header_link('size')?>">Size</a></td>
  448. <td class="sign snatches">
  449. <a href="<?=header_link('snatched')?>">
  450. <svg width="15" height="15" fill="white" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98"><path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path></svg>
  451. </a>
  452. </td>
  453. <td class="sign seeders">
  454. <a href="<?=header_link('seeders')?>">
  455. <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>
  456. </a>
  457. </td>
  458. <td class="sign leechers">
  459. <a href="<?=header_link('leechers')?>">
  460. <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>
  461. </a>
  462. </td>
  463. </tr>
  464. <?
  465. // Start printing torrent list
  466. foreach ($Results as $Key => $GroupID) {
  467. $GroupInfo = $Groups[$GroupID];
  468. if (empty($GroupInfo['Torrents'])) {
  469. continue;
  470. }
  471. $CategoryID = $GroupInfo['CategoryID'];
  472. $GroupYear = $GroupInfo['Year'];
  473. $Artists = $GroupInfo['Artists'];
  474. $GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
  475. $GroupPages = $GroupInfo['Pages'];
  476. $GroupStudio = $GroupInfo['Studio'];
  477. $GroupDLsiteID = $GroupInfo['DLSiteID'];
  478. $GroupName = empty($GroupInfo['Name']) ? (empty($GroupInfo['NameRJ']) ? $GroupInfo['NameJP'] : $GroupInfo['NameRJ']) : $GroupInfo['Name'];
  479. if ($GroupResults) {
  480. $Torrents = $GroupInfo['Torrents'];
  481. $GroupTime = $MaxSize = $TotalLeechers = $TotalSeeders = $TotalSnatched = 0;
  482. foreach ($Torrents as $T) {
  483. $GroupTime = max($GroupTime, strtotime($T['Time']));
  484. $MaxSize = max($MaxSize, $T['Size']);
  485. $TotalLeechers += $T['Leechers'];
  486. $TotalSeeders += $T['Seeders'];
  487. $TotalSnatched += $T['Snatched'];
  488. }
  489. } else {
  490. $TorrentID = $Key;
  491. $Torrents = [$TorrentID => $GroupInfo['Torrents'][$TorrentID]];
  492. }
  493. $TorrentTags = new Tags($GroupInfo['TagList']);
  494. if (isset($Artists)) {
  495. $DisplayName = '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
  496. } else {
  497. $DisplayName = '';
  498. }
  499. $SnatchedGroupClass = $GroupInfo['Flags']['IsSnatched'] ? ' snatched_group' : '';
  500. if ($GroupResults && (count($Torrents) > 1 && isset($GroupedCategories[$CategoryID - 1]))) {
  501. // These torrents are in a group
  502. $CoverArt = $GroupInfo['WikiImage'];
  503. $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
  504. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  505. $DisplayName .= "onmouseover=\"getCover(event)\" data-cover=\"".ImageTools::process($CoverArt)."\" onmouseleave=\"ungetCover(event)\" ";
  506. }
  507. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  508. if ($GroupYear) {
  509. $DisplayName .= " [$GroupYear]";
  510. }
  511. if ($GroupStudio) {
  512. $DisplayName .= " [$GroupStudio]";
  513. }
  514. if ($GroupCatalogueNumber) {
  515. $DisplayName .= " [$GroupCatalogueNumber]";
  516. }
  517. if ($GroupPages) {
  518. $DisplayName .= " [{$GroupPages}p]";
  519. }
  520. if ($GroupDLsiteID) {
  521. $DisplayName .= " [$GroupDLsiteID]";
  522. }
  523. ?>
  524. <tr class="group<?=$SnatchedGroupClass?>">
  525. <?
  526. $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
  527. ?>
  528. <td class="center">
  529. <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
  530. <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>
  531. </div>
  532. </td>
  533. <td class="center cats_col">
  534. <div title="<?=Format::pretty_category($CategoryID)?>" class="tooltip <?=Format::css_category($CategoryID)?>">
  535. </div>
  536. </td>
  537. <td colspan="2" class="big_info">
  538. <div class="group_info clear">
  539. <?=$DisplayName?>
  540. <? if (in_array($GroupID, $Bookmarks)) { ?>
  541. <span class="remove_bookmark float_right">
  542. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  543. </span>
  544. <? } else { ?>
  545. <span class="add_bookmark float_right">
  546. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  547. </span>
  548. <? } ?>
  549. <br />
  550. <div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?></div>
  551. </div>
  552. </td>
  553. <td class="nobr"><?=time_diff($GroupTime, 1)?></td>
  554. <td class="number_column nobr"><?=Format::get_size($MaxSize)?> (Max)</td>
  555. <td class="number_column"><?=number_format($TotalSnatched)?></td>
  556. <td class="number_column<?=($TotalSeeders == 0 ? ' r00' : '')?>"><?=number_format($TotalSeeders)?></td>
  557. <td class="number_column"><?=number_format($TotalLeechers)?></td>
  558. </tr>
  559. <?
  560. foreach ($Torrents as $TorrentID => $Data) {
  561. $Data['CategoryID'] = $CategoryID;
  562. // All of the individual torrents in the group
  563. //Get report info for each torrent, use the cache if available, if not, add to it.
  564. $Reported = false;
  565. $Reports = Torrents::get_reports($TorrentID);
  566. if (count($Reports) > 0) {
  567. $Reported = true;
  568. }
  569. $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
  570. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  571. if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
  572. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  573. $Tor = new BencodeTorrent($TorrentFile);
  574. $TorrentFileName = $Tor->Dec['info']['name'];
  575. $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
  576. }
  577. $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'];
  578. ?>
  579. <tr class="group_torrent groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
  580. <td colspan="3">
  581. <span>
  582. [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
  583. | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
  584. <? if (Torrents::can_use_token($Data)) { ?>
  585. | <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>
  586. <? } ?>
  587. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  588. </span>
  589. &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>
  590. </td>
  591. <td class="number_column"><?=$Data['FileCount']?></td>
  592. <td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
  593. <td class="number_column nobr"><?=Format::get_size($Data['Size'])?></td>
  594. <td class="number_column"><?=number_format($Data['Snatched'])?></td>
  595. <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
  596. <td class="number_column"><?=number_format($Data['Leechers'])?></td>
  597. </tr>
  598. <?
  599. }
  600. } else {
  601. // Viewing a type that does not require grouping
  602. list($TorrentID, $Data) = each($Torrents);
  603. $Reported = false;
  604. $Reports = Torrents::get_reports($TorrentID);
  605. if (count($Reports) > 0) {
  606. $Reported = true;
  607. }
  608. $Data['CategoryID'] = $CategoryID;
  609. $CoverArt = $GroupInfo['WikiImage'];
  610. $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
  611. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  612. $DisplayName .= "onmouseover=\"getCover(event)\" data-cover=\"".ImageTools::process($CoverArt)."\" onmouseleave=\"ungetCover(event)\" ";
  613. }
  614. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  615. if (isset($GroupedCategories[$CategoryID - 1])) {
  616. if ($GroupYear) {
  617. $DisplayName .= " [$GroupYear]";
  618. }
  619. if ($GroupStudio) {
  620. $DisplayName .= " [$GroupStudio]";
  621. }
  622. if ($GroupCatalogueNumber) {
  623. $DisplayName .= " [$GroupCatalogueNumber]";
  624. }
  625. if ($GroupPages) {
  626. $DisplayName .= " [{$GroupPages}p]";
  627. }
  628. if ($GroupDLsiteID) {
  629. $DisplayName .= " [$GroupDLsiteID]";
  630. }
  631. $ExtraInfo = Torrents::torrent_info($Data, true, true);
  632. } elseif ($Data['IsSnatched']) {
  633. $ExtraInfo = Format::torrent_label('Snatched!');
  634. } else {
  635. $ExtraInfo = '';
  636. }
  637. $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
  638. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  639. if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
  640. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  641. $Tor = new BencodeTorrent($TorrentFile);
  642. $TorrentFileName = $Tor->Dec['info']['name'];
  643. $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
  644. }
  645. $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'];
  646. ?>
  647. <tr class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
  648. <? if ($GroupResults) { ?>
  649. <td></td>
  650. <? } ?>
  651. <td class="center cats_col">
  652. <div title="<?=Format::pretty_category($CategoryID)?>" class="tooltip <?=Format::css_category($CategoryID)?>"></div>
  653. </td>
  654. <td class="big_info">
  655. <div class="group_info clear">
  656. <div class="float_right">
  657. <span>
  658. [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download">DL</a>
  659. | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
  660. <? if (Torrents::can_use_token($Data)) { ?>
  661. | <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>
  662. <? } ?>
  663. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  664. </span>
  665. <br />
  666. <? if (in_array($GroupID, $Bookmarks)) { ?>
  667. <span class="remove_bookmark float_right">
  668. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  669. </span>
  670. <? } else { ?>
  671. <span class="add_bookmark float_right">
  672. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  673. </span>
  674. <? } ?>
  675. </div>
  676. <?=$DisplayName?>
  677. <br />
  678. <div style="display: inline;" class="torrent_info"><?=$ExtraInfo?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported">Reported</strong><? } ?></div>
  679. <div class="tags"><?=$TorrentTags->format("torrents.php?$Action&amp;taglist=")?></div>
  680. </div>
  681. </td>
  682. <td class="number_column"><?=$Data['FileCount']?></td>
  683. <td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
  684. <td class="number_column nobr"><?=Format::get_size($Data['Size'])?></td>
  685. <td class="number_column"><?=number_format($Data['Snatched'])?></td>
  686. <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
  687. <td class="number_column"><?=number_format($Data['Leechers'])?></td>
  688. </tr>
  689. <?
  690. }
  691. }
  692. ?>
  693. </table>
  694. </div>
  695. <div class="linkbox"><?=$Pages?></div>
  696. </div>
  697. <? View::show_footer(); ?>