• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/composite/helper.php
  • Класс: BitrixMainCompositeshares
  • Вызов: shares::setOptions
static function setOptions($arOptions = array())
{
	$arOptions = array_merge(self::getOptions(), $arOptions);
	self::compileOptions($arOptions);

	$fileName = self::getConfigFilePath();
	$tempFileName = $fileName.md5(mt_rand()).".tmp";
	self::makeDirPath($fileName);

	$fh = fopen($tempFileName, "wb");
	if ($fh !== false)
	{
		$content = " $value)
		{
			if (is_integer($key))
			{
				$phpKey = $key;
			}
			else
			{
				$phpKey = """.self::escapePHPString($key).""";
			}

			if (is_array($value))
			{
				$content .= "t".$phpKey." => array(n";
				foreach ($value as $key2 => $val)
				{
					if (is_integer($key2))
					{
						$phpKey2 = $key2;
					}
					else
					{
						$phpKey2 = """.self::escapePHPString($key2).""";
					}

					$content .= "tt".$phpKey2." => "".self::escapePHPString($val)."",n";
				}
				$content .= "t),n";
			}
			else
			{
				$content .= "t".$phpKey." => "".self::escapePHPString($value)."",n";
			}
		}

		$content .= ");n?>";
		$written = fwrite($fh, $content);
		$len = strlen($content);
		if ($written === $len)
		{
			fclose($fh);
			if (file_exists($fileName))
			{
				unlink($fileName);
			}
			rename($tempFileName, $fileName);
			@chmod($fileName, defined("BX_FILE_PERMISSIONS") ? BX_FILE_PERMISSIONS : 0664);
		}
		else
		{
			fclose($fh);
			if (file_exists($tempFileName))
			{
				unlink($tempFileName);
			}
		}

		self::$options = array();
	}
}