diff --git a/bin/monitor.php b/bin/monitor.php index 6765287f9..f9133ca4f 100644 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -8,7 +8,7 @@ require_once("../test/showsleep.php"); require_once("../test/functions.php"); -$version="0.3r704"; +$version="0.3r705"; $db = new DB(); $functions = new Functions(); diff --git a/test/db_updates/db_update_18_02_2014.sql b/test/db_updates/db_update_18_02_2014.sql new file mode 100644 index 000000000..930700c38 --- /dev/null +++ b/test/db_updates/db_update_18_02_2014.sql @@ -0,0 +1,22 @@ +ALTER TABLE `releases` + DROP INDEX ix_releases_status, + ADD COLUMN `nzbstatus` BOOL NOT NULL DEFAULT 0, + ADD COLUMN `iscategorized` BOOL NOT NULL DEFAULT 0, + ADD COLUMN `isrenamed` BOOL NOT NULL DEFAULT 0, + ADD COLUMN `ishashed` BOOL NOT NULL DEFAULT 0, + ADD COLUMN `isrequestid` BOOL NOT NULL DEFAULT 0, + CREATE INDEX ix_releases_status (nzbstatus, iscategorized, isrenamed, nfostatus, ishashed, isrequestid, passwordstatus, dehashstatus, reqidstatus, musicinfoID, consoleinfoID, bookinfoID, haspreview, categoryID, imdbID, rageID); +UPDATE releases + SET nzbstatus = 1 WHERE (bitwise & 256) = 256, + SET iscategorized = 1 WHERE (bitwise & 1) = 1, + SET isrenamed = 1 WHERE (bitwise & 4) = 4, + SET ishashed = 1 WHERE (bitwise & 512) = 512, + SET isrequestid = 1 WHERE (bitwise & 1024) = 1024; + +DROP TRIGGER IF EXISTS check_insert; +DROP TRIGGER IF EXISTS check_update; + +CREATE TRIGGER check_insert BEFORE INSERT ON releases FOR EACH ROW BEGIN IF NEW.searchname REGEXP '[a-fA-F0-9]{32}' OR NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1;ELSEIF NEW.name REGEXP '^\\[[[:digit:]]+\\]' THEN SET NEW.isrequestid = 1; END IF; END; +CREATE TRIGGER check_update BEFORE UPDATE ON releases FOR EACH ROW BEGIN IF NEW.searchname REGEXP '[a-fA-F0-9]{32}' OR NEW.name REGEXP '[a-fA-F0-9]{32}' THEN SET NEW.ishashed = 1;ELSEIF NEW.name REGEXP '^\\[[[:digit:]]+\\]' THEN SET NEW.isrequestid = 1; END IF; END; + +UPDATE tmux SET value = '' WHERE setting = 'sqlpatch'; diff --git a/test/hash_decrypt.php b/test/hash_decrypt.php index 8349623e7..2f82e9c21 100755 --- a/test/hash_decrypt.php +++ b/test/hash_decrypt.php @@ -26,11 +26,11 @@ function preName($argv) $c = new ColorCLI(); $timestart = TIME(); if (isset($argv[1]) && $argv[1] === "all") - $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE (bitwise & 512) = 512'); + $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE ishashed = 1'); else if (isset($argv[1]) && $argv[1] === "full") - $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE (bitwise & 512) = 512 AND dehashstatus BETWEEN -6 AND 0'); + $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE ishashed = 1 AND dehashstatus BETWEEN -6 AND 0'); else if (isset($argv[1]) && is_numeric($argv[1])) - $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE (bitwise & 512) = 512 AND dehashstatus BETWEEN -6 AND 0 ORDER BY postdate DESC LIMIT '.$argv[1]); + $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE ishashed = 1 AND dehashstatus BETWEEN -6 AND 0 ORDER BY postdate DESC LIMIT '.$argv[1]); $total = $res->rowCount(); $counter = 0; $show = ''; @@ -54,7 +54,7 @@ function preName($argv) { $determinedcat = $category->determineCategory($row["groupID"], $pre['title']); $result = $db->query(sprintf("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, preID = %d, dehashstatus = 1, bitwise = ((bitwise & ~37)|37), searchname = %s, categoryID = %d WHERE ID = %d", $pre['ID'], $db->escapeString($pre['title']), $determinedcat, $row['ID'])); + . "anidbID = NULL, preID = %d, dehashstatus = 1, isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~32)|32), searchname = %s, categoryID = %d WHERE ID = %d", $pre['ID'], $db->escapeString($pre['title']), $determinedcat, $row['ID'])); $total = count($result); if ($total > 0) { diff --git a/test/jb_fix_names.php b/test/jb_fix_names.php index 00b2e0747..a936c6a48 100644 --- a/test/jb_fix_names.php +++ b/test/jb_fix_names.php @@ -53,29 +53,29 @@ function preName($argv, $argc) } if ($usepre === true) { $where = ''; - $why = ' WHERE preID IS NULL AND (bitwise & 256) = 256'; + $why = ' WHERE preID IS NULL AND nzbstatus = 1'; } else if (isset($argv[1]) && is_numeric($argv[1])) { $where = ''; - $why = ' WHERE (bitwise & 260) = 256'; + $why = ' WHERE nzbstatus = 1 AND isrenamed = 1'; } else if (isset($argv[2]) && is_numeric($argv[2]) && $full === true) { $where = ' AND groupid = ' . $argv[2]; - $why = ' WHERE (bitwise & 260) = 256'; + $why = ' WHERE nzbstatus = 1 AND isrenamed = 1'; } else if (isset($argv[2]) && preg_match('/\([\d, ]+\)/', $argv[2]) && $full === true) { $where = ' AND groupid IN ' . $argv[2]; - $why = ' WHERE (bitwise & 260) = 256'; + $why = ' WHERE nzbstatus = 1 AND isrenamed = 1'; } else if (isset($argv[2]) && preg_match('/\([\d, ]+\)/', $argv[2]) && $all === true) { $where = ' AND groupid IN ' . $argv[2]; - $why = ' WHERE (bitwise & 256) = 256'; + $why = ' WHERE nzbstatus = 1'; } else if (isset($argv[2]) && is_numeric($argv[2]) && $all === true) { $where = ' AND groupid = ' . $argv[2]; - $why = ' WHERE (bitwise & 256) = 256'; + $why = ' WHERE nzbstatus = 1'; } else if (isset($argv[2]) && is_numeric($argv[2])) { $where = ' AND groupid = ' . $argv[2]; - $why = ' WHERE (bitwise & 260) = 256'; + $why = ' WHERE nzbstatus = 1 AND isrenamed = 1'; } else if ($full === true) { - $why = ' WHERE ((bitwise & 260) = 256 OR categoryid between 8000 AND 8999)'; + $why = ' WHERE (nzbstatus = 1 AND isrenamed = 1 OR categoryid between 8000 AND 8999)'; } else if ($all === true) { - $why = ' WHERE (bitwise & 256) = 256'; + $why = ' WHERE nzbstatus = 1'; } else { $why = ' WHERE 1=1'; } @@ -144,10 +144,10 @@ function preName($argv, $argc) if ($propername == true) { $run = $db->exec(sprintf("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, bitwise = ((bitwise & ~5)|5), searchname = %s, categoryID = %d, preID = " . $preid . " WHERE ID = %d", $db->escapeString($cleanName), $determinedcat, $row['ID'])); + . "anidbID = NULL, iscategorized = 1, isrenamed = 1, searchname = %s, categoryID = %d, preID = " . $preid . " WHERE ID = %d", $db->escapeString($cleanName), $determinedcat, $row['ID'])); } else { $run = $db->exec(sprintf("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, bitwise = ((bitwise & ~1)|1), searchname = %s, categoryID = %d, preID = " . $preid . " WHERE ID = %d", $db->escapeString($cleanName), $determinedcat, $row['ID'])); + . "anidbID = NULL, iscategorized = 1, searchname = %s, categoryID = %d, preID = " . $preid . " WHERE ID = %d", $db->escapeString($cleanName), $determinedcat, $row['ID'])); } if ($increment === true) { @@ -177,7 +177,7 @@ function preName($argv, $argc) } } if ($cleanName == $row['name']) { - $db->query(sprintf("UPDATE releases SET bitwise = ((bitwise & ~5)|5) WHERE ID = %d", $row['ID'])); + $db->query(sprintf("UPDATE releases SET iscategorized = 1, isrenamed = 1 WHERE ID = %d", $row['ID'])); } if ($show === 2 && $usepre === false) { $consoletools->overWritePrimary("Renamed Releases: [Internal=" . number_format($internal) . "][External=" . number_format($external) . "][Prehash=" . number_format($pre) . "] " . $consoletools->percentString( ++$counter, $total)); @@ -200,7 +200,7 @@ function preName($argv, $argc) $timestart = TIME(); if (isset($argv[1]) && is_numeric($argv[1])) { - $relcount = categorizeRelease("searchname","WHERE ((bitwise & 1) = 0 OR categoryID = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); + $relcount = categorizeRelease("searchname","WHERE iscategorized = 0 OR categoryID = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); } else if (isset($argv[2]) && preg_match('/\([\d, ]+\)/', $argv[2]) && $full === true) { $relcount = categorizeRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND (bitwise & 1) = 0 ", true); } else if (isset($argv[2]) && preg_match('/\([\d, ]+\)/', $argv[2]) && $all === true) { @@ -214,9 +214,9 @@ function preName($argv, $argc) } else if (isset($argv[1]) && $argv[1] == "all") { $relcount = categorizeRelease("searchname", "", true); } else if (isset($argv[1]) && $argv[1] == "preid") { - $relcount = categorizeRelease("searchname", "WHERE preID IS NULL AND (bitwise & 256) = 256", true); + $relcount = categorizeRelease("searchname", "WHERE preID IS NULL AND nzbstatus = 1", true); } else { - $relcount = categorizeRelease("searchname", "WHERE ((bitwise & 1) = 0 OR categoryID = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); + $relcount = categorizeRelease("searchname", "WHERE iscategorized = 0 OR categoryID = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); } $consoletools = new ConsoleTools(); $time = $consoletools->convertTime(TIME() - $timestart); @@ -230,13 +230,13 @@ function resetSearchnames() $c = new ColorCLI(); echo $c->header("Resetting blank searchnames."); $bad = $db->queryDirect("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, preID = NULL, searchname = name, bitwise = ((bitwise & ~5)|0) WHERE searchname = ''"); + . "anidbID = NULL, preID = NULL, searchname = name, isrenamed = 0, iscategorized = 0 WHERE searchname = ''"); $tot = $bad->rowCount(); if ($tot > 0) { echo $c->primary(number_format($tot) . " Releases had no searchname."); } echo $c->header("Resetting searchnames that are 15 characters or less."); - $run = $db->queryDirect("UPDATE releases SET preID = NULL, searchname = name, bitwise = ((bitwise & ~5)|0) WHERE LENGTH(searchname) <= 15 AND LENGTH(name) > 15"); + $run = $db->queryDirect("UPDATE releases SET preID = NULL, searchname = name, isrenamed = 0, iscategorized = 0 WHERE LENGTH(searchname) <= 15 AND LENGTH(name) > 15"); $total = $run->rowCount(); if ($total > 0) { echo $c->primary(number_format($total) . " Releases had searchnames that were 15 characters or less."); @@ -259,7 +259,7 @@ function resetSearchnames() foreach ($resrel as $rowrel) { $catID = $cat->determineCategory($rowrel['groupID'], $rowrel[$type]); - $db->exec(sprintf("UPDATE releases SET bitwise = ((bitwise & ~1)|1), categoryID = %d WHERE ID = %d", $catID, $rowrel['ID'])); + $db->exec(sprintf("UPDATE releases SET iscategorized = 1, categoryID = %d WHERE ID = %d", $catID, $rowrel['ID'])); $relcount ++; if ($echooutput) $consoletools->overWritePrimary("Categorizing: " . $consoletools->percentString($relcount, $total)); diff --git a/test/namefixer.php b/test/namefixer.php index 42931e68d..584beda71 100644 --- a/test/namefixer.php +++ b/test/namefixer.php @@ -11,25 +11,57 @@ require_once("consoletools.php"); //This script is ported from nZEDb and adapted for newznab -/* Values of relnamestatus: - * 0 : New release, just inserted into the table. - * 1 : Categorized release. - * Previously (see 8,9,10): 2 : Fixed with namefixer. - * 3 : Fixed with post proc (from mp3 tags or music.php). - * 4 : Fixed with misc_sorter. - * 5 : Fixed with decrypt hashes. - * 6 : Matched properly in namecleaning.php's releaseCleaner function. - * 7 : Fixed with PAR2. - * 8 : Fixed with namefixer NFO. - * 9 : Fixed with namefixer Files. - * 10 : Fixed with namefixer preDB. - * 11 : Fixed with prehash.php - * 12 : Fixed with requestID. - * 16 : Fixed with jb_fix_names.php - * 20 : The release was checked by namefixer nfo but no name was found - * 21 : The release was checked by namefixer filename but no name was found - * 22 : The release was checked by namefixer par2 but no name was found - */ +/* These constants can not be used as they are + * To select where false - 'SELECT * FROM releases WHERE isrenamed = 0;' - selects all that have not been renamed + * To select where true - 'SELECT * FROM releases WHERE iscategorized = 1;' - selects all that have been categorized + * To select multiple true or false - 'SELECT * FROM releases WHERE isrenamed = 0 AND iscategorized = 0;' - selects all that have not been renamed and have not been categorized + * + * To set false - 'UPDATE releases SET isrenamed = 0);' - sets all releases to not renamed + * To set true - 'UPDATE releases SET iscategorized = 1;' - sets all releases to categorized + * To set multiple true or false - 'UPDATE releases SET iscategorized = 1 AND isrenamed = 0;' - sets all releases to categorized true and renamed false + + // One bit each, max 32, limited by 32 bit OS's + //const NF_NEW = 0; 0000 0000 0000 0000 0000 New release, just inserted into the table. + //const NF_CATEGORIZED = 1; 0000 0000 0000 0000 0001 Categorized release. + //0000 0000 0000 0000 0010 Spare - Previously 2 (now split into 8,9,10) : Fixed with namefixer. + //const NF_RENAMED = 4; 0000 0000 0000 0000 0100 Renamed using any script. + const NF_POST_PROC = 8; 0000 0000 0000 0000 1000 Processed by post proc (from mp3 tags or music.php). + const NF_MISC_SORTER = 16; 0000 0000 0000 0001 0000 Processed by misc_sorter. + const NF_PAR2 = 32; 0000 0000 0000 0010 0000 Processed by namefixer PAR2. + const NF_NF_NFO = 64; 0000 0000 0000 0100 0000 Processed by namefixer NFO. + const NF_NF_FILES = 128; 0000 0000 0000 1000 0000 Processed by namefixer Files. + + //const NZB_STATUS = 256; 0000 0000 0001 0000 0000 NZBStatus 0 = no nzb, 256 = is an nzb + //const HASHED = 512; 0000 0000 0010 0000 0000 ishashed 0 = not hashed, 512 = is hashed + //const REQUEST = 1024; 0000 0000 0100 0000 0000 isrequestid 0 = not a requestid, 1024 = is a requestid + + // To display counts for false + SELECT + (SELECT COUNT(*) FROM releases WHERE iscategorized = 0) as not_categorized, + (SELECT COUNT(*) FROM releases WHERE isrenamed = 0) as not_renamed, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 8) = 0) as not_proc_by_pp, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 16) = 0) as not_proc_by_sorter, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 32) = 0) as not_proc_by_par2, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 64) = 0) as not_proc_by_nfo, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 128) = 0) as not_proc_by_files, + (SELECT COUNT(*) FROM releases WHERE nzbstatus = 0) as no_nzb, + (SELECT COUNT(*) FROM releases WHERE ishashed = 0) as not_hashed, + (SELECT COUNT(*) FROM releases WHERE isrequestid = 0) as not_requestid; + + // To display counts for true + SELECT + (SELECT COUNT(*) FROM releases WHERE iscategorized = 1) as categorized, + (SELECT COUNT(*) FROM releases WHERE isrenamed = 1) as renamed, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 8) = 8) as proc_by_pp, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 16) = 16) as proc_by_sorter, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 32) = 32) as proc_by_par2, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 64) = 64) as proc_by_nfo, + (SELECT COUNT(*) FROM releases WHERE (bitwise & 128) = 128) as proc_by_files, + (SELECT COUNT(*) FROM releases WHERE nzbstatus = 1) as has_nzb, + (SELECT COUNT(*) FROM releases WHERE ishashed = 1) as is_hashed, + (SELECT COUNT(*) FROM releases WHERE isrequestid =1) as is_requestid; + + */ CONST PREDB_REGEX = "/([\w\(\)]+[\._]([\w\(\)]+[\._-])+[\w\(\)]+-\w+)/"; @@ -72,13 +104,13 @@ class Namefixer if ($cats === 3) { $query = "SELECT rel.ID AS releaseID FROM releases rel " . "INNER JOIN releasenfo nfo ON (nfo.releaseID = rel.ID) " - . "WHERE (bitwise & 256) = 256 AND preID IS NULL"; + . "WHERE nzbstatus = 1 AND preID IS NULL"; $cats = 2; $preid = true; } else { $query = "SELECT rel.ID AS releaseID FROM releases rel " . "INNER JOIN releasenfo nfo ON (nfo.releaseID = rel.ID) " - . "WHERE ((bitwise & 4) = 0 OR rel.categoryID = 8010) AND (bitwise & 64) = 0"; + . "WHERE (isrenamed = 0 OR rel.categoryID = 8010) AND (bitwise & 64) = 0"; } //24 hours, other cats @@ -149,14 +181,14 @@ class Namefixer $query = "SELECT relfiles.name AS textstring, rel.categoryID, rel.searchname, rel.groupID, relfiles.releaseID AS fileID, " . "rel.ID AS releaseID FROM releases rel " . "INNER JOIN releasefiles relfiles ON (relfiles.releaseID = rel.ID) " - . "WHERE (bitwise & 256) = 256 AND preID IS NULL"; + . "WHERE nzbstatus = 1 AND preID IS NULL"; $cats = 2; $preid = true; } else { $query = "SELECT relfiles.name AS textstring, rel.categoryID, rel.searchname, rel.groupID, relfiles.releaseID AS fileID, " . "rel.ID AS releaseID FROM releases rel " . "INNER JOIN releasefiles relfiles ON (relfiles.releaseID = rel.ID) " - . "WHERE ((bitwise & 4) = 0 OR rel.categoryID = 8010) AND (bitwise & 128) = 0"; + . "WHERE (isrenamed = 0 OR rel.categoryID = 8010) AND (bitwise & 128) = 0"; } //24 hours, other cats @@ -211,10 +243,10 @@ class Namefixer $functions = new Functions(); $type = "PAR2, "; if ($cats === 3) { - $query = "SELECT rel.ID AS releaseID, rel.guid, rel.groupID FROM releases rel WHERE (bitwise & 256) = 256 AND preID IS NULL"; + $query = "SELECT rel.ID AS releaseID, rel.guid, rel.groupID FROM releases rel WHERE nzbstatus = 1 AND preID IS NULL"; $cats = 2; } else { - $query = "SELECT rel.ID AS releaseID, rel.guid, rel.groupID FROM releases rel WHERE ((bitwise & 4) = 0 OR rel.categoryID = 8010) AND (bitwise & 32) = 0"; + $query = "SELECT rel.ID AS releaseID, rel.guid, rel.groupID FROM releases rel WHERE (isrenamed = 0 OR rel.categoryID = 8010) AND (bitwise & 32) = 0"; } //24 hours, other cats @@ -325,18 +357,18 @@ class Namefixer $db = new DB(); if ($namestatus == 1) { if ($type == "NFO, ") { - $status = "bitwise = ((bitwise & ~69)|69),"; + $status = "isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~64)|64),"; } else if ($type == "PAR2, ") { - $status = "bitwise = ((bitwise & ~37)|37),"; + $status = "isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~32)|32),"; } else if ($type == "Filenames, ") { - $status = "bitwise = ((bitwise & ~133)|133),"; + $status = "isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~128)|128),"; } $run = $db->exec(sprintf("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, preID = %s, searchname = %s, bitwise = ((bitwise & ~4)|4)," + . "anidbID = NULL, preID = %s, searchname = %s, isrenamed = 1," . " %s categoryID = %d WHERE ID = %d", $preid, $db->escapeString(substr($newname, 0, 255)), $status, $determinedcat, $release["releaseID"])); } else { $run = $db->exec(sprintf("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, preID = %s, searchname = %s, bitwise = ((bitwise & ~1)|1), " + . "anidbID = NULL, preID = %s, searchname = %s, iscategorized = 1, " . "categoryID = %d WHERE ID = %d", $preid, $db->escapeString(substr($newname, 0, 255)), $determinedcat, $release["releaseID"])); } } @@ -369,7 +401,7 @@ class Namefixer if ($namestatus == 1) { $db->query(sprintf("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, searchname = %s, categoryID = %d, bitwise = ((bitwise & ~5)|5), dehashstatus = 1 WHERE ID = %d", $db->escapeString($row["title"]), $determinedcat, $release["ID"])); + . "anidbID = NULL, searchname = %s, categoryID = %d, isrenamed = 1, iscategorized = 1, dehashstatus = 1 WHERE ID = %d", $db->escapeString($row["title"]), $determinedcat, $release["ID"])); } else { diff --git a/test/predb_hash_decrypt.php b/test/predb_hash_decrypt.php index 914c60228..f930eda24 100644 --- a/test/predb_hash_decrypt.php +++ b/test/predb_hash_decrypt.php @@ -26,11 +26,11 @@ function preName($argv) $c = new ColorCLI(); $timestart = TIME(); if (isset($argv[1]) && $argv[1] === "all") - $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE (bitwise & 512) = 512'); + $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE ishashed = 1'); else if (isset($argv[1]) && $argv[1] === "full") - $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE (bitwise & 512) = 512 AND dehashstatus BETWEEN -6 AND 0'); + $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE ishashed = 1 AND dehashstatus BETWEEN -6 AND 0'); else if (isset($argv[1]) && is_numeric($argv[1])) - $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE (bitwise & 512) = 512 AND dehashstatus BETWEEN -6 AND 0 ORDER BY postdate DESC LIMIT '.$argv[1]); + $res = $db->queryDirect('SELECT ID, name, searchname, groupID, categoryID FROM releases WHERE ishashed = 1 AND dehashstatus BETWEEN -6 AND 0 ORDER BY postdate DESC LIMIT '.$argv[1]); $total = $res->rowCount(); $counter = 0; $show = ''; @@ -54,7 +54,7 @@ function preName($argv) { $determinedcat = $category->determineCategory($row["groupID"], $pre['dirname']); $result = $db->query(sprintf("UPDATE releases SET rageID = NULL, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbID = NULL, musicinfoID = NULL, consoleinfoID = NULL, bookinfoID = NULL, " - . "anidbID = NULL, preID = %d, dehashstatus = 1, bitwise = ((bitwise & ~37)|37), searchname = %s, categoryID = %d WHERE ID = %d", $pre['ID'], $db->escapeString($pre['dirname']), $determinedcat, $row['ID'])); + . "anidbID = NULL, preID = %d, dehashstatus = 1, isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~32)|32), searchname = %s, categoryID = %d WHERE ID = %d", $pre['ID'], $db->escapeString($pre['dirname']), $determinedcat, $row['ID'])); $total = count($result); if ( $total > 0) { diff --git a/test/prehash.php b/test/prehash.php index 667ac838e..016ee804e 100755 --- a/test/prehash.php +++ b/test/prehash.php @@ -840,7 +840,7 @@ Class Predb $tq = ""; if ($time == 1) - $tq = " and r.adddate > (now() - interval 3 hour)"; + $tq = $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releaseID, rf.size DESC'; $ct = ""; if ($cats == 1) $ct = " and r.categoryID in (2020, 5050, 6070, 8010)"; @@ -852,11 +852,19 @@ Class Predb $te = " in the past 3 hours"; echo $this->c->header ("Fixing search names".$te." using the prehash md5."); } - $regex = "AND ((r.bitwise & 512) = 512 OR rf.name REGEXP'[a-fA-F0-9]{32}')"; - $res = $db->queryDirect(sprintf('SELECT r.ID AS releaseID, r.name, r.searchname, r.categoryID, r.groupID, ' + $regex = "AND ((r.ishashed = 1 OR rf.name REGEXP'[a-fA-F0-9]{32}')"; + if ($cats === 3) { + $query = sprintf('SELECT r.ID AS releaseID, r.name, r.searchname, r.categoryID, r.groupID, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN releasefiles rf ON r.ID = rf.releaseID ' - . 'WHERE (bitwise & 260) = 256 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq)); + . 'WHERE nzbstatus = 1 AND preID IS NULL %s', $regex); + } else { + $query = sprintf('SELECT r.ID AS releaseID, r.name, r.searchname, r.categoryID, r.groupID, ' + . 'dehashstatus, rf.name AS filename FROM releases r ' + . 'LEFT OUTER JOIN releasefiles rf ON r.ID = rf.releaseID ' + . 'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq); + } + $res = $db->queryDirect($query); $total = $res->rowCount(); echo $this->c->primary(number_format($total) . " releases to process."); if ($total > 0) { diff --git a/test/removeCrapReleases.php b/test/removeCrapReleases.php index c4407d2db..99916a8eb 100755 --- a/test/removeCrapReleases.php +++ b/test/removeCrapReleases.php @@ -78,7 +78,7 @@ if (isset($argv[1]) && $argv[1] == 'true') { { $type = "Gibberish"; $db = new DB(); - $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE searchname REGEXP '^[a-zA-Z0-9]{15,}$' AND nfostatus = 0 AND (bitwise & 1) = 1 AND rarinnerfilecount >= 0".$and); + $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE searchname REGEXP '^[a-zA-Z0-9]{15,}$' AND nfostatus = 0 AND iscategorized = 1 AND rarinnerfilecount >= 0".$and); $delcount = deleteReleases($sql, $type); return $delcount; } @@ -88,7 +88,7 @@ if (isset($argv[1]) && $argv[1] == 'true') { { $type = "Hashed"; $db = new DB(); - $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE searchname REGEXP '[a-zA-Z0-9]{25,}' AND nfostatus = 0 AND (bitwise & 1) = 1 AND rarinnerfilecount >= 0".$and); + $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE searchname REGEXP '[a-zA-Z0-9]{25,}' AND nfostatus = 0 AND iscategorized = 1 AND rarinnerfilecount >= 0".$and); $delcount = deleteReleases($sql, $type); return $delcount; } @@ -98,7 +98,7 @@ if (isset($argv[1]) && $argv[1] == 'true') { { $type = "Short"; $db = new DB(); - $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE searchname REGEXP '^[a-zA-Z0-9]{0,5}$' AND nfostatus = 0 AND (bitwise & 1) = 1 AND rarinnerfilecount >= 0".$and); + $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE searchname REGEXP '^[a-zA-Z0-9]{0,5}$' AND nfostatus = 0 AND iscategorized = 1 AND rarinnerfilecount >= 0".$and); $delcount = deleteReleases($sql, $type); return $delcount; } @@ -138,7 +138,7 @@ if (isset($argv[1]) && $argv[1] == 'true') { { $type = "Passworded"; $db = new DB(); - $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE ( searchname LIKE '%passworded%' OR searchname LIKE '%password protect%' OR searchname LIKE '%password%' OR searchname LIKE '%passwort%' OR searchname LIKE '%[pw]%' ) AND searchname NOT LIKE '%no password%' AND searchname NOT LIKE '%not passworded%' AND searchname NOT LIKE '%unlocker%' AND searchname NOT LIKE '%reset%' AND searchname NOT LIKE '%recovery%' AND searchname NOT LIKE '%keygen%' AND searchname NOT LIKE '%advanced%' AND (bitwise & 256) = 256 AND categoryID not in (4000, 4010, 4020, 4030, 4040, 4050, 4060, 4070)".$and); + $sql = $db->query("SELECT ID, guid, searchname FROM releases WHERE ( searchname LIKE '%passworded%' OR searchname LIKE '%password protect%' OR searchname LIKE '%password%' OR searchname LIKE '%passwort%' OR searchname LIKE '%[pw]%' ) AND searchname NOT LIKE '%no password%' AND searchname NOT LIKE '%not passworded%' AND searchname NOT LIKE '%unlocker%' AND searchname NOT LIKE '%reset%' AND searchname NOT LIKE '%recovery%' AND searchname NOT LIKE '%keygen%' AND searchname NOT LIKE '%advanced%' AND nzbstatus = 1 AND categoryID not in (4000, 4010, 4020, 4030, 4040, 4050, 4060, 4070)".$and); $delcount = deleteReleases($sql, $type); return $delcount; }