Fix attachment preview

This commit is contained in:
RainLoop Team 2016-03-01 22:51:37 +03:00
parent 1d8652ddc4
commit 8f1186c255
2 changed files with 54 additions and 43 deletions

View file

@ -8533,14 +8533,16 @@ class Actions
$self->cacheByKey($sRawKey); $self->cacheByKey($sRawKey);
$bDone = false; $sLoadedData = null;
if ($bThumbnail && !$bDownload) $bDetectImageOrientation = false;
if (!$bDownload)
{
if ($bThumbnail)
{ {
try try
{ {
$oImagine = new \Imagine\Gd\Imagine(); $oImagine = new \Imagine\Gd\Imagine();
$bDone = true;
$oImage = $oImagine->load(\stream_get_contents($rResource)); $oImage = $oImagine->load(\stream_get_contents($rResource));
$oImage = $this->correctImageOrientation($oImage, $bDetectImageOrientation, 60); $oImage = $this->correctImageOrientation($oImage, $bDetectImageOrientation, 60);
@ -8555,8 +8557,7 @@ class Actions
$self->Logger()->WriteExceptionShort($oException); $self->Logger()->WriteExceptionShort($oException);
} }
} }
else if ($bDetectImageOrientation &&
if (!$bDone && !$bDownload && $bDetectImageOrientation &&
\in_array($sContentTypeOut, array('image/png', 'image/jpeg', 'image/jpg')) && \in_array($sContentTypeOut, array('image/png', 'image/jpeg', 'image/jpg')) &&
\MailSo\Base\Utils::FunctionExistsAndEnabled('gd_info')) \MailSo\Base\Utils::FunctionExistsAndEnabled('gd_info'))
{ {
@ -8564,8 +8565,9 @@ class Actions
{ {
$oImagine = new \Imagine\Gd\Imagine(); $oImagine = new \Imagine\Gd\Imagine();
$bDone = true; $sLoadedData = \stream_get_contents($rResource);
$oImage = $oImagine->load(\stream_get_contents($rResource));
$oImage = $oImagine->load($sLoadedData);
$oImage = $this->correctImageOrientation($oImage, $bDetectImageOrientation); $oImage = $this->correctImageOrientation($oImage, $bDetectImageOrientation);
@ -8579,8 +8581,13 @@ class Actions
$self->Logger()->WriteExceptionShort($oException); $self->Logger()->WriteExceptionShort($oException);
} }
} }
else
{
$sLoadedData = \stream_get_contents($rResource);
}
}
if (!$bDone) if ($bDownload || $sLoadedData)
{ {
\header('Content-Type: '.$sContentTypeOut); \header('Content-Type: '.$sContentTypeOut);
\header('Content-Disposition: '.($bDownload ? 'attachment' : 'inline').'; '. \header('Content-Disposition: '.($bDownload ? 'attachment' : 'inline').'; '.
@ -8589,9 +8596,17 @@ class Actions
\header('Accept-Ranges: none', true); \header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary'); \header('Content-Transfer-Encoding: binary');
if (!$bDownload && $sLoadedData)
{
echo $sLoadedData;
unset($sLoadedData);
}
else
{
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource); \MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
} }
} }
}
}, $sFolder, $iUid, true, $sMimeIndex); }, $sFolder, $iUid, true, $sMimeIndex);
} }

View file

@ -11,16 +11,12 @@
@ini_set('magic_quotes_gpc', 0); @ini_set('magic_quotes_gpc', 0);
@ini_set('magic_quotes_runtime', 0); @ini_set('magic_quotes_runtime', 0);
define('APP_DEFAULT_DENY_ALL_HTACCESS', 'Deny from all
<IfModule mod_autoindex.c>
Options -Indexes
</ifModule>');
define('APP_START_TIME', time()); define('APP_START_TIME', time());
define('APP_REQUEST_RND', md5(APP_START.rand(10000, 99999).APP_START)); define('APP_REQUEST_RND', md5(APP_START.rand(10000, 99999).APP_START));
define('APP_VERSION_ROOT_PATH', APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/'); define('APP_VERSION_ROOT_PATH', APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/');
define('APP_USE_APC_CACHE', true); define('APP_USE_APC_CACHE', true);
define('APP_DEFAULT_DENY_ALL_HTACCESS', "Deny from all\n<IfModule mod_autoindex.c>\nOptions -Indexes\n</ifModule>");
if (function_exists('date_default_timezone_set')) if (function_exists('date_default_timezone_set'))
{ {