mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue