예제 #1
0
 /**
  * Loads and parses xml
  *
  * @param bool $force
  * @return bool
  *
  */
 private function _getInformation($force = false)
 {
     if ($this->init && !$force) {
         return true;
     }
     $this->init = true;
     try {
         $web_service = new CBitrixCloudBackupWebService();
         $web_service->setTimeout(10);
         $this->infoXML = $web_service->actionGetInformation();
     } catch (CBitrixCloudException $e) {
         return false;
     }
     $node = null;
     $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) {
             /* @var CDataXMLNode $nodeFile */
             $size = CBitrixCloudCDNQuota::parseSize($nodeFile->getAttribute("size"));
             $name = $nodeFile->getAttribute("name");
             $this->total_size += $size;
             $this->files[] = array("FILE_NAME" => $name, "FILE_SIZE" => (string) $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;
             }
         }
     }
     return true;
 }
예제 #2
0
 /**
  * Loads configuration from CBitrixCloudOption
  *
  * @return CBitrixCloudCDNConfig
  *
  */
 public function loadFromOptions()
 {
     $this->active = intval(CBitrixCloudOption::getOption("cdn_config_active")->getStringValue());
     $this->expires = intval(CBitrixCloudOption::getOption("cdn_config_expire_time")->getStringValue());
     $this->domain = CBitrixCloudOption::getOption("cdn_config_domain")->getStringValue();
     $this->sites = CBitrixCloudOption::getOption("cdn_config_site")->getArrayValue();
     $this->quota = CBitrixCloudCDNQuota::fromOption(CBitrixCloudOption::getOption("cdn_config_quota"));
     $this->classes = CBitrixCloudCDNClasses::fromOption(CBitrixCloudOption::getOption("cdn_class"));
     $this->server_groups = CBitrixCloudCDNServerGroups::fromOption(CBitrixCloudOption::getOption("cdn_server_group"));
     $this->locations = CBitrixCloudCDNLocations::fromOption(CBitrixCloudOption::getOption("cdn_location"), $this);
     return $this;
 }
예제 #3
0
 /**
  *
  * @param CBitrixCloudOption $option
  * @return CBitrixCloudCDNQuota
  *
  */
 public static function fromOption(CBitrixCloudOption $option)
 {
     $quota = new CBitrixCloudCDNQuota();
     $values = $option->getArrayValue();
     $quota->setExpires(intval($values["expires"]));
     $quota->setAllowedSize(doubleval($values["allow"]));
     $quota->setTrafficSize(doubleval($values["traffic"]));
     return $quota;
 }