當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utils::MimeContentType方法代碼示例

本文整理匯總了PHP中MailSo\Base\Utils::MimeContentType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::MimeContentType方法的具體用法?PHP Utils::MimeContentType怎麽用?PHP Utils::MimeContentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MailSo\Base\Utils的用法示例。


在下文中一共展示了Utils::MimeContentType方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ContentType

 /**
  * @return string
  */
 public function ContentType()
 {
     return \MailSo\Base\Utils::MimeContentType($this->sFileName);
 }
開發者ID:BertLasker,項目名稱:Catch-design,代碼行數:7,代碼來源:Attachment.php

示例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);
 }
開發者ID:ChristopheGitHub,項目名稱:rainloop-webmail,代碼行數:90,代碼來源:Actions.php

示例3: UploadHelpdeskFile

 /**
  * @return array
  */
 public function UploadHelpdeskFile()
 {
     $oAccount = null;
     $oUser = $this->getHelpdeskAccountFromParam($oAccount);
     if (!$this->oApiCapability->isHelpdeskSupported() || !$this->oApiCapability->isFilesSupported()) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::AccessDenied);
     }
     $aFileData = $this->getParamValue('FileData', null);
     $iSizeLimit = 0;
     $sError = '';
     $aResponse = array();
     if ($oUser) {
         if (is_array($aFileData)) {
             if (0 < $iSizeLimit && $iSizeLimit < (int) $aFileData['size']) {
                 $sError = 'size';
             } else {
                 $sSavedName = 'upload-post-' . md5($aFileData['name'] . $aFileData['tmp_name']);
                 if ($this->ApiFileCache()->moveUploadedFile($oUser, $sSavedName, $aFileData['tmp_name'])) {
                     $sUploadName = $aFileData['name'];
                     $iSize = $aFileData['size'];
                     $sMimeType = \MailSo\Base\Utils::MimeContentType($sUploadName);
                     $aResponse['HelpdeskFile'] = array('Name' => $sUploadName, 'TempName' => $sSavedName, 'MimeType' => $sMimeType, 'Size' => (int) $iSize, 'Hash' => \CApi::EncodeKeyValues(array('TempFile' => true, 'HelpdeskTenantID' => $oUser->IdTenant, 'HelpdeskUserID' => $oUser->IdHelpdeskUser, 'Name' => $sUploadName, 'TempName' => $sSavedName)));
                 } else {
                     $sError = 'unknown';
                 }
             }
         } else {
             $sError = 'unknown';
         }
     } else {
         $sError = 'auth';
     }
     if (0 < strlen($sError)) {
         $aResponse['Error'] = $sError;
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $aResponse);
 }
開發者ID:nsine,項目名稱:webmail-lite,代碼行數:40,代碼來源:Actions.php

示例4: CreateFile

 public function CreateFile($oAccount, $sType, $sPath, $sFileName, $mData, &$bResult, &$bBreak)
 {
     $oClient = $this->GetClient($oAccount, $sType);
     if ($oClient) {
         $bResult = false;
         $bBreak = true;
         $sMimeType = \MailSo\Base\Utils::MimeContentType($sFileName);
         $file = new Google_Service_Drive_DriveFile();
         $file->setTitle($sFileName);
         $file->setMimeType($sMimeType);
         $sPath = trim($sPath, '/');
         // Set the parent folder.
         if ($sPath != null) {
             $parent = new Google_Service_Drive_ParentReference();
             $parent->setId($sPath);
             $file->setParents(array($parent));
         }
         $oDrive = new Google_Service_Drive($oClient);
         try {
             $sData = '';
             if (is_resource($mData)) {
                 rewind($mData);
                 $sData = stream_get_contents($mData);
             } else {
                 $sData = $mData;
             }
             $oDrive->files->insert($file, array('data' => $sData, 'mimeType' => $sMimeType, 'uploadType' => 'media'));
             $bResult = true;
         } catch (Exception $ex) {
             $bResult = false;
         }
     }
 }
開發者ID:afterlogic,項目名稱:plugin-filestorage-google-drive,代碼行數:33,代碼來源:index.php

示例5: responseObject


