diff --git a/bin/monitor.php b/bin/monitor.php index 4b0080f70..102b85697 100755 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -63,26 +63,18 @@ $_DB_HOST = getenv('DB_HOST'); $_DB_PASSWORD = escapeshellarg(getenv('DB_PASSWORD')); $_DB_NAME = getenv('DB_NAME'); - -function getFileCount($path) { - $size = 0; - $ignore = array('.','..','cgi-bin','.DS_STORE'); - $include = array('.nzb','.NZB'); - $files = scandir($path); - foreach($files as $t) { - if(in_array($t, $ignore)) continue; - if (is_dir(rtrim($path, '/') . '/' . $t)) { - $size += getFileCount(rtrim($path, '/') . '/' . $t); - } else { - foreach($include as $needle){ - if(strpos($t,$needle)!==false) { - $size++; - continue; - } - }//if(in_array($t,$include)) $size++; +function getFileCount($directory) { + $include = array('*.nzb','*.NZB'); + $filecount=0; + foreach (glob($directory . "*",GLOB_ONLYDIR) as $subDir){ + $filecount += getFileCount($subDir . "/"); + } + foreach($include as $fileEnd){ + if (glob($directory . $fileEnd) != false) { + $filecount += count(glob($directory . $fileEnd)); } } - return $size; + return $filecount; } $_nzbs_to_import_begin=getFileCount('/home/jonnyboy/nzbs/test/'); @@ -235,7 +227,7 @@ while($i>0) shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:1.0 'echo \"\033[1;31m\" && cd $NNPATH && $_php update_predb.php true && date && echo \"$_string\"' 2>&1 1> /dev/null"); $time2 = TIME(); } else { - shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:1.0 'echo \"\033[1;31m\\n\n\nThis pane runs update_predb.php and cycles every {$array['PREDB_TIMER']} seconds.\"'"); + shell_exec("$_tmux respawnp -t {$array['TMUX_SESSION']}:1.0 'echo \"\033[1;31m\\n\n\nThis pane runs update_predb.php and cycles every {$array['PREDB_TIMER']}/60 seconds.\"'"); } //run $_php update_parsing.php in 1.1 every 1 hour diff --git a/bin/nzb-import-sub.php b/bin/nzb-import-sub.php index c7d5d3ebc..438d80e3e 100755 --- a/bin/nzb-import-sub.php +++ b/bin/nzb-import-sub.php @@ -24,7 +24,14 @@ $ps->maxThreads = 20; $ps->threadTimeLimit = 0; $selected = $subdir_count-1; -echo "Starting threaded import process\n"; +$varnames = shell_exec("cat ../edit_these.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); +$vardata = shell_exec('cat ../edit_these.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); +$varnames = explode("\n", $varnames); +$vardata = explode("\n", $vardata); +$array = array_combine($varnames, $vardata); +unset($array['']); + +echo "Starting threaded import process, {$array['NZBCOUNT']} per thread\n"; while ($ps->RunControlCode()) { diff --git a/bin/nzb-import.php b/bin/nzb-import.php index de27a7ad9..c903c8101 100755 --- a/bin/nzb-import.php +++ b/bin/nzb-import.php @@ -131,7 +131,15 @@ if (!isset($groups) || count($groups) == 0) { echo ("imported " . $nzbFile . $strTerminator); flush(); } - if ($nzbCount == 100) { + + $varnames = shell_exec("cat ../edit_these.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); + $vardata = shell_exec('cat ../edit_these.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); + $varnames = explode("\n", $varnames); + $vardata = explode("\n", $vardata); + $array = array_combine($varnames, $vardata); + unset($array['']); + + if ($nzbCount == $array['NZBCOUNT']) { break; } } diff --git a/bin/nzb-importonenzb.php b/bin/nzb-importonenzb.php index ba135ab9c..faa919277 100755 --- a/bin/nzb-importonenzb.php +++ b/bin/nzb-importonenzb.php @@ -189,7 +189,16 @@ if ($using_cli || $page->isPostBack() ) $retval.= "imported ".$nzbFile.$strTerminator; } } - if ($nzbCount == 10) + + + $varnames = shell_exec("cat ../edit_these.sh | grep ^export | cut -d \= -f1 | awk '{print $2;}'"); + $vardata = shell_exec('cat ../edit_these.sh | grep ^export | cut -d \" -f2 | awk "{print $1;}"'); + $varnames = explode("\n", $varnames); + $vardata = explode("\n", $vardata); + $array = array_combine($varnames, $vardata); + unset($array['']); + + if ($nzbCount == $array['NZBCOUNT']) { break; } diff --git a/edit_these.sh b/edit_these.sh index 643e943e2..95c045dde 100755 --- a/edit_these.sh +++ b/edit_these.sh @@ -59,6 +59,9 @@ export NZBS="/path/to/nzbs" #and 10 nzbs will be imported from each subfolder per loop. export NZBMULTI="false" +#How many nzbs to import per loop, if using NZBMULTI="true" the per folder +export NZBCOUNT="10" + #Choose to run the threaded or non-threaded newznab scripts true/false #such as update_binaries.php or update_binaries_threaded.php export THREADS="true" diff --git a/images/newznab-tmux.png b/images/newznab-tmux.png index 70d1d7c44..3ef07adf7 100644 Binary files a/images/newznab-tmux.png and b/images/newznab-tmux.png differ