/** * * @return CDataXML * @throws CBitrixCloudException */ public function actionStart($domain, $is_https, $language_id, $emails, $tests) { $this->addStr = ""; $this->addParams = array("domain" => $domain, "domain_is_https" => $is_https ? "Y" : "N", "lang" => $language_id); if (is_array($emails)) { foreach ($emails as $email) { $email = trim($email); if (strlen($email) > 0) { $this->addStr .= "&ar_emails[]=" . urlencode($email); } } } if (is_array($tests)) { foreach ($tests as $test) { $test = trim($test); if (strlen($test) > 0) { $this->addStr .= "&ar_tests[]=" . urlencode($test); } } } $option = CBitrixCloudOption::getOption('monitoring_devices'); $devices = $option->getArrayValue(); foreach ($devices as $domain_device) { if (list($myDomain, $myDevice) = explode("|", $domain_device, 2)) { if ($myDomain === $domain) { $this->addStr .= "&ar_devices[]=" . urlencode($myDevice); } } } $this->monitoring_action("monitoring_start"); }
/** * 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; }
/** * Shows information about CDN free space in Admin's informer popup * * @return void */ public function OnAdminInformerInsertItems() { $CDNAIParams = array("TITLE" => GetMessage("BCL_BACKUP_AI_TITLE"), "COLOR" => "peach"); $backup = self::getInstance(); $backup->loadFromOptions(); $last_request_time_option = CBitrixCloudOption::getOption("backup_last_backup_time"); try { if ($backup->getQuota() <= 0 && $last_request_time_option->getIntegerValue() <= 0) { $backup->_getInformation(true); $backup->saveToOptions(); $last_request_time_option->setStringValue((string) time()); } } catch (CBitrixCloudException $e) { ///TODO show error to user return; } if ($backup->getQuota() <= 0) { return; } $arFiles = $backup->listFiles(); if (empty($arFiles)) { $PROGRESS_FREE = 100; $AVAIL = $backup->getQuota(); $ALLOWED = CFile::FormatSize($backup->getQuota(), 0); $CDNAIParams["ALERT"] = true; $MESS = '<span class="adm-informer-strong-text">' . GetMessage("BCL_BACKUP_AI_NO_FILES") . '</span>'; $CDNAIParams["FOOTER"] = '<a href="/bitrix/admin/dump.php?lang=' . LANGUAGE_ID . '">' . GetMessage("BCL_BACKUP_AI_DO_BACKUP_STRONGLY") . '</a>'; } elseif ($backup->getLastTimeBackup() < time() - 7 * 24 * 3600) { $AVAIL = $backup->getQuota() - $backup->getUsage(); if ($AVAIL < 0.0) { $AVAIL = 0.0; } $PROGRESS_FREE = round($AVAIL / $backup->getQuota() * 100); $ALLOWED = CFile::FormatSize($backup->getQuota(), 0); $CDNAIParams["ALERT"] = true; $MESS = '<span class="adm-informer-strong-text">' . GetMessage("BCL_BACKUP_AI_LAST_TIME") . ': ' . FormatDate(array("today" => "today", "yesterday" => "yesterday", "" => "dago"), $backup->getLastTimeBackup()) . '.</span>'; $CDNAIParams["FOOTER"] = '<a href="/bitrix/admin/dump.php?lang=' . LANGUAGE_ID . '">' . GetMessage("BCL_BACKUP_AI_DO_BACKUP_STRONGLY") . '</a>'; } else { $AVAIL = $backup->getQuota() - $backup->getUsage(); if ($AVAIL < 0.0) { $AVAIL = 0.0; } $PROGRESS_FREE = round($AVAIL / $backup->getQuota() * 100); $ALLOWED = CFile::FormatSize($backup->getQuota(), 0); $CDNAIParams["ALERT"] = false; $MESS = GetMessage("BCL_BACKUP_AI_LAST_TIME") . ': ' . FormatDate(array("today" => "today", "yesterday" => "yesterday", "" => "dago"), $backup->getLastTimeBackup()); $CDNAIParams["FOOTER"] = '<a href="/bitrix/admin/dump.php?lang=' . LANGUAGE_ID . '">' . GetMessage("BCL_BACKUP_AI_DO_BACKUP") . '</a>'; } if (isset($CDNAIParams["ALERT"])) { $PROGRESS_FREE_BAR = $PROGRESS_FREE < 0 ? 0 : $PROGRESS_FREE; $CDNAIParams["HTML"] = ' <div class="adm-informer-item-section"> <span class="adm-informer-item-l"> <span class="adm-informer-strong-text">' . GetMessage("BCL_BACKUP_AI_USAGE_TOTAL") . '</span> ' . $ALLOWED . ' </span> <span class="adm-informer-item-r"> <span class="adm-informer-strong-text">' . GetMessage("BCL_BACKUP_AI_USAGE_AVAIL") . '</span> ' . CFile::FormatSize($AVAIL, 0) . ' </span> </div> <div class="adm-informer-status-bar-block" > <div class="adm-informer-status-bar-indicator" style="width:' . (100 - $PROGRESS_FREE_BAR) . '%; "></div> <div class="adm-informer-status-bar-text">' . (100 - $PROGRESS_FREE) . '%</div> </div> ' . $MESS; CAdminInformer::AddItem($CDNAIParams); } }
public function saveToOptions() { $domainNames = array_keys($this->domains); CBitrixCloudOption::getOption("monitoring_result")->setArrayValue($domainNames); foreach ($domainNames as $i => $domainName) { $this->domains[$domainName]->saveToOptions(CBitrixCloudOption::getOption("monitoring_result_{$i}")); } }
public function storeAlertsCurrentResult() { $alerts = $this->getAlertsCurrentResult(); if (is_array($alerts)) { CBitrixCloudOption::getOption("monitoring_alert")->setArrayValue($alerts); } }