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