diff --git a/lib/copy_this/misc/sphinxsearch/populate_rt_indexes.php b/lib/copy_this/misc/sphinxsearch/populate_rt_indexes.php
index 9b590d4ca..eb8ba482b 100644
--- a/lib/copy_this/misc/sphinxsearch/populate_rt_indexes.php
+++ b/lib/copy_this/misc/sphinxsearch/populate_rt_indexes.php
@@ -24,7 +24,7 @@ switch ($argv[1]) {
function releases_rt()
{
$pdo = new \DB();
- $rows = $pdo->queryExec('SELECT ID, guid, name, searchname, fromname FROM releases');
+ $rows = $pdo->queryExec('SELECT id, guid, name, searchname, fromname FROM releases');
if ($rows !== false && $rows->rowCount()) {
$sphinx = new \SphinxSearch();
diff --git a/lib/copy_this/www/lib/SphinxSearch.php b/lib/copy_this/www/lib/SphinxSearch.php
index 9e2e440dc..895e1cecd 100644
--- a/lib/copy_this/www/lib/SphinxSearch.php
+++ b/lib/copy_this/www/lib/SphinxSearch.php
@@ -40,17 +40,17 @@ class SphinxSearch
* Insert release into Sphinx RT table.
* @param $parameters
*/
- public function insertRelease($id, $guid, $name, $searchname, $fromname)
+ public function insertRelease($parameters)
{
- if (!is_null($this->sphinxQL) && $id) {
+ if (!is_null($this->sphinxQL) && $parameters['id']) {
$this->sphinxQL->queryExec(
sprintf(
'REPLACE INTO releases_rt (id, guid, name, searchname, fromname) VALUES (%s, %s, %s, %s, %s)',
- $id,
- $guid,
- $name,
- $searchname,
- $fromname
+ $parameters['id'],
+ $parameters['guid'],
+ $parameters['name'],
+ $parameters['searchname'],
+ $parameters['fromname']
)
);
}
diff --git a/lib/copy_this/www/lib/releases.php b/lib/copy_this/www/lib/releases.php
index e889d1258..b050542bf 100644
--- a/lib/copy_this/www/lib/releases.php
+++ b/lib/copy_this/www/lib/releases.php
@@ -1628,7 +1628,25 @@ class Releases
$properName = true;
}
}
- $relid = $this->insertRelease($cleanRelName, $db->escapeString(utf8_encode($cleanedName)), $row["parts"], $row["groupID"], $relguid, $catId, $row["regexID"], $row["date"], $row["fromname"], $row["reqID"], $page->site, Enzebe::NZB_NONE, $properName === true ? 1 : 0, $isReqID, $prehashID);
+ $relid = $this->insertRelease(
+ [
+ 'name' => $db->escapeString($cleanRelName),
+ 'searchname' => $db->escapeString(utf8_encode($cleanedName)),
+ 'totalpart' => $row["parts"],
+ 'groupID' => $row["groupID"],
+ 'guid' => $db->escapeString($row['guid']),
+ 'categoryID' => $catId,
+ 'regexID' => $row["regexID"],
+ 'postdate' => $db->escapeString($row['date']),
+ 'fromname' => $db->escapeString($row['fromname']),
+ 'reqid' => $row["reqID"],
+ 'passwordstatus' => ($page->site->checkpasswordedrar > 0 ? -1 : 0),
+ 'nzbstatus' => \Enzebe::NZB_NONE,
+ 'isrenamed' => ($properName === true ? 1 : 0),
+ 'reqidstatus' => ($isReqID === true ? 1 : 0),
+ 'preid' => ($prehashID === false ? 0 : $prehashID)
+ ]
+ );
//
// Tag every binary for this release with its parent release id
//
@@ -1914,31 +1932,41 @@ class Releases
return $relname;
}
- public function insertRelease($cleanRelName, $cleanedName, $parts, $group, $guid, $catId, $regexID, $date, $fromname, $reqID, $site, $nzbstatus, $isrenamed, $isReqID, $prehashID)
+ public function insertRelease(array $parameters = [])
{
$db = new DB();
$sphinxSearch = new SphinxSearch();
- if ($regexID == "")
- $regexID = " null ";
+ if ($parameters['regexID'] == "")
+ $parameters['regexID'] = " null ";
- if ($reqID != "")
- $reqID = $db->escapeString($reqID);
+ if ($parameters['reqID'] != "")
+ $parameters['reqID'] = $db->escapeString('reqID');
else
- $reqID = " null ";
+ $parameters['reqID'] = " null ";
- $sql = sprintf("insert into releases (name, searchname, totalpart, groupID, adddate, guid, categoryID, regexID, rageID, postdate, fromname, size, reqID, passwordstatus, completion, haspreview, nfostatus, nzbstatus,
+ $parameters['id'] = $db->queryInsert(sprintf("insert into releases (name, searchname, totalpart, groupID, adddate, guid, categoryID, regexID, rageID, postdate, fromname, size, reqID, passwordstatus, completion, haspreview, nfostatus, nzbstatus,
isrenamed, iscategorized, reqidstatus, prehashID)
- values (%s, %s, %d, %d, now(), %s, %d, %s, -1, %s, %s, 0, %s, %d, 100, %d, %d, %d, %d, 1, %d, %d)",
- $db->escapeString($cleanRelName), $cleanedName, $parts, $group, $db->escapeString($guid), $catId, $regexID,
- $db->escapeString($date), $db->escapeString($fromname), $reqID, ($site->checkpasswordedrar > 0 ? -1 : 0), -1, -1,
- $db->escapeString($nzbstatus), $db->escapeString($isrenamed), $db->escapeString($isReqID), $db->escapeString($prehashID)
- );
+ values (%s, %s, %d, %d, now(), %s, %d, %s, -1, %s, %s, 0, %s, %d, 100,-1, -1, %d, %d, 1, %d, %d)",
+ $parameters['name'],
+ $parameters['searchname'],
+ $parameters['totalpart'],
+ $parameters['groupID'],
+ $parameters['guid'],
+ $parameters['categoryID'],
+ $parameters['regexID'],
+ $parameters['postdate'],
+ $parameters['fromname'],
+ $parameters['reqID'],
+ $parameters['passwordstatus'],
+ $parameters['nzbstatus'],
+ $parameters['isrenamed'],
+ $parameters['reqidstatus'],
+ $parameters['prehashID']
+ ));
- $relid = $db->queryInsert($sql);
- $sphinxSearch->insertRelease($relid, $guid, $cleanRelName, $cleanedName, $fromname);
-
- return $relid;
+ $sphinxSearch->insertRelease($parameters);
+ return $parameters['id'];
}
/**
diff --git a/lib/copy_this/www/pages/search.php b/lib/copy_this/www/pages/search.php
new file mode 100644
index 000000000..cdd4e6e4e
--- /dev/null
+++ b/lib/copy_this/www/pages/search.php
@@ -0,0 +1,244 @@
+isLoggedIn()) {
+ $page->show403();
+}
+
+$grp = new Groups();
+$releases = new Releases();
+$c = new Category();
+
+$page->meta_title = "Search Nzbs";
+$page->meta_keywords = "search,nzb,description,details";
+$page->meta_description = "Search for Nzbs";
+
+$results = array();
+$searchtype = "basic";
+$searchStr = "";
+
+if (isset($_REQUEST["search_type"]) && $_REQUEST["search_type"] == "adv") {
+ $searchtype = "advanced";
+}
+
+if (isset($_REQUEST["id"]) && !isset($_REQUEST["searchadvr"]) && !isset($_REQUEST["subject"])) {
+ $offset = (isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset'])) ? $_REQUEST["offset"] : 0;
+ $ordering = $releases->getBrowseOrdering();
+ $orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
+
+ if ($searchtype == "basic") {
+ $searchStr = (string) $_REQUEST["id"];
+ $categoryId = array();
+ if (isset($_REQUEST["t"])) {
+ $categoryId = explode(",", $_REQUEST["t"]);
+ } else {
+ $categoryId[] = -1;
+ }
+
+ foreach ($ordering as $ordertype) {
+ $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/search/" . htmlentities($searchStr) . "?t=" . (implode(',', $categoryId)) . "&ob=" . $ordertype);
+ }
+
+ $page->smarty->assign('category', $categoryId);
+ $page->smarty->assign('pagerquerybase', WWW_TOP . "/search/" . htmlentities($searchStr) . "?t=" . (implode(',', $categoryId)) . "&ob=" . $orderby . "&offset=");
+ $page->smarty->assign('search', $searchStr);
+ if (isset ($_REQUEST['subject'])) {
+ $page->smarty->assign('subject', $_REQUEST['subject']);
+ }
+ $results = $releases->search($searchStr, -1, -1, -1, $categoryId, -1, -1, 0, 0, -1, -1, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"]);
+ }
+
+ $page->smarty->assign('lastvisit', $page->userdata['lastlogin']);
+ if (sizeof($results) > 0) {
+ $totalRows = $results[0]['_totalrows'];
+ } else {
+ $totalRows = 0;
+ }
+
+ $page->smarty->assign('pagertotalitems', $totalRows);
+ $page->smarty->assign('pageroffset', $offset);
+ $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
+ $page->smarty->assign('pagerquerysuffix', "#results");
+
+ $pager = $page->smarty->fetch("pager.tpl");
+ $page->smarty->assign('pager', $pager);
+}
+
+if (isset($_REQUEST["subject"]) && !isset($_REQUEST["searchadvr"]) && !isset($_REQUEST["id"])) {
+ $offset = (isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset'])) ? $_REQUEST["offset"] : 0;
+ $ordering = $releases->getBrowseOrdering();
+ $orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
+
+ if ($searchtype == "basic") {
+ $searchStr = (string) $_REQUEST["subject"];
+
+ $categoryId = array();
+ if (isset($_REQUEST["t"])) {
+ $categoryId = explode(",", $_REQUEST["t"]);
+ } else {
+ $categoryId[] = -1;
+ }
+
+ foreach ($ordering as $ordertype) {
+ $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/search/" . htmlentities($searchStr) . "?t=" . (implode(',', $categoryId)) . "&ob=" . $ordertype);
+ }
+
+ $page->smarty->assign('category', $categoryId);
+ $page->smarty->assign('pagerquerybase', WWW_TOP . "/search/" . htmlentities($searchStr) . "?t=" . (implode(',', $categoryId)) . "&ob=" . $orderby . "&offset=");
+ $page->smarty->assign('subject', $searchStr);
+ $results = $releases->search($searchStr, -1, -1, -1, $categoryId, -1, -1, 0, 0, -1, -1, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"]);
+ }
+
+ $page->smarty->assign('lastvisit', $page->userdata['lastlogin']);
+ if (sizeof($results) > 0) {
+ $totalRows = $results[0]['_totalrows'];
+ } else {
+ $totalRows = 0;
+ }
+
+ $page->smarty->assign('pagertotalitems', $totalRows);
+ $page->smarty->assign('pageroffset', $offset);
+ $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
+ $page->smarty->assign('pagerquerysuffix', "#results");
+
+ $pager = $page->smarty->fetch("pager.tpl");
+ $page->smarty->assign('pager', $pager);
+}
+
+if (isset($_REQUEST["searchadvr"]) && !isset($_REQUEST["id"]) && !isset($_REQUEST["subject"])) {
+ $offset = (isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset'])) ? $_REQUEST["offset"] : 0;
+ $ordering = $releases->getBrowseOrdering();
+ $orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
+
+ if ($searchtype !== "basic") {
+
+ $searchSearchName = (string) $_REQUEST["searchadvr"];
+ $searchUsenetName = (string) $_REQUEST["searchadvsubject"];
+ $searchPoster = (string) $_REQUEST["searchadvposter"];
+ $searchdaysnew = (string) $_REQUEST["searchadvdaysnew"];
+ $searchdaysold = (string) $_REQUEST["searchadvdaysold"];
+ $searchGroups = (string) $_REQUEST["searchadvgroups"];
+ $searchCat = (string) $_REQUEST["searchadvcat"];
+ $searchSizeFrom = (string) $_REQUEST["searchadvsizefrom"];
+ $searchSizeTo = (string) $_REQUEST["searchadvsizeto"];
+ $searchHasNFO = (string) $_REQUEST["searchadvhasnfo"];
+ $searchHascomments = (string) $_REQUEST["searchadvhascomments"];
+
+ $page->smarty->assign('searchadvr', $searchSearchName);
+ $page->smarty->assign('searchadvsubject', $searchUsenetName);
+ $page->smarty->assign('searchadvposter', $searchPoster);
+ $page->smarty->assign('searchadvdaysnew', $searchdaysnew);
+ $page->smarty->assign('searchadvdaysold', $searchdaysold);
+ $page->smarty->assign('selectedgroup', $searchGroups);
+ $page->smarty->assign('selectedcat', $searchCat);
+ $page->smarty->assign('selectedsizefrom', $searchSizeFrom);
+ $page->smarty->assign('selectedsizeto', $searchSizeTo);
+ $page->smarty->assign('searchadvhasnfo', $searchHasNFO);
+ $page->smarty->assign('searchadvhascomments', $searchHascomments);
+ foreach ($ordering as $ordertype) {
+ $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/search?searchadvr=" . htmlentities($searchSearchName) . "&searchadvsubject=" . htmlentities($searchUsenetName) . "&searchadvposter=" . htmlentities($searchPoster) . "&searchadvdaysnew=" . htmlentities($searchdaysnew) . "&searchadvdaysold=" . htmlentities($searchdaysold) . "&searchadvgroups=" . htmlentities($searchGroups) . "&searchadvcat=" . htmlentities($searchCat) . "&searchadvsizefrom=" . htmlentities($searchSizeFrom) . "&searchadvsizeto=" . htmlentities($searchSizeTo) . "&searchadvhasnfo=" . htmlentities($searchHasNFO) . "&searchadvhascomments=" . htmlentities($searchHascomments) . "&search_type=adv" . "&ob=" . $ordertype);
+ }
+
+ $page->smarty->assign('pagerquerybase', WWW_TOP . "/search?searchadvr=" . htmlentities($searchSearchName) . "&searchadvsubject=" . htmlentities($searchUsenetName) . "&searchadvposter=" . htmlentities($searchPoster) . "&searchadvdaysnew=" . htmlentities($searchdaysnew) . "&searchadvdaysold=" . htmlentities($searchdaysold) . "&searchadvgroups=" . htmlentities($searchGroups) . "&searchadvcat=" . htmlentities($searchCat) . "&searchadvsizefrom=" . htmlentities($searchSizeFrom) . "&searchadvsizeto=" . htmlentities($searchSizeTo) . "&searchadvhasnfo=" . htmlentities($searchHasNFO) . "&searchadvhascomments=" . htmlentities($searchHascomments) . "&search_type=adv" . "&ob=" . $orderby . "&offset=");
+ if ($_REQUEST["searchadvr"] == "") {
+ $searchSearchName = -1;
+ }
+ if ($_REQUEST["searchadvsubject"] == "") {
+ $searchUsenetName = -1;
+ }
+ if ($_REQUEST["searchadvposter"] == "") {
+ $searchPoster = -1;
+ }
+ if ($_REQUEST["searchadvdaysnew"] == "") {
+ $searchdaysnew = -1;
+ }
+ if ($_REQUEST["searchadvdaysold"] == "") {
+ $searchdaysold = -1;
+ }
+ if ($_REQUEST["searchadvcat"] == "") {
+ $searchCat = -1;
+ }
+ $results = $releases->search($searchSearchName, $searchUsenetName, $searchPoster, $searchGroups, [$searchCat], $searchSizeFrom, $searchSizeTo, $searchHasNFO, $searchHascomments, $searchdaysnew, $searchdaysold, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"], "advanced");
+ }
+
+ $page->smarty->assign('lastvisit', $page->userdata['lastlogin']);
+ if (sizeof($results) > 0) {
+ $totalRows = $results[0]['_totalrows'];
+ } else {
+ $totalRows = 0;
+ }
+
+ $page->smarty->assign('pagertotalitems', $totalRows);
+ $page->smarty->assign('pageroffset', $offset);
+ $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
+ $page->smarty->assign('pagerquerysuffix', "#results");
+
+ $pager = $page->smarty->fetch("pager.tpl");
+ $page->smarty->assign('pager', $pager);
+}
+
+$grouplist = $grp->getGroupsForSelect();
+$page->smarty->assign('grouplist', $grouplist);
+
+$catlist = $c->getForSelect();
+$page->smarty->assign('catlist', $catlist);
+
+$sizelist = array(-1 => '--Select--',
+ 1 => '100MB',
+ 2 => '250MB',
+ 3 => '500MB',
+ 4 => '1GB',
+ 5 => '2GB',
+ 6 => '3GB',
+ 7 => '4GB',
+ 8 => '8GB',
+ 9 => '16GB',
+ 10 => '32GB',
+ 11 => '64GB'
+);
+
+$page->smarty->assign('sizelist', $sizelist);
+$page->smarty->assign('results', $results);
+$page->smarty->assign('sadvanced', ($searchtype != "basic"));
+
+$ft1 = $db->checkIndex('releases', 'ix_releases_name_searchname_ft');
+$ft2 = $db->checkIndex('releases', 'ix_releases_name_ft');
+$ft3 = $db->checkIndex('releases', 'ix_releases_searchname_ft');
+switch (NN_RELEASE_SEARCH_TYPE) {
+ case ReleaseSearch::FULLTEXT:
+ $search_description =
+'MySQL Full Text Search Rules:
+A leading exclamation point(! in place of +) indicates that this word must be present in each row that is returned.
+A leading minus sign indicates that this word must not be present in any of the rows that are returned.
+By default (when neither + nor - is specified) the word is optional, but the rows that contain it are rated higher.
+See docs for more operators.';
+ break;
+ case ReleaseSearch::LIKE:
+ $search_description = 'Include ^ to indicate search must start with term, -- to exclude words.';
+ break;
+ case ReleaseSearch::SPHINX:
+ default:
+ $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.
';
+ break;
+}
+$page->smarty->assign('search_description', $search_description);
+
+
+$page->content = $page->smarty->fetch('search.tpl');
+$page->render();
\ No newline at end of file