Small fixes

This commit is contained in:
RainLoop Team 2015-07-23 21:57:46 +04:00
parent fc10f20770
commit 3849fd02b4
9 changed files with 113 additions and 29 deletions

View file

@ -560,7 +560,7 @@ class Actions
public function SetAuthLogoutToken()
{
@\header('X-RainLoop-Action: Logout');
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5(APP_START_TIME), 0, '/', null, null, true);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5(APP_START_TIME), 0);
}
/**
@ -575,7 +575,7 @@ class Actions
$sSpecAuthToken = '_'.$oAccount->GetAuthTokenQ();
$this->SetSpecAuthToken($sSpecAuthToken);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken, 0, '/', null, null, true);
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken, 0);
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken()))
{
@ -584,7 +584,7 @@ class Actions
'e' => $oAccount->Email(),
't' => $oAccount->SignMeToken()
)),
\time() + 60 * 60 * 24 * 30, '/', null, null, true);
\time() + 60 * 60 * 24 * 30);
$this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
@ -632,7 +632,7 @@ class Actions
*/
private function setAdminAuthToken($sToken)
{
\RainLoop\Utils::SetCookie(self::AUTH_ADMIN_TOKEN_KEY, $sToken, 0, '/', null, null, true);
\RainLoop\Utils::SetCookie(self::AUTH_ADMIN_TOKEN_KEY, $sToken, 0);
}
/**
@ -1171,7 +1171,7 @@ class Actions
'Time' => \microtime(true),
'MailTo' => 'MailTo',
'To' => $sTo
)), 0, '/', null, null, true);
)), 0);
}
}
@ -1400,6 +1400,7 @@ class Actions
'MaterialDesign' => (bool) $oConfig->Get('labs', 'use_material_design', true),
'FolderSpecLimit' => (int) $oConfig->Get('labs', 'folders_spec_limit', 50),
'StartupUrl' => \trim(\ltrim(\trim($oConfig->Get('labs', 'startup_url', '')), '#/')),
'FaviconStatus' => (bool) $oConfig->Get('labs', 'favicon_status', true),
'Filtered' => '' !== \trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', '')),
'Community' => true,
'PremType' => false,
@ -2151,7 +2152,7 @@ class Actions
if ($bAdditionalCodeSignMe)
{
\RainLoop\Utils::SetCookie(self::AUTH_TFA_SIGN_ME_TOKEN_KEY, $sSecretHash,
\time() + 60 * 60 * 24 * 14, '/', null, null, true);
\time() + 60 * 60 * 24 * 14);
}
if (!$bGood && !$this->TwoFactorAuthProvider()->VerifyCode($aData['Secret'], $sAdditionalCode))
@ -8324,21 +8325,28 @@ class Actions
$bDone = false;
if ($bThumbnail && !$bDownload)
{
\MailSo\Base\StreamWrappers\TempFile::Reg();
$sFileName = '';
$rTempResource = \MailSo\Base\StreamWrappers\TempFile::CreateStream(
\MailSo\Base\Utils::Md5Rand($sFileNameOut), $sFileName);
$sFileName = 'mailsotempfile://'.\MailSo\Base\Utils::Md5Rand($sFileNameOut);
$rTempResource = @\fopen($sFileName, 'r+b');
if (@\is_resource($rTempResource))
{
$bDone = true;
\MailSo\Base\Utils::MultipleStreamWriter($rResource, array($rTempResource));
@\fclose($rTempResource);
$oThumb =@ new \PHPThumb\GD($sFileName);
if ($oThumb)
try
{
$oThumb->adaptiveResize(60, 60)->show();
$bDone = true;
$oThumb = new \PHPThumb\GD($sFileName);
if ($oThumb)
{
$oThumb->adaptiveResize(60, 60)->show();
}
}
catch (\Exception $oException)
{
$self->Logger()->WriteExceptionShort($oException);
}
}
}

View file

@ -108,6 +108,8 @@ class Api
$sSslCafile = \RainLoop\Api::Config()->Get('ssl', 'cafile', '');
$sSslCapath = \RainLoop\Api::Config()->Get('ssl', 'capath', '');
\RainLoop\Utils::$CookieDefaultPath = \RainLoop\Api::Config()->Get('labs', 'cookie_path', '/');
if (!empty($sSslCafile) || !empty($sSslCapath))
{
\MailSo\Hooks::Add('Net.NetClient.StreamContextSettings/Filter', function (&$aStreamContextSettings) use ($sSslCafile, $sSslCapath) {

View file

@ -329,8 +329,9 @@ Enables caching in the system'),
'smtp_show_server_errors' => array(false),
'sieve_allow_raw_script' => array(false),
'sieve_utf8_folder_name' => array(true),
'mail_func_clear_headers ' => array(true),
'mail_func_additional_parameters ' => array(false),
'mail_func_clear_headers' => array(true),
'mail_func_additional_parameters' => array(false),
'favicon_status' => array(true),
'folders_spec_limit' => array(50),
'owncloud_save_folder' => array('Attachments'),
'curl_proxy' => array(''),
@ -347,6 +348,7 @@ Enables caching in the system'),
'fast_cache_memcache_port' => array(11211),
'fast_cache_memcache_expire' => array(43200),
'use_local_proxy_for_external_images' => array(false),
'cookie_path' => array('/'),
'startup_url' => array(''),
'emogrifier' => array(true),
'dev_email' => array(''),

View file

@ -4,6 +4,11 @@ namespace RainLoop;
class Utils
{
/**
* @var string
*/
static $CookieDefaultPath = '/';
static $Cookies = null;
static $RSA = null;
@ -299,7 +304,7 @@ class Utils
if (null === $sToken)
{
$sToken = \MailSo\Base\Utils::Md5Rand(APP_SALT);
\RainLoop\Utils::SetCookie($sKey, $sToken, \time() + 60 * 60 * 24 * 30, '/', null, null, true);
\RainLoop\Utils::SetCookie($sKey, $sToken, \time() + 60 * 60 * 24 * 30);
}
return \md5('Connection'.APP_SALT.$sToken.'Token'.APP_SALT);
@ -324,7 +329,7 @@ class Utils
if (null === $sToken)
{
$sToken = \MailSo\Base\Utils::Md5Rand(APP_SALT);
\RainLoop\Utils::SetCookie($sKey, $sToken, 0, '/', null, null, true);
\RainLoop\Utils::SetCookie($sKey, $sToken, 0);
}
return \md5('Session'.APP_SALT.$sToken.'Token'.APP_SALT);
@ -340,7 +345,7 @@ class Utils
$sToken = \RainLoop\Utils::GetCookie($sKey, '');
if (!empty($sToken))
{
\RainLoop\Utils::SetCookie($sKey, $sToken, \time() + 60 * 60 * 24 * 30, '/', null, null, true);
\RainLoop\Utils::SetCookie($sKey, $sToken, \time() + 60 * 60 * 24 * 30);
}
}
@ -503,13 +508,18 @@ class Utils
return isset(\RainLoop\Utils::$Cookies[$sName]) ? \RainLoop\Utils::$Cookies[$sName] : $mDefault;
}
public static function SetCookie($sName, $sValue = '', $iExpire = 0, $sPath = '/', $sDomain = '', $sSecure = false, $bHttpOnly = false)
public static function SetCookie($sName, $sValue = '', $iExpire = 0, $sPath = null, $sDomain = null, $sSecure = null, $bHttpOnly = true)
{
if (null === \RainLoop\Utils::$Cookies)
{
\RainLoop\Utils::$Cookies = is_array($_COOKIE) ? $_COOKIE : array();
}
if (null === $sPath)
{
$sPath = \RainLoop\Utils::$CookieDefaultPath;
}
\RainLoop\Utils::$Cookies[$sName] = $sValue;
@\setcookie($sName, $sValue, $iExpire, $sPath, $sDomain, $sSecure, $bHttpOnly);
}
@ -522,7 +532,7 @@ class Utils
}
unset(\RainLoop\Utils::$Cookies[$sName]);
@\setcookie($sName, '', \time() - 3600 * 24 * 30, '/');
@\setcookie($sName, '', \time() - 3600 * 24 * 30);
}
/**