From 0e49c06f6ab6c1e0c34f4fd52bb864910c865380 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 25 Jan 2019 09:05:00 +0100 Subject: [PATCH] Add config/nntmux_nntp.php and use the config in NNTP class --- Blacklight/NNTP.php | 32 ++++++++++++++++---------------- Changelog | 1 + config/nntmux_nntp.php | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 config/nntmux_nntp.php diff --git a/Blacklight/NNTP.php b/Blacklight/NNTP.php index 127adeb69..dce3b5652 100755 --- a/Blacklight/NNTP.php +++ b/Blacklight/NNTP.php @@ -146,7 +146,7 @@ class NNTP extends \Net_NNTP_Client */ public function doConnect($compression = true, $alternate = false) { - if ($this->_isConnected() && (($alternate && $this->_currentServer === env('NNTP_SERVER_A')) || (! $alternate && $this->_currentServer === env('NNTP_SERVER')))) { + if ($this->_isConnected() && (($alternate && $this->_currentServer === config('nntmux_nntp.alternate_server')) || (! $alternate && $this->_currentServer === config('nntmux_nntp.server')))) { return true; } @@ -156,19 +156,19 @@ class NNTP extends \Net_NNTP_Client // Set variables to connect based on if we are using the alternate provider or not. if (! $alternate) { - $sslEnabled = env('NNTP_SSLENABLED') ? true : false; - $this->_currentServer = env('NNTP_SERVER'); - $this->_currentPort = env('NNTP_PORT'); - $userName = env('NNTP_USERNAME'); - $password = env('NNTP_PASSWORD'); - $socketTimeout = ! empty(env('NNTP_SOCKET_TIMEOUT')) ? env('NNTP_SOCKET_TIMEOUT') : $this->_socketTimeout; + $sslEnabled = config('nntmux_nntp.ssl') ? true : false; + $this->_currentServer = config('nntmux_nntp.server'); + $this->_currentPort = config('nntmux_nntp.port'); + $userName = config('nntmux_nntp.username'); + $password = config('nntmux_nntp.password'); + $socketTimeout = ! empty(config('nntmux_nntp.socket_timeout')) ? config('nntmux_nntp.socket_timeout') : $this->_socketTimeout; } else { - $sslEnabled = env('NNTP_SSLENABLED_A') ? true : false; - $this->_currentServer = env('NNTP_SERVER_A'); - $this->_currentPort = env('NNTP_PORT_A'); - $userName = env('NNTP_USERNAME_A'); - $password = env('NNTP_PASSWORD_A'); - $socketTimeout = ! empty(env('NNTP_SOCKET_TIMEOUT_A')) ? env('NNTP_SOCKET_TIMEOUT_A') : $this->_socketTimeout; + $sslEnabled = config('nntmux_nntp.alternate_server_ssl') ? true : false; + $this->_currentServer = config('nntmux_nntp.alternate_server'); + $this->_currentPort = config('nntmux_nntp.alternate_server_port'); + $userName = config('nntmux_nntp.alternate_server_username'); + $password = config('nntmux_nntp.alternate_server_password'); + $socketTimeout = ! empty(config('nntmux_nntp.alternate_server_socket_timeout')) ? config('nntmux_nntp.alternate_server_socket_timeout') : $this->_socketTimeout; } $enc = ($sslEnabled ? ' (ssl)' : ' (non-ssl)'); @@ -561,7 +561,7 @@ class NNTP extends \Net_NNTP_Client } elseif ($alternate) { if (! $aConnected) { // Check if the current connected server is the alternate or not. - $aConnected = $this->_currentServer === env('NNTP_SERVER') ? $nntp->doConnect(true, true) : $nntp->doConnect(); + $aConnected = $this->_currentServer === config('nntmux_nntp.server') ? $nntp->doConnect(true, true) : $nntp->doConnect(); } // If we connected successfully to usenet try to download the article body. if ($aConnected === true) { @@ -1191,13 +1191,13 @@ class NNTP extends \Net_NNTP_Client $retVal = true; } else { switch ($this->_currentServer) { - case env('NNTP_SERVER'): + case config('nntmux_nntp.server'): if (\is_resource($this->_socket)) { $this->doQuit(true); } $retVal = $this->doConnect(); break; - case env('NNTP_SERVER_A'): + case config('nntmux_nntp.alternate_server'): if (\is_resource($this->_socket)) { $this->doQuit(true); } diff --git a/Changelog b/Changelog index ec50df377..f953c909f 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2019-01-25 DariusIII + * Chg: Add config/nntmux_nntp.php and use the config in NNTP class * Chg: Updated czproject/git-php (v3.16.1 => v3.16.2) 2019-01-24 DariusIII * Fix: Use inline string for settingValue in TmuxRun class diff --git a/config/nntmux_nntp.php b/config/nntmux_nntp.php new file mode 100644 index 000000000..9b5d844aa --- /dev/null +++ b/config/nntmux_nntp.php @@ -0,0 +1,16 @@ + env('NNTP_SERVER', ''), + 'alternate_server' => env('NNTP_SERVER_A', ''), + 'port' => env('NNTP_PORT', ''), + 'alternate_server_port' => env('NNTP_PORT_A', ''), + 'username' => env('NNTP_USERNAME', ''), + 'alternate_server_username' => env('NNTP_USERNAME_A', ''), + 'password' => env('NNTP_PASSWORD', ''), + 'alternate_server_password' => env('NNTP_PASSWORD_A', ''), + 'ssl' => env('NNTP_SSLENABLED', false), + 'alternate_server_ssl' => env('NNTP_SSLENABLED_A', false), + 'socket_timeout' => env('NNTP_SOCKET_TIMEOUT', 120), + 'alternate_server_socket_timeout' => env('NNTP_SOCKET_TIMEOUT_A', 120), +];