本文整理匯總了PHP中MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::EncodeHeaderUtf8AttributeValue方法的具體用法?PHP Utils::EncodeHeaderUtf8AttributeValue怎麽用?PHP Utils::EncodeHeaderUtf8AttributeValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::EncodeHeaderUtf8AttributeValue方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: RawOutputHeaders
/**
* @param bool $bDownload
* @param string $sContentType
* @param string $sFileName
*
* @return bool
*/
public function RawOutputHeaders($bDownload, $sContentType, $sFileName)
{
if ($bDownload) {
header('Content-Type: ' . $sContentType, true);
} else {
$aParts = explode('/', $sContentType, 2);
if (in_array(strtolower($aParts[0]), array('image', 'video', 'audio')) || in_array(strtolower($sContentType), array('application/pdf', 'application/x-pdf', 'text/html'))) {
header('Content-Type: ' . $sContentType, true);
} else {
header('Content-Type: text/plain', true);
}
}
header('Content-Disposition: ' . ($bDownload ? 'attachment' : 'inline') . '; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileName)), true);
header('Accept-Ranges: none', true);
header('Content-Transfer-Encoding: binary');
}
示例2: rawSmart
/**
* @param bool $bDownload
* @param bool $bThumbnail = false
*
* @return bool
*/
private function rawSmart($bDownload, $bThumbnail = false)
{
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$aValues = $this->getDecodedRawKeyValue($sRawKey);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
$sMimeIndex = isset($aValues['MimeIndex']) ? (string) $aValues['MimeIndex'] : '';
$sContentTypeIn = isset($aValues['MimeType']) ? (string) $aValues['MimeType'] : '';
$sFileNameIn = isset($aValues['FileName']) ? (string) $aValues['FileName'] : '';
$sFileHashIn = isset($aValues['FileHash']) ? (string) $aValues['FileHash'] : '';
$bDetectImageOrientation = !!$this->Config()->Get('labs', 'detect_image_exif_orientation', true);
if (!empty($sFileHashIn)) {
$this->verifyCacheByKey($sRawKey);
$oAccount = $this->getAccountFromToken();
$sContentTypeOut = empty($sContentTypeIn) ? \MailSo\Base\Utils::MimeContentType($sFileNameIn) : $sContentTypeIn;
$sFileNameOut = $this->MainClearFileName($sFileNameIn, $sContentTypeIn, $sMimeIndex);
$rResource = $this->FilesProvider()->GetFile($oAccount, $sFileHashIn);
if (\is_resource($rResource)) {
$sFileNameOut = \MailSo\Base\Utils::ConvertEncoding($sFileNameOut, \MailSo\Base\Enumerations\Charset::UTF_8, \MailSo\Base\Enumerations\Charset::CP858);
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: attachment; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
return true;
}
return false;
} else {
if (!empty($sFolder) && 0 < $iUid) {
$this->verifyCacheByKey($sRawKey);
}
}
$oAccount = $this->initMailClientConnection();
$self = $this;
return $this->MailClient()->MessageMimeStream(function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($self, $oAccount, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload, $bThumbnail, $bDetectImageOrientation) {
if ($oAccount && \is_resource($rResource)) {
$sContentTypeOut = $sContentTypeIn;
if (empty($sContentTypeOut)) {
$sContentTypeOut = $sContentType;
if (empty($sContentTypeOut)) {
$sContentTypeOut = empty($sFileName) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
}
}
$sFileNameOut = $sFileNameIn;
if (empty($sFileNameOut)) {
$sFileNameOut = $sFileName;
}
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
$self->cacheByKey($sRawKey);
$bDone = false;
if ($bThumbnail && !$bDownload) {
try {
$oImagine = new \Imagine\Gd\Imagine();
$bDone = true;
$oImage = $oImagine->load(\stream_get_contents($rResource));
$oImage = $this->correctImageOrientation($oImage, $bDetectImageOrientation, 60);
\header('Content-Disposition: inline; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut . '_thumb60x60.png')), true);
$oImage->show('png');
} catch (\Exception $oException) {
$self->Logger()->WriteExceptionShort($oException);
}
}
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) {
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: ' . ($bDownload ? 'attachment' : 'inline') . '; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
}
}
}, $sFolder, $iUid, true, $sMimeIndex);
}
示例3: rawSmart
/**
* @param bool $bDownload
* @param bool $bThumbnail = false
*
* @return bool
*/
private function rawSmart($bDownload, $bThumbnail = false)
{
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$aValues = $this->getDecodedRawKeyValue($sRawKey);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = (int) isset($aValues['Uid']) ? $aValues['Uid'] : 0;
$sMimeIndex = (string) isset($aValues['MimeIndex']) ? $aValues['MimeIndex'] : '';
$sContentTypeIn = (string) isset($aValues['MimeType']) ? $aValues['MimeType'] : '';
$sFileNameIn = (string) isset($aValues['FileName']) ? $aValues['FileName'] : '';
if (!empty($sFolder) && 0 < $iUid) {
$this->verifyCacheByKey($sRawKey);
}
$oAccount = $this->initMailClientConnection();
$self = $this;
return $this->MailClient()->MessageMimeStream(function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($self, $oAccount, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload, $bThumbnail) {
if ($oAccount && \is_resource($rResource)) {
$sContentTypeOut = $sContentTypeIn;
if (empty($sContentTypeOut)) {
$sContentTypeOut = $sContentType;
if (empty($sContentTypeOut)) {
$sContentTypeOut = empty($sFileName) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
}
}
$sFileNameOut = $sFileNameIn;
if (empty($sFileNameOut)) {
$sFileNameOut = $sFileName;
}
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
$self->cacheByKey($sRawKey);
$bDone = false;
if ($bThumbnail && !$bDownload) {
\MailSo\Base\StreamWrappers\TempFile::Reg();
$sFileName = 'mailsotempfile://' . \MailSo\Base\Utils::Md5Rand($sFileNameOut);
$rTempResource = @\fopen($sFileName, 'r+b');
if (@\is_resource($rTempResource)) {
\MailSo\Base\Utils::MultipleStreamWriter($rResource, array($rTempResource));
@\fclose($rTempResource);
$oThumb = @new \PHPThumb\GD($sFileName);
if ($oThumb) {
$oThumb->adaptiveResize(60, 60)->show();
$bDone = true;
}
}
}
if (!$bDone) {
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: ' . ($bDownload ? 'attachment' : 'inline') . '; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
}
}
}, $sFolder, $iUid, true, $sMimeIndex);
}
示例4: rawSmart
/**
* @param bool $bDownload
* @param bool $bThumbnail = false
*
* @return bool
*/
private function rawSmart($bDownload, $bThumbnail = false)
{
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$aValues = $this->getDecodedRawKeyValue($sRawKey);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
$sMimeIndex = isset($aValues['MimeIndex']) ? (string) $aValues['MimeIndex'] : '';
$sContentTypeIn = isset($aValues['MimeType']) ? (string) $aValues['MimeType'] : '';
$sFileNameIn = isset($aValues['FileName']) ? (string) $aValues['FileName'] : '';
$sFileHashIn = isset($aValues['FileHash']) ? (string) $aValues['FileHash'] : '';
if (!empty($sFileHashIn)) {
$this->verifyCacheByKey($sRawKey);
$oAccount = $this->getAccountFromToken();
$sContentTypeOut = empty($sContentTypeIn) ? \MailSo\Base\Utils::MimeContentType($sFileNameIn) : $sContentTypeIn;
$sFileNameOut = $this->MainClearFileName($sFileNameIn, $sContentTypeIn, $sMimeIndex);
$rResource = $this->FilesProvider()->GetFile($oAccount, $sFileHashIn);
if (\is_resource($rResource)) {
$sFileNameOut = \MailSo\Base\Utils::ConvertEncoding($sFileNameOut, \MailSo\Base\Enumerations\Charset::UTF_8, \MailSo\Base\Enumerations\Charset::CP858);
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: attachment; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
return true;
}
return false;
} else {
if (!empty($sFolder) && 0 < $iUid) {
$this->verifyCacheByKey($sRawKey);
}
}
$oAccount = $this->initMailClientConnection();
$self = $this;
return $this->MailClient()->MessageMimeStream(function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($self, $oAccount, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload, $bThumbnail) {
if ($oAccount && \is_resource($rResource)) {
$sContentTypeOut = $sContentTypeIn;
if (empty($sContentTypeOut)) {
$sContentTypeOut = $sContentType;
if (empty($sContentTypeOut)) {
$sContentTypeOut = empty($sFileName) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
}
}
$sFileNameOut = $sFileNameIn;
if (empty($sFileNameOut)) {
$sFileNameOut = $sFileName;
}
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
$self->cacheByKey($sRawKey);
$bDone = false;
if ($bThumbnail && !$bDownload) {
$sFileName = '';
$rTempResource = \MailSo\Base\StreamWrappers\TempFile::CreateStream(\MailSo\Base\Utils::Md5Rand($sFileNameOut), $sFileName);
if (@\is_resource($rTempResource)) {
$bDone = true;
\MailSo\Base\Utils::MultipleStreamWriter($rResource, array($rTempResource));
@\fclose($rTempResource);
try {
$oThumb = new \PHPThumb\GD($sFileName);
if ($oThumb) {
$oThumb->adaptiveResize(60, 60)->show();
}
} catch (\Exception $oException) {
$self->Logger()->WriteExceptionShort($oException);
}
}
}
if (!$bDone) {
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: ' . ($bDownload ? 'attachment' : 'inline') . '; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
}
}
}, $sFolder, $iUid, true, $sMimeIndex);
}
示例5: rawSmart
/**
* @param bool $bDownload
*
* @return bool
*/
private function rawSmart($bDownload)
{
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$aValues = $this->getDecodedRawKeyValue($sRawKey);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = (int) isset($aValues['Uid']) ? $aValues['Uid'] : 0;
$sMimeIndex = (string) isset($aValues['MimeIndex']) ? $aValues['MimeIndex'] : '';
$sContentTypeIn = (string) isset($aValues['MimeType']) ? $aValues['MimeType'] : '';
$sFileNameIn = (string) isset($aValues['FileName']) ? $aValues['FileName'] : '';
if (!empty($sFolder) && 0 < $iUid) {
$this->verifyCacheByKey($sRawKey);
}
$this->initMailClientConnection();
$self = $this;
return $this->MailClient()->MessageMimeStream(function ($rResource, $sContentType, $sFileName, $sMimeIndex = '') use($self, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload) {
if (\is_resource($rResource)) {
$sContentTypeOut = $sContentTypeIn;
if (empty($sContentTypeOut)) {
$sContentTypeOut = $sContentType;
if (empty($sContentTypeOut)) {
$sContentTypeOut = empty($sFileName) ? 'text/plain' : \MailSo\Base\Utils::MimeContentType($sFileName);
}
}
$sFileNameOut = $sFileNameIn;
if (empty($sFileNameOut)) {
$sFileNameOut = $sFileName;
}
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
\header('Content-Type: ' . $sContentTypeOut);
\header('Content-Disposition: ' . ($bDownload ? 'attachment' : 'inline') . '; ' . \trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
\header('Accept-Ranges: none', true);
\header('Content-Transfer-Encoding: binary');
$self->cacheByKey($sRawKey);
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
}
}, $sFolder, $iUid, true, $sMimeIndex);
}