//.........這裏部分代碼省略.........
                 $mResult['Safety'] = $mResponse->getSafety();
                 $mResult['HasExternals'] = $bHasExternals;
                 $mResult['FoundedCIDs'] = $aFoundedCIDs;
                 $mResult['FoundedContentLocationUrls'] = $aFoundedContentLocationUrls;
                 $mResult['Attachments'] = $this->responseObject($oAccount, $oAttachments, $sParent, array_merge($aParameters, array('FoundedCIDs' => $aFoundedCIDs, 'FoundedContentLocationUrls' => $aFoundedContentLocationUrls)));
                 //					$mResult['Html'] = \MailSo\Base\Utils::Utf8Clear($mResult['Html']);
                 //					$mResult['Plain'] = \MailSo\Base\Utils::Utf8Clear($mResult['Plain']);
             } else {
                 $mResult['@Object'] = 'Object/MessageListItem';
                 $mResult['Threads'] = $mResponse->getThreads();
             }
             $mResult['Custom'] = $this->responseObject($oAccount, $mResponse->getCustomList(), $sParent, $aParameters);
             $mResult['Subject'] = \MailSo\Base\Utils::Utf8Clear($mResult['Subject']);
         } else {
             if ('CApiMailIcs' === $sClassName) {
                 $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Uid' => $mResponse->Uid, 'Sequence' => $mResponse->Sequence, 'Attendee' => $mResponse->Attendee, 'File' => $mResponse->File, 'Type' => $mResponse->Type, 'Location' => $mResponse->Location, 'Description' => \MailSo\Base\LinkFinder::NewInstance()->Text($mResponse->Description)->UseDefaultWrappers(true)->CompileText(), 'When' => $mResponse->When, 'CalendarId' => $mResponse->CalendarId));
             } else {
                 if ('CApiMailVcard' === $sClassName) {
                     $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Uid' => $mResponse->Uid, 'File' => $mResponse->File, 'Name' => $mResponse->Name, 'Email' => $mResponse->Email, 'Exists' => $mResponse->Exists));
                 } else {
                     if ('CFilter' === $sClassName) {
                         $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Enable' => $mResponse->Enable, 'Field' => $mResponse->Field, 'Filter' => $mResponse->Filter, 'Condition' => $mResponse->Condition, 'Action' => $mResponse->Action, 'FolderFullName' => $mResponse->FolderFullName));
                     } else {
                         if ('CHelpdeskThread' === $sClassName) {
                             $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdHelpdeskThread' => $mResponse->IdHelpdeskThread, 'ThreadHash' => $mResponse->StrHelpdeskThreadHash, 'IdOwner' => $mResponse->IdOwner, 'Owner' => $mResponse->Owner, 'Type' => $mResponse->Type, 'Subject' => $mResponse->Subject, 'IsRead' => $mResponse->IsRead, 'IsArchived' => $mResponse->IsArchived, 'ItsMe' => $mResponse->ItsMe, 'HasAttachments' => $mResponse->HasAttachments, 'PostCount' => $mResponse->PostCount, 'Created' => $mResponse->Created, 'Updated' => $mResponse->Updated));
                         } else {
                             if ('CHelpdeskPost' === $sClassName) {
                                 $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdHelpdeskPost' => $mResponse->IdHelpdeskPost, 'IdHelpdeskThread' => $mResponse->IdHelpdeskThread, 'IdOwner' => $mResponse->IdOwner, 'Owner' => $mResponse->Owner, 'Attachments' => $this->responseObject($oAccount, $mResponse->Attachments, $sParent), 'IsThreadOwner' => $mResponse->IsThreadOwner, 'ItsMe' => $mResponse->ItsMe, 'Type' => $mResponse->Type, 'SystemType' => $mResponse->SystemType, 'Text' => \MailSo\Base\HtmlUtils::ConvertPlainToHtml($mResponse->Text), 'Created' => $mResponse->Created));
                             } else {
                                 if ('CHelpdeskAttachment' === $sClassName) {
                                     $iThumbnailLimit = 1024 * 1024 * 2;
                                     // 2MB
                                     /* @var $mResponse CHelpdeskAttachment */
                                     $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdHelpdeskAttachment' => $mResponse->IdHelpdeskAttachment, 'IdHelpdeskPost' => $mResponse->IdHelpdeskPost, 'IdHelpdeskThread' => $mResponse->IdHelpdeskThread, 'SizeInBytes' => $mResponse->SizeInBytes, 'FileName' => $mResponse->FileName, 'MimeType' => \MailSo\Base\Utils::MimeContentType($mResponse->FileName), 'Thumb' => \CApi::GetConf('labs.allow-thumbnail', true) && $mResponse->SizeInBytes < $iThumbnailLimit && \api_Utils::IsGDImageMimeTypeSuppoted(\MailSo\Base\Utils::MimeContentType($mResponse->FileName), $mResponse->FileName), 'Hash' => $mResponse->Hash, 'Content' => $mResponse->Content, 'Created' => $mResponse->Created));
                                 } else {
                                     if ('CFetcher' === $sClassName) {
                                         /* @var $mResponse \CFetcher */
                                         $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('IdFetcher' => $mResponse->IdFetcher, 'IdAccount' => $mResponse->IdAccount, 'IsEnabled' => $mResponse->IsEnabled, 'IsLocked' => $mResponse->IsLocked, 'Folder' => $mResponse->Folder, 'Name' => $mResponse->Name, 'Email' => $mResponse->Email, 'Signature' => $mResponse->Signature, 'SignatureOptions' => $mResponse->SignatureOptions, 'LeaveMessagesOnServer' => $mResponse->LeaveMessagesOnServer, 'IncomingMailServer' => $mResponse->IncomingMailServer, 'IncomingMailPort' => $mResponse->IncomingMailPort, 'IncomingMailLogin' => $mResponse->IncomingMailLogin, 'IsOutgoingEnabled' => $mResponse->IsOutgoingEnabled, 'OutgoingMailServer' => $mResponse->OutgoingMailServer, 'OutgoingMailPort' => $mResponse->OutgoingMailPort, 'OutgoingMailAuth' => $mResponse->OutgoingMailAuth, 'IncomingMailSsl' => $mResponse->IncomingMailSecurity === \MailSo\Net\Enumerations\ConnectionSecurityType::SSL, 'OutgoingMailSsl' => $mResponse->OutgoingMailSecurity === \MailSo\Net\Enumerations\ConnectionSecurityType::SSL));
                                     } else {
                                         if ('CApiMailFolder' === $sClassName) {
                                             $aExtended = null;
                                             $mStatus = $mResponse->getStatus();
                                             if (is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])) {
                                                 $aExtended = array('MessageCount' => (int) $mStatus['MESSAGES'], 'MessageUnseenCount' => (int) $mStatus['UNSEEN'], 'UidNext' => (string) $mStatus['UIDNEXT'], 'Hash' => \api_Utils::GenerateFolderHash($mResponse->getRawFullName(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT']));
                                             }
                                             $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('Type' => $mResponse->getType(), 'Name' => $mResponse->getName(), 'FullName' => $mResponse->getFullName(), 'FullNameRaw' => $mResponse->getRawFullName(), 'FullNameHash' => md5($mResponse->getRawFullName()), 'Delimiter' => $mResponse->getDelimiter(), 'IsSubscribed' => $oAccount->isExtensionEnabled(\CAccount::IgnoreSubscribeStatus) ? true : $mResponse->isSubscribed(), 'IsSelectable' => $mResponse->isSelectable(), 'Exists' => $mResponse->exists(), 'Extended' => $aExtended, 'SubFolders' => $this->responseObject($oAccount, $mResponse->getSubFolders(), $sParent, $aParameters)));
                                         } else {
                                             if ('CApiMailAttachment' === $sClassName) {
                                                 $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && is_array($aParameters['FoundedCIDs']) ? $aParameters['FoundedCIDs'] : null;
                                                 $mFoundedContentLocationUrls = isset($aParameters['FoundedContentLocationUrls']) && \is_array($aParameters['FoundedContentLocationUrls']) && 0 < \count($aParameters['FoundedContentLocationUrls']) ? $aParameters['FoundedContentLocationUrls'] : null;
                                                 if ($mFoundedCIDs || $mFoundedContentLocationUrls) {
                                                     $aFoundedCIDs = \array_merge($mFoundedCIDs ? $mFoundedCIDs : array(), $mFoundedContentLocationUrls ? $mFoundedContentLocationUrls : array());
                                                     $aFoundedCIDs = 0 < \count($mFoundedCIDs) ? $mFoundedCIDs : null;
                                                 }
                                                 $sMimeType = strtolower(trim($mResponse->getMimeType()));
                                                 $sMimeIndex = strtolower(trim($mResponse->getMimeIndex()));
                                                 $sContentTransferEncoding = strtolower(trim($mResponse->getEncoding()));
                                                 $sFileName = $mResponse->getFileName(true);
                                                 $iEstimatedSize = $mResponse->getEstimatedSize();
                                                 $iThumbnailLimit = 1024 * 1024 * 2;
                                                 // 2MB //TODO
                                                 if (in_array($sMimeType, array('application/octet-stream'))) {
                                                     $sMimeType = \MailSo\Base\Utils::MimeContentType($sFileName);
                                                 }
                                                 $sCid = \trim(\trim($mResponse->getCid()), '<>');
                                                 $mResult = array_merge($this->objectWrapper($oAccount, $mResponse, $sParent, $aParameters), array('FileName' => $sFileName, 'MimeType' => $sMimeType, 'MimePartIndex' => 'message/rfc822' === $sMimeType && ('base64' === $sContentTransferEncoding || 'quoted-printable' === $sContentTransferEncoding) ? '' : $sMimeIndex, 'EstimatedSize' => $iEstimatedSize, 'CID' => $sCid, 'ContentLocation' => $mResponse->getContentLocation(), 'Thumb' => \CApi::GetConf('labs.allow-thumbnail', true) && $iEstimatedSize < $iThumbnailLimit && \api_Utils::IsGDImageMimeTypeSuppoted($sMimeType, $sFileName), 'Expand' => \CApi::isExpandMimeTypeSupported($sMimeType, $sFileName), 'Iframed' => \CApi::isIframedMimeTypeSupported($sMimeType, $sFileName), 'Content' => $mResponse->getContent(), 'IsInline' => $mResponse->isInline(), 'IsLinked' => !empty($sCid) && $mFoundedCIDs && \in_array($sCid, $mFoundedCIDs) || $mFoundedContentLocationUrls && \in_array(\trim($mResponse->getContentLocation()), $mFoundedContentLocationUrls)));
開發者ID:Git-Host,項目名稱:email,代碼行數:67,代碼來源:ActionsBase.php

示例6: 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);
 }
開發者ID:skidu,項目名稱:rainloop-webmail,代碼行數:82,代碼來源:Actions.php

示例7: GetFont

 /**
  * @param string $sFontName
  * @return string
  */
 public function GetFont($sFontName)
 {
     $sFontFileName = $this->oPluginManager->GetFont($this->sName, $sFontName);
     if ($sFontFileName) {
         $sContentType = \MailSo\Base\Utils::MimeContentType($sFontFileName);
         $sType = \MailSo\Base\Utils::ContentTypeType($sContentType, $sFontFileName);
         if ('font' === $sType) {
             @header('Content-Type: ' . $sContentType);
             //				@header('Content-Disposition: attachment; filename="' . $sFontName . '"');
             $sFilePath = $sFontFileName;
             if (file_exists($sFilePath)) {
                 return file_get_contents($sFilePath);
             } else {
                 if (function_exists('http_response_code')) {
                     \http_response_code(404);
                 } else {
                     \header("HTTP/1.1 404 Not Found", true, 404);
                 }
             }
         }
     }
 }
開發者ID:nsine,項目名稱:webmail-lite,代碼行數:26,代碼來源:plugin.php

示例8: 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);
 }
開發者ID:sunhaolin,項目名稱:rainloop,代碼行數:60,代碼來源:Actions.php

示例9: 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);
 }
開發者ID:GTAWWEKID,項目名稱:tsiserver.us,代碼行數:42,代碼來源:Actions.php

示例10: GetImage

 /**
  * @param string $sFileName
  * @return string
  */
 public function GetImage($sFileName)
 {
     $sContentType = \MailSo\Base\Utils::MimeContentType($sFileName);
     if ('image' === \MailSo\Base\Utils::ContentTypeType($sContentType, $sFileName)) {
         @header('Content-Type: ' . $sContentType);
         $sFilePath = $this->GetPath() . '/images/' . $sFileName;
         if (file_exists($sFilePath)) {
             return file_get_contents($sFilePath);
         } else {
             if (function_exists('http_response_code')) {
                 \http_response_code(404);
             } else {
                 \header("HTTP/1.1 404 Not Found", true, 404);
             }
         }
     }
 }
開發者ID:BertLasker,項目名稱:Catch-design,代碼行數:21,代碼來源:plugin.php


注:本文中的MailSo\Base\Utils::MimeContentType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。