mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +03:00
Weekly fixes
This commit is contained in:
parent
053fd1c60b
commit
f1b3271b4d
16 changed files with 210 additions and 93 deletions
|
|
@ -280,20 +280,37 @@ class Http
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $bCheckProxy = true
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetScheme()
|
||||
public function GetScheme($bCheckProxy = true)
|
||||
{
|
||||
$sHttps = \strtolower($this->GetServer('HTTPS', ''));
|
||||
return ('on' === $sHttps || ('' === $sHttps && '443' === (string) $this->GetServer('SERVER_PORT', ''))) ? 'https' : 'http';
|
||||
return $this->IsSecure($bCheckProxy) ? 'https' : 'http';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bCheckProxy = true
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsSecure()
|
||||
public function IsSecure($bCheckProxy = true)
|
||||
{
|
||||
return ('https' === $this->GetScheme());
|
||||
$sHttps = \strtolower($this->GetServer('HTTPS', ''));
|
||||
if ('on' === $sHttps || ('' === $sHttps && '443' === (string) $this->GetServer('SERVER_PORT', '')))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($bCheckProxy && (
|
||||
('https' === \strtolower($this->GetServer('HTTP_X_FORWARDED_PROTO', ''))) ||
|
||||
('on' === \strtolower($this->GetServer('HTTP_X_FORWARDED_SSL', '')))
|
||||
))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -308,12 +325,10 @@ class Http
|
|||
$sHost = $this->GetServer('HTTP_HOST', '');
|
||||
if (0 === \strlen($sHost))
|
||||
{
|
||||
$sScheme = $this->GetScheme();
|
||||
$sName = $this->GetServer('SERVER_NAME');
|
||||
$iPort = (int) $this->GetServer('SERVER_PORT');
|
||||
$iPort = (int) $this->GetServer('SERVER_PORT', 80);
|
||||
|
||||
$sHost = (('http' === $sScheme && 80 === $iPort) || ('https' === $sScheme && 443 === $iPort))
|
||||
? $sName : $sName.':'.$iPort;
|
||||
$sHost = (\in_array($iPort, array(80, 433))) ? $sName : $sName.':'.$iPort;
|
||||
}
|
||||
|
||||
if ($bWithoutWWW)
|
||||
|
|
|
|||
|
|
@ -191,4 +191,25 @@ class CacheClient
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bCache = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Verify($bCache = false)
|
||||
{
|
||||
if ($this->oDriver)
|
||||
{
|
||||
$sCacheData = \gmdate('Y-m-d-H');
|
||||
if ($bCache && $sCacheData === $this->Get('__verify_key__'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->Set('__verify_key__', $sCacheData);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,6 +617,9 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$aReturn = array();
|
||||
|
||||
$sDelimiter = '';
|
||||
$bInbox = false;
|
||||
|
||||
$oImapResponse = null;
|
||||
foreach ($aResult as /* @var $oImapResponse \MailSo\Imap\Response */ $oImapResponse)
|
||||
{
|
||||
|
|
@ -628,6 +631,16 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$oFolder = Folder::NewInstance($oImapResponse->ResponseList[4],
|
||||
$oImapResponse->ResponseList[3], $oImapResponse->ResponseList[2]);
|
||||
|
||||
if ($oFolder->IsInbox())
|
||||
{
|
||||
$bInbox = true;
|
||||
}
|
||||
|
||||
if (empty($sDelimiter))
|
||||
{
|
||||
$sDelimiter = $oFolder->Delimiter();
|
||||
}
|
||||
|
||||
$aReturn[] = $oFolder;
|
||||
}
|
||||
catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException)
|
||||
|
|
@ -637,6 +650,11 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
}
|
||||
|
||||
if (!$bInbox && !empty($sDelimiter))
|
||||
{
|
||||
$aReturn[] = Folder::NewInstance('INBOX', $sDelimiter);
|
||||
}
|
||||
|
||||
if ($bUseListStatus)
|
||||
{
|
||||
foreach ($aResult as /* @var $oImapResponse \MailSo\Imap\Response */ $oImapResponse)
|
||||
|
|
|
|||
|
|
@ -104,6 +104,27 @@ class FolderCollection extends \MailSo\Base\Collection
|
|||
return $this->sNamespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function FindDelimiter()
|
||||
{
|
||||
$sDelimiter = '/';
|
||||
|
||||
$oFolder = $this->GetByFullNameRaw('INBOX');
|
||||
if (!$oFolder)
|
||||
{
|
||||
$oFolder = $this->GetByIndex(0);
|
||||
}
|
||||
|
||||
if ($oFolder)
|
||||
{
|
||||
$sDelimiter = $oFolder->Delimiter();
|
||||
}
|
||||
|
||||
return $sDelimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sNamespace
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2038,10 +2038,10 @@ class MailClient
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function folerListOptimization($aMailFoldersHelper, $iOptimizationLimit = 0)
|
||||
public function folderListOptimization($aMailFoldersHelper, $iOptimizationLimit = 0)
|
||||
{
|
||||
// optimization
|
||||
if (10 < $iOptimizationLimit && $iOptimizationLimit < \count($aMailFoldersHelper))
|
||||
if (10 < $iOptimizationLimit && \is_array($aMailFoldersHelper) && $iOptimizationLimit < \count($aMailFoldersHelper))
|
||||
{
|
||||
if ($this->oLogger)
|
||||
{
|
||||
|
|
@ -2056,7 +2056,7 @@ class MailClient
|
|||
'drafts',
|
||||
'junk', 'spam',
|
||||
'trash', 'bin',
|
||||
'archive', 'allmail', 'all',
|
||||
'archives', 'archive', 'allmail', 'all',
|
||||
'starred', 'flagged', 'important',
|
||||
'contacts', 'chats'
|
||||
);
|
||||
|
|
@ -2064,10 +2064,21 @@ class MailClient
|
|||
$aNewMailFoldersHelper = array();
|
||||
|
||||
$iCountLimit = $iForeachLimit;
|
||||
|
||||
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder \MailSo\Mail\Folder */ $oFolder)
|
||||
{
|
||||
// normal and subscribed only
|
||||
if ($oFolder && ($oFolder->IsSubscribed() || \in_array(\strtolower($oFolder->NameRaw()), $aFilteredNames)))
|
||||
// mandatory folders
|
||||
if ($oFolder && \in_array(\strtolower($oFolder->NameRaw()), $aFilteredNames))
|
||||
{
|
||||
$aNewMailFoldersHelper[] = $oFolder;
|
||||
$aMailFoldersHelper[$iIndex] = null;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($aMailFoldersHelper as $iIndex => /* @var $oImapFolder \MailSo\Mail\Folder */ $oFolder)
|
||||
{
|
||||
// subscribed folders
|
||||
if ($oFolder && $oFolder->IsSubscribed())
|
||||
{
|
||||
$aNewMailFoldersHelper[] = $oFolder;
|
||||
|
||||
|
|
@ -2205,7 +2216,7 @@ class MailClient
|
|||
}
|
||||
|
||||
$iCount = \count($aMailFoldersHelper);
|
||||
$aMailFoldersHelper = $this->folerListOptimization($aMailFoldersHelper, $iOptimizationLimit);
|
||||
$aMailFoldersHelper = $this->folderListOptimization($aMailFoldersHelper, $iOptimizationLimit);
|
||||
|
||||
$bOptimized = $iCount !== \count($aMailFoldersHelper);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3371,7 +3371,7 @@ class Actions
|
|||
$oCacher = $this->Cacher(null, true);
|
||||
$oHttp = \MailSo\Base\Http::SingletonInstance();
|
||||
|
||||
if (0 === \strlen($sDomain) || $oHttp->CheckLocalhost($sDomain) || !$oCacher)
|
||||
if (0 === \strlen($sDomain) || $oHttp->CheckLocalhost($sDomain) || !$oCacher || !$oCacher->Verify(true))
|
||||
{
|
||||
return 'NO';
|
||||
}
|
||||
|
|
@ -5028,8 +5028,7 @@ class Actions
|
|||
$sNamespace = $oFolderCollection->GetNamespace();
|
||||
$sParent = empty($sNamespace) ? '' : \substr($sNamespace, 0, -1);
|
||||
|
||||
$oInboxFolder = $oFolderCollection->GetByFullNameRaw('INBOX');
|
||||
$sDelimiter = $oInboxFolder ? $oInboxFolder->Delimiter() : '/';
|
||||
$sDelimiter = $oFolderCollection->FindDelimiter();
|
||||
|
||||
$aList = array();
|
||||
$aMap = $this->systemFoldersNames($oAccount);
|
||||
|
|
@ -5108,7 +5107,8 @@ class Actions
|
|||
if ($bDoItAgain)
|
||||
{
|
||||
$oFolderCollection = $this->MailClient()->Folders('', '*',
|
||||
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)
|
||||
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true),
|
||||
(int) $this->Config()->Get('labs', 'imap_folder_list_limit', 200)
|
||||
);
|
||||
|
||||
if ($oFolderCollection)
|
||||
|
|
@ -5950,9 +5950,7 @@ class Actions
|
|||
{
|
||||
$this->smtpSendMessage($oAccount, $oMessage, $rMessageStream, $iMessageStreamSize, $bDsn, true);
|
||||
|
||||
$this->deleteMessageAttachmnets($oAccount);
|
||||
|
||||
if (is_array($aDraftInfo) && 3 === count($aDraftInfo))
|
||||
if (\is_array($aDraftInfo) && 3 === \count($aDraftInfo))
|
||||
{
|
||||
$sDraftInfoType = $aDraftInfo[0];
|
||||
$sDraftInfoUid = $aDraftInfo[1];
|
||||
|
|
@ -6035,7 +6033,9 @@ class Actions
|
|||
@\fclose($rMessageStream);
|
||||
}
|
||||
|
||||
if (0 < strlen($sDraftFolder) && 0 < strlen($sDraftUid))
|
||||
$this->deleteMessageAttachmnets($oAccount);
|
||||
|
||||
if (0 < \strlen($sDraftFolder) && 0 < \strlen($sDraftUid))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class Social
|
|||
|
||||
$oSettings->SetConf('TwitterAccessToken', '');
|
||||
$oSettings->SetConf('TwitterSocialName', '');
|
||||
|
||||
|
||||
return $this->oActions->SettingsProvider()->Save($oAccount, $oSettings);
|
||||
}
|
||||
|
||||
|
|
@ -275,6 +275,7 @@ class Social
|
|||
{
|
||||
$sResult = '';
|
||||
$sLoginUrl = '';
|
||||
$oAccount = null;
|
||||
|
||||
$bLogin = false;
|
||||
$iErrorCode = \RainLoop\Notifications::UnknownError;
|
||||
|
|
@ -347,13 +348,7 @@ class Social
|
|||
if ($aUserData && \is_array($aUserData) &&
|
||||
!empty($aUserData['Email']) && isset($aUserData['Password']))
|
||||
{
|
||||
$oAccount = $this->oActions->LoginProcess($aUserData['Email'], $aUserData['Password']);
|
||||
if ($oAccount instanceof \RainLoop\Model\Account)
|
||||
{
|
||||
$this->oActions->AuthToken($oAccount);
|
||||
|
||||
$iErrorCode = 0;
|
||||
}
|
||||
$iErrorCode = $this->loginProcess($oAccount, $aUserData['Email'], $aUserData['Password']);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -421,6 +416,7 @@ class Social
|
|||
$mData = false;
|
||||
$sUserData = '';
|
||||
$aUserData = false;
|
||||
$oAccount = null;
|
||||
|
||||
$bLogin = false;
|
||||
$iErrorCode = \RainLoop\Notifications::UnknownError;
|
||||
|
|
@ -494,13 +490,7 @@ class Social
|
|||
if ($aUserData && \is_array($aUserData) &&
|
||||
!empty($aUserData['Email']) && isset($aUserData['Password']))
|
||||
{
|
||||
$oAccount = $this->oActions->LoginProcess($aUserData['Email'], $aUserData['Password']);
|
||||
if ($oAccount instanceof \RainLoop\Model\Account)
|
||||
{
|
||||
$this->oActions->AuthToken($oAccount);
|
||||
|
||||
$iErrorCode = 0;
|
||||
}
|
||||
$iErrorCode = $this->loginProcess($oAccount, $aUserData['Email'], $aUserData['Password']);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -543,6 +533,7 @@ class Social
|
|||
$sLoginUrl = '';
|
||||
|
||||
$sSocialName = '';
|
||||
$oAccount = null;
|
||||
|
||||
$bLogin = false;
|
||||
$iErrorCode = \RainLoop\Notifications::UnknownError;
|
||||
|
|
@ -670,13 +661,7 @@ class Social
|
|||
!empty($aUserData['Email']) &&
|
||||
isset($aUserData['Password']))
|
||||
{
|
||||
$oAccount = $this->oActions->LoginProcess($aUserData['Email'], $aUserData['Password']);
|
||||
if ($oAccount instanceof \RainLoop\Model\Account)
|
||||
{
|
||||
$this->oActions->AuthToken($oAccount);
|
||||
|
||||
$iErrorCode = 0;
|
||||
}
|
||||
$iErrorCode = $this->loginProcess($oAccount, $aUserData['Email'], $aUserData['Password']);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -876,4 +861,42 @@ class Social
|
|||
{
|
||||
return \implode('_', array('twitter', \md5($oTwitter->config['consumer_secret']), $sTwitterUserId, APP_SALT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|null $oAccount
|
||||
* @param string $sEmail
|
||||
* @param string $sPassword
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function loginProcess(&$oAccount, $sEmail, $sPassword)
|
||||
{
|
||||
$iErrorCode = \RainLoop\Notifications::UnknownError;
|
||||
|
||||
try
|
||||
{
|
||||
$oAccount = $this->oActions->LoginProcess($sEmail, $sPassword);
|
||||
if ($oAccount instanceof \RainLoop\Model\Account)
|
||||
{
|
||||
$this->oActions->AuthToken($oAccount);
|
||||
$iErrorCode = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$oAccount = null;
|
||||
$iErrorCode = \RainLoop\Notifications::AuthError;
|
||||
}
|
||||
}
|
||||
catch (\RainLoop\Exceptions\ClientException $oException)
|
||||
{
|
||||
$iErrorCode = $oException->getCode();
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
unset($oException);
|
||||
$iErrorCode = \RainLoop\Notifications::UnknownError;
|
||||
}
|
||||
|
||||
return $iErrorCode;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue