public static function getDefaultSiteId() { static $result = null; if ($result === null) { $res = \Bitrix\Main\SiteTable::getList(array('filter' => array('DEF' => 'Y'), 'select' => array('LID'))); if ($item = $res->fetch()) { $result = $item['LID']; } } return $result; }
public static function getParamsStructure() { $siteList = array(); $rsSite = \Bitrix\Main\SiteTable::getList(); while ($site = $rsSite->fetch()) { $siteList[$site["LID"]] = $site["NAME"] . " (" . $site["LID"] . ")"; } return array("SITE_ID" => array("TYPE" => "ENUM", 'MULTIPLE' => 'Y', "DEFAULT" => SITE_ID, "LABEL" => Loc::getMessage("SALE_DLVR_RSTR_BY_SITE_SITE_ID"), "OPTIONS" => $siteList)); }
public static function delete($id) { //We know for sure that languages and sites can refer to the culture. //Other entities should place CultureOnBeforeDelete event handler. $result = new Entity\DeleteResult(); $res = LanguageTable::getList(array('filter' => array('=CULTURE_ID' => $id))); while ($language = $res->fetch()) { $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_lang", array("#LID#" => $language["LID"])))); } $res = \Bitrix\Main\SiteTable::getList(array('filter' => array('=CULTURE_ID' => $id))); while ($site = $res->fetch()) { $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_site", array("#LID#" => $site["LID"])))); } if (!$result->isSuccess()) { return $result; } return parent::delete($id); }
function acrit_exportpro() { require __DIR__ . '/version.php'; $path = str_replace("\\", "/", __FILE__); $path = substr($path, 0, strlen($path) - strlen("/index.php")); include $path . "/version.php"; if (is_array($arModuleVersion) && array_key_exists("VERSION", $arModuleVersion)) { $this->MODULE_VERSION = $arModuleVersion["VERSION"]; $this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"]; } $this->MODULE_NAME = GetMessage('ACRIT_EXPORTPRO_MODULE_NAME'); $this->MODULE_DESCRIPTION = GetMessage('ACRIT_EXPORTPRO_MODULE_DESC'); $this->PARTNER_NAME = GetMessage("ACRIT_EXPORTPRO_PARTNER_NAME"); $this->PARTNER_URI = GetMessage("ACRIT_EXPORTPRO_PARTNER_URI"); $app = \Bitrix\Main\Application::getInstance(); $dbSite = \Bitrix\Main\SiteTable::getList(); while ($arSite = $dbSite->Fetch()) { if (!$arSite['DOC_ROOT']) { $this->siteArray[$arSite['LID']] = $app->getDocumentRoot() . $arSite['DIR']; } else { $this->siteArray[$arSite['LID']] = $arSite['DOC_ROOT']; } $this->siteArray[$arSite['LID']] = \Bitrix\Main\IO\Path::normalize($this->siteArray[$arSite['LID']]); } }
/** * @param string $dbName * @return array List of all sites & their params */ public static function getList($dbName = false) { if (!$dbName) { $connection = \Bitrix\Main\Application::getConnection(); $dbName = $connection->getDbName(); } $result = array(); $shellAdapter = new ShellAdapter(); $execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/bx-sites -o json -a list -d " . $dbName); $sitesData = $shellAdapter->getLastOutput(); if ($execRes) { $arData = json_decode($sitesData, true); if (isset($arData["params"])) { $result = $arData["params"]; } $rsSite = \Bitrix\Main\SiteTable::getList(); while ($site = $rsSite->fetch()) { foreach ($result as $siteId => $siteInfo) { $docRoot = strlen($site["DOC_ROOT"]) > 0 ? $site["DOC_ROOT"] : \Bitrix\Main\Application::getDocumentRoot(); if ($siteInfo["DocumentRoot"] == $docRoot) { $result[$siteId]["NAME"] = $site["NAME"] . " (" . $site["LID"] . ") "; } else { $result[$siteId]["NAME"] = $siteId; } } } } return $result; }
public function __construct($fileName, $settings) { $this->settings = array( 'SITE_ID' => $settings['SITE_ID'], 'PROTOCOL' => $settings['PROTOCOL'] == 'https' ? 'https' : 'http', 'DOMAIN' => $settings['DOMAIN'], ); $site = SiteTable::getRow(array("filter" => array("LID" => $this->settings['SITE_ID']))); $this->siteRoot = Path::combine( SiteTable::getDocumentRoot($this->settings['SITE_ID']), $site['DIR'] ); if(substr($fileName, -strlen(self::FILE_EXT)) != self::FILE_EXT) { $fileName .= self::FILE_EXT; } if($this->partFile == '') { $this->partFile = $fileName; } $this->pathPhysical = null; // hack for object reconstuct during file splitting parent::__construct($this->siteRoot.'/'.$fileName, $this->settings['SITE_ID']); $this->partChanged = $this->isExists() && !$this->isSplitNeeded(); }
function seoSitemapGetFilesData($PID, $arSitemap, $arCurrentDir, $sitemapFile) { global $NS; $arDirList = array(); if ($arCurrentDir['ACTIVE'] == SitemapRuntimeTable::ACTIVE) { $list = \CSeoUtils::getDirStructure($arSitemap['SETTINGS']['logical'] == 'Y', $arSitemap['SITE_ID'], $arCurrentDir['ITEM_PATH']); foreach ($list as $dir) { $dirKey = "/" . ltrim($dir['DATA']['ABS_PATH'], "/"); if ($dir['TYPE'] == 'F') { if (!isset($arSitemap['SETTINGS']['FILE'][$dirKey]) || $arSitemap['SETTINGS']['FILE'][$dirKey] == 'Y') { if (preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $dir['FILE'])) { $f = new IO\File($dir['DATA']['PATH'], $arSitemap['SITE_ID']); $sitemapFile->addFileEntry($f); $NS['files_count']++; } } } else { if (!isset($arSitemap['SETTINGS']['DIR'][$dirKey]) || $arSitemap['SETTINGS']['DIR'][$dirKey] == 'Y') { $arDirList[] = $dirKey; } } } } else { $len = strlen($arCurrentDir['ITEM_PATH']); if (!empty($arSitemap['SETTINGS']['DIR'])) { foreach ($arSitemap['SETTINGS']['DIR'] as $dirKey => $checked) { if ($checked == 'Y') { if (strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0) { $arDirList[] = $dirKey; } } } } if (!empty($arSitemap['SETTINGS']['FILE'])) { foreach ($arSitemap['SETTINGS']['FILE'] as $dirKey => $checked) { if ($checked == 'Y') { if (strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0) { $fileName = IO\Path::combine(SiteTable::getDocumentRoot($arSitemap['SITE_ID']), $dirKey); if (!is_dir($fileName)) { $f = new IO\File($fileName, $arSitemap['SITE_ID']); if ($f->isExists() && !$f->isSystem() && preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $f->getName())) { $sitemapFile->addFileEntry($f); $NS['files_count']++; } } } } } } } if (count($arDirList) > 0) { foreach ($arDirList as $dirKey) { $arRuntimeData = array('PID' => $PID, 'ITEM_PATH' => $dirKey, 'PROCESSED' => SitemapRuntimeTable::UNPROCESSED, 'ACTIVE' => SitemapRuntimeTable::ACTIVE, 'ITEM_TYPE' => SitemapRuntimeTable::ITEM_TYPE_DIR); SitemapRuntimeTable::add($arRuntimeData); } } SitemapRuntimeTable::update($arCurrentDir['ID'], array('PROCESSED' => SitemapRuntimeTable::PROCESSED)); }
/** * Returns urlrewrite array * * @param string $site Site ID. * @return array */ private static function getRewriteRules($site) { $docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/'); $rewriteRules = array(); $arUrlRewrite =& $rewriteRules; $rewriteFile = new \Bitrix\Main\IO\File($docRoot . '/urlrewrite.php'); if ($rewriteFile->isExists()) { include $rewriteFile->getPath(); } return $rewriteRules; }
public function installBitrix24MailService() { if (CModule::IncludeModule("mail")) { $result = \Bitrix\Main\SiteTable::getList(); while (($site = $result->fetch()) !== false) { if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite($site['LID'])) { continue; } \Bitrix\Mail\MailServicesTable::add(array('SITE_ID' => $site['LID'], 'ACTIVE' => 'Y', 'NAME' => 'bitrix24', 'SERVICE_TYPE' => 'controller')); } } }
public function __construct($path, $siteId = null) { if (empty($path)) { throw new InvalidPathException($path); } $this->originalPath = $path; $this->path = Path::normalize($path); if ($siteId === null) { $this->documentRoot = Main\Application::getDocumentRoot(); } else { $this->documentRoot = Main\SiteTable::getDocumentRoot($siteId); } if (empty($this->path)) { throw new InvalidPathException($path); } }
public static function checkFields(Entity\Result $result, $primary, array $data) { parent::checkFields($result, $primary, $data); if (isset($data['SITE_ID'])) { $selectResult = \Bitrix\Main\SiteTable::getByPrimary($data['SITE_ID']); if (!$selectResult->fetch()) { $field = static::getEntity()->getField('SITE_ID'); $result->addError(new Entity\FieldError($field, Localization\Loc::getMessage('MAIN_ENTITY_FIELD_INVALID', array('#FIELD_TITLE#' => $field->getTitle())), Entity\FieldError::INVALID_VALUE)); } } if (!empty($data['ICON'])) { if (!is_scalar($data['ICON']) || !preg_match('/[0-9]+/', $data['ICON'])) { $field = static::getEntity()->getField('ICON'); $result->addError(new Entity\FieldError($field, Localization\Loc::getMessage('MAIN_ENTITY_FIELD_INVALID', array('#FIELD_TITLE#' => $field->getTitle())), Entity\FieldError::INVALID_VALUE)); } } return $result; }
public static function getDocumentRoot($siteId = null) { if ($siteId === null) { $context = Application::getInstance()->getContext(); $siteId = $context->getSite(); } if (!isset(self::$documentRootCache[$siteId])) { $ar = SiteTable::getRow(array("filter" => array("LID" => $siteId))); if ($ar && ($docRoot = $ar["DOC_ROOT"]) && strlen($docRoot) > 0) { if (!IO\Path::isAbsolute($docRoot)) { $docRoot = IO\Path::combine(Application::getDocumentRoot(), $docRoot); } self::$documentRootCache[$siteId] = $docRoot; } else { self::$documentRootCache[$siteId] = Application::getDocumentRoot(); } } return self::$documentRootCache[$siteId]; }
protected function initializeSite() { $request = $this->getRequest(); $currentDirectory = $request->getRequestedPageDirectory(); $currentDomain = $request->getHttpHost(false); $site = SiteTable::getByDomainAndPath($currentDomain, $currentDirectory); if ($site === false) { $siteList = SiteTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC'), 'select' => array('*', 'ID' => 'LID'))); $site = $siteList->fetch(); } if ($site === false) { throw new SystemException("Site not found"); } $culture = Context\Culture::wakeUp($site["CULTURE_ID"]); if ($culture === null) { $culture = new Context\Culture(); } $this->site = new Context\Site($site); $this->site->setCulture($culture); $this->setContextCulture($culture, $this->site->getLanguage()); }
protected static function actionAdd($name, $arFields) { if ($name == 'ADDELEMENT') { if (!self::checkElement($arFields)) { return; } // we don't have the GLOBAL_ACTIVE flag in $arFields so we should check it manually if (is_array($arFields['IBLOCK_SECTION']) && count($arFields['IBLOCK_SECTION']) > 0) { $arNewSections = array(); $arFilter = array('ID' => $arFields['IBLOCK_SECTION'], 'IBLOCK_ID' => $arFields['IBLOCK_ID'], 'GLOBAL_ACTIVE' => 'Y'); $dbRes = \CIBlockSection::getList(array(), $arFilter, false, array('ID')); while ($ar = $dbRes->fetch()) { $arNewSections[] = $ar['ID']; } if (count($arNewSections) <= 0) { // element is added to inactive sections return; } $arFields['IBLOCK_SECTION'] = $arNewSections; } } elseif ($name == 'ADDSECTION') { $dbRes = \CIBlockSection::getList(array(), array('ID' => $arFields['ID'], 'GLOBAL_ACTIVE' => 'Y'), false, array('ID')); if (!$dbRes->fetch()) { // section is added to inactive branch return; } } $arSitemaps = SitemapIblockTable::getByIblock($arFields, $name == 'ADDSECTION' ? SitemapIblockTable::TYPE_SECTION : SitemapIblockTable::TYPE_ELEMENT); $arFields['TIMESTAMP_X'] = ConvertTimeStamp(false, "FULL"); if (isset($arFields['IBLOCK_SECTION']) && is_array($arFields['IBLOCK_SECTION']) && count($arFields['IBLOCK_SECTION']) > 0) { $arFields['IBLOCK_SECTION_ID'] = min($arFields['IBLOCK_SECTION']); } if (count($arSitemaps) > 0) { $arSiteDirs = array(); $dbSite = SiteTable::getList(array('select' => array('LID', 'DIR'))); while ($arSite = $dbSite->fetch()) { $arSiteDirs[$arSite['LID']] = $arSite['DIR']; } foreach ($arSitemaps as $arSitemap) { $arFields['LANG_DIR'] = $arSiteDirs[$arSitemap['SITE_ID']]; $rule = array('url' => $name == 'ADDSECTION' ? \CIBlock::replaceDetailUrl($arSitemaps[0]['SECTION_PAGE_URL'], $arFields, false, "S") : \CIBlock::replaceDetailUrl($arSitemaps[0]['DETAIL_PAGE_URL'], $arFields, false, "E"), 'lastmod' => MakeTimeStamp($arFields['TIMESTAMP_X'])); $fileName = str_replace(array('#IBLOCK_ID#', '#IBLOCK_CODE#', '#IBLOCK_XML_ID#'), array($arFields['IBLOCK_ID'], $arSitemap['IBLOCK_CODE'], $arSitemap['IBLOCK_XML_ID']), $arSitemap['SITEMAP_FILE_IBLOCK']); $sitemapFile = new SitemapFile($fileName, $arSitemap); $sitemapFile->appendIblockEntry($rule['url'], $rule['lastmod']); $sitemapIndex = new SitemapIndex($arSitemap['SITEMAP_FILE'], $arSitemap); $sitemapIndex->appendIndexEntry($sitemapFile); if ($arSitemap['ROBOTS'] == 'Y') { $robotsFile = new RobotsFile($arSitemap['SITE_ID']); $robotsFile->addRule(array(RobotsFile::SITEMAP_RULE, $sitemapIndex->getUrl())); } } } }
function InstallDB() { global $APPLICATION; global $DB; global $errors; $bitrix24 = ModuleManager::isModuleInstalled('bitrix24'); if (!$DB->Query("SELECT 'x' FROM b_catalog_group", true)) { $errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/catalog/install/db/" . strtolower($DB->type) . "/install.sql"); } if (!empty($errors)) { $APPLICATION->ThrowException(implode("", $errors)); return false; } ModuleManager::registerModule('catalog'); $eventManager = \Bitrix\Main\EventManager::getInstance(); $eventManager->registerEventHandler('sale', 'onBuildCouponProviders', 'catalog', '\\Bitrix\\Catalog\\DiscountCouponTable', 'couponManager'); RegisterModuleDependences("iblock", "OnIBlockDelete", "catalog", "CCatalog", "OnIBlockDelete"); RegisterModuleDependences("iblock", "OnIBlockElementDelete", "catalog", "CCatalogProduct", "OnIBlockElementDelete"); RegisterModuleDependences("iblock", "OnIBlockElementDelete", "catalog", "CPrice", "OnIBlockElementDelete"); RegisterModuleDependences("iblock", "OnIBlockElementDelete", "catalog", "CCatalogStoreProduct", "OnIBlockElementDelete"); RegisterModuleDependences("iblock", "OnIBlockElementDelete", "catalog", "CCatalogDocs", "OnIBlockElementDelete"); RegisterModuleDependences("iblock", "OnBeforeIBlockElementDelete", "catalog", "CCatalogDocs", "OnBeforeIBlockElementDelete"); RegisterModuleDependences("currency", "OnCurrencyDelete", "catalog", "CPrice", "OnCurrencyDelete"); RegisterModuleDependences("main", "OnGroupDelete", "catalog", "CCatalogProductGroups", "OnGroupDelete"); RegisterModuleDependences("iblock", "OnAfterIBlockElementUpdate", "catalog", "CCatalogProduct", "OnAfterIBlockElementUpdate"); RegisterModuleDependences("currency", "OnModuleUnInstall", "catalog", "", "CurrencyModuleUnInstallCatalog"); RegisterModuleDependences("iblock", "OnBeforeIBlockDelete", "catalog", "CCatalog", "OnBeforeCatalogDelete", 300); RegisterModuleDependences("iblock", "OnBeforeIBlockElementDelete", "catalog", "CCatalog", "OnBeforeIBlockElementDelete", 10000); RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "catalog", "CCatalogEvent", "GetAuditTypes"); RegisterModuleDependences('main', 'OnBuildGlobalMenu', 'catalog', 'CCatalogAdmin', 'OnBuildGlobalMenu'); RegisterModuleDependences('main', 'OnAdminListDisplay', 'catalog', 'CCatalogAdmin', 'OnAdminListDisplay'); RegisterModuleDependences('main', 'OnBuildGlobalMenu', 'catalog', 'CCatalogAdmin', 'OnBuildSaleMenu'); RegisterModuleDependences("catalog", "OnCondCatControlBuildList", "catalog", "CCatalogCondCtrlGroup", "GetControlDescr", 100); RegisterModuleDependences("catalog", "OnCondCatControlBuildList", "catalog", "CCatalogCondCtrlIBlockFields", "GetControlDescr", 200); RegisterModuleDependences("catalog", "OnCondCatControlBuildList", "catalog", "CCatalogCondCtrlIBlockProps", "GetControlDescr", 300); RegisterModuleDependences("catalog", "OnDocumentBarcodeDelete", "catalog", "CCatalogStoreDocsElement", "OnDocumentBarcodeDelete"); RegisterModuleDependences("catalog", "OnBeforeDocumentDelete", "catalog", "CCatalogStoreDocsBarcode", "OnBeforeDocumentDelete"); RegisterModuleDependences("catalog", "OnCatalogStoreDelete", "catalog", "CCatalogDocs", "OnCatalogStoreDelete"); RegisterModuleDependences("iblock", "OnBeforeIBlockPropertyDelete", "catalog", "CCatalog", "OnBeforeIBlockPropertyDelete"); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "catalog", "CCatalogCondCtrlBasketProductFields", "GetControlDescr", 1100); RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "catalog", "CCatalogCondCtrlBasketProductProps", "GetControlDescr", 1200); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "catalog", "CCatalogActionCtrlBasketProductFields", "GetControlDescr", 1200); RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "catalog", "CCatalogActionCtrlBasketProductProps", "GetControlDescr", 1300); RegisterModuleDependences("sale", "OnExtendBasketItems", "catalog", "CCatalogDiscount", "ExtendBasketItems", 100); RegisterModuleDependences('iblock', 'OnModuleUnInstall', 'catalog', 'CCatalog', 'OnIBlockModuleUnInstall'); if (!$bitrix24) { CAgent::AddAgent('\\Bitrix\\Catalog\\CatalogViewedProductTable::clearAgent();', 'catalog', 'N', (int) COption::GetOptionString("catalog", "viewed_period") * 24 * 3600); } $this->InstallTasks(); $arCount = $DB->Query("select count(ID) as COUNT from b_catalog_measure", true)->Fetch(); if (is_array($arCount) && isset($arCount['COUNT']) && intval($arCount['COUNT']) <= 0) { $DB->Query("insert into b_catalog_measure (CODE, SYMBOL_INTL, SYMBOL_LETTER_INTL, IS_DEFAULT) values(6, 'm', 'MTR', 'N')", true); $DB->Query("insert into b_catalog_measure (CODE, SYMBOL_INTL, SYMBOL_LETTER_INTL, IS_DEFAULT) values(112, 'l', 'LTR', 'N')", true); $DB->Query("insert into b_catalog_measure (CODE, SYMBOL_INTL, SYMBOL_LETTER_INTL, IS_DEFAULT) values(163, 'g', 'GRM', 'N')", true); $DB->Query("insert into b_catalog_measure (CODE, SYMBOL_INTL, SYMBOL_LETTER_INTL, IS_DEFAULT) values(166, 'kg', 'KGM', 'N')", true); $DB->Query("insert into b_catalog_measure (CODE, SYMBOL_INTL, SYMBOL_LETTER_INTL, IS_DEFAULT) values(796, 'pc. 1', 'PCE. NMB', 'Y')", true); } if (!$bitrix24) { $languageID = ''; $siteIterator = SiteTable::getList(array('select' => array('LID', 'LANGUAGE_ID'), 'filter' => array('=DEF' => 'Y', '=ACTIVE' => 'Y'))); if ($site = $siteIterator->fetch()) { $languageID = (string) $site['LANGUAGE_ID']; } if ($languageID == '') { $languageID = 'en'; } if ($languageID == 'ru') { $mess = Loc::getMessage('CATALOG_INSTALL_PROFILE_IRR2', null, 'ru'); if ($mess == '') { $mess = 'irr.ru'; } $strQuery = "select COUNT(CE.ID) as CNT from b_catalog_export CE where CE.IS_EXPORT = 'Y' and CE.FILE_NAME ='yandex' and CE.NAME = '" . $DB->ForSql($mess) . "'"; $rsProfiles = $DB->Query($strQuery, true); if (false !== $rsProfiles) { $arProfile = $rsProfiles->Fetch(); if ((int) $arProfile['CNT'] == 0) { $arFields = array('FILE_NAME' => 'yandex', 'NAME' => $mess, 'DEFAULT_PROFILE' => 'N', 'IN_MENU' => 'N', 'IN_AGENT' => 'N', 'IN_CRON' => 'N', 'NEED_EDIT' => 'Y', 'IS_EXPORT' => 'Y'); $arInsert = $DB->PrepareInsert("b_catalog_export", $arFields); $strQuery = "INSERT INTO b_catalog_export(" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")"; $DB->Query($strQuery, true); } } } } return true; }
private static function checkSiteId($siteId) { $siteId = Assert::expectStringNotNull($siteId, '$siteId'); $res = Main\SiteTable::getList(array('filter' => array('LID' => $siteId)))->fetch(); if (!$res) { throw new Main\ArgumentOutOfRangeException(Loc::getMessage('SALE_LOCATION_DEFAULTSITE_ENTITY_SITE_ID_UNKNOWN_EXCEPTION')); } return $siteId; }
function Update($ID, $arFields) { global $DB; if (!$this->CheckFields($arFields, $ID)) { return false; } if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") { $arFields["ACTIVE"] = "N"; } $arLID = array(); if (is_set($arFields, "LID")) { if (is_array($arFields["LID"])) { $arLID = $arFields["LID"]; } else { $arLID[] = $arFields["LID"]; } $arFields["LID"] = false; foreach ($arLID as $v) { $arFields["LID"] = $v; } } $arATTACHMENT_FILE = array(); if (is_set($arFields, "ATTACHMENT_FILE")) { if (is_array($arFields["ATTACHMENT_FILE"])) { $arATTACHMENT_FILE = $arFields["ATTACHMENT_FILE"]; } else { $arATTACHMENT_FILE[] = $arFields["ATTACHMENT_FILE"]; } $arATTACHMENT_FILE_tmp = array(); foreach ($arATTACHMENT_FILE as $v) { $v = intval($v); $arATTACHMENT_FILE_tmp[] = $v; } $arATTACHMENT_FILE = $arATTACHMENT_FILE_tmp; unset($arFields['ATTACHMENT_FILE']); } if (array_key_exists('NAME', $arFields)) { unset($arFields['NAME']); } $ID = intval($ID); Mail\Internal\EventMessageTable::update($ID, $arFields); if (count($arLID) > 0) { Mail\Internal\EventMessageSiteTable::delete($ID); $resultDb = \Bitrix\Main\SiteTable::getList(array('select' => array('LID'), 'filter' => array('LID' => $arLID))); while ($arResultSite = $resultDb->fetch()) { Mail\Internal\EventMessageSiteTable::add(array('EVENT_MESSAGE_ID' => $ID, 'SITE_ID' => $arResultSite['LID'])); } } if (count($arATTACHMENT_FILE) > 0) { foreach ($arATTACHMENT_FILE as $file_id) { Mail\Internal\EventMessageAttachmentTable::add(array('EVENT_MESSAGE_ID' => $ID, 'FILE_ID' => $file_id)); } } return true; }
} $dbRes = SitemapEntityTable::getList(array("filter" => array("SITEMAP_ID" => $ID))); while ($arRes = $dbRes->fetch()) { if (!is_array($arSitemap['SETTINGS'][$arRes["ENTITY_TYPE"] . '_AUTO'])) { $arSitemap['SETTINGS'][$arRes["ENTITY_TYPE"] . '_AUTO'] = array(); } $arSitemap['SETTINGS'][$arRes["ENTITY_TYPE"] . '_AUTO'][$arRes['ENTITY_ID']] = 'Y'; } if (empty($arSitemap['SETTINGS']['FILENAME_FORUM'])) { $arSitemap['SETTINGS']['FILENAME_FORUM'] = "sitemap_forum_#FORUM_ID#.xml"; } $SITE_ID = $arSitemap['SITE_ID']; } } if (strlen($SITE_ID) > 0) { $dbSite = Main\SiteTable::getByPrimary($SITE_ID); $arSite = $dbSite->fetch(); if (!is_array($arSite)) { $SITE_ID = ''; } else { $arSite['DOMAINS'] = array(); $robotsFile = new RobotsFile($SITE_ID); if ($robotsFile->isExists()) { $arHostsList = $robotsFile->getRules('Host'); foreach ($arHostsList as $rule) { $host = $rule[1]; if (strncmp($host, 'https://', 8) === 0) { $host = substr($host, 8); $bDefaultHttps = true; } $arSite['DOMAINS'][] = $host;
/** * @param $mailingChainId * @param array $params * @return string * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\DB\Exception */ protected static function sendInternal($mailingChainId, array $params) { if (static::$currentMailingChainFields !== null) { if (static::$currentMailingChainFields['ID'] != $mailingChainId) { static::$currentMailingChainFields = null; } } if (static::$currentMailingChainFields === null) { $mailingChainDb = MailingChainTable::getList(array('select' => array('*', 'SITE_ID' => 'MAILING.SITE_ID'), 'filter' => array('ID' => $mailingChainId))); if (!($mailingChain = $mailingChainDb->fetch())) { return PostingRecipientTable::SEND_RESULT_ERROR; } $charset = false; $siteDb = \Bitrix\Main\SiteTable::getList(array('select' => array('SERVER_NAME', 'NAME', 'CULTURE_CHARSET' => 'CULTURE.CHARSET'), 'filter' => array('LID' => $mailingChain['SITE_ID']))); if ($site = $siteDb->fetch()) { $charset = $site['CULTURE_CHARSET']; $serverName = $site['SERVER_NAME']; } else { throw new \Bitrix\Main\DB\Exception(Loc::getMessage('SENDER_POSTING_MANAGER_ERR_SITE', array('#SITE_ID#' => $mailingChain['SITE_ID']))); } if (!$charset) { throw new \Bitrix\Main\DB\Exception(Loc::getMessage('SENDER_POSTING_MANAGER_ERR_CHARSET', array('#SITE_ID#' => "[" . $mailingChain['SITE_ID'] . "]" . $site['NAME']))); } $attachmentList = array(); $attachmentDb = \Bitrix\Sender\MailingAttachmentTable::getList(array('select' => array('FILE_ID'), 'filter' => array('CHAIN_ID' => $mailingChainId))); while ($attachment = $attachmentDb->fetch()) { $attachmentList[] = $attachment['FILE_ID']; } static::$currentMailingChainFields = array(); static::$currentMailingChainFields['EVENT'] = array('FILE' => $attachmentList); static::$currentMailingChainFields['ID'] = $mailingChain['ID']; static::$currentMailingChainFields['MESSAGE'] = array('BODY_TYPE' => 'html', 'EMAIL_FROM' => $mailingChain['EMAIL_FROM'], 'EMAIL_TO' => '#EMAIL_TO#', 'SUBJECT' => $mailingChain['SUBJECT'], 'MESSAGE' => $mailingChain['MESSAGE'], 'MESSAGE_PHP' => \Bitrix\Main\Mail\Internal\EventMessageTable::replaceTemplateToPhp($mailingChain['MESSAGE'])); static::$currentMailingChainFields['SITE'] = array($mailingChain['SITE_ID']); static::$currentMailingChainFields['CHARSET'] = $charset; static::$currentMailingChainFields['SERVER_NAME'] = $serverName; static::$currentMailingChainFields['LINK_PROTOCOL'] = \Bitrix\Main\Config\Option::get("sender", "link_protocol", 'http'); } $messageParams = array('EVENT' => static::$currentMailingChainFields['EVENT'], 'FIELDS' => $params['FIELDS'], 'MESSAGE' => static::$currentMailingChainFields['MESSAGE'], 'SITE' => static::$currentMailingChainFields['SITE'], 'CHARSET' => static::$currentMailingChainFields['CHARSET']); if (!empty($params['FIELDS']['UNSUBSCRIBE_LINK'])) { if (substr($params['FIELDS']['UNSUBSCRIBE_LINK'], 0, 4) !== 'http') { if (!empty(static::$currentMailingChainFields['SERVER_NAME'])) { $serverName = static::$currentMailingChainFields['SERVER_NAME']; } else { $serverName = \Bitrix\Main\Config\Option::get("main", "server_name", $GLOBALS["SERVER_NAME"]); } $linkProtocol = static::$currentMailingChainFields['LINK_PROTOCOL']; $params['FIELDS']['UNSUBSCRIBE_LINK'] = $linkProtocol . '://' . $serverName . $params['FIELDS']['UNSUBSCRIBE_LINK']; } } $message = Mail\EventMessageCompiler::createInstance($messageParams); $message->compile(); $mailHeaders = $message->getMailHeaders(); if (!empty($params['FIELDS']['UNSUBSCRIBE_LINK'])) { $unsubUrl = $params['FIELDS']['UNSUBSCRIBE_LINK']; $mailHeaders['List-Unsubscribe'] = '<' . $unsubUrl . '>'; } // send mail $result = Mail\Mail::send(array('TO' => $message->getMailTo(), 'SUBJECT' => $message->getMailSubject(), 'BODY' => $message->getMailBody(), 'HEADER' => $mailHeaders, 'CHARSET' => $message->getMailCharset(), 'CONTENT_TYPE' => $message->getMailContentType(), 'MESSAGE_ID' => '', 'ATTACHMENT' => $message->getMailAttachment(), 'LINK_PROTOCOL' => static::$currentMailingChainFields['LINK_PROTOCOL'], 'LINK_DOMAIN' => static::$currentMailingChainFields['SERVER_NAME'], 'TRACK_READ' => isset($params['TRACK_READ']) ? $params['TRACK_READ'] : null, 'TRACK_CLICK' => isset($params['TRACK_CLICK']) ? $params['TRACK_CLICK'] : null)); if ($result) { return PostingRecipientTable::SEND_RESULT_SUCCESS; } else { return PostingRecipientTable::SEND_RESULT_ERROR; } }
/** * Returns site traffic capacity * * @param string $id Site ID. * @return array */ public static function getSiteCapacity($id) { $cache = new \CPHPCache(); if ($cache->initCache(time() - strtotime('today'), 'abtest_site_capacity', '/abtest')) { $capacity = $cache->getVars(); } else { if (Loader::includeModule('conversion')) { if ($conversionRates = Conversion\RateManager::getTypes(array('ACTIVE' => true))) { $baseRate = array_slice($conversionRates, 0, 1, true); $reportContext = new Conversion\ReportContext(); $from = new \DateTime('first day of last month'); $to = new \DateTime('today'); $capacity = array(); $res = \Bitrix\Main\SiteTable::getList(); while ($site = $res->fetch()) { $lid = $site['LID']; $reportContext->setAttribute('conversion_site', $lid); $rateData = reset($reportContext->getRatesDeprecated($baseRate, array('>=DAY' => Type\Date::createFromPhp($from), '<=DAY' => Type\Date::createFromPhp($to)), null)); $reportContext->unsetAttribute('conversion_site', $lid); $rate = $rateData['RATE']; $hits = $rateData['DENOMINATOR']; $daily = floor($hits / (date_diff($from, $to)->format('%a') + 1)); $min = $rate > 0 && $rate < 1 ? ceil(16 * (1 / $rate - 1) / pow(MIN_EFFECT, 2)) : 0; $est = $daily ? $min / ($daily / 2) : 0; $capacity[$lid] = array('daily' => $daily, 'min' => $min, 'est' => $est); } $cache->startDataCache(strtotime('tomorrow') - time()); $cache->endDataCache($capacity); } } } $result = array(); foreach ((array) $id as $lid) { $result[$lid] = isset($capacity[$lid]) ? $capacity[$lid] : array('min' => 0, 'est' => 0); } return is_array($id) ? $result : reset($result); }
$contextMenuItems[] = array("SEPARATOR" => "Y"); $contextMenuItems[] = array("TEXT" => GetMessage("BT_SALE_DISCOUNT_EDIT_MESS_NEW_DISCOUNT"), "LINK" => "/bitrix/admin/sale_discount_edit.php?lang=" . LANGUAGE_ID . GetFilterParams("filter_"), "ICON" => "btn_new"); $contextMenuItems[] = array("TEXT" => GetMessage("BT_SALE_DISCOUNT_EDIT_MESS_COPY_DISCOUNT"), "LINK" => '/bitrix/admin/sale_discount_edit.php?lang=' . LANGUAGE_ID . '&ID=' . $discountID . '&action=copy&' . GetFilterParams('filter_'), "ICON" => "btn_copy"); $contextMenuItems[] = array("TEXT" => GetMessage("BT_SALE_DISCOUNT_EDIT_MESS_DELETE_DISCOUNT"), "LINK" => "javascript:if(confirm('" . GetMessageJS("BT_SALE_DISCOUNT_EDIT_MESS_DELETE_DISCOUNT_CONFIRM") . "')) window.location='/bitrix/admin/sale_discount.php?lang=" . LANGUAGE_ID . "&ID=" . $discountID . "&action=delete&" . bitrix_sessid_get() . "';", "WARNING" => "Y", "ICON" => "btn_delete"); } } $contextMenu = new CAdminContextMenu($contextMenuItems); $contextMenu->Show(); unset($contextMenu, $contextMenuItems); if (!empty($errors)) { $errorMessage = new CAdminMessage(array("DETAILS" => implode('<br>', $errors), "TYPE" => "ERROR", "MESSAGE" => GetMessage("BT_SALE_DISCOUNT_EDIT_MESS_SAVE_ERROR"), "HTML" => true)); echo $errorMessage->Show(); unset($errorMessage); } $arSiteList = array(); $siteIterator = Main\SiteTable::getList(array('select' => array('LID', 'NAME'), 'order' => array('SORT' => 'ASC'))); while ($site = $siteIterator->fetch()) { $arSiteList[$site['LID']] = '(' . $site['LID'] . ') ' . $site['NAME']; } unset($site, $siteIterator); $control->BeginPrologContent(); CJSCore::Init(array('date')); $control->EndPrologContent(); $control->BeginEpilogContent(); echo GetFilterHiddens("filter_"); ?> <input type="hidden" name="Update" value="Y"> <input type="hidden" name="lang" value="<?php echo LANGUAGE_ID; ?> ">
public static function getSiteLanguages() { static $langs; if ($langs == null) { $langs = array(); $res = \Bitrix\Main\SiteTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'select' => array('LANGUAGE_ID'), 'group' => array('LANGUAGE_ID'))); while ($item = $res->fetch()) { $langs[ToUpper($item['LANGUAGE_ID'])] = true; } $langs = array_unique(array_keys($langs)); // all active sites languages } return $langs; }
public static function convertSiteRelativeToAbsolute($relativePath, $site = null) { if (!is_string($relativePath) || $relativePath == "") { $site = SITE_ID; } $basePath = Main\SiteTable::getDocumentRoot($site); return self::combine($basePath, $relativePath); }
/** * Function clears entire component cache. * * <p>Note: parameters must exactly match to startResultCache call.</p> * @param string $componentName * @param string $siteId * @return void * */ public static final function clearComponentCache($componentName, $siteId = "") { /** @global CCacheManager $CACHE_MANAGER */ global $CACHE_MANAGER; $componentRelativePath = CComponentEngine::MakeComponentPath($componentName); if ($componentRelativePath != "") { $obCache = new CPHPCache(); $obCache->CleanDir($componentRelativePath, "cache"); BXClearCache(true, $componentRelativePath); if ($siteId == "") { $rsSite = \Bitrix\Main\SiteTable::getList(array('order' => array('SORT' => 'ASC'))); while ($site = $rsSite->fetch()) { $componentCachePath = "/" . $site["LID"] . $componentRelativePath; $obCache = new CPHPCache(); $obCache->CleanDir($componentCachePath, "cache"); BXClearCache(true, $componentCachePath); } } else { $componentCachePath = "/" . $siteId . $componentRelativePath; $obCache = new CPHPCache(); $obCache->CleanDir($componentCachePath, "cache"); BXClearCache(true, $componentCachePath); } if (defined("BX_COMP_MANAGED_CACHE")) { $CACHE_MANAGER->ClearByTag($componentName); } } }
public static function reindexAll($maxExecutionTime = 0, $ns = array()) { @set_time_limit(0); if (!is_array($ns)) { $ns = array(); } if ($maxExecutionTime <= 0) { $nsOld = $ns; $ns = array("CLEAR" => "N", "ID" => "", "FLG" => "", "SESS_ID" => md5(uniqid("")), "max_execution_time" => $nsOld["max_execution_time"], "stepped" => $nsOld["stepped"], "max_file_size" => $nsOld["max_file_size"]); if ($nsOld["SITE_ID"] != "") { $ns["SITE_ID"] = $nsOld["SITE_ID"]; } } $ns["CNT"] = intval($ns["CNT"]); $arSites = array(); $filterRootPath = ""; $db = SiteTable::getList(array("select" => array("LID", "DOC_ROOT", "DIR"), "filter" => array("ACTIVE" => "Y"))); while ($ar = $db->fetch()) { if (empty($ar["DOC_ROOT"])) { $ar["DOC_ROOT"] = Application::getDocumentRoot(); } $arSites[] = array("site_id" => $ar["LID"], "root" => $ar["DOC_ROOT"], "path" => IO\Path::combine($ar["DOC_ROOT"], $ar["DIR"])); if ($ns["SITE_ID"] != "" && $ns["SITE_ID"] == $ar["LID"]) { $filterRootPath = $ar["DOC_ROOT"]; } } if ($ns["SITE_ID"] != "" && !empty($filterRootPath)) { $arSitesTmp = array(); $arKeys = array_keys($arSites); foreach ($arKeys as $key) { if ($arSites[$key]["root"] == $filterRootPath) { $arSitesTmp[] = $arSites[$key]; } } $arSites = $arSitesTmp; } uasort($arSites, function ($a, $b) { $la = strlen($a["path"]); $lb = strlen($b["path"]); if ($la == $lb) { if ($a["site_id"] == $b["site_id"]) { return 0; } else { return $a["site_id"] > $b["site_id"] ? -1 : 1; } } return $la > $lb ? -1 : 1; }); if ($ns["CLEAR"] != "Y") { $arAlreadyDeleted = array(); foreach ($arSites as $site) { Component\ParametersTable::deleteBySiteId($site["site_id"]); if (!in_array($site["root"], $arAlreadyDeleted)) { UrlRewriter::delete($site["site_id"], array("!ID" => "")); $arAlreadyDeleted[] = $site["root"]; } } } $ns["CLEAR"] = "Y"; clearstatcache(); $arAlreadyParsed = array(); foreach ($arSites as $site) { if (in_array($site["root"], $arAlreadyParsed)) { continue; } $arAlreadyParsed[] = $site["root"]; if ($maxExecutionTime > 0 && !empty($ns["FLG"]) && substr($ns["ID"] . "/", 0, strlen($site["root"] . "/")) != $site["root"] . "/") { continue; } UrlRewriter::recursiveReindex($site["root"], "/", $arSites, $maxExecutionTime, $ns); if ($maxExecutionTime > 0 && !empty($ns["FLG"])) { return $ns; } } return $ns["CNT"]; }
/** * @return array Order's statuses & flags. */ public static function getBitrixStatuses($siteId) { $result = array("CANCELED" => Loc::getMessage("SALE_EBAY_HLP_FLAG_CANCELED"), "ALLOW_DELIVERY" => Loc::getMessage("SALE_EBAY_HLP_FLAG_DELIVERY"), "PAYED" => Loc::getMessage("SALE_EBAY_HLP_FLAG_PAYED"), "DEDUCTED" => Loc::getMessage("SALE_EBAY_HLP_FLAG_DEDUCTED")); if (strlen($siteId) <= 0) { throw new ArgumentNullException("siteId"); } $dbRes = SiteTable::getList(array('filter' => array('LID' => $siteId), 'select' => array("LANGUAGE_ID"))); if ($site = $dbRes->fetch()) { $langId = $site["LANGUAGE_ID"]; } else { throw new SystemException("Site with id: \"" . $siteId . "\" not found!"); } $dbRes = StatusLangTable::getList(array('filter' => array('LID' => $langId, 'STATUS.TYPE' => 'O'), 'order' => array("STATUS.SORT" => "ASC", "NAME" => "ASC"), 'select' => array("ID" => "STATUS.ID", "NAME"))); while ($row = $dbRes->fetch()) { $result[$row['ID']] = Loc::getMessage("SALE_EBAY_HLP_STATUS") . " " . $row['NAME'] . ' [' . $row['ID'] . ']'; } return $result; }
public function __construct($siteId) { $this->siteId = $siteId; $this->documentRoot = SiteTable::getDocumentRoot($this->siteId); parent::__construct(IO\Path::combine($this->documentRoot, self::ROBOTS_FILE_NAME)); }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } use Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__); /* "GROUPS" => array( "FILTER_SETTINGS" => array( "NAME" => GetMessage("T_IBLOCK_DESC_FILTER_SETTINGS"), ), */ $arComponentParameters = array("PARAMETERS" => array("ID" => array("NAME" => Loc::getMessage("SALE_SLS_ID_PARAMETER"), "PARENT" => "BASE", "TYPE" => "STRING", "MULTIPLE" => "N"), "CODE" => array("NAME" => Loc::getMessage("SALE_SLS_CODE_PARAMETER"), "PARENT" => "BASE", "TYPE" => "STRING", "MULTIPLE" => "N"), "INPUT_NAME" => array("NAME" => Loc::getMessage("SALE_SLS_INPUT_NAME_PARAMETER"), "PARENT" => "BASE", "TYPE" => "STRING", "DEFAULT" => "LOCATION"), "PROVIDE_LINK_BY" => array("NAME" => Loc::getMessage("SALE_SLS_PROVIDE_LINK_BY_PARAMETER"), "PARENT" => "BASE", "TYPE" => "LIST", "VALUES" => array('id' => Loc::getMessage("SALE_SLS_PROVIDE_LINK_BY_PARAMETER_ID"), 'code' => Loc::getMessage("SALE_SLS_PROVIDE_LINK_BY_PARAMETER_CODE")), "DEFAULT" => "id"), "FILTER_BY_SITE" => array("NAME" => Loc::getMessage("SALE_SLS_FILTER_BY_SITE_PARAMETER"), "PARENT" => "DATA_SOURCE", "TYPE" => "CHECKBOX", "DEFAULT" => "N", "REFRESH" => "Y"), "SHOW_DEFAULT_LOCATIONS" => array("NAME" => Loc::getMessage("SALE_SLS_SHOW_DEFAULT_LOCATIONS_PARAMETER"), "PARENT" => "DATA_SOURCE", "TYPE" => "CHECKBOX", "DEFAULT" => "N", "REFRESH" => "Y"), "JS_CONTROL_GLOBAL_ID" => array("NAME" => Loc::getMessage("SALE_SLS_JSCONTROL_GLOBAL_ID_PARAMETER"), "PARENT" => "ADDITIONAL", "TYPE" => "STRING", "MULTIPLE" => "N", "DEFAULT" => ""), "JS_CALLBACK" => array("NAME" => Loc::getMessage("SALE_SLS_JS_CALLBACK"), "PARENT" => "ADDITIONAL", "TYPE" => "STRING"), "CACHE_TIME" => array("DEFAULT" => 36000000))); if ($arCurrentValues['FILTER_BY_SITE'] == 'Y' || $arCurrentValues['SHOW_DEFAULT_LOCATIONS'] == 'Y') { $res = \Bitrix\Main\SiteTable::getList(array('filter' => array('=ACTIVE' => 'Y'))); $sites = array(); while ($item = $res->Fetch()) { $sites[$item['LID']] = '[' . $item['LID'] . '] ' . $item['NAME']; } $arComponentParameters["PARAMETERS"]["FILTER_SITE_ID"] = array("NAME" => Loc::getMessage("SALE_SLS_FILTER_SITE_ID_PARAMETER"), "PARENT" => "DATA_SOURCE", "TYPE" => "LIST", "VALUES" => array_merge(array('current' => Loc::getMessage("SALE_SLS_FILTER_SITE_ID_CURRENT")), $sites)); }
/** * @return array * @throws \Bitrix\Main\ArgumentException */ public static function getDefaultEmailFromList() { $addressFromList = array(); $siteEmailDb = \Bitrix\Main\SiteTable::getList(array('select' => array('EMAIL'))); while ($siteEmail = $siteEmailDb->fetch()) { $addressFromList[] = $siteEmail['EMAIL']; } try { $mainEmail = \COption::GetOptionString('main', 'email_from'); if (!empty($mainEmail)) { $addressFromList[] = $mainEmail; } $saleEmail = \COption::GetOptionString('sale', 'order_email'); if (!empty($saleEmail)) { $addressFromList[] = $saleEmail; } $addressFromList = array_unique($addressFromList); trimArr($addressFromList, true); } catch (\Exception $e) { } return $addressFromList; }
} $userOptions = CUserOptions::GetOption('conversion', 'filter', array()); // PERIOD $from = ($d = $_GET['from'] ?: $userOptions['from']) && Date::isCorrect($d) ? new Date($d) : Date::createFromPhp(new DateTime('first day of last month')); $to = ($d = $_GET['to'] ?: $userOptions['to']) && Date::isCorrect($d) ? new Date($d) : Date::createFromPhp(new DateTime('last day of this month')); // RATES if (!($rateTypes = RateManager::getTypes())) { die('No rates available!'); } $rateName = $_GET['rate'] ?: $userOptions['rate']; if (!($rateType = $rateTypes[$rateName])) { list($rateName, $rateType) = each($rateTypes); } // SITES $sites = array(); $result = SiteTable::getList(array('select' => array('LID', 'NAME'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC'))); while ($row = $result->fetch()) { $sites[$row['LID']] = $row['NAME']; } if (!$sites) { die('No sites available!'); } $site = $_GET['site'] ?: $userOptions['site']; if (!($siteName = $sites[$site])) { list($site, $siteName) = each($sites); } // ATTRIBUTES if (!($attributeTypes = AttributeManager::getTypes())) { die('No attributes!'); } unset($attributeTypes['conversion_site']);