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

@ -1385,7 +1385,7 @@
{
PgpStore.openpgp.initWorker(Links.openPgpWorkerJs());
}
// PgpStore.openpgp.config.useWebCrypto = false;
PgpStore.openpgpKeyring = new openpgp.Keyring();
@ -1521,7 +1521,7 @@
self.initVerticalLayoutResizer(Enums.ClientSideKeyName.FolderListSize);
});
if (Tinycon && !Settings.settingsGet('Filtered'))
if (Tinycon && Settings.settingsGet('FaviconStatus') && !Settings.settingsGet('Filtered') )
{
Tinycon.setOptions({
fallback: false

View file

@ -43,14 +43,16 @@ class TempFile
/**
* @param string $sHash
* @param string $sFileName
*
* @return resource|bool
*/
public static function CreateStream($sHash)
public static function CreateStream($sHash, &$sFileName = '')
{
self::Reg();
return fopen(self::STREAM_NAME.'://'.$sHash, 'r+b');
$sFileName = self::STREAM_NAME.'://'.$sHash;
return fopen($sFileName, 'r+b');
}
/**
@ -72,6 +74,7 @@ class TempFile
is_resource(self::$aStreams[$sHashName]))
{
$this->rSream = self::$aStreams[$sHashName];
\fseek($this->rSream, 0);
$bResult = true;
}
else
@ -93,7 +96,7 @@ class TempFile
*/
public function stream_close()
{
return -1 !== fseek($this->rSream, 0);
return true;
}
/**

View file

@ -2448,6 +2448,38 @@ END;
return ('' === $sUser ? '' : $sUser.'@').$sDomain;
}
/**
* @param string $sHash
* @param string $sSalt
*
* @return int
*/
public static function HashToId($sHash, $sSalt = '')
{
$sData = $sHash ? @\MailSo\Base\Crypt::XxteaDecrypt(\hex2bin($sHash), \md5($sSalt)) : null;
$aMatch = array();
if ($sData && preg_match('/^id:(\d+)$/', $sData, $aMatch) && isset($aMatch[1]))
{
return is_numeric($aMatch[1]) ? (int) $aMatch[1] : null;
}
return null;
}
/**
* @param int $iID
* @param string $sSalt
*
* @return string
*/
public static function IdToHash($iID, $sSalt = '')
{
return is_int($iID) ?
\bin2hex(\MailSo\Base\Crypt::XxteaEncrypt('id:'.$iID, \md5($sSalt))) : null
;
}
/**
* @param string $sPassword
*

View file

@ -371,6 +371,33 @@ class Logger extends \MailSo\Base\Collection
return false;
}
/**
* @param \Exception $oException
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
* @param string $sName = ''
* @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
*
* @return bool
*/
public function WriteExceptionShort($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '',
$bSearchSecretWords = true, $bDiplayCrLf = false)
{
if ($oException instanceof \Exception)
{
if (isset($oException->__LOGINNED__))
{
return true;
}
$oException->__LOGINNED__ = true;
return $this->Write($oException->getMessage(), $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
}
return false;
}
/**
* @param mixed $mData
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE

View file

@ -1353,13 +1353,13 @@ class GD extends PHPThumb
switch ($this->format) {
case 'GIF':
$isCompatible = $gdInfo['GIF Create Support'];
$isCompatible = isset($gdInfo['GIF Create Support']);
break;
case 'JPG':
$isCompatible = (isset($gdInfo['JPG Support']) || isset($gdInfo['JPEG Support'])) ? true : false;
break;
case 'PNG':
$isCompatible = $gdInfo[$this->format . ' Support'];
$isCompatible = isset($gdInfo[$this->format . ' Support']);
break;
default:
$isCompatible = false;
@ -1367,7 +1367,7 @@ class GD extends PHPThumb
if (!$isCompatible) {
// one last check for "JPEG" instead
$isCompatible = $gdInfo['JPEG Support'];
$isCompatible = isset($gdInfo['JPEG Support']);
if (!$isCompatible) {
throw new \Exception("Your GD installation does not support {$this->format} image types");

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);
}
/**