Skip to content

Commit

Permalink
Add config/nntmux_nntp.php and use the config in NNTP class
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Jan 25, 2019
1 parent 70dece5 commit 0e49c06
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
32 changes: 16 additions & 16 deletions Blacklight/NNTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function __destruct()
*/
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;
}

Expand All @@ -156,19 +156,19 @@ public function doConnect($compression = true, $alternate = false)

// 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)');
Expand Down Expand Up @@ -561,7 +561,7 @@ public function getMessages($groupName, $identifiers, $alternate = false)
} 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) {
Expand Down Expand Up @@ -1191,13 +1191,13 @@ protected function _checkConnection($reSelectGroup = true)
$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);
}
Expand Down
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 16 additions & 0 deletions config/nntmux_nntp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return [
'server' => 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),
];

0 comments on commit 0e49c06

Please sign in to comment.