• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/file_proxy.php
  • Класс: \CCrmFileProxy
  • Вызов: CCrmFileProxy::TryResolveFile
static function TryResolveFile($var, &$file, $options = array())
{
	if(!is_array($options))
	{
		$options = array();
	}

	$result = null;
	if(is_array($var))
	{
		$enableUpload = isset($options['ENABLE_UPLOAD']) && $options['ENABLE_UPLOAD'];
		if($enableUpload)
		{
			$enableUploadCheck = !isset($options['ENABLE_UPLOAD_CHECK']) || $options['ENABLE_UPLOAD_CHECK'];
			if(!$enableUploadCheck || self::IsUploadedFile($var))
			{
				$result = $var;
			}
		}
	}
	elseif(is_numeric($var))
	{
		if(isset($options['ENABLE_ID']) && $options['ENABLE_ID'])
		{
			$result = CFile::MakeFileArray($var);
			$result['ID'] = $var;
		}
	}
	elseif(is_string($var))
	{
		$path = CCrmUrlUtil::ToAbsoluteUrl($var);
		//Parent directories and not secure URLs are not allowed.
		if($path !== '' && !CHTTP::isPathTraversalUri($path) && CCrmUrlUtil::IsSecureUrl($path))
		{
			$result = CFile::MakeFileArray($path);
		}
	}

	if(is_array($result))
	{
		$result['MODULE_ID'] = 'crm';
		$file = $result;
		return true;
	}

	return false;
}