diff --git a/misc/sphinxsearch/create_se_tables.php b/misc/sphinxsearch/create_se_tables.php index 0a567cfd1..31d96dbb3 100644 --- a/misc/sphinxsearch/create_se_tables.php +++ b/misc/sphinxsearch/create_se_tables.php @@ -1,7 +1,7 @@ queryExec('SELECT id, guid, name, searchname, fromname FROM releases'); if ($rows !== false && $rows->rowCount()) { diff --git a/misc/sphinxsearch/toggle_search_type.php b/misc/sphinxsearch/toggle_search_type.php index e5c7168d3..99cf683d3 100644 --- a/misc/sphinxsearch/toggle_search_type.php +++ b/misc/sphinxsearch/toggle_search_type.php @@ -1,7 +1,7 @@ log->error('Error, NN_RELEASE_SEARCH_TYPE in www/settings.php must be set to SPHINX to optimize for Sphinx!' . PHP_EOL); } break; case 'standard': - revertToStandard(new DB()); + revertToStandard(new Settings()); break; } diff --git a/misc/testing/checkblanklinenzbs.php b/misc/testing/checkblanklinenzbs.php index 790cb4650..878bd2afd 100644 --- a/misc/testing/checkblanklinenzbs.php +++ b/misc/testing/checkblanklinenzbs.php @@ -1,10 +1,10 @@ get(); diff --git a/misc/testing/deletepreviews.php b/misc/testing/deletepreviews.php index 06b917ae9..354ef2660 100644 --- a/misc/testing/deletepreviews.php +++ b/misc/testing/deletepreviews.php @@ -4,10 +4,10 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; $releases = new Releases(); -$db = new DB; +$db = new Settings; // // delete all previews over a year old diff --git a/misc/testing/deletereleases.php b/misc/testing/deletereleases.php index ab58a2191..76c44bdfd 100644 --- a/misc/testing/deletereleases.php +++ b/misc/testing/deletereleases.php @@ -5,10 +5,10 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; $releases = new Releases(); -$db = new DB(); +$db = new Settings(); // // [1] delete all releases for a group which only has x number of files diff --git a/misc/testing/dumpnfo.php b/misc/testing/dumpnfo.php index 9d0993906..cf91eada3 100644 --- a/misc/testing/dumpnfo.php +++ b/misc/testing/dumpnfo.php @@ -1 +1 @@ -queryDirect("select releases.searchname, releases.postdate, uncompress(releasenfo.nfo) as nfo from releases inner join releasenfo on releases.ID = releasenfo.releaseID and releasenfo.nfo is not null order by postdate"); while ($row = $db->getAssocArray($res)) { $dir = date("Ymd", strtotime($row["postdate"])); if (!file_exists($dir)) mkdir($dir); $filename = $dir."/".safeFilename($row["searchname"]).".nfo"; if (!file_exists($filename)) { $fh = fopen($filename, 'w'); fwrite($fh, \newznab\utility\Utility::cp437toUTF($row["nfo"])); fclose($fh); } } \ No newline at end of file +queryDirect("select releases.searchname, releases.postdate, uncompress(releasenfo.nfo) as nfo from releases inner join releasenfo on releases.ID = releasenfo.releaseID and releasenfo.nfo is not null order by postdate"); while ($row = $db->getAssocArray($res)) { $dir = date("Ymd", strtotime($row["postdate"])); if (!file_exists($dir)) mkdir($dir); $filename = $dir."/".safeFilename($row["searchname"]).".nfo"; if (!file_exists($filename)) { $fh = fopen($filename, 'w'); fwrite($fh, \newznab\utility\Utility::cp437toUTF($row["nfo"])); fclose($fh); } } \ No newline at end of file diff --git a/misc/testing/fixTVRage.php b/misc/testing/fixTVRage.php index 0093fa6b9..35259c2f9 100644 --- a/misc/testing/fixTVRage.php +++ b/misc/testing/fixTVRage.php @@ -3,7 +3,7 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -$db = new \newznab\db\DB(); +$db = new \newznab\db\Settings(); $sql = "select distinct rageid from tvrage where rageid in (select rageid from tvrage where rageid != -2 group by rageid having count(*) > 1)"; $rows = $db->query($sql); diff --git a/misc/testing/fix_filesize.php b/misc/testing/fix_filesize.php index daf011028..6d454dd4d 100644 --- a/misc/testing/fix_filesize.php +++ b/misc/testing/fix_filesize.php @@ -8,9 +8,9 @@ Author: lordgnu require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; -$db = new DB; +$db = new Settings; $s = New Sites; $nzb = new NZB; diff --git a/misc/testing/fixreleasename.php b/misc/testing/fixreleasename.php index 5253c6f5e..6334cc985 100644 --- a/misc/testing/fixreleasename.php +++ b/misc/testing/fixreleasename.php @@ -2,7 +2,7 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -$db = new \newznab\db\DB(); +$db = new \newznab\db\Settings(); //query to find rough matches $rows = $db->query("SELECT ID, searchname from releases where searchname like '%QWERTY%'"); diff --git a/misc/testing/getConsole.php b/misc/testing/getConsole.php index 7d5e9f338..ec8504313 100644 --- a/misc/testing/getConsole.php +++ b/misc/testing/getConsole.php @@ -3,11 +3,11 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; $console = new Console(true); -$db = new DB(); +$db = new Settings(); $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where consoleinfoID IS NULL and categoryID in ( select ID from category where parentID = %d ) ORDER BY id DESC LIMIT %d", Category::CAT_PARENT_GAME, Console::NUMTOPROCESSPERTIME)); diff --git a/misc/testing/getCovers.php b/misc/testing/getCovers.php index 33a301b67..e1963d369 100644 --- a/misc/testing/getCovers.php +++ b/misc/testing/getCovers.php @@ -3,11 +3,11 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; $movie = new Movie(true); -$db = new DB(); +$db = new Settings(); $movies = $db->query("SELECT imdbID from movieinfo where cover = 0"); diff --git a/misc/testing/getTVInfo.php b/misc/testing/getTVInfo.php index 39c82ff4c..a25268bc9 100644 --- a/misc/testing/getTVInfo.php +++ b/misc/testing/getTVInfo.php @@ -1,11 +1,11 @@ query("select name from releases where categoryID IN (select ID from category where parentID = 5000) limit 0, 50"); diff --git a/misc/testing/movecat.php b/misc/testing/movecat.php index a5ccb02f3..fe212fcf7 100644 --- a/misc/testing/movecat.php +++ b/misc/testing/movecat.php @@ -4,10 +4,10 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; $releases = new Releases(); -$db = new DB(); +$db = new Settings(); // // [1] move mp3 files from other misc into audio mp3 diff --git a/misc/testing/parread.php b/misc/testing/parread.php index 167d60b66..b536b04ee 100644 --- a/misc/testing/parread.php +++ b/misc/testing/parread.php @@ -2,12 +2,12 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; -$s = new Sites(); +$s = new Settings(); $site = $s->get(); $releases = new Releases(); -$db = new DB(); +$db = new Settings(); $nzb = new NZB(); $nntp = new NNTP; diff --git a/misc/testing/queryamazon.php b/misc/testing/queryamazon.php index 6056f5c50..a736a9454 100644 --- a/misc/testing/queryamazon.php +++ b/misc/testing/queryamazon.php @@ -1 +1 @@ -get(); $title = "Long Arm, The - Franz Habl "; $obj = new AmazonProductAPI($site->amazonpubkey, $site->amazonprivkey, $site->amazonassociatetag); try { $amaz = $obj->searchProducts($title, AmazonProductAPI::BOOKS, "TITLE"); $item = array(); $item["asin"] = (string) $amaz->Items->Item->ASIN; $item["url"] = (string) $amaz->Items->Item->DetailPageURL; $item["cover"] = (string) $amaz->Items->Item->LargeImage->URL; $item["author"] = (string) $amaz->Items->Item->ItemAttributes->Author; $item["dewey"] = (string) $amaz->Items->Item->ItemAttributes->DeweyDecimalNumber; $item["ean"] = (string) $amaz->Items->Item->ItemAttributes->EAN; $item["isbn"] = (string) $amaz->Items->Item->ItemAttributes->ISBN; $item["publisher"] = (string) $amaz->Items->Item->ItemAttributes->Publisher; $item["publishdate"] = (string) $amaz->Items->Item->ItemAttributes->PublicationDate; $item["pages"] = (string) $amaz->Items->Item->ItemAttributes->NumberOfPages; $item["title"] = (string) $amaz->Items->Item->ItemAttributes->Title; $item["review"] = ""; if (isset($amaz->Items->Item->EditorialReviews)) $item["review"] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content)); print_r($item); } catch(Exception $e) { echo "failed"; } \ No newline at end of file +get(); $title = "Long Arm, The - Franz Habl "; $obj = new AmazonProductAPI($site->amazonpubkey, $site->amazonprivkey, $site->amazonassociatetag); try { $amaz = $obj->searchProducts($title, AmazonProductAPI::BOOKS, "TITLE"); $item = array(); $item["asin"] = (string) $amaz->Items->Item->ASIN; $item["url"] = (string) $amaz->Items->Item->DetailPageURL; $item["cover"] = (string) $amaz->Items->Item->LargeImage->URL; $item["author"] = (string) $amaz->Items->Item->ItemAttributes->Author; $item["dewey"] = (string) $amaz->Items->Item->ItemAttributes->DeweyDecimalNumber; $item["ean"] = (string) $amaz->Items->Item->ItemAttributes->EAN; $item["isbn"] = (string) $amaz->Items->Item->ItemAttributes->ISBN; $item["publisher"] = (string) $amaz->Items->Item->ItemAttributes->Publisher; $item["publishdate"] = (string) $amaz->Items->Item->ItemAttributes->PublicationDate; $item["pages"] = (string) $amaz->Items->Item->ItemAttributes->NumberOfPages; $item["title"] = (string) $amaz->Items->Item->ItemAttributes->Title; $item["review"] = ""; if (isset($amaz->Items->Item->EditorialReviews)) $item["review"] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content)); print_r($item); } catch(Exception $e) { echo "failed"; } \ No newline at end of file diff --git a/misc/testing/refreshMovie.php b/misc/testing/refreshMovie.php index 436c19246..836f2f6c1 100644 --- a/misc/testing/refreshMovie.php +++ b/misc/testing/refreshMovie.php @@ -2,10 +2,10 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; $movie = new Movie(true); -$db = new DB(); +$db = new Settings(); $movies = array(); $counter = 1; $sleepsecsbetweenscrape = 1; diff --git a/misc/testing/regexverify.php b/misc/testing/regexverify.php index 6e30555bf..211f96a39 100644 --- a/misc/testing/regexverify.php +++ b/misc/testing/regexverify.php @@ -26,7 +26,7 @@ $regs = array( ); $releases = new Releases(); -$db = new DB(); +$db = new Settings(); # fetch enabled regular expression $catsql = "select ID,groupname,regex from releaseregex where status = 1"; $res = $db->query($catsql); diff --git a/misc/testing/rottentom.php b/misc/testing/rottentom.php index ac93f1395..9a3e41b85 100644 --- a/misc/testing/rottentom.php +++ b/misc/testing/rottentom.php @@ -1,7 +1,7 @@ get(); if (isset($site->rottentomatokey)) diff --git a/misc/testing/spotnab.php b/misc/testing/spotnab.php index d7f837839..36bef03c8 100644 --- a/misc/testing/spotnab.php +++ b/misc/testing/spotnab.php @@ -141,7 +141,7 @@ FETCHING 3. Consider fetching your own posts back just to test things out...: - SET @key := (SELECT value FROM site WHERE setting = 'spotnabsitepubkey'); + SET @key := (SELECT value FROM settings WHERE setting = 'spotnabsitepubkey'); INSERT INTO `spotnabsources` (`ID` , `username`, `useremail` , `usenetgroup`, `publickey` , `active` , `description` , `lastupdate` ) diff --git a/misc/testing/test_blacklist.php b/misc/testing/test_blacklist.php index b318d5b54..a4f95ffce 100644 --- a/misc/testing/test_blacklist.php +++ b/misc/testing/test_blacklist.php @@ -10,7 +10,7 @@ // require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; # If satisfied with what is matched, set this to true and have @@ -200,11 +200,11 @@ function get_block($offset, $batch) $catsql = "SELECT releases.*,groups.name as groupname FROM " ."releases LEFT JOIN groups on releases.groupID = groups.ID "; - $db = new DB(); + $db = new Settings(); return $db->query($catsql.sprintf(' LIMIT %d,%d', $offset, $batch)); } -$db = new DB(); +$db = new Settings(); $errcnt=0; $total=0; diff --git a/misc/testing/test_regex.php b/misc/testing/test_regex.php index bf7f482e9..841b873c2 100644 --- a/misc/testing/test_regex.php +++ b/misc/testing/test_regex.php @@ -7,7 +7,7 @@ // require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; function handleError($errno, $errstr, $errfile, $errline, array $errcontext) { @@ -26,7 +26,7 @@ $regs = array( "simple" => '"data.mp3', ); -$db = new DB(); +$db = new Settings(); # fetch enabled regular expression $catsql = "select ID,groupname,regex from releaseregex where status = 1"; $res = $db->query($catsql); diff --git a/misc/testing/testnewamazon.php b/misc/testing/testnewamazon.php index b649616dc..caf4f43c2 100644 --- a/misc/testing/testnewamazon.php +++ b/misc/testing/testnewamazon.php @@ -5,7 +5,7 @@ use newznab\libraries\ApaiIO\Configuration\GenericConfiguration; use newznab\libraries\ApaiIO\Operations\Search; use newznab\libraries\ApaiIO\ApaiIO; -$s = new Sites(); +$s = new Settings(); $site = $s->get(); $pubkey = $site->amazonpubkey; diff --git a/misc/testing/tidynzbfolder.php b/misc/testing/tidynzbfolder.php index 49195afc6..edc301918 100644 --- a/misc/testing/tidynzbfolder.php +++ b/misc/testing/tidynzbfolder.php @@ -1,11 +1,11 @@ get(); -$db = new DB(); +$db = new Settings(); $r = new Releases(); // diff --git a/misc/testing/timetest.php b/misc/testing/timetest.php index 6ccb07b83..5a8bcfb38 100644 --- a/misc/testing/timetest.php +++ b/misc/testing/timetest.php @@ -2,10 +2,10 @@ //This Script Verifies your System Time vs Myself Time vs PHP Time require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; $res=""; -$db = new DB(); +$db = new Settings(); $res = $db->queryonerow( sprintf("Select now()")); foreach($res as $time){ echo "Mysql Time Is Now ".$time."\n";} diff --git a/misc/testing/transactiontest.php b/misc/testing/transactiontest.php index 7f9b0c706..d79b63191 100644 --- a/misc/testing/transactiontest.php +++ b/misc/testing/transactiontest.php @@ -3,7 +3,7 @@ try { // Create the first database class instance (which will initialize the PDO connection) - $db = new DB(); + $db = new Settings(); // For debug set the error mode $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -18,7 +18,7 @@ try { echo "--[ Insert run: {$i} ]----------------------------------------". PHP_EOL; // Create a new db class instance (multiple can exist) - $newDb = new DB(); + $newDb = new Settings(); // Check that there is a new db class instance, but no new PDO instance var_dump( $newDb, $newDb->getPDO() ); diff --git a/misc/testing/updateCategories.php b/misc/testing/updateCategories.php index f51781f4a..f10c6932e 100644 --- a/misc/testing/updateCategories.php +++ b/misc/testing/updateCategories.php @@ -2,9 +2,9 @@ //This script will rerun all releases against Category.php require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; -$db = new DB(); +$db = new Settings(); $category = new Categorize(); $changedcount = 0; $rescount = 0; diff --git a/misc/testing/updateTVRage.php b/misc/testing/updateTVRage.php index d97d2a5c8..d7f973a18 100644 --- a/misc/testing/updateTVRage.php +++ b/misc/testing/updateTVRage.php @@ -1,9 +1,9 @@ query("select releaseID, videowidth, videoheight from releasevideo where definition is null"); foreach($rels as $rel) { $sql = sprintf("update releasevideo set definition = %d where releaseID = %d", $rv->determineVideoResolution($rel["videowidth"], $rel["videoheight"]), $rel["releaseID"]); $db->exec($sql); } ?> \ No newline at end of file +query("select releaseID, videowidth, videoheight from releasevideo where definition is null"); foreach($rels as $rel) { $sql = sprintf("update releasevideo set definition = %d where releaseID = %d", $rv->determineVideoResolution($rel["videowidth"], $rel["videoheight"]), $rel["releaseID"]); $db->exec($sql); } ?> \ No newline at end of file diff --git a/misc/update_scripts/backfill.php b/misc/update_scripts/backfill.php index 0cc514e59..41593f8ea 100644 --- a/misc/update_scripts/backfill.php +++ b/misc/update_scripts/backfill.php @@ -1,9 +1,9 @@ $pdo]); diff --git a/misc/update_scripts/import.php b/misc/update_scripts/import.php index e20c861c1..10597a999 100644 --- a/misc/update_scripts/import.php +++ b/misc/update_scripts/import.php @@ -2,11 +2,11 @@ require_once dirname(__FILE__) . '/../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; use newznab\utility\Utility; $releases = new Releases(); -$db = new DB(); +$db = new Settings(); $cat = new Categorize(); $releaseRegex = new ReleaseRegex(); $nzb = new NZB(); diff --git a/misc/update_scripts/nix_scripts/multiprocessing/.do_not_run/switch.php b/misc/update_scripts/nix_scripts/multiprocessing/.do_not_run/switch.php index d64a583c5..13c63f8f6 100644 --- a/misc/update_scripts/nix_scripts/multiprocessing/.do_not_run/switch.php +++ b/misc/update_scripts/nix_scripts/multiprocessing/.do_not_run/switch.php @@ -6,7 +6,7 @@ if (!isset($argv[1])) { require_once dirname(__FILE__) . '/../../../../../www/config.php'; -use newznab\db\DB; +use newznab\db\Settings; use newznab\processing\PProcess; use newznab\processing\post\ProcessAdditional; @@ -22,7 +22,7 @@ switch ($options[1]) { // $options[3] => (int) backfill type from tmux settings. 1 = Backfill interval , 2 = Bakfill all case 'backfill': if (in_array((int)$options[3], [1, 2])) { - $pdo = new DB(); + $pdo = new Settings(); $value = $pdo->queryOneRow("SELECT value FROM tmux WHERE setting = 'backfill_qty'"); if ($value !== false) { $nntp = nntp($pdo); @@ -37,7 +37,7 @@ switch ($options[1]) { * $options[3] => (int) Quantity of articles to download. */ case 'backfill_all_quantity': - $pdo = new DB(); + $pdo = new Settings(); $nntp = nntp($pdo); (new \Backfill())->backfillAllGroups($options[2], $options[3]); break; @@ -45,7 +45,7 @@ switch ($options[1]) { // BackFill a single group, 10000 parts. // $options[2] => (string)group name, Name of group to work on. case 'backfill_all_quick': - $pdo = new DB(); + $pdo = new Settings(); $nntp = nntp($pdo); (new \Backfill())->backfillAllGroups($options[2], 10000, 'normal'); break; @@ -59,10 +59,10 @@ switch ($options[1]) { * $options[6] => (int) Number of threads. */ case 'get_range': - $pdo = new DB(); + $pdo = new Settings(); $nntp = nntp($pdo); $groups = new \Groups(); - $s = new Sites(); + $s = new Settings(); $site = $s->get(); $groupMySQL = $groups->getByName($options[3]); if ($nntp->isError($nntp->selectGroup($groupMySQL['name']))) { @@ -126,7 +126,7 @@ switch ($options[1]) { * $options[2] => (string) Group name. */ case 'part_repair': - $pdo = new DB(); + $pdo = new Settings(); $groups = new \Groups(['Settings' => $pdo]); $groupMySQL = $groups->getByName($options[2]); $nntp = nntp($pdo); @@ -143,8 +143,8 @@ switch ($options[1]) { // Process releases. // $options[2] => (string)groupCount, number of groups terminated by _ | (int)groupid, group to work on case 'releases': - $pdo = new DB(); - $s = new Sites(); + $pdo = new Settings(); + $s = new Settings(); $site = $s->get(); $releases = new \Releases(['Settings' => $pdo]); @@ -180,7 +180,7 @@ switch ($options[1]) { * $options[2] => (string) Group name. */ case 'update_group_headers': - $pdo = new DB(); + $pdo = new Settings(); $nntp = nntp($pdo); $groups = new \Groups(); $groupMySQL = $groups->getByName($options[2]); @@ -193,7 +193,7 @@ switch ($options[1]) { case 'update_per_group': if (is_numeric($options[2])) { - $pdo = new DB(); + $pdo = new Settings(); // Get the group info from MySQL. $groupMySQL = $pdo->queryOneRow(sprintf('SELECT * FROM groups WHERE id = %d', $options[2])); @@ -227,7 +227,7 @@ switch ($options[1]) { case 'pp_additional': case 'pp_nfo': if (charCheck($options[2])) { - $pdo = new DB(); + $pdo = new Settings(); // Create the connection here and pass, this is for post processing, so check for alternate. $nntp = nntp($pdo, true); @@ -247,7 +247,7 @@ switch ($options[1]) { */ case 'pp_movie': if (charCheck($options[2])) { - $pdo = new DB(); + $pdo = new Settings(); (new PProcess(['Settings' => $pdo]))->processMovies('', $options[2], (isset($options[3]) ? $options[3] : '')); } break; @@ -259,7 +259,7 @@ switch ($options[1]) { */ case 'pp_tv': if (charCheck($options[2])) { - $pdo = new DB(); + $pdo = new Settings(); (new PProcess(['Settings' => $pdo]))->processTv('', $options[2], (isset($options[3]) ? $options[3] : '')); } break; @@ -273,7 +273,7 @@ switch ($options[1]) { */ function processReleases($site, $releases, $groupID) { - $s = new Sites(); + $s = new Settings(); $site = $s->get(); $releaseCreationLimit = ($site->maxnzbsprocessed != '' ? (int)$site->maxnzbsprocessed : 1000); $releases->applyRegex($groupID); @@ -307,7 +307,7 @@ function charCheck($char) /** * Check if the group should be processed. * - * @param \newznab\db\DB $pdo + * @param \newznab\db\Settings $pdo * @param int $groupID */ function collectionCheck(&$pdo, $groupID) @@ -320,7 +320,7 @@ function collectionCheck(&$pdo, $groupID) /** * Connect to usenet, return NNTP object. * - * @param \DB $pdo + * @param \newznab\db\Settings $pdo * @param bool $alternate Use alternate NNTP provider. * * @return NNTP @@ -328,9 +328,7 @@ function collectionCheck(&$pdo, $groupID) function &nntp(&$pdo, $alternate = false) { $nntp = new \NNTP(['Settings' => $pdo]); - $s = new Sites(); - $site = $s->get(); - if (($alternate && $site->alternate_nntp == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { + if (($alternate && $this->pdo->getSetting('alternate_nntp') == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { exit("ERROR: Unable to connect to usenet." . PHP_EOL); } diff --git a/misc/update_scripts/nix_scripts/tmux/bin/fixreleasenames.php b/misc/update_scripts/nix_scripts/tmux/bin/fixreleasenames.php index 4c6d244a5..9f7e5bfbf 100644 --- a/misc/update_scripts/nix_scripts/tmux/bin/fixreleasenames.php +++ b/misc/update_scripts/nix_scripts/tmux/bin/fixreleasenames.php @@ -2,14 +2,14 @@ require_once(dirname(__FILE__) . "/config.php"); -use newznab\db\DB; +use newznab\db\Settings; use newznab\processing\PProcess; $c = new ColorCLI(); if (!isset($argv[1])) { exit($c->error("This script is not intended to be run manually, it is called from fixreleasenames_threaded.py.")); } else if (isset($argv[1])) { - $db = new DB(); + $db = new Settings(); $namefixer = new \NameFixer(['Settings' => $pdo]); $pieces = explode(' ', $argv[1]); if (isset($pieces[1]) && $pieces[0] == 'nfo') { diff --git a/misc/update_scripts/nix_scripts/tmux/bin/groupfixrelnames.php b/misc/update_scripts/nix_scripts/tmux/bin/groupfixrelnames.php index becec5970..d9e844269 100644 --- a/misc/update_scripts/nix_scripts/tmux/bin/groupfixrelnames.php +++ b/misc/update_scripts/nix_scripts/tmux/bin/groupfixrelnames.php @@ -1,11 +1,11 @@ get(); if (!isset($argv[1])) { @@ -130,7 +130,7 @@ if (!isset($argv[1])) { if ($releases instanceof Traversable) { $nntp = new NNTP(['Settings' => $pdo]); - if (($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) { exit($pdo->log->error("Unable to connect to usenet.")); } diff --git a/misc/update_scripts/nix_scripts/tmux/bin/postprocess.php b/misc/update_scripts/nix_scripts/tmux/bin/postprocess.php index bd997314b..0980d03a0 100644 --- a/misc/update_scripts/nix_scripts/tmux/bin/postprocess.php +++ b/misc/update_scripts/nix_scripts/tmux/bin/postprocess.php @@ -2,11 +2,11 @@ require_once(dirname(__FILE__) . '/config.php'); -use newznab\db\DB; +use newznab\db\Settings; use newznab\processing\PProcess; -$pdo = new DB(); -$s = new Sites(); +$pdo = new Settings(); +$s = new Settings(); $site = $s->get(); /** Array with possible arguments for run and @@ -67,7 +67,7 @@ if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_ar $nntp = null; if ($args[$argv[1]] === true) { $nntp = new NNTP(['Settings' => $pdo]); - if (($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) { exit($pdo->log->error("Unable to connect to usenet." . PHP_EOL)); } } diff --git a/misc/update_scripts/nix_scripts/tmux/bin/update_groups.php b/misc/update_scripts/nix_scripts/tmux/bin/update_groups.php index 135482181..7ba533171 100644 --- a/misc/update_scripts/nix_scripts/tmux/bin/update_groups.php +++ b/misc/update_scripts/nix_scripts/tmux/bin/update_groups.php @@ -2,11 +2,11 @@ require_once(dirname(__FILE__) . '/config.php'); -use newznab\db\DB; +use newznab\db\Settings; $start = TIME(); -$pdo = new DB(); +$pdo = new Settings(); $consoleTools = new \ConsoleTools(['ColorCLI' => $pdo->log]); // Create the connection here and pass diff --git a/misc/update_scripts/nix_scripts/tmux/bin/update_releases.php b/misc/update_scripts/nix_scripts/tmux/bin/update_releases.php index 42ec9910b..fa635a543 100644 --- a/misc/update_scripts/nix_scripts/tmux/bin/update_releases.php +++ b/misc/update_scripts/nix_scripts/tmux/bin/update_releases.php @@ -1,13 +1,13 @@ get(); -$pdo = new DB(); +$pdo = new Settings(); if (isset($argv[2]) && $argv[2] === 'true') { // Create the connection here and pass diff --git a/misc/update_scripts/nix_scripts/tmux/lib/DB/mysqldump_tables.php b/misc/update_scripts/nix_scripts/tmux/lib/DB/mysqldump_tables.php index 9750c82e1..906aa6de5 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/DB/mysqldump_tables.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/DB/mysqldump_tables.php @@ -1,12 +1,12 @@ sqlpatch; $patched = 0; $patches = array(); - $db = new DB(); + $db = new Settings(); $backedup = false; $c = new ColorCLI(); $DIR = dirname (__FILE__); diff --git a/misc/update_scripts/nix_scripts/tmux/lib/decrypt_hashes.php b/misc/update_scripts/nix_scripts/tmux/lib/decrypt_hashes.php index 86dd017a2..337b31f5f 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/decrypt_hashes.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/decrypt_hashes.php @@ -1,9 +1,9 @@ log->error( diff --git a/misc/update_scripts/nix_scripts/tmux/lib/fixReleaseNames.php b/misc/update_scripts/nix_scripts/tmux/lib/fixReleaseNames.php index ce836433d..76884688c 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/fixReleaseNames.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/fixReleaseNames.php @@ -9,14 +9,14 @@ */ 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(); +$s = new Settings(); $site = $s->get(); if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]) && isset($argv[4])) { @@ -37,7 +37,7 @@ if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]) && isset($argv[4])) { $nntp = null; if ($argv[1] == 7 || $argv[1] == 8) { $nntp = new \NNTP(['Settings' => $pdo]); - if (($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) { echo $pdo->log->error("Unable to connect to usenet.\n"); return; } diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/change_USP_provider.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/change_USP_provider.php index c27e63aff..36bc2bca9 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/change_USP_provider.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/convert_mysql_tables.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/convert_mysql_tables.php index 16823b728..7ca35e77b 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/convert_mysql_tables.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/convert_to_tpg.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/convert_to_tpg.php index 3a4dc38fc..60340a1a0 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/convert_to_tpg.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/convert_to_tpg.php @@ -1,7 +1,7 @@ $pdo]); $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]); -$s = new Sites(); +$s = new Settings(); $site = $s->get(); $DoPartRepair = ($site->partrepair == '0') ? false : true; diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/mysqldump_tables.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/mysqldump_tables.php index 4301cc468..919e77db3 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/mysqldump_tables.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/mysqldump_tables.php @@ -1,13 +1,13 @@ $pdo->log]); $timestart = TIME(); $relcount = $deleted = $total = 0; diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/rename_to_lower.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/rename_to_lower.php index d842d60fb..9e4d151c4 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/rename_to_lower.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_postprocessing.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_postprocessing.php index 3353da3d3..dfc018f01 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_postprocessing.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_postprocessing.php @@ -1,9 +1,9 @@ $pdo->log]); $ran = false; diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_truncate.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_truncate.php index b95c026e4..a03eab198 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_truncate.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/reset_truncate.php @@ -1,10 +1,10 @@ get(); if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "drop")) { diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/resetdb.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/resetdb.php index 4913b3537..d86767963 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/DB/resetdb.php +++ b/misc/update_scripts/nix_scripts/tmux/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")); @@ -57,7 +57,7 @@ foreach ($tables as $row) { (new \SphinxSearch())->truncateRTIndex('releases_rt'); $pdo->optimise(false, 'full'); -$s = new Sites(); +$s = new Settings(); $site = $s->get(); echo $pdo->log->header("Deleting nzbfiles subfolders."); diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/clean_nzbs.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/clean_nzbs.php index 98dc1f9c2..df03c2727 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/clean_nzbs.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/clean_nzbs.php @@ -1,11 +1,11 @@ get(); if (isset($argv[1]) && ($argv[1] === "true" || $argv[1] === "delete")) { diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/renametopre.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/renametopre.php index 3a5d99678..465bc60fa 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/renametopre.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/testing/Dev/renametopre.php @@ -1,7 +1,7 @@ log->error( diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getConsole.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getConsole.php index 8bbe4b107..89d385ded 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getConsole.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getGameCovers.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getGameCovers.php index 3a17debd8..901eb2dc6 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getGameCovers.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getImdb.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getImdb.php index d10bba52a..97a714e50 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getImdb.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getMovieCovers.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getMovieCovers.php index 637d0849c..3302bcd83 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getMovieCovers.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getXXXCovers.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getXXXCovers.php index 6991235e2..94b2d3289 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/getXXXCovers.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/populate_tvrage.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/populate_tvrage.php index 2ab7ff847..f91e46ccd 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/populate_tvrage.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateBookImages.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateBookImages.php index 2ae28a851..8fdc013de 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateBookImages.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateXXXImages.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateXXXImages.php index b333ced02..5e4c1bf24 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateXXXImages.php +++ b/misc/update_scripts/nix_scripts/tmux/lib/testing/PostProc/updateXXXImages.php @@ -1,10 +1,10 @@ get(); if (!$site->tablepergroup) { diff --git a/misc/update_scripts/nix_scripts/tmux/lib/testing/populate_anidb.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/populate_anidb.php index 308d701a6..26ddd0a42 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/populate_anidb.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/predb_import_daily_batch.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/predb_import_daily_batch.php index aee44ad98..90abb542f 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/predb_import_daily_batch.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/lib/testing/recategorize.php b/misc/update_scripts/nix_scripts/tmux/lib/testing/recategorize.php index c995c343d..d7cd563f0 100644 --- a/misc/update_scripts/nix_scripts/tmux/lib/testing/recategorize.php +++ b/misc/update_scripts/nix_scripts/tmux/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/misc/update_scripts/nix_scripts/tmux/python/backfill_safe_threaded.py b/misc/update_scripts/nix_scripts/tmux/python/backfill_safe_threaded.py index 6bb6d0aa9..0f3d1bc34 100644 --- a/misc/update_scripts/nix_scripts/tmux/python/backfill_safe_threaded.py +++ b/misc/update_scripts/nix_scripts/tmux/python/backfill_safe_threaded.py @@ -47,7 +47,7 @@ previous = "'alt.binaries.crap'" while count < 10000: #get values from db cur = info.connect() - cur[0].execute("SELECT (SELECT value FROM site WHERE setting = 'backfillthreads') AS a, (SELECT value FROM tmux WHERE setting = 'backfill_qty') AS b, (SELECT value FROM tmux WHERE setting = 'backfill') AS c, (SELECT value FROM tmux WHERE setting = 'backfill_order') AS e, (SELECT value FROM tmux WHERE setting = 'backfill_days') AS f, (SELECT value FROM site WHERE setting = 'maxmssgs') AS g") + cur[0].execute("SELECT (SELECT value FROM settings WHERE setting = 'backfillthreads') AS a, (SELECT value FROM tmux WHERE setting = 'backfill_qty') AS b, (SELECT value FROM tmux WHERE setting = 'backfill') AS c, (SELECT value FROM tmux WHERE setting = 'backfill_order') AS e, (SELECT value FROM tmux WHERE setting = 'backfill_days') AS f, (SELECT value FROM settings WHERE setting = 'maxmssgs') AS g") dbgrab = cur[0].fetchall() run_threads = int(dbgrab[0][0]) backfill_qty = int(dbgrab[0][1]) @@ -74,7 +74,7 @@ while count < 10000: if intbackfilltype == 1: backfilldays = "backfill_target" elif intbackfilltype == 2: - backfilldays = "datediff(curdate(),(SELECT value FROM site WHERE setting = 'safebackfilldate'))" + backfilldays = "datediff(curdate(),(SELECT value FROM settings WHERE setting = 'safebackfilldate'))" #query to grab backfill groups if len(sys.argv) == 1: diff --git a/misc/update_scripts/nix_scripts/tmux/python/backfill_threaded.py b/misc/update_scripts/nix_scripts/tmux/python/backfill_threaded.py index 702de8481..70a5816f5 100644 --- a/misc/update_scripts/nix_scripts/tmux/python/backfill_threaded.py +++ b/misc/update_scripts/nix_scripts/tmux/python/backfill_threaded.py @@ -23,7 +23,7 @@ pathname = os.path.abspath(os.path.dirname(sys.argv[0])) print(bcolors.HEADER + "\nBackfill Threaded Started at {}".format(datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) #get values from db -cur[0].execute("SELECT (SELECT value FROM site WHERE setting = 'backfillthreads') as a, (SELECT value FROM tmux WHERE setting = 'backfill') as c, (SELECT value FROM tmux WHERE setting = 'backfill_groups') as d, (SELECT value FROM tmux WHERE setting = 'backfill_order') as e, (SELECT value FROM tmux WHERE setting = 'backfill_days') as f") +cur[0].execute("SELECT (SELECT value FROM settings WHERE setting = 'backfillthreads') as a, (SELECT value FROM tmux WHERE setting = 'backfill') as c, (SELECT value FROM tmux WHERE setting = 'backfill_groups') as d, (SELECT value FROM tmux WHERE setting = 'backfill_order') as e, (SELECT value FROM tmux WHERE setting = 'backfill_days') as f") dbgrab = cur[0].fetchall() run_threads = int(dbgrab[0][0]) type = int(dbgrab[0][1]) @@ -49,7 +49,7 @@ else: if intbackfilltype == 1: backfilldays = "backfill_target" elif intbackfilltype == 2: - backfilldays = "datediff(curdate(),(SELECT value FROM site WHERE setting = 'safebackfilldate'))" + backfilldays = "datediff(curdate(),(SELECT value FROM settings WHERE setting = 'safebackfilldate'))" #exit is set to safe backfill if len(sys.argv) == 1 and type == 4: diff --git a/misc/update_scripts/nix_scripts/tmux/python/binaries_safe_threaded.py b/misc/update_scripts/nix_scripts/tmux/python/binaries_safe_threaded.py index 1a04f31bb..d6b034f8b 100644 --- a/misc/update_scripts/nix_scripts/tmux/python/binaries_safe_threaded.py +++ b/misc/update_scripts/nix_scripts/tmux/python/binaries_safe_threaded.py @@ -24,7 +24,7 @@ count = 0 print(bcolors.HEADER + "\nBinaries Safe Threaded Started at {}".format(datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) #get values from db -cur[0].execute("SELECT (SELECT value FROM site WHERE setting = 'binarythreads') AS a, (SELECT value FROM site WHERE setting = 'maxmssgs') AS b") +cur[0].execute("SELECT (SELECT value FROM settings WHERE setting = 'binarythreads') AS a, (SELECT value FROM settings WHERE setting = 'maxmssgs') AS b") dbgrab = cur[0].fetchall() run_threads = int(dbgrab[0][0]) diff --git a/misc/update_scripts/nix_scripts/tmux/python/postprocess_threaded.py b/misc/update_scripts/nix_scripts/tmux/python/postprocess_threaded.py index 8646df698..80768408c 100644 --- a/misc/update_scripts/nix_scripts/tmux/python/postprocess_threaded.py +++ b/misc/update_scripts/nix_scripts/tmux/python/postprocess_threaded.py @@ -82,7 +82,7 @@ start_time = time.time() pathname = os.path.abspath(os.path.dirname(sys.argv[0])) if len(sys.argv) > 1 and sys.argv[1] == "additional": - cur[0].execute("SELECT (SELECT value FROM site WHERE setting = 'postthreads') AS a, (SELECT value FROM site WHERE setting = 'maxaddprocessed') AS b, (SELECT value FROM site WHERE setting = 'maxnfoprocessed') AS c, (SELECT value FROM site WHERE setting = 'maximdbprocessed') AS d, (SELECT value FROM site WHERE setting = 'maxrageprocessed') AS e, (SELECT value FROM site WHERE setting = 'maxsizetopostprocess') AS f, (SELECT value FROM site WHERE setting = 'tmpunrarpath') AS g, (SELECT value FROM tmux WHERE setting = 'post') AS h, (SELECT value FROM tmux WHERE setting = 'post_non') AS i, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -1 "+groupid+") as j, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -2 "+groupid+") as k, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -3 "+groupid+") as l, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -4 "+groupid+") as m, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -5 "+groupid+") as n, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -6 "+groupid+") as o") + cur[0].execute("SELECT (SELECT value FROM settings WHERE setting = 'postthreads') AS a, (SELECT value FROM settings WHERE setting = 'maxaddprocessed') AS b, (SELECT value FROM settings WHERE setting = 'maxnfoprocessed') AS c, (SELECT value FROM settings WHERE setting = 'maximdbprocessed') AS d, (SELECT value FROM settings WHERE setting = 'maxrageprocessed') AS e, (SELECT value FROM settings WHERE setting = 'maxsizetopostprocess') AS f, (SELECT value FROM settings WHERE setting = 'tmpunrarpath') AS g, (SELECT value FROM tmux WHERE setting = 'post') AS h, (SELECT value FROM tmux WHERE setting = 'post_non') AS i, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -1 "+groupid+") as j, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -2 "+groupid+") as k, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -3 "+groupid+") as l, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -4 "+groupid+") as m, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -5 "+groupid+") as n, (SELECT count(*) FROM releases WHERE haspreview = -1 and passwordstatus = -6 "+groupid+") as o") dbgrab = cur[0].fetchall() ps1 = format(int(dbgrab[0][9])) ps2 = format(int(dbgrab[0][10])) @@ -91,7 +91,7 @@ if len(sys.argv) > 1 and sys.argv[1] == "additional": ps5 = format(int(dbgrab[0][13])) ps6 = format(int(dbgrab[0][14])) elif len(sys.argv) > 1 and sys.argv[1] == "nfo": - cur[0].execute("SELECT (SELECT value FROM site WHERE setting = 'nfothreads') AS a, (SELECT value FROM site WHERE setting = 'maxaddprocessed') AS b, (SELECT value FROM site WHERE setting = 'maxnfoprocessed') AS c, (SELECT value FROM site WHERE setting = 'maximdbprocessed') AS d, (SELECT value FROM site WHERE setting = 'maxrageprocessed') AS e, (SELECT value FROM site WHERE setting = 'maxsizetopostprocess') AS f, (SELECT value FROM site WHERE setting = 'tmpunrarpath') AS g, (SELECT value FROM tmux WHERE setting = 'post') AS h, (SELECT value FROM tmux WHERE setting = 'post_non') AS i, (SELECT count(*) FROM releases WHERE nfostatus = -1 "+groupid+") as j, (SELECT count(*) FROM releases WHERE nfostatus = -2 "+groupid+") as k, (SELECT count(*) FROM releases WHERE nfostatus = -3 "+groupid+") as l, (SELECT count(*) FROM releases WHERE nfostatus = -4 "+groupid+") as m, (SELECT count(*) FROM releases WHERE nfostatus = -5 "+groupid+") as n, (SELECT count(*) FROM releases WHERE nfostatus = -6 "+groupid+") as o") + cur[0].execute("SELECT (SELECT value FROM settings WHERE setting = 'nfothreads') AS a, (SELECT value FROM settings WHERE setting = 'maxaddprocessed') AS b, (SELECT value FROM settings WHERE setting = 'maxnfoprocessed') AS c, (SELECT value FROM settings WHERE setting = 'maximdbprocessed') AS d, (SELECT value FROM settings WHERE setting = 'maxrageprocessed') AS e, (SELECT value FROM settings WHERE setting = 'maxsizetopostprocess') AS f, (SELECT value FROM settings WHERE setting = 'tmpunrarpath') AS g, (SELECT value FROM tmux WHERE setting = 'post') AS h, (SELECT value FROM tmux WHERE setting = 'post_non') AS i, (SELECT count(*) FROM releases WHERE nfostatus = -1 "+groupid+") as j, (SELECT count(*) FROM releases WHERE nfostatus = -2 "+groupid+") as k, (SELECT count(*) FROM releases WHERE nfostatus = -3 "+groupid+") as l, (SELECT count(*) FROM releases WHERE nfostatus = -4 "+groupid+") as m, (SELECT count(*) FROM releases WHERE nfostatus = -5 "+groupid+") as n, (SELECT count(*) FROM releases WHERE nfostatus = -6 "+groupid+") as o") dbgrab = cur[0].fetchall() ps1 = format(int(dbgrab[0][9])) ps2 = format(int(dbgrab[0][10])) @@ -100,7 +100,7 @@ elif len(sys.argv) > 1 and sys.argv[1] == "nfo": ps5 = format(int(dbgrab[0][13])) ps6 = format(int(dbgrab[0][14])) elif len(sys.argv) > 1 and (sys.argv[1] == "movie" or sys.argv[1] == "tv"): - cur[0].execute("SELECT(SELECT value FROM site WHERE setting = 'postthreadsnon') AS a, (SELECT value FROM site WHERE setting = 'maxaddprocessed') AS b, (SELECT value FROM site WHERE setting = 'maxnfoprocessed') AS c, (SELECT value FROM site WHERE setting = 'maximdbprocessed') AS d, (SELECT value FROM site WHERE setting = 'maxrageprocessed') AS e, (SELECT value FROM site WHERE setting = 'maxsizetopostprocess') AS f, (SELECT value FROM site WHERE setting = 'tmpunrarpath') AS g, (SELECT value FROM tmux WHERE setting = 'post') AS h, (SELECT value FROM tmux WHERE setting = 'post_non') AS i") + cur[0].execute("SELECT(SELECT value FROM settings WHERE setting = 'postthreadsnon') AS a, (SELECT value FROM settings WHERE setting = 'maxaddprocessed') AS b, (SELECT value FROM settings WHERE setting = 'maxnfoprocessed') AS c, (SELECT value FROM settings WHERE setting = 'maximdbprocessed') AS d, (SELECT value FROM settings WHERE setting = 'maxrageprocessed') AS e, (SELECT value FROM settings WHERE setting = 'maxsizetopostprocess') AS f, (SELECT value FROM settings WHERE setting = 'tmpunrarpath') AS g, (SELECT value FROM tmux WHERE setting = 'post') AS h, (SELECT value FROM tmux WHERE setting = 'post_non') AS i") dbgrab = cur[0].fetchall() else: print(bcolors.ERROR + "\nAn argument is required, \npostprocess_threaded.py [additional, nfo, movie, tv]\n" + bcolors.ENDC) diff --git a/misc/update_scripts/nix_scripts/tmux/python/releases_threaded.py b/misc/update_scripts/nix_scripts/tmux/python/releases_threaded.py index ea6e1e0c3..01112c8df 100644 --- a/misc/update_scripts/nix_scripts/tmux/python/releases_threaded.py +++ b/misc/update_scripts/nix_scripts/tmux/python/releases_threaded.py @@ -21,7 +21,7 @@ pathname = os.path.abspath(os.path.dirname(sys.argv[0])) print(bcolors.HEADER + "\nUpdate Releases Threaded Started at {}".format(datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) -cur[0].execute("SELECT (SELECT value FROM site WHERE setting = 'tablepergroup') AS a, (SELECT value FROM site WHERE setting = 'releasethreads') AS b") +cur[0].execute("SELECT (SELECT value FROM settings WHERE setting = 'tablepergroup') AS a, (SELECT value FROM settings WHERE setting = 'releasethreads') AS b") dbgrab = cur[0].fetchall() allowed = int(dbgrab[0][0]) threads = int(dbgrab[0][1]) diff --git a/misc/update_scripts/nix_scripts/tmux/python/requestid_threaded.py b/misc/update_scripts/nix_scripts/tmux/python/requestid_threaded.py index ac6d507f3..14dc810ef 100644 --- a/misc/update_scripts/nix_scripts/tmux/python/requestid_threaded.py +++ b/misc/update_scripts/nix_scripts/tmux/python/requestid_threaded.py @@ -44,7 +44,7 @@ except: print(bcolors.HEADER + "\n\nRequestID Threaded Started at {}".format(datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) -cur[0].execute("SELECT value FROM site WHERE setting = 'request_hours'") +cur[0].execute("SELECT value FROM settings WHERE setting = 'request_hours'") dbgrab = cur[0].fetchone() request_hours = str(dbgrab[0]) cur[0].execute("SELECT DISTINCT(g.id) FROM releases r INNER JOIN groups g ON r.groupid = g.id WHERE r.nzbstatus = 1 AND r.prehashid = 0 AND r.isrequestid = 1 AND r.reqidstatus in (0, -1) OR (r.reqidstatus = -3 AND r.adddate > NOW() - INTERVAL " + request_hours + " HOUR)") diff --git a/misc/update_scripts/nix_scripts/tmux/python/update_threaded.py b/misc/update_scripts/nix_scripts/tmux/python/update_threaded.py index 6ef063539..c88be1fb4 100644 --- a/misc/update_scripts/nix_scripts/tmux/python/update_threaded.py +++ b/misc/update_scripts/nix_scripts/tmux/python/update_threaded.py @@ -18,13 +18,13 @@ conf = info.readConfig() cur = info.connect() start_time = time.time() pathname = os.path.abspath(os.path.dirname(sys.argv[0])) -cur[0].execute("SELECT value FROM site WHERE setting = 'releasethreads'") +cur[0].execute("SELECT value FROM settings WHERE setting = 'releasethreads'") threads = cur[0].fetchone() threads = int(threads[0]) print(bcolors.HEADER + "\nUpdate Per Group Threaded Started at {}".format(datetime.datetime.now().strftime("%H:%M:%S")) + bcolors.ENDC) -cur[0].execute("SELECT value FROM site WHERE setting = 'tablepergroup'") +cur[0].execute("SELECT value FROM settings WHERE setting = 'tablepergroup'") allowed = cur[0].fetchone() if int(allowed[0]) == 0: print(bcolors.ERROR + "Table per group not enabled" + bcolors.ENDC) diff --git a/misc/update_scripts/nix_scripts/tmux/run.php b/misc/update_scripts/nix_scripts/tmux/run.php index cc782721f..6bb3799b7 100644 --- a/misc/update_scripts/nix_scripts/tmux/run.php +++ b/misc/update_scripts/nix_scripts/tmux/run.php @@ -1,13 +1,13 @@ get(); $t = new Tmux(); $tmux = $t->get(); @@ -175,7 +175,7 @@ function window_proxy($tmux_session, $window) } } - if ($nntpproxy === '1' && ($site->alternate_nntp == '1')) { + if ($nntpproxy === '1' && ($this->pdo->getSetting('alternate_nntp') == '1')) { $DIR = NN_TMUX; $nntpproxypy = $DIR . "python/nntpproxy.py"; if (file_exists($DIR . "python/lib/nntpproxy_a.conf")) { @@ -219,7 +219,7 @@ function window_optimize($tmux_session) function window_sharing($tmux_session) { - $pdo = new DB(); + $pdo = new Settings(); $sharing = $pdo->queryOneRow('SELECT enabled, posting, fetching FROM sharing'); $t = new \Tmux(); $tmux = $t->get(); diff --git a/misc/update_scripts/nix_scripts/tmux/scripts/reset_rar_check.php b/misc/update_scripts/nix_scripts/tmux/scripts/reset_rar_check.php index 5041290e8..1ae65df68 100644 --- a/misc/update_scripts/nix_scripts/tmux/scripts/reset_rar_check.php +++ b/misc/update_scripts/nix_scripts/tmux/scripts/reset_rar_check.php @@ -2,6 +2,6 @@ require(dirname(__FILE__) . "/../bin/config.php"); require_once(WWW_DIR . "/lib/framework/db.php"); -$db = new DB(); +$db = new Settings(); $rel = $db->query("update releases set passwordstatus = -1 where rarinnerfilecount = 0"); diff --git a/misc/update_scripts/nix_scripts/tmux/start.php b/misc/update_scripts/nix_scripts/tmux/start.php index 5b573e8f8..3c15bdbfd 100644 --- a/misc/update_scripts/nix_scripts/tmux/start.php +++ b/misc/update_scripts/nix_scripts/tmux/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(); diff --git a/misc/update_scripts/nntpproxy.php b/misc/update_scripts/nntpproxy.php index bcc74ff1e..6387f36ae 100644 --- a/misc/update_scripts/nntpproxy.php +++ b/misc/update_scripts/nntpproxy.php @@ -1,17 +1,15 @@ get(); $powerline = (isset($tmux->powerline)) ? $tmux->powerline : 0; -$s= new Sites(); -$site = $s->get(); $tmux_session = 'NNTPProxy'; @@ -21,7 +19,7 @@ function python_module_exist($module) return ($returnCode == 0 ? true : false); } -$nntpproxy = $site->nntpproxy; +$nntpproxy = $pdo->getSetting('nntpproxy'); if ($nntpproxy === '0') { exit(); } else { @@ -36,7 +34,6 @@ if ($nntpproxy === '0') { function window_proxy($tmux_session, $powerline) { global $pdo; - global $site; $DIR = NN_MISC; if ($powerline === '1') { @@ -45,7 +42,7 @@ function window_proxy($tmux_session, $powerline) $tmuxconfig = $DIR . "update_scripts/nix_scripts/tmux/tmux.conf"; } - $nntpproxy = $site->nntpproxy; + $nntpproxy = $pdo->getSetting('nntpproxy'); if ($nntpproxy === '1') { $DIR = NN_MISC; $nntpproxypy = $DIR . "update_scripts/nix_scripts/_tmux/python/nntpproxy.py"; @@ -55,7 +52,7 @@ function window_proxy($tmux_session, $powerline) } } - if ($nntpproxy == '1' && ($site->alternate_nntp == '1')) { + if ($nntpproxy == '1' && ($pdo->getSetting('alternate_nntp') == '1')) { $DIR = NN_MISC; $nntpproxypy = $DIR . "update_scripts/nix_scripts/tmux/python/nntpproxy.py"; if (file_exists($DIR . "update_scripts/nix_scripts/tmux/python/lib/nntpproxy_a.conf")) { diff --git a/misc/update_scripts/optimise_db.php b/misc/update_scripts/optimise_db.php index 3c474e17e..e61a79588 100644 --- a/misc/update_scripts/optimise_db.php +++ b/misc/update_scripts/optimise_db.php @@ -2,11 +2,11 @@ require_once("config.php"); -use newznab\db\DB; +use newznab\db\Settings; $force = ((isset($argv[1]) && ($argv[1] == "true"))); -$db = new DB; +$db = new Settings; $ret = $db->optimise($force); if (count($ret) > 0) diff --git a/misc/update_scripts/update_binaries.php b/misc/update_scripts/update_binaries.php index e210f63e8..0046e5a60 100644 --- a/misc/update_scripts/update_binaries.php +++ b/misc/update_scripts/update_binaries.php @@ -2,9 +2,9 @@ require_once("config.php"); -use newznab\db\DB; +use newznab\db\Settings; -$pdo = new DB(); +$pdo = new Settings(); // Create the connection here and pass $nntp = new \NNTP(['Settings' => $pdo]); diff --git a/misc/update_scripts/update_database_version.php b/misc/update_scripts/update_database_version.php index 33dfd1f36..d1c47868e 100644 --- a/misc/update_scripts/update_database_version.php +++ b/misc/update_scripts/update_database_version.php @@ -2,9 +2,9 @@ require_once("config.php"); -use newznab\db\DB; +use newznab\db\Settings; -$s = new Sites(); +$s = new Settings(); $site = $s->get(); $patches = $s->getUnappliedPatches($site); @@ -18,7 +18,7 @@ else { echo "Patchn : Executing patch ".basename($patch)."\n"; - $db = new DB(); + $db = new Settings(); $rows = $db->query("select * from site"); $dbData = file_get_contents($patch); diff --git a/newznab/controllers/AdminPage.php b/newznab/controllers/AdminPage.php index 5d798f645..68a06ab45 100644 --- a/newznab/controllers/AdminPage.php +++ b/newznab/controllers/AdminPage.php @@ -14,8 +14,8 @@ class AdminPage extends BasePage parent::__construct(); $tplpaths = []; - if ($this->site->style != "default") - $tplpaths["style_admin"] = WWW_DIR.'templates/'.$this->site->style.'/views/admin'; + if ($this->settings->getSetting('style') != "default") + $tplpaths["style_admin"] = WWW_DIR.'templates/'.$this->settings->getSetting('style').'/views/admin'; $tplpaths["admin"] = WWW_DIR.'templates/default/views/admin'; $tplpaths["frontend"] = WWW_DIR.'templates/default/views/frontend'; $this->smarty->setTemplateDir($tplpaths); diff --git a/newznab/controllers/AniDB.php b/newznab/controllers/AniDB.php index 24cc00879..dcb15deb8 100644 --- a/newznab/controllers/AniDB.php +++ b/newznab/controllers/AniDB.php @@ -1,11 +1,11 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); } /** diff --git a/newznab/controllers/Backfill.php b/newznab/controllers/Backfill.php index 5da1a6920..b19a5b7d3 100644 --- a/newznab/controllers/Backfill.php +++ b/newznab/controllers/Backfill.php @@ -1,13 +1,13 @@ _echoCLI = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->_groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->pdo])); $this->_nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Settings' => $this->pdo]) ); - $s = new Sites(); + $s = new Settings(); $this->site = $s->get(); $this->_debug = (NN_LOGGING || NN_DEBUG); diff --git a/newznab/controllers/BasePage.php b/newznab/controllers/BasePage.php index a11056c4c..e76f63cfc 100644 --- a/newznab/controllers/BasePage.php +++ b/newznab/controllers/BasePage.php @@ -3,11 +3,12 @@ require_once SMARTY_DIR . 'Smarty.class.php'; require_once NN_LIB . 'utility' . DS . 'SmartyUtils.php'; use newznab\controllers\Captcha; +use newznab\db\Settings; class BasePage { /** - * @var \newznab\db\DB + * @var \newznab\db\Settings */ public $settings = null; @@ -58,11 +59,10 @@ class BasePage } // set site variable - $s = new Sites(); - $this->site = $s->get(); + $this->pdo = new Settings(); // Buffer settings/DB connection. - $this->settings = new newznab\db\DB(); + $this->settings = new Settings(); $this->smarty = new Smarty(); $this->captcha = new Captcha(['Settings' => $this->settings]); diff --git a/newznab/controllers/Binaries.php b/newznab/controllers/Binaries.php index 41e8dbb86..b9c01581f 100644 --- a/newznab/controllers/Binaries.php +++ b/newznab/controllers/Binaries.php @@ -1,6 +1,6 @@ _colorCLI = ($options['ColorCLI'] instanceof \ColorCLI ? $options['ColorCLI'] : new \ColorCLI()); $this->_echoCLI = ($options['Echo'] && NN_ECHOCLI); - $this->_pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->_pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->_nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->_colorCLI, 'Settings' => $this->_pdo, 'ColorCLI' => $this->_colorCLI])); $this->_groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->_pdo])); @@ -145,18 +145,16 @@ class Binaries $this->n = "\n"; - $s = new Sites(); - $site = $s->get(); - $this->messageBuffer = ($site->maxmssgs != '') ? $site->maxmssgs : 20000; - $this->_compressedHeaders = ($site->compressedheaders == "1") ? true : false; - $this->MaxMsgsPerRun = (!empty($site->maxmsgsperrun)) ? $site->maxmsgsperrun : 200000; - $this->_newGroupScanByDays = ($site->newgroupscanmethod == "1") ? true : false; - $this->_newGroupMessagesToScan = (!empty($site->newgroupmsgstoscan)) ? $site->newgroupmsgstoscan : 50000; - $this->_newGroupDaysToScan = (!empty($site->newgroupdaystoscan)) ? $site->newgroupdaystoscan : 3; - $this->_tablePerGroup = ($site->tablepergroup == 1 ? true : false); - $this->_partRepair = ($site->partrepair == 0 ? false : true); - $this->_partRepairLimit = ($site->maxpartrepair != '') ? (int)$site->maxpartrepair : 15000; - $this->_partRepairMaxTries = ($site->partrepairmaxtries != '' ? (int)$site->partrepairmaxtries : 3); + $this->messageBuffer = ($this->_pdo->getSetting('maxmssgs') != '') ? $this->_pdo->getSetting('maxmssgs') : 20000; + $this->_compressedHeaders = ($this->_pdo->getSetting('compressedheaders') == "1") ? true : false; + $this->MaxMsgsPerRun = (!empty($this->_pdo->getSetting('maxmsgsperrun'))) ? $this->_pdo->getSetting('maxmsgsperrun') : 200000; + $this->_newGroupScanByDays = ($this->_pdo->getSetting('newsgroupscanmethod') == "1") ? true : false; + $this->_newGroupMessagesToScan = (!empty($this->_pdo->getSetting('newgroupmsgstoscan'))) ? $this->_pdo->getSetting('newgroupmsgstoscan') : 50000; + $this->_newGroupDaysToScan = (!empty($this->_pdo->getSetting('newgroupdaystoscan'))) ? $this->_pdo->getSetting('newgroupdaystoscan') : 3; + $this->_tablePerGroup = ($this->_pdo->getSetting('tablepergroup') == 1 ? true : false); + $this->_partRepair = ($this->_pdo->getSetting('partrepair') == 0 ? false : true); + $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->blackList = array(); //cache of our black/white list $this->blackList_by_group = array(); @@ -478,7 +476,7 @@ class Binaries */ function scan($groupArr, $first, $last, $type = 'update') { - $db = new DB(); + $db = new Settings(); $releaseRegex = new ReleaseRegex; $n = $this->n; // Check if MySQL tables exist, create if they do not, get their names at the same time. @@ -910,7 +908,7 @@ class Binaries */ private function addMissingParts($numbers, $tablename, $groupID) { - $db = new DB(); + $db = new Settings(); $added = false; $insertStr = "INSERT INTO $tablename (numberid, groupid) VALUES "; foreach ($numbers as $number) { @@ -1011,7 +1009,7 @@ class Binaries */ public function search($search, $limit = 1000, $excludedcats = array()) { - $db = new DB(); + $db = new Settings(); // // if the query starts with a ^ it indicates the search is looking for items which start with the term @@ -1059,7 +1057,7 @@ class Binaries */ public function getForReleaseId($id) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("select binaries.* from binaries where releaseid = %d order by relpart", $id)); } @@ -1069,7 +1067,7 @@ class Binaries */ public function getById($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select binaries.*, groups.name as groupname from binaries left outer join groups on binaries.groupid = groups.id where binaries.id = %d ", $id)); } @@ -1079,7 +1077,7 @@ class Binaries */ public function getBlacklist($activeonly = true) { - $db = new DB(); + $db = new Settings(); $where = ""; if ($activeonly) @@ -1098,7 +1096,7 @@ class Binaries */ public function getBlacklistByID($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from binaryblacklist where id = %d ", $id)); } @@ -1108,7 +1106,7 @@ class Binaries */ public function deleteBlacklist($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from binaryblacklist where id = %d", $id)); } @@ -1118,7 +1116,7 @@ class Binaries */ public function updateBlacklist($regex) { - $db = new DB(); + $db = new Settings(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -1136,7 +1134,7 @@ class Binaries */ public function addBlacklist($regex) { - $db = new DB(); + $db = new Settings(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -1157,7 +1155,7 @@ class Binaries */ public function delete($id) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from parts where binaryid = %d", $id)); $db->queryExec(sprintf("DELETE from binaries where id = %d", $id)); } diff --git a/newznab/controllers/Book.php b/newznab/controllers/Book.php index a08b286cf..f32c45b09 100644 --- a/newznab/controllers/Book.php +++ b/newznab/controllers/Book.php @@ -1,6 +1,6 @@ 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 DB(); + $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 3e19608f8..10961bba9 100644 --- a/newznab/controllers/Books.php +++ b/newznab/controllers/Books.php @@ -1,6 +1,6 @@ echooutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $s = new Sites(); - $this->site = $s->get(); - - $this->pubkey = $this->site->amazonpubkey; - $this->privkey = $this->site->amazonprivkey; - $this->asstag = $this->site->amazonassociatetag; + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->bookqty = ($this->site->maxbooksprocessed != '') ? $this->site->maxbooksprocessed : 300; - $this->sleeptime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000; + $this->sleeptime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = NN_COVERS . 'book' . DS; $this->bookreqids = ($this->site->book_reqids == null || $this->site->book_reqids == "") ? 7010 : $this->site->book_reqids; $this->renamed = ''; @@ -171,7 +168,7 @@ class Books sprintf( "SELECT COUNT(DISTINCT r.bookinfoid) AS num FROM releases r " . "INNER JOIN bookinfo boo ON boo.id = r.bookinfoid AND boo.title != '' and boo.cover = 1 " - . "WHERE r.nzbstatus = 1 AND r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') " + . "WHERE r.nzbstatus = 1 AND r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') " . "AND %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist ) ); @@ -224,7 +221,7 @@ class Books . "LEFT OUTER JOIN releasenfo rn ON rn.releaseid = r.id " . "INNER JOIN bookinfo boo ON boo.id = r.bookinfoid " . "WHERE r.nzbstatus = 1 AND boo.cover = 1 AND boo.title != '' AND " - . "r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') AND %s %s %s %s " + . "r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') AND %s %s %s %s " . "GROUP BY boo.id ORDER BY %s %s" . $limit, $browseby, $catsrch, $maxage, $exccatlist, $order[0], $order[1] ); diff --git a/newznab/controllers/Captcha.php b/newznab/controllers/Captcha.php index 7986f6cb8..e4e2555f3 100644 --- a/newznab/controllers/Captcha.php +++ b/newznab/controllers/Captcha.php @@ -1,13 +1,13 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $s = new \Sites(); - $this->site = $s->get(); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); } /** @@ -189,8 +187,8 @@ class Captcha { return true; } - $this->sitekey = $this->site->recaptchapublickey; - $this->secretkey = $this->site->recaptchaprivatekey; + $this->sitekey = $this->pdo->getSetting('recaptchapublickey'); + $this->secretkey = $this->pdo->getSetting('recaptchaprivatekey'); if ($this->sitekey != false && $this->sitekey != '') { if ($this->secretkey != false && $this->secretkey != '') { diff --git a/newznab/controllers/Categorize.php b/newznab/controllers/Categorize.php index 8cd81344c..1c69b4e19 100644 --- a/newznab/controllers/Categorize.php +++ b/newznab/controllers/Categorize.php @@ -1,5 +1,7 @@ site = $s->get(); - $this->pdo = new \newznab\db\DB(); - $this->categorizeForeign = ($this->site->categorizeforeign == "0") ? false : true; - $this->catWebDL = ($this->site->catwebdl == "0") ? false : true; + $this->pdo = new Settings(); + $this->categorizeForeign = ($this->pdo->getSetting('categorizeforeign') == "0") ? false : true; + $this->catWebDL = ($this->pdo->getSetting('catwebdl') == "0") ? false : true; } /** diff --git a/newznab/controllers/Category.php b/newznab/controllers/Category.php index 583a2b10d..379e1024d 100644 --- a/newznab/controllers/Category.php +++ b/newznab/controllers/Category.php @@ -1,6 +1,6 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); } /** @@ -143,7 +143,7 @@ class Category */ public function isParent($cid) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $ret = $db->queryOneRow(sprintf("select count(*) as count from category where id = %d and parentid is null", $cid), true); if ($ret['count']) return true; @@ -156,7 +156,7 @@ class Category */ public function getChildren($cid) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); return $db->query(sprintf("select c.* from category c where parentid = %d", $cid), true); } @@ -166,7 +166,7 @@ class Category */ public function getFlat($activeonly = false) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $act = ""; if ($activeonly) $act = sprintf(" where c.status = %d ", Category::STATUS_ACTIVE); @@ -181,7 +181,7 @@ class Category */ public function getEnabledParentNames() { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); return $db->query("SELECT title FROM category WHERE parentid IS NULL AND status = 1"); } @@ -193,7 +193,7 @@ class Category */ public function getDisabledIDs() { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); return $db->query("SELECT id FROM category WHERE status = 2 OR parentid IN (SELECT id FROM category WHERE status = 2 AND parentid IS NULL)"); } @@ -202,14 +202,14 @@ class Category */ public function getById($id) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); return $db->queryOneRow(sprintf("SELECT c.disablepreview, c.id, c.description, c.minsizetoformrelease, c.maxsizetoformrelease, CONCAT(COALESCE(cp.title,'') , CASE WHEN cp.title IS NULL THEN '' ELSE ' > ' END , c.title) as title, c.status, c.parentid from category c left outer join category cp on cp.id = c.parentid where c.id = %d", $id)); } public function getSizeRangeById($id) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $res = $db->queryOneRow(sprintf("SELECT c.minsizetoformrelease, c.maxsizetoformrelease, cp.minsizetoformrelease as p_minsizetoformrelease, cp.maxsizetoformrelease as p_maxsizetoformrelease" . " from category c left outer join category cp on cp.id = c.parentid where c.id = %d", $id ) @@ -255,14 +255,14 @@ class Category */ public function getByIds($ids) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); return $db->query(sprintf("SELECT concat(cp.title, ' > ',c.title) as title from category c inner join category cp on cp.id = c.parentid where c.id in (%s)", implode(',', $ids))); } public function getNameByID($ID) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $parent = $db->queryOneRow(sprintf("SELECT title FROM category WHERE id = %d", substr($ID, 0, 1) . "000")); $cat = $db->queryOneRow(sprintf("SELECT title FROM category WHERE id = %d", $ID)); @@ -274,7 +274,7 @@ class Category */ public function update($id, $status, $desc, $disablepreview, $minsize, $maxsize) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); return $db->queryExec(sprintf("update category set disablepreview = %d, status = %d, minsizetoformrelease = %d, maxsizetoformrelease = %d, description = %s where id = %d", $disablepreview, $status, $minsize, $maxsize, $db->escapeString($desc), $id)); } @@ -284,7 +284,7 @@ class Category */ public function getForMenu($excludedcats = array()) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $ret = array(); $exccatlist = ""; @@ -340,7 +340,7 @@ class Category */ public function get($activeonly = false, $excludedcats = array()) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $exccatlist = ""; if (count($excludedcats) > 0) diff --git a/newznab/controllers/Console.php b/newznab/controllers/Console.php index 2d7a84987..fc453c62f 100644 --- a/newznab/controllers/Console.php +++ b/newznab/controllers/Console.php @@ -1,7 +1,7 @@ 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\DB(); - $this->imgSavePath = WWW_DIR.'covers/console/'; + $this->pdo = new Settings(); + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); + $this->imgSavePath = NN_COVERS . 'console' . DS; } /** diff --git a/newznab/controllers/Contents.php b/newznab/controllers/Contents.php index ec94db79e..400f2a992 100644 --- a/newznab/controllers/Contents.php +++ b/newznab/controllers/Contents.php @@ -1,6 +1,6 @@ queryExec(sprintf("DELETE from content where id=%d", $id)); } @@ -43,7 +43,7 @@ class Contents */ public function update($content) { - $db = new DB(); + $db = new Settings(); $content = $this->validate($content); $db->queryExec(sprintf("update content set role=%d, title = %s , url = %s , body = %s , metadescription = %s , metakeywords = %s , contenttype = %d , showinmenu = %d , status = %d , ordinal = %d where id = %d ", $content["role"], $db->escapeString($content["title"]), $db->escapeString($content["url"]), $db->escapeString($content["body"]), $db->escapeString($content["metadescription"]), $db->escapeString($content["metakeywords"]), $content["contenttype"], $content["showinmenu"], $content["status"], $content["ordinal"], $content["id"] )); } @@ -53,7 +53,7 @@ class Contents */ public function add($content) { - $db = new DB(); + $db = new Settings(); $content = $this->validate($content); @@ -65,7 +65,7 @@ class Contents */ public function get() { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("select * from content where status = 1 order by contenttype, coalesce(ordinal, 1000000)")); } @@ -74,7 +74,7 @@ class Contents */ public function getAll() { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("select * from content order by contenttype, coalesce(ordinal, 1000000)")); } @@ -83,7 +83,7 @@ class Contents */ public function getByID($id, $role) { - $db = new DB(); + $db = new Settings(); if ($role == Users::ROLE_ADMIN) $role = ""; else @@ -97,7 +97,7 @@ class Contents */ public function getIndex() { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from content where status=1 and contenttype = %d ", Contents::TYPEINDEX), true); } @@ -106,7 +106,7 @@ class Contents */ public function getForMenuByTypeAndRole($id, $role) { - $db = new DB(); + $db = new Settings(); if ($role == Users::ROLE_ADMIN) $role = ""; else diff --git a/newznab/controllers/Enzebe.php b/newznab/controllers/Enzebe.php index 68e72a31b..525836dc3 100644 --- a/newznab/controllers/Enzebe.php +++ b/newznab/controllers/Enzebe.php @@ -1,6 +1,6 @@ pdo = ($pdo instanceof DB ? $pdo : new DB()); - $s = new Sites(); + $this->pdo = ($pdo instanceof Settings ? $pdo : new Settings()); + $s = new Settings(); $this->site = $s->get(); $this->tablePerGroup = ($this->site->tablepergroup == 0 ? false : true); @@ -104,7 +104,7 @@ class Enzebe public function initiateForWrite($groupID) { $this->groupid = $groupID; - $site = new Sites(); + $site = new Settings(); // Set table names if ($this->tablePerGroup === true) { if ($this->groupid == '') { diff --git a/newznab/controllers/Episode.php b/newznab/controllers/Episode.php index cc8656679..233e6a37f 100644 --- a/newznab/controllers/Episode.php +++ b/newznab/controllers/Episode.php @@ -1,6 +1,6 @@ queryOneRow(sprintf('SELECT * FROM episodeinfo WHERE id = %d', $episodeinfoID)); } @@ -21,7 +21,7 @@ class Episode */ public function getEpisodeInfoByName($showtitle, $fullep, $epabsolute='0') { - $db = new DB(); + $db = new Settings(); if($epabsolute == '0') //as string - not int. if(!preg_match('/[21]\d{3}\/\d{2}\/\d{2}/', $fullep)) diff --git a/newznab/controllers/Film.php b/newznab/controllers/Film.php index 4eace77a8..5cdb753fc 100644 --- a/newznab/controllers/Film.php +++ b/newznab/controllers/Film.php @@ -1,6 +1,6 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $s = new Sites(); - $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->lookuplanguage = ($this->site->lookuplanguage != '') ? (string)$this->site->lookuplanguage : 'en'; + $this->lookuplanguage = ($this->pdo->getSetting('lookuplanguage') != '') ? (string)$this->pdo->getSetting('lookuplanguage') : 'en'; - $this->fanartapikey = $this->site->fanarttvkey; - $this->imdburl = ($this->site->imdburl == 0 ? false : true); - $this->movieqty = ($this->site->maximdbprocessed != '') ? $this->site->maximdbprocessed : 100; + $this->fanartapikey = $this->pdo->getSetting('fanarttvkey'); + $this->imdburl = ($this->pdo->getSetting('imdburl') == 0 ? false : true); + $this->movieqty = ($this->pdo->getSetting('maximdbprocessed') != '') ? $this->pdo->getSetting('maximdbprocessed') : 100; $this->searchEngines = true; - $this->showPasswords = ($this->site->showpasswordedrelease != '') ? $this->site->showpasswordedrelease : 0; + $this->showPasswords = ($this->pdo->getSetting('showpasswordedrelease') != '') ? $this->pdo->getSetting('showpasswordedrelease') : 0; $this->debug = NN_DEBUG; $this->echooutput = ($options['Echo'] && NN_ECHOCLI && $this->pdo->cli); diff --git a/newznab/controllers/Forum.php b/newznab/controllers/Forum.php index b8f48017a..5edad0166 100644 --- a/newznab/controllers/Forum.php +++ b/newznab/controllers/Forum.php @@ -1,6 +1,6 @@ queryExec(sprintf("update forumpost set replies = replies + 1, updateddate = now() where id = %d", $parentid)); } - $db->queryInsert(sprintf("INSERT INTO `forumpost` (`forumID`,`parentid`,`userid`,`subject`,`message`, `locked`, `sticky`, `replies`, `createddate`, `updateddate`) VALUES ( 1, %d, %d, %s, %s, %d, %d, %d,NOW(), NOW())", + $db->queryInsert(sprintf("INSERT INTO `forumpost` (`forumid`,`parentid`,`userid`,`subject`,`message`, `locked`, `sticky`, `replies`, `createddate`, `updateddate`) VALUES ( 1, %d, %d, %s, %s, %d, %d, %d,NOW(), NOW())", $parentid, $userid, $db->escapeString($subject) , $db->escapeString($message), $locked, $sticky, $replies)); } @@ -35,7 +35,7 @@ class Forum */ public function getParent($parent) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf(" SELECT forumpost.*, users.username from forumpost left outer join users on users.id = forumpost.userid where forumpost.id = %d ", $parent)); } @@ -44,7 +44,7 @@ class Forum */ public function getRecentPosts($limit) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("select forumpost.*, users.username from forumpost join (select case when parentid = 0 then id else parentid end as id, max(createddate) from forumpost group by case when parentid = 0 then id else parentid end order by max(createddate) desc) x on x.id = forumpost.id inner join users on userid = users.id limit %d", $limit)); } @@ -54,7 +54,7 @@ class Forum */ public function getPosts($parent) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf(" SELECT forumpost.*, CASE WHEN role=%d THEN 1 ELSE 0 END AS 'isadmin', users.username from forumpost left outer join users on users.id = forumpost.userid where forumpost.id = %d or parentid = %d order by createddate asc limit 250", Users::ROLE_ADMIN, $parent, $parent)); } @@ -63,7 +63,7 @@ class Forum */ public function getPost($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf(" SELECT * from forumpost where id = %d", $id)); } @@ -72,7 +72,7 @@ class Forum */ public function getBrowseCount() { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("select count(id) as num from forumpost where parentid = 0")); return $res["num"]; } @@ -82,7 +82,7 @@ class Forum */ public function getBrowseRange($start, $num) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; @@ -97,7 +97,7 @@ class Forum */ public function deleteParent($parent) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from forumpost where id = %d or parentid = %d", $parent, $parent)); } @@ -106,7 +106,7 @@ class Forum */ public function deletePost($id) { - $db = new DB(); + $db = new Settings(); $post = $this->getPost($id); if ($post) { @@ -122,7 +122,7 @@ class Forum */ public function deleteUser($id) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from forumpost where userid = %d", $id)); } @@ -131,7 +131,7 @@ class Forum */ public function getCountForUser($uid) { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("select count(id) as num from forumpost where userid = %d", $uid)); return $res["num"]; } @@ -141,7 +141,7 @@ class Forum */ public function getForUserRange($uid, $start, $num) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; diff --git a/newznab/controllers/Games.php b/newznab/controllers/Games.php index 29a233ed3..0ba0ca9a7 100644 --- a/newznab/controllers/Games.php +++ b/newznab/controllers/Games.php @@ -1,7 +1,7 @@ site = $s->get(); $this->echoOutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $this->publicKey = $this->site->giantbombkey; - $this->gameQty = ($this->site->maxgamesprocessed != '') ? $this->site->maxgamesprocessed : 150; - $this->sleepTime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000; + $this->publicKey = $this->pdo->getSetting('giantbombkey'); + $this->gameQty = ($this->pdo->getSetting('maxgamesprocessed') != '') ? $this->pdo->getSetting('maxgamesprocessed') : 150; + $this->sleepTime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = NN_COVERS . 'games' . DS; $this->renamed = ''; $this->matchPercentage = 60; $this->maxHitRequest = false; $this->cookie = NN_TMP . 'xxx.cookie'; - if ($this->site->lookupgames == 2) { + if ($this->pdo->getSetting('lookupgames') == 2) { $this->renamed = 'AND isrenamed = 1'; } //$this->cleangames = ($this->site->('lookupgames') == 2) ? 'AND isrenamed = 1' : ''; @@ -175,7 +173,7 @@ class Games WHERE r.nzbstatus = 1 AND con.title != '' AND con.cover = 1 - AND r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') + AND r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') AND %s %s %s %s", $this->getBrowseBy(), $catsrch, @@ -236,7 +234,7 @@ class Games . "LEFT OUTER JOIN releasenfo rn ON rn.releaseid = r.id " . "INNER JOIN gamesinfo con ON con.id = r.gamesinfo_id " . "WHERE r.nzbstatus = 1 AND con.title != '' AND " - . "r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') AND %s %s %s %s " + . "r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') AND %s %s %s %s " . "GROUP BY con.id ORDER BY %s %s" . $limit, $browseby, $catsrch, diff --git a/newznab/controllers/Genres.php b/newznab/controllers/Genres.php index e5d87f0c5..4b0f45986 100644 --- a/newznab/controllers/Genres.php +++ b/newznab/controllers/Genres.php @@ -1,6 +1,6 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); } public function getGenres($type = '', $activeonly = false) diff --git a/newznab/controllers/Groups.php b/newznab/controllers/Groups.php index 0e9a370c2..3fc62bb82 100644 --- a/newznab/controllers/Groups.php +++ b/newznab/controllers/Groups.php @@ -1,6 +1,6 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); } /** * Get all group rows. diff --git a/newznab/controllers/IRCScraper.php b/newznab/controllers/IRCScraper.php index 5d1cc55a6..d8526e43a 100644 --- a/newznab/controllers/IRCScraper.php +++ b/newznab/controllers/IRCScraper.php @@ -1,6 +1,6 @@ _titleIgnoreRegex = SCRAPE_IRC_TITLE_IGNORE; } - $this->_pdo = new DB(); + $this->_pdo = new Settings(); $this->_groupList = array(); $this->_silent = $silent; $this->_debug = $debug; diff --git a/newznab/controllers/Info.php b/newznab/controllers/Info.php index c142d9ee5..1a014ea60 100644 --- a/newznab/controllers/Info.php +++ b/newznab/controllers/Info.php @@ -1,5 +1,5 @@ null, ]; $options += $defaults; - $s = new Sites(); - $this->site = $s->get(); $this->echo = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $s = new Sites(); - $this->site = $s->get(); - $this->nzbs = ($this->site->maxnfoprocessed != '') ? (int)$this->site->maxnfoprocessed : 100; - $this->maxsize = ($this->site->maxsizetoprocessnfo != '') ? (int)$this->site->maxsizetoprocessnfo : 100; + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); + $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)) : ''); - $this->minsize = ($this->site->minsizetoprocessnfo != '') ? (int)$this->site->minsizetoprocessnfo : 100; + $this->minsize = ($this->pdo->getSetting('minsizetoprocessnfo') != '') ? (int)$this->pdo->getSetting('minsizetoprocessnfo') : 100; $this->minsize = ($this->minsize > 0 ? ('AND size > ' . ($this->minsize * 1048576)) : ''); - $this->maxRetries = (int)($this->site->maxnforetries >= 0 ? -((int)$this->site->maxnforetries + 1) : self::NFO_UNPROC); + $this->maxRetries = (int)($this->pdo->getSetting('maxnforetries') >= 0 ? -((int)$this->pdo->getSetting('maxnforetries') + 1) : self::NFO_UNPROC); $this->maxRetries = ($this->maxRetries < -8 ? -8 : $this->maxRetries); - $this->tmpPath = (string)$this->site->tmpunrarpath; + $this->tmpPath = (string)$this->pdo->getSetting('tmpunrarpath'); if (!preg_match('/[\/\\\\]$/', $this->tmpPath)) { $this->tmpPath .= DS; } @@ -240,16 +236,15 @@ class Info * "AND r.nzbstatus = 1 AND r.nfostatus BETWEEN -8 AND -1 AND r.size < 1073741824 AND r.size > 1048576" * To use in a query. * - * @param DB $pdo + * @param Settings $pdo * * @return string * @access public * @static */ - static public function NfoQueryString(DB &$pdo) + 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); diff --git a/newznab/controllers/Konsole.php b/newznab/controllers/Konsole.php index fca3d60cd..e9662055a 100644 --- a/newznab/controllers/Konsole.php +++ b/newznab/controllers/Konsole.php @@ -1,6 +1,6 @@ echooutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $s = new Sites(); - $this->site = $s->get(); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); - $this->pubkey = $this->site->amazonpubkey; - $this->privkey = $this->site->amazonprivkey; - $this->asstag = $this->site->amazonassociatetag; - $this->gameqty = ($this->site->maxgamesprocessed != '') ? $this->site->maxgamesprocessed : 150; - $this->sleeptime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000; + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); + $this->gameqty = ($this->pdo->getSetting('maxgamesprocessed') != '') ? $this->pdo->getSetting('maxgamesprocessed') : 150; + $this->sleeptime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = NN_COVERS . 'console' . DS; $this->renamed = ''; - if ($this->site->lookupgames == 2) { + if ($this->pdo->getSetting('lookupgames') == 2) { $this->renamed = 'AND isrenamed = 1'; } //$this->cleanconsole = ($this->pdo->getSetting('lookupgames') == 2) ? 'AND isrenamed = 1' : ''; @@ -151,7 +149,7 @@ class Konsole FROM releases r INNER JOIN consoleinfo con ON con.id = r.consoleinfoid AND con.title != '' AND con.cover = 1 WHERE r.nzbstatus = 1 - AND r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') + AND r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') AND %s %s %s %s", $this->getBrowseBy(), $catsrch, @@ -205,7 +203,7 @@ class Konsole . "INNER JOIN consoleinfo con ON con.id = r.consoleinfoid " . "INNER JOIN genres ON con.genreid = genres.id " . "WHERE r.nzbstatus = 1 AND con.title != '' AND " - . "r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') AND %s %s + . "r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') AND %s %s %s " . "GROUP BY con.id ORDER BY %s %s" . $limit, $browseby, $catsrch, $exccatlist, $order[0], $order[1] ) diff --git a/newznab/controllers/Menu.php b/newznab/controllers/Menu.php index d79a153d5..c0d083972 100644 --- a/newznab/controllers/Menu.php +++ b/newznab/controllers/Menu.php @@ -1,6 +1,6 @@ query(sprintf("select * from menu order by role, ordinal")); } @@ -55,7 +55,7 @@ class Menu */ public function getById($id) { - $db = new newznab\db\DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from menu where id = %d", $id)); } @@ -64,7 +64,7 @@ class Menu */ public function delete($id) { - $db = new newznab\db\DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from menu where id = %d", $id)); } @@ -73,7 +73,7 @@ class Menu */ public function add($menu) { - $db = new newznab\db\DB(); + $db = new Settings(); return $db->queryInsert(sprintf("INSERT INTO menu (href, title, tooltip, role, ordinal, menueval, newwindow ) VALUES (%s, %s, %s, %d, %d, %s, %d) ", $db->escapeString($menu["href"]), $db->escapeString($menu["title"]), $db->escapeString($menu["tooltip"]), $menu["role"] , $menu["ordinal"], $db->escapeString($menu["menueval"]), $menu["newwindow"] )); } @@ -83,7 +83,7 @@ class Menu */ public function update($menu) { - $db = new newznab\db\DB(); + $db = new Settings(); return $db->queryExec(sprintf("update menu set href = %s, title = %s, tooltip = %s, role = %d, ordinal = %d, menueval = %s, newwindow=%d where id = %d ", $db->escapeString($menu["href"]), $db->escapeString($menu["title"]), $db->escapeString($menu["tooltip"]), $menu["role"] , $menu["ordinal"], $db->escapeString($menu["menueval"]), $menu["newwindow"], $menu["id"] )); } } \ No newline at end of file diff --git a/newznab/controllers/MiscSorter.php b/newznab/controllers/MiscSorter.php index c9a000597..5271119a8 100644 --- a/newznab/controllers/MiscSorter.php +++ b/newznab/controllers/MiscSorter.php @@ -1,6 +1,6 @@ echooutput = (NN_ECHOCLI && $echooutput); $this->qty = 100; - $this->pdo = ($pdo instanceof DB ? $pdo : new DB()); + $this->pdo = ($pdo instanceof Settings ? $pdo : new Settings()); $this->category = new Categorize(); $this->movie = new Film(); $this->namefixer = new NameFixer(); $this->music = new Musik(); $this->console = new Konsole(); - $s = new Sites(); - $this->site = $s->get(); $this->book = new Books(); $this->c = new ColorCLI(); - $this->pubkey = $this->site->amazonpubkey; - $this->privkey = $this->site->amazonprivkey; - $this->asstag = $this->site->amazonassociatetag; + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); } // Main function that determines which operation(s) should be run based on the releases NFO file @@ -558,7 +556,7 @@ class MiscSorter echo $e->getMessage(); } - //$amazon = new AmazonProductAPI($this->site->amazonpubkey, $this->site->amazonprivkey, $this->site->amazonassociatetag); + //$amazon = new AmazonProductAPI($this->pdo->getSetting('amazonpubkey'), $this->pdo->getSetting('amazonprivkey'), $this->pdo->getSetting('amazonassociatetag')); $amalookup = new Lookup(); $apaiIo = new ApaiIO($conf); diff --git a/newznab/controllers/Movie.php b/newznab/controllers/Movie.php index 7d13da0d9..9af331bb6 100644 --- a/newznab/controllers/Movie.php +++ b/newznab/controllers/Movie.php @@ -1,7 +1,7 @@ echooutput = (NN_ECHOCLI && $echooutput); - $s = new \Sites(); - $site = $s->get(); - $this->apikey = $site->tmdbkey; - $this->lookuplanguage = $site->lookuplanguage; - $this->pdo = new DB(); + $this->pdo = new Settings(); + $this->apikey = $this->pdo->getSetting('tmdbkey'); + $this->lookuplanguage = $this->pdo->getSetting('lookuplanguage'); $this->imgSavePath = NN_COVERS . 'movies' . DS; } @@ -348,7 +346,7 @@ class Movie */ public function getBrowseBy() { - $this->pdo = new newznab\db\DB; + $this->pdo = new newznab\db\Settings; $browseby = ' '; $browsebyArr = $this->getBrowseByOptions(); @@ -793,7 +791,7 @@ class Movie */ public function updateUpcoming() { - $s = new Sites(); + $s = new Settings(); $site = $s->get(); if (isset($site->rottentomatokey)) { diff --git a/newznab/controllers/Music.php b/newznab/controllers/Music.php index c4d36ae2f..85e67b053 100644 --- a/newznab/controllers/Music.php +++ b/newznab/controllers/Music.php @@ -1,7 +1,7 @@ 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\DB(); + $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/'; } @@ -238,7 +236,7 @@ class Music */ public function getBrowseBy() { - $this->pdo = new newznab\db\DB; + $this->pdo = new newznab\db\Settings; $browseby = ' '; $browsebyArr = $this->getBrowseByOptions(); diff --git a/newznab/controllers/Musik.php b/newznab/controllers/Musik.php index 04933ff6f..4efe5939c 100644 --- a/newznab/controllers/Musik.php +++ b/newznab/controllers/Musik.php @@ -1,5 +1,5 @@ echooutput = ($options['Echo'] && NN_ECHOCLI); - $s = new Sites(); - $this->site = $s->get(); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $this->pubkey = $this->site->amazonpubkey; - $this->privkey = $this->site->amazonprivkey; - $this->asstag = $this->site->amazonassociatetag; - $this->musicqty = ($this->site->maxmusicprocessed != '') ? $this->site->maxmusicprocessed : 150; - $this->sleeptime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000; + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); + $this->pubkey = $this->pdo->getSetting('amazonpubkey'); + $this->privkey = $this->pdo->getSetting('amazonprivkey'); + $this->asstag = $this->pdo->getSetting('amazonassociatetag'); + $this->musicqty = ($this->pdo->getSetting('maxmusicprocessed') != '') ? $this->pdo->getSetting('maxmusicprocessed') : 150; + $this->sleeptime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = NN_COVERS . 'music' . DS; $this->renamed = ''; - if ($this->site->lookupmusic == 2) { + if ($this->pdo->getSetting('lookupmusic') == 2) { $this->renamed = 'AND isrenamed = 1'; } } @@ -190,7 +188,7 @@ class Musik $exccatlist = " AND r.categoryid NOT IN (" . implode(",", $excludedcats) . ")"; } - $sql = sprintf("SELECT COUNT(DISTINCT r.musicinfoid) AS num FROM releases r INNER JOIN musicinfo m ON m.id = r.musicinfoid AND m.title != '' AND m.cover = 1 WHERE nzbstatus = 1 AND r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') AND %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist); + $sql = sprintf("SELECT COUNT(DISTINCT r.musicinfoid) AS num FROM releases r INNER JOIN musicinfo m ON m.id = r.musicinfoid AND m.title != '' AND m.cover = 1 WHERE nzbstatus = 1 AND r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') AND %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist); $res = $this->pdo->queryOneRow($sql); return $res["num"]; } @@ -245,7 +243,7 @@ class Musik . "LEFT OUTER JOIN releasenfo rn ON rn.releaseid = r.id " . "INNER JOIN musicinfo m ON m.id = r.musicinfoid " . "WHERE r.nzbstatus = 1 AND m.title != '' AND " - . "r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') AND %s %s %s " + . "r.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') AND %s %s %s " . "GROUP BY m.id ORDER BY %s %s" . $limit, $browseby, $catsrch, $exccatlist, $order[0], $order[1])); } diff --git a/newznab/controllers/NNTP.php b/newznab/controllers/NNTP.php index 2edc46f3a..845dffe29 100644 --- a/newznab/controllers/NNTP.php +++ b/newznab/controllers/NNTP.php @@ -107,9 +107,7 @@ class NNTP extends Net_NNTP_Client $this->_echo = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof \newznab\db\DB ? $options['Settings'] : new \newznab\db\DB()); - $s = new Sites(); - $this->site = $s->get(); + $this->pdo = ($options['Settings'] instanceof \newznab\db\Settings ? $options['Settings'] : new \newznab\db\Settings()); $this->_debugBool = (NN_LOGGING || NN_DEBUG); if ($this->_debugBool) { @@ -120,7 +118,7 @@ class NNTP extends Net_NNTP_Client } } - $this->_nntpRetries = ($this->site->nntpretries != '') ? (int)$this->site->nntpretries : 0 + 1; + $this->_nntpRetries = ($this->pdo->getSetting('nntpretries') != '') ? (int)$this->pdo->getSetting('>nntpretries') : 0 + 1; $this->_initiateYEncSettings(); } @@ -274,7 +272,7 @@ class NNTP extends Net_NNTP_Client // If we are connected and authenticated, try enabling compression if we have it enabled. if ($connected === true && $authenticated === true) { // Check if we should use compression on the connection. - if ($compression === false || $this->site->compressedheaders == 0) { + if ($compression === false || $this->pdo->getSetting('compressedheaders') == 0) { $this->_compressionSupported = false; } if ($this->_debugBool) { @@ -347,7 +345,7 @@ class NNTP extends Net_NNTP_Client */ public function enableCompression() { - if (!$this->site->compressedheaders == 1) { + if (!$this->pdo->getSetting('compressedheaders') == 1) { return; } $this->_enableCompression(); @@ -1220,7 +1218,7 @@ class NNTP extends Net_NNTP_Client protected function _initiateYEncSettings() { // Check if the user wants to use yyDecode or the simple_php_yenc_decode extension. - $this->_yyDecoderPath = ($this->site->yydecoderpath != '') ? (string)$this->site->yydecoderpath : false; + $this->_yyDecoderPath = ($this->pdo->getSetting('yydecoderpath') != '') ? (string)$this->pdo->getSetting('yydecoderpath') : false; if (strpos((string)$this->_yyDecoderPath, 'simple_php_yenc_decode') !== false) { if (extension_loaded('simple_php_yenc_decode')) { $this->_yEncExtension = true; diff --git a/newznab/controllers/NZB.php b/newznab/controllers/NZB.php index fc1917ba5..3aa50c4d4 100644 --- a/newznab/controllers/NZB.php +++ b/newznab/controllers/NZB.php @@ -1,6 +1,6 @@ pdo = ($pdo instanceof DB ? $pdo : new DB()); - $s = new Sites(); - $this->site = $s->get(); + $this->pdo = ($pdo instanceof Settings ? $pdo : new Settings()); - $this->tablePerGroup = ($this->site->tablepergroup == 0 ? false : true); - $nzbSplitLevel = $this->site->nzbsplitlevel; + $this->tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 0 ? false : true); + $nzbSplitLevel = $this->pdo->getSetting('nzbsplitlevel'); $this->nzbSplitLevel = (empty($nzbSplitLevel) ? 1 : $nzbSplitLevel); - $this->siteNzbPath = (string)$this->site->nzbpath; + $this->siteNzbPath = (string)$this->pdo->getSetting('nzbpath'); if (substr($this->siteNzbPath, -1) !== DS) { $this->siteNzbPath .= DS; } @@ -35,7 +33,7 @@ class NZB */ function writeNZBforReleaseId($relid, $name, $catId, $path, $groupID) { - $db = new DB(); + $db = new Settings(); $cat = new Category(); $this->groupID = $groupID; // Set table names @@ -50,7 +48,7 @@ class NZB $pName = 'parts'; } $catrow = $cat->getById($catId); - $site = new Sites(); + $site = new Settings(); $fp = gzopen($path, "w"); if ($fp) { @@ -130,7 +128,7 @@ class NZB function getNZBPath($releaseGuid, $sitenzbpath = "", $createIfDoesntExist = false) { if ($sitenzbpath == "") { - $s = new Sites; + $s = new Settings; $site = $s->get(); $sitenzbpath = $site->nzbpath; } diff --git a/newznab/controllers/NZBContents.php b/newznab/controllers/NZBContents.php index b00cdfd6e..c4a3a9b77 100644 --- a/newznab/controllers/NZBContents.php +++ b/newznab/controllers/NZBContents.php @@ -1,6 +1,6 @@ NNTP ; Class NNTP. * 'Nfo' => Nfo ; Class Info. * 'NZB' => NZB ; Class NZB. - * 'Settings' => DB ; Class newznab\db\DB. + * 'Settings' => DB ; Class newznab\db\Settings. * 'PostProcess' => PProcess ; Class PProcess. * ) * @@ -87,7 +87,7 @@ Class NZBContents $options += $defaults; $this->echooutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->echooutput, 'Settings' => $this->pdo])); $this->nfo = ($options['Nfo'] instanceof \Info ? $options['Nfo'] : new \Info(['Echo' => $this->echooutput, 'Settings' => $this->pdo])); $this->pp = ( @@ -98,10 +98,8 @@ 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->site->alternate_nntp == 1 ? true : false); + $this->alternateNNTP = ($this->pdo->getSetting('alternate_nntp') == 1 ? true : false); } /** diff --git a/newznab/controllers/NZBExport.php b/newznab/controllers/NZBExport.php index b32bc2f7b..b7c954f9f 100644 --- a/newznab/controllers/NZBExport.php +++ b/newznab/controllers/NZBExport.php @@ -1,6 +1,6 @@ browser = $options['Browser']; $this->echoCLI = (!$this->browser && NN_ECHOCLI && $options['Echo']); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Setting'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Setting'] : new Settings()); $this->releases = ($options['Releases'] instanceof \Releases ? $options['Releases'] : new \Releases(['Settings' => $this->pdo])); $this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo)); } diff --git a/newznab/controllers/NZBImport.php b/newznab/controllers/NZBImport.php index 8070f5490..470b24216 100644 --- a/newznab/controllers/NZBImport.php +++ b/newznab/controllers/NZBImport.php @@ -1,6 +1,6 @@ site = $s->get(); $this->echoCLI = (!$this->browser && NN_ECHOCLI && $options['Echo']); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->binaries = ($options['Binaries'] instanceof \Binaries ? $options['Binaries'] : new \Binaries(['Settings' => $this->pdo, 'Echo' => $this->echoCLI])); $this->category = ($options['Categorize'] instanceof \Categorize ? $options['Categorize'] : new \Categorize(['Settings' => $this->pdo])); $this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo)); $this->releaseCleaner = ($options['ReleaseCleaning'] instanceof \ReleaseCleaning ? $options['ReleaseCleaning'] : new \ReleaseCleaning($this->pdo)); $this->releases = ($options['Releases'] instanceof \Releases ? $options['Releases'] : new \Releases(['settings' => $this->pdo])); - $s = new Sites(); - $this->site = $s->get(); - $this->crossPostt = ($this->site->crossposttime != '') ? $this->site->crossposttime : 2; + $this->crossPostt = ($this->pdo->getSetting('crossposttime') != '') ? $this->pdo->getSetting('crossposttime') : 2; $this->browser = $options['Browser']; $this->retVal = ''; } @@ -403,7 +399,7 @@ class NZBImport 'postdate' => $this->pdo->escapeString($nzbDetails['postDate']), 'fromname' => $escapedFromName, 'reqid' => NULL, - 'passwordstatus' => ($this->site->checkpasswordedrar > 0 ? -1 : 0), + 'passwordstatus' => ($this->pdo->getSetting('checkpasswordedrar') > 0 ? -1 : 0), 'size' => $this->pdo->escapeString($nzbDetails['totalSize']), 'categoryid' => $this->category->determineCategory($nzbDetails['groupid'], $cleanName), 'isrenamed' => $renamed, diff --git a/newznab/controllers/NameFixer.php b/newznab/controllers/NameFixer.php index ea771408f..aa69be5c8 100644 --- a/newznab/controllers/NameFixer.php +++ b/newznab/controllers/NameFixer.php @@ -1,6 +1,6 @@ echooutput = ($options['Echo'] && NN_ECHOCLI); $this->relid = $this->fixed = $this->checked = 0; - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->timeother = ' AND rel.adddate > (NOW() - INTERVAL 0 HOUR) AND rel.categoryid IN (1090, 2020, 3050, 6050, 5050, 7050, 8010, 8020) GROUP BY rel.id ORDER BY postdate DESC'; $this->timeall = ' AND rel.adddate > (NOW() - INTERVAL 6 HOUR) GROUP BY rel.id ORDER BY postdate DESC'; $this->fullother = ' AND rel.categoryid IN (1090, 2020, 3050, 6050, 5050, 7050, 8010, 8020) GROUP BY rel.id'; diff --git a/newznab/controllers/Nfo.php b/newznab/controllers/Nfo.php index 6db406c52..a71bb97a8 100644 --- a/newznab/controllers/Nfo.php +++ b/newznab/controllers/Nfo.php @@ -1,6 +1,6 @@ $blob){ $query = sprintf( "REPLACE INTO releasenfo (id, releaseid, binaryID, nfo) ". @@ -489,7 +489,7 @@ class Nfo // nzb files are further parsed for nfo segments that can // be extracted and applied to the release $nzb = new NZB(); - $db = new DB(); + $db = new Settings(); // How many releases to handle at a time $batch=Nfo::NNTP_BATCH_COUNT; @@ -587,7 +587,7 @@ class Nfo */ public function deleteReleaseNfo($relid) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from releasenfo where releaseid = %d", $relid)); } @@ -596,7 +596,7 @@ class Nfo */ private function setNfoMissing($relid) { - $db = new DB(); + $db = new Settings(); $q = sprintf("UPDATE releases SET releasenfoid = %d ". "WHERE id = %d", Nfo::FLAG_NFO_MISSING, $relid); return $db->queryExec($q); @@ -607,7 +607,7 @@ class Nfo */ public function getNfo($relid, &$nfoout) { - $db = new DB(); + $db = new Settings(); // Has NFO Query $mnfo = "SELECT uncompress(rn.nfo) as nfo FROM releases r ". "INNER JOIN releasenfo rn ON rn.releaseid = r.id AND rn.id = r.releasenfoid ". diff --git a/newznab/controllers/Parsing.php b/newznab/controllers/Parsing.php index a0890a594..4d7c8e5f0 100644 --- a/newznab/controllers/Parsing.php +++ b/newznab/controllers/Parsing.php @@ -1,6 +1,6 @@ other releases into real names. @@ -8,7 +8,7 @@ use newznab\db\DB; class Parsing { /** - * @var newznab\db\DB + * @var newznab\db\Settings */ public $pdo; @@ -33,9 +33,7 @@ class Parsing $this->parsprocessed = 0; $this->releasefilesprocessed = 0; $this->cleanup = ['nuke' => [], 'misc' => []]; - $s = new Sites(); - $this->site = $s->get(); - $this->pdo = new newznab\db\DB(); + $this->pdo = new Settings(); } /** @@ -1485,12 +1483,12 @@ class Parsing /** * update a release name * - * @param DB $pdo + * @param Settings $pdo * @param $id * @param $oldname * @param $newname */ - private function updateName(DB $pdo, $id, $oldname, $newname) + private function updateName(Settings $pdo, $id, $oldname, $newname) { if ($this->verbose) echo sprintf("OLD : %s\nNEW : %s\n\n", $oldname, $newname); diff --git a/newznab/controllers/PostProcess.php b/newznab/controllers/PostProcess.php index 9c26e04d5..ce16e5c17 100644 --- a/newznab/controllers/PostProcess.php +++ b/newznab/controllers/PostProcess.php @@ -2,7 +2,7 @@ require_once NN_LIBS . 'rarinfo/par2info.php'; require_once NN_LIBS . 'rarinfo/archiveinfo.php'; -use newznab\db\DB; +use newznab\db\Settings; use newznab\utility\Utility; /** @@ -12,7 +12,7 @@ class PostProcess { /** - * @var newznab\db\DB + * @var newznab\db\Settings */ public $pdo; @@ -29,12 +29,10 @@ class PostProcess public function __construct($echooutput = false) { $this->echooutput = (NN_ECHOCLI && $echooutput);; - $s = new \Sites(); - $this->site = $s->get(); - $this->pdo = new DB(); + $this->pdo = new Settings(); $this->mediafileregex = 'AVI|VOB|MKV|MP4|TS|WMV|MOV|M4V|F4V|MPG|MPEG|M2TS'; $this->audiofileregex = 'MP3|AAC|OGG'; - $this->mp3SavePath = WWW_DIR.'covers/audio/'; + $this->mp3SavePath = NN_COVERS .'audio' . DS; } /** @@ -64,7 +62,7 @@ class PostProcess // // Delete any passworded releases // - if($this->site->deletepasswordedrelease == 1) + if($this->pdo->getSetting('deletepasswordedrelease') == 1) { echo "PostPrc : Removing unwanted releases\n"; $result = $this->pdo->query("select id from releases where passwordstatus > 0"); @@ -75,11 +73,11 @@ class PostProcess // // Delete any releases which are older than site's release retention days // - if($this->site->releaseretentiondays != 0) + if($this->pdo->getSetting('releaseretentiondays') != 0) { - echo "PostPrc : Deleting releases older than ".$this->site->releaseretentiondays." days\n"; + echo "PostPrc : Deleting releases older than ".$this->pdo->getSetting('releaseretentiondays')." days\n"; - $result = $this->pdo->query(sprintf("select id from releases where postdate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->site->releaseretentiondays)); + $result = $this->pdo->query(sprintf("select id from releases where postdate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->pdo->getSetting('releaseretentiondays'))); foreach ($result as $row) $r->delete($row["id"]); } @@ -87,13 +85,13 @@ class PostProcess // // Delete any audiopreviews older than site->audiopreviewprune days // - if($this->site->audiopreviewprune > 0) + if($this->pdo->getSetting('audiopreviewprune') > 0) { - $result = $this->pdo->query(sprintf("select guid from releases where categoryid in (select id from category where parentid = ".Category::CAT_PARENT_MUSIC.") and haspreview = 2 and adddate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->site->audiopreviewprune)); + $result = $this->pdo->query(sprintf("select guid from releases where categoryid in (select id from category where parentid = ".Category::CAT_PARENT_MUSIC.") and haspreview = 2 and adddate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->pdo->getSetting('audiopreviewprune'))); if (sizeof($result) > 0) { - echo "PostPrc : Deleting ".count($result)." audio previews older than ".$this->site->audiopreviewprune." days\n"; + echo "PostPrc : Deleting ".count($result)." audio previews older than ".$this->pdo->getSetting('audiopreviewprune')." days\n"; foreach ($result as $row) { $r->updateHasPreview($row["guid"], 0); @@ -105,7 +103,7 @@ class PostProcess // // Delete any releases suspected of being spam/virus // - if($this->site->removespam != 0) + if($this->pdo->getSetting('removespam') != 0) { $spamIDs = array(); @@ -119,9 +117,9 @@ class PostProcess // // all releases containing exe not in permitted categories // - if ($this->site->exepermittedcategories != '') + if ($this->pdo->getSetting('exepermittedcategories') != '') { - $sql = sprintf("select releasefiles.releaseid as id from releasefiles inner join releases on releases.id = releasefiles.releaseid left join releasenfo on releasenfo.releaseid = releases.id where releasefiles.name like '%%.exe' and releases.categoryid not in (%s) group by releasefiles.releaseid", $this->site->exepermittedcategories); + $sql = sprintf("select releasefiles.releaseid as id from releasefiles inner join releases on releases.id = releasefiles.releaseid left join releasenfo on releasenfo.releaseid = releases.id where releasefiles.name like '%%.exe' and releases.categoryid not in (%s) group by releasefiles.releaseid", $this->pdo->getSetting('exepermittedcategories')); $result = $this->pdo->query($sql); $spamIDs = array_merge($result, $spamIDs); } @@ -161,7 +159,7 @@ class PostProcess */ public function processNfos() { - if ($this->site->lookupnfo == 1) + if ($this->pdo->getSetting('lookupnfo') == 1) { $nfo = new Nfo($this->echooutput); $nfo->processNfoFiles(500); @@ -189,7 +187,7 @@ class PostProcess */ public function processMovies() { - if ($this->site->lookupimdb == 1) + if ($this->pdo->getSetting('lookupimdb') == 1) { $movie = new Movie($this->echooutput); $movie->processMovieReleases(); @@ -201,7 +199,7 @@ class PostProcess */ public function processMusic() { - if ($this->site->lookupmusic == 1) + if ($this->pdo->getSetting('lookupmusic') == 1) { $music = new Music($this->echooutput); $music->processMusicReleases(); @@ -213,7 +211,7 @@ class PostProcess */ public function processBooks() { - if ($this->site->lookupbooks == 1) + if ($this->pdo->getSetting('lookupbooks') == 1) { $book = new Book($this->echooutput); $book->processBookReleases(); @@ -225,7 +223,7 @@ class PostProcess */ public function processGames() { - if ($this->site->lookupgames == 1) + if ($this->pdo->getSetting('lookupgames') == 1) { $console = new Console($this->echooutput); $console->processConsoleReleases(); @@ -261,20 +259,20 @@ class PostProcess */ public function processTv() { - if ($this->site->lookupanidb == 1) + if ($this->pdo->getSetting('lookupanidb') == 1) { $anidb = new AniDB($this->echooutput); $anidb->animetitlesUpdate(); $anidb->processAnimeReleases(); } - if ($this->site->lookuptvrage == 1) + if ($this->pdo->getSetting('lookuptvrage') == 1) { $tvrage = new TVRage($this->echooutput); - $tvrage->processTvReleases(($this->site->lookuptvrage==1)); + $tvrage->processTvReleases(($this->pdo->getSetting('lookuptvrage') == 1)); } - if ($this->site->lookupthetvdb == 1) + if ($this->pdo->getSetting('lookupthetvdb') == 1) { $thetvdb = new TheTVDB($this->echooutput); $thetvdb->processReleases(); @@ -287,20 +285,20 @@ class PostProcess public function processOtherMiscCategory() { $p = null; - if($this->site->updatecleanup == 1) + if($this->pdo->getSetting('updatecleanup') == 1) { $p = new Parsing(false, true, false); $p->cleanup(); } - if($this->site->updateparsing == 1) + if($this->pdo->getSetting('updateparsing') == 1) { if ($p == null) $p = new Parsing(false, true, false); $p->process(); } - if($this->site->removespecial == 1) + if($this->pdo->getSetting('removespecial') == 1) { if ($p == null) $p = new Parsing(false, true, false); @@ -315,12 +313,12 @@ class PostProcess { $maxattemptstocheckpassworded = 5; - $processVideoSample = ($this->site->ffmpegpath != '') ? true : false; - $processMediainfo = ($this->site->mediainfopath != '') ? true : false; - $processPasswords = ($this->site->unrarpath != '') ? true : false; - $processAudioSample = ($this->site->saveaudiopreview == 1) ? true : false; + $processVideoSample = ($this->pdo->getSetting('ffmpegpath') != '') ? true : false; + $processMediainfo = ($this->pdo->getSetting('mediainfopath') != '') ? true : false; + $processPasswords = ($this->pdo->getSetting('unrarpath') != '') ? true : false; + $processAudioSample = ($this->pdo->getSetting('saveaudiopreview') == 1) ? true : false; - $tmpPath = $this->site->tmpunrarpath; + $tmpPath = $this->pdo->getSetting('tmpunrarpath'); if (substr($tmpPath, -strlen( '/' ) ) != '/') { $tmpPath = $tmpPath.'/'; @@ -368,7 +366,7 @@ class PostProcess // only load nzbs and check for rar files if we are doing something with them. if ($processVideoSample || $processMediainfo || $processPasswords || $processAudioSample) { - $nzbfile = $nzb->getNZBPath($rel['guid'], $this->site->nzbpath); + $nzbfile = $nzb->getNZBPath($rel['guid'], $this->pdo->getSetting('nzbpath')); if (!$nzbInfo->loadFromFile($nzbfile)) { continue; @@ -401,7 +399,7 @@ class PostProcess file_put_contents($samplefile, $sampleBinary); - $blnTookSample = $this->getSample($tmpPath, $this->site->ffmpegpath, $rel['guid']); + $blnTookSample = $this->getSample($tmpPath, $this->pdo->getSetting('ffmpegpath'), $rel['guid']); if ($blnTookSample) $this->updateReleaseHasPreview($rel['guid']); @@ -432,13 +430,13 @@ class PostProcess if ($processVideoSample && $blnTookSample === false) { - $blnTookSample = $this->getSample($tmpPath, $this->site->ffmpegpath, $rel['guid']); + $blnTookSample = $this->getSample($tmpPath, $this->pdo->getSetting('ffmpegpath'), $rel['guid']); if ($blnTookSample) $this->updateReleaseHasPreview($rel['guid']); } if ($processMediainfo) - $blnTookMediainfo = $this->getMediainfo($tmpPath, $this->site->mediainfopath, $rel['id']); + $blnTookMediainfo = $this->getMediainfo($tmpPath, $this->pdo->getSetting('mediainfopath'), $rel['id']); unlink($mediafile); } @@ -470,23 +468,23 @@ class PostProcess $this->updateReleaseHasPreview($rel['guid'], 2); if ($processMediainfo) - $blnTookMediainfo = $this->getMediainfo($tmpPath, $this->site->mediainfopath, $rel['id']); + $blnTookMediainfo = $this->getMediainfo($tmpPath, $this->pdo->getSetting('mediainfopath'), $rel['id']); - if ($this->site->lamepath != "") - $this->lameAudioSample($this->site->lamepath, $rel['guid']); + if ($this->pdo->getSetting('lamepath') != "") + $this->lameAudioSample($this->pdo->getSetting('lamepath'), $rel['guid']); unlink($audiofile); } unset($audioBinary); } - if (!empty($nzbInfo->rarfiles) && ($this->site->checkpasswordedrar > 0 || (($processVideoSample || $processAudioSample) && $blnTookSample === false) || $processMediainfo)) + if (!empty($nzbInfo->rarfiles) && ($this->pdo->getSetting('checkpasswordedrar') > 0 || (($processVideoSample || $processAudioSample) && $blnTookSample === false) || $processMediainfo)) { $mysqlkeepalive = 0; foreach($nzbInfo->rarfiles as $rarFile) { //dont process any more rars if a passworded rar has been detected and the site is set to automatically delete them - if ($this->site->deletepasswordedrelease == 1 && max($passStatus) == Releases::PASSWD_RAR) + if ($this->pdo->getSetting('deletepasswordedrelease') == 1 && max($passStatus) == Releases::PASSWD_RAR) { echo "-Skipping processing of rar {$rarFile['subject']} as this release has already been marked as passworded.\n"; continue; @@ -510,24 +508,24 @@ class PostProcess { $relFiles = $this->processReleaseFiles($fetchedBinary, $rel['id']); - if ($this->site->checkpasswordedrar > 0 && $processPasswords) + if ($this->pdo->getSetting('checkpasswordedrar') > 0 && $processPasswords) { - $passStatus[] = $this->processReleasePasswords($fetchedBinary, $tmpPath, $this->site->unrarpath, $this->site->checkpasswordedrar); + $passStatus[] = $this->processReleasePasswords($fetchedBinary, $tmpPath, $this->pdo->getSetting('unrarpath'), $this->pdo->getSetting('checkpasswordedrar')); } // we need to unrar the fetched binary if checkpasswordedrar wasnt 2 - if ($this->site->checkpasswordedrar < 2 && $processPasswords) + if ($this->pdo->getSetting('checkpasswordedrar') < 2 && $processPasswords) { $rarfile = $tmpPath.'rarfile.rar'; file_put_contents($rarfile, $fetchedBinary); - $execstring = '"'.$this->site->unrarpath.'" e -ai -ep -c- -id -r -kb -p- -y -inul "'.$rarfile.'" "'.$tmpPath.'"'; + $execstring = '"'.$this->pdo->getSetting('unrarpath').'" e -ai -ep -c- -id -r -kb -p- -y -inul "'.$rarfile.'" "'.$tmpPath.'"'; $output = Utility::runCmd($execstring, false, true); unlink($rarfile); } if ($processVideoSample && $blnTookSample === false) { - $blnTookSample = $this->getSample($tmpPath, $this->site->ffmpegpath, $rel['guid']); + $blnTookSample = $this->getSample($tmpPath, $this->pdo->getSetting('ffmpegpath'), $rel['guid']); if ($blnTookSample) $this->updateReleaseHasPreview($rel['guid']); } @@ -545,14 +543,14 @@ class PostProcess if ($processMediainfo && $blnTookMediainfo === false) { - $blnTookMediainfo = $this->getMediainfo($tmpPath, $this->site->mediainfopath, $rel['id']); + $blnTookMediainfo = $this->getMediainfo($tmpPath, $this->pdo->getSetting('mediainfopath'), $rel['id']); } // // Has to be done after mediainfo // - if ($blnTookAudioSample && $this->site->lamepath != "") - $this->lameAudioSample($this->site->lamepath, $rel['guid']); + if ($blnTookAudioSample && $this->pdo->getSetting('lamepath') != "") + $this->lameAudioSample($this->pdo->getSetting('lamepath'), $rel['guid']); if ($mysqlkeepalive % 25 == 0) $this->pdo->query("select 1"); @@ -886,7 +884,7 @@ class PostProcess $minacceptableencodefilesize = 10000; $samplefile = $this->mp3SavePath.$releaseguid.'.mp3'; $samplefileogg = $this->mp3SavePath.$releaseguid.'.ogg'; - $ffmpeginfo = $this->site->ffmpegpath; + $ffmpeginfo = $this->pdo->getSetting('ffmpegpath'); if (file_exists($samplefile)) { @@ -987,9 +985,9 @@ class PostProcess */ public function processMusicFromMediaInfo() { - $processMediainfo = ($this->site->mediainfopath != '') ? true : false; - $processAudioSample = ($this->site->saveaudiopreview == 1) ? true : false; - $processMusic = ($this->site->lookupmusic == 1) ? true : false; + $processMediainfo = ($this->pdo->getSetting('mediainfopath') != '') ? true : false; + $processAudioSample = ($this->pdo->getSetting('saveaudiopreview') == 1) ? true : false; + $processMusic = ($this->pdo->getSetting('lookupmusic') == 1) ? true : false; if ($processMusic && $processMediainfo && $processAudioSample) { diff --git a/newznab/controllers/PreDB.php b/newznab/controllers/PreDB.php index 99b461fe7..944f07426 100644 --- a/newznab/controllers/PreDB.php +++ b/newznab/controllers/PreDB.php @@ -1,6 +1,6 @@ echooutput = (NN_ECHOCLI && $echooutput); - $this->pdo = new DB(); + $this->pdo = new Settings(); } /** @@ -57,9 +57,8 @@ class PreDB { // Only use Sphinx if this is a search request if ($dirname) { - $s = new Sites(); - $site = $s->get(); - if ($site->sphinxenabled && $site->sphinxindexpredb) { + + if ($this->pdo->getSetting('sphinxenabled') && $this->pdo->getSetting('sphinxindexpredb')) { // Search using Sphinx $sphinx = new Sphinx(); $count = $sphinx->getPreCount($dirname, $category); @@ -84,9 +83,7 @@ class PreDB { // Only use Sphinx if this is a search request if ($dirname) { - $s = new Sites(); - $site = $s->get(); - if ($site->sphinxenabled && $site->sphinxindexpredb) { + if ($this->pdo->getSetting('sphinxenabled') && $this->pdo->getSetting('sphinxindexpredb')) { // Search using Sphinx $sphinx = new Sphinx(); $results = $sphinx->getPreRange($start, $num, $dirname, $category); @@ -138,11 +135,11 @@ class PreDB /** * Add/Update predb row. * - * @param newznab\db\DB $pdo + * @param newznab\db\Settings $pdo * @param $preArray * @return bool */ - public function updatePreDB(DB $pdo, $preArray) + public function updatePreDB(Settings $pdo, $preArray) { if(!preg_match('/^(UN)?((MOD)?NUKED?|DELPRE)$/', $preArray['category'])) { @@ -210,10 +207,7 @@ class PreDB public function nzpreUpdate() { - $s = new Sites(); - $site = $s->get(); - - if(empty($site->nzpregroup) || empty($site->nzpresubject) || empty($site->nzpreposter) || empty($site->nzprefield) || empty($site->nzprekey)) + if(empty($this->pdo->getSetting('nzpregroup')) || empty($this->pdo->getSetting('nzpresubject')) || empty($this->pdo->getSetting('nzpreposter')) || empty($this->pdo->getSetting('nzprefield')) || empty($this->pdo->getSetting('nzprekey'))) return false; if($this->echooutput) @@ -226,37 +220,37 @@ class PreDB return false; } - $ret = $groupData = $nntp->selectGroup($site->nzpregroup); + $ret = $groupData = $nntp->selectGroup($this->pdo->getSetting('nzpregroup')); if($nntp->isError($ret)) { echo "Predb : Error ".$ret->getMessage()."\n"; return false; } - $ret = $groupMsgs = $nntp->getOverview(($groupData['last']-(!empty($site->nzprearticles) ? $site->nzprearticles : 500)).'-'.$groupData['last']); + $ret = $groupMsgs = $nntp->getOverview(($groupData['last']-(!empty($this->pdo->getSetting('nzprearticles')) ? $this->pdo->getSetting('nzprearticles') : 500)).'-'.$groupData['last']); if($nntp->isError($ret)) { echo "Predb : Error ".$ret->getMessage()."\n"; return false; } $added_updated = 0; - $nzprekey = $site->nzprekey; + $nzprekey = $this->pdo->getSetting('nzprekey'); while(strlen($nzprekey) < 1024) $nzprekey = $nzprekey.$nzprekey; - $cnt = !empty($site->nzprearticles) ? $site->nzprearticles : 500; + $cnt = !empty($this->pdo->getSetting('nzprearticles')) ? $this->pdo->getSetting('nzprearticles') : 500; foreach($groupMsgs as $groupMsg) { if ($cnt%50==0 && $cnt != 0 && $this->echooutput) echo $cnt.".."; $cnt--; - if(preg_match('/^'.$site->nzpresubject.'$/', $groupMsg['Subject']) && preg_match('/^'.$site->nzpreposter.'$/', $groupMsg['From'])) { + if(preg_match('/^'.$this->pdo->getSetting('nzpresubject').'$/', $groupMsg['Subject']) && preg_match('/^'.$this->pdo->getSetting('nzpreposter').'$/', $groupMsg['From'])) { $ret = $msgHeader = $nntp->getHeader($groupMsg['Message-ID']); if($nntp->isError($ret)) continue; for($i=0; $i < count($msgHeader); $i++) { - if(preg_match('/^'.$site->nzprefield.': /', $msgHeader[$i])) { - if($nzpreParse = $this->nzpreParse(str_replace($site->nzprefield.': ', '', $msgHeader[$i]), $nzprekey)) + if(preg_match('/^'.$this->pdo->getSetting('nzprefield').': /', $msgHeader[$i])) { + if($nzpreParse = $this->nzpreParse(str_replace($this->pdo->getSetting('nzprefield').': ', '', $msgHeader[$i]), $nzprekey)) { if ($this->updatePreDB($this->pdo, $nzpreParse)) { @@ -275,4 +269,4 @@ class PreDB if($this->echooutput) echo "\nPredb : Added/Updated ".$added_updated." records\n"; } -} +} \ No newline at end of file diff --git a/newznab/controllers/PreHash.php b/newznab/controllers/PreHash.php index 8eeb00ae2..3f3992221 100644 --- a/newznab/controllers/PreHash.php +++ b/newznab/controllers/PreHash.php @@ -1,7 +1,7 @@ echooutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); } /** diff --git a/newznab/controllers/ReleaseCleaning.php b/newznab/controllers/ReleaseCleaning.php index 17273a53c..c29e890cb 100644 --- a/newznab/controllers/ReleaseCleaning.php +++ b/newznab/controllers/ReleaseCleaning.php @@ -1,6 +1,6 @@ e1 = self::REGEX_FILE_EXTENSIONS . self::REGEX_END; $this->e2 = self::REGEX_FILE_EXTENSIONS . self::REGEX_SUBJECT_SIZE . self::REGEX_END; - $this->pdo = ($settings instanceof DB ? $settings : new DB()); + $this->pdo = ($settings instanceof Settings ? $settings : new Settings()); } public function releaseCleaner($subject, $fromName, $groupName, $usepre = false) diff --git a/newznab/controllers/ReleaseComments.php b/newznab/controllers/ReleaseComments.php index 3dde85184..0330477c2 100644 --- a/newznab/controllers/ReleaseComments.php +++ b/newznab/controllers/ReleaseComments.php @@ -1,6 +1,6 @@ queryOneRow(sprintf("SELECT * FROM releasecomment WHERE id = %d", $id)); } @@ -22,7 +22,7 @@ class ReleaseComments */ public function getCommentsByGid($gid) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("SELECT rc.id, text, createddate, sourceid, CASE WHEN sourceid = 0 THEN (SELECT username FROM users WHERE id = userid) ELSE username END AS username, CASE WHEN sourceid = 0 THEN (SELECT role FROM users WHERE id = userid) ELSE '-1' END AS role, CASE WHEN sourceid =0 THEN (SELECT r.name AS rolename FROM users AS u LEFT JOIN userroles AS r ON r.id = u.role WHERE u.id = userid) ELSE (SELECT description AS rolename FROM spotnabsources WHERE id = sourceid) END AS rolename FROM releasecomment rc WHERE isvisible = 1 AND gid = %s AND (userid IN (SELECT id FROM users) OR rc.username IS NOT NULL) ORDER BY createddate DESC LIMIT 100", $db->escapeString($gid))); } @@ -31,7 +31,7 @@ class ReleaseComments */ public function getCommentsByGuid($guid) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("SELECT rc.id, text, createddate, sourceid, CASE WHEN sourceid = 0 THEN (SELECT username FROM users WHERE id = userid) ELSE username END AS username FROM releasecomment rc LEFT JOIN releases r ON r.gid = rc.gid WHERE isvisible = 1 AND guid = %s AND (userid IN (SELECT id FROM users) OR rc.username IS NOT NULL) ORDER BY createddate DESC LIMIT 100", $db->escapeString($guid))); } @@ -40,7 +40,7 @@ class ReleaseComments */ public function getCommentCount($refdate=Null, $localOnly=Null) { - $db = new DB(); + $db = new Settings(); if($refdate !== Null){ if(is_string($refdate)){ // ensure we're in the right format @@ -80,7 +80,7 @@ class ReleaseComments */ public function deleteComment($id) { - $db = new DB(); + $db = new Settings(); $res = $this->getCommentById($id); if ($res) { @@ -94,7 +94,7 @@ class ReleaseComments */ public function deleteCommentsForRelease($id) { - $db = new DB(); + $db = new Settings(); $res = $this->getCommentById($id); if ($res) { @@ -108,7 +108,7 @@ class ReleaseComments */ public function deleteCommentsForUser($id) { - $db = new DB(); + $db = new Settings(); $numcomments = $this->getCommentCountForUser($id); if ($numcomments > 0) @@ -130,9 +130,9 @@ class ReleaseComments if(strlen(trim($text)) == 0) return false; - $db = new DB(); + $db = new Settings(); - $site = new Sites(); + $site = new Settings(); $s = $site->get(); if ($s->storeuserips != "1") $host = ""; @@ -147,7 +147,7 @@ class ReleaseComments */ public function getCommentsRange($start, $num) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; @@ -163,7 +163,7 @@ class ReleaseComments */ public function updateReleaseCommentCount($gid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update releases SET comments = (SELECT count(id) FROM releasecomment WHERE releasecomment.gid = releases.gid AND isvisible = 1) WHERE releases.gid = %s", $db->escapeString($gid) )); @@ -174,7 +174,7 @@ class ReleaseComments */ public function getCommentCountForUser($uid) { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("SELECT count(id) AS num FROM releasecomment WHERE userid = %d AND isvisible = 1", $uid)); return $res["num"]; } @@ -184,7 +184,7 @@ class ReleaseComments */ public function getCommentsForUserRange($uid, $start, $num) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; diff --git a/newznab/controllers/ReleaseExtra.php b/newznab/controllers/ReleaseExtra.php index f43253444..f218c99d8 100644 --- a/newznab/controllers/ReleaseExtra.php +++ b/newznab/controllers/ReleaseExtra.php @@ -1,6 +1,6 @@ query(sprintf("select * from releaseaudio where releaseid = %d order by audioID ASC", $id)); } public function getBriefByGuid($guid) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select containerformat,videocodec,videoduration,videoaspect, concat(releasevideo.videowidth,'x',releasevideo.videoheight,' @',format(videoframerate,0),'fps') as size, group_concat(distinct releaseaudio.audiolanguage SEPARATOR ', ') as audio, group_concat(distinct releaseaudio.audiobitrate SEPARATOR ', ') as audiobitrate, group_concat(distinct releaseaudio.audioformat SEPARATOR ', ') as audioformat, group_concat(distinct releaseaudio.audiomode SEPARATOR ', ') as audiomode, group_concat(distinct releaseaudio.audiobitratemode SEPARATOR ', ') as audiobitratemode, group_concat(distinct releasesubs.subslanguage SEPARATOR ', ') as subs from releaseaudio left outer join releasesubs on releaseaudio.releaseid = releasesubs.releaseid left outer join releasevideo on releasevideo.releaseid = releaseaudio.releaseid inner join releases r on r.id = releaseaudio.releaseid where r.guid = %s group by r.id", $db->escapeString($guid))); } public function delete($id) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from releaseaudio where releaseid = %d", $id)); $db->queryExec(sprintf("DELETE from releasesubs where releaseid = %d", $id)); $db->queryExec(sprintf("DELETE from releaseextrafull where releaseid = %d", $id)); @@ -165,7 +165,7 @@ class ReleaseExtra */ public function addVideo($releaseID, $containerformat, $overallbitrate, $videoduration, $videoformat, $videocodec, $videowidth, $videoheight, $videoaspect, $videoframerate, $videolibrary) { - $db = new DB(); + $db = new Settings(); $row = $this->getVideo($releaseID); if ($row) @@ -191,7 +191,7 @@ class ReleaseExtra public function getVideo($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from releasevideo where releaseid = %d", $id)); } @@ -239,7 +239,7 @@ class ReleaseExtra */ public function addAudio($releaseID, $audioID, $audioformat, $audiomode, $audiobitratemode, $audiobitrate, $audiochannels, $audiosamplerate, $audiolibrary, $audiolanguage, $audiotitle) { - $db = new DB(); + $db = new Settings(); $row = $this->getAudioAndChannel($releaseID, $audioID); if ($row) @@ -259,14 +259,14 @@ class ReleaseExtra public function getAudioAndChannel($rid, $aid) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from releaseaudio where releaseid = %d and audioID = %d", $rid, $aid)); } public function addSubs($releaseID, $subsID, $subslanguage) { - $db = new DB(); + $db = new Settings(); $row = $this->getSubs($releaseID); if ($row) return -1; @@ -278,21 +278,21 @@ class ReleaseExtra public function getSubs($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT group_concat(subslanguage SEPARATOR ', ') as subs FROM `releasesubs` WHERE `releaseid` = %d ORDER BY `subsID` ASC", $id)); } public function deleteFull($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from releaseextrafull where releaseid = %d", $id)); } public function addFull($id, $xml) { - $db = new DB(); + $db = new Settings(); $row = $this->getFull($id); if ($row) return -1; @@ -302,7 +302,7 @@ class ReleaseExtra public function getFull($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from releaseextrafull where releaseid = %d", $id)); } diff --git a/newznab/controllers/ReleaseFiles.php b/newznab/controllers/ReleaseFiles.php index 0bd9b9321..1e750edba 100644 --- a/newznab/controllers/ReleaseFiles.php +++ b/newznab/controllers/ReleaseFiles.php @@ -1,6 +1,6 @@ query(sprintf("select * from releasefiles where releaseid = %d order by releasefiles.name ", $id)); } @@ -21,7 +21,7 @@ class ReleaseFiles */ public function getByGuid($guid) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("select releasefiles.* from releasefiles inner join releases r on r.id = releasefiles.releaseid where r.guid = %s order by releasefiles.name ", $db->escapeString($guid))); } @@ -30,7 +30,7 @@ class ReleaseFiles */ public function delete($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from releasefiles where releaseid = %d", $id)); } @@ -39,7 +39,7 @@ class ReleaseFiles */ public function add($id, $name, $size, $createddate, $passworded) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("INSERT INTO releasefiles (releaseid, name, size, createddate, passworded) VALUES (%d, %s, %s, from_unixtime(%d), %d)", $id, $db->escapeString($name), $db->escapeString($size), $createddate, $passworded ); return $db->queryInsert($sql); } diff --git a/newznab/controllers/ReleaseImage.php b/newznab/controllers/ReleaseImage.php index 4ae6e0e5d..23e7c3353 100644 --- a/newznab/controllers/ReleaseImage.php +++ b/newznab/controllers/ReleaseImage.php @@ -1,6 +1,6 @@ audSavePath = NN_COVERS . 'audiosample' . DS; // releases guid diff --git a/newznab/controllers/ReleaseRegex.php b/newznab/controllers/ReleaseRegex.php index b20ee316f..feef7e7df 100644 --- a/newznab/controllers/ReleaseRegex.php +++ b/newznab/controllers/ReleaseRegex.php @@ -1,6 +1,6 @@ regexes = []; - $this->pdo = new DB(); - $s = new Sites(); - $this->site = $s->get(); - $this->tablePerGroup = $this->site->tablepergroup; + $this->pdo = new Settings(); + $this->tablePerGroup = $this->pdo->getSetting('tablepergroup'); } /** diff --git a/newznab/controllers/ReleaseRemover.php b/newznab/controllers/ReleaseRemover.php index ae5473be4..f3d60c7ca 100644 --- a/newznab/controllers/ReleaseRemover.php +++ b/newznab/controllers/ReleaseRemover.php @@ -1,6 +1,6 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->consoleTools = ($options['ConsoleTools'] instanceof \ConsoleTools ? $options['ConsoleTools'] : new \ConsoleTools(['ColorCLI' => $this->pdo->log])); $this->releases = ($options['Releases'] instanceof \Releases ? $options['Releases'] : new \Releases(['Settings' => $this->pdo])); $this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo)); diff --git a/newznab/controllers/ReleaseSearch.php b/newznab/controllers/ReleaseSearch.php index 681819e16..608c6c55b 100644 --- a/newznab/controllers/ReleaseSearch.php +++ b/newznab/controllers/ReleaseSearch.php @@ -1,6 +1,6 @@ pdo = ($settings instanceof newznab\db\DB ? $settings : new newznab\db\DB()); + $this->pdo = ($settings instanceof newznab\db\Settings ? $settings : new newznab\db\Settings()); } /** diff --git a/newznab/controllers/Releases.php b/newznab/controllers/Releases.php index e38ceda7b..666120ace 100644 --- a/newznab/controllers/Releases.php +++ b/newznab/controllers/Releases.php @@ -1,6 +1,6 @@ echoCLI = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $s = new Sites(); - $this->site = $s->get(); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->consoleTools = ($options['ConsoleTools'] instanceof \ConsoleTools ? $options['ConsoleTools'] : new \ConsoleTools(['ColorCLI' => $this->pdo->log])); $this->groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->pdo])); $this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB()); $this->releaseCleaning = ($options['ReleaseCleaning'] instanceof \ReleaseCleaning ? $options['ReleaseCleaning'] : new \ReleaseCleaning($this->pdo)); $this->releaseImage = ($options['ReleaseImage'] instanceof \ReleaseImage ? $options['ReleaseImage'] : new \ReleaseImage($this->pdo)); - $this->updategrabs = ($this->site->grabstatus == '0' ? false : true); - $this->passwordStatus = ($this->site->checkpasswordedrar == 1 ? -1 : 0); + $this->updategrabs = ($this->pdo->getSetting('grabstatus') == '0' ? false : true); + $this->passwordStatus = ($this->pdo->getSetting('checkpasswordedrar') == 1 ? -1 : 0); $this->sphinxSearch = new \SphinxSearch(); $this->releaseSearch = new \ReleaseSearch($this->pdo, $this->sphinxSearch); $this->releaseRegex = new \ReleaseRegex(); - $this->tablePerGroup = ($this->site->tablepergroup == 0 ? false : true); - $this->crossPostTime = ($this->site->crossposttime != '' ? (int)$this->site->crossposttime : 2); - $this->releaseCreationLimit = ($this->site->maxnzbsprocessed != '' ? (int)$this->site->maxnzbsprocessed : 1000); - $this->completion = ($this->site->completionpercent != '' ? (int)$this->site->completionpercent : 0); - $this->processRequestIDs = (int)$this->site->lookup_reqids; + $this->tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 0 ? false : true); + $this->crossPostTime = ($this->pdo->getSetting('crossposttime') != '' ? (int)$this->pdo->getSetting('crossposttime') : 2); + $this->releaseCreationLimit = ($this->pdo->getSetting('maxnzbsprocessed') != '' ? (int)$this->pdo->getSetting('maxnzbsprocessed') : 1000); + $this->completion = ($this->pdo->getSetting('completionpercent') != '' ? (int)$this->pdo->getSetting('completionpercent') : 0); + $this->processRequestIDs = (int)$this->pdo->getSetting('lookup_reqids'); if ($this->completion > 100) { $this->completion = 100; echo $this->pdo->log->error(PHP_EOL . 'You have an invalid setting for completion. It must be lower than 100.'); @@ -559,7 +557,7 @@ class Releases $anidb = ($anidbid > -1) ? sprintf(" and releases.anidbid = %d ", $anidbid) : ''; $airdate = ($airdate > -1) ? sprintf(" and releases.tvairdate >= DATE_SUB(CURDATE(), INTERVAL %d DAY) ", $airdate) : ''; - $sql = sprintf(" SELECT releases.*, rn.id AS nfoid, m.title AS imdbtitle, m.cover, m.imdbid, m.rating, m.plot, m.year, m.genre, m.director, m.actors, g.name AS group_name, concat(cp.title, ' > ', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, coalesce(cp.id,0) AS parentCategoryID, mu.title AS mu_title, mu.url AS mu_url, mu.artist AS mu_artist, mu.publisher AS mu_publisher, mu.releasedate AS mu_releasedate, mu.review AS mu_review, mu.tracks AS mu_tracks, mu.cover AS mu_cover, mug.title AS mu_genre, co.title AS co_title, co.url AS co_url, co.publisher AS co_publisher, co.releasedate AS co_releasedate, co.review AS co_review, co.cover AS co_cover, cog.title AS co_genre, bo.title AS bo_title, bo.url AS bo_url, bo.publisher AS bo_publisher, bo.author AS bo_author, bo.publishdate AS bo_publishdate, bo.review AS bo_review, bo.cover AS bo_cover FROM releases LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN category cp ON cp.id = c.parentid LEFT OUTER JOIN groups g ON g.id = releases.groupid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN movieinfo m ON m.imdbid = releases.imdbid AND m.title != '' LEFT OUTER JOIN musicinfo mu ON mu.id = releases.musicinfoid LEFT OUTER JOIN genres mug ON mug.id = mu.genreID LEFT OUTER JOIN bookinfo bo ON bo.id = releases.bookinfoid LEFT OUTER JOIN consoleinfo co ON co.id = releases.consoleinfoid LEFT OUTER JOIN genres cog ON cog.id = co.genreID %s WHERE releases.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') %s %s %s %s ORDER BY postdate DESC %s", $cartsrch, $catsrch, $rage, $anidb, $airdate, $limit); + $sql = sprintf(" SELECT releases.*, rn.id AS nfoid, m.title AS imdbtitle, m.cover, m.imdbid, m.rating, m.plot, m.year, m.genre, m.director, m.actors, g.name AS group_name, concat(cp.title, ' > ', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, coalesce(cp.id,0) AS parentCategoryID, mu.title AS mu_title, mu.url AS mu_url, mu.artist AS mu_artist, mu.publisher AS mu_publisher, mu.releasedate AS mu_releasedate, mu.review AS mu_review, mu.tracks AS mu_tracks, mu.cover AS mu_cover, mug.title AS mu_genre, co.title AS co_title, co.url AS co_url, co.publisher AS co_publisher, co.releasedate AS co_releasedate, co.review AS co_review, co.cover AS co_cover, cog.title AS co_genre, bo.title AS bo_title, bo.url AS bo_url, bo.publisher AS bo_publisher, bo.author AS bo_author, bo.publishdate AS bo_publishdate, bo.review AS bo_review, bo.cover AS bo_cover FROM releases LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN category cp ON cp.id = c.parentid LEFT OUTER JOIN groups g ON g.id = releases.groupid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN movieinfo m ON m.imdbid = releases.imdbid AND m.title != '' LEFT OUTER JOIN musicinfo mu ON mu.id = releases.musicinfoid LEFT OUTER JOIN genres mug ON mug.id = mu.genreID LEFT OUTER JOIN bookinfo bo ON bo.id = releases.bookinfoid LEFT OUTER JOIN consoleinfo co ON co.id = releases.consoleinfoid LEFT OUTER JOIN genres cog ON cog.id = co.genreID %s WHERE releases.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') %s %s %s %s ORDER BY postdate DESC %s", $cartsrch, $catsrch, $rage, $anidb, $airdate, $limit); return $this->pdo->query($sql, true); } @@ -607,7 +605,7 @@ class Releases GROUP BY rageid, season, episode, categoryid ) z ON z.id = releases.id WHERE %s %s %s - AND releases.passwordstatus <= (SELECT VALUE FROM site WHERE setting='showpasswordedrelease') + AND releases.passwordstatus <= (SELECT VALUE FROM settings WHERE setting='showpasswordedrelease') ORDER BY postdate DESC %s", $usql, $usql, $exccatlist, $airdate, $limit ); @@ -649,7 +647,7 @@ class Releases LEFT OUTER JOIN groups g ON g.id = releases.groupid LEFT OUTER JOIN movieinfo mi ON mi.imdbid = releases.imdbid WHERE %s %s - AND releases.passwordstatus <= (SELECT VALUE FROM site WHERE setting='showpasswordedrelease') + AND releases.passwordstatus <= (SELECT VALUE FROM settings WHERE setting='showpasswordedrelease') ORDER BY postdate DESC %s", $usql, $exccatlist, $limit ); @@ -691,7 +689,7 @@ class Releases $maxagesql = sprintf(" and releases.postdate > now() - interval %d day ", $maxage); $order = $this->getBrowseOrder($orderby); - $sql = sprintf(" SELECT releases.*, concat(cp.title, '-', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, groups.name AS group_name, pre.ctime, pre.nuketype, rn.id AS nfoid, re.releaseid AS reID FROM releases LEFT OUTER JOIN releasevideo re ON re.releaseid = releases.id LEFT OUTER JOIN groups ON groups.id = releases.groupid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN predb pre ON pre.id = releases.preid LEFT OUTER JOIN category cp ON cp.id = c.parentid WHERE %s %s AND releases.passwordstatus <= (SELECT VALUE FROM site WHERE setting='showpasswordedrelease') %s ORDER BY %s %s" . $limit, $usql, $exccatlist, $maxagesql, $order[0], $order[1]); + $sql = sprintf(" SELECT releases.*, concat(cp.title, '-', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, groups.name AS group_name, pre.ctime, pre.nuketype, rn.id AS nfoid, re.releaseid AS reID FROM releases LEFT OUTER JOIN releasevideo re ON re.releaseid = releases.id LEFT OUTER JOIN groups ON groups.id = releases.groupid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN predb pre ON pre.id = releases.preid LEFT OUTER JOIN category cp ON cp.id = c.parentid WHERE %s %s AND releases.passwordstatus <= (SELECT VALUE FROM settings WHERE setting='showpasswordedrelease') %s ORDER BY %s %s" . $limit, $usql, $exccatlist, $maxagesql, $order[0], $order[1]); return $this->pdo->query($sql, true); } @@ -731,7 +729,7 @@ class Releases if ($maxage > 0) $maxagesql = sprintf(" and releases.postdate > now() - interval %d day ", $maxage); - $res = $this->pdo->queryOneRow(sprintf(" SELECT count(releases.id) AS num FROM releases WHERE %s %s AND releases.passwordstatus <= (SELECT VALUE FROM site WHERE setting='showpasswordedrelease') %s", $usql, $exccatlist, $maxagesql), true); + $res = $this->pdo->queryOneRow(sprintf(" SELECT count(releases.id) AS num FROM releases WHERE %s %s AND releases.passwordstatus <= (SELECT VALUE FROM settings WHERE setting='showpasswordedrelease') %s", $usql, $exccatlist, $maxagesql), true); return $res["num"]; } @@ -988,7 +986,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 Sites(); + $s = new Settings(); $site = $s->get(); if ($site->sphinxenabled) { $sphinx = new Sphinx(); @@ -1050,7 +1048,7 @@ class Releases $genresql .= "1=2 )"; } - $sql = sprintf("SELECT releases.*, musicinfo.cover AS mi_cover, musicinfo.review AS mi_review, musicinfo.tracks AS mi_tracks, musicinfo.publisher AS mi_publisher, musicinfo.title AS mi_title, musicinfo.artist AS mi_artist, genres.title AS music_genrename, concat(cp.title, ' > ', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, groups.name AS group_name, rn.id AS nfoid FROM releases %s LEFT OUTER JOIN musicinfo ON musicinfo.id = releases.musicinfoid LEFT JOIN genres ON genres.id = musicinfo.genreID LEFT OUTER JOIN groups ON groups.id = releases.groupid LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN category cp ON cp.id = c.parentid WHERE releases.passwordstatus <= (SELECT VALUE FROM site WHERE setting='showpasswordedrelease') %s %s %s %s ORDER BY postdate DESC LIMIT %d, %d ", $usecatindex, $searchsql, $catsrch, $maxage, $genresql, $offset, $limit); + $sql = sprintf("SELECT releases.*, musicinfo.cover AS mi_cover, musicinfo.review AS mi_review, musicinfo.tracks AS mi_tracks, musicinfo.publisher AS mi_publisher, musicinfo.title AS mi_title, musicinfo.artist AS mi_artist, genres.title AS music_genrename, concat(cp.title, ' > ', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, groups.name AS group_name, rn.id AS nfoid FROM releases %s LEFT OUTER JOIN musicinfo ON musicinfo.id = releases.musicinfoid LEFT JOIN genres ON genres.id = musicinfo.genreID LEFT OUTER JOIN groups ON groups.id = releases.groupid LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN category cp ON cp.id = c.parentid WHERE releases.passwordstatus <= (SELECT VALUE FROM settings WHERE setting='showpasswordedrelease') %s %s %s %s ORDER BY postdate DESC LIMIT %d, %d ", $usecatindex, $searchsql, $catsrch, $maxage, $genresql, $offset, $limit); $orderpos = strpos($sql, "order by"); $wherepos = strpos($sql, "where"); $sqlcount = "SELECT count(releases.id) AS num FROM releases INNER JOIN musicinfo ON musicinfo.id = releases.musicinfoid " . substr($sql, $wherepos, $orderpos - $wherepos); @@ -1068,7 +1066,7 @@ class Releases */ public function searchBook($author, $title, $offset = 0, $limit = 100, $maxage = -1) { - $s = new Sites(); + $s = new Settings(); $site = $s->get(); if ($site->sphinxenabled) { $sphinx = new Sphinx(); @@ -1090,7 +1088,7 @@ class Releases else $maxage = ""; - $sql = sprintf("SELECT releases.*, bookinfo.cover AS bi_cover, bookinfo.review AS bi_review, bookinfo.publisher AS bi_publisher, bookinfo.pages AS bi_pages, bookinfo.publishdate AS bi_publishdate, bookinfo.title AS bi_title, bookinfo.author AS bi_author, genres.title AS book_genrename, concat(cp.title, ' > ', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, groups.name AS group_name, rn.id AS nfoid FROM releases LEFT OUTER JOIN bookinfo ON bookinfo.id = releases.bookinfoid LEFT JOIN genres ON genres.id = bookinfo.genreID LEFT OUTER JOIN groups ON groups.id = releases.groupid LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN category cp ON cp.id = c.parentid WHERE releases.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') %s %s ORDER BY postdate DESC LIMIT %d, %d ", $searchsql, $maxage, $offset, $limit); + $sql = sprintf("SELECT releases.*, bookinfo.cover AS bi_cover, bookinfo.review AS bi_review, bookinfo.publisher AS bi_publisher, bookinfo.pages AS bi_pages, bookinfo.publishdate AS bi_publishdate, bookinfo.title AS bi_title, bookinfo.author AS bi_author, genres.title AS book_genrename, concat(cp.title, ' > ', c.title) AS category_name, concat(cp.id, ',', c.id) AS category_ids, groups.name AS group_name, rn.id AS nfoid FROM releases LEFT OUTER JOIN bookinfo ON bookinfo.id = releases.bookinfoid LEFT JOIN genres ON genres.id = bookinfo.genreID LEFT OUTER JOIN groups ON groups.id = releases.groupid LEFT OUTER JOIN category c ON c.id = releases.categoryid LEFT OUTER JOIN releasenfo rn ON rn.releaseid = releases.id AND rn.nfo IS NOT NULL LEFT OUTER JOIN category cp ON cp.id = c.parentid WHERE releases.passwordstatus <= (SELECT value FROM settings WHERE setting='showpasswordedrelease') %s %s ORDER BY postdate DESC LIMIT %d, %d ", $searchsql, $maxage, $offset, $limit); $orderpos = strpos($sql, "order by"); $wherepos = strpos($sql, "where"); $sqlcount = "SELECT count(releases.id) AS num FROM releases INNER JOIN bookinfo ON bookinfo.id = releases.bookinfoid " . substr($sql, $wherepos, $orderpos - $wherepos); @@ -1337,7 +1335,7 @@ class Releases */ public function getZipped($guids) { - $s = new Sites(); + $s = new Settings(); $this->nzb = new NZB; $site = $s->get(); $zipfile = new zipfile(); @@ -1447,7 +1445,7 @@ class Releases $this->echoCLI = ($echooutput && NN_ECHOCLI); $page = new Page(); $groupID = ''; - $s = new Sites(); + $s = new Settings(); echo $s->getLicense(); if (!empty($groupName)) { @@ -1631,7 +1629,7 @@ class Releases $page = new Page(); $group = $this->groups->getCBPTableNames($this->tablePerGroup, $groupID); $this->pdo->log->doEcho($this->pdo->log->primary('Marking binaries where all parts are available')); - $result = $this->pdo->queryDirect(sprintf("SELECT relname, date, SUM(reltotalpart) AS reltotalpart, groupid, reqid, fromname, SUM(num) AS num, coalesce(g.minfilestoformrelease, s.minfilestoformrelease) AS minfilestoformrelease FROM ( SELECT relname, reltotalpart, groupid, reqid, fromname, max(date) AS date, COUNT(id) AS num FROM %s WHERE procstat = %s GROUP BY relname, reltotalpart, groupid, reqid, fromname ORDER BY NULL ) x LEFT OUTER JOIN groups g ON g.id = x.groupid INNER JOIN ( SELECT value AS minfilestoformrelease FROM site WHERE setting = 'minfilestoformrelease' ) s GROUP BY relname, groupid, reqid, fromname, minfilestoformrelease ORDER BY NULL", $group['bname'], Releases::PROCSTAT_TITLEMATCHED)); + $result = $this->pdo->queryDirect(sprintf("SELECT relname, date, SUM(reltotalpart) AS reltotalpart, groupid, reqid, fromname, SUM(num) AS num, coalesce(g.minfilestoformrelease, s.minfilestoformrelease) AS minfilestoformrelease FROM ( SELECT relname, reltotalpart, groupid, reqid, fromname, max(date) AS date, COUNT(id) AS num FROM %s WHERE procstat = %s GROUP BY relname, reltotalpart, groupid, reqid, fromname ORDER BY NULL ) x LEFT OUTER JOIN groups g ON g.id = x.groupid INNER JOIN ( SELECT value AS minfilestoformrelease FROM settings WHERE setting = 'minfilestoformrelease' ) s GROUP BY relname, groupid, reqid, fromname, minfilestoformrelease ORDER BY NULL", $group['bname'], Releases::PROCSTAT_TITLEMATCHED)); while ($row = $this->pdo->getAssocArray($result)) { $retcount++; @@ -1912,7 +1910,7 @@ class Releases $serverrev = intval($matches[1]); if ($serverrev > $rev) { - $site = new Sites; + $site = new Settings; $queries = explode(";", $regfile); $queries = array_map("trim", $queries); @@ -2137,7 +2135,7 @@ class Releases { $users = new Users(); - $s = new Sites(); + $s = new Settings(); $nfo = new Nfo(); $site = $s->get(); $rf = new ReleaseFiles(); @@ -2443,7 +2441,7 @@ class Releases $echoCLI = NN_ECHOCLI; $groups = new Groups(); - $s = new Sites(); + $s = new Settings(); $site = $s->get(); $consoleTools = new ConsoleTools(['ColorCLI' => $this->pdo->log]); if ($local === false && $site->lookup_reqids == 0) { @@ -2515,9 +2513,9 @@ class Releases $groupIDs = [['id' => $groupID]]; } - $maxSizeSetting = $this->site->maxsizetoformrelease; - $minSizeSetting = $this->site->minsizetoformrelease; - $minFilesSetting = $this->site->minfilestoformrelease; + $maxSizeSetting = $this->pdo->getSetting('maxsizetoformrelease'); + $minSizeSetting = $this->pdo->getSetting('minsizetoformrelease'); + $minFilesSetting = $this->pdo->getSetting('minfilestoformrelease'); foreach ($groupIDs as $groupID) { $releases = $this->pdo->queryDirect( @@ -2614,11 +2612,11 @@ class Releases } // Releases past retention. - if ($this->site->releaseretentiondays != 0) { + if ($this->pdo->getSetting('releaseretentiondays') != 0) { $releases = $this->pdo->queryDirect( sprintf( 'SELECT id, guid FROM releases WHERE postdate < (NOW() - INTERVAL %d DAY)', - $this->site->releaseretentiondays + $this->pdo->getSetting('releaseretentiondays') ) ); if ($releases instanceof \Traversable) { @@ -2630,7 +2628,7 @@ class Releases } // Passworded releases. - if ($this->site->deletepasswordedrelease == 1) { + if ($this->pdo->getSetting('deletepasswordedrelease') == 1) { $releases = $this->pdo->queryDirect( sprintf( 'SELECT id, guid FROM releases WHERE passwordstatus = %d', @@ -2646,7 +2644,7 @@ class Releases } // Possibly passworded releases. - if ($this->site->deletepossiblerelease == 1) { + if ($this->pdo->getSetting('deletepossiblerelease') == 1) { $releases = $this->pdo->queryDirect( sprintf( 'SELECT id, guid FROM releases WHERE passwordstatus = %d', @@ -2764,7 +2762,7 @@ class Releases } // Misc other. - if ($this->site->miscotherretentionhours > 0) { + if ($this->pdo->getSetting('miscotherretentionhours') > 0) { $releases = $this->pdo->queryDirect( sprintf(' SELECT id, guid @@ -2772,7 +2770,7 @@ class Releases WHERE categoryid = %d AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_MISC_OTHER, - $this->site->miscotherretentionhours + $this->pdo->getSetting('miscotherretentionhours') ) ); if ($releases instanceof \Traversable) { @@ -2784,7 +2782,7 @@ class Releases } // Misc hashed. - if ($this->site->mischashedretentionhours > 0) { + if ($this->pdo->getSetting('mischashedretentionhours') > 0) { $releases = $this->pdo->queryDirect( sprintf(' SELECT id, guid @@ -2792,7 +2790,7 @@ class Releases WHERE categoryid = %d AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_MISC_HASHED, - $this->site->mischashedretentionhours + $this->pdo->getSetting('mischashedretentionhours') ) ); if ($releases instanceof \Traversable) { @@ -2959,7 +2957,7 @@ class Releases } $setting = $this->pdo->queryOneRow( "SELECT value - FROM site + FROM settings WHERE setting = 'showpasswordedrelease'" ); $passwordStatus = ('= ' . \Releases::PASSWD_NONE); diff --git a/newznab/controllers/RequestID.php b/newznab/controllers/RequestID.php index 7e3e5602c..a28b91d3e 100644 --- a/newznab/controllers/RequestID.php +++ b/newznab/controllers/RequestID.php @@ -1,6 +1,6 @@ echoOutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->category = ($options['Categorize'] instanceof \Categorize ? $options['Categorize'] : new \Categorize(['Settings' => $this->pdo])); $this->groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->pdo])); $this->consoleTools = ($options['ConsoleTools'] instanceof \ConsoleTools ? $options['ConsoleTools'] : new \ConsoleTools(['ColorCLI' => $this->pdo->log])); @@ -156,7 +156,7 @@ abstract class RequestID protected $category; /** - * @var newznab\db\DB + * @var newznab\db\Settings */ protected $pdo; diff --git a/newznab/controllers/RequestIDWeb.php b/newznab/controllers/RequestIDWeb.php index 78487f5ee..5515369a3 100644 --- a/newznab/controllers/RequestIDWeb.php +++ b/newznab/controllers/RequestIDWeb.php @@ -31,9 +31,7 @@ class RequestIDWeb extends RequestID public function __construct(array $options = array()) { parent::__construct($options); - $s = new Sites(); - $this->site = $s->get(); - $this->_request_hours = ($this->site->request_hours != '') ? (int)$this->site->request_hours : 1; + $this->_request_hours = ($this->pdo->getSetting('request_hours') != '') ? (int)$this->pdo->getSetting('request_hours') : 1; } /** diff --git a/newznab/controllers/SABnzbd.php b/newznab/controllers/SABnzbd.php index 933f1c86e..9bc483c6a 100644 --- a/newznab/controllers/SABnzbd.php +++ b/newznab/controllers/SABnzbd.php @@ -1,6 +1,7 @@ uid = $page->userdata['id']; $this->rsstoken = $page->userdata['rsstoken']; $this->serverurl = $page->serverurl; + $this->pdo = new Settings(); // Set up properties. - switch ($page->site->sabintegrationtype) { + switch ($this->pdo->getSetting('sabintegrationtype')) { case self::INTEGRATION_TYPE_USER: if (!empty($_COOKIE['sabnzbd_' . $this->uid . '__apikey']) && !empty($_COOKIE['sabnzbd_' . $this->uid . '__host'])) { $this->url = $_COOKIE['sabnzbd_' . $this->uid . '__host']; @@ -117,11 +119,11 @@ class SABnzbd break; case self::INTEGRATION_TYPE_SITEWIDE: - if (!empty($page->site->sabapikey) && !empty($page->site->saburl)) { - $this->url = $page->site->saburl; - $this->apikey = $page->site->sabapikey; - $this->priority = $page->site->sabpriority; - $this->apikeytype = $page->site->sabapikeytype; + if (!empty($this->pdo->getSetting('sabapikey')) && !empty($page->settings->saburl)) { + $this->url = $page->settings->saburl; + $this->apikey = $page->settings->sabapikey; + $this->priority = $page->settings->sabpriority; + $this->apikeytype = $page->settings->sabapikeytype; } $this->integrated = self::INTEGRATION_TYPE_SITEWIDE; $this->integratedBool = true; diff --git a/newznab/controllers/Sharing.php b/newznab/controllers/Sharing.php index a63dc460a..da71a788f 100644 --- a/newznab/controllers/Sharing.php +++ b/newznab/controllers/Sharing.php @@ -1,6 +1,6 @@ pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); // Get all sharing info from DB. $check = $this->pdo->queryOneRow('SELECT * FROM sharing'); diff --git a/newznab/controllers/Sites.php b/newznab/controllers/Sites.php index 4e60516c4..35a356f6b 100644 --- a/newznab/controllers/Sites.php +++ b/newznab/controllers/Sites.php @@ -1,6 +1,6 @@ row2Object($form); if (substr($site->nzbpath, strlen($site->nzbpath) - 1) != '/') @@ -79,7 +79,7 @@ class Sites $cache->delete($sql); } - $db = new DB(); + $db = new Settings(); $rows = $db->query($sql, true, NN_CACHE_EXPIRY_MEDIUM); if ($rows === false) @@ -131,7 +131,7 @@ class Sites public function updateItem($setting, $value) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("update site set value = %s where setting = %s", $db->escapeString($value), $db->escapeString($setting)); return $db->exec($sql); diff --git a/newznab/controllers/Sphinx.php b/newznab/controllers/Sphinx.php index 9f7b28e2b..59c7b78ee 100644 --- a/newznab/controllers/Sphinx.php +++ b/newznab/controllers/Sphinx.php @@ -10,6 +10,7 @@ if (!defined("FS_ROOT")) { define('FS_ROOT', realpath(dirname(__FILE__))); } use newznab\libraries\Cache; +use newznab\db\Settings; // Every day define("INDEX_MERGE_FREQ", 1440); @@ -30,10 +31,8 @@ class Sphinx */ function __construct() { - $s = new Sites; - - $this->site = $s->get(); $this->nzb = new NZB; + $this->pdo = new Settings(); $this->indexes = array("releases", "releasefiles", "releasenfo", "nzbs", "predb"); } @@ -81,8 +80,8 @@ class Sphinx */ public function getNextRebuildDate() { - $rebuildStr = $this->site->sphinxrebuildfreq_day." " - . $this->site->sphinxrebuildfreq; + $rebuildStr = $this->pdo->getSetting('sphinxrebuildfreq_day')." " + . $this->pdo->getSetting('sphinxrebuildfreq'); $rebuildDate = strtotime($rebuildStr); if ($rebuildDate < time(true)) { // Date is in the past, pick the next one @@ -107,7 +106,7 @@ class Sphinx return false; } - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); if ($lastRebuildDate == 0) { $lastRebuildDate = "NOW()"; @@ -145,7 +144,7 @@ class Sphinx return false; } - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); if ($lastMergedDate == 0) { $lastMergedDate = "NOW()"; @@ -253,7 +252,7 @@ class Sphinx $index .= "_delta"; } - $handle = fopen($this->site->sphinxconfpath, 'r'); + $handle = fopen($this->pdo->getSetting('sphinxconfpath'), 'r'); if ($handle) { $indexPath = ""; while ($line = fgets($handle)) { @@ -305,9 +304,9 @@ class Sphinx */ public function update() { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); - if (!$this->site->sphinxenabled) { + if (!$this->pdo->getSetting('sphinxenabled')) { // Sphinx is disabled, so we don't do anything. return; } @@ -325,10 +324,10 @@ class Sphinx $indexDetails = $this->indexDetails($index); $isMergeDueDate = (strtotime($row['nextmergedate']) <= time(true)); $isMergeDueSize = (intval($indexDetails["total-documents"]) >= - intval($this->site->sphinxmergefreq_count)); + intval($this->pdo->getSetting('sphinxmergefreq_count'))); if (strtotime($row['nextrebuilddate']) <= time(true) && - $this->site->sphinxrebuildfreq_day != "") + $this->pdo->getSetting('sphinxrebuildfreq_day') != "") { // Rebuild required printf("Index '%s' is going to be rebuilt.\n", $index); @@ -376,8 +375,8 @@ class Sphinx */ public function getSphinxBinPath($bin) { - $path = rtrim($this->site->sphinxbinpath, DIRECTORY_SEPARATOR); - $conf = $this->site->sphinxconfpath; + $path = rtrim($this->pdo->getSetting('sphinxbinpath'), DIRECTORY_SEPARATOR); + $conf = $this->pdo->getSetting('sphinxconfpath'); if ($path) { // $path is a path to a directory. @@ -399,7 +398,7 @@ class Sphinx public function isIndexEnabled($index) { // Is Sphinx enabled? - if (!$this->site->sphinxenabled) { + if (!$this->pdo->getSetting('sphinxenabled')) { return false; } @@ -410,13 +409,13 @@ class Sphinx case "releases": return true; // Always enabled, as long as Sphinx is case "releasenfo": - return (bool)$this->site->sphinxindexnfos; + return (bool)$this->pdo->getSetting('sphinxindexnfos'); case "releasefiles": - return (bool)$this->site->sphinxindexreleasefiles; + return (bool)$this->pdo->getSetting('sphinxindexreleasefiles'); case "nzbs": - return (bool)$this->site->sphinxindexnzbs; + return (bool)$this->pdo->getSetting('sphinxindexnzbs'); case "predb": - return (bool)$this->site->sphinxindexpredb; + return (bool)$this->pdo->getSetting('sphinxindexpredb'); default: return false; } @@ -533,7 +532,7 @@ class Sphinx // Get connection to Sphinx's MySQL interface. // Connect to Sphinx - $hostport = explode (":", $this->site->sphinxserverhost); + $hostport = explode (":", $this->pdo->getSetting('sphinxserverhost')); $sdb = mysqli_connect($hostport[0], "root", "", "", $hostport[1]); if (!$sdb) { // Couldn't connect to Sphinx. @@ -541,7 +540,7 @@ class Sphinx } // Get connection to Newznab's MySQL database - $ndb = new newznab\db\DB; + $ndb = new newznab\db\Settings; // Determine which release to start with if ($startingID < 0) { @@ -570,7 +569,7 @@ class Sphinx while ($row = $ndb->getAssocArray($result)) { $fileNames = ""; $fileCount = 0; - $nzbpath = $this->nzb->getNZBPath($row['guid'], $this->site->nzbpath); + $nzbpath = $this->nzb->getNZBPath($row['guid'], $this->pdo->getSetting('nzbpath')); if (file_exists($nzbpath)) { $nzbfile = file_get_contents('compress.zlib://'.$nzbpath); $files = $this->nzb->nzbFileList($nzbfile); @@ -630,7 +629,7 @@ class Sphinx } // Connect to Sphinx - $hostport = explode (":", $this->site->sphinxserverhost); + $hostport = explode (":", $this->pdo->getSetting('sphinxserverhost')); $sdb = mysqli_connect($hostport[0], "root", "", "", $hostport[1]); if (!$sdb) { // Couldn't connect to Sphinx. @@ -675,7 +674,7 @@ class Sphinx } if ($lookupQuery && count($results) > 0) { - $ndb = new newznab\db\DB; + $ndb = new newznab\db\Settings; $sql = sprintf($lookupQuery, implode(",", $results)); $result = $ndb->queryDirect($sql); if ($result) @@ -721,7 +720,7 @@ class Sphinx $indexes=array(), $lookup=true, $where=array(), &$lookupQuery="") { - $ndb = new newznab\db\DB; + $ndb = new newznab\db\Settings; $offset = intval($offset); $limit = intval($limit); @@ -944,7 +943,7 @@ class Sphinx . "LEFT OUTER JOIN predb pre " . "ON pre.id = releases.preid " . "WHERE releases.passwordstatus <= (SELECT value " - . "FROM site WHERE setting='showpasswordedrelease') " + . "FROM settings WHERE setting='showpasswordedrelease') " . "AND releases.id IN (%s)"; } @@ -970,7 +969,7 @@ class Sphinx $limit=100, $name="", $cat=array(-1), $maxage=-1, $indexes=array(), $lookup=true) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $order = array("postdate", "desc"); $search = array($name); if ($series != "") { @@ -1019,7 +1018,7 @@ class Sphinx . "LEFT OUTER JOIN category cp " . "ON cp.id = c.parentid " . "WHERE releases.passwordstatus <= (SELECT value " - . "FROM site WHERE setting='showpasswordedrelease') " + . "FROM settings WHERE setting='showpasswordedrelease') " . "AND releases.id IN (%s)"; } $sphinxQuery = $this->buildQuery($search, $cat, $offset, $limit, $order, @@ -1036,7 +1035,7 @@ class Sphinx $cat=array(-1), $genre="", $maxage=-1, $indexes=array(), $lookup=true) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $search = array(); $order = array("postdate", "desc"); $where = array(); @@ -1085,7 +1084,7 @@ class Sphinx . "LEFT OUTER JOIN movieinfo " . "ON releases.imdbid = movieinfo.imdbid " . "WHERE releases.passwordstatus <= (SELECT value " - . "FROM site WHERE setting='showpasswordedrelease') " + . "FROM settings WHERE setting='showpasswordedrelease') " . "AND releases.id IN (%s)"; } $sphinxQuery = $this->buildQuery($search, $cat, $offset, $limit, $order, @@ -1103,7 +1102,7 @@ class Sphinx $cat=array(-1), $maxage=-1, $indexes=array(), $lookup=true) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $search = array(); $where = array(); $order = array("postdate", "desc"); @@ -1163,7 +1162,7 @@ class Sphinx . "LEFT OUTER JOIN category cp " . "ON cp.id = c.parentid " . "WHERE releases.passwordstatus <= (SELECT value " - . "FROM site WHERE setting='showpasswordedrelease') " + . "FROM settings WHERE setting='showpasswordedrelease') " . "AND releases.id IN (%s)"; } $sphinxQuery = $this->buildQuery($search, $cat, $offset, $limit, $order, @@ -1179,7 +1178,7 @@ class Sphinx public function searchBook($author, $title, $offset=0, $limit=100, $maxage=-1, $indexes=array(), $lookup=true) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $order = array("postdate", "desc"); $search = array(); if ($author != "") { @@ -1224,7 +1223,7 @@ class Sphinx . "LEFT OUTER JOIN category cp " . "ON cp.id = c.parentid " . "WHERE releases.passwordstatus <= (SELECT value " - . "FROM site WHERE setting='showpasswordedrelease')" + . "FROM settings WHERE setting='showpasswordedrelease')" . "AND releases.id IN (%s)"; } @@ -1242,7 +1241,7 @@ class Sphinx $name='', $maxage=-1, $indexes=array(), $lookup=true) { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $where = array(); $search = array(); $order = array("postdate", "desc"); @@ -1276,7 +1275,7 @@ class Sphinx . "LEFT OUTER JOIN category cp " . "ON cp.id = c.parentid " . "WHERE releases.passwordstatus <= (SELECT value " - . "FROM site WHERE setting='showpasswordedrelease')" + . "FROM settings WHERE setting='showpasswordedrelease')" . "AND releases.id IN (%s)"; } $sphinxQuery = $this->buildQuery($search, array(-1), $offset, $limit, @@ -1291,7 +1290,7 @@ class Sphinx */ public function getPreRange($start=0, $num, $dirname='', $category='') { - $db = new newznab\db\DB(); + $db = new newznab\db\Settings(); $dirname = empty($category) ? $dirname : $dirname." @category =".$category; $sphinxQuery = sprintf("SELECT id " ."FROM predb, predb_delta " diff --git a/newznab/controllers/SphinxSearch.php b/newznab/controllers/SphinxSearch.php index 4a47e628d..f198c610e 100644 --- a/newznab/controllers/SphinxSearch.php +++ b/newznab/controllers/SphinxSearch.php @@ -24,7 +24,7 @@ class SphinxSearch if (!defined('NN_SPHINXQL_SOCK_FILE')) { define('NN_SPHINXQL_SOCK_FILE', ''); } - $this->sphinxQL = new newznab\db\DB( + $this->sphinxQL = new DB( [ 'dbname' => '', 'dbport' => NN_SPHINXQL_PORT, diff --git a/newznab/controllers/SpotNab.php b/newznab/controllers/SpotNab.php index ecd862414..d7e89e7fa 100644 --- a/newznab/controllers/SpotNab.php +++ b/newznab/controllers/SpotNab.php @@ -1,6 +1,6 @@ _pdo = new DB(); + $this->_pdo = new Settings(); $this->_nntp = new NNTP(['Settings' => $this->_pdo]); $this->releaseImage = new \ReleaseImage($this->_pdo); $this->nzb = new \NZB($this->_pdo); - $s = new Sites(); + $s = new Settings(); $this->_site = $s->get(); $this->_globals = $this->_site; @@ -264,7 +264,7 @@ class SpotNab { // *********************************************************************** public function auto_clean($max_days=90){ - $db = new DB(); + $db = new Settings(); // automatically sweep old sources lingering that have not shown any // sort of life what-so-ever for more then 90 days $sql = "DELETE FROM spotnabsources WHERE " @@ -288,7 +288,7 @@ class SpotNab { $sql_rel = "SELECT gid FROM releases WHERE gid IN ('%s') "; $sql_del = "DELETE FROM releasecomment WHERE gid IN ('%s')"; $total_delcnt = 0; - $db = new DB(); + $db = new Settings(); while(1) { $res = $db->query(sprintf($sql, $offset, $batch)); @@ -333,7 +333,7 @@ class SpotNab { // using existing sources // - it has never posted discovery information // - it has never scanned for existing discoveries - $db = new DB(); + $db = new Settings(); // resets sources so they need to query again $sources = "UPDATE spotnabsources SET " @@ -367,7 +367,7 @@ class SpotNab { // *********************************************************************** public function fetch_discovery($reftime=Null, $retries=3){ - $db = new DB(); + $db = new Settings(); $last = $first = Null; // Return Value; Initialize it to Okay @@ -384,7 +384,7 @@ class SpotNab { } if($reftime === Null){ - $q = "SELECT updateddate FROM site WHERE " + $q = "SELECT updateddate FROM settings WHERE " ."setting = 'spotnabdiscover'"; $res = $db->queryOneRow($q); if($res){ @@ -529,9 +529,9 @@ class SpotNab { // *********************************************************************** public function auto_post_discovery($repost_sec=SpotNab::POST_BROADCAST_INTERVAL){ - $db = new DB(); + $db = new Settings(); // performs a post discovery once the time in seconds has elapsed - $q = "SELECT updateddate FROM site WHERE " + $q = "SELECT updateddate FROM settings WHERE " ."setting = 'spotnabbroadcast'"; $res = $db->queryOneRow($q); $then = strtotime($res['updateddate']); @@ -652,7 +652,7 @@ class SpotNab { * The specified $reftime is presumed to be local *not utc* */ - $db = new DB(); + $db = new Settings(); $last = $first = Null; // Return Value; Initialize it to Okay @@ -905,7 +905,7 @@ class SpotNab { public function processGID($limit=500, $batch=5000, $delete_broken_releases=false){ // Process until someone presses cntrl-c - $db = new DB(); + $db = new Settings(); $nzb = new NZB(); $processed = 0; @@ -1007,7 +1007,7 @@ class SpotNab { public function keygen($print=true, $force_regen=false){ // Simply generate a Public/Private Key pair if they don't already // exist - $db = new DB(); + $db = new Settings(); // A small boolean we safely toggle after performing // a few checks first to make sure it's safe to do so @@ -1330,7 +1330,7 @@ class SpotNab { // Prepare some general SQL Commands for saving later if all goes well // - $db = new DB(); + $db = new Settings(); $rc = new ReleaseComments(); // Comments @@ -1553,7 +1553,7 @@ class SpotNab { // Prepare some general SQL Commands for saving later if all goes well // - $db = new DB(); + $db = new Settings(); // Auto Enable Flag (used for inserts only) $auto_enable = ($this->_auto_enable)?"1":"0"; @@ -1891,7 +1891,7 @@ class SpotNab { { $message['comments'] = $data['comments']; - $db = new DB(); + $db = new Settings(); $sql = sprintf("UPDATE releasecomment " ."SET issynced = 1 WHERE id IN (%s)", implode(",", $data['ids'])); @@ -2135,7 +2135,7 @@ class SpotNab { // Assumed to be in Y-m-d H:i:s format or int // convert local time into UTC $reftime = $this->local2utc($reftime, "YmdHis"); - $s = new Sites(); + $s = new Settings(); $msgid = sprintf('<%s.%s.%d@%s>', $this->getRandomStr(30), @@ -2245,7 +2245,7 @@ class SpotNab { * but otherwise it's expected format is string "Y-m-d H:i:s" */ - $db = new DB(); + $db = new Settings(); // Now we fetch for any new posts since reference point $sql = sprintf("SELECT r.gid, rc.id, rc.text, u.username, " @@ -2488,7 +2488,7 @@ class SpotNab { public function getSources() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT id, lastupdate,lastbroadcast, active, description, " ."(SELECT count(id) from releasecomment where sourceid = s.id)" ." AS comments FROM spotnabsources s"); @@ -2496,14 +2496,14 @@ class SpotNab { public function getSourceById($id) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("SELECT * FROM spotnabsources WHERE id = %d", $id); return $db->queryOneRow($sql); } public function addSource($description,$username,$usermail,$usenetgroup,$publickey) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("INSERT INTO spotnabsources " ."(description, username, useremail," ." usenetgroup, publickey, active) " @@ -2516,7 +2516,7 @@ class SpotNab { public function updateSource($id, $description,$username,$usermail,$usenetgroup,$publickey) { - $db = new DB(); + $db = new Settings(); return $db->queryExec( sprintf("UPDATE spotnabsources SET " ."description = %s, username = %s, useremail = %s," @@ -2528,19 +2528,19 @@ class SpotNab { public function deleteSource($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE FROM spotnabsources WHERE id = %d", $id)); } public function toggleSource($id, $active) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("update spotnabsources SET active = %d WHERE id = %d", $active, $id)); } public function getDefaultValue($table,$field) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("SHOW COLUMNS FROM %s WHERE field = %s", $table, $db->escapeString($field))); } } \ No newline at end of file diff --git a/newznab/controllers/TheTVDB.php b/newznab/controllers/TheTVDB.php index 68803d167..24ec1c7a0 100644 --- a/newznab/controllers/TheTVDB.php +++ b/newznab/controllers/TheTVDB.php @@ -1,6 +1,6 @@ echooutput = (NN_ECHOCLI && $echooutput); $this->MIRROR = 'http://www.thetvdb.com'; - $this->pdo = new DB(); + $this->pdo = new Settings(); $this->echooutput = $echooutput; } diff --git a/newznab/controllers/Tmux.php b/newznab/controllers/Tmux.php index ab6da0012..ff59a321d 100644 --- a/newznab/controllers/Tmux.php +++ b/newznab/controllers/Tmux.php @@ -1,6 +1,6 @@ pdo = (empty($pdo) ? new DB() : $pdo); - $s = new Sites; - $this->site = $s->get(); + $this->pdo = (empty($pdo) ? new Settings() : $pdo); } public function version() { - return $this->site->dbversion; + return $$this->pdo->getSetting('dbversion'); } public function update($form) @@ -181,7 +179,7 @@ class Tmux public function getConstantSettings() { $tmuxstr = 'SELECT value FROM tmux WHERE setting ='; - $settstr = 'SELECT value FROM site WHERE setting ='; + $settstr = 'SELECT value FROM settings WHERE setting ='; $sql = sprintf( "SELECT @@ -201,7 +199,7 @@ class Tmux public function getMonitorSettings() { $tmuxstr = 'SELECT value FROM tmux WHERE setting ='; - $settstr = 'SELECT value FROM site WHERE setting ='; + $settstr = 'SELECT value FROM settings WHERE setting ='; $sql = sprintf( "SELECT @@ -433,7 +431,7 @@ class Tmux AND (now() - INTERVAL backfill_target DAY) < first_record_postdate ) AS backfill_groups_days, (SELECT COUNT(*) FROM groups WHERE first_record IS NOT NULL AND backfill = 1 AND (now() - INTERVAL datediff(curdate(), - (SELECT VALUE FROM site WHERE setting = 'safebackfilldate')) DAY) < first_record_postdate) AS backfill_groups_date", + (SELECT VALUE FROM settings WHERE setting = 'safebackfilldate')) DAY) < first_record_postdate) AS backfill_groups_date", $this->pdo->escapeString($db_name) ); case 6: diff --git a/newznab/controllers/TmuxOutput.php b/newznab/controllers/TmuxOutput.php index fd4bd3990..f4149767b 100644 --- a/newznab/controllers/TmuxOutput.php +++ b/newznab/controllers/TmuxOutput.php @@ -1,6 +1,6 @@ get(); $t = new Tmux(); $tmux = $t->get(); - $this->_vers = $site->dbversion; + $this->_vers = $this->pdo->getSetting('dbversion'); $this->_tvers = $tmux->sqlpatch; diff --git a/newznab/controllers/TmuxRun.php b/newznab/controllers/TmuxRun.php index b396a9f0d..d0327fdc7 100644 --- a/newznab/controllers/TmuxRun.php +++ b/newznab/controllers/TmuxRun.php @@ -1,6 +1,6 @@ _dateFormat = '%Y-%m-%d %T'; diff --git a/newznab/controllers/TraktTv.php b/newznab/controllers/TraktTv.php index 2b04ad998..040ac8de4 100644 --- a/newznab/controllers/TraktTv.php +++ b/newznab/controllers/TraktTv.php @@ -24,7 +24,7 @@ Class TraktTv ]; $options += $defaults; - $settings = ($options['Settings'] instanceof Sites ? $options['Settings'] : new Sites()); + $settings = ($options['Settings'] instanceof Sites ? $options['Settings'] : new Settings()); $this->APIKEY = $settings->get()->trakttvkey; } diff --git a/newznab/controllers/TvAnger.php b/newznab/controllers/TvAnger.php index adefa4b7a..d610ecdb7 100644 --- a/newznab/controllers/TvAnger.php +++ b/newznab/controllers/TvAnger.php @@ -1,6 +1,6 @@ null, ]; $options += $defaults; - $s = new Sites(); + $s = new Settings(); $this->site = $s->get(); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->rageqty = ($this->site->maxrageprocessed != '') ? $this->site->maxrageprocessed : 75; $this->echooutput = ($options['Echo'] && NN_ECHOCLI); diff --git a/newznab/controllers/TvRage.php b/newznab/controllers/TvRage.php index 4a520a6e7..4f81abf9f 100644 --- a/newznab/controllers/TvRage.php +++ b/newznab/controllers/TvRage.php @@ -1,6 +1,6 @@ echooutput = (NN_ECHOCLI && $echooutput); - $this->pdo = new DB(); + $this->pdo = new Settings(); $this->xmlFullSearchUrl = "http://services.tvrage.com/feeds/full_search.php?show="; $this->xmlFullShowInfoUrl = "http://services.tvrage.com/feeds/full_show_info.php?sid="; @@ -389,7 +389,7 @@ class TvRage public function updateEpInfo($show, $relid) { - $this->pdo = new newznab\db\DB; + $this->pdo = new newznab\db\Settings; if (empty($show['airdate']) || !strtotime($show['airdate'])) { $tvairdate = "null"; @@ -429,7 +429,7 @@ class TvRage public function updateRageInfo($rageid, $show, $tvrShow, $relid) { - $this->pdo = new newznab\db\DB; + $this->pdo = new newznab\db\Settings; $idCheck = $this->getByRageID($rageid); diff --git a/newznab/controllers/UserMovies.php b/newznab/controllers/UserMovies.php index 7e4d29607..3fb96a997 100644 --- a/newznab/controllers/UserMovies.php +++ b/newznab/controllers/UserMovies.php @@ -1,12 +1,12 @@ escapeString(implode('|', $catid)) : "null"; @@ -16,33 +16,33 @@ class UserMovies public function getMovies($uid) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select usermovies.*, movieinfo.year, movieinfo.plot, movieinfo.cover, movieinfo.title from usermovies left outer join movieinfo on movieinfo.imdbid = usermovies.imdbid where userid = %d order by movieinfo.title asc", $uid); return $db->query($sql); } public function delMovie($uid, $imdbid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from usermovies where userid = %d and imdbid = %d ", $uid, $imdbid)); } public function getMovie($uid, $imdbid) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select usermovies.*, movieinfo.title from usermovies left outer join movieinfo on movieinfo.imdbid = usermovies.imdbid where usermovies.userid = %d and usermovies.imdbid = %d ", $uid, $imdbid); return $db->queryOneRow($sql); } public function delMovieForUser($uid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from usermovies where userid = %d", $uid)); } public function updateMovie($uid, $imdbid, $catid=array()) { - $db = new DB(); + $db = new Settings(); $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; diff --git a/newznab/controllers/UserSeries.php b/newznab/controllers/UserSeries.php index 012745505..5c934e7cd 100644 --- a/newznab/controllers/UserSeries.php +++ b/newznab/controllers/UserSeries.php @@ -1,12 +1,12 @@ escapeString(implode('|', $catid)) : "null"; @@ -16,39 +16,39 @@ class UserSeries public function getShows($uid) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select userseries.*, tvrage.releasetitle from userseries inner join (SELECT id, releasetitle, rageid FROM tvrage GROUP BY rageid) tvrage on tvrage.rageid = userseries.rageid where userid = %d order by tvrage.releasetitle asc", $uid); return $db->query($sql); } public function delShow($uid, $rageid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from userseries where userid = %d and rageid = %d ", $uid, $rageid)); } public function getShow($uid, $rageid) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select userseries.*, tvrage.releasetitle from userseries left outer join (SELECT id, releasetitle, rageid FROM tvrage GROUP BY rageid) tvrage on tvrage.rageid = userseries.rageid where userseries.userid = %d and userseries.rageid = %d ", $uid, $rageid); return $db->queryOneRow($sql); } public function delShowForUser($uid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from userseries where userid = %d", $uid)); } public function delShowForSeries($sid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from userseries where rageid = %d", $sid)); } public function updateShow($uid, $rageid, $catid=array()) { - $db = new DB(); + $db = new Settings(); $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; diff --git a/newznab/controllers/Users.php b/newznab/controllers/Users.php index d9bd7019a..c2d7fd4c0 100644 --- a/newznab/controllers/Users.php +++ b/newznab/controllers/Users.php @@ -1,6 +1,6 @@ null, ]; $options += $defaults; - $this->site= new Sites(); + $this->site= new Settings(); $this->site = $this->site->get(); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $this->password_hash_cost = (defined('NN_PASSWORD_HASH_COST') ? NN_PASSWORD_HASH_COST : 11); } @@ -470,7 +470,7 @@ class Users public function signup($uname, $pass, $email, $host, $role = self::ROLE_USER, $notes, $invites = self::DEFAULT_INVITES, $invitecode = '', $forceinvitemode = false) { - $site = new Sites; + $site = new Settings; $this->site = $site->get(); $uname = trim($uname); @@ -557,7 +557,7 @@ class Users { - $site = new Sites(); + $site = new Settings(); $this->site = $site->get(); if ($this->site->storeuserips != "1") $host = ""; @@ -591,7 +591,7 @@ class Users { $_SESSION['uid'] = $uid; - $site = new Sites(); + $site = new Settings(); $this->site = $site->get(); if ($this->site->storeuserips != "1") diff --git a/newznab/controllers/XXX.php b/newznab/controllers/XXX.php index 62080aa7a..66dbdf494 100644 --- a/newznab/controllers/XXX.php +++ b/newznab/controllers/XXX.php @@ -1,6 +1,6 @@ null, ]; $options += $defaults; - $s = new Sites(); + $s = new Settings(); $this->site = $s->get(); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $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->showPasswords = ($this->site->showpasswordedrelease != '') ? $this->site->showpasswordedrelease : 0; + $this->showPasswords = ($this->pdo->getSetting('showpasswordedrelease') != '') ? $this->pdo->getSetting('showpasswordedrelease') : 0; $this->debug = NN_DEBUG; $this->echooutput = ($options['Echo'] && NN_ECHOCLI); $this->imgSavePath = NN_COVERS . 'xxx' . DS; diff --git a/newznab/db/populate/AniDB.php b/newznab/db/populate/AniDB.php index 85122cf8c..84319ec4b 100644 --- a/newznab/db/populate/AniDB.php +++ b/newznab/db/populate/AniDB.php @@ -3,7 +3,7 @@ namespace newznab\db\populate; require_once NN_LIBS . 'simple_html_dom.php'; -use newznab\db\DB; +use newznab\db\Settings; class AniDB @@ -23,7 +23,7 @@ class AniDB public $imgSavePath; /** - * @var \newznab\db\DB + * @var \newznab\db\Settings */ public $pdo; @@ -69,7 +69,7 @@ class AniDB $options += $defaults; $this->echooutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $s = new \Sites(); $this->site = $s->get(); diff --git a/newznab/libraries/Forking.php b/newznab/libraries/Forking.php index f1a6a58aa..1626476b4 100644 --- a/newznab/libraries/Forking.php +++ b/newznab/libraries/Forking.php @@ -1,7 +1,7 @@ work = []; // Init Settings here, as forking causes errors when it's destroyed. - $this->pdo = new DB(); + $this->pdo = new Settings(); // Process extra work that should not be forked and done before forking. $this->processStartWork(); @@ -307,7 +307,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 site WHERE setting = 'maxmssgs') AS maxmsgs"); + $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; $orderby = "ORDER BY a.last_record ASC"; @@ -1086,7 +1086,7 @@ class Forking extends \fork_daemon private $safeBackfillGroup = ''; /** - * @var \newznab\db\DB + * @var \newznab\db\Settings */ public $pdo; diff --git a/newznab/libraries/ForkingImportNZB.php b/newznab/libraries/ForkingImportNZB.php index 888623d61..277b5ac20 100644 --- a/newznab/libraries/ForkingImportNZB.php +++ b/newznab/libraries/ForkingImportNZB.php @@ -1,7 +1,7 @@ new DB(), + 'settings' => new Settings(), ]; $options += $defaults; diff --git a/newznab/processing/PProcess.php b/newznab/processing/PProcess.php index 559aeda6b..97c04533c 100644 --- a/newznab/processing/PProcess.php +++ b/newznab/processing/PProcess.php @@ -1,7 +1,7 @@ site = $s->get(); //\\ Class instances. - $this->pdo = (($options['Settings'] instanceof DB) ? $options['Settings'] : new DB()); + $this->pdo = (($options['Settings'] instanceof Settings) ? $options['Settings'] : new Settings()); $this->groups = (($options['Groups'] instanceof \Groups) ? $options['Groups'] : new \Groups()); $this->_par2Info = new \Par2Info(); $this->debugging = ($options['Logger'] instanceof \Logger ? $options['Logger'] : new \Logger(['ColorCLI' => $this->pdo->log])); diff --git a/newznab/processing/post/AniDB.php b/newznab/processing/post/AniDB.php index 4a954d916..18f790c03 100644 --- a/newznab/processing/post/AniDB.php +++ b/newznab/processing/post/AniDB.php @@ -1,7 +1,7 @@ echooutput = ($options['Echo'] && NN_ECHOCLI); - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); $s = new \Sites(); $this->site = $s->get(); diff --git a/newznab/processing/post/ProcessAdditional.php b/newznab/processing/post/ProcessAdditional.php index 0c87dc9cd..532874fce 100644 --- a/newznab/processing/post/ProcessAdditional.php +++ b/newznab/processing/post/ProcessAdditional.php @@ -4,7 +4,7 @@ namespace newznab\processing\post; require_once NN_LIBS . 'rarinfo/archiveinfo.php'; require_once NN_LIBS . 'rarinfo/par2info.php'; -use newznab\db\DB; +use newznab\db\Settings; use newznab\utility\Utility; class ProcessAdditional @@ -17,7 +17,7 @@ class ProcessAdditional const maxCompressedFilesToCheck = 20; /** - * @var \newznab\db\DB + * @var \newznab\db\Settings */ public $pdo; @@ -284,7 +284,7 @@ class ProcessAdditional $this->_echoCLI = ($options['Echo'] && NN_ECHOCLI && (strtolower(PHP_SAPI) === 'cli')); $this->_echoDebug = NN_DEBUG; - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $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)); diff --git a/www/admin/ajax_sharing_settings.php b/www/admin/ajax_sharing_settings.php index 21e310a38..1b57955ce 100644 --- a/www/admin/ajax_sharing_settings.php +++ b/www/admin/ajax_sharing_settings.php @@ -2,11 +2,11 @@ require_once("config.php"); -use newznab\db\DB; +use newznab\db\Settings; // Login check. $admin = new AdminPage; -$db = new DB(); +$db = new 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/www/admin/ajax_welcome_msg.php b/www/admin/ajax_welcome_msg.php index f65ee6e36..7c11f3ef7 100644 --- a/www/admin/ajax_welcome_msg.php +++ b/www/admin/ajax_welcome_msg.php @@ -3,7 +3,7 @@ require_once("config.php"); // login check $admin = new AdminPage; -$s = new Sites(); +$s = new Settings(); if (isset($_GET['action'])) { diff --git a/www/admin/db-optimise.php b/www/admin/db-optimise.php index 9d2dda0a6..3319b4959 100644 --- a/www/admin/db-optimise.php +++ b/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/www/admin/index.php b/www/admin/index.php index 8df013b32..50f2c1e66 100644 --- a/www/admin/index.php +++ b/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); @@ -39,10 +39,10 @@ if ($page->site->rawretentiondays > 10) // // database patches uptodate // -$s = new Sites(); +$s = new Settings(); 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/www/admin/sharing.php b/www/admin/sharing.php index 942dc7fce..a25771da9 100644 --- a/www/admin/sharing.php +++ b/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/www/admin/site-debug.php b/www/admin/site-debug.php index 40859de73..c3be70921 100644 --- a/www/admin/site-debug.php +++ b/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/www/admin/site-edit.php b/www/admin/site-edit.php index 5b7d642f3..846e42adc 100644 --- a/www/admin/site-edit.php +++ b/www/admin/site-edit.php @@ -3,7 +3,7 @@ require_once("config.php"); $page = new AdminPage(); -$sites = new Sites(); +$sites = new Settings(); $id = 0; // set the current action @@ -70,6 +70,21 @@ $page->smarty->assign('yesno_names', array( 'Yes', 'No')); $page->smarty->assign('passwd_ids', array(1,0)); $page->smarty->assign('passwd_names', array( 'Deep (requires unrar)', 'None')); +/*0 = English, 2 = Danish, 3 = French, 1 = German*/ +$page->smarty->assign('langlist_ids', [0, 2, 3, 1]); +$page->smarty->assign('langlist_names', ['English', 'Danish', 'French', 'German']); + +$page->smarty->assign('imdblang_ids', + [ + 'en', 'da', 'nl', 'fi', 'fr', 'de', 'it', 'tlh', 'no', 'po', 'ru', 'es', + 'sv' + ]); +$page->smarty->assign('imdblang_names', + [ + 'English', 'Danish', 'Dutch', 'Finnish', 'French', 'German', 'Italian', + 'Klingon', 'Norwegian', 'Polish', 'Russian', 'Spanish', 'Swedish' + ]); + $page->smarty->assign('sabintegrationtype_ids', array(SABnzbd::INTEGRATION_TYPE_USER, SABnzbd::INTEGRATION_TYPE_SITEWIDE, SABnzbd::INTEGRATION_TYPE_NONE)); $page->smarty->assign('sabintegrationtype_names', array( 'User', 'Site-wide', 'None (Off)')); diff --git a/www/pages/api.php b/www/pages/api.php index cb12d5f4e..e12ecc4ee 100644 --- a/www/pages/api.php +++ b/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/www/pages/dlbrowse.php b/www/pages/dlbrowse.php index b951e32df..ae4e91954 100644 --- a/www/pages/dlbrowse.php +++ b/www/pages/dlbrowse.php @@ -1,17 +1,17 @@ isLoggedIn()) $page->show403(); $r = new Releases(); -$s = new Sites(); +$s = new Settings(); $site = $s->get(); -$db = new DB(); +$db = new Settings(); if ($site->sabvdir == "" || $site->sabcompletedir == "" || !file_exists($site->sabcompletedir)) $page->show404(); diff --git a/www/pages/myshows.php b/www/pages/myshows.php index a68178e87..1f31004c5 100644 --- a/www/pages/myshows.php +++ b/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/www/pages/prehashinfo.php b/www/pages/prehashinfo.php index 8971c5943..699281a5f 100644 --- a/www/pages/prehashinfo.php +++ b/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/www/pages/profileedit.php b/www/pages/profileedit.php index e7b1c2051..d36cf1d99 100644 --- a/www/pages/profileedit.php +++ b/www/pages/profileedit.php @@ -6,7 +6,7 @@ $category = new Category; $sab = new SABnzbd($page); $nzbGet = new NZBGet($page); $users = new Users(); -$s = new Sites(); +$s = new Settings(); $site = $s->get(); if (!$users->isLoggedIn())