mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
More functions without type hinting found and fixt
Use PECL yaml (else Spyc) Upgrade Spyc (with removed dump code)
This commit is contained in:
parent
cd3d8b94b2
commit
75b4b64118
43 changed files with 893 additions and 1482 deletions
|
|
@ -456,7 +456,7 @@ class Http
|
|||
}
|
||||
}
|
||||
|
||||
if (\is_array($aHttpHeaders) && 0 < \count($aHttpHeaders))
|
||||
if (0 < \count($aHttpHeaders))
|
||||
{
|
||||
$aOptions[CURLOPT_HTTPHEADER] = $aHttpHeaders;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ END;
|
|||
{
|
||||
$sResultHeaders = $sIncHeaders;
|
||||
|
||||
if (\is_array($aHeadersToRemove) && 0 < \count($aHeadersToRemove))
|
||||
if ($aHeadersToRemove)
|
||||
{
|
||||
$aHeadersToRemove = \array_map('strtolower', $aHeadersToRemove);
|
||||
|
||||
|
|
@ -1016,19 +1016,16 @@ END;
|
|||
|
||||
public static function ClearArrayUtf8Values(array &$aInput)
|
||||
{
|
||||
if (\is_array($aInput))
|
||||
foreach ($aInput as $mKey => $mItem)
|
||||
{
|
||||
foreach ($aInput as $mKey => $mItem)
|
||||
if (\is_string($mItem))
|
||||
{
|
||||
if (\is_string($mItem))
|
||||
{
|
||||
$aInput[$mKey] = static::Utf8Clear($mItem);
|
||||
}
|
||||
else if (\is_array($mItem))
|
||||
{
|
||||
static::ClearArrayUtf8Values($mItem);
|
||||
$aInput[$mKey] = $mItem;
|
||||
}
|
||||
$aInput[$mKey] = static::Utf8Clear($mItem);
|
||||
}
|
||||
else if (\is_array($mItem))
|
||||
{
|
||||
static::ClearArrayUtf8Values($mItem);
|
||||
$aInput[$mKey] = $mItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1046,11 +1043,6 @@ END;
|
|||
$oLogger = \MailSo\Config::$SystemLogger;
|
||||
}
|
||||
|
||||
if (!($oLogger instanceof \MailSo\Log\Logger))
|
||||
{
|
||||
$oLogger = null;
|
||||
}
|
||||
|
||||
if ($oLogger)
|
||||
{
|
||||
$oLogger->Write('json_encode: '.\trim(
|
||||
|
|
@ -1355,7 +1347,7 @@ END;
|
|||
public static function PrepareFetchSequence(array $aSequence) : string
|
||||
{
|
||||
$aResult = array();
|
||||
if (\is_array($aSequence) && 0 < \count($aSequence))
|
||||
if (0 < \count($aSequence))
|
||||
{
|
||||
$iStart = null;
|
||||
$iPrev = null;
|
||||
|
|
@ -1431,7 +1423,7 @@ END;
|
|||
public static function MultipleStreamWriter($rRead, array $aWrite, int $iBufferLen = 8192, bool $bResetTimeLimit = true, bool $bFixCrLf = false, bool $bRewindOnComplete = false) : int
|
||||
{
|
||||
$mResult = false;
|
||||
if ($rRead && \is_array($aWrite) && 0 < \count($aWrite))
|
||||
if ($rRead && 0 < \count($aWrite))
|
||||
{
|
||||
$mResult = 0;
|
||||
while (!\feof($rRead))
|
||||
|
|
@ -1792,18 +1784,16 @@ END;
|
|||
if (null === $aCache)
|
||||
{
|
||||
$sDisableFunctions = \ini_get('disable_functions');
|
||||
$sDisableFunctions = \is_string($sDisableFunctions) && 0 < \strlen($sDisableFunctions) ? $sDisableFunctions : '';
|
||||
$sDisableFunctions = \is_string($sDisableFunctions) ? $sDisableFunctions : '';
|
||||
|
||||
$aCache = \explode(',', $sDisableFunctions);
|
||||
$aCache = \is_array($aCache) && 0 < \count($aCache) ? $aCache : array();
|
||||
|
||||
if (\extension_loaded('suhosin'))
|
||||
{
|
||||
$sSuhosin = \ini_get('suhosin.executor.func.blacklist');
|
||||
$sSuhosin = \is_string($sSuhosin) && 0 < \strlen($sSuhosin) ? $sSuhosin : '';
|
||||
$sSuhosin = \is_string($sSuhosin) ? $sSuhosin : '';
|
||||
|
||||
$aSuhosinCache = \explode(',', $sSuhosin);
|
||||
$aSuhosinCache = \is_array($aSuhosinCache) && 0 < \count($aSuhosinCache) ? $aSuhosinCache : array();
|
||||
|
||||
if (0 < \count($aSuhosinCache))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class CacheClient
|
|||
return '1' === $this->Get($sKey.'/LOCK');
|
||||
}
|
||||
|
||||
public function Get($sKey, $bClearAfterGet = false)
|
||||
public function Get(string $sKey, bool $bClearAfterGet = false)
|
||||
{
|
||||
$sValue = '';
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class BodyStructure
|
|||
|
||||
private function __construct(string $sContentType, ?string $sCharset, array $aBodyParams, ?string $sContentID,
|
||||
?string $sDescription, ?string $sMailEncodingName, ?string $sDisposition, ?array $aDispositionParams, string $sFileName,
|
||||
?string $sLanguage, ?string $sLocation, int $iSize, int $iTextLineCount, string $sPartID, ?array $aSubParts)
|
||||
?string $sLanguage, ?string $sLocation, int $iSize, int $iTextLineCount, string $sPartID, array $aSubParts)
|
||||
{
|
||||
$this->sContentType = $sContentType;
|
||||
$this->sCharset = $sCharset;
|
||||
|
|
@ -113,50 +113,32 @@ class BodyStructure
|
|||
$this->aSubParts = $aSubParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* return string
|
||||
*/
|
||||
public function MailEncodingName()
|
||||
public function MailEncodingName() : ?string
|
||||
{
|
||||
return $this->sMailEncodingName;
|
||||
}
|
||||
|
||||
/**
|
||||
* return string
|
||||
*/
|
||||
public function PartID()
|
||||
public function PartID() : string
|
||||
{
|
||||
return (string) $this->sPartID;
|
||||
}
|
||||
|
||||
/**
|
||||
* return string
|
||||
*/
|
||||
public function FileName()
|
||||
public function FileName() : string
|
||||
{
|
||||
return $this->sFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* return string
|
||||
*/
|
||||
public function ContentType()
|
||||
public function ContentType() : string
|
||||
{
|
||||
return $this->sContentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* return int
|
||||
*/
|
||||
public function Size()
|
||||
public function Size() : int
|
||||
{
|
||||
return (int) $this->iSize;
|
||||
return $this->iSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* return int
|
||||
*/
|
||||
public function EstimatedSize()
|
||||
public function EstimatedSize() : int
|
||||
{
|
||||
$fCoefficient = 1;
|
||||
switch (\strtolower($this->MailEncodingName()))
|
||||
|
|
@ -172,52 +154,33 @@ class BodyStructure
|
|||
return (int) ($this->Size() * $fCoefficient);
|
||||
}
|
||||
|
||||
/**
|
||||
* return string
|
||||
*/
|
||||
public function Charset()
|
||||
public function Charset() : ?string
|
||||
{
|
||||
return $this->sCharset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return string
|
||||
*/
|
||||
public function ContentID()
|
||||
public function ContentID() : string
|
||||
{
|
||||
return (null === $this->sContentID) ? '' : $this->sContentID;
|
||||
}
|
||||
|
||||
/**
|
||||
* return string
|
||||
*/
|
||||
public function ContentLocation()
|
||||
public function ContentLocation() : string
|
||||
{
|
||||
return (null === $this->sLocation) ? '' : $this->sLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* return bool
|
||||
*/
|
||||
public function IsInline()
|
||||
public function IsInline() : bool
|
||||
{
|
||||
return (null === $this->sDisposition) ?
|
||||
(0 < \strlen($this->ContentID())) : ('inline' === strtolower($this->sDisposition));
|
||||
}
|
||||
|
||||
/**
|
||||
* return bool
|
||||
*/
|
||||
public function IsImage()
|
||||
public function IsImage() : bool
|
||||
{
|
||||
return 'image' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* return bool
|
||||
*/
|
||||
public function IsArchive()
|
||||
public function IsArchive() : bool
|
||||
{
|
||||
return 'archive' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
|
||||
}
|
||||
|
|
@ -305,7 +268,7 @@ class BodyStructure
|
|||
return $oItem->IsInline();
|
||||
});
|
||||
|
||||
if (is_array($aSearchParts) && 1 === \count($aSearchParts) && isset($aSearchParts[0]))
|
||||
if (1 === \count($aSearchParts) && isset($aSearchParts[0]))
|
||||
{
|
||||
return $aSearchParts[0];
|
||||
}
|
||||
|
|
@ -364,7 +327,6 @@ class BodyStructure
|
|||
|
||||
/**
|
||||
* @param mixed $fCallback
|
||||
*
|
||||
*/
|
||||
public function SearchByCallback($fCallback) : array
|
||||
{
|
||||
|
|
@ -374,12 +336,9 @@ class BodyStructure
|
|||
$aReturn[] = $this;
|
||||
}
|
||||
|
||||
if (\is_array($this->aSubParts) && 0 < \count($this->aSubParts))
|
||||
foreach ($this->aSubParts as /* @var $oSubPart \MailSo\Imap\BodyStructure */ $oSubPart)
|
||||
{
|
||||
foreach ($this->aSubParts as /* @var $oSubPart \MailSo\Imap\BodyStructure */ $oSubPart)
|
||||
{
|
||||
$aReturn = \array_merge($aReturn, $oSubPart->SearchByCallback($fCallback));
|
||||
}
|
||||
$aReturn = \array_merge($aReturn, $oSubPart->SearchByCallback($fCallback));
|
||||
}
|
||||
|
||||
return $aReturn;
|
||||
|
|
@ -410,7 +369,7 @@ class BodyStructure
|
|||
$oPart = $this;
|
||||
}
|
||||
|
||||
if (null === $oPart && is_array($this->aSubParts) && 0 < count($this->aSubParts))
|
||||
if (null === $oPart)
|
||||
{
|
||||
foreach ($this->aSubParts as /* @var $oSubPart \MailSo\Imap\BodyStructure */ $oSubPart)
|
||||
{
|
||||
|
|
@ -426,7 +385,7 @@ class BodyStructure
|
|||
return $oPart;
|
||||
}
|
||||
|
||||
private static function decodeAttrParamenter(array $aParams, string $sParamName, string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8) : string
|
||||
private static function decodeAttrParameter(array $aParams, string $sParamName, string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8) : string
|
||||
{
|
||||
$sResult = '';
|
||||
if (isset($aParams[$sParamName]))
|
||||
|
|
@ -436,7 +395,7 @@ class BodyStructure
|
|||
else if (isset($aParams[$sParamName.'*']))
|
||||
{
|
||||
$aValueParts = \explode("''", $aParams[$sParamName.'*'], 2);
|
||||
if (\is_array($aValueParts) && 2 === \count($aValueParts))
|
||||
if (2 === \count($aValueParts))
|
||||
{
|
||||
$sCharset = isset($aValueParts[0]) ? $aValueParts[0] : \MailSo\Base\Enumerations\Charset::UTF_8;
|
||||
|
||||
|
|
@ -463,7 +422,7 @@ class BodyStructure
|
|||
if ($sCharsetIndex < $iIndex && false !== \strpos($sValue, "''"))
|
||||
{
|
||||
$aValueParts = \explode("''", $sValue, 2);
|
||||
if (\is_array($aValueParts) && 2 === \count($aValueParts) && 0 < \strlen($aValueParts[0]))
|
||||
if (2 === \count($aValueParts) && 0 < \strlen($aValueParts[0]))
|
||||
{
|
||||
$sCharsetIndex = $iIndex;
|
||||
$sCharset = $aValueParts[0];
|
||||
|
|
@ -492,322 +451,308 @@ class BodyStructure
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
public static function NewInstance(array $aBodyStructure, string $sPartID = '') : self
|
||||
public static function NewInstance(array $aBodyStructure, string $sPartID = '') : ?self
|
||||
{
|
||||
if (!\is_array($aBodyStructure) || 2 > \count($aBodyStructure))
|
||||
if (2 > \count($aBodyStructure))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
|
||||
$sBodyMainType = null;
|
||||
if (\is_string($aBodyStructure[0]) && 'NIL' !== $aBodyStructure[0])
|
||||
{
|
||||
$sBodyMainType = null;
|
||||
if (\is_string($aBodyStructure[0]) && 'NIL' !== $aBodyStructure[0])
|
||||
$sBodyMainType = $aBodyStructure[0];
|
||||
}
|
||||
|
||||
$sBodySubType = null;
|
||||
$sContentType = '';
|
||||
$aSubParts = array();
|
||||
$aBodyParams = array();
|
||||
$sName = null;
|
||||
$sCharset = null;
|
||||
$sContentID = null;
|
||||
$sDescription = null;
|
||||
$sMailEncodingName = null;
|
||||
$iSize = 0;
|
||||
$iTextLineCount = 0; // valid for rfc822/message and text parts
|
||||
$iExtraItemPos = 0; // list index of items which have no well-established position (such as 0, 1, 5, etc).
|
||||
|
||||
if (null === $sBodyMainType)
|
||||
{
|
||||
// Process multipart body structure
|
||||
if (!\is_array($aBodyStructure[0]))
|
||||
{
|
||||
$sBodyMainType = $aBodyStructure[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
$sBodySubType = null;
|
||||
$sContentType = '';
|
||||
$aSubParts = null;
|
||||
$aBodyParams = array();
|
||||
$sName = null;
|
||||
$sCharset = null;
|
||||
$sContentID = null;
|
||||
$sDescription = null;
|
||||
$sMailEncodingName = null;
|
||||
$iSize = 0;
|
||||
$iTextLineCount = 0; // valid for rfc822/message and text parts
|
||||
$iExtraItemPos = 0; // list index of items which have no well-established position (such as 0, 1, 5, etc).
|
||||
|
||||
if (null === $sBodyMainType)
|
||||
$sBodyMainType = 'multipart';
|
||||
$sSubPartIDPrefix = '';
|
||||
if (0 === \strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1])
|
||||
{
|
||||
// Process multipart body structure
|
||||
if (!\is_array($aBodyStructure[0]))
|
||||
// This multi-part is root part of message.
|
||||
$sSubPartIDPrefix = $sPartID;
|
||||
$sPartID .= 'TEXT';
|
||||
}
|
||||
else if (0 < \strlen($sPartID))
|
||||
{
|
||||
// This multi-part is a part of another multi-part.
|
||||
$sSubPartIDPrefix = $sPartID.'.';
|
||||
}
|
||||
|
||||
$iIndex = 1;
|
||||
|
||||
while ($iExtraItemPos < \count($aBodyStructure) && \is_array($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$oPart = self::NewInstance($aBodyStructure[$iExtraItemPos], $sSubPartIDPrefix.$iIndex);
|
||||
if (null === $oPart)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
|
||||
// For multipart, we have no charset info in the part itself. Thus,
|
||||
// obtain charset from nested parts.
|
||||
if ($sCharset == null)
|
||||
{
|
||||
$sBodyMainType = 'multipart';
|
||||
$sSubPartIDPrefix = '';
|
||||
if (0 === \strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1])
|
||||
{
|
||||
// This multi-part is root part of message.
|
||||
$sSubPartIDPrefix = $sPartID;
|
||||
$sPartID .= 'TEXT';
|
||||
}
|
||||
else if (0 < \strlen($sPartID))
|
||||
{
|
||||
// This multi-part is a part of another multi-part.
|
||||
$sSubPartIDPrefix = $sPartID.'.';
|
||||
}
|
||||
|
||||
$aSubParts = array();
|
||||
$iIndex = 1;
|
||||
|
||||
while ($iExtraItemPos < \count($aBodyStructure) && \is_array($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$oPart = self::NewInstance($aBodyStructure[$iExtraItemPos], $sSubPartIDPrefix.$iIndex);
|
||||
if (null === $oPart)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For multipart, we have no charset info in the part itself. Thus,
|
||||
// obtain charset from nested parts.
|
||||
if ($sCharset == null)
|
||||
{
|
||||
$sCharset = $oPart->Charset();
|
||||
}
|
||||
|
||||
$aSubParts[] = $oPart;
|
||||
$iExtraItemPos++;
|
||||
$iIndex++;
|
||||
}
|
||||
}
|
||||
$sCharset = $oPart->Charset();
|
||||
}
|
||||
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
if (!\is_string($aBodyStructure[$iExtraItemPos]) || 'NIL' === $aBodyStructure[$iExtraItemPos])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
$aSubParts[] = $oPart;
|
||||
++$iExtraItemPos;
|
||||
++$iIndex;
|
||||
}
|
||||
|
||||
$sBodySubType = \strtolower($aBodyStructure[$iExtraItemPos]);
|
||||
$iExtraItemPos++;
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
if (!\is_string($aBodyStructure[$iExtraItemPos]) || 'NIL' === $aBodyStructure[$iExtraItemPos])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
$sBodySubType = \strtolower($aBodyStructure[$iExtraItemPos]);
|
||||
++$iExtraItemPos;
|
||||
}
|
||||
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
$sBodyParamList = $aBodyStructure[$iExtraItemPos];
|
||||
if (\is_array($sBodyParamList))
|
||||
{
|
||||
$sBodyParamList = $aBodyStructure[$iExtraItemPos];
|
||||
if (\is_array($sBodyParamList))
|
||||
{
|
||||
$aBodyParams = self::getKeyValueListFromArrayList($sBodyParamList);
|
||||
}
|
||||
$aBodyParams = self::getKeyValueListFromArrayList($sBodyParamList);
|
||||
}
|
||||
}
|
||||
|
||||
++$iExtraItemPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Process simple (singlepart) body structure
|
||||
if (7 > \count($aBodyStructure))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$sBodyMainType = \strtolower($sBodyMainType);
|
||||
if (!\is_string($aBodyStructure[1]) || 'NIL' === $aBodyStructure[1])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$sBodySubType = \strtolower($aBodyStructure[1]);
|
||||
|
||||
$aBodyParamList = $aBodyStructure[2];
|
||||
if (\is_array($aBodyParamList))
|
||||
{
|
||||
$aBodyParams = self::getKeyValueListFromArrayList($aBodyParamList);
|
||||
if (isset($aBodyParams['charset']))
|
||||
{
|
||||
$sCharset = $aBodyParams['charset'];
|
||||
}
|
||||
|
||||
$iExtraItemPos++;
|
||||
$sName = self::decodeAttrParameter($aBodyParams, 'name', $sContentType);
|
||||
}
|
||||
|
||||
if (null !== $aBodyStructure[3] && 'NIL' !== $aBodyStructure[3])
|
||||
{
|
||||
if (!\is_string($aBodyStructure[3]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$sContentID = $aBodyStructure[3];
|
||||
}
|
||||
|
||||
if (null !== $aBodyStructure[4] && 'NIL' !== $aBodyStructure[4])
|
||||
{
|
||||
if (!\is_string($aBodyStructure[4]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$sDescription = $aBodyStructure[4];
|
||||
}
|
||||
|
||||
if (null !== $aBodyStructure[5] && 'NIL' !== $aBodyStructure[5])
|
||||
{
|
||||
if (!\is_string($aBodyStructure[5]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
$sMailEncodingName = $aBodyStructure[5];
|
||||
}
|
||||
|
||||
if (\is_numeric($aBodyStructure[6]))
|
||||
{
|
||||
$iSize = (int) $aBodyStructure[6];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Process simple (singlepart) body structure
|
||||
if (7 > \count($aBodyStructure))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
$iSize = -1;
|
||||
}
|
||||
|
||||
$sBodyMainType = \strtolower($sBodyMainType);
|
||||
if (!\is_string($aBodyStructure[1]) || 'NIL' === $aBodyStructure[1])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (0 === \strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1])
|
||||
{
|
||||
// This is the only sub-part of the message (otherwise, it would be
|
||||
// one of sub-parts of a multi-part, and partID would already be fully set up).
|
||||
$sPartID .= '1';
|
||||
}
|
||||
|
||||
$sBodySubType = \strtolower($aBodyStructure[1]);
|
||||
|
||||
$aBodyParamList = $aBodyStructure[2];
|
||||
if (\is_array($aBodyParamList))
|
||||
$iExtraItemPos = 7;
|
||||
if ('text' === $sBodyMainType)
|
||||
{
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
$aBodyParams = self::getKeyValueListFromArrayList($aBodyParamList);
|
||||
if (isset($aBodyParams['charset']))
|
||||
if (\is_numeric($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$sCharset = $aBodyParams['charset'];
|
||||
$iTextLineCount = (int) $aBodyStructure[$iExtraItemPos];
|
||||
}
|
||||
|
||||
if (\is_array($aBodyParams))
|
||||
else
|
||||
{
|
||||
$sName = self::decodeAttrParamenter($aBodyParams, 'name', $sContentType);
|
||||
$iTextLineCount = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $aBodyStructure[3] && 'NIL' !== $aBodyStructure[3])
|
||||
{
|
||||
if (!\is_string($aBodyStructure[3]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$sContentID = $aBodyStructure[3];
|
||||
}
|
||||
|
||||
if (null !== $aBodyStructure[4] && 'NIL' !== $aBodyStructure[4])
|
||||
{
|
||||
if (!\is_string($aBodyStructure[4]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$sDescription = $aBodyStructure[4];
|
||||
}
|
||||
|
||||
if (null !== $aBodyStructure[5] && 'NIL' !== $aBodyStructure[5])
|
||||
{
|
||||
if (!\is_string($aBodyStructure[5]))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
$sMailEncodingName = $aBodyStructure[5];
|
||||
}
|
||||
|
||||
if (\is_numeric($aBodyStructure[6]))
|
||||
{
|
||||
$iSize = (int) $aBodyStructure[6];
|
||||
}
|
||||
else
|
||||
{
|
||||
$iSize = -1;
|
||||
$iTextLineCount = -1;
|
||||
}
|
||||
|
||||
if (0 === \strlen($sPartID) || '.' === $sPartID[\strlen($sPartID) - 1])
|
||||
++$iExtraItemPos;
|
||||
}
|
||||
else if ('message' === $sBodyMainType && 'rfc822' === $sBodySubType)
|
||||
{
|
||||
if ($iExtraItemPos + 2 < \count($aBodyStructure))
|
||||
{
|
||||
// This is the only sub-part of the message (otherwise, it would be
|
||||
// one of sub-parts of a multi-part, and partID would already be fully set up).
|
||||
$sPartID .= '1';
|
||||
}
|
||||
|
||||
$iExtraItemPos = 7;
|
||||
if ('text' === $sBodyMainType)
|
||||
{
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
if (\is_numeric($aBodyStructure[$iExtraItemPos + 2]))
|
||||
{
|
||||
if (\is_numeric($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$iTextLineCount = (int) $aBodyStructure[$iExtraItemPos];
|
||||
}
|
||||
else
|
||||
{
|
||||
$iTextLineCount = -1;
|
||||
}
|
||||
$iTextLineCount = (int) $aBodyStructure[$iExtraItemPos + 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$iTextLineCount = -1;
|
||||
}
|
||||
|
||||
$iExtraItemPos++;
|
||||
}
|
||||
else if ('message' === $sBodyMainType && 'rfc822' === $sBodySubType)
|
||||
else
|
||||
{
|
||||
if ($iExtraItemPos + 2 < \count($aBodyStructure))
|
||||
{
|
||||
if (\is_numeric($aBodyStructure[$iExtraItemPos + 2]))
|
||||
{
|
||||
$iTextLineCount = (int) $aBodyStructure[$iExtraItemPos + 2];
|
||||
}
|
||||
else
|
||||
{
|
||||
$iTextLineCount = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$iTextLineCount = -1;
|
||||
}
|
||||
|
||||
$iExtraItemPos += 3;
|
||||
$iTextLineCount = -1;
|
||||
}
|
||||
|
||||
$iExtraItemPos++; // skip MD5 digest of the body because most mail servers leave it NIL anyway
|
||||
$iExtraItemPos += 3;
|
||||
}
|
||||
|
||||
$sContentType = $sBodyMainType.'/'.$sBodySubType;
|
||||
|
||||
$sDisposition = null;
|
||||
$aDispositionParams = null;
|
||||
$sFileName = null;
|
||||
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
$aDispList = $aBodyStructure[$iExtraItemPos];
|
||||
if (\is_array($aDispList) && 1 < \count($aDispList))
|
||||
{
|
||||
if (null !== $aDispList[0])
|
||||
{
|
||||
if (\is_string($aDispList[0]) && 'NIL' !== $aDispList[0])
|
||||
{
|
||||
$sDisposition = $aDispList[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aDispParamList = $aDispList[1];
|
||||
if (\is_array($aDispParamList))
|
||||
{
|
||||
$aDispositionParams = self::getKeyValueListFromArrayList($aDispParamList);
|
||||
if (\is_array($aDispositionParams))
|
||||
{
|
||||
$sFileName = self::decodeAttrParamenter($aDispositionParams, 'filename', $sCharset ?: '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$iExtraItemPos++;
|
||||
|
||||
$sLanguage = null;
|
||||
if ($iExtraItemPos < count($aBodyStructure))
|
||||
{
|
||||
if (null !== $aBodyStructure[$iExtraItemPos] && 'NIL' !== $aBodyStructure[$iExtraItemPos])
|
||||
{
|
||||
if (\is_array($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$sLanguage = \implode(',', $aBodyStructure[$iExtraItemPos]);
|
||||
}
|
||||
else if (\is_string($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$sLanguage = $aBodyStructure[$iExtraItemPos];
|
||||
}
|
||||
}
|
||||
$iExtraItemPos++;
|
||||
}
|
||||
|
||||
$sLocation = null;
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
if (null !== $aBodyStructure[$iExtraItemPos] && 'NIL' !== $aBodyStructure[$iExtraItemPos])
|
||||
{
|
||||
if (\is_string($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$sLocation = $aBodyStructure[$iExtraItemPos];
|
||||
}
|
||||
}
|
||||
$iExtraItemPos++;
|
||||
}
|
||||
|
||||
return new self(
|
||||
$sContentType,
|
||||
$sCharset,
|
||||
$aBodyParams,
|
||||
$sContentID,
|
||||
$sDescription,
|
||||
$sMailEncodingName,
|
||||
$sDisposition,
|
||||
$aDispositionParams,
|
||||
\MailSo\Base\Utils::Utf8Clear((null === $sFileName || 0 === \strlen($sFileName)) ? $sName : $sFileName),
|
||||
$sLanguage,
|
||||
$sLocation,
|
||||
$iSize,
|
||||
$iTextLineCount,
|
||||
$sPartID,
|
||||
$aSubParts
|
||||
);
|
||||
++$iExtraItemPos; // skip MD5 digest of the body because most mail servers leave it NIL anyway
|
||||
}
|
||||
|
||||
$sContentType = $sBodyMainType.'/'.$sBodySubType;
|
||||
|
||||
$sDisposition = null;
|
||||
$aDispositionParams = null;
|
||||
$sFileName = null;
|
||||
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
$aDispList = $aBodyStructure[$iExtraItemPos];
|
||||
if (\is_array($aDispList) && 1 < \count($aDispList))
|
||||
{
|
||||
if (null !== $aDispList[0])
|
||||
{
|
||||
if (\is_string($aDispList[0]) && 'NIL' !== $aDispList[0])
|
||||
{
|
||||
$sDisposition = $aDispList[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aDispParamList = $aDispList[1];
|
||||
if (\is_array($aDispParamList))
|
||||
{
|
||||
$aDispositionParams = self::getKeyValueListFromArrayList($aDispParamList);
|
||||
$sFileName = self::decodeAttrParameter($aDispositionParams, 'filename', $sCharset ?: '');
|
||||
}
|
||||
}
|
||||
|
||||
++$iExtraItemPos;
|
||||
|
||||
$sLanguage = null;
|
||||
if ($iExtraItemPos < count($aBodyStructure))
|
||||
{
|
||||
if (null !== $aBodyStructure[$iExtraItemPos] && 'NIL' !== $aBodyStructure[$iExtraItemPos])
|
||||
{
|
||||
if (\is_array($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$sLanguage = \implode(',', $aBodyStructure[$iExtraItemPos]);
|
||||
}
|
||||
else if (\is_string($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$sLanguage = $aBodyStructure[$iExtraItemPos];
|
||||
}
|
||||
}
|
||||
++$iExtraItemPos;
|
||||
}
|
||||
|
||||
$sLocation = null;
|
||||
if ($iExtraItemPos < \count($aBodyStructure))
|
||||
{
|
||||
if (null !== $aBodyStructure[$iExtraItemPos] && 'NIL' !== $aBodyStructure[$iExtraItemPos])
|
||||
{
|
||||
if (\is_string($aBodyStructure[$iExtraItemPos]))
|
||||
{
|
||||
$sLocation = $aBodyStructure[$iExtraItemPos];
|
||||
}
|
||||
}
|
||||
++$iExtraItemPos;
|
||||
}
|
||||
|
||||
return new self(
|
||||
$sContentType,
|
||||
$sCharset,
|
||||
$aBodyParams,
|
||||
$sContentID,
|
||||
$sDescription,
|
||||
$sMailEncodingName,
|
||||
$sDisposition,
|
||||
$aDispositionParams,
|
||||
\MailSo\Base\Utils::Utf8Clear($sFileName ?: $sName),
|
||||
$sLanguage,
|
||||
$sLocation,
|
||||
$iSize,
|
||||
$iTextLineCount,
|
||||
$sPartID,
|
||||
$aSubParts
|
||||
);
|
||||
}
|
||||
|
||||
public static function NewInstanceFromRfc822SubPart(array $aBodyStructure, string $sSubPartID) : ?self
|
||||
{
|
||||
$oBody = null;
|
||||
$aBodySubStructure = self::findPartByIndexInArray($aBodyStructure, $sSubPartID);
|
||||
if ($aBodySubStructure && \is_array($aBodySubStructure) && isset($aBodySubStructure[8]))
|
||||
{
|
||||
$oBody = self::NewInstance($aBodySubStructure[8], $sSubPartID);
|
||||
return self::NewInstance($aBodySubStructure[8], $sSubPartID);
|
||||
}
|
||||
|
||||
return $oBody;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function findPartByIndexInArray(array $aList, string $sPartID) : ?array
|
||||
|
|
@ -832,15 +777,12 @@ class BodyStructure
|
|||
/**
|
||||
* Returns dict with key="charset" and value="US-ASCII" for array ("CHARSET" "US-ASCII").
|
||||
* Keys are lowercased (StringDictionary itself does this), values are not altered.
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static function getKeyValueListFromArrayList(array $aList) : array
|
||||
{
|
||||
$aDict = null;
|
||||
$aDict = array();
|
||||
if (0 === \count($aList) % 2)
|
||||
{
|
||||
$aDict = array();
|
||||
for ($iIndex = 0, $iLen = \count($aList); $iIndex < $iLen; $iIndex += 2)
|
||||
{
|
||||
if (\is_string($aList[$iIndex]) && isset($aList[$iIndex + 1]) && \is_string($aList[$iIndex + 1]))
|
||||
|
|
|
|||
|
|
@ -36,10 +36,6 @@ class FetchType
|
|||
const UID = 'UID';
|
||||
const INDEX = 'INDEX';
|
||||
|
||||
const GMAIL_MSGID = 'X-GM-MSGID';
|
||||
const GMAIL_THRID = 'X-GM-THRID';
|
||||
const GMAIL_LABELS = 'X-GM-LABELS';
|
||||
|
||||
private static function addHelper(array &$aReturn, $mType)
|
||||
{
|
||||
if (\is_string($mType))
|
||||
|
|
@ -47,7 +43,7 @@ class FetchType
|
|||
$aReturn[$mType] = '';
|
||||
}
|
||||
else if (\is_array($mType) && 2 === count($mType) && \is_string($mType[0]) &&
|
||||
is_callable($mType[1]))
|
||||
\is_callable($mType[1]))
|
||||
{
|
||||
$aReturn[$mType[0]] = $mType[1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,4 @@ class StoreAction
|
|||
const ADD_FLAGS_SILENT = '+FLAGS.SILENT';
|
||||
const REMOVE_FLAGS = '-FLAGS';
|
||||
const REMOVE_FLAGS_SILENT = '-FLAGS.SILENT';
|
||||
|
||||
const SET_GMAIL_LABELS = 'X-GM-LABELS';
|
||||
const SET_GMAIL_LABELS_SILENT = 'X-GM-LABELS.SILENT';
|
||||
const ADD_GMAIL_LABELS = '+X-GM-LABELS';
|
||||
const ADD_GMAIL_LABELS_SILENT = '+X-GM-LABELS.SILENT';
|
||||
const REMOVE_GMAIL_LABELS = '-X-GM-LABELS';
|
||||
const REMOVE_GMAIL_LABELS_SILENT = '-X-GM-LABELS.SILENT';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,9 @@ class FetchResponse
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mNullResult = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetFetchEnvelopeValue(int $iIndex, $mNullResult)
|
||||
public function GetFetchEnvelopeValue(int $iIndex, ?string $mNullResult = null)
|
||||
{
|
||||
return self::findEnvelopeIndex($this->GetEnvelope(), $iIndex, $mNullResult);
|
||||
}
|
||||
|
|
@ -60,7 +58,7 @@ class FetchResponse
|
|||
public function GetFetchEnvelopeEmailCollection(int $iIndex, string $sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1) : ?\MailSo\Mime\EmailCollection
|
||||
{
|
||||
$oResult = null;
|
||||
$aEmails = $this->GetFetchEnvelopeValue($iIndex, null);
|
||||
$aEmails = $this->GetFetchEnvelopeValue($iIndex);
|
||||
if (is_array($aEmails) && 0 < count($aEmails))
|
||||
{
|
||||
$oResult = \MailSo\Mime\EmailCollection::NewInstance();
|
||||
|
|
@ -92,22 +90,18 @@ class FetchResponse
|
|||
|
||||
public function GetFetchBodyStructure(string $sRfc822SubMimeIndex = '') : ?BodyStructure
|
||||
{
|
||||
$oBodyStructure = null;
|
||||
$aBodyStructureArray = $this->GetFetchValue(Enumerations\FetchType::BODYSTRUCTURE);
|
||||
|
||||
if (is_array($aBodyStructureArray))
|
||||
{
|
||||
if (0 < strlen($sRfc822SubMimeIndex))
|
||||
{
|
||||
$oBodyStructure = BodyStructure::NewInstanceFromRfc822SubPart($aBodyStructureArray, $sRfc822SubMimeIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oBodyStructure = BodyStructure::NewInstance($aBodyStructureArray);
|
||||
return BodyStructure::NewInstanceFromRfc822SubPart($aBodyStructureArray, $sRfc822SubMimeIndex);
|
||||
}
|
||||
return BodyStructure::NewInstance($aBodyStructureArray);
|
||||
}
|
||||
|
||||
return $oBodyStructure;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -144,7 +138,6 @@ class FetchResponse
|
|||
|
||||
public function GetHeaderFieldsValue(string $sRfc822SubMimeIndex = '') : string
|
||||
{
|
||||
$sReturn = '';
|
||||
$bNextIsValue = false;
|
||||
|
||||
$sRfc822SubMimeIndex = 0 < \strlen($sRfc822SubMimeIndex) ? ''.$sRfc822SubMimeIndex.'.' : '';
|
||||
|
|
@ -155,8 +148,7 @@ class FetchResponse
|
|||
{
|
||||
if ($bNextIsValue)
|
||||
{
|
||||
$sReturn = (string) $mItem;
|
||||
break;
|
||||
return (string) $mItem;
|
||||
}
|
||||
|
||||
if (\is_string($mItem) && (
|
||||
|
|
@ -169,28 +161,24 @@ class FetchResponse
|
|||
}
|
||||
}
|
||||
|
||||
return $sReturn;
|
||||
return '';
|
||||
}
|
||||
|
||||
private static function findFetchUidAndSize(array $aList) : bool
|
||||
{
|
||||
$bUid = false;
|
||||
$bSize = false;
|
||||
if (is_array($aList))
|
||||
foreach ($aList as $mItem)
|
||||
{
|
||||
foreach ($aList as $mItem)
|
||||
if (Enumerations\FetchType::UID === $mItem)
|
||||
{
|
||||
if (Enumerations\FetchType::UID === $mItem)
|
||||
{
|
||||
$bUid = true;
|
||||
}
|
||||
else if (Enumerations\FetchType::RFC822_SIZE === $mItem)
|
||||
{
|
||||
$bSize = true;
|
||||
}
|
||||
$bUid = true;
|
||||
}
|
||||
else if (Enumerations\FetchType::RFC822_SIZE === $mItem)
|
||||
{
|
||||
$bSize = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $bUid && $bSize;
|
||||
}
|
||||
|
||||
|
|
@ -216,11 +204,9 @@ class FetchResponse
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mNullResult = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function findEnvelopeIndex(array $aEnvelope, int $iIndex, $mNullResult)
|
||||
private static function findEnvelopeIndex(array $aEnvelope, int $iIndex, ?string $mNullResult)
|
||||
{
|
||||
return (isset($aEnvelope[$iIndex]) && 'NIL' !== $aEnvelope[$iIndex] && '' !== $aEnvelope[$iIndex])
|
||||
? $aEnvelope[$iIndex] : $mNullResult;
|
||||
|
|
|
|||
|
|
@ -45,28 +45,20 @@ class Folder
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aExtended;
|
||||
private $aExtended = array();
|
||||
|
||||
/**
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
private function __construct(string $sFullNameRaw, string $sDelimiter, array $aFlags)
|
||||
{
|
||||
$this->sNameRaw = '';
|
||||
$this->sFullNameRaw = '';
|
||||
$this->sDelimiter = '';
|
||||
$this->aFlags = array();
|
||||
$this->aExtended = array();
|
||||
|
||||
$sDelimiter = 'NIL' === \strtoupper($sDelimiter) ? '' : $sDelimiter;
|
||||
if (empty($sDelimiter))
|
||||
{
|
||||
$sDelimiter = '.'; // default delimiter
|
||||
}
|
||||
|
||||
if (!\is_array($aFlags) ||
|
||||
!\is_string($sDelimiter) || 1 < \strlen($sDelimiter) ||
|
||||
!\is_string($sFullNameRaw) || 0 === \strlen($sFullNameRaw))
|
||||
if (1 < \strlen($sDelimiter) || 0 === \strlen($sFullNameRaw))
|
||||
{
|
||||
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
|
||||
}
|
||||
|
|
@ -143,7 +135,7 @@ class Folder
|
|||
/**
|
||||
* @param mixed $mData
|
||||
*/
|
||||
public function SetExtended(string $sName, $mData)
|
||||
public function SetExtended(string $sName, $mData) : void
|
||||
{
|
||||
$this->aExtended[$sName] = $mData;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -611,13 +611,13 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$sSearchCriterias = !strlen(\trim($sSearchCriterias)) || '*' === $sSearchCriterias
|
||||
? 'ALL' : $sSearchCriterias;
|
||||
|
||||
if (!\is_array($aSortTypes) || 0 === \count($aSortTypes))
|
||||
if (!$aSortTypes)
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
else if (!$this->IsSupported('SORT'))
|
||||
if (!$this->IsSupported('SORT'))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||
|
|
@ -647,7 +647,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
? 'ALL' : $sSearchCriterias;
|
||||
|
||||
$sCmd = $bSort ? 'SORT': 'SEARCH';
|
||||
if ($bSort && (!\is_array($aSortTypes) || 0 === \count($aSortTypes) || !$this->IsSupported('SORT')))
|
||||
if ($bSort && (!$aSortTypes || !$this->IsSupported('SORT')))
|
||||
{
|
||||
$this->writeLogException(
|
||||
new \MailSo\Base\Exceptions\InvalidArgumentException(),
|
||||
|
|
@ -661,7 +661,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
\MailSo\Log\Enumerations\Type::ERROR, true);
|
||||
}
|
||||
|
||||
if (!\is_array($aSearchOrSortReturn) || 0 === \count($aSearchOrSortReturn))
|
||||
if (!$aSearchOrSortReturn)
|
||||
{
|
||||
$aSearchOrSortReturn = array('ALL');
|
||||
}
|
||||
|
|
@ -1620,18 +1620,15 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
private function prepareParamLine(array $aParams = array()) : string
|
||||
{
|
||||
$sReturn = '';
|
||||
if (\is_array($aParams) && 0 < \count($aParams))
|
||||
foreach ($aParams as $mParamItem)
|
||||
{
|
||||
foreach ($aParams as $mParamItem)
|
||||
if (\is_array($mParamItem) && 0 < \count($mParamItem))
|
||||
{
|
||||
if (\is_array($mParamItem) && 0 < \count($mParamItem))
|
||||
{
|
||||
$sReturn .= ' ('.\trim($this->prepareParamLine($mParamItem)).')';
|
||||
}
|
||||
else if (\is_string($mParamItem))
|
||||
{
|
||||
$sReturn .= ' '.$mParamItem;
|
||||
}
|
||||
$sReturn .= ' ('.\trim($this->prepareParamLine($mParamItem)).')';
|
||||
}
|
||||
else if (\is_string($mParamItem))
|
||||
{
|
||||
$sReturn .= ' '.$mParamItem;
|
||||
}
|
||||
}
|
||||
return $sReturn;
|
||||
|
|
|
|||
|
|
@ -71,14 +71,10 @@ class Response
|
|||
private function recToLine(array $aList) : string
|
||||
{
|
||||
$aResult = array();
|
||||
if (\is_array($aList))
|
||||
foreach ($aList as $mItem)
|
||||
{
|
||||
foreach ($aList as $mItem)
|
||||
{
|
||||
$aResult[] = \is_array($mItem) ? '('.$this->recToLine($mItem).')' : (string) $mItem;
|
||||
}
|
||||
$aResult[] = \is_array($mItem) ? '('.$this->recToLine($mItem).')' : (string) $mItem;
|
||||
}
|
||||
|
||||
return \implode(' ', $aResult);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ class ResponseCollection extends \MailSo\Base\Collection
|
|||
return $aReturn;
|
||||
}
|
||||
|
||||
public function getMessageSimpleThreadResult($sStatus, $bReturnUid) : array
|
||||
public function getMessageSimpleThreadResult(string $sStatus, bool $bReturnUid) : array
|
||||
{
|
||||
$aReturn = array();
|
||||
foreach ($this as $oResponse) {
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ abstract class Driver
|
|||
return $this->writeImplementation($mDesc);
|
||||
}
|
||||
|
||||
final public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '', $bDiplayCrLf = false)
|
||||
final public function Write(string $sDesc, int $iType = \MailSo\Log\Enumerations\Type::INFO, string $sName = '', bool $bDiplayCrLf = false)
|
||||
{
|
||||
$bResult = true;
|
||||
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly))
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class Logger extends \MailSo\Base\Collection
|
|||
|
||||
public function AddSecret(string $sWord) : void
|
||||
{
|
||||
if (\is_string($sWord) && 0 < \strlen(\trim($sWord)))
|
||||
if (0 < \strlen(\trim($sWord)))
|
||||
{
|
||||
$this->aSecretWords[] = $sWord;
|
||||
$this->aSecretWords = \array_unique($this->aSecretWords);
|
||||
|
|
@ -185,21 +185,17 @@ class Logger extends \MailSo\Base\Collection
|
|||
|
||||
public function __loggerShutDown() : void
|
||||
{
|
||||
if ($this->bUsed)
|
||||
if ($this->bUsed && $aStatistic = \MailSo\Base\Loader::Statistic())
|
||||
{
|
||||
$aStatistic = \MailSo\Base\Loader::Statistic();
|
||||
if (\is_array($aStatistic))
|
||||
if (isset($aStatistic['php']['memory_get_peak_usage']))
|
||||
{
|
||||
if (isset($aStatistic['php']['memory_get_peak_usage']))
|
||||
{
|
||||
$this->Write('Memory peak usage: '.$aStatistic['php']['memory_get_peak_usage'],
|
||||
\MailSo\Log\Enumerations\Type::MEMORY);
|
||||
}
|
||||
$this->Write('Memory peak usage: '.$aStatistic['php']['memory_get_peak_usage'],
|
||||
\MailSo\Log\Enumerations\Type::MEMORY);
|
||||
}
|
||||
|
||||
if (isset($aStatistic['time']))
|
||||
{
|
||||
$this->Write('Time delta: '.$aStatistic['time'], \MailSo\Log\Enumerations\Type::TIME_DELTA);
|
||||
}
|
||||
if (isset($aStatistic['time']))
|
||||
{
|
||||
$this->Write('Time delta: '.$aStatistic['time'], \MailSo\Log\Enumerations\Type::TIME_DELTA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ class Attachment
|
|||
*/
|
||||
private $oBodyStructure;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->Clear();
|
||||
|
|
|
|||
|
|
@ -198,41 +198,38 @@ class Folder
|
|||
$aFlags = $this->oImapFolder->FlagsLowerCase();
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::USER;
|
||||
|
||||
if (\is_array($aFlags))
|
||||
switch (true)
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
case \in_array('\inbox', $aFlags) || 'INBOX' === \strtoupper($this->FullNameRaw()):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::INBOX;
|
||||
break;
|
||||
case \in_array('\sent', $aFlags):
|
||||
case \in_array('\sentmail', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::SENT;
|
||||
break;
|
||||
case \in_array('\drafts', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::DRAFTS;
|
||||
break;
|
||||
case \in_array('\junk', $aFlags):
|
||||
case \in_array('\spam', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::JUNK;
|
||||
break;
|
||||
case \in_array('\trash', $aFlags):
|
||||
case \in_array('\bin', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::TRASH;
|
||||
break;
|
||||
case \in_array('\important', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::IMPORTANT;
|
||||
break;
|
||||
case \in_array('\flagged', $aFlags):
|
||||
case \in_array('\starred', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::FLAGGED;
|
||||
break;
|
||||
case \in_array('\all', $aFlags):
|
||||
case \in_array('\allmail', $aFlags):
|
||||
case \in_array('\archive', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::ALL;
|
||||
break;
|
||||
}
|
||||
case \in_array('\inbox', $aFlags) || 'INBOX' === \strtoupper($this->FullNameRaw()):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::INBOX;
|
||||
break;
|
||||
case \in_array('\sent', $aFlags):
|
||||
case \in_array('\sentmail', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::SENT;
|
||||
break;
|
||||
case \in_array('\drafts', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::DRAFTS;
|
||||
break;
|
||||
case \in_array('\junk', $aFlags):
|
||||
case \in_array('\spam', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::JUNK;
|
||||
break;
|
||||
case \in_array('\trash', $aFlags):
|
||||
case \in_array('\bin', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::TRASH;
|
||||
break;
|
||||
case \in_array('\important', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::IMPORTANT;
|
||||
break;
|
||||
case \in_array('\flagged', $aFlags):
|
||||
case \in_array('\starred', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::FLAGGED;
|
||||
break;
|
||||
case \in_array('\all', $aFlags):
|
||||
case \in_array('\allmail', $aFlags):
|
||||
case \in_array('\archive', $aFlags):
|
||||
$iListType = \MailSo\Imap\Enumerations\FolderType::ALL;
|
||||
break;
|
||||
}
|
||||
|
||||
return $iListType;
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ class MailClient
|
|||
*/
|
||||
public function MessageDelete(string $sFolder, array $aIndexRange, bool $bIndexIsUid, bool $bUseExpunge = true, bool $bExpungeAll = false) : self
|
||||
{
|
||||
if (0 === \strlen($sFolder) || !\is_array($aIndexRange) || 0 === \count($aIndexRange))
|
||||
if (0 === \strlen($sFolder) || 0 === \count($aIndexRange))
|
||||
{
|
||||
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
|
||||
}
|
||||
|
|
@ -482,8 +482,7 @@ class MailClient
|
|||
*/
|
||||
public function MessageMove(string $sFromFolder, string $sToFolder, array $aIndexRange, bool $bIndexIsUid, bool $bUseMoveSupported = false, bool $bExpungeAll = false) : self
|
||||
{
|
||||
if (0 === \strlen($sFromFolder) || 0 === \strlen($sToFolder) ||
|
||||
!\is_array($aIndexRange) || 0 === \count($aIndexRange))
|
||||
if (!$sFromFolder || !$sToFolder || 0 === \count($aIndexRange))
|
||||
{
|
||||
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
|
||||
}
|
||||
|
|
@ -513,8 +512,7 @@ class MailClient
|
|||
*/
|
||||
public function MessageCopy(string $sFromFolder, string $sToFolder, array $aIndexRange, bool $bIndexIsUid) : self
|
||||
{
|
||||
if (0 === \strlen($sFromFolder) || 0 === \strlen($sToFolder) ||
|
||||
!\is_array($aIndexRange) || 0 === \count($aIndexRange))
|
||||
if (!$sFromFolder || !$sToFolder || 0 === \count($aIndexRange))
|
||||
{
|
||||
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
|
||||
}
|
||||
|
|
@ -603,20 +601,6 @@ class MailClient
|
|||
|
||||
$sHighestModSeq = isset($aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::HIGHESTMODSEQ])
|
||||
? (string) $aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::HIGHESTMODSEQ] : '';
|
||||
|
||||
if ($this->IsGmail() &&
|
||||
('INBOX' === $sFolderName || '[gmail]' === \strtolower(\substr($sFolderName, 0, 7))))
|
||||
{
|
||||
$oFolder = $this->oImapClient->FolderCurrentInformation();
|
||||
if ($oFolder && null !== $oFolder->Exists && $oFolder->FolderName === $sFolderName)
|
||||
{
|
||||
$iSubCount = (int) $oFolder->Exists;
|
||||
if (0 < $iSubCount && $iSubCount < $iCount)
|
||||
{
|
||||
$iCount = $iSubCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function GenerateImapClientHash() : string
|
||||
|
|
@ -656,43 +640,40 @@ class MailClient
|
|||
))
|
||||
), $sPrevUidNext.':*', true);
|
||||
|
||||
if (\is_array($aFetchResponse) && 0 < \count($aFetchResponse))
|
||||
foreach ($aFetchResponse as /* @var $oFetchResponse \MailSo\Imap\FetchResponse */ $oFetchResponse)
|
||||
{
|
||||
foreach ($aFetchResponse as /* @var $oFetchResponse \MailSo\Imap\FetchResponse */ $oFetchResponse)
|
||||
$aFlags = \array_map('strtolower', $oFetchResponse->GetFetchValue(
|
||||
\MailSo\Imap\Enumerations\FetchType::FLAGS));
|
||||
|
||||
if (!\in_array(\strtolower(\MailSo\Imap\Enumerations\MessageFlag::SEEN), $aFlags))
|
||||
{
|
||||
$aFlags = \array_map('strtolower', $oFetchResponse->GetFetchValue(
|
||||
\MailSo\Imap\Enumerations\FetchType::FLAGS));
|
||||
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
|
||||
$sHeaders = $oFetchResponse->GetHeaderFieldsValue();
|
||||
|
||||
if (!\in_array(\strtolower(\MailSo\Imap\Enumerations\MessageFlag::SEEN), $aFlags))
|
||||
$oHeaders = \MailSo\Mime\HeaderCollection::NewInstance()->Parse($sHeaders);
|
||||
|
||||
$sContentTypeCharset = $oHeaders->ParameterValue(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\Parameter::CHARSET
|
||||
);
|
||||
|
||||
$sCharset = '';
|
||||
if (0 < \strlen($sContentTypeCharset))
|
||||
{
|
||||
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
|
||||
$sHeaders = $oFetchResponse->GetHeaderFieldsValue();
|
||||
|
||||
$oHeaders = \MailSo\Mime\HeaderCollection::NewInstance()->Parse($sHeaders);
|
||||
|
||||
$sContentTypeCharset = $oHeaders->ParameterValue(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\Parameter::CHARSET
|
||||
);
|
||||
|
||||
$sCharset = '';
|
||||
if (0 < \strlen($sContentTypeCharset))
|
||||
{
|
||||
$sCharset = $sContentTypeCharset;
|
||||
}
|
||||
|
||||
if (0 < \strlen($sCharset))
|
||||
{
|
||||
$oHeaders->SetParentCharset($sCharset);
|
||||
}
|
||||
|
||||
$aNewMessages[] = array(
|
||||
'Folder' => $sFolderName,
|
||||
'Uid' => $sUid,
|
||||
'Subject' => $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SUBJECT, 0 === \strlen($sCharset)),
|
||||
'From' => $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, 0 === \strlen($sCharset))
|
||||
);
|
||||
$sCharset = $sContentTypeCharset;
|
||||
}
|
||||
|
||||
if (0 < \strlen($sCharset))
|
||||
{
|
||||
$oHeaders->SetParentCharset($sCharset);
|
||||
}
|
||||
|
||||
$aNewMessages[] = array(
|
||||
'Folder' => $sFolderName,
|
||||
'Uid' => $sUid,
|
||||
'Subject' => $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SUBJECT, 0 === \strlen($sCharset)),
|
||||
'From' => $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, 0 === \strlen($sCharset))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -710,14 +691,8 @@ class MailClient
|
|||
$aFlags = array();
|
||||
|
||||
$bSelect = false;
|
||||
if ($this->IsGmail() &&
|
||||
('INBOX' === $sFolderName || '[gmail]' === \strtolower(\substr($sFolderName, 0, 7))))
|
||||
{
|
||||
$this->oImapClient->FolderSelect($sFolderName);
|
||||
$bSelect = true;
|
||||
}
|
||||
|
||||
if (\is_array($aUids) && 0 < \count($aUids))
|
||||
if (0 < \count($aUids))
|
||||
{
|
||||
if (!$bSelect)
|
||||
{
|
||||
|
|
@ -730,14 +705,11 @@ class MailClient
|
|||
\MailSo\Imap\Enumerations\FetchType::FLAGS
|
||||
), \MailSo\Base\Utils::PrepareFetchSequence($aUids), true);
|
||||
|
||||
if (\is_array($aFetchResponse) && 0 < \count($aFetchResponse))
|
||||
foreach ($aFetchResponse as $oFetchResponse)
|
||||
{
|
||||
foreach ($aFetchResponse as $oFetchResponse)
|
||||
{
|
||||
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
|
||||
$aFlags[(\is_numeric($sUid) ? (int) $sUid : 0)] =
|
||||
$oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::FLAGS);
|
||||
}
|
||||
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
|
||||
$aFlags[(\is_numeric($sUid) ? (int) $sUid : 0)] =
|
||||
$oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::FLAGS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -796,17 +768,10 @@ class MailClient
|
|||
return 0 < $iResult ? $iResult : 0;
|
||||
}
|
||||
|
||||
public function IsGmail() : bool
|
||||
{
|
||||
return 'ssl://imap.gmail.com' === \strtolower($this->oImapClient->GetConnectedHost());
|
||||
}
|
||||
|
||||
private function escapeSearchString(string $sSearch, bool $bDetectGmail = true) : string
|
||||
private function escapeSearchString(string $sSearch) : string
|
||||
{
|
||||
return !\MailSo\Base\Utils::IsAscii($sSearch)
|
||||
? '{'.\strlen($sSearch).'}'."\r\n".$sSearch : $this->oImapClient->EscapeString($sSearch);
|
||||
// return ($bDetectGmail && !\MailSo\Base\Utils::IsAscii($sSearch) && $this->IsGmail())
|
||||
// ? '{'.\strlen($sSearch).'+}'."\r\n".$sSearch : $this->oImapClient->EscapeString($sSearch);
|
||||
}
|
||||
|
||||
private function parseSearchDate(string $sDate, int $iTimeZoneOffset) : int
|
||||
|
|
@ -867,7 +832,7 @@ class MailClient
|
|||
|
||||
$mMatch = array();
|
||||
\preg_match_all('/".*?(?<!\\\)"/', $sSearch, $mMatch);
|
||||
if (\is_array($mMatch) && isset($mMatch[0]) && \is_array($mMatch[0]) && 0 < \count($mMatch[0]))
|
||||
if (\is_array($mMatch) && isset($mMatch[0]) && \is_array($mMatch[0]))
|
||||
{
|
||||
foreach ($mMatch[0] as $sItem)
|
||||
{
|
||||
|
|
@ -883,7 +848,7 @@ class MailClient
|
|||
}
|
||||
|
||||
\preg_match_all('/\'.*?(?<!\\\)\'/', $sSearch, $mMatch);
|
||||
if (\is_array($mMatch) && isset($mMatch[0]) && \is_array($mMatch[0]) && 0 < \count($mMatch[0]))
|
||||
if (\is_array($mMatch) && isset($mMatch[0]) && \is_array($mMatch[0]))
|
||||
{
|
||||
foreach ($mMatch[0] as $sItem)
|
||||
{
|
||||
|
|
@ -985,11 +950,9 @@ class MailClient
|
|||
|
||||
if (0 < \strlen(\trim($sSearch)))
|
||||
{
|
||||
$sGmailRawSearch = '';
|
||||
$sResultBodyTextSearch = '';
|
||||
|
||||
$aLines = $this->parseSearchString($sSearch);
|
||||
$bIsGmail = $this->oImapClient->IsSupported('X-GM-EXT-1');
|
||||
|
||||
if (1 === \count($aLines) && isset($aLines['OTHER']))
|
||||
{
|
||||
|
|
@ -1073,19 +1036,12 @@ class MailClient
|
|||
$aCompareArray = array('file', 'files', 'attach', 'attachs', 'attachment', 'attachments');
|
||||
if (\count($aCompareArray) > \count(\array_diff($aCompareArray, $aValue)))
|
||||
{
|
||||
if ($bIsGmail)
|
||||
{
|
||||
$sGmailRawSearch .= ' has:attachment';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Simple, is not detailed search (Sometimes doesn't work)
|
||||
$aCriteriasResult[] = 'OR OR OR';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type application/';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type multipart/m';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type multipart/signed';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type multipart/report';
|
||||
}
|
||||
// Simple, is not detailed search (Sometimes doesn't work)
|
||||
$aCriteriasResult[] = 'OR OR OR';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type application/';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type multipart/m';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type multipart/signed';
|
||||
$aCriteriasResult[] = 'HEADER Content-Type multipart/report';
|
||||
}
|
||||
|
||||
case 'IS':
|
||||
|
|
@ -1133,7 +1089,7 @@ class MailClient
|
|||
$sDate = $sRawValue;
|
||||
$aDate = \explode('/', $sDate);
|
||||
|
||||
if (\is_array($aDate) && 2 === \count($aDate))
|
||||
if (2 === \count($aDate))
|
||||
{
|
||||
if (0 < \strlen($aDate[0]))
|
||||
{
|
||||
|
|
@ -1176,24 +1132,10 @@ class MailClient
|
|||
if ('' !== \trim($sMainText))
|
||||
{
|
||||
$sMainText = \trim(\MailSo\Base\Utils::StripSpaces($sMainText), '"');
|
||||
if ($bIsGmail)
|
||||
{
|
||||
$sGmailRawSearch .= ' '.$sMainText;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sResultBodyTextSearch .= ' '.$sMainText;
|
||||
}
|
||||
$sResultBodyTextSearch .= ' '.$sMainText;
|
||||
}
|
||||
}
|
||||
|
||||
$sGmailRawSearch = \trim($sGmailRawSearch);
|
||||
if ($bIsGmail && 0 < \strlen($sGmailRawSearch))
|
||||
{
|
||||
$aCriteriasResult[] = 'X-GM-RAW';
|
||||
$aCriteriasResult[] = $this->escapeSearchString($sGmailRawSearch, false);
|
||||
}
|
||||
|
||||
$sResultBodyTextSearch = \trim($sResultBodyTextSearch);
|
||||
if (0 < \strlen($sResultBodyTextSearch))
|
||||
{
|
||||
|
|
@ -1248,7 +1190,7 @@ class MailClient
|
|||
else
|
||||
{
|
||||
$mMap = $this->threadArrayMap($mItem);
|
||||
if (\is_array($mMap) && 0 < \count($mMap))
|
||||
if (0 < \count($mMap))
|
||||
{
|
||||
$aNew = \array_merge($aNew, $mMap);
|
||||
}
|
||||
|
|
@ -1266,16 +1208,13 @@ class MailClient
|
|||
if (\is_array($mItem))
|
||||
{
|
||||
$aMap = $this->threadArrayMap($mItem);
|
||||
if (\is_array($aMap))
|
||||
if (1 < \count($aMap))
|
||||
{
|
||||
if (1 < \count($aMap))
|
||||
{
|
||||
$aResult[] = $aMap;
|
||||
}
|
||||
else if (0 < \count($aMap))
|
||||
{
|
||||
$aResult[] = $aMap[0];
|
||||
}
|
||||
$aResult[] = $aMap;
|
||||
}
|
||||
else if (0 < \count($aMap))
|
||||
{
|
||||
$aResult[] = $aMap[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1484,7 +1423,7 @@ class MailClient
|
|||
*/
|
||||
public function MessageListByRequestIndexOrUids(MessageCollection $oMessageCollection, array $aRequestIndexOrUids, bool $bIndexAsUid, bool $bSimple = false)
|
||||
{
|
||||
if (\is_array($aRequestIndexOrUids) && 0 < \count($aRequestIndexOrUids))
|
||||
if (0 < \count($aRequestIndexOrUids))
|
||||
{
|
||||
$aFetchResponse = $this->oImapClient->Fetch(array(
|
||||
\MailSo\Imap\Enumerations\FetchType::INDEX,
|
||||
|
|
@ -1498,7 +1437,7 @@ class MailClient
|
|||
$this->getEnvelopeOrHeadersRequestString()
|
||||
), \MailSo\Base\Utils::PrepareFetchSequence($aRequestIndexOrUids), $bIndexAsUid);
|
||||
|
||||
if (\is_array($aFetchResponse) && 0 < \count($aFetchResponse))
|
||||
if (0 < \count($aFetchResponse))
|
||||
{
|
||||
$aFetchIndexArray = array();
|
||||
$oFetchResponseItem = null;
|
||||
|
|
@ -1703,7 +1642,6 @@ class MailClient
|
|||
|
||||
if ($bUseThreadSortIfSupported && 0 < $iThreadUid && \is_array($mAllThreads))
|
||||
{
|
||||
$aUids = array();
|
||||
$iResultRootUid = 0;
|
||||
|
||||
if (isset($mAllThreads[$iThreadUid]))
|
||||
|
|
@ -1747,7 +1685,7 @@ class MailClient
|
|||
$aSearchedUids = $this->GetUids($oCacher, $sSearch, $sFilter,
|
||||
$oMessageCollection->FolderName, $oMessageCollection->FolderHash);
|
||||
|
||||
if (\is_array($aSearchedUids) && 0 < \count($aSearchedUids))
|
||||
if (0 < \count($aSearchedUids))
|
||||
{
|
||||
$aFlippedSearchedUids = \array_flip($aSearchedUids);
|
||||
|
||||
|
|
@ -1875,13 +1813,13 @@ class MailClient
|
|||
$aUids = $this->oImapClient->MessageSimpleSearch(
|
||||
'HEADER Message-ID '.$sMessageId, true);
|
||||
|
||||
return \is_array($aUids) && 1 === \count($aUids) && \is_numeric($aUids[0]) ? (int) $aUids[0] : null;
|
||||
return 1 === \count($aUids) && \is_numeric($aUids[0]) ? (int) $aUids[0] : null;
|
||||
}
|
||||
|
||||
public function folderListOptimization(array $aMailFoldersHelper, int $iOptimizationLimit = 0) : array
|
||||
{
|
||||
// optimization
|
||||
if (10 < $iOptimizationLimit && \is_array($aMailFoldersHelper) && $iOptimizationLimit < \count($aMailFoldersHelper))
|
||||
if (10 < $iOptimizationLimit && $iOptimizationLimit < \count($aMailFoldersHelper))
|
||||
{
|
||||
if ($this->oLogger)
|
||||
{
|
||||
|
|
@ -2006,16 +1944,21 @@ class MailClient
|
|||
return $aMailFoldersHelper;
|
||||
}
|
||||
|
||||
public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : FolderCollection
|
||||
public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : ?FolderCollection
|
||||
{
|
||||
$oFolderCollection = false;
|
||||
$oFolderCollection = null;
|
||||
|
||||
$aSubscribedFolders = null;
|
||||
$aImapSubscribedFoldersHelper = null;
|
||||
if ($bUseListSubscribeStatus)
|
||||
{
|
||||
try
|
||||
{
|
||||
$aSubscribedFolders = $this->oImapClient->FolderSubscribeList($sParent, $sListPattern);
|
||||
$aImapSubscribedFoldersHelper = array();
|
||||
foreach ($aSubscribedFolders as /* @var $oImapFolder \MailSo\Imap\Folder */ $oImapFolder)
|
||||
{
|
||||
$aImapSubscribedFoldersHelper[] = $oImapFolder->FullNameRaw();
|
||||
}
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
|
|
@ -2023,22 +1966,9 @@ class MailClient
|
|||
}
|
||||
}
|
||||
|
||||
$aImapSubscribedFoldersHelper = null;
|
||||
if (\is_array($aSubscribedFolders))
|
||||
{
|
||||
$aImapSubscribedFoldersHelper = array();
|
||||
foreach ($aSubscribedFolders as /* @var $oImapFolder \MailSo\Imap\Folder */ $oImapFolder)
|
||||
{
|
||||
$aImapSubscribedFoldersHelper[] = $oImapFolder->FullNameRaw();
|
||||
}
|
||||
}
|
||||
|
||||
$aFolders = $this->oImapClient->FolderList($sParent, $sListPattern);
|
||||
|
||||
$bOptimized = false;
|
||||
$aMailFoldersHelper = null;
|
||||
|
||||
if (\is_array($aFolders))
|
||||
if ($aFolders)
|
||||
{
|
||||
$aMailFoldersHelper = array();
|
||||
|
||||
|
|
@ -2053,15 +1983,13 @@ class MailClient
|
|||
$iCount = \count($aMailFoldersHelper);
|
||||
$aMailFoldersHelper = $this->folderListOptimization($aMailFoldersHelper, $iOptimizationLimit);
|
||||
|
||||
$bOptimized = $iCount !== \count($aMailFoldersHelper);
|
||||
}
|
||||
if ($aMailFoldersHelper)
|
||||
{
|
||||
$oFolderCollection = FolderCollection::NewInstance();
|
||||
$oFolderCollection->InitByUnsortedMailFolderArray($aMailFoldersHelper);
|
||||
|
||||
if (\is_array($aMailFoldersHelper))
|
||||
{
|
||||
$oFolderCollection = FolderCollection::NewInstance();
|
||||
$oFolderCollection->InitByUnsortedMailFolderArray($aMailFoldersHelper);
|
||||
|
||||
$oFolderCollection->Optimized = $bOptimized;
|
||||
$oFolderCollection->Optimized = $iCount !== \count($aMailFoldersHelper);
|
||||
}
|
||||
}
|
||||
|
||||
if ($oFolderCollection)
|
||||
|
|
@ -2075,10 +2003,6 @@ class MailClient
|
|||
return -1;
|
||||
case 'INBOX' === $sB:
|
||||
return 1;
|
||||
case '[GMAIL]' === $sA:
|
||||
return -1;
|
||||
case '[GMAIL]' === $sB:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return \strnatcasecmp($oFolderA->FullName(), $oFolderB->FullName());
|
||||
|
|
@ -2111,7 +2035,7 @@ class MailClient
|
|||
if (0 === \strlen($sDelimiter) || 0 < \strlen(\trim($sFolderParentFullNameRaw)))
|
||||
{
|
||||
$aFolders = $this->oImapClient->FolderList('', 0 === \strlen(\trim($sFolderParentFullNameRaw)) ? 'INBOX' : $sFolderParentFullNameRaw);
|
||||
if (!\is_array($aFolders) || !isset($aFolders[0]))
|
||||
if (!$aFolders)
|
||||
{
|
||||
// TODO
|
||||
throw new \MailSo\Mail\Exceptions\RuntimeException(
|
||||
|
|
@ -2177,7 +2101,7 @@ class MailClient
|
|||
}
|
||||
|
||||
$aFolders = $this->oImapClient->FolderList('', $sPrevFolderFullNameRaw);
|
||||
if (!\is_array($aFolders) || !isset($aFolders[0]))
|
||||
if (!$aFolders)
|
||||
{
|
||||
// TODO
|
||||
throw new \MailSo\Mail\Exceptions\RuntimeException('Cannot rename non-existen folder');
|
||||
|
|
@ -2186,16 +2110,13 @@ class MailClient
|
|||
$sDelimiter = $aFolders[0]->Delimiter();
|
||||
$iLast = \strrpos($sPrevFolderFullNameRaw, $sDelimiter);
|
||||
|
||||
$mSubscribeFolders = null;
|
||||
$aSubscribeFolders = array();
|
||||
if ($bSubscribeOnModify)
|
||||
{
|
||||
$mSubscribeFolders = $this->oImapClient->FolderSubscribeList($sPrevFolderFullNameRaw, '*');
|
||||
if (\is_array($mSubscribeFolders) && 0 < count($mSubscribeFolders))
|
||||
$aSubscribeFolders = $this->oImapClient->FolderSubscribeList($sPrevFolderFullNameRaw, '*');
|
||||
foreach ($aSubscribeFolders as /* @var $oFolder \MailSo\Imap\Folder */ $oFolder)
|
||||
{
|
||||
foreach ($mSubscribeFolders as /* @var $oFolder \MailSo\Imap\Folder */ $oFolder)
|
||||
{
|
||||
$this->oImapClient->FolderUnSubscribe($oFolder->FullNameRaw());
|
||||
}
|
||||
$this->oImapClient->FolderUnSubscribe($oFolder->FullNameRaw());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2203,7 +2124,7 @@ class MailClient
|
|||
\MailSo\Base\Enumerations\Charset::UTF_8,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP);
|
||||
|
||||
if($bRenameOrMove)
|
||||
if ($bRenameOrMove)
|
||||
{
|
||||
if (0 < \strlen($sDelimiter) && false !== \strpos($sNewFolderFullNameRaw, $sDelimiter))
|
||||
{
|
||||
|
|
@ -2217,18 +2138,15 @@ class MailClient
|
|||
|
||||
$this->oImapClient->FolderRename($sPrevFolderFullNameRaw, $sNewFolderFullNameRaw);
|
||||
|
||||
if (\is_array($mSubscribeFolders) && 0 < count($mSubscribeFolders))
|
||||
foreach ($aSubscribeFolders as /* @var $oFolder \MailSo\Imap\Folder */ $oFolder)
|
||||
{
|
||||
foreach ($mSubscribeFolders as /* @var $oFolder \MailSo\Imap\Folder */ $oFolder)
|
||||
$sFolderFullNameRawForResubscrine = $oFolder->FullNameRaw();
|
||||
if (0 === \strpos($sFolderFullNameRawForResubscrine, $sPrevFolderFullNameRaw))
|
||||
{
|
||||
$sFolderFullNameRawForResubscrine = $oFolder->FullNameRaw();
|
||||
if (0 === \strpos($sFolderFullNameRawForResubscrine, $sPrevFolderFullNameRaw))
|
||||
{
|
||||
$sNewFolderFullNameRawForResubscrine = $sNewFolderFullNameRaw.
|
||||
\substr($sFolderFullNameRawForResubscrine, \strlen($sPrevFolderFullNameRaw));
|
||||
$sNewFolderFullNameRawForResubscrine = $sNewFolderFullNameRaw.
|
||||
\substr($sFolderFullNameRawForResubscrine, \strlen($sPrevFolderFullNameRaw));
|
||||
|
||||
$this->oImapClient->FolderSubscribe($sNewFolderFullNameRawForResubscrine);
|
||||
}
|
||||
$this->oImapClient->FolderSubscribe($sNewFolderFullNameRawForResubscrine);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ class Message
|
|||
|
||||
public function SetThreads(array $aThreads)
|
||||
{
|
||||
$this->aThreads = \is_array($aThreads) ? $aThreads : array();
|
||||
$this->aThreads = $aThreads;
|
||||
}
|
||||
|
||||
public function TextPartIsTrimmed() : bool
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
$aResult = array();
|
||||
|
||||
$aHeaders = $this->ValuesByName(Enumerations\Header::AUTHENTICATION_RESULTS);
|
||||
if (\is_array($aHeaders) && 0 < \count($aHeaders))
|
||||
if (0 < \count($aHeaders))
|
||||
{
|
||||
foreach ($aHeaders as $sHeaderValue)
|
||||
{
|
||||
|
|
@ -265,31 +265,28 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
{
|
||||
// X-DKIM-Authentication-Results: signer="hostinger.com" status="pass"
|
||||
$aHeaders = $this->ValuesByName(Enumerations\Header::X_DKIM_AUTHENTICATION_RESULTS);
|
||||
if (\is_array($aHeaders) && 0 < \count($aHeaders))
|
||||
foreach ($aHeaders as $sHeaderValue)
|
||||
{
|
||||
foreach ($aHeaders as $sHeaderValue)
|
||||
$sStatus = '';
|
||||
$sHeader = '';
|
||||
|
||||
$aMatch = array();
|
||||
|
||||
$sHeaderValue = \preg_replace('/[\r\n\t\s]+/', ' ', $sHeaderValue);
|
||||
|
||||
if (\preg_match('/status[\s]?=[\s]?"([a-zA-Z0-9]+)"/i', $sHeaderValue, $aMatch) && !empty($aMatch[1]))
|
||||
{
|
||||
$sStatus = '';
|
||||
$sHeader = '';
|
||||
$sStatus = $aMatch[1];
|
||||
}
|
||||
|
||||
$aMatch = array();
|
||||
if (\preg_match('/signer[\s]?=[\s]?"([^";]+)"/i', $sHeaderValue, $aMatch) && !empty($aMatch[1]))
|
||||
{
|
||||
$sHeader = \trim($aMatch[1]);
|
||||
}
|
||||
|
||||
$sHeaderValue = \preg_replace('/[\r\n\t\s]+/', ' ', $sHeaderValue);
|
||||
|
||||
if (\preg_match('/status[\s]?=[\s]?"([a-zA-Z0-9]+)"/i', $sHeaderValue, $aMatch) && !empty($aMatch[1]))
|
||||
{
|
||||
$sStatus = $aMatch[1];
|
||||
}
|
||||
|
||||
if (\preg_match('/signer[\s]?=[\s]?"([^";]+)"/i', $sHeaderValue, $aMatch) && !empty($aMatch[1]))
|
||||
{
|
||||
$sHeader = \trim($aMatch[1]);
|
||||
}
|
||||
|
||||
if (!empty($sStatus) && !empty($sHeader))
|
||||
{
|
||||
$aResult[] = array($sStatus, $sHeader, $sHeaderValue);
|
||||
}
|
||||
if (!empty($sStatus) && !empty($sHeader))
|
||||
{
|
||||
$aResult[] = array($sStatus, $sHeader, $sHeaderValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -300,15 +297,13 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
public function PopulateEmailColectionByDkim(EmailCollection $oEmails) : void
|
||||
{
|
||||
$aDkimStatuses = $this->DkimStatuses();
|
||||
if (\is_array($aDkimStatuses) && 0 < \count($aDkimStatuses)) {
|
||||
foreach ($oEmails as $oEmail) {
|
||||
$sEmail = $oEmail->GetEmail();
|
||||
foreach ($aDkimStatuses as $aDkimData) {
|
||||
if (isset($aDkimData[0], $aDkimData[1]) &&
|
||||
$aDkimData[1] === \strstr($sEmail, $aDkimData[1]))
|
||||
{
|
||||
$oEmail->SetDkimStatusAndValue($aDkimData[0], empty($aDkimData[2]) ? '' : $aDkimData[2]);
|
||||
}
|
||||
foreach ($oEmails as $oEmail) {
|
||||
$sEmail = $oEmail->GetEmail();
|
||||
foreach ($aDkimStatuses as $aDkimData) {
|
||||
if (isset($aDkimData[0], $aDkimData[1]) &&
|
||||
$aDkimData[1] === \strstr($sEmail, $aDkimData[1]))
|
||||
{
|
||||
$oEmail->SetDkimStatusAndValue($aDkimData[0], empty($aDkimData[2]) ? '' : $aDkimData[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Message
|
|||
private $aAlternativeParts;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Mime\AttachmentCollection
|
||||
* @var AttachmentCollection
|
||||
*/
|
||||
private $oAttachmentCollection;
|
||||
|
||||
|
|
@ -73,16 +73,16 @@ class Message
|
|||
public function MessageId() : string
|
||||
{
|
||||
$sResult = '';
|
||||
if (!empty($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID]))
|
||||
if (!empty($this->aHeadersValue[Enumerations\Header::MESSAGE_ID]))
|
||||
{
|
||||
$sResult = $this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID];
|
||||
$sResult = $this->aHeadersValue[Enumerations\Header::MESSAGE_ID];
|
||||
}
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
public function SetMessageId(string $sMessageId) : void
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID] = $sMessageId;
|
||||
$this->aHeadersValue[Enumerations\Header::MESSAGE_ID] = $sMessageId;
|
||||
}
|
||||
|
||||
public function RegenerateMessageId(string $sHostName = '') : void
|
||||
|
|
@ -90,76 +90,76 @@ class Message
|
|||
$this->SetMessageId($this->generateNewMessageId($sHostName));
|
||||
}
|
||||
|
||||
public function Attachments() : \MailSo\Mime\AttachmentCollection
|
||||
public function Attachments() : AttachmentCollection
|
||||
{
|
||||
return $this->oAttachmentCollection;
|
||||
}
|
||||
|
||||
public function GetSubject() : string
|
||||
{
|
||||
return isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT]) ?
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT] : '';
|
||||
return isset($this->aHeadersValue[Enumerations\Header::SUBJECT]) ?
|
||||
$this->aHeadersValue[Enumerations\Header::SUBJECT] : '';
|
||||
}
|
||||
|
||||
public function GetFrom() : ?\MailSo\Mime\Email
|
||||
public function GetFrom() : ?Email
|
||||
{
|
||||
$oResult = null;
|
||||
|
||||
if (isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::FROM_]) &&
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::FROM_] instanceof \MailSo\Mime\Email)
|
||||
if (isset($this->aHeadersValue[Enumerations\Header::FROM_]) &&
|
||||
$this->aHeadersValue[Enumerations\Header::FROM_] instanceof Email)
|
||||
{
|
||||
$oResult = $this->aHeadersValue[\MailSo\Mime\Enumerations\Header::FROM_];
|
||||
$oResult = $this->aHeadersValue[Enumerations\Header::FROM_];
|
||||
}
|
||||
|
||||
return $oResult;
|
||||
}
|
||||
|
||||
public function GetTo() : \MailSo\Mime\EmailCollection
|
||||
public function GetTo() : EmailCollection
|
||||
{
|
||||
$oResult = \MailSo\Mime\EmailCollection::NewInstance();
|
||||
$oResult = EmailCollection::NewInstance();
|
||||
|
||||
if (isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_]) &&
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_] instanceof \MailSo\Mime\EmailCollection)
|
||||
if (isset($this->aHeadersValue[Enumerations\Header::TO_]) &&
|
||||
$this->aHeadersValue[Enumerations\Header::TO_] instanceof EmailCollection)
|
||||
{
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_]);
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[Enumerations\Header::TO_]);
|
||||
}
|
||||
|
||||
return $oResult->Unique();
|
||||
}
|
||||
|
||||
public function GetBcc() : ?\MailSo\Mime\EmailCollection
|
||||
public function GetBcc() : ?EmailCollection
|
||||
{
|
||||
$oResult = null;
|
||||
|
||||
if (isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC]) &&
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC] instanceof \MailSo\Mime\EmailCollection)
|
||||
if (isset($this->aHeadersValue[Enumerations\Header::BCC]) &&
|
||||
$this->aHeadersValue[Enumerations\Header::BCC] instanceof EmailCollection)
|
||||
{
|
||||
$oResult = $this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC];
|
||||
$oResult = $this->aHeadersValue[Enumerations\Header::BCC];
|
||||
}
|
||||
|
||||
return $oResult ? $oResult->Unique() : null;
|
||||
}
|
||||
|
||||
public function GetRcpt() : \MailSo\Mime\EmailCollection
|
||||
public function GetRcpt() : EmailCollection
|
||||
{
|
||||
$oResult = \MailSo\Mime\EmailCollection::NewInstance();
|
||||
$oResult = EmailCollection::NewInstance();
|
||||
|
||||
if (isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_]) &&
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_] instanceof \MailSo\Mime\EmailCollection)
|
||||
if (isset($this->aHeadersValue[Enumerations\Header::TO_]) &&
|
||||
$this->aHeadersValue[Enumerations\Header::TO_] instanceof EmailCollection)
|
||||
{
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_]);
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[Enumerations\Header::TO_]);
|
||||
}
|
||||
|
||||
if (isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::CC]) &&
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::CC] instanceof \MailSo\Mime\EmailCollection)
|
||||
if (isset($this->aHeadersValue[Enumerations\Header::CC]) &&
|
||||
$this->aHeadersValue[Enumerations\Header::CC] instanceof EmailCollection)
|
||||
{
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::CC]);
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[Enumerations\Header::CC]);
|
||||
}
|
||||
|
||||
if (isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC]) &&
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC] instanceof \MailSo\Mime\EmailCollection)
|
||||
if (isset($this->aHeadersValue[Enumerations\Header::BCC]) &&
|
||||
$this->aHeadersValue[Enumerations\Header::BCC] instanceof EmailCollection)
|
||||
{
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC]);
|
||||
$oResult->MergeWithOtherCollection($this->aHeadersValue[Enumerations\Header::BCC]);
|
||||
}
|
||||
|
||||
return $oResult->Unique();
|
||||
|
|
@ -178,21 +178,21 @@ class Message
|
|||
|
||||
public function SetSubject(string $sSubject) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT] = $sSubject;
|
||||
$this->aHeadersValue[Enumerations\Header::SUBJECT] = $sSubject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetInReplyTo(string $sInReplyTo) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::IN_REPLY_TO] = $sInReplyTo;
|
||||
$this->aHeadersValue[Enumerations\Header::IN_REPLY_TO] = $sInReplyTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetReferences(string $sReferences) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::REFERENCES] =
|
||||
$this->aHeadersValue[Enumerations\Header::REFERENCES] =
|
||||
\MailSo\Base\Utils::StripSpaces($sReferences);
|
||||
|
||||
return $this;
|
||||
|
|
@ -200,8 +200,8 @@ class Message
|
|||
|
||||
public function SetReadReceipt(string $sEmail) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO] = $sEmail;
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO] = $sEmail;
|
||||
$this->aHeadersValue[Enumerations\Header::DISPOSITION_NOTIFICATION_TO] = $sEmail;
|
||||
$this->aHeadersValue[Enumerations\Header::X_CONFIRM_READING_TO] = $sEmail;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -216,20 +216,20 @@ class Message
|
|||
$sResult = '';
|
||||
switch ($iValue)
|
||||
{
|
||||
case \MailSo\Mime\Enumerations\MessagePriority::HIGH:
|
||||
$sResult = \MailSo\Mime\Enumerations\MessagePriority::HIGH.' (Highest)';
|
||||
case Enumerations\MessagePriority::HIGH:
|
||||
$sResult = Enumerations\MessagePriority::HIGH.' (Highest)';
|
||||
break;
|
||||
case \MailSo\Mime\Enumerations\MessagePriority::NORMAL:
|
||||
$sResult = \MailSo\Mime\Enumerations\MessagePriority::NORMAL.' (Normal)';
|
||||
case Enumerations\MessagePriority::NORMAL:
|
||||
$sResult = Enumerations\MessagePriority::NORMAL.' (Normal)';
|
||||
break;
|
||||
case \MailSo\Mime\Enumerations\MessagePriority::LOW:
|
||||
$sResult = \MailSo\Mime\Enumerations\MessagePriority::LOW.' (Lowest)';
|
||||
case Enumerations\MessagePriority::LOW:
|
||||
$sResult = Enumerations\MessagePriority::LOW.' (Lowest)';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 < \strlen($sResult))
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_PRIORITY] = $sResult;
|
||||
$this->aHeadersValue[Enumerations\Header::X_PRIORITY] = $sResult;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -240,20 +240,20 @@ class Message
|
|||
$sResult = '';
|
||||
switch ($iValue)
|
||||
{
|
||||
case \MailSo\Mime\Enumerations\Sensitivity::CONFIDENTIAL:
|
||||
case Enumerations\Sensitivity::CONFIDENTIAL:
|
||||
$sResult = 'Company-Confidential';
|
||||
break;
|
||||
case \MailSo\Mime\Enumerations\Sensitivity::PERSONAL:
|
||||
case Enumerations\Sensitivity::PERSONAL:
|
||||
$sResult = 'Personal';
|
||||
break;
|
||||
case \MailSo\Mime\Enumerations\Sensitivity::PRIVATE_:
|
||||
case Enumerations\Sensitivity::PRIVATE_:
|
||||
$sResult = 'Private';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 < \strlen($sResult))
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SENSITIVITY] = $sResult;
|
||||
$this->aHeadersValue[Enumerations\Header::SENSITIVITY] = $sResult;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -261,66 +261,66 @@ class Message
|
|||
|
||||
public function SetXMailer(string $sXMailer) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_MAILER] = $sXMailer;
|
||||
$this->aHeadersValue[Enumerations\Header::X_MAILER] = $sXMailer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetFrom(\MailSo\Mime\Email $oEmail) : self
|
||||
public function SetFrom(Email $oEmail) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::FROM_] = $oEmail;
|
||||
$this->aHeadersValue[Enumerations\Header::FROM_] = $oEmail;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetTo(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
public function SetTo(EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_] = $oEmails;
|
||||
$this->aHeadersValue[Enumerations\Header::TO_] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetDate(int $iDateTime) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DATE] = gmdate('r', $iDateTime);
|
||||
$this->aHeadersValue[Enumerations\Header::DATE] = gmdate('r', $iDateTime);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetReplyTo(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
public function SetReplyTo(EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::REPLY_TO] = $oEmails;
|
||||
$this->aHeadersValue[Enumerations\Header::REPLY_TO] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetCc(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
public function SetCc(EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::CC] = $oEmails;
|
||||
$this->aHeadersValue[Enumerations\Header::CC] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetBcc(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
public function SetBcc(EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC] = $oEmails;
|
||||
$this->aHeadersValue[Enumerations\Header::BCC] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetSender(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
public function SetSender(EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SENDER] = $oEmails;
|
||||
$this->aHeadersValue[Enumerations\Header::SENDER] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function SetDraftInfo(string $sType, string $sUid, string $sFolder) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_DRAFT_INFO] = \MailSo\Mime\ParameterCollection::NewInstance()
|
||||
->Add(\MailSo\Mime\Parameter::NewInstance('type', $sType))
|
||||
->Add(\MailSo\Mime\Parameter::NewInstance('uid', $sUid))
|
||||
->Add(\MailSo\Mime\Parameter::NewInstance('folder', base64_encode($sFolder)))
|
||||
$this->aHeadersValue[Enumerations\Header::X_DRAFT_INFO] = ParameterCollection::NewInstance()
|
||||
->Add(Parameter::NewInstance('type', $sType))
|
||||
->Add(Parameter::NewInstance('uid', $sUid))
|
||||
->Add(Parameter::NewInstance('folder', base64_encode($sFolder)))
|
||||
;
|
||||
|
||||
return $this;
|
||||
|
|
@ -329,14 +329,14 @@ class Message
|
|||
public function AddPlain(string $sPlain) : self
|
||||
{
|
||||
return $this->AddAlternative(
|
||||
\MailSo\Mime\Enumerations\MimeType::TEXT_PLAIN, trim($sPlain),
|
||||
Enumerations\MimeType::TEXT_PLAIN, trim($sPlain),
|
||||
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
|
||||
}
|
||||
|
||||
public function AddHtml(string $sHtml) : self
|
||||
{
|
||||
return $this->AddAlternative(
|
||||
\MailSo\Mime\Enumerations\MimeType::TEXT_HTML, trim($sHtml),
|
||||
Enumerations\MimeType::TEXT_HTML, trim($sHtml),
|
||||
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
|
||||
}
|
||||
|
||||
|
|
@ -380,7 +380,7 @@ class Message
|
|||
(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? \getmypid() : '')).'@'.$sHostName.'>';
|
||||
}
|
||||
|
||||
private function createNewMessageAttachmentBody(\MailSo\Mime\Attachment $oAttachment) : \MailSo\Mime\Part
|
||||
private function createNewMessageAttachmentBody(Attachment $oAttachment) : Part
|
||||
{
|
||||
$oAttachmentPart = Part::NewInstance();
|
||||
|
||||
|
|
@ -395,22 +395,22 @@ class Message
|
|||
{
|
||||
$oContentTypeParameters =
|
||||
ParameterCollection::NewInstance()->Add(Parameter::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Parameter::NAME, $sFileName));
|
||||
Enumerations\Parameter::NAME, $sFileName));
|
||||
|
||||
$oContentDispositionParameters =
|
||||
ParameterCollection::NewInstance()->Add(Parameter::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Parameter::FILENAME, $sFileName));
|
||||
Enumerations\Parameter::FILENAME, $sFileName));
|
||||
}
|
||||
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_TYPE,
|
||||
$oAttachment->ContentType().';'.
|
||||
(($oContentTypeParameters) ? ' '.$oContentTypeParameters->ToString() : '')
|
||||
)
|
||||
);
|
||||
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_DISPOSITION,
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_DISPOSITION,
|
||||
($oAttachment->IsInline() ? 'inline' : 'attachment').';'.
|
||||
(($oContentDispositionParameters) ? ' '.$oContentDispositionParameters->ToString() : '')
|
||||
)
|
||||
|
|
@ -419,14 +419,14 @@ class Message
|
|||
if (0 < strlen($sCID))
|
||||
{
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_ID, $sCID)
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_ID, $sCID)
|
||||
);
|
||||
}
|
||||
|
||||
if (0 < strlen($sContentLocation))
|
||||
{
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_LOCATION, $sContentLocation)
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_LOCATION, $sContentLocation)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -436,7 +436,7 @@ class Message
|
|||
{
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING,
|
||||
Enumerations\Header::CONTENT_TRANSFER_ENCODING,
|
||||
\MailSo\Base\Enumerations\Encoding::BASE64_LOWER
|
||||
)
|
||||
);
|
||||
|
|
@ -458,17 +458,17 @@ class Message
|
|||
return $oAttachmentPart;
|
||||
}
|
||||
|
||||
private function createNewMessageAlternativePartBody(array $aAlternativeData) : \MailSo\Mime\Part
|
||||
private function createNewMessageAlternativePartBody(array $aAlternativeData) : ?Part
|
||||
{
|
||||
$oAlternativePart = null;
|
||||
|
||||
if (is_array($aAlternativeData) && isset($aAlternativeData[0]))
|
||||
if (isset($aAlternativeData[0]))
|
||||
{
|
||||
$oAlternativePart = Part::NewInstance();
|
||||
$oParameters = ParameterCollection::NewInstance();
|
||||
$oParameters->append(
|
||||
Parameter::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Parameter::CHARSET,
|
||||
Enumerations\Parameter::CHARSET,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_8)
|
||||
);
|
||||
|
||||
|
|
@ -481,7 +481,7 @@ class Message
|
|||
}
|
||||
|
||||
$oAlternativePart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_TYPE,
|
||||
$aAlternativeData[0].'; '.$oParameters->ToString())
|
||||
);
|
||||
|
||||
|
|
@ -502,7 +502,7 @@ class Message
|
|||
if (isset($aAlternativeData[2]) && 0 < strlen($aAlternativeData[2]))
|
||||
{
|
||||
$oAlternativePart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING,
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_TRANSFER_ENCODING,
|
||||
$aAlternativeData[2]
|
||||
)
|
||||
);
|
||||
|
|
@ -531,7 +531,7 @@ class Message
|
|||
return $oAlternativePart;
|
||||
}
|
||||
|
||||
private function createNewMessageSimpleOrAlternativeBody() : \MailSo\Mime\Part
|
||||
private function createNewMessageSimpleOrAlternativeBody() : Part
|
||||
{
|
||||
$oResultPart = null;
|
||||
if (1 < count($this->aAlternativeParts))
|
||||
|
|
@ -539,11 +539,11 @@ class Message
|
|||
$oResultPart = Part::NewInstance();
|
||||
|
||||
$oResultPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\MimeType::MULTIPART_ALTERNATIVE.'; '.
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_TYPE,
|
||||
Enumerations\MimeType::MULTIPART_ALTERNATIVE.'; '.
|
||||
ParameterCollection::NewInstance()->Add(
|
||||
Parameter::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Parameter::BOUNDARY,
|
||||
Enumerations\Parameter::BOUNDARY,
|
||||
$this->generateNewBoundary())
|
||||
)->ToString()
|
||||
)
|
||||
|
|
@ -575,13 +575,13 @@ class Message
|
|||
if ($this->bAddEmptyTextPart)
|
||||
{
|
||||
$oResultPart = $this->createNewMessageAlternativePartBody(array(
|
||||
\MailSo\Mime\Enumerations\MimeType::TEXT_PLAIN, null
|
||||
Enumerations\MimeType::TEXT_PLAIN, null
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$aAttachments = $this->oAttachmentCollection->getArrayCopy();
|
||||
if (\is_array($aAttachments) && 1 === count($aAttachments) && isset($aAttachments[0]))
|
||||
if (1 === count($aAttachments) && isset($aAttachments[0]))
|
||||
{
|
||||
$this->oAttachmentCollection->Clear();
|
||||
|
||||
|
|
@ -596,7 +596,7 @@ class Message
|
|||
return $oResultPart;
|
||||
}
|
||||
|
||||
private function createNewMessageRelatedBody(\MailSo\Mime\Part $oIncPart) : \MailSo\Mime\Part
|
||||
private function createNewMessageRelatedBody(Part $oIncPart) : Part
|
||||
{
|
||||
$oResultPart = null;
|
||||
|
||||
|
|
@ -606,11 +606,11 @@ class Message
|
|||
$oResultPart = Part::NewInstance();
|
||||
|
||||
$oResultPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\MimeType::MULTIPART_RELATED.'; '.
|
||||
Header::NewInstance(Enumerations\Header::CONTENT_TYPE,
|
||||
Enumerations\MimeType::MULTIPART_RELATED.'; '.
|
||||
ParameterCollection::NewInstance()->Add(
|
||||
Parameter::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Parameter::BOUNDARY,
|
||||
Enumerations\Parameter::BOUNDARY,
|
||||
$this->generateNewBoundary())
|
||||
)->ToString()
|
||||
)
|
||||
|
|
@ -631,7 +631,7 @@ class Message
|
|||
return $oResultPart;
|
||||
}
|
||||
|
||||
private function createNewMessageMixedBody(\MailSo\Mime\Part $oIncPart) : \MailSo\Mime\Part
|
||||
private function createNewMessageMixedBody(Part $oIncPart) : Part
|
||||
{
|
||||
$oResultPart = null;
|
||||
|
||||
|
|
@ -640,11 +640,11 @@ class Message
|
|||
{
|
||||
$oResultPart = Part::NewInstance();
|
||||
|
||||
$oResultPart->Headers->AddByName(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\MimeType::MULTIPART_MIXED.'; '.
|
||||
$oResultPart->Headers->AddByName(Enumerations\Header::CONTENT_TYPE,
|
||||
Enumerations\MimeType::MULTIPART_MIXED.'; '.
|
||||
ParameterCollection::NewInstance()->Add(
|
||||
Parameter::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Parameter::BOUNDARY,
|
||||
Enumerations\Parameter::BOUNDARY,
|
||||
$this->generateNewBoundary())
|
||||
)->ToString()
|
||||
);
|
||||
|
|
@ -664,40 +664,40 @@ class Message
|
|||
return $oResultPart;
|
||||
}
|
||||
|
||||
private function setDefaultHeaders(\MailSo\Mime\Part $oIncPart, bool $bWithoutBcc = false) : \MailSo\Mime\Part
|
||||
private function setDefaultHeaders(Part $oIncPart, bool $bWithoutBcc = false) : Part
|
||||
{
|
||||
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DATE]))
|
||||
if (!isset($this->aHeadersValue[Enumerations\Header::DATE]))
|
||||
{
|
||||
$oIncPart->Headers->SetByName(\MailSo\Mime\Enumerations\Header::DATE, \gmdate('r'), true);
|
||||
$oIncPart->Headers->SetByName(Enumerations\Header::DATE, \gmdate('r'), true);
|
||||
}
|
||||
|
||||
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID]))
|
||||
if (!isset($this->aHeadersValue[Enumerations\Header::MESSAGE_ID]))
|
||||
{
|
||||
$oIncPart->Headers->SetByName(\MailSo\Mime\Enumerations\Header::MESSAGE_ID, $this->generateNewMessageId(), true);
|
||||
$oIncPart->Headers->SetByName(Enumerations\Header::MESSAGE_ID, $this->generateNewMessageId(), true);
|
||||
}
|
||||
|
||||
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_MAILER]) && $this->bAddDefaultXMailer)
|
||||
if (!isset($this->aHeadersValue[Enumerations\Header::X_MAILER]) && $this->bAddDefaultXMailer)
|
||||
{
|
||||
$oIncPart->Headers->SetByName(\MailSo\Mime\Enumerations\Header::X_MAILER, 'MailSo/2.0.1-djmaze', true);
|
||||
$oIncPart->Headers->SetByName(Enumerations\Header::X_MAILER, 'MailSo/2.0.1-djmaze', true);
|
||||
}
|
||||
|
||||
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MIME_VERSION]))
|
||||
if (!isset($this->aHeadersValue[Enumerations\Header::MIME_VERSION]))
|
||||
{
|
||||
$oIncPart->Headers->SetByName(\MailSo\Mime\Enumerations\Header::MIME_VERSION, '1.0', true);
|
||||
$oIncPart->Headers->SetByName(Enumerations\Header::MIME_VERSION, '1.0', true);
|
||||
}
|
||||
|
||||
foreach ($this->aHeadersValue as $sName => $mValue)
|
||||
{
|
||||
if (\is_object($mValue))
|
||||
{
|
||||
if ($mValue instanceof \MailSo\Mime\EmailCollection || $mValue instanceof \MailSo\Mime\Email ||
|
||||
$mValue instanceof \MailSo\Mime\ParameterCollection)
|
||||
if ($mValue instanceof EmailCollection || $mValue instanceof Email ||
|
||||
$mValue instanceof ParameterCollection)
|
||||
{
|
||||
$mValue = $mValue->ToString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!($bWithoutBcc && \strtolower(\MailSo\Mime\Enumerations\Header::BCC) === \strtolower($sName)))
|
||||
if (!($bWithoutBcc && \strtolower(Enumerations\Header::BCC) === \strtolower($sName)))
|
||||
{
|
||||
$oIncPart->Headers->SetByName($sName, (string) $mValue);
|
||||
}
|
||||
|
|
@ -706,7 +706,7 @@ class Message
|
|||
return $oIncPart;
|
||||
}
|
||||
|
||||
public function ToPart(bool $bWithoutBcc = false) : \MailSo\Mime\Part
|
||||
public function ToPart(bool $bWithoutBcc = false) : Part
|
||||
{
|
||||
$oPart = $this->createNewMessageSimpleOrAlternativeBody();
|
||||
$oPart = $this->createNewMessageRelatedBody($oPart);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ class PartCollection extends \MailSo\Base\Collection
|
|||
*/
|
||||
public function ToStream(string $sBoundary)
|
||||
{
|
||||
$rResult = null;
|
||||
if (0 < \strlen($sBoundary))
|
||||
{
|
||||
$aResult = array();
|
||||
|
|
@ -57,6 +56,6 @@ class PartCollection extends \MailSo\Base\Collection
|
|||
return \MailSo\Base\StreamWrappers\SubStreams::CreateStream($aResult);
|
||||
}
|
||||
|
||||
return $rResult;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,21 +411,19 @@ abstract class NetClient
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $mReadLen = null
|
||||
*
|
||||
* @throws \MailSo\Net\Exceptions\SocketConnectionDoesNotAvailableException
|
||||
* @throws \MailSo\Net\Exceptions\SocketReadException
|
||||
*/
|
||||
protected function getNextBuffer($mReadLen = null, bool $bForceLogin = false) : void
|
||||
protected function getNextBuffer(?int $iReadLen = null, bool $bForceLogin = false) : void
|
||||
{
|
||||
if (null === $mReadLen)
|
||||
if (null === $iReadLen)
|
||||
{
|
||||
$this->sResponseBuffer = \fgets($this->rConnect);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sResponseBuffer = '';
|
||||
$iRead = $mReadLen;
|
||||
$iRead = $iReadLen;
|
||||
while (0 < $iRead)
|
||||
{
|
||||
$sAddRead = \fread($this->rConnect, $iRead);
|
||||
|
|
@ -465,7 +463,7 @@ abstract class NetClient
|
|||
else
|
||||
{
|
||||
$iReadedLen = \strlen($this->sResponseBuffer);
|
||||
if (null === $mReadLen || $bForceLogin)
|
||||
if (null === $iReadLen || $bForceLogin)
|
||||
{
|
||||
$iLimit = 5000; // 5KB
|
||||
if ($iLimit < $iReadedLen)
|
||||
|
|
@ -481,7 +479,7 @@ abstract class NetClient
|
|||
}
|
||||
else
|
||||
{
|
||||
$this->writeLog('Received '.$iReadedLen.'/'.$mReadLen.' bytes.',
|
||||
$this->writeLog('Received '.$iReadedLen.'/'.$iReadLen.' bytes.',
|
||||
\MailSo\Log\Enumerations\Type::INFO);
|
||||
}
|
||||
|
||||
|
|
@ -507,10 +505,7 @@ abstract class NetClient
|
|||
$this->writeLog($sDesc, $iDescType, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception $oException
|
||||
*/
|
||||
protected function writeLogException($oException,
|
||||
protected function writeLogException(\Throwable $oException,
|
||||
int $iDescType = \MailSo\Log\Enumerations\Type::NOTICE, bool $bThrowException = false) : void
|
||||
{
|
||||
if ($this->oLogger)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception
|
|||
{
|
||||
parent::__construct($sMessage, $iCode, $oPrevious);
|
||||
|
||||
if (is_array($aResponses))
|
||||
{
|
||||
$this->aResponses = $aResponses;
|
||||
}
|
||||
$this->aResponses = $aResponses;
|
||||
}
|
||||
|
||||
public function GetResponses() : array
|
||||
|
|
@ -40,6 +37,7 @@ class ResponseException extends \MailSo\Sieve\Exceptions\Exception
|
|||
|
||||
public function GetLastResponse() : ?\MailSo\Sieve\Response
|
||||
{
|
||||
return 0 < count($this->aResponses) ? $this->aResponses[count($this->aResponses) - 1] : null;
|
||||
$iCnt = count($this->aResponses);
|
||||
return $iCnt ? $this->aResponses[$iCnt - 1] : null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,9 +87,9 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
|
||||
parent::Connect($sServerName, $iPort, $iSecurityType, $bVerifySsl, $bAllowSelfSigned);
|
||||
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
$this->parseStartupResponse($mResponse);
|
||||
$aResponse = $this->parseResponse();
|
||||
$this->validateResponse($aResponse);
|
||||
$this->parseStartupResponse($aResponse);
|
||||
|
||||
if (\MailSo\Net\Enumerations\ConnectionSecurityType::UseStartTLS(
|
||||
$this->IsSupported('STARTTLS'), $this->iSecurityType))
|
||||
|
|
@ -97,9 +97,9 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
$this->sendRequestWithCheck('STARTTLS');
|
||||
$this->EnableCrypto();
|
||||
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
$this->parseStartupResponse($mResponse);
|
||||
$aResponse = $this->parseResponse();
|
||||
$this->validateResponse($aResponse);
|
||||
$this->parseStartupResponse($aResponse);
|
||||
}
|
||||
else if (\MailSo\Net\Enumerations\ConnectionSecurityType::STARTTLS === $this->iSecurityType)
|
||||
{
|
||||
|
|
@ -142,9 +142,9 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
$this->sendRequest($sAuth);
|
||||
}
|
||||
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
$this->parseStartupResponse($mResponse);
|
||||
$aResponse = $this->parseResponse();
|
||||
$this->validateResponse($aResponse);
|
||||
$this->parseStartupResponse($aResponse);
|
||||
$bAuth = true;
|
||||
}
|
||||
else if ($this->IsAuthSupported('LOGIN'))
|
||||
|
|
@ -158,9 +158,9 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
$this->sendRequest('{'.\strlen($sPassword).'+}');
|
||||
$this->sendRequest($sPassword);
|
||||
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
$this->parseStartupResponse($mResponse);
|
||||
$aResponse = $this->parseResponse();
|
||||
$this->validateResponse($aResponse);
|
||||
$this->parseStartupResponse($aResponse);
|
||||
$bAuth = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -213,22 +213,19 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
public function ListScripts() : array
|
||||
{
|
||||
$this->sendRequest('LISTSCRIPTS');
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
$aResponse = $this->parseResponse();
|
||||
$this->validateResponse($aResponse);
|
||||
|
||||
$aResult = array();
|
||||
if (\is_array($mResponse))
|
||||
foreach ($aResponse as $sLine)
|
||||
{
|
||||
foreach ($mResponse as $sLine)
|
||||
$aTokens = $this->parseLine($sLine);
|
||||
if (false === $aTokens)
|
||||
{
|
||||
$aTokens = $this->parseLine($sLine);
|
||||
if (false === $aTokens)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$aResult[$aTokens[0]] = 'ACTIVE' === substr($sLine, -6);
|
||||
continue;
|
||||
}
|
||||
|
||||
$aResult[$aTokens[0]] = 'ACTIVE' === substr($sLine, -6);
|
||||
}
|
||||
|
||||
return $aResult;
|
||||
|
|
@ -241,9 +238,9 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
public function Capability() : array
|
||||
{
|
||||
$this->sendRequest('CAPABILITY');
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
$this->parseStartupResponse($mResponse);
|
||||
$aResponse = $this->parseResponse();
|
||||
$this->validateResponse($aResponse);
|
||||
$this->parseStartupResponse($aResponse);
|
||||
|
||||
return $this->aCapa;
|
||||
}
|
||||
|
|
@ -266,23 +263,23 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
public function GetScript(string $sScriptName) : string
|
||||
{
|
||||
$this->sendRequest('GETSCRIPT "'.$sScriptName.'"');
|
||||
$mResponse = $this->parseResponse();
|
||||
$this->validateResponse($mResponse);
|
||||
$aResponse = $this->parseResponse();
|
||||
$this->validateResponse($aResponse);
|
||||
|
||||
$sScript = '';
|
||||
if (\is_array($mResponse) && 0 < \count($mResponse))
|
||||
if (0 < \count($aResponse))
|
||||
{
|
||||
if ('{' === $mResponse[0][0])
|
||||
if ('{' === $aResponse[0][0])
|
||||
{
|
||||
\array_shift($mResponse);
|
||||
\array_shift($aResponse);
|
||||
}
|
||||
|
||||
if (\in_array(\substr($mResponse[\count($mResponse) - 1], 0, 2), array('OK', 'NO')))
|
||||
if (\in_array(\substr($aResponse[\count($aResponse) - 1], 0, 2), array('OK', 'NO')))
|
||||
{
|
||||
\array_pop($mResponse);
|
||||
\array_pop($aResponse);
|
||||
}
|
||||
|
||||
$sScript = \implode("\n", $mResponse);
|
||||
$sScript = \implode("\n", $aResponse);
|
||||
}
|
||||
|
||||
return $sScript;
|
||||
|
|
@ -341,14 +338,11 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
public function GetActiveScriptName() : string
|
||||
{
|
||||
$aList = $this->ListScripts();
|
||||
if (\is_array($aList) && 0 < \count($aList))
|
||||
foreach ($aList as $sName => $bIsActive)
|
||||
{
|
||||
foreach ($aList as $sName => $bIsActive)
|
||||
if ($bIsActive)
|
||||
{
|
||||
if ($bIsActive)
|
||||
{
|
||||
return $sName;
|
||||
}
|
||||
return $sName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -398,9 +392,9 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
*/
|
||||
private function parseStartupResponse($mResponse) : void
|
||||
private function parseStartupResponse(array $aResponse) : void
|
||||
{
|
||||
foreach ($mResponse as $sLine)
|
||||
foreach ($aResponse as $sLine)
|
||||
{
|
||||
$aTokens = $this->parseLine($sLine);
|
||||
|
||||
|
|
@ -518,7 +512,7 @@ class ManageSieveClient extends \MailSo\Net\NetClient
|
|||
*/
|
||||
private function validateResponse(array $aResponse)
|
||||
{
|
||||
if (!\is_array($aResponse) || 0 === \count($aResponse) ||
|
||||
if (!$aResponse ||
|
||||
'OK' !== \substr($aResponse[\count($aResponse) - 1], 0, 2))
|
||||
{
|
||||
$this->writeLogException(
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception
|
|||
{
|
||||
parent::__construct($sMessage, $iCode, $oPrevious);
|
||||
|
||||
if (is_array($aResponses))
|
||||
{
|
||||
$this->aResponses = $aResponses;
|
||||
}
|
||||
$this->aResponses = $aResponses;
|
||||
}
|
||||
|
||||
public function GetResponses() : array
|
||||
|
|
@ -40,6 +37,7 @@ class ResponseException extends \MailSo\Smtp\Exceptions\Exception
|
|||
|
||||
public function GetLastResponse() : ?\MailSo\Smtp\Response
|
||||
{
|
||||
return 0 < count($this->aResponses) ? $this->aResponses[count($this->aResponses) - 1] : null;
|
||||
$iCnt = count($this->aResponses);
|
||||
return $iCnt ? $this->aResponses[$iCnt - 1] : null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,7 +289,6 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
|
||||
$sCmd = 'FROM:<'.$sFrom.'>';
|
||||
|
||||
$sSizeIfSupported = (string) $sSizeIfSupported;
|
||||
if (0 < \strlen($sSizeIfSupported) && \is_numeric($sSizeIfSupported) && $this->IsSupported('SIZE'))
|
||||
{
|
||||
$sCmd .= ' SIZE='.$sSizeIfSupported;
|
||||
|
|
@ -577,7 +576,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Smtp\Exceptions\Exception
|
||||
*/
|
||||
private function ehlo($sHost) : void
|
||||
private function ehlo(string $sHost) : void
|
||||
{
|
||||
$this->sendRequestWithCheck('EHLO', 250, $sHost);
|
||||
|
||||
|
|
@ -588,7 +587,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$sLine = \trim($aMatch[1]);
|
||||
$aLine = \preg_split('/[ =]/', $sLine, 2);
|
||||
if (\is_array($aLine) && 0 < \count($aLine) && !empty($aLine[0]))
|
||||
if (!empty($aLine[0]))
|
||||
{
|
||||
$sCapa = \strtoupper($aLine[0]);
|
||||
if (('AUTH' === $sCapa || 'SIZE' === $sCapa) && !empty($aLine[1]))
|
||||
|
|
@ -646,7 +645,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
$this->getNextBuffer();
|
||||
$aParts = \preg_split('/([\s\-]+)/', $this->sResponseBuffer, 2, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
if (\is_array($aParts) && 3 === \count($aParts) && \is_numeric($aParts[0]))
|
||||
if (3 === \count($aParts) && \is_numeric($aParts[0]))
|
||||
{
|
||||
if ('-' !== \substr($aParts[1], 0, 1) && !\in_array((int) $aParts[0], $mExpectCode))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue