$SearchFormats[$ID] = strtolower($Val); } /** End preparation of property arrays **/ /** Start query preparation **/ $SphQL = new SphinxqlQuery(); $SphQLTor = new SphinxqlQuery(); if ($OrderBy == 'random') { $SphQL->select('id, groupid, categoryid')->order_by('RAND()', ''); $Random = true; } elseif ($GroupResults) { $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); } 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; $EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator // File list searches make use of the proximity operator to ensure that all keywords match the same file if (!empty($_GET['filelist'])) { $SearchString = trim($_GET['filelist']); if ($SearchString !== '') { $SearchString = '"' . Sphinxql::sph_escape_string($_GET['filelist']) . '"~20'; $SphQL->where_match($SearchString, 'filelist', false); $SphQLTor->where_match($SearchString, 'filelist', false); $EnableNegation = true; }