From 5a762f506657ebf365f2681c3a194178286e770c Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Wed, 23 Jul 2014 19:05:16 +0400 Subject: [PATCH] Small fixes --- .../app/libraries/MailSo/Imap/ImapClient.php | 2 +- .../0.0.0/app/libraries/MailSo/Log/Logger.php | 31 +++++++++++++++++-- .../app/libraries/MailSo/Net/NetClient.php | 6 ++++ .../app/libraries/MailSo/Pop3/Pop3Client.php | 2 +- .../MailSo/Poppassd/PoppassdClient.php | 2 +- .../app/libraries/MailSo/Smtp/SmtpClient.php | 2 +- .../0.0.0/app/libraries/RainLoop/Actions.php | 29 ++++++++++------- .../libraries/RainLoop/Config/Application.php | 7 +++-- 8 files changed, 61 insertions(+), 20 deletions(-) diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index 19e8c729d..ae9210c08 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -1594,7 +1594,7 @@ class ImapClient extends \MailSo\Net\NetClient $aResult = $aParams; if (\is_array($aResult) && 2 === count($aResult)) { - $aResult[1] = '"*******"'; + $aResult[1] = '"********"'; } break; } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php index c0ce34fe2..e7533e518 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Log/Logger.php @@ -23,6 +23,11 @@ class Logger extends \MailSo\Base\Collection */ private $aSecretWords; + /** + * @var bool + */ + private $bShowSecter; + /** * @access protected */ @@ -33,6 +38,7 @@ class Logger extends \MailSo\Base\Collection $this->bUsed = false; $this->aForbiddenTypes = array(); $this->aSecretWords = array(); + $this->bShowSecter = false; \register_shutdown_function(array(&$this, '__loggerShutDown')); } @@ -87,6 +93,7 @@ class Logger extends \MailSo\Base\Collection /** * @param string $sWord + * * @return bool */ public function AddSecret($sWord) @@ -94,10 +101,30 @@ class Logger extends \MailSo\Base\Collection if (0 < \strlen(\trim($sWord))) { $this->aSecretWords[] = $sWord; - $this->aSecretWords = array_unique($this->aSecretWords); + $this->aSecretWords = \array_unique($this->aSecretWords); } } + /** + * @param bool $bShow + * + * @return \MailSo\Log\Logger + */ + public function SetShowSecter($bShow) + { + $this->bShowSecter = !!$bShow; + + return $this; + } + + /** + * @return bool + */ + public function IsShowSecter() + { + return $this->bShowSecter; + } + /** * @param int $iType * @@ -176,7 +203,7 @@ class Logger extends \MailSo\Base\Collection $aLoggers = array(); $iResult = 1; - if ($bSearchWords && 0 < \count($this->aSecretWords)) + if ($bSearchWords && !$this->bShowSecter && 0 < \count($this->aSecretWords)) { $sDesc = \str_replace($this->aSecretWords, '*******', $sDesc); } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Net/NetClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Net/NetClient.php index 6309ff9dd..bcb67ff7e 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Net/NetClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Net/NetClient.php @@ -334,6 +334,12 @@ abstract class NetClient $bFake = 0 < \strlen($sFakeRaw); $sRaw .= "\r\n"; + + if ($this->oLogger && $this->oLogger->IsShowSecter()) + { + $bFake = false; + } + if ($bFake) { $sFakeRaw .= "\r\n"; diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Pop3/Pop3Client.php b/rainloop/v/0.0.0/app/libraries/MailSo/Pop3/Pop3Client.php index 66a9966bf..85a722bc1 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Pop3/Pop3Client.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Pop3/Pop3Client.php @@ -256,7 +256,7 @@ class Pop3Client extends \MailSo\Net\NetClient switch ($sCommand) { case 'PASS': - $sResult = '*******'; + $sResult = '********'; break; } } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Poppassd/PoppassdClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Poppassd/PoppassdClient.php index 7a259eb09..b09bb16f8 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Poppassd/PoppassdClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Poppassd/PoppassdClient.php @@ -155,7 +155,7 @@ class PoppassdClient extends \MailSo\Net\NetClient { case 'pass': case 'newpass': - $sResult = '*******'; + $sResult = '********'; break; } } diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php index 174e9ffb8..ecd419394 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Smtp/SmtpClient.php @@ -570,7 +570,7 @@ class SmtpClient extends \MailSo\Net\NetClient $sCommand = \trim($sCommand); $sRealCommand = $sCommand.(0 === \strlen($sAddToCommand) ? '' : ' '.$sAddToCommand); - $sFakeCommand = ($bSecureLog) ? '**********' : ''; + $sFakeCommand = ($bSecureLog) ? '********' : ''; $this->iRequestTime = \microtime(true); $this->sendRaw($sRealCommand, true, $sFakeCommand); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 938d87184..6ceb9bb25 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -336,7 +336,7 @@ class Actions if (false !== \strpos($sFileName, '{user:uid}')) { $sFileName = \str_replace('{user:uid}', - \base_convert(\sprintf('%u', \crc32(md5(\RainLoop\Utils::GetConnectionToken()))), 10, 32), + \base_convert(\sprintf('%u', \crc32(\md5(\RainLoop\Utils::GetConnectionToken()))), 10, 32), $sFileName ); } @@ -345,19 +345,22 @@ class Actions { $sFileName = \str_replace('{user:ip}', $this->Http()->GetClientIp(), $sFileName); } - - $this->ParseQueryAuthString(); - - $oAccount = $this->getAccountFromToken(false); - if ($oAccount) + + if (\preg_match('/\{user:(email|login|domain)\}/i', $sFileName)) { - $sEmail = $oAccount->Email(); - $sFileName = \str_replace('{user:email}', $sEmail, $sFileName); - $sFileName = \str_replace('{user:login}', \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail), $sFileName); - $sFileName = \str_replace('{user:domain}', \MailSo\Base\Utils::GetDomainFromEmail($sEmail), $sFileName); + $this->ParseQueryAuthString(); + + $oAccount = $this->getAccountFromToken(false); + if ($oAccount) + { + $sEmail = $oAccount->Email(); + $sFileName = \str_replace('{user:email}', $sEmail, $sFileName); + $sFileName = \str_replace('{user:login}', \MailSo\Base\Utils::GetAccountNameFromEmail($sEmail), $sFileName); + $sFileName = \str_replace('{user:domain}', \MailSo\Base\Utils::GetDomainFromEmail($sEmail), $sFileName); + } } - $sFileName = \preg_replace('/\{user:([^}]*)\}/', 'unknown', $sFileName); + $sFileName = \preg_replace('/\{user:([^}]*)\}/i', 'unknown', $sFileName); } if (false !== \strpos($sFileName, '{labs:')) @@ -369,7 +372,7 @@ class Actions $sFileName = \preg_replace('/\{labs:([^}]*)\}/', 'labs', $sFileName); } - if (0 === strlen($sFileName)) + if (0 === \strlen($sFileName)) { $sFileName = 'rainloop-log.txt'; } @@ -794,6 +797,8 @@ class Actions if (!!$this->Config()->Get('logs', 'enable', true)) { + $this->oLogger->SetShowSecter(!$this->Config()->Get('logs', 'hide_passwords', true)); + $sLogFileFullPath = \APP_PRIVATE_DATA.'logs/'.$this->compileLogFileName(); $sLogFileDir = \dirname($sLogFileFullPath); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 379c85ea0..721ed312e 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -140,6 +140,9 @@ Values: 'write_on_error_only' => array(false, 'Logs entire request only if error occured'), 'write_on_timeout_only' => array(0, 'Logs entire request only if request timeout (in seconds) occured.'), + + 'hide_passwords' => array(true, 'Required for development purposes only. +Disabling this option is not recommended.'), 'filename' => array('log-{date:Y-m-d}.txt', 'Log filename. @@ -151,9 +154,9 @@ Patterns: Detailed info: http://www.php.net/manual/en/function.date.php {user:email} - Replaced by user\'s email address If user is not logged in, value is set to "unknown" - {user:login} - Replaced by user\'s login + {user:login} - Replaced by user\'s login (the user part of an email) If user is not logged in, value is set to "unknown" - {user:domain} - Replaced by user\'s domain name + {user:domain} - Replaced by user\'s domain name (the domain part of an email) If user is not logged in, value is set to "unknown" {user:uid} - Replaced by user\'s UID regardless of account currently used {user:ip} - Replaced by user\'s IP address