mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Improved logging
Small fixes
This commit is contained in:
parent
187e44607d
commit
6c28b24aaf
11 changed files with 301 additions and 246 deletions
|
|
@ -951,64 +951,67 @@ class Utils
|
||||||
\str_replace($aJsonReplaces[0], $aJsonReplaces[1], $sText));
|
\str_replace($aJsonReplaces[0], $aJsonReplaces[1], $sText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $aInput
|
||||||
|
*/
|
||||||
|
public static function ClearArrayUtf8Values(&$aInput)
|
||||||
|
{
|
||||||
|
if (\is_array($aInput))
|
||||||
|
{
|
||||||
|
foreach ($aInput as $mKey => $mItem)
|
||||||
|
{
|
||||||
|
if (\is_string($mItem))
|
||||||
|
{
|
||||||
|
$aInput[$mKey] = \MailSo\Base\Utils::Utf8Clear($mItem);
|
||||||
|
}
|
||||||
|
else if (\is_array($mItem))
|
||||||
|
{
|
||||||
|
\MailSo\Base\Utils::ClearArrayUtf8Values($mItem);
|
||||||
|
$aInput[$mKey] = $mItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $mInput
|
* @param mixed $mInput
|
||||||
|
* @param \MailSo\Log\Logger|null $oLogger = null
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function Php2js($mInput)
|
public static function Php2js($mInput, $oLogger = null)
|
||||||
{
|
{
|
||||||
return \json_encode($mInput, \defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0);
|
static $iOpt = null;
|
||||||
|
if (null === $iOpt)
|
||||||
|
{
|
||||||
|
$iOpt = \defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0;
|
||||||
|
}
|
||||||
|
|
||||||
// if (\is_null($mInput))
|
$sResult = @\json_encode($mInput, $iOpt);
|
||||||
// {
|
if (!\is_string($sResult) || '' === $sResult)
|
||||||
// return 'null';
|
{
|
||||||
// }
|
if ($oLogger instanceof \MailSo\Log\Logger)
|
||||||
// else if ($mInput === false)
|
{
|
||||||
// {
|
$oLogger->Write('json_encode: '.\trim(
|
||||||
// return 'false';
|
(\MailSo\Base\Utils::FunctionExistsAndEnabled('json_last_error') ? ' [Error Code: '.\json_last_error().']' : '').
|
||||||
// }
|
(\MailSo\Base\Utils::FunctionExistsAndEnabled('json_last_error_msg') ? ' [Error Message: '.\json_last_error_msg().']' : '')
|
||||||
// else if ($mInput === true)
|
), \MailSo\Log\Enumerations\Type::WARNING, 'JSON'
|
||||||
// {
|
);
|
||||||
// return 'true';
|
}
|
||||||
// }
|
|
||||||
// else if (\is_scalar($mInput))
|
if (\is_array($mInput))
|
||||||
// {
|
{
|
||||||
// if (\is_float($mInput))
|
if ($oLogger instanceof \MailSo\Log\Logger)
|
||||||
// {
|
{
|
||||||
// $mInput = \str_replace(',', '.', \strval($mInput));
|
$oLogger->Write('Try to clear Utf8 before json_encode', \MailSo\Log\Enumerations\Type::INFO, 'JSON');
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return '"'.\MailSo\Base\Utils::InlineRebuildStringToJsString($mInput).'"';
|
\MailSo\Base\Utils::ClearArrayUtf8Values($mInput);
|
||||||
// }
|
$sResult = @\json_encode($mInput, $iOpt);
|
||||||
//
|
}
|
||||||
// $bIsList = true;
|
}
|
||||||
// for ($iIndex = 0, \reset($mInput), $iLen = \count($mInput); $iIndex < $iLen; $iIndex++, \next($mInput))
|
|
||||||
// {
|
return $sResult;
|
||||||
// if (\key($mInput) !== $iIndex)
|
|
||||||
// {
|
|
||||||
// $bIsList = false;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// $aResult = array();
|
|
||||||
// if ($bIsList)
|
|
||||||
// {
|
|
||||||
// foreach ($mInput as $mValue)
|
|
||||||
// {
|
|
||||||
// $aResult[] = \MailSo\Base\Utils::Php2js($mValue);
|
|
||||||
// }
|
|
||||||
// return '['.\join(',', $aResult).']';
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// foreach ($mInput as $sKey => $mValue)
|
|
||||||
// {
|
|
||||||
// $aResult[] = \MailSo\Base\Utils::Php2js($sKey).':'.\MailSo\Base\Utils::Php2js($mValue);
|
|
||||||
// }
|
|
||||||
// return '{'.\join(',', $aResult).'}';
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -357,8 +357,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$this->aCapabilityItems = $this->Capability();
|
$this->aCapabilityItems = $this->Capability();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bResult && is_array($this->aCapabilityItems) &&
|
return $bResult && \is_array($this->aCapabilityItems) &&
|
||||||
in_array(strtoupper($sExtentionName), $this->aCapabilityItems);
|
\in_array(\strtoupper($sExtentionName), $this->aCapabilityItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -498,14 +498,14 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
$aReturn = array();
|
$aReturn = array();
|
||||||
|
|
||||||
if (is_array($aResult))
|
if (\is_array($aResult))
|
||||||
{
|
{
|
||||||
$oImapResponse = null;
|
$oImapResponse = null;
|
||||||
foreach ($aResult as /* @var $oImapResponse \MailSo\Imap\Response */ $oImapResponse)
|
foreach ($aResult as /* @var $oImapResponse \MailSo\Imap\Response */ $oImapResponse)
|
||||||
{
|
{
|
||||||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType &&
|
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType &&
|
||||||
'STATUS' === $oImapResponse->StatusOrIndex && isset($oImapResponse->ResponseList[3]) &&
|
'STATUS' === $oImapResponse->StatusOrIndex && isset($oImapResponse->ResponseList[3]) &&
|
||||||
is_array($oImapResponse->ResponseList[3]))
|
\is_array($oImapResponse->ResponseList[3]))
|
||||||
{
|
{
|
||||||
$sName = null;
|
$sName = null;
|
||||||
foreach ($oImapResponse->ResponseList[3] as $sArrayItem)
|
foreach ($oImapResponse->ResponseList[3] as $sArrayItem)
|
||||||
|
|
@ -540,7 +540,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
public function FolderStatus($sFolderName, array $aStatusItems)
|
public function FolderStatus($sFolderName, array $aStatusItems)
|
||||||
{
|
{
|
||||||
$aResult = false;
|
$aResult = false;
|
||||||
if (count($aStatusItems) > 0)
|
if (\count($aStatusItems) > 0)
|
||||||
{
|
{
|
||||||
$this->SendRequest('STATUS',
|
$this->SendRequest('STATUS',
|
||||||
array($this->EscapeString($sFolderName), $aStatusItems));
|
array($this->EscapeString($sFolderName), $aStatusItems));
|
||||||
|
|
@ -735,7 +735,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
protected function initCurrentFolderInformation($aResult, $sFolderName, $bIsWritable)
|
protected function initCurrentFolderInformation($aResult, $sFolderName, $bIsWritable)
|
||||||
{
|
{
|
||||||
if (is_array($aResult))
|
if (\is_array($aResult))
|
||||||
{
|
{
|
||||||
$oImapResponse = null;
|
$oImapResponse = null;
|
||||||
$oResult = FolderInformation::NewInstance($sFolderName, $bIsWritable);
|
$oResult = FolderInformation::NewInstance($sFolderName, $bIsWritable);
|
||||||
|
|
@ -744,13 +744,13 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType)
|
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType)
|
||||||
{
|
{
|
||||||
if (count($oImapResponse->ResponseList) > 2 &&
|
if (\count($oImapResponse->ResponseList) > 2 &&
|
||||||
'FLAGS' === $oImapResponse->ResponseList[1] && is_array($oImapResponse->ResponseList[2]))
|
'FLAGS' === $oImapResponse->ResponseList[1] && \is_array($oImapResponse->ResponseList[2]))
|
||||||
{
|
{
|
||||||
$oResult->Flags = $oImapResponse->ResponseList[2];
|
$oResult->Flags = $oImapResponse->ResponseList[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($oImapResponse->OptionalResponse) && count($oImapResponse->OptionalResponse) > 1)
|
if (is_array($oImapResponse->OptionalResponse) && \count($oImapResponse->OptionalResponse) > 1)
|
||||||
{
|
{
|
||||||
if ('PERMANENTFLAGS' === $oImapResponse->OptionalResponse[0] &&
|
if ('PERMANENTFLAGS' === $oImapResponse->OptionalResponse[0] &&
|
||||||
is_array($oImapResponse->OptionalResponse[1]))
|
is_array($oImapResponse->OptionalResponse[1]))
|
||||||
|
|
@ -775,9 +775,9 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($oImapResponse->ResponseList) > 2 &&
|
if (\count($oImapResponse->ResponseList) > 2 &&
|
||||||
is_string($oImapResponse->ResponseList[2]) &&
|
\is_string($oImapResponse->ResponseList[2]) &&
|
||||||
is_numeric($oImapResponse->ResponseList[1]))
|
\is_numeric($oImapResponse->ResponseList[1]))
|
||||||
{
|
{
|
||||||
switch($oImapResponse->ResponseList[2])
|
switch($oImapResponse->ResponseList[2])
|
||||||
{
|
{
|
||||||
|
|
@ -889,7 +889,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$aFetchItems = \MailSo\Imap\Enumerations\FetchType::ChangeFetchItemsBefourRequest($aInputFetchItems);
|
$aFetchItems = \MailSo\Imap\Enumerations\FetchType::ChangeFetchItemsBefourRequest($aInputFetchItems);
|
||||||
foreach ($aFetchItems as $sName => $mItem)
|
foreach ($aFetchItems as $sName => $mItem)
|
||||||
{
|
{
|
||||||
if (0 < strlen($sName) && '' !== $mItem)
|
if (0 < \strlen($sName) && '' !== $mItem)
|
||||||
{
|
{
|
||||||
if (null === $this->aFetchCallbacks)
|
if (null === $this->aFetchCallbacks)
|
||||||
{
|
{
|
||||||
|
|
@ -900,7 +900,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->SendRequest((($bIndexIsUid) ? 'UID ' : '').'FETCH', array($sIndexRange, array_keys($aFetchItems)));
|
$this->SendRequest((($bIndexIsUid) ? 'UID ' : '').'FETCH', array($sIndexRange, \array_keys($aFetchItems)));
|
||||||
$aResult = $this->validateResponse($this->parseResponse());
|
$aResult = $this->validateResponse($this->parseResponse());
|
||||||
$this->aFetchCallbacks = null;
|
$this->aFetchCallbacks = null;
|
||||||
|
|
||||||
|
|
@ -938,13 +938,13 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
|
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
|
||||||
&& 'QUOTA' === $oImapResponse->StatusOrIndex
|
&& 'QUOTA' === $oImapResponse->StatusOrIndex
|
||||||
&& is_array($oImapResponse->ResponseList)
|
&& \is_array($oImapResponse->ResponseList)
|
||||||
&& isset($oImapResponse->ResponseList[3])
|
&& isset($oImapResponse->ResponseList[3])
|
||||||
&& is_array($oImapResponse->ResponseList[3])
|
&& \is_array($oImapResponse->ResponseList[3])
|
||||||
&& 2 < count($oImapResponse->ResponseList[3])
|
&& 2 < \count($oImapResponse->ResponseList[3])
|
||||||
&& 'STORAGE' === strtoupper($oImapResponse->ResponseList[3][0])
|
&& 'STORAGE' === \strtoupper($oImapResponse->ResponseList[3][0])
|
||||||
&& is_numeric($oImapResponse->ResponseList[3][1])
|
&& \is_numeric($oImapResponse->ResponseList[3][1])
|
||||||
&& is_numeric($oImapResponse->ResponseList[3][2])
|
&& \is_numeric($oImapResponse->ResponseList[3][2])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$aReturn = array(
|
$aReturn = array(
|
||||||
|
|
@ -954,10 +954,10 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
if (5 < count($oImapResponse->ResponseList[3])
|
if (5 < \count($oImapResponse->ResponseList[3])
|
||||||
&& 'MESSAGE' === strtoupper($oImapResponse->ResponseList[3][3])
|
&& 'MESSAGE' === \strtoupper($oImapResponse->ResponseList[3][3])
|
||||||
&& is_numeric($oImapResponse->ResponseList[3][4])
|
&& \is_numeric($oImapResponse->ResponseList[3][4])
|
||||||
&& is_numeric($oImapResponse->ResponseList[3][5])
|
&& \is_numeric($oImapResponse->ResponseList[3][5])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$aReturn[2] = (int) $oImapResponse->ResponseList[3][4];
|
$aReturn[2] = (int) $oImapResponse->ResponseList[3][4];
|
||||||
|
|
@ -987,7 +987,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias
|
$sSearchCriterias = !\MailSo\Base\Validator::NotEmptyString($sSearchCriterias, true) || '*' === $sSearchCriterias
|
||||||
? 'ALL' : $sSearchCriterias;
|
? 'ALL' : $sSearchCriterias;
|
||||||
|
|
||||||
if (!is_array($aSortTypes) || 0 === count($aSortTypes))
|
if (!\is_array($aSortTypes) || 0 === \count($aSortTypes))
|
||||||
{
|
{
|
||||||
$this->writeLogException(
|
$this->writeLogException(
|
||||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||||
|
|
@ -1018,8 +1018,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
&& ($sCmd === $oImapResponse->StatusOrIndex ||
|
&& ($sCmd === $oImapResponse->StatusOrIndex ||
|
||||||
($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex) && !empty($oImapResponse->ResponseList[2]) &&
|
($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex) && !empty($oImapResponse->ResponseList[2]) &&
|
||||||
$sCmd === $oImapResponse->ResponseList[2])
|
$sCmd === $oImapResponse->ResponseList[2])
|
||||||
&& is_array($oImapResponse->ResponseList)
|
&& \is_array($oImapResponse->ResponseList)
|
||||||
&& 2 < count($oImapResponse->ResponseList))
|
&& 2 < \count($oImapResponse->ResponseList))
|
||||||
{
|
{
|
||||||
$iStart = 2;
|
$iStart = 2;
|
||||||
if ($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex &&
|
if ($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex &&
|
||||||
|
|
@ -1029,7 +1029,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$iStart = 3;
|
$iStart = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($iIndex = $iStart, $iLen = count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
for ($iIndex = $iStart, $iLen = \count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
||||||
{
|
{
|
||||||
$aReturn[] = (int) $oImapResponse->ResponseList[$iIndex];
|
$aReturn[] = (int) $oImapResponse->ResponseList[$iIndex];
|
||||||
}
|
}
|
||||||
|
|
@ -1203,14 +1203,14 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
public function MessageSimpleSearch($sSearchCriterias = 'ALL', $bReturnUid = true, $sCharset = '')
|
public function MessageSimpleSearch($sSearchCriterias = 'ALL', $bReturnUid = true, $sCharset = '')
|
||||||
{
|
{
|
||||||
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
|
$sCommandPrefix = ($bReturnUid) ? 'UID ' : '';
|
||||||
$sSearchCriterias = 0 === strlen($sSearchCriterias) || '*' === $sSearchCriterias
|
$sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias
|
||||||
? 'ALL' : $sSearchCriterias;
|
? 'ALL' : $sSearchCriterias;
|
||||||
|
|
||||||
$aRequest = array();
|
$aRequest = array();
|
||||||
if (0 < strlen($sCharset))
|
if (0 < \strlen($sCharset))
|
||||||
{
|
{
|
||||||
$aRequest[] = 'CHARSET';
|
$aRequest[] = 'CHARSET';
|
||||||
$aRequest[] = strtoupper($sCharset);
|
$aRequest[] = \strtoupper($sCharset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$aRequest[] = $sSearchCriterias;
|
$aRequest[] = $sSearchCriterias;
|
||||||
|
|
@ -1228,7 +1228,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
&& ($sCmd === $oImapResponse->StatusOrIndex ||
|
&& ($sCmd === $oImapResponse->StatusOrIndex ||
|
||||||
($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex) && !empty($oImapResponse->ResponseList[2]) &&
|
($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex) && !empty($oImapResponse->ResponseList[2]) &&
|
||||||
$sCmd === $oImapResponse->ResponseList[2])
|
$sCmd === $oImapResponse->ResponseList[2])
|
||||||
&& is_array($oImapResponse->ResponseList)
|
&& \is_array($oImapResponse->ResponseList)
|
||||||
&& 2 < count($oImapResponse->ResponseList))
|
&& 2 < count($oImapResponse->ResponseList))
|
||||||
{
|
{
|
||||||
$iStart = 2;
|
$iStart = 2;
|
||||||
|
|
@ -1239,14 +1239,14 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$iStart = 3;
|
$iStart = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($iIndex = $iStart, $iLen = count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
for ($iIndex = $iStart, $iLen = \count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
||||||
{
|
{
|
||||||
$aReturn[] = (int) $oImapResponse->ResponseList[$iIndex];
|
$aReturn[] = (int) $oImapResponse->ResponseList[$iIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$aReturn = array_reverse($aReturn);
|
$aReturn = \array_reverse($aReturn);
|
||||||
return $aReturn;
|
return $aReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1331,7 +1331,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
$aRequest = array();
|
$aRequest = array();
|
||||||
$aRequest[] = $sThreadType;
|
$aRequest[] = $sThreadType;
|
||||||
$aRequest[] = strtoupper($sCharset);
|
$aRequest[] = \strtoupper($sCharset);
|
||||||
$aRequest[] = $sSearchCriterias;
|
$aRequest[] = $sSearchCriterias;
|
||||||
|
|
||||||
$sCmd = 'THREAD';
|
$sCmd = 'THREAD';
|
||||||
|
|
@ -1348,8 +1348,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
&& ($sCmd === $oImapResponse->StatusOrIndex ||
|
&& ($sCmd === $oImapResponse->StatusOrIndex ||
|
||||||
($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex) && !empty($oImapResponse->ResponseList[2]) &&
|
($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex) && !empty($oImapResponse->ResponseList[2]) &&
|
||||||
$sCmd === $oImapResponse->ResponseList[2])
|
$sCmd === $oImapResponse->ResponseList[2])
|
||||||
&& is_array($oImapResponse->ResponseList)
|
&& \is_array($oImapResponse->ResponseList)
|
||||||
&& 2 < count($oImapResponse->ResponseList))
|
&& 2 < \count($oImapResponse->ResponseList))
|
||||||
{
|
{
|
||||||
$iStart = 2;
|
$iStart = 2;
|
||||||
if ($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex &&
|
if ($bReturnUid && 'UID' === $oImapResponse->StatusOrIndex &&
|
||||||
|
|
@ -1359,7 +1359,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$iStart = 3;
|
$iStart = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($iIndex = $iStart, $iLen = count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
for ($iIndex = $iStart, $iLen = \count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
||||||
{
|
{
|
||||||
$aNewValue = $this->validateThreadItem($oImapResponse->ResponseList[$iIndex]);
|
$aNewValue = $this->validateThreadItem($oImapResponse->ResponseList[$iIndex]);
|
||||||
if (false !== $aNewValue)
|
if (false !== $aNewValue)
|
||||||
|
|
@ -1386,7 +1386,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function MessageCopy($sToFolder, $sIndexRange, $bIndexIsUid)
|
public function MessageCopy($sToFolder, $sIndexRange, $bIndexIsUid)
|
||||||
{
|
{
|
||||||
if (0 === strlen($sIndexRange))
|
if (0 === \strlen($sIndexRange))
|
||||||
{
|
{
|
||||||
$this->writeLogException(
|
$this->writeLogException(
|
||||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||||
|
|
@ -1411,7 +1411,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function MessageMove($sToFolder, $sIndexRange, $bIndexIsUid)
|
public function MessageMove($sToFolder, $sIndexRange, $bIndexIsUid)
|
||||||
{
|
{
|
||||||
if (0 === strlen($sIndexRange))
|
if (0 === \strlen($sIndexRange))
|
||||||
{
|
{
|
||||||
$this->writeLogException(
|
$this->writeLogException(
|
||||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||||
|
|
@ -1440,12 +1440,12 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function MessageExpunge($sUidRangeIfSupported = '', $bForceUidExpunge = false)
|
public function MessageExpunge($sUidRangeIfSupported = '', $bForceUidExpunge = false)
|
||||||
{
|
{
|
||||||
$sUidRangeIfSupported = trim($sUidRangeIfSupported);
|
$sUidRangeIfSupported = \trim($sUidRangeIfSupported);
|
||||||
|
|
||||||
$sCmd = 'EXPUNGE';
|
$sCmd = 'EXPUNGE';
|
||||||
$aArguments = array();
|
$aArguments = array();
|
||||||
|
|
||||||
if ($bForceUidExpunge && 0 < strlen($sUidRangeIfSupported) && $this->IsSupported('UIDPLUS'))
|
if ($bForceUidExpunge && 0 < \strlen($sUidRangeIfSupported) && $this->IsSupported('UIDPLUS'))
|
||||||
{
|
{
|
||||||
$sCmd = 'UID '.$sCmd;
|
$sCmd = 'UID '.$sCmd;
|
||||||
$aArguments = array($sUidRangeIfSupported);
|
$aArguments = array($sUidRangeIfSupported);
|
||||||
|
|
@ -1470,14 +1470,13 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true) ||
|
if (!\MailSo\Base\Validator::NotEmptyString($sIndexRange, true) ||
|
||||||
!\MailSo\Base\Validator::NotEmptyString($sStoreAction, true) ||
|
!\MailSo\Base\Validator::NotEmptyString($sStoreAction, true) ||
|
||||||
0 === count($aInputStoreItems))
|
0 === \count($aInputStoreItems))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sCmd = ($bIndexIsUid) ? 'UID STORE' : 'STORE';
|
$sCmd = ($bIndexIsUid) ? 'UID STORE' : 'STORE';
|
||||||
return $this->SendRequestWithCheck($sCmd,
|
return $this->SendRequestWithCheck($sCmd, array($sIndexRange, $sStoreAction, $aInputStoreItems));
|
||||||
array($sIndexRange, $sStoreAction, $aInputStoreItems));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1517,15 +1516,15 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
if (null !== $iUid)
|
if (null !== $iUid)
|
||||||
{
|
{
|
||||||
$aLastResponse = $this->GetLastResponse();
|
$aLastResponse = $this->GetLastResponse();
|
||||||
if (is_array($aLastResponse) && 0 < count($aLastResponse) && $aLastResponse[count($aLastResponse) - 1])
|
if (\is_array($aLastResponse) && 0 < \count($aLastResponse) && $aLastResponse[\count($aLastResponse) - 1])
|
||||||
{
|
{
|
||||||
$oLast = $aLastResponse[count($aLastResponse) - 1];
|
$oLast = $aLastResponse[count($aLastResponse) - 1];
|
||||||
if ($oLast && \MailSo\Imap\Enumerations\ResponseType::TAGGED === $oLast->ResponseType && is_array($oLast->OptionalResponse))
|
if ($oLast && \MailSo\Imap\Enumerations\ResponseType::TAGGED === $oLast->ResponseType && \is_array($oLast->OptionalResponse))
|
||||||
{
|
{
|
||||||
if (0 < strlen($oLast->OptionalResponse[0]) &&
|
if (0 < \strlen($oLast->OptionalResponse[0]) &&
|
||||||
0 < strlen($oLast->OptionalResponse[2]) &&
|
0 < \strlen($oLast->OptionalResponse[2]) &&
|
||||||
'APPENDUID' === strtoupper($oLast->OptionalResponse[0]) &&
|
'APPENDUID' === strtoupper($oLast->OptionalResponse[0]) &&
|
||||||
is_numeric($oLast->OptionalResponse[2])
|
\is_numeric($oLast->OptionalResponse[2])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$iUid = (int) $oLast->OptionalResponse[2];
|
$iUid = (int) $oLast->OptionalResponse[2];
|
||||||
|
|
@ -1556,7 +1555,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function SendRequest($sCommand, $aParams = array())
|
public function SendRequest($sCommand, $aParams = array())
|
||||||
{
|
{
|
||||||
if (!\MailSo\Base\Validator::NotEmptyString($sCommand, true) || !is_array($aParams))
|
if (!\MailSo\Base\Validator::NotEmptyString($sCommand, true) || !\is_array($aParams))
|
||||||
{
|
{
|
||||||
$this->writeLogException(
|
$this->writeLogException(
|
||||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||||
|
|
@ -1567,7 +1566,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
$sTag = $this->getNewTag();
|
$sTag = $this->getNewTag();
|
||||||
|
|
||||||
$sCommand = trim($sCommand);
|
$sCommand = \trim($sCommand);
|
||||||
$sRealCommand = $sTag.' '.$sCommand.$this->prepearParamLine($aParams);
|
$sRealCommand = $sTag.' '.$sCommand.$this->prepearParamLine($aParams);
|
||||||
|
|
||||||
$sFakeCommand = '';
|
$sFakeCommand = '';
|
||||||
|
|
@ -1577,7 +1576,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$sFakeCommand = $sTag.' '.$sCommand.$this->prepearParamLine($aFakeParams);
|
$sFakeCommand = $sTag.' '.$sCommand.$this->prepearParamLine($aFakeParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->aTagTimeouts[$sTag] = microtime(true);
|
$this->aTagTimeouts[$sTag] = \microtime(true);
|
||||||
$this->sendRaw($sRealCommand, true, $sFakeCommand);
|
$this->sendRaw($sRealCommand, true, $sFakeCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1594,7 +1593,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
case 'LOGIN':
|
case 'LOGIN':
|
||||||
$aResult = $aParams;
|
$aResult = $aParams;
|
||||||
if (is_array($aResult) && 2 === count($aResult))
|
if (\is_array($aResult) && 2 === count($aResult))
|
||||||
{
|
{
|
||||||
$aResult[1] = '"*******"';
|
$aResult[1] = '"*******"';
|
||||||
}
|
}
|
||||||
|
|
@ -1642,7 +1641,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
private function validateResponse($aResult)
|
private function validateResponse($aResult)
|
||||||
{
|
{
|
||||||
if (!is_array($aResult) || 0 === $iCnt = count($aResult))
|
if (!\is_array($aResult) || 0 === $iCnt = \count($aResult))
|
||||||
{
|
{
|
||||||
$this->writeLogException(
|
$this->writeLogException(
|
||||||
new Exceptions\ResponseNotFoundException(),
|
new Exceptions\ResponseNotFoundException(),
|
||||||
|
|
@ -1677,7 +1676,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
protected function parseResponse($sEndTag = null, $bFindCapa = false)
|
protected function parseResponse($sEndTag = null, $bFindCapa = false)
|
||||||
{
|
{
|
||||||
if (is_resource($this->rConnect))
|
if (\is_resource($this->rConnect))
|
||||||
{
|
{
|
||||||
$oImapResponse = null;
|
$oImapResponse = null;
|
||||||
$sEndTag = (null === $sEndTag) ? $this->getCurrentTag() : $sEndTag;
|
$sEndTag = (null === $sEndTag) ? $this->getCurrentTag() : $sEndTag;
|
||||||
|
|
@ -1705,7 +1704,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
{
|
{
|
||||||
if (isset($this->aTagTimeouts[$sEndTag]))
|
if (isset($this->aTagTimeouts[$sEndTag]))
|
||||||
{
|
{
|
||||||
$this->writeLog((microtime(true) - $this->aTagTimeouts[$sEndTag]).' ('.$sEndTag.')',
|
$this->writeLog((\microtime(true) - $this->aTagTimeouts[$sEndTag]).' ('.$sEndTag.')',
|
||||||
\MailSo\Log\Enumerations\Type::TIME);
|
\MailSo\Log\Enumerations\Type::TIME);
|
||||||
|
|
||||||
unset($this->aTagTimeouts[$sEndTag]);
|
unset($this->aTagTimeouts[$sEndTag]);
|
||||||
|
|
@ -1749,24 +1748,24 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
private function initCapabilityImapResponse($oImapResponse)
|
private function initCapabilityImapResponse($oImapResponse)
|
||||||
{
|
{
|
||||||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
|
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType
|
||||||
&& is_array($oImapResponse->ResponseList))
|
&& \is_array($oImapResponse->ResponseList))
|
||||||
{
|
{
|
||||||
$aList = null;
|
$aList = null;
|
||||||
if (isset($oImapResponse->ResponseList[1]) && is_string($oImapResponse->ResponseList[1]) &&
|
if (isset($oImapResponse->ResponseList[1]) && \is_string($oImapResponse->ResponseList[1]) &&
|
||||||
'CAPABILITY' === strtoupper($oImapResponse->ResponseList[1]))
|
'CAPABILITY' === \strtoupper($oImapResponse->ResponseList[1]))
|
||||||
{
|
{
|
||||||
$aList = array_slice($oImapResponse->ResponseList, 2);
|
$aList = \array_slice($oImapResponse->ResponseList, 2);
|
||||||
}
|
}
|
||||||
else if ($oImapResponse->OptionalResponse && is_array($oImapResponse->OptionalResponse) &&
|
else if ($oImapResponse->OptionalResponse && \is_array($oImapResponse->OptionalResponse) &&
|
||||||
1 < count($oImapResponse->OptionalResponse) && is_string($oImapResponse->OptionalResponse[0]) &&
|
1 < \count($oImapResponse->OptionalResponse) && \is_string($oImapResponse->OptionalResponse[0]) &&
|
||||||
'CAPABILITY' === strtoupper($oImapResponse->OptionalResponse[0]))
|
'CAPABILITY' === \strtoupper($oImapResponse->OptionalResponse[0]))
|
||||||
{
|
{
|
||||||
$aList = array_slice($oImapResponse->OptionalResponse, 1);
|
$aList = \array_slice($oImapResponse->OptionalResponse, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($aList) && 0 < count($aList))
|
if (\is_array($aList) && 0 < \count($aList))
|
||||||
{
|
{
|
||||||
$this->aCapabilityItems = array_map('strtoupper', $aList);
|
$this->aCapabilityItems = \array_map('strtoupper', $aList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2115,13 +2114,13 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$sAtomBuilder = '';
|
$sAtomBuilder = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sAtomBuilder .= substr($this->sResponseBuffer, $iCharBlockStartPos, $iPos - $iCharBlockStartPos + 1);
|
$sAtomBuilder .= \substr($this->sResponseBuffer, $iCharBlockStartPos, $iPos - $iCharBlockStartPos + 1);
|
||||||
|
|
||||||
$iPos++;
|
$iPos++;
|
||||||
$this->iResponseBufParsedPos = $iPos;
|
$this->iResponseBufParsedPos = $iPos;
|
||||||
|
|
||||||
$sListBlock = $this->partialParseResponseBranch($mNull, $iStackIndex, true,
|
$sListBlock = $this->partialParseResponseBranch($mNull, $iStackIndex, true,
|
||||||
null === $sPreviousAtomUpperCase ? '' : strtoupper($sPreviousAtomUpperCase));
|
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase));
|
||||||
|
|
||||||
if (null !== $sListBlock)
|
if (null !== $sListBlock)
|
||||||
{
|
{
|
||||||
|
|
@ -2144,7 +2143,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
if ($iPos > $iCharBlockStartPos || null !== $sAtomBuilder)
|
if ($iPos > $iCharBlockStartPos || null !== $sAtomBuilder)
|
||||||
{
|
{
|
||||||
$sLastCharBlock = substr($this->sResponseBuffer, $iCharBlockStartPos, $iPos - $iCharBlockStartPos);
|
$sLastCharBlock = \substr($this->sResponseBuffer, $iCharBlockStartPos, $iPos - $iCharBlockStartPos);
|
||||||
if (null === $sAtomBuilder)
|
if (null === $sAtomBuilder)
|
||||||
{
|
{
|
||||||
$aList[] = $sLastCharBlock;
|
$aList[] = $sLastCharBlock;
|
||||||
|
|
@ -2164,9 +2163,9 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
if (null !== $oImapResponse)
|
if (null !== $oImapResponse)
|
||||||
{
|
{
|
||||||
// if (1 === count($aList))
|
// if (1 === \count($aList))
|
||||||
if (!$bCountOneInited && 1 === count($aList))
|
if (!$bCountOneInited && 1 === \count($aList))
|
||||||
// if (isset($aList[0]) && !isset($aList[1])) // fast 1 === count($aList)
|
// if (isset($aList[0]) && !isset($aList[1])) // fast 1 === \count($aList)
|
||||||
{
|
{
|
||||||
$bCountOneInited = true;
|
$bCountOneInited = true;
|
||||||
|
|
||||||
|
|
@ -2188,9 +2187,9 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$oImapResponse->ResponseType = \MailSo\Imap\Enumerations\ResponseType::UNKNOWN;
|
$oImapResponse->ResponseType = \MailSo\Imap\Enumerations\ResponseType::UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if (2 === count($aList))
|
// else if (2 === \count($aList))
|
||||||
else if (!$bCountTwoInited && 2 === count($aList))
|
else if (!$bCountTwoInited && 2 === \count($aList))
|
||||||
// else if (isset($aList[1]) && !isset($aList[2])) // fast 2 === count($aList)
|
// else if (isset($aList[1]) && !isset($aList[2])) // fast 2 === \count($aList)
|
||||||
{
|
{
|
||||||
$bCountTwoInited = true;
|
$bCountTwoInited = true;
|
||||||
|
|
||||||
|
|
@ -2244,19 +2243,19 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
private function partialResponseLiteralCallbackCallable($sParent, $sLiteralAtomUpperCase, $rImapStream, $iLiteralLen)
|
private function partialResponseLiteralCallbackCallable($sParent, $sLiteralAtomUpperCase, $rImapStream, $iLiteralLen)
|
||||||
{
|
{
|
||||||
$sLiteralAtomUpperCasePeek = '';
|
$sLiteralAtomUpperCasePeek = '';
|
||||||
if (0 === strpos($sLiteralAtomUpperCase, 'BODY'))
|
if (0 === \strpos($sLiteralAtomUpperCase, 'BODY'))
|
||||||
{
|
{
|
||||||
$sLiteralAtomUpperCasePeek = str_replace('BODY', 'BODY.PEEK', $sLiteralAtomUpperCase);
|
$sLiteralAtomUpperCasePeek = \str_replace('BODY', 'BODY.PEEK', $sLiteralAtomUpperCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sFetchKey = '';
|
$sFetchKey = '';
|
||||||
if (is_array($this->aFetchCallbacks))
|
if (\is_array($this->aFetchCallbacks))
|
||||||
{
|
{
|
||||||
if (0 < strlen($sLiteralAtomUpperCasePeek) && isset($this->aFetchCallbacks[$sLiteralAtomUpperCasePeek]))
|
if (0 < \strlen($sLiteralAtomUpperCasePeek) && isset($this->aFetchCallbacks[$sLiteralAtomUpperCasePeek]))
|
||||||
{
|
{
|
||||||
$sFetchKey = $sLiteralAtomUpperCasePeek;
|
$sFetchKey = $sLiteralAtomUpperCasePeek;
|
||||||
}
|
}
|
||||||
else if (0 < strlen($sLiteralAtomUpperCase) && isset($this->aFetchCallbacks[$sLiteralAtomUpperCase]))
|
else if (0 < \strlen($sLiteralAtomUpperCase) && isset($this->aFetchCallbacks[$sLiteralAtomUpperCase]))
|
||||||
{
|
{
|
||||||
$sFetchKey = $sLiteralAtomUpperCase;
|
$sFetchKey = $sLiteralAtomUpperCase;
|
||||||
}
|
}
|
||||||
|
|
@ -2270,7 +2269,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
\MailSo\Base\StreamWrappers\Literal::CreateStream($rImapStream, $iLiteralLen);
|
\MailSo\Base\StreamWrappers\Literal::CreateStream($rImapStream, $iLiteralLen);
|
||||||
|
|
||||||
$bResult = true;
|
$bResult = true;
|
||||||
$this->writeLog('Callback for '.$sParent.' / '.$sLiteralAtomUpperCase.
|
$this->writeLog('Start Callback for '.$sParent.' / '.$sLiteralAtomUpperCase.
|
||||||
' - try to read '.$iLiteralLen.' bytes.', \MailSo\Log\Enumerations\Type::NOTE);
|
' - try to read '.$iLiteralLen.' bytes.', \MailSo\Log\Enumerations\Type::NOTE);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -2284,31 +2283,53 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
$this->writeLogException($oException);
|
$this->writeLogException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
$iNotReadLiteralLen = 0;
|
if (\is_resource($rImapLiteralStream))
|
||||||
while (!\feof($rImapLiteralStream))
|
|
||||||
{
|
{
|
||||||
$sBuf = \fread($rImapLiteralStream, 8192);
|
$iNotReadLiteralLen = 0;
|
||||||
if (false !== $sBuf)
|
|
||||||
{
|
|
||||||
\MailSo\Base\Utils::ResetTimeLimit();
|
|
||||||
$iNotReadLiteralLen += \strlen($sBuf);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($iNotReadLiteralLen > 0)
|
$bFeof = \feof($rImapLiteralStream);
|
||||||
|
$this->writeLog('End Callback for '.$sParent.' / '.$sLiteralAtomUpperCase.
|
||||||
|
' - feof = '.($bFeof ? 'good' : 'BAD'), $bFeof ?
|
||||||
|
\MailSo\Log\Enumerations\Type::NOTE : \MailSo\Log\Enumerations\Type::WARNING);
|
||||||
|
|
||||||
|
if (!$bFeof)
|
||||||
|
{
|
||||||
|
while (!@\feof($rImapLiteralStream))
|
||||||
|
{
|
||||||
|
$sBuf = @\fread($rImapLiteralStream, 1024 * 1024);
|
||||||
|
if (false === $sBuf || 0 === \strlen($sBuf) || null === $sBuf)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
\MailSo\Base\Utils::ResetTimeLimit();
|
||||||
|
$iNotReadLiteralLen += \strlen($sBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\is_resource($rImapLiteralStream) && !@\feof($rImapLiteralStream))
|
||||||
|
{
|
||||||
|
@\stream_get_contents($rImapLiteralStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\is_resource($rImapLiteralStream))
|
||||||
|
{
|
||||||
|
@\fclose($rImapLiteralStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($iNotReadLiteralLen > 0)
|
||||||
|
{
|
||||||
|
$this->writeLog('Not read literal size is '.$iNotReadLiteralLen.' bytes.',
|
||||||
|
\MailSo\Log\Enumerations\Type::WARNING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$this->writeLog('Not read literal size '.$iNotReadLiteralLen.' bytes.',
|
$this->writeLog('Literal stream is not resource after callback.',
|
||||||
\MailSo\Log\Enumerations\Type::WARNING);
|
\MailSo\Log\Enumerations\Type::WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
\MailSo\Base\Loader::IncStatistic('NetRead', $iLiteralLen);
|
\MailSo\Base\Loader::IncStatistic('NetRead', $iLiteralLen);
|
||||||
|
|
||||||
if (\is_resource($rImapLiteralStream))
|
|
||||||
{
|
|
||||||
\fclose($rImapLiteralStream);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bResult;
|
return $bResult;
|
||||||
|
|
@ -2363,7 +2384,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
*/
|
*/
|
||||||
public function EscapeString($sStringForEscape)
|
public function EscapeString($sStringForEscape)
|
||||||
{
|
{
|
||||||
return '"'.str_replace(array('\\', '"'), array('\\\\', '\\"'), $sStringForEscape).'"';
|
return '"'.\str_replace(array('\\', '"'), array('\\\\', '\\"'), $sStringForEscape).'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@ abstract class Driver
|
||||||
*/
|
*/
|
||||||
protected $aPrefixes;
|
protected $aPrefixes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $bGuidPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
|
@ -62,6 +67,7 @@ abstract class Driver
|
||||||
$this->sName = 'INFO';
|
$this->sName = 'INFO';
|
||||||
$this->bTimePrefix = true;
|
$this->bTimePrefix = true;
|
||||||
$this->bTypedPrefix = true;
|
$this->bTypedPrefix = true;
|
||||||
|
$this->bGuidPrefix = true;
|
||||||
|
|
||||||
$this->iWriteOnTimeoutOnly = 0;
|
$this->iWriteOnTimeoutOnly = 0;
|
||||||
$this->bWriteOnErrorOnly = false;
|
$this->bWriteOnErrorOnly = false;
|
||||||
|
|
@ -80,6 +86,15 @@ abstract class Driver
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \MailSo\Log\Driver
|
||||||
|
*/
|
||||||
|
public function DisableGuidPrefix()
|
||||||
|
{
|
||||||
|
$this->bGuidPrefix = false;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \MailSo\Log\Driver
|
* @return \MailSo\Log\Driver
|
||||||
*/
|
*/
|
||||||
|
|
@ -150,9 +165,11 @@ abstract class Driver
|
||||||
protected function loggerLineImplementation($sTimePrefix, $sDesc,
|
protected function loggerLineImplementation($sTimePrefix, $sDesc,
|
||||||
$iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '')
|
$iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '')
|
||||||
{
|
{
|
||||||
return ($this->bTimePrefix ? '['.$sTimePrefix.'] ' : '').
|
return \ltrim(
|
||||||
($this->bTypedPrefix ? $this->getTypedPrefix($iType, $sName) : '').
|
($this->bTimePrefix ? '['.$sTimePrefix.']' : '').
|
||||||
$sDesc;
|
($this->bGuidPrefix ? '['.\MailSo\Log\Logger::Guid().']' : '').
|
||||||
|
($this->bTypedPrefix ? ' '.$this->getTypedPrefix($iType, $sName) : '')
|
||||||
|
).$sDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -215,6 +232,7 @@ abstract class Driver
|
||||||
array_unshift($this->aCache, $sFlush);
|
array_unshift($this->aCache, $sFlush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->aCache[] = '--- FlushLogCache: Trigger';
|
||||||
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
|
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
|
||||||
|
|
||||||
$this->bFlushCache = true;
|
$this->bFlushCache = true;
|
||||||
|
|
@ -234,6 +252,7 @@ abstract class Driver
|
||||||
array_unshift($this->aCache, $sFlush);
|
array_unshift($this->aCache, $sFlush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->aCache[] = '--- FlushLogCache: Trigger';
|
||||||
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
|
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
|
||||||
|
|
||||||
$this->bFlushCache = true;
|
$this->bFlushCache = true;
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,22 @@ class Logger extends \MailSo\Base\Collection
|
||||||
return $oInstance;
|
return $oInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @staticvar string $sCache;
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function Guid()
|
||||||
|
{
|
||||||
|
static $sCache = null;
|
||||||
|
if (null === $sCache)
|
||||||
|
{
|
||||||
|
$sCache = \substr(\md5(\microtime(true).\rand(10000, 99999)), -8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sCache;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -792,12 +792,13 @@ class Actions
|
||||||
$this->oLogger->WriteEmptyLine();
|
$this->oLogger->WriteEmptyLine();
|
||||||
|
|
||||||
$oHttp = $this->Http();
|
$oHttp = $this->Http();
|
||||||
$this->oLogger->Write(
|
$this->oLogger->Write('[DATE:'.\gmdate('d.m.y').'][RL:'.APP_VERSION.'][PHP:'.PHP_VERSION.'][IP:'.
|
||||||
$oHttp->GetMethod().': '.$oHttp->GetHost(false, false).$oHttp->GetServer('REQUEST_URI', ''),
|
$oHttp->GetClientIp().'][PID:'.(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? \getmypid() : 'unknown').
|
||||||
\MailSo\Log\Enumerations\Type::NOTE, 'REQUEST');
|
'][GUID:'.\MailSo\Log\Logger::Guid().']');
|
||||||
|
|
||||||
$this->oLogger->Write('[PHP:'.PHP_VERSION.'][RL:'.APP_VERSION.'][DATE:'.\gmdate('d.m.y').'][IP:'.
|
$this->oLogger->Write(
|
||||||
$oHttp->GetClientIp().'][PID:'.(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? \getmypid() : 'unknown').']');
|
' ['.$oHttp->GetMethod().'] '.$oHttp->GetScheme().'://'.$oHttp->GetHost(false, false).$oHttp->GetServer('REQUEST_URI', ''),
|
||||||
|
\MailSo\Log\Enumerations\Type::NOTE, 'REQUEST');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7287,7 +7288,7 @@ class Actions
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mResult = '['.\get_class($mResponse).']';
|
$mResult = '["'.\get_class($mResponse).'"]';
|
||||||
$bHook = false;
|
$bHook = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,8 @@ class ServiceActions
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Logger()->Write(\MailSo\Base\Utils::Php2js($aPost), \MailSo\Log\Enumerations\Type::INFO, 'POST', true);
|
$this->Logger()->Write(\MailSo\Base\Utils::Php2js($aPost, $this->Logger()),
|
||||||
|
\MailSo\Log\Enumerations\Type::INFO, 'POST', true);
|
||||||
}
|
}
|
||||||
else if (3 < \count($this->aPaths) && $this->oHttp->IsGet())
|
else if (3 < \count($this->aPaths) && $this->oHttp->IsGet())
|
||||||
{
|
{
|
||||||
|
|
@ -195,7 +196,7 @@ class ServiceActions
|
||||||
$this->Plugins()->RunHook('filter.ajax-response', array($sAction, &$aResponseItem));
|
$this->Plugins()->RunHook('filter.ajax-response', array($sAction, &$aResponseItem));
|
||||||
|
|
||||||
@\header('Content-Type: application/json; charset=utf-8');
|
@\header('Content-Type: application/json; charset=utf-8');
|
||||||
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem);
|
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, $this->Logger());
|
||||||
|
|
||||||
$sObResult = @\ob_get_clean();
|
$sObResult = @\ob_get_clean();
|
||||||
|
|
||||||
|
|
@ -299,7 +300,7 @@ class ServiceActions
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Plugins()->RunHook('filter.upload-response', array(&$aResponseItem));
|
$this->Plugins()->RunHook('filter.upload-response', array(&$aResponseItem));
|
||||||
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem);
|
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, $this->Logger());
|
||||||
|
|
||||||
$sObResult = @\ob_get_clean();
|
$sObResult = @\ob_get_clean();
|
||||||
if (0 < \strlen($sObResult))
|
if (0 < \strlen($sObResult))
|
||||||
|
|
@ -620,7 +621,7 @@ class ServiceActions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bJson ? \MailSo\Base\Utils::Php2js(array($sTheme, $sResult)) : $sResult;
|
return $bJson ? \MailSo\Base\Utils::Php2js(array($sTheme, $sResult), $this->Logger()) : $sResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -886,7 +887,7 @@ class ServiceActions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return \MailSo\Base\Utils::Php2js($aResult);
|
return \MailSo\Base\Utils::Php2js($aResult, $this->Logger());
|
||||||
|
|
||||||
case 'redirect':
|
case 'redirect':
|
||||||
default:
|
default:
|
||||||
|
|
@ -925,7 +926,7 @@ class ServiceActions
|
||||||
return \MailSo\Base\Utils::Php2js(array(
|
return \MailSo\Base\Utils::Php2js(array(
|
||||||
'Action' => 'ExternalSso',
|
'Action' => 'ExternalSso',
|
||||||
'Result' => $sResult
|
'Result' => $sResult
|
||||||
));
|
), $this->Logger());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1038,7 +1039,7 @@ class ServiceActions
|
||||||
\RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH.'app/templates/Views/Common', $this->oActions).
|
\RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH.'app/templates/Views/Common', $this->oActions).
|
||||||
$this->oActions->Plugins()->CompileTemplate($bAdmin);
|
$this->oActions->Plugins()->CompileTemplate($bAdmin);
|
||||||
|
|
||||||
return 'window.rainloopTEMPLATES='.\MailSo\Base\Utils::Php2js(array($sHtml)).';';
|
return 'window.rainloopTEMPLATES='.\MailSo\Base\Utils::Php2js(array($sHtml), $this->Logger()).';';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue