• Модуль: advertising
  • Путь к файлу: ~/bitrix/modules/advertising/classes/general/advertising.php
  • Класс: CAdvBanner_all
  • Вызов: CAdvBanner_all::makeFileArrayFromArray
static function makeFileArrayFromArray($file_array, $description = null, $options = array())
{
	$result = false;

	if (is_uploaded_file($file_array["tmp_name"]))
	{
		$result = $file_array;
		if (!is_null($description))
			$result["description"] = $description;
	}
	elseif (
		$file_array["tmp_name"] <> ''
		&& mb_strpos($file_array["tmp_name"], CTempFile::GetAbsoluteRoot()) === 0
	)
	{
		$io = CBXVirtualIo::GetInstance();
		$absPath = $io->CombinePath("/", $file_array["tmp_name"]);
		$tmpPath = CTempFile::GetAbsoluteRoot()."/";
		if (mb_strpos($absPath, $tmpPath) === 0 || (($absPath = ltrim($absPath, "/")) && mb_strpos($absPath, $tmpPath) === 0))
		{
			$result = $file_array;
			$result["tmp_name"] = $absPath;
			$result["error"] = intval($result["error"]);
			if (!is_null($description))
				$result["description"] = $description;
		}
	}
	elseif ($file_array["tmp_name"] <> '')
	{
		$io = CBXVirtualIo::GetInstance();
		$normPath = $io->CombinePath("/", $file_array["tmp_name"]);
		$absPath = $io->CombinePath(CTempFile::GetAbsoluteRoot(), $normPath);
		$tmpPath = CTempFile::GetAbsoluteRoot()."/";
		if (mb_strpos($absPath, $tmpPath) === 0 && $io->FileExists($absPath) ||
			($absPath = $io->CombinePath($_SERVER["DOCUMENT_ROOT"], $normPath)) && mb_strpos($absPath, $tmpPath) === 0)
		{
			$result = $file_array;
			$result["tmp_name"] = $absPath;
			$result["error"] = intval($result["error"]);
			if (!is_null($description))
				$result["description"] = $description;
		}
	}
	else
	{
		$emptyFile = array(
			"name" => null,
			"type" => null,
			"tmp_name" => null,
			"error" => 4,
			"size" => 0,
		);
		if ($file_array == $emptyFile)
		{
			$result = $emptyFile;
			if (!is_null($description))
				$result["description"] = $description;
		}
	}

	return $result;
}