mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-10-02 01:44:40 +08:00
remove imap_message_list_hide_deleted_messages setting (it's a bad idea to use it)
fixed uid cacher certificate validatetion on test connection (first look)
This commit is contained in:
parent
1fee4d35f9
commit
60b449b9f8
8 changed files with 168 additions and 170 deletions
|
@ -2,7 +2,7 @@
|
|||
"name": "RainLoop",
|
||||
"title": "RainLoop Webmail",
|
||||
"version": "1.6.9",
|
||||
"release": "169",
|
||||
"release": "170",
|
||||
"description": "Simple, modern & fast web-based email client",
|
||||
"homepage": "http://rainloop.net",
|
||||
"main": "gulpfile.js",
|
||||
|
|
|
@ -1,60 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace MailSo;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Base
|
||||
*/
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $ICONV = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $MBSTRING = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $FixIconvByMbstring = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $MessageListFastSimpleSearch = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $MessageListCountLimitTrigger = 0;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $MessageListUndeletedFilter = false;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $MessageListDateFilter = 0;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $LogSimpleLiterals = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $PreferStartTlsIfAutoDetect = true;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Log\Logger|null
|
||||
*/
|
||||
public static $SystemLogger = null;
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace MailSo;
|
||||
|
||||
/**
|
||||
* @category MailSo
|
||||
* @package Base
|
||||
*/
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $ICONV = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $MBSTRING = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $FixIconvByMbstring = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $MessageListFastSimpleSearch = true;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $MessageListCountLimitTrigger = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public static $MessageListDateFilter = 0;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $LogSimpleLiterals = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public static $PreferStartTlsIfAutoDetect = true;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Log\Logger|null
|
||||
*/
|
||||
public static $SystemLogger = null;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @param string $sServerName
|
||||
* @param int $iPort = 143
|
||||
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
|
||||
* @param bool $bCapturePeerCertIfSsl = false
|
||||
*
|
||||
* @return \MailSo\Imap\ImapClient
|
||||
*
|
||||
|
@ -134,11 +135,11 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Imap\Exceptions\Exception
|
||||
*/
|
||||
public function Connect($sServerName, $iPort = 143,
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT)
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bCapturePeerCertIfSsl = false)
|
||||
{
|
||||
$this->aTagTimeouts['*'] = \microtime(true);
|
||||
|
||||
parent::Connect($sServerName, $iPort, $iSecurityType);
|
||||
parent::Connect($sServerName, $iPort, $iSecurityType, $bCapturePeerCertIfSsl);
|
||||
|
||||
$this->parseResponseWithValidation('*', true);
|
||||
|
||||
|
@ -628,19 +629,19 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($bUseListStatus)
|
||||
{
|
||||
foreach ($aResult as /* @var $oImapResponse \MailSo\Imap\Response */ $oImapResponse)
|
||||
{
|
||||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oImapResponse->ResponseType &&
|
||||
'STATUS' === $oImapResponse->StatusOrIndex &&
|
||||
'STATUS' === $oImapResponse->StatusOrIndex &&
|
||||
isset($oImapResponse->ResponseList[2]) &&
|
||||
isset($oImapResponse->ResponseList[3]) &&
|
||||
\is_array($oImapResponse->ResponseList[3]))
|
||||
{
|
||||
$sFolderNameRaw = $oImapResponse->ResponseList[2];
|
||||
|
||||
|
||||
$oCurrentFolder = null;
|
||||
foreach ($aReturn as &$oFolder)
|
||||
{
|
||||
|
@ -650,7 +651,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (null !== $oCurrentFolder)
|
||||
{
|
||||
$sName = null;
|
||||
|
@ -667,13 +668,13 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$sName = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (0 < count($aStatus))
|
||||
{
|
||||
$oCurrentFolder->SetExtended('STATUS', $aStatus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unset($oCurrentFolder);
|
||||
}
|
||||
}
|
||||
|
@ -700,9 +701,9 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$sCmd = 'LIST';
|
||||
}
|
||||
|
||||
|
||||
$sListPattern = 0 === strlen(trim($sListPattern)) ? '*' : $sListPattern;
|
||||
|
||||
|
||||
$aParameters = array(
|
||||
$this->EscapeString($sParentFolderName),
|
||||
$this->EscapeString($sListPattern)
|
||||
|
@ -724,7 +725,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$bUseListStatus = false;
|
||||
}
|
||||
|
||||
|
||||
$this->SendRequest($sCmd, $aParameters);
|
||||
|
||||
return $this->getFoldersFromResult(
|
||||
|
@ -1085,7 +1086,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$iStart = 3;
|
||||
}
|
||||
|
||||
|
||||
for ($iIndex = $iStart, $iLen = \count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
||||
{
|
||||
$aReturn[] = (int) $oImapResponse->ResponseList[$iIndex];
|
||||
|
@ -1142,7 +1143,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$aRequest[] = 'RETURN';
|
||||
$aRequest[] = $aSearchOrSortReturn;
|
||||
|
||||
|
||||
$aRequest[] = $aSortTypes;
|
||||
$aRequest[] = \MailSo\Base\Utils::IsAscii($sSearchCriterias) ? 'US-ASCII' : 'UTF-8';
|
||||
}
|
||||
|
@ -1415,7 +1416,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$iStart = 3;
|
||||
}
|
||||
|
||||
|
||||
for ($iIndex = $iStart, $iLen = \count($oImapResponse->ResponseList); $iIndex < $iLen; $iIndex++)
|
||||
{
|
||||
$aNewValue = $this->validateThreadItem($oImapResponse->ResponseList[$iIndex]);
|
||||
|
@ -1454,7 +1455,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
return $this->SendRequestWithCheck($sCommandPrefix.'COPY',
|
||||
array($sIndexRange, $this->EscapeString($sToFolder)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $sToFolder
|
||||
* @param string $sIndexRange
|
||||
|
@ -1488,21 +1489,23 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sUidRangeIfSupported
|
||||
* @param string $sUidRangeIfSupported = ''
|
||||
* @param bool $bForceUidExpunge = false
|
||||
* @param bool $bExpungeAll = false
|
||||
*
|
||||
* @return \MailSo\Imap\ImapClient
|
||||
*
|
||||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Imap\Exceptions\Exception
|
||||
*/
|
||||
public function MessageExpunge($sUidRangeIfSupported = '', $bForceUidExpunge = false)
|
||||
public function MessageExpunge($sUidRangeIfSupported = '', $bForceUidExpunge = false, $bExpungeAll = false)
|
||||
{
|
||||
$sUidRangeIfSupported = \trim($sUidRangeIfSupported);
|
||||
|
||||
$sCmd = 'EXPUNGE';
|
||||
$aArguments = array();
|
||||
|
||||
if ($bForceUidExpunge && 0 < \strlen($sUidRangeIfSupported) && $this->IsSupported('UIDPLUS'))
|
||||
if (!$bExpungeAll && $bForceUidExpunge && 0 < \strlen($sUidRangeIfSupported) && $this->IsSupported('UIDPLUS'))
|
||||
{
|
||||
$sCmd = 'UID '.$sCmd;
|
||||
$aArguments = array($sUidRangeIfSupported);
|
||||
|
@ -1737,7 +1740,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$oImapResponse = null;
|
||||
$sEndTag = (null === $sEndTag) ? $this->getCurrentTag() : $sEndTag;
|
||||
|
||||
|
||||
while (true)
|
||||
{
|
||||
$oImapResponse = Response::NewInstance();
|
||||
|
@ -1929,11 +1932,11 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$this->writeLog('Literal stream read warning "read '.$iLiteralSize.' of '.
|
||||
$iLiteralLen.'" bytes', \MailSo\Log\Enumerations\Type::WARNING);
|
||||
}
|
||||
|
||||
|
||||
if (!$bTreatAsAtom)
|
||||
{
|
||||
$aList[] = $sLiteral;
|
||||
|
||||
|
||||
if (\MailSo\Config::$LogSimpleLiterals)
|
||||
{
|
||||
$this->writeLog('{'.\strlen($sLiteral).'} '.$sLiteral, \MailSo\Log\Enumerations\Type::INFO);
|
||||
|
@ -1965,7 +1968,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$sAtomBlock = $this->partialParseResponseBranch($mNull, $iStackIndex, true,
|
||||
null === $sPreviousAtomUpperCase ? '' : \strtoupper($sPreviousAtomUpperCase));
|
||||
|
||||
|
||||
$sAtomBuilder .= $sAtomBlock;
|
||||
$iPos = $this->iResponseBufParsedPos;
|
||||
$sAtomBuilder .= ($bIsClosingBracketSquare) ? ']' : ')';
|
||||
|
@ -1987,7 +1990,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
if (null !== $oImapResponse && $oImapResponse->IsStatusResponse)
|
||||
{
|
||||
$oImapResponse->OptionalResponse = $aSubItems;
|
||||
|
||||
|
||||
$bIsGotoDefault = true;
|
||||
$bIsGotoNotAtomBracket = false;
|
||||
continue;
|
||||
|
@ -2350,7 +2353,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
if (\is_resource($rImapLiteralStream))
|
||||
{
|
||||
$iNotReadLiteralLen = 0;
|
||||
|
||||
|
||||
$bFeof = \feof($rImapLiteralStream);
|
||||
$this->writeLog('End Callback for '.$sParent.' / '.$sLiteralAtomUpperCase.
|
||||
' - feof = '.($bFeof ? 'good' : 'BAD'), $bFeof ?
|
||||
|
|
|
@ -495,6 +495,7 @@ class MailClient
|
|||
* @param array $aIndexRange
|
||||
* @param bool $bIndexIsUid
|
||||
* @param bool $bUseExpunge = true
|
||||
* @param bool $bExpungeAll = false
|
||||
*
|
||||
* @return \MailSo\Mail\MailClient
|
||||
*
|
||||
|
@ -502,7 +503,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Imap\Exceptions\Exception
|
||||
*/
|
||||
public function MessageDelete($sFolder, $aIndexRange, $bIndexIsUid, $bUseExpunge = true)
|
||||
public function MessageDelete($sFolder, $aIndexRange, $bIndexIsUid, $bUseExpunge = true, $bExpungeAll = false)
|
||||
{
|
||||
if (0 === \strlen($sFolder) || !\is_array($aIndexRange) || 0 === \count($aIndexRange))
|
||||
{
|
||||
|
@ -520,7 +521,7 @@ class MailClient
|
|||
|
||||
if ($bUseExpunge)
|
||||
{
|
||||
$this->oImapClient->MessageExpunge($bIndexIsUid ? $sIndexRange : '', $bIndexIsUid);
|
||||
$this->oImapClient->MessageExpunge($bIndexIsUid ? $sIndexRange : '', $bIndexIsUid, $bExpungeAll);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -532,6 +533,7 @@ class MailClient
|
|||
* @param array $aIndexRange
|
||||
* @param bool $bIndexIsUid
|
||||
* @param bool $bUseMoveSupported = false
|
||||
* @param bool $bExpungeAll = false
|
||||
*
|
||||
* @return \MailSo\Mail\MailClient
|
||||
*
|
||||
|
@ -539,7 +541,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Imap\Exceptions\Exception
|
||||
*/
|
||||
public function MessageMove($sFromFolder, $sToFolder, $aIndexRange, $bIndexIsUid, $bUseMoveSupported = false)
|
||||
public function MessageMove($sFromFolder, $sToFolder, $aIndexRange, $bIndexIsUid, $bUseMoveSupported = false, $bExpungeAll = false)
|
||||
{
|
||||
if (0 === \strlen($sFromFolder) || 0 === \strlen($sToFolder) ||
|
||||
!\is_array($aIndexRange) || 0 === \count($aIndexRange))
|
||||
|
@ -559,7 +561,7 @@ class MailClient
|
|||
$this->oImapClient->MessageCopy($sToFolder,
|
||||
\MailSo\Base\Utils::PrepearFetchSequence($aIndexRange), $bIndexIsUid);
|
||||
|
||||
$this->MessageDelete($sFromFolder, $aIndexRange, $bIndexIsUid, true);
|
||||
$this->MessageDelete($sFromFolder, $aIndexRange, $bIndexIsUid, true, $bExpungeAll);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -647,11 +649,10 @@ class MailClient
|
|||
* @param int $iCount
|
||||
* @param int $iUnseenCount
|
||||
* @param string $sUidNext
|
||||
* @param \MailSo\Cache\CacheClient|null $oCacher = null
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initFolderValues($sFolderName, &$iCount, &$iUnseenCount, &$sUidNext, $oCacher = null)
|
||||
protected function initFolderValues($sFolderName, &$iCount, &$iUnseenCount, &$sUidNext)
|
||||
{
|
||||
$aFolderStatus = $this->oImapClient->FolderStatus($sFolderName, array(
|
||||
\MailSo\Imap\Enumerations\FolderResponseStatus::MESSAGES,
|
||||
|
@ -668,36 +669,7 @@ class MailClient
|
|||
$sUidNext = isset($aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::UIDNEXT])
|
||||
? (string) $aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::UIDNEXT] : '0';
|
||||
|
||||
if (\MailSo\Config::$MessageListUndeletedFilter)
|
||||
{
|
||||
$oFolder = $this->oImapClient->FolderCurrentInformation();
|
||||
if (!$oFolder || $oFolder->FolderName !== $sFolderName)
|
||||
{
|
||||
$this->oImapClient->FolderExamine($sFolderName);
|
||||
}
|
||||
|
||||
$aUids = $this->getSearchUidsResult('',
|
||||
$sFolderName, false, false, false, $oCacher);
|
||||
|
||||
$iNewCount = \count($aUids);
|
||||
if (0 < $iNewCount && $iNewCount !== $iCount)
|
||||
{
|
||||
$iCount = $iNewCount;
|
||||
|
||||
$aUids = $this->getSearchUidsResult('is:unread',
|
||||
$sFolderName, false, false, false, $oCacher);
|
||||
|
||||
$iUnseenCount = \count($aUids);
|
||||
}
|
||||
else if (0 === $iNewCount)
|
||||
{
|
||||
$iCount = 0;
|
||||
$iUnseenCount = 0;
|
||||
}
|
||||
|
||||
unset($aUids);
|
||||
}
|
||||
else if ($this->IsGmail())
|
||||
if ($this->IsGmail())
|
||||
{
|
||||
$oFolder = $this->oImapClient->FolderCurrentInformation();
|
||||
if ($oFolder && null !== $oFolder->Exists && $oFolder->FolderName === $sFolderName)
|
||||
|
@ -800,7 +772,6 @@ class MailClient
|
|||
* @param string $sFolderName
|
||||
* @param string $sPrevUidNext = ''
|
||||
* @param array $aUids = ''
|
||||
* @param \MailSo\Cache\CacheClient|null $oCacher = null
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
@ -808,7 +779,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Imap\Exceptions\Exception
|
||||
*/
|
||||
public function FolderInformation($sFolderName, $sPrevUidNext = '', $aUids = array(), $oCacher = null)
|
||||
public function FolderInformation($sFolderName, $sPrevUidNext = '', $aUids = array())
|
||||
{
|
||||
$aFlags = array();
|
||||
|
||||
|
@ -847,7 +818,7 @@ class MailClient
|
|||
$iUnseenCount = 0;
|
||||
$sUidNext = '0';
|
||||
|
||||
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $sUidNext, $oCacher);
|
||||
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $sUidNext);
|
||||
|
||||
$aResult = array(
|
||||
'Folder' => $sFolderName,
|
||||
|
@ -865,7 +836,6 @@ class MailClient
|
|||
|
||||
/**
|
||||
* @param string $sFolderName
|
||||
* @param \MailSo\Cache\CacheClient|null $oCacher = null
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
@ -873,13 +843,13 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Imap\Exceptions\Exception
|
||||
*/
|
||||
public function FolderHash($sFolderName, $oCacher = null)
|
||||
public function FolderHash($sFolderName)
|
||||
{
|
||||
$iCount = 0;
|
||||
$iUnseenCount = 0;
|
||||
$sUidNext = '0';
|
||||
|
||||
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $sUidNext, $oCacher);
|
||||
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $sUidNext);
|
||||
|
||||
return self::GenerateHash($sFolderName, $iCount, $iUnseenCount, $sUidNext);
|
||||
}
|
||||
|
@ -1327,10 +1297,6 @@ class MailClient
|
|||
}
|
||||
|
||||
$sCriteriasResult = \trim(\implode(' ', $aCriteriasResult));
|
||||
if (\MailSo\Config::$MessageListUndeletedFilter)
|
||||
{
|
||||
$sCriteriasResult .= ' UNDELETED';
|
||||
}
|
||||
|
||||
if (0 < $iTimeFilter)
|
||||
{
|
||||
|
@ -1420,11 +1386,6 @@ class MailClient
|
|||
public function MessageListThreadsMap($sFolderName, $sFolderHash, $oCacher)
|
||||
{
|
||||
$sSearchHash = '';
|
||||
if (\MailSo\Config::$MessageListUndeletedFilter)
|
||||
{
|
||||
$sSearchHash .= ' UNDELETED';
|
||||
}
|
||||
|
||||
if (0 < \MailSo\Config::$MessageListDateFilter)
|
||||
{
|
||||
$iD = \time() - 3600 * 24 * 30 * \MailSo\Config::$MessageListDateFilter;
|
||||
|
@ -1608,7 +1569,7 @@ class MailClient
|
|||
$aSerialized = @\unserialize($sSerialized);
|
||||
if (\is_array($aSerialized) && isset($aSerialized['FolderHash'], $aSerialized['Uids']) &&
|
||||
\is_array($aSerialized['Uids']) &&
|
||||
($sFolderHash === $aSerialized['FolderHash'] || false === $sFolderHash))
|
||||
($sFolderHash === $aSerialized['FolderHash']))
|
||||
{
|
||||
if ($this->oLogger)
|
||||
{
|
||||
|
@ -1762,7 +1723,7 @@ class MailClient
|
|||
$oCacher = null;
|
||||
}
|
||||
|
||||
$this->initFolderValues($sFolderName, $iMessageRealCount, $iMessageUnseenCount, $sUidNext, $oCacher);
|
||||
$this->initFolderValues($sFolderName, $iMessageRealCount, $iMessageUnseenCount, $sUidNext);
|
||||
$iMessageCount = $iMessageRealCount;
|
||||
|
||||
$oMessageCollection->FolderHash = self::GenerateHash($sFolderName, $iMessageRealCount, $iMessageUnseenCount, $sUidNext);
|
||||
|
@ -1860,8 +1821,7 @@ class MailClient
|
|||
|
||||
if (1 < $iMessageCount)
|
||||
{
|
||||
if ($bMessageListOptimization ||
|
||||
(!\MailSo\Config::$MessageListUndeletedFilter && 0 === \MailSo\Config::$MessageListDateFilter))
|
||||
if ($bMessageListOptimization || 0 === \MailSo\Config::$MessageListDateFilter)
|
||||
{
|
||||
$aIndexOrUids = \array_reverse(\range(1, $iMessageCount));
|
||||
}
|
||||
|
|
|
@ -172,6 +172,7 @@ abstract class NetClient
|
|||
* @param string $sServerName
|
||||
* @param int $iPort
|
||||
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
|
||||
* @param bool $bCapturePeerCertIfSsl = false
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
@ -180,7 +181,7 @@ abstract class NetClient
|
|||
* @throws \MailSo\Net\Exceptions\SocketCanNotConnectToHostException
|
||||
*/
|
||||
public function Connect($sServerName, $iPort,
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT)
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT, $bCapturePeerCertIfSsl = false)
|
||||
{
|
||||
if (!\MailSo\Base\Validator::NotEmptyString($sServerName, true) || !\MailSo\Base\Validator::PortInt($iPort))
|
||||
{
|
||||
|
@ -206,6 +207,8 @@ abstract class NetClient
|
|||
$this->bSecure = \MailSo\Net\Enumerations\ConnectionSecurityType::UseSSL($iPort, $iSecurityType);
|
||||
$this->sConnectedHost = $this->bSecure ? 'ssl://'.$sServerName : $sServerName;
|
||||
|
||||
$bCapturePeerCertIfSsl = !!($bCapturePeerCertIfSsl && $this->bSecure);
|
||||
|
||||
if (!$this->bSecure && \MailSo\Net\Enumerations\ConnectionSecurityType::SSL === $this->iSecurityType)
|
||||
{
|
||||
$this->writeLogException(
|
||||
|
@ -217,8 +220,24 @@ abstract class NetClient
|
|||
$this->writeLog('Start connection to "'.$this->sConnectedHost.':'.$this->iConnectedPort.'"',
|
||||
\MailSo\Log\Enumerations\Type::NOTE);
|
||||
|
||||
$this->rConnect = @\fsockopen($this->sConnectedHost, $this->iConnectedPort,
|
||||
$iErrorNo, $sErrorStr, $this->iConnectTimeOut);
|
||||
if ($bCapturePeerCertIfSsl && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_context_create') &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_socket_client') && defined('STREAM_CLIENT_CONNECT'))
|
||||
{
|
||||
$rStreamContext = \stream_context_create(array('ssl' => array('capture_peer_cert' => true)));
|
||||
$sRemoteSocket = (0 === \strpos($this->sConnectedHost, 'ssl://')
|
||||
? $this->sConnectedHost : 'tcp://'.$this->sConnectedHost).':'.$this->iConnectedPort;
|
||||
|
||||
if ($rStreamContext)
|
||||
{
|
||||
$this->rConnect = @\stream_socket_client($sRemoteSocket, $iErrorNo, $sErrorStr,
|
||||
$this->iConnectTimeOut, STREAM_CLIENT_CONNECT, $rStreamContext);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->rConnect = @\fsockopen($this->sConnectedHost, $this->iConnectedPort,
|
||||
$iErrorNo, $sErrorStr, $this->iConnectTimeOut);
|
||||
}
|
||||
|
||||
if (!\is_resource($this->rConnect))
|
||||
{
|
||||
|
@ -308,6 +327,15 @@ abstract class NetClient
|
|||
$this->IsConnected(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|bool
|
||||
*/
|
||||
public function StreamContextParams()
|
||||
{
|
||||
return \is_resource($this->rConnect) && \MailSo\Base\Utils::FunctionExistsAndEnabled('stream_context_get_options')
|
||||
? \stream_context_get_params($this->rConnect) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRaw
|
||||
* @param bool $bWriteToLog = true
|
||||
|
|
|
@ -973,12 +973,12 @@ class Actions
|
|||
'Plugins' => array()
|
||||
);
|
||||
|
||||
if ($aResult['UseRsaEncryption'] &&
|
||||
if ($aResult['UseRsaEncryption'] &&
|
||||
\file_exists(APP_PRIVATE_DATA.'rsa/public') && \file_exists(APP_PRIVATE_DATA.'rsa/private'))
|
||||
{
|
||||
$aResult['RsaPublicKey'] = \file_get_contents(APP_PRIVATE_DATA.'rsa/public');
|
||||
$aResult['RsaPublicKey'] = $aResult['RsaPublicKey'] ? $aResult['RsaPublicKey'] : '';
|
||||
|
||||
|
||||
if (false === \strpos($aResult['RsaPublicKey'], 'PUBLIC KEY'))
|
||||
{
|
||||
$aResult['RsaPublicKey'] = '';
|
||||
|
@ -1563,7 +1563,7 @@ class Actions
|
|||
$oLogger = $this->Logger();
|
||||
$oLogger->Write('Trying to decode encrypted data', \MailSo\Log\Enumerations\Type::INFO, 'RSA');
|
||||
|
||||
$sPrivateKey = file_exists(APP_PRIVATE_DATA.'rsa/private') ?
|
||||
$sPrivateKey = file_exists(APP_PRIVATE_DATA.'rsa/private') ?
|
||||
\file_get_contents(APP_PRIVATE_DATA.'rsa/private') : '';
|
||||
|
||||
if (!empty($sPrivateKey))
|
||||
|
@ -2737,13 +2737,27 @@ class Actions
|
|||
$oDomain = $this->DomainProvider()->LoadOrCreateNewFromAction($this, 'domain-test-connection.de');
|
||||
if ($oDomain)
|
||||
{
|
||||
// $oOpenSSL = \MailSo\Base\Utils::FunctionExistsAndEnabled('openssl_x509_parse');
|
||||
$oOpenSSL = false; // TODO in dev
|
||||
|
||||
try
|
||||
{
|
||||
$oImapClient = \MailSo\Imap\ImapClient::NewInstance()->SetLogger($this->Logger());
|
||||
$oImapClient->SetTimeOuts(5);
|
||||
|
||||
$iTime = \microtime(true);
|
||||
$oImapClient->Connect($oDomain->IncHost($oDomain->Name()), $oDomain->IncPort(), $oDomain->IncSecure());
|
||||
$oImapClient->Connect($oDomain->IncHost($oDomain->Name()), $oDomain->IncPort(), $oDomain->IncSecure(), $oOpenSSL);
|
||||
|
||||
if ($oOpenSSL)
|
||||
{
|
||||
$aStreamContextParams = $oImapClient->StreamContextParams();
|
||||
if (isset($aStreamContextParams['options']['ssl']['peer_certificate']))
|
||||
{
|
||||
$aParseData = @\openssl_x509_parse($aStreamContextParams['options']['ssl']['peer_certificate']);
|
||||
$this->Logger()->WriteDump($aParseData);
|
||||
}
|
||||
}
|
||||
|
||||
$iImapTime = \microtime(true) - $iTime;
|
||||
$oImapClient->Disconnect();
|
||||
$bImapResult = true;
|
||||
|
@ -3756,7 +3770,7 @@ class Actions
|
|||
'Send Mails' => \MailSo\Imap\Enumerations\FolderType::SENT,
|
||||
|
||||
'Drafts' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
|
||||
|
||||
|
||||
'Draft' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
|
||||
'Draft Mail' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
|
||||
'Draft Mails' => \MailSo\Imap\Enumerations\FolderType::DRAFTS,
|
||||
|
@ -3817,7 +3831,7 @@ class Actions
|
|||
$aResult[$iFolderListType] = $oFolder->FullNameRaw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($aFolders as $oFolder)
|
||||
{
|
||||
$oSub = $oFolder->SubFolders();
|
||||
|
@ -3833,7 +3847,7 @@ class Actions
|
|||
{
|
||||
$sName = $oFolder->Name();
|
||||
$sFullName = $oFolder->FullName();
|
||||
|
||||
|
||||
if (isset($aMap[$sName], $aMap[$sFullName]))
|
||||
{
|
||||
$iFolderType = isset($aMap[$sName]) ? $aMap[$sName] : $aMap[$sFullName];
|
||||
|
@ -3849,7 +3863,7 @@ class Actions
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($aFolders as $oFolder)
|
||||
{
|
||||
$oSub = $oFolder->SubFolders();
|
||||
|
@ -4151,8 +4165,9 @@ class Actions
|
|||
try
|
||||
{
|
||||
$aInboxInformation = $this->MailClient()->FolderInformation(
|
||||
$sFolder, $sPrevUidNext, $aFlagsFilteredUids, $this->cacherForUids()
|
||||
$sFolder, $sPrevUidNext, $aFlagsFilteredUids
|
||||
);
|
||||
|
||||
if (\is_array($aInboxInformation) && isset($aInboxInformation['Flags']) && \is_array($aInboxInformation['Flags']))
|
||||
{
|
||||
foreach ($aInboxInformation['Flags'] as $iUid => $aFlags)
|
||||
|
@ -4205,10 +4220,7 @@ class Actions
|
|||
{
|
||||
try
|
||||
{
|
||||
$aInboxInformation = $this->MailClient()->FolderInformation(
|
||||
$sFolder, '', array(), $this->cacherForUids()
|
||||
);
|
||||
|
||||
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder, '', array());
|
||||
if (\is_array($aInboxInformation) && isset($aInboxInformation['Folder']))
|
||||
{
|
||||
$aResult['List'][] = $aInboxInformation;
|
||||
|
@ -4245,7 +4257,7 @@ class Actions
|
|||
|
||||
$sRawKey = $this->GetActionParam('RawKey', '');
|
||||
$aValues = $this->getDecodedClientRawKeyValue($sRawKey, 9);
|
||||
|
||||
|
||||
if (is_array($aValues) && 9 === count($aValues))
|
||||
{
|
||||
$sFolder =(string) $aValues[0];
|
||||
|
@ -5650,9 +5662,10 @@ class Actions
|
|||
|
||||
try
|
||||
{
|
||||
$this->MailClient()->MessageDelete($sFolder, $aFilteredUids, true);
|
||||
|
||||
$sHash = $this->MailClient()->FolderHash($sFolder, $this->cacherForUids());
|
||||
$this->MailClient()->MessageDelete($sFolder, $aFilteredUids, true,
|
||||
!!$this->Config()->Get('labs', 'use_imap_expunge_all_on_delete', false));
|
||||
|
||||
$sHash = $this->MailClient()->FolderHash($sFolder);
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
|
@ -5682,10 +5695,12 @@ class Actions
|
|||
|
||||
try
|
||||
{
|
||||
$this->MailClient()->MessageMove($sFromFolder, $sToFolder,
|
||||
$aFilteredUids, true, $this->Config()->Get('labs', 'use_imap_move', true));
|
||||
$this->MailClient()->MessageMove($sFromFolder, $sToFolder, $aFilteredUids, true,
|
||||
!!$this->Config()->Get('labs', 'use_imap_move', true),
|
||||
!!$this->Config()->Get('labs', 'use_imap_expunge_all_on_delete', false)
|
||||
);
|
||||
|
||||
$sHash = $this->MailClient()->FolderHash($sFromFolder, $this->cacherForUids());
|
||||
$sHash = $this->MailClient()->FolderHash($sFromFolder);
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
|
@ -5719,7 +5734,7 @@ class Actions
|
|||
$this->MailClient()->MessageCopy($sFromFolder, $sToFolder,
|
||||
$aFilteredUids, true);
|
||||
|
||||
$sHash = $this->MailClient()->FolderHash($sFromFolder, $this->cacherForUids());
|
||||
$sHash = $this->MailClient()->FolderHash($sFromFolder);
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
|
@ -7225,7 +7240,7 @@ class Actions
|
|||
|
||||
return isset($aLang[$sKey]) ? $aLang[$sKey] : $sKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return MailSo\Cache\CacheClient|null
|
||||
*/
|
||||
|
|
|
@ -78,16 +78,13 @@ class Api
|
|||
|
||||
\MailSo\Config::$MessageListFastSimpleSearch =
|
||||
!!\RainLoop\Api::Config()->Get('labs', 'imap_message_list_fast_simple_search', true);
|
||||
|
||||
|
||||
\MailSo\Config::$MessageListCountLimitTrigger =
|
||||
(int) \RainLoop\Api::Config()->Get('labs', 'imap_message_list_count_limit_trigger', 0);
|
||||
|
||||
\MailSo\Config::$MessageListDateFilter =
|
||||
(int) \RainLoop\Api::Config()->Get('labs', 'imap_message_list_date_filter', 0);
|
||||
|
||||
\MailSo\Config::$MessageListUndeletedFilter =
|
||||
!!\RainLoop\Api::Config()->Get('labs', 'imap_message_list_hide_deleted_messages', false);
|
||||
|
||||
\MailSo\Config::$SystemLogger = \RainLoop\Api::Logger();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,11 +238,11 @@ Enables caching in the system'),
|
|||
'use_imap_thread' => array(true),
|
||||
'use_imap_move' => array(true),
|
||||
'use_imap_auth_plain' => array(false),
|
||||
'use_imap_expunge_all_on_delete' => array(false),
|
||||
'imap_forwarded_flag' => array('$Forwarded'),
|
||||
'imap_read_receipt_flag' => array('$ReadReceipt'),
|
||||
'imap_body_text_limit' => array(555000),
|
||||
'imap_message_list_fast_simple_search' => array(true),
|
||||
'imap_message_list_hide_deleted_messages' => array(false),
|
||||
'imap_message_list_count_limit_trigger' => array(0),
|
||||
'imap_message_list_date_filter' => array(0),
|
||||
'smtp_show_server_errors' => array(false),
|
||||
|
|
Loading…
Add table
Reference in a new issue