From 0fd5f1ae80d60330a3ecd6dbc5bb73b450642cba Mon Sep 17 00:00:00 2001 From: Darko Date: Wed, 10 Jun 2015 10:25:55 +0200 Subject: [PATCH] Cleanup the scripts, fix more references to site table. --- newznab/controllers/Backfill.php | 2 -- newznab/controllers/Binaries.php | 22 ++++++++++------------ newznab/controllers/Book.php | 8 +++----- newznab/controllers/Books.php | 2 -- newznab/controllers/Categorize.php | 2 -- newznab/controllers/Console.php | 10 ++++------ newznab/controllers/Enzebe.php | 3 +-- newznab/controllers/Film.php | 2 -- newznab/controllers/Info.php | 13 +++---------- newznab/controllers/Konsole.php | 2 -- newznab/controllers/MiscSorter.php | 2 -- newznab/controllers/Movie.php | 13 +++++-------- newznab/controllers/Music.php | 10 ++++------ newznab/controllers/Musik.php | 2 -- newznab/controllers/NNTP.php | 2 -- newznab/controllers/NZB.php | 5 +---- newznab/controllers/NZBContents.php | 2 -- newznab/controllers/Parsing.php | 2 -- newznab/controllers/PostProcess.php | 2 -- newznab/controllers/ReleaseComments.php | 5 +---- newznab/controllers/ReleaseRegex.php | 2 -- newznab/controllers/RequestIDWeb.php | 2 -- newznab/controllers/Tmux.php | 2 -- newznab/controllers/TmuxOutput.php | 2 -- newznab/controllers/TraktTv.php | 5 +++-- newznab/controllers/TvAnger.php | 2 -- newznab/controllers/Users.php | 5 ----- 27 files changed, 35 insertions(+), 96 deletions(-) diff --git a/newznab/controllers/Backfill.php b/newznab/controllers/Backfill.php index 5a5172d78..1e7065ee7 100644 --- a/newznab/controllers/Backfill.php +++ b/newznab/controllers/Backfill.php @@ -106,8 +106,6 @@ class Backfill $this->_nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Settings' => $this->pdo]) ); - $s = new Sites(); - $this->site = $s->get(); $this->_debug = (NN_LOGGING || NN_DEBUG); if ($this->_debug) { diff --git a/newznab/controllers/Binaries.php b/newznab/controllers/Binaries.php index b4518644c..f9022f53e 100644 --- a/newznab/controllers/Binaries.php +++ b/newznab/controllers/Binaries.php @@ -161,8 +161,6 @@ class Binaries $this->_echoCLI = ($options['Echo'] && NN_ECHOCLI); - $s = new Sites(); - $this->_site = $s->get(); $this->_pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->_groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->_pdo])); $this->_colorCLI = ($options['ColorCLI'] instanceof \ColorCLI ? $options['ColorCLI'] : new \ColorCLI()); @@ -179,16 +177,16 @@ class Binaries } } - $this->messageBuffer = ($this->_site->maxmssgs != '') ? $this->_site->maxmssgs : 20000; - $this->_compressedHeaders = ($this->_site->compressedheaders == 1 ? true : false); - $this->_partRepair = ($this->_site->partrepair == 0 ? false : true); - $this->_newGroupScanByDays = ($this->_site->newgroupscanmethod == 1 ? true : false); - $this->_newGroupMessagesToScan = ($this->_site->newgroupmsgstoscan != '') ? $this->_site->newgroupmsgstoscan : 50000; - $this->_newGroupDaysToScan = ($this->_site->newgroupdaystoscan != '') ? (int)$this->_site->newgroupdaystoscan : 3; - $this->_partRepairLimit = ($this->_site->maxpartrepair != '') ? (int)$this->_site->maxpartrepair : 15000; - $this->_partRepairMaxTries = ($this->_site->partrepairmaxtries != '' ? (int)$this->_site->partrepairmaxtries : 3); - $this->_showDroppedYEncParts = ($this->_site->showdroppedyencparts == 1 ? true : false); - $this->_tablePerGroup = ($this->_site->tablepergroup == 1 ? true : false); + $this->messageBuffer = ($this->_pdo->getSetting('maxmssgs') != '') ? $this->_pdo->getSetting('maxmssgs') : 20000; + $this->_compressedHeaders = ($this->_pdo->getSetting('compressedheaders') == 1 ? true : false); + $this->_partRepair = ($this->_pdo->getSetting('partrepair') == 0 ? false : true); + $this->_newGroupScanByDays = ($this->_pdo->getSetting('newgroupscanmethod') == 1 ? true : false); + $this->_newGroupMessagesToScan = ($this->_pdo->getSetting('newgroupmsgstoscan') != '') ? $this->_pdo->getSetting('newgroupmsgstoscan') : 50000; + $this->_newGroupDaysToScan = ($this->_pdo->getSetting('newgroupdaystoscan') != '') ? (int)$this->_pdo->getSetting('newgroupdaystoscan') : 3; + $this->_partRepairLimit = ($this->_pdo->getSetting('maxpartrepair') != '') ? (int)$this->_pdo->getSetting('maxpartrepair') : 15000; + $this->_partRepairMaxTries = ($this->_pdo->getSetting('partrepairmaxtries') != '' ? (int)$this->_pdo->getSetting('partrepairmaxtries') : 3); + $this->_showDroppedYEncParts = ($this->_pdo->getSetting('showdroppedyencparts') == 1 ? true : false); + $this->_tablePerGroup = ($this->_pdo->getSetting('tablepergroup') == 1 ? true : false); $this->blackList = $this->whiteList = []; } diff --git a/newznab/controllers/Book.php b/newznab/controllers/Book.php index 0de800db1..66b2a0502 100644 --- a/newznab/controllers/Book.php +++ b/newznab/controllers/Book.php @@ -28,12 +28,10 @@ class Book public function __construct($echooutput = false) { $this->echooutput = (NN_ECHOCLI && $echooutput); - $s = new Sites(); - $site = $s->get(); - $this->pubkey = $site->amazonpubkey; - $this->privkey = $site->amazonprivkey; - $this->asstag = $site->amazonassociatetag; $this->pdo = new Settings(); + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->imgSavePath = WWW_DIR.'covers/book/'; } diff --git a/newznab/controllers/Books.php b/newznab/controllers/Books.php index 69333e2a9..28d035ed7 100644 --- a/newznab/controllers/Books.php +++ b/newznab/controllers/Books.php @@ -79,8 +79,6 @@ class Books $this->echooutput = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $s = new Sites(); - $this->site = $s->get(); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); $this->privkey = $this->pdo->getSetting('amazonprivkey'); diff --git a/newznab/controllers/Categorize.php b/newznab/controllers/Categorize.php index ac15fef3d..e905a90b7 100644 --- a/newznab/controllers/Categorize.php +++ b/newznab/controllers/Categorize.php @@ -48,8 +48,6 @@ class Categorize extends Category public function __construct(array $options = array()) { //parent::__construct($options); - $s = new Sites(); - $this->site = $s->get(); $this->pdo = new newznab\db\Settings(); $this->categorizeForeign = ($this->pdo->getSetting('categorizeforeign') == "0") ? false : true; $this->catWebDL = ($this->pdo->getSetting('catwebdl') == "0") ? false : true; diff --git a/newznab/controllers/Console.php b/newznab/controllers/Console.php index 28932ccd8..01c99fc95 100644 --- a/newznab/controllers/Console.php +++ b/newznab/controllers/Console.php @@ -29,12 +29,10 @@ class Console public function __construct($echooutput=false) { $this->echooutput = (NN_ECHOCLI && $echooutput); - $s = new Sites(); - $site = $s->get(); - $this->pubkey = $site->amazonpubkey; - $this->privkey = $site->amazonprivkey; - $this->asstag = $site->amazonassociatetag; - $this->pdo = new newznab\db\Settings(); + $this->pdo = new Settings(); + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->imgSavePath = WWW_DIR.'covers/console/'; } diff --git a/newznab/controllers/Enzebe.php b/newznab/controllers/Enzebe.php index 97a9fb4b1..b29e195cd 100644 --- a/newznab/controllers/Enzebe.php +++ b/newznab/controllers/Enzebe.php @@ -102,7 +102,6 @@ class Enzebe public function initiateForWrite($groupID) { $this->groupid = $groupID; - $site = new Sites(); // Set table names if ($this->tablePerGroup === true) { if ($this->groupid == '') { @@ -132,7 +131,7 @@ class Enzebe $this->_nzbHeadString = ( "\n\n\n\n\n %s\n %s\n\n\n" ); } diff --git a/newznab/controllers/Film.php b/newznab/controllers/Film.php index e2a5523d2..5c10694ec 100644 --- a/newznab/controllers/Film.php +++ b/newznab/controllers/Film.php @@ -145,8 +145,6 @@ class Film $options += $defaults; $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $s = new Sites(); - $this->site = $s->get(); $this->releaseImage = ($options['ReleaseImage'] instanceof \ReleaseImage ? $options['ReleaseImage'] : new \ReleaseImage($this->pdo)); $this->lookuplanguage = ($this->pdo->getSetting('lookuplanguage') != '') ? (string)$this->pdo->getSetting('lookuplanguage') : 'en'; diff --git a/newznab/controllers/Info.php b/newznab/controllers/Info.php index fa5433094..4b71ebfae 100644 --- a/newznab/controllers/Info.php +++ b/newznab/controllers/Info.php @@ -81,13 +81,8 @@ class Info 'Settings' => null, ]; $options += $defaults; - $s = new Sites(); - $this->site = $s->get(); - $this->echo = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $s = new Sites(); - $this->site = $s->get(); $this->nzbs = ($this->pdo->getSetting('maxnfoprocessed') != '') ? (int)$this->pdo->getSetting('maxnfoprocessed') : 100; $this->maxsize = ($this->pdo->getSetting('maxsizetoprocessnfo') != '') ? (int)$this->pdo->getSetting('maxsizetoprocessnfo') : 100; $this->maxsize = ($this->maxsize > 0 ? ('AND size < ' . ($this->maxsize * 1073741824)) : ''); @@ -248,11 +243,9 @@ class Info */ static public function NfoQueryString(Settings &$pdo) { - $s = new Sites(); - $site = $s->get(); - $maxSize = $site->maxsizetoprocessnfo; - $minSize = $site->minsizetoprocessnfo; - $maxRetries = (int)($site->maxnforetries >= 0 ? -((int)$site->maxnforetries + 1) : self::NFO_UNPROC); + $maxSize = $pdo->getSetting('maxsizetoprocessnfo'); + $minSize = $pdo->getSetting('minsizetoprocessnfo'); + $maxRetries = (int)($pdo->getSetting('maxnforetries') >= 0 ? -((int)$pdo->getSetting('maxnforetries') + 1) : self::NFO_UNPROC); return ( sprintf( 'AND r.nzbstatus = %d AND r.nfostatus BETWEEN %d AND %d %s %s', diff --git a/newznab/controllers/Konsole.php b/newznab/controllers/Konsole.php index d9aff3477..9c3ac09ff 100644 --- a/newznab/controllers/Konsole.php +++ b/newznab/controllers/Konsole.php @@ -75,8 +75,6 @@ class Konsole $this->echooutput = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $s = new Sites(); - $this->site = $s->get(); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); $this->privkey = $this->pdo->getSetting('amazonprivkey'); diff --git a/newznab/controllers/MiscSorter.php b/newznab/controllers/MiscSorter.php index f44c7c266..b697fa710 100644 --- a/newznab/controllers/MiscSorter.php +++ b/newznab/controllers/MiscSorter.php @@ -51,8 +51,6 @@ class MiscSorter $this->category = new Categorize(['Settings' => $this->pdo]); $this->movie = new Film(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); - $s = new Sites(); - $this->site = $s->get(); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); $this->privkey = $this->pdo->getSetting('amazonprivkey'); $this->asstag = $this->pdo->getSetting('amazonassociatetag'); diff --git a/newznab/controllers/Movie.php b/newznab/controllers/Movie.php index 38417a326..7d4db9634 100644 --- a/newznab/controllers/Movie.php +++ b/newznab/controllers/Movie.php @@ -49,11 +49,9 @@ class Movie public function __construct($echooutput = false) { $this->echooutput = (NN_ECHOCLI && $echooutput); - $s = new \Sites(); - $site = $s->get(); - $this->apikey = $site->tmdbkey; - $this->lookuplanguage = $site->lookuplanguage; $this->pdo = new Settings(); + $this->apikey = $this->pdo->getSetting('tmdbkey'); + $this->lookuplanguage = $this->pdo->getSetting('lookuplanguage'); $this->imgSavePath = NN_COVERS . 'movies' . DS; } @@ -793,11 +791,10 @@ class Movie */ public function updateUpcoming() { - $s = new Sites(); - $site = $s->get(); - if (isset($site->rottentomatokey)) + $rtkey = $this->pdo->getSetting('rottentomatokey'); + if (isset($rtkey)) { - $rt = new RottenTomato($site->rottentomatokey); + $rt = new RottenTomato($this->pdo->getSetting('rottentomatokey')); $ret = $rt->getMoviesBoxOffice(); if ($ret != "") diff --git a/newznab/controllers/Music.php b/newznab/controllers/Music.php index d465762cb..4b68d0b87 100644 --- a/newznab/controllers/Music.php +++ b/newznab/controllers/Music.php @@ -29,12 +29,10 @@ class Music public function __construct($echooutput = false) { $this->echooutput = (NN_ECHOCLI && $echooutput); - $s = new Sites(); - $site = $s->get(); - $this->pubkey = $site->amazonpubkey; - $this->privkey = $site->amazonprivkey; - $this->asstag = $site->amazonassociatetag; - $this->pdo = new newznab\db\Settings(); + $this->pdo = new Settings(); + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->imgSavePath = WWW_DIR.'covers/music/'; } diff --git a/newznab/controllers/Musik.php b/newznab/controllers/Musik.php index 26805a47e..6a38b6552 100644 --- a/newznab/controllers/Musik.php +++ b/newznab/controllers/Musik.php @@ -72,8 +72,6 @@ class Musik $options += $defaults; $this->echooutput = ($options['Echo'] && NN_ECHOCLI); - $s = new Sites(); - $this->site = $s->get(); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); diff --git a/newznab/controllers/NNTP.php b/newznab/controllers/NNTP.php index a2f3cf342..f9c4ecdaf 100644 --- a/newznab/controllers/NNTP.php +++ b/newznab/controllers/NNTP.php @@ -108,8 +108,6 @@ class NNTP extends Net_NNTP_Client $this->_echo = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof \newznab\db\Settings ? $options['Settings'] : new \newznab\db\Settings()); - $s = new Sites(); - $this->site = $s->get(); $this->_debugBool = (NN_LOGGING || NN_DEBUG); if ($this->_debugBool) { diff --git a/newznab/controllers/NZB.php b/newznab/controllers/NZB.php index a8f1b9596..ffe2b0d56 100644 --- a/newznab/controllers/NZB.php +++ b/newznab/controllers/NZB.php @@ -97,8 +97,6 @@ class NZB { $this->pdo = ($pdo instanceof Settings ? $pdo : new Settings()); - $s = new Sites(); - $this->site = $s->get(); $this->tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 0 ? false : true); $nzbSplitLevel = $this->pdo->getSetting('nzbsplitlevel'); $this->nzbSplitLevel = (empty($nzbSplitLevel) ? 1 : $nzbSplitLevel); @@ -118,7 +116,6 @@ class NZB public function initiateForWrite($groupID) { $this->groupID = $groupID; - $site = new Sites(); // Set table names if ($this->tablePerGroup === true) { if ($this->groupID == '') { @@ -158,7 +155,7 @@ class NZB $this->_nzbHeadString = ( "\n\n\n\n\n %s\n %s\n\n\n" ); } diff --git a/newznab/controllers/NZBContents.php b/newznab/controllers/NZBContents.php index 2a2c14b8a..a2b880eed 100644 --- a/newznab/controllers/NZBContents.php +++ b/newznab/controllers/NZBContents.php @@ -98,8 +98,6 @@ Class NZBContents $this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo)); $t = new Tmux(); $this->tmux = $t->get(); - $s = new Sites(); - $this->site = $s->get(); $this->lookuppar2 = ($this->tmux->lookuppar2 == 1 ? true : false); $this->alternateNNTP = ($this->pdo->getSetting('alternate_nntp') == 1 ? true : false); } diff --git a/newznab/controllers/Parsing.php b/newznab/controllers/Parsing.php index 5fbc9ae54..2076b5019 100644 --- a/newznab/controllers/Parsing.php +++ b/newznab/controllers/Parsing.php @@ -33,8 +33,6 @@ class Parsing $this->parsprocessed = 0; $this->releasefilesprocessed = 0; $this->cleanup = ['nuke' => [], 'misc' => []]; - $s = new Sites(); - $this->site = $s->get(); $this->pdo = new newznab\db\Settings(); } diff --git a/newznab/controllers/PostProcess.php b/newznab/controllers/PostProcess.php index c4c0975e2..bd6a7fc66 100644 --- a/newznab/controllers/PostProcess.php +++ b/newznab/controllers/PostProcess.php @@ -29,8 +29,6 @@ class PostProcess public function __construct($echooutput = false) { $this->echooutput = (NN_ECHOCLI && $echooutput);; - $s = new \Sites(); - $this->site = $s->get(); $this->pdo = new Settings(); $this->mediafileregex = 'AVI|VOB|MKV|MP4|TS|WMV|MOV|M4V|F4V|MPG|MPEG|M2TS'; $this->audiofileregex = 'MP3|AAC|OGG'; diff --git a/newznab/controllers/ReleaseComments.php b/newznab/controllers/ReleaseComments.php index 75601837f..a1f0c9cea 100644 --- a/newznab/controllers/ReleaseComments.php +++ b/newznab/controllers/ReleaseComments.php @@ -131,10 +131,7 @@ class ReleaseComments return false; $db = new Settings(); - - $site = new Sites(); - $s = $site->get(); - if ($s->storeuserips != "1") + if ($db->getSetting('storeuserips') != "1") $host = ""; $comid = $db->queryInsert(sprintf("INSERT INTO releasecomment (releaseid, gid, text, userid, createddate, host) VALUES (%d, %s, %s, %d, now(), %s)", $id, $db->escapeString($gid), $db->escapeString($text), $userid, $db->escapeString($host))); diff --git a/newznab/controllers/ReleaseRegex.php b/newznab/controllers/ReleaseRegex.php index 4cee3e6b4..07684f853 100644 --- a/newznab/controllers/ReleaseRegex.php +++ b/newznab/controllers/ReleaseRegex.php @@ -29,8 +29,6 @@ class ReleaseRegex { $this->regexes = []; $this->pdo = new Settings(); - $s = new Sites(); - $this->site = $s->get(); $this->tablePerGroup = $this->pdo->getSetting('tablepergroup'); } diff --git a/newznab/controllers/RequestIDWeb.php b/newznab/controllers/RequestIDWeb.php index 9d03f9a97..be5be3b96 100644 --- a/newznab/controllers/RequestIDWeb.php +++ b/newznab/controllers/RequestIDWeb.php @@ -31,8 +31,6 @@ class RequestIDWeb extends RequestID public function __construct(array $options = array()) { parent::__construct($options); - $s = new Sites(); - $this->site = $s->get(); $this->_request_hours = ($this->pdo->getSetting('request_hours') != '') ? (int)$this->pdo->getSetting('request_hours') : 1; } diff --git a/newznab/controllers/Tmux.php b/newznab/controllers/Tmux.php index e9e2dcd38..912557fef 100644 --- a/newznab/controllers/Tmux.php +++ b/newznab/controllers/Tmux.php @@ -15,8 +15,6 @@ class Tmux function __construct(Settings $pdo = null) { $this->pdo = (empty($pdo) ? new Settings() : $pdo); - $s = new Sites; - $this->site = $s->get(); } public function version() diff --git a/newznab/controllers/TmuxOutput.php b/newznab/controllers/TmuxOutput.php index 8ff81b4b6..e9f50fcc7 100644 --- a/newznab/controllers/TmuxOutput.php +++ b/newznab/controllers/TmuxOutput.php @@ -33,8 +33,6 @@ class TmuxOutput extends Tmux { parent::__construct($pdo); - $s = new Sites(); - $site = $s->get(); $t = new Tmux(); $tmux = $t->get(); $this->_git = new \newznab\utility\Git(); // Do not remove the full namespace/ PHP gets confused for some reason without it. diff --git a/newznab/controllers/TraktTv.php b/newznab/controllers/TraktTv.php index 2b04ad998..431b844de 100644 --- a/newznab/controllers/TraktTv.php +++ b/newznab/controllers/TraktTv.php @@ -1,6 +1,7 @@ APIKEY = $settings->get()->trakttvkey; + $settings = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); + $this->APIKEY = $settings->getSetting('trakttvkey'); } /** diff --git a/newznab/controllers/TvAnger.php b/newznab/controllers/TvAnger.php index 1a71bbc00..1857a42c4 100644 --- a/newznab/controllers/TvAnger.php +++ b/newznab/controllers/TvAnger.php @@ -36,8 +36,6 @@ class TvAnger 'Settings' => null, ]; $options += $defaults; - $s = new Sites(); - $this->site = $s->get(); $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->rageqty = ($this->pdo->getSetting('maxrageprocessed') != '') ? $this->pdo->getSetting('maxrageprocessed') : 75; diff --git a/newznab/controllers/Users.php b/newznab/controllers/Users.php index 3ff0b3a9f..ed8b8e45c 100644 --- a/newznab/controllers/Users.php +++ b/newznab/controllers/Users.php @@ -477,8 +477,6 @@ class Users public function signup($uname, $pass, $email, $host, $role = self::ROLE_USER, $notes, $invites = self::DEFAULT_INVITES, $invitecode = '', $forceinvitemode = false) { - $site = new Sites; - $this->site = $site->get(); $uname = trim($uname); $pass = trim($pass); @@ -563,9 +561,6 @@ class Users public function add($uname, $pass, $email, $role, $notes, $host, $invites = self::DEFAULT_INVITES, $invitedby = 0) { - - $site = new Sites(); - $this->site = $site->get(); if ($this->pdo->getSetting('storeuserips') != "1") $host = "";