Gazelle/sections/torrents/browse.php

724 lines
29 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2013-11-11 08:00:59 +00:00
include(SERVER_ROOT.'/sections/torrents/functions.php');
2011-03-28 14:21:28 +00:00
// The "order by x" links on columns headers
2013-11-11 08:00:59 +00:00
function header_link($SortKey, $DefaultWay = 'desc') {
2013-05-28 08:01:02 +00:00
global $OrderBy, $OrderWay;
2013-04-17 08:00:58 +00:00
if ($SortKey == $OrderBy) {
2013-11-11 08:00:59 +00:00
if ($OrderWay == 'desc') {
$NewWay = 'asc';
2013-04-17 08:00:58 +00:00
} else {
2013-11-11 08:00:59 +00:00
$NewWay = 'desc';
2013-04-17 08:00:58 +00:00
}
} else {
$NewWay = $DefaultWay;
}
2013-11-11 08:00:59 +00:00
return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(array('order_way', 'order_by'));
}
if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
if (!empty($_GET['searchstr'])) {
$InfoHash = $_GET['searchstr'];
2013-12-13 08:00:46 +00:00
2013-11-11 08:00:59 +00:00
} else {
$InfoHash = $_GET['groupname'];
}
2013-02-22 08:00:24 +00:00
2013-11-11 08:00:59 +00:00
// Search by infohash
if ($InfoHash = is_valid_torrenthash($InfoHash)) {
$InfoHash = db_string(pack('H*', $InfoHash));
$DB->query("
SELECT ID, GroupID
FROM torrents
WHERE info_hash = '$InfoHash'");
if ($DB->has_results()) {
list($ID, $GroupID) = $DB->next_record();
header("Location: torrents.php?id=$GroupID&torrentid=$ID");
die();
}
}
2011-03-28 14:21:28 +00:00
}
// Setting default search options
2013-11-11 08:00:59 +00:00
if (!empty($_GET['setdefault'])) {
$UnsetList = array('page', 'setdefault');
$UnsetRegexp = '/(&|^)('.implode('|', $UnsetList).')=.*?(&|$)/i';
2011-03-28 14:21:28 +00:00
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
2013-11-11 08:00:59 +00:00
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
if (!empty($SiteOptions)) {
$SiteOptions = unserialize($SiteOptions);
} else {
$SiteOptions = array();
}
$SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
2013-07-04 08:00:56 +00:00
$DB->query("
UPDATE users_info
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction("user_info_heavy_$UserID");
2013-11-11 08:00:59 +00:00
$Cache->update_row(false, array('DefaultSearch' => $SiteOptions['DefaultSearch']));
2011-03-28 14:21:28 +00:00
$Cache->commit_transaction(0);
// Clearing default search options
2013-11-11 08:00:59 +00:00
} elseif (!empty($_GET['cleardefault'])) {
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
2013-11-11 08:00:59 +00:00
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
2013-04-17 08:00:58 +00:00
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = '';
2013-07-04 08:00:56 +00:00
$DB->query("
UPDATE users_info
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('DefaultSearch' => ''));
2011-03-28 14:21:28 +00:00
$Cache->commit_transaction(0);
// Use default search options
2013-11-11 08:00:59 +00:00
} elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) === 1 && isset($_GET['page']))) {
if (!empty($LoggedUser['DefaultSearch'])) {
if (!empty($_GET['page'])) {
$Page = $_GET['page'];
parse_str($LoggedUser['DefaultSearch'], $_GET);
$_GET['page'] = $Page;
} else {
parse_str($LoggedUser['DefaultSearch'], $_GET);
}
2011-03-28 14:21:28 +00:00
}
}
2013-11-11 08:00:59 +00:00
// Terms were not submitted via the search form
2015-01-28 08:00:26 +00:00
if (isset($_GET['searchsubmit'])) {
$GroupResults = !empty($_GET['group_results']);
2013-11-11 08:00:59 +00:00
} else {
2015-01-28 08:00:26 +00:00
$GroupResults = !$LoggedUser['DisableGrouping2'];
2011-03-28 14:21:28 +00:00
}
2013-11-11 08:00:59 +00:00
if (!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
$OrderWay = 'asc';
} else {
$OrderWay = 'desc';
}
2013-02-22 08:00:24 +00:00
2015-01-28 08:00:26 +00:00
if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_by']])) {
$OrderBy = 'time'; // For header links
2013-11-11 08:00:59 +00:00
} else {
2015-01-28 08:00:26 +00:00
$OrderBy = $_GET['order_by'];
2013-11-11 08:00:59 +00:00
}
2011-03-28 14:21:28 +00:00
2015-01-28 08:00:26 +00:00
$Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
$Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
$Results = $Search->query($_GET);
$Groups = $Search->get_groups();
$NumResults = $Search->record_count();
2013-11-11 08:00:59 +00:00
$HideFilter = isset($LoggedUser['ShowTorFilter']) && $LoggedUser['ShowTorFilter'] == 0;
// This is kinda ugly, but the enormous if paragraph was really hard to read
$AdvancedSearch = !empty($_GET['action']) && $_GET['action'] == 'advanced';
$AdvancedSearch |= !empty($LoggedUser['SearchType']) && (empty($_GET['action']) || $_GET['action'] == 'advanced');
$AdvancedSearch &= check_perms('site_advanced_search');
if ($AdvancedSearch) {
$Action = 'action=advanced';
$HideBasic = ' hidden';
$HideAdvanced = '';
2013-04-17 08:00:58 +00:00
} else {
2013-11-11 08:00:59 +00:00
$Action = 'action=basic';
$HideBasic = '';
$HideAdvanced = ' hidden';
2013-04-17 08:00:58 +00:00
}
2011-03-28 14:21:28 +00:00
2013-11-11 08:00:59 +00:00
View::show_header('Browse Torrents', 'browse');
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
<div class="thin widethin">
<div class="header">
<h2>Torrents</h2>
</div>
<form class="search_form" name="torrents" method="get" action="" onsubmit="$(this).disableUnset();">
<div class="box filter_torrents">
<div class="head">
<strong>
<span id="ft_basic_text" class="<?=$HideBasic?>">Basic /</span>
<span id="ft_basic_link" class="<?=$HideAdvanced?>"><a href="#" onclick="return toggleTorrentSearch('basic');">Basic</a> /</span>
<span id="ft_advanced_text" class="<?=$HideAdvanced?>">Advanced</span>
<span id="ft_advanced_link" class="<?=$HideBasic?>"><a href="#" onclick="return toggleTorrentSearch('advanced');">Advanced</a></span>
Search
</strong>
<span style="float: right;">
<a href="#" onclick="return toggleTorrentSearch(0);" id="ft_toggle" class="brackets"><?=$HideFilter ? 'Show' : 'Hide'?></a>
</span>
</div>
<div id="ft_container" class="pad<?=$HideFilter ? ' hidden' : ''?>">
2012-09-01 08:00:24 +00:00
<table class="layout">
2013-11-11 08:00:59 +00:00
<tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
<td class="label">Artist name:</td>
<td colspan="3" class="ft_artistname">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="artistname" class="inputtext smaller fti_advanced" value="<?Format::form('artistname')?>" />
2013-11-11 08:00:59 +00:00
</td>
</tr>
<tr id="album_torrent_name" class="ftr_advanced<?=$HideAdvanced?>">
<td class="label">Album/Torrent name:</td>
<td colspan="3" class="ft_groupname">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="groupname" class="inputtext smaller fti_advanced" value="<?Format::form('groupname')?>" />
2013-11-11 08:00:59 +00:00
</td>
</tr>
<tr id="record_label" class="ftr_advanced<?=$HideAdvanced?>">
<td class="label">Record label:</td>
<td colspan="3" class="ft_recordlabel">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="recordlabel" class="inputtext smaller fti_advanced" value="<?Format::form('recordlabel')?>" />
2013-11-11 08:00:59 +00:00
</td>
</tr>
<tr id="catalogue_number_year" class="ftr_advanced<?=$HideAdvanced?>">
<td class="label">Catalogue number:</td>
<td class="ft_cataloguenumber">
2014-03-23 08:00:50 +00:00
<input type="search" size="40" name="cataloguenumber" class="inputtext smallest fti_advanced" value="<?Format::form('cataloguenumber')?>" />
2013-11-11 08:00:59 +00:00
</td>
<td class="label">Year:</td>
<td class="ft_year">
2014-03-23 08:00:50 +00:00
<input type="search" name="year" class="inputtext smallest fti_advanced" value="<?Format::form('year')?>" size="4" />
2013-11-11 08:00:59 +00:00
</td>
</tr>
<tr id="edition_expand" class="ftr_advanced<?=$HideAdvanced?>">
<td colspan="4" class="center ft_edition_expand"><a href="#" class="brackets" onclick="ToggleEditionRows(); return false;">Click here to toggle searching for specific remaster information</a></td>
</tr>
<?
if (Format::form('remastertitle', true) == ''
&& Format::form('remasteryear', true) == ''
&& Format::form('remasterrecordlabel', true) == ''
&& Format::form('remastercataloguenumber', true) == ''
) {
$Hidden = ' hidden';
} else {
$Hidden = '';
}
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
<tr id="edition_title" class="ftr_advanced<?=$HideAdvanced . $Hidden?>">
<td class="label">Edition title:</td>
<td class="ft_remastertitle">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="remastertitle" class="inputtext smaller fti_advanced" value="<?Format::form('remastertitle')?>" />
2013-11-11 08:00:59 +00:00
</td>
<td class="label">Edition year:</td>
<td class="ft_remasteryear">
2014-03-23 08:00:50 +00:00
<input type="search" name="remasteryear" class="inputtext smallest fti_advanced" value="<?Format::form('remasteryear')?>" size="4" />
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-11-11 08:00:59 +00:00
<tr id="edition_label" class="ftr_advanced<?=$HideAdvanced . $Hidden?>">
<td class="label">Edition release label:</td>
<td colspan="3" class="ft_remasterrecordlabel">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="remasterrecordlabel" class="inputtext smaller fti_advanced" value="<?Format::form('remasterrecordlabel')?>" />
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-11-11 08:00:59 +00:00
<tr id="edition_catalogue" class="ftr_advanced<?=$HideAdvanced . $Hidden?>">
<td class="label">Edition catalogue number:</td>
<td colspan="3" class="ft_remastercataloguenumber">
2014-03-23 08:00:50 +00:00
<input type="search" size="40" name="remastercataloguenumber" class="inputtext smallest fti_advanced" value="<?Format::form('remastercataloguenumber')?>" />
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-11-11 08:00:59 +00:00
<tr id="file_list" class="ftr_advanced<?=$HideAdvanced?>">
<td class="label">File list:</td>
<td colspan="3" class="ft_filelist">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="filelist" class="inputtext fti_advanced" value="<?Format::form('filelist')?>" />
2013-11-11 08:00:59 +00:00
</td>
2011-03-28 14:21:28 +00:00
</tr>
2013-11-11 08:00:59 +00:00
<tr id="torrent_description" class="ftr_advanced<?=$HideAdvanced?>">
<td class="label"><span title="Search torrent descriptions (not group information)" class="tooltip">Torrent description:</span></td>
<td colspan="3" class="ft_description">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="description" class="inputtext fti_advanced" value="<?Format::form('description')?>" />
2013-11-11 08:00:59 +00:00
</td>
</tr>
<tr id="rip_specifics" class="ftr_advanced<?=$HideAdvanced?>">
<td class="label">Rip specifics:</td>
<td class="nobr ft_ripspecifics" colspan="3">
<select id="bitrate" name="encoding" class="ft_bitrate fti_advanced">
2011-03-28 14:21:28 +00:00
<option value="">Bitrate</option>
2013-11-11 08:00:59 +00:00
<? foreach ($Bitrates as $BitrateName) { ?>
<option value="<?=display_str($BitrateName); ?>"<?Format::selected('encoding', $BitrateName)?>><?=display_str($BitrateName); ?></option>
<? } ?> </select>
2013-02-22 08:00:24 +00:00
2013-11-11 08:00:59 +00:00
<select name="format" class="ft_format fti_advanced">
2011-03-28 14:21:28 +00:00
<option value="">Format</option>
2013-11-11 08:00:59 +00:00
<? foreach ($Formats as $FormatName) { ?>
<option value="<?=display_str($FormatName); ?>"<?Format::selected('format', $FormatName)?>><?=display_str($FormatName); ?></option>
<? } ?> </select>
<select name="media" class="ft_media fti_advanced">
2011-03-28 14:21:28 +00:00
<option value="">Media</option>
2013-11-11 08:00:59 +00:00
<? foreach ($Media as $MediaName) { ?>
<option value="<?=display_str($MediaName); ?>"<?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?></option>
<? } ?>
</select>
<select name="releasetype" class="ft_releasetype fti_advanced">
<option value="">Release type</option>
<? foreach ($ReleaseTypes as $ID=>$Type) { ?>
<option value="<?=display_str($ID); ?>"<?Format::selected('releasetype', $ID)?>><?=display_str($Type); ?></option>
<? } ?>
2011-03-28 14:21:28 +00:00
</select>
</td>
</tr>
2013-11-11 08:00:59 +00:00
<tr id="misc" class="ftr_advanced<?=$HideAdvanced?>">
2011-03-28 14:21:28 +00:00
<td class="label">Misc:</td>
2013-11-11 08:00:59 +00:00
<td class="nobr ft_misc" colspan="3">
<select name="haslog" class="ft_haslog fti_advanced">
2011-03-28 14:21:28 +00:00
<option value="">Has Log</option>
2013-11-11 08:00:59 +00:00
<option value="1"<?Format::selected('haslog', '1')?>>Yes</option>
<option value="0"<?Format::selected('haslog', '0')?>>No</option>
<option value="100"<?Format::selected('haslog', '100')?>>100% only</option>
<option value="-1"<?Format::selected('haslog', '-1')?>>&lt;100%/Unscored</option>
2011-03-28 14:21:28 +00:00
</select>
2013-11-11 08:00:59 +00:00
<select name="hascue" class="ft_hascue fti_advanced">
2011-03-28 14:21:28 +00:00
<option value="">Has Cue</option>
2013-11-11 08:00:59 +00:00
<option value="1"<?Format::selected('hascue', 1)?>>Yes</option>
<option value="0"<?Format::selected('hascue', 0)?>>No</option>
2011-03-28 14:21:28 +00:00
</select>
2013-11-11 08:00:59 +00:00
<select name="scene" class="ft_scene fti_advanced">
2011-03-28 14:21:28 +00:00
<option value="">Scene</option>
2013-11-11 08:00:59 +00:00
<option value="1"<?Format::selected('scene', 1)?>>Yes</option>
<option value="0"<?Format::selected('scene', 0)?>>No</option>
2011-03-28 14:21:28 +00:00
</select>
2013-11-11 08:00:59 +00:00
<select name="vanityhouse" class="ft_vanityhouse fti_advanced">
<option value="">Vanity House</option>
<option value="1"<?Format::selected('vanityhouse', 1)?>>Yes</option>
<option value="0"<?Format::selected('vanityhouse', 0)?>>No</option>
2011-03-28 14:21:28 +00:00
</select>
2013-11-11 08:00:59 +00:00
<select name="freetorrent" class="ft_freetorrent fti_advanced">
<option value="">Leech Status</option>
<option value="1"<?Format::selected('freetorrent', 1)?>>Freeleech</option>
<option value="2"<?Format::selected('freetorrent', 2)?>>Neutral Leech</option>
<option value="3"<?Format::selected('freetorrent', 3)?>>Either</option>
<option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
2011-03-28 14:21:28 +00:00
</select>
</td>
</tr>
2013-11-11 08:00:59 +00:00
<tr id="search_terms" class="ftr_basic<?=$HideBasic?>">
2011-03-28 14:21:28 +00:00
<td class="label">Search terms:</td>
2013-11-11 08:00:59 +00:00
<td colspan="3" class="ftb_searchstr">
2014-03-23 08:00:50 +00:00
<input type="search" spellcheck="false" size="40" name="searchstr" class="inputtext fti_basic" value="<?Format::form('searchstr')?>" />
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-11-11 08:00:59 +00:00
<tr id="tagfilter">
<td class="label"><span title="Use !tag to exclude tag" class="tooltip">Tags (comma-separated):</span></td>
<td colspan="3" class="ft_taglist">
2015-01-28 08:00:26 +00:00
<input type="search" size="40" id="tags" name="taglist" class="inputtext smaller" value="<?=display_str($Search->get_terms('taglist'))?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
2013-11-11 08:00:59 +00:00
<input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-11-11 08:00:59 +00:00
<tr id="order">
2011-03-28 14:21:28 +00:00
<td class="label">Order by:</td>
2013-11-11 08:00:59 +00:00
<td colspan="3" class="ft_order">
<select name="order_by" style="width: auto;" class="ft_order_by">
<option value="time"<?Format::selected('order_by', 'time')?>>Time added</option>
<option value="year"<?Format::selected('order_by', 'year')?>>Year</option>
<option value="size"<?Format::selected('order_by', 'size')?>>Size</option>
<option value="snatched"<?Format::selected('order_by', 'snatched')?>>Snatched</option>
<option value="seeders"<?Format::selected('order_by', 'seeders')?>>Seeders</option>
<option value="leechers"<?Format::selected('order_by', 'leechers')?>>Leechers</option>
<option value="random"<?Format::selected('order_by', 'random')?>>Random</option>
2011-03-28 14:21:28 +00:00
</select>
2013-11-11 08:00:59 +00:00
<select name="order_way" class="ft_order_way">
<option value="desc"<?Format::selected('order_way', 'desc')?>>Descending</option>
<option value="asc"<?Format::selected('order_way', 'asc')?>>Ascending</option>
</select>
</td>
</tr>
<tr id="search_group_results">
<td class="label">
<label for="group_results">Group by release:</label>
</td>
<td colspan="3" class="ft_group_results">
2015-01-28 08:00:26 +00:00
<input type="checkbox" value="1" name="group_results" id="group_results"<?=$GroupResults ? ' checked="checked"' : ''?> />
2011-03-28 14:21:28 +00:00
</td>
</tr>
</table>
2013-11-11 08:00:59 +00:00
<table class="layout cat_list ft_cat_list">
2011-03-28 14:21:28 +00:00
<?
2013-11-11 08:00:59 +00:00
$x = 0;
2011-03-28 14:21:28 +00:00
reset($Categories);
2013-08-28 23:08:41 +00:00
foreach ($Categories as $CatKey => $CatName) {
2013-11-11 08:00:59 +00:00
if ($x % 7 == 0) {
if ($x > 0) {
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
</tr>
<? } ?>
2011-03-28 14:21:28 +00:00
<tr>
2013-11-11 08:00:59 +00:00
<?
}
$x++;
?>
2011-03-28 14:21:28 +00:00
<td>
2013-04-17 08:00:58 +00:00
<input type="checkbox" name="filter_cat[<?=($CatKey + 1)?>]" id="cat_<?=($CatKey + 1)?>" value="1"<? if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<? } ?> />
<label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
2011-03-28 14:21:28 +00:00
</td>
2013-08-28 23:08:41 +00:00
<?
}
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
</tr>
2011-03-28 14:21:28 +00:00
</table>
2013-11-11 08:00:59 +00:00
<table class="layout cat_list<? if (empty($LoggedUser['ShowTags'])) { ?> hidden<? } ?>" id="taglist">
2011-03-28 14:21:28 +00:00
<tr>
<?
$GenreTags = $Cache->get_value('genre_tags');
2013-04-17 08:00:58 +00:00
if (!$GenreTags) {
2013-07-04 08:00:56 +00:00
$DB->query('
SELECT Name
FROM tags
WHERE TagType = \'genre\'
ORDER BY Name');
2013-04-17 08:00:58 +00:00
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
2011-03-28 14:21:28 +00:00
}
$x = 0;
2013-08-28 23:08:41 +00:00
foreach ($GenreTags as $Tag) {
2011-03-28 14:21:28 +00:00
?>
2013-11-12 08:00:58 +00:00
<td width="12.5%"><a href="#" onclick="add_tag('<?=$Tag?>'); return false;"><?=$Tag?></a></td>
2011-03-28 14:21:28 +00:00
<?
$x++;
2013-04-17 08:00:58 +00:00
if ($x % 7 == 0) {
2011-03-28 14:21:28 +00:00
?>
</tr>
<tr>
<?
}
2013-11-11 08:00:59 +00:00
}
2013-04-17 08:00:58 +00:00
if ($x % 7 != 0) { // Padding
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
<td colspan="<?=(7 - ($x % 7))?>"> </td>
<? } ?>
2011-03-28 14:21:28 +00:00
</tr>
</table>
2012-09-01 08:00:24 +00:00
<table class="layout cat_list" width="100%">
2011-03-28 14:21:28 +00:00
<tr>
2013-11-11 08:00:59 +00:00
<td class="label">
2013-11-12 08:00:58 +00:00
<a class="brackets" href="#" onclick="$('#taglist').gtoggle(); if (this.innerHTML == 'View tags') { this.innerHTML = 'Hide tags'; } else { this.innerHTML = 'View tags'; }; return false;"><?=(empty($LoggedUser['ShowTags']) ? 'View tags' : 'Hide tags')?></a>
2013-11-11 08:00:59 +00:00
</td>
2011-03-28 14:21:28 +00:00
</tr>
</table>
2013-11-11 08:00:59 +00:00
<div class="submit ft_submit">
<span style="float: left;"><?=number_format($NumResults)?> Results</span>
2013-04-17 08:00:58 +00:00
<input type="submit" value="Filter torrents" />
2013-11-11 08:00:59 +00:00
<input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
<input type="hidden" name="searchsubmit" value="1" />
<input type="button" value="Reset" onclick="location.href = 'torrents.php<? if (isset($_GET['action']) && $_GET['action'] === 'advanced') { ?>?action=advanced<? } ?>'" />
2011-03-28 14:21:28 +00:00
&nbsp;&nbsp;
2015-01-28 08:00:26 +00:00
<? if ($Search->has_filters()) { ?>
2013-04-17 08:00:58 +00:00
<input type="submit" name="setdefault" value="Make default" />
2013-08-28 23:08:41 +00:00
<?
}
2013-11-11 08:00:59 +00:00
if (!empty($LoggedUser['DefaultSearch'])) {
2011-03-28 14:21:28 +00:00
?>
2013-04-17 08:00:58 +00:00
<input type="submit" name="cleardefault" value="Clear default" />
<? } ?>
2011-03-28 14:21:28 +00:00
</div>
</div>
</div>
</form>
2013-11-11 08:00:59 +00:00
<?
if ($NumResults == 0) {
$DB->query("
SELECT
tags.Name,
((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score
FROM xbt_snatched AS s
INNER JOIN torrents AS t ON t.ID = s.fid
INNER JOIN torrents_group AS g ON t.GroupID = g.ID
INNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID
INNER JOIN tags ON tags.ID = tt.TagID
WHERE s.uid = '$LoggedUser[ID]'
AND tt.TagID != '13679'
AND tt.TagID != '4820'
AND tt.TagID != '2838'
AND g.CategoryID = '1'
AND tags.Uses > '10'
GROUP BY tt.TagID
ORDER BY Score DESC
LIMIT 8");
?>
<div class="box pad" align="center">
<h2>Your search did not match anything.</h2>
<p>Make sure all names are spelled correctly, or try making your search less specific.</p>
<p>You might like (beta): <? while (list($Tag) = $DB->next_record()) { ?><a href="torrents.php?taglist=<?=$Tag?>"><?=$Tag?></a><? } ?></p>
</div>
</div>
<?
View::show_footer();die();
}
if ($NumResults < ($Page - 1) * TORRENTS_PER_PAGE + 1) {
$LastPage = ceil($NumResults / TORRENTS_PER_PAGE);
$Pages = Format::get_pages(0, $NumResults, TORRENTS_PER_PAGE);
?>
<div class="box pad" align="center">
<h2>The requested page contains no matches.</h2>
<p>You are requesting page <?=$Page?>, but the search returned only <?=number_format($LastPage) ?> pages.</p>
</div>
<div class="linkbox">Go to page <?=$Pages?></div>
</div>
<?
View::show_footer();die();
}
// List of pages
$Pages = Format::get_pages($Page, $NumResults, TORRENTS_PER_PAGE);
$Bookmarks = Bookmarks::all_bookmarks('torrent');
?>
2011-03-28 14:21:28 +00:00
<div class="linkbox"><?=$Pages?></div>
2013-11-11 08:00:59 +00:00
<table class="torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>" id="torrent_table">
2011-03-28 14:21:28 +00:00
<tr class="colhead">
2013-11-11 08:00:59 +00:00
<? if ($GroupResults) { ?>
2011-03-28 14:21:28 +00:00
<td class="small"></td>
<? } ?>
<td class="small cats_col"></td>
2013-11-11 08:00:59 +00:00
<td width="100%">Name / <a href="<?=header_link('year')?>">Year</a></td>
2011-03-28 14:21:28 +00:00
<td>Files</td>
2013-11-11 08:00:59 +00:00
<td><a href="<?=header_link('time')?>">Time</a></td>
<td><a href="<?=header_link('size')?>">Size</a></td>
2013-11-01 08:01:02 +00:00
<td class="sign snatches">
2013-11-11 08:00:59 +00:00
<a href="<?=header_link('snatched')?>">
2013-10-26 08:00:58 +00:00
<img src="static/styles/<?=$LoggedUser['StyleName']?>/images/snatched.png" class="tooltip" alt="Snatches" title="Snatches" />
</a>
</td>
2013-11-01 08:01:02 +00:00
<td class="sign seeders">
2013-11-11 08:00:59 +00:00
<a href="<?=header_link('seeders')?>">
2013-10-26 08:00:58 +00:00
<img src="static/styles/<?=$LoggedUser['StyleName']?>/images/seeders.png" class="tooltip" alt="Seeders" title="Seeders" />
</a>
</td>
2013-11-01 08:01:02 +00:00
<td class="sign leechers">
2013-11-11 08:00:59 +00:00
<a href="<?=header_link('leechers')?>">
2013-10-26 08:00:58 +00:00
<img src="static/styles/<?=$LoggedUser['StyleName']?>/images/leechers.png" class="tooltip" alt="Leechers" title="Leechers" />
</a>
</td>
2011-03-28 14:21:28 +00:00
</tr>
<?
2013-04-17 08:00:58 +00:00
2013-11-11 08:00:59 +00:00
// Start printing torrent list
2015-01-28 08:00:26 +00:00
foreach ($Results as $Key => $GroupID) {
2013-11-11 08:00:59 +00:00
$GroupInfo = $Groups[$GroupID];
if (empty($GroupInfo['Torrents'])) {
continue;
2011-03-28 14:21:28 +00:00
}
2015-01-28 08:00:26 +00:00
$CategoryID = $GroupInfo['CategoryID'];
2013-11-11 08:00:59 +00:00
$GroupYear = $GroupInfo['Year'];
$ExtendedArtists = $GroupInfo['ExtendedArtists'];
$GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
$GroupName = $GroupInfo['Name'];
$GroupRecordLabel = $GroupInfo['RecordLabel'];
$ReleaseType = $GroupInfo['ReleaseType'];
if ($GroupResults) {
$Torrents = $GroupInfo['Torrents'];
$GroupTime = $MaxSize = $TotalLeechers = $TotalSeeders = $TotalSnatched = 0;
foreach ($Torrents as $T) {
2015-01-28 08:00:26 +00:00
$GroupTime = max($GroupTime, strtotime($T['Time']));
$MaxSize = max($MaxSize, $T['Size']);
$TotalLeechers += $T['Leechers'];
$TotalSeeders += $T['Seeders'];
$TotalSnatched += $T['Snatched'];
2013-11-11 08:00:59 +00:00
}
} else {
2015-01-28 08:00:26 +00:00
$TorrentID = $Key;
$Torrents = array($TorrentID => $GroupInfo['Torrents'][$TorrentID]);
2011-03-28 14:21:28 +00:00
}
2013-11-11 08:00:59 +00:00
$TorrentTags = new Tags($GroupInfo['TagList']);
2011-03-28 14:21:28 +00:00
2013-11-12 08:00:58 +00:00
if (!empty($ExtendedArtists[1])
|| !empty($ExtendedArtists[4])
|| !empty($ExtendedArtists[5])
|| !empty($ExtendedArtists[6])
) {
2013-11-11 08:00:59 +00:00
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
$DisplayName = Artists::display_artists($ExtendedArtists);
} else {
$DisplayName = '';
}
$SnatchedGroupClass = $GroupInfo['Flags']['IsSnatched'] ? ' snatched_group' : '';
2011-03-28 14:21:28 +00:00
2013-11-11 08:00:59 +00:00
if ($GroupResults && (count($Torrents) > 1 || isset($GroupedCategories[$CategoryID - 1]))) {
// These torrents are in a group
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" class=\"tooltip\" title=\"View torrent group\" dir=\"ltr\">$GroupName</a>";
if ($GroupYear > 0) {
$DisplayName .= " [$GroupYear]";
2011-03-28 14:21:28 +00:00
}
2013-11-11 08:00:59 +00:00
if ($GroupInfo['VanityHouse']) {
$DisplayName .= ' [<abbr class="tooltip" title="This is a Vanity House release">VH</abbr>]';
2013-04-17 08:00:58 +00:00
}
2013-11-11 08:00:59 +00:00
$DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
<tr class="group<?=$SnatchedGroupClass?>">
2013-02-25 21:16:55 +00:00
<?
2013-11-11 08:00:59 +00:00
$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
?>
<td class="center">
<div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
2015-11-15 08:00:28 +00:00
<a href="#" class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Collapse this group. Hold [Command] <em>(Mac)</em> or [Ctrl] <em>(PC)</em> while clicking to collapse all groups on this page."></a>
2013-11-11 08:00:59 +00:00
</div>
</td>
<td class="center cats_col">
<div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($CategoryID)?> <?=$TorrentTags->css_name()?>">
</div>
</td>
<td colspan="2" class="big_info">
<? if ($LoggedUser['CoverArt']) { ?>
2013-02-25 21:16:55 +00:00
<div class="group_image float_left clear">
2013-11-11 08:00:59 +00:00
<? ImageTools::cover_thumb($GroupInfo['WikiImage'], $GroupInfo['CategoryID']) ?>
2013-02-25 21:16:55 +00:00
</div>
2013-11-11 08:00:59 +00:00
<? } ?>
2013-02-25 21:16:55 +00:00
<div class="group_info clear">
<?=$DisplayName?>
2013-11-11 08:00:59 +00:00
<? if (in_array($GroupID, $Bookmarks)) { ?>
2014-05-29 08:00:27 +00:00
<span class="remove_bookmark float_right">
<a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
</span>
2013-11-11 08:00:59 +00:00
<? } else { ?>
2014-05-29 08:00:27 +00:00
<span class="add_bookmark float_right">
<a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
</span>
2013-11-11 08:00:59 +00:00
<? } ?>
<br />
<div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?></div>
2013-02-25 21:16:55 +00:00
</div>
2011-03-28 14:21:28 +00:00
</td>
2013-08-28 23:08:41 +00:00
<td class="nobr"><?=time_diff($GroupTime, 1)?></td>
<td class="number_column nobr"><?=Format::get_size($MaxSize)?> (Max)</td>
<td class="number_column"><?=number_format($TotalSnatched)?></td>
2013-11-12 08:00:58 +00:00
<td class="number_column<?=($TotalSeeders == 0 ? ' r00' : '')?>"><?=number_format($TotalSeeders)?></td>
2013-08-28 23:08:41 +00:00
<td class="number_column"><?=number_format($TotalLeechers)?></td>
2011-03-28 14:21:28 +00:00
</tr>
<?
2013-11-11 08:00:59 +00:00
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
2013-02-22 08:00:24 +00:00
2013-11-11 08:00:59 +00:00
$EditionID = 0;
$FirstUnknown = null;
2013-02-22 08:00:24 +00:00
2013-11-11 08:00:59 +00:00
foreach ($Torrents as $TorrentID => $Data) {
// All of the individual torrents in the group
2013-02-22 08:00:24 +00:00
2013-11-11 08:00:59 +00:00
//Get report info for each torrent, use the cache if available, if not, add to it.
$Reported = false;
$Reports = Torrents::get_reports($TorrentID);
if (count($Reports) > 0) {
$Reported = true;
}
if ($Data['Remastered'] && !$Data['RemasterYear']) {
$FirstUnknown = !isset($FirstUnknown);
}
$SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
if (isset($GroupedCategories[$CategoryID - 1])
&& ($Data['RemasterTitle'] != $LastRemasterTitle
|| $Data['RemasterYear'] != $LastRemasterYear
|| $Data['RemasterRecordLabel'] != $LastRemasterRecordLabel
|| $Data['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber)
|| $FirstUnknown
2013-11-12 08:00:58 +00:00
|| $Data['Media'] != $LastMedia
) {
2013-11-11 08:00:59 +00:00
$EditionID++;
?>
<tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
2015-11-15 08:00:28 +00:00
<td colspan="9" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event);" class="tooltip" title="Collapse this edition. Hold [Command] <em>(Mac)</em> or [Ctrl] <em>(PC)</em> while clicking to collapse all editions in this torrent group.">&minus;</a> <?=Torrents::edition_string($Data, $GroupInfo)?></strong></td>
2013-11-11 08:00:59 +00:00
</tr>
<?
}
$LastRemasterTitle = $Data['RemasterTitle'];
$LastRemasterYear = $Data['RemasterYear'];
$LastRemasterRecordLabel = $Data['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Data['RemasterCatalogueNumber'];
$LastMedia = $Data['Media'];
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
<tr class="group_torrent groupid_<?=$GroupID?> edition_<?=$EditionID?><?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
2011-03-28 14:21:28 +00:00
<td colspan="3">
<span>
2013-11-11 08:00:59 +00:00
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
<? if (Torrents::can_use_token($Data)) { ?>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
2011-03-28 14:21:28 +00:00
</span>
2013-11-11 08:00:59 +00:00
&raquo; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Data)?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported">Reported</strong><? } ?></a>
2011-03-28 14:21:28 +00:00
</td>
2013-11-11 08:00:59 +00:00
<td><?=$Data['FileCount']?></td>
<td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
<td class="number_column nobr"><?=Format::get_size($Data['Size'])?></td>
<td class="number_column"><?=number_format($Data['Snatched'])?></td>
<td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
<td class="number_column"><?=number_format($Data['Leechers'])?></td>
2011-03-28 14:21:28 +00:00
</tr>
<?
2013-11-11 08:00:59 +00:00
}
} else {
// Viewing a type that does not require grouping
2013-04-17 08:00:58 +00:00
2013-11-11 08:00:59 +00:00
list($TorrentID, $Data) = each($Torrents);
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" class=\"tooltip\" title=\"View torrent\" dir=\"ltr\">$GroupName</a>";
if (isset($GroupedCategories[$CategoryID - 1])) {
if ($GroupYear) {
$DisplayName .= " [$GroupYear]";
2013-04-17 08:00:58 +00:00
}
2013-11-11 08:00:59 +00:00
if ($CategoryID == 1 && $ReleaseType > 0) {
$DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
2013-04-17 08:00:58 +00:00
}
2013-11-11 08:00:59 +00:00
$ExtraInfo = Torrents::torrent_info($Data, true, true);
} elseif ($Data['IsSnatched']) {
$ExtraInfo = Format::torrent_label('Snatched!');
} else {
$ExtraInfo = '';
}
$SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
2011-03-28 14:21:28 +00:00
?>
2013-11-11 08:00:59 +00:00
<tr class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
<? if ($GroupResults) { ?>
2011-03-28 14:21:28 +00:00
<td></td>
2013-11-11 08:00:59 +00:00
<? } ?>
2013-10-26 08:00:58 +00:00
<td class="center cats_col">
2013-11-11 08:00:59 +00:00
<div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($CategoryID)?> <?=$TorrentTags->css_name()?>"></div>
2013-10-26 08:00:58 +00:00
</td>
2013-02-25 21:16:55 +00:00
<td class="big_info">
2013-11-11 08:00:59 +00:00
<? if ($LoggedUser['CoverArt']) { ?>
2013-02-25 21:16:55 +00:00
<div class="group_image float_left clear">
2013-11-11 08:00:59 +00:00
<?=ImageTools::cover_thumb($GroupInfo['WikiImage'], $CategoryID) ?>
2013-02-25 21:16:55 +00:00
</div>
2013-11-11 08:00:59 +00:00
<? } ?>
<div class="group_info clear">
<span>
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
<? if (Torrents::can_use_token($Data)) { ?>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
<? } ?>
| <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
</span>
2013-02-25 21:16:55 +00:00
<?=$DisplayName?>
2013-11-11 08:00:59 +00:00
<div class="torrent_info"><?=$ExtraInfo?></div>
<div class="tags"><?=$TorrentTags->format("torrents.php?$Action&amp;taglist=")?></div>
2013-02-25 21:16:55 +00:00
</div>
2011-03-28 14:21:28 +00:00
</td>
2013-11-11 08:00:59 +00:00
<td><?=$Data['FileCount']?></td>
<td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
<td class="number_column nobr"><?=Format::get_size($Data['Size'])?></td>
<td class="number_column"><?=number_format($Data['Snatched'])?></td>
<td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
<td class="number_column"><?=number_format($Data['Leechers'])?></td>
2011-03-28 14:21:28 +00:00
</tr>
<?
}
2013-11-11 08:00:59 +00:00
}
2011-03-28 14:21:28 +00:00
?>
</table>
<div class="linkbox"><?=$Pages?></div>
2013-11-11 08:00:59 +00:00
</div>
<? View::show_footer(); ?>