Exemplo n.º 1
0
 /**
  * Loads and parses xml
  *
  * @param boolean $sendAdditionalInfo Flag to send https and optimize parameters.
  *
  * @return CBitrixCloudCDNConfig
  * @throws CBitrixCloudException
  */
 public function loadRemoteXML($sendAdditionalInfo = false)
 {
     //Get configuration from remote service
     $this->sites = CBitrixCloudOption::getOption("cdn_config_site")->getArrayValue();
     $this->domain = CBitrixCloudOption::getOption("cdn_config_domain")->getStringValue();
     if ($sendAdditionalInfo) {
         $this->https = CBitrixCloudOption::getOption("cdn_config_https")->getStringValue() === "true";
         $this->optimize = CBitrixCloudOption::getOption("cdn_config_optimize")->getStringValue() === "true";
     }
     $web_service = new CBitrixCloudCDNWebService($this->domain, $this->optimize, $this->https);
     $web_service->setDebug($this->debug);
     $obXML = $web_service->actionGetConfig();
     //
     // Parse it
     //
     $node = $obXML->SelectNodes("/control");
     if (is_object($node)) {
         $this->active = intval($node->getAttribute("active"));
         $this->expires = strtotime($node->getAttribute("expires"));
     } else {
         $this->active = 0;
         $this->expires = 0;
     }
     $node = $obXML->SelectNodes("/control/quota");
     if (is_object($node)) {
         $this->quota = CBitrixCloudCDNQuota::fromXMLNode($node);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "2")));
     }
     $node = $obXML->SelectNodes("/control/classes");
     if (is_object($node)) {
         $this->classes = CBitrixCloudCDNClasses::fromXMLNode($node);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "3")));
     }
     $node = $obXML->SelectNodes("/control/servergroups");
     if (is_object($node)) {
         $this->server_groups = CBitrixCloudCDNServerGroups::fromXMLNode($node);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "4")));
     }
     $node = $obXML->SelectNodes("/control/locations");
     if (is_object($node)) {
         $this->locations = CBitrixCloudCDNLocations::fromXMLNode($node, $this);
     } else {
         throw new CBitrixCloudException(GetMessage("BCL_CDN_CONFIG_XML_PARSE", array("#CODE#" => "5")));
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  *
  * @return void
  * @throws CBitrixCloudException
  */
 private static function stop()
 {
     $o = CBitrixCloudCDNConfig::getInstance()->loadFromOptions();
     $a = new CBitrixCloudCDNWebService($o->getDomain());
     $a->actionStop();
 }