BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

browse.php 37KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. <?php
  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. {
  6. global $OrderBy, $OrderWay;
  7. if ($SortKey === $OrderBy) {
  8. if ($OrderWay === 'desc') {
  9. $NewWay = 'asc';
  10. } else {
  11. $NewWay = 'desc';
  12. }
  13. } else {
  14. $NewWay = $DefaultWay;
  15. }
  16. return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(['order_way', 'order_by']);
  17. }
  18. if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
  19. if (!empty($_GET['searchstr'])) {
  20. $InfoHash = $_GET['searchstr'];
  21. } else {
  22. $InfoHash = $_GET['groupname'];
  23. }
  24. // Search by infohash
  25. if ($InfoHash = is_valid_torrenthash($InfoHash)) {
  26. $InfoHash = db_string(pack('H*', $InfoHash));
  27. $DB->query("
  28. SELECT ID, GroupID
  29. FROM torrents
  30. WHERE info_hash = '$InfoHash'");
  31. if ($DB->has_results()) {
  32. list($ID, $GroupID) = $DB->next_record();
  33. header("Location: torrents.php?id=$GroupID&torrentid=$ID");
  34. die();
  35. }
  36. }
  37. }
  38. // Setting default search options
  39. if (!empty($_GET['setdefault'])) {
  40. $UnsetList = ['page', 'setdefault'];
  41. $UnsetRegexp = '/(&|^)('.implode('|', $UnsetList).')=.*?(&|$)/i';
  42. $DB->query("
  43. SELECT SiteOptions
  44. FROM users_info
  45. WHERE UserID = ?", $LoggedUser['ID']);
  46. list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
  47. $SiteOptions = json_decode($SiteOptions, true) ?? [];
  48. $SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
  49. $DB->query("
  50. UPDATE users_info
  51. SET SiteOptions = ?
  52. WHERE UserID = ?", json_encode($SiteOptions), $LoggedUser['ID']);
  53. $Cache->begin_transaction("user_info_heavy_$UserID");
  54. $Cache->update_row(false, ['DefaultSearch' => $SiteOptions['DefaultSearch']]);
  55. $Cache->commit_transaction(0);
  56. // Clearing default search options
  57. } elseif (!empty($_GET['cleardefault'])) {
  58. $DB->query("
  59. SELECT SiteOptions
  60. FROM users_info
  61. WHERE UserID = ?", $LoggedUser['ID']);
  62. list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
  63. $SiteOptions = json_decode($SiteOptions, true) ?? [];
  64. $SiteOptions['DefaultSearch'] = '';
  65. $DB->query("
  66. UPDATE users_info
  67. SET SiteOptions = ?
  68. WHERE UserID = ?", json_encode($SiteOptions), $LoggedUser['ID']);
  69. $Cache->begin_transaction("user_info_heavy_$UserID");
  70. $Cache->update_row(false, ['DefaultSearch' => '']);
  71. $Cache->commit_transaction(0);
  72. // Use default search options
  73. } elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) === 1 && isset($_GET['page']))) {
  74. if (!empty($LoggedUser['DefaultSearch'])) {
  75. if (!empty($_GET['page'])) {
  76. $Page = $_GET['page'];
  77. parse_str($LoggedUser['DefaultSearch'], $_GET);
  78. $_GET['page'] = $Page;
  79. } else {
  80. parse_str($LoggedUser['DefaultSearch'], $_GET);
  81. }
  82. }
  83. }
  84. // Terms were not submitted via the search form
  85. if (isset($_GET['searchsubmit'])) {
  86. $GroupResults = !empty($_GET['group_results']);
  87. } else {
  88. $GroupResults = !$LoggedUser['DisableGrouping2'];
  89. }
  90. if (!empty($_GET['order_way']) && $_GET['order_way'] === 'asc') {
  91. $OrderWay = 'asc';
  92. } else {
  93. $OrderWay = 'desc';
  94. }
  95. if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_by']])) {
  96. $OrderBy = 'time'; // For header links
  97. } else {
  98. $OrderBy = $_GET['order_by'];
  99. }
  100. $Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
  101. $Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
  102. if (isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] === 1) {
  103. $Search->insert_hidden_tags('!lolicon !shotacon !toddlercon');
  104. }
  105. if (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] === 1) {
  106. $Search->insert_hidden_tags('!scat');
  107. }
  108. if (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] === 1) {
  109. $Search->insert_hidden_tags('!snuff');
  110. }
  111. $Results = $Search->query($_GET);
  112. $Groups = $Search->get_groups();
  113. $NumResults = $Search->record_count();
  114. $HideFilter = isset($LoggedUser['ShowTorFilter']) && $LoggedUser['ShowTorFilter'] === 0;
  115. // This is kinda ugly, but the enormous if paragraph was really hard to read
  116. $AdvancedSearch = !empty($_GET['action']) && $_GET['action'] === 'advanced';
  117. $AdvancedSearch |= !empty($LoggedUser['SearchType']) && (empty($_GET['action']) || $_GET['action'] === 'advanced');
  118. $AdvancedSearch &= check_perms('site_advanced_search');
  119. if ($AdvancedSearch) {
  120. $Action = 'action=advanced';
  121. $HideBasic = ' hidden';
  122. $HideAdvanced = '';
  123. } else {
  124. $Action = 'action=basic';
  125. $HideBasic = '';
  126. $HideAdvanced = ' hidden';
  127. }
  128. # Start the search form
  129. View::show_header('Browse Torrents', 'browse');
  130. ?>
  131. <div class="thin widethin">
  132. <div class="header">
  133. <h2>Torrents</h2>
  134. </div>
  135. <form class="search_form" name="torrents" method="get" onsubmit="$(this).disableUnset();">
  136. <div class="box filter_torrents">
  137. <div class="head">
  138. <strong>
  139. <span id="ft_basic" class="<?=$HideBasic?>">Basic Search
  140. (<a class="clickable" onclick="toggleTorrentSearch('advanced')">Advanced</a>)</span>
  141. <span id="ft_advanced" class="<?=$HideAdvanced?>">Advanced
  142. Search (<a class="clickable" onclick="toggleTorrentSearch('basic')">Basic</a>)</span>
  143. </strong>
  144. <span class="float_right">
  145. <a onclick="return toggleTorrentSearch(0);" id="ft_toggle" class="brackets"><?=$HideFilter ? 'Show' : 'Hide'?></a>
  146. </span>
  147. </div>
  148. <div id="ft_container"
  149. class="pad<?=$HideFilter ? ' hidden' : ''?>">
  150. <?php if ((isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] === 1)
  151. || (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] === 1)
  152. || (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] === 1)
  153. ) { ?>
  154. <svg title="Your profile settings exclude some results" class="search_warning tooltip" width="10" height="15">
  155. <rect x=3 width="4" height="10" rx="2" ry="2" />
  156. <circle cx="5" cy="13" r="2" /></svg>
  157. <?php } ?>
  158. <table class="layout">
  159. <tr id="catalogue_number"
  160. class="ftr_advanced<?=$HideAdvanced?>">
  161. <td class="label">
  162. <!-- Catalogue Number -->
  163. </td>
  164. <td class="ft_cataloguenumber">
  165. <input type="search" size="19" name="cataloguenumber" class="inputtext smallest fti_advanced"
  166. placeholder="Accession Number"
  167. value="<?Format::form('cataloguenumber')?>" />
  168. </td>
  169. </tr>
  170. <tr id="album_torrent_name"
  171. class="ftr_advanced<?=$HideAdvanced?>">
  172. <td class="label">
  173. <!-- Torrent Name -->
  174. </td>
  175. <td class="ft_groupname">
  176. <input type="search" spellcheck="false" size="65" name="advgroupname"
  177. class="inputtext smaller fti_advanced" placeholder="Torrent Title"
  178. value="<?Format::form('advgroupname')?>" />
  179. </td>
  180. </tr>
  181. <tr id="artist_name"
  182. class="ftr_advanced<?=$HideAdvanced?>">
  183. <td class="label">
  184. <!-- Artist Name -->
  185. </td>
  186. <td class="ft_artistname">
  187. <input type="search" spellcheck="false" size="65" id="artist" name="artistname"
  188. class="inputtext smaller fti_advanced" placeholder="Author Name"
  189. value="<?Format::form('artistname')?>"
  190. <?php Users::has_autocomplete_enabled('other'); ?>/>
  191. </td>
  192. </tr>
  193. <tr id="year" class="ftr_advanced<?=$HideAdvanced?>">
  194. <td class="label">
  195. <!-- Year -->
  196. </td>
  197. <td class="ft_year">
  198. <input type="search" name="year" class="inputtext smallest fti_advanced" placeholder="Year"
  199. value="<?Format::form('year')?>"
  200. size="12" />
  201. </td>
  202. </tr>
  203. <tr id="torrent_description"
  204. class="ftr_advanced<?=$HideAdvanced?>">
  205. <td class="label">
  206. <!-- Torrent Description -->
  207. </td>
  208. <td class="ft_description">
  209. <input type="search" spellcheck="false" size="65" name="description" class="inputtext fti_advanced"
  210. placeholder="Torrent Description"
  211. value="<?php Format::form('description') ?>" /><br /><br />
  212. Search torrent descriptions (not group information)
  213. </td>
  214. </tr>
  215. <tr id="file_list" class="ftr_advanced<?=$HideAdvanced?>">
  216. <td class="label">
  217. <!-- File List -->
  218. </td>
  219. <td class="ft_filelist">
  220. <input type="search" spellcheck="false" size="65" name="filelist" class="inputtext fti_advanced"
  221. placeholder="File List"
  222. value="<?Format::form('filelist')?>" />
  223. </td>
  224. </tr>
  225. <!-- Platforms -->
  226. <tr id="rip_specifics"
  227. class="ftr_advanced<?=$HideAdvanced?>">
  228. <td class="label">Platforms</td>
  229. <td class="nobr ft_ripspecifics">
  230. <select name="media" class="ft_media fti_advanced">
  231. <option value="">Sequencing</option>
  232. <?php foreach ($Media as $MediaName) { ?>
  233. <option value="<?=display_str($MediaName); ?>"
  234. <?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?>
  235. </option>
  236. <?php } ?>
  237. </select>
  238. <select name="media" class="ft_media fti_advanced">
  239. <option value="">Imaging</option>
  240. <?php foreach ($MediaManga as $MediaName) { ?>
  241. <option value="<?=display_str($MediaName); ?>"
  242. <?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?>
  243. </option>
  244. <?php } ?>
  245. </select>
  246. </td>
  247. </tr>
  248. <!-- Formats -->
  249. <tr id="rip_specifics"
  250. class="ftr_advanced<?=$HideAdvanced?>">
  251. <td class="label">Formats</td>
  252. <td class="nobr ft_ripspecifics">
  253. <select id=" container" name="container" class="ft_container fti_advanced">
  254. <option value="">DNA/RNA</option>
  255. <?php foreach ($Containers as $Key => $Container) { ?>
  256. <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
  257. </option>
  258. <?php } ?>
  259. </select>
  260. <select id=" container" name="container" class="ft_container fti_advanced">
  261. <option value="">Proteins</option>
  262. <?php foreach ($ContainersProt as $Key => $Container) { ?>
  263. <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
  264. </option>
  265. <?php } ?>
  266. </select>
  267. <select id=" container" name="container" class="ft_container fti_advanced">
  268. <option value="">Imaging</option>
  269. <?php foreach ($ContainersGames as $Key => $Container) { ?>
  270. <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
  271. </option>
  272. <?php } ?>
  273. </select>
  274. <select id=" container" name="container" class="ft_container fti_advanced">
  275. <option value="">Extras</option>
  276. <?php foreach ($ContainersExtra as $Key => $Container) { ?>
  277. <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
  278. </option>
  279. <?php } ?>
  280. </select>
  281. </td>
  282. </tr>
  283. <!-- Misc -->
  284. <tr id="misc" class="ftr_advanced<?=$HideAdvanced?>">
  285. <td class="label">Misc</td>
  286. <td class="nobr ft_misc">
  287. <select name="resolution" class="ft_resolution fti_advanced">
  288. <option value="">Assembly Level</option>
  289. <?php foreach ($Resolutions as $Resolution) { ?>
  290. <option value="<?=display_str($Resolution); ?>"
  291. <?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?>
  292. </option>
  293. <?php } ?>
  294. </select>
  295. <select name=" censored" class="ft_censored fti_advanced">
  296. <option value="">Alignment</option>
  297. <option value="1" <?Format::selected('censored', 1)?>>Aligned
  298. </option>
  299. <option value="0" <?Format::selected('censored', 0)?>>Unaligned
  300. </option>
  301. </select>
  302. <select name="freetorrent" class="ft_freetorrent fti_advanced">
  303. <option value="">Leech Status</option>
  304. <option value="1" <?Format::selected('freetorrent', 1)?>>Freeleech
  305. </option>
  306. <option value="2" <?Format::selected('freetorrent', 2)?>>Neutral
  307. Leech</option>
  308. <option value="3" <?Format::selected('freetorrent', 3)?>>Either
  309. </option>
  310. <option value="0" <?Format::selected('freetorrent', 0)?>>Normal
  311. </option>
  312. </select>
  313. <select name="codec" class="ft_codec fti_advanced">
  314. <option value="">License</option>
  315. <?php foreach ($Codecs as $Codec) { ?>
  316. <option value="<?=display_str($Codec); ?>" <?Format::selected('codec', $Codec)?>><?=display_str($Codec); ?>
  317. </option>
  318. <?php } ?>
  319. </select>
  320. </td>
  321. </tr>
  322. <!-- Size -->
  323. <tr id="size" class="ftr_advanced<?=$HideAdvanced?>">
  324. <td class="label">Size</td>
  325. <td class="ft_size">
  326. <input type="size_min" spellcheck="false" size="6" name="size_min" class="inputtext smaller fti_advanced"
  327. placeholder="Min"
  328. value="<?Format::form('size_min')?>" />
  329. &ndash;
  330. <input type="size_max" spellcheck="false" size="6" name="size_max" class="inputtext smaller fti_advanced"
  331. placeholder="Max"
  332. value="<?Format::form('size_max')?>" />
  333. <select name="size_unit" class="ft_size fti_advanced">
  334. <option value="">Unit</option>
  335. <option value="0" <?Format::selected('size_unit', 0)?>>B
  336. </option>
  337. <option value="1" <?Format::selected('size_unit', 1)?>>KiB
  338. </option>
  339. <option value="2" <?Format::selected('size_unit', 2)?>>MiB
  340. </option>
  341. <option value="3" <?Format::selected('size_unit', 3)?>>GiB
  342. </option>
  343. <option value="4" <?Format::selected('size_unit', 4)?>>TiB
  344. </option>
  345. </select>
  346. </td>
  347. </tr>
  348. <!-- Start basic search options -->
  349. <tr id="search_terms" class="ftr_basic<?=$HideBasic?>">
  350. <td class="label">
  351. <!-- Search Terms -->
  352. </td>
  353. <td class="ftb_searchstr">
  354. <input type="search" spellcheck="false" size="48" name="searchstr" class="inputtext fti_basic"
  355. placeholder="Search Terms"
  356. value="<?Format::form('searchstr')?>"
  357. aria-label="Terms to search">
  358. </td>
  359. </tr>
  360. <tr id="tagfilter">
  361. <td class="label">
  362. <!-- Tags (comma-separated) -->
  363. </td>
  364. <td class="ft_taglist">
  365. <input type="search" size="37" id="tags" name="taglist" class="inputtext smaller"
  366. placeholder="Tags (comma-separated)"
  367. value="<?=display_str($Search->get_terms('taglist'))?>"
  368. <?php Users::has_autocomplete_enabled('other'); ?>
  369. aria-label="Tags to search">&nbsp;
  370. <input type="radio" name="tags_type" id="tags_type0" value="0" <?Format::selected('tags_type', 0, 'checked')?>
  371. /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
  372. <input type="radio" name="tags_type" id="tags_type1" value="1" <?Format::selected('tags_type', 1, 'checked')?>
  373. /><label for="tags_type1"> All</label><br /><br />
  374. Use !tag to exclude tags
  375. </td>
  376. </tr>
  377. <tr id="order">
  378. <td class="label">Order By</td>
  379. <td class="ft_order">
  380. <select name="order_by" style="width: auto;" class="ft_order_by" aria-label="Property to order by">
  381. <option value="time" <?Format::selected('order_by', 'time')?>>Time
  382. Added</option>
  383. <option value="year" <?Format::selected('order_by', 'year')?>>Year
  384. </option>
  385. <option value="size" <?Format::selected('order_by', 'size')?>>Size
  386. </option>
  387. <option value="snatched" <?Format::selected('order_by', 'snatched')?>>Snatched
  388. </option>
  389. <option value="seeders" <?Format::selected('order_by', 'seeders')?>>Seeders
  390. </option>
  391. <option value="leechers" <?Format::selected('order_by', 'leechers')?>>Leechers
  392. </option>
  393. <option value="cataloguenumber" <?Format::selected('order_by', 'cataloguenumber')?>>Accession
  394. Number</option>
  395. <option value="random" <?Format::selected('order_by', 'random')?>>Random
  396. </option>
  397. </select>
  398. <select name="order_way" class="ft_order_way" aria-label="Direction to order">
  399. <option value="desc" <?Format::selected('order_way', 'desc')?>>Descending
  400. </option>
  401. <option value="asc" <?Format::selected('order_way', 'asc')?>>Ascending
  402. </option>
  403. </select>
  404. </td>
  405. </tr>
  406. <tr id="search_group_results">
  407. <td class="label">
  408. <label for="group_results">Group Torrents</label>
  409. </td>
  410. <td class="ft_group_results">
  411. <input type="checkbox" value="1" name="group_results" id="group_results" <?=$GroupResults ? ' checked="checked"' : ''?>
  412. />
  413. </td>
  414. </tr>
  415. </table>
  416. <table class="layout cat_list ft_cat_list">
  417. <?php
  418. $x = 0;
  419. reset($Categories);
  420. foreach ($Categories as $CatKey => $CatName) {
  421. if ($x % 7 === 0) {
  422. if ($x > 0) {
  423. ?>
  424. </tr>
  425. <?php
  426. } ?>
  427. <tr>
  428. <?php
  429. }
  430. $x++; ?>
  431. <td>
  432. <input type="checkbox"
  433. name="filter_cat[<?=($CatKey + 1)?>]"
  434. id="cat_<?=($CatKey + 1)?>" value="1" <?php if (isset($_GET['filter_cat'][$CatKey + 1])) { ?>
  435. checked="checked"<?php } ?> />
  436. <label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
  437. </td>
  438. <?php
  439. }
  440. ?>
  441. </tr>
  442. </table>
  443. <table
  444. class="layout cat_list<?php if (empty($LoggedUser['ShowTags'])) { ?> hidden<?php } ?>"
  445. id="taglist">
  446. <tr>
  447. <?php
  448. $GenreTags = $Cache->get_value('genre_tags');
  449. if (!$GenreTags) {
  450. $DB->query('
  451. SELECT Name
  452. FROM tags
  453. WHERE TagType = \'genre\'
  454. ORDER BY Name');
  455. $GenreTags = $DB->collect('Name');
  456. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  457. }
  458. $x = 0;
  459. foreach ($GenreTags as $Tag) {
  460. ?>
  461. <td><a href="#"
  462. onclick="add_tag('<?=$Tag?>'); return false;"><?=$Tag?></a></td>
  463. <?php
  464. $x++;
  465. if ($x % 7 === 0) {
  466. ?>
  467. </tr>
  468. <tr>
  469. <?php
  470. }
  471. }
  472. if ($x % 7 !== 0) { // Padding
  473. ?>
  474. <td colspan="<?=(7 - ($x % 7))?>"> </td>
  475. <?php } ?>
  476. </tr>
  477. </table>
  478. <table class="layout cat_list">
  479. <tr>
  480. <td class="label">
  481. <a class="brackets" data-toggle-target="#taglist"
  482. data-toggle-replace="<?=(empty($LoggedUser['ShowTags']) ? 'Hide tags' : 'View tags')?>"><?=(empty($LoggedUser['ShowTags']) ? 'View tags' : 'Hide tags')?></a>
  483. </td>
  484. </tr>
  485. </table>
  486. <div class="submit ft_submit">
  487. <span class="float_left"><?=number_format($NumResults)?>
  488. Results</span>
  489. <input type="submit" value="Search" />
  490. <input type="hidden" name="action" id="ft_type"
  491. value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
  492. <input type="hidden" name="searchsubmit" value="1" />
  493. <input type="button" value="Reset"
  494. onclick="location.href = 'torrents.php<?php if (isset($_GET['action']) && $_GET['action'] === 'advanced') { ?>?action=advanced<?php } ?>'" />
  495. &nbsp;&nbsp;
  496. <?php if ($Search->has_filters()) { ?>
  497. <input type="submit" name="setdefault" value="Make Default" />
  498. <?php }
  499. if (!empty($LoggedUser['DefaultSearch'])) { ?>
  500. <input type="submit" name="cleardefault" value="Clear Default" />
  501. <?php } ?>
  502. </div>
  503. </div>
  504. </div>
  505. </form>
  506. <?php if ($NumResults === 0) { ?>
  507. <div class="torrents_nomatch box pad" align="center">
  508. <h2>Your search did not match anything.</h2>
  509. <p>Make sure all names are spelled correctly, or try making your search less specific.</p>
  510. </div>
  511. </div>
  512. <?php
  513. View::show_footer();
  514. die();
  515. }
  516. if ($NumResults < ($Page - 1) * TORRENTS_PER_PAGE + 1) {
  517. $LastPage = ceil($NumResults / TORRENTS_PER_PAGE);
  518. $Pages = Format::get_pages(0, $NumResults, TORRENTS_PER_PAGE); ?>
  519. <div class="torrents_nomatch box pad" align="center">
  520. <h2>The requested page contains no matches.</h2>
  521. <p>You are requesting page <?=$Page?>, but the search returned only
  522. <?=number_format($LastPage) ?> pages.</p>
  523. </div>
  524. <div class="linkbox">Go to page <?=$Pages?>
  525. </div>
  526. </div>
  527. <?php
  528. View::show_footer();
  529. die();
  530. }
  531. // List of pages
  532. $Pages = Format::get_pages($Page, $NumResults, TORRENTS_PER_PAGE);
  533. $Bookmarks = Bookmarks::all_bookmarks('torrent');
  534. ?>
  535. <div class="linkbox"><?=$Pages?>
  536. </div>
  537. <table
  538. class="box torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>"
  539. id="torrent_table">
  540. <tr class="colhead">
  541. <?php if ($GroupResults) { ?>
  542. <td class="small"></td>
  543. <?php } ?>
  544. <td class="small cats_col"></td>
  545. <td>Name / <a
  546. href="<?=header_link('year')?>">Year</a>
  547. </td>
  548. <td>Files</td>
  549. <td><a
  550. href="<?=header_link('time')?>">Time</a>
  551. </td>
  552. <td><a
  553. href="<?=header_link('size')?>">Size</a>
  554. </td>
  555. <td class="sign snatches">
  556. <a href="<?=header_link('snatched')?>"
  557. aria-label="Sort by snatches">
  558. <svg width="15" height="15" fill="black" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98">
  559. <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>
  560. </svg>
  561. </a>
  562. </td>
  563. <td class="sign seeders">
  564. <a href="<?=header_link('seeders')?>"
  565. aria-label="Sort by seeders">
  566. <svg width="11" height="15" fill="black" class="tooltip" alt="Seeders" title="Seeders">
  567. <polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon>
  568. </svg>
  569. </a>
  570. </td>
  571. <td class="sign leechers">
  572. <a href="<?=header_link('leechers')?>"
  573. aria-label="Sort by leechers">
  574. <svg width="11" height="15" fill="black" class="tooltip" alt="Leechers" title="Leechers">
  575. <polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon>
  576. </svg>
  577. </a>
  578. </td>
  579. </tr>
  580. <?php
  581. // Start printing torrent list
  582. foreach ($Results as $Key => $GroupID) {
  583. $GroupInfo = $Groups[$GroupID];
  584. if (empty($GroupInfo['Torrents'])) {
  585. continue;
  586. }
  587. $CategoryID = $GroupInfo['CategoryID'];
  588. $GroupYear = $GroupInfo['Year'];
  589. $Artists = $GroupInfo['Artists'];
  590. $GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
  591. $GroupPages = $GroupInfo['Pages'];
  592. $GroupStudio = $GroupInfo['Studio'];
  593. $GroupDLsiteID = $GroupInfo['DLSiteID'];
  594. $GroupName = empty($GroupInfo['Name']) ? (empty($GroupInfo['NameRJ']) ? $GroupInfo['NameJP'] : $GroupInfo['NameRJ']) : $GroupInfo['Name'];
  595. if ($GroupResults) {
  596. $Torrents = $GroupInfo['Torrents'];
  597. $GroupTime = $MaxSize = $TotalLeechers = $TotalSeeders = $TotalSnatched = 0;
  598. foreach ($Torrents as $T) {
  599. $GroupTime = max($GroupTime, strtotime($T['Time']));
  600. $MaxSize = max($MaxSize, $T['Size']);
  601. $TotalLeechers += $T['Leechers'];
  602. $TotalSeeders += $T['Seeders'];
  603. $TotalSnatched += $T['Snatched'];
  604. }
  605. } else {
  606. $TorrentID = $Key;
  607. $Torrents = [$TorrentID => $GroupInfo['Torrents'][$TorrentID]];
  608. }
  609. $TorrentTags = new Tags($GroupInfo['TagList']);
  610. if (isset($Artists)) {
  611. $DisplayName = '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
  612. } else {
  613. $DisplayName = '';
  614. }
  615. $SnatchedGroupClass = $GroupInfo['Flags']['IsSnatched'] ? ' snatched_group' : '';
  616. if ($GroupResults && (count($Torrents) > 1 && isset($GroupedCategories[$CategoryID - 1]))) {
  617. // These torrents are in a group
  618. $CoverArt = $GroupInfo['WikiImage'];
  619. $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
  620. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  621. $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
  622. }
  623. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  624. if ($GroupYear) {
  625. $DisplayName .= " [$GroupYear]";
  626. }
  627. if ($GroupStudio) {
  628. $DisplayName .= " [$GroupStudio]";
  629. }
  630. if ($GroupCatalogueNumber) {
  631. $DisplayName .= " [$GroupCatalogueNumber]";
  632. }
  633. if ($GroupPages) {
  634. $DisplayName .= " [{$GroupPages}p]";
  635. }
  636. if ($GroupDLsiteID) {
  637. $DisplayName .= " [$GroupDLsiteID]";
  638. } ?>
  639. <tr class="group<?=$SnatchedGroupClass?>">
  640. <?php
  641. $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1); ?>
  642. <td class="center">
  643. <div id="showimg_<?=$GroupID?>"
  644. class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
  645. <a class="tooltip show_torrents_link"
  646. onclick="toggle_group(<?=$GroupID?>, this, event)"
  647. title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
  648. </div>
  649. </td>
  650. <td class="center cats_col">
  651. <div title="<?=Format::pretty_category($CategoryID)?>"
  652. class="tooltip <?=Format::css_category($CategoryID)?>">
  653. </div>
  654. </td>
  655. <td colspan="2" class="big_info">
  656. <div class="group_info clear">
  657. <?=$DisplayName?>
  658. <?php if (in_array($GroupID, $Bookmarks)) { ?>
  659. <span class="remove_bookmark float_right">
  660. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
  661. class="brackets"
  662. onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove
  663. bookmark</a>
  664. </span>
  665. <?php } else { ?>
  666. <span class="add_bookmark float_right">
  667. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
  668. class="brackets"
  669. onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  670. </span>
  671. <?php } ?>
  672. <br />
  673. <div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?>
  674. </div>
  675. </div>
  676. </td>
  677. <td class="nobr"><?=time_diff($GroupTime, 1)?>
  678. </td>
  679. <td class="number_column nobr"><?=Format::get_size($MaxSize)?>
  680. (Max)</td>
  681. <td class="number_column"><?=number_format($TotalSnatched)?>
  682. </td>
  683. <td
  684. class="number_column<?=($TotalSeeders === 0 ? ' r00' : '')?>">
  685. <?=number_format($TotalSeeders)?>
  686. </td>
  687. <td class="number_column"><?=number_format($TotalLeechers)?>
  688. </td>
  689. </tr>
  690. <?php
  691. foreach ($Torrents as $TorrentID => $Data) {
  692. $Data['CategoryID'] = $CategoryID;
  693. // All of the individual torrents in the group
  694. // Get report info for each torrent, use the cache if available, if not, add to it
  695. $Reported = false;
  696. $Reports = Torrents::get_reports($TorrentID);
  697. if (count($Reports) > 0) {
  698. $Reported = true;
  699. }
  700. $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
  701. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  702. if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
  703. if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
  704. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  705. $Tor = new BencodeTorrent($TorrentFile, false, false);
  706. $TorrentFileName = $Tor->Dec['info']['name'];
  707. $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
  708. }
  709. $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'];
  710. } ?>
  711. <tr
  712. class="group_torrent groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
  713. <td colspan="3">
  714. <span>
  715. [ <a href="<?=$TorrentDL?>" class="tooltip"
  716. title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
  717. <?php if (isset($TorrentMG)) { ?>
  718. | <a href="<?=$TorrentMG?>" class="tooltip"
  719. title="Magnet Link">MG</a>
  720. <?php }
  721. if (Torrents::can_use_token($Data)) { ?>
  722. | <a
  723. href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
  724. class="tooltip" title="Use a FL Token"
  725. onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  726. <?php } ?>
  727. | <a
  728. href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
  729. class="tooltip" title="Report">RP</a> ]
  730. </span>
  731. &raquo; <a
  732. href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Data)?><?php if ($Reported) { ?> / <strong
  733. class="torrent_label tl_reported tooltip"
  734. title="Type: <?=ucfirst($Reports[0]['Type'])?><br>Comment: <?=htmlentities(htmlentities($Reports[0]['UserComment']))?>">Reported</strong><?php } ?></a>
  735. </td>
  736. <td class="number_column"><?=$Data['FileCount']?>
  737. </td>
  738. <td class="nobr"><?=time_diff($Data['Time'], 1)?>
  739. </td>
  740. <td class="number_column nobr"><?=Format::get_size($Data['Size'])?>
  741. </td>
  742. <td class="number_column"><?=number_format($Data['Snatched'])?>
  743. </td>
  744. <td
  745. class="number_column<?=($Data['Seeders'] === 0) ? ' r00' : ''?>">
  746. <?=number_format($Data['Seeders'])?>
  747. </td>
  748. <td class="number_column"><?=number_format($Data['Leechers'])?>
  749. </td>
  750. </tr>
  751. <?php
  752. }
  753. } else {
  754. // Viewing a type that does not require grouping
  755. $TorrentID = key($Torrents);
  756. $Data = current($Torrents);
  757. $Reported = false;
  758. $Reports = Torrents::get_reports($TorrentID);
  759. if (count($Reports) > 0) {
  760. $Reported = true;
  761. }
  762. $Data['CategoryID'] = $CategoryID;
  763. $CoverArt = $GroupInfo['WikiImage'];
  764. $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
  765. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  766. $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
  767. }
  768. $DisplayName .= "dir=\"ltr\">$GroupName</a>";
  769. if (isset($GroupedCategories[$CategoryID - 1])) {
  770. if ($GroupYear) {
  771. $DisplayName .= " [$GroupYear]";
  772. }
  773. if ($GroupStudio) {
  774. $DisplayName .= " [$GroupStudio]";
  775. }
  776. if ($GroupCatalogueNumber) {
  777. $DisplayName .= " [$GroupCatalogueNumber]";
  778. }
  779. if ($GroupPages) {
  780. $DisplayName .= " [{$GroupPages}p]";
  781. }
  782. if ($GroupDLsiteID) {
  783. $DisplayName .= " [$GroupDLsiteID]";
  784. }
  785. $ExtraInfo = Torrents::torrent_info($Data, true, true);
  786. } elseif ($Data['IsSnatched']) {
  787. $ExtraInfo = Format::torrent_label('Snatched!');
  788. } else {
  789. $ExtraInfo = '';
  790. }
  791. $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
  792. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  793. if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
  794. if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
  795. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  796. $Tor = new BencodeTorrent($TorrentFile, false, false);
  797. $TorrentFileName = $Tor->Dec['info']['name'];
  798. $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
  799. }
  800. $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'];
  801. } ?>
  802. <tr
  803. class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
  804. <?php if ($GroupResults) { ?>
  805. <td></td>
  806. <?php } ?>
  807. <td class="center cats_col">
  808. <div title="<?=Format::pretty_category($CategoryID)?>"
  809. class="tooltip <?=Format::css_category($CategoryID)?>"></div>
  810. </td>
  811. <td class="big_info">
  812. <div class="group_info clear">
  813. <div class="float_right">
  814. <span>
  815. [ <a href="<?=$TorrentDL?>" class="tooltip"
  816. title="Download">DL</a>
  817. <?php if (isset($TorrentMG)) { ?>
  818. | <a href="<?=$TorrentMG?>" class="tooltip"
  819. title="Magnet Link">MG</a>
  820. <?php }
  821. if (Torrents::can_use_token($Data)) { ?>
  822. | <a
  823. href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
  824. class="tooltip" title="Use a FL Token"
  825. onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  826. <?php } ?>
  827. | <a
  828. href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
  829. class="tooltip" title="Report">RP</a> ]
  830. </span>
  831. <br />
  832. <?php if (in_array($GroupID, $Bookmarks)) { ?>
  833. <span class="remove_bookmark float_right">
  834. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
  835. class="brackets"
  836. onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove
  837. bookmark</a>
  838. </span>
  839. <?php } else { ?>
  840. <span class="add_bookmark float_right">
  841. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
  842. class="brackets"
  843. onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  844. </span>
  845. <?php } ?>
  846. </div>
  847. <?=$DisplayName?>
  848. <br />
  849. <div style="display: inline;" class="torrent_info"><?=$ExtraInfo?><?php if ($Reported) { ?> / <strong
  850. class="torrent_label tl_reported tooltip"
  851. title="Type: <?=ucfirst($Reports[0]['Type'])?><br>Comment: <?=htmlentities(htmlentities($Reports[0]['UserComment']))?>">Reported</strong><?php } ?>
  852. </div>
  853. <div class="tags"><?=$TorrentTags->format("torrents.php?$Action&amp;taglist=")?>
  854. </div>
  855. </div>
  856. </td>
  857. <td class="number_column"><?=$Data['FileCount']?>
  858. </td>
  859. <td class="nobr"><?=time_diff($Data['Time'], 1)?>
  860. </td>
  861. <td class="number_column nobr"><?=Format::get_size($Data['Size'])?>
  862. </td>
  863. <td class="number_column"><?=number_format($Data['Snatched'])?>
  864. </td>
  865. <td
  866. class="number_column<?=($Data['Seeders'] === 0) ? ' r00' : ''?>">
  867. <?=number_format($Data['Seeders'])?>
  868. </td>
  869. <td class="number_column"><?=number_format($Data['Leechers'])?>
  870. </td>
  871. </tr>
  872. <?php
  873. }
  874. }
  875. ?>
  876. </table>
  877. <div class="linkbox"><?=$Pages?>
  878. </div>
  879. </div>
  880. <?php View::show_footer();