• Модуль: bitrixcloud
  • Путь к файлу: ~/bitrix/modules/bitrixcloud/classes/general/backup_webservice.php
  • Класс: CBitrixCloudBackupWebService
  • Вызов: CBitrixCloudBackupWebService::actionAddBackupJob
public function actionAddBackupJob($secret_key, $url, $time = 0, $weekdays = array()) /*. throws CBitrixCloudException .*/
{
	if ($secret_key == "")
	{
		throw new CBitrixCloudException(GetMessage("BCL_BACKUP_EMPTY_SECRET_KEY"), "");
	}

	$parsedUrl = parse_url($url);
	if (
		!is_array($parsedUrl)
		|| !($parsedUrl["scheme"] === "http" || $parsedUrl["scheme"] === "https")
		|| $parsedUrl["host"] == ''
		|| !(intval($parsedUrl["port"]) == 0 || intval($parsedUrl["port"]) == 80)
		|| $parsedUrl["path"] <> ''
		|| $parsedUrl["user"] <> ''
		|| $parsedUrl["pass"] <> ''
		|| $parsedUrl["query"] <> ''
		|| $parsedUrl["fragment"] <> ''
	)
	{
		throw new CBitrixCloudException(GetMessage("BCL_BACKUP_WRONG_URL"), "");
	}

	$time = intval($time);
	if ($time < 0 || $time >= 24*3600)
	{
		throw new CBitrixCloudException(GetMessage("BCL_BACKUP_WRONG_TIME"), "");
	}

	$weekdaysIsOk = is_array($weekdays);
	if ($weekdaysIsOk)
	{
		foreach ($weekdays as $dow)
		{
			if (intval($dow) < 0 || intval($dow) > 6)
				$weekdaysIsOk = false;
		}
	}
	if (!$weekdaysIsOk)
	{
		throw new CBitrixCloudException(GetMessage("BCL_BACKUP_WRONG_WEEKDAYS"), "");
	}

	$h = intval($time/3600);
	$time -= $h*3600;
	$m = intval($time/60);
	$this->addParams = array(
		"secret_key" => trim($secret_key),
		"time" => $h.":".$m,
		"domain" => $parsedUrl["host"],
		"spd" => CUpdateClient::getSpd(),
		"CHHB" => $_SERVER["HTTP_HOST"],
		"CSAB" => $_SERVER["SERVER_ADDR"],
	);

	if ($parsedUrl["scheme"] === "https")
	{
		$this->addParams["domain_is_https"] = "Y";
	}

	$this->addStr = "";
	foreach ($weekdays as $dow)
	{
		$this->addStr .= "&ar_weekdays[]=".intval($dow);
	}

	return $this->backup_action("add_backup_job");
}