From 273d2c6be3f1ea406f4aeee1de946096dd0880c2 Mon Sep 17 00:00:00 2001 From: Darko Date: Mon, 1 Jun 2015 11:49:17 +0200 Subject: [PATCH] Fix references to site. --- misc/update_scripts/nix_scripts/tmux/run.php | 8 ++------ newznab/controllers/Info.php | 7 +++---- newznab/controllers/Releases.php | 19 +++++++----------- newznab/controllers/SpotNab.php | 2 -- newznab/controllers/TmuxOutput.php | 21 +++++++++++--------- resources/db/patches/0122~settings.sql | 2 +- 6 files changed, 25 insertions(+), 34 deletions(-) diff --git a/misc/update_scripts/nix_scripts/tmux/run.php b/misc/update_scripts/nix_scripts/tmux/run.php index 484e0428b..5f667a62b 100644 --- a/misc/update_scripts/nix_scripts/tmux/run.php +++ b/misc/update_scripts/nix_scripts/tmux/run.php @@ -9,7 +9,6 @@ $DIR = NN_TMUX; $c = new ColorCLI(); $t = new Tmux(); $tmux = $t->get(); -$patch = (isset($tmux->sqlpatch)) ? $tmux->sqlpatch : 0; $import = (isset($tmux->import)) ? $tmux->import : 0; $tmux_session = (isset($tmux->tmux_session)) ? $tmux->tmux_session : 0; $seq = (isset($tmux->sequential)) ? $tmux->sequential : 0; @@ -19,6 +18,8 @@ $nntpproxy = $pdo->getSetting('nntpproxy'); $tablepergroup = $pdo->getSetting('tablepergroup'); $tablepergroup = ($tablepergroup != '') ? $tablepergroup : 0; +// Check that Db patch level is current. Also checks nZEDb.xml is valid. +Utility::isPatched(); Utility::clearScreen(); echo "Starting Tmux...\n"; @@ -33,11 +34,6 @@ if (count($nntpkill) !== 0) { exec("tmux list-session", $session); } -// Check database patch version -if ($patch < 121) { - exit($c->error("\nYour database is not up to date. Please update.\nphp ${NN_WWW}lib/DB/patchDB.php\n")); -} - //check if session exists $session = shell_exec("tmux list-session | grep $tmux_session"); // Kill the placeholder diff --git a/newznab/controllers/Info.php b/newznab/controllers/Info.php index 1a014ea60..fee311575 100644 --- a/newznab/controllers/Info.php +++ b/newznab/controllers/Info.php @@ -244,10 +244,9 @@ class Info */ static public function NfoQueryString(Settings &$pdo) { - - $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/Releases.php b/newznab/controllers/Releases.php index 666120ace..7709494c7 100644 --- a/newznab/controllers/Releases.php +++ b/newznab/controllers/Releases.php @@ -987,8 +987,7 @@ class Releases public function searchAudio($artist, $album, $label, $track, $year, $genre = array(-1), $offset = 0, $limit = 100, $cat = array(-1), $maxage = -1) { $s = new Settings(); - $site = $s->get(); - if ($site->sphinxenabled) { + if ($s->getSetting('sphinxenabled')) { $sphinx = new Sphinx(); $results = $sphinx->searchAudio($artist, $album, $label, $track, $year, $genre, $offset, $limit, $cat, $maxage, array(), true); if (is_array($results)) @@ -1067,8 +1066,7 @@ class Releases public function searchBook($author, $title, $offset = 0, $limit = 100, $maxage = -1) { $s = new Settings(); - $site = $s->get(); - if ($site->sphinxenabled) { + if ($s->getSetting('sphinxenabled')) { $sphinx = new Sphinx(); $results = $sphinx->searchBook($author, $title, $offset, $limit, $maxage, array(), true); if (is_array($results)) @@ -1337,11 +1335,10 @@ class Releases { $s = new Settings(); $this->nzb = new NZB; - $site = $s->get(); $zipfile = new zipfile(); foreach ($guids as $guid) { - $nzbpath = $this->nzb->getNZBPath($guid, $site->nzbpath); + $nzbpath = $this->nzb->getNZBPath($guid, $s->getSetting('nzbpath')); if (file_exists($nzbpath)) { ob_start(); @@ -1910,7 +1907,7 @@ class Releases $serverrev = intval($matches[1]); if ($serverrev > $rev) { - $site = new Settings; + $site = new Sites(); $queries = explode(";", $regfile); $queries = array_map("trim", $queries); @@ -2137,7 +2134,6 @@ class Releases $users = new Users(); $s = new Settings(); $nfo = new Nfo(); - $site = $s->get(); $rf = new ReleaseFiles(); $re = new ReleaseExtra(); $rc = new ReleaseComments(); @@ -2154,9 +2150,9 @@ class Releases $nzbpath = ""; if ($isGuid) - $nzbpath = $site->nzbpath . substr($identifier, 0, 1) . "/" . $identifier . ".nzb.gz"; + $nzbpath = $s->getSetting('nzbpath') . substr($identifier, 0, 1) . "/" . $identifier . ".nzb.gz"; elseif ($rel) - $nzbpath = $site->nzbpath . substr($rel["guid"], 0, 1) . "/" . $rel["guid"] . ".nzb.gz"; + $nzbpath = $s->getSetting('nzbpath') . substr($rel["guid"], 0, 1) . "/" . $rel["guid"] . ".nzb.gz"; if ($nzbpath != "" && file_exists($nzbpath)) unlink($nzbpath); @@ -2442,9 +2438,8 @@ class Releases $echoCLI = NN_ECHOCLI; $groups = new Groups(); $s = new Settings(); - $site = $s->get(); $consoleTools = new ConsoleTools(['ColorCLI' => $this->pdo->log]); - if ($local === false && $site->lookup_reqids == 0) { + if ($local === false && $s->getSetting('lookup_reqids') == 0) { return; } diff --git a/newznab/controllers/SpotNab.php b/newznab/controllers/SpotNab.php index d7e89e7fa..fa7bafc4b 100644 --- a/newznab/controllers/SpotNab.php +++ b/newznab/controllers/SpotNab.php @@ -156,8 +156,6 @@ class SpotNab { $this->_nntp = new NNTP(['Settings' => $this->_pdo]); $this->releaseImage = new \ReleaseImage($this->_pdo); $this->nzb = new \NZB($this->_pdo); - $s = new Settings(); - $this->_site = $s->get(); $this->_globals = $this->_site; $this->_post_user = $post_user; diff --git a/newznab/controllers/TmuxOutput.php b/newznab/controllers/TmuxOutput.php index f4149767b..7e45a46ca 100644 --- a/newznab/controllers/TmuxOutput.php +++ b/newznab/controllers/TmuxOutput.php @@ -1,6 +1,7 @@ get(); - $this->_vers = $this->pdo->getSetting('dbversion'); - $this->_tvers = $tmux->sqlpatch; + $this->_git = new \newznab\utility\Git(); // Do not remove the full namespace/ PHP gets confused for some reason without it. + $this->_vers = Utility::getValidVersionsFile(); $this->_setColourMasks(); @@ -110,12 +114,11 @@ class TmuxOutput extends Tmux { $buffer = ''; $state = ($this->runVar['settings']['is_running'] == 1) ? 'Running' : 'Disabled'; - //$version = $this->_tvers . 'r' . $this->_vers; - $tversion = '0.5r01275'; + $version = $this->_vers->versions->git->tag . 'r' . $this->_git->commits(); $buffer .= sprintf($this->tmpMasks[2], - "Monitor $state v$tversion @ $this->_tvers [" . $this->_vers ."]: ", - $this->relativeTime($this->runVar['timers']['timer1']) + "Monitor $state v$version [" . $this->runVar['constants']['sqlpatch'] . "]: ", + $this->relativeTime($this->runVar['timers']['timer1']) ); $buffer .= sprintf($this->tmpMasks[1], diff --git a/resources/db/patches/0122~settings.sql b/resources/db/patches/0122~settings.sql index 4e1e734bb..e14236865 100644 --- a/resources/db/patches/0122~settings.sql +++ b/resources/db/patches/0122~settings.sql @@ -10,4 +10,4 @@ ALTER TABLE site ADD PRIMARY KEY (section, subsection, name), ADD UNIQUE INDEX ui_settings_setting (setting); RENAME TABLE site TO settings; -INSERT IGNORE INTO settings (name, setting, value) VALUES('sqlpatch', 'sqlpatch', 122); \ No newline at end of file +UPDATE `settings` SET `value` = '122' WHERE `setting` = 'sqlpatch'; \ No newline at end of file