当前位置: 首页>>代码示例>>PHP>>正文


PHP api_Utils::GetFileExtensionFromMimeContentType方法代码示例

本文整理汇总了PHP中api_Utils::GetFileExtensionFromMimeContentType方法的典型用法代码示例。如果您正苦于以下问题:PHP api_Utils::GetFileExtensionFromMimeContentType方法的具体用法?PHP api_Utils::GetFileExtensionFromMimeContentType怎么用?PHP api_Utils::GetFileExtensionFromMimeContentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在api_Utils的用法示例。


在下文中一共展示了api_Utils::GetFileExtensionFromMimeContentType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AjaxFilesCheckUrl

 /**
  * @return array
  */
 public function AjaxFilesCheckUrl()
 {
     $oAccount = $this->GetDefaultAccount();
     $mResult = false;
     if ($oAccount) {
         $sUrl = trim($this->getParamValue('Url', ''));
         if (!empty($sUrl)) {
             $iLinkType = \api_Utils::GetLinkType($sUrl);
             if ($iLinkType === \EFileStorageLinkType::GoogleDrive) {
                 if ($this->oApiTenants) {
                     $oTenant = 0 < $oAccount->IdTenant ? $this->oApiTenants->getTenantById($oAccount->IdTenant) : $this->oApiTenants->getDefaultGlobalTenant();
                 }
                 $oSocial = $oTenant->getSocialByName('google');
                 if ($oSocial) {
                     $oInfo = \api_Utils::GetGoogleDriveFileInfo($sUrl, $oSocial->SocialApiKey);
                     if ($oInfo) {
                         $mResult['Size'] = 0;
                         if (isset($oInfo->fileSize)) {
                             $mResult['Size'] = $oInfo->fileSize;
                         } else {
                             $aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
                             $mResult['Size'] = $aRemoteFileInfo['size'];
                         }
                         $mResult['Name'] = isset($oInfo->title) ? $oInfo->title : '';
                         $mResult['Thumb'] = isset($oInfo->thumbnailLink) ? $oInfo->thumbnailLink : null;
                     }
                 }
             } else {
                 //$sUrl = \api_Utils::GetRemoteFileRealUrl($sUrl);
                 $oInfo = \api_Utils::GetOembedFileInfo($sUrl);
                 if ($oInfo) {
                     $mResult['Size'] = isset($oInfo->fileSize) ? $oInfo->fileSize : '';
                     $mResult['Name'] = isset($oInfo->title) ? $oInfo->title : '';
                     $mResult['LinkType'] = $iLinkType;
                     $mResult['Thumb'] = isset($oInfo->thumbnail_url) ? $oInfo->thumbnail_url : null;
                 } else {
                     if (\api_Utils::GetLinkType($sUrl) === \EFileStorageLinkType::DropBox) {
                         $sUrl = str_replace('?dl=0', '', $sUrl);
                     }
                     $sUrl = \api_Utils::GetRemoteFileRealUrl($sUrl);
                     if ($sUrl) {
                         $aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
                         $sFileName = basename($sUrl);
                         $sFileExtension = \api_Utils::GetFileExtension($sFileName);
                         if (empty($sFileExtension)) {
                             $sFileExtension = \api_Utils::GetFileExtensionFromMimeContentType($aRemoteFileInfo['content-type']);
                             $sFileName .= '.' . $sFileExtension;
                         }
                         if ($sFileExtension === 'htm') {
                             $oCurl = curl_init();
                             \curl_setopt_array($oCurl, array(CURLOPT_URL => $sUrl, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => '', CURLOPT_RETURNTRANSFER => true, CURLOPT_AUTOREFERER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5, CURLOPT_MAXREDIRS => 5));
                             $sContent = curl_exec($oCurl);
                             //$aInfo = curl_getinfo($oCurl);
                             curl_close($oCurl);
                             preg_match('/<title>(.*?)<\\/title>/s', $sContent, $aTitle);
                             $sTitle = isset($aTitle['1']) ? trim($aTitle['1']) : '';
                         }
                         $mResult['Name'] = isset($sTitle) && strlen($sTitle) > 0 ? $sTitle : urldecode($sFileName);
                         $mResult['Size'] = $aRemoteFileInfo['size'];
                     }
                 }
             }
         }
     }
     return $this->DefaultResponse(null, __FUNCTION__, $mResult);
 }
开发者ID:nsine,项目名称:webmail-lite,代码行数:69,代码来源:Actions.php

示例2: AjaxFilesCheckUrl

 /**
  * @return array
  */
 public function AjaxFilesCheckUrl()
 {
     $oAccount = $this->GetDefaultAccount();
     $mResult = false;
     if ($oAccount) {
         $sUrl = trim($this->getParamValue('Url', ''));
         if (!empty($sUrl)) {
             if (\api_Utils::GetLinkType($sUrl) === \EFileStorageLinkType::GoogleDrive) {
                 if ($this->oApiTenants) {
                     $oTenant = 0 < $oAccount->IdTenant ? $this->oApiTenants->GetTenantById($oAccount->IdTenant) : $this->oApiTenants->GetDefaultGlobalTenant();
                 }
                 $oSocial = $oTenant->GetSocialByName('google');
                 if ($oSocial) {
                     $oInfo = \api_Utils::GetGoogleDriveFileInfo($sUrl, $oSocial->SocialApiKey);
                     if ($oInfo) {
                         $mResult['Size'] = 0;
                         if (isset($oInfo->fileSize)) {
                             $mResult['Size'] = $oInfo->fileSize;
                         } else {
                             $aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
                             $mResult['Size'] = $aRemoteFileInfo['size'];
                         }
                         $mResult['Name'] = isset($oInfo->title) ? $oInfo->title : '';
                         $mResult['Thumb'] = isset($oInfo->thumbnailLink) ? $oInfo->thumbnailLink : null;
                     }
                 }
             } else {
                 if (\api_Utils::GetLinkType($sUrl) === \EFileStorageLinkType::DropBox) {
                     $sUrl = str_replace('?dl=0', '', $sUrl);
                 }
                 if (\api_Utils::RemoteFileExists($sUrl)) {
                     $aRemoteFileInfo = \api_Utils::GetRemoteFileInfo($sUrl);
                     $sFileExtension = \api_Utils::GetFileExtensionFromMimeContentType($aRemoteFileInfo['content-type']);
                     $sFileName = basename($sUrl);
                     $sFileExtension = \api_Utils::GetFileExtension($sFileName);
                     if (empty($sFileExtension)) {
                         $sFileExtension = \api_Utils::GetFileExtensionFromMimeContentType($aRemoteFileInfo['content-type']);
                         $sFileName .= '.' . $sFileExtension;
                     }
                     if ($sFileExtension === 'htm') {
                         $sContent = file_get_contents($sUrl);
                         preg_match('/<title>(.*?)<\\/title>/s', $sContent, $aTitle);
                         $sTitle = isset($aTitle['1']) ? trim($aTitle['1']) : '';
                     }
                     $mResult['Name'] = isset($sTitle) && strlen($sTitle) > 0 ? $sTitle : urldecode($sFileName);
                     $mResult['Size'] = $aRemoteFileInfo['size'];
                 }
             }
         }
     }
     return $this->DefaultResponse(null, __FUNCTION__, $mResult);
 }
开发者ID:BertLasker,项目名称:Catch-design,代码行数:55,代码来源:Actions.php


注:本文中的api_Utils::GetFileExtensionFromMimeContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。