• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
  • Класс: CWebDavIblock
  • Вызов: CWebDavIblock::PUT
function PUT(&$options)
{
	WDUnpackCookie();
	$_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] = (is_string($_SESSION["WEBDAV_DATA"]["PUT_EMPTY"]) ? $_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] : "");
	$_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] = (is_string($_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"]) ? $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] : "");

	$this->IsDir($options, true);

	if ($this->arParams["is_dir"] === true)
		return "409 Conflict";
	if ($this->arParams["parent_id"] === false)
		return false;

	$options["new"] = ($this->arParams["not_found"] === true);
	$options["ELEMENT_ID"] = $this->arParams["item_id"];
	if (!$this->CheckWebRights("PUT", array('arElement' => $this->arParams)))
	{
		$this->ThrowAccessDenied(__LINE__);
		return false;
	}

	$options["FILE_NAME"] = (!empty($this->arParams["file_name"]) ? $this->arParams["file_name"] : $this->arParams["basename"]);
	$options["FILE_NAME"] = $this->CorrectName($options["FILE_NAME"]);
	$options["~path"] = $this->_udecode($options["path"]);
	$options["set_now"] = false;

	if (($_SERVER['REQUEST_METHOD'] == "PUT" || $_SERVER['REQUEST_METHOD'] == "LOCK") &&
		/*empty($_SESSION["WEBDAV_DATA"]["PUT_EMPTY"]) && */ intval($options["content_length"]) <= 0)
	{
		// Sometimes file is uploaded in 2 steps: 1) PUT with content_length == 0, when PUT with content_length >= 0.
		$_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] = $options["~path"];
		$options["set_now"] = true;
	}
	if (!empty($_SESSION["WEBDAV_DATA"]["PUT_EMPTY"]) && $_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] != $options["~path"])
	{
		if ($_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] == $options["~path"])
		{
		}
		elseif (mb_substr($options["FILE_NAME"], 0, 2) == "._" &&
			$_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] == str_replace($options["FILE_NAME"], mb_substr($options["FILE_NAME"], 2), $options["~path"]))
		{
			// Mac OS uploads in 4 PUT: 
// 1. PUT with content_length == 0; // 2. PUT with content_length == 0 && file_name == "._".file_name; // 3. PUT with content_length >= 0 && file_name == "._".file_name; // 4. PUT with content_length >= 0. $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] = $options["~path"]; } else { $_SESSION["WEBDAV_DATA"] = array(); } } WDPackCookie(); if (!empty($_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"]) && $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] == $options["~path"]) { "no need to check data"; } elseif (!$options["set_now"] && !empty($_SESSION["WEBDAV_DATA"]["PUT_EMPTY"]) && $_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] == $options["~path"]) { "no need to check data"; } elseif (!$this->CheckWebRights("", $options = array_merge($options, array( "action" => ($this->arParams["not_found"] ? "create" : "edit"), "arElement" => $this->arParams)), false)) { $this->ThrowAccessDenied(__LINE__); return false; } elseif ($this->check_creator && $this->arParams["is_file"] === true && $this->arParams["element_array"]["CREATED_BY"] != $GLOBALS["USER"]->GetID()) { $this->ThrowAccessDenied(__LINE__); return false; } $options["IBLOCK_SECTION_ID"] = $this->arParams["parent_id"]; if ($this->arParams["parent_id"] <= 0 && $this->arRootSection) $options["IBLOCK_SECTION_ID"] = $this->arRootSection["ID"]; $options["TMP_FILE"] = CTempFile::GetFileName($options["FILE_NAME"]); CheckDirPath($options["TMP_FILE"]); $fp = fopen($options["TMP_FILE"], "w"); return $fp; }