• Модуль: mail
  • Путь к файлу: ~/bitrix/modules/mail/lib/registrar/omnilance.php
  • Класс: BitrixMailRegistrarOmnilance
  • Вызов: Omnilance::updateDns
static function updateDns(string $user, string $password, string $domain, array $params, ?string &$error): ?bool
{
	$error = null;
	$domain = mb_strtolower($domain);
	$domain = Encoding::convertEncoding($domain, SITE_CHARSET, 'UTF-8');
	$params = Encoding::convertEncoding($params, SITE_CHARSET, 'UTF-8');

	$first = true;
	foreach ($params as $dns)
	{
		$payLoad = [
			'type' => (isset($dns['type']) && is_string($dns['type'])) ? strtoupper($dns['type']) : null,
			'name' => (isset($dns['name']) && is_string($dns['name'])) ? $dns['name'] : '',
			'value' => isset($dns['value']) ? [$dns['value']] : [],
			'ttl' => 3600
		];
		$payLoad = json_encode($payLoad);

		$omnilance = new self($user, $password);

		if ($first)
		{
			$res = $omnilance->sendPostCommand('domains/createZoneRecord/'.$domain, $payLoad);
		}
		else
		{
			$res = $omnilance->sendPostCommand('domains/createDnsRecord/'.$domain, $payLoad);
		}

		$res = json_decode($res, true);

		if (isset($res['error']))
		{
			$error = $res['message'] ?? $res['error'];
		}
		$first = false;
	}

	return $error === null;
}