本文整理匯總了PHP中MailSo\Base\Utils::FpassthruWithTimeLimitReset方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::FpassthruWithTimeLimitReset方法的具體用法?PHP Utils::FpassthruWithTimeLimitReset怎麽用?PHP Utils::FpassthruWithTimeLimitReset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::FpassthruWithTimeLimitReset方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: raw
/**
* @return bool
*/
private function raw($bDownload = true, $bThumbnail = false)
{
$self = $this;
return $this->rawCallback((string) $this->getParamValue('RawKey', ''), function ($oAccount, $sContentType, $sFileName, $rResource, $oHelpdeskUser = null) use($self, $bDownload, $bThumbnail) {
$self->RawOutputHeaders($bDownload, $sContentType, $sFileName);
if (!$bDownload && 'text/html' === $sContentType) {
$sHtml = stream_get_contents($rResource);
if ($sHtml) {
$sCharset = '';
$aMacth = array();
if (preg_match('/charset[\\s]?=[\\s]?([^\\s"\']+)/i', $sHtml, $aMacth) && !empty($aMacth[1])) {
$sCharset = $aMacth[1];
}
if ('' !== $sCharset && \MailSo\Base\Enumerations\Charset::UTF_8 !== $sCharset) {
$sHtml = \MailSo\Base\Utils::ConvertEncoding($sHtml, \MailSo\Base\Utils::NormalizeCharset($sCharset, true), \MailSo\Base\Enumerations\Charset::UTF_8);
}
include_once PSEVEN_APP_ROOT_PATH . 'libraries/other/CssToInlineStyles.php';
$oCssToInlineStyles = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($sHtml);
$oCssToInlineStyles->setEncoding('utf-8');
$oCssToInlineStyles->setUseInlineStylesBlock(true);
echo '<html><head></head><body>' . \MailSo\Base\HtmlUtils::ClearHtmlSimple($oCssToInlineStyles->convert(), true, true) . '</body></html>';
}
} else {
if ($bThumbnail && !$bDownload) {
$self->thumbResource($oAccount ? $oAccount : $oHelpdeskUser, $rResource, $sFileName);
} else {
\MailSo\Base\Utils::FpassthruWithTimeLimitReset($rResource);
}
}
}, !$bDownload);
}
示例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);
}