\w+)\.sql$#',
+ 'safe' => true,
+ ];
+ $files = Utility::getDirFiles($options);
+ natsort($files);
+
+ $last = (preg_match($options['regex'], end($files), $matches)) ? (int)$matches['patch'] : false;
+
+ if ($update) {
+ if ($last !== false && $this->_vers->sql->file->__toString() != $last) {
+ echo $this->out->primary("Updating latest patch file to " . $last);
+ $this->_vers->sql->file = $last;
+ $this->_changes |= self::UPDATED_SQL_FILE_LAST;
+ }
+
+ if ($this->_vers->sql->file->__toString() != $last) {
+ $this->_vers->sql->file = $last;
+ $this->_changes |= self::UPDATED_SQL_DB_PATCH;
+ }
+ }
+ return $last;
+ }
+
+ public function getCommit()
+ {
+ return $this->_vers->git->commit->__toString();
+ }
+
+ public function getGitHookPrecommit()
+ {
+ return $this->_vers->git->hooks->precommit->__toString();
+ }
+
+ public function getSQLPatchFromDb()
+ {
+ return $this->_vers->sql->db->__toString();
+ }
+
+ public function getSQLPatchFromFiles()
+ {
+ return $this->_vers->sql->file->__toString();
+ }
+
+ public function getTagVersion()
+ {
+ return $this->_vers->git->tag->__toString();
+ }
+
+ public function getValidVersionsFile($filepath = null)
+ {
+ $filepath = empty($filepath) ? $this->_filespec : $filepath;
+
+ $temp = libxml_use_internal_errors(true);
+ $this->_xml = simplexml_load_file($filepath);
+ libxml_use_internal_errors($temp);
+
+ if ($this->_xml === false) {
+ if (Utility::isCLI()) {
+ $this->out->error("Your versions XML file ($filepath) is broken, try updating from git.");
+ }
+ throw new \Exception("Failed to open versions XML file '$filepath'");
+ }
+
+ if ($this->_xml->count() > 0) {
+ $vers = $this->_xml->xpath('/newznab/versions');
+
+ if ($vers[0]->count() == 0) {
+ $this->out->error("Your versions XML file ({NN_VERSIONS}) does not contain version info, try updating from git.");
+ throw new \Exception("Failed to find versions node in XML file '$filepath'");
+ } else {
+ $this->out->primary("Your versions XML file ({NN_VERSIONS}) looks okay, continuing.");
+ $this->_vers = &$this->_xml->versions;
+ }
+ } else {
+ throw new \RuntimeException("No elements in file!\n");
+ }
+
+ return $this->_xml;
+ }
+
+ /**
+ * Check whether the XML has been changed by one of the methods here.
+ * @return boolean True if the XML has been changed.
+ */
+ public function hasChanged()
+ {
+ return $this->_changes != 0;
+ }
+
+ public function save()
+ {
+ if ($this->hasChanged()) {
+ $this->_xml->asXML($this->_filespec);
+ $this->_changes = 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/lib/DB/patches/0001_tmux.sql b/lib/copy_this/resources/patches/0001_tmux.sql
similarity index 100%
rename from lib/DB/patches/0001_tmux.sql
rename to lib/copy_this/resources/patches/0001_tmux.sql
diff --git a/lib/DB/patches/0002_tmux.sql b/lib/copy_this/resources/patches/0002_tmux.sql
similarity index 100%
rename from lib/DB/patches/0002_tmux.sql
rename to lib/copy_this/resources/patches/0002_tmux.sql
diff --git a/lib/DB/patches/0004_tmux.sql b/lib/copy_this/resources/patches/0004_tmux.sql
similarity index 100%
rename from lib/DB/patches/0004_tmux.sql
rename to lib/copy_this/resources/patches/0004_tmux.sql
diff --git a/lib/DB/patches/0005_releases.sql b/lib/copy_this/resources/patches/0005_releases.sql
similarity index 100%
rename from lib/DB/patches/0005_releases.sql
rename to lib/copy_this/resources/patches/0005_releases.sql
diff --git a/lib/DB/patches/0006_tmux.sql b/lib/copy_this/resources/patches/0006_tmux.sql
similarity index 100%
rename from lib/DB/patches/0006_tmux.sql
rename to lib/copy_this/resources/patches/0006_tmux.sql
diff --git a/lib/DB/patches/0007_releases_tmux.sql b/lib/copy_this/resources/patches/0007_releases_tmux.sql
similarity index 100%
rename from lib/DB/patches/0007_releases_tmux.sql
rename to lib/copy_this/resources/patches/0007_releases_tmux.sql
diff --git a/lib/DB/patches/0008_releases.sql b/lib/copy_this/resources/patches/0008_releases.sql
similarity index 100%
rename from lib/DB/patches/0008_releases.sql
rename to lib/copy_this/resources/patches/0008_releases.sql
diff --git a/lib/DB/patches/0009_releases.sql b/lib/copy_this/resources/patches/0009_releases.sql
similarity index 100%
rename from lib/DB/patches/0009_releases.sql
rename to lib/copy_this/resources/patches/0009_releases.sql
diff --git a/lib/DB/patches/0010_releases.sql b/lib/copy_this/resources/patches/0010_releases.sql
similarity index 100%
rename from lib/DB/patches/0010_releases.sql
rename to lib/copy_this/resources/patches/0010_releases.sql
diff --git a/lib/DB/patches/0011_prehash.sql b/lib/copy_this/resources/patches/0011_prehash.sql
similarity index 100%
rename from lib/DB/patches/0011_prehash.sql
rename to lib/copy_this/resources/patches/0011_prehash.sql
diff --git a/lib/DB/patches/0012_prehash.sql b/lib/copy_this/resources/patches/0012_prehash.sql
similarity index 100%
rename from lib/DB/patches/0012_prehash.sql
rename to lib/copy_this/resources/patches/0012_prehash.sql
diff --git a/lib/DB/patches/0013_tmux.sql b/lib/copy_this/resources/patches/0013_tmux.sql
similarity index 100%
rename from lib/DB/patches/0013_tmux.sql
rename to lib/copy_this/resources/patches/0013_tmux.sql
diff --git a/lib/DB/patches/0014_prehash.sql b/lib/copy_this/resources/patches/0014_prehash.sql
similarity index 100%
rename from lib/DB/patches/0014_prehash.sql
rename to lib/copy_this/resources/patches/0014_prehash.sql
diff --git a/lib/DB/patches/0015_sharing.sql b/lib/copy_this/resources/patches/0015_sharing.sql
similarity index 100%
rename from lib/DB/patches/0015_sharing.sql
rename to lib/copy_this/resources/patches/0015_sharing.sql
diff --git a/lib/DB/patches/0016_tmux.sql b/lib/copy_this/resources/patches/0016_tmux.sql
similarity index 100%
rename from lib/DB/patches/0016_tmux.sql
rename to lib/copy_this/resources/patches/0016_tmux.sql
diff --git a/lib/DB/patches/0017_tmux.sql b/lib/copy_this/resources/patches/0017_tmux.sql
similarity index 100%
rename from lib/DB/patches/0017_tmux.sql
rename to lib/copy_this/resources/patches/0017_tmux.sql
diff --git a/lib/DB/patches/0018_sharing.sql b/lib/copy_this/resources/patches/0018_sharing.sql
similarity index 100%
rename from lib/DB/patches/0018_sharing.sql
rename to lib/copy_this/resources/patches/0018_sharing.sql
diff --git a/lib/DB/patches/0019_sharing.sql b/lib/copy_this/resources/patches/0019_sharing.sql
similarity index 100%
rename from lib/DB/patches/0019_sharing.sql
rename to lib/copy_this/resources/patches/0019_sharing.sql
diff --git a/lib/DB/patches/0020_tmux.sql b/lib/copy_this/resources/patches/0020_tmux.sql
similarity index 100%
rename from lib/DB/patches/0020_tmux.sql
rename to lib/copy_this/resources/patches/0020_tmux.sql
diff --git a/lib/DB/patches/0021_tmux.sql b/lib/copy_this/resources/patches/0021_tmux.sql
similarity index 100%
rename from lib/DB/patches/0021_tmux.sql
rename to lib/copy_this/resources/patches/0021_tmux.sql
diff --git a/lib/DB/patches/0022_releases.sql b/lib/copy_this/resources/patches/0022_releases.sql
similarity index 100%
rename from lib/DB/patches/0022_releases.sql
rename to lib/copy_this/resources/patches/0022_releases.sql
diff --git a/lib/DB/patches/0023_tmux.sql b/lib/copy_this/resources/patches/0023_tmux.sql
similarity index 100%
rename from lib/DB/patches/0023_tmux.sql
rename to lib/copy_this/resources/patches/0023_tmux.sql
diff --git a/lib/DB/patches/0024_tmux.sql b/lib/copy_this/resources/patches/0024_tmux.sql
similarity index 100%
rename from lib/DB/patches/0024_tmux.sql
rename to lib/copy_this/resources/patches/0024_tmux.sql
diff --git a/lib/DB/patches/0025_tmux.sql b/lib/copy_this/resources/patches/0025_tmux.sql
similarity index 100%
rename from lib/DB/patches/0025_tmux.sql
rename to lib/copy_this/resources/patches/0025_tmux.sql
diff --git a/lib/DB/patches/0026_tmux.sql b/lib/copy_this/resources/patches/0026_tmux.sql
similarity index 100%
rename from lib/DB/patches/0026_tmux.sql
rename to lib/copy_this/resources/patches/0026_tmux.sql
diff --git a/lib/DB/patches/0027_prehash.sql b/lib/copy_this/resources/patches/0027_prehash.sql
similarity index 100%
rename from lib/DB/patches/0027_prehash.sql
rename to lib/copy_this/resources/patches/0027_prehash.sql
diff --git a/lib/DB/patches/0028_tmux.sql b/lib/copy_this/resources/patches/0028_tmux.sql
similarity index 100%
rename from lib/DB/patches/0028_tmux.sql
rename to lib/copy_this/resources/patches/0028_tmux.sql
diff --git a/lib/DB/patches/0029_releases.sql b/lib/copy_this/resources/patches/0029_releases.sql
similarity index 100%
rename from lib/DB/patches/0029_releases.sql
rename to lib/copy_this/resources/patches/0029_releases.sql
diff --git a/lib/DB/patches/0030_tmux.sql b/lib/copy_this/resources/patches/0030_tmux.sql
similarity index 100%
rename from lib/DB/patches/0030_tmux.sql
rename to lib/copy_this/resources/patches/0030_tmux.sql
diff --git a/lib/DB/patches/0031_releases.sql b/lib/copy_this/resources/patches/0031_releases.sql
similarity index 100%
rename from lib/DB/patches/0031_releases.sql
rename to lib/copy_this/resources/patches/0031_releases.sql
diff --git a/lib/DB/patches/0032_releases.sql b/lib/copy_this/resources/patches/0032_releases.sql
similarity index 100%
rename from lib/DB/patches/0032_releases.sql
rename to lib/copy_this/resources/patches/0032_releases.sql
diff --git a/lib/DB/patches/0033_releases.sql b/lib/copy_this/resources/patches/0033_releases.sql
similarity index 100%
rename from lib/DB/patches/0033_releases.sql
rename to lib/copy_this/resources/patches/0033_releases.sql
diff --git a/lib/DB/patches/0034_tmux.sql b/lib/copy_this/resources/patches/0034_tmux.sql
similarity index 100%
rename from lib/DB/patches/0034_tmux.sql
rename to lib/copy_this/resources/patches/0034_tmux.sql
diff --git a/lib/DB/patches/0035_prehash.sql b/lib/copy_this/resources/patches/0035_prehash.sql
similarity index 100%
rename from lib/DB/patches/0035_prehash.sql
rename to lib/copy_this/resources/patches/0035_prehash.sql
diff --git a/lib/DB/patches/0036_tmux.sql b/lib/copy_this/resources/patches/0036_tmux.sql
similarity index 100%
rename from lib/DB/patches/0036_tmux.sql
rename to lib/copy_this/resources/patches/0036_tmux.sql
diff --git a/lib/DB/patches/0037_tmux.sql b/lib/copy_this/resources/patches/0037_tmux.sql
similarity index 100%
rename from lib/DB/patches/0037_tmux.sql
rename to lib/copy_this/resources/patches/0037_tmux.sql
diff --git a/lib/DB/patches/0038_releasesearch.sql b/lib/copy_this/resources/patches/0038_releasesearch.sql
similarity index 100%
rename from lib/DB/patches/0038_releasesearch.sql
rename to lib/copy_this/resources/patches/0038_releasesearch.sql
diff --git a/lib/DB/patches/0039_prehash.sql b/lib/copy_this/resources/patches/0039_prehash.sql
similarity index 100%
rename from lib/DB/patches/0039_prehash.sql
rename to lib/copy_this/resources/patches/0039_prehash.sql
diff --git a/lib/DB/patches/0040_tmux.sql b/lib/copy_this/resources/patches/0040_tmux.sql
similarity index 100%
rename from lib/DB/patches/0040_tmux.sql
rename to lib/copy_this/resources/patches/0040_tmux.sql
diff --git a/lib/DB/patches/0041_predbhash.sql b/lib/copy_this/resources/patches/0041_predbhash.sql
similarity index 100%
rename from lib/DB/patches/0041_predbhash.sql
rename to lib/copy_this/resources/patches/0041_predbhash.sql
diff --git a/lib/DB/patches/0042_predbhash.sql b/lib/copy_this/resources/patches/0042_predbhash.sql
similarity index 100%
rename from lib/DB/patches/0042_predbhash.sql
rename to lib/copy_this/resources/patches/0042_predbhash.sql
diff --git a/lib/DB/patches/0043_prehash.sql b/lib/copy_this/resources/patches/0043_prehash.sql
similarity index 100%
rename from lib/DB/patches/0043_prehash.sql
rename to lib/copy_this/resources/patches/0043_prehash.sql
diff --git a/lib/DB/patches/0044_releasecomment.sql b/lib/copy_this/resources/patches/0044_releasecomment.sql
similarity index 100%
rename from lib/DB/patches/0044_releasecomment.sql
rename to lib/copy_this/resources/patches/0044_releasecomment.sql
diff --git a/lib/DB/patches/0045_prehash.sql b/lib/copy_this/resources/patches/0045_prehash.sql
similarity index 100%
rename from lib/DB/patches/0045_prehash.sql
rename to lib/copy_this/resources/patches/0045_prehash.sql
diff --git a/lib/DB/patches/0046_releasecomment.sql b/lib/copy_this/resources/patches/0046_releasecomment.sql
similarity index 100%
rename from lib/DB/patches/0046_releasecomment.sql
rename to lib/copy_this/resources/patches/0046_releasecomment.sql
diff --git a/lib/DB/patches/0047_users.sql b/lib/copy_this/resources/patches/0047_users.sql
similarity index 100%
rename from lib/DB/patches/0047_users.sql
rename to lib/copy_this/resources/patches/0047_users.sql
diff --git a/lib/DB/patches/0049_site.sql b/lib/copy_this/resources/patches/0049_site.sql
similarity index 100%
rename from lib/DB/patches/0049_site.sql
rename to lib/copy_this/resources/patches/0049_site.sql
diff --git a/lib/DB/patches/0050_category.sql b/lib/copy_this/resources/patches/0050_category.sql
similarity index 100%
rename from lib/DB/patches/0050_category.sql
rename to lib/copy_this/resources/patches/0050_category.sql
diff --git a/lib/DB/patches/0051_tmux.sql b/lib/copy_this/resources/patches/0051_tmux.sql
similarity index 100%
rename from lib/DB/patches/0051_tmux.sql
rename to lib/copy_this/resources/patches/0051_tmux.sql
diff --git a/lib/DB/patches/0052~gamesinfo.sql b/lib/copy_this/resources/patches/0052~gamesinfo.sql
similarity index 100%
rename from lib/DB/patches/0052~gamesinfo.sql
rename to lib/copy_this/resources/patches/0052~gamesinfo.sql
diff --git a/lib/DB/patches/0053~site.sql b/lib/copy_this/resources/patches/0053~site.sql
similarity index 100%
rename from lib/DB/patches/0053~site.sql
rename to lib/copy_this/resources/patches/0053~site.sql
diff --git a/lib/DB/patches/0054~releases.sql b/lib/copy_this/resources/patches/0054~releases.sql
similarity index 100%
rename from lib/DB/patches/0054~releases.sql
rename to lib/copy_this/resources/patches/0054~releases.sql
diff --git a/lib/DB/patches/0055~users.sql b/lib/copy_this/resources/patches/0055~users.sql
similarity index 100%
rename from lib/DB/patches/0055~users.sql
rename to lib/copy_this/resources/patches/0055~users.sql
diff --git a/lib/DB/patches/0056~menu.sql b/lib/copy_this/resources/patches/0056~menu.sql
similarity index 100%
rename from lib/DB/patches/0056~menu.sql
rename to lib/copy_this/resources/patches/0056~menu.sql
diff --git a/lib/DB/patches/0057~releases.sql b/lib/copy_this/resources/patches/0057~releases.sql
similarity index 100%
rename from lib/DB/patches/0057~releases.sql
rename to lib/copy_this/resources/patches/0057~releases.sql
diff --git a/lib/DB/patches/0058~tmux.sql b/lib/copy_this/resources/patches/0058~tmux.sql
similarity index 100%
rename from lib/DB/patches/0058~tmux.sql
rename to lib/copy_this/resources/patches/0058~tmux.sql
diff --git a/lib/DB/patches/0059~users.sql b/lib/copy_this/resources/patches/0059~users.sql
similarity index 100%
rename from lib/DB/patches/0059~users.sql
rename to lib/copy_this/resources/patches/0059~users.sql
diff --git a/lib/DB/patches/0060~xxxinfo.sql b/lib/copy_this/resources/patches/0060~xxxinfo.sql
similarity index 100%
rename from lib/DB/patches/0060~xxxinfo.sql
rename to lib/copy_this/resources/patches/0060~xxxinfo.sql
diff --git a/lib/DB/patches/0061~releases.sql b/lib/copy_this/resources/patches/0061~releases.sql
similarity index 100%
rename from lib/DB/patches/0061~releases.sql
rename to lib/copy_this/resources/patches/0061~releases.sql
diff --git a/lib/DB/patches/0062~releases.sql b/lib/copy_this/resources/patches/0062~releases.sql
similarity index 100%
rename from lib/DB/patches/0062~releases.sql
rename to lib/copy_this/resources/patches/0062~releases.sql
diff --git a/lib/DB/patches/0063~site.sql b/lib/copy_this/resources/patches/0063~site.sql
similarity index 100%
rename from lib/DB/patches/0063~site.sql
rename to lib/copy_this/resources/patches/0063~site.sql
diff --git a/lib/DB/patches/0064~site.sql b/lib/copy_this/resources/patches/0064~site.sql
similarity index 100%
rename from lib/DB/patches/0064~site.sql
rename to lib/copy_this/resources/patches/0064~site.sql
diff --git a/lib/DB/patches/0065~users.sql b/lib/copy_this/resources/patches/0065~users.sql
similarity index 100%
rename from lib/DB/patches/0065~users.sql
rename to lib/copy_this/resources/patches/0065~users.sql
diff --git a/lib/DB/patches/0066~genres.sql b/lib/copy_this/resources/patches/0066~genres.sql
similarity index 100%
rename from lib/DB/patches/0066~genres.sql
rename to lib/copy_this/resources/patches/0066~genres.sql
diff --git a/lib/DB/patches/0067~gamesinfo.sql b/lib/copy_this/resources/patches/0067~gamesinfo.sql
similarity index 100%
rename from lib/DB/patches/0067~gamesinfo.sql
rename to lib/copy_this/resources/patches/0067~gamesinfo.sql
diff --git a/lib/DB/patches/0068~xxxinfo.sql b/lib/copy_this/resources/patches/0068~xxxinfo.sql
similarity index 100%
rename from lib/DB/patches/0068~xxxinfo.sql
rename to lib/copy_this/resources/patches/0068~xxxinfo.sql
diff --git a/lib/DB/patches/0069~site.sql b/lib/copy_this/resources/patches/0069~site.sql
similarity index 100%
rename from lib/DB/patches/0069~site.sql
rename to lib/copy_this/resources/patches/0069~site.sql
diff --git a/lib/DB/patches/0070~animetitles.sql b/lib/copy_this/resources/patches/0070~animetitles.sql
similarity index 100%
rename from lib/DB/patches/0070~animetitles.sql
rename to lib/copy_this/resources/patches/0070~animetitles.sql
diff --git a/lib/DB/patches/0071~site.sql b/lib/copy_this/resources/patches/0071~site.sql
similarity index 100%
rename from lib/DB/patches/0071~site.sql
rename to lib/copy_this/resources/patches/0071~site.sql
diff --git a/lib/DB/patches/0072~site.sql b/lib/copy_this/resources/patches/0072~site.sql
similarity index 100%
rename from lib/DB/patches/0072~site.sql
rename to lib/copy_this/resources/patches/0072~site.sql
diff --git a/lib/DB/patches/0073~releases.sql b/lib/copy_this/resources/patches/0073~releases.sql
similarity index 100%
rename from lib/DB/patches/0073~releases.sql
rename to lib/copy_this/resources/patches/0073~releases.sql
diff --git a/lib/DB/patches/0074~releases.sql b/lib/copy_this/resources/patches/0074~releases.sql
similarity index 100%
rename from lib/DB/patches/0074~releases.sql
rename to lib/copy_this/resources/patches/0074~releases.sql
diff --git a/lib/DB/patches/0075~site.sql b/lib/copy_this/resources/patches/0075~site.sql
similarity index 100%
rename from lib/DB/patches/0075~site.sql
rename to lib/copy_this/resources/patches/0075~site.sql
diff --git a/lib/DB/patches/0078~site.sql b/lib/copy_this/resources/patches/0078~site.sql
similarity index 100%
rename from lib/DB/patches/0078~site.sql
rename to lib/copy_this/resources/patches/0078~site.sql
diff --git a/lib/DB/patches/0079~site.sql b/lib/copy_this/resources/patches/0079~site.sql
similarity index 100%
rename from lib/DB/patches/0079~site.sql
rename to lib/copy_this/resources/patches/0079~site.sql
diff --git a/lib/DB/patches/0080~site.sql b/lib/copy_this/resources/patches/0080~site.sql
similarity index 100%
rename from lib/DB/patches/0080~site.sql
rename to lib/copy_this/resources/patches/0080~site.sql
diff --git a/lib/DB/patches/0081~movieinfo.sql b/lib/copy_this/resources/patches/0081~movieinfo.sql
similarity index 100%
rename from lib/DB/patches/0081~movieinfo.sql
rename to lib/copy_this/resources/patches/0081~movieinfo.sql
diff --git a/lib/DB/patches/0082~tvrageepisodes.sql b/lib/copy_this/resources/patches/0082~tvrageepisodes.sql
similarity index 100%
rename from lib/DB/patches/0082~tvrageepisodes.sql
rename to lib/copy_this/resources/patches/0082~tvrageepisodes.sql
diff --git a/lib/DB/patches/0083~site.sql b/lib/copy_this/resources/patches/0083~site.sql
similarity index 100%
rename from lib/DB/patches/0083~site.sql
rename to lib/copy_this/resources/patches/0083~site.sql
diff --git a/lib/DB/patches/0084~groups.sql b/lib/copy_this/resources/patches/0084~groups.sql
similarity index 100%
rename from lib/DB/patches/0084~groups.sql
rename to lib/copy_this/resources/patches/0084~groups.sql
diff --git a/lib/DB/patches/0085~site.sql b/lib/copy_this/resources/patches/0085~site.sql
similarity index 100%
rename from lib/DB/patches/0085~site.sql
rename to lib/copy_this/resources/patches/0085~site.sql
diff --git a/lib/DB/patches/0086~category.sql b/lib/copy_this/resources/patches/0086~category.sql
similarity index 100%
rename from lib/DB/patches/0086~category.sql
rename to lib/copy_this/resources/patches/0086~category.sql
diff --git a/lib/DB/patches/0087~site.sql b/lib/copy_this/resources/patches/0087~site.sql
similarity index 100%
rename from lib/DB/patches/0087~site.sql
rename to lib/copy_this/resources/patches/0087~site.sql
diff --git a/lib/DB/patches/0088~site.sql b/lib/copy_this/resources/patches/0088~site.sql
similarity index 100%
rename from lib/DB/patches/0088~site.sql
rename to lib/copy_this/resources/patches/0088~site.sql
diff --git a/lib/DB/patches/0089~site.sql b/lib/copy_this/resources/patches/0089~site.sql
similarity index 100%
rename from lib/DB/patches/0089~site.sql
rename to lib/copy_this/resources/patches/0089~site.sql
diff --git a/lib/DB/patches/0090~bookinfo.sql b/lib/copy_this/resources/patches/0090~bookinfo.sql
similarity index 100%
rename from lib/DB/patches/0090~bookinfo.sql
rename to lib/copy_this/resources/patches/0090~bookinfo.sql
diff --git a/lib/DB/patches/0091~releasesearch.sql b/lib/copy_this/resources/patches/0091~releasesearch.sql
similarity index 100%
rename from lib/DB/patches/0091~releasesearch.sql
rename to lib/copy_this/resources/patches/0091~releasesearch.sql
diff --git a/lib/DB/patches/0092~bookinfo.sql b/lib/copy_this/resources/patches/0092~bookinfo.sql
similarity index 100%
rename from lib/DB/patches/0092~bookinfo.sql
rename to lib/copy_this/resources/patches/0092~bookinfo.sql
diff --git a/lib/DB/patches/0093~anidb.sql b/lib/copy_this/resources/patches/0093~anidb.sql
similarity index 100%
rename from lib/DB/patches/0093~anidb.sql
rename to lib/copy_this/resources/patches/0093~anidb.sql
diff --git a/lib/DB/patches/0094~site.sql b/lib/copy_this/resources/patches/0094~site.sql
similarity index 100%
rename from lib/DB/patches/0094~site.sql
rename to lib/copy_this/resources/patches/0094~site.sql
diff --git a/lib/DB/patches/0095~releases.sql b/lib/copy_this/resources/patches/0095~releases.sql
similarity index 100%
rename from lib/DB/patches/0095~releases.sql
rename to lib/copy_this/resources/patches/0095~releases.sql
diff --git a/lib/DB/patches/0096~site.sql b/lib/copy_this/resources/patches/0096~site.sql
similarity index 100%
rename from lib/DB/patches/0096~site.sql
rename to lib/copy_this/resources/patches/0096~site.sql
diff --git a/lib/DB/patches/0097~releases.sql b/lib/copy_this/resources/patches/0097~releases.sql
similarity index 100%
rename from lib/DB/patches/0097~releases.sql
rename to lib/copy_this/resources/patches/0097~releases.sql
diff --git a/lib/DB/patches/0098~tmux.sql b/lib/copy_this/resources/patches/0098~tmux.sql
similarity index 100%
rename from lib/DB/patches/0098~tmux.sql
rename to lib/copy_this/resources/patches/0098~tmux.sql
diff --git a/lib/DB/patches/0099~releases.sql b/lib/copy_this/resources/patches/0099~releases.sql
similarity index 100%
rename from lib/DB/patches/0099~releases.sql
rename to lib/copy_this/resources/patches/0099~releases.sql
diff --git a/lib/DB/patches/0100~binaries.sql b/lib/copy_this/resources/patches/0100~binaries.sql
similarity index 100%
rename from lib/DB/patches/0100~binaries.sql
rename to lib/copy_this/resources/patches/0100~binaries.sql
diff --git a/lib/DB/patches/0101~tmux.sql b/lib/copy_this/resources/patches/0101~tmux.sql
similarity index 100%
rename from lib/DB/patches/0101~tmux.sql
rename to lib/copy_this/resources/patches/0101~tmux.sql
diff --git a/lib/DB/patches/0102~predb.sql b/lib/copy_this/resources/patches/0102~predb.sql
similarity index 100%
rename from lib/DB/patches/0102~predb.sql
rename to lib/copy_this/resources/patches/0102~predb.sql
diff --git a/lib/DB/patches/0103~site.sql b/lib/copy_this/resources/patches/0103~site.sql
similarity index 100%
rename from lib/DB/patches/0103~site.sql
rename to lib/copy_this/resources/patches/0103~site.sql
diff --git a/lib/DB/patches/0104~releasecomment.sql b/lib/copy_this/resources/patches/0104~releasecomment.sql
similarity index 100%
rename from lib/DB/patches/0104~releasecomment.sql
rename to lib/copy_this/resources/patches/0104~releasecomment.sql
diff --git a/lib/DB/patches/0105~site.sql b/lib/copy_this/resources/patches/0105~site.sql
similarity index 100%
rename from lib/DB/patches/0105~site.sql
rename to lib/copy_this/resources/patches/0105~site.sql
diff --git a/lib/DB/patches/0106~category.sql b/lib/copy_this/resources/patches/0106~category.sql
similarity index 100%
rename from lib/DB/patches/0106~category.sql
rename to lib/copy_this/resources/patches/0106~category.sql
diff --git a/lib/DB/patches/0107~prehash.sql b/lib/copy_this/resources/patches/0107~prehash.sql
similarity index 100%
rename from lib/DB/patches/0107~prehash.sql
rename to lib/copy_this/resources/patches/0107~prehash.sql
diff --git a/lib/DB/patches/0108~regexless.sql b/lib/copy_this/resources/patches/0108~regexless.sql
similarity index 100%
rename from lib/DB/patches/0108~regexless.sql
rename to lib/copy_this/resources/patches/0108~regexless.sql
diff --git a/lib/DB/patches/0109~site.sql b/lib/copy_this/resources/patches/0109~site.sql
similarity index 100%
rename from lib/DB/patches/0109~site.sql
rename to lib/copy_this/resources/patches/0109~site.sql
diff --git a/lib/DB/patches/0110~category.sql b/lib/copy_this/resources/patches/0110~category.sql
similarity index 100%
rename from lib/DB/patches/0110~category.sql
rename to lib/copy_this/resources/patches/0110~category.sql
diff --git a/lib/DB/patches/0111~collections.sql b/lib/copy_this/resources/patches/0111~collections.sql
similarity index 100%
rename from lib/DB/patches/0111~collections.sql
rename to lib/copy_this/resources/patches/0111~collections.sql
diff --git a/lib/DB/patches/0112~category.sql b/lib/copy_this/resources/patches/0112~category.sql
similarity index 100%
rename from lib/DB/patches/0112~category.sql
rename to lib/copy_this/resources/patches/0112~category.sql
diff --git a/lib/DB/patches/0113~releases.sql b/lib/copy_this/resources/patches/0113~releases.sql
similarity index 100%
rename from lib/DB/patches/0113~releases.sql
rename to lib/copy_this/resources/patches/0113~releases.sql
diff --git a/lib/DB/patches/0114~collection_regexes.sql b/lib/copy_this/resources/patches/0114~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0114~collection_regexes.sql
rename to lib/copy_this/resources/patches/0114~collection_regexes.sql
diff --git a/lib/DB/patches/0115~tmux.sql b/lib/copy_this/resources/patches/0115~tmux.sql
similarity index 100%
rename from lib/DB/patches/0115~tmux.sql
rename to lib/copy_this/resources/patches/0115~tmux.sql
diff --git a/lib/DB/patches/0116~tmux.sql b/lib/copy_this/resources/patches/0116~tmux.sql
similarity index 100%
rename from lib/DB/patches/0116~tmux.sql
rename to lib/copy_this/resources/patches/0116~tmux.sql
diff --git a/lib/DB/patches/0117~tmux.sql b/lib/copy_this/resources/patches/0117~tmux.sql
similarity index 100%
rename from lib/DB/patches/0117~tmux.sql
rename to lib/copy_this/resources/patches/0117~tmux.sql
diff --git a/lib/DB/patches/0118~release_naming_regexes.sql b/lib/copy_this/resources/patches/0118~release_naming_regexes.sql
similarity index 100%
rename from lib/DB/patches/0118~release_naming_regexes.sql
rename to lib/copy_this/resources/patches/0118~release_naming_regexes.sql
diff --git a/lib/DB/patches/0119~category_regex.sql b/lib/copy_this/resources/patches/0119~category_regex.sql
similarity index 100%
rename from lib/DB/patches/0119~category_regex.sql
rename to lib/copy_this/resources/patches/0119~category_regex.sql
diff --git a/lib/DB/patches/0120~release_naming_regexes.sql b/lib/copy_this/resources/patches/0120~release_naming_regexes.sql
similarity index 100%
rename from lib/DB/patches/0120~release_naming_regexes.sql
rename to lib/copy_this/resources/patches/0120~release_naming_regexes.sql
diff --git a/lib/DB/patches/0121~collection_regexes.sql b/lib/copy_this/resources/patches/0121~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0121~collection_regexes.sql
rename to lib/copy_this/resources/patches/0121~collection_regexes.sql
diff --git a/lib/DB/patches/0122~general.sql b/lib/copy_this/resources/patches/0122~general.sql
similarity index 100%
rename from lib/DB/patches/0122~general.sql
rename to lib/copy_this/resources/patches/0122~general.sql
diff --git a/lib/DB/patches/0123~release_naming_regexes.sql b/lib/copy_this/resources/patches/0123~release_naming_regexes.sql
similarity index 100%
rename from lib/DB/patches/0123~release_naming_regexes.sql
rename to lib/copy_this/resources/patches/0123~release_naming_regexes.sql
diff --git a/lib/DB/patches/0124~movieinfo.sql b/lib/copy_this/resources/patches/0124~movieinfo.sql
similarity index 100%
rename from lib/DB/patches/0124~movieinfo.sql
rename to lib/copy_this/resources/patches/0124~movieinfo.sql
diff --git a/lib/DB/patches/0125~faileddownloads.sql b/lib/copy_this/resources/patches/0125~faileddownloads.sql
similarity index 100%
rename from lib/DB/patches/0125~faileddownloads.sql
rename to lib/copy_this/resources/patches/0125~faileddownloads.sql
diff --git a/lib/DB/patches/0127~site.sql b/lib/copy_this/resources/patches/0127~site.sql
similarity index 100%
rename from lib/DB/patches/0127~site.sql
rename to lib/copy_this/resources/patches/0127~site.sql
diff --git a/lib/DB/patches/0128~collection_regexes.sql b/lib/copy_this/resources/patches/0128~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0128~collection_regexes.sql
rename to lib/copy_this/resources/patches/0128~collection_regexes.sql
diff --git a/lib/DB/patches/0129~category_regexes.sql b/lib/copy_this/resources/patches/0129~category_regexes.sql
similarity index 100%
rename from lib/DB/patches/0129~category_regexes.sql
rename to lib/copy_this/resources/patches/0129~category_regexes.sql
diff --git a/lib/DB/patches/0130~release_naming_regexes.sql b/lib/copy_this/resources/patches/0130~release_naming_regexes.sql
similarity index 100%
rename from lib/DB/patches/0130~release_naming_regexes.sql
rename to lib/copy_this/resources/patches/0130~release_naming_regexes.sql
diff --git a/lib/DB/patches/0131~blacklist.sql b/lib/copy_this/resources/patches/0131~blacklist.sql
similarity index 100%
rename from lib/DB/patches/0131~blacklist.sql
rename to lib/copy_this/resources/patches/0131~blacklist.sql
diff --git a/lib/DB/patches/0132~site.sql b/lib/copy_this/resources/patches/0132~site.sql
similarity index 100%
rename from lib/DB/patches/0132~site.sql
rename to lib/copy_this/resources/patches/0132~site.sql
diff --git a/lib/DB/patches/0133~collection_regexes.sql b/lib/copy_this/resources/patches/0133~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0133~collection_regexes.sql
rename to lib/copy_this/resources/patches/0133~collection_regexes.sql
diff --git a/lib/DB/patches/0134~collection_regexes.sql b/lib/copy_this/resources/patches/0134~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0134~collection_regexes.sql
rename to lib/copy_this/resources/patches/0134~collection_regexes.sql
diff --git a/lib/DB/patches/0135~collection_regexes.sql b/lib/copy_this/resources/patches/0135~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0135~collection_regexes.sql
rename to lib/copy_this/resources/patches/0135~collection_regexes.sql
diff --git a/lib/DB/patches/0136~release_naming_regexes.sql b/lib/copy_this/resources/patches/0136~release_naming_regexes.sql
similarity index 100%
rename from lib/DB/patches/0136~release_naming_regexes.sql
rename to lib/copy_this/resources/patches/0136~release_naming_regexes.sql
diff --git a/lib/DB/patches/0137~groups.sql b/lib/copy_this/resources/patches/0137~groups.sql
similarity index 100%
rename from lib/DB/patches/0137~groups.sql
rename to lib/copy_this/resources/patches/0137~groups.sql
diff --git a/lib/DB/patches/0138~collection_regexes.sql b/lib/copy_this/resources/patches/0138~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0138~collection_regexes.sql
rename to lib/copy_this/resources/patches/0138~collection_regexes.sql
diff --git a/lib/DB/patches/0139~users.sql b/lib/copy_this/resources/patches/0139~users.sql
similarity index 100%
rename from lib/DB/patches/0139~users.sql
rename to lib/copy_this/resources/patches/0139~users.sql
diff --git a/lib/DB/patches/0140~collection_regexes.sql b/lib/copy_this/resources/patches/0140~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0140~collection_regexes.sql
rename to lib/copy_this/resources/patches/0140~collection_regexes.sql
diff --git a/lib/DB/patches/0141~collection_regexes.sql b/lib/copy_this/resources/patches/0141~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0141~collection_regexes.sql
rename to lib/copy_this/resources/patches/0141~collection_regexes.sql
diff --git a/lib/DB/patches/0142~collection_regexes.sql b/lib/copy_this/resources/patches/0142~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0142~collection_regexes.sql
rename to lib/copy_this/resources/patches/0142~collection_regexes.sql
diff --git a/lib/DB/patches/0143~collection_regexes.sql b/lib/copy_this/resources/patches/0143~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0143~collection_regexes.sql
rename to lib/copy_this/resources/patches/0143~collection_regexes.sql
diff --git a/lib/DB/patches/0144~site.sql b/lib/copy_this/resources/patches/0144~site.sql
similarity index 100%
rename from lib/DB/patches/0144~site.sql
rename to lib/copy_this/resources/patches/0144~site.sql
diff --git a/lib/DB/patches/0145~collection_regexes.sql b/lib/copy_this/resources/patches/0145~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0145~collection_regexes.sql
rename to lib/copy_this/resources/patches/0145~collection_regexes.sql
diff --git a/lib/DB/patches/0146~collection_regexes.sql b/lib/copy_this/resources/patches/0146~collection_regexes.sql
similarity index 100%
rename from lib/DB/patches/0146~collection_regexes.sql
rename to lib/copy_this/resources/patches/0146~collection_regexes.sql
diff --git a/lib/DB/patches/0147~site.sql b/lib/copy_this/resources/patches/0147~site.sql
similarity index 100%
rename from lib/DB/patches/0147~site.sql
rename to lib/copy_this/resources/patches/0147~site.sql
diff --git a/lib/DB/patches/0148~site.sql b/lib/copy_this/resources/patches/0148~site.sql
similarity index 100%
rename from lib/DB/patches/0148~site.sql
rename to lib/copy_this/resources/patches/0148~site.sql
diff --git a/lib/copy_this/resources/patches/0149~site.sql b/lib/copy_this/resources/patches/0149~site.sql
new file mode 100644
index 000000000..86c6b14b1
--- /dev/null
+++ b/lib/copy_this/resources/patches/0149~site.sql
@@ -0,0 +1,14 @@
+ALTER TABLE site
+ADD section VARCHAR(25) NOT NULL DEFAULT '',
+ADD subsection VARCHAR(25) NOT NULL DEFAULT '',
+ADD name VARCHAR(25) NOT NULL DEFAULT '',
+ADD hint TEXT NOT NULL;
+ALTER TABLE site DROP COLUMN id;
+ALTER TABLE site DROP INDEX setting;
+UPDATE site SET name = setting;
+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', 149);
+
diff --git a/lib/copy_this/www/admin/ajax_sharing_settings.php b/lib/copy_this/www/admin/ajax_sharing_settings.php
index d57e713a7..fec342120 100644
--- a/lib/copy_this/www/admin/ajax_sharing_settings.php
+++ b/lib/copy_this/www/admin/ajax_sharing_settings.php
@@ -4,7 +4,7 @@ require_once './config.php';
// Login check.
$admin = new AdminPage;
-$db = new newznab\db\DB();
+$db = new newznab\db\Settings();
if (isset($_GET['site_ID']) && isset($_GET['site_status'])) {
$db->queryExec(sprintf('UPDATE sharing_sites SET enabled = %d WHERE id = %d', $_GET['site_status'], $_GET['site_ID']));
diff --git a/lib/copy_this/www/admin/db-optimise.php b/lib/copy_this/www/admin/db-optimise.php
index 978d04a28..58c24141b 100644
--- a/lib/copy_this/www/admin/db-optimise.php
+++ b/lib/copy_this/www/admin/db-optimise.php
@@ -2,10 +2,10 @@
require_once './config.php';
-use newznab\db\DB;
+use newznab\db\Settings;
$page = new AdminPage();
-$db = new DB;
+$db = new Settings;
$tablelist = $db->optimise();
$page->title = "DB Table Optimise";
diff --git a/lib/copy_this/www/admin/index.php b/lib/copy_this/www/admin/index.php
index d65829ff8..09633e91a 100644
--- a/lib/copy_this/www/admin/index.php
+++ b/lib/copy_this/www/admin/index.php
@@ -2,7 +2,7 @@
require_once './config.php';
-use newznab\db\DB;
+use newznab\db\Settings;
$page = new AdminPage();
@@ -18,7 +18,7 @@ $statusmsgs = array();
//
// mysql config settings
//
-$db = new DB();
+$db = new Settings();
$result = $db->queryDirect("SELECT @@group_concat_max_len, @@max_allowed_packet");
$data = $db->getAssocArray($result);
@@ -42,7 +42,7 @@ if ($page->site->rawretentiondays > 10)
$s = new Sites();
if (!property_exists($page->site, "dbversion"))
{
- $db = new DB();
+ $db = new Settings();
$db->queryInsert('INSERT INTO site (setting, value, updateddate ) VALUES (\'dbversion\', \'$Rev: 2248 $\', now())');
$page->site = $s->get();
}
diff --git a/lib/copy_this/www/admin/sharing.php b/lib/copy_this/www/admin/sharing.php
index 62dd0d4c2..1d480f371 100644
--- a/lib/copy_this/www/admin/sharing.php
+++ b/lib/copy_this/www/admin/sharing.php
@@ -1,12 +1,12 @@
title = 'Sharing Settings';
-$db = new DB();
+$db = new Settings();
$offset = (isset($_GET['offset']) ? $_GET['offset'] : 0);
diff --git a/lib/copy_this/www/admin/site-debug.php b/lib/copy_this/www/admin/site-debug.php
index 9830b7f42..d4af956d7 100644
--- a/lib/copy_this/www/admin/site-debug.php
+++ b/lib/copy_this/www/admin/site-debug.php
@@ -18,7 +18,7 @@ unset($s->sabapikey);
unset($s->sabcompletedir);
unset($s->sabvdir);
-$db = new newznab\db\DB;
+$db = new newznab\db\Settings;
$totalsize = 0;
$alltables = $db->query("show table status");
foreach ($alltables as $tablename)
diff --git a/lib/copy_this/www/pages/api.php b/lib/copy_this/www/pages/api.php
index cb12d5f4e..e12ecc4ee 100644
--- a/lib/copy_this/www/pages/api.php
+++ b/lib/copy_this/www/pages/api.php
@@ -656,10 +656,10 @@ function addCoverURL(&$releases, callable $getCoverURL)
/**
* Add language from media info XML to release search names.
* @param array $releases
- * @param \newznab\db\DB $settings
+ * @param \newznab\db\Settings $settings
* @return array
*/
-function addLanguage(&$releases, \newznab\db\DB $settings)
+function addLanguage(&$releases, \newznab\db\Settings $settings)
{
if ($releases && count($releases)) {
foreach ($releases as $key => $release) {
diff --git a/lib/copy_this/www/pages/content.php b/lib/copy_this/www/pages/content.php
index e280f0ccd..ad2836f5f 100644
--- a/lib/copy_this/www/pages/content.php
+++ b/lib/copy_this/www/pages/content.php
@@ -1,6 +1,4 @@
isLoggedIn())
@@ -11,7 +10,7 @@ $r = new Releases();
$s = new Sites();
$site = $s->get();
-$db = new DB();
+$db = new Settings();
if ($site->sabvdir == "" || $site->sabcompletedir == "" || !file_exists($site->sabcompletedir))
$page->show404();
diff --git a/lib/copy_this/www/pages/myshows.php b/lib/copy_this/www/pages/myshows.php
index a68178e87..1f31004c5 100644
--- a/lib/copy_this/www/pages/myshows.php
+++ b/lib/copy_this/www/pages/myshows.php
@@ -1,6 +1,6 @@
isLoggedIn())
$page->show403();
@@ -34,7 +34,7 @@ switch($action) {
}
else
{
- $db = new DB();
+ $db = new Settings();
$show = $db->queryOneRow(sprintf("select releasetitle from tvrage where rageID = %d", $rid));
if (!$show)
$page->show404('Seriously?');
diff --git a/lib/copy_this/www/pages/prehashinfo.php b/lib/copy_this/www/pages/prehashinfo.php
index 8971c5943..699281a5f 100644
--- a/lib/copy_this/www/pages/prehashinfo.php
+++ b/lib/copy_this/www/pages/prehashinfo.php
@@ -149,7 +149,7 @@ if (isset($_GET['type'])) {
case 'r':
case 'requestid':
if (isset($_GET['reqid']) && is_numeric($_GET['reqid']) && isset($_GET['group']) && is_string($_GET['group'])) {
- $db = new newznab\db\DB();
+ $db = new newznab\db\Settings();
$preData = $db->query(
sprintf('
SELECT p.*
@@ -175,7 +175,7 @@ if (isset($_GET['type'])) {
case 't':
case 'title':
if (isset($_GET['title'])) {
- $db = new newznab\db\DB();
+ $db = new newznab\db\Settings();
$preData = $db->query(
sprintf('SELECT * FROM prehash p WHERE p.title %s %s %s LIKE %s LIMIT %d OFFSET %d',
$newer,
@@ -193,7 +193,7 @@ if (isset($_GET['type'])) {
case 'm':
case 'md5':
if (isset($_GET['md5']) && strlen($_GET['title']) === 32) {
- $db = new newznab\db\DB();
+ $db = new newznab\db\Settings();
$preData = $db->query(
sprintf('SELECT * FROM prehash p INNER JOIN predbhash ph ON ph.pre_id = p.id WHERE MATCH(hashes) AGAINST (%s) %s %s %s LIMIT %d OFFSET %d',
$db->escapeString($_GET['md5']),
@@ -210,7 +210,7 @@ if (isset($_GET['type'])) {
case 's':
case 'sha1':
if (isset($_GET['sha1']) && strlen($_GET['sha1']) === 40) {
- $db = new newznab\db\DB();
+ $db = new newznab\db\Settings();
$preData = $db->query(
sprintf('SELECT * FROM prehash p INNER JOIN predbhash ph ON ph.pre_id = p.id WHERE MATCH(hashes) AGAINST (%s) %s %s %s LIMIT %d OFFSET %d',
$db->escapeString($_GET['sha1']),
@@ -226,7 +226,7 @@ if (isset($_GET['type'])) {
case 'a':
case 'all':
- $db = new newznab\db\DB();
+ $db = new newznab\db\Settings();
$preData = $db->query(
sprintf('SELECT * FROM prehash p WHERE 1=1 %s %s %s ORDER BY p.predate DESC LIMIT %d OFFSET %d',
$newer,
diff --git a/lib/copy_this/www/templates/nntmux/views/frontend/rssdesc.tpl b/lib/copy_this/www/templates/nntmux/views/frontend/rssdesc.tpl
index 91913e941..c9a509bd0 100644
--- a/lib/copy_this/www/templates/nntmux/views/frontend/rssdesc.tpl
+++ b/lib/copy_this/www/templates/nntmux/views/frontend/rssdesc.tpl
@@ -2,7 +2,7 @@
{$page->title}
- Here you can choose rss feeds from site categories. The feeds will present either decriptions or
+ Here you can choose rss feeds from settings categories. The feeds will present either decriptions or
downloads of Nzb files.
diff --git a/lib/decrypt_hashes.php b/lib/decrypt_hashes.php
index 620f631ce..63737f134 100644
--- a/lib/decrypt_hashes.php
+++ b/lib/decrypt_hashes.php
@@ -1,9 +1,9 @@
log->error(
diff --git a/lib/fixReleaseNames.php b/lib/fixReleaseNames.php
index 3d92696c0..1ff47f5bc 100644
--- a/lib/fixReleaseNames.php
+++ b/lib/fixReleaseNames.php
@@ -9,11 +9,11 @@
*/
require_once(dirname(__FILE__)."/../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
$n = "\n";
-$pdo = new DB();
+$pdo = new Settings();
$namefixer = new \NameFixer(['Settings' => $pdo]);
$predb = new \PreHash(['Echo' => true, 'Settings' => $pdo]);
$s = new Sites();
diff --git a/lib/testing/DB/change_USP_provider.php b/lib/testing/DB/change_USP_provider.php
index c27e63aff..36bc2bca9 100644
--- a/lib/testing/DB/change_USP_provider.php
+++ b/lib/testing/DB/change_USP_provider.php
@@ -1,7 +1,7 @@
log->setColor('Yellow') . "This script is used when you have switched UseNet Providers(USP) so you can pickup where you left off, rather than resetting all the groups.\nOnly use this script after you have updated your config.php file with your new USP info!!\nMake sure you " . $pdo->log->setColor('Red', 'Bold') . "DO NOT" . $pdo->log->setcolor('Yellow') . " have any update or postprocess scripts running when running this script!\n\n" . $pdo->log->setColor('Cyan') . "Usage: php change_USP_provider true\n");
diff --git a/lib/testing/DB/convert_mysql_tables.php b/lib/testing/DB/convert_mysql_tables.php
index 16823b728..7ca35e77b 100644
--- a/lib/testing/DB/convert_mysql_tables.php
+++ b/lib/testing/DB/convert_mysql_tables.php
@@ -1,11 +1,11 @@
true]);
+$pdo = new Settings(['checkVersion' => true]);
$ftinnodb = $pdo->isDbVersionAtLeast('5.6');
if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "fmyisam") {
diff --git a/lib/testing/DB/convert_to_tpg.php b/lib/testing/DB/convert_to_tpg.php
index b96b559d8..ddb4faaee 100644
--- a/lib/testing/DB/convert_to_tpg.php
+++ b/lib/testing/DB/convert_to_tpg.php
@@ -1,11 +1,11 @@
$pdo]);
$consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
$s = new Sites();
diff --git a/lib/testing/DB/mysqldump_tables.php b/lib/testing/DB/mysqldump_tables.php
index 4301cc468..919e77db3 100644
--- a/lib/testing/DB/mysqldump_tables.php
+++ b/lib/testing/DB/mysqldump_tables.php
@@ -1,13 +1,13 @@
$pdo->log]);
$timestart = TIME();
$relcount = $deleted = $total = 0;
diff --git a/lib/testing/DB/rename_to_lower.php b/lib/testing/DB/rename_to_lower.php
index d842d60fb..9e4d151c4 100644
--- a/lib/testing/DB/rename_to_lower.php
+++ b/lib/testing/DB/rename_to_lower.php
@@ -4,7 +4,7 @@ require_once(dirname(__FILE__) . "/../../../bin/config.php");
passthru('clear');
-$pdo = new newznab\db\DB();
+$pdo = new newznab\db\Settings();
if (!isset($argv[1]) || (isset($argv[1]) && $argv[1] !== 'true')) {
exit($pdo->log->error("\nThis script renames all table columns to lowercase, it can be dangerous. Please BACKUP your database before running this script.\n"
diff --git a/lib/testing/DB/reset_postprocessing.php b/lib/testing/DB/reset_postprocessing.php
index 3353da3d3..dfc018f01 100644
--- a/lib/testing/DB/reset_postprocessing.php
+++ b/lib/testing/DB/reset_postprocessing.php
@@ -1,9 +1,9 @@
$pdo->log]);
$ran = false;
diff --git a/lib/testing/DB/reset_truncate.php b/lib/testing/DB/reset_truncate.php
index b95c026e4..727ad3994 100644
--- a/lib/testing/DB/reset_truncate.php
+++ b/lib/testing/DB/reset_truncate.php
@@ -1,9 +1,9 @@
get();
diff --git a/lib/testing/DB/resetdb.php b/lib/testing/DB/resetdb.php
index 4913b3537..fcf43a7fa 100644
--- a/lib/testing/DB/resetdb.php
+++ b/lib/testing/DB/resetdb.php
@@ -1,11 +1,11 @@
log->error("\nThis script removes all releases and release related files. To run:\nphp resetdb.php true\n"));
diff --git a/lib/testing/Dev/clean_nzbs.php b/lib/testing/Dev/clean_nzbs.php
index 98dc1f9c2..a3c1c7e23 100644
--- a/lib/testing/Dev/clean_nzbs.php
+++ b/lib/testing/Dev/clean_nzbs.php
@@ -1,10 +1,10 @@
get();
diff --git a/lib/testing/Dev/renametopre.php b/lib/testing/Dev/renametopre.php
index 3a5d99678..465bc60fa 100644
--- a/lib/testing/Dev/renametopre.php
+++ b/lib/testing/Dev/renametopre.php
@@ -1,7 +1,7 @@
log->error(
diff --git a/lib/testing/PostProc/check_previews.php b/lib/testing/PostProc/check_previews.php
index a27df6249..28188ae70 100644
--- a/lib/testing/PostProc/check_previews.php
+++ b/lib/testing/PostProc/check_previews.php
@@ -4,10 +4,10 @@
// --------------------------------------------------------------
require_once(dirname(__FILE__) . "/../../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
use newznab\utility\Utility;
-$pdo = new DB();
+$pdo = new Settings();
$row = $pdo->queryOneRow("SELECT value FROM site WHERE setting = 'coverspath'");
if ($row !== false) {
diff --git a/lib/testing/PostProc/getConsole.php b/lib/testing/PostProc/getConsole.php
index 8bbe4b107..89d385ded 100644
--- a/lib/testing/PostProc/getConsole.php
+++ b/lib/testing/PostProc/getConsole.php
@@ -3,11 +3,11 @@
require_once(dirname(__FILE__) . "/../../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
$console = new \Konsole(['Echo' => true, 'Settings' => $pdo]);
$res = $pdo->queryDirect(sprintf("SELECT searchname, id FROM releases WHERE consoleinfoid IS NULL AND categoryid BETWEEN 1000 AND 1999 ORDER BY id DESC" ));
diff --git a/lib/testing/PostProc/getGameCovers.php b/lib/testing/PostProc/getGameCovers.php
index 3a17debd8..901eb2dc6 100644
--- a/lib/testing/PostProc/getGameCovers.php
+++ b/lib/testing/PostProc/getGameCovers.php
@@ -3,10 +3,10 @@
require_once(dirname(__FILE__) . "/../../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
$game = new \Games(['Echo' => true, 'Settings' => $pdo]);
$res = $pdo->query(
diff --git a/lib/testing/PostProc/getImdb.php b/lib/testing/PostProc/getImdb.php
index d10bba52a..97a714e50 100644
--- a/lib/testing/PostProc/getImdb.php
+++ b/lib/testing/PostProc/getImdb.php
@@ -2,9 +2,9 @@
//This script will update all records in the movieinfo table
require_once(dirname(__FILE__) . "/../../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
$c = new \ColorCLI();
$movie = new \Film(['Echo' => true, 'Settings' => $pdo]);
diff --git a/lib/testing/PostProc/getMovieCovers.php b/lib/testing/PostProc/getMovieCovers.php
index 637d0849c..3302bcd83 100644
--- a/lib/testing/PostProc/getMovieCovers.php
+++ b/lib/testing/PostProc/getMovieCovers.php
@@ -2,9 +2,9 @@
//This script will update all records in the movieinfo table where there is no cover
require_once(dirname(__FILE__) . "/../../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
$movie = new \Film(array('Echo' => true, 'Settings' => $pdo));
diff --git a/lib/testing/PostProc/getXXXCovers.php b/lib/testing/PostProc/getXXXCovers.php
index 6991235e2..94b2d3289 100644
--- a/lib/testing/PostProc/getXXXCovers.php
+++ b/lib/testing/PostProc/getXXXCovers.php
@@ -2,10 +2,10 @@
//This script will update all records in the xxxinfo table where there is no cover
require_once(dirname(__FILE__) . "/../../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
$movie = new XXX();
$c = new ColorCLI();
diff --git a/lib/testing/PostProc/populate_tvrage.php b/lib/testing/PostProc/populate_tvrage.php
index 2ab7ff847..f91e46ccd 100644
--- a/lib/testing/PostProc/populate_tvrage.php
+++ b/lib/testing/PostProc/populate_tvrage.php
@@ -1,10 +1,10 @@
log->error("\nThis script will download all tvrage shows and insert into the db.\n\n"
diff --git a/lib/testing/PostProc/updateBookImages.php b/lib/testing/PostProc/updateBookImages.php
index 2ae28a851..8fdc013de 100644
--- a/lib/testing/PostProc/updateBookImages.php
+++ b/lib/testing/PostProc/updateBookImages.php
@@ -1,10 +1,10 @@
$pdo, 'Echo' => true]);
$shows = $pdo->queryDirect("SELECT rageid FROM tvrage WHERE imgdata IS NULL ORDER BY rageid DESC LIMIT 2000");
diff --git a/lib/testing/PostProc/updateXXXImages.php b/lib/testing/PostProc/updateXXXImages.php
index b333ced02..5e4c1bf24 100644
--- a/lib/testing/PostProc/updateXXXImages.php
+++ b/lib/testing/PostProc/updateXXXImages.php
@@ -1,10 +1,10 @@
get();
diff --git a/lib/testing/_run_once/tpg_fixes.php b/lib/testing/_run_once/tpg_fixes.php
index 1ea2ea8fe..57fd322bb 100644
--- a/lib/testing/_run_once/tpg_fixes.php
+++ b/lib/testing/_run_once/tpg_fixes.php
@@ -28,9 +28,9 @@ if (!isset($argv[1]) || !in_array($argv[1], ['1'])) {
require_once(dirname(__FILE__) . "/../../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
$s = new Sites();
$site = $s->get();
diff --git a/lib/testing/populate_anidb.php b/lib/testing/populate_anidb.php
index 308d701a6..26ddd0a42 100644
--- a/lib/testing/populate_anidb.php
+++ b/lib/testing/populate_anidb.php
@@ -4,9 +4,9 @@
*/
require_once(dirname(__FILE__) . "/../../bin/config.php");
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
if ($argc > 1 && $argv[1] == true) {
(new \PopulateAniDB(['Settings' => $pdo, 'Echo' => true]))->populateTable('full');
diff --git a/lib/testing/predb_import_daily_batch.php b/lib/testing/predb_import_daily_batch.php
index aee44ad98..90abb542f 100644
--- a/lib/testing/predb_import_daily_batch.php
+++ b/lib/testing/predb_import_daily_batch.php
@@ -4,7 +4,7 @@
pre-fetching groupid and other data for faster inclusion in the main query.
*/
-use newznab\db\DB;
+use newznab\db\Settings;
use newznab\utility\Utility;
$config = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR .
@@ -72,7 +72,7 @@ if ($result) {
exec('clear');
$all_matches = array_unique($all_matches[1]);
$total = count($all_matches);
- $pdo = new DB();
+ $pdo = new Settings();
if ($argv[1] != 'progress') {
$progress['last'] = !is_numeric($argv[1]) ? time() : $argv[1];
diff --git a/lib/testing/recategorize.php b/lib/testing/recategorize.php
index c995c343d..d7cd563f0 100644
--- a/lib/testing/recategorize.php
+++ b/lib/testing/recategorize.php
@@ -1,7 +1,7 @@
0) {
//check the db connection
if ($pdo->ping(true) == false) {
unset($pdo);
- $pdo = new DB();
+ $pdo = new Settings();
}
$timer01 = time();
diff --git a/run.php b/run.php
index e624b6962..963d8b21f 100644
--- a/run.php
+++ b/run.php
@@ -1,14 +1,12 @@
get();
$t = new Tmux();
$tmux = $t->get();
$patch = (isset($tmux->sqlpatch)) ? $tmux->sqlpatch : 0;
@@ -17,12 +15,13 @@ $tmux_session = (isset($tmux->tmux_session)) ? $tmux->tmux_session : 0;
$seq = (isset($tmux->sequential)) ? $tmux->sequential : 0;
$powerline = (isset($tmux->powerline)) ? $tmux->powerline : 0;
$colors = (isset($tmux->colors)) ? $tmux->colors : 0;
-$nntpproxy = $site->nntpproxy;
-$tablepergroup = $site->tablepergroup;
+$nntpproxy = $pdo->getSetting('nntpproxy');
+$tablepergroup = $pdo->getSetting('tablepergroup');
$tablepergroup = ($tablepergroup != '') ? $tablepergroup : 0;
-$delaytimet = $site->delaytime;
+$delaytimet = $pdo->getSetting('delaytime');
$delaytimet = ($delaytimet) ? (int)$delaytimet : 2;
+Utility::isPatched();
Utility::clearScreen();
echo "Starting Tmux...\n";
@@ -38,9 +37,9 @@ if (count($nntpkill) !== 0) {
}
// Check database patch version
-if ($patch < 148) {
+/*if ($patch < 149) {
exit($c->error("\nYour database is not up to date. Please update.\nphp /var/www/newznab/misc/update_scripts/nix_scripts/tmux/lib/DB/patchDB.php\n"));
-}
+}*/
//check if session exists
$session = shell_exec("tmux list-session | grep $tmux_session");
@@ -50,7 +49,7 @@ if (count($session) !== 0) {
exit($pdo->log->error("tmux session: '" . $tmux_session . "' is already running, aborting.\n"));
}
-$nntpproxy = $site->nntpproxy;
+$nntpproxy = $pdo->getSetting('nntpproxy');
if ($nntpproxy == '1') {
$modules = ["nntp", "socketpool"];
foreach ($modules as &$value) {
@@ -62,16 +61,16 @@ if ($nntpproxy == '1') {
}
//reset collections dateadded to now if dateadded > delay time check
-echo $db->log->header("Resetting expired collections dateadded to now. This could take a minute or two. Really.");
+echo $pdo->log->header("Resetting expired collections dateadded to now. This could take a minute or two. Really.");
if ($tablepergroup == 1) {
$sql = "SHOW table status";
- $tables = $db->queryDirect($sql);
+ $tables = $pdo->queryDirect($sql);
$ran = 0;
foreach ($tables as $row) {
$tbl = $row['name'];
if (preg_match('/collections_\d+/', $tbl)) {
- $run = $db->queryExec('UPDATE ' . $tbl .
+ $run = $pdo->queryExec('UPDATE ' . $tbl .
' SET dateadded = now() WHERE dateadded < now() - INTERVAL ' .
$delaytimet . ' HOUR');
if ($run !== false) {
@@ -79,15 +78,15 @@ if ($tablepergroup == 1) {
}
}
}
- echo $db->log->primary(number_format($ran) . " collections reset.");
+ echo $pdo->log->primary(number_format($ran) . " collections reset.");
} else {
$ran = 0;
- $run = $db->queryExec('update collections set dateadded = now() WHERE dateadded < now() - INTERVAL ' .
+ $run = $pdo->queryExec('update collections set dateadded = now() WHERE dateadded < now() - INTERVAL ' .
$delaytimet . ' HOUR');
if ($run !== false) {
$ran += $run->rowCount();
}
- echo $db->log->primary(number_format($ran) . " collections reset.");
+ echo $pdo->log->primary(number_format($ran) . " collections reset.");
}
sleep(2);
@@ -105,13 +104,13 @@ function writelog($pane)
}
//remove folders from tmpunrar
-if (isset($site->tmpunrarpath)) {
- $tmpunrar = $site->tmpunrarpath;
+/*if (isset($pdo->getSetting('tmpunrarpath'))) {
+ $tmpunrar = $pdo->getSetting('tmpunrarpath');
if ((count(glob("$tmpunrar/*", GLOB_ONLYDIR))) > 0) {
echo $c->info("Removing dead folders from " . $tmpunrar);
exec("rm -r " . $tmpunrar . "/*");
}
-}
+}*/
function command_exist($cmd)
{
@@ -134,12 +133,12 @@ function python_module_exist($module)
return ($returnCode == 0 ? true : false);
}
-$nntpproxy = $site->nntpproxy;
+$nntpproxy = $pdo->getSetting('nntpproxy');
if ($nntpproxy == '1') {
$modules = array("nntp", "socketpool");
foreach ($modules as &$value) {
if (!python_module_exist($value)) {
- exit($db->log->error("\nNNTP Proxy requires " . $value . " python module but it's not installed. Aborting.\n"));
+ exit($pdo->log->error("\nNNTP Proxy requires " . $value . " python module but it's not installed. Aborting.\n"));
}
}
}
@@ -196,8 +195,8 @@ function start_apps($tmux_session)
function window_proxy($tmux_session, $window)
{
- global $site;
- $nntpproxy = $site->nntpproxy;
+ global $pdo;
+ $nntpproxy = $pdo->getSetting('nntpproxy');
if ($nntpproxy === '1') {
$DIR = NN_MISC;
$nntpproxypy = $DIR . "update_scripts/nix_scripts/tmux/python/nntpproxy.py";
@@ -207,7 +206,7 @@ function window_proxy($tmux_session, $window)
}
}
- if ($nntpproxy === '1' && ($site->alternate_nntp == '1')) {
+ if ($nntpproxy === '1' && ($pdo->getSetting('alternate_nntp') == '1')) {
$DIR = NN_TMUX;
$nntpproxypy = $DIR . "python/nntpproxy.py";
if (file_exists($DIR . "python/lib/nntpproxy_a.conf")) {
@@ -251,8 +250,8 @@ function window_optimize($tmux_session)
function window_sharing($tmux_session)
{
- $db = new newznab\db\DB();
- $sharing = $db->queryOneRow('SELECT enabled, posting, fetching FROM sharing');
+ $pdo = new newznab\db\Settings();
+ $sharing = $pdo->queryOneRow('SELECT enabled, posting, fetching FROM sharing');
$t = new \Tmux();
$tmux = $t->get();
$tmux_share = (isset($tmux->run_sharing)) ? $tmux->run_sharing : 0;
diff --git a/scripts/reset_rar_check.php b/scripts/reset_rar_check.php
index f1d4c1cc3..302e284f9 100755
--- a/scripts/reset_rar_check.php
+++ b/scripts/reset_rar_check.php
@@ -1,6 +1,6 @@
query("update releases set passwordstatus = -1 where rarinnerfilecount = 0");
diff --git a/start.php b/start.php
index 5b573e8f8..3c15bdbfd 100644
--- a/start.php
+++ b/start.php
@@ -8,9 +8,9 @@
*/
require_once realpath(__DIR__ . '/../../../../www/config.php');
-use newznab\db\DB;
+use newznab\db\Settings;
-$pdo = new DB();
+$pdo = new Settings();
$tmux = new \Tmux();
$tmux_settings = $tmux->get();