From 8aa37f79bd3ac9cb4e66577ef7e009de1397242a Mon Sep 17 00:00:00 2001 From: Darko Date: Fri, 21 Feb 2014 10:27:54 +0100 Subject: [PATCH] Optimized some scripts, dropped bitwise column, replaced stuff, removed optional NFO, EBBOK, MOVIE, MUSIC AND GAMES pp, those are now mandatory. --- bin/monitor.php | 76 +++++++++++------------ bin/scripts/check_vars.sh | 2 +- config.sh | 10 +-- test/db_updates/db_update_21_02_2014.sql | 17 ++++++ test/hash_decrypt.php | 2 +- test/namefixer.php | 77 ++++-------------------- test/nzbcontents.php | 4 +- test/predb_hash_decrypt.php | 2 +- 8 files changed, 78 insertions(+), 112 deletions(-) create mode 100644 test/db_updates/db_update_21_02_2014.sql diff --git a/bin/monitor.php b/bin/monitor.php index a8fba73f4..85a908d36 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.3r718"; +$version="0.3r720"; $db = new DB(); $functions = new Functions(); @@ -29,24 +29,24 @@ $proc = "SELECT ( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID BETWEEN 2000 AND 2999 AND imdbID IS NULL ) AS movies, ( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID BETWEEN 3000 AND 3999 AND musicinfoID IS NULL) AS audio, ( SELECT COUNT(*) FROM releases r USE INDEX(ix_releases_status), category c WHERE c.ID = r.categoryID AND c.parentID = 6000 AND r.passwordstatus BETWEEN -6 AND -1 AND r.haspreview = -1 AND c.disablepreview = 0) AS xxx, -( SELECT COUNT(*) FROM releases r USE INDEX(ix_releases_status) left join category c on c.ID = r.categoryID where (r.passwordstatus between -6 and -1) or (r.haspreview = -1 and c.disablepreview = 0)) AS pc, +( SELECT COUNT(*) FROM releases r USE INDEX(ix_releases_status) INNER JOIN category c on c.ID = r.categoryID WHERE (r.passwordstatus between -6 and -1) OR (r.haspreview = -1 and c.disablepreview = 0)) AS pc, ( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID BETWEEN 5000 AND 5999 AND rageID = -1) AS tv, ( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID = 7020 AND bookinfoID IS NULL ) AS book, ( SELECT COUNT(*) FROM releases r USE INDEX(ix_releases_status), category c WHERE c.ID = r.categoryID AND r.passwordstatus BETWEEN -6 AND -1 AND r.haspreview = -1 AND c.disablepreview = 0) AS work, ( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status)) AS releases, ( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE releasenfoID = 0) AS nforemains, ( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE releasenfoID not in (0, -1)) AS nfo, -( SELECT table_rows AS cnt FROM information_schema.TABLES where table_name = 'parts' AND TABLE_SCHEMA = '".DB_NAME."' ) AS parts, +( SELECT table_rows AS cnt FROM information_schema.TABLES WHERE table_name = 'parts' AND TABLE_SCHEMA = '".DB_NAME."' ) AS parts, ( SELECT COUNT(ID) FROM binaries WHERE procstat = 0 ) AS binaries, -( SELECT table_rows AS cnt FROM information_schema.TABLES where table_name = 'binaries' AND TABLE_SCHEMA = '".DB_NAME."' ) AS binaries_total, -( SELECT concat(round((data_length+index_length)/(1024*1024*1024),2),'GB') AS cnt FROM information_schema.tables where table_name = 'parts' AND TABLE_SCHEMA = '".DB_NAME."' ) AS partsize, -( SELECT concat(round((data_length+index_length)/(1024*1024*1024),2),'GB') AS cnt FROM information_schema.tables where table_name = 'binaries' AND TABLE_SCHEMA = '".DB_NAME."' ) AS binariessize, +( SELECT table_rows AS cnt FROM information_schema.TABLES WHERE table_name = 'binaries' AND TABLE_SCHEMA = '".DB_NAME."' ) AS binaries_total, +( SELECT concat(round((data_length+index_length)/(1024*1024*1024),2),'GB') AS cnt FROM information_schema.tables WHERE table_name = 'parts' AND TABLE_SCHEMA = '".DB_NAME."' ) AS partsize, +( SELECT concat(round((data_length+index_length)/(1024*1024*1024),2),'GB') AS cnt FROM information_schema.tables WHERE table_name = 'binaries' AND TABLE_SCHEMA = '".DB_NAME."' ) AS binariessize, ( SELECT COUNT( ID ) FROM groups WHERE active = 1 ) AS active_groups, ( SELECT COUNT( ID ) FROM groups WHERE name IS NOT NULL ) AS all_groups, ( SELECT COUNT( ID ) FROM groups WHERE first_record IS NOT NULL and `backfill_target` > 0 and first_record_postdate != '2000-00-00 00:00:00' < first_record_postdate) AS backfill_groups, ( SELECT UNIX_TIMESTAMP(adddate) from prehash order by adddate DESC limit 1 ) AS newestprehash, ( SELECT UNIX_TIMESTAMP(updatedate) from predb order by updatedate DESC limit 1 ) AS newestpredb, -( SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES where table_name = 'prehash' AND TABLE_SCHEMA = '".DB_NAME."' ) AS prehash, +( SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'prehash' AND TABLE_SCHEMA = '".DB_NAME."' ) AS prehash, ( SELECT name from releases order by adddate desc limit 1 ) AS newestaddname"; //$proc = "SELECT * FROM procCnt;"; $proc2 = "SELECT @@ -107,7 +107,7 @@ $old_session="{$array['TMUX_SESSION']}"; $getdate = gmDate("Ymd"); //build queries for shell -$_backfill_increment = "UPDATE groups set backfill_target=backfill_target+1 where active=1 and backfill_target<{$array['MAXDAYS']};"; +$_backfill_increment = "UPDATE groups set backfill_target=backfill_target+1 WHERE active=1 and backfill_target<{$array['MAXDAYS']};"; $mysql_command_1 = "$_mysql --defaults-file=$_conf/my.cnf -u$_DB_USER -h $_DB_HOST $_DB_NAME -e \"$_backfill_increment\""; $reset_bin = "UPDATE binaries SET procstat=0, procattempts=0, regexID=NULL, relpart=0, reltotalpart=0, relname=NULL;"; $mysql_command_2 = "$_mysql --defaults-file=$_conf/my.cnf -u$_DB_USER -h $_DB_HOST $_DB_NAME -e \"$reset_bin\""; @@ -1203,14 +1203,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs postprocess_nfo.php in pane 2.0 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $nfo_remaining_now > 0 ) && ( $array['NFOS'] != "false" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $nfo_remaining_now > 0 )) { $color = get_color(); $log = writelog($panes2[0]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.0 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes2[0] $ds2 && cd $_bin && $_php postprocess_nfo.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[0] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['NFOS'] == "false" ) { + } /*elseif ( $array['NFOS'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.0 'echo \"\033[38;5;\"$color\"m\n$panes2[0] Disabled by NFOS\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + }*/ elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.0 'echo \"\033[38;5;\"$color\"m\n$panes2[0] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $nfo_remaining_now == 0 ) { @@ -1219,14 +1219,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs postprocess_nfo1.php in pane 2.4 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $nfo_remaining_now >= 500 ) && ( $array['NFOS'] == "true" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $nfo_remaining_now >= 500 )) { $color = get_color(); $log = writelog($panes2[4]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.4 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes2[4] $ds2 && cd $_bin && $_php postprocess_nfo1.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[4] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['NFOS'] = "false" ) { + } /*elseif ( $array['NFOS'] = "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.4 'echo \"\033[38;5;\"$color\"m\n$panes2[4] Disabled by NFOS\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + } */elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.4 'echo \"\033[38;5;\"$color\"m\n$panes2[4] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $nfo_remaining_now == 0 ) { @@ -1235,14 +1235,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processGames.php in pane 2.1 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $console_releases_proc > 0 ) && ( $array['GAMES'] != "false" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $console_releases_proc > 0 )) { $color = get_color(); $log = writelog($panes2[1]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.1 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes2[1] $ds2 && cd $_bin && $_php processGames.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[1] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['GAMES'] == "false" ) { + }/* elseif ( $array['GAMES'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.1 'echo \"\033[38;5;\"$color\"m\n$panes2[1] Disabled by GAMES\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + } */elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.1 'echo \"\033[38;5;\"$color\"m\n$panes2[1] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $console_releases_proc == 0 ) { @@ -1251,14 +1251,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processGames1.php in pane 2.5 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $console_releases_proc >= 200 ) && ( $array['GAMES'] == "true" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $console_releases_proc >= 200 )) { $color = get_color(); $log = writelog($panes2[5]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.5 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes2[5] $ds2 && cd $_bin && $_php processGames1.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[5] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['GAMES'] == "false" ) { + } /*elseif ( $array['GAMES'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.5 'echo \"\033[38;5;\"$color\"m\n$panes2[5] Disabled by GAMES\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + } */elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.5 'echo \"\033[38;5;\"$color\"m\n$panes2[5] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $console_releases_proc == 0 ) { @@ -1267,14 +1267,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processMovies.php in pane 2.2 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $movie_releases_proc > 0 ) && ( $array['MOVIES'] != "false" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $movie_releases_proc > 0 )) { $color = get_color(); $log = writelog($panes2[2]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.2 'echo \"\033[38;5;\"$color\"\" && $ds1 $panes2[2] $ds2 && cd $_bin && $_php processMovies.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[2] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['MOVIES'] == "false" ) { + }/* elseif ( $array['MOVIES'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.2 'echo \"\033[38;5;\"$color\"m\n$panes2[2] Disabled by MOVIES\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + }*/ elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.2 'echo \"\033[38;5;\"$color\"m\n$panes2[2] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $movie_releases_proc == 0 ) { @@ -1283,14 +1283,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processMovies1.php in pane 2.6 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $movie_releases_proc >= 200 ) && ( $array['MOVIES'] == "true" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $movie_releases_proc >= 200 )) { $color = get_color(); $log = writelog($panes2[6]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.6 'echo \"\033[38;5;\"$color\"\" && $ds1 $panes2[6] $ds2 && cd $_bin && $_php processMovies1.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[6] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['MOVIES'] == "false" ) { + }/*elseif ( $array['MOVIES'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.6 'echo \"\033[38;5;\"$color\"m\n$panes2[6] Disabled by MOVIES\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + }*/elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.6 'echo \"\033[38;5;\"$color\"m\n$panes2[6] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $movie_releases_proc == 0 ) { @@ -1299,14 +1299,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processMusic.php in pane 2.3 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $music_releases_proc > 0 ) && ( $array['MUSIC'] != "false" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $music_releases_proc > 0 )) { $color = get_color(); $log = writelog($panes2[3]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.3 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes2[3] $ds2 && cd $_bin && $_php processMusic.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[3] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['MUSIC'] == "false" ) { + }/* elseif ( $array['MUSIC'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.3 'echo \"\033[38;5;\"$color\"m\n$panes2[3] Disabled by MUSIC\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + }*/ elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.3 'echo \"\033[38;5;\"$color\"m\n$panes2[3] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $music_releases_proc == 0 ) { @@ -1315,14 +1315,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processMusic1.php in pane 2.7 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $music_releases_proc >= 200 ) && ( $array['MUSIC'] == "true" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $music_releases_proc >= 200 )) { $color = get_color(); $log = writelog($panes2[7]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.7 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes2[7] $ds2 && cd $_bin && $_php processMusic1.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes2[7] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['MUSIC'] == "false" ) { + }/* elseif ( $array['MUSIC'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.7 'echo \"\033[38;5;\"$color\"m\n$panes2[7] Disabled by MUSIC\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + }*/ elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:2.7 'echo \"\033[38;5;\"$color\"m\n$panes2[7] Disabled by MAX_LOAD\"' 2>&1 1> /dev/null"); } elseif ( $music_releases_proc == 0 ) { @@ -1397,14 +1397,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processBooks.php in pane 3.2 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $book_releases_proc > 0 ) && ( $array['EBOOK'] != "false" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $book_releases_proc > 0 )) { $color = get_color(); $log = writelog($panes3[2]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:3.2 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes3[2] $ds2 && cd $_bin && $_php processBooks.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes3[2] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['EBOOK'] == "false" ) { + }/* elseif ( $array['EBOOK'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:3.2 'echo \"\033[38;5;\"$color\"m\n$panes3[2] Disabled by EBOOK\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + }*/ elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:3.2 'echo \"\033[38;5;\"$color\"m\n$panes3[2] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $book_releases_proc == 0 ) { @@ -1413,14 +1413,14 @@ $usptotalconnections = str_replace("\n", '', shell_exec("ss -n | grep -c " . $i } //runs processBooks.php in pane 3.6 once if needed then exits - if (( $array['MAX_LOAD'] >= get_load()) && ( $book_releases_proc >=200 ) && ( $array['EBOOK'] == "true" )) { + if (( $array['MAX_LOAD'] >= get_load()) && ( $book_releases_proc >=200 )) { $color = get_color(); $log = writelog($panes3[6]); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:3.6 'echo \"\033[38;5;\"$color\"m\" && $ds1 $panes3[6] $ds2 && cd $_bin && $_php processBooks1.php 2>&1 $log && echo \" \033[1;0;33m\" && $ds1 $panes3[6] $ds3' 2>&1 1> /dev/null"); - } elseif ( $array['EBOOK'] == "false" ) { + }/* elseif ( $array['EBOOK'] == "false" ) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:3.6 'echo \"\033[38;5;\"$color\"m\n$panes3[6] Disabled by EBOOK\" && date +\"%D %T\"' 2>&1 1> /dev/null"); - } elseif ( $array['MAX_LOAD'] <= get_load()) { + }*/ elseif ( $array['MAX_LOAD'] <= get_load()) { $color = get_color(); shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:3.6 'echo \"\033[38;5;\"$color\"m\n$panes3[6] Disabled by MAX_LOAD\" && date +\"%D %T\"' 2>&1 1> /dev/null"); } elseif ( $book_releases_proc == 0 ) { diff --git a/bin/scripts/check_vars.sh b/bin/scripts/check_vars.sh index e349d8ea4..4e1aa36a0 100755 --- a/bin/scripts/check_vars.sh +++ b/bin/scripts/check_vars.sh @@ -11,7 +11,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" source defaults.sh -for vars in RUNNING NFOS GAMES MOVIES MUSIC EBOOK TVRAGE OTHERS UNWANTED KEEP_KILLED SEQUENTIAL BINARIES BINARIES_THREADS BACKFILL BACKFILL_THREADS KEVIN_SAFER KEVIN_BACKFILL_PARTS KEVIN_THREADED IMPORT NZB_THREADS IMPORT_TRUE MISC_ONLY RELEASES FIXRELEASES PREDBHASH REQID REMOVECRAP UPPRE PREDB SPOTNAB TV_SCHEDULE SPHINX DELETE_PARTS FIX_POSIX USE_HTOP USE_BWMNG USE_MYTOP USE_ATOP USE_NMON USE_IOTOP USE_VNSTAT USE_TCPTRACK USE_TOP USE_IFTOP USE_CONSOLE POWERLINE RAMDISK CHOWN_TRUE WRITE_LOGS +for vars in RUNNING TVRAGE OTHERS UNWANTED KEEP_KILLED SEQUENTIAL BINARIES BINARIES_THREADS BACKFILL BACKFILL_THREADS KEVIN_SAFER KEVIN_BACKFILL_PARTS KEVIN_THREADED IMPORT NZB_THREADS IMPORT_TRUE MISC_ONLY RELEASES FIXRELEASES PREDBHASH REQID REMOVECRAP UPPRE PREDB SPOTNAB TV_SCHEDULE SPHINX DELETE_PARTS FIX_POSIX USE_HTOP USE_BWMNG USE_MYTOP USE_ATOP USE_NMON USE_IOTOP USE_VNSTAT USE_TCPTRACK USE_TOP USE_IFTOP USE_CONSOLE POWERLINE RAMDISK CHOWN_TRUE WRITE_LOGS do #echo $vars=\"${!vars}\" if [[ ${!vars} != "true" && ${!vars} != "false" ]]; then diff --git a/config.sh b/config.sh index 9b36eee97..70aa75997 100644 --- a/config.sh +++ b/config.sh @@ -42,19 +42,19 @@ export ADMIN_PATH=$NEWZPATH"/www/admin" #post processing per category #this now takes true or false. #run processNfos -export NFOS="false" +#export NFOS="false" #run processGames -export GAMES="false" +#export GAMES="false" #run processMovies -export MOVIES="false" +#export MOVIES="false" #run processMusic -export MUSIC="false" +#export MUSIC="false" #run processEbook -export EBOOK="false" +#export EBOOK="false" #these are true/false #run processTV diff --git a/test/db_updates/db_update_21_02_2014.sql b/test/db_updates/db_update_21_02_2014.sql new file mode 100644 index 000000000..a90c17bc2 --- /dev/null +++ b/test/db_updates/db_update_21_02_2014.sql @@ -0,0 +1,17 @@ +ALTER TABLE `releases` + DROP INDEX ix_releases_status, + CHANGE COLUMN `nzbstatus` `nzbstatus` BIT NOT NULL DEFAULT 0, + CHANGE COLUMN `iscategorized` `iscategorized` BIT NOT NULL DEFAULT 0, + CHANGE COLUMN `isrenamed` `isrenamed` BIT NOT NULL DEFAULT 0, + CHANGE COLUMN `ishashed` `ishashed` BIT NOT NULL DEFAULT 0, + CHANGE COLUMN `isrequestid` `isrequestid` BIT NOT NULL DEFAULT 0, + ADD COLUMN `proc_par2` BIT NOT NULL DEFAULT 0, + ADD COLUMN `proc_nfo` BIT NOT NULL DEFAULT 0, + ADD COLUMN `proc_files` BIT NOT NULL DEFAULT 0, + ADD INDEX ix_releases_status (iscategorized, isrenamed, nfostatus, ishashed, passwordstatus, dehashstatus, reqidstatus, musicinfoID, consoleinfoID, bookinfoID, haspreview, categoryID, imdbID, rageID); + +UPDATE releases SET proc_par2 = 1 WHERE (bitwise & 32) = 32; +UPDATE releases SET proc_nfo = 1 WHERE (bitwise & 64) = 64; +UPDATE releases SET proc_files = 1 WHERE (bitwise & 128) = 128; +ALTER TABLE `releases` DROP COLUMN `bitwise`; + diff --git a/test/hash_decrypt.php b/test/hash_decrypt.php index 2f82e9c21..9ad32ce2e 100755 --- a/test/hash_decrypt.php +++ b/test/hash_decrypt.php @@ -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, isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~32)|32), 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, 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/namefixer.php b/test/namefixer.php index 584beda71..294aa00fd 100644 --- a/test/namefixer.php +++ b/test/namefixer.php @@ -11,58 +11,6 @@ require_once("consoletools.php"); //This script is ported from nZEDb and adapted for newznab -/* 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+)/"; @@ -110,7 +58,7 @@ class Namefixer } else { $query = "SELECT rel.ID AS releaseID FROM releases rel " . "INNER JOIN releasenfo nfo ON (nfo.releaseID = rel.ID) " - . "WHERE (isrenamed = 0 OR rel.categoryID = 8010) AND (bitwise & 64) = 0"; + . "WHERE (isrenamed = 0 OR rel.categoryID = 8010) AND proc_nfo = 0"; } //24 hours, other cats @@ -138,7 +86,7 @@ class Namefixer //ignore encrypted nfos if (preg_match('/^=newz\[NZB\]=\w+/', $relrow['textstring'])) { - $db->query(sprintf("UPDATE releases SET bitwise = ((bitwise & ~64)|64) WHERE ID = %d", $relrow['rel.ID'])); + $db->query(sprintf("UPDATE releases SET proc_nfo = 1 WHERE ID = %d", $relrow['rel.ID'])); $this->checked++; } else { $this->done = $this->matched = false; @@ -188,7 +136,7 @@ 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 (isrenamed = 0 OR rel.categoryID = 8010) AND (bitwise & 128) = 0"; + . "WHERE (isrenamed = 0 OR rel.categoryID = 8010) AND proc_files = 0"; } //24 hours, other cats @@ -246,7 +194,7 @@ class Namefixer $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 (isrenamed = 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 proc_par2 = 0"; } //24 hours, other cats @@ -357,11 +305,11 @@ class Namefixer $db = new DB(); if ($namestatus == 1) { if ($type == "NFO, ") { - $status = "isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~64)|64),"; + $status = "isrenamed = 1, iscategorized = 1, proc_nfo = 1,"; } else if ($type == "PAR2, ") { - $status = "isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~32)|32),"; + $status = "isrenamed = 1, iscategorized = 1, proc_par2 = 1,"; } else if ($type == "Filenames, ") { - $status = "isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~128)|128),"; + $status = "isrenamed = 1, iscategorized = 1, proc_files = 1,"; } $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, isrenamed = 1," @@ -467,22 +415,23 @@ class Namefixer $this->gameCheck($release, $echo, $type, $namestatus, $show); $this->appCheck($release, $echo, $type, $namestatus, $show); } - // The release didn't match so set relnamestatus to 20 so it doesn't get rechecked. Also allows removeCrapReleases to run extra things on the release. + // The release didn't match so set proc_nfo = 1 so it doesn't get rechecked. Also allows removeCrapReleases to run extra things on the release. if ($namestatus == 1 && $this->matched === false && $type == "NFO, ") { $db = new Db; - $db->exec(sprintf("UPDATE releases SET bitwise = ((bitwise & ~64)|64) WHERE ID = %d", $release['releaseID'])); + $db->exec(sprintf("UPDATE releases SET proc_nfo = 1 WHERE ID = %d", $release['releaseID'])); } - // The release didn't match so set relnamestatus to 21 so it doesn't get rechecked. Also allows removeCrapReleases to run extra things on the release. + // The release didn't match so set proc_files = 1 so it doesn't get rechecked. Also allows removeCrapReleases to run extra things on the release. elseif ($namestatus == 1 && $this->matched === false && $type == "Filenames, ") { $db = new DB(); - $db->exec(sprintf("UPDATE releases SET bitwise = ((bitwise & ~128)|128) WHERE ID = %d", $release["releaseID"])); + $db->exec(sprintf("UPDATE releases SET proc_files = 1 WHERE ID = %d", $release["releaseID"])); } + // The release didn't match so set proc_par2 = 1 so it doesn't get rechecked. Also allows removeCrapReleases to run extra things on the release. elseif ($namestatus == 1 && $this->matched === false && $type == "PAR2, ") { $db = new DB(); - $db->exec(sprintf("UPDATE releases SET bitwise = ((bitwise & ~32)|32) WHERE ID = %d", $release["releaseID"])); + $db->exec(sprintf("UPDATE releases SET proc_par2 = 1 WHERE ID = %d", $release["releaseID"])); } } // diff --git a/test/nzbcontents.php b/test/nzbcontents.php index 4843bd823..97c602bcc 100644 --- a/test/nzbcontents.php +++ b/test/nzbcontents.php @@ -75,14 +75,14 @@ Class NZBcontents $pp = new Functions(); if (($pp->parsePAR2($nzbcontents->segments->segment, $relID, $groupID, $nntp, $show)) === true && $namestatus === 1) { - $db->exec(sprintf('UPDATE releases SET bitwise = ((bitwise & ~32)|32) WHERE ID = %d', $relID)); + $db->exec(sprintf('UPDATE releases SET proc_par2 = 1 WHERE ID = %d', $relID)); return true; } } } } if ($namestatus === 1) - $db->exec(sprintf('UPDATE releases SET bitwise = ((bitwise & ~32)|32) WHERE ID = %d', $relID)); + $db->exec(sprintf('UPDATE releases SET proc_par2 = 1 WHERE ID = %d', $relID)); return false; } diff --git a/test/predb_hash_decrypt.php b/test/predb_hash_decrypt.php index f930eda24..0a9a7525b 100644 --- a/test/predb_hash_decrypt.php +++ b/test/predb_hash_decrypt.php @@ -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, isrenamed = 1, iscategorized = 1, bitwise = ((bitwise & ~32)|32), 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, searchname = %s, categoryID = %d WHERE ID = %d", $pre['ID'], $db->escapeString($pre['dirname']), $determinedcat, $row['ID'])); $total = count($result); if ( $total > 0) {