/** * * @param string $operation * @param string $check_word * @param string $file_name * @return CBitrixCloudBackupBucket * */ private function _getBucket($operation, $check_word, $file_name) { if (!CModule::IncludeModule('clouds')) { throw new CBitrixCloudException("Module clouds not installed."); } $web_service = new CBitrixCloudBackupWebService(); if ($operation === "write") { $obXML = $web_service->actionWriteFile($check_word, $file_name); } else { $obXML = $web_service->actionReadFile($check_word, $file_name); } $bucket_name = is_object($node = $obXML->SelectNodes("/control/bucket/bucket_name")) ? $node->textContent() : ""; $prefix = is_object($node = $obXML->SelectNodes("/control/bucket/prefix")) ? $node->textContent() : ""; $access_key = is_object($node = $obXML->SelectNodes("/control/bucket/access_key")) ? $node->textContent() : ""; $secret_key = is_object($node = $obXML->SelectNodes("/control/bucket/secret_key")) ? $node->textContent() : ""; $session_token = is_object($node = $obXML->SelectNodes("/control/bucket/session_token")) ? $node->textContent() : ""; $file_name = is_object($node = $obXML->SelectNodes("/control/bucket/file_name")) ? $node->textContent() : ""; return new CBitrixCloudBackupBucket($bucket_name, $prefix, $access_key, $secret_key, $session_token, $check_word, $file_name); }
public function getBackupJob() { try { $web_service = new CBitrixCloudBackupWebService(); $infoXML = $web_service->actionGetBackupJob(); } catch (CBitrixCloudException $e) { return $e->getMessage(); //."[".htmlspecialcharsEx($e->getErrorCode())."]"; } $result = array(); $jobList = $infoXML->SelectNodes("/control/JobList"); if (is_object($jobList)) { $jobEntries = $jobList->elementsByName("JobEntry"); foreach ($jobEntries as $jobEntry) { $info = array(); foreach ($jobEntry->children() as $field) { $name = $field->name(); $value = $field->textContent(); $info[$name] = $value; } $result[] = array("URL" => $info["Url"], "TIME" => $info["Time"], "WEEK_DAYS" => explode(",", $info["WeekDays"]), "STATUS" => $info["Status"], "FINISH_TIME" => $info["FinishTime"]); } } return $result; }
/** * Loads and parses xml * * @return void * */ private function _getInformation($force = false) { if ($this->init && !$force) { return; } $this->init = true; $web_service = new CBitrixCloudBackupWebService(); $this->infoXML = $web_service->actionGetInformation(); $node = $this->infoXML->SelectNodes("/control/quota/allow"); if (is_object($node)) { $this->quota = CBitrixCloudCDNQuota::parseSize($node->textContent()); } $node = $this->infoXML->SelectNodes("/control/files"); if (is_object($node)) { $this->last_backup_time = 0; $this->total_size = 0.0; $this->files = array(); $nodeFiles = $node->elementsByName("file"); foreach ($nodeFiles as $nodeFile) { $size = CBitrixCloudCDNQuota::parseSize($nodeFile->getAttribute("size")); $name = $nodeFile->getAttribute("name"); $this->total_size += $size; $this->files[] = array("FILE_NAME" => $name, "FILE_SIZE" => $size); $time = strtotime(preg_replace('/^(\\d{4})(\\d\\d)(\\d\\d)_(\\d\\d)(\\d\\d)(\\d\\d)(.*)$/', '\\1-\\2-\\3 \\4:\\5:\\6', $name)); if ($time > $this->last_backup_time) { $this->last_backup_time = $time; } } } }