/** * @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); }