diff --git a/Changelog b/Changelog index 5dcdd78ca..046919bce 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-01-05 DariusIII + * Chg: Update ConsoleTools class and related scripts * Chg: Update Forking and postprocess.php * Chg: Update Movie class and add missing rtrating column to movieinfo table in mysql-ddl.sql * Chg: Update nntmux/AniDB class diff --git a/misc/testing/DB/populate_nzb_guid.php b/misc/testing/DB/populate_nzb_guid.php index 55d9fe793..6ce3365cf 100644 --- a/misc/testing/DB/populate_nzb_guid.php +++ b/misc/testing/DB/populate_nzb_guid.php @@ -26,7 +26,7 @@ if (isset($argv[1])) { function create_guids($live, $delete = false) { $pdo = new DB(); - $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); + $consoletools = new ConsoleTools(); $timestart = time(); $relcount = $deleted = $total = 0; diff --git a/misc/testing/DB/reset_postprocessing.php b/misc/testing/DB/reset_postprocessing.php index e5f54bd46..16cd948c0 100755 --- a/misc/testing/DB/reset_postprocessing.php +++ b/misc/testing/DB/reset_postprocessing.php @@ -9,7 +9,7 @@ use nntmux\ConsoleTools; $category = new Category(); $pdo = new DB(); -$consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); +$consoletools = new ConsoleTools(); $ran = false; if (isset($argv[1], $argv[2]) && $argv[1] === 'all' && $argv[2] === 'true') { diff --git a/misc/testing/DB/resetdb.php b/misc/testing/DB/resetdb.php index 2cab4f318..2173d12d1 100644 --- a/misc/testing/DB/resetdb.php +++ b/misc/testing/DB/resetdb.php @@ -33,7 +33,7 @@ $timestart = time(); $relcount = 0; $ri = new ReleaseImage(); $nzb = new NZB($pdo); -$consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); +$consoletools = new ConsoleTools(); $pdo->queryExec('UPDATE groups SET first_record = 0, first_record_postdate = NULL, last_record = 0, last_record_postdate = NULL, last_updated = NULL'); echo ColorCLI::primary('Reseting all groups completed.'); diff --git a/misc/testing/PostProc/check_previews.php b/misc/testing/PostProc/check_previews.php index 87a8674ee..2d66660a2 100644 --- a/misc/testing/PostProc/check_previews.php +++ b/misc/testing/PostProc/check_previews.php @@ -27,7 +27,7 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) { $releases = new Releases(['Settings' => $pdo]); $nzb = new NZB($pdo); $releaseImage = new ReleaseImage(); - $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); + $consoletools = new ConsoleTools(); $couldbe = $argv[1] === 'true' ? $couldbe = 'were ' : 'could be '; $limit = $counterfixed = 0; if (isset($argv[2]) && is_numeric($argv[2])) { diff --git a/misc/testing/Releases/recategorize.php b/misc/testing/Releases/recategorize.php index d8bbc558b..cafdc5993 100644 --- a/misc/testing/Releases/recategorize.php +++ b/misc/testing/Releases/recategorize.php @@ -55,7 +55,7 @@ function reCategorize($argv) } else { $chgcount = categorizeRelease('', $update, true); } - $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); + $consoletools = new ConsoleTools(); $time = $consoletools->convertTime(time() - $timestart); if ($update === true) { echo ColorCLI::header('Finished re-categorizing '.number_format($chgcount).' releases in '.$time.' , using the searchname.'.PHP_EOL); @@ -72,7 +72,7 @@ function categorizeRelease($where, $update = true, $echooutput = false) global $pdo; $cat = new Categorize(['Settings' => $pdo]); $pdo->log = new ColorCLI(); - $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); + $consoletools = new ConsoleTools(); $relcount = $chgcount = 0; echo ColorCLI::primary('SELECT id, searchname, fromname, groups_id, categories_id FROM releases '.$where); $resrel = $pdo->queryDirect('SELECT id, searchname, fromname, groups_id, categories_id FROM releases '.$where); diff --git a/misc/update/decrypt_hashes.php b/misc/update/decrypt_hashes.php index a50aa54c9..3ca906dad 100755 --- a/misc/update/decrypt_hashes.php +++ b/misc/update/decrypt_hashes.php @@ -27,7 +27,7 @@ function getPreName($argv) { global $pdo; $timestart = time(); - $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); + $consoletools = new ConsoleTools(); $namefixer = new NameFixer(['Settings' => $pdo, 'ConsoleTools' => $consoletools]); $res = false; diff --git a/misc/update/tmux/bin/postprocess_threaded.php b/misc/update/tmux/bin/postprocess_threaded.php deleted file mode 100644 index 58cd80704..000000000 --- a/misc/update/tmux/bin/postprocess_threaded.php +++ /dev/null @@ -1,44 +0,0 @@ -error('This script is not intended to be run manually, it is called from postprocess.php.')); -} - -$tmux = new Tmux; -$torun = $tmux->get()->post; - -$pieces = explode(' =+= ', $argv[1]); - -$postprocess = new PostProcess(['Echo' => true]); -if (isset($pieces[6])) { - // Create the connection here and pass - $nntp = new NNTP(); - if ($nntp->doConnect() === false) { - exit($c->error('Unable to connect to usenet.')); - } - - $postprocess->processAdditional($nntp, $argv[1]); - $nntp->doQuit(); -} elseif (isset($pieces[3])) { - // Create the connection here and pass - $nntp = new NNTP(); - if ($nntp->doConnect() === false) { - exit($c->error('Unable to connect to usenet.')); - } - - $postprocess->processNfos($argv[1], $nntp); - $nntp->doQuit(); -} elseif (isset($pieces[2])) { - $postprocess->processMovies($argv[1]); - echo '.'; -} elseif (isset($pieces[1])) { - $postprocess->processTv($argv[1]); -} diff --git a/misc/update/tmux/bin/update_groups.php b/misc/update/tmux/bin/update_groups.php index 8addbc32c..5f9ffd5cf 100644 --- a/misc/update/tmux/bin/update_groups.php +++ b/misc/update/tmux/bin/update_groups.php @@ -9,7 +9,7 @@ use nntmux\ConsoleTools; $start = time(); $pdo = new DB(); -$consoleTools = new ConsoleTools(['ColorCLI' => $pdo->log]); +$consoleTools = new ConsoleTools(); // Create the connection here and pass $nntp = new NNTP(['Settings' => $pdo]); diff --git a/nntmux/ConsoleTools.php b/nntmux/ConsoleTools.php index e8aa2e15d..1070c6da0 100755 --- a/nntmux/ConsoleTools.php +++ b/nntmux/ConsoleTools.php @@ -8,7 +8,7 @@ namespace nntmux; class ConsoleTools { /** - * @var ColorCLI + * @var \nntmux\ColorCLI */ public $cli; @@ -18,19 +18,10 @@ class ConsoleTools public $lastMessageLength; /** - * Construct. - * - * @param array $options + * ConsoleTools constructor. */ - public function __construct(array $options = []) + public function __construct() { - $defaults = [ - 'ColorCLI' => null, - ]; - $options += $defaults; - - $this->cli = ($options['ColorCLI'] instanceof ColorCLI ? $options['ColorCLI'] : new ColorCLI()); - $this->lastMessageLength = 0; } @@ -44,11 +35,11 @@ class ConsoleTools $this->lastMessageLength = 0; } - echo str_repeat(chr(8), $this->lastMessageLength); + echo str_repeat(\chr(8), $this->lastMessageLength); echo str_repeat(' ', $this->lastMessageLength); - echo str_repeat(chr(8), $this->lastMessageLength); + echo str_repeat(\chr(8), $this->lastMessageLength); - $this->lastMessageLength = strlen($message); + $this->lastMessageLength = \strlen($message); echo ColorCLI::headerOver($message); } @@ -62,11 +53,11 @@ class ConsoleTools $this->lastMessageLength = 0; } - echo str_repeat(chr(8), $this->lastMessageLength); + echo str_repeat(\chr(8), $this->lastMessageLength); echo str_repeat(' ', $this->lastMessageLength); - echo str_repeat(chr(8), $this->lastMessageLength); + echo str_repeat(\chr(8), $this->lastMessageLength); - $this->lastMessageLength = strlen($message); + $this->lastMessageLength = \strlen($message); echo ColorCLI::primaryOver($message); } @@ -80,11 +71,11 @@ class ConsoleTools $this->lastMessageLength = 0; } - echo str_repeat(chr(8), $this->lastMessageLength); + echo str_repeat(\chr(8), $this->lastMessageLength); echo str_repeat(' ', $this->lastMessageLength); - echo str_repeat(chr(8), $this->lastMessageLength); + echo str_repeat(\chr(8), $this->lastMessageLength); - $this->lastMessageLength = strlen($message); + $this->lastMessageLength = \strlen($message); echo $message; } @@ -94,7 +85,7 @@ class ConsoleTools public function appendWrite($message): void { echo $message; - $this->lastMessageLength += strlen($message); + $this->lastMessageLength += \strlen($message); } /** @@ -106,7 +97,7 @@ class ConsoleTools public function percentString($cur, $total): string { $percent = 100 * $cur / $total; - $formatString = '% '.strlen($total).'d/%d (% 2d%%)'; + $formatString = '% '.\strlen($total).'d/%d (% 2d%%)'; return sprintf($formatString, $cur, $total, $percent); } @@ -122,7 +113,7 @@ class ConsoleTools { $percent1 = 100 * ($first - 1) / $total; $percent2 = 100 * $last / $total; - $formatString = '% '.strlen($total).'d-% '.strlen($total).'d/%d (% 2d%%-% 3d%%)'; + $formatString = '% '.\strlen($total).'d-% '.\strlen($total).'d/%d (% 2d%%-% 3d%%)'; return sprintf($formatString, $first, $last, $total, $percent1, $percent2); } diff --git a/nntmux/NameFixer.php b/nntmux/NameFixer.php index 3b7e9572f..7e609d2d0 100755 --- a/nntmux/NameFixer.php +++ b/nntmux/NameFixer.php @@ -172,7 +172,7 @@ class NameFixer $this->fullall = ''; $this->_fileName = ''; $this->done = $this->matched = false; - $this->consoletools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools(['ColorCLI' => $this->pdo->log])); + $this->consoletools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools()); $this->category = ($options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => $this->pdo])); $this->text = ($options['Misc'] instanceof Utility ? $options['Misc'] : new Utility()); $this->_groups = ($options['Groups'] instanceof Groups ? $options['Groups'] : new Groups(['Settings' => $this->pdo])); diff --git a/nntmux/PreDb.php b/nntmux/PreDb.php index 4c50502b8..b6d53fa9c 100755 --- a/nntmux/PreDb.php +++ b/nntmux/PreDb.php @@ -67,7 +67,7 @@ class PreDb { $this->dateLimit = $dateLimit; - $consoleTools = new ConsoleTools(['ColorCLI' => $this->pdo->log]); + $consoleTools = new ConsoleTools(); $updated = 0; if ($this->echooutput) { diff --git a/nntmux/ReleaseRemover.php b/nntmux/ReleaseRemover.php index 1407ea3be..d890b7d76 100755 --- a/nntmux/ReleaseRemover.php +++ b/nntmux/ReleaseRemover.php @@ -133,7 +133,7 @@ class ReleaseRemover $options += $defaults; $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $this->consoleTools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools(['ColorCLI' => $this->pdo->log])); + $this->consoleTools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools()); $this->releases = ($options['Releases'] instanceof Releases ? $options['Releases'] : new Releases(['Settings' => $this->pdo])); $this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB($this->pdo)); $this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage()); diff --git a/nntmux/processing/ProcessReleases.php b/nntmux/processing/ProcessReleases.php index fe05e9c78..307626f38 100755 --- a/nntmux/processing/ProcessReleases.php +++ b/nntmux/processing/ProcessReleases.php @@ -138,7 +138,7 @@ class ProcessReleases $this->echoCLI = ($options['Echo'] && NN_ECHOCLI); $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); - $this->consoleTools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools(['ColorCLI' => $this->pdo->log])); + $this->consoleTools = ($options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools()); $this->groups = ($options['Groups'] instanceof Groups ? $options['Groups'] : new Groups(['Settings' => $this->pdo])); $this->nzb = ($options['NZB'] instanceof NZB ? $options['NZB'] : new NZB($this->pdo)); $this->releaseCleaning = ($options['ReleaseCleaning'] instanceof ReleaseCleaning ? $options['ReleaseCleaning'] : new ReleaseCleaning($this->pdo));