Gazelle/sections/torrents/browse.php

1252 lines
43 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/************************************************************************
*-------------------- Browse page ---------------------------------------
* Welcome to one of the most complicated pages in all of gazelle - the
2013-02-22 08:00:24 +00:00
* browse page.
*
2011-03-28 14:21:28 +00:00
* This is the page that is displayed when someone visits torrents.php, if
* you're not using sphinx.
2013-02-22 08:00:24 +00:00
*
2011-03-28 14:21:28 +00:00
* It also handle snatch lists, and seeding/leeching/uploaded lists.
2013-02-22 08:00:24 +00:00
*
2011-03-28 14:21:28 +00:00
* It offers normal and advanced search, as well as enabled/disabled
2013-02-22 08:00:24 +00:00
* grouping.
2011-03-28 14:21:28 +00:00
*
* For the Sphinx version, see sections/torrents/browse2.php
*
* This version is a little outdated. You should probably set up Sphinx.
*
* Don't blink.
*************************************************************************/
$ErrorPage = true;
define('EXPLAIN_HACK',false);
2013-04-19 08:00:55 +00:00
if (EXPLAIN_HACK) {
2011-03-28 14:21:28 +00:00
$SCFR = '';
} else {
$SCFR = 'SQL_CALC_FOUND_ROWS';
}
// Function to build a SQL WHERE to search for a string
// Offers exact searching, fulltext searching, and negative searching
2013-04-19 08:00:55 +00:00
function build_search($SearchStr, $Field, $Exact=false, $SQLWhere='', $FullText=0, &$FilterString='') {
2013-04-17 08:00:58 +00:00
if ($SQLWhere != '') {
$AddWhere = false;
} else {
$AddWhere = true;
}
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if (!$Exact) {
if ($FullText && preg_match('/[^a-zA-Z0-9 ]/i',$SearchStr)) {
$FullText = 0;
}
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
$SearchLength = strlen(trim($SearchStr));
$SearchStr = preg_replace('/\s\s+/',' ',trim($SearchStr));
$SearchStr = preg_replace_callback('/"(([^"])*)"/','quotes',$SearchStr);
$SearchStr = explode(' ',$SearchStr);
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
$FilterString = '(.+?)';
foreach ($SearchStr as $SearchVal) {
if (trim($SearchVal) != '') {
$SearchVal = trim($SearchVal);
$SearchVal = str_replace('{{SPACE}}',' ',$SearchVal);
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
// Choose between fulltext or LIKE based off length of the string
2013-04-17 08:00:58 +00:00
if ($FullText && strlen($SearchVal) > 2) {
if ($SQLWhere != '') {
$SQLWhere.= ' AND ';
}
if (substr($SearchVal,0,1) == '-') {
$SQLWhere.="MATCH ($Field) AGAINST ('".db_string($SearchVal)."' IN BOOLEAN MODE)";
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
$SQLWhere.="MATCH ($Field) AGAINST ('".db_string($SearchVal)."')";
2011-03-28 14:21:28 +00:00
}
} else {
2013-04-17 08:00:58 +00:00
if ($SQLWhere != '') {
$SQLWhere.= ' AND ';
}
if (substr($SearchVal,0,1) == '-') {
2011-03-28 14:21:28 +00:00
$SQLWhere.=$Field." NOT LIKE '%".db_string(substr($SearchVal,1))."%'";
} else {
$SQLWhere.=$Field." LIKE '%".db_string($SearchVal)."%'";
}
}
2013-04-17 08:00:58 +00:00
$FilterString.="($SearchVal)(.+?)";
2011-03-28 14:21:28 +00:00
}
}
} else {
2013-04-17 08:00:58 +00:00
if ($SQLWhere != '') {
$SQLWhere.= ' AND ';
}
2011-03-28 14:21:28 +00:00
$SQLWhere.=$Field." LIKE '".db_string($SearchStr)."'";
2013-04-17 08:00:58 +00:00
$FilterString.="(.+?)($SearchStr)(.+?)";
2011-03-28 14:21:28 +00:00
}
$Search = 1;
2013-04-17 08:00:58 +00:00
$FilterString = "/$FilterString/si";
if ($SQLWhere != '' && $AddWhere) {
$SQLWhere = 'WHERE '.$SQLWhere;
}
2011-03-28 14:21:28 +00:00
return $SQLWhere;
}
function quotes($Str) {
$Str = str_replace(' ','{{SPACE}}',trim($Str[1]));
return ' '.$Str.' ';
}
// The "order by x" links on columns headers
2013-04-17 08:00:58 +00:00
function header_link($SortKey,$DefaultWay = 'DESC') {
2011-03-28 14:21:28 +00:00
global $OrderBy,$OrderWay;
2013-04-17 08:00:58 +00:00
if ($SortKey == $OrderBy) {
if ($OrderWay == 'DESC') {
$NewWay = 'ASC';
} else {
$NewWay = 'DESC';
}
} else {
$NewWay = $DefaultWay;
}
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
return 'torrents.php?order_way='.$NewWay.'&amp;order_by='.$SortKey.'&amp;'.Format::get_url(array('order_way','order_by'));
2011-03-28 14:21:28 +00:00
}
// Setting default search options
2013-04-17 08:00:58 +00:00
if ($_GET['setdefault']) {
$UnsetList[] = '/(&?page\=.+?&?)/i';
$UnsetList[] = '/(&?setdefault\=.+?&?)/i';
2011-03-28 14:21:28 +00:00
$DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
2013-04-17 08:00:58 +00:00
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, true);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = preg_replace($UnsetList,'',$_SERVER['QUERY_STRING']);
2011-03-28 14:21:28 +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'=>preg_replace($UnsetList,'',$_SERVER['QUERY_STRING'])));
$Cache->commit_transaction(0);
// Clearing default search options
2013-04-17 08:00:58 +00:00
} elseif ($_GET['cleardefault']) {
2011-03-28 14:21:28 +00:00
$DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
2013-04-17 08:00:58 +00:00
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, true);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = '';
2011-03-28 14:21:28 +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'=>''));
$Cache->commit_transaction(0);
// Use default search options
2013-04-17 08:00:58 +00:00
} elseif (!$_SERVER['QUERY_STRING'] && $LoggedUser['DefaultSearch']) {
2011-03-28 14:21:28 +00:00
parse_str($LoggedUser['DefaultSearch'],$_GET);
}
// If a user is hammering the search page (either via a <script type="text/javascript">, or just general zeal)
2013-04-17 08:00:58 +00:00
if ($_SERVER['QUERY_STRING'] != '' && !check_perms('torrents_search_fast') && $_SERVER['QUERY_STRING'] != 'action=basic' && $_SERVER['QUERY_STRING'] != 'action=advanced') {
if ($LoggedUser['last_browse'] > time() - 1) {
2011-03-28 14:21:28 +00:00
error('You can only search for torrents once every second.');
} else {
$_SESSION['logged_user']['last_browse'] = time();
}
}
2013-04-17 08:00:58 +00:00
$OrderBy = 's3'; // We order by GroupTime by default
$OrderWay = 'DESC'; // We also order descending by default
2011-03-28 14:21:28 +00:00
2012-10-11 08:00:15 +00:00
list($Page,$Limit) = Format::page_limit(TORRENTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if (preg_match('/^s[1-7]$/',$_GET['order_by'])) {
$OrderBy = strtolower($_GET['order_by']);
}
if (in_array(strtolower($_GET['order_way']),array('desc','asc'))) {
$OrderWay = strtoupper($_GET['order_way']);
}
2011-03-28 14:21:28 +00:00
// Uploaded, seeding, leeching, snatched lists
2013-04-17 08:00:58 +00:00
if ($_GET['userid'] && is_number($_GET['userid'])) {
2011-03-28 14:21:28 +00:00
$UserID=ceil($_GET['userid']);
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$DB->query("SELECT m.Paranoia, p.Level FROM users_main AS m JOIN permissions AS p ON p.ID=m.PermissionID WHERE ID='".$UserID."'");
list($Paranoia, $UserClass) = $DB->next_record();
$TorrentWhere='';
$TorrentJoin='';
2013-04-17 08:00:58 +00:00
if ($_GET['type'] == 'uploaded') {
if (!check_paranoia('uploads', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentWhere = "WHERE t.UserID='".$UserID."'";
$Title = 'Uploaded Torrents';
} elseif ($_GET['type'] == 'seeding') {
if (!check_paranoia('seeding', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid=t.ID AND xfu.uid='$UserID' AND xfu.remaining=0";
$Title = 'Seeding Torrents';
$TimeField = 'xfu.mtime';
$TimeLabel = 'Seeding Time';
} elseif ($_GET['type'] == 'leeching') {
if (!check_paranoia('leeching', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid=t.ID AND xfu.uid='$UserID' AND xfu.remaining>0";
$Title = 'Leeching Torrents';
$TimeField = 'xfu.mtime';
$TimeLabel = 'Leeching Time';
} elseif ($_GET['type'] == 'snatched') {
if (!check_paranoia('snatched', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentJoin = "JOIN xbt_snatched AS xs ON xs.fid=t.ID AND xs.uid='$UserID'";
$Title = 'Snatched Torrents';
$TimeField = 'xs.tstamp';
$TimeLabel = 'Snatched Time';
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
} else {
// Something fishy in $_GET['type']
unset($UserID);
unset($_GET['userid']);
}
if ($TorrentJoin || $TorrentWhere) {
2013-04-17 08:00:58 +00:00
$_GET['disablegrouping'] = 1; // We disable grouping on these lists
2011-03-28 14:21:28 +00:00
}
}
$DisableGrouping = 0;
// If grouping is disabled
2013-04-17 08:00:58 +00:00
if (($LoggedUser['DisableGrouping'] && !$_GET['enablegrouping']) || $_GET['disablegrouping'] == '1' || $_GET['artistname'] != '') {
$DisableGrouping = 1;
2011-03-28 14:21:28 +00:00
}
// Advanced search
2013-04-17 08:00:58 +00:00
if ((strtolower($_GET['action']) == 'advanced' || ($LoggedUser['SearchType'] && strtolower($_GET['action']) != 'basic')) && check_perms('site_advanced_search')) {
$TorrentSpecifics = 0; // How many options are we searching by? (Disabled grouping only)
if ($DisableGrouping) {
foreach ($_GET as $SearchType=>$SearchStr) {
switch ($SearchType) {
2011-03-28 14:21:28 +00:00
case 'bitrate':
case 'format':
case 'media':
case 'haslog':
case 'hascue':
case 'scene':
case 'remastered':
case 'remastertitle':
case 'freeleech':
2013-04-17 08:00:58 +00:00
if ($SearchStr != '') {
$TorrentSpecifics += 1;
}
2011-03-28 14:21:28 +00:00
}
}
reset($_GET);
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
$TorrentSpecifics = 1;
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
// And now we start building the mega SQL query
2013-04-17 08:00:58 +00:00
if ($_GET['artistname'] != '') {
2011-03-28 14:21:28 +00:00
$TorrentJoin .= ' LEFT JOIN torrents_artists AS ta ON g.ID = ta.GroupID LEFT JOIN artists AS a ON ta.ArtistID = a.ID';
2013-04-17 08:00:58 +00:00
$TorrentWhere = build_search($_GET['artistname'],'a.Name',$_GET['exactartist'],$TorrentWhere);
2011-03-28 14:21:28 +00:00
}
2013-04-17 08:00:58 +00:00
if ($_GET['torrentname'] != '') {
if (!$DisableGrouping) {
$GroupWhere = build_search($_GET['torrentname'],'GroupName',$_GET['exacttorrent'],$GroupWhere);
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
$TorrentWhere = build_search($_GET['torrentname'],'g.Name',$_GET['exacttorrent'],$TorrentWhere);
2011-03-28 14:21:28 +00:00
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['remastertitle'] != '') {
2011-03-28 14:21:28 +00:00
$RemasterTitle = $_GET['remastertitle'];
2013-04-17 08:00:58 +00:00
if ($_GET['exactremaster']) {
2011-03-28 14:21:28 +00:00
$RemasterTitle = '%'.$RemasterTitle.'%';
}
2013-04-17 08:00:58 +00:00
$GroupWhere = build_search($RemasterTitle,'RemasterTitleList',$_GET['exactremaster'],$GroupWhere,0,$RemasterRegEx);
if ($TorrentSpecifics > 0) {
$TorrentWhere = build_search($_GET['remastertitle'],'t.RemasterTitle',$_GET['exactremaster'],$TorrentWhere);
2011-03-28 14:21:28 +00:00
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['year'] != '' && is_numeric($_GET['year'])) {
if (!$DisableGrouping) {
if ($GroupWhere == '') {
$GroupWhere='WHERE ';
} else {
$GroupWhere.= ' AND ';
}
2011-03-28 14:21:28 +00:00
$GroupWhere.="GroupYear='".db_string($_GET['year'])."'";
} else {
2013-04-17 08:00:58 +00:00
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
2011-03-28 14:21:28 +00:00
$TorrentWhere.="g.Year='".db_string($_GET['year'])."'";
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['bitrate'] != '') {
if (in_array($_GET['bitrate'],$Bitrates)) {
if ($_GET['bitrate'] == 'Other') {
if ($_GET['other_bitrate'] != '') {
2011-03-28 14:21:28 +00:00
$GroupWhere=build_search(db_string($_GET['other_bitrate']),'EncodingList',false,$GroupWhere);
2013-04-17 08:00:58 +00:00
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
2013-02-22 08:00:24 +00:00
} else {
2013-04-17 08:00:58 +00:00
$TorrentWhere.= ' AND ';
2011-03-28 14:21:28 +00:00
}
}
$TorrentWhere.="t.Encoding LIKE '%".db_string($_GET['other_bitrate'])."%'";
}
} else {
2013-04-17 08:00:58 +00:00
$GroupWhere = build_search(db_string($_GET['bitrate']),'EncodingList',false,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
2013-02-22 08:00:24 +00:00
} else {
2013-04-17 08:00:58 +00:00
$TorrentWhere.= ' AND ';
2011-03-28 14:21:28 +00:00
}
$TorrentWhere.="t.Encoding LIKE '".db_string($_GET['bitrate'])."'";
}
}
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['format'] != '' && in_array($_GET['format'],$Formats)) {
$GroupWhere = build_search('%'.$_GET['format'].'%','FormatList',f,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
2011-03-28 14:21:28 +00:00
$TorrentWhere.="t.Format='".db_string($_GET['format'])."'";
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['media'] != '' && in_array($_GET['media'],$Media)) {
$GroupWhere = build_search('%'.$_GET['media'].'%','MediaList',false,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
2011-03-28 14:21:28 +00:00
$TorrentWhere.="t.Media='".db_string($_GET['media'])."'";
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['filelist'] != '') {
$TorrentWhere = build_search('%'.$_GET['filelist'].'%','t.FileList',true,$TorrentWhere);
2011-03-28 14:21:28 +00:00
}
2013-04-17 08:00:58 +00:00
if ($_GET['haslog'] != '') {
2011-03-28 14:21:28 +00:00
$HasLog = ceil($_GET['haslog']);
2013-04-17 08:00:58 +00:00
if ($_GET['haslog'] == '100' || $_GET['haslog'] == '-100') {
$GroupWhere = build_search($_GET['haslog'],'LogScoreList',false,$GroupWhere);
2011-03-28 14:21:28 +00:00
$HasLog = 1;
}
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
$GroupWhere = build_search('%'.$HasLog.'%','LogList',true,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($_GET['haslog'] == '100' || $_GET['haslog'] == '-100') {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
$TorrentWhere.= ' AND ';
2011-03-28 14:21:28 +00:00
}
2013-04-17 08:00:58 +00:00
if ($_GET['haslog'] == '-100') {
$TorrentWhere.= "t.LogScore!='100'";
} else {
$TorrentWhere.= "t.LogScore='100'";
}
}
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
2011-03-28 14:21:28 +00:00
}
2013-04-17 08:00:58 +00:00
$TorrentWhere.= "t.HasLog='$HasLog'";
2011-03-28 14:21:28 +00:00
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['hascue'] != '') {
$GroupWhere = build_search('%'.$_GET['hascue'].'%','CueList',true,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
$TorrentWhere.= "t.HasCue='".ceil($_GET['hascue'])."'";
2011-03-28 14:21:28 +00:00
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['scene'] != '') {
$GroupWhere = build_search('%'.$_GET['scene'].'%','SceneList',true,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
$TorrentWhere.= "t.Scene='".ceil($_GET['scene'])."'";
2011-03-28 14:21:28 +00:00
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['freeleech'] != '') {
$GroupWhere = build_search('%'.$_GET['freeleech'].'%','FreeTorrentList',true,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
$TorrentWhere.= "t.FreeTorrent='".ceil($_GET['freeleech'])."'";
2011-03-28 14:21:28 +00:00
}
}
2013-04-17 08:00:58 +00:00
if ($_GET['remastered'] != '') {
$GroupWhere = build_search('%'.$_GET['remastered'].'%','RemasterList',true,$GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
$TorrentWhere.= "t.Remastered='".ceil($_GET['remastered'])."'";
2011-03-28 14:21:28 +00:00
}
}
} else {
// Basic search
2013-04-17 08:00:58 +00:00
if ($_GET['searchstr'] != '') {
2011-03-28 14:21:28 +00:00
// Change special characters into 'normal' characters
$SearchStr = strtr($_GET['searchstr'],$SpecialChars);
2013-04-17 08:00:58 +00:00
if (!$DisableGrouping) {
$GroupWhere = build_search($SearchStr,'SearchText',false,$GroupWhere,1);
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
$TorrentWhere = build_search($SearchStr,'g.SearchText',false,$TorrentWhere);
2011-03-28 14:21:28 +00:00
}
}
}
// Searching tags is the same for basic and advanced search
2013-04-17 08:00:58 +00:00
if (isset($_GET['searchtags']) && $_GET['searchtags'] != '') {
if ($DisableGrouping) {
$TagField = 'g.TagList';
} else {
$TagField = 'h.TagList';
}
$Tags = explode(',',$_GET['searchtags']);
foreach ($Tags as $Key => $Tag) :
if (trim($Tag) != '') {
if ($TagSearch != '') {
if ($_GET['tags_type']) {
$TagSearch.= ' AND ';
} else {
$TagSearch.= ' OR ';
}
2011-03-28 14:21:28 +00:00
}
$Tag = trim(str_replace('.','_',$Tag));
2013-04-17 08:00:58 +00:00
if (!$DisableGrouping) {
2011-03-28 14:21:28 +00:00
// Fulltext
2013-04-17 08:00:58 +00:00
$TagSearch.= " MATCH ($TagField) AGAINST ('".db_string($Tag)."'";
if (substr($Tag,0,1) == '-') {
2011-03-28 14:21:28 +00:00
$TagSearch.=' IN BOOLEAN MODE';
}
2013-04-17 08:00:58 +00:00
$TagSearch.= ')';
2011-03-28 14:21:28 +00:00
} else {
$TagSearch.=$TagField." LIKE '%".db_string($Tag)."%'";
}
}
2013-04-17 08:00:58 +00:00
endforeach;
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if ($TagSearch != '') {
if ($DisableGrouping) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
$TorrentWhere.= "($TagSearch)";
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
if ($GroupWhere == '') {
$GroupWhere = 'WHERE ';
} else {
$GroupWhere.= ' AND ';
}
$GroupWhere.= "($TagSearch)";
2011-03-28 14:21:28 +00:00
}
}
}
// Filtering categories is also the same for basic and advanced search
2013-04-17 08:00:58 +00:00
if ($_GET['filter_cat'] != '') {
if ($DisableGrouping) {
$CategoryField = 'g.CategoryID';
} else {
$CategoryField = 'GroupCategoryID';
}
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
foreach ($_GET['filter_cat'] as $CatKey => $CatVal) {
if ($CatFilter != '') {
$CatFilter.= ' OR ';
}
2011-03-28 14:21:28 +00:00
$CatFilter.=$CategoryField."='".db_string(ceil($CatKey))."'";
}
2013-04-17 08:00:58 +00:00
if ($DisableGrouping) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
}
$TorrentWhere.= "($CatFilter)";
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
if ($GroupWhere == '') {
$GroupWhere = 'WHERE ';
} else {
$GroupWhere.= ' AND ';
}
$GroupWhere.="($CatFilter)";
2011-03-28 14:21:28 +00:00
}
}
// Label for the 'time' column - can also be "seeding time", "leeching time", or "snatched time"
2013-04-17 08:00:58 +00:00
if (!$TimeLabel) {
$TimeLabel = 'Added';
}
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if (!is_array($TorrentCache)) {
2011-03-28 14:21:28 +00:00
if (!$DisableGrouping) {
// Build SQL query for enabled grouping
2013-04-17 08:00:58 +00:00
if ($TorrentWhere != '') {
if ($GroupWhere == '') {
$GroupWhere = 'WHERE ';
} else {
$GroupWhere.= ' AND ';
}
$GroupWhere.= "(SELECT t.GroupID FROM torrents AS t $TorrentWhere AND t.GroupID=h.GroupID LIMIT 1)";
2011-03-28 14:21:28 +00:00
}
$DB->query("SELECT $SCFR
h.GroupID,
h.GroupName,
h.GroupYear AS s2,
h.GroupCategoryID,
h.GroupTime AS s3,
h.MaxTorrentSize AS s4,
h.TotalSnatches AS s5,
h.TotalSeeders AS s6,
h.TotalLeechers AS s7,
h.TorrentIDList,
h.TagList,
h.MediaList,
h.FormatList,
h.EncodingList,
h.YearList,
h.RemasterList,
h.RemasterTitleList,
h.SceneList,
h.LogList,
h.CueList,
h.LogScoreList,
h.FileCountList,
h.FreeTorrentList,
h.SizeList,
h.LeechersList,
h.SeedersList,
h.SnatchedList,
h.TimeList,
h.SearchText AS s1
FROM torrent_hash AS h
$TorrentJoin
$GroupWhere
ORDER BY $OrderBy $OrderWay
LIMIT $Limit");
$TorrentList=$DB->to_array();
2013-04-17 08:00:58 +00:00
if (EXPLAIN_HACK) {
$DB->query("EXPLAIN SELECT NULL FROM (SELECT NULL FROM torrent_hash AS h $TorrentJoin $GroupWhere) AS Count");
2011-03-28 14:21:28 +00:00
list($Null,$Null,$Null,$Null,$Null,$Null,$Null,$Null,$TorrentCount)=$DB->next_record();
} else {
2013-04-17 08:00:58 +00:00
$DB->query('SELECT FOUND_ROWS()');
2011-03-28 14:21:28 +00:00
list($TorrentCount) = $DB->next_record();
}
} else {
// Build SQL for disabled grouping
2013-04-17 08:00:58 +00:00
if (!$TimeField) {
$TimeField = 't.Time';
}
2011-03-28 14:21:28 +00:00
$DB->query("SELECT $SCFR
g.ID,
g.Name,
g.Year AS s2,
g.CategoryID,
2013-04-17 08:00:58 +00:00
$TimeField AS s3,
2011-03-28 14:21:28 +00:00
t.Size AS s4,
t.Snatched AS s5,
t.Seeders AS s6,
t.Leechers AS s7,
t.ID,
g.TagList,
t.Media,
t.Format,
t.Encoding,
t.RemasterYear,
t.Remastered,
t.RemasterTitle,
t.Scene,
t.HasLog,
t.HasCue,
t.LogScore,
t.FileCount,
t.FreeTorrent,
g.SearchText AS s1
FROM torrents AS t
2013-04-17 08:00:58 +00:00
INNER JOIN torrents_group AS g ON g.ID=t.GroupID
2011-03-28 14:21:28 +00:00
$TorrentJoin
$TorrentWhere
ORDER BY $OrderBy $OrderWay
LIMIT $Limit");
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
$TorrentList = $DB->to_array();
if (EXPLAIN_HACK) {
$DB->query("EXPLAIN SELECT NULL FROM (SELECT NULL FROM torrent_hash AS h $TorrentJoin $GroupWhere) AS Count");
2011-03-28 14:21:28 +00:00
list($Null,$Null,$Null,$Null,$Null,$Null,$Null,$Null,$TorrentCount)=$DB->next_record();
} else {
2013-04-17 08:00:58 +00:00
$DB->query('SELECT FOUND_ROWS()');
2011-03-28 14:21:28 +00:00
list($TorrentCount) = $DB->next_record();
}
}
2013-04-17 08:00:58 +00:00
if ($UserID) {
2011-03-28 14:21:28 +00:00
// Get the username, so we can display the title as "<user>'s snatched torrents", etc
$DB->query("SELECT Username FROM users_main WHERE ID='".db_string($UserID)."'");
2013-04-17 08:00:58 +00:00
list($TitleUser) = $DB->next_record();
2011-03-28 14:21:28 +00:00
}
} else {
// We got the results from cache
2013-04-17 08:00:58 +00:00
$TorrentCount = $TorrentCache[0];
$TorrentList = $TorrentCache[1];
if ($UserID) {
$TitleUser = $TorrentCache[2];
}
2011-03-28 14:21:28 +00:00
}
2013-02-22 08:00:24 +00:00
2013-04-19 08:00:55 +00:00
// List of pages
2013-05-15 08:00:54 +00:00
$Pages = Format::get_pages($Page, $TorrentCount, TORRENTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
// Gets tacked onto torrent download URLs
2013-04-17 08:00:58 +00:00
$DownloadString = '&amp;authkey='.$LoggedUser['AuthKey'].'&amp;torrent_pass='.$LoggedUser['torrent_pass'];
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if ($Title) {
$Title = "$TitleUser's $Title";
} else {
$Title = 'Browse Torrents';
}
2011-03-28 14:21:28 +00:00
2012-10-11 08:00:15 +00:00
View::show_header($Title,'browse');
2011-03-28 14:21:28 +00:00
?>
2013-01-15 08:00:37 +00:00
<form name="filter" method="get" action="">
2013-04-17 08:00:58 +00:00
<? if ($UserID) { ?>
2011-03-28 14:21:28 +00:00
<input type="hidden" name="type" value="<?=display_str($_GET['type'])?>" />
<input type="hidden" name="userid" value="<?=display_str($_GET['userid'])?>" />
2013-04-17 08:00:58 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
<div class="filter_torrents">
<h3>
Filter
2013-04-17 08:00:58 +00:00
<? if (strtolower($_GET['action']) != 'advanced' && (!$LoggedUser['SearchType'] || strtolower($_GET['action']) == 'basic') && check_perms('site_advanced_search')) { ?>
2012-10-11 08:00:15 +00:00
(<a href="torrents.php?action=advanced&amp;<?=Format::get_url(array('action'))?>">Advanced Search</a>)
2013-04-17 08:00:58 +00:00
<? } elseif ((strtolower($_GET['action']) == 'advanced' || ($LoggedUser['SearchType'] && strtolower($_GET['action']) != 'basic')) && check_perms('site_advanced_search')) { ?>
(<a href="torrents.php?<? if ($LoggedUser['SearchType']) { ?>action=basic&amp;<? } echo Format::get_url(array('action')); ?>">Basic Search</a>)
<? } ?>
2011-03-28 14:21:28 +00:00
</h3>
<div class="box pad">
2012-09-01 08:00:24 +00:00
<table class="layout">
2013-04-17 08:00:58 +00:00
<? $AdvancedSearch = false;
if ((strtolower($_GET['action']) == 'advanced' || ($LoggedUser['SearchType'] && strtolower($_GET['action']) != 'basic')) && check_perms('site_advanced_search')) :
$AdvancedSearch = true;
2011-03-28 14:21:28 +00:00
?>
<tr>
<td class="label">Artist Name:</td>
<td colspan="3">
<input type="text" spellcheck="false" size="40" name="artistname" class="inputtext smaller" value="<?=display_str($_GET['artistname'])?>" />&nbsp;
2013-04-17 08:00:58 +00:00
<input type="checkbox" name="exactartist" id="exactartist" value="1"<? if ($_GET['exactartist']) { ?> checked="checked"<? } ?> /> <label for="exactartist">Exact Phrase</label>
2011-03-28 14:21:28 +00:00
<input type="hidden" name="action" value="advanced" />
</td>
</tr>
<tr>
<td class="label">Album/Torrent Name:</td>
<td colspan="3">
<input type="text" spellcheck="false" size="40" name="torrentname" class="inputtext smaller" value="<?=display_str($_GET['torrentname'])?>" />&nbsp;
2013-04-17 08:00:58 +00:00
<input type="checkbox" name="exacttorrent" id="exacttorrent" value="1"<? if ($_GET['exacttorrent']) { ?> checked="checked"<? } ?> /> <label for="exacttorrent">Exact Phrase</label>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<tr>
<td class="label">Edition Information:</td>
<td colspan="3">
<input type="text" spellcheck="false" size="40" name="remastertitle" class="inputtext smaller" value="<?=display_str($_GET['remastertitle'])?>" />&nbsp;
2013-04-17 08:00:58 +00:00
<input type="checkbox" name="exactremaster" id="exactremaster" value="1"<? if ($_GET['exactremaster']) { ?> checked="checked"<? } ?> /> <label for="exactremaster">Exact Phrase</label>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<tr>
<td class="label">File List:</td>
<td colspan="3"><input type="text" spellcheck="false" size="40" name="filelist" class="inputtext" value="<?=display_str($_GET['filelist']); ?>" /></td>
</tr>
<tr>
<td class="label">Rip Specifics:</td>
<td class="nobr">
2013-04-17 08:00:58 +00:00
<select id=bitrate name="bitrate" style="width: auto;" onchange="Bitrate()">
2011-03-28 14:21:28 +00:00
<option value="">Bitrate</option>
2013-04-17 08:00:58 +00:00
<? if ($_GET['bitrate'] && $_GET['bitrate'] == 'Other') {
2011-03-28 14:21:28 +00:00
$OtherBitrate = true;
} else {
$OtherBitrate = false;
}
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
foreach ($Bitrates as $BitrateName) { ?>
<option value="<?=display_str($BitrateName); ?>"<? if ($BitrateName == $_GET['bitrate']) { ?> selected="selected"<? } ?>><?=display_str($BitrateName); ?></option>
<? } ?> </select>
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
<span id="other_bitrate_span"<? if (!$OtherBitrate) { echo ' style="display: none;"'; } ?> >
<input type="text" spellcheck="false" name="other_bitrate" size="5" id="other_bitrate"<? if ($OtherBitrate) { echo ' value="'.display_str($_GET['other_bitrate']).'"';} ?> />
2011-03-28 14:21:28 +00:00
</span>
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
<select name="format" style="width: auto;">
2011-03-28 14:21:28 +00:00
<option value="">Format</option>
2013-04-17 08:00:58 +00:00
<? foreach ($Formats as $FormatName) { ?>
<option value="<?=display_str($FormatName); ?>"<? if ($FormatName == $_GET['format']) { ?> selected="selected"<? } ?>><?=display_str($FormatName); ?></option>
<? } ?> </select>
<select name="media" style="width: auto;">
2011-03-28 14:21:28 +00:00
<option value="">Media</option>
2013-04-17 08:00:58 +00:00
<? foreach ($Media as $MediaName) { ?>
<option value="<?=display_str($MediaName); ?>"<? if ($MediaName == $_GET['media']) { ?> selected="selected"<? } ?>><?=display_str($MediaName); ?></option>
<? } ?>
2011-03-28 14:21:28 +00:00
</select>
</td>
<td class="label">Year:</td>
<td><input type="text" name="year" class="inputtext smallest" value="<?=display_str($_GET['year']); ?>" size="4" /></td>
</tr>
<tr>
<td class="label">Misc:</td>
<td class="nobr" colspan="3">
2013-04-17 08:00:58 +00:00
<select name="haslog" style="width: auto;">
2011-03-28 14:21:28 +00:00
<option value="">Has Log</option>
2013-04-17 08:00:58 +00:00
<option value="1"<? if ($_GET['haslog'] == '1') { ?> selected="selected"<? } ?>>Yes</option>
<option value="0"<? if ($_GET['haslog'] == '0') { ?> selected="selected"<? } ?>>No</option>
<option value="100"<? if ($_GET['haslog'] == '100') { ?> selected="selected"<? } ?>>100% only</option>
<option value="-100"<? if ($_GET['haslog'] == '-100') { ?> selected="selected"<? } ?>>&lt;100%/Unscored</option>
2011-03-28 14:21:28 +00:00
</select>
2013-04-17 08:00:58 +00:00
<select name="hascue" style="width: auto;">
2011-03-28 14:21:28 +00:00
<option value="">Has Cue</option>
2013-04-17 08:00:58 +00:00
<option value="1"<? if ($_GET['hascue'] == '1') { ?> selected="selected"<? } ?>>Yes</option>
<option value="0"<? if ($_GET['hascue'] == '0') { ?> selected="selected"<? } ?>>No</option>
2011-03-28 14:21:28 +00:00
</select>
2013-04-17 08:00:58 +00:00
<select name="scene" style="width: auto;">
2011-03-28 14:21:28 +00:00
<option value="">Scene</option>
2013-04-17 08:00:58 +00:00
<option value="1"<? if ($_GET['scene'] == '1') { ?> selected="selected"<? } ?>>Yes</option>
<option value="0"<? if ($_GET['scene'] == '0') { ?> selected="selected"<? } ?>>No</option>
2011-03-28 14:21:28 +00:00
</select>
2013-04-17 08:00:58 +00:00
<select name="freeleech" style="width: auto;">
2011-03-28 14:21:28 +00:00
<option value="">Freeleech</option>
2013-04-17 08:00:58 +00:00
<option value="1"<? if ($_GET['freeleech'] == '1') { ?> selected="selected"<? } ?>>Yes</option>
<option value="0"<? if ($_GET['freeleech'] == '0') { ?> selected="selected"<? } ?>>No</option>
2011-03-28 14:21:28 +00:00
</select>
2013-04-17 08:00:58 +00:00
<select name="remastered" style="width: auto;">
<option value="">Remastered</option>
<option value="1"<? if ($_GET['remastered'] == '1') { ?> selected="selected"<? } ?>>Yes</option>
<option value="0"<? if ($_GET['remastered'] == '0') { ?> selected="selected"<? } ?>>No</option>
2011-03-28 14:21:28 +00:00
</select>
</td>
</tr>
2013-04-17 08:00:58 +00:00
<? else: ?>
2011-03-28 14:21:28 +00:00
<tr>
<td class="label">Search terms:</td>
<td colspan="3">
<input type="text" spellcheck="false" size="40" name="searchstr" class="inputtext" value="<?=display_str($_GET['searchstr'])?>" />
2013-04-17 08:00:58 +00:00
<? if ($LoggedUser['SearchType']) { ?>
2011-03-28 14:21:28 +00:00
<input type="hidden" name="action" value="basic" />
2013-04-17 08:00:58 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</td>
</tr>
2013-04-17 08:00:58 +00:00
<? endif; ?>
2011-03-28 14:21:28 +00:00
<tr>
<td class="label">Tags (comma-separated):</td>
<td colspan="3">
<input type="text" size="40" id="tags" name="searchtags" class="inputtext smaller" title="Use -tag to exclude tag" value="<?=display_str($_GET['searchtags'])?>" />&nbsp;
2013-04-17 08:00:58 +00:00
<input type="radio" name="tags_type" id="tags_type0" value="0"<? if ($_GET['tags_type'] == 0) { ?> checked="checked"<? } ?> /> <label for="tags_type0">Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<? if ($_GET['tags_type'] == 1) { ?> checked="checked"<? } ?> /> <label for="tags_type1">All</label>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<tr>
<td class="label">Order by:</td>
2013-04-17 08:00:58 +00:00
<td colspan="<?=($AdvancedSearch) ? '3' : '1' ?>">
<select name="order_by" style="width: auto;">
<option value="s1"<? if ($OrderBy == 's1') { ?> selected="selected"<? } ?>>Name</option>
<option value="s2"<? if ($OrderBy == 's2') { ?> selected="selected"<? } ?>>Year</option>
<option value="s3"<? if ($OrderBy == 's3') { ?> selected="selected"<? } ?>><?=$TimeLabel?></option>
<option value="s4"<? if ($OrderBy == 's4') { ?> selected="selected"<? } ?>>Size</option>
<option value="s5"<? if ($OrderBy == 's5') { ?> selected="selected"<? } ?>>Snatched</option>
<option value="s6"<? if ($OrderBy == 's6') { ?> selected="selected"<? } ?>>Seeders</option>
<option value="s7"<? if ($OrderBy == 's7') { ?> selected="selected"<? } ?>>Leechers</option>
2011-03-28 14:21:28 +00:00
</select>
<select name="order_way">
2013-04-17 08:00:58 +00:00
<option value="desc"<? if ($OrderWay == 'DESC') { ?> selected="selected"<? } ?>>Descending</option>
<option value="asc"<? if ($OrderWay == 'ASC') { ?> selected="selected"<? } ?>>Ascending</option>
2011-03-28 14:21:28 +00:00
</select>&nbsp;&nbsp;&nbsp;&nbsp;
<?/*
2013-04-17 08:00:58 +00:00
<? if ($LoggedUser['DisableGrouping']) { ?>
<input type="checkbox" name="enablegrouping" id="enablegrouping" value="1"<? if (!$DisableGrouping) { ?> checked="checked"<? } ?> /> <label for="enablegrouping"><strong>Enable grouping</strong></label>
<? } else { ?>
<input type="checkbox" name="disablegrouping" id="disablegrouping" value="1"<? if ($DisableGrouping) { ?> checked="checked"<? } ?> /> <label for="disablegrouping"><strong>Disable grouping</strong></label>
<? } ?>
2011-03-28 14:21:28 +00:00
*/?>
</td>
</tr>
</table>
2012-09-01 08:00:24 +00:00
<table class="layout cat_list">
2011-03-28 14:21:28 +00:00
<?
2013-04-17 08:00:58 +00:00
$x = 1;
2011-03-28 14:21:28 +00:00
reset($Categories);
2013-04-17 08:00:58 +00:00
foreach ($Categories as $CatKey => $CatName) :
if ($x % 8 == 0 || $x == 1) {
2011-03-28 14:21:28 +00:00
?>
<tr>
<? } ?>
<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-04-17 08:00:58 +00:00
if ($x % 7 == 0) {
2011-03-28 14:21:28 +00:00
?>
</tr>
2013-04-17 08:00:58 +00:00
<? }
2011-03-28 14:21:28 +00:00
$x++;
2013-04-17 08:00:58 +00:00
endforeach;
2011-03-28 14:21:28 +00:00
?>
</table>
2013-04-17 08:00:58 +00:00
<table class="layout cat_list<? if (!$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) {
2011-03-28 14:21:28 +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-04-17 08:00:58 +00:00
foreach ($GenreTags as $Tag) :
2011-03-28 14:21:28 +00:00
?>
<td width="12.5%"><a href="#" onclick="add_tag('<?=$Tag?>');return false;"><?=$Tag?></a></td>
<?
$x++;
2013-04-17 08:00:58 +00:00
if ($x % 7 == 0) {
2011-03-28 14:21:28 +00:00
?>
</tr>
<tr>
<?
}
2013-04-17 08:00:58 +00:00
endforeach;
if ($x % 7 != 0) { // Padding
2011-03-28 14:21:28 +00:00
?>
2013-04-17 08:00:58 +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-04-17 08:00:58 +00:00
<td class="label"><a href="#" onclick="$('#taglist').toggle();return false;" class="brackets">View tags</a></td>
2011-03-28 14:21:28 +00:00
</tr>
</table>
<div class="submit">
2013-04-17 08:00:58 +00:00
<span style="float: left;"><?=number_format($TorrentCount)?> Results</span>
<input type="submit" value="Filter torrents" />
<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;
2013-04-17 08:00:58 +00:00
<? if (isset($TorrentWhere) || isset($GroupWhere) || $OrderBy != 's3' || $OrderWay != 'DESC') { ?>
<input type="submit" name="setdefault" value="Make default" />
<? }
if ($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>
<div class="linkbox"><?=$Pages?></div>
2013-04-17 08:00:58 +00:00
<? if (count($TorrentList) > 0) { ?>
<table class="torrent_table cats<?=(($DisableGrouping) ? ' no_grouping' : ' grouping') ?>" id="torrent_table">
2011-03-28 14:21:28 +00:00
<tr class="colhead">
2013-04-17 08:00:58 +00:00
<? if (!$DisableGrouping) { ?>
2011-03-28 14:21:28 +00:00
<td class="small"></td>
<? } ?>
<td class="small cats_col"></td>
<td width="100%"><a href="<?=header_link('s1','ASC')?>">Name</a> / <a href="<?=header_link('s2')?>">Year</a></td>
<td>Files</td>
<td><a href="<?=header_link('s3')?>"><?=$TimeLabel?></a></td>
<td><a href="<?=header_link('s4')?>">Size</a></td>
<td class="sign"><a href="<?=header_link('s5')?>"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/snatched.png" alt="Snatches" title="Snatches" /></a></td>
<td class="sign"><a href="<?=header_link('s6')?>"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/seeders.png" alt="Seeders" title="Seeders" /></a></td>
<td class="sign"><a href="<?=header_link('s7')?>"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/leechers.png" alt="Leechers" title="Leechers" /></a></td>
</tr>
<?
2013-04-17 08:00:58 +00:00
if ($LoggedUser['TorrentGrouping'] == 0) {
$HideGroup = '';
$ActionTitle = 'Collapse';
$ActionURL = 'hide';
} elseif ($LoggedUser['TorrentGrouping'] == 1) {
$HideGroup = 'hide';
$ActionTitle = 'Expand';
$ActionURL = 'show';
2011-03-28 14:21:28 +00:00
}
// Start printing torrent list
$GroupIDs = array();
2013-04-17 08:00:58 +00:00
foreach ($TorrentList as $Key => $Properties) {
2011-03-28 14:21:28 +00:00
$GroupIDs[] = $Properties[0];
}
2012-10-11 08:00:15 +00:00
$Artists = Artists::get_artists($GroupIDs);
2011-03-28 14:21:28 +00:00
foreach ($TorrentList as $Key => $Properties) {
2013-02-25 21:16:55 +00:00
list($GroupID,$GroupName,$GroupYear,$GroupCategoryID,$GroupTime,$MaxSize,$TotalSnatched,$TotalSeeders,$TotalLeechers,$TorrentsID,$TagsList,$TorrentsMedia,$TorrentsFormat,$TorrentsEncoding,$TorrentsYear,$TorrentsRemastered,$TorrentsRemasterTitle,$TorrentsScene,$TorrentsLog,$TorrentsCue,$TorrentsLogScores,$TorrentsFileCount,$TorrentsFreeTorrent,$TorrentsSize,$TorrentsLeechers,$TorrentsSeeders,$TorrentsSnatched,$TorrentsTime) = $Properties;
2013-04-17 08:00:58 +00:00
$Torrents['id'] = explode('|',$TorrentsID);
$Torrents['media'] = explode('|',$TorrentsMedia);
$Torrents['format'] = explode('|',$TorrentsFormat);
$Torrents['encoding'] = explode('|',$TorrentsEncoding);
$Torrents['year'] = explode('|',$TorrentsYear);
$Torrents['remastered'] = explode('|',$TorrentsRemastered);
$Torrents['remastertitle'] = explode('|',$TorrentsRemasterTitle);
$Torrents['scene'] = explode('|',$TorrentsScene);
$Torrents['log'] = explode('|',$TorrentsLog);
$Torrents['cue'] = explode('|',$TorrentsCue);
$Torrents['score'] = explode('|',$TorrentsLogScores);
$Torrents['filecount'] = explode('|',$TorrentsFileCount);
$Torrents['size'] = explode('|',$TorrentsSize);
$Torrents['leechers'] = explode('|',$TorrentsLeechers);
$Torrents['seeders'] = explode('|',$TorrentsSeeders);
$Torrents['snatched'] = explode('|',$TorrentsSnatched);
$Torrents['freetorrent'] = explode('|',$TorrentsFreeTorrent);
$Torrents['time'] = explode('|',$TorrentsTime);
2011-03-28 14:21:28 +00:00
if (!$DisableGrouping) {
// Since these fields are surrounded by |s, we get extra elements added to the arrays
array_pop($Torrents['media']);
array_pop($Torrents['format']);
array_pop($Torrents['encoding']);
array_pop($Torrents['remastertitle']);
array_pop($Torrents['log']);
array_pop($Torrents['cue']);
array_pop($Torrents['score']);
array_pop($Torrents['freetorrent']);
array_shift($Torrents['media']);
array_shift($Torrents['format']);
array_shift($Torrents['encoding']);
array_shift($Torrents['remastertitle']);
array_shift($Torrents['log']);
array_shift($Torrents['cue']);
array_shift($Torrents['score']);
array_shift($Torrents['freetorrent']);
} else {
2013-04-17 08:00:58 +00:00
$Torrents['size'][0] = $MaxSize;
$Torrents['leechers'][0] = $TotalLeechers;
$Torrents['seeders'][0] = $TotalSeeders;
$Torrents['snatched'][0] = $TotalSnatched;
2011-03-28 14:21:28 +00:00
}
2013-02-25 21:16:55 +00:00
$TorrentTags = new Tags($TagsList);
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if ($GroupName == '') {
$GroupName = '- None -';
}
2012-10-11 08:00:15 +00:00
$DisplayName = Artists::display_artists($Artists[$GroupID]);
2013-04-17 08:00:58 +00:00
if ((count($Torrents['id']) > 1 || $GroupCategoryID == 1) && !$DisableGrouping) {
2011-03-28 14:21:28 +00:00
// These torrents are in a group
$DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
2013-04-17 08:00:58 +00:00
if ($GroupYear > 0) {
$DisplayName.=" [$GroupYear]";
}
2011-03-28 14:21:28 +00:00
?>
<tr class="group">
<td class="center"><div title="<?=$ActionTitle?>" id="showimg_<?=$GroupID?>" class="<?=$ActionURL?>_torrents"><a href="#" class="show_torrents_link" onclick="$('.groupid_<?=$GroupID?>').toggle(); return false;"></a></div></td>
2013-02-25 21:16:55 +00:00
<td class="center cats_col"><div title="<?=$TorrentTags->title()?>" class="<?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>"></div></td>
<td colspan="2" class="big_info">
<?
// Image cover art requires WikiImage
/*
if ($LoggedUser['CoverArt']) : ?>
<div class="group_image float_left clear">
<? ImageTools::cover_thumb('', $GroupCategoryID - 1) ?>
</div>
<? endif;
*/
?>
<div class="group_info clear">
<?=$DisplayName?>
2013-04-17 08:00:58 +00:00
<span style="float: right;"><a href="#showimg_<?=$GroupID?>" onclick="Bookmark(<?=$GroupID?>);this.innerHTML='Bookmarked';return false;" class="brackets">Bookmark</a></span>
2013-02-25 21:16:55 +00:00
<div class="tags"><?=$TorrentTags->format('torrents.php?searchtags=')?></div>
</div>
2011-03-28 14:21:28 +00:00
</td>
<td class="nobr"><?=time_diff($GroupTime,1)?></td>
2012-10-11 08:00:15 +00:00
<td class="nobr"><?=Format::get_size($MaxSize)?> (Max)</td>
2011-03-28 14:21:28 +00:00
<td><?=number_format($TotalSnatched)?></td>
2013-04-17 08:00:58 +00:00
<td<?=($TotalSeeders == 0) ? ' class="r00"' : ''?>><?=number_format($TotalSeeders)?></td>
2011-03-28 14:21:28 +00:00
<td><?=number_format($TotalLeechers)?></td>
</tr>
<?
$Row = 'a';
2013-04-17 08:00:58 +00:00
foreach ($Torrents['id'] as $Key => $Val) :
2011-03-28 14:21:28 +00:00
// All of the individual torrents in the group
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
// If they're using the advanced search and have chosen enabled grouping, we just skip the torrents that don't check out
2013-04-17 08:00:58 +00:00
if (!empty($_GET['bitrate']) && $Torrents['encoding'][$Key] != $_GET['bitrate']) {
continue;
}
if (!empty($_GET['format']) && $Torrents['format'][$Key] != $_GET['format']) {
continue;
}
if (!empty($_GET['media']) && $Torrents['media'][$Key] != $_GET['media']) {
continue;
}
if (!empty($_GET['haslog'])) {
if ($_GET['haslog'] == '100' && $Torrents['score'][$Key] != 100) {
2011-03-28 14:21:28 +00:00
continue;
}
2013-04-17 08:00:58 +00:00
if ($_GET['haslog'] == '-100' && $Torrents['score'][$Key] == 100 || !$Torrents['log'][$Key]) {
2011-03-28 14:21:28 +00:00
continue;
}
2013-04-17 08:00:58 +00:00
if (($_GET['haslog'] == '1' || $_GET['haslog'] == '0') && $Torrents['log'][$Key] != $_GET['haslog']) {
2013-02-22 08:00:24 +00:00
continue;
2011-03-28 14:21:28 +00:00
}
}
2013-04-17 08:00:58 +00:00
if (!empty($_GET['hascue']) && $Torrents['cue'][$Key] != $_GET['hascue']) {
continue;
}
if (!empty($_GET['scene']) && $Torrents['scene'][$Key] != $_GET['scene']) {
continue;
}
if (!empty($_GET['freeleech']) && $Torrents['freetorrent'][$Key] != $_GET['freeleech']) {
continue;
}
if (!empty($_GET['remastered']) && $Torrents['remastered'][$Key] != $_GET['remastered']) {
continue;
}
if (!empty($_GET['exactremaster']) && !empty($_GET['remastertitle'])) {
if (strtolower(trim($Torrents['remastertitle'][$Key])) != strtolower(trim($_GET['remastertitle']))) {
2011-03-28 14:21:28 +00:00
continue;
}
2013-04-17 08:00:58 +00:00
} elseif (!empty($_GET['remastertitle'])) {
2011-03-28 14:21:28 +00:00
$Continue = false;
$RemasterParts = explode(' ', $_GET['remastertitle']);
2013-04-17 08:00:58 +00:00
foreach ($RemasterParts as $RemasterPart) {
if (stripos($Torrents['remastertitle'][$Key],$RemasterPart) === false) {
2011-03-28 14:21:28 +00:00
$Continue = true;
}
}
2013-04-17 08:00:58 +00:00
if ($Continue) {
2011-03-28 14:21:28 +00:00
continue;
}
}
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
$ExtraInfo = '';
$AddExtra = '';
2013-02-22 08:00:24 +00:00
2013-04-17 08:00:58 +00:00
if ($Torrents['format'][$Key]) {
$ExtraInfo.=$Torrents['format'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['encoding'][$Key]) {
$ExtraInfo.=$AddExtra.$Torrents['encoding'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['log'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Log';
$AddExtra = ' / ';
if ($Torrents['score'][$Key]) {
$ExtraInfo.=' ('.$Torrents['score'][$Key].'%) ';
}
}
if ($Torrents['cue'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Cue';
$AddExtra = ' / ';
}
if ($Torrents['media'][$Key]) {
$ExtraInfo.=$AddExtra.$Torrents['media'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['scene'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Scene';
$AddExtra = ' / ';
}
if (trim($Torrents['remastertitle'][$Key])) {
$ExtraInfo.=$AddExtra.$Torrents['remastertitle'][$Key];
$AddExtra = ' - ';
} elseif ($Torrents['remastered'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Remastered';
$AddExtra = ' - ';
}
if ($Torrents['year'][$Key] > '0') {
$ExtraInfo.=$AddExtra.$Torrents['year'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['freetorrent'][$Key] == '1') {
$ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
2011-03-28 14:21:28 +00:00
}
?>
<tr class="group_torrent groupid_<?=$GroupID?> <?=$HideGroup?>">
<td colspan="3">
<span>
2012-08-14 08:00:18 +00:00
[ <a href="torrents.php?action=download&amp;id=<?=$Torrents['id'][$Key]?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
| <a href="reportsv2.php?action=report&amp;id=<?=$Torrents['id'][$Key]?>" title="Report">RP</a> ]
2011-03-28 14:21:28 +00:00
</span>
&raquo; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$Val?>"><?=$ExtraInfo?></a>
</td>
<td><?=$Torrents['filecount'][$Key]?></td>
<td class="nobr"><?=time_diff($Torrents['time'][$Key],1)?></td>
2012-10-11 08:00:15 +00:00
<td class="nobr"><?=Format::get_size($Torrents['size'][$Key])?></td>
2011-03-28 14:21:28 +00:00
<td><?=number_format($Torrents['snatched'][$Key])?></td>
2013-04-17 08:00:58 +00:00
<td<?=($Torrents['seeders'][$Key] == 0) ? ' class="r00"' : ''?>><?=number_format($Torrents['seeders'][$Key])?></td>
2011-03-28 14:21:28 +00:00
<td><?=number_format($Torrents['leechers'][$Key])?></td>
</tr>
<?
2013-04-17 08:00:58 +00:00
endforeach;
2011-03-28 14:21:28 +00:00
} else {
// Either grouping is disabled, or we're viewing a type that does not require grouping
2013-04-17 08:00:58 +00:00
if ($GroupCategoryID == 1) {
2011-03-28 14:21:28 +00:00
$DisplayName.='<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$Torrents['id'][0].'" title="View Torrent">'.$GroupName.'</a>';
} else {
$DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
}
2013-04-17 08:00:58 +00:00
$ExtraInfo = '';
$AddExtra = '';
if ($Torrents['format'][0]) {
$ExtraInfo.=$Torrents['format'][0];
$AddExtra=' / ';
}
if ($Torrents['encoding'][0]) {
$ExtraInfo.=$AddExtra.$Torrents['encoding'][0];
$AddExtra=' / ';
}
if ($Torrents['log'][0] == '1') {
$ExtraInfo.=$AddExtra.'Log';
$AddExtra = ' / ';
}
if ($Torrents['score'][0]) {
$ExtraInfo.=' ('.$Torrents['score'][0].'%) ';
}
if ($Torrents['cue'][0] == '1') {
$ExtraInfo.=$AddExtra.'Cue';
$AddExtra = ' / ';
}
if ($Torrents['media'][0]) {
$ExtraInfo.=$AddExtra.$Torrents['media'][0];
$AddExtra = ' / ';
}
if ($Torrents['scene'][0] == '1') {
$ExtraInfo.=$AddExtra.'Scene';
$AddExtra = ' / ';
}
if (trim($Torrents['remastertitle'][0])) {
$ExtraInfo.=$AddExtra.$Torrents['remastertitle'][0];
$AddExtra = ' - ';
} elseif ($Torrents['remastered'][0] == '1') {
$ExtraInfo.=$AddExtra.'Remastered';
$AddExtra = ' - ';
}
if ($Torrents['year'][0] > '0') {
$ExtraInfo.=$AddExtra.$Torrents['year'][0];
$AddExtra = ' / ';
}
if ($Torrents['freetorrent'][0] == '1') {
$ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
}
if ($ExtraInfo != '') {
$ExtraInfo = "[$ExtraInfo]";
}
if ($GroupYear > 0) {
$ExtraInfo.=" [$GroupYear]";
}
if (!isset($TimeField) || $TimeField == 't.Time') {
$GroupTime = strtotime($GroupTime);
}
2011-03-28 14:21:28 +00:00
?>
<tr class="torrent">
2013-04-17 08:00:58 +00:00
<? if (!$DisableGrouping) { ?>
2011-03-28 14:21:28 +00:00
<td></td>
<? } ?>
2013-02-25 21:16:55 +00:00
<td class="center cats_col"><div title="<?=$TorrentTags->title()?>" class="<?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>"></div></td>
<td class="big_info">
<? /* if ($LoggedUser['CoverArt']) : ?>
<div class="group_image float_left clear">
<? ImageTools::cover_thumb('', $GroupCategoryID - 1) ?>
</div>
<? endif; */ ?>
<div class="group_info">
<span>[ <a href="torrents.php?action=download&amp;id=<?=$Torrents['id'][0].$DownloadString?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a> | <a href="reportsv2.php?action=report&amp;id=<?=$Torrents['id'][0]?>" title="Report">RP</a> ]</span>
<?=$DisplayName?>
<?=$ExtraInfo?>
<div class="tags"><?=$TorrentTags->format()?></div>
</div>
2011-03-28 14:21:28 +00:00
</td>
<td><?=$Torrents['filecount'][0]?></td>
<td class="nobr"><?=time_diff($GroupTime,1)?></td>
2012-10-11 08:00:15 +00:00
<td class="nobr"><?=Format::get_size($Torrents['size'][0])?></td>
2011-03-28 14:21:28 +00:00
<td><?=number_format($TotalSnatched)?></td>
2013-04-17 08:00:58 +00:00
<td<?=($TotalSeeders == 0) ? ' class="r00"' : ''?>><?=number_format($TotalSeeders)?></td>
2011-03-28 14:21:28 +00:00
<td><?=number_format($TotalLeechers)?></td>
</tr>
<?
}
}
?>
</table>
2013-04-17 08:00:58 +00:00
<? } else {
2013-02-22 08:00:24 +00:00
$DB->query("SELECT
2013-04-17 08:00:58 +00:00
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");
2011-03-28 14:21:28 +00:00
?>
<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>
2013-04-17 08:00:58 +00:00
<p>You might like (beta): <? while (list($Tag) = $DB->next_record()) { ?><a href="torrents.php?searchtags=<?=$Tag?>"><?=$Tag?></a><? } ?></p>
2011-03-28 14:21:28 +00:00
</div>
2013-04-17 08:00:58 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
<div class="linkbox"><?=$Pages?></div>
2012-10-11 08:00:15 +00:00
<? View::show_footer(array('disclaimer'=>false)); ?>