• Модуль: dav
  • Путь к файлу: ~/bitrix/modules/dav/classes/general/request.php
  • Класс: CDavRequest
  • Вызов: CDavRequest::__construct
public function __construct($arRequestParameters)
{
	$this->arRequestParameters = $arRequestParameters;

	if (!isset($this->arRequestParameters['PATH_INFO']) && isset($this->arRequestParameters['ORIG_PATH_INFO']))
	{
		$this->arRequestParameters['PATH_INFO'] = $this->arRequestParameters['ORIG_PATH_INFO'];
	}

	static $arAgentsMap = [
		'iphone'            => 'iphone',		// Apple iPhone iCal
		'davkit'            => 'davkit',		// Apple iCal
		'mac os'            => 'davkit',		// Apple iCal (Mac Os X > 10.8)
		'macos'             => 'davkit',         // Apple iCal (Mac Os > 11)
		'mac_os_x'          => 'davkit',		// Apple iCal (Mac Os X > 10.8)
		'mac+os+x'          => 'davkit',		// Apple iCal (Mac Os X > 10.10)
		'dataaccess'        => 'dataaccess',	// Apple addressbook iPhone
		'cfnetwork'         => 'cfnetwork',		// Apple Addressbook
		'bionicmessage.net' => 'funambol',		// funambol GroupDAV connector from bionicmessage.net
		'zideone'           => 'zideone',		// zideone outlook plugin
		'lightning'         => 'lightning',		// Lighting (SOGo connector for addressbook)
		'webkit'			=> 'webkit',		// Webkit Browser (also reports KHTML!)
		'khtml'             => 'kde',			// KDE clients
		'neon'              => 'neon',
		'ical4ol'			=> 'ical4ol',		// iCal4OL client
		'sunbird'			=> 'sunbird',		// Mozilla Sunbird
		'ios/5'             => 'dataaccess',    // iOS/5
		'ios/6'             => 'dataaccess',    // iOS/6
		'ios/7'             => 'dataaccess',    // iOS/7
		'ios/8'             => 'dataaccess',    // iOS/8
		'ios/9'             => 'dataaccess',    // iOS/9
		'ios/10'            => 'dataaccess',    // iOS/10
		'ios/11'            => 'dataaccess',    // iOS/11
		'ios/12'            => 'dataaccess',    // iOS/12
		'ios/13'            => 'dataaccess',    // iOS/13
		'ios/14'            => 'dataaccess',    // iOS/14
		'ios/15'            => 'dataaccess',    // iOS/15
		'ios/16'            => 'dataaccess',    // iOS/16
		'carddavbitrix24'   => 'dataaccess',
		'caldavbitrix24'    => 'dataaccess',
		'coredav'           => 'davkit',    //
	];

	$httpUserAgent = mb_strtolower($this->arRequestParameters['HTTP_USER_AGENT']);
	foreach ($arAgentsMap as $pattern => $name)
	{
		if (mb_strpos($httpUserAgent, $pattern) !== false)
		{
			$this->agent = $name;
			break;
		}
	}

	$this->isUrlRequired = ($this->agent === 'kde');
	$this->isRedundantNamespaceDeclarationsRequired = in_array($this->agent, array('cfnetwork', 'dataaccess', 'davkit', 'neon', 'iphone'));

	$uri = "";
	if ($this->isUrlRequired)
	{
		$scheme = $this->GetParameter("HTTPS") === "on"
			? "https"
			: "http"
		;
		$uri = $scheme . '://' . $this->GetParameter('HTTP_HOST');
	}

	$requestUri = $this->GetParameter('REQUEST_URI');
	$requestUri = preg_replace("/%0D|%0A/i", "", $requestUri);
	$requestUri = urldecode($requestUri);
	$requestUri = preg_replace("/r|n/i", "", $requestUri);

	$uri .= $requestUri;

	$p = $this->GetParameter("PATH_INFO");
	if (!empty($p))
	{
		$uri = mb_substr($uri, 0, -mb_strlen($p));
	}

	$pathInfo = empty($p) ? "/" : $p;

	if (mb_substr($pathInfo, -mb_strlen("/index.php")) === "/index.php")
	{
		$pathInfo = mb_substr($pathInfo, 0, -mb_strlen("/index.php"));
	}

	$this->baseUri = $uri;
	$this->uri = str_replace("//", "/", $uri.$pathInfo);
	$this->path = strtr($pathInfo, array('%' => '%25', '#' => '%23', '?' => '%3F'));

	if (empty($this->path))
	{
		if ($this->GetParameter("REQUEST_METHOD") === "GET")
		{
			header("Location: ".$this->baseUri."/");
			die();
		}

		$this->path = "/";
	}

	if (ini_get("magic_quotes_gpc"))
	{
		$this->path = stripslashes($this->path);
	}


	if ($this->GetParameter('HTTP_DEPTH') !== null)
	{
		$this->depth = $this->GetParameter('HTTP_DEPTH');
	}
	elseif (in_array($this->GetParameter('REQUEST_METHOD'), ['PROPFIND', 'DELETE', 'MOVE', 'COPY', 'LOCK']))
	{
		$this->depth = 'infinity';
	}
	elseif ($this->GetParameter('REQUEST_METHOD') === "GET")
	{
		$this->depth = 1;
	}
	else
	{
		$this->depth = 0;
	}

	if ($this->depth !== 'infinity')
	{
		$this->depth = intval($this->depth);
	}
}