diff --git a/bin/fixreleasenames.php b/bin/fixreleasenames.php index 55aaf8376..d5b472939 100644 --- a/bin/fixreleasenames.php +++ b/bin/fixreleasenames.php @@ -14,7 +14,7 @@ $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 Settings(); + $db = new DB(); $namefixer = new Namefixer(true); $pieces = explode(' ', $argv[1]); if (isset($pieces[1]) && $pieces[0] == 'nfo') { diff --git a/bin/groupfixrelnames.php b/bin/groupfixrelnames.php index e59828afa..599013a84 100644 --- a/bin/groupfixrelnames.php +++ b/bin/groupfixrelnames.php @@ -1,6 +1,6 @@ log->error("This script is not intended to be run manually, it is called from groupfixrelnames_threaded.py.")); diff --git a/bin/monitor.php b/bin/monitor.php index e2d9fa11d..2c7120ddd 100644 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -10,7 +10,7 @@ require_once(dirname(__FILE__) . "/../lib/functions.php"); $version = "0.4r2100"; -$pdo = new Settings(); +$pdo = new DB(); $s = new Sites(); $site = $s->get(); $patch = $site->dbversion; @@ -458,7 +458,7 @@ $mask4 = $c->primaryOver("%-16.16s") . " " . $c->tmuxOrange("%25.25s %25.25s"); $mask5 = $c->tmuxOrange("%-16.16s %25.25s %25.25s"); // Ananlyze tables -printf($pdo->log->info("\nAnalyzing your tables to refresh your indexes.")); +printf($c->info("\nAnalyzing your tables to refresh your indexes.")); $pdo->optimise(false, 'analyze', false, ['releases']); sleep(5); @@ -529,7 +529,7 @@ while ($i > 0) { //check the db connection if ($pdo->ping(true) == false) { unset($pdo); - $pdo = new Settings(); + $pdo = new DB(); } //kill mediainfo and ffmpeg if exceeds 60 sec shell_exec("killall -o 60s -9 mediainfo 2>&1 1> /dev/null"); @@ -1925,7 +1925,7 @@ function run_ircscraper($tmux_session, $_php, $pane, $run_ircscraper) function run_sharing($tmux_session, $_php, $pane, $_sleep, $sharing_timer) { - $pdo = new Settings(); + $pdo = new DB(); $sharing = $pdo->queryOneRow('SELECT enabled, posting, fetching FROM sharing'); $t = new Tmux(); $tmux = $t->get(); diff --git a/bin/nzb-import-new.php b/bin/nzb-import-new.php index e88a928f8..06f9df4c0 100644 --- a/bin/nzb-import-new.php +++ b/bin/nzb-import-new.php @@ -20,7 +20,7 @@ if (!isset($argv[1])) { )); } -$db = new Settings(); +$db = new DB(); $binaries = new Binaries(); $s = new Sites(); $site = $s->get(); diff --git a/bin/postprocess_new.php b/bin/postprocess_new.php index 9bf98a5d6..a09cbf507 100644 --- a/bin/postprocess_new.php +++ b/bin/postprocess_new.php @@ -12,7 +12,7 @@ require_once(dirname(__FILE__) . '/../lib/TvAnger.php'); require_once(dirname(__FILE__) . '/../lib/Pprocess.php'); require_once(dirname(__FILE__) . '/../lib/Info.php'); -$pdo = new Settings(); +$pdo = new DB(); /** Array with possible arguments for run and whether or not those methods of operation require NNTP diff --git a/bin/requestID.php b/bin/requestID.php index 841b3b0ff..fde0c9778 100644 --- a/bin/requestID.php +++ b/bin/requestID.php @@ -1,7 +1,7 @@ error("This script is not intended to be run manually, it is called from requestid_threaded.py.")); } $pieces = explode(' ', $argv[1]); -$db = new Settings(); +$db = new DB(); $n = "\n"; $category = new Categorize(); $groups = new Groups(); @@ -119,7 +119,7 @@ function getReleaseNameFromRequestID($tmux, $requestID, $groupName) function localLookup($requestID, $groupName, $oldname) { - $db = new Settings(); + $db = new DB(); $groups = new Groups(); $f = new Functions(); $groupID = $f->getIDByName($groupName); diff --git a/bin/update_groups.php b/bin/update_groups.php index bd46d0c58..a6d2c98ae 100644 --- a/bin/update_groups.php +++ b/bin/update_groups.php @@ -23,7 +23,7 @@ if ($nntp->isError($data)) { echo $c->header("Inserting new values into shortgroups table."); -$db = new Settings(); +$db = new DB(); $db->queryExec('TRUNCATE TABLE shortgroups'); // Put into an array all active groups diff --git a/bin/update_parsing.php b/bin/update_parsing.php index 188629827..f397905bd 100644 --- a/bin/update_parsing.php +++ b/bin/update_parsing.php @@ -57,7 +57,7 @@ $notnforelchange = 0; $rescount = 0; $nopreCount = 0; $test = 0; -$db = new Settings(); +$db = new DB(); $updated = 0; @@ -143,7 +143,7 @@ function updateCategory($rel,$foundName,$methodused) } else { - $db = new Settings(); + $db = new DB(); $releases = new Releases(); $foundName = html_entity_decode($foundName); $foundName = str_replace(''', '', $foundName); diff --git a/lib/DB/mysqldump_tables.php b/lib/DB/mysqldump_tables.php index 9fa77c560..5dcf8ffe8 100644 --- a/lib/DB/mysqldump_tables.php +++ b/lib/DB/mysqldump_tables.php @@ -5,7 +5,7 @@ require_once(WWW_DIR . "/lib/ColorCLI.php"); // This script can dump all tables or just collections/binaries/parts/partrepair/groups. -$db = new Settings(); +$db = new DB(); $c = new ColorCLI(); if ($db->dbSystem() == "pgsql") { exit($c->error("\nThis script is only for mysql.\n")); diff --git a/lib/DB/patchDB.php b/lib/DB/patchDB.php index e3bfddafb..38095c0f5 100644 --- a/lib/DB/patchDB.php +++ b/lib/DB/patchDB.php @@ -17,7 +17,7 @@ function SplitSQL($file, $delimiter = ';') if (is_resource($file) === true) { $query = array(); - $db = new Settings(); + $db = new DB(); $dbsys = DB_TYPE; $c = new ColorCLI(); @@ -77,7 +77,7 @@ function SplitSQL($file, $delimiter = ';') function BackupDatabase() { - $db = new Settings(); + $db = new DB(); $c = new ColorCLI(); $DIR = dirname (__FILE__); @@ -109,7 +109,7 @@ if (isset($os) && $os == "unix") { $currentversion = $tmux->sqlpatch; $patched = 0; $patches = array(); - $db = new Settings(); + $db = new DB(); $backedup = false; $c = new ColorCLI(); $DIR = dirname (__FILE__); diff --git a/lib/IRCScraper.php b/lib/IRCScraper.php index b69ad53b5..88127576b 100644 --- a/lib/IRCScraper.php +++ b/lib/IRCScraper.php @@ -1,6 +1,6 @@ queryExec(sprintf('UPDATE sharing_sites SET enabled = %d WHERE ID = %d', $_GET['site_status'], $_GET['site_ID'])); diff --git a/lib/copy_this/www/admin/sharing.php b/lib/copy_this/www/admin/sharing.php index d6b3f262f..462485ddd 100644 --- a/lib/copy_this/www/admin/sharing.php +++ b/lib/copy_this/www/admin/sharing.php @@ -6,7 +6,7 @@ require_once(WWW_DIR."/lib/framework/db.php"); $page = new AdminPage(); $page->title = 'Sharing Settings'; -$db = new Settings(); +$db = new DB(); $offset = (isset($_GET['offset']) ? $_GET['offset'] : 0); diff --git a/lib/copy_this/www/lib/Tmux.php b/lib/copy_this/www/lib/Tmux.php index 6e9abb0b1..831486ed0 100644 --- a/lib/copy_this/www/lib/Tmux.php +++ b/lib/copy_this/www/lib/Tmux.php @@ -1,5 +1,5 @@ n; diff --git a/lib/copy_this/www/lib/binaries.php b/lib/copy_this/www/lib/binaries.php index 7ddcb6498..e04c46343 100644 --- a/lib/copy_this/www/lib/binaries.php +++ b/lib/copy_this/www/lib/binaries.php @@ -1,5 +1,5 @@ n; @@ -470,7 +470,7 @@ class Binaries */ private function partRepair($nntp, $group) { - $db = new Settings(); + $db = new DB(); $parts = array(); $chunks = array(); @@ -567,7 +567,7 @@ class Binaries */ private function addMissingParts($numbers, $groupID) { - $db = new Settings(); + $db = new DB(); $added = false; $insertStr = "INSERT INTO partrepair (numberID, groupID) VALUES "; foreach ($numbers as $number) { @@ -668,7 +668,7 @@ class Binaries */ public function search($search, $limit = 1000, $excludedcats = array()) { - $db = new Settings(); + $db = new DB(); // // if the query starts with a ^ it indicates the search is looking for items which start with the term @@ -716,7 +716,7 @@ class Binaries */ public function getForReleaseId($id) { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select binaries.* from binaries where releaseID = %d order by relpart", $id)); } @@ -726,7 +726,7 @@ class Binaries */ public function getById($id) { - $db = new Settings(); + $db = new DB(); 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)); } @@ -736,7 +736,7 @@ class Binaries */ public function getBlacklist($activeonly = true) { - $db = new Settings(); + $db = new DB(); $where = ""; if ($activeonly) @@ -755,7 +755,7 @@ class Binaries */ public function getBlacklistByID($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from binaryblacklist where ID = %d ", $id)); } @@ -765,7 +765,7 @@ class Binaries */ public function deleteBlacklist($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from binaryblacklist where ID = %d", $id)); } @@ -775,7 +775,7 @@ class Binaries */ public function updateBlacklist($regex) { - $db = new Settings(); + $db = new DB(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -793,7 +793,7 @@ class Binaries */ public function addBlacklist($regex) { - $db = new Settings(); + $db = new DB(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -814,7 +814,7 @@ class Binaries */ public function delete($id) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from parts where binaryID = %d", $id)); $db->queryExec(sprintf("DELETE from binaries where ID = %d", $id)); } diff --git a/lib/copy_this/www/lib/book.php b/lib/copy_this/www/lib/book.php index 40a534fe8..e9102c98f 100644 --- a/lib/copy_this/www/lib/book.php +++ b/lib/copy_this/www/lib/book.php @@ -33,7 +33,7 @@ class Book */ public function getBookInfo($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT bookinfo.*, genres.title as genres FROM bookinfo left outer join genres on genres.ID = bookinfo.genreID where bookinfo.ID = %d ", $id)); } @@ -42,7 +42,7 @@ class Book */ public function getBookInfoByName($author, $title) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT * FROM bookinfo where author like %s and title like %s", $db->escapeString("%".$author."%"), $db->escapeString("%".$title."%"))); } @@ -51,7 +51,7 @@ class Book */ public function getRange($start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -66,7 +66,7 @@ class Book */ public function getCount() { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow("select count(ID) as num from bookinfo"); return $res["num"]; } @@ -76,7 +76,7 @@ class Book */ public function getBookCount($maxage=-1) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -96,7 +96,7 @@ class Book */ public function getBookRange($start, $num, $orderby, $maxage=-1) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -248,7 +248,7 @@ class Book */ public function update($id, $title, $asin, $url, $author, $publisher, $publishdate, $cover) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update bookinfo SET title=%s, asin=%s, url=%s, author=%s, publisher=%s, publishdate='%s', cover=%d, updateddate=NOW() WHERE ID = %d", $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $db->escapeString($author), $db->escapeString($publisher), $publishdate, $cover, $id)); @@ -260,7 +260,7 @@ class Book */ public function updateBookInfo($author, $title) { - $db = new Settings(); + $db = new DB(); $ri = new ReleaseImage(); $mus = array(); @@ -368,7 +368,7 @@ class Book public function processBookReleases() { $ret = 0; - $db = new Settings(); + $db = new DB(); $numlookedup = 0; $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where bookinfoID IS NULL and categoryID = %d ORDER BY postdate DESC LIMIT 100", Category::CAT_BOOK_EBOOK)); @@ -483,7 +483,7 @@ class Book */ public function addUpdateBookInfo($title, $asin, $url, $author, $publisher, $publishdate, $review, $cover, $dewey, $ean, $isbn, $pages) { - $db = new Settings(); + $db = new DB(); if ($pages == 0) $pages = "null"; diff --git a/lib/copy_this/www/lib/category.php b/lib/copy_this/www/lib/category.php index 7f379f69c..8400abbbb 100644 --- a/lib/copy_this/www/lib/category.php +++ b/lib/copy_this/www/lib/category.php @@ -1,5 +1,5 @@ 0) @@ -139,7 +139,7 @@ class Category */ public function isParent($cid) { - $db = new Settings(); + $db = new DB(); $ret = $db->queryOneRow(sprintf("select count(*) as count from category where ID = %d and parentID is null", $cid), true); if ($ret['count']) return true; @@ -152,7 +152,7 @@ class Category */ public function getFlat($activeonly = false) { - $db = new Settings(); + $db = new DB(); $act = ""; if ($activeonly) $act = sprintf(" where c.status = %d ", Category::STATUS_ACTIVE); @@ -165,7 +165,7 @@ class Category */ public function getChildren($cid) { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select c.* from category c where parentID = %d", $cid), true); } @@ -177,7 +177,7 @@ class Category */ public function getEnabledParentNames() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT title FROM category WHERE parentID IS NULL AND status = 1"); } @@ -187,7 +187,7 @@ class Category */ public function getById($id) { - $db = new Settings(); + $db = new DB(); 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)); } @@ -198,7 +198,7 @@ class Category */ public function getSizeRangeById($id) { - $db = new Settings(); + $db = new DB(); $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 ) @@ -239,14 +239,14 @@ class Category */ public function getByIds($ids) { - $db = new Settings(); + $db = new DB(); 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 Settings(); + $db = new DB(); $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)); @@ -258,7 +258,7 @@ class Category */ public function update($id, $status, $desc, $disablepreview, $minsize, $maxsize) { - $db = new Settings(); + $db = new DB(); 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)); } @@ -268,7 +268,7 @@ class Category */ public function getForMenu($excludedcats = array()) { - $db = new Settings(); + $db = new DB(); $ret = array(); $exccatlist = ""; diff --git a/lib/copy_this/www/lib/console.php b/lib/copy_this/www/lib/console.php index ee4b11e62..5adc2a28f 100644 --- a/lib/copy_this/www/lib/console.php +++ b/lib/copy_this/www/lib/console.php @@ -35,7 +35,7 @@ class Console */ public function getConsoleInfo($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT consoleinfo.*, genres.title as genres FROM consoleinfo left outer join genres on genres.ID = consoleinfo.genreID where consoleinfo.ID = %d ", $id)); } @@ -44,7 +44,7 @@ class Console */ public function getConsoleInfoByName($title, $platform) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT * FROM consoleinfo where title like %s and platform like %s", $db->escapeString("%".$title."%"), $db->escapeString("%".$platform."%"))); } @@ -53,7 +53,7 @@ class Console */ public function getRange($start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -68,7 +68,7 @@ class Console */ public function getCount() { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow("select count(ID) as num from consoleinfo"); return $res["num"]; } @@ -78,7 +78,7 @@ class Console */ public function getConsoleCount($cat, $maxage=-1, $excludedcats=array()) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -129,7 +129,7 @@ class Console */ public function getConsoleRange($cat, $start, $num, $orderby, $maxage=-1, $excludedcats=array()) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -256,7 +256,7 @@ class Console */ public function update($id, $title, $asin, $url, $salesrank, $platform, $publisher, $releasedate, $esrb, $cover, $genreID) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update consoleinfo SET title=%s, asin=%s, url=%s, salesrank=%s, platform=%s, publisher=%s, releasedate='%s', esrb=%s, cover=%d, genreID=%d, updateddate=NOW() WHERE ID = %d", $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $salesrank, $db->escapeString($platform), $db->escapeString($publisher), $releasedate, $db->escapeString($esrb), $cover, $genreID, $id)); @@ -267,7 +267,7 @@ class Console */ public function updateConsoleInfo($gameInfo) { - $db = new Settings(); + $db = new DB(); $gen = new Genres(); $ri = new ReleaseImage(); @@ -520,7 +520,7 @@ class Console public function processConsoleReleases() { $ret = 0; - $db = new Settings(); + $db = new DB(); $numlookedup = 0; $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 postdate DESC LIMIT 100", Category::CAT_PARENT_GAME)); diff --git a/lib/copy_this/www/lib/content.php b/lib/copy_this/www/lib/content.php index cf7db2f4d..6975b571b 100644 --- a/lib/copy_this/www/lib/content.php +++ b/lib/copy_this/www/lib/content.php @@ -35,7 +35,7 @@ class Contents */ public function delete($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from content where id=%d", $id)); } @@ -44,7 +44,7 @@ class Contents */ public function update($content) { - $db = new Settings(); + $db = new DB(); $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"] )); } @@ -54,7 +54,7 @@ class Contents */ public function add($content) { - $db = new Settings(); + $db = new DB(); $content = $this->validate($content); @@ -66,7 +66,7 @@ class Contents */ public function get() { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select * from content where status = 1 order by contenttype, coalesce(ordinal, 1000000)")); } @@ -75,7 +75,7 @@ class Contents */ public function getAll() { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select * from content order by contenttype, coalesce(ordinal, 1000000)")); } @@ -84,7 +84,7 @@ class Contents */ public function getByID($id, $role) { - $db = new Settings(); + $db = new DB(); if ($role == Users::ROLE_ADMIN) $role = ""; else @@ -98,7 +98,7 @@ class Contents */ public function getIndex() { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from content where status=1 and contenttype = %d ", Contents::TYPEINDEX), true); } @@ -107,7 +107,7 @@ class Contents */ public function getForMenuByTypeAndRole($id, $role) { - $db = new Settings(); + $db = new DB(); if ($role == Users::ROLE_ADMIN) $role = ""; else diff --git a/lib/copy_this/www/lib/episode.php b/lib/copy_this/www/lib/episode.php index 7493326c5..c579965bb 100644 --- a/lib/copy_this/www/lib/episode.php +++ b/lib/copy_this/www/lib/episode.php @@ -11,7 +11,7 @@ class Episode */ public function getEpisodeInfoByID($episodeinfoID) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf('SELECT * FROM episodeinfo WHERE ID = %d', $episodeinfoID)); } @@ -20,7 +20,7 @@ class Episode */ public function getEpisodeInfoByName($showtitle, $fullep, $epabsolute='0') { - $db = new Settings(); + $db = new DB(); if($epabsolute == '0') //as string - not int. if(!preg_match('/[21]\d{3}\/\d{2}\/\d{2}/', $fullep)) diff --git a/lib/copy_this/www/lib/forum.php b/lib/copy_this/www/lib/forum.php index 0158facb5..8d8c12d9b 100644 --- a/lib/copy_this/www/lib/forum.php +++ b/lib/copy_this/www/lib/forum.php @@ -11,7 +11,7 @@ class Forum */ public function add($parentid, $userid, $subject, $message, $locked = 0, $sticky = 0, $replies = 0) { - $db = new Settings(); + $db = new DB(); if ($message == "") return -1; @@ -34,7 +34,7 @@ class Forum */ public function getParent($parent) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf(" SELECT forumpost.*, users.username from forumpost left outer join users on users.ID = forumpost.userID where forumpost.ID = %d ", $parent)); } @@ -43,7 +43,7 @@ class Forum */ public function getRecentPosts($limit) { - $db = new Settings(); + $db = new DB(); 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)); } @@ -53,7 +53,7 @@ class Forum */ public function getPosts($parent) { - $db = new Settings(); + $db = new DB(); 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)); } @@ -62,7 +62,7 @@ class Forum */ public function getPost($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf(" SELECT * from forumpost where ID = %d", $id)); } @@ -71,7 +71,7 @@ class Forum */ public function getBrowseCount() { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("select count(ID) as num from forumpost where parentID = 0")); return $res["num"]; } @@ -81,7 +81,7 @@ class Forum */ public function getBrowseRange($start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -96,7 +96,7 @@ class Forum */ public function deleteParent($parent) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from forumpost where ID = %d or parentID = %d", $parent, $parent)); } @@ -105,7 +105,7 @@ class Forum */ public function deletePost($id) { - $db = new Settings(); + $db = new DB(); $post = $this->getPost($id); if ($post) { @@ -121,7 +121,7 @@ class Forum */ public function deleteUser($id) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from forumpost where userID = %d", $id)); } @@ -130,7 +130,7 @@ class Forum */ public function getCountForUser($uid) { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("select count(ID) as num from forumpost where userID = %d", $uid)); return $res["num"]; } @@ -140,7 +140,7 @@ class Forum */ public function getForUserRange($uid, $start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; diff --git a/lib/copy_this/www/lib/genres.php b/lib/copy_this/www/lib/genres.php index 7a705e6ba..50843c79a 100644 --- a/lib/copy_this/www/lib/genres.php +++ b/lib/copy_this/www/lib/genres.php @@ -1,6 +1,6 @@ query(sprintf("SELECT groups.*, COALESCE(rel.num, 0) AS num_releases FROM groups @@ -51,7 +51,7 @@ class Groups */ public function getGroupsForSelect() { - $db = new Settings(); + $db = new DB(); $categories = $db->query("SELECT * FROM groups WHERE active = 1 ORDER BY name"); $temp_array = array(); @@ -68,7 +68,7 @@ class Groups */ public function getByID($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from groups where ID = %d ", $id)); } @@ -78,7 +78,7 @@ class Groups */ public function getActive() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT * FROM groups WHERE active = 1 ORDER BY name"); } @@ -88,14 +88,14 @@ class Groups */ public function getByName($grp) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from groups where name = '%s' ", $grp)); } public function getByNameByID($ID) { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("select name from groups where ID = %d ", $ID)); return $res["name"]; @@ -103,7 +103,7 @@ class Groups public function getIDByName($name) { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("SELECT ID FROM groups WHERE name = %s", $db->escapeString($name))); return $res["ID"]; @@ -114,7 +114,7 @@ class Groups */ public function getCount($groupname = "", $activeonly = false) { - $db = new Settings(); + $db = new DB(); $grpsql = ''; if ($groupname != "") @@ -133,7 +133,7 @@ class Groups */ public function getRange($start, $num, $groupname = "", $activeonly = false) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; else @@ -161,7 +161,7 @@ class Groups */ public function add($group) { - $db = new Settings(); + $db = new DB(); if ($group["minfilestoformrelease"] == "" || $group["minfilestoformrelease"] == "0") $minfiles = 'null'; @@ -196,7 +196,7 @@ class Groups */ public function delete($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from groups where ID = %d", $id)); } @@ -206,7 +206,7 @@ class Groups */ public function reset($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("update groups set backfill_target=0, first_record=0, first_record_postdate=null, last_record=0, last_record_postdate=null, last_updated=null where ID = %d", $id)); } @@ -218,7 +218,7 @@ class Groups { require_once(WWW_DIR . "/lib/binaries.php"); - $db = new Settings(); + $db = new DB(); $releases = new Releases(); $binaries = new Binaries(); @@ -238,7 +238,7 @@ class Groups */ public function update($group) { - $db = new Settings(); + $db = new DB(); if ($group["minfilestoformrelease"] == "" || $group["minfilestoformrelease"] == "0") $minfiles = 'null'; @@ -266,7 +266,7 @@ class Groups if ($groupList == "") { $ret[] = "No group list provided."; } else { - $db = new Settings(); + $db = new DB(); $nntp = new Nntp; if (!$nntp->doConnect()) { $ret[] = "Failed to get NNTP connection"; @@ -302,7 +302,7 @@ class Groups */ public function updateGroupStatus($id, $status = 0) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update groups SET active = %d WHERE id = %d", $status, $id)); $status = ($status == 0) ? 'deactivated' : 'activated'; diff --git a/lib/copy_this/www/lib/menu.php b/lib/copy_this/www/lib/menu.php index 73daeedef..fd3669325 100644 --- a/lib/copy_this/www/lib/menu.php +++ b/lib/copy_this/www/lib/menu.php @@ -12,7 +12,7 @@ class Menu */ public function get($role, $serverurl) { - $db = new Settings(); + $db = new DB(); $guest = ""; if ($role != Users::ROLE_GUEST) @@ -46,7 +46,7 @@ class Menu */ public function getAll() { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select * from menu order by role, ordinal")); } @@ -55,7 +55,7 @@ class Menu */ public function getById($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from menu where ID = %d", $id)); } @@ -64,7 +64,7 @@ class Menu */ public function delete($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from menu where ID = %d", $id)); } @@ -73,7 +73,7 @@ class Menu */ public function add($menu) { - $db = new Settings(); + $db = new DB(); 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 Settings(); + $db = new DB(); 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/lib/copy_this/www/lib/movie.php b/lib/copy_this/www/lib/movie.php index 5652ab26a..755b4de33 100644 --- a/lib/copy_this/www/lib/movie.php +++ b/lib/copy_this/www/lib/movie.php @@ -38,7 +38,7 @@ class Movie */ public function getMovieInfo($imdbId) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT * FROM movieinfo where imdbID = %d", $imdbId)); } @@ -47,7 +47,7 @@ class Movie */ public function getMovieInfoMultiImdb($imdbIds) { - $db = new Settings(); + $db = new DB(); $allids = implode(",", array_filter($imdbIds)); $sql = sprintf("SELECT DISTINCT movieinfo.*, releases.imdbID AS relimdb FROM movieinfo LEFT OUTER JOIN releases ON releases.imdbID = movieinfo.imdbID WHERE movieinfo.imdbID IN (%s)", $allids); return $db->query($sql); @@ -58,7 +58,7 @@ class Movie */ public function delete($imdbId) { - $db = new Settings(); + $db = new DB(); @unlink($this->imgSavePath.$imdbId.'-cover.jpg'); @unlink($this->imgSavePath.$imdbId.'-backdrop.jpg'); return $db->queryOneRow(sprintf("delete FROM movieinfo where imdbID = %d", $imdbId)); @@ -80,7 +80,7 @@ class Movie */ public function getRange($start, $num, $moviename="") { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -99,7 +99,7 @@ class Movie */ public function getCount($moviename="") { - $db = new Settings(); + $db = new DB(); $rsql = ''; if ($moviename != "") @@ -114,7 +114,7 @@ class Movie */ public function getMovieCount($cat, $maxage=-1, $excludedcats=array()) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -167,7 +167,7 @@ class Movie */ public function getMovieRange($cat, $start, $num, $orderby, $maxage=-1, $excludedcats=array()) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -373,7 +373,7 @@ class Movie */ public function update($id, $title, $tagline, $plot, $year, $rating, $genre, $director, $actors, $language, $cover, $backdrop) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update movieinfo SET title=%s, tagline=%s, plot=%s, year=%s, rating=%s, genre=%s, director=%s, actors=%s, language=%s, cover=%d, backdrop=%d, updateddate=NOW() WHERE imdbID = %d", $db->escapeString($title), $db->escapeString($tagline), $db->escapeString($plot), $db->escapeString($year), $db->escapeString($rating), $db->escapeString($genre), $db->escapeString($director), $db->escapeString($actors), $db->escapeString($language), $cover, $backdrop, $id)); @@ -492,7 +492,7 @@ class Movie } $mov['language'] = html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8'); - $db = new Settings(); + $db = new DB(); $query = sprintf(" INSERT INTO movieinfo (imdbID, tmdbID, title, rating, tagline, trailer, plot, year, genre, director, actors, language, cover, backdrop, createddate, updateddate) @@ -668,7 +668,7 @@ class Movie public function processMovieReleases() { $ret = 0; - $db = new Settings(); + $db = new DB(); $nfo = new Nfo(); $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where imdbID IS NULL and categoryID in ( select ID from category where parentID = %d ) ORDER BY postdate DESC LIMIT 100", Category::CAT_PARENT_MOVIE)); @@ -767,7 +767,7 @@ class Movie */ public function getUpcoming($type, $source="rottentomato") { - $db = new Settings(); + $db = new DB(); $sql = sprintf("select * from upcoming where source = %s and typeid = %d", $db->escapeString($source), $type); return $db->queryOneRow($sql); } @@ -810,7 +810,7 @@ class Movie */ public function updateInsUpcoming($source, $type, $info) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("INSERT into upcoming (source,typeID,info,updateddate) VALUES (%s, %d, %s, now()) ON DUPLICATE KEY UPDATE info = %s", $db->escapeString($source), $type, $db->escapeString($info), $db->escapeString($info)); diff --git a/lib/copy_this/www/lib/music.php b/lib/copy_this/www/lib/music.php index 4b78e3fef..51a4c3da5 100644 --- a/lib/copy_this/www/lib/music.php +++ b/lib/copy_this/www/lib/music.php @@ -34,7 +34,7 @@ class Music */ public function getMusicInfo($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT musicinfo.*, genres.title as genres FROM musicinfo left outer join genres on genres.ID = musicinfo.genreID where musicinfo.ID = %d ", $id)); } @@ -43,7 +43,7 @@ class Music */ public function getMusicInfoByName($artist, $album) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT * FROM musicinfo where artist like %s and title like %s", $db->escapeString("%".$artist."%"), $db->escapeString("%".$album."%"))); } @@ -52,7 +52,7 @@ class Music */ public function getRange($start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -67,7 +67,7 @@ class Music */ public function getCount() { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow("select count(ID) as num from musicinfo"); return $res["num"]; } @@ -77,7 +77,7 @@ class Music */ public function getMusicCount($cat, $maxage=-1, $excludedcats=array()) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -128,7 +128,7 @@ class Music */ public function getMusicRange($cat, $start, $num, $orderby, $maxage=-1, $excludedcats=array()) { - $db = new Settings(); + $db = new DB(); $browseby = $this->getBrowseBy(); @@ -258,7 +258,7 @@ class Music */ public function update($id, $title, $asin, $url, $salesrank, $artist, $publisher, $releasedate, $year, $tracks, $cover, $genreID) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update musicinfo SET title=%s, asin=%s, url=%s, salesrank=%s, artist=%s, publisher=%s, releasedate='%s', year=%s, tracks=%s, cover=%d, genreID=%d, updateddate=NOW() WHERE ID = %d", $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $salesrank, $db->escapeString($artist), $db->escapeString($publisher), $releasedate, $db->escapeString($year), $db->escapeString($tracks), $cover, $genreID, $id)); @@ -269,7 +269,7 @@ class Music */ public function updateMusicInfo($artist, $album, $year) { - $db = new Settings(); + $db = new DB(); $gen = new Genres(); $ri = new ReleaseImage(); @@ -435,7 +435,7 @@ class Music public function processMusicReleases() { $ret = 0; - $db = new Settings(); + $db = new DB(); $numlookedup = 0; $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where musicinfoID IS NULL and categoryID in ( select ID from category where parentID = %d ) ORDER BY postdate DESC LIMIT 1000", Category::CAT_PARENT_MUSIC)); @@ -559,7 +559,7 @@ class Music */ public function processMusicReleaseFromMediaInfo() { - $db = new Settings(); + $db = new DB(); $res = $db->query("SELECT r.searchname, ref.releaseID, ref.mediainfo FROM releaseextrafull ref INNER JOIN releases r ON r.ID = ref.releaseID WHERE r.musicinfoID = -2"); $rescount = sizeof($res); @@ -619,7 +619,7 @@ class Music */ public function addUpdateMusicInfo($title, $asin, $url, $salesrank, $artist, $publisher, $releasedate, $review, $year, $genreID, $tracks, $cover) { - $db = new Settings(); + $db = new DB(); if (strlen($year) > 4) { if (preg_match("/\d{4}/", $year, $matches)) diff --git a/lib/copy_this/www/lib/nfo.php b/lib/copy_this/www/lib/nfo.php index 48be1c985..e76201d3f 100644 --- a/lib/copy_this/www/lib/nfo.php +++ b/lib/copy_this/www/lib/nfo.php @@ -224,7 +224,7 @@ class Nfo // it no good, we need to add it to the skipped array which // must be passed into the function. - $db = new Settings(); + $db = new DB(); foreach($blobhash as $uid => $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 Settings(); + $db = new DB(); // 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 Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from releasenfo where releaseID = %d", $relid)); } @@ -596,7 +596,7 @@ class Nfo */ private function setNfoMissing($relid) { - $db = new Settings(); + $db = new DB(); $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 Settings(); + $db = new DB(); // 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/lib/copy_this/www/lib/nntp.php b/lib/copy_this/www/lib/nntp.php index d26c4a66b..9413c41d8 100644 --- a/lib/copy_this/www/lib/nntp.php +++ b/lib/copy_this/www/lib/nntp.php @@ -3,7 +3,7 @@ * Attempt to include PEAR's nntp class if it has not already been included. */ require_once(WWW_DIR . "/lib/Net_NNTP/NNTP/Client.php"); -require_once(WWW_DIR . "/lib/framework/Settings.php"); +require_once(WWW_DIR . "/lib/framework/db.php"); require_once(WWW_DIR . "/lib/Tmux.php"); require_once(WWW_DIR . "/lib/site.php"); require_once(WWW_DIR . "/lib/util.php"); diff --git a/lib/copy_this/www/lib/nzb.php b/lib/copy_this/www/lib/nzb.php index 6c64cb41f..97fb4aae3 100644 --- a/lib/copy_this/www/lib/nzb.php +++ b/lib/copy_this/www/lib/nzb.php @@ -1,5 +1,5 @@ getById($catId); $site = new Sites(); diff --git a/lib/copy_this/www/lib/parsing.php b/lib/copy_this/www/lib/parsing.php index 014f82e8f..f893e9408 100644 --- a/lib/copy_this/www/lib/parsing.php +++ b/lib/copy_this/www/lib/parsing.php @@ -1,5 +1,5 @@ echoonly) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update releases SET name = %s, searchname = %s, categoryID = %d, imdbID = NULL, rageID = -1, bookinfoID = NULL, musicinfoID = NULL, consoleinfoID = NULL WHERE releases.ID = %d", $db->escapeString($name), $db->escapeString($searchname), $categoryID, $rel['RID'])); } $this->numupdated++; diff --git a/lib/copy_this/www/lib/postprocess.php b/lib/copy_this/www/lib/postprocess.php index ac6212e59..4d0dd0cf4 100644 --- a/lib/copy_this/www/lib/postprocess.php +++ b/lib/copy_this/www/lib/postprocess.php @@ -62,7 +62,7 @@ class PostProcess public function processUnwanted() { $r = new Releases; - $db = new Settings(); + $db = new DB(); $currTime_ori = $db->queryOneRow("SELECT NOW() as now"); // @@ -242,7 +242,7 @@ class PostProcess */ public function processUnknownCategory() { - $db = new Settings(); + $db = new DB(); $sql = sprintf("select ID from releases where categoryID = %d", Category::CAT_NOT_DETERMINED); $result = $db->query($sql); $rescount = sizeof($result); @@ -335,7 +335,7 @@ class PostProcess if (!file_exists($tmpPath)) mkdir($tmpPath, 0766, true); - $db = new Settings(); + $db = new DB(); $nntp = new Nntp; $nzb = new Nzb; @@ -604,7 +604,7 @@ class PostProcess $retval = array(); $rar = new ArchiveInfo(); $rf = new ReleaseFiles; - $db = new Settings(); + $db = new DB(); $rar->setData($fetchedBinary, true); if ($rar->error) diff --git a/lib/copy_this/www/lib/predb.php b/lib/copy_this/www/lib/predb.php index 5cee12d65..56636e539 100644 --- a/lib/copy_this/www/lib/predb.php +++ b/lib/copy_this/www/lib/predb.php @@ -21,7 +21,7 @@ class PreDB */ public function getByID($preID) { - $db = new Settings(); + $db = new DB(); $predbQuery = $db->query(sprintf("SELECT * FROM predb WHERE ID = %s LIMIT %d", $preID, 1)); return isset($predbQuery[0]) ? $predbQuery[0] : false; @@ -32,7 +32,7 @@ class PreDB */ public function getByDirname($dirname) { - $db = new Settings(); + $db = new DB(); $dirname = str_replace(' ', '_', $dirname); $predbQuery = $db->query(sprintf("SELECT * FROM predb WHERE dirname = %s LIMIT %d", $db->escapeString($dirname), 1)); @@ -58,7 +58,7 @@ class PreDB } } - $db = new Settings(); + $db = new DB(); $dirname = empty($dirname) ? '' : sprintf("WHERE dirname LIKE %s", $db->escapeString('%'.$dirname.'%')); $category = empty($category) ? '' : sprintf((empty($dirname) ? 'WHERE' : ' AND')." category = %s", $db->escapeString($category)); @@ -87,7 +87,7 @@ class PreDB } } - $db = new Settings(); + $db = new DB(); $dirname = str_replace(' ', '%', $dirname); $dirname = empty($dirname) ? '' : sprintf('WHERE dirname LIKE %s', $db->escapeString('%'.$dirname.'%')); @@ -103,7 +103,7 @@ class PreDB */ public function processReleases($daysback = 3) { - $db = new Settings(); + $db = new DB(); if ($this->echooutput) echo "Predb : Updating releases with pre data\n"; @@ -210,7 +210,7 @@ class PreDB if($this->echooutput) echo "Predb : Checking for new pre data "; - $db = new Settings(); + $db = new DB(); $nntp = new Nntp(); if(!$nntp->doConnect()) { diff --git a/lib/copy_this/www/lib/releasecomments.php b/lib/copy_this/www/lib/releasecomments.php index 71d1ba3ab..5689c2640 100644 --- a/lib/copy_this/www/lib/releasecomments.php +++ b/lib/copy_this/www/lib/releasecomments.php @@ -12,7 +12,7 @@ class ReleaseComments */ public function getCommentById($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT * FROM releasecomment WHERE ID = %d", $id)); } @@ -21,7 +21,7 @@ class ReleaseComments */ public function getCommentsByGid($gid) { - $db = new Settings(); + $db = new DB(); 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 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))); } @@ -30,7 +30,7 @@ class ReleaseComments */ public function getCommentsByGuid($guid) { - $db = new Settings(); + $db = new DB(); 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))); } @@ -39,7 +39,7 @@ class ReleaseComments */ public function getCommentCount($refdate=Null, $localOnly=Null) { - $db = new Settings(); + $db = new DB(); if($refdate !== Null){ if(is_string($refdate)){ // ensure we're in the right format @@ -79,7 +79,7 @@ class ReleaseComments */ public function deleteComment($id) { - $db = new Settings(); + $db = new DB(); $res = $this->getCommentById($id); if ($res) { @@ -93,7 +93,7 @@ class ReleaseComments */ public function deleteCommentsForRelease($id) { - $db = new Settings(); + $db = new DB(); $res = $this->getCommentById($id); if ($res) { @@ -107,7 +107,7 @@ class ReleaseComments */ public function deleteCommentsForUser($id) { - $db = new Settings(); + $db = new DB(); $numcomments = $this->getCommentCountForUser($id); if ($numcomments > 0) @@ -129,7 +129,7 @@ class ReleaseComments if(strlen(trim($text)) == 0) return false; - $db = new Settings(); + $db = new DB(); $site = new Sites(); $s = $site->get(); @@ -146,7 +146,7 @@ class ReleaseComments */ public function getCommentsRange($start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -162,7 +162,7 @@ class ReleaseComments */ public function updateReleaseCommentCount($gid) { - $db = new Settings(); + $db = new DB(); $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) )); @@ -173,7 +173,7 @@ class ReleaseComments */ public function getCommentCountForUser($uid) { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("SELECT count(ID) AS num FROM releasecomment WHERE userID = %d AND isvisible = 1", $uid)); return $res["num"]; } @@ -183,7 +183,7 @@ class ReleaseComments */ public function getCommentsForUserRange($uid, $start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; diff --git a/lib/copy_this/www/lib/releaseextra.php b/lib/copy_this/www/lib/releaseextra.php index 36d77c2b5..a8b3e9693 100644 --- a/lib/copy_this/www/lib/releaseextra.php +++ b/lib/copy_this/www/lib/releaseextra.php @@ -1,5 +1,5 @@ queryOneRow(sprintf("select * from releasevideo where releaseID = %d", $id)); } public function getAudio($id) { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select * from releaseaudio where releaseID = %d order by audioID ASC", $id)); } public function getAudioAndChannel($rid, $aid) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from releaseaudio where releaseID = %d and audioID = %d", $rid, $aid)); } public function getSubs($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT group_concat(subslanguage SEPARATOR ', ') as subs FROM `releasesubs` WHERE `releaseID` = %d ORDER BY `subsID` ASC", $id)); } public function getBriefByGuid($guid) { - $db = new Settings(); + $db = new DB(); 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 Settings(); + $db = new DB(); $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)); @@ -214,7 +214,7 @@ class ReleaseExtra */ public function addVideo($releaseID, $containerformat, $overallbitrate, $videoduration, $videoformat, $videocodec, $videowidth, $videoheight, $videoaspect, $videoframerate, $videolibrary) { - $db = new Settings(); + $db = new DB(); $row = $this->getVideo($releaseID); if ($row) @@ -243,7 +243,7 @@ class ReleaseExtra */ public function addAudio($releaseID, $audioID, $audioformat, $audiomode, $audiobitratemode, $audiobitrate, $audiochannels, $audiosamplerate, $audiolibrary, $audiolanguage, $audiotitle) { - $db = new Settings(); + $db = new DB(); $row = $this->getAudioAndChannel($releaseID, $audioID); if ($row) @@ -263,7 +263,7 @@ class ReleaseExtra public function addSubs($releaseID, $subsID, $subslanguage) { - $db = new Settings(); + $db = new DB(); $row = $this->getSubs($releaseID); if ($row) return -1; @@ -275,21 +275,21 @@ class ReleaseExtra public function getFull($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from releaseextrafull where releaseID = %d", $id)); } public function deleteFull($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from releaseextrafull where releaseID = %d", $id)); } public function addFull($id, $xml) { - $db = new Settings(); + $db = new DB(); $row = $this->getFull($id); if ($row) return -1; diff --git a/lib/copy_this/www/lib/releasefiles.php b/lib/copy_this/www/lib/releasefiles.php index ac433884e..ec95fb823 100644 --- a/lib/copy_this/www/lib/releasefiles.php +++ b/lib/copy_this/www/lib/releasefiles.php @@ -11,7 +11,7 @@ class ReleaseFiles */ public function get($id) { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select * from releasefiles where releaseID = %d order by releasefiles.name ", $id)); } @@ -20,7 +20,7 @@ class ReleaseFiles */ public function getByGuid($guid) { - $db = new Settings(); + $db = new DB(); 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))); } @@ -29,7 +29,7 @@ class ReleaseFiles */ public function delete($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from releasefiles where releaseID = %d", $id)); } @@ -38,7 +38,7 @@ class ReleaseFiles */ public function add($id, $name, $size, $createddate, $passworded) { - $db = new Settings(); + $db = new DB(); $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/lib/copy_this/www/lib/releaseimage.php b/lib/copy_this/www/lib/releaseimage.php index b663a04e8..3d7e123fd 100644 --- a/lib/copy_this/www/lib/releaseimage.php +++ b/lib/copy_this/www/lib/releaseimage.php @@ -1,5 +1,5 @@ regexes)) return $this->regexes; - $db = new Settings(); + $db = new DB(); $where = ""; if ($activeonly) @@ -68,7 +68,7 @@ class ReleaseRegex public function getGroupsForSelect() { - $db = new Settings(); + $db = new DB(); $categories = $db->query("SELECT distinct coalesce(groupname,'all') as groupname from releaseregex order by groupname "); $temp_array = array(); @@ -85,7 +85,7 @@ class ReleaseRegex */ public function getByID($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from releaseregex where ID = %d ", $id)); } @@ -115,7 +115,7 @@ class ReleaseRegex */ public function delete($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from releaseregex where ID = %d", $id)); } @@ -125,7 +125,7 @@ class ReleaseRegex */ public function update($regex) { - $db = new Settings(); + $db = new DB(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -150,7 +150,7 @@ class ReleaseRegex */ public function add($regex) { - $db = new Settings(); + $db = new DB(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -178,7 +178,7 @@ class ReleaseRegex $outcome = @preg_match($regexArr["regex"], $binarySubject, $matches); if ($outcome === false) { echo "ERROR: " . ($regexArr["ID"] < 10000 ? "System" : "Custom") . " release regex '" . $regexArr["ID"] . "' is not a valid regex.\n"; - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update releaseregex set status=0 where ID = %d and status=1", $regexArr["ID"])); return $ret; @@ -309,7 +309,7 @@ class ReleaseRegex public function fetchTestBinaries($groupname, $numarticles, $clearexistingbins) { - $db = new Settings(); + $db = new DB(); $nntp = new Nntp(); $binaries = new Binaries(); $groups = new Groups(); diff --git a/lib/copy_this/www/lib/releases.php b/lib/copy_this/www/lib/releases.php index 18af886e8..df7094e98 100644 --- a/lib/copy_this/www/lib/releases.php +++ b/lib/copy_this/www/lib/releases.php @@ -1,5 +1,5 @@ 0) { @@ -119,7 +119,7 @@ class Releases */ public function getCount() { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow("select count(ID) as num from releases"); return $res["num"]; @@ -130,7 +130,7 @@ class Releases */ public function getRange($start, $num) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -145,7 +145,7 @@ class Releases */ public function getPreviewCount($previewtype, $cat) { - $db = new Settings(); + $db = new DB(); $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -180,7 +180,7 @@ class Releases */ public function getPreviewRange($previewtype, $cat, $start, $num) { - $db = new Settings(); + $db = new DB(); $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -220,7 +220,7 @@ class Releases */ public function getBrowseCount($cat, $maxage = -1, $excludedcats = array(), $grp = array()) { - $db = new Settings(); + $db = new DB(); $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -273,7 +273,7 @@ class Releases */ public function getBrowseRange($cat, $start, $num, $orderby, $maxage = -1, $excludedcats = array(), $grp = array()) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -383,7 +383,7 @@ class Releases */ public function getForExport($postfrom, $postto, $group, $cat) { - $db = new Settings(); + $db = new DB(); if ($postfrom != "") { $dateparts = explode("/", $postfrom); if (count($dateparts) == 3) @@ -418,7 +418,7 @@ class Releases */ public function getEarliestUsenetPostDate() { - $db = new Settings(); + $db = new DB(); $row = $db->queryOneRow("SELECT DATE_FORMAT(min(postdate), '%d/%m/%Y') as postdate from releases"); return $row["postdate"]; @@ -429,7 +429,7 @@ class Releases */ public function getLatestUsenetPostDate() { - $db = new Settings(); + $db = new DB(); $row = $db->queryOneRow("SELECT DATE_FORMAT(max(postdate), '%d/%m/%Y') as postdate from releases"); return $row["postdate"]; @@ -440,7 +440,7 @@ class Releases */ public function getReleasedGroupsForSelect($blnIncludeAll = true) { - $db = new Settings(); + $db = new DB(); $groups = $db->query("select distinct groups.ID, groups.name from releases inner join groups on groups.ID = releases.groupID"); $temp_array = array(); @@ -458,7 +458,7 @@ class Releases */ public function getRss($cat, $num, $uid = 0, $rageid, $anidbid, $airdate = -1) { - $db = new Settings(); + $db = new DB(); $limit = " LIMIT 0," . ($num > 100 ? 100 : $num); @@ -505,7 +505,7 @@ class Releases */ public function getShowsRss($num, $uid = 0, $excludedcats = array(), $airdate = -1) { - $db = new Settings(); + $db = new DB(); $exccatlist = ""; if (count($excludedcats) > 0) @@ -555,7 +555,7 @@ class Releases */ public function getMyMoviesRss($num, $uid = 0, $excludedcats = array()) { - $db = new Settings(); + $db = new DB(); $exccatlist = ""; if (count($excludedcats) > 0) @@ -597,7 +597,7 @@ class Releases */ public function getShowsRange($usershows, $start, $num, $orderby, $maxage = -1, $excludedcats = array()) { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -637,7 +637,7 @@ class Releases */ public function getShowsCount($usershows, $maxage = -1, $excludedcats = array()) { - $db = new Settings(); + $db = new DB(); $exccatlist = ""; if (count($excludedcats) > 0) @@ -671,7 +671,7 @@ class Releases */ public function delete($id, $isGuid = false) { - $db = new Settings(); + $db = new DB(); $users = new Users(); $s = new Sites(); $nfo = new Nfo(); @@ -732,7 +732,7 @@ class Releases */ public function deleteSingle($guid, $id, $nzb, $releaseImage) { - $db = new Settings(); + $db = new DB(); $releaseImage = new ReleaseImage(); // Delete NZB from disk. $nzbPath = $nzb->getNZBPath($guid); @@ -776,7 +776,7 @@ class Releases */ public function update($id, $name, $searchname, $fromname, $category, $parts, $grabs, $size, $posteddate, $addeddate, $rageid, $seriesfull, $season, $episode, $imdbid, $anidbid, $tvdbid, $consoleinfoid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update releases set name=%s, searchname=%s, fromname=%s, categoryID=%d, totalpart=%d, grabs=%d, size=%s, postdate=%s, adddate=%s, rageID=%d, seriesfull=%s, season=%s, episode=%s, imdbID=%d, anidbID=%d, tvdbID=%d,consoleinfoID=%d where id = %d", $db->escapeString($name), $db->escapeString($searchname), $db->escapeString($fromname), $category, $parts, $grabs, $db->escapeString($size), $db->escapeString($posteddate), $db->escapeString($addeddate), $rageid, $db->escapeString($seriesfull), $db->escapeString($season), $db->escapeString($episode), $imdbid, $anidbid, $tvdbid, $consoleinfoid, $id @@ -800,7 +800,7 @@ class Releases 'imdbID' => $imdbid ); - $db = new Settings(); + $db = new DB(); $updateSql = array(); foreach ($update as $updk => $updv) { if ($updv != '') @@ -827,7 +827,7 @@ class Releases */ public function updateHasPreview($guid, $haspreview) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update releases set haspreview = %d where guid = %s", $haspreview, $db->escapeString($guid))); } @@ -858,7 +858,7 @@ class Releases // // Search using MySQL // - $db = new Settings(); + $db = new DB(); $catsrch = ""; $usecatindex = ""; @@ -972,7 +972,7 @@ class Releases return $results; } - $db = new Settings(); + $db = new DB(); if ($rageId != "-1") $rageId = sprintf(" and rageID = %d ", $rageId); @@ -1076,7 +1076,7 @@ class Releases return $results; } - $db = new Settings(); + $db = new DB(); $anidbID = ($anidbID > -1) ? sprintf(" AND anidbID = %d ", $anidbID) : ''; @@ -1142,7 +1142,7 @@ class Releases return $results; } - $db = new Settings(); + $db = new DB(); $searchsql = ""; if ($artist != "") @@ -1222,7 +1222,7 @@ class Releases return $results; } - $db = new Settings(); + $db = new DB(); $searchsql = ""; if ($author != "") @@ -1262,7 +1262,7 @@ class Releases return $results; } - $db = new Settings(); + $db = new DB(); if ($imdbId != "-1" && is_numeric($imdbId)) { //pad id with zeros just in case @@ -1383,7 +1383,7 @@ class Releases */ public function getByGuid($guid) { - $db = new Settings(); + $db = new DB(); if (is_array($guid)) { $tmpguids = array(); foreach ($guid as $g) @@ -1433,7 +1433,7 @@ class Releases */ public function removeRageIdFromReleases($rageid) { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("select count(ID) as num from releases where rageID = %d", $rageid)); $ret = $res["num"]; $db->queryExec(sprintf("update releases set rageID = -1, seriesfull = null, season = null, episode = null where rageID = %d", $rageid)); @@ -1446,7 +1446,7 @@ class Releases */ public function removeThetvdbIdFromReleases($tvdbID) { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("SELECT count(ID) AS num FROM releases WHERE tvdbID = %d", $tvdbID)); $ret = $res["num"]; $res = $db->queryExec(sprintf("update releases SET tvdbID = -1 where tvdbID = %d", $tvdbID)); @@ -1456,7 +1456,7 @@ class Releases public function removeAnidbIdFromReleases($anidbID) { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow(sprintf("SELECT count(ID) AS num FROM releases WHERE anidbID = %d", $anidbID)); $ret = $res["num"]; $db->queryExec(sprintf("update releases SET anidbID = -1, episode = null, tvtitle = null, tvairdate = null where anidbID = %d", $anidbID)); @@ -1466,14 +1466,14 @@ class Releases public function getById($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select releases.*, groups.name as group_name from releases left outer join groups on groups.ID = releases.groupID where releases.ID = %d ", $id)); } public function getReleaseNfo($id, $incnfo = true) { - $db = new Settings(); + $db = new DB(); $selnfo = ($incnfo) ? ', uncompress(nfo) as nfo' : ''; return $db->queryOneRow(sprintf("SELECT ID, releaseID" . $selnfo . " FROM releasenfo where releaseID = %d AND nfo IS NOT NULL", $id)); @@ -1481,7 +1481,7 @@ class Releases public function updateGrab($guid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update releases set grabs = grabs + 1 where guid = %s", $db->escapeString($guid))); } @@ -1489,7 +1489,7 @@ class Releases { require_once(WWW_DIR . "/lib/binaries.php"); - $db = new Settings(); + $db = new DB(); $currTime_ori = $db->queryOneRow("SELECT NOW() as now"); $cat = new Categorize(); $nzb = new Nzb(); @@ -1872,7 +1872,7 @@ class Releases public function insertRelease($cleanRelName, $cleanedName, $parts, $group, $guid, $catId, $regexID, $date, $fromname, $reqID, $site, $nzbstatus, $isrenamed, $isReqID, $prehashID) { - $db = new Settings(); + $db = new DB(); if ($regexID == "") $regexID = " null "; @@ -1953,7 +1953,7 @@ class Releases if (preg_match('/\/\*\$Rev: (\d{3,4})/i', $regfile, $matches)) { $serverrev = intval($matches[1]); if ($serverrev > $rev) { - $db = new Settings(); + $db = new DB(); $site = new Sites; $queries = explode(";", $regfile); @@ -1980,7 +1980,7 @@ class Releases public function getTopDownloads() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT ID, searchname, guid, adddate, grabs FROM releases where grabs > 0 @@ -1991,7 +1991,7 @@ class Releases public function getTopComments() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT ID, guid, searchname, adddate, comments FROM releases where comments > 0 @@ -2002,7 +2002,7 @@ class Releases public function getRecentlyAdded() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT concat(cp.title, ' > ', category.title) as title, COUNT(*) AS count FROM category @@ -2021,7 +2021,7 @@ class Releases */ public function getNewestMovies() { - $db = new Settings(); + $db = new DB(); return $db->query( "SELECT DISTINCT (a.imdbID), @@ -2047,7 +2047,7 @@ class Releases */ public function getNewestConsole() { - $db = new Settings(); + $db = new DB(); return $db->query( "SELECT DISTINCT (a.consoleinfoID), @@ -2073,7 +2073,7 @@ class Releases */ public function getNewestGames() { - $db = new Settings(); + $db = new DB(); return $db->query( "SELECT DISTINCT (a.gamesinfo_id), @@ -2099,7 +2099,7 @@ class Releases */ public function getNewestMP3s() { - $db = new Settings(); + $db = new DB(); return $db->query( "SELECT DISTINCT (a.musicinfoID), @@ -2125,7 +2125,7 @@ class Releases */ public function getNewestBooks() { - $db = new Settings(); + $db = new DB(); return $db->query( "SELECT DISTINCT (a.bookinfoID), diff --git a/lib/copy_this/www/lib/site.php b/lib/copy_this/www/lib/site.php index 1a454454b..acbc0abfc 100644 --- a/lib/copy_this/www/lib/site.php +++ b/lib/copy_this/www/lib/site.php @@ -1,5 +1,5 @@ site->sphinxenabled) { // Sphinx is disabled, so we don't do anything. @@ -974,7 +974,7 @@ class Sphinx $limit=100, $name="", $cat=array(-1), $maxage=-1, $indexes=array(), $lookup=true) { - $db = new Settings(); + $db = new DB(); $order = array("postdate", "desc"); $search = array($name); if ($series != "") { @@ -1040,7 +1040,7 @@ class Sphinx $cat=array(-1), $genre="", $maxage=-1, $indexes=array(), $lookup=true) { - $db = new Settings(); + $db = new DB(); $search = array(); $order = array("postdate", "desc"); $where = array(); @@ -1107,7 +1107,7 @@ class Sphinx $cat=array(-1), $maxage=-1, $indexes=array(), $lookup=true) { - $db = new Settings(); + $db = new DB(); $search = array(); $where = array(); $order = array("postdate", "desc"); @@ -1183,7 +1183,7 @@ class Sphinx public function searchBook($author, $title, $offset=0, $limit=100, $maxage=-1, $indexes=array(), $lookup=true) { - $db = new Settings(); + $db = new DB(); $order = array("postdate", "desc"); $search = array(); if ($author != "") { @@ -1246,7 +1246,7 @@ class Sphinx $name='', $maxage=-1, $indexes=array(), $lookup=true) { - $db = new Settings(); + $db = new DB(); $where = array(); $search = array(); $order = array("postdate", "desc"); @@ -1295,7 +1295,7 @@ class Sphinx */ public function getPreRange($start=0, $num, $dirname='', $category='') { - $db = new Settings(); + $db = new DB(); $dirname = empty($category) ? $dirname : $dirname." @category =".$category; $sphinxQuery = sprintf("SELECT id " ."FROM predb, predb_delta " diff --git a/lib/copy_this/www/lib/spotnab.php b/lib/copy_this/www/lib/spotnab.php index 9609812b9..acf9e851e 100644 --- a/lib/copy_this/www/lib/spotnab.php +++ b/lib/copy_this/www/lib/spotnab.php @@ -267,7 +267,7 @@ class SpotNab { // *********************************************************************** public function auto_clean($max_days=90){ - $db = new Settings(); + $db = new DB(); // 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 " @@ -291,7 +291,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 Settings(); + $db = new DB(); while(1) { $res = $db->query(sprintf($sql, $offset, $batch)); @@ -336,7 +336,7 @@ class SpotNab { // using existing sources // - it has never posted discovery information // - it has never scanned for existing discoveries - $db = new Settings(); + $db = new DB(); // resets sources so they need to query again $sources = "UPDATE spotnabsources SET " @@ -370,7 +370,7 @@ class SpotNab { // *********************************************************************** public function fetch_discovery($reftime=Null, $retries=3){ - $db = new Settings(); + $db = new DB(); $last = $first = Null; // Return Value; Initialize it to Okay @@ -530,7 +530,7 @@ class SpotNab { // *********************************************************************** public function auto_post_discovery($repost_sec=SpotNab::POST_BROADCAST_INTERVAL){ - $db = new Settings(); + $db = new DB(); // performs a post discovery once the time in seconds has elapsed $q = "SELECT updateddate FROM site WHERE " ."setting = 'spotnabbroadcast'"; @@ -653,7 +653,7 @@ class SpotNab { * The specified $reftime is presumed to be local *not utc* */ - $db = new Settings(); + $db = new DB(); $last = $first = Null; // Return Value; Initialize it to Okay @@ -901,7 +901,7 @@ class SpotNab { public function processGID($limit=500, $batch=5000, $delete_broken_releases=false){ // Process until someone presses cntrl-c - $db = new Settings(); + $db = new DB(); $nzb = new NZB(); $processed = 0; @@ -991,7 +991,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 Settings(); + $db = new DB(); // A small boolean we safely toggle after performing // a few checks first to make sure it's safe to do so @@ -1314,7 +1314,7 @@ class SpotNab { // Prepare some general SQL Commands for saving later if all goes well // - $db = new Settings(); + $db = new DB(); $rc = new ReleaseComments(); // Comments @@ -1535,7 +1535,7 @@ class SpotNab { // Prepare some general SQL Commands for saving later if all goes well // - $db = new Settings(); + $db = new DB(); // Auto Enable Flag (used for inserts only) $auto_enable = ($this->_auto_enable)?"1":"0"; @@ -1873,7 +1873,7 @@ class SpotNab { { $message['comments'] = $data['comments']; - $db = new Settings(); + $db = new DB(); $sql = sprintf("UPDATE releasecomment " ."SET issynced = 1 WHERE ID IN (%s)", implode(",", $data['ids'])); @@ -2220,7 +2220,7 @@ class SpotNab { * but otherwise it's expected format is string "Y-m-d H:i:s" */ - $db = new Settings(); + $db = new DB(); // Now we fetch for any new posts since reference point $sql = sprintf("SELECT r.gid, rc.ID, rc.text, u.username, " @@ -2463,7 +2463,7 @@ class SpotNab { public function getSources() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT ID, lastupdate,lastbroadcast, active, description, " ."(SELECT count(ID) from releasecomment where sourceid = s.ID)" ." AS comments FROM spotnabsources s"); @@ -2471,14 +2471,14 @@ class SpotNab { public function getSourceById($id) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("SELECT * FROM spotnabsources WHERE id = %d", $id); return $db->queryOneRow($sql); } public function addSource($description,$username,$usermail,$usenetgroup,$publickey) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("INSERT INTO spotnabsources " ."(description, username, useremail," ." usenetgroup, publickey, active) " @@ -2491,7 +2491,7 @@ class SpotNab { public function updateSource($id, $description,$username,$usermail,$usenetgroup,$publickey) { - $db = new Settings(); + $db = new DB(); return $db->queryExec( sprintf("UPDATE spotnabsources SET " ."description = %s, username = %s, useremail = %s," @@ -2503,19 +2503,19 @@ class SpotNab { public function deleteSource($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE FROM spotnabsources WHERE id = %d", $id)); } public function toggleSource($id, $active) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("update spotnabsources SET active = %d WHERE id = %d", $active, $id)); } public function getDefaultValue($table,$field) { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("SHOW COLUMNS FROM %s WHERE field = %s", $table, $db->escapeString($field))); } } diff --git a/lib/copy_this/www/lib/thetvdb.php b/lib/copy_this/www/lib/thetvdb.php index 7192d2430..3d55b3d5b 100644 --- a/lib/copy_this/www/lib/thetvdb.php +++ b/lib/copy_this/www/lib/thetvdb.php @@ -19,7 +19,7 @@ class TheTVDB public function addSeries($TheTVDBAPIArray) { - $db = new Settings(); + $db = new DB(); $airstime = $TheTVDBAPIArray['airstime']; if($airstime != "") @@ -51,7 +51,7 @@ class TheTVDB public function addEpisodes($TheTVDBAPIArray) { - $db = new Settings(); + $db = new DB(); for($i=0; $i < count($TheTVDBAPIArray['episodetvdbID']); $i++) { $airdate = strftime('%Y-%m-%d %H:%M:%S', strtotime($TheTVDBAPIArray['episodefirstaired'][$i].' '.$TheTVDBAPIArray['airstime'])); @@ -74,7 +74,7 @@ class TheTVDB public function updateSeries($tvdbID, $actors, $airsday, $airstime, $contentrating, $firstaired, $genre, $imdbID, $network, $overview, $rating, $ratingcount, $runtime, $seriesname, $status) { - $db = new Settings(); + $db = new DB(); if ($airstime != "") $airstime = $db->escapeString(date("H:i:s", strtotime($airstime))); else @@ -102,33 +102,33 @@ class TheTVDB public function deleteTitle($tvdbID) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE FROM thetvdb WHERE tvdbID = %d", $tvdbID)); } public function addEmptySeries($seriesname) { - $db = new Settings(); + $db = new DB(); $db->queryInsert(sprintf("INSERT INTO thetvdb (tvdbID, seriesname, createddate) VALUES (0, %s, now())", $db->escapeString($seriesname))); } public function getSeriesInfoByID($tvdbID) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT * FROM thetvdb WHERE tvdbID = %d", $tvdbID)); } public function getSeriesInfoByName($seriesname) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("SELECT * FROM thetvdb WHERE seriesname = %s", $db->escapeString($seriesname))); } public function getSeriesRange($start, $num, $seriesname='') { - $db = new Settings(); + $db = new DB(); $limit = ($start === false) ? '' : " LIMIT ".$start.",".$num; @@ -141,7 +141,7 @@ class TheTVDB public function getSeriesCount($seriesname='') { - $db = new Settings(); + $db = new DB(); $rsql = ''; if ($seriesname != '') @@ -179,13 +179,13 @@ class TheTVDB if($this->echooutput && $echooutput) echo 'TheTVDB : '.$seriesName.' '.$fullep." Not found\n"; - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf('UPDATE releases SET episodeinfoID = %d WHERE ID = %d', -2, $releaseID)); } public function processReleases() { - $db = new Settings(); + $db = new DB(); $results = $db->queryDirect(sprintf("SELECT ID, searchname, rageID, anidbID, seriesfull, season, episode, tvtitle FROM releases WHERE episodeinfoID IS NULL AND categoryID IN ( SELECT ID FROM category WHERE parentID = %d ) LIMIT 150", Category::CAT_PARENT_TV)); diff --git a/lib/copy_this/www/lib/tvrage.php b/lib/copy_this/www/lib/tvrage.php index 3e4b7d343..479382a1b 100644 --- a/lib/copy_this/www/lib/tvrage.php +++ b/lib/copy_this/www/lib/tvrage.php @@ -35,20 +35,20 @@ class TvRage public function getByID($id) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from tvrage where ID = %d", $id )); } public function getByRageID($id) { - $db = new Settings(); + $db = new DB(); return $db->query(sprintf("select * from tvrage where rageID = %d", $id )); } public function getByTitle($title) { // check if we already have an entry for this show - $db = new Settings(); + $db = new DB(); $sql = sprintf("SELECT rageID from tvrage where (releasetitle = %s or releasetitle = %s)", $db->escapeString($title), $db->escapeString(str_replace(' and ', ' & ', $title))); $res = $db->queryOneRow($sql); if ($res) @@ -61,14 +61,14 @@ class TvRage { $releasename = str_replace(array('.','_'), array(' ',' '), $releasename); - $db = new Settings(); + $db = new DB(); return $db->queryInsert(sprintf("insert into tvrage (rageID, releasetitle, description, genre, country, createddate, imgdata) values (%d, %s, %s, %s, %s, now(), %s)", $rageid, $db->escapeString($releasename), $db->escapeString($desc), $db->escapeString($genre), $db->escapeString($country), $db->escapeString($imgbytes))); } public function update($id, $rageid, $releasename, $desc, $genre, $country, $imgbytes) { - $db = new Settings(); + $db = new DB(); if ($imgbytes != "") $imgbytes = sprintf(", imgdata = %s", $db->escapeString($imgbytes)); @@ -79,13 +79,13 @@ class TvRage public function delete($id) { - $db = new Settings(); + $db = new DB(); return $db->queryExec(sprintf("DELETE from tvrage where ID = %d",$id)); } public function getRange($start, $num, $ragename="") { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -101,7 +101,7 @@ class TvRage public function getCount($ragename="") { - $db = new Settings(); + $db = new DB(); $rsql = ''; if ($ragename != "") @@ -113,7 +113,7 @@ class TvRage public function getCalendar($date = "") { - $db = new Settings(); + $db = new DB(); if(!preg_match('/\d{4}-\d{2}-\d{2}/',$date)) $date = date("Y-m-d"); $sql = sprintf("SELECT * FROM episodeinfo WHERE rageID > %d AND DATE(airdate) = %s order by airdate asc ", 0, $db->escapeString($date)); @@ -122,7 +122,7 @@ class TvRage public function getSeriesList($uid, $letter="", $ragename="") { - $db = new Settings(); + $db = new DB(); $rsql = ''; if ($letter != "") @@ -144,7 +144,7 @@ class TvRage public function updateSchedule() { - $db = new Settings(); + $db = new DB(); $countries = $db->query("select distinct(country) as country from tvrage where country != ''"); $showsindb = $db->query("select distinct(rageid) as rageid from tvrage"); @@ -423,7 +423,7 @@ class TvRage } } - $db = new Settings(); + $db = new DB(); $sql = sprintf("update tvrage set description = %s, imgdata = %s where id = %d", $db->escapeString($desc), $db->escapeString($imgbytes), $id); return $db->queryExec($sql); @@ -499,7 +499,7 @@ class TvRage public function processTvReleases($lookupTvRage=true, $numtoProcess=100) { $ret = 0; - $db = new Settings(); + $db = new DB(); $nfo = new Nfo(); // get all releases without a rageid which are in a tv category. diff --git a/lib/copy_this/www/lib/usermovies.php b/lib/copy_this/www/lib/usermovies.php index 48d0a120a..a063d7ff7 100644 --- a/lib/copy_this/www/lib/usermovies.php +++ b/lib/copy_this/www/lib/usermovies.php @@ -5,7 +5,7 @@ class UserMovies { public function addMovie($uid, $imdbid, $catid=array()) { - $db = new Settings(); + $db = new DB(); $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; @@ -15,33 +15,33 @@ class UserMovies public function getMovies($uid) { - $db = new Settings(); + $db = new DB(); $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 Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from usermovies where userID = %d and imdbID = %d ", $uid, $imdbid)); } public function getMovie($uid, $imdbid) { - $db = new Settings(); + $db = new DB(); $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 Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from usermovies where userID = %d", $uid)); } public function updateMovie($uid, $imdbid, $catid=array()) { - $db = new Settings(); + $db = new DB(); $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; diff --git a/lib/copy_this/www/lib/users.php b/lib/copy_this/www/lib/users.php index 1f713872f..e9a3dafd4 100644 --- a/lib/copy_this/www/lib/users.php +++ b/lib/copy_this/www/lib/users.php @@ -1,5 +1,5 @@ query("select * from users"); } public function delete($id) { - $db = new Settings(); + $db = new DB(); $this->delCartForUser($id); $this->delUserCategoryExclusions($id); $this->delDownloadRequests($id); @@ -70,7 +70,7 @@ class Users public function getRange($start, $num, $orderby, $username = '', $email = '', $host = '', $role = '') { - $db = new Settings(); + $db = new DB(); if ($start === false) $limit = ""; @@ -138,7 +138,7 @@ class Users public function getCount() { - $db = new Settings(); + $db = new DB(); $res = $db->queryOneRow("select count(ID) as num from users WHERE email != 'sharing@nZEDb.com'"); return $res["num"]; @@ -146,7 +146,7 @@ class Users public function add($uname, $pass, $email, $role, $notes, $host, $invites = Users::DEFAULT_INVITES, $invitedby = 0) { - $db = new Settings(); + $db = new DB(); $site = new Sites(); $s = $site->get(); @@ -165,7 +165,7 @@ class Users public function update($id, $uname, $email, $grabs, $role, $notes, $invites, $movieview, $musicview, $gameview, $xxxview, $consoleview, $bookview, $queueType = '', $nzbgetURL = '', $nzbgetUsername = '', $nzbgetPassword = '', $saburl = '', $sabapikey = '', $sabpriority = '', $sabapikeytype = '', $nzbvortexServerUrl, $nzbvortexApiKey = false, $cp_url = false, $cp_api = false) { - $db = new Settings(); + $db = new DB(); $uname = trim($uname); $email = trim($email); @@ -245,7 +245,7 @@ class Users public function updateUserRole($uid, $role) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users set role = %d where id = %d", $role, $uid)); return Users::SUCCESS; @@ -253,7 +253,7 @@ class Users public function updateUserRoleChangeDate($uid, $date) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users SET rolechangedate = '%s' WHERE ID = %d", $date, $uid)); return Users::SUCCESS; @@ -261,7 +261,7 @@ class Users public function updateExpiredRoles($uprole, $downrole, $msgsubject, $msgbody) { - $db = new Settings(); + $db = new DB(); $site = new Sites; $s = $site->get(); @@ -277,7 +277,7 @@ class Users public function updateRssKey($uid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users set rsstoken = md5(%s) where id = %d", $db->escapeString(uniqid()), $uid)); return Users::SUCCESS; @@ -285,7 +285,7 @@ class Users public function updatePassResetGuid($id, $guid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users set resetguid = %s where id = %d", $db->escapeString($guid), $id)); return Users::SUCCESS; @@ -293,7 +293,7 @@ class Users public function updatePassword($id, $password) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users set password = %s, userseed=md5(%s) where id = %d", $db->escapeString($this->hashPassword($password)), $db->escapeString(generateUuid()), $id)); return Users::SUCCESS; @@ -301,34 +301,34 @@ class Users public function getByEmail($email) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from users where lower(email) = %s ", $db->escapeString(strtolower($email)))); } public function getByPassResetGuid($guid) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select * from users where resetguid = %s ", $db->escapeString($guid))); } public function getByUsername($uname) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select users.*, userroles.name as rolename, userroles.apirequests, userroles.downloadrequests from users inner join userroles on userroles.ID = users.role where username = %s ", $db->escapeString($uname))); } public function incrementGrabs($id, $num = 1) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users set grabs = grabs + %d where id = %d ", $num, $id)); } public function getById($id) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("select users.*, userroles.name as rolename, userroles.hideads, userroles.canpreview, userroles.canpre, userroles.apirequests, userroles.downloadrequests, NOW() as now from users inner join userroles on userroles.ID = users.role where users.id = %d ", $id); return $db->queryOneRow($sql); @@ -336,7 +336,7 @@ class Users public function getByIdAndRssToken($id, $rsstoken) { - $db = new Settings(); + $db = new DB(); $res = $this->getById($id); return ($res && $res["rsstoken"] == $rsstoken ? $res : null); @@ -344,7 +344,7 @@ class Users public function getByRssToken($rsstoken) { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow(sprintf("select users.*, userroles.apirequests, userroles.downloadrequests, NOW() as now from users inner join userroles on userroles.ID = users.role where users.rsstoken = %s ", $db->escapeString($rsstoken))); } @@ -366,7 +366,7 @@ class Users public function isDisabled($username) { - $db = new Settings(); + $db = new DB(); $role = $db->queryOneRow(sprintf("select role as role from users where username = %s ", $db->escapeString($username))); return ($role["role"] == Users::ROLE_DISABLED); @@ -544,7 +544,7 @@ class Users public function updateSiteAccessed($uid, $host = "") { - $db = new Settings(); + $db = new DB(); $hostSql = ''; if ($host != '') $hostSql = sprintf(', host = %s', $db->escapeString($host)); @@ -554,7 +554,7 @@ class Users public function updateApiAccessed($uid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users set apiaccess = now() where id = %d ", $uid)); } @@ -568,7 +568,7 @@ class Users public function addCart($uid, $releaseid) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("insert into usercart (userID, releaseID, createddate) values (%d, %d, now())", $uid, $releaseid); return $db->queryInsert($sql); @@ -576,7 +576,7 @@ class Users public function getCart($uid, $releaseid = "") { - $db = new Settings(); + $db = new DB(); if ($releaseid != "") $releaseid = " and releases.ID = " . $db->escapeString($releaseid); @@ -585,7 +585,7 @@ class Users public function delCartByGuid($guids, $uid) { - $db = new Settings(); + $db = new DB(); if (!is_array($guids)) return false; @@ -602,7 +602,7 @@ class Users public function delCartByUserAndRelease($guid, $uid) { - $db = new Settings(); + $db = new DB(); $rel = $db->queryOneRow(sprintf("select ID from releases where guid = %s", $db->escapeString($guid))); if ($rel) $db->queryExec(sprintf("DELETE FROM usercart WHERE userID = %d AND releaseID = %d", $uid, $rel["ID"])); @@ -610,19 +610,19 @@ class Users public function delCartForUser($uid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from usercart where userID = %d", $uid)); } public function delCartForRelease($rid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from usercart where releaseID = %d", $rid)); } public function addCategoryExclusions($uid, $catids) { - $db = new Settings(); + $db = new DB(); $this->delUserCategoryExclusions($uid); if (count($catids) > 0) { foreach ($catids as $catid) { @@ -633,7 +633,7 @@ class Users public function getCategoryExclusion($uid) { - $db = new Settings(); + $db = new DB(); $ret = array(); $data = $db->query(sprintf("select categoryID from userexcat where userID = %d union distinct select categoryID from roleexcat inner join users on users.role = roleexcat.role where users.ID = %d", $uid, $uid)); foreach ($data as $d) @@ -644,7 +644,7 @@ class Users public function getRoleCategoryExclusion($role) { - $db = new Settings(); + $db = new DB(); $ret = array(); $data = $db->query(sprintf("select categoryID from roleexcat where role = %d", $role)); foreach ($data as $d) @@ -655,7 +655,7 @@ class Users public function addRoleCategoryExclusions($role, $catids) { - $db = new Settings(); + $db = new DB(); $this->delRoleCategoryExclusions($role); if (count($catids) > 0) { foreach ($catids as $catid) { @@ -670,7 +670,7 @@ class Users $ret = array(); if ($data) { - $db = new Settings(); + $db = new DB(); $category = new Category(); $data = $category->getByIds($data); foreach ($data as $d) @@ -682,19 +682,19 @@ class Users public function delCategoryExclusion($uid, $catid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from userexcat where userID = %d and categoryID = %d", $uid, $catid)); } public function delUserCategoryExclusions($uid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from userexcat where userID = %d", $uid)); } public function delRoleCategoryExclusions($role) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from roleexcat where role = %d", $role)); } @@ -714,7 +714,7 @@ class Users public function getInvite($inviteToken) { - $db = new Settings(); + $db = new DB(); // // Tidy any old invites sent greater than DEFAULT_INVITE_EXPIRY_DAYS days ago. @@ -726,13 +726,13 @@ class Users public function addInvite($uid, $inviteToken) { - $db = new Settings(); + $db = new DB(); $db->queryInsert(sprintf("insert into userinvite (guid, userID, createddate) values (%s, %d, now())", $db->escapeString($inviteToken), $uid)); } public function deleteInvite($inviteToken) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from userinvite where guid = %s ", $db->escapeString($inviteToken))); } @@ -742,7 +742,7 @@ class Users if (!$invite) return -1; - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("update users set invites = case when invites <= 0 then 0 else invites-1 end where ID = %d ", $invite["userID"])); $this->deleteInvite($invitecode); @@ -751,7 +751,7 @@ class Users public function getTopGrabbers() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT ID, username, SUM(grabs) as grabs FROM users GROUP BY ID, username @@ -763,7 +763,7 @@ class Users public function getUsersByMonth() { - $db = new Settings(); + $db = new DB(); return $db->query("SELECT DATE_FORMAT(createddate, '%M %Y') AS mth, COUNT(*) AS num FROM users @@ -775,7 +775,7 @@ class Users public function getUsersByHostHash() { - $db = new Settings(); + $db = new DB(); $site = new Sites(); $s = $site->get(); @@ -808,7 +808,7 @@ class Users public function getUsersByRole() { - $db = new Settings(); + $db = new DB(); return $db->query("select ur.name, count(u.ID) as num from users u inner join userroles ur on ur.ID = u.role @@ -819,7 +819,7 @@ class Users public function getLoginCountsByMonth() { - $db = new Settings(); + $db = new DB(); return $db->query("select 'Login' as type, sum(case when lastlogin > curdate() - INTERVAL 1 DAY then 1 else 0 end) as 1day, @@ -843,14 +843,14 @@ class Users public function getRoles() { - $db = new Settings(); + $db = new DB(); return $db->query("select * from userroles"); } public function getRoleById($id) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("select * from userroles where ID = %d", $id); return $db->queryOneRow($sql); @@ -858,14 +858,14 @@ class Users public function getDefaultRole() { - $db = new Settings(); + $db = new DB(); return $db->queryOneRow("select * from userroles where isdefault = 1"); } public function addRole($name, $apirequests, $downloadrequests, $defaultinvites, $canpreview, $canpre, $hideads) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("insert into userroles (name, apirequests, downloadrequests, defaultinvites, canpreview, canpre, hideads) VALUES (%s, %d, %d, %d, %d, %d)", $db->escapeString($name), $apirequests, $downloadrequests, $defaultinvites, $canpreview, $canpre, $hideads); return $db->queryInsert($sql); @@ -873,7 +873,7 @@ class Users public function updateRole($id, $name, $apirequests, $downloadrequests, $defaultinvites, $isdefault, $canpreview, $canpre, $hideads) { - $db = new Settings(); + $db = new DB(); if ($isdefault == 1) $db->queryExec("update userroles set isdefault=0"); @@ -882,7 +882,7 @@ class Users public function deleteRole($id) { - $db = new Settings(); + $db = new DB(); $res = $db->query(sprintf("select ID from users where role = %d", $id)); if (sizeof($res) > 0) { $userids = array(); @@ -898,7 +898,7 @@ class Users public function getApiRequests($userid) { - $db = new Settings(); + $db = new DB(); //clear old requests //$db->queryExec(sprintf("DELETE FROM userrequests WHERE (userID = %d AND timestamp < DATE_SUB(NOW(), INTERVAL 1 DAY))", $userid)); $db->queryExec(sprintf("DELETE FROM userrequests WHERE timestamp < DATE_SUB(NOW(), INTERVAL 1 DAY)", $userid)); @@ -910,7 +910,7 @@ class Users public function addApiRequest($userid, $request, $hosthash) { - $db = new Settings(); + $db = new DB(); $hosthash = ($hosthash != "" ? $db->escapeString($hosthash) : "null"); $sql = sprintf("insert into userrequests (userID, request, timestamp, hosthash) VALUES (%d, %s, now(), %s)", $userid, $db->escapeString($request), $hosthash); @@ -920,7 +920,7 @@ class Users public function delApiRequests($userid) { - $db = new Settings(); + $db = new DB(); return $db->queryInsert(sprintf("delete from userrequests where userID = %d", $userid)); } @@ -933,7 +933,7 @@ class Users */ public function pruneRequestHistory($days = 0) { - $db = new Settings(); + $db = new DB(); if ($days == 0) { $days = 1; $db->queryExec("update userdownloads set releaseID = null"); @@ -945,7 +945,7 @@ class Users public function getDownloadRequests($userid, $hosthash = "", $site = "") { - $db = new Settings(); + $db = new DB(); if ($hosthash != "" && $site->userhostexclusion != '') { $ipsql = ""; @@ -965,7 +965,7 @@ class Users public function getDownloadRequestsForUserAndAllHostHashes($userid) { - $db = new Settings(); + $db = new DB(); $sql = sprintf("select distinct hosthash from userdownloads where userID = %d and hosthash is not null and hosthash != ''", $userid); $rows = $db->query($sql); @@ -982,7 +982,7 @@ class Users public function addDownloadRequest($userid, $hosthash, $relGuid) { - $db = new Settings(); + $db = new DB(); $hosthash = ($hosthash != "" ? $db->escapeString($hosthash) : "null"); $sql = sprintf("insert into userdownloads (userID, timestamp, hosthash, releaseID) VALUES (%d, now(), %s, (select ID from releases where guid = %s))", $userid, $hosthash, $db->escapeString($relGuid)); @@ -992,14 +992,14 @@ class Users public function delDownloadRequests($userid) { - $db = new Settings(); + $db = new DB(); return $db->queryInsert(sprintf("delete from userdownloads where userID = %d", $userid)); } public function delDownloadRequestsForRelease($releaseID) { - $db = new Settings(); + $db = new DB(); return $db->queryInsert(sprintf("delete from userdownloads where releaseID = %d", $releaseID)); } diff --git a/lib/copy_this/www/lib/userseries.php b/lib/copy_this/www/lib/userseries.php index 5298151d9..40065513d 100644 --- a/lib/copy_this/www/lib/userseries.php +++ b/lib/copy_this/www/lib/userseries.php @@ -5,7 +5,7 @@ class UserSeries { public function addShow($uid, $rageid, $catid=array()) { - $db = new Settings(); + $db = new DB(); $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; @@ -15,39 +15,39 @@ class UserSeries public function getShows($uid) { - $db = new Settings(); + $db = new DB(); $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 Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from userseries where userID = %d and rageID = %d ", $uid, $rageid)); } public function getShow($uid, $rageid) { - $db = new Settings(); + $db = new DB(); $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 Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from userseries where userID = %d", $uid)); } public function delShowForSeries($sid) { - $db = new Settings(); + $db = new DB(); $db->queryExec(sprintf("DELETE from userseries where rageID = %d", $sid)); } public function updateShow($uid, $rageid, $catid=array()) { - $db = new Settings(); + $db = new DB(); $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; diff --git a/lib/copy_this/www/pages/prehashinfo.php b/lib/copy_this/www/pages/prehashinfo.php index 1f21374f8..9e6ec8a36 100644 --- a/lib/copy_this/www/pages/prehashinfo.php +++ b/lib/copy_this/www/pages/prehashinfo.php @@ -1,6 +1,6 @@ query( sprintf(' SELECT p.* @@ -178,7 +178,7 @@ if (isset($_GET['type'])) { case 't': case 'title': if (isset($_GET['title'])) { - $db = new Settings(); + $db = new DB(); $preData = $db->query( sprintf('SELECT * FROM prehash p WHERE p.title %s %s %s LIKE %s LIMIT %d OFFSET %d', $newer, @@ -196,7 +196,7 @@ if (isset($_GET['type'])) { case 'm': case 'md5': if (isset($_GET['md5']) && strlen($_GET['title']) === 32) { - $db = new Settings(); + $db = new DB(); $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']), @@ -213,7 +213,7 @@ if (isset($_GET['type'])) { case 's': case 'sha1': if (isset($_GET['sha1']) && strlen($_GET['sha1']) === 40) { - $db = new Settings(); + $db = new DB(); $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']), @@ -229,7 +229,7 @@ if (isset($_GET['type'])) { case 'a': case 'all': - $db = new Settings(); + $db = new DB(); $preData = $db->query( sprintf('SELECT * FROM prehash p WHERE 1=1 %s %s %s ORDER BY p.predate DESC LIMIT %d OFFSET %d', $newer, diff --git a/lib/functions.php b/lib/functions.php index 554200189..fc8f21b09 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1,5 +1,5 @@ log = new ColorCLI(); $ran = false; diff --git a/lib/testing/convert_mysql_tables.php b/lib/testing/convert_mysql_tables.php index e032ed611..9111abf62 100644 --- a/lib/testing/convert_mysql_tables.php +++ b/lib/testing/convert_mysql_tables.php @@ -5,7 +5,7 @@ require_once(dirname(__FILE__) . "/../../bin/config.php"); require_once(WWW_DIR."lib/framework/db.php"); $sql = "SHOW tables"; -$db = new Settings(); +$db = new DB(); if (isset($argv[1]) && $argv[1] == "myisam") { diff --git a/lib/testing/getGames.php b/lib/testing/getGames.php index 4381e1c04..4116d005d 100644 --- a/lib/testing/getGames.php +++ b/lib/testing/getGames.php @@ -6,7 +6,7 @@ require_once(WWW_DIR . "/lib/ColorCLI.php"); $game = new Games(true); -$pdo = new Settings(); +$pdo = new DB(); $c = new ColorCLI(); $res = $pdo->query( diff --git a/lib/testing/getXXXCovers.php b/lib/testing/getXXXCovers.php index 47f979f3a..8b83922fb 100644 --- a/lib/testing/getXXXCovers.php +++ b/lib/testing/getXXXCovers.php @@ -5,7 +5,7 @@ require_once(WWW_DIR . "/lib/XXX.php"); require_once(WWW_DIR . "/lib/ColorCLI.php"); -$pdo = new Settings(); +$pdo = new DB(); $movie = new XXX(); $c = new ColorCLI(); diff --git a/lib/testing/populate_anidb.php b/lib/testing/populate_anidb.php index 9ddd23d95..14f82cb6c 100644 --- a/lib/testing/populate_anidb.php +++ b/lib/testing/populate_anidb.php @@ -4,7 +4,7 @@ */ require_once(dirname(__FILE__) . "/../../bin/config.php"); -require_once(WWW_DIR . "/lib/framework/Settings.php"); +require_once(WWW_DIR . "/lib/framework/db.php"); require_once(WWW_DIR . "/lib/util.php"); require_once(WWW_DIR . "/lib/releaseimage.php"); require_once(WWW_DIR . "/lib/Tmux.php"); diff --git a/lib/testing/recategorize.php b/lib/testing/recategorize.php index 200675a76..8fcb536c1 100644 --- a/lib/testing/recategorize.php +++ b/lib/testing/recategorize.php @@ -1,6 +1,6 @@ query("update releases set passwordstatus = -1 where rarinnerfilecount = 0"); diff --git a/start.php b/start.php index fee879fa2..c9a8d9055 100644 --- a/start.php +++ b/start.php @@ -5,7 +5,7 @@ require_once (WWW_DIR.'/lib/site.php'); require_once(WWW_DIR. '/lib/Tmux.php'); require_once(WWW_DIR . "/lib/ColorCLI.php"); -$db = new Settings(); +$db = new DB(); $DIR = dirname (__FILE__); $c = new ColorCLI(); $s = new Sites(); @@ -168,7 +168,7 @@ function window_ircscraper($tmux_session) function window_sharing($tmux_session) { - $db = new Settings(); + $db = new DB(); $sharing = $db->queryOneRow('SELECT enabled, posting, fetching FROM sharing'); $t = new Tmux(); $tmux = $t->get();