2011-03-28 14:21:28 +00:00
< ?
/************************************************************************
*-------------------- Browse page ---------------------------------------
* Welcome to one of the most complicated pages in all of gazelle - the
2012-11-01 08:00:21 +00:00
* browse page .
*
2011-03-28 14:21:28 +00:00
* This is the page that is displayed when someone visits torrents . php
2012-11-01 08:00:21 +00:00
*
2011-03-28 14:21:28 +00:00
* It offers normal and advanced search , as well as enabled / disabled
2012-11-01 08:00:21 +00:00
* grouping .
2011-03-28 14:21:28 +00:00
*
* For an outdated non - Sphinx version , use / sections / torrents / browse . php .
*
* Don ' t blink .
* Blink and you ' re dead .
* Don ' t turn your back .
* Don ' t look away .
* And don ' t blink .
* Good Luck .
*
*************************************************************************/
2013-03-29 08:00:08 +00:00
2011-03-28 14:21:28 +00:00
include ( SERVER_ROOT . '/sections/torrents/functions.php' );
// The "order by x" links on columns headers
2013-07-04 08:00:56 +00:00
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' ));
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
/** Start default parameters and validation **/
if ( ! empty ( $_GET [ 'searchstr' ]) || ! empty ( $_GET [ 'groupname' ])) {
if ( ! empty ( $_GET [ 'searchstr' ])) {
2011-03-28 14:21:28 +00:00
$InfoHash = $_GET [ 'searchstr' ];
} else {
$InfoHash = $_GET [ 'groupname' ];
}
2012-11-01 08:00:21 +00:00
// Search by infohash
if ( $InfoHash = is_valid_torrenthash ( $InfoHash )) {
2013-07-04 08:00:56 +00:00
$InfoHash = db_string ( pack ( 'H*' , $InfoHash ));
$DB -> query ( "
SELECT ID , GroupID
FROM torrents
WHERE info_hash = '$InfoHash' " );
2013-07-10 00:08:53 +00:00
if ( $DB -> has_results ()) {
2011-03-28 14:21:28 +00:00
list ( $ID , $GroupID ) = $DB -> next_record ();
2013-07-04 08:00:56 +00:00
header ( " Location: torrents.php?id= $GroupID &torrentid= $ID " );
2011-03-28 14:21:28 +00:00
die ();
}
}
}
// Setting default search options
2012-11-01 08:00:21 +00:00
if ( ! empty ( $_GET [ 'setdefault' ])) {
2013-06-11 08:01:24 +00:00
$UnsetList = array ( 'page' , 'setdefault' );
$UnsetRegexp = '/(&|^)(' . implode ( '|' , $UnsetList ) . ')=.*?(&|$)/i' ;
2011-03-28 14:21:28 +00:00
2013-06-11 08:01:24 +00:00
$DB -> query ( "
SELECT SiteOptions
FROM users_info
2013-07-04 08:00:56 +00:00
WHERE UserID = '".db_string($LoggedUser[' ID '])."' " );
2013-06-11 08:01:24 +00:00
list ( $SiteOptions ) = $DB -> next_record ( MYSQLI_NUM , false );
2012-11-01 08:00:21 +00:00
if ( ! empty ( $SiteOptions )) {
2011-03-28 14:21:28 +00:00
$SiteOptions = unserialize ( $SiteOptions );
} else {
$SiteOptions = array ();
}
2013-06-11 08:01:24 +00:00
$SiteOptions [ 'DefaultSearch' ] = preg_replace ( $UnsetRegexp , '' , $_SERVER [ 'QUERY_STRING' ]);
$DB -> query ( "
UPDATE users_info
2013-07-04 08:00:56 +00:00
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' ]));
2011-03-28 14:21:28 +00:00
$Cache -> commit_transaction ( 0 );
// Clearing default search options
2012-11-01 08:00:21 +00:00
} elseif ( ! empty ( $_GET [ 'cleardefault' ])) {
2013-06-11 08:01:24 +00:00
$DB -> query ( "
SELECT SiteOptions
FROM users_info
2013-07-04 08:00:56 +00:00
WHERE UserID = '".db_string($LoggedUser[' ID '])."' " );
2013-06-11 08:01:24 +00:00
list ( $SiteOptions ) = $DB -> next_record ( MYSQLI_NUM , false );
$SiteOptions = unserialize ( $SiteOptions );
$SiteOptions [ 'DefaultSearch' ] = '' ;
$DB -> query ( "
UPDATE users_info
2013-07-04 08:00:56 +00:00
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-07-17 08:00:52 +00:00
} elseif ( empty ( $_SERVER [ 'QUERY_STRING' ]) || ( count ( $_GET ) === 1 && isset ( $_GET [ 'page' ]))) {
2012-11-01 08:00:21 +00:00
if ( ! empty ( $LoggedUser [ 'DefaultSearch' ])) {
if ( ! empty ( $_GET [ 'page' ])) {
$Page = $_GET [ 'page' ];
2013-07-04 08:00:56 +00:00
parse_str ( $LoggedUser [ 'DefaultSearch' ], $_GET );
2012-11-01 08:00:21 +00:00
$_GET [ 'page' ] = $Page ;
} else {
2013-07-04 08:00:56 +00:00
parse_str ( $LoggedUser [ 'DefaultSearch' ], $_GET );
2012-11-01 08:00:21 +00:00
}
2011-03-28 14:21:28 +00:00
}
}
2012-11-01 08:00:21 +00:00
// Terms were not submitted via the search form
if ( ! isset ( $_GET [ 'searchsubmit' ])) {
$_GET [ 'group_results' ] = ! $LoggedUser [ 'DisableGrouping2' ];
}
if ( isset ( $_GET [ 'group_results' ]) && $_GET [ 'group_results' ]) {
$_GET [ 'group_results' ] = 1 ;
$GroupResults = true ;
$SortOrders = array (
// 'url attr' => [global order, order within group]
'year' => array ( 'year' , 'year' ),
'time' => array ( 'id' , 'id' ),
'size' => array ( 'maxsize' , 'size' ),
'seeders' => array ( 'sumseeders' , 'seeders' ),
'leechers' => array ( 'sumleechers' , 'leechers' ),
'snatched' => array ( 'sumsnatched' , 'snatched' ),
'random' => false );
2013-07-04 08:00:56 +00:00
2012-11-01 08:00:21 +00:00
$AggregateExp = array (
'maxsize' => 'MAX(size) AS maxsize' ,
'sumseeders' => 'SUM(seeders) AS sumseeders' ,
'sumleechers' => 'SUM(leechers) AS sumleechers' ,
'sumsnatched' => 'SUM(snatched) AS sumsnatched' );
} else {
$SortOrders = array (
'year' => 'year' ,
'time' => 'id' ,
'size' => 'size' ,
'seeders' => 'seeders' ,
'leechers' => 'leechers' ,
'snatched' => 'snatched' ,
'random' => false );
}
2011-03-28 14:21:28 +00:00
2012-11-01 08:00:21 +00:00
if ( empty ( $_GET [ 'order_by' ]) || ! isset ( $SortOrders [ $_GET [ 'order_by' ]])) {
$_GET [ 'order_by' ] = 'time' ;
$OrderBy = 'time' ; // For header links
} else {
$OrderBy = $_GET [ 'order_by' ];
}
2013-04-15 08:00:54 +00:00
if ( ! empty ( $_GET [ 'order_way' ]) && $_GET [ 'order_way' ] == 'asc' ) {
2012-11-01 08:00:21 +00:00
$OrderWay = 'asc' ;
} else {
$_GET [ 'order_way' ] = 'desc' ;
$OrderWay = 'desc' ;
}
/** End default parameters and validation **/
/** Start preparation of property arrays **/
2011-03-28 14:21:28 +00:00
array_pop ( $Bitrates ); // remove 'other'
2013-06-11 08:01:24 +00:00
$SearchBitrates = array_merge ( $Bitrates , array ( 'v0' , 'v1' , 'v2' , '24bit' ));
2011-03-28 14:21:28 +00:00
2012-11-01 08:00:21 +00:00
foreach ( $SearchBitrates as $ID => $Val ) {
$SearchBitrates [ $ID ] = strtolower ( $Val );
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
foreach ( $Formats as $ID => $Val ) {
$SearchFormats [ $ID ] = strtolower ( $Val );
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
/** End preparation of property arrays **/
/** Start query preparation **/
2013-03-17 08:00:17 +00:00
$SphQL = new SphinxqlQuery ();
$SphQLTor = new SphinxqlQuery ();
2011-03-28 14:21:28 +00:00
2012-11-01 08:00:21 +00:00
if ( $OrderBy == 'random' ) {
$SphQL -> select ( 'id, groupid, categoryid' )
-> order_by ( 'RAND()' , '' );
$Random = true ;
2013-04-15 08:00:54 +00:00
} elseif ( $GroupResults ) {
2012-11-01 08:00:21 +00:00
$OrderProperties = $SortOrders [ $OrderBy ];
$SphQL -> select ( 'groupid, categoryid' . ( isset ( $AggregateExp [ $OrderProperties [ 0 ]]) ? ', ' . $AggregateExp [ $OrderProperties [ 0 ]] : '' ))
-> group_by ( 'groupid' )
-> order_by ( $OrderProperties [ 0 ], $OrderWay )
-> order_group_by ( $OrderProperties [ 1 ], $OrderWay );
2011-03-28 14:21:28 +00:00
2012-11-01 08:00:21 +00:00
} else {
$SphQL -> select ( 'id, groupid, categoryid' )
-> order_by ( $SortOrders [ $OrderBy ], $OrderWay );
}
$SphQL -> from ( 'torrents, delta' );
$SphQLTor -> select ( 'id, groupid' ) -> from ( 'torrents, delta' );
/** End query preparation **/
/** Start building search query **/
$Filtered = false ;
2012-09-02 08:00:26 +00:00
$EnableNegation = false ; // Sphinx needs at least one positive search condition to support the NOT operator
2013-07-04 08:00:56 +00:00
// File list searches make use of the proximity operator to ensure that all keywords match the same file
2012-11-01 08:00:21 +00:00
if ( ! empty ( $_GET [ 'filelist' ])) {
2012-09-02 08:00:26 +00:00
$SearchString = trim ( $_GET [ 'filelist' ]);
2012-11-01 08:00:21 +00:00
if ( $SearchString != '' ) {
2013-03-17 08:00:17 +00:00
$SearchString = '"' . Sphinxql :: escape_string ( $_GET [ 'filelist' ]) . '"~20' ;
2012-11-01 08:00:21 +00:00
$SphQL -> where_match ( $SearchString , 'filelist' , false );
$SphQLTor -> where_match ( $SearchString , 'filelist' , false );
2012-09-02 08:00:26 +00:00
$EnableNegation = true ;
2012-11-01 08:00:21 +00:00
$Filtered = true ;
2011-03-28 14:21:28 +00:00
}
2012-09-02 08:00:26 +00:00
}
// Collect all entered search terms to find out whether to enable the NOT operator
2013-07-04 08:00:56 +00:00
$GroupFields = array ( 'artistname' , 'groupname' , 'recordlabel' , 'cataloguenumber' , 'taglist' );
2012-11-01 08:00:21 +00:00
$TorrentFields = array ( 'remastertitle' , 'remasteryear' , 'remasterrecordlabel' , 'remastercataloguenumber' , 'encoding' , 'format' , 'media' );
2012-10-16 08:00:18 +00:00
$SearchWords = array ();
2012-11-01 08:00:21 +00:00
foreach ( array ( 'artistname' , 'groupname' , 'recordlabel' , 'cataloguenumber' ,
'taglist' , 'remastertitle' , 'remasteryear' , 'remasterrecordlabel' ,
'remastercataloguenumber' , 'encoding' , 'format' , 'media' ) as $Search ) {
if ( ! empty ( $_GET [ $Search ])) {
2012-09-02 08:00:26 +00:00
$SearchString = trim ( $_GET [ $Search ]);
2012-11-01 08:00:21 +00:00
if ( $SearchString != '' ) {
2012-09-02 08:00:26 +00:00
$SearchWords [ $Search ] = array ( 'include' => array (), 'exclude' => array ());
2012-11-01 08:00:21 +00:00
if ( $Search == 'taglist' ) {
2012-09-02 08:00:26 +00:00
$SearchString = strtr ( $SearchString , '.' , '_' );
$Words = explode ( ',' , $SearchString );
} else {
$Words = explode ( ' ' , $SearchString );
}
2012-11-01 08:00:21 +00:00
foreach ( $Words as $Word ) {
2012-09-02 08:00:26 +00:00
$Word = trim ( $Word );
2012-12-07 08:00:19 +00:00
// Skip isolated hyphens to enable "Artist - Title" searches
if ( $Word == '-' ) {
continue ;
}
2012-11-01 08:00:21 +00:00
if ( $Word [ 0 ] == '!' && strlen ( $Word ) >= 2 ) {
2013-07-04 08:00:56 +00:00
if ( strpos ( $Word , '!' , 1 ) === false ) {
2012-09-02 08:00:26 +00:00
$SearchWords [ $Search ][ 'exclude' ][] = $Word ;
} else {
$SearchWords [ $Search ][ 'include' ][] = $Word ;
$EnableNegation = true ;
}
2012-11-01 08:00:21 +00:00
} elseif ( $Word != '' ) {
2012-09-02 08:00:26 +00:00
$SearchWords [ $Search ][ 'include' ][] = $Word ;
$EnableNegation = true ;
}
}
}
2011-03-28 14:21:28 +00:00
}
2012-09-02 08:00:26 +00:00
}
//Simple search
2012-11-01 08:00:21 +00:00
if ( ! empty ( $_GET [ 'searchstr' ])) {
2012-09-02 08:00:26 +00:00
$SearchString = trim ( $_GET [ 'searchstr' ]);
2013-06-11 08:01:24 +00:00
$Words = explode ( ' ' , strtolower ( $SearchString ));
2012-11-01 08:00:21 +00:00
if ( ! empty ( $Words )) {
2012-09-02 08:00:26 +00:00
$FilterBitrates = $FilterFormats = array ();
$BasicSearch = array ( 'include' => array (), 'exclude' => array ());
2012-11-01 08:00:21 +00:00
foreach ( $Words as $Word ) {
2012-09-02 08:00:26 +00:00
$Word = trim ( $Word );
2012-12-07 08:00:19 +00:00
// Skip isolated hyphens to enable "Artist - Title" searches
if ( $Word == '-' ) {
continue ;
}
2012-11-01 08:00:21 +00:00
if ( $Word [ 0 ] == '!' && strlen ( $Word ) >= 2 ) {
if ( $Word == '!100%' ) {
2012-09-02 08:00:26 +00:00
$_GET [ 'haslog' ] = '-1' ;
2013-06-11 08:01:24 +00:00
} elseif ( strpos ( $Word , '!' , 1 ) === false ) {
2012-09-02 08:00:26 +00:00
$BasicSearch [ 'exclude' ][] = $Word ;
2011-03-28 14:21:28 +00:00
} else {
2012-09-02 08:00:26 +00:00
$BasicSearch [ 'include' ][] = $Word ;
$EnableNegation = true ;
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
} elseif ( in_array ( $Word , $SearchBitrates )) {
2012-09-02 08:00:26 +00:00
$FilterBitrates [] = $Word ;
$EnableNegation = true ;
2012-11-01 08:00:21 +00:00
} elseif ( in_array ( $Word , $SearchFormats )) {
2012-09-02 08:00:26 +00:00
$FilterFormats [] = $Word ;
$EnableNegation = true ;
2012-11-01 08:00:21 +00:00
} elseif ( $Word == '100%' ) {
2012-09-02 08:00:26 +00:00
$_GET [ 'haslog' ] = '100' ;
2012-11-01 08:00:21 +00:00
} elseif ( $Word != '' ) {
2012-09-02 08:00:26 +00:00
$BasicSearch [ 'include' ][] = $Word ;
$EnableNegation = true ;
2011-03-28 14:21:28 +00:00
}
}
2012-11-01 08:00:21 +00:00
if ( ! $EnableNegation && ! empty ( $BasicSearch [ 'exclude' ])) {
2012-09-02 08:00:26 +00:00
$BasicSearch [ 'include' ] = array_merge ( $BasicSearch [ 'include' ], $BasicSearch [ 'exclude' ]);
unset ( $BasicSearch [ 'exclude' ]);
}
$QueryParts = array ();
2012-11-01 08:00:21 +00:00
foreach ( $BasicSearch [ 'include' ] as $Word ) {
2013-03-17 08:00:17 +00:00
$QueryParts [] = Sphinxql :: escape_string ( $Word );
2012-09-02 08:00:26 +00:00
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $BasicSearch [ 'exclude' ])) {
foreach ( $BasicSearch [ 'exclude' ] as $Word ) {
2013-06-11 08:01:24 +00:00
$QueryParts [] = '!' . Sphinxql :: escape_string ( substr ( $Word , 1 ));
2012-09-02 08:00:26 +00:00
}
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $FilterBitrates )) {
$SearchString = implode ( ' ' , $FilterBitrates );
$SphQL -> where_match ( $SearchString , 'encoding' , false );
$SphQLTor -> where_match ( $SearchString , 'encoding' , false );
$Filtered = true ;
2012-09-02 08:00:26 +00:00
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $FilterFormats )) {
$SearchString = implode ( ' ' , $FilterFormats );
$SphQL -> where_match ( $SearchString , 'format' , false );
$SphQLTor -> where_match ( $SearchString , 'format' , false );
$Filtered = true ;
2012-09-02 08:00:26 +00:00
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $QueryParts )) {
$SearchString = implode ( ' ' , $QueryParts );
$SphQL -> where_match ( $SearchString , '(groupname,artistname,yearfulltext)' , false );
$SphQLTor -> where_match ( $SearchString , '(groupname,artistname,yearfulltext)' , false );
$Filtered = true ;
2011-03-28 14:21:28 +00:00
}
}
}
2012-09-02 08:00:26 +00:00
// Tag list
2012-11-01 08:00:21 +00:00
if ( ! empty ( $SearchWords [ 'taglist' ])) {
2013-04-19 08:00:55 +00:00
global $Cache , $DB ;
//Get tag aliases.
$TagAliases = $Cache -> get_value ( 'tag_aliases_search' );
if ( ! $TagAliases ) {
2013-07-04 08:00:56 +00:00
$DB -> query ( '
2013-06-11 08:01:24 +00:00
SELECT ID , BadTag , AliasTag
FROM tag_aliases
2013-07-04 08:00:56 +00:00
ORDER BY BadTag ' );
2013-04-19 08:00:55 +00:00
$TagAliases = $DB -> to_array ();
//Unify tag aliases to be in_this_format as tags not in.this.format
array_walk_recursive ( $TagAliases , create_function ( '&$val' , '$val = preg_replace("/\./","_", $val);' ));
//Clean up the array for smaller cache size
foreach ( $TagAliases as & $TagAlias ) {
foreach ( array_keys ( $TagAlias ) as $Key ) {
if ( is_numeric ( $Key )) {
unset ( $TagAlias [ $Key ]);
}
}
}
$Cache -> cache_value ( 'tag_aliases_search' , $TagAliases , 3600 * 24 * 7 ); // cache for 7 days
}
//Get tags
2012-09-02 08:00:26 +00:00
$Tags = $SearchWords [ 'taglist' ];
2013-04-19 08:00:55 +00:00
//Replace bad tags with tag aliases
//In other news oh God I'm going to hell for all this preg_replace, but they're kept in two separate formats
for ( $i = 0 ; $i < sizeof ( $Tags [ 'include' ]) ; $i ++ ) {
foreach ( $TagAliases as $TagAlias ) {
if ( $Tags [ 'include' ][ $i ] === $TagAlias [ 'BadTag' ]) {
$Tags [ 'include' ][ $i ] = $TagAlias [ 'AliasTag' ];
break ;
}
}
}
for ( $i = 0 ; $i < sizeof ( $Tags [ 'exclude' ]) ; $i ++ ) {
foreach ( $TagAliases as $TagAlias ) {
if ( preg_replace ( '/^!/' , '' , $Tags [ 'exclude' ][ $i ]) === $TagAlias [ 'BadTag' ]) {
$Tags [ 'exclude' ][ $i ] = '!' . $TagAlias [ 'AliasTag' ];
break ;
}
}
}
//Only keep unique entries after unifying tag standard
$Tags [ 'include' ] = array_unique ( $Tags [ 'include' ]);
$Tags [ 'exclude' ] = array_unique ( $Tags [ 'exclude' ]);
2013-07-04 08:00:56 +00:00
$TagListString = implode ( ', ' , array_merge ( $Tags [ 'include' ], $Tags [ 'exclude' ]));
2012-11-01 08:00:21 +00:00
if ( ! $EnableNegation && ! empty ( $Tags [ 'exclude' ])) {
2012-09-02 08:00:26 +00:00
$Tags [ 'include' ] = array_merge ( $Tags [ 'include' ], $Tags [ 'exclude' ]);
unset ( $Tags [ 'exclude' ]);
}
2012-11-01 08:00:21 +00:00
foreach ( $Tags [ 'include' ] as & $Tag ) {
2013-03-17 08:00:17 +00:00
$Tag = Sphinxql :: escape_string ( $Tag );
2012-09-02 08:00:26 +00:00
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $Tags [ 'exclude' ])) {
foreach ( $Tags [ 'exclude' ] as & $Tag ) {
2013-03-17 08:00:17 +00:00
$Tag = '!' . Sphinxql :: escape_string ( substr ( $Tag , 1 ));
2011-03-28 14:21:28 +00:00
}
}
2012-09-02 08:00:26 +00:00
$QueryParts = array ();
// 'All' tags
2012-11-01 08:00:21 +00:00
if ( ! isset ( $_GET [ 'tags_type' ]) || $_GET [ 'tags_type' ] == 1 ) {
2012-09-02 08:00:26 +00:00
$_GET [ 'tags_type' ] = '1' ;
$Tags = array_merge ( $Tags [ 'include' ], $Tags [ 'exclude' ]);
2012-11-01 08:00:21 +00:00
if ( ! empty ( $Tags )) {
2012-09-02 08:00:26 +00:00
$QueryParts [] = implode ( ' ' , $Tags );
}
2011-03-28 14:21:28 +00:00
}
2012-09-02 08:00:26 +00:00
// 'Any' tags
else {
$_GET [ 'tags_type' ] = '0' ;
2012-11-01 08:00:21 +00:00
if ( ! empty ( $Tags [ 'include' ])) {
2012-09-02 08:00:26 +00:00
$QueryParts [] = '( ' . implode ( ' | ' , $Tags [ 'include' ]) . ' )' ;
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $Tags [ 'exclude' ])) {
2012-09-02 08:00:26 +00:00
$QueryParts [] = implode ( ' ' , $Tags [ 'exclude' ]);
}
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $QueryParts )) {
$SphQL -> where_match ( implode ( ' ' , $QueryParts ), 'taglist' , false );
$Filtered = true ;
2012-09-02 08:00:26 +00:00
}
unset ( $SearchWords [ 'taglist' ]);
}
2012-11-01 08:00:21 +00:00
elseif ( ! isset ( $_GET [ 'tags_type' ])) {
2011-03-28 14:21:28 +00:00
$_GET [ 'tags_type' ] = '1' ;
}
2012-11-01 08:00:21 +00:00
foreach ( $SearchWords as $Search => $Words ) {
2012-09-02 08:00:26 +00:00
$QueryParts = array ();
2012-11-01 08:00:21 +00:00
if ( ! $EnableNegation && ! empty ( $Words [ 'exclude' ])) {
2012-09-02 08:00:26 +00:00
$Words [ 'include' ] = array_merge ( $Words [ 'include' ], $Words [ 'exclude' ]);
unset ( $Words [ 'exclude' ]);
}
2012-11-01 08:00:21 +00:00
foreach ( $Words [ 'include' ] as $Word ) {
2013-03-17 08:00:17 +00:00
$QueryParts [] = Sphinxql :: escape_string ( $Word );
2012-09-02 08:00:26 +00:00
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $Words [ 'exclude' ])) {
foreach ( $Words [ 'exclude' ] as $Word ) {
2013-06-11 08:01:24 +00:00
$QueryParts [] = '!' . Sphinxql :: escape_string ( substr ( $Word , 1 ));
2011-03-28 14:21:28 +00:00
}
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $QueryParts )) {
$SearchString = implode ( ' ' , $QueryParts );
$SphQL -> where_match ( $SearchString , $Search , false );
$SphQLTor -> where_match ( $SearchString , $Search , false );
$Filtered = true ;
2012-09-02 08:00:26 +00:00
}
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $_GET [ 'year' ])) {
2011-03-28 14:21:28 +00:00
$Years = explode ( '-' , $_GET [ 'year' ]);
2012-11-01 08:00:21 +00:00
if ( is_number ( $Years [ 0 ]) || ( empty ( $Years [ 0 ]) && ! empty ( $Years [ 1 ]) && is_number ( $Years [ 1 ]))) {
2013-07-17 08:00:52 +00:00
if ( count ( $Years ) === 1 ) {
2012-11-01 08:00:21 +00:00
$SphQL -> where ( 'year' , ( int ) $Years [ 0 ]);
$SphQLTor -> where ( 'year' , ( int ) $Years [ 0 ]);
2011-03-28 14:21:28 +00:00
} else {
2012-11-01 08:00:21 +00:00
if ( empty ( $Years [ 1 ]) || ! is_number ( $Years [ 1 ])) {
2011-03-28 14:21:28 +00:00
$Years [ 1 ] = PHP_INT_MAX ;
2012-11-01 08:00:21 +00:00
} elseif ( $Years [ 0 ] > $Years [ 1 ]) {
2011-03-28 14:21:28 +00:00
$Years = array_reverse ( $Years );
}
2012-11-01 08:00:21 +00:00
$SphQL -> where_between ( 'year' , array (( int ) $Years [ 0 ], ( int ) $Years [ 1 ]));
$SphQLTor -> where_between ( 'year' , array (( int ) $Years [ 0 ], ( int ) $Years [ 1 ]));
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
$Filtered = true ;
2011-03-28 14:21:28 +00:00
}
}
2013-04-19 08:00:55 +00:00
if ( isset ( $_GET [ 'haslog' ]) && $_GET [ 'haslog' ] !== '' ) {
2013-07-17 08:00:52 +00:00
if ( $_GET [ 'haslog' ] === '100' ) {
2012-11-01 08:00:21 +00:00
$SphQL -> where ( 'logscore' , 100 );
$SphQLTor -> where ( 'logscore' , 100 );
$Filtered = true ;
2013-04-19 08:00:55 +00:00
} elseif ( $_GET [ 'haslog' ] < 0 ) {
2012-11-01 08:00:21 +00:00
// Exclude torrents with log score equal to 100
$SphQL -> where ( 'logscore' , 100 , true );
$SphQL -> where ( 'haslog' , 1 );
$SphQLTor -> where ( 'logscore' , 100 , true );
$SphQLTor -> where ( 'haslog' , 1 );
$Filtered = true ;
} elseif ( $_GET [ 'haslog' ] == 0 ) {
$SphQL -> where ( 'haslog' , 0 );
$SphQLTor -> where ( 'haslog' , 0 );
2011-03-28 14:21:28 +00:00
} else {
2012-11-01 08:00:21 +00:00
$SphQL -> where ( 'haslog' , 1 );
$SphQLTor -> where ( 'haslog' , 1 );
$Filtered = true ;
}
2011-03-28 14:21:28 +00:00
}
2013-06-11 08:01:24 +00:00
foreach ( array ( 'hascue' , 'scene' , 'vanityhouse' , 'releasetype' ) as $Search ) {
2012-11-01 08:00:21 +00:00
if ( isset ( $_GET [ $Search ]) && $_GET [ $Search ] !== '' ) {
$SphQL -> where ( $Search , $_GET [ $Search ]);
// Release type is group specific
if ( $Search != 'releasetype' ) {
$SphQLTor -> where ( $Search , $_GET [ $Search ]);
}
if ( $_GET [ $Search ] !== 0 ) {
2013-06-11 08:01:24 +00:00
//TODO: Clean up this hack
2012-11-01 08:00:21 +00:00
// Hack! Deleted torrents may show up if we set to true unconditionally. Hope no one notices
$Filtered = true ;
2011-05-13 08:00:07 +00:00
}
2011-03-28 14:21:28 +00:00
}
}
2012-12-26 08:00:54 +00:00
if ( ! empty ( $_GET [ 'freetorrent' ]) || $_GET [ 'freetorrent' ] === '0' ) {
2012-11-01 08:00:21 +00:00
switch ( $_GET [ 'freetorrent' ]) {
case 0 : // Only normal freeleech
$SphQL -> where ( 'freetorrent' , 0 );
$SphQLTor -> where ( 'freetorrent' , 0 );
$Filtered = true ;
break ;
case 1 : // Only free leech
$SphQL -> where ( 'freetorrent' , 1 );
$SphQLTor -> where ( 'freetorrent' , 1 );
$Filtered = true ;
break ;
case 2 : // Only neutral leech
$SphQL -> where ( 'freetorrent' , 2 );
$SphQLTor -> where ( 'freetorrent' , 2 );
$Filtered = true ;
break ;
case 3 : // Free or neutral leech
$SphQL -> where ( 'freetorrent' , 0 , true );
$SphQLTor -> where ( 'freetorrent' , 0 , true );
$Filtered = true ;
break ;
2011-03-28 14:21:28 +00:00
}
}
2012-11-01 08:00:21 +00:00
if ( ! empty ( $_GET [ 'filter_cat' ])) {
$SphQL -> where ( 'categoryid' , array_keys ( $_GET [ 'filter_cat' ]));
$Filtered = true ;
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
if ( ! $Filtered ) {
$SphQL -> where ( 'size' , 0 , true );
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
/** End building search query **/
2011-03-28 14:21:28 +00:00
2012-11-01 08:00:21 +00:00
/** Run search query and collect results **/
if ( isset ( $Random ) && $GroupResults ) {
// ORDER BY RAND() can't be used together with GROUP BY, so we need some special tactics
$Page = 1 ;
2013-07-04 08:00:56 +00:00
$SphQL -> limit ( 0 , 5 * TORRENTS_PER_PAGE , 5 * TORRENTS_PER_PAGE );
2012-11-01 08:00:21 +00:00
$SphQLResult = $SphQL -> query ();
$TotalCount = $SphQLResult -> get_meta ( 'total_found' );
$Results = $SphQLResult -> to_array ( 'groupid' );
$GroupIDs = array_keys ( $Results );
$Debug -> log_var ( $SphQLResult -> get_meta (), 'Result meta info' );
$GroupCount = count ( $GroupIDs );
while ( $SphQLResult -> get_meta ( 'total' ) < $TotalCount && $GroupCount < TORRENTS_PER_PAGE ) {
// Make sure we get TORRENTS_PER_PAGE results, or all of them if there are less than TORRENTS_PER_PAGE hits
$SphQL -> where ( 'groupid' , $GroupIDs , true );
$SphQLResult = $SphQL -> query ();
if ( ! $SphQLResult -> get_meta ( 'total' )) {
break ;
}
$Results += $SphQLResult -> to_array ( 'groupid' );
$GroupIDs = array_keys ( $Results );
$GroupCount = count ( $GroupIDs );
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
if ( $GroupCount > TORRENTS_PER_PAGE ) {
$Results = array_slice ( $Results , 0 , TORRENTS_PER_PAGE , true );
}
$GroupIDs = array_keys ( $Results );
$TorrentCount = count ( $Results );
2012-08-08 08:00:12 +00:00
} else {
2012-11-01 08:00:21 +00:00
if ( ! empty ( $_GET [ 'page' ]) && is_number ( $_GET [ 'page' ]) && $_GET [ 'page' ] > 0 ) {
if ( check_perms ( 'site_search_many' )) {
$Page = $_GET [ 'page' ];
} else {
2013-07-04 08:00:56 +00:00
$Page = min ( SPHINX_MAX_MATCHES / TORRENTS_PER_PAGE , $_GET [ 'page' ]);
2011-03-28 14:21:28 +00:00
}
2012-11-01 08:00:21 +00:00
$Offset = ( $Page - 1 ) * TORRENTS_PER_PAGE ;
$SphQL -> limit ( $Offset , TORRENTS_PER_PAGE , $Offset + TORRENTS_PER_PAGE );
} else {
$Page = 1 ;
$SphQL -> limit ( 0 , TORRENTS_PER_PAGE , TORRENTS_PER_PAGE );
}
$SphQLResult = $SphQL -> query ();
$TorrentCount = $SphQLResult -> get_meta ( 'total_found' );
if ( $GroupResults ) {
$Results = $SphQLResult -> to_array ( 'groupid' );
$GroupIDs = array_keys ( $Results );
} else {
$Results = $SphQLResult -> to_array ( 'id' );
$GroupIDs = $SphQLResult -> collect ( 'groupid' );
2011-03-28 14:21:28 +00:00
}
}
2012-11-01 08:00:21 +00:00
if ( ! check_perms ( 'site_search_many' ) && $TorrentCount > SPHINX_MAX_MATCHES ) {
$TorrentCount = SPHINX_MAX_MATCHES ;
}
if ( $TorrentCount ) {
$Groups = Torrents :: get_groups ( $GroupIDs );
$Groups = $Groups [ 'matches' ];
if ( ! empty ( $Groups ) && $GroupResults ) {
$TorrentIDs = array ();
foreach ( $Groups as $Group ) {
if ( ! empty ( $Group [ 'Torrents' ])) {
$TorrentIDs = array_merge ( $TorrentIDs , array_keys ( $Group [ 'Torrents' ]));
}
2011-03-28 14:21:28 +00:00
}
2013-02-19 08:00:30 +00:00
if ( ! empty ( $TorrentIDs )) {
// Get a list of all torrent ids that match the search query
$SphQLTor -> where ( 'id' , $TorrentIDs ) -> limit ( 0 , count ( $TorrentIDs ), count ( $TorrentIDs ));
$SphQLResultTor = $SphQLTor -> query ();
$TorrentIDs = array_fill_keys ( $SphQLResultTor -> collect ( 'id' ), true );
}
2011-03-28 14:21:28 +00:00
}
}
2012-11-01 08:00:21 +00:00
/** End run search query and collect results **/
2011-03-28 14:21:28 +00:00
2013-02-24 08:00:18 +00:00
$HideFilter = isset ( $LoggedUser [ 'ShowTorFilter' ]) && $LoggedUser [ 'ShowTorFilter' ] == 0 ;
2013-02-23 08:00:22 +00:00
// This is kinda ugly, but the enormous if paragraph was really hard to read
2013-04-17 08:00:58 +00:00
$AdvancedSearch = ! empty ( $_GET [ 'action' ]) && $_GET [ 'action' ] == 'advanced' ;
$AdvancedSearch |= ! empty ( $LoggedUser [ 'SearchType' ]) && ( empty ( $_GET [ 'action' ]) || $_GET [ 'action' ] == 'advanced' );
2013-02-23 08:00:22 +00:00
$AdvancedSearch &= check_perms ( 'site_advanced_search' );
if ( $AdvancedSearch ) {
2011-03-28 14:21:28 +00:00
$Action = 'action=advanced' ;
2013-02-23 08:00:22 +00:00
$HideBasic = ' hidden' ;
$HideAdvanced = '' ;
} else {
$Action = 'action=basic' ;
$HideBasic = '' ;
$HideAdvanced = ' hidden' ;
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
View :: show_header ( 'Browse Torrents' , 'browse' );
2011-03-28 14:21:28 +00:00
?>
2012-12-19 08:00:21 +00:00
< div class = " thin widethin " >
2013-02-23 08:00:22 +00:00
< div class = " header " >
< h2 > Torrents </ h2 >
</ div >
2012-09-15 08:00:25 +00:00
< form class = " search_form " name = " torrents " method = " get " action = " " >
2013-02-24 08:00:18 +00:00
< div class = " box filter_torrents " >
2013-02-23 08:00:22 +00:00
< 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; " >
2013-02-24 08:00:18 +00:00
< a href = " # " onclick = " return toggleTorrentSearch(0); " id = " ft_toggle " class = " brackets " >< ? = $HideFilter ? 'Show' : 'Hide' ?> </a>
2013-02-23 08:00:22 +00:00
</ span >
</ div >
2013-02-24 08:00:18 +00:00
< div id = " ft_container " class = " pad<?= $HideFilter ? ' hidden' : ''?> " >
2012-09-05 08:00:24 +00:00
< table class = " layout " >
2013-02-23 08:00:22 +00:00
< tr id = " artist_name " class = " ftr_advanced<?= $HideAdvanced ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Artist name :</ td >
< td colspan = " 3 " class = " ft_artistname " >
2013-02-23 08:00:22 +00:00
< input type = " text " spellcheck = " false " size = " 40 " name = " artistname " class = " inputtext smaller fti_advanced " value = " <?Format::form('artistname')?> " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2013-02-23 08:00:22 +00:00
< tr id = " album_torrent_name " class = " ftr_advanced<?= $HideAdvanced ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Album / Torrent name :</ td >
< td colspan = " 3 " class = " ft_groupname " >
2013-02-23 08:00:22 +00:00
< input type = " text " spellcheck = " false " size = " 40 " name = " groupname " class = " inputtext smaller fti_advanced " value = " <?Format::form('groupname')?> " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2013-02-23 08:00:22 +00:00
< tr id = " record_label " class = " ftr_advanced<?= $HideAdvanced ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Record label :</ td >
< td colspan = " 3 " class = " ft_recordlabel " >
2013-02-23 08:00:22 +00:00
< input type = " text " spellcheck = " false " size = " 40 " name = " recordlabel " class = " inputtext smaller fti_advanced " value = " <?Format::form('recordlabel')?> " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2013-02-23 08:00:22 +00:00
< tr id = " catalogue_number_year " class = " ftr_advanced<?= $HideAdvanced ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Catalogue number :</ td >
< td class = " ft_cataloguenumber " >
2013-04-17 08:00:58 +00:00
< input type = " text " size = " 40 " name = " cataloguenumber " class = " inputtext smallest fti_advanced " value = " <?Format::form('cataloguenumber')?> " />
2011-03-28 14:21:28 +00:00
</ td >
< td class = " label " > Year :</ td >
2012-11-06 08:00:20 +00:00
< td class = " ft_year " >
2013-02-23 08:00:22 +00:00
< input type = " text " name = " year " class = " inputtext smallest fti_advanced " value = " <?Format::form('year')?> " size = " 4 " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2013-02-23 08:00:22 +00:00
< tr id = " edition_expand " class = " ftr_advanced<?= $HideAdvanced ?> " >
2013-07-04 08:00:56 +00:00
< 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 >
2011-03-28 14:21:28 +00:00
</ tr >
< ?
2013-07-04 08:00:56 +00:00
if ( Format :: form ( 'remastertitle' , true ) == '' && Format :: form ( 'remasteryear' , true ) == '' &&
Format :: form ( 'remasterrecordlabel' , true ) == '' && Format :: form ( 'remastercataloguenumber' , true ) == '' ) {
2013-02-23 08:00:22 +00:00
$Hidden = ' hidden' ;
2011-03-28 14:21:28 +00:00
} else {
$Hidden = '' ;
}
?>
2013-02-23 08:00:22 +00:00
< tr id = " edition_title " class = " ftr_advanced<?= $HideAdvanced . $Hidden ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Edition title :</ td >
< td class = " ft_remastertitle " >
2013-02-23 08:00:22 +00:00
< input type = " text " spellcheck = " false " size = " 40 " name = " remastertitle " class = " inputtext smaller fti_advanced " value = " <?Format::form('remastertitle')?> " />
2011-03-28 14:21:28 +00:00
</ td >
2012-11-06 08:00:20 +00:00
< td class = " label " > Edition year :</ td >
< td class = " ft_remasteryear " >
2013-02-23 08:00:22 +00:00
< input type = " text " name = " remasteryear " class = " inputtext smallest fti_advanced " value = " <?Format::form('remasteryear')?> " size = " 4 " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2013-02-23 08:00:22 +00:00
< tr id = " edition_label " class = " ftr_advanced<?= $HideAdvanced . $Hidden ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Edition release label :</ td >
< td colspan = " 3 " class = " ft_remasterrecordlabel " >
2013-02-23 08:00:22 +00:00
< input type = " text " 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-02-23 08:00:22 +00:00
< tr id = " edition_catalogue " class = " ftr_advanced<?= $HideAdvanced . $Hidden ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Edition catalogue number :</ td >
< td colspan = " 3 " class = " ft_remastercataloguenumber " >
2013-02-23 08:00:22 +00:00
< input type = " text " size = " 40 " name = " remastercataloguenumber " class = " inputtext smallest fti_advanced " value = " <?Format::form('remastercataloguenumber')?> " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2013-02-23 08:00:22 +00:00
< tr id = " file_list " class = " ftr_advanced<?= $HideAdvanced ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > File list :</ td >
< td colspan = " 3 " class = " ft_filelist " >
2013-02-23 08:00:22 +00:00
< input type = " text " spellcheck = " false " size = " 40 " name = " filelist " class = " inputtext fti_advanced " value = " <?Format::form('filelist')?> " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2013-02-23 08:00:22 +00:00
< tr id = " rip_specifics " class = " ftr_advanced<?= $HideAdvanced ?> " >
2012-11-06 08:00:20 +00:00
< td class = " label " > Rip specifics :</ td >
2012-12-27 08:00:27 +00:00
< td class = " nobr ft_ripspecifics " colspan = " 3 " >
2013-02-23 08:00:22 +00:00
< select id = " bitrate " name = " encoding " class = " ft_bitrate fti_advanced " >
2011-03-28 14:21:28 +00:00
< option value = " " > Bitrate </ option >
2012-11-01 08:00:21 +00:00
< ? foreach ( $Bitrates as $BitrateName ) { ?>
2013-04-17 08:00:58 +00:00
< option value = " <?=display_str( $BitrateName ); ?> " < ? Format :: selected ( 'encoding' , $BitrateName ) ?> ><?=display_str($BitrateName); ?></option>
2011-03-28 14:21:28 +00:00
< ? } ?> </select>
2012-11-01 08:00:21 +00:00
2013-02-23 08:00:22 +00:00
< select name = " format " class = " ft_format fti_advanced " >
2011-03-28 14:21:28 +00:00
< option value = " " > Format </ option >
2012-11-01 08:00:21 +00:00
< ? foreach ( $Formats as $FormatName ) { ?>
2013-04-17 08:00:58 +00:00
< option value = " <?=display_str( $FormatName ); ?> " < ? Format :: selected ( 'format' , $FormatName ) ?> ><?=display_str($FormatName); ?></option>
2011-03-28 14:21:28 +00:00
< ? } ?> </select>
2013-02-23 08:00:22 +00:00
< select name = " media " class = " ft_media fti_advanced " >
2011-03-28 14:21:28 +00:00
< option value = " " > Media </ option >
2012-11-01 08:00:21 +00:00
< ? foreach ( $Media as $MediaName ) { ?>
2013-07-04 08:00:56 +00:00
< option value = " <?=display_str( $MediaName ); ?> " < ? Format :: selected ( 'media' , $MediaName ) ?> ><?=display_str($MediaName); ?></option>
2011-03-28 14:21:28 +00:00
< ? } ?>
</ select >
2013-02-23 08:00:22 +00:00
< select name = " releasetype " class = " ft_releasetype fti_advanced " >
2011-03-28 14:21:28 +00:00
< option value = " " > Release type </ option >
2012-11-01 08:00:21 +00:00
< ? foreach ( $ReleaseTypes as $ID => $Type ) { ?>
2013-07-04 08:00:56 +00:00
< 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-02-23 08:00:22 +00:00
< tr id = " misc " class = " ftr_advanced<?= $HideAdvanced ?> " >
2011-03-28 14:21:28 +00:00
< td class = " label " > Misc :</ td >
2012-12-27 08:00:27 +00:00
< td class = " nobr ft_misc " colspan = " 3 " >
2013-02-23 08:00:22 +00:00
< select name = " haslog " class = " ft_haslog fti_advanced " >
2011-03-28 14:21:28 +00:00
< option value = " " > Has Log </ option >
2013-07-04 08:00:56 +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' ) ?> ><100%/Unscored</option>
2011-03-28 14:21:28 +00:00
</ select >
2013-02-23 08:00:22 +00:00
< select name = " hascue " class = " ft_hascue fti_advanced " >
2011-03-28 14:21:28 +00:00
< option value = " " > Has Cue </ option >
2013-07-04 08:00:56 +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-02-23 08:00:22 +00:00
< select name = " scene " class = " ft_scene fti_advanced " >
2011-03-28 14:21:28 +00:00
< option value = " " > Scene </ option >
2013-07-04 08:00:56 +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-02-23 08:00:22 +00:00
< select name = " vanityhouse " class = " ft_vanityhouse fti_advanced " >
2011-08-09 21:03:28 +00:00
< option value = " " > Vanity House </ option >
2013-07-04 08:00:56 +00:00
< option value = " 1 " < ? Format :: selected ( 'vanityhouse' , 1 ) ?> >Yes</option>
< option value = " 0 " < ? Format :: selected ( 'vanityhouse' , 0 ) ?> >No</option>
2011-08-09 21:03:28 +00:00
</ select >
2013-02-23 08:00:22 +00:00
< select name = " freetorrent " class = " ft_freetorrent fti_advanced " >
2011-05-13 08:00:07 +00:00
< option value = " " > Leech Status </ option >
2013-07-04 08:00:56 +00:00
< 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-02-23 08:00:22 +00:00
< tr id = " search_terms " class = " ftr_basic<?= $HideBasic ?> " >
2011-03-28 14:21:28 +00:00
< td class = " label " > Search terms :</ td >
2012-11-02 08:00:18 +00:00
< td colspan = " 3 " class = " ftb_searchstr " >
2013-02-23 08:00:22 +00:00
< input type = " text " spellcheck = " false " size = " 40 " name = " searchstr " class = " inputtext fti_basic " value = " <?Format::form('searchstr')?> " />
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
2012-11-06 08:00:20 +00:00
< tr id = " tagfilter " >
2011-03-28 14:21:28 +00:00
< td class = " label " > Tags ( comma - separated ) :</ td >
2012-11-02 08:00:18 +00:00
< td colspan = " 3 " class = " ft_taglist " >
2013-07-04 08:00:56 +00:00
< input type = " text " size = " 40 " id = " tags " name = " taglist " class = " inputtext smaller " title = " Use !tag to exclude tag " value = " <?=str_replace('_', '.', display_str( $TagListString )) /* Use aliased tags, not actual query string. */ ?> " />& nbsp ;
< input type = " radio " name = " tags_type " id = " tags_type0 " value = " 0 " < ? Format :: selected ( 'tags_type' , 0 , 'checked' ) ?> /><label for="tags_type0"> Any</label>
< 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 >
2012-11-06 08:00:20 +00:00
< tr id = " order " >
2011-03-28 14:21:28 +00:00
< td class = " label " > Order by :</ td >
2013-04-17 08:00:58 +00:00
< td colspan = " 3 " class = " ft_order " >
2013-05-25 08:01:03 +00:00
< select name = " order_by " style = " width: auto; " class = " ft_order_by " >
2013-07-04 08:00:56 +00:00
< 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 >
2012-11-02 08:00:18 +00:00
< select name = " order_way " class = " ft_order_way " >
2013-07-04 08:00:56 +00:00
< option value = " desc " < ? Format :: selected ( 'order_way' , 'desc' ) ?> >Descending</option>
< option value = " asc " < ? Format :: selected ( 'order_way' , 'asc' ) ?> >Ascending</option>
2011-03-28 14:21:28 +00:00
</ select >
</ td >
</ tr >
2012-11-18 08:00:19 +00:00
< tr id = " search_group_results " >
2012-11-02 08:00:18 +00:00
< td class = " label " >
< label for = " group_results " > Group by release :</ label >
</ td >
2013-02-23 08:00:22 +00:00
< td colspan = " 3 " class = " ft_group_results " >
2013-05-21 08:01:09 +00:00
< input type = " checkbox " value = " 1 " name = " group_results " id = " group_results " < ? Format :: selected ( 'group_results' , 1 , 'checked' ) ?> />
2012-11-02 08:00:18 +00:00
</ td >
2012-11-01 08:00:21 +00:00
</ tr >
2011-03-28 14:21:28 +00:00
</ table >
2012-11-02 08:00:18 +00:00
< table class = " layout cat_list ft_cat_list " >
2011-03-28 14:21:28 +00:00
< ?
2013-04-17 08:00:58 +00:00
$x = 0 ;
2011-03-28 14:21:28 +00:00
reset ( $Categories );
2012-11-01 08:00:21 +00:00
foreach ( $Categories as $CatKey => $CatName ) {
2013-04-17 08:00:58 +00:00
if ( $x % 7 == 0 ) {
2012-11-01 08:00:21 +00:00
if ( $x > 0 ) {
2011-03-28 14:21:28 +00:00
?>
</ tr >
< ? } ?>
< tr >
< ?
}
$x ++ ;
?>
< td >
2013-05-21 08:01:09 +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 >
< ?
}
?>
</ tr >
</ table >
2012-12-27 08:00:27 +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' );
2012-11-01 08:00:21 +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 ;
2012-11-01 08:00:21 +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
if ( $x % 7 != 0 ) { // Padding
2011-03-28 14:21:28 +00:00
?>
2013-05-21 08:01:09 +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 >
< td class = " label " >
2013-07-04 08:00:56 +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>
2011-03-28 14:21:28 +00:00
</ td >
</ tr >
</ table >
2012-11-02 08:00:18 +00:00
< div class = " submit ft_submit " >
2013-04-17 08:00:58 +00:00
< span style = " float: left; " >< ? = number_format ( $TorrentCount ) ?> Results</span>
< input type = " submit " value = " Filter torrents " />
2013-05-21 08:01:09 +00:00
< input type = " hidden " name = " action " id = " ft_type " value = " <?=( $AdvancedSearch ? 'advanced' : 'basic')?> " />
2012-11-01 08:00:21 +00:00
< input type = " hidden " name = " searchsubmit " value = " 1 " />
2013-07-17 08:00:52 +00:00
< 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 ( $Filtered ) { ?>
< input type = " submit " name = " setdefault " value = " Make default " />
2011-03-28 14:21:28 +00:00
< ?
2013-04-17 08:00:58 +00:00
}
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +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 >
2012-11-01 08:00:21 +00:00
< ?
if ( $TorrentCount == 0 ) {
2013-07-04 08:00:56 +00:00
$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 " );
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?taglist=<?=$Tag?>"><?=$Tag?></a><? } ?></p>
2011-03-28 14:21:28 +00:00
</ div >
2012-12-12 08:00:17 +00:00
</ div >
2011-03-28 14:21:28 +00:00
< ?
2012-10-11 08:00:15 +00:00
View :: show_footer (); die ();
2011-03-28 14:21:28 +00:00
}
2013-04-17 08:00:58 +00:00
if ( $TorrentCount < ( $Page - 1 ) * TORRENTS_PER_PAGE + 1 ) {
$LastPage = ceil ( $TorrentCount / TORRENTS_PER_PAGE );
2012-10-11 08:00:15 +00:00
$Pages = Format :: get_pages ( 0 , $TorrentCount , TORRENTS_PER_PAGE );
2012-08-08 08:00:12 +00:00
?>
< div class = " box pad " align = " center " >
< h2 > The requested page contains no matches .</ h2 >
2013-04-17 08:00:58 +00:00
< p > You are requesting page < ? = $Page ?> , but the search returned only <?=number_format($LastPage) ?> pages.</p>
2012-08-08 08:00:12 +00:00
</ div >
< div class = " linkbox " > Go to page < ? = $Pages ?> </div>
2012-12-12 08:00:17 +00:00
</ div >
2012-08-08 08:00:12 +00:00
< ?
2012-10-11 08:00:15 +00:00
View :: show_footer (); die ();
2012-08-08 08:00:12 +00:00
}
// List of pages
2012-10-11 08:00:15 +00:00
$Pages = Format :: get_pages ( $Page , $TorrentCount , TORRENTS_PER_PAGE );
2011-03-28 14:21:28 +00:00
2013-03-29 08:00:08 +00:00
$Bookmarks = Bookmarks :: all_bookmarks ( 'torrent' );
2011-03-28 14:21:28 +00:00
?>
2012-08-08 08:00:12 +00:00
< div class = " linkbox " >< ? = $Pages ?> </div>
2011-03-28 14:21:28 +00:00
2012-11-01 08:00:21 +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 " >
2012-11-01 08:00:21 +00:00
< ? if ( $GroupResults ) { ?>
2011-03-28 14:21:28 +00:00
< td class = " small " ></ td >
2012-11-01 08:00:21 +00:00
< ? } ?>
2011-03-28 14:21:28 +00:00
< td class = " small cats_col " ></ td >
2011-04-13 15:36:33 +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 >
< td >< a href = " <?=header_link('time')?> " > Time </ a ></ td >
< td >< a href = " <?=header_link('size')?> " > Size </ a ></ td >
< td class = " sign " >< a href = " <?=header_link('snatched')?> " >< img src = " static/styles/<?= $LoggedUser['StyleName'] ?>/images/snatched.png " alt = " Snatches " title = " Snatches " /></ a ></ td >
< td class = " sign " >< a href = " <?=header_link('seeders')?> " >< img src = " static/styles/<?= $LoggedUser['StyleName'] ?>/images/seeders.png " alt = " Seeders " title = " Seeders " /></ a ></ td >
< td class = " sign " >< a href = " <?=header_link('leechers')?> " >< img src = " static/styles/<?= $LoggedUser['StyleName'] ?>/images/leechers.png " alt = " Leechers " title = " Leechers " /></ a ></ td >
</ tr >
< ?
2012-11-01 08:00:21 +00:00
2011-03-28 14:21:28 +00:00
// Start printing torrent list
2012-11-01 08:00:21 +00:00
foreach ( $Results as $Result ) {
$GroupID = $Result [ 'groupid' ];
$GroupInfo = $Groups [ $GroupID ];
if ( empty ( $GroupInfo [ 'Torrents' ])) {
continue ;
}
$CategoryID = $Result [ '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 ) {
2012-12-07 08:00:19 +00:00
if ( isset ( $TorrentIDs [ $T [ 'ID' ]])) {
$GroupTime = max ( $GroupTime , strtotime ( $T [ 'Time' ]));
$MaxSize = max ( $MaxSize , $T [ 'Size' ]);
$TotalLeechers += $T [ 'Leechers' ];
$TotalSeeders += $T [ 'Seeders' ];
$TotalSnatched += $T [ 'Snatched' ];
2012-11-01 08:00:21 +00:00
}
}
} else {
$Torrents = array ( $Result [ 'id' ] => $GroupInfo [ 'Torrents' ][ $Result [ 'id' ]]);
}
2011-03-28 14:21:28 +00:00
2013-02-25 21:16:55 +00:00
$TorrentTags = new Tags ( $GroupInfo [ 'TagList' ]);
2012-11-01 08:00:21 +00:00
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 = '' ;
}
2012-12-06 08:00:17 +00:00
$SnatchedGroupClass = $GroupInfo [ 'Flags' ][ 'IsSnatched' ] ? ' snatched_group' : '' ;
2013-04-19 08:00:55 +00:00
if ( $GroupResults && ( count ( $Torrents ) > 1 || isset ( $GroupedCategories [ $CategoryID - 1 ]))) {
2011-03-28 14:21:28 +00:00
// These torrents are in a group
2013-07-04 08:00:56 +00:00
$DisplayName .= " <a href= \" torrents.php?id= $GroupID\ " title = \ " View Torrent \" dir= \" ltr \" > $GroupName </a> " ;
2012-11-01 08:00:21 +00:00
if ( $GroupYear > 0 ) {
2013-04-17 08:00:58 +00:00
$DisplayName .= " [ $GroupYear ] " ;
2012-11-01 08:00:21 +00:00
}
if ( $GroupVanityHouse ) {
2013-04-19 08:00:55 +00:00
$DisplayName .= ' [<abbr title="This is a Vanity House release">VH</abbr>]' ;
2011-03-28 14:21:28 +00:00
}
2012-02-07 08:00:20 +00:00
$DisplayName .= ' [' . $ReleaseTypes [ $ReleaseType ] . ']' ;
2011-03-28 14:21:28 +00:00
?>
2012-12-06 08:00:17 +00:00
< tr class = " group<?= $SnatchedGroupClass ?> " >
2011-03-28 14:21:28 +00:00
< ?
2011-07-04 08:00:07 +00:00
$ShowGroups = ! ( ! empty ( $LoggedUser [ 'TorrentGrouping' ]) && $LoggedUser [ 'TorrentGrouping' ] == 1 );
2011-03-28 14:21:28 +00:00
?>
2011-09-04 08:00:07 +00:00
< td class = " center " >
2011-03-28 14:21:28 +00:00
< div title = " View " id = " showimg_<?= $GroupID ?> " class = " <?=( $ShowGroups ? 'hide' : 'show')?>_torrents " >
2012-10-05 08:00:20 +00:00
< a href = " # " class = " show_torrents_link " onclick = " toggle_group(<?= $GroupID ?>, this, event) " title = " Collapse this group. Hold "Ctrl" while clicking to collapse all groups on this page. " ></ a >
2011-03-28 14:21:28 +00:00
</ div >
</ td >
< td class = " center cats_col " >
2013-02-25 21:16:55 +00:00
< div title = " <?= $TorrentTags->title ()?> " class = " <?=Format::css_category( $CategoryID )?> <?= $TorrentTags->css_name ()?> " >
2011-03-28 14:21:28 +00:00
</ div >
</ td >
2013-02-25 21:16:55 +00:00
< td colspan = " 2 " class = " big_info " >
2013-04-17 08:00:58 +00:00
< ? if ( $LoggedUser [ 'CoverArt' ]) : ?>
2013-02-25 21:16:55 +00:00
< div class = " group_image float_left clear " >
2013-04-30 18:18:07 +00:00
< ? ImageTools :: cover_thumb ( $GroupInfo [ 'WikiImage' ], $GroupInfo [ 'CategoryID' ]) ?>
2013-02-25 21:16:55 +00:00
</ div >
2013-04-17 08:00:58 +00:00
< ? endif ; ?>
2013-02-25 21:16:55 +00:00
< div class = " group_info clear " >
< ? = $DisplayName ?>
2012-11-01 08:00:21 +00:00
< ? if ( in_array ( $GroupID , $Bookmarks )) { ?>
2013-02-25 21:16:55 +00:00
< span class = " remove_bookmark float_right " >< a href = " # " id = " bookmarklink_torrent_<?= $GroupID ?> " class = " brackets " title = " Remove bookmark " onclick = " Unbookmark('torrent',<?= $GroupID ?>,'Bookmark');return false; " > Unbookmark </ a ></ span >
2011-03-28 14:21:28 +00:00
< ? } else { ?>
2013-02-25 21:16:55 +00:00
< span class = " add_bookmark float_right " >< a href = " # " id = " bookmarklink_torrent_<?= $GroupID ?> " class = " brackets " title = " Add bookmark " onclick = " Bookmark('torrent',<?= $GroupID ?>,'Unbookmark');return false; " > Bookmark </ a ></ span >
2011-03-28 14:21:28 +00:00
< ? } ?>
2013-02-25 21:16:55 +00:00
< br />
< div class = " tags " >< ? = $TorrentTags -> format ( 'torrents.php?' . $Action . '&taglist=' ) ?> </div>
2011-03-28 14:21:28 +00:00
</ div >
</ td >
< td class = " nobr " >< ? = time_diff ( $GroupTime , 1 ) ?> </td>
2012-11-01 08:00:21 +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-05-16 16:15:57 +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 >
2012-11-01 08:00:21 +00:00
< ?
2011-03-28 14:21:28 +00:00
$LastRemasterYear = '-' ;
$LastRemasterTitle = '' ;
$LastRemasterRecordLabel = '' ;
$LastRemasterCatalogueNumber = '' ;
2011-09-04 08:00:07 +00:00
$LastMedia = '' ;
2012-11-01 08:00:21 +00:00
2011-09-04 08:00:07 +00:00
$EditionID = 0 ;
2012-10-16 08:00:18 +00:00
$FirstUnknown = null ;
2011-03-28 14:21:28 +00:00
2012-11-01 08:00:21 +00:00
foreach ( $Torrents as $TorrentID => $Data ) {
2011-03-28 14:21:28 +00:00
// All of the individual torrents in the group
2012-11-01 08:00:21 +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
2012-11-01 08:00:21 +00:00
if ( ! isset ( $TorrentIDs [ $TorrentID ])) {
2011-03-28 14:21:28 +00:00
continue ;
}
2013-04-19 08:00:55 +00:00
2013-04-17 08:00:58 +00:00
//Get report info for each torrent, use the cache if available, if not, add to it.
$Reported = false ;
2013-08-12 08:00:44 +00:00
$Reports = Torrents :: get_reports ( $TorrentID );
2013-04-17 08:00:58 +00:00
if ( count ( $Reports ) > 0 ) {
$Reported = true ;
}
2011-03-28 14:21:28 +00:00
2011-09-05 08:00:07 +00:00
if ( $Data [ 'Remastered' ] && ! $Data [ 'RemasterYear' ]) {
$FirstUnknown = ! isset ( $FirstUnknown );
}
2012-12-06 08:00:17 +00:00
$SnatchedTorrentClass = $Data [ 'IsSnatched' ] ? ' snatched_torrent' : '' ;
2013-02-16 08:00:57 +00:00
2013-04-17 08:00:58 +00:00
if ( isset ( $GroupedCategories [ $CategoryID - 1 ])
2012-11-01 08:00:21 +00:00
&& ( $Data [ 'RemasterTitle' ] != $LastRemasterTitle
|| $Data [ 'RemasterYear' ] != $LastRemasterYear
|| $Data [ 'RemasterRecordLabel' ] != $LastRemasterRecordLabel
|| $Data [ 'RemasterCatalogueNumber' ] != $LastRemasterCatalogueNumber )
|| $FirstUnknown
|| $Data [ 'Media' ] != $LastMedia ) {
2011-09-05 08:00:07 +00:00
$EditionID ++ ;
2011-03-28 14:21:28 +00:00
?>
2012-12-06 08:00:17 +00:00
< tr class = " group_torrent groupid_<?= $GroupID ?> edition<?= $SnatchedGroupClass . (!empty( $LoggedUser['TorrentGrouping'] ) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?> " >
2013-03-17 08:00:17 +00:00
< td colspan = " 9 " class = " edition_info " >< strong >< a href = " # " onclick = " toggle_edition(<?= $GroupID ?>, <?= $EditionID ?>, this, event) " title = " Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group. " >& minus ; </ a > < ? = Torrents :: edition_string ( $Data , $GroupInfo ) ?> </strong></td>
2011-03-28 14:21:28 +00:00
</ tr >
< ?
}
$LastRemasterTitle = $Data [ 'RemasterTitle' ];
$LastRemasterYear = $Data [ 'RemasterYear' ];
$LastRemasterRecordLabel = $Data [ 'RemasterRecordLabel' ];
$LastRemasterCatalogueNumber = $Data [ 'RemasterCatalogueNumber' ];
2011-09-04 08:00:07 +00:00
$LastMedia = $Data [ 'Media' ];
2011-03-28 14:21:28 +00:00
?>
2013-04-17 08:00:58 +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 >
2011-10-29 08:00:15 +00:00
[ < a href = " torrents.php?action=download&id=<?= $TorrentID ?>&authkey=<?= $LoggedUser['AuthKey'] ?>&torrent_pass=<?= $LoggedUser['torrent_pass'] ?> " title = " Download " >< ? = $Data [ 'HasFile' ] ? 'DL' : 'Missing' ?> </a>
2012-10-28 08:00:19 +00:00
< ? if ( Torrents :: can_use_token ( $Data )) { ?>
2012-09-09 08:00:26 +00:00
| < a href = " torrents.php?action=download&id=<?= $TorrentID ?>&authkey=<?= $LoggedUser['AuthKey'] ?>&torrent_pass=<?= $LoggedUser['torrent_pass'] ?>&usetoken=1 " title = " Use a FL Token " onclick = " return confirm('Are you sure you want to use a freeleech token here?'); " > FL </ a >
2011-10-29 08:00:15 +00:00
< ? } ?>
| < a href = " reportsv2.php?action=report&id=<?= $TorrentID ?> " title = " Report " > RP </ a > ]
2011-03-28 14:21:28 +00:00
</ span >
2013-04-19 08:00:55 +00:00
& raquo ; < a href = " torrents.php?id=<?= $GroupID ?>&torrentid=<?= $TorrentID ?> " >< ? = Torrents :: torrent_info ( $Data ) ?> <? if ($Reported) { ?> / <strong class="torrent_label tl_reported" title="Reported">Reported</strong><? } ?></a>
2011-03-28 14:21:28 +00:00
</ td >
< td >< ? = $Data [ 'FileCount' ] ?> </td>
2012-11-01 08:00:21 +00:00
< td class = " nobr " >< ? = time_diff ( $Data [ 'Time' ], 1 ) ?> </td>
2012-10-11 08:00:15 +00:00
< td class = " nobr " >< ? = Format :: get_size ( $Data [ 'Size' ]) ?> </td>
2011-03-28 14:21:28 +00:00
< td >< ? = number_format ( $Data [ 'Snatched' ]) ?> </td>
2013-04-17 08:00:58 +00:00
< td < ? = ( $Data [ 'Seeders' ] == 0 ) ? ' class="r00"' : '' ?> ><?=number_format($Data['Seeders'])?></td>
2011-03-28 14:21:28 +00:00
< td >< ? = number_format ( $Data [ 'Leechers' ]) ?> </td>
</ tr >
< ?
}
} else {
// Viewing a type that does not require grouping
2012-10-16 08:00:18 +00:00
2012-11-01 08:00:21 +00:00
list ( $TorrentID , $Data ) = each ( $Torrents );
2013-07-04 08:00:56 +00:00
$DisplayName .= " <a href= \" torrents.php?id= $GroupID &torrentid= $TorrentID #torrent $TorrentID\ " title = \ " View Torrent \" dir= \" ltr \" > $GroupName </a> " ;
2013-04-17 08:00:58 +00:00
if ( isset ( $GroupedCategories [ $CategoryID - 1 ])) {
2012-11-01 08:00:21 +00:00
if ( $GroupYear ) {
2013-04-17 08:00:58 +00:00
$DisplayName .= " [ $GroupYear ] " ;
2012-11-01 08:00:21 +00:00
}
2013-04-15 08:00:54 +00:00
if ( $CategoryID == 1 && $ReleaseType > 0 ) {
2012-11-01 08:00:21 +00:00
$DisplayName .= ' [' . $ReleaseTypes [ $ReleaseType ] . ']' ;
}
$ExtraInfo = Torrents :: torrent_info ( $Data , true , true );
2012-11-04 08:00:20 +00:00
} elseif ( $Data [ 'IsSnatched' ]) {
2013-01-03 08:00:30 +00:00
$ExtraInfo = Format :: torrent_label ( 'Snatched!' );
2012-11-01 08:00:21 +00:00
} else {
$ExtraInfo = '' ;
2011-03-28 14:21:28 +00:00
}
2012-12-06 08:00:17 +00:00
$SnatchedTorrentClass = $Data [ 'IsSnatched' ] ? ' snatched_torrent' : '' ;
2011-03-28 14:21:28 +00:00
?>
2012-12-06 08:00:17 +00:00
< tr class = " torrent<?= $SnatchedTorrentClass . $SnatchedGroupClass ?> " >
< ? if ( $GroupResults ) { ?>
2011-03-28 14:21:28 +00:00
< td ></ td >
2012-12-06 08:00:17 +00:00
< ? } ?>
2011-03-28 14:21:28 +00:00
< td class = " center cats_col " >
2013-02-25 21:16:55 +00:00
< div title = " <?= $TorrentTags->title ()?> " class = " <?=Format::css_category( $CategoryID )?> <?= $TorrentTags->css_name ()?> " ></ div >
2011-03-28 14:21:28 +00:00
</ td >
2013-02-25 21:16:55 +00:00
< td class = " big_info " >
2013-04-17 08:00:58 +00:00
< ? if ( $LoggedUser [ 'CoverArt' ]) : ?>
2013-02-25 21:16:55 +00:00
< div class = " group_image float_left clear " >
2013-04-30 18:18:07 +00:00
< ? ImageTools :: cover_thumb ( $GroupInfo [ 'WikiImage' ], $CategoryID ) ?>
2013-02-25 21:16:55 +00:00
</ div >
2013-04-17 08:00:58 +00:00
< ? endif ; ?>
2013-02-25 21:16:55 +00:00
< div class = " group_info clear " >
< span >
[ < a href = " torrents.php?action=download&id=<?= $TorrentID ?>&authkey=<?= $LoggedUser['AuthKey'] ?>&torrent_pass=<?= $LoggedUser['torrent_pass'] ?> " title = " Download " > DL </ a >
2012-10-28 08:00:19 +00:00
< ? if ( Torrents :: can_use_token ( $Data )) { ?>
2013-02-25 21:16:55 +00:00
| < a href = " torrents.php?action=download&id=<?= $TorrentID ?>&authkey=<?= $LoggedUser['AuthKey'] ?>&torrent_pass=<?= $LoggedUser['torrent_pass'] ?>&usetoken=1 " title = " Use a FL Token " onclick = " return confirm('Are you sure you want to use a freeleech token here?'); " > FL </ a >
2013-02-16 08:00:57 +00:00
< ? } ?>
2013-02-25 21:16:55 +00:00
| < a href = " reportsv2.php?action=report&id=<?= $TorrentID ?> " title = " Report " > RP </ a > ]
</ span >
< ? = $DisplayName ?>
< div class = " torrent_info " >< ? = $ExtraInfo ?> </div>
< div class = " tags " >< ? = $TorrentTags -> format ( 'torrents.php?' . $Action . '&taglist=' ) ?> </div>
</ div >
2011-03-28 14:21:28 +00:00
</ td >
< td >< ? = $Data [ 'FileCount' ] ?> </td>
2012-11-01 08:00:21 +00:00
< td class = " nobr " >< ? = time_diff ( $Data [ 'Time' ], 1 ) ?> </td>
2012-10-11 08:00:15 +00:00
< td class = " nobr " >< ? = Format :: get_size ( $Data [ 'Size' ]) ?> </td>
2012-11-01 08:00:21 +00:00
< td >< ? = number_format ( $Data [ 'Snatched' ]) ?> </td>
2013-04-17 08:00:58 +00:00
< td < ? = ( $Data [ 'Seeders' ] == 0 ) ? ' class="r00"' : '' ?> ><?=number_format($Data['Seeders'])?></td>
2012-11-01 08:00:21 +00:00
< td >< ? = number_format ( $Data [ 'Leechers' ]) ?> </td>
2011-03-28 14:21:28 +00:00
</ tr >
< ?
}
}
?>
</ table >
< div class = " linkbox " >< ? = $Pages ?> </div>
2012-12-02 08:00:19 +00:00
</ div >
2012-11-01 08:00:21 +00:00
< ? View :: show_footer (); ?>