diff --git a/Blacklight/ReleaseSearch.php b/Blacklight/ReleaseSearch.php index 44512916b..51503cc6a 100755 --- a/Blacklight/ReleaseSearch.php +++ b/Blacklight/ReleaseSearch.php @@ -52,9 +52,11 @@ class ReleaseSearch * @param array $options Array where keys are the column name, and value is the search string. * @param bool $forceLike Force a "like" search on the column. * - * @return string + * @param null $query + * @param bool $builder + * */ - public function getSearchSQL(array $options = [], $forceLike = false): string + public function getSearchSQL(array $options = [], $forceLike = false, $query = null, $builder = false) { $this->searchOptions = $options; @@ -62,7 +64,7 @@ class ReleaseSearch return $this->likeSQL(); } - return $this->sphinxSQL(); + return $this->sphinxSQL($query, $builder); } /** @@ -104,11 +106,12 @@ class ReleaseSearch } /** - * Create SQL sub-query using sphinx full text search. + * @param null $query + * @param bool $builder * * @return string */ - private function sphinxSQL(): string + private function sphinxSQL($query = null, $builder = false) { $searchQuery = $fullReturn = ''; @@ -131,6 +134,10 @@ class ReleaseSearch } } if ($searchQuery !== '') { + if ($builder === true) { + return $query->whereRaw("(rse.query = '@@relaxed ?')", [trim($searchQuery).$this->sphinxQueryOpt]); + } + $fullReturn = sprintf("AND (rse.query = '@@relaxed %s')", trim($searchQuery).$this->sphinxQueryOpt); } else { $fullReturn = $this->likeSQL(); diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index 8cb5f1cea..f9254578c 100755 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -66,44 +66,6 @@ class Releases $this->showPasswords = self::showPasswords(); } - /** - * Used for pager on browse page. - * - * @param array $cat - * @param int $maxAge - * @param array $excludedCats - * @param string|int $groupName - * - * @return int - */ - public function getBrowseCount($cat, $maxAge = -1, array $excludedCats = [], $groupName = ''): int - { - $sql = sprintf( - 'SELECT COUNT(r.id) AS count - FROM releases r - %s - WHERE r.nzbstatus = %d - AND r.passwordstatus %s - %s %s %s %s', - ($groupName !== -1 ? 'LEFT JOIN groups g ON g.id = r.groups_id' : ''), - NZB::NZB_ADDED, - $this->showPasswords, - ($groupName !== -1 ? sprintf(' AND g.name = %s', $this->pdo->escapeString($groupName)) : ''), - Category::getCategorySearch($cat), - ($maxAge > 0 ? (' AND r.postdate > NOW() - INTERVAL '.$maxAge.' DAY ') : ''), - (\count($excludedCats) ? (' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')') : '') - ); - $count = Cache::get(md5($sql)); - if ($count !== null) { - return $count; - } - $count = $this->pdo->query($sql); - $expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_short')); - Cache::put(md5($sql), $count[0]['count'], $expiresAt); - - return $count[0]['count'] ?? 0; - } - /** * @param array $cat * @param $orderBy @@ -119,25 +81,25 @@ class Releases $orderBy = $this->getBrowseOrder($orderBy); $qry = Release::query() ->fromSub(function ($query) use ($cat, $maxAge, $excludedCats, $groupName, $minSize, $orderBy) { - $query->select(['releases.*', 'g.name as group_name']) - ->from('releases') - ->where('releases.nzbstatus', NZB::NZB_ADDED); + $query->select(['r.*', 'g.name as group_name']) + ->from('releases as r') + ->where('r.nzbstatus', NZB::NZB_ADDED); self::showPasswords($query, true); if ($cat !== [-1]) { Category::getCategorySearch($cat, $query, true); } - $query->leftJoin('groups as g', 'g.id', '=', 'releases.groups_id'); + $query->leftJoin('groups as g', 'g.id', '=', 'r.groups_id'); if ($maxAge > 0) { - $query->where('releases.postdate', '>', Carbon::now()->subDays($maxAge)); + $query->where('r.postdate', '>', Carbon::now()->subDays($maxAge)); } if (\count($excludedCats) > 0) { - $query->whereNotIn('releases.categories_id', $excludedCats); + $query->whereNotIn('r.categories_id', $excludedCats); } if ($groupName !== -1) { $query->where('g.name', $groupName); } if ($minSize > 0) { - $query->where('releases.size', '>=', $minSize); + $query->where('r.size', '>=', $minSize); } $query->orderBy($orderBy[0], $orderBy[1]); }, 'r') @@ -181,26 +143,26 @@ class Releases return '='.self::PASSWD_NONE; } - return $query->where('releases.passwordstatus', self::PASSWD_NONE); + return $query->where('r.passwordstatus', self::PASSWD_NONE); case 1: // Show releases with no password or a potential password (Show unprocessed releases). if ($builder === false) { return '<= '.self::PASSWD_POTENTIAL; } - return $query->where('releases.passwordstatus', '=<', self::PASSWD_POTENTIAL); + return $query->where('r.passwordstatus', '=<', self::PASSWD_POTENTIAL); case 2: // Hide releases with a password or a potential password (Show unprocessed releases). if ($builder === false) { return '<= '.self::PASSWD_NONE; } - return $query->where('releases.passwordstatus', '=<', self::PASSWD_NONE); + return $query->where('r.passwordstatus', '=<', self::PASSWD_NONE); case 10: // Shows everything. default: if ($builder === false) { return '<= '.self::PASSWD_RAR; } - return $query->where('releases.passwordstatus', '=<', self::PASSWD_RAR); + return $query->where('r.passwordstatus', '=<', self::PASSWD_RAR); } } @@ -624,29 +586,29 @@ class Releases /** * Function for searching on the site (by subject, searchname or advanced). * - * @param string|int $searchName - * @param string|int $usenetName - * @param string|int $posterName - * @param string|int $fileName - * @param string|int $groupName - * @param int $sizeFrom - * @param int $sizeTo - * @param int $hasNfo - * @param int $hasComments - * @param int $daysNew - * @param int $daysOld - * @param int $offset - * @param int $limit - * @param string|array $orderBy - * @param int $maxAge - * @param int|array $excludedCats - * @param string $type - * @param array $cat * - * @param int $minSize - * @return array + * + * @param $searchName + * @param $usenetName + * @param $posterName + * @param $fileName + * @param $groupName + * @param $sizeFrom + * @param $sizeTo + * @param $hasNfo + * @param $hasComments + * @param $daysNew + * @param $daysOld + * @param string|array $orderBy + * @param int $maxAge + * @param array $excludedCats + * @param string $type + * @param array $cat + * @param int $minSize + * + * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|mixed */ - public function search($searchName, $usenetName, $posterName, $fileName, $groupName, $sizeFrom, $sizeTo, $hasNfo, $hasComments, $daysNew, $daysOld, $offset = 0, $limit = 1000, $orderBy = '', $maxAge = -1, array $excludedCats = [], $type = 'basic', array $cat = [-1], $minSize = 0): array + public function search($searchName, $usenetName, $posterName, $fileName, $groupName, $sizeFrom, $sizeTo, $hasNfo, $hasComments, $daysNew, $daysOld, $orderBy = '', $maxAge = -1, array $excludedCats = [], $type = 'basic', array $cat = [-1], $minSize = 0) { $sizeRange = [ 1 => 1, @@ -684,82 +646,82 @@ class Releases $searchOptions['filename'] = $fileName; } - $catQuery = ''; - if ($type === 'basic') { - $catQuery = Category::getCategorySearch($cat); - } elseif ($type === 'advanced' && (int) $cat[0] !== -1) { - $catQuery = sprintf('AND r.categories_id = %d', $cat[0]); - } + $sql = Release::query() + ->fromSub(function ($query) use ($maxAge, $groupName, $sizeFrom, $sizeRange, $sizeTo, $hasNfo, $hasComments, $cat, $excludedCats, $type, $daysNew, $daysOld, $searchOptions, $minSize) { + $query->select(['r.*', 'r.categories_id AS category_ids', 'df.failed as failed', 'g.name as group_name', 'rn.releases_id as nfoid', 're.releases_id as reid', 'cp.id as categoryparentid', 'v.tvdb', 'v.trakt', 'v.tvrage', 'v.tvmaze', 'v.imdb', 'v.tmdb', 'tve.firstaired']) + ->selectRaw("CONCAT(cp.title, ' > ', c.title) AS category_name") + ->from('releases as r') + ->leftJoin('video_data as re','re.releases_id', '=', 'r.id') + ->leftJoin('videos as v', 'v.id', '=', 'r.videos_id') + ->leftJoin('tv_episodes as tve', 'tve.id', '=', 'r.tv_episodes_id') + ->leftJoin('release_nfos as rn', 'rn.releases_id', '=', 'r.id') + ->leftJoin('groups as g', 'g.id', '=', 'r.groups_id') + ->leftJoin('categories as c', 'c.id', '=', 'r.categories_id') + ->leftJoin('categories as cp', 'cp.id', '=', 'c.parentid') + ->leftJoin('dnzb_failures as df', 'df.release_id', '=', 'r.id') + ->join('releases_se as rse', 'rse.id', '=', 'r.id'); + //self::showPasswords($query, true); + $query->where('r.nzbstatus', '=', NZB::NZB_ADDED); - $whereSql = sprintf( - '%s WHERE r.passwordstatus %s AND r.nzbstatus = %d %s %s %s %s %s %s %s %s %s %s %s %s', - $this->releaseSearch->getFullTextJoinString(), - $this->showPasswords, - NZB::NZB_ADDED, - ($maxAge > 0 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $maxAge) : ''), - ((int) $groupName !== -1 ? sprintf(' AND r.groups_id = %d ', Group::getIDByName($groupName)) : ''), - (array_key_exists($sizeFrom, $sizeRange) ? ' AND r.size > '.(string) (104857600 * (int) $sizeRange[$sizeFrom]).' ' : ''), - (array_key_exists($sizeTo, $sizeRange) ? ' AND r.size < '.(string) (104857600 * (int) $sizeRange[$sizeTo]).' ' : ''), - ((int) $hasNfo !== 0 ? ' AND r.nfostatus = 1 ' : ''), - ((int) $hasComments !== 0 ? ' AND r.comments > 0 ' : ''), - $catQuery, - ((int) $daysNew !== -1 ? sprintf(' AND r.postdate < (NOW() - INTERVAL %d DAY) ', $daysNew) : ''), - ((int) $daysOld !== -1 ? sprintf(' AND r.postdate > (NOW() - INTERVAL %d DAY) ', $daysOld) : ''), - (\count($excludedCats) > 0 ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''), - (\count($searchOptions) > 0 ? $this->releaseSearch->getSearchSQL($searchOptions) : ''), - ($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '') - ); + if ($maxAge > 0) { + $query->where('r.postdate', '>', Carbon::now()->subDays($maxAge)); + } - $baseSql = sprintf( - "SELECT r.*, - CONCAT(cp.title, ' > ', c.title) AS category_name, - %s AS category_ids, - df.failed AS failed, - g.name AS group_name, - rn.releases_id AS nfoid, - re.releases_id AS reid, - cp.id AS categoryparentid, - v.tvdb, v.trakt, v.tvrage, v.tvmaze, v.imdb, v.tmdb, - tve.firstaired - FROM releases r - LEFT OUTER JOIN video_data re ON re.releases_id = r.id - LEFT OUTER JOIN videos v ON r.videos_id = v.id - LEFT OUTER JOIN tv_episodes tve ON r.tv_episodes_id = tve.id - LEFT OUTER JOIN release_nfos rn ON rn.releases_id = r.id - LEFT JOIN groups g ON g.id = r.groups_id - LEFT JOIN categories c ON c.id = r.categories_id - LEFT JOIN categories cp ON cp.id = c.parentid - LEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id - %s", - $this->getConcatenatedCategoryIDs(), - $whereSql - ); + if ((int) $groupName !== -1) { + $query->where('r.groups_id', '=', Group::getIDByName($groupName)); + } - $sql = sprintf( - 'SELECT * FROM ( - %s - ) r - ORDER BY r.%s %s - LIMIT %d OFFSET %d', - $baseSql, - $orderBy[0], - $orderBy[1], - $limit, - $offset - ); + if (array_key_exists($sizeFrom, $sizeRange)) { + $query->where('r.size', '<', (string) (104857600 * (int) $sizeRange[$sizeTo])); + } - $releases = Cache::get(md5($sql)); + if ((int) $hasNfo !== 0) { + $query->where('r.nfostatus', '=', 1); + } + + if ((int) $hasComments !== 0) { + $query->where('r.comments', '>', 0); + } + + if ($type === 'basic') { + Category::getCategorySearch($cat, $query, true); + } elseif ($type === 'advanced' && (int) $cat[0] !== -1) { + $query->where('r.categories_id', '=', $cat[0]); + } + + if ((int) $daysNew !== -1) { + $query->where('r.postdate', '<', Carbon::now()->subDays($daysNew)); + } + + if ((int) $daysOld !== -1) { + $query->where('r.postdate', '>', Carbon::now()->subDays($daysOld)); + } + + if (\count($excludedCats) > 0) { + $query->whereNotIn('r.categories_id', $excludedCats); + } + + if (\count($searchOptions) > 0) { + $this->releaseSearch->getSearchSQL($searchOptions, false, $query, true); + } + + if ($minSize > 0) { + $query->where('r.size', '>=', $minSize); + } + }, 'r') + ->orderBy('r.'.$orderBy[0], $orderBy[1]); + + + $releases = Cache::get(md5($searchName.$usenetName.$posterName.$fileName.$groupName.$sizeFrom.$sizeTo.$hasNfo.$hasComments.$daysNew.$daysOld.implode('.', $orderBy).$maxAge. implode('.',$excludedCats).$type.implode('.',$cat).$minSize)); if ($releases !== null) { return $releases; } - $releases = $this->pdo->query($sql); - if (! empty($releases) && \count($releases)) { - $releases[0]['_totalrows'] = $this->getPagerCount($baseSql); - } + $releases = $sql->paginate(config('nntmux.items_per_page')); + $expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium')); - Cache::put(md5($sql), $releases, $expiresAt); + Cache::put(md5($searchName.$usenetName.$posterName.$fileName.$groupName.$sizeFrom.$sizeTo.$hasNfo.$hasComments.$daysNew.$daysOld.implode('.', $orderBy).$maxAge. implode('.',$excludedCats).$type.implode('.',$cat).$minSize), $releases, $expiresAt); return $releases; } @@ -1110,8 +1072,6 @@ class Releases 0, -1, -1, - 0, - $limit, '', -1, $excludedCats, diff --git a/Changelog b/Changelog index 98627bba8..c93b4313b 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-04-12 DariusIII + * Chg: Update search * Fix: Fix missing = in search query * Chg: Update headermenu search * Chg: Update search diff --git a/app/Http/Controllers/Api/ApiController.php b/app/Http/Controllers/Api/ApiController.php index fc19df00f..8477bc713 100644 --- a/app/Http/Controllers/Api/ApiController.php +++ b/app/Http/Controllers/Api/ApiController.php @@ -124,7 +124,6 @@ class ApiController extends BasePageController $groupName = $api->group(); UserRequest::addApiRequest($uid, $request->getRequestUri()); $categoryID = $api->categoryID(); - $limit = $api->limit(); if ($request->has('q')) { $relData = $releases->search( @@ -139,8 +138,6 @@ class ApiController extends BasePageController 0, -1, -1, - $offset, - $limit, '', $maxAge, $catExclusions, @@ -149,7 +146,9 @@ class ApiController extends BasePageController $minSize ); } else { + $page = $request->has('page') ? $request->input('page') : 1; $relData = $releases->getBrowseRange( + $page, $categoryID, '', $maxAge, diff --git a/app/Http/Controllers/BasePageController.php b/app/Http/Controllers/BasePageController.php index 244aa2171..a3e3acd4c 100644 --- a/app/Http/Controllers/BasePageController.php +++ b/app/Http/Controllers/BasePageController.php @@ -94,7 +94,7 @@ class BasePageController extends Controller */ public function __construct(Request $request) { - $this->middleware('auth')->except('api', 'rss', 'contact', 'showContactForm', 'callback', 'search'); + $this->middleware('auth')->except('api', 'rss', 'contact', 'showContactForm', 'callback'); // Buffer settings/DB connection. $this->settings = new Settings(); $this->pdo = new DB(); diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 323f46fde..d82d50dcc 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -17,6 +17,7 @@ class SearchController extends BasePageController public function search(Request $request) { $this->setPrefs(); + dump($request->all()); $releases = new Releases(['Groups' => null, 'Settings' => $this->settings]); $meta_title = 'Search Nzbs'; @@ -32,12 +33,10 @@ class SearchController extends BasePageController $ordering = $releases->getBrowseOrdering(); $orderBy = ($request->has('ob') && \in_array($request->input('ob'), $ordering, false) ? $request->input('ob') : ''); - $offset = ($request->has('offset') && ctype_digit($request->input('offset'))) ? $request->input('offset') : 0; $this->smarty->assign( [ - 'subject' => '', 'search' => '', 'category' => [0], 'pagertotalitems' => 0, - 'pageritemsperpage' => 1, 'pageroffset' => 1, 'covgroup' => '', + 'subject' => '', 'search' => '', 'category' => [0], 'covgroup' => '', ] ); @@ -61,7 +60,7 @@ class SearchController extends BasePageController foreach ($releases->getBrowseOrdering() as $orderType) { $this->smarty->assign( 'orderby'.$orderType, - WWW_TOP.'/search/'.htmlentities($searchString, ENT_QUOTES | ENT_HTML5).'?t='.implode(',', $categoryID).'&ob='.$orderType + WWW_TOP.'/search?id='.htmlentities($searchString, ENT_QUOTES | ENT_HTML5).'?t='.implode(',', $categoryID).'&ob='.$orderType ); } @@ -77,8 +76,6 @@ class SearchController extends BasePageController 0, -1, -1, - $offset, - config('nntmux.items_per_page'), $orderBy, -1, $this->userdata['categoryexclusions'], @@ -86,15 +83,12 @@ class SearchController extends BasePageController $categoryID ); + dump($results->total()); + + $this->smarty->assign( [ 'lastvisit' => $this->userdata['lastlogin'], - 'pagertotalitems' => \count($results) > 0 ? $results[0]['_totalrows'] : 0, - 'pageroffset' => $offset, - 'pageritemsperpage' => config('nntmux.items_per_page'), - 'pagerquerysuffix' => '#results', - 'pagerquerybase' => WWW_TOP.'/search/'.htmlentities($searchString, ENT_QUOTES | ENT_HTML5).'?t='. - implode(',', $categoryID).'&ob='.$orderBy.'&offset=', 'category' => $categoryID, ] ); @@ -145,8 +139,6 @@ class SearchController extends BasePageController $searchVars['searchadvhascomments'], ($searchVars['searchadvdaysnew'] === '' ? -1 : $searchVars['searchadvdaysnew']), ($searchVars['searchadvdaysold'] === '' ? -1 : $searchVars['searchadvdaysold']), - $offset, - config('nntmux.items_per_page'), $orderBy, -1, $this->userdata['categoryexclusions'], @@ -154,14 +146,12 @@ class SearchController extends BasePageController [$searchVars['searchadvcat'] === '' ? -1 : $searchVars['searchadvcat']] ); + dump($results->total()); + + $this->smarty->assign( [ 'lastvisit' => $this->userdata['lastlogin'], - 'pagertotalitems' => \count($results) > 0 ? $results[0]['_totalrows'] : 0, - 'pageroffset' => $offset, - 'pageritemsperpage' => config('nntmux.items_per_page'), - 'pagerquerysuffix' => '#results', - 'pagerquerybase' => WWW_TOP.'/search?'.$orderByString.'&search_type=adv&ob='.$orderBy.'&offset=', ] ); } @@ -192,7 +182,6 @@ You can combine some of these rules, but not all.
'; 'grouplist' => Group::getGroupsForSelect(), 'catlist' => Category::getForSelect(), 'search_description' => $search_description, - 'pager' => $this->smarty->fetch('pager.tpl'), ] ); diff --git a/public/pages/search.php b/public/pages/search.php deleted file mode 100644 index 5c46a8549..000000000 --- a/public/pages/search.php +++ /dev/null @@ -1,192 +0,0 @@ -show403(); -} - -$releases = new Releases(['Groups' => null, 'Settings' => $page->settings]); - -$page->meta_title = 'Search Nzbs'; -$page->meta_keywords = 'search,nzb,description,details'; -$page->meta_description = 'Search for Nzbs'; - -$results = []; - -$searchType = 'basic'; -if (request()->has('search_type') && request()->input('search_type') === 'adv') { - $searchType = 'advanced'; -} - -$ordering = $releases->getBrowseOrdering(); -$orderBy = (request()->has('ob') && in_array(request()->input('ob'), $ordering, false) ? request()->input('ob') : ''); -$offset = (request()->has('offset') && ctype_digit(request()->input('offset'))) ? request()->input('offset') : 0; - -$page->smarty->assign( - [ - 'subject' => '', 'search' => '', 'category' => [0], 'pagertotalitems' => 0, - 'pageritemsperpage' => 1, 'pageroffset' => 1, 'covgroup' => '', - ] -); - -if ($searchType === 'basic' && ! request()->has('searchadvr') && (request()->has('id') || request()->has('subject'))) { - $searchString = ''; - switch (true) { - case request()->has('subject'): - $searchString = (string) request()->input('subject'); - $page->smarty->assign('subject', $searchString); - break; - case request()->has('id'): - $searchString = (string) request()->input('id'); - $page->smarty->assign('search', $searchString); - break; - } - - $categoryID[] = -1; - if (request()->has('t')) { - $categoryID = explode(',', request()->input('t')); - } - foreach ($releases->getBrowseOrdering() as $orderType) { - $page->smarty->assign( - 'orderby'.$orderType, - WWW_TOP.'/search/'.htmlentities($searchString, ENT_QUOTES | ENT_HTML5).'?t='.implode(',', $categoryID).'&ob='.$orderType - ); - } - - $results = $releases->search( - $searchString, - -1, - -1, - -1, - -1, - -1, - -1, - 0, - 0, - -1, - -1, - $offset, - config('nntmux.items_per_page'), - $orderBy, - -1, - $page->userdata['categoryexclusions'], - 'basic', - $categoryID - ); - - $page->smarty->assign( - [ - 'lastvisit' => $page->userdata['lastlogin'], - 'pagertotalitems' => \count($results) > 0 ? $results[0]['_totalrows'] : 0, - 'pageroffset' => $offset, - 'pageritemsperpage' => config('nntmux.items_per_page'), - 'pagerquerysuffix' => '#results', - 'pagerquerybase' => WWW_TOP.'/search/'.htmlentities($searchString, ENT_QUOTES | ENT_HTML5).'?t='. - implode(',', $categoryID).'&ob='.$orderBy.'&offset=', - 'category' => $categoryID, - ] - ); -} - -$searchVars = [ - 'searchadvr' => '', 'searchadvsubject' => '', 'searchadvposter' => '', - 'searchadvfilename' => '', 'searchadvdaysnew' => '', 'searchadvdaysold' => '', - 'searchadvgroups' => '', 'searchadvcat' => '', 'searchadvsizefrom' => '', - 'searchadvsizeto' => '', 'searchadvhasnfo' => '', 'searchadvhascomments' => '', -]; - -foreach ($searchVars as $searchVarKey => $searchVar) { - $searchVars[$searchVarKey] = (request()->has($searchVarKey) ? (string) request()->input($searchVarKey) : ''); -} - -$searchVars['selectedgroup'] = $searchVars['searchadvgroups']; -$searchVars['selectedcat'] = $searchVars['searchadvcat']; -$searchVars['selectedsizefrom'] = $searchVars['searchadvsizefrom']; -$searchVars['selectedsizeto'] = $searchVars['searchadvsizeto']; -foreach ($searchVars as $searchVarKey => $searchVar) { - $page->smarty->assign($searchVarKey, $searchVars[$searchVarKey]); -} - -if ($searchType !== 'basic' && request()->has('searchadvr') && ! request()->has('id') && ! request()->has('subject')) { - $orderByString = ''; - foreach ($searchVars as $searchVarKey => $searchVar) { - $orderByString .= "&$searchVarKey=".htmlentities($searchVar, ENT_QUOTES | ENT_HTML5); - } - $orderByString = ltrim($orderByString, '&'); - - foreach ($ordering as $orderType) { - $page->smarty->assign( - 'orderby'.$orderType, - WWW_TOP.'/search?'.$orderByString.'&search_type=adv&ob='.$orderType - ); - } - - $results = $releases->search( - ($searchVars['searchadvr'] === '' ? -1 : $searchVars['searchadvr']), - ($searchVars['searchadvsubject'] === '' ? -1 : $searchVars['searchadvsubject']), - ($searchVars['searchadvposter'] === '' ? -1 : $searchVars['searchadvposter']), - ($searchVars['searchadvfilename'] === '' ? -1 : $searchVars['searchadvfilename']), - $searchVars['searchadvgroups'], - $searchVars['searchadvsizefrom'], - $searchVars['searchadvsizeto'], - $searchVars['searchadvhasnfo'], - $searchVars['searchadvhascomments'], - ($searchVars['searchadvdaysnew'] === '' ? -1 : $searchVars['searchadvdaysnew']), - ($searchVars['searchadvdaysold'] === '' ? -1 : $searchVars['searchadvdaysold']), - $offset, - config('nntmux.items_per_page'), - $orderBy, - -1, - $page->userdata['categoryexclusions'], - 'advanced', - [$searchVars['searchadvcat'] === '' ? -1 : $searchVars['searchadvcat']] - ); - - $page->smarty->assign( - [ - 'lastvisit' => $page->userdata['lastlogin'], - 'pagertotalitems' => \count($results) > 0 ? $results[0]['_totalrows'] : 0, - 'pageroffset' => $offset, - 'pageritemsperpage' => config('nntmux.items_per_page'), - 'pagerquerysuffix' => '#results', - 'pagerquerybase' => WWW_TOP.'/search?'.$orderByString.'&search_type=adv&ob='.$orderBy.'&offset=', - ] - ); -} - -$search_description = - 'Sphinx Search Rules:
-The search is case insensitive.
-All words must be separated by spaces. -Do not seperate words using . or _ or -, sphinx will match a space against those automatically.
-Putting | between words makes any of those words optional.
-Putting << between words makes the word on the left have to be before the word on the right.
-Putting - or ! in front of a word makes that word excluded. Do not add a space between the - or ! and the word.
-Quoting all the words using " will look for an exact match.
-Putting ^ at the start will limit searches to releases that start with that word.
-Putting $ at the end will limit searches to releases that end with that word.
-Putting a * after a word will do a partial word search. ie: fish* will match fishing.
-If your search is only words seperated by spaces, all those words will be mandatory, the order of the words is not important.
-You can enclose words using paranthesis. ie: (^game*|^dex*)s03*(x264<<nogrp$)
-You can combine some of these rules, but not all.
'; - -$page->smarty->assign( - [ - 'sizelist' => [ - -1 => '--Select--', 1 => '100MB', 2 => '250MB', 3 => '500MB', 4 => '1GB', 5 => '2GB', - 6 => '3GB', 7 => '4GB', 8 => '8GB', 9 => '16GB', 10 => '32GB', 11 => '64GB', - ], - 'results' => $results, 'sadvanced' => $searchType !== 'basic', - 'grouplist' => Group::getGroupsForSelect(), - 'catlist' => Category::getForSelect(), - 'search_description' => $search_description, - 'pager' => $page->smarty->fetch('pager.tpl'), - ] -); - -$page->content = $page->smarty->fetch('search.tpl'); -$page->pagerender(); diff --git a/resources/views/themes/Charisma/books.tpl b/resources/views/themes/Charisma/books.tpl index 3506c61e0..c9f6c191e 100755 --- a/resources/views/themes/Charisma/books.tpl +++ b/resources/views/themes/Charisma/books.tpl @@ -47,7 +47,7 @@
- {$pager} + {$results->links()}

@@ -198,7 +198,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Charisma/browse.tpl b/resources/views/themes/Charisma/browse.tpl index 7579d4c50..2ad9754a2 100755 --- a/resources/views/themes/Charisma/browse.tpl +++ b/resources/views/themes/Charisma/browse.tpl @@ -63,7 +63,7 @@
- {$pager} + {$results->links()}

@@ -203,7 +203,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Charisma/multi-operations.tpl b/resources/views/themes/Charisma/multi-operations.tpl index ed0923d4b..5b1b07c5c 100755 --- a/resources/views/themes/Charisma/multi-operations.tpl +++ b/resources/views/themes/Charisma/multi-operations.tpl @@ -1,5 +1,5 @@
- {$pager} + {$results->links()}
With Selected: diff --git a/resources/views/themes/Charisma/music.tpl b/resources/views/themes/Charisma/music.tpl index 56a546020..af7e85cde 100755 --- a/resources/views/themes/Charisma/music.tpl +++ b/resources/views/themes/Charisma/music.tpl @@ -46,7 +46,7 @@
- {$pager} + {$results->links()}

@@ -201,7 +201,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Charisma/search.tpl b/resources/views/themes/Charisma/search.tpl index bf40e1997..5e7381a9c 100755 --- a/resources/views/themes/Charisma/search.tpl +++ b/resources/views/themes/Charisma/search.tpl @@ -181,7 +181,7 @@
- {$pager} + {$results->links()}

@@ -376,7 +376,7 @@
- {$pager} + {$results->links()}



diff --git a/resources/views/themes/Charisma/viewmoviefull.tpl b/resources/views/themes/Charisma/viewmoviefull.tpl index b1c756ad8..8d53a60a9 100755 --- a/resources/views/themes/Charisma/viewmoviefull.tpl +++ b/resources/views/themes/Charisma/viewmoviefull.tpl @@ -194,7 +194,7 @@
- {$pager} + {$results->links()}
{/if} diff --git a/resources/views/themes/Charisma/viewxxxfull.tpl b/resources/views/themes/Charisma/viewxxxfull.tpl index 53675af3e..e1ff999a4 100755 --- a/resources/views/themes/Charisma/viewxxxfull.tpl +++ b/resources/views/themes/Charisma/viewxxxfull.tpl @@ -188,7 +188,7 @@
- {$pager} + {$results->links()}
{/if} diff --git a/resources/views/themes/Charisma/xxx.tpl b/resources/views/themes/Charisma/xxx.tpl index 36c6b51e4..ce108b980 100755 --- a/resources/views/themes/Charisma/xxx.tpl +++ b/resources/views/themes/Charisma/xxx.tpl @@ -47,7 +47,7 @@
- {$pager} + {$results->links()}

@@ -388,7 +388,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Gentele/books.tpl b/resources/views/themes/Gentele/books.tpl index bad2991b9..7fe5ce086 100755 --- a/resources/views/themes/Gentele/books.tpl +++ b/resources/views/themes/Gentele/books.tpl @@ -54,7 +54,7 @@
- {$pager} + {$results->links()}

@@ -233,7 +233,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Gentele/multi-operations.tpl b/resources/views/themes/Gentele/multi-operations.tpl index ab45ced44..3e2e70591 100755 --- a/resources/views/themes/Gentele/multi-operations.tpl +++ b/resources/views/themes/Gentele/multi-operations.tpl @@ -1,5 +1,5 @@
- {$pager} + {$results->links()}
With Selected:
- {$pager} + {$results->links()}

@@ -230,7 +230,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Gentele/search.tpl b/resources/views/themes/Gentele/search.tpl index 3a569b48a..3cc7b9e64 100755 --- a/resources/views/themes/Gentele/search.tpl +++ b/resources/views/themes/Gentele/search.tpl @@ -197,7 +197,7 @@
- {$pager} + {$results->links()}

@@ -429,7 +429,7 @@
- {$pager} + {$results->links()}



diff --git a/resources/views/themes/Gentele/viewmoviefull.tpl b/resources/views/themes/Gentele/viewmoviefull.tpl index 8ed10186c..5694a3ee4 100755 --- a/resources/views/themes/Gentele/viewmoviefull.tpl +++ b/resources/views/themes/Gentele/viewmoviefull.tpl @@ -224,7 +224,7 @@
- {$pager} + {$results->links()}
{/if} diff --git a/resources/views/themes/Gentele/viewxxxfull.tpl b/resources/views/themes/Gentele/viewxxxfull.tpl index 144b5671e..8e36ee41b 100755 --- a/resources/views/themes/Gentele/viewxxxfull.tpl +++ b/resources/views/themes/Gentele/viewxxxfull.tpl @@ -218,7 +218,7 @@
- {$pager} + {$results->links()}
{/if} diff --git a/resources/views/themes/Gentele/xxx.tpl b/resources/views/themes/Gentele/xxx.tpl index a52c2960d..cc195c89e 100755 --- a/resources/views/themes/Gentele/xxx.tpl +++ b/resources/views/themes/Gentele/xxx.tpl @@ -53,7 +53,7 @@
- {$pager} + {$results->links()}

@@ -441,7 +441,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Omicron/books.tpl b/resources/views/themes/Omicron/books.tpl index 2e8f39f9b..dd803d8fb 100755 --- a/resources/views/themes/Omicron/books.tpl +++ b/resources/views/themes/Omicron/books.tpl @@ -47,7 +47,7 @@
- {$pager} + {$results->links()}

@@ -201,7 +201,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Omicron/browse.tpl b/resources/views/themes/Omicron/browse.tpl index bc4dddfce..5dafe7ad3 100755 --- a/resources/views/themes/Omicron/browse.tpl +++ b/resources/views/themes/Omicron/browse.tpl @@ -63,7 +63,7 @@
- {$pager} + {$results->links()}

@@ -203,7 +203,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Omicron/multi-operations.tpl b/resources/views/themes/Omicron/multi-operations.tpl index ed0923d4b..5b1b07c5c 100755 --- a/resources/views/themes/Omicron/multi-operations.tpl +++ b/resources/views/themes/Omicron/multi-operations.tpl @@ -1,5 +1,5 @@
- {$pager} + {$results->links()}
With Selected: diff --git a/resources/views/themes/Omicron/music.tpl b/resources/views/themes/Omicron/music.tpl index 5d92f5f0f..fca3d64e5 100755 --- a/resources/views/themes/Omicron/music.tpl +++ b/resources/views/themes/Omicron/music.tpl @@ -46,7 +46,7 @@
- {$pager} + {$results->links()}

@@ -204,7 +204,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/Omicron/search.tpl b/resources/views/themes/Omicron/search.tpl index 3a569b48a..3cc7b9e64 100755 --- a/resources/views/themes/Omicron/search.tpl +++ b/resources/views/themes/Omicron/search.tpl @@ -197,7 +197,7 @@
- {$pager} + {$results->links()}

@@ -429,7 +429,7 @@
- {$pager} + {$results->links()}



diff --git a/resources/views/themes/Omicron/viewmoviefull.tpl b/resources/views/themes/Omicron/viewmoviefull.tpl index 37abbd071..0a45e8e98 100755 --- a/resources/views/themes/Omicron/viewmoviefull.tpl +++ b/resources/views/themes/Omicron/viewmoviefull.tpl @@ -194,7 +194,7 @@
- {$pager} + {$results->links()}
{/if} diff --git a/resources/views/themes/Omicron/viewxxxfull.tpl b/resources/views/themes/Omicron/viewxxxfull.tpl index 166e981e9..840705f6f 100755 --- a/resources/views/themes/Omicron/viewxxxfull.tpl +++ b/resources/views/themes/Omicron/viewxxxfull.tpl @@ -188,7 +188,7 @@
- {$pager} + {$results->links()}
{/if} diff --git a/resources/views/themes/Omicron/xxx.tpl b/resources/views/themes/Omicron/xxx.tpl index 257ac3574..6f346d0fa 100755 --- a/resources/views/themes/Omicron/xxx.tpl +++ b/resources/views/themes/Omicron/xxx.tpl @@ -47,7 +47,7 @@
- {$pager} + {$results->links()}

@@ -394,7 +394,7 @@
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/admin/anidb-list.tpl b/resources/views/themes/admin/anidb-list.tpl index cb11f31fd..d03553278 100644 --- a/resources/views/themes/admin/anidb-list.tpl +++ b/resources/views/themes/admin/anidb-list.tpl @@ -14,7 +14,7 @@ - {$pager} + {$results->links()}

@@ -44,7 +44,7 @@
- {$pager} + {$results->links()} {else}

No AniDB episodes available.

{/if} diff --git a/resources/views/themes/admin/book-list.tpl b/resources/views/themes/admin/book-list.tpl index 65e3448ba..b9295665f 100644 --- a/resources/views/themes/admin/book-list.tpl +++ b/resources/views/themes/admin/book-list.tpl @@ -2,7 +2,7 @@
{if $booklist} - {$pager} + {$results->links()} @@ -24,7 +24,7 @@

- {$pager} + {$results->links()} {else}

No books available.

{/if} diff --git a/resources/views/themes/admin/category_regexes-list.tpl b/resources/views/themes/admin/category_regexes-list.tpl index 6a8460736..a19b4e6d9 100644 --- a/resources/views/themes/admin/category_regexes-list.tpl +++ b/resources/views/themes/admin/category_regexes-list.tpl @@ -13,7 +13,7 @@ {if $regex} -
{$pager}
+
{$results->links()}
@@ -49,6 +49,6 @@ {/foreach}
id
-
{$pager}
+
{$results->links()}
{/if}
diff --git a/resources/views/themes/admin/collection_regexes-list.tpl b/resources/views/themes/admin/collection_regexes-list.tpl index 6a19d3e2d..b928be5f7 100644 --- a/resources/views/themes/admin/collection_regexes-list.tpl +++ b/resources/views/themes/admin/collection_regexes-list.tpl @@ -11,7 +11,7 @@ {if $regex} -
{$pager}
+
{$results->links()}
@@ -45,6 +45,6 @@ {/foreach}
id
-
{$pager}
+
{$results->links()}
{/if} diff --git a/resources/views/themes/admin/comments-list.tpl b/resources/views/themes/admin/comments-list.tpl index 98f14d132..6088d719c 100644 --- a/resources/views/themes/admin/comments-list.tpl +++ b/resources/views/themes/admin/comments-list.tpl @@ -1,7 +1,7 @@

{$title}

{if $commentslist} - {$pager} + {$results->links()} diff --git a/resources/views/themes/admin/console-list.tpl b/resources/views/themes/admin/console-list.tpl index f359ab586..ee7de7778 100644 --- a/resources/views/themes/admin/console-list.tpl +++ b/resources/views/themes/admin/console-list.tpl @@ -2,7 +2,7 @@
{if $consolelist} - {$pager} + {$results->links()}
user
@@ -24,7 +24,7 @@

- {$pager} + {$results->links()} {else}

No games available.

{/if} diff --git a/resources/views/themes/admin/failrel-list.tpl b/resources/views/themes/admin/failrel-list.tpl index 8677a214c..fee84b17f 100644 --- a/resources/views/themes/admin/failrel-list.tpl +++ b/resources/views/themes/admin/failrel-list.tpl @@ -2,7 +2,7 @@

{$title}

{if $releaselist} - {$pager} + {$results->links()} @@ -35,7 +35,7 @@

- {$pager} + {$results->links()} {else}

No releases available.

{/if} diff --git a/resources/views/themes/admin/game-list.tpl b/resources/views/themes/admin/game-list.tpl index 7374f4de1..189a54d5f 100644 --- a/resources/views/themes/admin/game-list.tpl +++ b/resources/views/themes/admin/game-list.tpl @@ -1,7 +1,7 @@

{$title}

{if $gamelist} - {$pager} + {$results->links()} diff --git a/resources/views/themes/admin/group-list.tpl b/resources/views/themes/admin/group-list.tpl index 872ba79a3..7e3a5060a 100644 --- a/resources/views/themes/admin/group-list.tpl +++ b/resources/views/themes/admin/group-list.tpl @@ -14,7 +14,7 @@
- {$pager} + {$results->links()}
- {$pager} + {$results->links()}
diff --git a/resources/views/themes/admin/movie-list.tpl b/resources/views/themes/admin/movie-list.tpl index b625be86f..566004433 100644 --- a/resources/views/themes/admin/movie-list.tpl +++ b/resources/views/themes/admin/movie-list.tpl @@ -2,7 +2,7 @@

{$title}

{if $movielist} - {$pager} + {$results->links()}
ID
diff --git a/resources/views/themes/admin/music-list.tpl b/resources/views/themes/admin/music-list.tpl index bed946973..970f99b6f 100644 --- a/resources/views/themes/admin/music-list.tpl +++ b/resources/views/themes/admin/music-list.tpl @@ -2,7 +2,7 @@

{$title}

{if $musiclist} - {$pager} + {$results->links()}
IMDB ID
@@ -24,7 +24,7 @@

- {$pager} + {$results->links()} {else}

No Music available.

{/if} diff --git a/resources/views/themes/admin/predb.tpl b/resources/views/themes/admin/predb.tpl index abeb24b05..9fa745990 100755 --- a/resources/views/themes/admin/predb.tpl +++ b/resources/views/themes/admin/predb.tpl @@ -13,7 +13,7 @@
- {$pager} + {$results->links()} @@ -365,6 +365,6 @@
Date

- {$pager} + {$results->links()}
diff --git a/resources/views/themes/admin/preview-list.tpl b/resources/views/themes/admin/preview-list.tpl index 55bbfc85a..e5875f176 100644 --- a/resources/views/themes/admin/preview-list.tpl +++ b/resources/views/themes/admin/preview-list.tpl @@ -18,7 +18,7 @@

{if $releaselist} - {$pager} + {$results->links()} @@ -39,7 +39,7 @@

- {$pager} + {$results->links()} {else}

No results.

{/if} diff --git a/resources/views/themes/admin/release-list.tpl b/resources/views/themes/admin/release-list.tpl index 6dfb4cb34..0f7880e18 100644 --- a/resources/views/themes/admin/release-list.tpl +++ b/resources/views/themes/admin/release-list.tpl @@ -2,7 +2,7 @@

{$title}

{if $releaselist} - {$pager} + {$results->links()} @@ -33,7 +33,7 @@

- {$pager} + {$results->links()} {else}

No releases available.

{/if} diff --git a/resources/views/themes/admin/release_naming_regexes-list.tpl b/resources/views/themes/admin/release_naming_regexes-list.tpl index bc0802ea4..036c98c46 100644 --- a/resources/views/themes/admin/release_naming_regexes-list.tpl +++ b/resources/views/themes/admin/release_naming_regexes-list.tpl @@ -11,7 +11,7 @@ {if isset($regex)} -
{$pager}
+
{$results->links()}
@@ -46,6 +46,6 @@ {/foreach}
id
-
{$pager}
+
{$results->links()}
{/if} diff --git a/resources/views/themes/admin/sharing.tpl b/resources/views/themes/admin/sharing.tpl index d3db9b914..748501b6b 100644 --- a/resources/views/themes/admin/sharing.tpl +++ b/resources/views/themes/admin/sharing.tpl @@ -190,7 +190,7 @@ {if $sites}
These are the remote websites we have seen so far:
- {$pager} + {$results->links()}
[Enable All] @@ -231,7 +231,7 @@ {/foreach} - {$pager} + {$results->links()} {else}

No remote sites found in your database.

{/if} diff --git a/resources/views/themes/admin/show-list.tpl b/resources/views/themes/admin/show-list.tpl index 7fa043564..5c75055f8 100755 --- a/resources/views/themes/admin/show-list.tpl +++ b/resources/views/themes/admin/show-list.tpl @@ -10,7 +10,7 @@
- {$pager} + {$results->links()}

- {$pager} + {$results->links()}