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

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