diff --git a/README.md b/README.md index 39d7af03e..6a9b69492 100755 --- a/README.md +++ b/README.md @@ -1,23 +1,31 @@ I have forked jonnyboys newznab-tmux as he and the dev team have moved to another project (https://github.com/nZEDb/nZEDb). I will try as much as i can to maintain and improve these tmux scripts, where possible and needed, as they are a valuable addendum to newznab+. Support is given on irc.synirc.net #tmux channel. -I started adapting some of more interesting scripts from nZEDb, but they require tempering with newznab database, so use them at your own risk. Any update to nn+ db could render them useless. Scripts require PHP version => 5.5 and Python 2.7x or newer. +I started adapting some of more interesting scripts from nZEDb, but they require tempering with newznab database, so use them at your own risk. By using newznab-tmux you will render your indexer incompatible with newznab (you can revert changes by forcing the svn checkout, it will replace the changed files. Newznab is not aware of the changes in database, so you are safe to leave them as they are). Scripts require PHP version >= 5.5.x and Python 2.7x or newer. -Now, clone my github. These scripts need to run from this location and this is where I was asked to put them. If you have decided to use an alternate location, you will need to edit the file bin/config.php to point to the file newznab/www/config.php. If you do not, these scripts will not run. +# Steps to have a working tmux install: - cd /var/www/newznab/misc/update_scripts/nix_scripts/ - git clone https://github.com/DariusIII/newznab-tmux.git tmux - cd tmux + CD to the root of your newznab install, ie. cd /var/www/newznab + Next steps are very important: + + git init + git remote add origin https://github.com/DariusIII/newznab-tmux.git + git fetch + git reset --hard origin/your_wanted_branch, ie. git reset --hard origin/master + git checkout -t origin/your_wanted_branch, ie. git checkout -t origin/master -There is a lib folder in main tmux folder. In that folder you will find two folders, /DB/ and /copy_this/. if you are setting up tmux for the first time, import db.sql using cli (mysql -u {┤your username} -p newznab < db.sql). + There is a lib folder in main tmux folder. In that folder you will find DB folder. If you are setting up tmux for the first time, import db.sql using cli (mysql -u {┤your username} -p newznab < db.sql). + After importing db.sql you need to run the patchDB.php from same folder. After the last patch is applied, you need to manualy apply the next patch labeled XXXX~settings.sql (XXXX is a patch number that is different on dev/master(0122) and regexless branch(0149)). + When you have manualy applied that patch, you can use the new database updater located in /path/to/newznab/cli/ and run update_db.php true and it will apply the rest of the patches (if they exist). + After these steps, patchDB is unusable anymore and you need to use the new update_db.php script in cli folder. -1. Copy files from /lib/copy_this/www folder into your newznab installation folder. I have created the nntmux theme where all the settings are available. + You need to chmod to 777 following folders now: + resources/* + libs/smarty/templates_c + nzbfiles/ -2. Copy files from /lib/copy_this/misc folder into your newznab installation folder. - -3. Most of the scripts are now threaded. - -4. All the required folders are created when you copy files from copy_this folder. + You need to add an alias to your apache/nginx conf of your indexer: + Alias /covers /path/to/newznab/resources/covers # yEnc: @@ -37,7 +45,7 @@ There is a lib folder in main tmux folder. In that folder you will find two fold cd ~/ rm -rf simple_php_yenc_decode/ - yydecode + yydecode: cd ~/ mkdir -p yydecode @@ -65,14 +73,14 @@ There is a lib folder in main tmux folder. In that folder you will find two fold # Alternate NNTP provider: - Newznab-tmux has added support for dual NNTP providers, you need to edit the provided config.php in lib/copy_this/config_edit_before_copy folder + Newznab-tmux has added support for dual NNTP providers, you need to edit the provided config.php.example in www folder. # Sphinx support: - Newznab-tmux now comes with its own Sphinx support, ported from nZEDb. Installation readme is in misc/sphinxsearch folder, and in copy_this/misc/sphinxsearch folder + Newznab-tmux now comes with its own Sphinx support, ported from nZEDb. Installation readme is in misc/sphinxsearch folder. This version of tmux has many core newznab files modified, use at your own risk. -Tmux is started with start.php (php start.php command). Scripts not used anymore are still available for your use, but you need to run them manualy. +Tmux is started by following command in cli, from tmux folder: php tmux-ui.php start. Tmux can be gracefuly stopped in similar manner php tmux-ui.php stop. diff --git a/newznab/build/newznab.xml b/newznab/build/newznab.xml index 1af5b4afd..2263d4d48 100644 --- a/newznab/build/newznab.xml +++ b/newznab/build/newznab.xml @@ -2,8 +2,8 @@ - 152 - 152 + 155 + 155 0.4.1 diff --git a/newznab/controllers/Backfill.php b/newznab/controllers/Backfill.php index 3ba6d6656..5a5172d78 100644 --- a/newznab/controllers/Backfill.php +++ b/newznab/controllers/Backfill.php @@ -77,6 +77,12 @@ class Backfill */ protected $_safePartRepair; + /** + * Should we disable the group if we have backfilled far enough? + * @var bool + */ + protected $_disableBackfillGroup; + /** * Constructor. * @@ -116,6 +122,7 @@ class Backfill $this->_safeBackFillDate = ($this->pdo->getSetting('safebackfilldate') != '') ? (string)$this->pdo->getSetting('safebackfilldate') : '2008-08-14'; $this->_safePartRepair = ($this->pdo->getSetting('safepartrepair') == 1 ? 'update' : 'backfill'); $this->_tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 1 ? true : false); + $this->_disableBackfillGroup = ($this->pdo->getSetting('disablebackfillgroup') == 1 ? true : false); } /** @@ -270,11 +277,23 @@ class Backfill $dMessage = "We have hit the maximum we can backfill for " . $groupName . - ", skipping it, consider disabling backfill on it."; + ($this->_disableBackfillGroup ? ", disabling backfill on it." : + ", skipping it, consider disabling backfill on it."); if ($this->_debug) { $this->_debugging->log('Backfill', "backfillGroup", $dMessage, \Logger::LOG_NOTICE); } + if ($this->_disableBackfillGroup) { + $this->pdo->queryExec( + sprintf(' + UPDATE groups + SET backfill = 0 + WHERE id = %d', + $groupArr['id'] + ) + ); + } + if ($this->_echoCLI) { $this->pdo->log->doEcho($this->pdo->log->notice($dMessage), true); } diff --git a/newznab/controllers/Releases.php b/newznab/controllers/Releases.php index 631a5eeb9..0373c7c79 100644 --- a/newznab/controllers/Releases.php +++ b/newznab/controllers/Releases.php @@ -909,7 +909,6 @@ class Releases * @param string $usenetName * @param string $posterName * @param string $groupName - * @param array $cat * @param int $sizeFrom * @param int $sizeTo * @param int $hasNfo @@ -920,18 +919,32 @@ class Releases * @param int $limit * @param string $orderBy * @param int $maxAge - * @param array $excludedCats + * @param integer[] $excludedCats * @param string $type + * @param array $cat * * @return array */ public function search( - $searchName, $usenetName, $posterName, $groupName, $cat = [-1], $sizeFrom, - $sizeTo, $hasNfo, $hasComments, $daysNew, $daysOld, $offset = 0, $limit = 1000, - $orderBy = '', $maxAge = -1, $excludedCats = [], $type = 'basic' - ) - { - $sizeRange = array( + $searchName, + $usenetName, + $posterName, + $groupName, + $sizeFrom, + $sizeTo, + $hasNfo, + $hasComments, + $daysNew, + $daysOld, + $offset = 0, + $limit = 1000, + $orderBy = '', + $maxAge = -1, + $excludedCats = [], + $type = 'basic', + $cat = [-1] + ) { + $sizeRange = [ 1 => 1, 2 => 2.5, 3 => 5, @@ -943,7 +956,7 @@ class Releases 9 => 160, 10 => 320, 11 => 640, - ); + ]; if ($orderBy == '') { $orderBy = []; diff --git a/newznab/controllers/Users.php b/newznab/controllers/Users.php index cbfe4a4d6..73b3a53af 100644 --- a/newznab/controllers/Users.php +++ b/newznab/controllers/Users.php @@ -18,6 +18,7 @@ class Users const ROLE_USER = 1; const ROLE_ADMIN = 2; const ROLE_DISABLED = 3; + const ROLE_MODERATOR = 4; const DEFAULT_INVITES = 1; const DEFAULT_INVITE_EXPIRY_DAYS = 7; @@ -434,9 +435,7 @@ class Users public function isDisabled($username) { - $role = $this->pdo->queryOneRow(sprintf("select role as role from users where username = %s ", $this->pdo->escapeString($username))); - - return ($role["role"] == Users::ROLE_DISABLED); + return $this->roleCheck(self::ROLE_DISABLED, $username); } public function isValidUrl($url) @@ -995,4 +994,53 @@ class Users { return $this->pdo->queryInsert(sprintf("delete from userdownloads where releaseid = %d", $releaseID)); } + + /** + * Checks if a user is a specific role. + * + * @notes Uses type of $user to denote identifier. if string: username, if int: userid + * @param int $roleID + * @param string|int $user + * @return bool + */ + public function roleCheck($roleID, $user) { + + if (is_string($user) && strlen($user) > 0) { + $user = $this->pdo->escapeString($user); + $querySuffix = "username = '$user'"; + } elseif (is_int($user) && $user >= 0) { + $querySuffix = "id = $user"; + } else { + return false; + } + + $result = $this->pdo->queryOneRow( + sprintf( + "SELECT role FROM users WHERE %s", + $querySuffix + ) + ); + + return ((integer)$result['role'] == (integer) $roleID) ? true : false; + } + + /** + * Wrapper for roleCheck specifically for Admins. + * + * @param int $userID + * @return bool + */ + public function isAdmin($userID) { + return $this->roleCheck(self::ROLE_ADMIN, (integer) $userID); + } + + /** + * Wrapper for roleCheck specifically for Moderators. + * + * @param int $userId + * @return bool + */ + public function isModerator($userId) { + return $this->roleCheck(self::ROLE_MODERATOR, (integer) $userId); + } } \ No newline at end of file diff --git a/resources/db/patches/0153~settings.sql b/resources/db/patches/0153~settings.sql new file mode 100644 index 000000000..86fe9c1df --- /dev/null +++ b/resources/db/patches/0153~settings.sql @@ -0,0 +1,6 @@ +INSERT IGNORE INTO settings (name, value, hint, setting) +VALUES ( + 'disablebackfillgroup', 0, + 'Whether to disable backfill on a group if the target date has been reached.', + 'disablebackfillgroup' +); \ No newline at end of file diff --git a/resources/db/patches/0154~settings.sql b/resources/db/patches/0154~settings.sql new file mode 100644 index 000000000..a05edfd59 --- /dev/null +++ b/resources/db/patches/0154~settings.sql @@ -0,0 +1 @@ +INSERT INTO settings (section, subsection, name, value, hint, setting) VALUES ('', '', 'privateprofiles', 1, 'Hide profiles from other users (admin/mod can still access).', 'privateprofiles'); \ No newline at end of file diff --git a/resources/db/patches/0155~settings.sql b/resources/db/patches/0155~settings.sql new file mode 100644 index 000000000..4bd4f1750 --- /dev/null +++ b/resources/db/patches/0155~settings.sql @@ -0,0 +1,9 @@ +INSERT IGNORE INTO settings (name, value, hint, setting) +VALUES ( + 'processthumbnails', 0, + 'Whether to attempt to process a video thumbnail image. You must have ffmpeg for this.', + 'processthumbnails' +); + +UPDATE settings SET value = 1 +WHERE setting = 'processthumbnails' AND (SELECT * FROM (SELECT value FROM settings WHERE setting = 'ffmpegpath') s) != ''; \ No newline at end of file diff --git a/www/admin/release-files.php b/www/admin/release-files.php index ed0e72caa..e5e136ee5 100644 --- a/www/admin/release-files.php +++ b/www/admin/release-files.php @@ -16,7 +16,7 @@ if (isset($_GET["id"])) if (!$rel) $page->show404(); - $nzbpath = $nzb->getNZBPath($_GET["id"], $page->site->nzbpath); + $nzbpath = $nzb->getNZBPath($_GET["id"], $page->settings->getSetting('nzbpath')); if (!file_exists($nzbpath)) $page->show404(); diff --git a/www/admin/site-debug.php b/www/admin/site-debug.php index d4af956d7..4f6a2b278 100644 --- a/www/admin/site-debug.php +++ b/www/admin/site-debug.php @@ -4,7 +4,7 @@ require_once './config.php'; $page = new AdminPage(); -$s = $page->site; +$s = $page->settings; unset($s->siteseed); unset($s->amazonprivkey); unset($s->tmdbkey); diff --git a/www/pages/details.php b/www/pages/details.php index c3a05e76f..bcdc849ea 100644 --- a/www/pages/details.php +++ b/www/pages/details.php @@ -180,6 +180,7 @@ if (isset($_GET["id"])) $page->smarty->assign('prehash', $pre); $page->smarty->assign('comments',$comments); $page->smarty->assign('searchname',$releases->getSimilarName($data['searchname'])); + $page->smarty->assign('privateprofiles', ($page->settings->getSetting('privateprofiles') == 1) ? true : false ); $page->meta_title = "View NZB"; $page->meta_keywords = "view,nzb,description,details"; diff --git a/www/pages/forum.php b/www/pages/forum.php index 035464b0b..d106e3fd0 100644 --- a/www/pages/forum.php +++ b/www/pages/forum.php @@ -28,6 +28,7 @@ $page->smarty->assign('pageroffset',$offset); $page->smarty->assign('pageritemsperpage',ITEMS_PER_PAGE); $page->smarty->assign('pagerquerybase', WWW_TOP."/forum?offset="); $page->smarty->assign('pagerquerysuffix', "#results"); +$page->smarty->assign('privateprofiles', ($page->settings->getSetting('privateprofiles') == 1) ? true : false ); $pager = $page->smarty->fetch("pager.tpl"); $page->smarty->assign('pager', $pager); diff --git a/www/pages/forumpost.php b/www/pages/forumpost.php index 1030da5d4..729123cea 100644 --- a/www/pages/forumpost.php +++ b/www/pages/forumpost.php @@ -25,6 +25,7 @@ $page->meta_keywords = "view,forum,post,thread"; $page->meta_description = "View forum post"; $page->smarty->assign('results', $results); +$page->smarty->assign('privateprofiles', ($page->settings->getSetting('privateprofiles') == 1) ? true : false ); $page->content = $page->smarty->fetch('forumpost.tpl'); $page->render(); diff --git a/www/pages/profile.php b/www/pages/profile.php index 3f1cb512a..6c527c3e9 100644 --- a/www/pages/profile.php +++ b/www/pages/profile.php @@ -19,6 +19,29 @@ elseif (isset($_GET["name"])) else $userid = $users->currentUserId(); +$privileged = ($users->isAdmin($userid) || $users->isModerator($userid)) ? true : false; +$privateProfiles = ($page->settings->getSetting('privateprofiles') == 1) ? true : false; +$publicView = false; + +if (!$privateProfiles || $privileged) { + + $altID = (isset($_GET['id']) && $_GET['id'] >= 0) ? (int) $_GET['id'] : false; + $altUsername = (isset($_GET['name']) && strlen($_GET['name']) > 0) ? $_GET['name'] : false; + + // If both 'id' and 'name' are specified, 'id' should take precedence. + if ($altID === false && $altUsername !== false) { + $user = $users->getByUsername($altUsername); + if ($user) { + $altID = $user['id']; + } + } else if ($altID !== false) { + $userid = $altID; + $publicView = true; + } +} + + + $data = $users->getById($userid); if (!$data) $page->show404(); @@ -31,6 +54,9 @@ $page->smarty->assign('apihits', $users->getApiRequests($userid)); $page->smarty->assign('grabstoday', $users->getDownloadRequests($userid)); $page->smarty->assign('userinvitedby',$invitedby); $page->smarty->assign('user',$data); +$page->smarty->assign('privateprofiles', $privateProfiles); +$page->smarty->assign('publicview', $publicView); +$page->smarty->assign('privileged', $privileged); $commentcount = $rc->getCommentCountForUser($userid); $offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0; @@ -39,6 +65,7 @@ $page->smarty->assign('pageroffset',$offset); $page->smarty->assign('pageritemsperpage',ITEMS_PER_PAGE); $page->smarty->assign('pagerquerybase', "/profile?id=".$userid."&offset="); $page->smarty->assign('pagerquerysuffix', "#comments"); +$page->smarty->assign('privateprofiles', ($page->settings->getSetting('privateprofiles') == 1) ? true : false ); $pager = $page->smarty->fetch("pager.tpl"); $page->smarty->assign('pager', $pager); diff --git a/www/pages/search.php b/www/pages/search.php index 0c4f7dc32..f99cd9386 100644 --- a/www/pages/search.php +++ b/www/pages/search.php @@ -1,205 +1,137 @@ isLoggedIn()) { +if (!$page->users->isLoggedIn()) { $page->show403(); } -$grp = new Groups(); -$releases = new Releases(); -$c = new Category(); +$groups = new Groups(['Settings' => $page->settings]); +$releases = new Releases(['Groups' => $groups, 'Settings' => $page->settings]); -$page->meta_title = "Search Nzbs"; -$page->meta_keywords = "search,nzb,description,details"; +$page->meta_title = "Search Nzbs"; +$page->meta_keywords = "search,nzb,description,details"; $page->meta_description = "Search for Nzbs"; -$results = array(); -$searchtype = "basic"; -$searchStr = ""; +$results = []; +$searchType = "basic"; if (isset($_REQUEST["search_type"]) && $_REQUEST["search_type"] == "adv") { - $searchtype = "advanced"; + $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"] : ''; +$ordering = $releases->getBrowseOrdering(); +$orderBy = (isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : ''); +$offset = (isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset'])) ? $_REQUEST["offset"] : 0; - 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( + [ + 'subject' => '', 'search' => '', 'category' => [0], 'pagertotalitems' => 0, + 'pageritemsperpage' => 1, 'pageroffset' => 1, 'covgroup' => '' + ] ); -$page->smarty->assign('sizelist', $sizelist); -$page->smarty->assign('results', $results); -$page->smarty->assign('sadvanced', ($searchtype != "basic")); +if ((isset($_REQUEST["id"]) || isset($_REQUEST["subject"])) && !isset($_REQUEST["searchadvr"]) && $searchType == "basic") { + + $searchString = ''; + switch (true) { + case isset($_REQUEST["subject"]): + $searchString = (string) $_REQUEST["subject"]; + $page->smarty->assign('subject', $searchString); + break; + case isset($_REQUEST["id"]): + $searchString =(string) $_REQUEST["id"]; + $page->smarty->assign('search', $searchString); + break; + } + + $categoryID[] = -1; + if (isset($_REQUEST['t'])) { + $categoryID = explode(',', $_REQUEST['t']); + } + foreach ($releases->getBrowseOrdering() as $orderType) { + $page->smarty->assign( + "orderby$orderType", + WWW_TOP . '/search/' . htmlentities($searchString) . '?t=' . (implode(',', $categoryID)) . "&ob=$orderType" + ); + } + + $results = $releases->search( + $searchString, -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, 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' => ITEMS_PER_PAGE, + 'pagerquerysuffix' => "#results", + 'pagerquerybase' => + WWW_TOP . "/search/" . htmlentities($searchString) . "?t=" . + (implode(',', $categoryID)) . "&ob=$orderBy&offset=", + 'category' => $categoryID + ] + ); + +} + +$searchVars = [ + 'searchadvr' => '', 'searchadvsubject' => '', 'searchadvposter' => '', + 'searchadvdaysnew' => '', 'searchadvdaysold' => '', 'searchadvgroups' => '', + 'searchadvcat' => '', 'searchadvsizefrom' => '', 'searchadvsizeto' => '', + 'searchadvhasnfo' => '', 'searchadvhascomments' => '' +]; + +foreach($searchVars as $searchVarKey => $searchVar) { + $searchVars[$searchVarKey] = (isset($_REQUEST[$searchVarKey]) ? (string) $_REQUEST[$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 (isset($_REQUEST["searchadvr"]) && !isset($_REQUEST["id"]) && !isset($_REQUEST["subject"]) && $searchType != "basic") { + + $orderByString = ''; + foreach ($searchVars as $searchVarKey => $searchVar) { + $orderByString .= "&$searchVarKey=" . htmlentities($searchVar); + } + $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['searchadvgroups'], $searchVars['searchadvsizefrom'], $searchVars['searchadvsizeto'], + $searchVars['searchadvhasnfo'], $searchVars['searchadvhascomments'], + ($searchVars['searchadvdaysnew'] == '' ? -1 : $searchVars['searchadvdaysnew']), + ($searchVars['searchadvdaysold'] == '' ? -1 : $searchVars['searchadvdaysold']), + $offset, 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' => ITEMS_PER_PAGE, + 'pagerquerysuffix' => "#results", + 'pagerquerybase' => WWW_TOP . "/search?$orderByString&search_type=adv&ob=$orderBy&offset=" + ] + ); +} $ft1 = $page->settings->checkIndex('releases', 'ix_releases_name_searchname_ft'); $ft2 = $page->settings->checkIndex('releases', 'ix_releases_name_ft'); @@ -207,7 +139,7 @@ $ft3 = $page->settings->checkIndex('releases', 'ix_releases_searchname_ft'); switch (NN_RELEASE_SEARCH_TYPE) { case ReleaseSearch::FULLTEXT: $search_description = -'MySQL Full Text Search Rules:
+ '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.
@@ -219,7 +151,7 @@ See + '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.
@@ -235,8 +167,20 @@ 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->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' => $groups->getGroupsForSelect(), + 'catlist' => (new Category(['Settings' => $page->settings]))->getForSelect(), + 'search_description' => $search_description, + 'pager' => $page->smarty->fetch("pager.tpl") + ] +); $page->content = $page->smarty->fetch('search.tpl'); $page->render(); \ No newline at end of file diff --git a/www/templates/nntmux/views/admin/site-edit.tpl b/www/templates/nntmux/views/admin/site-edit.tpl index 3380a74ff..ebe94ad01 100644 --- a/www/templates/nntmux/views/admin/site-edit.tpl +++ b/www/templates/nntmux/views/admin/site-edit.tpl @@ -662,6 +662,15 @@ + + + + {html_radios id="disablebackfillgroup" name='disablebackfillgroup' values=$yesno_ids output=$yesno_names selected=$fsite->disablebackfillgroup separator='
'} +
Whether to disable a group automatically during backfill if the target date has been reached.
+ + + + @@ -1610,6 +1619,15 @@ + + + + + {html_radios id="privateprofiles" name='privateprofiles' values=$yesno_ids output=$yesno_names selected=$fsite->privateprofiles separator='
'} +
Should we disallow users from accessing profiles other than their own? (regardless of this setting admin/mod can access).
+ + + : diff --git a/www/templates/nntmux/views/frontend/forum.tpl b/www/templates/nntmux/views/frontend/forum.tpl index 57fbad568..81e8372db 100644 --- a/www/templates/nntmux/views/frontend/forum.tpl +++ b/www/templates/nntmux/views/frontend/forum.tpl @@ -25,10 +25,12 @@ {$result.message|escape:"htmlall"|truncate:200:'...':false:false} - -
{$result.username} -
- on {$result.createddate|date_format}
({$result.createddate|timeago})
+ {if !$privateprofiles || $isadmin || $ismod} + {$result.username}
+ {else} + {$result.username} + {/if} + {$result.createddate|date_format}
({$result.createddate|timeago})
{$result.updateddate|date_format}
({$result.updateddate|timeago})
diff --git a/www/templates/nntmux/views/frontend/forumpost.tpl b/www/templates/nntmux/views/frontend/forumpost.tpl index 97012692c..8382fc526 100644 --- a/www/templates/nntmux/views/frontend/forumpost.tpl +++ b/www/templates/nntmux/views/frontend/forumpost.tpl @@ -17,10 +17,11 @@ {foreach from=$results item=result name=result} - {if $result.isadmin == 1}{/if} - {$result.username} - {if $result.isadmin == 1}{/if} -
+ {if !$privateprofiles || $isadmin || $ismod} + {$result.username} + {else} + {$result.username} + {/if} on {$result.createddate|date_format}
({$result.createddate|timeago})
{if $userdata.role==2}
diff --git a/www/templates/nntmux/views/frontend/profile.tpl b/www/templates/nntmux/views/frontend/profile.tpl index 8afd37fb1..4950c917f 100644 --- a/www/templates/nntmux/views/frontend/profile.tpl +++ b/www/templates/nntmux/views/frontend/profile.tpl @@ -3,14 +3,14 @@ - {if $user.id==$userdata.id || $userdata.role==2}{/if} + {if $isadmin || !$publicview}{/if} {if $userdata.role==2}{/if} - {if $user.id==$userdata.id || $userdata.role==2}{/if} - {if $user.id==$userdata.id || $userdata.role==2} + {if $isadmin || !$publicview}{/if} + {if $isadmin || !$publicview} {/if} @@ -37,8 +37,17 @@ {/if} {if $userinvitedby && $userinvitedby.username != ""} - - {/if} + + + + {/if} - {if $user.id==$userdata.id || $userdata.role==2}{/if} - {if $page->site->sabintegrationtype == 2 && $user.id==$userdata.id} + {if $isadmin || !$publicview}{/if} + {if $page->settings->getSetting('sabintegrationtype') == 2 && $user.id==$userdata.id}
Username:{$user.username|escape:"htmlall"}
Email:{$user.email}
Email:{$user.email}
Registered:{$user.createddate|date_format} ({$user.createddate|timeago} ago)
Last Login:{$user.lastlogin|date_format} ({$user.lastlogin|timeago} ago)
Role:{$user.rolename}
Theme:{$user.style}
Notes:{$user.notes|escape:htmlall}{if $user.notes|count_characters > 0}
{/if}Add/Edit
Site Api/Rss Key:{$user.rsstoken}
Site Api/Rss Key:{$user.rsstoken}
API Hits Today:{$apihits.num} {if $userdata.role==2 && $apihits.num > 0}Reset{/if}
Grabs Today:{$grabstoday.num} {if $grabstoday.num >= $user.downloadrequests}  (Next DL in {($grabstoday.nextdl/3600)|intval}h {($grabstoday.nextdl/60) % 60}m){/if}{if $userdata.role==2 && $grabstoday.num > 0}Reset{/if}
Invited By:{$userinvitedby.username}
Invited By: + {if $privileged || !$privateprofiles} + {$userinvitedby.username} + {else} + {$userinvitedby.username} + {/if} + +
UI Preferences: @@ -50,8 +59,8 @@ {if $user.bookview == "1"}View book covers{else}View standard book category{/if}
Excluded Categories:{$exccats|replace:",":"
"}
Excluded Categories:{$exccats|replace:",":"
"}
SABnzbd Integration: Url: {if $saburl == ''}N/A{else}{$saburl}{/if}
diff --git a/www/templates/nntmux/views/frontend/profileedit.tpl b/www/templates/nntmux/views/frontend/profileedit.tpl index 5bb1ab0b3..a17269665 100644 --- a/www/templates/nntmux/views/frontend/profileedit.tpl +++ b/www/templates/nntmux/views/frontend/profileedit.tpl @@ -42,7 +42,7 @@
Site Preferences - {if $page->site->userselstyle == 1} + {if $page->settings->getSetting('userselstyle') == 1}
Site theme: @@ -113,7 +113,7 @@
- {if $page->site->sabintegrationtype != 1} + {if $page->settings->getSetting('sabintegrationtype') != 1}
Queue Type @@ -130,7 +130,7 @@
{/if} - {if $user.queuetype == 2 && ($page->site->sabintegrationtype == 0 || $page->site->sabintegrationtype == 2)} + {if $user.queuetype == 2 && ($page->settings->getSetting('sabintegrationtype') == 0 || $page->settings->getSetting('sabintegrationtype') == 2)}
NZBGet Integration @@ -164,7 +164,7 @@
{/if} - {if $user.queuetype == 1 && $page->site->sabintegrationtype == 2} + {if $user.queuetype == 1 && $page->settings->getSetting('sabintegrationtype') == 2}
SABnzbd Integration diff --git a/www/templates/nntmux/views/frontend/viewnzb.tpl b/www/templates/nntmux/views/frontend/viewnzb.tpl index da28806aa..87a521e02 100644 --- a/www/templates/nntmux/views/frontend/viewnzb.tpl +++ b/www/templates/nntmux/views/frontend/viewnzb.tpl @@ -575,14 +575,10 @@ {foreach from=$comments|@array_reverse:true item=comment} diff --git a/www/templates/nntmux/views/frontend/viewqueue.tpl b/www/templates/nntmux/views/frontend/viewqueue.tpl index f1b36cb4a..ef5c4ced2 100644 --- a/www/templates/nntmux/views/frontend/viewqueue.tpl +++ b/www/templates/nntmux/views/frontend/viewqueue.tpl @@ -1,10 +1,10 @@ {if $error == ''} -{if $page->site->sabintegrationtype > 0 || $user.queuetype == 2} +{if $page->settings->getSetting('sabintegrationtype') > 0 || $user.queuetype == 2}

The following queue is pulled from {$serverURL|escape:"htmlall"}.
- {if $page->site->sabintegrationtype == 2 || $user.queuetype == 2}Edit your queue settings in your profile.{/if} + {if $page->settings->getSetting('sabintegrationtype') == 2 || $user.queuetype == 2}Edit your queue settings in your profile.{/if}

{if $user.queuetype == 2}
- {if $comment.role == -1} - {$comment.username}{if $isadmin} @{$comment.rolename}{/if} - {elseif $comment.role == 2} - {$comment.username} - {elseif $comment.role == 4} - {$comment.username} - {else} + {if !$privateprofiles || $isadmin || $ismod} {$comment.username} + {else} + {$comment.username} {/if}
{$comment.createddate|daysago}