mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
Release commit
This commit is contained in:
parent
86f855fa5b
commit
b01f298b7b
13 changed files with 121 additions and 42 deletions
|
|
@ -617,6 +617,15 @@ class Actions
|
|||
*/
|
||||
public function ClearAdminAuthToken()
|
||||
{
|
||||
$aAdminHash = \RainLoop\Utils::DecodeKeyValues($this->getAdminAuthToken());
|
||||
if (
|
||||
!empty($aAdminHash[0]) && !empty($aAdminHash[1]) && !empty($aAdminHash[2]) &&
|
||||
'token' === $aAdminHash[0] && \md5(APP_SALT) === $aAdminHash[1]
|
||||
)
|
||||
{
|
||||
$this->Cacher()->Delete(\RainLoop\KeyPathHelper::SessionAdminKey($aAdminHash[2]));
|
||||
}
|
||||
|
||||
\RainLoop\Utils::ClearCookie(self::AUTH_ADMIN_TOKEN_KEY);
|
||||
}
|
||||
|
||||
|
|
@ -997,11 +1006,17 @@ class Actions
|
|||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string
|
||||
*/
|
||||
private function getAdminToken()
|
||||
{
|
||||
return \RainLoop\Utils::EncodeKeyValues(array('token', \md5(APP_SALT)));
|
||||
$sRand = \MailSo\Base\Utils::Md5Rand();
|
||||
if (!$this->Cacher()->Set(\RainLoop\KeyPathHelper::SessionAdminKey($sRand), \time()))
|
||||
{
|
||||
$sRand = '';
|
||||
}
|
||||
|
||||
return '' === $sRand ? '' : \RainLoop\Utils::EncodeKeyValues(array('token', \md5(APP_SALT), $sRand));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1015,8 +1030,10 @@ class Actions
|
|||
if ($this->Config()->Get('security', 'allow_admin_panel', true))
|
||||
{
|
||||
$aAdminHash = \RainLoop\Utils::DecodeKeyValues($this->getAdminAuthToken());
|
||||
if ((!empty($aAdminHash[0]) && !empty($aAdminHash[1]) &&
|
||||
'token' === $aAdminHash[0] && \md5(APP_SALT) === $aAdminHash[1]))
|
||||
if (!empty($aAdminHash[0]) && !empty($aAdminHash[1]) && !empty($aAdminHash[2]) &&
|
||||
'token' === $aAdminHash[0] && \md5(APP_SALT) === $aAdminHash[1] &&
|
||||
'' !== $this->Cacher()->Get(\RainLoop\KeyPathHelper::SessionAdminKey($aAdminHash[2]), '')
|
||||
)
|
||||
{
|
||||
$bResult = true;
|
||||
}
|
||||
|
|
@ -1119,7 +1136,7 @@ class Actions
|
|||
if (!empty($aAccountHash[8]) && !empty($aAccountHash[9])) // init proxy user/password
|
||||
{
|
||||
$oAccount->SetProxyAuthUser($aAccountHash[8]);
|
||||
$oAccount->SetProxyAuthUser($aAccountHash[89]);
|
||||
$oAccount->SetProxyAuthPassword($aAccountHash[9]);
|
||||
}
|
||||
|
||||
$this->Logger()->AddSecret($oAccount->Password());
|
||||
|
|
@ -2895,14 +2912,17 @@ class Actions
|
|||
public function DoLogout()
|
||||
{
|
||||
$oAccount = $this->getAccountFromToken(false);
|
||||
if ($oAccount && $oAccount->SignMe())
|
||||
if ($oAccount)
|
||||
{
|
||||
$this->ClearSignMeData($oAccount);
|
||||
}
|
||||
if ($oAccount->SignMe())
|
||||
{
|
||||
$this->ClearSignMeData($oAccount);
|
||||
}
|
||||
|
||||
if ($oAccount && '' === $oAccount->ParentEmail())
|
||||
{
|
||||
\RainLoop\Utils::ClearCookie(\RainLoop\Actions::AUTH_SPEC_TOKEN_KEY);
|
||||
if (!$oAccount->IsAdditionalAccount())
|
||||
{
|
||||
\RainLoop\Utils::ClearCookie(\RainLoop\Actions::AUTH_SPEC_TOKEN_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->TrueResponse(__FUNCTION__);
|
||||
|
|
|
|||
|
|
@ -130,4 +130,14 @@ class KeyPathHelper
|
|||
{
|
||||
return '/CssCache/'.$sHash.'/'.$sTheme.'/'.APP_VERSION.'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRand
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function SessionAdminKey($sRand)
|
||||
{
|
||||
return '/Session/AdminKey/'.\md5($sRand).'/';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -522,13 +522,13 @@ class Domain
|
|||
if (0 < strlen($sW))
|
||||
{
|
||||
$sEmail = \MailSo\Base\Utils::IdnToUtf8($sEmail, true);
|
||||
$sLogin = \MailSo\Base\Utils::IdnToUtf8($sLogin);
|
||||
$sLogin = \MailSo\Base\Utils::IdnToUtf8($sLogin, true);
|
||||
|
||||
$sW = \preg_replace('/([^\s]+)@[^\s]*/', '$1', $sW);
|
||||
$sW = ' '.\trim(\preg_replace('/[\s;,\r\n\t]+/', ' ', $sW)).' ';
|
||||
|
||||
$sUserPart = \MailSo\Base\Utils::GetAccountNameFromEmail(0 < \strlen($sLogin) ? $sLogin : $sEmail);
|
||||
return false !== \strpos($sW, ' '.$sUserPart.' ');
|
||||
return false !== \stripos($sW, ' '.$sUserPart.' ');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -23,46 +23,50 @@ class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\ISuggestion
|
|||
try
|
||||
{
|
||||
if (!$oAccount || !\RainLoop\Utils::IsOwnCloud() ||
|
||||
!\class_exists('\\OCP\\Contacts') || !\OCP\Contacts::isEnabled())
|
||||
!\class_exists('\\OCP\\Contacts') || !\OCP\Contacts::isEnabled() ||
|
||||
!\class_exists('\\OCP\\User') || !\OCP\User::isLoggedIn()
|
||||
)
|
||||
{
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
$aSearchResult = \OCP\Contacts::search($sQuery, array('FN', 'EMAIL'));
|
||||
|
||||
foreach ($aSearchResult as $aContact)
|
||||
if (\is_array($aSearchResult) && 0 < \count($aSearchResult))
|
||||
{
|
||||
if (0 >= $iLimit)
|
||||
foreach ($aSearchResult as $aContact)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$sUid = empty($aContact['UID']) ? '' : $aContact['UID'];
|
||||
if (!empty($sUid))
|
||||
{
|
||||
$sFullName = isset($aContact['FN']) ? \trim($aContact['FN']) : '';
|
||||
$mEmails = isset($aContact['EMAIL']) ? $aContact['EMAIL'] : '';
|
||||
|
||||
if (!\is_array($mEmails))
|
||||
if (0 >= $iLimit)
|
||||
{
|
||||
$mEmails = array($mEmails);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($mEmails as $sEmail)
|
||||
$sUid = empty($aContact['UID']) ? '' : $aContact['UID'];
|
||||
if (!empty($sUid))
|
||||
{
|
||||
$sEmail = \trim($sEmail);
|
||||
if (!empty($sEmail))
|
||||
$sFullName = isset($aContact['FN']) ? \trim($aContact['FN']) : '';
|
||||
$mEmails = isset($aContact['EMAIL']) ? $aContact['EMAIL'] : '';
|
||||
|
||||
if (!\is_array($mEmails))
|
||||
{
|
||||
$iLimit--;
|
||||
$aResult[$sUid] = array($sEmail, $sFullName);
|
||||
$mEmails = array($mEmails);
|
||||
}
|
||||
|
||||
foreach ($mEmails as $sEmail)
|
||||
{
|
||||
$sEmail = \trim($sEmail);
|
||||
if (!empty($sEmail))
|
||||
{
|
||||
$iLimit--;
|
||||
$aResult[$sUid] = array($sEmail, $sFullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aResult = \array_values($aResult);
|
||||
}
|
||||
|
||||
unset($aSearchResult);
|
||||
|
||||
$aResult = \array_values($aResult);
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1121,7 +1121,7 @@ class ServiceActions
|
|||
private function localError($sTitle, $sDesc)
|
||||
{
|
||||
@header('Content-Type: text/html; charset=utf-8');
|
||||
return $this->oActions->ErrorTemplates($sTitle, \nl2br($sDesc));
|
||||
return $this->ErrorTemplates($sTitle, \nl2br($sDesc));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue