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

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