Beispiel #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;
 }