mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-05 06:22:52 +08:00
Fix attachment preview
This commit is contained in:
parent
1d8652ddc4
commit
8f1186c255
2 changed files with 54 additions and 43 deletions
|
@ -8533,54 +8533,61 @@ class Actions
|
|||
|
||||
$self->cacheByKey($sRawKey);
|
||||
|
||||
$bDone = false;
|
||||
if ($bThumbnail && !$bDownload)
|
||||
$sLoadedData = null;
|
||||
$bDetectImageOrientation = false;
|
||||
if (!$bDownload)
|
||||
{
|
||||
try
|
||||
if ($bThumbnail)
|
||||
{
|
||||
$oImagine = new \Imagine\Gd\Imagine();
|
||||
try
|
||||
{
|
||||
$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);
|
||||
|
||||
\header('Content-Disposition: inline; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut.'_thumb60x60.png')), true);
|
||||
\header('Content-Disposition: inline; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut.'_thumb60x60.png')), true);
|
||||
|
||||
$oImage->show('png');
|
||||
$oImage->show('png');
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
$self->Logger()->WriteExceptionShort($oException);
|
||||
}
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
else if ($bDetectImageOrientation &&
|
||||
\in_array($sContentTypeOut, array('image/png', 'image/jpeg', 'image/jpg')) &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('gd_info'))
|
||||
{
|
||||
$self->Logger()->WriteExceptionShort($oException);
|
||||
try
|
||||
{
|
||||
$oImagine = new \Imagine\Gd\Imagine();
|
||||
|
||||
$sLoadedData = \stream_get_contents($rResource);
|
||||
|
||||
$oImage = $oImagine->load($sLoadedData);
|
||||
|
||||
$oImage = $this->correctImageOrientation($oImage, $bDetectImageOrientation);
|
||||
|
||||
\header('Content-Disposition: inline; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
|
||||
|
||||
$oImage->show($sContentTypeOut === 'image/png' ? 'png' : 'jpg');
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
$self->Logger()->WriteExceptionShort($oException);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sLoadedData = \stream_get_contents($rResource);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bDone && !$bDownload && $bDetectImageOrientation &&
|
||||
\in_array($sContentTypeOut, array('image/png', 'image/jpeg', 'image/jpg')) &&
|
||||
\MailSo\Base\Utils::FunctionExistsAndEnabled('gd_info'))
|
||||
{
|
||||
try
|
||||
{
|
||||
$oImagine = new \Imagine\Gd\Imagine();
|
||||
|
||||
$bDone = true;
|
||||
$oImage = $oImagine->load(\stream_get_contents($rResource));
|
||||
|
||||
$oImage = $this->correctImageOrientation($oImage, $bDetectImageOrientation);
|
||||
|
||||
\header('Content-Disposition: inline; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
|
||||
|
||||
$oImage->show($sContentTypeOut === 'image/png' ? 'png' : 'jpg');
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
$self->Logger()->WriteExceptionShort($oException);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bDone)
|
||||
if ($bDownload || $sLoadedData)
|
||||
{
|
||||
\header('Content-Type: '.$sContentTypeOut);
|
||||
\header('Content-Disposition: '.($bDownload ? 'attachment' : 'inline').'; '.
|
||||
|
@ -8589,7 +8596,15 @@ class Actions
|
|||
\header('Accept-Ranges: none', true);
|
||||
\header('Content-Transfer-Encoding: binary');
|
||||
|
||||
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
|
||||
if (!$bDownload && $sLoadedData)
|
||||
{
|
||||
echo $sLoadedData;
|
||||
unset($sLoadedData);
|
||||
}
|
||||
else
|
||||
{
|
||||
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, $sFolder, $iUid, true, $sMimeIndex);
|
||||
|
|
|
@ -11,16 +11,12 @@
|
|||
@ini_set('magic_quotes_gpc', 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_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_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'))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue