diff --git a/Blacklight/NNTP.php b/Blacklight/NNTP.php index c1219e1ff..e7ea2c3ca 100755 --- a/Blacklight/NNTP.php +++ b/Blacklight/NNTP.php @@ -103,6 +103,11 @@ class NNTP extends \Net_NNTP_Client protected Tmux $_tmux; + /** + * @var resource + */ + protected $_socket = null; + /** * Default constructor. */ @@ -118,6 +123,8 @@ class NNTP extends \Net_NNTP_Client $this->_currentServer = config('nntmux_nntp.server'); $this->_primaryNntpConnections = config('nntmux_nntp.main_nntp_connections'); $this->_alternateNntpConnections = config('nntmux_nntp.alternate_nntp_connections'); + $this->_selectedGroupSummary = null; + $this->_overviewFormatCache = null; } /** @@ -314,6 +321,7 @@ class NNTP extends \Net_NNTP_Client $this->_postingAllowed = false; $this->_selectedGroupSummary = null; $this->_overviewFormatCache = null; + $this->_socket = null; } /** @@ -333,14 +341,14 @@ class NNTP extends \Net_NNTP_Client /** * @param string $group Name of the group to select. - * @param bool $articles (optional) experimental! When true the article numbers is returned in 'articles'. + * @param mixed $articles (optional) experimental! When true the article numbers is returned in 'articles'. * @param bool $force Force a refresh to get updated data from the usenet server. * @return mixed On success : (array) Group information. * * @throws \Exception * On failure : (object) PEAR_Error. */ - public function selectGroup(string $group, bool $articles = false, bool $force = false) + public function selectGroup(string $group, mixed $articles = false, bool $force = false): mixed { $connected = $this->_checkConnection(false); if ($connected !== true) { @@ -365,7 +373,7 @@ class NNTP extends \Net_NNTP_Client * @throws \Exception * On failure : (object) PEAR_Error. */ - public function getOverview($range = null, $names = true, $forceNames = true) + public function getOverview($range = null, $names = true, $forceNames = true): mixed { $connected = $this->_checkConnection(); if ($connected !== true) { @@ -484,12 +492,12 @@ class NNTP extends \Net_NNTP_Client * * Returns a list of valid groups (that the client is permitted to select) and associated information. * - * @param string $wildMat (optional) http://tools.ietf.org/html/rfc3977#section-4 + * @param mixed $wildMat (optional) http://tools.ietf.org/html/rfc3977#section-4 * @return array|string Pear error on failure, array with groups on success. * * @throws \Exception */ - public function getGroups(?string $wildMat = null) + public function getGroups(mixed $wildMat = null): mixed { // Enabled header compression if not enabled. $this->_enableCompression(); @@ -1275,7 +1283,7 @@ class NNTP extends \Net_NNTP_Client * Connect to a NNTP server. * * @param string|null $host (optional) The address of the NNTP-server to connect to, defaults to 'localhost'. - * @param mixed $encryption (optional) Use TLS/SSL on the connection? + * @param mixed|null $encryption (optional) Use TLS/SSL on the connection? * (string) 'tcp' => Use no encryption. * 'ssl', 'sslv3', 'tls' => Use encryption. * (null)|(false) Use no encryption. @@ -1285,7 +1293,7 @@ class NNTP extends \Net_NNTP_Client * @return mixed (bool) On success: True when posting allowed, otherwise false. * (object) On failure: pear_error */ - public function connect(?string $host = null, $encryption = null, ?int $port = null, ?int $timeout = 15, int $socketTimeout = 120): mixed + public function connect(?string $host = null, mixed $encryption = null, ?int $port = null, ?int $timeout = 15, int $socketTimeout = 120): mixed { if ($this->_isConnected()) { return $this->throwError('Already connected, disconnect first!', null); @@ -1330,7 +1338,6 @@ class NNTP extends \Net_NNTP_Client $message .= ' Try disabling SSL/TLS, and/or try a different port.'; } $message .= ' [ERROR '.$errorNumber.': '.$errorString.']'; - $this->_logger?->notice($message); return $this->throwError($message); } @@ -1339,7 +1346,6 @@ class NNTP extends \Net_NNTP_Client $this->_socketTimeout = $socketTimeout ?: $this->_socketTimeout; // Set the socket timeout. stream_set_timeout($this->_socket, $this->_socketTimeout); - $this->_logger?->info("Connection to $transport://$host:$port has been established."); // Retrieve the server's initial response. $response = $this->_getStatusResponse(); if (self::isError($response)) { @@ -1351,7 +1357,6 @@ class NNTP extends \Net_NNTP_Client return true; // 201, Posting NOT allowed case NET_NNTP_PROTOCOL_RESPONSECODE_READY_POSTING_PROHIBITED: - $this->_logger?->info('Posting not allowed!'); return false; default: diff --git a/Blacklight/processing/PostProcess.php b/Blacklight/processing/PostProcess.php index 9f407165e..8e17cafba 100755 --- a/Blacklight/processing/PostProcess.php +++ b/Blacklight/processing/PostProcess.php @@ -59,7 +59,7 @@ class PostProcess $this->Nfo = new Nfo; // Site settings. - $this->addpar2 = config('nntmux:settings.add_par2'); + $this->addpar2 = config('nntmux_settings.add_par2'); $this->alternateNNTP = config('nntmux_nntp.use_alternate_nntp_server'); } diff --git a/composer.json b/composer.json index eb1087cec..66d2fda29 100644 --- a/composer.json +++ b/composer.json @@ -87,7 +87,7 @@ "mtownsend/xml-to-array": "^2.0", "nesbot/carbon": "^3.8", "opis/closure": "^3.6", - "pear/net_nntp": "^1.6.0", + "pear/net_nntp": "^2.0", "php-ffmpeg/php-ffmpeg": "^1.2", "php-http/guzzle7-adapter": "^1.0", "php-http/message": "^1.16", diff --git a/composer.lock b/composer.lock index c52dd6a26..accbbee4c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b77ae5efdf1ae2cb9f0cfcd5d1c12fc6", + "content-hash": "0ba181ec4daee5e458c7267cde49bda1", "packages": [ { "name": "aharen/omdbapi", @@ -6547,21 +6547,21 @@ }, { "name": "pear/net_nntp", - "version": "v1.6.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/DariusIII/Net_NNTP.git", - "reference": "f66697dd987137acef0ea7ad251375efb81bb2d2" + "reference": "d977a1967f9e065fe02268290816504e2b364990" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/DariusIII/Net_NNTP/zipball/f66697dd987137acef0ea7ad251375efb81bb2d2", - "reference": "f66697dd987137acef0ea7ad251375efb81bb2d2", + "url": "https://api.github.com/repos/DariusIII/Net_NNTP/zipball/d977a1967f9e065fe02268290816504e2b364990", + "reference": "d977a1967f9e065fe02268290816504e2b364990", "shasum": "" }, "require": { "pear/pear": "^1.4.5", - "php": ">=5.0" + "php": ">=8.2" }, "require-dev": { "phpunit/phpunit": "*" @@ -6591,7 +6591,7 @@ "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_NNTP", "source": "https://github.com/pear/Net_NNTP" }, - "time": "2022-02-05T23:35:21+00:00" + "time": "2024-11-03T11:06:55+00:00" }, { "name": "pear/pear", diff --git a/misc/update/tmux/run.php b/misc/update/tmux/run.php index 49e3a50ea..c0589b2da 100644 --- a/misc/update/tmux/run.php +++ b/misc/update/tmux/run.php @@ -1,158 +1,112 @@ delay time check -$colorCli->header('Resetting collections that have expired to this moment. This could take some time if many collections need to be reset'); + $colorCli->header('Resetting collections that have expired to this moment. This could take some time if many collections need to be reset'); -DB::transaction(function () use ($delaytime) { - Collection::query()->where('dateadded', '<', now()->subHours($delaytime))->update(['dateadded' => now()]); -}, 10); + DB::transaction(function () use ($delaytime) { + Collection::query()->where('dateadded', '<', now()->subHours($delaytime))->update(['dateadded' => now()]); + }, 10); -function command_exist($cmd): bool -{ - $returnVal = Process::run("which $cmd 2>/dev/null"); + function command_exist($cmd): bool + { + $returnVal = Process::run("which $cmd 2>/dev/null"); - return $returnVal->seeInOutput($cmd); -} + return $returnVal->seeInOutput($cmd); + } //check for apps -$apps = ['time', 'tmux', 'nice', 'tee']; -foreach ($apps as &$value) { - if (! command_exist($value)) { - $colorCli->error('Tmux scripts require '.$value.' but its not installed. Aborting.'); - exit(); - } -} - -unset($value); - -function start_apps($tmux_session): void -{ - $htop = Settings::settingValue('htop'); - $vnstat = Settings::settingValue('vnstat'); - $vnstat_args = Settings::settingValue('vnstat_args'); - $tcptrack = Settings::settingValue('tcptrack'); - $tcptrack_args = Settings::settingValue('tcptrack_args'); - $nmon = Settings::settingValue('nmon'); - $bwmng = Settings::settingValue('bwmng'); - $mytop = Settings::settingValue('mytop'); - $redis = Settings::settingValue('redis'); - $showprocesslist = Settings::settingValue('showprocesslist'); - $processupdate = Settings::settingValue('processupdate'); - $console_bash = Settings::settingValue('console'); - - if ((int) $htop === 1 && command_exist('htop')) { - Process::run("tmux new-window -t $tmux_session -n htop 'printf \"\033]2;htop\033\" && htop'"); + $apps = ['time', 'tmux', 'nice', 'tee']; + foreach ($apps as &$value) { + if (! command_exist($value)) { + $colorCli->error('Tmux scripts require '.$value.' but its not installed. Aborting.'); + exit(); + } } - if ((int) $nmon === 1 && command_exist('nmon')) { - Process::run("tmux new-window -t $tmux_session -n nmon 'printf \"\033]2;nmon\033\" && nmon -t'"); + unset($value); + + function start_apps($tmux_session): void + { + $processupdate = Settings::settingValue('site.tmux.processupdate'); + $console_bash = Settings::settingValue('site.tmux.console'); + + if ((int) $console_bash === 1) { + Process::run("tmux new-window -t $tmux_session -n bash 'printf \"\033]2;Bash\033\" && bash -i'"); + } } - if ((int) $vnstat === 1 && command_exist('vnstat')) { - Process::run("tmux new-window -t $tmux_session -n vnstat 'printf \"\033]2;vnstat\033\" && watch -n10 \"vnstat {$vnstat_args}\"'"); + function window_utilities($tmux_session) + { + Process::run("tmux new-window -t $tmux_session -n utils 'printf \"\033]2;fixReleaseNames\033\"'"); + Process::run("tmux splitw -t $tmux_session:1 -v -l 50% 'printf \"\033]2;updateTVandTheaters\033\"'"); + Process::run("tmux selectp -t $tmux_session:1.0; tmux splitw -t $tmux_session:1 -h -l 50% 'printf \"\033]2;removeCrapReleases\033\"'"); + Process::run("tmux selectp -t $tmux_session:1.2; tmux splitw -t $tmux_session:1 -h -l 50% 'printf \"\033]2;decryptHashes\033\"'"); } - if ((int) $tcptrack === 1 && command_exist('tcptrack')) { - Process::run("tmux new-window -t $tmux_session -n tcptrack 'printf \"\033]2;tcptrack\033\" && tcptrack {$tcptrack_args}'"); + function window_stripped_utilities($tmux_session) + { + Process::run("tmux new-window -t $tmux_session -n utils 'printf \"\033]2;updateTVandTheaters\033\"'"); + Process::run("tmux selectp -t $tmux_session:1.0; tmux splitw -t $tmux_session:1 -h -l 50% 'printf \"\033]2;postprocessing_amazon\033\"'"); } - if ((int) $bwmng === 1 && command_exist('bwm-ng')) { - Process::run("tmux new-window -t $tmux_session -n bwm-ng 'printf \"\033]2;bwm-ng\033\" && bwm-ng'"); + function window_ircscraper($tmux_session) + { + Process::run("tmux new-window -t $tmux_session -n IRCScraper 'printf \"\033]2;scrapeIRC\033\"'"); } - if ((int) $mytop === 1 && command_exist('mytop')) { - Process::run("tmux new-window -t $tmux_session -n mytop 'printf \"\033]2;mytop\033\" && mytop -u'"); + function window_post($tmux_session) + { + Process::run("tmux new-window -t $tmux_session -n post 'printf \"\033]2;postprocessing_additional\033\"'"); + Process::run("tmux splitw -t $tmux_session:2 -v -l 67% 'printf \"\033]2;postprocessing_non_amazon\033\"'"); + Process::run("tmux splitw -t $tmux_session:2 -v -l 50% 'printf \"\033]2;postprocessing_amazon\033\"'"); } - if ((int) $redis === 1 && command_exist('redis-cli')) { - Process::run("tmux new-window -t $tmux_session -n redis-stat 'printf \"\033]2;redis-stat\033\" && redis-stat --verbose --server=63790'"); + function attach($tmuxPath, $tmux_session): void + { + Process::run("tmux respawnp -t $tmux_session:0.0 'php ".$tmuxPath."monitor.php'"); + Process::run("tmux select-window -t $tmux_session:0; tmux attach-session -d -t $tmux_session"); } - if ((int) $showprocesslist === 1) { - Process::run("tmux new-window -t $tmux_session -n showprocesslist 'printf \"\033]2;showprocesslist\033\" && watch -n .5 \"mysql -e \\\"SELECT time, state, info FROM information_schema.processlist WHERE command != \\\\\\\"Sleep\\\\\\\" AND time >= $processupdate ORDER BY time DESC \\\G\\\"\"'"); - } - - if ((int) $console_bash === 1) { - Process::run("tmux new-window -t $tmux_session -n bash 'printf \"\033]2;Bash\033\" && bash -i'"); - } -} - -function window_utilities($tmux_session) -{ - Process::run("tmux new-window -t $tmux_session -n utils 'printf \"\033]2;fixReleaseNames\033\"'"); - Process::run("tmux splitw -t $tmux_session:1 -v -l 50% 'printf \"\033]2;updateTVandTheaters\033\"'"); - Process::run("tmux selectp -t $tmux_session:1.0; tmux splitw -t $tmux_session:1 -h -l 50% 'printf \"\033]2;removeCrapReleases\033\"'"); - Process::run("tmux selectp -t $tmux_session:1.2; tmux splitw -t $tmux_session:1 -h -l 50% 'printf \"\033]2;decryptHashes\033\"'"); -} - -function window_stripped_utilities($tmux_session) -{ - Process::run("tmux new-window -t $tmux_session -n utils 'printf \"\033]2;updateTVandTheaters\033\"'"); - Process::run("tmux selectp -t $tmux_session:1.0; tmux splitw -t $tmux_session:1 -h -l 50% 'printf \"\033]2;postprocessing_amazon\033\"'"); -} - -function window_ircscraper($tmux_session) -{ - Process::run("tmux new-window -t $tmux_session -n IRCScraper 'printf \"\033]2;scrapeIRC\033\"'"); -} - -function window_post($tmux_session) -{ - Process::run("tmux new-window -t $tmux_session -n post 'printf \"\033]2;postprocessing_additional\033\"'"); - Process::run("tmux splitw -t $tmux_session:2 -v -l 67% 'printf \"\033]2;postprocessing_non_amazon\033\"'"); - Process::run("tmux splitw -t $tmux_session:2 -v -l 50% 'printf \"\033]2;postprocessing_amazon\033\"'"); -} - -function attach($tmuxPath, $tmux_session): void -{ - Process::run("tmux respawnp -t $tmux_session:0.0 'php ".$tmuxPath."monitor.php'"); - Process::run("tmux select-window -t $tmux_session:0; tmux attach-session -d -t $tmux_session"); -} - //create tmux session -$tmuxConfig = $tmuxPath.'tmux.conf'; + $tmuxConfig = $tmuxPath.'tmux.conf'; -if ((int) $seq === 1) { - Process::run("cd {$tmuxPath}; tmux -f $tmuxConfig new-session -d -s $tmux_session -n Monitor 'printf \"\033]2;\"Monitor\"\033\"'"); - Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -h -l 67% 'printf \"\033]2;update_releases\033\"'"); - Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -v -l 25% 'printf \"\033]2;nzb-import\033\"'"); + if ((int) $seq === 1) { + Process::run("cd {$tmuxPath}; tmux -f $tmuxConfig new-session -d -s $tmux_session -n Monitor 'printf \"\033]2;\"Monitor\"\033\"'"); + Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -h -l 67% 'printf \"\033]2;update_releases\033\"'"); - window_utilities($tmux_session); - window_post($tmux_session); -} elseif ((int) $seq === 2) { - Process::run("cd {$tmuxPath}; tmux -f $tmuxConfig new-session -d -s $tmux_session -n Monitor 'printf \"\033]2;\"Monitor\"\033\"'"); - Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -h -l 67% 'printf \"\033]2;sequential\033\"'"); - Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -v -l 25% 'printf \"\033]2;nzb-import\033\"'"); + window_utilities($tmux_session); + window_post($tmux_session); + } elseif ((int) $seq === 2) { + Process::run("cd {$tmuxPath}; tmux -f $tmuxConfig new-session -d -s $tmux_session -n Monitor 'printf \"\033]2;\"Monitor\"\033\"'"); + Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -h -l 67% 'printf \"\033]2;sequential\033\"'"); + window_stripped_utilities($tmux_session); + } else { + Process::run("cd {$tmuxPath}; tmux -f $tmuxConfig new-session -d -s $tmux_session -n Monitor 'printf \"\033]2;Monitor\033\"'"); + Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -h -l 67% 'printf \"\033]2;update_binaries\033\"'"); + Process::run("tmux selectp -t $tmux_session:0.2; tmux splitw -t $tmux_session:0 -v -l 67% 'printf \"\033]2;backfill\033\"'"); + Process::run("tmux splitw -t $tmux_session -v -l 50% 'printf \"\033]2;update_releases\033\"'"); - window_stripped_utilities($tmux_session); -} else { - Process::run("cd {$tmuxPath}; tmux -f $tmuxConfig new-session -d -s $tmux_session -n Monitor 'printf \"\033]2;Monitor\033\"'"); - Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -h -l 67% 'printf \"\033]2;update_binaries\033\"'"); - Process::run("tmux selectp -t $tmux_session:0.0; tmux splitw -t $tmux_session:0 -v -l 25% 'printf \"\033]2;nzb-import\033\"'"); - Process::run("tmux selectp -t $tmux_session:0.2; tmux splitw -t $tmux_session:0 -v -l 67% 'printf \"\033]2;backfill\033\"'"); - Process::run("tmux splitw -t $tmux_session -v -l 50% 'printf \"\033]2;update_releases\033\"'"); - - window_utilities($tmux_session); - window_post($tmux_session); -} -window_ircscraper($tmux_session); -start_apps($tmux_session); -attach($tmuxPath, $tmux_session); + window_utilities($tmux_session); + window_post($tmux_session); + } + window_ircscraper($tmux_session); + start_apps($tmux_session); + attach($tmuxPath, $tmux_session);