1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
manager.php
См. документацию.
1<?php
2namespace Bitrix\Landing;
3
4use \Bitrix\Main\Localization\Loc;
5use \Bitrix\Main\Config\Option;
6use \Bitrix\Main\Application;
7use \Bitrix\Main\Loader;
8use \Bitrix\Main\ModuleManager;
9use \Bitrix\Landing\Assets;
10
11Loc::loadMessages(__FILE__);
12
14{
20
25 const PUBLICATION_PATH = '/pub/site/';
27
31 const BUY_LICENSE_PATH = '/bitrix/tools/landing/ajax.php?redirect=upgrade';
32
36 const FEATURE_CREATE_SITE = 'create_site';
37 const FEATURE_CREATE_PAGE = 'create_page';
38 const FEATURE_CUSTOM_DOMAIN = 'custom_domain';
39 const FEATURE_ENABLE_ALL_HOOKS = 'enable_all_hooks';
40 const FEATURE_PUBLICATION_SITE = 'publication_site';
41 const FEATURE_PUBLICATION_PAGE = 'publication_page';
42 const FEATURE_PERMISSIONS_AVAILABLE = 'permissions_available';
43 const FEATURE_DYNAMIC_BLOCK = 'dynamic_block';
44 const FEATURE_FREE_DOMAIN = 'free_domain';
45 const FEATURE_ALLOW_EXPORT = 'allow_export';
46 const FEATURE_ALLOW_VIEW_PAGE = 'allow_view_page';
47
52 protected static $forceB24disable = false;
53
58 protected static $tmpFeatures = [];
59
65 private static $themeTypoId = '';
66
71 public static function getApplication()
72 {
73 return $GLOBALS['APPLICATION'];
74 }
75
80 public static function getUserInstance()
81 {
82 return $GLOBALS['USER'];
83 }
84
89 public static function getCacheManager()
90 {
91 return $GLOBALS['CACHE_MANAGER'];
92 }
93
98 public static function getUfManager()
99 {
100 return $GLOBALS['USER_FIELD_MANAGER'];
101 }
102
107 public static function getUserId(): int
108 {
109 $user = self::getUserInstance();
110 if ($user instanceof \CUser)
111 {
112 return (int)$user->getId();
113 }
114 return 0;
115 }
116
121 public static function getUserFullName()
122 {
123 $user = self::getUserInstance();
124 if ($user instanceof \CUser)
125 {
126 return $user->getFullName();
127 }
128 return '';
129 }
130
135 public static function isAdmin()
136 {
137 $user = self::getUserInstance();
138
139 if (!($user instanceof \CUser))
140 {
141 return false;
142 }
143
144 if (ModuleManager::isModuleInstalled('bitrix24'))
145 {
146 return $user->canDoOperation('bitrix24_config');
147 }
148 else
149 {
150 return $user->isAdmin();
151 }
152 }
153
160 public static function getOption($code, $default = null)
161 {
162 return Option::get('landing', $code, $default);
163 }
164
171 public static function setOption($code, $value)
172 {
173 Option::set('landing', $code, $value);
174 }
175
180 public static function getDocRoot()
181 {
182 static $docRoot = null;
183
184 if ($docRoot === null)
185 {
186 $context = Application::getInstance()->getContext();
187 $server = $context->getServer();
188 $docRoot = $server->getDocumentRoot();
189 }
190
191 return $docRoot;
192 }
193
198 public static function getCurDir()
199 {
200 return Application::getInstance()->getContext()
201 ->getRequest()
202 ->getRequestedPageDirectory();
203 }
204
211 public static function setPageTitle($title, $single = false)
212 {
213 static $application = null;
214 static $disable = false;
215
216 if ($application === null)
217 {
218 $application = self::getApplication();
219 }
220
221 if ($title && !$disable)
222 {
223 $application->setTitle($title);
224 $application->setPageProperty('title', $title);
225 if ($single)
226 {
227 $disable = true;
228 }
229 }
230 }
231
237 protected static function getMainSiteById(string $siteId)
238 {
239 static $sites = [];
240
241 if (!array_key_exists($siteId, $sites))
242 {
244 ->setSelect(['*'])
245 ->where('LID', '=', $siteId)
246 ->setCacheTtl(86400)
247 ->exec()
248 ->fetch()
249 ;
250 }
251
252 return $sites[$siteId];
253 }
254
261 protected static function createPublicationPath(string $basePath, string $siteId = null): void
262 {
263 static $paths = [];
264
265 if (!in_array($basePath, $paths))
266 {
267 $paths[] = $basePath;
268
269 if (mb_substr($basePath, 0, 1) != '/')
270 {
271 $basePath = '/' . $basePath;
272 }
273 if (mb_substr($basePath, -1) != '/')
274 {
275 $basePath = $basePath . '/';
276 }
277
278 $docRoot = '';
279 $subDirSite = '';
280 $basePathOriginal = $basePath;
281
282 // gets current doc root or gets from the site
283 if ($siteId)
284 {
285 if ($smnSite = self::getMainSiteById($siteId))
286 {
287 if ($smnSite['DOC_ROOT'])
288 {
289 $docRoot = $smnSite['DOC_ROOT'] . $smnSite['DIR'];
290 }
291 else
292 {
293 $docRoot = self::getDocRoot() . $smnSite['DIR'];
294 }
295 $subDirSite = rtrim($smnSite['DIR'], '/');
296 }
297 $docRoot = rtrim($docRoot, '/');
298 }
299 if (!$docRoot)
300 {
301 $docRoot = self::getDocRoot();
302 }
304
305 // create path
306 if (\checkDirPath($basePath))
307 {
308 if (!file_exists($basePath . 'index.php'))
309 {
310 \rewriteFile(
311 $basePath . 'index.php',
312 file_get_contents(
313 self::getDocRoot() .
314 '/bitrix/modules/landing/install/pub/site/index.php'
315 )
316 );
317 }
318 }
319 // and add template rules for main
320 if ($siteId)
321 {
322 $fields = [
323 'SORT' => 0,
324 'SITE_ID' => $siteId,
325 'CONDITION' => 'CSite::inDir(\'' . $subDirSite . $basePathOriginal . '\')',
326 'TEMPLATE' => self::getTemplateId($siteId),
327 ];
328 $check = \Bitrix\Main\SiteTemplateTable::getList(array(
329 'filter' => [
330 '=SITE_ID' => $fields['SITE_ID'],
331 '=CONDITION' => $fields['CONDITION'],
332 '=TEMPLATE' => $fields['TEMPLATE'],
333 ],
334 ))->fetch();
335 if (!$check)
336 {
337 \Bitrix\Main\SiteTemplateTable::add(
338 $fields
339 );
340 \Bitrix\Main\UrlRewriter::add(
341 $siteId,
342 [
343 'ID' => 'bitrix:landing.pub',
344 'PATH' => $subDirSite. $basePathOriginal . 'index.php',
345 'CONDITION' => '#^' . $subDirSite. $basePathOriginal . '#',
346 ]
347 );
348 }
349 }
350 }
351 }
352
358 protected static function getSmnSiteDir(?string $siteId): string
359 {
360 static $sites = [];
361
362 if (!$siteId)
363 {
364 $siteId = SITE_ID;
365 }
366
367 if (!isset($sites[$siteId]))
368 {
369 $sites[$siteId] = '';
370 if ($smnSite = self::getMainSiteById($siteId))
371 {
372 $sites[$siteId] = rtrim($smnSite['DIR'], '/');
373 }
374 }
375
376 return $sites[$siteId];
377 }
378
383 public static function getPublicationPathConst()
384 {
385 if (defined('LANDING_PUBLICATION_PATH_CONST'))
386 {
387 return LANDING_PUBLICATION_PATH_CONST;
388 }
389 return self::isB24()
390 ? self::PUBLICATION_PATH
391 : self::PUBLICATION_PATH_SITEMAN;
392 }
393
401 public static function getPublicationPath($siteCode = null, $siteId = null, $createPubPath = false)
402 {
403 $typePublicationPath = Site\Type::getPublicationPath();
404
405 $basePath = $typePublicationPath;
406 if ($basePath === null)
407 {
408 $basePath = self::getOption(
409 'pub_path_' . (!isset($siteId) ? (self::getMainSiteId()) : $siteId),
410 self::getPublicationPathConst()
411 );
412 }
413 $subDir = self::getSmnSiteDir($siteId);
414 if ($siteCode === null)
415 {
416 if (
417 $createPubPath &&
418 ModuleManager::isModuleInstalled('bitrix24')
419 )
420 {
421 $createPubPath = false;
422 }
423 if ($createPubPath && $siteId)
424 {
425 self::createPublicationPath(
426 $basePath,
427 $siteId
428 );
429 }
430 return $subDir . $basePath;
431 }
432 else
433 {
434 return $subDir . str_replace(
435 '#id#',
436 $siteCode,
437 $basePath . '#id#/'
438 );
439 }
440 }
441
442 public static function isAutoPublicationEnabled(): bool
443 {
444 return
445 Site\Type::isPublicScope()
446 && \CUserOptions::getOption('landing', 'auto_publication', 'Y') === 'Y'
447 ;
448 }
449
457 public static function setPageClass($marker, $class)
458 {
459 self::setPageView($marker, $class);
460 }
461
470 public static function setPageView(string $marker, string $content, bool $skipTrim = false): void
471 {
472 if (!$skipTrim)
473 {
474 $content = trim($content);
475 }
476
477 if ($content)
478 {
479 $application = self::getApplication();
480 $existContent = $application->getPageProperty($marker);
481 $application->setPageProperty(
482 $marker,
483 $existContent . ($existContent != '' ? ' ' : '') . $content
484 );
485 }
486 }
487
493 public static function clearPageView($marker): void
494 {
495 self::getApplication()->setPageProperty($marker, '');
496 }
497
503 public static function getPageView($marker)
504 {
505 return self::getApplication()->getPageProperty($marker);
506 }
507
513 public static function getTemplateId($siteId = null)
514 {
515 static $tplId = [];
516
517 if (!isset($tplId[$siteId]))
518 {
519 if ($siteId)
520 {
521 $tplId[$siteId] = self::getOption('site_template_id_' . $siteId);
522 }
523 if (!$tplId[$siteId])
524 {
525 $tplId[$siteId] = self::getOption('site_template_id', 'landing24');
526 }
527 }
528
529 return $tplId[$siteId];
530 }
531
537 public static function isTemplateIdSystem($templateId)
538 {
539 return $templateId === 'landing24';
540 }
541
546 public static function getMainSiteId()
547 {
548 return defined('SMN_SITE_ID') ? SMN_SITE_ID : SITE_ID;
549 }
550
556 public static function getRandomString(int $length): string
557 {
558 return mb_strtolower(\Bitrix\Main\Security\Random::getStringByCharsets($length, 'abcdefghijklmnopqrstuvwxyz'));
559 }
560
567 public static function setThemeTypoId($themeTypoId)
568 {
569 self::$themeTypoId = $themeTypoId;
570 }
571
577 public static function initAssets($lid = 0)
578 {
579 $assets = Assets\Manager::getInstance();
580 $assets->setOutput($lid);
581 }
582
590 public static function savePicture($file, $ext = false, $params = array())
591 {
592 // local file
593 if (!is_array($file) && mb_substr($file, 0, 1) == '/')
594 {
595 $file = \CFile::makeFileArray($file);
596 }
597 // url of picture
598 else if (!is_array($file))
599 {
600 $httpClient = new \Bitrix\Main\Web\HttpClient();
601 $httpClient->setPrivateIp(false);
602 $httpClient->setTimeout(5);
603 $httpClient->setStreamTimeout(5);
604 $urlComponents = parse_url($file);
605
606 // detect tmp file name
607 if ($urlComponents && $urlComponents['path'] != '')
608 {
609 $tempPath = \CFile::getTempName('', bx_basename(urldecode($urlComponents['path'])));
610 }
611 else
612 {
613 $tempPath = \CFile::getTempName('', bx_basename(urldecode($file)));
614 }
615 if ($ext !== false && in_array($ext, explode(',', \CFile::getImageExtensions())))
616 {
617 if (mb_substr($tempPath, -3) != $ext)
618 {
619 $tempPath = $tempPath . '.' . $ext;
620 }
621 }
622
623 // download and save
624 if ($httpClient->download($file, $tempPath))
625 {
626 $fileName = $httpClient->getHeaders()->getFilename();
627 $file = \CFile::makeFileArray($tempPath);
628 if ($file && $fileName)
629 {
630 $file['name'] = $fileName;
631 }
632 }
633 }
634
635 // base64
636 elseif (
637 is_array($file) &&
638 isset($file[0]) &&
639 isset($file[1])
640 )
641 {
642 $fileParts = explode('.', $file[0]);
643 $ext = array_pop($fileParts);
644 $tempPath = \CFile::getTempName(
645 '',
646 \CUtil::translit(
647 implode('', $fileParts),
648 'ru'
649 ) . '.' . $ext
650 );
651 $fileIO = new \Bitrix\Main\IO\File(
652 $tempPath
653 );
654 $fileIO->putContents(
655 base64_decode($file[1])
656 );
657 $file = \CFile::makeFileArray($tempPath);
658 }
659
660 $isSvg = false;
661 $isImage = \CFile::checkImageFile($file, 0, 0, 0, array('IMAGE')) === null;
662
663 if (!$isImage && (Manager::getOption('allow_svg_content') === 'Y'))
664 {
665 $extension = \getFileExtension(mb_strtolower($file['name']));
666 if ($extension === 'svg')
667 {
668 $isSvg = true;
669 }
670 }
671
672 // post array or file from prev. steps
673 if ($isImage || $isSvg)
674 {
675 // resize if needed
676 if (
677 $isImage &&
678 isset($params['width']) &&
679 isset($params['height'])
680 )
681 {
682 \CFile::resizeImage(
683 $file,
684 $params,
685 isset($params['resize_type'])
686 ? intval($params['resize_type'])
687 : BX_RESIZE_IMAGE_PROPORTIONAL);
688 }
689 // if duplicate change size little (bug #167903)
690 if ($isImage && self::isDuplicateExistsInAnotherModule($file['tmp_name'], $file['size']))
691 {
692 [$width, $height] = getimagesize($file['tmp_name']) ?: [0, 0];
693 if ($width && $height)
694 {
695 \CFile::resizeImage($file, ['width' => $width-1, 'height' => $height-1]);
696 }
697 }
698 // save
699 $module = 'landing';
700 $file['name'] = File::transliterateFileName($file['name']);
701 $file['name'] = File::sanitizeFileName($file['name']);
702 $file['MODULE_ID'] = $module;
703 $file = \CFile::saveFile($file, $module);
704 if ($file)
705 {
706 $file = \CFile::getFileArray($file);
707 }
708 if ($file)
709 {
710 $file['SRC'] = str_replace(
711 '%',
712 '%25',
713 $file['SRC']
714 );
715 return $file;
716 }
717 }
718
719 return false;
720 }
721
728 private static function isDuplicateExistsInAnotherModule(string $filePath, int $size): bool
729 {
730 $hash = self::calculateHash($filePath, $size);
731 if (!$hash)
732 {
733 return false;
734 }
735
736 $original = \CFile::findDuplicate($size, $hash);
737 if ($original === null)
738 {
739 return false;
740 }
741
742 // we allow duplicate only within from current module
743 return $original->getFile()->getModuleId() !== 'landing';
744 }
745
753 private static function calculateHash(string $filePath, int $size): string
754 {
755 $hash = '';
756
757 if ($size > 0 && Option::get('main', 'control_file_duplicates', 'N') === 'Y')
758 {
759 $maxSize = (int)Option::get('main', 'duplicates_max_size', '100') * 1024 * 1024; //Mbytes
760 if ($size <= $maxSize || $maxSize === 0)
761 {
762 $hash = hash_file('md5', $filePath);
763 }
764 }
765
766 return $hash;
767 }
768
774 public static function enableFeatureTmp($feature)
775 {
776 self::$tmpFeatures[$feature] = true;
777 }
778
784 public static function disableFeatureTmp($feature)
785 {
786 if (isset(self::$tmpFeatures[$feature]))
787 {
788 unset(self::$tmpFeatures[$feature]);
789 }
790 }
791
796 public static function disableAllFeaturesTmp()
797 {
798 self::$tmpFeatures = [];
799 }
800
807 public static function checkMultiFeature(array $features, array $params = [])
808 {
809 $features = array_unique($features);
810
811 foreach ($features as $feature)
812 {
813 if (is_string($feature))
814 {
815 $check = self::checkFeature($feature, $params);
816 if (!$check)
817 {
818 return false;
819 }
820 }
821 else
822 {
823 return false;
824 }
825 }
826
827 return true;
828 }
829
836 public static function checkFeature(string $feature, array $params = array()): bool
837 {
838 // temporary set features
839 if (
840 isset(self::$tmpFeatures[$feature]) &&
841 self::$tmpFeatures[$feature]
842 )
843 {
844 return true;
845 }
846 if (!isset($params['type']) || !$params['type'])
847 {
848 $params['type'] = 'PAGE';
849 }
850
851 if (
852 $feature == self::FEATURE_CREATE_SITE ||
853 $feature == self::FEATURE_PUBLICATION_SITE
854 )
855 {
856 $params['action_type'] = ($feature == self::FEATURE_CREATE_SITE)
857 ? 'create' : 'publication';
858 return Restriction\Manager::isAllowed(
859 'limit_sites_number',
860 $params,
861 $feature
862 );
863 }
864 else if (
865 $feature == self::FEATURE_CREATE_PAGE ||
866 $feature == self::FEATURE_PUBLICATION_PAGE
867 )
868 {
869 $params['action_type'] = ($feature == self::FEATURE_CREATE_PAGE)
870 ? 'create' : 'publication';
871 return Restriction\Manager::isAllowed(
872 'limit_sites_number_page',
873 $params,
874 $feature
875 );
876 }
877 elseif ($feature == self::FEATURE_ENABLE_ALL_HOOKS)
878 {
879 if (isset($params['hook']))
880 {
881 return Restriction\Hook::isHookAllowed($params['hook']);
882 }
883 return true;
884 }
885 elseif ($feature == self::FEATURE_PERMISSIONS_AVAILABLE)
886 {
887 return Restriction\Manager::isAllowed(
888 'limit_sites_access_permissions'
889 );
890 }
891 elseif ($feature == self::FEATURE_DYNAMIC_BLOCK)
892 {
893 return Restriction\Manager::isAllowed(
894 'limit_sites_dynamic_blocks',
895 $params
896 );
897 }
898 elseif ($feature == self::FEATURE_FREE_DOMAIN)
899 {
900 return Restriction\Manager::isAllowed(
901 'limit_free_domen'
902 );
903 }
904 elseif ($feature == self::FEATURE_ALLOW_EXPORT)
905 {
906 return Restriction\Manager::isAllowed(
907 'limit_sites_transfer'
908 );
909 }
910 elseif ($feature == self::FEATURE_ALLOW_VIEW_PAGE)
911 {
912 return Restriction\Manager::isAllowed(
913 'limit_knowledge_base_number_page_view',
914 $params
915 );
916 }
917 // for backward compatibility
918 elseif ($feature == self::FEATURE_CUSTOM_DOMAIN)
919 {
920 return true;
921 }
922
923 return false;
924 }
925
930 public static function getZone()
931 {
932 static $zone = null;
933
934 if ($zone !== null)
935 {
936 return $zone;
937 }
938
939 $request = Application::getInstance()->getContext()->getRequest();
940 if ($request->get('user_lang'))
941 {
942 $zone = $request->get('user_lang');
943 }
944 else if (Loader::includeModule('bitrix24'))
945 {
946 $zone = \CBitrix24::getPortalZone();
947 }
948 if (!isset($zone) || !$zone)
949 {
950 $zone = Application::getInstance()->getContext()->getLanguage();
951 }
952
953 return $zone;
954 }
955
960 public static function getLangISO(): string
961 {
962 $transform = [
963 'br' => 'pt-BR',
964 'la' => 'es',
965 'sc' => 'zh-Hans',
966 'tc' => 'zh-Hant',
967 'vn' => 'vi',
968 'ua' => 'uk',
969 'in' => 'hi',
970 ];
971
972 return $transform[LANGUAGE_ID] ?? LANGUAGE_ID;
973 }
974
980 public static function availableOnlyForZone(string $zone): bool
981 {
982 static $available = null;
983
984 if ($available !== null)
985 {
986 return $available;
987 }
988
989 $available = true;
990
991 if ($zone === 'ru')
992 {
993 if (!in_array(self::getZone(), ['ru', 'by', 'kz', 'uz']))
994 {
995 $available = false;
996 }
997 }
998
999 return $available;
1000 }
1001
1007 public static function getMarketCollectionId(string $type): int
1008 {
1009 $zone = self::getZone();
1010 switch ($type)
1011 {
1012 case 'form_minisite':
1013 $minisites = [
1014 'ru' => 18108954,
1015 'uz' => 18108954,
1016 'by' => 18108962,
1017 'kz' => 18108964,
1018 'en' => 18108970,
1019 ];
1020
1021 return $minisites[$zone] ?? $minisites['en'];
1022
1023 default:
1024 return 0;
1025 }
1026 }
1027
1032 public static function isHttps()
1033 {
1034 static $isHttps = null;
1035
1036 if ($isHttps === null)
1037 {
1038 $context = Application::getInstance()->getContext();
1039 $isHttps = $context->getRequest()->isHttps();
1040 }
1041
1042 return $isHttps;
1043 }
1044
1049 public static function isAjaxRequest(): bool
1050 {
1051 return Application::getInstance()->getContext()->getRequest()->isAjaxRequest();
1052 }
1053
1058 public static function getHttpHost()
1059 {
1060 static $host = null;
1061
1062 if ($host === null)
1063 {
1064 $context = Application::getInstance()->getContext();
1065 $host = $context->getServer()->getHttpHost();
1066
1067 // strip port
1068 if (mb_strpos($host, ':') !== false)
1069 {
1070 [$host] = explode(':', $host);
1071 }
1072 }
1073
1074 return $host;
1075 }
1076
1082 public static function getUrlFromFile($file)
1083 {
1084 if (
1085 mb_substr($file, 0, 1) == '/' &&
1086 mb_substr($file, 0, 2) != '//' &&
1087 self::getHttpHost()
1088 )
1089 {
1090 return '//' .
1091 self::getHttpHost() .
1092 $file;
1093 }
1094 else
1095 {
1096 return $file;
1097 }
1098 }
1099
1105 public static function getPreviewHost(): string
1106 {
1107 if (!defined('LANDING_PREVIEW_URL'))
1108 {
1109 define('LANDING_PREVIEW_URL', self::getRegionPreviewDomain());
1110 }
1111
1112 return LANDING_PREVIEW_URL;
1113 }
1114
1120 public static function getPreviewWebhook(): string
1121 {
1122 if (!defined('LANDING_PREVIEW_WEBHOOK'))
1123 {
1124 $host = self::getRegionPreviewDomain();
1125 define('LANDING_PREVIEW_WEBHOOK', $host . '/rest/1/gvsn3ngrn7vb4t1m/');
1126 }
1127
1128 return LANDING_PREVIEW_WEBHOOK;
1129 }
1130
1135 public static function isB24(): bool
1136 {
1137 static $return = null;
1138
1139 if (self::$forceB24disable === true)
1140 {
1141 return false;
1142 }
1143
1144 if ($return === null)
1145 {
1146 if (
1147 defined('LANDING_DISABLE_B24_MODE') &&
1148 LANDING_DISABLE_B24_MODE === true
1149 )
1150 {
1151 $return = false;
1152 }
1153 else
1154 {
1155 $return = ModuleManager::isModuleInstalled('bitrix24') ||
1156 ModuleManager::isModuleInstalled('crm') ||
1157 ModuleManager::isModuleInstalled('intranet');
1158 }
1159 }
1160
1161 return $return;
1162 }
1163
1168 public static function isB24Cloud(): bool
1169 {
1170 return self::isB24() && ModuleManager::isModuleInstalled('bitrix24');
1171 }
1172
1173
1178 public static function isB24Connector(): bool
1179 {
1180 static $return = null;
1181
1182 if ($return === null)
1183 {
1184 $return =
1185 !self::isB24()
1186 && Loader::includeModule('b24connector')
1187 && Loader::includeModule('socialservices');
1188 }
1189
1190 return $return;
1191 }
1192
1198 public static function forceB24disable($flag)
1199 {
1200 self::$forceB24disable = $flag === true;
1201 }
1202
1207 public static function isExtendedSMN()
1208 {
1209 static $option = null;
1210
1211 if ($option === null)
1212 {
1213 $option = self::getOption('smn_extended', 'N') == 'Y';
1214 }
1215
1216 return $option;
1217 }
1218
1223 public static function isStoreEnabled()
1224 {
1225 return ModuleManager::isModuleInstalled('sale') &&
1226 ModuleManager::isModuleInstalled('catalog') &&
1227 ModuleManager::isModuleInstalled('iblock');
1228 }
1229
1235 public static function getRestPath(): string
1236 {
1237 return '';
1238 }
1239
1244 public static function isCloudDisable()
1245 {
1246 return defined('LANDING_DISABLE_CLOUD') &&
1247 LANDING_DISABLE_CLOUD === true;
1248 }
1249
1250
1255 public static function getVersion()
1256 {
1257 static $arModuleVersion = null;
1258
1259 if ($arModuleVersion === null)
1260 {
1261 $arModuleVersion = [];
1262 include self::getDocRoot() . '/bitrix/modules/landing/install/version.php';
1263 }
1264
1265 return isset($arModuleVersion['VERSION']) ? $arModuleVersion['VERSION'] : null;
1266 }
1267
1272 public static function licenseIsValid()
1273 {
1274 $finishDate = Option::get('main', '~support_finish_date');
1275 $finishDate = \makeTimestamp($finishDate, 'YYYY-MM-DD');
1276 if ($finishDate < time())
1277 {
1278 return false;
1279 }
1280 return true;
1281 }
1282
1288 public static function licenseIsFreeSite(string $type): bool
1289 {
1290 return
1291 $type !== 'KNOWLEDGE'
1292 && $type !== 'STORE'
1293 && (!\CBitrix24::isLicensePaid() || \CBitrix24::getLicenseType() === 'alive')
1294 && !\CBitrix24::IsNfrLicense()
1295 ;
1296 }
1297
1298 public static function isFreePublicAllowed(): bool
1299 {
1300 return in_array(self::getZone(), ['ru', 'by', 'kz', 'uz', 'es', 'la', 'mx', 'co', 'br', 'in', 'hi']);
1301 }
1302
1310 public static function sanitize($value, &$bad = false, $splitter = ' ')
1311 {
1312 static $sanitizer = null;
1313
1314 if (!is_bool($bad))
1315 {
1316 $bad = false;
1317 }
1318
1319 if ($sanitizer === null)
1320 {
1321 $sanitizer = false;
1322 if (Loader::includeModule('security'))
1323 {
1324 $sanitizer = new \Bitrix\Security\Filter\Auditor\Xss(
1325 $splitter
1326 );
1327 }
1328 }
1329
1330 if ($sanitizer)
1331 {
1332 // bad value exists
1333 if (is_array($value))
1334 {
1335 foreach ($value as &$val)
1336 {
1337 $val = self::sanitize($val, $bad, $splitter);
1338 }
1339 unset($val);
1340 }
1341 else if ($sanitizer->process($value))
1342 {
1343 $bad = true;
1344 $value = $sanitizer->getFilteredValue();
1345 $value = str_replace(
1346 [' bxstyle="', '<sv g ', '<?', '?>', '<fo rm '],
1347 [' style="', '<svg ', '< ?', '? >', '<form '],
1348 $value
1349 );
1350 }
1351 else
1352 {
1353 $value = str_replace(
1354 [' bxstyle="', '<sv g ', '<?', '?>', '<fo rm '],
1355 [' style="', '<svg ', '< ?', '? >', '<form '],
1356 $value
1357 );
1358 }
1359 }
1360
1361 return $value;
1362 }
1363
1368 public static function getDeletedLT()
1369 {
1370 $deletedDays = (int) Manager::getOption('deleted_lifetime_days', 30);
1371 $deletedDays = max(1, $deletedDays);
1372 return $deletedDays;
1373 }
1374
1379 public static function getExternalSiteController()
1380 {
1381 static $class = '';
1382
1383 if (!$class)
1384 {
1385 if (class_exists('\LandingSiteController'))
1386 {
1387 $class = '\LandingSiteController';
1388 }
1389 else if (
1390 Loader::includeModule('bitrix24') &&
1391 class_exists('\Bitrix\Bitrix24\SiteController')
1392 )
1393 {
1394 $class = '\Bitrix\Bitrix24\SiteController';
1395 }
1396 else if (class_exists('\Bitrix\Landing\External\Site24'))
1397 {
1398 $class = '\Bitrix\Landing\External\Site24';
1399 }
1400 }
1401
1402 return $class;
1403 }
1404
1409 public static function resetToFree()
1410 {
1411 self::clearCache();
1412 self::setOption('html_disabled', 'Y');
1413 self::setOption('reset_to_free_time', time());
1414 Restriction\Site::manageFreeDomains(false, Restriction\Site::FREE_DOMAIN_GRACE_DAYS * 86400);
1415 }
1416
1422 public static function onBitrix24LicenseChange(string $licenseType): void
1423 {
1424 self::clearCache();
1425 self::setOption('reset_to_free_time', 0);
1429 }
1430
1435 public static function clearCache(): void
1436 {
1437 // for clear cache in cloud
1438 if (!self::isB24())
1439 {
1440 return;
1441 }
1442 $res = Site::getList([
1443 'select' => [
1444 'ID',
1445 ],
1446 'filter' => [
1447 'ACTIVE' => 'Y',
1448 ],
1449 ]);
1450 while ($row = $res->fetch())
1451 {
1452 Site::update($row['ID'], []);
1453 }
1454 }
1455
1460 public static function clearCacheForSite(int $siteId): void
1461 {
1462 if (!self::isB24())
1463 {
1464 return;
1465 }
1466
1467 Site::update($siteId, []);
1468 }
1469
1473 public static function clearCacheForLanding(int $lid): void
1474 {
1475 if (!self::isB24())
1476 {
1477 return;
1478 }
1480 'select' => [
1481 'SITE_ID',
1482 ],
1483 'filter' => [
1484 '=ACTIVE' => 'Y',
1485 '=DELETED' => 'N',
1486 '=ID' => $lid,
1487 ],
1488 ]);
1489 if ($row = $res->fetch())
1490 {
1491 Site::update($row['SITE_ID'], []);
1492 }
1493 }
1494
1500 public static function checkRepositoryVersion()
1501 {
1502 }
1503
1508 public static function getThemes()
1509 {
1510 }
1511
1516 public static function getThemesTypo()
1517 {
1518 }
1519
1524 public static function setThemeId()
1525 {
1526 }
1527
1532 public static function getThemeId()
1533 {
1534 }
1535
1540 public static function setTheme()
1541 {
1542 }
1543
1544
1549 private static function getRegionPreviewDomain(): string
1550 {
1551 $region = Application::getInstance()->getLicense()->getRegion();
1552
1553 if (in_array($region, ['ru', 'by', 'kz', 'uz'], true))
1554 {
1555 return 'https://preview.bitrix24.tech';
1556 }
1557
1558 // Default global domain
1559 return 'https://preview.bitrix24.site';
1560 }
1561}
$type
Определения options.php:106
$basePath
Определения include.php:41
static isB24()
Определения manager.php:1135
static getRestPath()
Определения manager.php:1235
static getUserInstance()
Определения manager.php:80
static getOption($code, $default=null)
Определения manager.php:160
const FEATURE_PERMISSIONS_AVAILABLE
Определения manager.php:42
static onBitrix24LicenseChange(string $licenseType)
Определения manager.php:1422
static getVersion()
Определения manager.php:1255
static getDocRoot()
Определения manager.php:180
static setOption($code, $value)
Определения manager.php:171
const FEATURE_ALLOW_VIEW_PAGE
Определения manager.php:46
static isStoreEnabled()
Определения manager.php:1223
static getApplication()
Определения manager.php:71
static getDeletedLT()
Определения manager.php:1368
static getUserId()
Определения manager.php:107
const USER_AGREEMENT_VERSION
Определения manager.php:19
static licenseIsValid()
Определения manager.php:1272
static createPublicationPath(string $basePath, string $siteId=null)
Определения manager.php:261
const FEATURE_ALLOW_EXPORT
Определения manager.php:45
static $tmpFeatures
Определения manager.php:58
static getCacheManager()
Определения manager.php:89
const FEATURE_DYNAMIC_BLOCK
Определения manager.php:43
static getMainSiteById(string $siteId)
Определения manager.php:237
static getPreviewHost()
Определения manager.php:1105
static isExtendedSMN()
Определения manager.php:1207
static isB24Connector()
Определения manager.php:1178
const FEATURE_CREATE_PAGE
Определения manager.php:37
const FEATURE_CREATE_SITE
Определения manager.php:36
static isFreePublicAllowed()
Определения manager.php:1298
const FEATURE_PUBLICATION_PAGE
Определения manager.php:41
static getUfManager()
Определения manager.php:98
static setPageTitle($title, $single=false)
Определения manager.php:211
static getPreviewWebhook()
Определения manager.php:1120
static getCurDir()
Определения manager.php:198
static getThemes()
Определения manager.php:1508
static getThemeId()
Определения manager.php:1532
static forceB24disable($flag)
Определения manager.php:1198
static isAdmin()
Определения manager.php:135
static licenseIsFreeSite(string $type)
Определения manager.php:1288
static clearCacheForSite(int $siteId)
Определения manager.php:1460
static getUserFullName()
Определения manager.php:121
static isCloudDisable()
Определения manager.php:1244
static setThemeId()
Определения manager.php:1524
static resetToFree()
Определения manager.php:1409
static isB24Cloud()
Определения manager.php:1168
static sanitize($value, &$bad=false, $splitter=' ')
Определения manager.php:1310
const FEATURE_CUSTOM_DOMAIN
Определения manager.php:38
static getThemesTypo()
Определения manager.php:1516
static $forceB24disable
Определения manager.php:52
const PUBLICATION_PATH
Определения manager.php:25
static checkRepositoryVersion()
Определения manager.php:1500
const FEATURE_FREE_DOMAIN
Определения manager.php:44
static setTheme()
Определения manager.php:1540
static getExternalSiteController()
Определения manager.php:1379
const FEATURE_PUBLICATION_SITE
Определения manager.php:40
const PUBLICATION_PATH_SITEMAN
Определения manager.php:26
const BUY_LICENSE_PATH
Определения manager.php:31
static clearCacheForLanding(int $lid)
Определения manager.php:1473
const FEATURE_ENABLE_ALL_HOOKS
Определения manager.php:39
static clearCache()
Определения manager.php:1435
static publishByLicenseChange()
Определения site.php:498
static manageFreeDomains(bool $setActive, int $executeAfterSeconds=0)
Определения site.php:326
static checkLimitsByLicenseChange()
Определения site.php:503
static getList(array $parameters=array())
Определения datamanager.php:431
$sites
Определения clear_component_cache.php:15
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
Определения file_new.php:759
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
$res
Определения filter_act.php:7
$region
Определения .description.php:13
$docRoot
Определения options.php:20
$context
Определения csv_new_setup.php:223
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$application
Определения bitrix.php:23
$siteId
Определения ajax.php:8
@ landing
Определения Tools.php:9
$user
Определения mysql_to_pgsql.php:33
$host
Определения mysql_to_pgsql.php:32
$GLOBALS['____1690880296']
Определения license.php:1
font size
Определения invoice.php:442
$title
Определения pdf.php:123
$paths
Определения options.php:2080
$option
Определения options.php:1711
$val
Определения options.php:1793
const SITE_ID
Определения sonet_set_content_view.php:12
path
Определения template_copy.php:201
$fields
Определения yandex_run.php:501