include(SERVER_ROOT.'/sections/torrents/functions.php');
// The "order by x" links on columns headers
function header_link($SortKey, $DefaultWay = 'desc') {
global $OrderBy, $OrderWay;
if ($SortKey == $OrderBy) {
if ($OrderWay == 'desc') {
$NewWay = 'asc';
} else {
$NewWay = 'desc';
}
} else {
$NewWay = $DefaultWay;
}
return "torrents.php?order_way=$NewWay&order_by=$SortKey&".Format::get_url(array('order_way', 'order_by'));
}
if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
if (!empty($_GET['searchstr'])) {
$InfoHash = $_GET['searchstr'];
} else {
$InfoHash = $_GET['groupname'];
}
// 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();
}
}
}
// Setting default search options
if (!empty($_GET['setdefault'])) {
$UnsetList = array('page', 'setdefault');
$UnsetRegexp = '/(&|^)('.implode('|', $UnsetList).')=.*?(&|$)/i';
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
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']);
$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' => $SiteOptions['DefaultSearch']));
$Cache->commit_transaction(0);
// Clearing default search options
} elseif (!empty($_GET['cleardefault'])) {
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = '';
$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' => ''));
$Cache->commit_transaction(0);
// Use default search options
} 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);
}
}
}
// Terms were not submitted via the search form
if (isset($_GET['searchsubmit'])) {
$GroupResults = !empty($_GET['group_results']);
} else {
$GroupResults = !$LoggedUser['DisableGrouping2'];
}
if (!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
$OrderWay = 'asc';
} else {
$OrderWay = 'desc';
}
if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_by']])) {
$OrderBy = 'time'; // For header links
} else {
$OrderBy = $_GET['order_by'];
}
$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();
$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 = '';
} else {
$Action = 'action=basic';
$HideBasic = '';
$HideAdvanced = ' hidden';
}
View::show_header('Browse Torrents', 'browse');
?>
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");
?>
Your search did not match anything.
Make sure all names are spelled correctly, or try making your search less specific.
You might like (beta): while (list($Tag) = $DB->next_record()) { ?>=$Tag?> } ?>
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);
?>
The requested page contains no matches.
You are requesting page =$Page?>, but the search returned only =number_format($LastPage) ?> pages.
Go to page =$Pages?>
View::show_footer();die();
}
// List of pages
$Pages = Format::get_pages($Page, $NumResults, TORRENTS_PER_PAGE);
$Bookmarks = Bookmarks::all_bookmarks('torrent');
?>
=$Pages?>
if ($GroupResults) { ?>
|
} ?>
|
Name / Year |
Files |
Time |
Size |
|
|
|
// Start printing torrent list
foreach ($Results as $Key => $GroupID) {
$GroupInfo = $Groups[$GroupID];
if (empty($GroupInfo['Torrents'])) {
continue;
}
$CategoryID = $GroupInfo['CategoryID'];
$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) {
$GroupTime = max($GroupTime, strtotime($T['Time']));
$MaxSize = max($MaxSize, $T['Size']);
$TotalLeechers += $T['Leechers'];
$TotalSeeders += $T['Seeders'];
$TotalSnatched += $T['Snatched'];
}
} else {
$TorrentID = $Key;
$Torrents = array($TorrentID => $GroupInfo['Torrents'][$TorrentID]);
}
$TorrentTags = new Tags($GroupInfo['TagList']);
if (!empty($ExtendedArtists[1])
|| !empty($ExtendedArtists[4])
|| !empty($ExtendedArtists[5])
|| !empty($ExtendedArtists[6])
) {
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
$DisplayName = Artists::display_artists($ExtendedArtists);
} else {
$DisplayName = '';
}
$SnatchedGroupClass = $GroupInfo['Flags']['IsSnatched'] ? ' snatched_group' : '';
if ($GroupResults && (count($Torrents) > 1 || isset($GroupedCategories[$CategoryID - 1]))) {
// These torrents are in a group
$DisplayName .= "$GroupName";
if ($GroupYear > 0) {
$DisplayName .= " [$GroupYear]";
}
if ($GroupInfo['VanityHouse']) {
$DisplayName .= ' [VH]';
}
$DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
?>
$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
?>
|
|
if ($LoggedUser['CoverArt']) { ?>
ImageTools::cover_thumb($GroupInfo['WikiImage'], $GroupInfo['CategoryID']) ?>
} ?>
=$DisplayName?>
if (in_array($GroupID, $Bookmarks)) { ?>
Remove bookmark
} else { ?>
Bookmark
} ?>
=$TorrentTags->format('torrents.php?'.$Action.'&taglist=')?>
|
=time_diff($GroupTime, 1)?> |
=Format::get_size($MaxSize)?> (Max) |
=number_format($TotalSnatched)?> |
=number_format($TotalSeeders)?> |
=number_format($TotalLeechers)?> |
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
$EditionID = 0;
$FirstUnknown = null;
foreach ($Torrents as $TorrentID => $Data) {
// All of the individual torrents in the group
//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
|| $Data['Media'] != $LastMedia
) {
$EditionID++;
?>
− =Torrents::edition_string($Data, $GroupInfo)?> |
}
$LastRemasterTitle = $Data['RemasterTitle'];
$LastRemasterYear = $Data['RemasterYear'];
$LastRemasterRecordLabel = $Data['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Data['RemasterCatalogueNumber'];
$LastMedia = $Data['Media'];
?>
[ =$Data['HasFile'] ? 'DL' : 'Missing'?>
if (Torrents::can_use_token($Data)) { ?>
| FL
} ?>
| RP ]
» =Torrents::torrent_info($Data)?> if ($Reported) { ?> / Reported } ?>
|
=$Data['FileCount']?> |
=time_diff($Data['Time'], 1)?> |
=Format::get_size($Data['Size'])?> |
=number_format($Data['Snatched'])?> |
=number_format($Data['Seeders'])?> |
=number_format($Data['Leechers'])?> |
}
} else {
// Viewing a type that does not require grouping
list($TorrentID, $Data) = each($Torrents);
$DisplayName .= "$GroupName";
if (isset($GroupedCategories[$CategoryID - 1])) {
if ($GroupYear) {
$DisplayName .= " [$GroupYear]";
}
if ($CategoryID == 1 && $ReleaseType > 0) {
$DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
}
$ExtraInfo = Torrents::torrent_info($Data, true, true);
} elseif ($Data['IsSnatched']) {
$ExtraInfo = Format::torrent_label('Snatched!');
} else {
$ExtraInfo = '';
}
$SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
?>
if ($GroupResults) { ?>
|
} ?>
|
if ($LoggedUser['CoverArt']) { ?>
=ImageTools::cover_thumb($GroupInfo['WikiImage'], $CategoryID) ?>
} ?>
[ DL
if (Torrents::can_use_token($Data)) { ?>
| FL
} ?>
| RP ]
=$DisplayName?>
=$ExtraInfo?>
=$TorrentTags->format("torrents.php?$Action&taglist=")?>
|
=$Data['FileCount']?> |
=time_diff($Data['Time'], 1)?> |
=Format::get_size($Data['Size'])?> |
=number_format($Data['Snatched'])?> |
=number_format($Data['Seeders'])?> |
=number_format($Data['Leechers'])?> |
}
}
?>
=$Pages?>
View::show_footer(); ?>