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

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