mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 04:22:15 +08:00
Inherit logger as Trait
This commit is contained in:
parent
b5b1d5f88a
commit
0a3effc6ba
27 changed files with 157 additions and 199 deletions
|
@ -113,8 +113,8 @@ trait Messages
|
||||||
if (FetchResponse::isValidImapResponse($oResponse)) {
|
if (FetchResponse::isValidImapResponse($oResponse)) {
|
||||||
if (FetchResponse::hasUidAndSize($oResponse)) {
|
if (FetchResponse::hasUidAndSize($oResponse)) {
|
||||||
yield new FetchResponse($oResponse);
|
yield new FetchResponse($oResponse);
|
||||||
} else if ($this->oLogger) {
|
} else {
|
||||||
$this->oLogger->Write('Skipped Imap Response! ['.$oResponse.']', \LOG_NOTICE);
|
$this->logWrite('Skipped Imap Response! ['.$oResponse.']', \LOG_NOTICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$sAuthzid = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
|
$sAuthzid = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
|
||||||
$this->sendRaw($SASL->authenticate($sLogin, $sPassword/*, $sAuthzid*/), true);
|
$this->sendRaw($SASL->authenticate($sLogin, $sPassword/*, $sAuthzid*/), true);
|
||||||
$sChallenge = $SASL->challenge($this->getResponseValue($this->getResponse(), Enumerations\ResponseType::CONTINUATION));
|
$sChallenge = $SASL->challenge($this->getResponseValue($this->getResponse(), Enumerations\ResponseType::CONTINUATION));
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sChallenge);
|
$this->logMask($sChallenge);
|
||||||
$this->sendRaw($sChallenge);
|
$this->sendRaw($sChallenge);
|
||||||
$oResponse = $this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
$SASL->verify($this->getResponseValue($oResponse));
|
$SASL->verify($this->getResponseValue($oResponse));
|
||||||
|
@ -162,16 +162,16 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
else if ('CRAM-MD5' === $type)
|
else if ('CRAM-MD5' === $type)
|
||||||
{
|
{
|
||||||
$sChallenge = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
|
$sChallenge = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
|
||||||
$this->oLogger->Write('challenge: '.\base64_decode($sChallenge));
|
$this->logWrite('challenge: '.\base64_decode($sChallenge));
|
||||||
$sAuth = $SASL->authenticate($sLogin, $sPassword, $sChallenge);
|
$sAuth = $SASL->authenticate($sLogin, $sPassword, $sChallenge);
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sAuth);
|
$this->logMask($sAuth);
|
||||||
$this->sendRaw($sAuth);
|
$this->sendRaw($sAuth);
|
||||||
$oResponse = $this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
}
|
}
|
||||||
else if ('PLAIN' === $type || 'OAUTHBEARER' === $type /*|| 'PLAIN-CLIENTTOKEN' === $type*/)
|
else if ('PLAIN' === $type || 'OAUTHBEARER' === $type /*|| 'PLAIN-CLIENTTOKEN' === $type*/)
|
||||||
{
|
{
|
||||||
$sAuth = $SASL->authenticate($sLogin, $sPassword);
|
$sAuth = $SASL->authenticate($sLogin, $sPassword);
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sAuth);
|
$this->logMask($sAuth);
|
||||||
if ($this->hasCapability('SASL-IR')) {
|
if ($this->hasCapability('SASL-IR')) {
|
||||||
$oResponse = $this->SendRequestGetResponse('AUTHENTICATE', array($type, $sAuth));
|
$oResponse = $this->SendRequestGetResponse('AUTHENTICATE', array($type, $sAuth));
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,8 +187,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$oR = $oResponse->getLast();
|
$oR = $oResponse->getLast();
|
||||||
if ($oR && Enumerations\ResponseType::CONTINUATION === $oR->ResponseType) {
|
if ($oR && Enumerations\ResponseType::CONTINUATION === $oR->ResponseType) {
|
||||||
if (!empty($oR->ResponseList[1]) && preg_match('/^[a-zA-Z0-9=+\/]+$/', $oR->ResponseList[1])) {
|
if (!empty($oR->ResponseList[1]) && preg_match('/^[a-zA-Z0-9=+\/]+$/', $oR->ResponseList[1])) {
|
||||||
$this->Logger()->Write(\base64_decode($oR->ResponseList[1]),
|
$this->logWrite(\base64_decode($oR->ResponseList[1]), \LOG_WARNING);
|
||||||
\LOG_WARNING);
|
|
||||||
}
|
}
|
||||||
$this->sendRaw('');
|
$this->sendRaw('');
|
||||||
$oResponse = $this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
|
@ -200,14 +199,14 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$this->sendRaw($SASL->authenticate($sLogin, $sPassword, $sB64), true);
|
$this->sendRaw($SASL->authenticate($sLogin, $sPassword, $sB64), true);
|
||||||
$this->getResponse();
|
$this->getResponse();
|
||||||
$sPass = $SASL->challenge(''/*UGFzc3dvcmQ6*/);
|
$sPass = $SASL->challenge(''/*UGFzc3dvcmQ6*/);
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sPass);
|
$this->logMask($sPass);
|
||||||
$this->sendRaw($sPass);
|
$this->sendRaw($sPass);
|
||||||
$oResponse = $this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sPassword = $this->EscapeString(\mb_convert_encoding($sPassword, 'ISO-8859-1', 'UTF-8'));
|
$sPassword = $this->EscapeString(\mb_convert_encoding($sPassword, 'ISO-8859-1', 'UTF-8'));
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
$oResponse = $this->SendRequestGetResponse('LOGIN',
|
$oResponse = $this->SendRequestGetResponse('LOGIN',
|
||||||
array(
|
array(
|
||||||
$this->EscapeString($sLogin),
|
$this->EscapeString($sLogin),
|
||||||
|
|
52
snappymail/v/0.0.0/app/libraries/MailSo/Log/Inherit.php
Normal file
52
snappymail/v/0.0.0/app/libraries/MailSo/Log/Inherit.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of MailSo.
|
||||||
|
*
|
||||||
|
* (c) 2014 Usenko Timur
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace MailSo\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category MailSo
|
||||||
|
* @package Log
|
||||||
|
*/
|
||||||
|
trait Inherit
|
||||||
|
{
|
||||||
|
protected ?Logger $oLogger = null;
|
||||||
|
|
||||||
|
public function Logger(): ?Logger
|
||||||
|
{
|
||||||
|
return $this->oLogger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function SetLogger(?Logger $oLogger): void
|
||||||
|
{
|
||||||
|
$this->oLogger = $oLogger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logWrite(string $sDesc, int $iType = \LOG_INFO,
|
||||||
|
string $sName = '', bool $bSearchSecretWords = true, bool $bDiplayCrLf = false): bool
|
||||||
|
{
|
||||||
|
return $this->oLogger && $this->oLogger->Write($sDesc, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logException(\Throwable $oException, int $iType = \LOG_NOTICE, string $sName = ''): void
|
||||||
|
{
|
||||||
|
$this->oLogger && $this->oLogger->WriteException($oException, $iType, $sName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logMask(string $sWord): void
|
||||||
|
{
|
||||||
|
$this->oLogger && $this->oLogger->AddSecret($sWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public function logWriteDump($mValue, int $iType = \LOG_INFO, string $sName = '') : bool
|
||||||
|
public function logWriteExceptionShort(\Throwable $oException, int $iType = \LOG_NOTICE, string $sName = '') : void
|
||||||
|
*/
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ use MailSo\Mime\Enumerations\Parameter as MimeParameter;
|
||||||
*/
|
*/
|
||||||
class MailClient
|
class MailClient
|
||||||
{
|
{
|
||||||
private ?\MailSo\Log\Logger $oLogger = null;
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
private \MailSo\Imap\ImapClient $oImapClient;
|
private \MailSo\Imap\ImapClient $oImapClient;
|
||||||
|
|
||||||
|
@ -400,17 +400,13 @@ class MailClient
|
||||||
"ThreadsMapSorted/{$sSearch}/{$sFolderName}/{$oMessageCollection->FolderInfo->etag}";
|
"ThreadsMapSorted/{$sSearch}/{$sFolderName}/{$oMessageCollection->FolderInfo->etag}";
|
||||||
// "ThreadsMapSorted/{$sSearch}/{$iThreadLimit}/{$sFolderName}/{$oMessageCollection->FolderInfo->etag}";
|
// "ThreadsMapSorted/{$sSearch}/{$iThreadLimit}/{$sFolderName}/{$oMessageCollection->FolderInfo->etag}";
|
||||||
|
|
||||||
if ($this->oLogger) {
|
$this->logWrite($sSerializedHashKey);
|
||||||
$this->oLogger->Write($sSerializedHashKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sSerializedUids = $oCacher->Get($sSerializedHashKey);
|
$sSerializedUids = $oCacher->Get($sSerializedHashKey);
|
||||||
if (!empty($sSerializedUids)) {
|
if (!empty($sSerializedUids)) {
|
||||||
$aSerializedUids = \json_decode($sSerializedUids, true);
|
$aSerializedUids = \json_decode($sSerializedUids, true);
|
||||||
if (isset($aSerializedUids['ThreadsUids']) && \is_array($aSerializedUids['ThreadsUids'])) {
|
if (isset($aSerializedUids['ThreadsUids']) && \is_array($aSerializedUids['ThreadsUids'])) {
|
||||||
if ($this->oLogger) {
|
$this->logWrite('Get Serialized Thread UIDS from cache ("'.$sFolderName.'" / '.$sSearch.') [count:'.\count($aSerializedUids['ThreadsUids']).']');
|
||||||
$this->oLogger->Write('Get Serialized Thread UIDS from cache ("'.$sFolderName.'" / '.$sSearch.') [count:'.\count($aSerializedUids['ThreadsUids']).']');
|
|
||||||
}
|
|
||||||
return $aSerializedUids['ThreadsUids'];
|
return $aSerializedUids['ThreadsUids'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,9 +435,7 @@ class MailClient
|
||||||
'ThreadsUids' => $aResult
|
'ThreadsUids' => $aResult
|
||||||
)));
|
)));
|
||||||
|
|
||||||
if ($this->oLogger) {
|
$this->logWrite('Save Serialized Thread UIDS to cache ("'.$sFolderName.'" / '.$sSearch.') [count:'.\count($aResult).']');
|
||||||
$this->oLogger->Write('Save Serialized Thread UIDS to cache ("'.$sFolderName.'" / '.$sSearch.') [count:'.\count($aResult).']');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $aResult;
|
return $aResult;
|
||||||
|
@ -571,9 +565,7 @@ class MailClient
|
||||||
$sFolderHash === $aSerialized['FolderHash'] &&
|
$sFolderHash === $aSerialized['FolderHash'] &&
|
||||||
\is_array($aSerialized['Uids'])
|
\is_array($aSerialized['Uids'])
|
||||||
) {
|
) {
|
||||||
if ($this->oLogger) {
|
$this->logWrite('Get Serialized '.($bReturnUid?'UIDS':'IDS').' from cache ('.$sSerializedLog.') [count:'.\count($aSerialized['Uids']).']');
|
||||||
$this->oLogger->Write('Get Serialized '.($bReturnUid?'UIDS':'IDS').' from cache ('.$sSerializedLog.') [count:'.\count($aSerialized['Uids']).']');
|
|
||||||
}
|
|
||||||
return $aSerialized['Uids'];
|
return $aSerialized['Uids'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,9 +598,7 @@ class MailClient
|
||||||
'Uids' => $aResultUids
|
'Uids' => $aResultUids
|
||||||
)));
|
)));
|
||||||
|
|
||||||
if ($this->oLogger) {
|
$this->logWrite('Save Serialized '.($bReturnUid?'UIDS':'IDS').' to cache ('.$sSerializedLog.') [count:'.\count($aResultUids).']');
|
||||||
$this->oLogger->Write('Save Serialized '.($bReturnUid?'UIDS':'IDS').' to cache ('.$sSerializedLog.') [count:'.\count($aResultUids).']');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $aResultUids;
|
return $aResultUids;
|
||||||
|
@ -664,9 +654,7 @@ class MailClient
|
||||||
// || (!$this->oImapClient->hasCapability('SORT') && !$this->oImapClient->CapabilityValue('THREAD'))) {
|
// || (!$this->oImapClient->hasCapability('SORT') && !$this->oImapClient->CapabilityValue('THREAD'))) {
|
||||||
// Don't use THREAD for speed
|
// Don't use THREAD for speed
|
||||||
$oMessageCollection->Limited = true;
|
$oMessageCollection->Limited = true;
|
||||||
if ($this->oLogger) {
|
$this->logWrite('List optimization (count: '.$oInfo->MESSAGES.', limit:'.$message_list_limit.')');
|
||||||
$this->oLogger->Write('List optimization (count: '.$oInfo->MESSAGES.', limit:'.$message_list_limit.')');
|
|
||||||
}
|
|
||||||
if (\strlen($sSearch)) {
|
if (\strlen($sSearch)) {
|
||||||
// Don't use SORT for speed
|
// Don't use SORT for speed
|
||||||
$aUids = $this->GetUids($oParams, $sSearch, $oInfo->etag/*, $bUseSort*/);
|
$aUids = $this->GetUids($oParams, $sSearch, $oInfo->etag/*, $bUseSort*/);
|
||||||
|
@ -746,8 +734,8 @@ class MailClient
|
||||||
$aUids = \array_slice($aUids, $oParams->iOffset, $oParams->iLimit);
|
$aUids = \array_slice($aUids, $oParams->iOffset, $oParams->iLimit);
|
||||||
$this->MessageListByRequestIndexOrUids($oMessageCollection, new SequenceSet($aUids), $aAllThreads);
|
$this->MessageListByRequestIndexOrUids($oMessageCollection, new SequenceSet($aUids), $aAllThreads);
|
||||||
}
|
}
|
||||||
} else if ($this->oLogger) {
|
} else {
|
||||||
$this->oLogger->Write('No messages in '.$oMessageCollection->FolderName);
|
$this->logWrite('No messages in '.$oMessageCollection->FolderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $oMessageCollection;
|
return $oMessageCollection;
|
||||||
|
@ -775,7 +763,7 @@ class MailClient
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bUseListSubscribeStatus && !$this->oImapClient->hasCapability('LIST-EXTENDED')) {
|
if ($bUseListSubscribeStatus && !$this->oImapClient->hasCapability('LIST-EXTENDED')) {
|
||||||
// $this->oLogger && $this->oLogger->Write('RFC5258 not supported, using LSUB');
|
// $this->logWrite('RFC5258 not supported, using LSUB');
|
||||||
// \SnappyMail\Log::warning('IMAP', 'RFC5258 not supported, using LSUB');
|
// \SnappyMail\Log::warning('IMAP', 'RFC5258 not supported, using LSUB');
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -916,7 +904,7 @@ class MailClient
|
||||||
/**
|
/**
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function SetLogger(\MailSo\Log\Logger $oLogger) : void
|
public function SetLogger(?\MailSo\Log\Logger $oLogger) : void
|
||||||
{
|
{
|
||||||
$this->oLogger = $oLogger;
|
$this->oLogger = $oLogger;
|
||||||
$this->oImapClient->SetLogger($oLogger);
|
$this->oImapClient->SetLogger($oLogger);
|
||||||
|
|
|
@ -17,6 +17,8 @@ namespace MailSo\Net;
|
||||||
*/
|
*/
|
||||||
abstract class NetClient
|
abstract class NetClient
|
||||||
{
|
{
|
||||||
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
|
@ -34,11 +36,6 @@ abstract class NetClient
|
||||||
|
|
||||||
private float $iStartConnectTime = 0;
|
private float $iStartConnectTime = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \MailSo\Log\Logger
|
|
||||||
*/
|
|
||||||
protected $oLogger = null;
|
|
||||||
|
|
||||||
public ConnectSettings $Settings;
|
public ConnectSettings $Settings;
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
|
@ -295,34 +292,22 @@ abstract class NetClient
|
||||||
|
|
||||||
protected function writeLog(string $sDesc, int $iDescType = \LOG_INFO) : void
|
protected function writeLog(string $sDesc, int $iDescType = \LOG_INFO) : void
|
||||||
{
|
{
|
||||||
$this->oLogger && $this->oLogger->Write($sDesc, $iDescType, $this->getLogName());
|
$this->logWrite($sDesc, $iDescType, $this->getLogName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function writeLogWithCrlf(string $sDesc) : void
|
protected function writeLogWithCrlf(string $sDesc) : void
|
||||||
{
|
{
|
||||||
$this->oLogger && $this->oLogger->Write($sDesc, \LOG_INFO, $this->getLogName(), true, true);
|
$this->logWrite($sDesc, \LOG_INFO, $this->getLogName(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function writeLogException(\Throwable $oException, int $iDescType = \LOG_NOTICE, bool $bThrowException = true) : void
|
protected function writeLogException(\Throwable $oException, int $iDescType = \LOG_NOTICE, bool $bThrowException = true) : void
|
||||||
{
|
{
|
||||||
if ($this->oLogger) {
|
if ($oException instanceof Exceptions\SocketCanNotConnectToHostException) {
|
||||||
if ($oException instanceof Exceptions\SocketCanNotConnectToHostException) {
|
$this->logWrite('Socket: ['.$oException->getSocketCode().'] '.$oException->getSocketMessage(), $iDescType, $this->getLogName());
|
||||||
$this->oLogger->Write('Socket: ['.$oException->getSocketCode().'] '.$oException->getSocketMessage(), $iDescType, $this->getLogName());
|
|
||||||
}
|
|
||||||
$this->oLogger->WriteException($oException, $iDescType, $this->getLogName());
|
|
||||||
}
|
}
|
||||||
|
$this->logException($oException, $iDescType, $this->getLogName());
|
||||||
if ($bThrowException) {
|
if ($bThrowException) {
|
||||||
throw $oException;
|
throw $oException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetLogger(\MailSo\Log\Logger $oLogger) : void
|
|
||||||
{
|
|
||||||
$this->oLogger = $oLogger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Logger() : ?\MailSo\Log\Logger
|
|
||||||
{
|
|
||||||
return $this->oLogger;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
$sAuthzid = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), \MailSo\Imap\Enumerations\ResponseType::CONTINUATION);
|
$sAuthzid = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), \MailSo\Imap\Enumerations\ResponseType::CONTINUATION);
|
||||||
$this->sendRaw($SASL->authenticate($sLogin, $sPassword/*, $sAuthzid* /), true);
|
$this->sendRaw($SASL->authenticate($sLogin, $sPassword/*, $sAuthzid* /), true);
|
||||||
$sChallenge = $SASL->challenge($this->getResponseValue($this->getResponse(), \MailSo\Imap\Enumerations\ResponseType::CONTINUATION));
|
$sChallenge = $SASL->challenge($this->getResponseValue($this->getResponse(), \MailSo\Imap\Enumerations\ResponseType::CONTINUATION));
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sChallenge);
|
$this->logMask($sChallenge);
|
||||||
$this->sendRaw($sChallenge);
|
$this->sendRaw($sChallenge);
|
||||||
$oResponse = $this->getResponse();
|
$oResponse = $this->getResponse();
|
||||||
$SASL->verify($this->getResponseValue($oResponse));
|
$SASL->verify($this->getResponseValue($oResponse));
|
||||||
|
@ -126,7 +126,7 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
else if ('PLAIN' === $type || 'OAUTHBEARER' === $type || 'XOAUTH2' === $type)
|
else if ('PLAIN' === $type || 'OAUTHBEARER' === $type || 'XOAUTH2' === $type)
|
||||||
{
|
{
|
||||||
$sAuth = $SASL->authenticate($sLogin, $sPassword, $sLoginAuthKey);
|
$sAuth = $SASL->authenticate($sLogin, $sPassword, $sLoginAuthKey);
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sAuth);
|
$this->logMask($sAuth);
|
||||||
|
|
||||||
if ($oSettings->authPlainLiteral) {
|
if ($oSettings->authPlainLiteral) {
|
||||||
$this->sendRaw("AUTHENTICATE \"{$type}\" {".\strlen($sAuth).'+}');
|
$this->sendRaw("AUTHENTICATE \"{$type}\" {".\strlen($sAuth).'+}');
|
||||||
|
@ -143,7 +143,7 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
$sLogin = $SASL->authenticate($sLogin, $sPassword);
|
$sLogin = $SASL->authenticate($sLogin, $sPassword);
|
||||||
$sPassword = $SASL->challenge('');
|
$sPassword = $SASL->challenge('');
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
|
|
||||||
$this->sendRaw('AUTHENTICATE "LOGIN"');
|
$this->sendRaw('AUTHENTICATE "LOGIN"');
|
||||||
$this->sendRaw('{'.\strlen($sLogin).'+}');
|
$this->sendRaw('{'.\strlen($sLogin).'+}');
|
||||||
|
|
|
@ -166,7 +166,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
// RFC 5802
|
// RFC 5802
|
||||||
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 234, '');
|
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 234, '');
|
||||||
$sChallenge = $SASL->challenge($sResult);
|
$sChallenge = $SASL->challenge($sResult);
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sChallenge);
|
$this->logMask($sChallenge);
|
||||||
$SASL->verify($this->sendRequestWithCheck($sChallenge, 235, '', true));
|
$SASL->verify($this->sendRequestWithCheck($sChallenge, 235, '', true));
|
||||||
} else switch ($type) {
|
} else switch ($type) {
|
||||||
// RFC 4616
|
// RFC 4616
|
||||||
|
@ -174,14 +174,14 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
case 'XOAUTH2':
|
case 'XOAUTH2':
|
||||||
case 'OAUTHBEARER':
|
case 'OAUTHBEARER':
|
||||||
$sAuth = $SASL->authenticate($sLogin, $sPassword);
|
$sAuth = $SASL->authenticate($sLogin, $sPassword);
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sAuth);
|
$this->logMask($sAuth);
|
||||||
$this->sendRequestWithCheck($sAuth, 235, '', true);
|
$this->sendRequestWithCheck($sAuth, 235, '', true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'LOGIN':
|
case 'LOGIN':
|
||||||
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 334, '');
|
$sResult = $this->sendRequestWithCheck($SASL->authenticate($sLogin, $sPassword, $sResult), 334, '');
|
||||||
$sPassword = $SASL->challenge($sResult);
|
$sPassword = $SASL->challenge($sResult);
|
||||||
$this->oLogger && $this->oLogger->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
$this->sendRequestWithCheck($sPassword, 235, '', true);
|
$this->sendRequestWithCheck($sPassword, 235, '', true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ class Actions
|
||||||
use Actions\Localization;
|
use Actions\Localization;
|
||||||
use Actions\Themes;
|
use Actions\Themes;
|
||||||
|
|
||||||
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
const AUTH_MAILTO_TOKEN_KEY = 'smmailtoauth';
|
const AUTH_MAILTO_TOKEN_KEY = 'smmailtoauth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,11 +58,6 @@ class Actions
|
||||||
*/
|
*/
|
||||||
protected $oPlugins = null;
|
protected $oPlugins = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \MailSo\Log\Logger
|
|
||||||
*/
|
|
||||||
protected $oLogger = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \MailSo\Log\Logger
|
* @var \MailSo\Log\Logger
|
||||||
*/
|
*/
|
||||||
|
@ -140,7 +137,7 @@ class Actions
|
||||||
|
|
||||||
$oHttp = $this->Http();
|
$oHttp = $this->Http();
|
||||||
|
|
||||||
$this->oLogger->Write(
|
$this->logWrite(
|
||||||
'[SM:' . APP_VERSION . '][IP:'
|
'[SM:' . APP_VERSION . '][IP:'
|
||||||
. $oHttp->GetClientIp($this->oConfig->Get('labs', 'http_client_ip_check_proxy', false))
|
. $oHttp->GetClientIp($this->oConfig->Get('labs', 'http_client_ip_check_proxy', false))
|
||||||
. '][PID:' . (\MailSo\Base\Utils::FunctionCallable('getmypid') ? \getmypid() : 'unknown')
|
. '][PID:' . (\MailSo\Base\Utils::FunctionCallable('getmypid') ? \getmypid() : 'unknown')
|
||||||
|
@ -560,11 +557,6 @@ class Actions
|
||||||
return $this->oPlugins;
|
return $this->oPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Logger(): \MailSo\Log\Logger
|
|
||||||
{
|
|
||||||
return $this->oLogger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function LoggerAuth(): \MailSo\Log\Logger
|
public function LoggerAuth(): \MailSo\Log\Logger
|
||||||
{
|
{
|
||||||
if (!$this->oLoggerAuth) {
|
if (!$this->oLoggerAuth) {
|
||||||
|
@ -1130,7 +1122,7 @@ class Actions
|
||||||
|
|
||||||
public function Location(string $sUrl, int $iStatus = 302): void
|
public function Location(string $sUrl, int $iStatus = 302): void
|
||||||
{
|
{
|
||||||
$this->oLogger->Write("{$iStatus} Location: {$sUrl}");
|
$this->logWrite("{$iStatus} Location: {$sUrl}");
|
||||||
\MailSo\Base\Http::Location($sUrl, $iStatus);
|
\MailSo\Base\Http::Location($sUrl, $iStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ trait AdminDomains
|
||||||
}
|
}
|
||||||
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
$sImapErrorDesc = $oException->getSocketMessage();
|
$sImapErrorDesc = $oException->getSocketMessage();
|
||||||
if (empty($sImapErrorDesc)) {
|
if (empty($sImapErrorDesc)) {
|
||||||
$sImapErrorDesc = $oException->getMessage();
|
$sImapErrorDesc = $oException->getMessage();
|
||||||
|
@ -116,7 +116,7 @@ trait AdminDomains
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
$sImapErrorDesc = $oException->getMessage();
|
$sImapErrorDesc = $oException->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ trait AdminDomains
|
||||||
}
|
}
|
||||||
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
$sSmtpErrorDesc = $oException->getSocketMessage();
|
$sSmtpErrorDesc = $oException->getSocketMessage();
|
||||||
if (empty($sSmtpErrorDesc)) {
|
if (empty($sSmtpErrorDesc)) {
|
||||||
$sSmtpErrorDesc = $oException->getMessage();
|
$sSmtpErrorDesc = $oException->getMessage();
|
||||||
|
@ -154,7 +154,7 @@ trait AdminDomains
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
$sSmtpErrorDesc = $oException->getMessage();
|
$sSmtpErrorDesc = $oException->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ trait AdminDomains
|
||||||
}
|
}
|
||||||
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
catch (\MailSo\Net\Exceptions\SocketCanNotConnectToHostException $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
$sSieveErrorDesc = $oException->getSocketMessage();
|
$sSieveErrorDesc = $oException->getSocketMessage();
|
||||||
if (empty($sSieveErrorDesc)) {
|
if (empty($sSieveErrorDesc)) {
|
||||||
$sSieveErrorDesc = $oException->getMessage();
|
$sSieveErrorDesc = $oException->getMessage();
|
||||||
|
@ -187,7 +187,7 @@ trait AdminDomains
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
$sSieveErrorDesc = $oException->getMessage();
|
$sSieveErrorDesc = $oException->getMessage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -258,7 +258,7 @@ trait Contacts
|
||||||
if (\is_resource($rFile) && $oAddressBookProvider && $oAddressBookProvider->IsActive()) {
|
if (\is_resource($rFile) && $oAddressBookProvider && $oAddressBookProvider->IsActive()) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->Logger()->Write('Import contacts from vcf');
|
$this->logWrite('Import contacts from vcf');
|
||||||
foreach (\RainLoop\Providers\AddressBook\Utils::VcfStreamToContacts($rFile) as $oContact) {
|
foreach (\RainLoop\Providers\AddressBook\Utils::VcfStreamToContacts($rFile) as $oContact) {
|
||||||
if ($oAddressBookProvider->ContactSave($oContact)) {
|
if ($oAddressBookProvider->ContactSave($oContact)) {
|
||||||
++$iCount;
|
++$iCount;
|
||||||
|
@ -267,7 +267,7 @@ trait Contacts
|
||||||
}
|
}
|
||||||
catch (\Throwable $oExc)
|
catch (\Throwable $oExc)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oExc);
|
$this->logException($oExc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $iCount;
|
return $iCount;
|
||||||
|
@ -280,7 +280,7 @@ trait Contacts
|
||||||
if (\is_resource($rFile) && $oAddressBookProvider && $oAddressBookProvider->IsActive()) {
|
if (\is_resource($rFile) && $oAddressBookProvider && $oAddressBookProvider->IsActive()) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->Logger()->Write('Import contacts from csv');
|
$this->logWrite('Import contacts from csv');
|
||||||
$sDelimiter = ((int)\strpos($sFileStart, ',') > (int)\strpos($sFileStart, ';')) ? ',' : ';';
|
$sDelimiter = ((int)\strpos($sFileStart, ',') > (int)\strpos($sFileStart, ';')) ? ',' : ';';
|
||||||
foreach (\RainLoop\Providers\AddressBook\Utils::CsvStreamToContacts($rFile, $sDelimiter) as $oContact) {
|
foreach (\RainLoop\Providers\AddressBook\Utils::CsvStreamToContacts($rFile, $sDelimiter) as $oContact) {
|
||||||
if ($oAddressBookProvider->ContactSave($oContact)) {
|
if ($oAddressBookProvider->ContactSave($oContact)) {
|
||||||
|
@ -290,7 +290,7 @@ trait Contacts
|
||||||
}
|
}
|
||||||
catch (\Throwable $oExc)
|
catch (\Throwable $oExc)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oExc);
|
$this->logException($oExc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $iCount;
|
return $iCount;
|
||||||
|
|
|
@ -299,7 +299,7 @@ trait Folders
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ trait Messages
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ trait Messages
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException, \LOG_ERR);
|
$this->logException($oException, \LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ trait Messages
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->Logger()->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->TrueResponse();
|
return $this->TrueResponse();
|
||||||
|
|
|
@ -156,7 +156,7 @@ trait Raw
|
||||||
|
|
||||||
$self->cacheByKey($sRawKey);
|
$self->cacheByKey($sRawKey);
|
||||||
|
|
||||||
$self->Logger()->Write(\print_r([
|
$self->logWrite(\print_r([
|
||||||
$sFileName,
|
$sFileName,
|
||||||
$sContentType,
|
$sContentType,
|
||||||
$sFileNameIn,
|
$sFileNameIn,
|
||||||
|
|
|
@ -60,7 +60,7 @@ trait Response
|
||||||
$sErrorMessage = $oException->getCode().' - '.$oException->getMessage();
|
$sErrorMessage = $oException->getCode().' - '.$oException->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Logger()->WriteException($oException->getPrevious() ?: $oException);
|
$this->logException($oException->getPrevious() ?: $oException);
|
||||||
|
|
||||||
return $this->DefaultResponse(false, [
|
return $this->DefaultResponse(false, [
|
||||||
'ErrorCode' => $iErrorCode,
|
'ErrorCode' => $iErrorCode,
|
||||||
|
|
|
@ -38,7 +38,7 @@ trait User
|
||||||
$sPassword = $this->GetActionParam('Password', '');
|
$sPassword = $this->GetActionParam('Password', '');
|
||||||
$bSignMe = !empty($this->GetActionParam('signMe', 0));
|
$bSignMe = !empty($this->GetActionParam('signMe', 0));
|
||||||
|
|
||||||
$this->Logger()->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$oAccount = $this->LoginProcess($sEmail, $sPassword, $bSignMe);
|
$oAccount = $this->LoginProcess($sEmail, $sPassword, $bSignMe);
|
||||||
|
@ -116,17 +116,17 @@ trait User
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bMainCache) {
|
if ($bMainCache) {
|
||||||
$this->Logger()->Write('Cacher GC: Begin');
|
$this->logWrite('Cacher GC: Begin');
|
||||||
$this->Cacher()->GC(48);
|
$this->Cacher()->GC(48);
|
||||||
$this->Logger()->Write('Cacher GC: End');
|
$this->logWrite('Cacher GC: End');
|
||||||
|
|
||||||
$this->Logger()->Write('Storage GC: Begin');
|
$this->logWrite('Storage GC: Begin');
|
||||||
$this->StorageProvider()->GC();
|
$this->StorageProvider()->GC();
|
||||||
$this->Logger()->Write('Storage GC: End');
|
$this->logWrite('Storage GC: End');
|
||||||
} else if ($bFilesCache) {
|
} else if ($bFilesCache) {
|
||||||
$this->Logger()->Write('Files GC: Begin');
|
$this->logWrite('Files GC: Begin');
|
||||||
$this->FilesProvider()->GC(48);
|
$this->FilesProvider()->GC(48);
|
||||||
$this->Logger()->Write('Files GC: End');
|
$this->logWrite('Files GC: End');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Plugins()->RunHook('service.app-delay-start-end');
|
$this->Plugins()->RunHook('service.app-delay-start-end');
|
||||||
|
|
|
@ -32,13 +32,13 @@ trait UserAuth
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\str_contains($sEmail, '@')) {
|
if (!\str_contains($sEmail, '@')) {
|
||||||
$this->Logger()->Write('The email address "' . $sEmail . '" is not complete', \LOG_INFO, 'LOGIN');
|
$this->logWrite('The email address "' . $sEmail . '" is not complete', \LOG_INFO, 'LOGIN');
|
||||||
|
|
||||||
$bAdded = false;
|
$bAdded = false;
|
||||||
|
|
||||||
if ($this->Config()->Get('login', 'determine_user_domain', false)) {
|
if ($this->Config()->Get('login', 'determine_user_domain', false)) {
|
||||||
$sUserHost = \trim($this->Http()->GetHost(true, true));
|
$sUserHost = \trim($this->Http()->GetHost(true, true));
|
||||||
$this->Logger()->Write('Determined user domain: ' . $sUserHost, \LOG_INFO, 'LOGIN');
|
$this->logWrite('Determined user domain: ' . $sUserHost, \LOG_INFO, 'LOGIN');
|
||||||
|
|
||||||
$aDomainParts = \explode('.', $sUserHost);
|
$aDomainParts = \explode('.', $sUserHost);
|
||||||
$iLimit = \min(\count($aDomainParts), 14);
|
$iLimit = \min(\count($aDomainParts), 14);
|
||||||
|
@ -50,13 +50,13 @@ trait UserAuth
|
||||||
$oDomain = $oDomainProvider->Load($sLine, false);
|
$oDomain = $oDomainProvider->Load($sLine, false);
|
||||||
if ($oDomain) {
|
if ($oDomain) {
|
||||||
$bAdded = true;
|
$bAdded = true;
|
||||||
$this->Logger()->Write('Check "' . $sLine . '": OK (' . $sEmail . ' > ' . $sEmail . '@' . $sLine . ')',
|
$this->logWrite('Check "' . $sLine . '": OK (' . $sEmail . ' > ' . $sEmail . '@' . $sLine . ')',
|
||||||
\LOG_INFO, 'LOGIN');
|
\LOG_INFO, 'LOGIN');
|
||||||
|
|
||||||
$sEmail .= '@' . $sLine;
|
$sEmail .= '@' . $sLine;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
$this->Logger()->Write('Check "' . $sLine . '": NO', \LOG_INFO, 'LOGIN');
|
$this->logWrite('Check "' . $sLine . '": NO', \LOG_INFO, 'LOGIN');
|
||||||
}
|
}
|
||||||
|
|
||||||
\array_shift($aDomainParts);
|
\array_shift($aDomainParts);
|
||||||
|
@ -66,17 +66,17 @@ trait UserAuth
|
||||||
$oDomain = $oDomainProvider->Load($sUserHost, true);
|
$oDomain = $oDomainProvider->Load($sUserHost, true);
|
||||||
if ($oDomain) {
|
if ($oDomain) {
|
||||||
$bAdded = true;
|
$bAdded = true;
|
||||||
$this->Logger()->Write('Check "' . $sUserHost . '" with wildcard: OK (' . $sEmail . ' > ' . $sEmail . '@' . $sUserHost . ')',
|
$this->logWrite('Check "' . $sUserHost . '" with wildcard: OK (' . $sEmail . ' > ' . $sEmail . '@' . $sUserHost . ')',
|
||||||
\LOG_INFO, 'LOGIN');
|
\LOG_INFO, 'LOGIN');
|
||||||
|
|
||||||
$sEmail .= '@' . $sUserHost;
|
$sEmail .= '@' . $sUserHost;
|
||||||
} else {
|
} else {
|
||||||
$this->Logger()->Write('Check "' . $sUserHost . '" with wildcard: NO', \LOG_INFO, 'LOGIN');
|
$this->logWrite('Check "' . $sUserHost . '" with wildcard: NO', \LOG_INFO, 'LOGIN');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$bAdded) {
|
if (!$bAdded) {
|
||||||
$this->Logger()->Write('Domain was not found!', \LOG_INFO, 'LOGIN');
|
$this->logWrite('Domain was not found!', \LOG_INFO, 'LOGIN');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,12 +88,12 @@ trait UserAuth
|
||||||
} else if ('gethostname' === $sDefDomain) {
|
} else if ('gethostname' === $sDefDomain) {
|
||||||
$sDefDomain = \gethostname();
|
$sDefDomain = \gethostname();
|
||||||
}
|
}
|
||||||
$this->Logger()->Write('Default domain "' . $sDefDomain . '" was used. (' . $sEmail . ' > ' . $sEmail . '@' . $sDefDomain . ')',
|
$this->logWrite('Default domain "' . $sDefDomain . '" was used. (' . $sEmail . ' > ' . $sEmail . '@' . $sDefDomain . ')',
|
||||||
\LOG_INFO, 'LOGIN');
|
\LOG_INFO, 'LOGIN');
|
||||||
|
|
||||||
$sEmail .= '@' . $sDefDomain;
|
$sEmail .= '@' . $sDefDomain;
|
||||||
} else {
|
} else {
|
||||||
$this->Logger()->Write('Default domain not configured.', \LOG_INFO, 'LOGIN');
|
$this->logWrite('Default domain not configured.', \LOG_INFO, 'LOGIN');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,9 +105,9 @@ trait UserAuth
|
||||||
$sLogin = \mb_strtolower($sLogin);
|
$sLogin = \mb_strtolower($sLogin);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Logger()->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
$this->Plugins()->RunHook('login.credentials', array(&$sEmail, &$sLogin, &$sPassword));
|
$this->Plugins()->RunHook('login.credentials', array(&$sEmail, &$sLogin, &$sPassword));
|
||||||
$this->Logger()->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -105,7 +105,7 @@ class ActionsAdmin extends Actions
|
||||||
$sLogin = trim($this->GetActionParam('Login', ''));
|
$sLogin = trim($this->GetActionParam('Login', ''));
|
||||||
$sPassword = $this->GetActionParam('Password', '');
|
$sPassword = $this->GetActionParam('Password', '');
|
||||||
|
|
||||||
$this->Logger()->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
|
|
||||||
$totp = $this->Config()->Get('security', 'admin_totp', '');
|
$totp = $this->Config()->Get('security', 'admin_totp', '');
|
||||||
|
|
||||||
|
@ -172,11 +172,11 @@ class ActionsAdmin extends Actions
|
||||||
$oConfig = $this->Config();
|
$oConfig = $this->Config();
|
||||||
|
|
||||||
$sPassword = $this->GetActionParam('Password', '');
|
$sPassword = $this->GetActionParam('Password', '');
|
||||||
$this->Logger()->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
|
|
||||||
$sNewPassword = $this->GetActionParam('newPassword', '');
|
$sNewPassword = $this->GetActionParam('newPassword', '');
|
||||||
if (\strlen($sNewPassword)) {
|
if (\strlen($sNewPassword)) {
|
||||||
$this->Logger()->AddSecret($sNewPassword);
|
$this->logMask($sNewPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
$passfile = APP_PRIVATE_DATA.'admin_password.txt';
|
$passfile = APP_PRIVATE_DATA.'admin_password.txt';
|
||||||
|
|
|
@ -4,6 +4,8 @@ namespace RainLoop\Common;
|
||||||
|
|
||||||
abstract class PdoAbstract
|
abstract class PdoAbstract
|
||||||
{
|
{
|
||||||
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \PDO
|
* @var \PDO
|
||||||
*/
|
*/
|
||||||
|
@ -19,11 +21,6 @@ abstract class PdoAbstract
|
||||||
*/
|
*/
|
||||||
protected $bSqliteCollate = true;
|
protected $bSqliteCollate = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \MailSo\Log\Logger
|
|
||||||
*/
|
|
||||||
protected $oLogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -34,11 +31,6 @@ abstract class PdoAbstract
|
||||||
return !!\class_exists('PDO');
|
return !!\class_exists('PDO');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetLogger(?\MailSo\Log\Logger $oLogger)
|
|
||||||
{
|
|
||||||
$this->oLogger = $oLogger;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getPdoAccessData() : array
|
protected function getPdoAccessData() : array
|
||||||
{
|
{
|
||||||
return array('', '', '', '');
|
return array('', '', '', '');
|
||||||
|
@ -98,7 +90,7 @@ abstract class PdoAbstract
|
||||||
// $bCaseFunc = true;
|
// $bCaseFunc = true;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// $this->oLogger->Write('PDO:'.$sPdoType.($bCaseFunc ? '/SQLITE_NOCASE_UTF8' : ''));
|
// $this->logWrite('PDO:'.$sPdoType.($bCaseFunc ? '/SQLITE_NOCASE_UTF8' : ''));
|
||||||
|
|
||||||
$this->oPDO = $oPdo;
|
$this->oPDO = $oPdo;
|
||||||
return $oPdo;
|
return $oPdo;
|
||||||
|
|
|
@ -190,18 +190,18 @@ abstract class Account implements \JsonSerializable
|
||||||
if (isset($aAccountHash['name'])) {
|
if (isset($aAccountHash['name'])) {
|
||||||
$oAccount->sName = $aAccountHash['name'];
|
$oAccount->sName = $aAccountHash['name'];
|
||||||
}
|
}
|
||||||
$oActions->Logger()->AddSecret($oAccount->sPassword);
|
$oActions->logMask($oAccount->sPassword);
|
||||||
// init smtp user/password
|
// init smtp user/password
|
||||||
if (isset($aAccountHash['smtp'])) {
|
if (isset($aAccountHash['smtp'])) {
|
||||||
$oAccount->sSmtpLogin = $aAccountHash['smtp']['user'];
|
$oAccount->sSmtpLogin = $aAccountHash['smtp']['user'];
|
||||||
$oAccount->sSmtpPassword = $aAccountHash['smtp']['pass'];
|
$oAccount->sSmtpPassword = $aAccountHash['smtp']['pass'];
|
||||||
$oActions->Logger()->AddSecret($oAccount->sSmtpPassword);
|
$oActions->logMask($oAccount->sSmtpPassword);
|
||||||
}
|
}
|
||||||
// init proxy user/password
|
// init proxy user/password
|
||||||
if (isset($aAccountHash['proxy'])) {
|
if (isset($aAccountHash['proxy'])) {
|
||||||
$oAccount->sProxyAuthUser = $aAccountHash['proxy']['user'];
|
$oAccount->sProxyAuthUser = $aAccountHash['proxy']['user'];
|
||||||
$oAccount->sProxyAuthPassword = $aAccountHash['proxy']['pass'];
|
$oAccount->sProxyAuthPassword = $aAccountHash['proxy']['pass'];
|
||||||
$oActions->Logger()->AddSecret($oAccount->sProxyAuthPassword);
|
$oActions->logMask($oAccount->sProxyAuthPassword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ namespace RainLoop\Plugins;
|
||||||
|
|
||||||
class Manager
|
class Manager
|
||||||
{
|
{
|
||||||
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \RainLoop\Actions
|
* @var \RainLoop\Actions
|
||||||
*/
|
*/
|
||||||
|
@ -21,14 +23,8 @@ class Manager
|
||||||
|
|
||||||
private bool $bIsEnabled;
|
private bool $bIsEnabled;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \MailSo\Log\Logger
|
|
||||||
*/
|
|
||||||
private $oLogger;
|
|
||||||
|
|
||||||
public function __construct(\RainLoop\Actions $oActions)
|
public function __construct(\RainLoop\Actions $oActions)
|
||||||
{
|
{
|
||||||
$this->oLogger = null;
|
|
||||||
$this->oActions = $oActions;
|
$this->oActions = $oActions;
|
||||||
|
|
||||||
$oConfig = $oActions->Config();
|
$oConfig = $oActions->Config();
|
||||||
|
@ -121,8 +117,7 @@ class Manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->oActions->Logger()->Write('Cannot get installed plugins from '.APP_PLUGINS_PATH,
|
$this->oActions->logWrite('Cannot get installed plugins from '.APP_PLUGINS_PATH, \LOG_ERR);
|
||||||
\LOG_ERR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $aList;
|
return $aList;
|
||||||
|
@ -478,24 +473,13 @@ class Manager
|
||||||
return $this->bIsEnabled ? \count($this->aPlugins) : 0;
|
return $this->bIsEnabled ? \count($this->aPlugins) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetLogger(\MailSo\Log\Logger $oLogger) : self
|
|
||||||
{
|
|
||||||
$this->oLogger = $oLogger;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function WriteLog(string $sDesc, int $iType = \LOG_INFO) : void
|
public function WriteLog(string $sDesc, int $iType = \LOG_INFO) : void
|
||||||
{
|
{
|
||||||
if ($this->oLogger) {
|
$this->logWrite($sDesc, $iType, 'PLUGIN');
|
||||||
$this->oLogger->Write($sDesc, $iType, 'PLUGIN');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function WriteException(string $sDesc, int $iType = \LOG_INFO) : void
|
public function WriteException(string $sDesc, int $iType = \LOG_INFO) : void
|
||||||
{
|
{
|
||||||
if ($this->oLogger) {
|
$this->logException($sDesc, $iType, 'PLUGIN');
|
||||||
$this->oLogger->WriteException($sDesc, $iType, 'PLUGIN');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,13 @@ namespace RainLoop\Providers;
|
||||||
|
|
||||||
abstract class AbstractProvider
|
abstract class AbstractProvider
|
||||||
{
|
{
|
||||||
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \RainLoop\Model\Account
|
* @var \RainLoop\Model\Account
|
||||||
*/
|
*/
|
||||||
protected $oAccount;
|
protected $oAccount;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \MailSo\Log\Logger
|
|
||||||
*/
|
|
||||||
protected $oLogger = null;
|
|
||||||
|
|
||||||
public function IsActive() : bool
|
public function IsActive() : bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -23,14 +20,4 @@ abstract class AbstractProvider
|
||||||
{
|
{
|
||||||
$this->oAccount = $oAccount;
|
$this->oAccount = $oAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetLogger(?\MailSo\Log\Logger $oLogger)
|
|
||||||
{
|
|
||||||
$this->oLogger = $oLogger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Logger() : ?\MailSo\Log\Logger
|
|
||||||
{
|
|
||||||
return $this->oLogger;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ trait CardDAV
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->oLogger->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ trait CardDAV
|
||||||
{
|
{
|
||||||
\MailSo\Base\Utils::ResetTimeLimit();
|
\MailSo\Base\Utils::ResetTimeLimit();
|
||||||
|
|
||||||
$this->oLogger->Write($sCmd.' '.$sUrl.(('PUT' === $sCmd || 'POST' === $sCmd) && null !== $mData ? ' ('.\strlen($mData).')' : ''),
|
$this->logWrite($sCmd.' '.$sUrl.(('PUT' === $sCmd || 'POST' === $sCmd) && null !== $mData ? ' ('.\strlen($mData).')' : ''),
|
||||||
\LOG_INFO, 'DAV');
|
\LOG_INFO, 'DAV');
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -105,7 +105,7 @@ trait CardDAV
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->oLogger->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -124,7 +124,7 @@ trait CardDAV
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->oLogger->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -271,7 +271,7 @@ trait CardDAV
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->oLogger->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
$bGood = false;
|
$bGood = false;
|
||||||
|
@ -316,7 +316,7 @@ trait CardDAV
|
||||||
'password' => $sPassword
|
'password' => $sPassword
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->oLogger->AddSecret($sPassword);
|
$this->logMask($sPassword);
|
||||||
|
|
||||||
if (!empty($sProxy)) {
|
if (!empty($sProxy)) {
|
||||||
$aSettings['proxy'] = $sProxy;
|
$aSettings['proxy'] = $sProxy;
|
||||||
|
@ -327,7 +327,7 @@ trait CardDAV
|
||||||
|
|
||||||
$oClient->__UrlPath__ = $aUrl['path'];
|
$oClient->__UrlPath__ = $aUrl['path'];
|
||||||
|
|
||||||
$this->oLogger->Write('DavClient: User: '.$aSettings['userName'].', Url: '.$sUrl, \LOG_INFO, 'DAV');
|
$this->logWrite('DavClient: User: '.$aSettings['userName'].', Url: '.$sUrl, \LOG_INFO, 'DAV');
|
||||||
|
|
||||||
return $oClient;
|
return $oClient;
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,7 @@ trait CardDAV
|
||||||
|
|
||||||
$bGood = $sNewPath && $this->checkContactsPath($oClient, $sNewPath);
|
$bGood = $sNewPath && $this->checkContactsPath($oClient, $sNewPath);
|
||||||
if (!$bGood) {
|
if (!$bGood) {
|
||||||
$this->oLogger->Write('Contacts path not found at: '.$sPath, \LOG_INFO, 'DAV');
|
$this->logWrite('Contacts path not found at: '.$sPath, \LOG_INFO, 'DAV');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,10 +275,8 @@ class PdoAddressBook
|
||||||
try {
|
try {
|
||||||
$oVCard = \Sabre\VObject\Reader::read($sBody);
|
$oVCard = \Sabre\VObject\Reader::read($sBody);
|
||||||
} catch (\Throwable $oExc) {
|
} catch (\Throwable $oExc) {
|
||||||
if ($this->oLogger) {
|
$this->logException($oExc);
|
||||||
$this->oLogger->WriteException($oExc);
|
$this->oLogger && $this->oLogger->WriteDump($sBody);
|
||||||
$this->oLogger->WriteDump($sBody);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,7 +339,7 @@ class PdoAddressBook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Throwable $oExc) {
|
} catch (\Throwable $oExc) {
|
||||||
$this->oLogger && $this->oLogger->WriteException($oExc);
|
$this->logException($oExc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,9 @@ namespace RainLoop\Providers\Filters;
|
||||||
|
|
||||||
class SieveStorage implements FiltersInterface
|
class SieveStorage implements FiltersInterface
|
||||||
{
|
{
|
||||||
const SIEVE_FILE_NAME = 'rainloop.user';
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
/**
|
const SIEVE_FILE_NAME = 'rainloop.user';
|
||||||
* @var \MailSo\Log\Logger
|
|
||||||
*/
|
|
||||||
private $oLogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \RainLoop\Plugins\Manager
|
* @var \RainLoop\Plugins\Manager
|
||||||
|
@ -23,8 +20,6 @@ class SieveStorage implements FiltersInterface
|
||||||
|
|
||||||
public function __construct($oPlugins, $oConfig)
|
public function __construct($oPlugins, $oConfig)
|
||||||
{
|
{
|
||||||
$this->oLogger = null;
|
|
||||||
|
|
||||||
$this->oPlugins = $oPlugins;
|
$this->oPlugins = $oPlugins;
|
||||||
$this->oConfig = $oConfig;
|
$this->oConfig = $oConfig;
|
||||||
}
|
}
|
||||||
|
@ -123,9 +118,4 @@ class SieveStorage implements FiltersInterface
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetLogger(?\MailSo\Log\Logger $oLogger)
|
|
||||||
{
|
|
||||||
$this->oLogger = $oLogger;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ use RainLoop\Providers\Storage\Enumerations\StorageType;
|
||||||
|
|
||||||
class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||||
{
|
{
|
||||||
|
use \MailSo\Log\Inherit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -16,16 +18,10 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||||
*/
|
*/
|
||||||
private $bLocal;
|
private $bLocal;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \MailSo\Log\Logger
|
|
||||||
*/
|
|
||||||
protected $oLogger;
|
|
||||||
|
|
||||||
public function __construct(string $sStoragePath, bool $bLocal = false)
|
public function __construct(string $sStoragePath, bool $bLocal = false)
|
||||||
{
|
{
|
||||||
$this->sDataPath = \rtrim(\trim($sStoragePath), '\\/');
|
$this->sDataPath = \rtrim(\trim($sStoragePath), '\\/');
|
||||||
$this->bLocal = $bLocal;
|
$this->bLocal = $bLocal;
|
||||||
$this->oLogger = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,11 +165,6 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||||
return $sFilePath;
|
return $sFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetLogger(?\MailSo\Log\Logger $oLogger)
|
|
||||||
{
|
|
||||||
$this->oLogger = $oLogger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function GC() : void
|
public function GC() : void
|
||||||
{
|
{
|
||||||
\clearstatcache();
|
\clearstatcache();
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Suggestions extends \RainLoop\Providers\AbstractProvider
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
$this->oLogger && $this->oLogger->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extensions/Plugins
|
// Extensions/Plugins
|
||||||
|
@ -67,7 +67,7 @@ class Suggestions extends \RainLoop\Providers\AbstractProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Throwable $oException) {
|
} catch (\Throwable $oException) {
|
||||||
$this->oLogger && $this->oLogger->WriteException($oException);
|
$this->logException($oException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Sync
|
||||||
$this->oImapSource->TAG_PREFIX = 'S';
|
$this->oImapSource->TAG_PREFIX = 'S';
|
||||||
$this->oImapTarget->TAG_PREFIX = 'T';
|
$this->oImapTarget->TAG_PREFIX = 'T';
|
||||||
|
|
||||||
// $this->oImapTarget->Logger()->Write('Get oImapTarget->FolderList');
|
// $this->oImapTarget->logWrite('Get oImapTarget->FolderList');
|
||||||
\SnappyMail\Log::notice('SYNC', 'Get oImapTarget->FolderList');
|
\SnappyMail\Log::notice('SYNC', 'Get oImapTarget->FolderList');
|
||||||
$aTargetFolders = $this->oImapTarget->FolderList($sParent, $sListPattern);
|
$aTargetFolders = $this->oImapTarget->FolderList($sParent, $sListPattern);
|
||||||
if (!$aTargetFolders) {
|
if (!$aTargetFolders) {
|
||||||
|
|
Loading…
Reference in a new issue