diff --git a/newznab/controllers/TvAnger.php b/newznab/controllers/TvAnger.php index d610ecdb7..b3098d284 100644 --- a/newznab/controllers/TvAnger.php +++ b/newznab/controllers/TvAnger.php @@ -36,11 +36,9 @@ class TvAnger 'Settings' => null, ]; $options += $defaults; - $s = new Settings(); - $this->site = $s->get(); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $this->rageqty = ($this->site->maxrageprocessed != '') ? $this->site->maxrageprocessed : 75; + $this->rageqty = ($this->pdo->getSetting('maxrageprocessed') != '') ? $this->pdo->getSetting('maxrageprocessed') : 75; $this->echooutput = ($options['Echo'] && NN_ECHOCLI); diff --git a/newznab/controllers/Users.php b/newznab/controllers/Users.php index c2d7fd4c0..da5f9feb2 100644 --- a/newznab/controllers/Users.php +++ b/newznab/controllers/Users.php @@ -46,8 +46,6 @@ class Users 'Settings' => null, ]; $options += $defaults; - $this->site= new Settings(); - $this->site = $this->site->get(); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); @@ -344,7 +342,7 @@ class Users { $data = $this->pdo->query(sprintf("select id,email from users WHERE role = %d and rolechangedate < now()", $uprole)); foreach ($data as $u) { - Utility::sendEmail($u["email"], $msgsubject, $msgbody, $this->site->email); + Utility::sendEmail($u["email"], $msgsubject, $msgbody, $this->pdo->getSetting('email')); $this->pdo->queryExec(sprintf("update users SET role = %d, rolechangedate=null WHERE id = %d", $downrole, $u["id"])); } @@ -470,8 +468,6 @@ class Users public function signup($uname, $pass, $email, $host, $role = self::ROLE_USER, $notes, $invites = self::DEFAULT_INVITES, $invitecode = '', $forceinvitemode = false) { - $site = new Settings; - $this->site = $site->get(); $uname = trim($uname); $pass = trim($pass); @@ -500,7 +496,7 @@ class Users // the invite would still have been used up // $invitedby = 0; - if (($this->site->registerstatus == Sites::REGISTER_STATUS_INVITE) && !$forceinvitemode) { + if (($this->pdo->getSetting('registerstatus') == Settings::REGISTER_STATUS_INVITE) && !$forceinvitemode) { if ($invitecode == '') return Users::ERR_SIGNUP_BADINVITECODE; @@ -555,11 +551,7 @@ class Users public function add($uname, $pass, $email, $role, $notes, $host, $invites = self::DEFAULT_INVITES, $invitedby = 0) { - - - $site = new Settings(); - $this->site = $site->get(); - if ($this->site->storeuserips != "1") + if ($this->pdo->getSetting('storeuserips') != "1") $host = ""; if ($invitedby == 0) @@ -591,10 +583,7 @@ class Users { $_SESSION['uid'] = $uid; - $site = new Settings(); - $this->site = $site->get(); - - if ($this->site->storeuserips != "1") + if ($this->pdo->getSetting('storeuserips') != "1") $host = ''; $this->updateSiteAccessed($uid, $host); @@ -793,11 +782,11 @@ class Users { $ipsql = "('-1')"; - if ($this->site->userhostexclusion != '') { + if ($this->pdo->getSetting('userhostexclusion') != '') { $ipsql = ""; - $ips = explode(",", $this->site->userhostexclusion); + $ips = explode(",", $this->pdo->getSetting('userhostexclusion')); foreach ($ips as $ip) { - $ipsql .= $this->pdo->escapeString($this->getHostHash($ip, $this->site->siteseed)) . ","; + $ipsql .= $this->pdo->escapeString($this->getHostHash($ip, $this->pdo->getSetting('siteseed'))) . ","; } $ipsql = "(" . $ipsql . " '-1')"; } @@ -821,7 +810,7 @@ class Users public function getHostHash($host, $siteseed = "") { if ($siteseed == "") { - $siteseed = $this->site->siteseed; + $siteseed = $this->pdo->getSetting('siteseed'); } return self::hashSHA1($siteseed . $host . $siteseed); diff --git a/newznab/controllers/XXX.php b/newznab/controllers/XXX.php index 66dbdf494..0d1ebc66f 100644 --- a/newznab/controllers/XXX.php +++ b/newznab/controllers/XXX.php @@ -60,13 +60,11 @@ class XXX 'Settings' => null, ]; $options += $defaults; - $s = new Settings(); - $this->site = $s->get(); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->releaseImage = ($options['ReleaseImage'] instanceof \ReleaseImage ? $options['ReleaseImage'] : new \ReleaseImage($this->pdo)); - $this->movieqty = ($this->site->maxxxxprocessed != '') ? $this->site->maxxxxprocessed : 100; + $this->movieqty = ($this->pdo->getSetting('maxxxxprocessed') != '') ? $this->pdo->getSetting('maxxxxprocessed') : 100; $this->showPasswords = ($this->pdo->getSetting('showpasswordedrelease') != '') ? $this->pdo->getSetting('showpasswordedrelease') : 0; $this->debug = NN_DEBUG; $this->echooutput = ($options['Echo'] && NN_ECHOCLI); diff --git a/newznab/libraries/Forking.php b/newznab/libraries/Forking.php index 1626476b4..097d41e4e 100644 --- a/newznab/libraries/Forking.php +++ b/newznab/libraries/Forking.php @@ -32,8 +32,6 @@ class Forking extends \fork_daemon parent::__construct(); $this->_colorCLI = new \ColorCLI(); - $s = new \Sites(); - $this->site = $s->get(); $this->register_logging( [0 => $this, 1 => 'logger'], @@ -287,7 +285,7 @@ class Forking extends \fork_daemon ($this->workTypeOptions[0] === false ? '' : (', ' . $this->workTypeOptions[0] . ' AS max')) ) ); - return $this->site->backfillthreads; + return $this->pdo->getSetting('backfillthreads'); } public function backFillChildWorker($groups, $identifier = '') @@ -308,7 +306,7 @@ class Forking extends \fork_daemon $this->register_child_run([0 => $this, 1 => 'safeBackfillChildWorker']); $run = $this->pdo->query("SELECT (SELECT value FROM tmux WHERE setting = 'backfill_qty') AS qty, (SELECT value FROM tmux WHERE setting = 'backfill') AS backfill, (SELECT value FROM tmux WHERE setting = 'backfill_order') AS orderby, (SELECT value FROM tmux WHERE setting = 'backfill_days') AS days, (SELECT value FROM settings WHERE setting = 'maxmssgs') AS maxmsgs"); - $threads = $this->site->backfillthreads; + $threads = $this->pdo->getSetting('backfillthreads'); $orderby = "ORDER BY a.last_record ASC"; switch ((int)$run[0]['orderby']) { @@ -337,7 +335,7 @@ class Forking extends \fork_daemon if ($run[0]['days'] == 1) { $backfilldays = "backfill_target"; } elseif ($run[0]['days'] == 2) { - $backfilldays = round(abs(strtotime(date("Y-m-d")) - strtotime($this->site->safebackfilldate)) / 86400);; + $backfilldays = round(abs(strtotime(date("Y-m-d")) - strtotime($this->pdo->getSetting('safebackfilldate'))) / 86400);; } $data = $this->pdo->queryOneRow( @@ -406,7 +404,7 @@ class Forking extends \fork_daemon $this->workTypeOptions[0] ) ); - return $this->site->binarythreads; + return $this->pdo->getSetting('binarythreads'); } public function binariesChildWorker($groups, $identifier = '') @@ -425,8 +423,8 @@ class Forking extends \fork_daemon { $this->register_child_run([0 => $this, 1 => 'safeBinariesChildWorker']); - $maxmssgs = $this->site->maxmssgs; - $threads = $this->site->binarythreads; + $maxmssgs = $this->pdo->getSetting('maxmssgs'); + $threads = $this->pdo->getSetting('binarythreads'); $groups = $this->pdo->query("SELECT g.name AS groupname, g.last_record AS our_last, a.last_record AS their_last FROM groups g INNER JOIN shortgroups a ON g.active = 1 AND g.name = a.name ORDER BY a.last_record DESC"); @@ -494,8 +492,8 @@ class Forking extends \fork_daemon $select = "DISTINCT LEFT(r.guid, 1) AS guidchar, COUNT(*) AS count"; - $threads = $this->site->fixnamethreads; - $maxperrun = $this->site->fixnamesperrun; + $threads = $this->pdo->getSetting('fixnamethreads'); + $maxperrun = $this->pdo->getSetting('fixnamesperrun'); if ($threads > 16) { $threads = 16; @@ -572,7 +570,7 @@ class Forking extends \fork_daemon { $this->register_child_run([0 => $this, 1 => 'releasesChildWorker']); - $this->tablePerGroup = ($this->site->tablepergroup == 1 ? true : false); + $this->tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 1 ? true : false); if ($this->tablePerGroup === true) { $groups = $this->pdo->queryDirect('SELECT id FROM groups WHERE (active = 1 OR backfill = 1)'); @@ -588,7 +586,7 @@ class Forking extends \fork_daemon $this->work = $this->pdo->query('SELECT name FROM groups WHERE (active = 1 OR backfill = 1)'); } - return $this->site->releasethreads; + return $this->pdo->getSetting('releasethreads'); } public function releasesChildWorker($groups, $identifier = '') @@ -648,10 +646,10 @@ class Forking extends \fork_daemon private function checkProcessAdditional() { $this->ppAddMinSize = - ($this->site->minsizetopostprocess != '') ? (int)$this->site->minsizetopostprocess: 1; + ($this->pdo->getSetting('minsizetopostprocess') != '') ? (int)$this->pdo->getSetting('minsizetopostprocess'): 1; $this->ppAddMinSize = ($this->ppAddMinSize > 0 ? ('AND r.size > ' . ($this->ppAddMinSize * 1048576)) : ''); $this->ppAddMaxSize = - ($this->site->maxsizetopostprocess != '') ? (int)$this->site->maxsizetopostprocess : 100; + ($this->pdo->getSetting('maxsizetopostprocess') != '') ? (int)$this->pdo->getSetting('maxsizetopostprocess') : 100; $this->ppAddMaxSize = ($this->ppAddMaxSize > 0 ? ('AND r.size < ' . ($this->ppAddMaxSize * 1073741824)) : ''); return ( $this->pdo->queryOneRow( @@ -696,7 +694,7 @@ class Forking extends \fork_daemon $this->ppAddMinSize ) ); - $maxProcesses = $this->site->postthreads; + $maxProcesses = $this->pdo->getSetting('postthreads'); } return $maxProcesses; } @@ -709,7 +707,7 @@ class Forking extends \fork_daemon */ private function checkProcessNfo() { - if ($this->site->lookupnfo == 1) { + if ($this->pdo->getSetting('lookupnfo') == 1) { $this->nfoQueryString = \Info::NfoQueryString($this->pdo); return ( $this->pdo->queryOneRow( @@ -739,7 +737,7 @@ class Forking extends \fork_daemon $this->nfoQueryString ) ); - $maxProcesses = $this->site->nfothreads; + $maxProcesses = $this->pdo->getSetting('nfothreads'); } return $maxProcesses; } @@ -750,7 +748,7 @@ class Forking extends \fork_daemon */ private function checkProcessMovies() { - if ($this->site->lookupimdb > 0) { + if ($this->pdo->getSetting('lookupimdb') > 0) { return ( $this->pdo->queryOneRow( sprintf(' @@ -762,7 +760,7 @@ class Forking extends \fork_daemon %s %s LIMIT 1', \Enzebe::NZB_ADDED, - ($this->site->lookupimdb == 2 ? 'AND isrenamed = 1' : ''), + ($this->pdo->getSetting('lookupimdb') == 2 ? 'AND isrenamed = 1' : ''), ($this->ppRenamedOnly ? 'AND isrenamed = 1' : '') ) ) === false ? false : true @@ -789,11 +787,11 @@ class Forking extends \fork_daemon LIMIT 16', ($this->ppRenamedOnly ? 2 : 1), \Enzebe::NZB_ADDED, - ($this->site->lookupimdb == 2 ? 'AND isrenamed = 1' : ''), + ($this->pdo->getSetting('lookupimdb') == 2 ? 'AND isrenamed = 1' : ''), ($this->ppRenamedOnly ? 'AND isrenamed = 1' : '') ) ); - $maxProcesses = $this->site->postthreadsnon; + $maxProcesses = $this->pdo->getSetting('postthreadsnon'); } return $maxProcesses; } @@ -804,7 +802,7 @@ class Forking extends \fork_daemon */ private function checkProcessTV() { - if ($this->site->lookuptvrage > 0) { + if ($this->pdo->getSetting('lookuptvrage') > 0) { return ( $this->pdo->queryOneRow( sprintf(' @@ -817,7 +815,7 @@ class Forking extends \fork_daemon %s %s LIMIT 1', \Enzebe::NZB_ADDED, - ($this->site->lookuptvrage == 2 ? 'AND isrenamed = 1' : ''), + ($this->pdo->getSetting('lookuptvrage') == 2 ? 'AND isrenamed = 1' : ''), ($this->ppRenamedOnly ? 'AND isrenamed = 1' : '') ) ) === false ? false : true @@ -845,11 +843,11 @@ class Forking extends \fork_daemon LIMIT 16', ($this->ppRenamedOnly ? 2 : 1), \Enzebe::NZB_ADDED, - ($this->site->lookuptvrage == 2 ? 'AND isrenamed = 1' : ''), + ($this->pdo->getSetting('lookuptvrage') == 2 ? 'AND isrenamed = 1' : ''), ($this->ppRenamedOnly ? 'AND isrenamed = 1' : '') ) ); - $maxProcesses = $this->site->postthreadsnon; + $maxProcesses = $this->pdo->getSetting('postthreadsnon'); } return $maxProcesses; } @@ -864,7 +862,7 @@ class Forking extends \fork_daemon $sharing = $this->pdo->queryOneRow('SELECT enabled FROM sharing'); if ($sharing !== false && $sharing['enabled'] == 1) { $nntp = new \NNTP(['Settings' => $this->pdo]); - if (($this->site->alternate_nntp == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) === true) { + if (($this->pdo->getSetting('alternate_nntp') == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) === true) { (new PProcess(['Settings' => $this->pdo, 'ColorCLI' => $this->_colorCLI]))->processSharing($nntp); } return true; @@ -910,7 +908,7 @@ class Forking extends \fork_daemon \RequestID::REQID_UPROC ) ); - return $this->site->reqidthreads; + return $this->pdo->getSetting('reqidthreads'); } public function requestIDChildWorker($groups, $identifier = '') @@ -930,7 +928,7 @@ class Forking extends \fork_daemon { $this->register_child_run([0 => $this, 1 => 'updatePerGroupChildWorker']); $this->work = $this->pdo->query('SELECT id FROM groups WHERE (active = 1 OR backfill = 1)'); - return $this->site->releasethreads; + return $this->pdo->getSetting('releasethreads'); } public function updatePerGroupChildWorker($groups, $identifier = '') diff --git a/newznab/processing/PProcess.php b/newznab/processing/PProcess.php index 97c04533c..4490ceafd 100644 --- a/newznab/processing/PProcess.php +++ b/newznab/processing/PProcess.php @@ -99,8 +99,8 @@ class PProcess //\\ //\\ Site settings. - $this->addpar2 = ($this->site->addpar2 == 0) ? false : true; - $this->alternateNNTP = ($this->site->alternate_nntp == 1 ? true : false); + $this->addpar2 = ($this->pdo->getSetting('addpar2') == 0) ? false : true; + $this->alternateNNTP = ($this->pdo->getSetting('alternate_nntp') == 1 ? true : false); //\\ } @@ -135,7 +135,7 @@ class PProcess */ public function processAnime() { - if ($this->site->lookupanidb != 0) { + if ($this->pdo->getSetting('lookupanidb') != 0) { (new AniDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processAnimeReleases(); } } @@ -147,7 +147,7 @@ class PProcess */ public function processBooks() { - if ($this->site->lookupbooks != 0) { + if ($this->pdo->getSetting('lookupbooks') != 0) { (new \Books(['Echo' => $this->echooutput, 'Settings' => $this->pdo, ]))->processBookReleases(); } } @@ -159,7 +159,7 @@ class PProcess */ public function processConsoles() { - if ($this->site->lookupgames != 0) { + if ($this->pdo->getSetting('lookupgames') != 0) { (new \Konsole(['Settings' => $this->pdo, 'Echo' => $this->echooutput]))->processConsoleReleases(); } } @@ -171,7 +171,7 @@ class PProcess */ public function processGames() { - if ($this->site->lookupgames != 0) { + if ($this->pdo->getSetting('lookupgames') != 0) { (new \Games(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processGamesReleases(); } } @@ -188,7 +188,7 @@ class PProcess */ public function processMovies($groupID = '', $guidChar = '', $processMovies = '') { - $processMovies = (is_numeric($processMovies) ? $processMovies : $this->site->lookupimdb); + $processMovies = (is_numeric($processMovies) ? $processMovies : $this->pdo->getSetting('lookupimdb')); if ($processMovies > 0) { (new \Film(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processMovieReleases($groupID, $guidChar, $processMovies); } @@ -201,7 +201,7 @@ class PProcess */ public function processMusic() { - if ($this->site->lookupmusic != 0) { + if ($this->pdo->getSetting('lookupmusic') != 0) { (new \Musik(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processMusicReleases(); } } @@ -217,8 +217,8 @@ class PProcess */ public function processNfos(&$nntp, $groupID = '', $guidChar = '') { - if ($this->site->lookupnfo == 1) { - $this->Nfo->processNfoFiles($nntp, $groupID, $guidChar, (int)$this->site->lookupimdb, (int)$this->site->lookuptvrage); + if ($this->pdo->getSetting('lookupnfo') == 1) { + $this->Nfo->processNfoFiles($nntp, $groupID, $guidChar, (int)$this->pdo->getSetting('lookupimdb'), (int)$this->pdo->getSetting('lookuptvrage')); } } @@ -265,7 +265,7 @@ class PProcess */ public function processTv($groupID = '', $guidChar = '', $processTV = '') { - $processTV = (is_numeric($processTV) ? $processTV : $this->site->lookuptvrage); + $processTV = (is_numeric($processTV) ? $processTV : $this->pdo->getSetting('lookuptvrage')); if ($processTV > 0) { (new \TvAnger(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processTvReleases($groupID, $guidChar, $processTV); } @@ -273,7 +273,7 @@ class PProcess public function processTvDB() { - if ($this->site->lookupthetvdb == 1) + if ($this->pdo->getSetting('lookupthetvdb') == 1) { $thetvdb = new \TheTVDB($this->echooutput); $thetvdb->processReleases(); @@ -285,7 +285,7 @@ class PProcess */ public function processXXX() { - if ($this->site->lookupxxx == 1) { + if ($this->pdo->getSetting('lookupxxx') == 1) { (new \XXX(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); } } diff --git a/newznab/processing/post/AniDB.php b/newznab/processing/post/AniDB.php index 18f790c03..01f665539 100644 --- a/newznab/processing/post/AniDB.php +++ b/newznab/processing/post/AniDB.php @@ -48,10 +48,7 @@ class AniDB $this->echooutput = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $s = new \Sites(); - $this->site = $s->get(); - - $qty = $this->site->maxanidbprocessed; + $qty = $this->pdo->getSetting('maxanidbprocessed'); $this->aniqty = !empty($qty) ? $qty : 100; $this->status = 'NULL'; diff --git a/newznab/processing/post/ProcessAdditional.php b/newznab/processing/post/ProcessAdditional.php index 532874fce..e22c3e445 100644 --- a/newznab/processing/post/ProcessAdditional.php +++ b/newznab/processing/post/ProcessAdditional.php @@ -287,7 +287,7 @@ class ProcessAdditional $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->_nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->_echoCLI, 'Settings' => $this->pdo])); - $this->_nzb = ($options['NZB'] instanceof \Enzebe ? $options['NZB'] : new \Enzebe($this->pdo)); + $this->_nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo)); $this->_groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->pdo])); $this->_archiveInfo = new \ArchiveInfo(); $this->_releaseFiles = ($options['ReleaseFiles'] instanceof \ReleaseFiles ? $options['ReleaseFiles'] : new \ReleaseFiles($this->pdo)); @@ -301,33 +301,33 @@ class ProcessAdditional $s = new \Sites(); $this->site = $s->get(); - $this->_innerFileBlacklist = ($this->site->innerfileblacklist == '' ? false : $this->site->innerfileblacklist); - $this->_maxNestedLevels = ($this->site->maxnestedlevels == 0 ? 3 : $this->site->maxnestedlevels); - $this->_extractUsingRarInfo = ($this->site->extractusingrarinfo == 0 ? false : true); + $this->_innerFileBlacklist = ($this->pdo->getSetting('innerfileblacklist') == '' ? false : $this->pdo->getSetting('innerfileblacklist')); + $this->_maxNestedLevels = ($this->pdo->getSetting('maxnestedlevels') == 0 ? 3 : $this->pdo->getSetting('maxnestedlevels')); + $this->_extractUsingRarInfo = ($this->pdo->getSetting('extractusingrarinfo') == 0 ? false : true); $this->_7zipPath = false; $this->_unrarPath = false; // Pass the binary extractors to ArchiveInfo. $clients = array(); - if ($this->site->unrarpath != '') { - $clients += array(\ArchiveInfo::TYPE_RAR => $this->site->unrarpath); - $this->_unrarPath = $this->site->unrarpath; + if ($this->pdo->getSetting('unrarpath') != '') { + $clients += array(\ArchiveInfo::TYPE_RAR => $this->pdo->getSetting('unrarpath')); + $this->_unrarPath = $this->pdo->getSetting('unrarpath'); } - if ($this->site->zippath != '') { - $clients += array(\ArchiveInfo::TYPE_ZIP => $this->site->zippath); - $this->_7zipPath = $this->site->zippath; + if ($this->pdo->getSetting('zippath') != '') { + $clients += array(\ArchiveInfo::TYPE_ZIP => $this->pdo->getSetting('zippath')); + $this->_7zipPath = $this->pdo->getSetting('zippath'); } $this->_archiveInfo->setExternalClients($clients); $this->_hasGNUFile = (Utility::hasCommand('file') === true ? true : false); $this->_killString = '"'; - if ($this->site->timeoutpath != '' && $this->site->timeoutseconds > 0) { + if ($this->pdo->getSetting('timeoutpath') != '' && $this->pdo->getSetting('timeoutseconds') > 0) { $this->_killString = ( - '"' . $this->site->timeoutpath . + '"' . $this->pdo->getSetting('timeoutpath') . '" --foreground --signal=KILL ' . - $this->site->timeoutseconds . ' "' + $this->pdo->getSetting('timeoutseconds') . ' "' ); } @@ -335,52 +335,52 @@ class ProcessAdditional // Maximum amount of releases to fetch per run. $this->_queryLimit = - ($this->site->maxaddprocessed != '') ? (int)$this->site->maxaddprocessed : 25; + ($this->pdo->getSetting('maxaddprocessed') != '') ? (int)$this->pdo->getSetting('maxaddprocessed') : 25; // Maximum message id's to download per file type in the NZB (video, jpg, etc). $this->_segmentsToDownload = - ($this->site->segmentstodownload != '') ? (int)$this->site->segmentstodownload : 2; + ($this->pdo->getSetting('segmentstodownload') != '') ? (int)$this->pdo->getSetting('segmentstodownload') : 2; // Maximum message id's to download for a RAR file. $this->_maximumRarSegments = - ($this->site->maxpartsprocessed != '') ? (int)$this->site->maxpartsprocessed : 3; + ($this->pdo->getSetting('maxpartsprocessed') != '') ? (int)$this->pdo->getSetting('maxpartsprocessed') : 3; // Maximum RAR files to check for a password before stopping. $this->_maximumRarPasswordChecks = - ($this->site->passchkattempts != '') ? (int)$this->site->passchkattempts : 1; + ($this->pdo->getSetting('passchkattempts') != '') ? (int)$this->pdo->getSetting('passchkattempts') : 1; $this->_maximumRarPasswordChecks = ($this->_maximumRarPasswordChecks < 1 ? 1 : $this->_maximumRarPasswordChecks); // Maximum size of releases in GB. $this->_maxSize = - ($this->site->maxsizetopostprocess != '') ? (int)$this->site->maxsizetopostprocess : 100; + ($this->pdo->getSetting('maxsizetopostprocess') != '') ? (int)$this->pdo->getSetting('maxsizetopostprocess') : 100; $this->_maxSize = ($this->_maxSize > 0 ? ('AND r.size < ' . ($this->_maxSize * 1073741824)) : ''); // Minimum size of releases in MB. $this->_minSize = - ($this->site->minsizetopostprocess != '') ? (int)$this->site->minsizetopostprocess : 100; + ($this->pdo->getSetting('minsizetopostprocess') != '') ? (int)$this->pdo->getSetting('minsizetopostprocess') : 100; $this->_minSize = ($this->_minSize > 0 ? ('AND r.size > ' . ($this->_minSize * 1048576)) : ''); // Use the alternate NNTP provider for downloading Message-ID's ? - $this->_alternateNNTP = ($this->site->alternate_nntp == 1 ? true : false); + $this->_alternateNNTP = ($this->pdo->getSetting('alternate_nntp') == 1 ? true : false); - $this->_ffMPEGDuration = ($this->site->ffmpeg_duration != '') ? (int)$this->site->ffmpeg_duration : 5; + $this->_ffMPEGDuration = ($this->pdo->getSetting('ffmpeg_duration') != '') ? (int)$this->pdo->getSetting('ffmpeg_duration') : 5; - $this->_addPAR2Files = ($this->site->addpar2 === '0') ? false : true; + $this->_addPAR2Files = ($this->pdo->getSetting('addpar2') === '0') ? false : true; - if (!$this->site->ffmpegpath) { + if (!$this->pdo->getSetting('ffmpegpath')) { $this->_processAudioSample = $this->_processThumbnails = $this->_processVideo = false; } else { - $this->_processAudioSample = ($this->site->processaudiosample == 0) ? false : true; - $this->_processThumbnails = ($this->site->processthumbnails == 0 ? false : true); - $this->_processVideo = ($this->site->processvideos == 0) ? false : true; + $this->_processAudioSample = ($this->pdo->getSetting('processaudiosample') == 0) ? false : true; + $this->_processThumbnails = ($this->pdo->getSetting('processthumbnails') == 0 ? false : true); + $this->_processVideo = ($this->pdo->getSetting('processvideos') == 0) ? false : true; } - $this->_processJPGSample = ($this->site->processjpg == 0) ? false : true; - $this->_processMediaInfo = ($this->site->mediainfopath == '') ? false : true; + $this->_processJPGSample = ($this->pdo->getSetting('processjpg') == 0) ? false : true; + $this->_processMediaInfo = ($this->pdo->getSetting('mediainfopath') == '') ? false : true; $this->_processAudioInfo = $this->_processMediaInfo; $this->_processPasswords = ( - ((($this->site->checkpasswordedrar == 0) ? false : true)) && - (($this->site->unrarpath == '') ? false : true) + ((($this->pdo->getSetting('checkpasswordedrar') == 0) ? false : true)) && + (($this->pdo->getSetting('unrarpath') == '') ? false : true) ); $this->_audioSavePath = NN_COVERS . 'audiosample' . DS; @@ -444,7 +444,7 @@ class ProcessAdditional protected function _setMainTempPath(&$groupID = '', &$guidChar) { // Set up the temporary files folder location. - $this->_mainTmpPath = (string)$this->site->tmpunrarpath; + $this->_mainTmpPath = (string)$this->pdo->getSetting('tmpunrarpath'); // Check if it ends with a dir separator. if (!preg_match('/[\/\\\\]$/', $this->_mainTmpPath)) { @@ -687,7 +687,7 @@ class ProcessAdditional */ protected function _getNZBContents() { - $nzbPath = $this->_nzb->getNZBPath($this->_release['guid']); + $nzbPath = $this->_nzb->NZBPath($this->_release['guid']); if ($nzbPath === false) { $this->_echo('NZB not found for GUID: ' . $this->_release['guid'], 'warning'); @@ -1633,7 +1633,7 @@ class ProcessAdditional // Get the media info for the file. $xmlArray = Utility::runCmd( - $this->_killString . $this->site->mediainfopath . '" --Output=XML "' . $fileLocation . '"' + $this->_killString . $this->pdo->getSetting('mediainfopath') . '" --Output=XML "' . $fileLocation . '"' ); if (is_array($xmlArray)) { @@ -1721,7 +1721,7 @@ class ProcessAdditional // Create an audio sample. Utility::runCmd( $this->_killString . - $this->site->ffmpegpath . + $this->pdo->getSetting('ffmpegpath') . '" -t 30 -i "' . $fileLocation . '" -acodec libvorbis -loglevel quiet -y "' . @@ -1824,7 +1824,7 @@ class ProcessAdditional // Get the real duration of the file. $time = Utility::runCmd( $this->_killString . - $this->site->ffmpegpath . + $this->pdo->getSetting('ffmpegpath') . '" -i "' . $videoLocation . '" -vcodec copy -y 2>&1 "' . $tmpVideo . '"', @@ -1870,7 +1870,7 @@ class ProcessAdditional // Create the image. Utility::runCmd( $this->_killString . - $this->site->ffmpegpath . + $this->pdo->getSetting('ffmpegpath') . '" -i "' . $fileLocation . '" -ss ' . ($time === '' ? '00:00:03.00' : $time) . @@ -1961,7 +1961,7 @@ class ProcessAdditional // Try to get the sample (from the end instead of the start). Utility::runCmd( $this->_killString . - $this->site->ffmpegpath . + $this->pdo->getSetting('ffmpegpath') . '" -i "' . $fileLocation . '" -ss ' . $lowestLength . @@ -1978,7 +1978,7 @@ class ProcessAdditional // If longer than 60 or we could not get the video length, run the old way. Utility::runCmd( $this->_killString . - $this->site->ffmpegpath . + $this->pdo->getSetting('ffmpegpath') . '" -i "' . $fileLocation . '" -vcodec libtheora -filter:v scale=320:-1 -t ' . @@ -2052,7 +2052,7 @@ class ProcessAdditional // Run media info on it. $xmlArray = Utility::runCmd( - $this->_killString . $this->site->mediainfopath . '" --Output=XML "' . $fileLocation . '"' + $this->_killString . $this->pdo->getSetting('mediainfopath') . '" --Output=XML "' . $fileLocation . '"' ); // Check if we got it. diff --git a/newznab/utility/Utility.php b/newznab/utility/Utility.php index d53a94866..9a796a547 100644 --- a/newznab/utility/Utility.php +++ b/newznab/utility/Utility.php @@ -593,10 +593,9 @@ class Utility $mail->Password = PHPMAILER_SMTP_PASSWORD; } } - $s = new \Sites(); - $settings = $s->get(); + $settings = new Settings(); - $site_email = $settings->email; + $site_email = $settings->getSetting('email'); $fromEmail = (PHPMAILER_FROM_EMAIL === '') ? $site_email : PHPMAILER_FROM_EMAIL; $fromName = (PHPMAILER_FROM_NAME === '') ? $settings->title : PHPMAILER_FROM_NAME; @@ -632,7 +631,7 @@ class Utility static public function fileInfo($path) { $output = ''; - $magicPath = (new \Sites())->get()->magic_file_path; + $magicPath = (new Settings())->getSetting('magic_file_path'); if (self::hasCommand('file') && (!self::isWin() || !empty($magicPath))) { $magicSwitch = empty($magicPath) ? '' : " -m $magicPath"; $output = Utility::runCmd('file' . $magicSwitch . ' -b "' . $path . '"'); diff --git a/www/admin/site-edit.php b/www/admin/site-edit.php index 846e42adc..2e4accd5c 100644 --- a/www/admin/site-edit.php +++ b/www/admin/site-edit.php @@ -1,7 +1,7 @@ update($_POST); + $ret = $page->settings->update($_POST); if (is_int($ret)) { - if ($ret == Sites::ERR_BADUNRARPATH) + if ($ret == Settings::ERR_BADUNRARPATH) $error = "The unrar path does not point to a valid binary"; - elseif ($ret == Sites::ERR_BADFFMPEGPATH) + elseif ($ret == Settings::ERR_BADFFMPEGPATH) $error = "The ffmpeg path does not point to a valid binary"; - elseif ($ret == Sites::ERR_BADMEDIAINFOPATH) + elseif ($ret == Settings::ERR_BADMEDIAINFOPATH) $error = "The mediainfo path does not point to a valid binary"; - elseif ($ret == Sites::ERR_BADNZBPATH) + elseif ($ret == Settings::ERR_BADNZBPATH) $error = "The nzb path does not point to a valid directory"; - elseif ($ret == Sites::ERR_DEEPNOUNRAR) + elseif ($ret == Settings::ERR_DEEPNOUNRAR) $error = "Deep password check requires a valid path to unrar binary"; - elseif ($ret == Sites::ERR_BADTMPUNRARPATH) + elseif ($ret == Settings::ERR_BADTMPUNRARPATH) $error = "The temp unrar path is not a valid directory"; elseif ($ret == Sites::ERR_BADLAMEPATH) $error = "The lame path is not a valid directory"; @@ -43,13 +43,13 @@ switch($action) if ($error == "") { $site = $ret; - $returnid = $site->id; + $returnid = $site['id']; header("Location:".WWW_TOP."/site-edit.php?id=".$returnid); } else { $page->smarty->assign('error', $error); - $site = $sites->row2Object($_POST); + $page->smarty->assign('settings', $page->settings->rowsToArray($_POST)); $page->smarty->assign('fsite', $site); } @@ -58,8 +58,9 @@ switch($action) default: $page->title = "Site Edit"; - $site = $sites->get(); + $site = $page->settings; $page->smarty->assign('fsite', $site); + $page->smarty->assign('settings', $site->getSettingsAsTree()); break; } @@ -150,7 +151,7 @@ $page->smarty->assign('book_reqids_ids', $book_reqids_ids); $page->smarty->assign('book_reqids_names', $book_reqids_names); // convert from a list to an array as we need to use an array, but teh sites table only saves strings -$books_selected = explode(",", $page->site->book_reqids); +$books_selected = explode(",", $page->settings->book_reqids); // convert from a string array to an int array $books_selected = array_map(create_function('$value', 'return (int)$value;'), $books_selected); diff --git a/www/pages/ajax_profile.php b/www/pages/ajax_profile.php index 66fb82b81..af86e7841 100644 --- a/www/pages/ajax_profile.php +++ b/www/pages/ajax_profile.php @@ -6,7 +6,7 @@ if (!$users->isLoggedIn()) if (isset($_GET['action']) && $_GET['action'] == "1" && isset($_GET['emailto'])) { $emailto = $_GET['emailto']; - $ret = $users->sendInvite($page->site->title, $page->site->email, $page->serverurl, $users->currentUserId(), $emailto); + $ret = $users->sendInvite($page->settings->title, $page->settings->email, $page->serverurl, $users->currentUserId(), $emailto); if (!$ret) print "Invite not sent."; else diff --git a/www/pages/api.php b/www/pages/api.php index e12ecc4ee..33be5dbd3 100644 --- a/www/pages/api.php +++ b/www/pages/api.php @@ -94,8 +94,8 @@ if ($users->isLoggedIn()) { // // A hash of the users ip to record against the api hit // - if ($page->site->storeuserips == 1) - $hosthash = $users->getHostHash($_SERVER["REMOTE_ADDR"], $page->site->siteseed); + if ($page->settings->getSetting('storeuserips') == 1) + $hosthash = $users->getHostHash($_SERVER["REMOTE_ADDR"], $page->settings->getSetting('siteseed')); $maxRequests = $res['apirequests']; } } @@ -440,7 +440,7 @@ switch ($function) { case 'r': verifyEmptyParameter('email'); - if (!in_array((int)$page->site->registerstatus, [Sites::REGISTER_STATUS_OPEN, Sites::REGISTER_STATUS_API_ONLY])) { + if (!in_array((int)$page->settings->getSetting('registerstatus'), [Sites::REGISTER_STATUS_OPEN, Sites::REGISTER_STATUS_API_ONLY])) { showApiError(104); } diff --git a/www/pages/contact-us.php b/www/pages/contact-us.php index 588ee86ba..f05c51fb7 100644 --- a/www/pages/contact-us.php +++ b/www/pages/contact-us.php @@ -9,7 +9,7 @@ if (isset($_POST["useremail"])) { if ($page->captcha->getError() === false) { $email = $_POST["useremail"]; - $mailto = $page->site->email; + $mailto = $page->settings->getSetting('email'); $mailsubj = "Contact Form Submitted"; $mailhead = "From: $email\n"; $mailbody = "Values submitted from contact form:\n"; @@ -24,13 +24,13 @@ if (isset($_POST["useremail"])) { Utility::sendEmail($mailto, $mailsubj, $mailbody, $email); } - $page->smarty->assign("msg", "