mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-13 02:46:30 +00:00
Empty commit
This commit is contained in:
parent
3e8fc731cc
commit
69e1208c2a
43
gazelle.sql
43
gazelle.sql
@ -928,27 +928,29 @@ CREATE TABLE `sphinx_t` (
|
|||||||
`id` int(11) NOT NULL,
|
`id` int(11) NOT NULL,
|
||||||
`gid` int(11) NOT NULL,
|
`gid` int(11) NOT NULL,
|
||||||
`uid` int(11) NOT NULL,
|
`uid` int(11) NOT NULL,
|
||||||
`size` bigint(20) DEFAULT NULL,
|
`size` bigint(20) NOT NULL,
|
||||||
`snatched` int(11) DEFAULT NULL,
|
`snatched` int(11) NOT NULL,
|
||||||
`seeders` int(11) DEFAULT NULL,
|
`seeders` int(11) NOT NULL,
|
||||||
`leechers` int(11) DEFAULT NULL,
|
`leechers` int(11) NOT NULL,
|
||||||
`time` int(11) DEFAULT NULL,
|
`time` int(11) NOT NULL,
|
||||||
`logscore` smallint(6) DEFAULT NULL,
|
`logscore` smallint(6) NOT NULL,
|
||||||
`scene` tinyint(4) DEFAULT NULL,
|
`scene` tinyint(4) NOT NULL,
|
||||||
`haslog` tinyint(4) DEFAULT NULL,
|
`haslog` tinyint(4) NOT NULL,
|
||||||
`hascue` tinyint(4) DEFAULT NULL,
|
`hascue` tinyint(4) NOT NULL,
|
||||||
`freetorrent` tinyint(4) DEFAULT NULL,
|
`freetorrent` tinyint(4) NOT NULL,
|
||||||
`media` varchar(15) DEFAULT NULL,
|
`media` varchar(15) NOT NULL,
|
||||||
`format` varchar(15) DEFAULT NULL,
|
`format` varchar(15) NOT NULL,
|
||||||
`encoding` varchar(30) DEFAULT NULL,
|
`encoding` varchar(30) NOT NULL,
|
||||||
`remyear` smallint(6) DEFAULT NULL,
|
`remyear` smallint(6) NOT NULL,
|
||||||
`remtitle` varchar(80) DEFAULT NULL,
|
`remtitle` varchar(80) NOT NULL,
|
||||||
`remrlabel` varchar(80) DEFAULT NULL,
|
`remrlabel` varchar(80) NOT NULL,
|
||||||
`remcnumber` varchar(80) DEFAULT NULL,
|
`remcnumber` varchar(80) NOT NULL,
|
||||||
`filelist` mediumtext,
|
`filelist` mediumtext,
|
||||||
`remident` int(10) unsigned DEFAULT NULL,
|
`remident` int(10) unsigned NOT NULL,
|
||||||
|
`description` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
KEY `gid_remident` (`gid`,`remident`)
|
KEY `gid_remident` (`gid`,`remident`),
|
||||||
|
KEY `format` (`format`)
|
||||||
) ENGINE=InnoDB CHARSET utf8;
|
) ENGINE=InnoDB CHARSET utf8;
|
||||||
|
|
||||||
CREATE TABLE `sphinx_tg` (
|
CREATE TABLE `sphinx_tg` (
|
||||||
@ -1322,7 +1324,8 @@ CREATE TABLE `users_donor_ranks` (
|
|||||||
PRIMARY KEY (`UserID`),
|
PRIMARY KEY (`UserID`),
|
||||||
KEY `DonationTime` (`DonationTime`),
|
KEY `DonationTime` (`DonationTime`),
|
||||||
KEY `SpecialRank` (`SpecialRank`),
|
KEY `SpecialRank` (`SpecialRank`),
|
||||||
KEY `Rank` (`Rank`)
|
KEY `Rank` (`Rank`),
|
||||||
|
KEY `TotalRank` (`TotalRank`)
|
||||||
) ENGINE=InnoDB CHARSET utf8;
|
) ENGINE=InnoDB CHARSET utf8;
|
||||||
|
|
||||||
CREATE TABLE `users_downloads` (
|
CREATE TABLE `users_downloads` (
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// The "order by x" links on columns headers
|
// The "order by x" links on columns headers
|
||||||
function header_link($SortKey, $DefaultWay = 'desc') {
|
function header_link($SortKey, $DefaultWay = 'desc') {
|
||||||
global $OrderBy,$OrderWay;
|
global $OrderBy, $OrderWay;
|
||||||
if ($SortKey == $OrderBy) {
|
if ($SortKey == $OrderBy) {
|
||||||
if ($OrderWay == 'desc') {
|
if ($OrderWay == 'desc') {
|
||||||
$NewWay = 'asc';
|
$NewWay = 'asc';
|
||||||
@ -14,11 +14,32 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
} else {
|
} else {
|
||||||
$NewWay = $DefaultWay;
|
$NewWay = $DefaultWay;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "torrents.php?order_way=$NewWay&order_by=$SortKey&".Format::get_url(array('order_way', 'order_by'));
|
return "torrents.php?order_way=$NewWay&order_by=$SortKey&".Format::get_url(array('order_way', 'order_by'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Start default parameters and validation **/
|
/** Start default parameters and validation **/
|
||||||
|
if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
|
||||||
|
if (!empty($_GET['searchstr'])) {
|
||||||
|
$InfoHash = $_GET['searchstr'];
|
||||||
|
} else {
|
||||||
|
$InfoHash = $_GET['groupname'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search by infohash
|
||||||
|
if ($InfoHash = is_valid_torrenthash($InfoHash)) {
|
||||||
|
$InfoHash = db_string(pack('H*', $InfoHash));
|
||||||
|
$DB->query("
|
||||||
|
SELECT ID, GroupID
|
||||||
|
FROM torrents
|
||||||
|
WHERE info_hash = '$InfoHash'");
|
||||||
|
if ($DB->has_results()) {
|
||||||
|
list($ID, $GroupID) = $DB->next_record();
|
||||||
|
header("Location: torrents.php?id=$GroupID&torrentid=$ID");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setting default search options
|
// Setting default search options
|
||||||
if (!empty($_GET['setdefault'])) {
|
if (!empty($_GET['setdefault'])) {
|
||||||
$UnsetList = array('page', 'setdefault');
|
$UnsetList = array('page', 'setdefault');
|
||||||
@ -51,7 +72,7 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
|
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
|
||||||
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
|
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
|
||||||
$SiteOptions = unserialize($SiteOptions);
|
$SiteOptions = unserialize($SiteOptions);
|
||||||
$SiteOptions['DefaultSearch']='';
|
$SiteOptions['DefaultSearch'] = '';
|
||||||
$DB->query("
|
$DB->query("
|
||||||
UPDATE users_info
|
UPDATE users_info
|
||||||
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
|
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
|
||||||
@ -89,12 +110,14 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
'leechers' => array('sumleechers', 'leechers'),
|
'leechers' => array('sumleechers', 'leechers'),
|
||||||
'snatched' => array('sumsnatched', 'snatched'),
|
'snatched' => array('sumsnatched', 'snatched'),
|
||||||
'random' => false);
|
'random' => false);
|
||||||
|
|
||||||
$AggregateExp = array(
|
$AggregateExp = array(
|
||||||
'maxsize' => 'MAX(size) AS maxsize',
|
'maxsize' => 'MAX(size) AS maxsize',
|
||||||
'sumseeders' => 'SUM(seeders) AS sumseeders',
|
'sumseeders' => 'SUM(seeders) AS sumseeders',
|
||||||
'sumleechers' => 'SUM(leechers) AS sumleechers',
|
'sumleechers' => 'SUM(leechers) AS sumleechers',
|
||||||
'sumsnatched' => 'SUM(snatched) AS sumsnatched');
|
'sumsnatched' => 'SUM(snatched) AS sumsnatched');
|
||||||
} else {
|
} else {
|
||||||
|
$GroupResults = false;
|
||||||
$SortOrders = array(
|
$SortOrders = array(
|
||||||
'year' => 'year',
|
'year' => 'year',
|
||||||
'time' => 'id',
|
'time' => 'id',
|
||||||
@ -160,7 +183,7 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
$Filtered = false;
|
$Filtered = false;
|
||||||
$EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator
|
$EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator
|
||||||
|
|
||||||
// Filelist searches makes use of the proximity operator to ensure that all keywords match the same file
|
// File list searches make use of the proximity operator to ensure that all keywords match the same file
|
||||||
if (!empty($_GET['filelist'])) {
|
if (!empty($_GET['filelist'])) {
|
||||||
$SearchString = trim($_GET['filelist']);
|
$SearchString = trim($_GET['filelist']);
|
||||||
if ($SearchString !== '') {
|
if ($SearchString !== '') {
|
||||||
@ -173,12 +196,10 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Collect all entered search terms to find out whether to enable the NOT operator
|
// Collect all entered search terms to find out whether to enable the NOT operator
|
||||||
$GroupFields = array('artistname', 'groupname', 'recordlabel', 'cataloguenumber', 'taglist');
|
|
||||||
$TorrentFields = array('remastertitle', 'remasteryear', 'remasterrecordlabel', 'remastercataloguenumber', 'encoding', 'format', 'media');
|
|
||||||
$SearchWords = array();
|
$SearchWords = array();
|
||||||
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
|
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
|
||||||
'taglist', 'remastertitle', 'remasteryear', 'remasterrecordlabel',
|
'taglist', 'remastertitle', 'remasteryear', 'remasterrecordlabel',
|
||||||
'remastercataloguenumber', 'encoding', 'format', 'media') as $Search) {
|
'remastercataloguenumber', 'encoding', 'format', 'media', 'description') as $Search) {
|
||||||
if (!empty($_GET[$Search])) {
|
if (!empty($_GET[$Search])) {
|
||||||
$SearchString = trim($_GET[$Search]);
|
$SearchString = trim($_GET[$Search]);
|
||||||
if ($SearchString !== '') {
|
if ($SearchString !== '') {
|
||||||
@ -191,7 +212,11 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
}
|
}
|
||||||
foreach ($Words as $Word) {
|
foreach ($Words as $Word) {
|
||||||
$Word = trim($Word);
|
$Word = trim($Word);
|
||||||
if ($Word[0] == '!' && strlen($Word) >= 2) {
|
// Skip isolated hyphens to enable "Artist - Title" searches
|
||||||
|
if ($Word === '-') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($Word[0] === '!' && strlen($Word) >= 2) {
|
||||||
if (strpos($Word, '!', 1) === false) {
|
if (strpos($Word, '!', 1) === false) {
|
||||||
$SearchWords[$Search]['exclude'][] = $Word;
|
$SearchWords[$Search]['exclude'][] = $Word;
|
||||||
} else {
|
} else {
|
||||||
@ -216,8 +241,12 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
$BasicSearch = array('include' => array(), 'exclude' => array());
|
$BasicSearch = array('include' => array(), 'exclude' => array());
|
||||||
foreach ($Words as $Word) {
|
foreach ($Words as $Word) {
|
||||||
$Word = trim($Word);
|
$Word = trim($Word);
|
||||||
if ($Word[0] == '!' && strlen($Word) >= 2) {
|
// Skip isolated hyphens to enable "Artist - Title" searches
|
||||||
if ($Word == '!100%') {
|
if ($Word === '-') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($Word[0] === '!' && strlen($Word) >= 2) {
|
||||||
|
if ($Word === '!100%') {
|
||||||
$_GET['haslog'] = '-1';
|
$_GET['haslog'] = '-1';
|
||||||
} elseif (strpos($Word, '!', 1) === false) {
|
} elseif (strpos($Word, '!', 1) === false) {
|
||||||
$BasicSearch['exclude'][] = $Word;
|
$BasicSearch['exclude'][] = $Word;
|
||||||
@ -274,7 +303,51 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
|
|
||||||
// Tag list
|
// Tag list
|
||||||
if (!empty($SearchWords['taglist'])) {
|
if (!empty($SearchWords['taglist'])) {
|
||||||
|
//Get tag aliases.
|
||||||
|
$TagAliases = $Cache->get_value('tag_aliases_search');
|
||||||
|
if ($TagAliases === false) {
|
||||||
|
$DB->query('
|
||||||
|
SELECT ID, BadTag, AliasTag
|
||||||
|
FROM tag_aliases
|
||||||
|
ORDER BY BadTag');
|
||||||
|
$TagAliases = $DB->to_array(false, MYSQLI_ASSOC, false);
|
||||||
|
//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
|
||||||
$Tags = $SearchWords['taglist'];
|
$Tags = $SearchWords['taglist'];
|
||||||
|
//Replace bad tags with tag aliases
|
||||||
|
$End = count($Tags['include']);
|
||||||
|
for ($i = 0; $i < $End; $i++) {
|
||||||
|
foreach ($TagAliases as $TagAlias) {
|
||||||
|
if ($Tags['include'][$i] === $TagAlias['BadTag']) {
|
||||||
|
$Tags['include'][$i] = $TagAlias['AliasTag'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$End = count($Tags['exclude']);
|
||||||
|
for ($i = 0; $i < $End; $i++) {
|
||||||
|
foreach ($TagAliases as $TagAlias) {
|
||||||
|
if (substr($Tags['exclude'][$i], 1) === $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']);
|
||||||
|
$TagListString = implode(', ', array_merge($Tags['include'], $Tags['exclude']));
|
||||||
if (!$EnableNegation && !empty($Tags['exclude'])) {
|
if (!$EnableNegation && !empty($Tags['exclude'])) {
|
||||||
$Tags['include'] = array_merge($Tags['include'], $Tags['exclude']);
|
$Tags['include'] = array_merge($Tags['include'], $Tags['exclude']);
|
||||||
unset($Tags['exclude']);
|
unset($Tags['exclude']);
|
||||||
@ -290,13 +363,15 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
|
|
||||||
$QueryParts = array();
|
$QueryParts = array();
|
||||||
// 'All' tags
|
// 'All' tags
|
||||||
if (!isset($_GET['tags_type']) || $_GET['tags_type'] === '1') {
|
if (!isset($_GET['tags_type']) || $_GET['tags_type'] == 1) {
|
||||||
$_GET['tags_type'] = '1';
|
$_GET['tags_type'] = '1';
|
||||||
$Tags = array_merge($Tags['include'], $Tags['exclude']);
|
$Tags = array_merge($Tags['include'], $Tags['exclude']);
|
||||||
if (!empty($Tags)) {
|
if (!empty($Tags)) {
|
||||||
$QueryParts[] = implode(' ', $Tags);
|
$QueryParts[] = implode(' ', $Tags);
|
||||||
}
|
}
|
||||||
} else { // 'Any' tags
|
}
|
||||||
|
// 'Any' tags
|
||||||
|
else {
|
||||||
$_GET['tags_type'] = '0';
|
$_GET['tags_type'] = '0';
|
||||||
if (!empty($Tags['include'])) {
|
if (!empty($Tags['include'])) {
|
||||||
$QueryParts[] = '( '.implode(' | ', $Tags['include']).' )';
|
$QueryParts[] = '( '.implode(' | ', $Tags['include']).' )';
|
||||||
@ -311,9 +386,13 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
$Filtered = true;
|
$Filtered = true;
|
||||||
}
|
}
|
||||||
unset($SearchWords['taglist']);
|
unset($SearchWords['taglist']);
|
||||||
} elseif (!isset($_GET['tags_type'])) {
|
}
|
||||||
|
elseif (!isset($_GET['tags_type'])) {
|
||||||
$_GET['tags_type'] = '1';
|
$_GET['tags_type'] = '1';
|
||||||
}
|
}
|
||||||
|
if (!isset($TagListString)) {
|
||||||
|
$TagListString = "";
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($SearchWords as $Search => $Words) {
|
foreach ($SearchWords as $Search => $Words) {
|
||||||
$QueryParts = array();
|
$QueryParts = array();
|
||||||
@ -385,7 +464,8 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
$SphQLTor->where($Search, $_GET[$Search]);
|
$SphQLTor->where($Search, $_GET[$Search]);
|
||||||
}
|
}
|
||||||
if ($_GET[$Search] !== 0) {
|
if ($_GET[$Search] !== 0) {
|
||||||
// Hack! Deleted torrents may show up if we set to true unconditionally. Hope no one notices
|
// This condition is required because all attributes are 0
|
||||||
|
// for deleted torrents and we abuse that to detect them
|
||||||
$Filtered = true;
|
$Filtered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -457,7 +537,7 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
if (check_perms('site_search_many')) {
|
if (check_perms('site_search_many')) {
|
||||||
$Page = $_GET['page'];
|
$Page = $_GET['page'];
|
||||||
} else {
|
} else {
|
||||||
$Page = min(SPHINX_MAX_MATCHES/TORRENTS_PER_PAGE, $_GET['page']);
|
$Page = min(SPHINX_MAX_MATCHES / TORRENTS_PER_PAGE, $_GET['page']);
|
||||||
}
|
}
|
||||||
$Offset = ($Page - 1) * TORRENTS_PER_PAGE;
|
$Offset = ($Page - 1) * TORRENTS_PER_PAGE;
|
||||||
$SphQL->limit($Offset, TORRENTS_PER_PAGE, $Offset + TORRENTS_PER_PAGE);
|
$SphQL->limit($Offset, TORRENTS_PER_PAGE, $Offset + TORRENTS_PER_PAGE);
|
||||||
@ -482,6 +562,7 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
|
|
||||||
if ($TorrentCount) {
|
if ($TorrentCount) {
|
||||||
$Groups = Torrents::get_groups($GroupIDs);
|
$Groups = Torrents::get_groups($GroupIDs);
|
||||||
|
|
||||||
if (!empty($Groups) && $GroupResults) {
|
if (!empty($Groups) && $GroupResults) {
|
||||||
$TorrentIDs = array();
|
$TorrentIDs = array();
|
||||||
foreach ($Groups as $Group) {
|
foreach ($Groups as $Group) {
|
||||||
@ -489,11 +570,12 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
$TorrentIDs = array_merge($TorrentIDs, array_keys($Group['Torrents']));
|
$TorrentIDs = array_merge($TorrentIDs, array_keys($Group['Torrents']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!empty($TorrentIDs)) {
|
||||||
// Get a list of all torrent IDs that match the search query
|
// Get a list of all torrent ids that match the search query
|
||||||
$SphQLTor->where('id', $TorrentIDs)->limit(0, count($TorrentIDs), count($TorrentIDs));
|
$SphQLTor->where('id', $TorrentIDs)->limit(0, count($TorrentIDs), count($TorrentIDs));
|
||||||
$SphQLResultTor = $SphQLTor->query();
|
$SphQLResultTor = $SphQLTor->query();
|
||||||
$TorrentIDs = array_fill_keys($SphQLResultTor->collect('id'), true);
|
$TorrentIDs = array_fill_keys($SphQLResultTor->collect('id'), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** End run search query and collect results **/
|
/** End run search query and collect results **/
|
||||||
|
@ -20,10 +20,8 @@
|
|||||||
*
|
*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
include(SERVER_ROOT.'/sections/torrents/functions.php');
|
include(SERVER_ROOT.'/sections/torrents/functions.php');
|
||||||
|
|
||||||
|
|
||||||
// The "order by x" links on columns headers
|
// The "order by x" links on columns headers
|
||||||
function header_link($SortKey, $DefaultWay = 'desc') {
|
function header_link($SortKey, $DefaultWay = 'desc') {
|
||||||
global $OrderBy, $OrderWay;
|
global $OrderBy, $OrderWay;
|
||||||
@ -170,7 +168,7 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
array_pop($Bitrates); // remove 'other'
|
array_pop($Bitrates); // remove 'other'
|
||||||
$SearchBitrates = array_merge($Bitrates, array('v0', 'v1', 'v2', '24bit'));
|
$SearchBitrates = array_merge($Bitrates, array('v0', 'v1', 'v2', '24bit'));
|
||||||
|
|
||||||
foreach ($SearchBitrates as $ID=>$Val) {
|
foreach ($SearchBitrates as $ID => $Val) {
|
||||||
$SearchBitrates[$ID] = strtolower($Val);
|
$SearchBitrates[$ID] = strtolower($Val);
|
||||||
}
|
}
|
||||||
foreach ($Formats as $ID => $Val) {
|
foreach ($Formats as $ID => $Val) {
|
||||||
@ -208,7 +206,7 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
// File list searches make use of the proximity operator to ensure that all keywords match the same file
|
// File list searches make use of the proximity operator to ensure that all keywords match the same file
|
||||||
if (!empty($_GET['filelist'])) {
|
if (!empty($_GET['filelist'])) {
|
||||||
$SearchString = trim($_GET['filelist']);
|
$SearchString = trim($_GET['filelist']);
|
||||||
if ($SearchString != '') {
|
if ($SearchString !== '') {
|
||||||
$SearchString = '"'.Sphinxql::sph_escape_string($_GET['filelist']).'"~20';
|
$SearchString = '"'.Sphinxql::sph_escape_string($_GET['filelist']).'"~20';
|
||||||
$SphQL->where_match($SearchString, 'filelist', false);
|
$SphQL->where_match($SearchString, 'filelist', false);
|
||||||
$SphQLTor->where_match($SearchString, 'filelist', false);
|
$SphQLTor->where_match($SearchString, 'filelist', false);
|
||||||
@ -218,15 +216,13 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Collect all entered search terms to find out whether to enable the NOT operator
|
// Collect all entered search terms to find out whether to enable the NOT operator
|
||||||
$GroupFields = array('artistname', 'groupname', 'recordlabel', 'cataloguenumber', 'taglist');
|
|
||||||
$TorrentFields = array('remastertitle', 'remasteryear', 'remasterrecordlabel', 'remastercataloguenumber', 'encoding', 'format', 'media');
|
|
||||||
$SearchWords = array();
|
$SearchWords = array();
|
||||||
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
|
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
|
||||||
'taglist', 'remastertitle', 'remasteryear', 'remasterrecordlabel',
|
'taglist', 'remastertitle', 'remasteryear', 'remasterrecordlabel',
|
||||||
'remastercataloguenumber', 'encoding', 'format', 'media') as $Search) {
|
'remastercataloguenumber', 'encoding', 'format', 'media', 'description') as $Search) {
|
||||||
if (!empty($_GET[$Search])) {
|
if (!empty($_GET[$Search])) {
|
||||||
$SearchString = trim($_GET[$Search]);
|
$SearchString = trim($_GET[$Search]);
|
||||||
if ($SearchString != '') {
|
if ($SearchString !== '') {
|
||||||
$SearchWords[$Search] = array('include' => array(), 'exclude' => array());
|
$SearchWords[$Search] = array('include' => array(), 'exclude' => array());
|
||||||
if ($Search == 'taglist') {
|
if ($Search == 'taglist') {
|
||||||
$SearchString = strtr($SearchString, '.', '_');
|
$SearchString = strtr($SearchString, '.', '_');
|
||||||
@ -237,17 +233,17 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
foreach ($Words as $Word) {
|
foreach ($Words as $Word) {
|
||||||
$Word = trim($Word);
|
$Word = trim($Word);
|
||||||
// Skip isolated hyphens to enable "Artist - Title" searches
|
// Skip isolated hyphens to enable "Artist - Title" searches
|
||||||
if ($Word == '-') {
|
if ($Word === '-') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($Word[0] == '!' && strlen($Word) >= 2) {
|
if ($Word[0] === '!' && strlen($Word) >= 2) {
|
||||||
if (strpos($Word, '!', 1) === false) {
|
if (strpos($Word, '!', 1) === false) {
|
||||||
$SearchWords[$Search]['exclude'][] = $Word;
|
$SearchWords[$Search]['exclude'][] = $Word;
|
||||||
} else {
|
} else {
|
||||||
$SearchWords[$Search]['include'][] = $Word;
|
$SearchWords[$Search]['include'][] = $Word;
|
||||||
$EnableNegation = true;
|
$EnableNegation = true;
|
||||||
}
|
}
|
||||||
} elseif ($Word != '') {
|
} elseif ($Word !== '') {
|
||||||
$SearchWords[$Search]['include'][] = $Word;
|
$SearchWords[$Search]['include'][] = $Word;
|
||||||
$EnableNegation = true;
|
$EnableNegation = true;
|
||||||
}
|
}
|
||||||
@ -266,11 +262,11 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
foreach ($Words as $Word) {
|
foreach ($Words as $Word) {
|
||||||
$Word = trim($Word);
|
$Word = trim($Word);
|
||||||
// Skip isolated hyphens to enable "Artist - Title" searches
|
// Skip isolated hyphens to enable "Artist - Title" searches
|
||||||
if ($Word == '-') {
|
if ($Word === '-') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($Word[0] == '!' && strlen($Word) >= 2) {
|
if ($Word[0] === '!' && strlen($Word) >= 2) {
|
||||||
if ($Word == '!100%') {
|
if ($Word === '!100%') {
|
||||||
$_GET['haslog'] = '-1';
|
$_GET['haslog'] = '-1';
|
||||||
} elseif (strpos($Word, '!', 1) === false) {
|
} elseif (strpos($Word, '!', 1) === false) {
|
||||||
$BasicSearch['exclude'][] = $Word;
|
$BasicSearch['exclude'][] = $Word;
|
||||||
@ -284,9 +280,9 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
} elseif (in_array($Word, $SearchFormats)) {
|
} elseif (in_array($Word, $SearchFormats)) {
|
||||||
$FilterFormats[] = $Word;
|
$FilterFormats[] = $Word;
|
||||||
$EnableNegation = true;
|
$EnableNegation = true;
|
||||||
} elseif ($Word == '100%') {
|
} elseif ($Word === '100%') {
|
||||||
$_GET['haslog'] = '100';
|
$_GET['haslog'] = '100';
|
||||||
} elseif ($Word != '') {
|
} elseif ($Word !== '') {
|
||||||
$BasicSearch['include'][] = $Word;
|
$BasicSearch['include'][] = $Word;
|
||||||
$EnableNegation = true;
|
$EnableNegation = true;
|
||||||
}
|
}
|
||||||
@ -327,18 +323,17 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
|
|
||||||
// Tag list
|
// Tag list
|
||||||
if (!empty($SearchWords['taglist'])) {
|
if (!empty($SearchWords['taglist'])) {
|
||||||
global $Cache, $DB;
|
// Get tag aliases.
|
||||||
//Get tag aliases.
|
|
||||||
$TagAliases = $Cache->get_value('tag_aliases_search');
|
$TagAliases = $Cache->get_value('tag_aliases_search');
|
||||||
if (!$TagAliases) {
|
if ($TagAliases === false) {
|
||||||
$DB->query('
|
$DB->query('
|
||||||
SELECT ID, BadTag, AliasTag
|
SELECT ID, BadTag, AliasTag
|
||||||
FROM tag_aliases
|
FROM tag_aliases
|
||||||
ORDER BY BadTag');
|
ORDER BY BadTag');
|
||||||
$TagAliases = $DB->to_array();
|
$TagAliases = $DB->to_array(false, MYSQLI_ASSOC, false);
|
||||||
//Unify tag aliases to be in_this_format as tags not in.this.format
|
// 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);'));
|
array_walk_recursive($TagAliases, create_function('&$val', '$val = preg_replace("/\./","_", $val);'));
|
||||||
//Clean up the array for smaller cache size
|
// Clean up the array for smaller cache size
|
||||||
foreach ($TagAliases as &$TagAlias) {
|
foreach ($TagAliases as &$TagAlias) {
|
||||||
foreach (array_keys($TagAlias) as $Key) {
|
foreach (array_keys($TagAlias) as $Key) {
|
||||||
if (is_numeric($Key)) {
|
if (is_numeric($Key)) {
|
||||||
@ -348,11 +343,11 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
}
|
}
|
||||||
$Cache->cache_value('tag_aliases_search', $TagAliases, 3600 * 24 * 7); // cache for 7 days
|
$Cache->cache_value('tag_aliases_search', $TagAliases, 3600 * 24 * 7); // cache for 7 days
|
||||||
}
|
}
|
||||||
//Get tags
|
// Get tags
|
||||||
$Tags = $SearchWords['taglist'];
|
$Tags = $SearchWords['taglist'];
|
||||||
//Replace bad tags with tag aliases
|
// 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
|
$End = count($Tags['include']);
|
||||||
for ($i = 0; $i < sizeof($Tags['include']) ; $i++) {
|
for ($i = 0; $i < $End; $i++) {
|
||||||
foreach ($TagAliases as $TagAlias) {
|
foreach ($TagAliases as $TagAlias) {
|
||||||
if ($Tags['include'][$i] === $TagAlias['BadTag']) {
|
if ($Tags['include'][$i] === $TagAlias['BadTag']) {
|
||||||
$Tags['include'][$i] = $TagAlias['AliasTag'];
|
$Tags['include'][$i] = $TagAlias['AliasTag'];
|
||||||
@ -360,15 +355,16 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ($i = 0; $i < sizeof($Tags['exclude']) ; $i++) {
|
$End = count($Tags['exclude']);
|
||||||
|
for ($i = 0; $i < $End; $i++) {
|
||||||
foreach ($TagAliases as $TagAlias) {
|
foreach ($TagAliases as $TagAlias) {
|
||||||
if (preg_replace('/^!/', '', $Tags['exclude'][$i]) === $TagAlias['BadTag']) {
|
if (substr($Tags['exclude'][$i], 1) === $TagAlias['BadTag']) {
|
||||||
$Tags['exclude'][$i] = '!'.$TagAlias['AliasTag'];
|
$Tags['exclude'][$i] = '!'.$TagAlias['AliasTag'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Only keep unique entries after unifying tag standard
|
// Only keep unique entries after unifying tag standard
|
||||||
$Tags['include'] = array_unique($Tags['include']);
|
$Tags['include'] = array_unique($Tags['include']);
|
||||||
$Tags['exclude'] = array_unique($Tags['exclude']);
|
$Tags['exclude'] = array_unique($Tags['exclude']);
|
||||||
$TagListString = implode(', ', array_merge($Tags['include'], $Tags['exclude']));
|
$TagListString = implode(', ', array_merge($Tags['include'], $Tags['exclude']));
|
||||||
@ -488,8 +484,8 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
$SphQLTor->where($Search, $_GET[$Search]);
|
$SphQLTor->where($Search, $_GET[$Search]);
|
||||||
}
|
}
|
||||||
if ($_GET[$Search] !== 0) {
|
if ($_GET[$Search] !== 0) {
|
||||||
//TODO: Clean up this hack
|
// This condition is required because all attributes are 0
|
||||||
// Hack! Deleted torrents may show up if we set to true unconditionally. Hope no one notices
|
// for deleted torrents and we abuse that to detect them
|
||||||
$Filtered = true;
|
$Filtered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -713,6 +709,12 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
<input type="text" spellcheck="false" size="40" name="filelist" class="inputtext fti_advanced" value="<?Format::form('filelist')?>" />
|
<input type="text" spellcheck="false" size="40" name="filelist" class="inputtext fti_advanced" value="<?Format::form('filelist')?>" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr id="torrent_description" class="ftr_advanced<?=$HideAdvanced?>">
|
||||||
|
<td class="label"><span title="Search torrent descriptions (not group information)" class="tooltip">Torrent description:</span></td>
|
||||||
|
<td colspan="3" class="ft_description">
|
||||||
|
<input type="text" spellcheck="false" size="40" name="description" class="inputtext fti_advanced" value="<?Format::form('description')?>" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr id="rip_specifics" class="ftr_advanced<?=$HideAdvanced?>">
|
<tr id="rip_specifics" class="ftr_advanced<?=$HideAdvanced?>">
|
||||||
<td class="label">Rip specifics:</td>
|
<td class="label">Rip specifics:</td>
|
||||||
<td class="nobr ft_ripspecifics" colspan="3">
|
<td class="nobr ft_ripspecifics" colspan="3">
|
||||||
@ -782,9 +784,9 @@ function header_link($SortKey, $DefaultWay = 'desc') {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="tagfilter">
|
<tr id="tagfilter">
|
||||||
<td class="label">Tags (comma-separated):</td>
|
<td class="label"><span title="Use !tag to exclude tag" class="tooltip">Tags (comma-separated):</span></td>
|
||||||
<td colspan="3" class="ft_taglist">
|
<td colspan="3" class="ft_taglist">
|
||||||
<input type="text" size="40" id="tags" name="taglist" class="tooltip inputtext smaller" title="Use !tag to exclude tag" value="<?=str_replace('_', '.', display_str($TagListString)) /* Use aliased tags, not actual query string. */ ?>" />
|
<input type="text" size="40" id="tags" name="taglist" class="inputtext smaller" value="<?=str_replace('_', '.', display_str($TagListString)) /* Use aliased tags, not actual query string. */ ?>" />
|
||||||
<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_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>
|
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
|
||||||
</td>
|
</td>
|
||||||
|
@ -48,12 +48,12 @@ source torrents : torrents_base {
|
|||||||
sql_query_pre = truncate sphinx_t
|
sql_query_pre = truncate sphinx_t
|
||||||
sql_query_pre = insert into sphinx_t \
|
sql_query_pre = insert into sphinx_t \
|
||||||
(id, gid, size, snatched, seeders, leechers, time, logscore, scene, \
|
(id, gid, size, snatched, seeders, leechers, time, logscore, scene, \
|
||||||
haslog, hascue, freetorrent, media, format, encoding, \
|
haslog, hascue, freetorrent, description, media, format, encoding, \
|
||||||
remyear, remtitle, remrlabel, remcnumber, filelist, uid, remident) \
|
remyear, remtitle, remrlabel, remcnumber, filelist, uid, remident) \
|
||||||
select id, groupid, size, snatched, seeders, leechers, unix_timestamp(time), \
|
select id, groupid, size, snatched, seeders, leechers, unix_timestamp(time), \
|
||||||
logscore, cast(scene as char), cast(haslog as char), \
|
logscore, cast(scene as char), cast(haslog as char), \
|
||||||
cast(hascue as char), cast(freetorrent as char), media, \
|
cast(hascue as char), cast(freetorrent as char), description, \
|
||||||
format, encoding, remasteryear, remastertitle, \
|
media, format, encoding, remasteryear, remastertitle, \
|
||||||
remasterrecordlabel, remastercataloguenumber, filelist, userid, \
|
remasterrecordlabel, remastercataloguenumber, filelist, userid, \
|
||||||
crc32(concat_ws(' ', media, remasteryear, remastertitle, \
|
crc32(concat_ws(' ', media, remasteryear, remastertitle, \
|
||||||
remasterrecordlabel, remastercataloguenumber)) \
|
remasterrecordlabel, remastercataloguenumber)) \
|
||||||
@ -77,7 +77,7 @@ source torrents : torrents_base {
|
|||||||
cnumber cataloguenumber, catid categoryid, \
|
cnumber cataloguenumber, catid categoryid, \
|
||||||
t.time, reltype releasetype, size>>10 size, \
|
t.time, reltype releasetype, size>>10 size, \
|
||||||
snatched, seeders, leechers, logscore, scene, \
|
snatched, seeders, leechers, logscore, scene, \
|
||||||
vanityhouse, haslog, hascue, freetorrent, \
|
vanityhouse, haslog, hascue, freetorrent, description, \
|
||||||
media, format, encoding, remyear remasteryear, \
|
media, format, encoding, remyear remasteryear, \
|
||||||
remtitle remastertitle, remrlabel remasterrecordlabel, \
|
remtitle remastertitle, remrlabel remasterrecordlabel, \
|
||||||
remcnumber remastercataloguenumber, \
|
remcnumber remastercataloguenumber, \
|
||||||
|
Loading…
Reference in New Issue
Block a user