1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
main.php
См. документацию.
1<?php
2
9
10use Bitrix\Main;
13use Bitrix\Main\Page\Asset;
18
19IncludeModuleLangFile(__FILE__);
20
21abstract class CAllMain
22{
23 var $ma;
31 public $oAsset;
35 var $sPath2css = [];
44 var $bInAjax = false;
50 var $ShowPanel = null;
51 var $PanelShowed = false;
55 var $buffer_man = false;
56 var $buffer_manual = false;
61 var $LAST_ERROR = false;
62 var $ERROR_STACK = [];
65 var $ShowIncludeStat = false;
67 var $__view = [];
69 var $editArea = false;
71 var $arComponentMatch = false;
73 private $__componentStack = [];
74
75 public function __construct()
76 {
77 $this->oAsset = Asset::getInstance();
78 }
79
80 public function GetCurPage($get_index_page = null)
81 {
82 if (null === $get_index_page)
83 {
84 if (defined('BX_DISABLE_INDEX_PAGE'))
85 {
86 $get_index_page = !BX_DISABLE_INDEX_PAGE;
87 }
88 else
89 {
90 $get_index_page = true;
91 }
92 }
93
94 if ($this->sDocPath2 === null)
95 {
96 $this->sDocPath2 = GetPagePath(false, true);
97 }
98
100
101 if (!$get_index_page)
102 {
103 if (($i = mb_strpos($str, '/index.php')) !== false)
104 {
105 $str = mb_substr($str, 0, $i) . '/';
106 }
107 }
108
109 return $str;
110 }
111
112 public function SetCurPage($page)
113 {
114 $this->sDocPath2 = GetPagePath($page, true);
115 $this->sDirPath = GetDirPath($this->sDocPath2);
116 }
117
118 public function GetCurUri($addParam = "", $get_index_page = null)
119 {
120 $page = $this->GetCurPage($get_index_page);
121 $param = $this->GetCurParam();
122 if ($param <> '')
123 {
124 $url = $page . "?" . $param . ($addParam != "" ? "&" . $addParam : "");
125 }
126 else
127 {
128 $url = $page . ($addParam != "" ? "?" . $addParam : "");
129 }
130 return $url;
131 }
132
133 public function GetCurPageParam($strParam = "", $arParamKill = [], $get_index_page = null)
134 {
135 $sUrlPath = $this->GetCurPage($get_index_page);
136
137 $strNavQueryString = DeleteParam($arParamKill);
138 if ($strNavQueryString <> "" && $strParam <> "")
139 {
140 $strNavQueryString = "&" . $strNavQueryString;
141 }
142 if ($strNavQueryString == "" && $strParam == "")
143 {
144 return $sUrlPath;
145 }
146 else
147 {
148 return $sUrlPath . "?" . $strParam . $strNavQueryString;
149 }
150 }
151
152 public function GetCurParam()
153 {
154 return $_SERVER["QUERY_STRING"] ?? '';
155 }
156
157 public function GetCurDir()
158 {
159 if ($this->sDirPath === null)
160 {
161 $this->sDirPath = GetDirPath($this->GetCurPage(true));
162 }
163 return $this->sDirPath;
164 }
165
166 public function GetFileRecursive($strFileName, $strDir = false)
167 {
168 if ($strDir === false)
169 {
170 $strDir = $this->GetCurDir();
171 }
172
174 $fn = $io->CombinePath("/", $strDir, $strFileName);
175
176 $p = null;
177 while (!$io->FileExists($io->RelativeToAbsolutePath($fn)))
178 {
179 $p = bxstrrpos($strDir, "/");
180 if ($p === false)
181 {
182 break;
183 }
184 $strDir = mb_substr($strDir, 0, $p);
185 $fn = $io->CombinePath("/", $strDir, $strFileName);
186 }
187 if ($p === false)
188 {
189 return false;
190 }
191
192 return $fn;
193 }
194
195 public function IncludeAdminFile($strTitle, $filepath)
196 {
197 //define all global vars
198 static $exclude = ["this" => 1, "exclude" => 1, "key" => 1, "GLOBALS" => 1, "strTitle" => 1, "filepath" => 1];
199 foreach ($GLOBALS as $key => $value)
200 {
201 if (!isset($exclude[$key]))
202 {
203 global ${$key};
204 }
205 }
206
207 //title
208 $this->SetTitle($strTitle);
209
210 include($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog_admin_after.php");
211 include($filepath);
212 include($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_admin.php");
213 die();
214 }
215
217 {
218 $this->arAuthResult = $arAuthResult;
219 }
220
221 public function AuthForm($mess, $show_prolog = true, $show_epilog = true, $not_show_links = "N", $do_die = true)
222 {
223 static $exclude = ["this" => 1, "exclude" => 1, "key" => 1, "GLOBALS" => 1, "mess" => 1, "show_prolog" => 1, "show_epilog" => 1, "not_show_links" => 1, "do_die" => 1];
224 foreach ($GLOBALS as $key => $value)
225 {
226 if (!isset($exclude[$key]))
227 {
228 global ${$key};
229 }
230 }
231
232 if (str_starts_with($this->GetCurDir(), BX_ROOT . "/admin/") || (defined("ADMIN_SECTION") && ADMIN_SECTION === true))
233 {
234 $isAdmin = "_admin";
235 }
236 else
237 {
238 $isAdmin = "";
239 }
240
241 if (isset($this->arAuthResult) && $this->arAuthResult !== true && (is_array($this->arAuthResult) || $this->arAuthResult <> ''))
242 {
244 }
245 else
246 {
247 $arAuthResult = $mess;
248 }
249
251 global $APPLICATION, $forgot_password, $change_password, $register, $confirm_registration;
252
253 //page title
254 $APPLICATION->SetTitle(GetMessage("AUTH_TITLE"));
255
256 if (
257 is_array($arAuthResult)
258 && isset($arAuthResult["TYPE"])
259 && isset($arAuthResult["ERROR_TYPE"])
260 && $arAuthResult["TYPE"] === "ERROR"
261 && $arAuthResult["ERROR_TYPE"] === "CHANGE_PASSWORD"
262 )
263 {
264 //require to change the password after N days
265 $change_password = "yes";
266 }
267
268 $inc_file = "";
269 if ($forgot_password == "yes")
270 {
271 //pass request form
272 $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_SEND_PASSWORD"));
273 $comp_name = "system.auth.forgotpasswd";
274 $inc_file = "forgot_password";
275 }
276 elseif ($change_password == "yes")
277 {
278 //pass change form
279 $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CHANGE_PASSWORD"));
280 $comp_name = "system.auth.changepasswd";
281 $inc_file = "change_password";
282 }
283 elseif ($register == "yes" && $isAdmin == "" && COption::GetOptionString("main", "new_user_registration", "N") == "Y")
284 {
285 //registration form
286 $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_REGISTER"));
287 $comp_name = "system.auth.registration";
288 }
289 elseif (($confirm_registration === "yes") && ($isAdmin === "") && (COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y"))
290 {
291 //confirm registartion
292 $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_CONFIRM"));
293 $comp_name = "system.auth.confirmation";
294 }
295 elseif (
296 CModule::IncludeModule("security")
297 && \Bitrix\Security\Mfa\Otp::isOtpRequired()
298 && (!isset($_REQUEST["login_form"]) || $_REQUEST["login_form"] !== "yes")
299 )
300 {
301 //otp form
302 $APPLICATION->SetTitle(GetMessage("AUTH_TITLE_OTP"));
303 $comp_name = "system.auth.otp";
304 $inc_file = "otp";
305 }
306 else
307 {
308 header('X-Bitrix-Ajax-Status: Authorize');
309
310 //auth form
311 $comp_name = "system.auth.authorize";
312 $inc_file = "authorize";
313 }
314
315 if ($show_prolog)
316 {
318
319 define("BX_AUTH_FORM", true);
320 include($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/prolog" . $isAdmin . "_after.php");
321 }
322
323 if ($isAdmin == "")
324 {
325 // form by Components 2.0
326 $this->IncludeComponent(
327 "bitrix:" . $comp_name,
328 COption::GetOptionString("main", "auth_components_template", ""),
329 [
330 "AUTH_RESULT" => $arAuthResult,
331 "NOT_SHOW_LINKS" => $not_show_links,
332 ]
333 );
334 }
335 else
336 {
337 include($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/auth/wrapper.php");
338 }
339
341 $autoCompositeArea?->end();
342
343 if ($show_epilog)
344 {
345 include($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog" . $isAdmin . ".php");
346 }
347
348 if ($do_die)
349 {
350 die();
351 }
352 }
353
354 public function ShowAuthForm($message)
355 {
356 $this->AuthForm($message, false, false, "N", false);
357 }
358
362 public function SetNeedCAPTHA($mode)
363 {
364 $kernelSession = Main\Application::getInstance()->getKernelSession();
365 $kernelSession["BX_LOGIN_NEED_CAPTCHA"] = (bool)$mode;
366 }
367
371 public function NeedCAPTHA()
372 {
373 $kernelSession = Main\Application::getInstance()->getKernelSession();
374 return !empty($kernelSession["BX_LOGIN_NEED_CAPTCHA"]);
375 }
376
377 public function NeedCAPTHAForLogin($login)
378 {
379 //When last login was failed then ask for CAPTCHA
380 if ($this->NeedCAPTHA())
381 {
382 return true;
383 }
384
385 //This is local cache. May save one query.
386 $USER_ATTEMPTS = false;
387
388 $session = Main\Application::getInstance()->getSession();
389
390 //Check if SESSION cache for POLICY_ATTEMPTS is actual for given login
391 if (!$session->has("BX_LOGIN_NEED_CAPTCHA_LOGIN") || $session["BX_LOGIN_NEED_CAPTCHA_LOGIN"]["LOGIN"] !== $login)
392 {
393 $POLICY_ATTEMPTS = 0;
394 if ($login <> '')
395 {
396 $rsUser = CUser::GetList('LOGIN', 'DESC', [
397 "LOGIN_EQUAL_EXACT" => $login,
398 "EXTERNAL_AUTH_ID" => "",
399 ],
400 ['FIELDS' => ['ID', 'LOGIN', 'LOGIN_ATTEMPTS']]
401 );
402 $arUser = $rsUser->Fetch();
403 if ($arUser)
404 {
405 $policy = CUser::getPolicy($arUser["ID"]);
406 $POLICY_ATTEMPTS = (int)$policy->getLoginAttempts();
407 $USER_ATTEMPTS = (int)$arUser["LOGIN_ATTEMPTS"];
408 }
409 }
410 $session["BX_LOGIN_NEED_CAPTCHA_LOGIN"] = [
411 "LOGIN" => $login,
412 "POLICY_ATTEMPTS" => $POLICY_ATTEMPTS,
413 ];
414 }
415
416 //For users who had successful login and if policy is set
417 //check for CAPTCHA display
418 if ($login <> '' && $session["BX_LOGIN_NEED_CAPTCHA_LOGIN"]["POLICY_ATTEMPTS"] > 0)
419 {
420 //We need to know how many attempts user made
421 if ($USER_ATTEMPTS === false)
422 {
423 $rsUser = CUser::GetList('LOGIN', 'DESC', [
424 "LOGIN_EQUAL_EXACT" => $login,
425 "EXTERNAL_AUTH_ID" => "",
426 ],
427 ['FIELDS' => ['ID', 'LOGIN', 'LOGIN_ATTEMPTS']]
428 );
429 $arUser = $rsUser->Fetch();
430 if ($arUser)
431 {
432 $USER_ATTEMPTS = intval($arUser["LOGIN_ATTEMPTS"]);
433 }
434 else
435 {
436 $USER_ATTEMPTS = 0;
437 }
438 }
439 //When user login attempts exceeding the policy we'll show the CAPTCHA
440 if ($USER_ATTEMPTS >= $session["BX_LOGIN_NEED_CAPTCHA_LOGIN"]["POLICY_ATTEMPTS"])
441 {
442 return true;
443 }
444 }
445
446 return false;
447 }
448
449 public function GetMenuHtml($type = "left", $bMenuExt = false, $template = false, $sInitDir = false)
450 {
451 $menu = $this->GetMenu($type, $bMenuExt, $template, $sInitDir);
452 return $menu->GetMenuHtml();
453 }
454
455 public function GetMenuHtmlEx($type = "left", $bMenuExt = false, $template = false, $sInitDir = false)
456 {
457 $menu = $this->GetMenu($type, $bMenuExt, $template, $sInitDir);
458 return $menu->GetMenuHtmlEx();
459 }
460
461 public function GetMenu($type = "left", $bMenuExt = false, $template = false, $sInitDir = false)
462 {
463 $menu = new CMenu($type);
464 if ($sInitDir === false)
465 {
466 $sInitDir = $this->GetCurDir();
467 }
468 if (!$menu->Init($sInitDir, $bMenuExt, $template))
469 {
470 $menu->MenuDir = $sInitDir;
471 }
472 return $menu;
473 }
474
479 public static function IsHTTPS()
480 {
481 return Main\Context::getCurrent()->getRequest()->isHttps();
482 }
483
484 public function GetTitle($property_name = false, $strip_tags = false)
485 {
486 if ($property_name !== false && $this->GetProperty($property_name) <> '')
487 {
488 $res = $this->GetProperty($property_name);
489 }
490 else
491 {
493 }
494 if ($strip_tags && is_string($res))
495 {
496 return strip_tags($res);
497 }
498 return $res;
499 }
500
501 public function SetTitle($title, $arOptions = null)
502 {
503 $this->sDocTitle = $title;
504
505 if (is_array($arOptions))
506 {
507 $this->sDocTitleChanger = $arOptions;
508 }
509 else
510 {
511 $arTrace = array_reverse(Main\Diag\Helper::getBackTrace(0, DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS));
512
513 foreach ($arTrace as $arTraceRes)
514 {
515 if (isset($arTraceRes['class']) && isset($arTraceRes['function']))
516 {
517 if (strtoupper($arTraceRes['class']) == 'CBITRIXCOMPONENT' && strtoupper($arTraceRes['function']) == 'INCLUDECOMPONENT' && is_object($arTraceRes['object']))
518 {
520 $comp = $arTraceRes['object'];
521 $this->sDocTitleChanger = [
522 'COMPONENT_NAME' => $comp->GetName(),
523 ];
524
525 break;
526 }
527 }
528 }
529 }
530 }
531
532 public function ShowTitle($property_name = "title", $strip_tags = true)
533 {
534 $this->AddBufferContent([&$this, "GetTitle"], $property_name, $strip_tags);
535 }
536
537 public function SetPageProperty($PROPERTY_ID, $PROPERTY_VALUE, $arOptions = null)
538 {
539 $this->arPageProperties[mb_strtoupper($PROPERTY_ID)] = $PROPERTY_VALUE;
540
541 if (is_array($arOptions))
542 {
543 $this->arPagePropertiesChanger[mb_strtoupper($PROPERTY_ID)] = $arOptions;
544 }
545 }
546
547 public function GetPageProperty($PROPERTY_ID, $default_value = false)
548 {
549 if (isset($this->arPageProperties[mb_strtoupper($PROPERTY_ID)]))
550 {
551 return $this->arPageProperties[mb_strtoupper($PROPERTY_ID)];
552 }
553 return $default_value;
554 }
555
556 public function ShowProperty($PROPERTY_ID, $default_value = false)
557 {
558 $this->AddBufferContent([&$this, "GetProperty"], $PROPERTY_ID, $default_value);
559 }
560
561 public function GetProperty($PROPERTY_ID, $default_value = false)
562 {
563 $propVal = $this->GetPageProperty($PROPERTY_ID);
564 if ($propVal !== false)
565 {
566 return $propVal;
567 }
568
569 $propVal = $this->GetDirProperty($PROPERTY_ID);
570 if ($propVal !== false)
571 {
572 return $propVal;
573 }
574
575 return $default_value;
576 }
577
578 public function GetPagePropertyList()
579 {
581 }
582
583 public static function InitPathVars(&$site, &$path)
584 {
585 $site = false;
586 if (is_array($path))
587 {
588 $site = $path[0];
589 $path = $path[1];
590 }
591 return $path;
592 }
593
594 public function SetDirProperty($PROPERTY_ID, $PROPERTY_VALUE, $path = false)
595 {
597
598 if ($path === false)
599 {
600 $path = $this->GetCurDir();
601 }
602 if ($site === false)
603 {
604 $site = SITE_ID;
605 }
606
607 if (!isset($this->arDirProperties[$site][$path]))
608 {
609 $this->InitDirProperties([$site, $path]);
610 }
611
612 $this->arDirProperties[$site][$path][mb_strtoupper($PROPERTY_ID)] = $PROPERTY_VALUE;
613 }
614
615 public function InitDirProperties($path)
616 {
618
619 $DOC_ROOT = CSite::GetSiteDocRoot($site);
620
621 if ($path === false)
622 {
623 $path = $this->GetCurDir();
624 }
625 if ($site === false)
626 {
627 $site = SITE_ID;
628 }
629
630 if (isset($this->arDirProperties[$site][$path]))
631 {
632 return true;
633 }
634
636
637 $dir = $path;
638 while (true) // until the root
639 {
640 $dir = rtrim($dir, "/");
641 $section_file_name = $DOC_ROOT . $dir . "/.section.php";
642
643 if ($io->FileExists($section_file_name))
644 {
645 $arDirProperties = false;
646 include($io->GetPhysicalName($section_file_name));
647 if (is_array($arDirProperties))
648 {
649 foreach ($arDirProperties as $prid => $prval)
650 {
651 $prid = mb_strtoupper($prid);
652 if (!isset($this->arDirProperties[$site][$path][$prid]))
653 {
654 $this->arDirProperties[$site][$path][$prid] = $prval;
655 }
656 }
657 }
658 }
659
660 if ($dir == '')
661 {
662 break;
663 }
664
665 // file or folder
666 $pos = bxstrrpos($dir, "/");
667 if ($pos === false)
668 {
669 break;
670 }
671
672 //parent folder
673 $dir = mb_substr($dir, 0, $pos + 1);
674 }
675
676 return true;
677 }
678
679 public function GetDirProperty($PROPERTY_ID, $path = false, $default_value = false)
680 {
682
683 if ($path === false)
684 {
685 $path = $this->GetCurDir();
686 }
687 if ($site === false)
688 {
689 $site = SITE_ID;
690 }
691
692 if (!isset($this->arDirProperties[$site][$path]))
693 {
694 $this->InitDirProperties([$site, $path]);
695 }
696
697 $prop_id = mb_strtoupper($PROPERTY_ID);
698 if (isset($this->arDirProperties[$site][$path][$prop_id]))
699 {
700 return $this->arDirProperties[$site][$path][$prop_id];
701 }
702
703 return $default_value;
704 }
705
706 public function GetDirPropertyList($path = false)
707 {
709
710 if ($path === false)
711 {
712 $path = $this->GetCurDir();
713 }
714 if ($site === false)
715 {
716 $site = SITE_ID;
717 }
718
719 if (!isset($this->arDirProperties[$site][$path]))
720 {
721 $this->InitDirProperties([$site, $path]);
722 }
723
724 if (isset($this->arDirProperties[$site][$path]) && is_array($this->arDirProperties[$site][$path]))
725 {
726 return $this->arDirProperties[$site][$path];
727 }
728
729 return false;
730 }
731
732 public function GetMeta($id, $meta_name = false, $bXhtmlStyle = true)
733 {
734 if (!$meta_name)
735 {
736 $meta_name = $id;
737 }
738 $val = $this->GetProperty($id);
739 if (!empty($val))
740 {
741 return '<meta name="' . htmlspecialcharsbx($meta_name) . '" content="' . htmlspecialcharsEx($val) . '"' . ($bXhtmlStyle ? ' /' : '') . '>' . "\n";
742 }
743 return '';
744 }
745
746 public function GetLink($id, $rel = null, $bXhtmlStyle = true)
747 {
748 if ($rel === null)
749 {
750 $rel = $id;
751 }
752 $href = $this->GetProperty($id);
753 if ($href <> '')
754 {
755 return '<link rel="' . $rel . '" href="' . $href . '"' . ($bXhtmlStyle ? ' /' : '') . '>' . "\n";
756 }
757 return '';
758 }
759
760 public static function ShowBanner($type, $html_before = "", $html_after = "")
761 {
762 if (!CModule::IncludeModule("advertising"))
763 {
764 return;
765 }
766
768 global $APPLICATION;
769 $APPLICATION->AddBufferContent(["CAdvBanner", "Show"], $type, $html_before, $html_after);
770 }
771
772 public function ShowMeta($id, $meta_name = false, $bXhtmlStyle = true)
773 {
774 $this->AddBufferContent([&$this, "GetMeta"], $id, $meta_name, $bXhtmlStyle);
775 }
776
777 public function ShowLink($id, $rel = null, $bXhtmlStyle = true)
778 {
779 $this->AddBufferContent([&$this, "GetLink"], $id, $rel, $bXhtmlStyle);
780 }
781
782 public function SetAdditionalCSS($Path2css, $additional = false)
783 {
784 $this->oAsset->addCss($Path2css, $additional);
785
786 if ($additional)
787 {
788 $this->arHeadAdditionalCSS[] = $this->oAsset->getAssetPath($Path2css);
789 }
790 else
791 {
792 $this->sPath2css[] = $this->oAsset->getAssetPath($Path2css);
793 }
794 }
795
797 public function GetAdditionalCSS()
798 {
799 $n = count($this->sPath2css);
800 if ($n > 0)
801 {
802 return $this->sPath2css[$n - 1];
803 }
804 return false;
805 }
806
807 public function GetCSSArray()
808 {
809 return array_unique($this->sPath2css);
810 }
811
813 public function GetCSS($cMaxStylesCnt = true, $bXhtmlStyle = true, $assetTargetType = Main\Page\AssetShowTargetType::ALL)
814 {
815 if ($cMaxStylesCnt === true)
816 {
817 $cMaxStylesCnt = Main\Config\Option::get('main', 'max_css_files', 20);
818 }
819 $this->oAsset->setMaxCss($cMaxStylesCnt);
820 $this->oAsset->setXhtml($bXhtmlStyle);
821 $res = $this->oAsset->getCss($assetTargetType);
822 return $res;
823 }
824
825 public function ShowCSS($cMaxStylesCnt = true, $bXhtmlStyle = true)
826 {
827 $this->AddBufferContent([&$this, "GetHeadStrings"], 'BEFORE_CSS');
828 $this->AddBufferContent([&$this, "GetCSS"], $cMaxStylesCnt, $bXhtmlStyle);
829 }
830
832 public function AddHeadString($str, $bUnique = false, $location = AssetLocation::AFTER_JS_KERNEL)
833 {
834 $location = Asset::getLocationByName($location);
835 $this->oAsset->addString($str, $bUnique, $location);
836 }
837
838 public function GetHeadStrings($location = AssetLocation::AFTER_JS_KERNEL)
839 {
840 $location = Asset::getLocationByName($location);
841 if ($location === AssetLocation::AFTER_JS_KERNEL)
842 {
843 $res = $this->oAsset->getJs(1);
844 }
845 else
846 {
847 $res = $this->oAsset->getStrings($location);
848 }
849
850 return ($res == '' ? '' : $res . "\n");
851 }
852
853 public function ShowHeadStrings()
854 {
855 if (!$this->oAsset->getShowHeadString())
856 {
857 $this->oAsset->setShowHeadString();
858 $this->AddBufferContent([&$this, "GetHeadStrings"], 'DEFAULT');
859 }
860 }
861
863 public function AddHeadScript($src, $additional = false)
864 {
865 $this->oAsset->addJs($src, $additional);
866
867 if ($src <> '')
868 {
869 if ($additional)
870 {
871 $this->arHeadAdditionalScripts[] = Asset::getAssetPath($src);
872 }
873 else
874 {
875 $this->arHeadScripts[] = Asset::getAssetPath($src);
876 }
877 }
878 }
879
881 public function AddLangJS($content)
882 {
883 $this->oAsset->addString($content, true, 'AFTER_CSS');
884 }
885
887 public function AddAdditionalJS($content)
888 {
889 $this->oAsset->addString($content, false, AssetLocation::AFTER_JS);
890 }
891
892 public static function IsExternalLink($src)
893 {
894 return (strncasecmp($src, 'http://', 7) == 0 || strncasecmp($src, 'https://', 8) == 0 || strncmp($src, '//', 2) == 0);
895 }
896
898 public function AddCSSKernelInfo($module = '', $arCSS = [])
899 {
900 $this->oAsset->addCssKernelInfo($module, $arCSS);
901 }
902
904 public function AddJSKernelInfo($module = '', $arJS = [])
905 {
906 $this->oAsset->addJsKernelInfo($module, $arJS);
907 }
908
910 public function GroupModuleJS($from = '', $to = '')
911 {
912 $this->oAsset->groupJs($from, $to);
913 }
914
916 public function MoveJSToBody($module = '')
917 {
918 $this->oAsset->moveJs($module);
919 }
920
922 public function GroupModuleCSS($from = '', $to = '')
923 {
924 $this->oAsset->groupCss($from, $to);
925 }
926
928 public function SetUniqueCSS($id = '', $cssType = 'page')
929 {
930 $cssType = (($cssType == 'page') ? 'PAGE' : 'TEMPLATE');
931 $this->oAsset->setUnique($cssType, $id);
932 return true;
933 }
934
936 public function SetUniqueJS()
937 {
938 return true;
939 }
940
942 public function GetHeadScripts($type = 0)
943 {
944 return $this->oAsset->getJs($type);
945 }
946
947 public function ShowHeadScripts()
948 {
949 $this->oAsset->setShowHeadScript();
950 $this->AddBufferContent([&$this, "GetHeadScripts"], 2);
951 }
952
953 public function ShowBodyScripts()
954 {
955 $this->oAsset->setShowBodyScript();
956 $this->AddBufferContent([&$this, "GetHeadScripts"], 3);
957 }
958
959 public function ShowHead($bXhtmlStyle = true)
960 {
961 echo '<meta http-equiv="Content-Type" content="text/html; charset=' . LANG_CHARSET . '"' . ($bXhtmlStyle ? ' /' : '') . '>' . "\n";
962 $this->ShowMeta("robots", false, $bXhtmlStyle);
963 $this->ShowMeta("keywords", false, $bXhtmlStyle);
964 $this->ShowMeta("description", false, $bXhtmlStyle);
965 $this->ShowLink("canonical", null, $bXhtmlStyle);
966 $this->ShowCSS(true, $bXhtmlStyle);
967 $this->ShowHeadStrings();
968 $this->ShowHeadScripts();
969 }
970
971 public function ShowAjaxHead($bXhtmlStyle = true, $showCSS = true, $showStrings = true, $showScripts = true)
972 {
973 $this->RestartBuffer();
974 $this->sPath2css = [];
975 $this->arHeadAdditionalCSS = [];
976 $this->arHeadAdditionalStrings = [];
977 $this->arHeadAdditionalScripts = [];
978 $this->arHeadScripts = [];
979 $this->arHeadStrings = [];
980 $this->bInAjax = true;
981
982 $this->oAsset = $this->oAsset->setAjax();
983
984 if ($showCSS === true)
985 {
986 $this->ShowCSS(true, $bXhtmlStyle);
987 }
988
989 if ($showStrings === true)
990 {
991 $this->ShowHeadStrings();
992 }
993
994 if ($showScripts === true)
995 {
996 $this->ShowHeadScripts();
997 }
998 }
999
1000 public function SetShowIncludeAreas($bShow = true)
1001 {
1002 Main\Application::getInstance()->getKernelSession()["SESS_INCLUDE_AREAS"] = $bShow;
1003 }
1004
1005 public function GetShowIncludeAreas()
1006 {
1007 global $USER;
1008
1009 if (!is_object($USER) || !$USER->IsAuthorized() || defined('ADMIN_SECTION') && ADMIN_SECTION)
1010 {
1011 return false;
1012 }
1013 $kernelSession = Main\Application::getInstance()->getKernelSession();
1014 if (isset($kernelSession["SESS_INCLUDE_AREAS"]) && $kernelSession["SESS_INCLUDE_AREAS"])
1015 {
1016 return true;
1017 }
1018 static $panel_dynamic_mode = null;
1019 if (!isset($panel_dynamic_mode))
1020 {
1021 $aUserOpt = CUserOptions::GetOption("global", "settings", []);
1022 $panel_dynamic_mode = (isset($aUserOpt["panel_dynamic_mode"]) && $aUserOpt["panel_dynamic_mode"] == "Y");
1023 }
1024 return $panel_dynamic_mode;
1025 }
1026
1027 public function SetPublicShowMode($mode)
1028 {
1029 $this->SetShowIncludeAreas($mode != 'view');
1030 }
1031
1032 public function GetPublicShowMode()
1033 {
1034 return $this->GetShowIncludeAreas() ? 'configure' : 'view';
1035 }
1036
1037 public function SetEditArea($areaId, $arIcons)
1038 {
1039 if (!$this->GetShowIncludeAreas())
1040 {
1041 return;
1042 }
1043
1044 if ($this->editArea === false)
1045 {
1046 $this->editArea = new CEditArea();
1047 }
1048
1049 $this->editArea->SetEditArea($areaId, $arIcons);
1050 }
1051
1052 public function IncludeStringBefore()
1053 {
1054 if ($this->editArea === false)
1055 {
1056 $this->editArea = new CEditArea();
1057 }
1058 return $this->editArea->IncludeStringBefore();
1059 }
1060
1061 public function IncludeStringAfter($arIcons = false, $arParams = [])
1062 {
1063 return $this->editArea->IncludeStringAfter($arIcons, $arParams);
1064 }
1065
1066 public function IncludeString($string, $arIcons = false)
1067 {
1068 return $this->IncludeStringBefore() . $string . $this->IncludeStringAfter($arIcons);
1069 }
1070
1071 public function GetTemplatePath($rel_path)
1072 {
1073 if (!str_starts_with($rel_path, "/"))
1074 {
1075 if (defined("SITE_TEMPLATE_ID"))
1076 {
1077 $path = getLocalPath("templates/" . SITE_TEMPLATE_ID . "/" . $rel_path, BX_PERSONAL_ROOT);
1078 if ($path !== false)
1079 {
1080 return $path;
1081 }
1082 }
1083
1084 $path = getLocalPath("templates/.default/" . $rel_path, BX_PERSONAL_ROOT);
1085 if ($path !== false)
1086 {
1087 return $path;
1088 }
1089
1090 //we don't use /local folder for components 1.0
1091 $module_id = mb_substr($rel_path, 0, mb_strpos($rel_path, "/"));
1092 if ($module_id <> '')
1093 {
1094 $path = "/bitrix/modules/" . $module_id . "/install/templates/" . $rel_path;
1095 if (file_exists($_SERVER["DOCUMENT_ROOT"] . $path))
1096 {
1097 return $path;
1098 }
1099 }
1100
1101 return false;
1102 }
1103
1104 return $rel_path;
1105 }
1106
1107 public function SetTemplateCSS($rel_path)
1108 {
1109 if ($path = $this->GetTemplatePath($rel_path))
1110 {
1111 $this->SetAdditionalCSS($path);
1112 }
1113 }
1114
1115 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1116 // COMPONENTS 2.0 >>>>>
1117 public function IncludeComponent($componentName, $componentTemplate, $arParams = [], $parentComponent = null, $arFunctionParams = [], $returnResult = false)
1118 {
1120 global $APPLICATION, $USER;
1121
1122 if (is_array($this->arComponentMatch))
1123 {
1124 $skipComponent = true;
1125 foreach ($this->arComponentMatch as $cValue)
1126 {
1127 if (mb_strpos($componentName, $cValue) !== false)
1128 {
1129 $skipComponent = false;
1130 break;
1131 }
1132 }
1133 if ($skipComponent)
1134 {
1135 return false;
1136 }
1137 }
1138
1139 $componentRelativePath = CComponentEngine::MakeComponentPath($componentName);
1140 if ($componentRelativePath == '')
1141 {
1142 return false;
1143 }
1144
1145 $debug = null;
1146 $bShowDebug = Main\Application::getInstance()->getKernelSession()["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y"
1147 && (
1148 $USER->CanDoOperation('edit_php')
1149 || Main\Application::getInstance()->getKernelSession()["SHOW_SQL_STAT"] == "Y"
1150 )
1151 && !defined("PUBLIC_AJAX_MODE");
1152 if ($bShowDebug || $APPLICATION->ShowIncludeStat)
1153 {
1154 $debug = new CDebugInfo();
1155 $debug->Start();
1156 }
1157
1158 if (is_object($parentComponent))
1159 {
1160 if (!($parentComponent instanceof cbitrixcomponent))
1161 {
1162 $parentComponent = null;
1163 }
1164 }
1165
1166 $bDrawIcons = ((!isset($arFunctionParams["HIDE_ICONS"]) || $arFunctionParams["HIDE_ICONS"] <> "Y") && $APPLICATION->GetShowIncludeAreas());
1167
1168 if ($bDrawIcons)
1169 {
1170 echo $this->IncludeStringBefore();
1171 }
1172
1173 $result = null;
1174 $bComponentEnabled = (!isset($arFunctionParams["ACTIVE_COMPONENT"]) || $arFunctionParams["ACTIVE_COMPONENT"] <> "N");
1175
1176 $component = new CBitrixComponent();
1177 if ($component->InitComponent($componentName))
1178 {
1179 $obAjax = null;
1180 if ($bComponentEnabled)
1181 {
1182 if (($arParams['AJAX_MODE'] ?? '') == 'Y')
1183 {
1184 $obAjax = new CComponentAjax($componentName, $componentTemplate, $arParams, $parentComponent);
1185 }
1186
1187 $this->__componentStack[] = $component;
1188 $result = $component->IncludeComponent($componentTemplate, $arParams, $parentComponent, $returnResult);
1189
1190 array_pop($this->__componentStack);
1191 }
1192
1193 if ($bDrawIcons)
1194 {
1195 $panel = new CComponentPanel($component, $componentName, $componentTemplate, $parentComponent, $bComponentEnabled);
1196 $arIcons = $panel->GetIcons();
1197
1198 echo $this->IncludeStringAfter($arIcons["icons"], $arIcons["parameters"]);
1199 }
1200
1201 if ($bComponentEnabled && $obAjax)
1202 {
1203 $obAjax->Process();
1204 }
1205 }
1206
1207 if ($bShowDebug)
1208 {
1209 echo $debug->Output($componentName, "/bitrix/components" . $componentRelativePath . "/component.php", ($arParams["CACHE_TYPE"] ?? '') . ($arParams["MENU_CACHE_TYPE"] ?? ''));
1210 }
1211 elseif (isset($debug))
1212 {
1213 $debug->Stop($componentName, "/bitrix/components" . $componentRelativePath . "/component.php", ($arParams["CACHE_TYPE"] ?? '') . ($arParams["MENU_CACHE_TYPE"] ?? ''));
1214 }
1215
1216 return $result;
1217 }
1218
1226 {
1227 return end($this->__componentStack);
1228 }
1229
1234 public function getComponentStack()
1235 {
1236 return $this->__componentStack;
1237 }
1238
1244 public function clearViewContent(string $view): void
1245 {
1246 if ($this->__view[$view] ?? null)
1247 {
1248 unset($this->__view[$view]);
1249 }
1250 }
1251
1252 public function AddViewContent($view, $content, $pos = 500)
1253 {
1254 if (!isset($this->__view[$view]) || !is_array($this->__view[$view]))
1255 {
1256 $this->__view[$view] = [[$content, $pos]];
1257 }
1258 else
1259 {
1260 $this->__view[$view][] = [$content, $pos];
1261 }
1262 }
1263
1264 public function ShowViewContent($view)
1265 {
1266 $this->AddBufferContent([&$this, "GetViewContent"], $view);
1267 }
1268
1269 public function GetViewContent($view)
1270 {
1271 if (!isset($this->__view[$view]) || !is_array($this->__view[$view]))
1272 {
1273 return '';
1274 }
1275
1276 uasort(
1277 $this->__view[$view],
1278 function ($a, $b) {
1279 if ($a[1] == $b[1])
1280 {
1281 return 0;
1282 }
1283 return ($a[1] < $b[1] ? -1 : 1);
1284 }
1285 );
1286
1287 $res = [];
1288 foreach ($this->__view[$view] as $item)
1289 {
1290 $res[] = $item[0];
1291 }
1292
1293 return implode($res);
1294 }
1295
1296 public static function OnChangeFileComponent($path, $site)
1297 {
1298 // kind of optimization
1299 if (HasScriptExtension($path) && basename($path) !== '.access.php')
1300 {
1301 if ($site === false)
1302 {
1303 $site = SITE_ID;
1304 }
1305 $docRoot = CSite::GetSiteDocRoot($site);
1306
1307 Main\UrlRewriter::delete($site, ["PATH" => $path, "!ID" => '']);
1308 Main\Component\ParametersTable::deleteByFilter(["SITE_ID" => $site, "REAL_PATH" => $path]);
1310 }
1311 }
1312 // <<<<< COMPONENTS 2.0
1313 // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1314
1315 // $arParams - do not change!
1316 public function IncludeFile($rel_path, $arParams = [], $arFunctionParams = [])
1317 {
1321
1322 if (Main\Application::getInstance()->getKernelSession()["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || Main\Application::getInstance()->getKernelSession()["SHOW_SQL_STAT"] == "Y"))
1323 {
1324 $debug = new CDebugInfo();
1325 $debug->Start();
1326 }
1327 elseif ($APPLICATION->ShowIncludeStat)
1328 {
1329 $debug = new CDebugInfo();
1330 $debug->Start();
1331 }
1332 else
1333 {
1334 $debug = null;
1335 }
1336
1337 $sType = "TEMPLATE";
1338 $bComponent = false;
1339 if (!str_starts_with($rel_path, "/"))
1340 {
1341 $bComponent = true;
1342 $path = getLocalPath("templates/" . SITE_TEMPLATE_ID . "/" . $rel_path, BX_PERSONAL_ROOT);
1343 if ($path === false)
1344 {
1345 $sType = "DEFAULT";
1346 $path = getLocalPath("templates/.default/" . $rel_path, BX_PERSONAL_ROOT);
1347 if ($path === false)
1348 {
1349 $path = BX_PERSONAL_ROOT . "/templates/" . SITE_TEMPLATE_ID . "/" . $rel_path;
1350 $module_id = mb_substr($rel_path, 0, mb_strpos($rel_path, "/"));
1351 if ($module_id <> '')
1352 {
1353 $path = "/bitrix/modules/" . $module_id . "/install/templates/" . $rel_path;
1354 $sType = "MODULE";
1355 if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $path))
1356 {
1357 $sType = "TEMPLATE";
1358 $path = BX_PERSONAL_ROOT . "/templates/" . SITE_TEMPLATE_ID . "/" . $rel_path;
1359 }
1360 }
1361 }
1362 }
1363 }
1364 else
1365 {
1366 $path = $rel_path;
1367 }
1368
1369 if (isset($arFunctionParams["WORKFLOW"]) && $arFunctionParams["WORKFLOW"] && !IsModuleInstalled("workflow"))
1370 {
1371 $arFunctionParams["WORKFLOW"] = false;
1372 }
1373 elseif ($sType != "TEMPLATE" && isset($arFunctionParams["WORKFLOW"]) && $arFunctionParams["WORKFLOW"])
1374 {
1375 $arFunctionParams["WORKFLOW"] = false;
1376 }
1377
1378 $bDrawIcons = (
1379 (!isset($arFunctionParams["SHOW_BORDER"]) || $arFunctionParams["SHOW_BORDER"] !== false)
1380 && $APPLICATION->GetShowIncludeAreas()
1381 && (
1382 $USER->CanDoFileOperation('fm_edit_existent_file', [SITE_ID, $path])
1383 || ($arFunctionParams["WORKFLOW"] && $USER->CanDoFileOperation('fm_edit_in_workflow', [SITE_ID, $path]))
1384 )
1385 );
1386
1387 $iSrcLine = 0;
1388 $sSrcFile = '';
1389 $arIcons = [];
1390
1391 if ($bDrawIcons)
1392 {
1393 $path_url = "path=" . $path;
1394 $encSiteTemplateId = urlencode(SITE_TEMPLATE_ID);
1395 $editor = '';
1396 $resize = 'false';
1397
1398 if (!in_array($arFunctionParams['MODE'], ['html', 'text', 'php']))
1399 {
1400 $arFunctionParams['MODE'] = $bComponent ? 'php' : 'html';
1401 }
1402
1403 if ($sType != 'TEMPLATE')
1404 {
1405 switch ($arFunctionParams['MODE'])
1406 {
1407 case 'html':
1408 $editor = "/bitrix/admin/fileman_html_edit.php?site=" . SITE_ID . "&";
1409 break;
1410 case 'text':
1411 $editor = "/bitrix/admin/fileman_file_edit.php?site=" . SITE_ID . "&";
1412 break;
1413 case 'php':
1414 $editor = "/bitrix/admin/fileman_file_edit.php?full_src=Y&site=" . SITE_ID . "&";
1415 break;
1416 }
1417 $editor .= "templateID=" . $encSiteTemplateId . "&";
1418 }
1419 else
1420 {
1421 switch ($arFunctionParams['MODE'])
1422 {
1423 case 'html':
1424 $editor = '/bitrix/admin/public_file_edit.php?site=' . SITE_ID . '&bxpublic=Y&from=includefile&templateID=' . $encSiteTemplateId . '&';
1425 break;
1426
1427 case 'text':
1428 $editor = '/bitrix/admin/public_file_edit.php?site=' . SITE_ID . '&bxpublic=Y&from=includefile&noeditor=Y&';
1429 $resize = 'true';
1430 break;
1431
1432 case 'php':
1433 $editor = '/bitrix/admin/public_file_edit_src.php?site=' . SITE_ID . '&templateID=' . $encSiteTemplateId . '&';
1434 $resize = 'true';
1435 break;
1436 }
1437 }
1438
1439 if ($arFunctionParams["TEMPLATE"])
1440 {
1441 $arFunctionParams["TEMPLATE"] = "&template=" . urlencode($arFunctionParams["TEMPLATE"]);
1442 }
1443
1444 if ($arFunctionParams["BACK_URL"])
1445 {
1446 $arFunctionParams["BACK_URL"] = "&back_url=" . urlencode($arFunctionParams["BACK_URL"]);
1447 }
1448 else
1449 {
1450 $arFunctionParams["BACK_URL"] = "&back_url=" . urlencode($_SERVER["REQUEST_URI"]);
1451 }
1452
1453 if ($arFunctionParams["LANG"])
1454 {
1455 $arFunctionParams["LANG"] = "&lang=" . urlencode($arFunctionParams["LANG"]);
1456 }
1457 else
1458 {
1459 $arFunctionParams["LANG"] = "&lang=" . LANGUAGE_ID;
1460 }
1461
1462 $arPanelParams = [];
1463
1464 $bDefaultExists = false;
1465 if ($USER->CanDoOperation('edit_php') && $bComponent)
1466 {
1467 $bDefaultExists = true;
1468 $arPanelParams["TOOLTIP"] = [
1469 'TITLE' => GetMessage("main_incl_component1"),
1470 'TEXT' => $rel_path,
1471 ];
1472
1473 $aTrace = Main\Diag\Helper::getBackTrace(1, DEBUG_BACKTRACE_IGNORE_ARGS);
1474
1475 $sSrcFile = $aTrace[0]["file"];
1476 $iSrcLine = intval($aTrace[0]["line"]);
1477 $arIcons[] = [
1478 'URL' => 'javascript:' . $APPLICATION->GetPopupLink([
1479 'URL' => "/bitrix/admin/component_props.php?" .
1480 "path=" . urlencode(CUtil::addslashes($rel_path)) .
1481 "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) .
1482 "&lang=" . LANGUAGE_ID .
1483 "&src_path=" . urlencode(CUtil::addslashes($sSrcFile)) .
1484 "&src_line=" . $iSrcLine,
1485 ]),
1486 'ICON' => "parameters",
1487 'TITLE' => GetMessage("main_incl_file_comp_param"),
1488 'DEFAULT' => true,
1489 ];
1490 }
1491
1492 if ($sType == "MODULE")
1493 {
1494 $arIcons[] = [
1495 'URL' => 'javascript:if(confirm(\'' . GetMessage("MAIN_INC_BLOCK_MODULE") . '\'))window.location=\'' . $editor . '&path=' . urlencode(BX_PERSONAL_ROOT . '/templates/' . SITE_TEMPLATE_ID . '/' . $rel_path) . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . '&template=' . $path . '\';',
1496 'ICON' => 'copy',
1497 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", (!is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"]), GetMessage("main_incl_file_edit_copy"))),
1498 ];
1499 }
1500 elseif ($sType == "DEFAULT")
1501 {
1502 $arIcons[] = [
1503 'URL' => 'javascript:if(confirm(\'' . GetMessage("MAIN_INC_BLOCK_COMMON") . '\'))window.location=\'' . $editor . $path_url . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . $arFunctionParams["TEMPLATE"] . '\';',
1504 'ICON' => 'edit-common',
1505 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", (!is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"]), GetMessage("MAIN_INC_BLOCK_EDIT"))),
1506 ];
1507
1508 $arIcons[] = [
1509 'URL' => $editor . '&path=' . urlencode(BX_PERSONAL_ROOT . '/templates/' . SITE_TEMPLATE_ID . '/' . $rel_path) . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . '&template=' . $path,
1510 'ICON' => 'copy',
1511 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", (!is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"]), GetMessage("MAIN_INC_BLOCK_COMMON_COPY"))),
1512 ];
1513 }
1514 else
1515 {
1516 $arPanelParams["TOOLTIP"] = [
1517 'TITLE' => GetMessage('main_incl_file'),
1518 'TEXT' => $path,
1519 ];
1520
1521 $arIcons[] = [
1522 'URL' => 'javascript:' . $APPLICATION->GetPopupLink(
1523 [
1524 'URL' => $editor . $path_url . $arFunctionParams["BACK_URL"] . $arFunctionParams["LANG"] . $arFunctionParams["TEMPLATE"],
1525 "PARAMS" => [
1526 'width' => 770,
1527 'height' => 470,
1528 'resize' => $resize,
1529 ],
1530 ]
1531 ),
1532 'ICON' => 'bx-context-toolbar-edit-icon',
1533 'TITLE' => str_replace("#MODE#", $arFunctionParams["MODE"], str_replace("#BLOCK_TYPE#", (!is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"]), GetMessage("MAIN_INC_ED"))),
1534 'DEFAULT' => !$bDefaultExists,
1535 ];
1536
1537 if ($arFunctionParams["WORKFLOW"])
1538 {
1539 $arIcons[] = [
1540 'URL' => '/bitrix/admin/workflow_edit.php?' . $arFunctionParams["LANG"] . '&fname=' . urlencode($path) . $arFunctionParams["TEMPLATE"] . $arFunctionParams["BACK_URL"],
1541 'ICON' => 'bx-context-toolbar-edit-icon',
1542 'TITLE' => str_replace("#BLOCK_TYPE#", (!is_set($arFunctionParams, "NAME") ? GetMessage("MAIN__INC_BLOCK") : $arFunctionParams["NAME"]), GetMessage("MAIN_INC_ED_WF")),
1543 ];
1544 }
1545 }
1546
1547 echo $this->IncludeStringBefore();
1548 }
1549
1550 $res = null;
1551 if (is_file($_SERVER["DOCUMENT_ROOT"] . $path))
1552 {
1553 if (is_array($arParams))
1554 {
1555 extract($arParams, EXTR_SKIP);
1556 }
1557
1558 $res = include($_SERVER["DOCUMENT_ROOT"] . $path);
1559 }
1560
1561 if (Main\Application::getInstance()->getKernelSession()["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || Main\Application::getInstance()->getKernelSession()["SHOW_SQL_STAT"] == "Y"))
1562 {
1563 echo $debug->Output($rel_path, $path);
1564 }
1565 elseif (is_object($debug))
1566 {
1567 $debug->Stop($rel_path, $path);
1568 }
1569
1570 if ($bDrawIcons)
1571 {
1572 $comp_id = $path;
1573 if ($sSrcFile)
1574 {
1575 $comp_id .= '|' . $sSrcFile;
1576 }
1577 if ($iSrcLine)
1578 {
1579 $comp_id .= '|' . $iSrcLine;
1580 }
1581
1582 $arPanelParams['COMPONENT_ID'] = md5($comp_id);
1583 echo $this->IncludeStringAfter($arIcons, $arPanelParams);
1584 }
1585
1586 return $res;
1587 }
1588
1589 public function AddChainItem($title, $link = "", $bUnQuote = true)
1590 {
1591 if ($bUnQuote)
1592 {
1593 $title = str_replace(["&amp;", "&quot;", "&#039;", "&lt;", "&gt;"], ["&", "\"", "'", "<", ">"], $title);
1594 }
1595 $this->arAdditionalChain[] = ["TITLE" => $title, "LINK" => htmlspecialcharsbx($link)];
1596 }
1597
1598 public function GetNavChain($path = false, $iNumFrom = 0, $sNavChainPath = false, $bIncludeOnce = false, $bShowIcons = true)
1599 {
1600 if ($this->GetProperty("NOT_SHOW_NAV_CHAIN") == "Y")
1601 {
1602 return "";
1603 }
1604
1605 CMain::InitPathVars($site, $path);
1606 $DOC_ROOT = CSite::GetSiteDocRoot($site);
1607
1608 if ($path === false)
1609 {
1610 $path = $this->GetCurDir();
1611 }
1612
1613 $arChain = [];
1614 $strChainTemplate = $DOC_ROOT . SITE_TEMPLATE_PATH . "/chain_template.php";
1615 if (!file_exists($strChainTemplate))
1616 {
1617 if (($template = getLocalPath("templates/.default/chain_template.php", BX_PERSONAL_ROOT)) !== false)
1618 {
1619 $strChainTemplate = $DOC_ROOT . $template;
1620 }
1621 }
1622
1623 $io = CBXVirtualIo::GetInstance();
1624
1625 while (true)//until the root
1626 {
1627 $path = rtrim($path, "/");
1628
1629 $chain_file_name = $DOC_ROOT . $path . "/.section.php";
1630 if ($io->FileExists($chain_file_name))
1631 {
1632 $sChainTemplate = "";
1633 $sSectionName = "";
1634 include($io->GetPhysicalName($chain_file_name));
1635 if ($sSectionName <> '')
1636 {
1637 $arChain[] = ["TITLE" => $sSectionName, "LINK" => $path . "/"];
1638 }
1639 if ($sChainTemplate <> '')
1640 {
1641 $strChainTemplate = $sChainTemplate;
1642 }
1643 }
1644
1645 if ($path . '/' == SITE_DIR)
1646 {
1647 break;
1648 }
1649
1650 if ($path == '')
1651 {
1652 break;
1653 }
1654
1655 //file or folder
1656 $pos = bxstrrpos($path, "/");
1657 if ($pos === false)
1658 {
1659 break;
1660 }
1661
1662 //parent folder
1663 $path = mb_substr($path, 0, $pos + 1);
1664 }
1665
1666 if ($sNavChainPath !== false)
1667 {
1668 $strChainTemplate = $DOC_ROOT . $sNavChainPath;
1669 }
1670
1671 $arChain = array_reverse($arChain);
1672 $arChain = array_merge($arChain, $this->arAdditionalChain);
1673 if ($iNumFrom > 0)
1674 {
1675 $arChain = array_slice($arChain, $iNumFrom);
1676 }
1677
1678 return $this->_mkchain($arChain, $strChainTemplate, $bIncludeOnce, $bShowIcons);
1679 }
1680
1681 public function _mkchain($arChain, $strChainTemplate, $bIncludeOnce = false, $bShowIcons = true)
1682 {
1683 $strChain = $sChainProlog = $sChainEpilog = "";
1684 if (file_exists($strChainTemplate))
1685 {
1686 $ITEM_COUNT = count($arChain);
1687 $arCHAIN = $arChain;
1688 $arCHAIN_LINK = &$arChain;
1689 $arResult = &$arChain; // for component 2.0
1690 if ($bIncludeOnce)
1691 {
1692 $strChain = include($strChainTemplate);
1693 }
1694 else
1695 {
1696 foreach ($arChain as $i => $arChainItem)
1697 {
1698 $ITEM_INDEX = $i;
1699 $TITLE = $arChainItem["TITLE"];
1700 $LINK = $arChainItem["LINK"];
1701 $sChainBody = "";
1702 include($strChainTemplate);
1703 $strChain .= $sChainBody;
1704 if ($i == 0)
1705 {
1706 $strChain = $sChainProlog . $strChain;
1707 }
1708 }
1709 if (!empty($arChain))
1710 {
1711 $strChain .= $sChainEpilog;
1712 }
1713 }
1714 }
1715
1717 global $USER;
1718 if ($this->GetShowIncludeAreas() && $USER->CanDoOperation('edit_php') && $bShowIcons)
1719 {
1720 $site = CSite::GetSiteByFullPath($strChainTemplate);
1721 $DOC_ROOT = CSite::GetSiteDocRoot($site);
1722
1723 if (mb_strpos($strChainTemplate, $DOC_ROOT) === 0)
1724 {
1725 $path = mb_substr($strChainTemplate, mb_strlen($DOC_ROOT));
1726
1727 $templ_perm = $this->GetFileAccessPermission($path);
1728 if ((!defined("ADMIN_SECTION") || ADMIN_SECTION !== true) && $templ_perm >= "W")
1729 {
1730 $arIcons = [];
1731 $arIcons[] = [
1732 "URL" => "/bitrix/admin/fileman_file_edit.php?lang=" . LANGUAGE_ID . "&site=" . $site . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&full_src=Y&path=" . urlencode($path),
1733 "ICON" => "nav-template",
1734 "TITLE" => GetMessage("MAIN_INC_ED_NAV"),
1735 ];
1736
1737 $strChain = $this->IncludeString($strChain, $arIcons);
1738 }
1739 }
1740 }
1741 return $strChain;
1742 }
1743
1744 public function ShowNavChain($path = false, $iNumFrom = 0, $sNavChainPath = false)
1745 {
1746 $this->AddBufferContent([&$this, "GetNavChain"], $path, $iNumFrom, $sNavChainPath);
1747 }
1748
1749 public function ShowNavChainEx($path = false, $iNumFrom = 0, $sNavChainPath = false)
1750 {
1751 $this->AddBufferContent([&$this, "GetNavChain"], $path, $iNumFrom, $sNavChainPath, true);
1752 }
1753
1754 /*****************************************************/
1755
1756 public function SetFileAccessPermission($path, $arPermissions, $bOverWrite = true)
1757 {
1758 global $CACHE_MANAGER;
1759
1760 CMain::InitPathVars($site, $path);
1761 $DOC_ROOT = CSite::GetSiteDocRoot($site);
1762
1763 $path = rtrim($path, "/");
1764 if ($path == '')
1765 {
1766 $path = "/";
1767 }
1768
1769 if (($p = bxstrrpos($path, "/")) !== false)
1770 {
1771 $path_file = mb_substr($path, $p + 1);
1772 $path_dir = mb_substr($path, 0, $p);
1773 }
1774 else
1775 {
1776 return false;
1777 }
1778
1779 if ($path_file == "" && $path_dir == "")
1780 {
1781 $path_file = "/";
1782 }
1783
1784 $PERM = [];
1785
1786 $io = CBXVirtualIo::GetInstance();
1787 if ($io->FileExists($DOC_ROOT . $path_dir . "/.access.php"))
1788 {
1789 include $io->GetPhysicalName($DOC_ROOT . $path_dir . "/.access.php");
1790 }
1791
1792 $FILE_PERM = $PERM[$path_file];
1793 if (!is_array($FILE_PERM))
1794 {
1795 $FILE_PERM = [];
1796 }
1797
1798 if (!$bOverWrite && !empty($FILE_PERM))
1799 {
1800 return true;
1801 }
1802
1803 $bDiff = false;
1804
1805 $str = "<?\n";
1806 foreach ($arPermissions as $group => $perm)
1807 {
1808 if ($perm <> '')
1809 {
1810 $str .= "\$PERM[\"" . EscapePHPString($path_file) . "\"][\"" . EscapePHPString($group) . "\"]=\"" . EscapePHPString($perm) . "\";\n";
1811 }
1812
1813 if (!$bDiff)
1814 {
1815 //compatibility with group id
1816 $curr_perm = $FILE_PERM[$group];
1817 if (!isset($curr_perm) && preg_match('/^G[0-9]+$/', $group))
1818 {
1819 $curr_perm = $FILE_PERM[mb_substr($group, 1)];
1820 }
1821
1822 if ($curr_perm != $perm)
1823 {
1824 $bDiff = true;
1825 }
1826 }
1827 }
1828
1829 foreach ($PERM as $file => $arPerm)
1830 {
1831 if (strval($file) !== $path_file)
1832 {
1833 foreach ($arPerm as $group => $perm)
1834 {
1835 $str .= "\$PERM[\"" . EscapePHPString($file) . "\"][\"" . EscapePHPString($group) . "\"]=\"" . EscapePHPString($perm) . "\";\n";
1836 }
1837 }
1838 }
1839
1840 if (!$bDiff)
1841 {
1842 foreach ($FILE_PERM as $group => $perm)
1843 {
1844 //compatibility with group id
1845 $new_perm = $arPermissions[$group];
1846 if (!isset($new_perm) && preg_match('/^G[0-9]+$/', $group))
1847 {
1848 $new_perm = $arPermissions[substr($group, 1)];
1849 }
1850
1851 if ($new_perm != $perm)
1852 {
1853 $bDiff = true;
1854 break;
1855 }
1856 }
1857 }
1858
1859 $str .= "?" . ">";
1860
1861 $this->SaveFileContent($DOC_ROOT . $path_dir . "/.access.php", $str);
1862 $CACHE_MANAGER->CleanDir("menu");
1864 unset($this->FILE_PERMISSION_CACHE[$site . "|" . $path_dir . "/.access.php"]);
1865
1866 if ($bDiff)
1867 {
1868 foreach (GetModuleEvents("main", "OnChangePermissions", true) as $arEvent)
1869 {
1870 ExecuteModuleEventEx($arEvent, [[$site, $path], $arPermissions, $FILE_PERM]);
1871 }
1872
1873 if (COption::GetOptionString("main", "event_log_file_access", "N") === "Y")
1874 {
1875 CEventLog::Log(CEventLog::SEVERITY_SECURITY, "FILE_PERMISSION_CHANGED", "main", "[" . $site . "] " . $path, ['before' => $FILE_PERM, 'after' => array_filter($arPermissions)]);
1876 }
1877 }
1878 return true;
1879 }
1880
1882 {
1883 global $CACHE_MANAGER;
1884
1886 $DOC_ROOT = CSite::GetSiteDocRoot($site);
1887
1888 $path = rtrim($path, "/");
1889 if ($path == '')
1890 {
1891 $path = "/";
1892 }
1893
1894 if (($p = bxstrrpos($path, "/")) !== false)
1895 {
1896 $path_file = mb_substr($path, $p + 1);
1897 $path_dir = mb_substr($path, 0, $p);
1898 }
1899 else
1900 {
1901 return false;
1902 }
1903
1904 $PERM = [];
1906 if (!$io->FileExists($DOC_ROOT . $path_dir . "/.access.php"))
1907 {
1908 return true;
1909 }
1910
1911 include($io->GetPhysicalName($DOC_ROOT . $path_dir . "/.access.php"));
1912
1913 $str = "<?\n";
1914 foreach ($PERM as $file => $arPerm)
1915 {
1916 if ($file != $path_file || $arGroups !== false)
1917 {
1918 foreach ($arPerm as $group => $perm)
1919 {
1920 $bExists = false;
1921 if (is_array($arGroups))
1922 {
1923 //compatibility with group id
1924 if (in_array($group, $arGroups))
1925 {
1926 $bExists = true;
1927 }
1928 elseif (preg_match('/^G[0-9]+$/', $group) && in_array(mb_substr($group, 1), $arGroups))
1929 {
1930 $bExists = true;
1931 }
1932 elseif (preg_match('/^[0-9]+$/', $group) && in_array('G' . $group, $arGroups))
1933 {
1934 $bExists = true;
1935 }
1936 }
1937 if ($file != $path_file || ($arGroups !== false && !$bExists))
1938 {
1939 $str .= "\$PERM[\"" . EscapePHPString($file) . "\"][\"" . EscapePHPString($group) . "\"]=\"" . EscapePHPString($perm) . "\";\n";
1940 }
1941 }
1942 }
1943 }
1944
1945 $str .= "?" . ">";
1946
1947 $this->SaveFileContent($DOC_ROOT . $path_dir . "/.access.php", $str);
1948 $CACHE_MANAGER->CleanDir("menu");
1949 CBitrixComponent::clearComponentCache("bitrix:menu");
1950 unset($this->FILE_PERMISSION_CACHE[$site . "|" . $path_dir . "/.access.php"]);
1951
1952 foreach (GetModuleEvents("main", "OnChangePermissions", true) as $arEvent)
1953 {
1954 ExecuteModuleEventEx($arEvent, [[$site, $path], []]);
1955 }
1956
1957 return true;
1958 }
1959
1960 public function CopyFileAccessPermission($path_from, $path_to, $bOverWrite = false)
1961 {
1962 CMain::InitPathVars($site_from, $path_from);
1963 $DOC_ROOT_FROM = CSite::GetSiteDocRoot($site_from);
1964
1965 CMain::InitPathVars($site_to, $path_to);
1966
1967 //upper .access.php
1968 if (($p = bxstrrpos($path_from, "/")) !== false)
1969 {
1970 $path_from_file = mb_substr($path_from, $p + 1);
1971 $path_from_dir = mb_substr($path_from, 0, $p);
1972 }
1973 else
1974 {
1975 return false;
1976 }
1977
1978 $PERM = [];
1979
1981 if (!$io->FileExists($DOC_ROOT_FROM . $path_from_dir . "/.access.php"))
1982 {
1983 return true;
1984 }
1985
1986 include($io->GetPhysicalName($DOC_ROOT_FROM . $path_from_dir . "/.access.php"));
1987
1988 $FILE_PERM = $PERM[$path_from_file];
1989 if (!empty($FILE_PERM))
1990 {
1991 return $this->SetFileAccessPermission([$site_to, $path_to], $FILE_PERM, $bOverWrite);
1992 }
1993
1994 return true;
1995 }
1996
1997 public function GetFileAccessPermission($path, $groups = false, $task_mode = false) // task_mode - new access mode
1998 {
1999 global $USER;
2000
2001 if ($groups === false)
2002 {
2003 if (!is_object($USER))
2004 {
2005 $groups = ['G2'];
2006 }
2007 else
2008 {
2009 $groups = $USER->GetAccessCodes();
2010 }
2011 }
2012 elseif (is_array($groups) && !empty($groups))
2013 {
2014 //compatibility with user groups id
2015 $bNumbers = preg_match('/^[0-9]+$/', $groups[0]);
2016 if ($bNumbers)
2017 {
2018 foreach ($groups as $key => $val)
2019 {
2020 $groups[$key] = "G" . $val;
2021 }
2022 }
2023 }
2024
2026 $DOC_ROOT = CSite::GetSiteDocRoot($site);
2027
2028 //Windows files are case-insensitive
2029 $bWin = (strncasecmp(PHP_OS, "WIN", 3) == 0);
2030 if ($bWin)
2031 {
2032 $path = mb_strtolower($path);
2033 }
2034
2035 if (trim($path, "/") != "")
2036 {
2037 $path = Rel2Abs("/", $path);
2038 if ($path == "")
2039 {
2040 return (!$task_mode ? 'D' : [CTask::GetIdByLetter('D', 'main', 'file')]);
2041 }
2042 }
2043
2044 if (COption::GetOptionString("main", "controller_member", "N") == "Y" && COption::GetOptionString("main", "~controller_limited_admin", "N") == "Y")
2045 {
2046 $bAdminM = (is_object($USER) && $USER->IsAdmin());
2047 }
2048 else
2049 {
2050 $bAdminM = in_array("G1", $groups);
2051 }
2052
2053 if ($bAdminM)
2054 {
2055 return (!$task_mode ? 'X' : [CTask::GetIdByLetter('X', 'main', 'file')]);
2056 }
2057
2059 {
2060 return (!$task_mode ? 'D' : [CTask::GetIdByLetter('D', 'main', 'file')]);
2061 }
2062
2063 $max_perm = "D";
2064 $arGroupTask = [];
2065
2067
2068 //in the group list * === "any group"
2069 $groups[] = "*";
2070 while (true)//till the root
2071 {
2072 $path = rtrim($path, "\0");
2073 $path = rtrim($path, "/");
2074
2075 if ($path == '')
2076 {
2077 $access_file_name = "/.access.php";
2078 $Dir = "/";
2079 }
2080 else
2081 {
2082 //file or folder
2083 $pos = bxstrrpos($path, "/");
2084 if ($pos === false)
2085 {
2086 break;
2087 }
2088 $Dir = mb_substr($path, $pos + 1);
2089
2090 //security fix: under Windows "my." == "my"
2091 $Dir = TrimUnsafe($Dir);
2092
2093 //parent folder
2094 $path = mb_substr($path, 0, $pos + 1);
2095
2096 $access_file_name = $path . ".access.php";
2097 }
2098
2099 if (array_key_exists($site . "|" . $access_file_name, $this->FILE_PERMISSION_CACHE))
2100 {
2101 $PERM = $this->FILE_PERMISSION_CACHE[$site . "|" . $access_file_name];
2102 }
2103 else
2104 {
2105 $PERM = [];
2106
2107 //file with rights array
2108 if ($io->FileExists($DOC_ROOT . $access_file_name))
2109 {
2110 include($io->GetPhysicalName($DOC_ROOT . $access_file_name));
2111 }
2112
2113 //Windows files are case-insensitive
2114 if ($bWin && !empty($PERM))
2115 {
2116 $PERM_TMP = [];
2117 foreach ($PERM as $key => $val)
2118 {
2119 $PERM_TMP[mb_strtolower($key)] = $val;
2120 }
2121 $PERM = $PERM_TMP;
2122 }
2123
2124 $this->FILE_PERMISSION_CACHE[$site . "|" . $access_file_name] = $PERM;
2125 }
2126
2127 //check wheather the rights are assigned to this file\folder for these groups
2128 if (isset($PERM[$Dir]) && is_array($PERM[$Dir]))
2129 {
2130 $dir_perm = $PERM[$Dir];
2131 foreach ($groups as $key => $group_id)
2132 {
2133 if (isset($dir_perm[$group_id]))
2134 {
2135 $perm = $dir_perm[$group_id];
2136 }
2137 elseif (preg_match('/^G([0-9]+)$/', $group_id, $match)) //compatibility with group id
2138 {
2139 if (isset($dir_perm[$match[1]]))
2140 {
2141 $perm = $dir_perm[$match[1]];
2142 }
2143 else
2144 {
2145 continue;
2146 }
2147 }
2148 else
2149 {
2150 continue;
2151 }
2152
2153 if ($task_mode)
2154 {
2155 if (str_starts_with($perm, 'T_'))
2156 {
2157 $tid = intval(substr($perm, 2));
2158 }
2159 elseif (($tid = CTask::GetIdByLetter($perm, 'main', 'file')) === false)
2160 {
2161 continue;
2162 }
2163
2164 $arGroupTask[$group_id] = $tid;
2165 }
2166 else
2167 {
2168 if (str_starts_with($perm, 'T_'))
2169 {
2170 $tid = intval(substr($perm, 2));
2171 $perm = CTask::GetLetter($tid);
2172 if ($perm == '')
2173 {
2174 $perm = 'D';
2175 }
2176 }
2177
2178 if ($max_perm == "" || $perm > $max_perm)
2179 {
2180 $max_perm = $perm;
2181 if ($perm == "W")
2182 {
2183 break 2;
2184 }
2185 }
2186 }
2187
2188 if ($group_id == "*")
2189 {
2190 break 2;
2191 }
2192
2193 // delete the group from the list, we have rights already for it
2194 unset($groups[$key]);
2195
2196 if (count($groups) == 1 && in_array("*", $groups))
2197 {
2198 break 2;
2199 }
2200 }
2201
2202 if (count($groups) <= 1)
2203 {
2204 break;
2205 }
2206 }
2207
2208 if ($path == '')
2209 {
2210 break;
2211 }
2212 }
2213
2214 if ($task_mode)
2215 {
2216 $arTasks = array_unique(array_values($arGroupTask));
2217 if (empty($arTasks))
2218 {
2219 return [CTask::GetIdByLetter('D', 'main', 'file')];
2220 }
2221 sort($arTasks);
2222 return $arTasks;
2223 }
2224 else
2225 {
2226 return $max_perm;
2227 }
2228 }
2229
2233 public function GetFileAccessPermissionByUser($userID, $path, $groups = false, $task_mode = false)
2234 {
2235 $intUserID = intval($userID);
2236 if ($intUserID . '|' != $userID . '|')
2237 {
2238 return (!$task_mode ? 'D' : [CTask::GetIdByLetter('D', 'main', 'file')]);
2239 }
2240
2241 if ($groups === false)
2242 {
2243 $groups = CUser::GetUserGroup($intUserID);
2244 }
2245
2246 return $this->GetFileAccessPermission($path, $groups, $task_mode);
2247 }
2248
2249 public function SaveFileContent($abs_path, $strContent)
2250 {
2251 $strContent = str_replace("\r\n", "\n", $strContent);
2252
2253 $file = [];
2254 $this->ResetException();
2255
2256 foreach (GetModuleEvents("main", "OnBeforeChangeFile", true) as $arEvent)
2257 {
2258 if (!ExecuteModuleEventEx($arEvent, [$abs_path, &$strContent]))
2259 {
2260 if (!$this->GetException())
2261 {
2262 $this->ThrowException(GetMessage("main_save_file_handler_error", ["#HANDLER#" => $arEvent["TO_NAME"]]));
2263 }
2264 return false;
2265 }
2266 }
2267
2269 $fileIo = $io->GetFile($abs_path);
2270
2271 $io->CreateDirectory($fileIo->GetPath());
2272
2273 if ($fileIo->IsExists())
2274 {
2275 $file["exists"] = true;
2276 if (!$fileIo->IsWritable())
2277 {
2278 $fileIo->MarkWritable();
2279 }
2280 $file["size"] = $fileIo->GetFileSize();
2281 }
2282
2283 /****************************** QUOTA ******************************/
2284 if (COption::GetOptionInt("main", "disk_space") > 0)
2285 {
2286 $quota = new CDiskQuota();
2287 if (false === $quota->checkDiskQuota(["FILE_SIZE" => mb_strlen($strContent) - intval($file["size"])]))
2288 {
2289 $this->ThrowException($quota->LAST_ERROR, "BAD_QUOTA");
2290 return false;
2291 }
2292 }
2293 /****************************** QUOTA ******************************/
2294 if ($fileIo->PutContents($strContent))
2295 {
2296 $fileIo->MarkWritable();
2297 }
2298 else
2299 {
2300 if ($file["exists"])
2301 {
2302 $this->ThrowException(GetMessage("MAIN_FILE_NOT_CREATE"), "FILE_NOT_CREATE");
2303 }
2304 else
2305 {
2306 $this->ThrowException(GetMessage("MAIN_FILE_NOT_OPENED"), "FILE_NOT_OPEN");
2307 }
2308 return false;
2309 }
2310
2312
2313 $site = CSite::GetSiteByFullPath($abs_path);
2314 $DOC_ROOT = CSite::GetSiteDocRoot($site);
2315 if (mb_strtoupper(mb_substr(PHP_OS, 0, 3)) === 'WIN')
2316 {
2317 //Fix for name case under Windows
2318 $abs_path = mb_strtolower($abs_path);
2319 $DOC_ROOT = mb_strtolower($DOC_ROOT);
2320 }
2321
2322 if (mb_strpos($abs_path, $DOC_ROOT) === 0 && $site !== false)
2323 {
2324 $DOC_ROOT = rtrim($DOC_ROOT, "/\\");
2325 $path = "/" . ltrim(mb_substr($abs_path, mb_strlen($DOC_ROOT)), "/\\");
2326
2327 foreach (GetModuleEvents("main", "OnChangeFile", true) as $arEvent)
2328 {
2329 ExecuteModuleEventEx($arEvent, [$path, $site]);
2330 }
2331 }
2332 /****************************** QUOTA ******************************/
2333 if (COption::GetOptionInt("main", "disk_space") > 0)
2334 {
2335 $fs = $fileIo->GetFileSize();
2336 CDiskQuota::updateDiskQuota("files", $fs - intval($file["size"]), "update");
2337 }
2338 /****************************** QUOTA ******************************/
2339 return true;
2340 }
2341
2342 public function GetFileContent($path)
2343 {
2344 clearstatcache();
2345
2347
2348 if (!$io->FileExists($path))
2349 {
2350 return false;
2351 }
2352 $f = $io->GetFile($path);
2353 if ($f->GetFileSize() <= 0)
2354 {
2355 return "";
2356 }
2357 $contents = $f->GetContents();
2358 return $contents;
2359 }
2360
2364 public static function ProcessLPA($filesrc = false, $old_filesrc = false)
2365 {
2366 return LPA::Process($filesrc, $old_filesrc);
2367 }
2368
2372 public static function LPAComponentChecker(&$arParams, &$arPHPparams, $parentParamName = false)
2373 {
2374 LPA::ComponentChecker($arParams, $arPHPparams, $parentParamName);
2375 }
2376
2377 public static function _ReplaceNonLatin($str)
2378 {
2379 return preg_replace("/[^a-zA-Z0-9_:.!\$\\-;@^~]/i", "", $str);
2380 }
2381
2382 public function GetLangSwitcherArray()
2383 {
2384 return $this->GetSiteSwitcherArray();
2385 }
2386
2387 public function GetSiteSwitcherArray()
2388 {
2389 $cur_dir = $this->GetCurDir();
2390 $cur_page = $this->GetCurPage();
2391 $bAdmin = (str_starts_with($cur_dir, BX_ROOT . "/admin/"));
2392
2393 $path_without_lang = $path_without_lang_tmp = "";
2394
2395 $db_res = CSite::GetList('', '', ["ACTIVE" => "Y", "ID" => LANG]);
2396 if (($ar = $db_res->Fetch()) && mb_strpos($cur_page, $ar["DIR"]) === 0)
2397 {
2398 $path_without_lang = mb_substr($cur_page, mb_strlen($ar["DIR"]) - 1);
2399 $path_without_lang = ltrim($path_without_lang, "/");
2400 $path_without_lang_tmp = rtrim($path_without_lang, "/");
2401 }
2402
2403 $result = [];
2404 $db_res = CSite::GetList("SORT", "ASC", ["ACTIVE" => "Y"]);
2405 while ($ar = $db_res->Fetch())
2406 {
2407 $ar["NAME"] = htmlspecialcharsbx($ar["NAME"]);
2408 $ar["SELECTED"] = ($ar["LID"] == LANG);
2409
2410 if ($bAdmin)
2411 {
2412 $p = rtrim(str_replace("&#", "#", preg_replace("/lang=[^&#]*&*/", "", $_SERVER["QUERY_STRING"])), "&");
2413 $ar["PATH"] = $this->GetCurPage() . "?lang=" . $ar["LID"] . ($p <> '' ? '&' . $p : '');
2414 }
2415 else
2416 {
2417 $ar["PATH"] = "";
2418
2419 if (mb_strlen($path_without_lang) > 1 && file_exists($ar["ABS_DOC_ROOT"] . "/" . $ar["DIR"] . "/" . $path_without_lang_tmp))
2420 {
2421 $ar["PATH"] = $ar["DIR"] . $path_without_lang;
2422 }
2423
2424 if ($ar["PATH"] == '')
2425 {
2426 $ar["PATH"] = $ar["DIR"];
2427 }
2428
2429 if ($ar["ABS_DOC_ROOT"] !== $_SERVER["DOCUMENT_ROOT"])
2430 {
2431 $ar["FULL_URL"] = (CMain::IsHTTPS() ? "https://" : "http://") . $ar["SERVER_NAME"] . $ar["PATH"];
2432 }
2433 else
2434 {
2435 $ar["FULL_URL"] = $ar["PATH"];
2436 }
2437 }
2438
2439 $result[] = $ar;
2440 }
2441 return $result;
2442 }
2443
2444 /*
2445 Returns an array of roles for a module
2446 W - max rights (admin)
2447 D - min rights (access denied)
2448
2449 $module_id - a module id
2450 $arGroups - array of groups ID, if not set then for current useer
2451 $use_default_role - "Y" - use default role
2452 $max_role_for_super_admin - "Y" - for group ID=1 return max rights
2453 */
2454 public static function GetUserRoles($module_id, $arGroups = false, $use_default_role = "Y", $max_role_for_super_admin = "Y", $site_id = false)
2455 {
2456 global $DB, $USER;
2457 static $MODULE_ROLES = [];
2458
2459 $arRoles = [];
2460 $min_role = "D";
2461 $max_role = "W";
2462 if ($arGroups === false)
2463 {
2464 if (is_object($USER))
2465 {
2466 $arGroups = $USER->GetUserGroupArray();
2467 }
2468 if (!is_array($arGroups))
2469 {
2470 $arGroups[] = 2;
2471 }
2472 }
2473 $key = $use_default_role . "_" . $max_role_for_super_admin;
2474 $groups = '';
2475 if (is_array($arGroups) && !empty($arGroups))
2476 {
2477 foreach ($arGroups as $grp)
2478 {
2479 $groups .= ($groups <> '' ? ',' : '') . intval($grp);
2480 }
2481 $key .= "_" . $groups;
2482 }
2483
2484 $cache_site_key = ($site_id ?: "COMMON");
2485
2486 if (isset($MODULE_ROLES[$module_id][$cache_site_key][$key]))
2487 {
2488 $arRoles = $MODULE_ROLES[$module_id][$cache_site_key][$key];
2489 }
2490 else
2491 {
2492 if (is_array($arGroups) && !empty($arGroups))
2493 {
2494 if (in_array(1, $arGroups) && $max_role_for_super_admin == "Y")
2495 {
2496 $arRoles[] = $max_role;
2497 }
2498
2499 $strSql =
2500 "SELECT MG.G_ACCESS FROM b_group G " .
2501 " LEFT JOIN b_module_group MG ON (G.ID = MG.GROUP_ID " .
2502 " AND MG.MODULE_ID = '" . $DB->ForSql($module_id, 50) . "') " .
2503 " AND MG.SITE_ID " . ($site_id ? "= '" . $DB->ForSql($site_id) . "'" : "IS NULL") . " " .
2504 "WHERE G.ID in (" . $groups . ") AND G.ACTIVE = 'Y'";
2505
2506 $t = $DB->Query($strSql);
2507
2508 $default_role = $min_role;
2509 if ($use_default_role == "Y")
2510 {
2511 $default_role = COption::GetOptionString($module_id, "GROUP_DEFAULT_RIGHT", $min_role);
2512 }
2513
2514 while ($tr = $t->Fetch())
2515 {
2516 if ($tr["G_ACCESS"] !== null)
2517 {
2518 $arRoles[] = $tr["G_ACCESS"];
2519 }
2520 else
2521 {
2522 if ($use_default_role == "Y")
2523 {
2524 $arRoles[] = $default_role;
2525 }
2526 }
2527 }
2528 }
2529 //if($use_default_role=="Y")
2530 //{
2531 // $arRoles[] = COption::GetOptionString($module_id, "GROUP_DEFAULT_RIGHT", $min_role);
2532 //}
2533 $arRoles = array_unique($arRoles);
2534 $MODULE_ROLES[$module_id][$cache_site_key][$key] = $arRoles;
2535 }
2536 return $arRoles;
2537 }
2538
2549 public static function GetUserRight($moduleId, $groups = false, $use_default_level = 'Y', $max_right_for_super_admin = 'Y', $siteId = false)
2550 {
2551 global $USER;
2552
2553 $minRight = 'D';
2554 $maxRight = 'W';
2555
2556 if ($groups === false && ($USER instanceof CUser))
2557 {
2558 if ($max_right_for_super_admin == 'Y' && $USER->IsAdmin())
2559 {
2560 return $maxRight;
2561 }
2562 $groups = $USER->GetUserGroupArray();
2563 }
2564
2565 if (!is_array($groups))
2566 {
2567 $groups = [2];
2568 }
2569
2570 if (
2571 $max_right_for_super_admin == 'Y'
2572 && in_array(1, $groups)
2573 && (
2574 COption::GetOptionString('main', 'controller_member', 'N') != 'Y'
2575 || COption::GetOptionString('main', '~controller_limited_admin', 'N') != 'Y'
2576 )
2577 )
2578 {
2579 return $maxRight;
2580 }
2581
2582 if (!is_array($siteId))
2583 {
2584 $siteId = [$siteId];
2585 }
2586
2587 $modulePermissions = ModuleGroupTable::query()
2588 ->setSelect(['*'])
2589 ->where('MODULE_ID', $moduleId)
2590 ->where('GROUP.ACTIVE', 'Y')
2591 ->setCacheTtl(86400)
2592 ->cacheJoins(true)
2593 ->fetchAll()
2594 ;
2595
2596 $right = '';
2597 foreach ($modulePermissions as $permission)
2598 {
2599 // site filter
2600 if (in_array($permission['SITE_ID'], $siteId))
2601 {
2602 // group filter
2603 if (in_array($permission['GROUP_ID'], $groups))
2604 {
2605 // max
2606 if ($permission['G_ACCESS'] > $right)
2607 {
2608 $right = $permission['G_ACCESS'];
2609 }
2610 }
2611 }
2612 }
2613
2614 if ($right == '' && $use_default_level == 'Y')
2615 {
2616 $right = COption::GetOptionString($moduleId, 'GROUP_DEFAULT_RIGHT', $minRight);
2617 }
2618
2619 return $right;
2620 }
2621
2622 public static function GetUserRightArray($moduleId, $groups)
2623 {
2624 $arRes = [];
2625
2626 if (is_array($groups) && !empty($groups))
2627 {
2628 $query = ModuleGroupTable::query()
2629 ->setSelect(['*'])
2630 ->where('MODULE_ID', $moduleId)
2631 ->where('GROUP.ACTIVE', 'Y')
2632 ->setCacheTtl(86400)
2633 ->cacheJoins(true)
2634 ->exec()
2635 ;
2636
2637 while ($tr = $query->fetch())
2638 {
2639 if (in_array($tr['GROUP_ID'], $groups))
2640 {
2641 $arRes[($tr['SITE_ID'] != '' ? $tr['SITE_ID'] : 'common')][$tr['GROUP_ID']] = $tr['G_ACCESS'];
2642 }
2643 }
2644 }
2645
2646 return $arRes;
2647 }
2648
2649 public static function GetGroupRightList($arFilter, $site_id = false)
2650 {
2651 static $fields = ['MODULE_ID' => 1, 'GROUP_ID' => 1, 'G_ACCESS' => 1];
2652
2653 $query = ModuleGroupTable::query()->setSelect(['*']);
2654
2655 foreach ($arFilter as $field => $value)
2656 {
2657 if (isset($fields[$field]))
2658 {
2659 $query->where($field, $value);
2660 }
2661 }
2662
2663 if ($site_id)
2664 {
2665 $query->where('SITE_ID', $site_id);
2666 }
2667 else
2668 {
2669 $query->whereNull('SITE_ID');
2670 }
2671
2672 return $query->exec();
2673 }
2674
2675 public static function GetGroupRight($module_id, $arGroups = false, $use_default_level = "Y", $max_right_for_super_admin = "Y", $site_id = false)
2676 {
2677 return CMain::GetUserRight($module_id, $arGroups, $use_default_level, $max_right_for_super_admin, $site_id);
2678 }
2679
2680 public static function SetGroupRight($module_id, $group_id, $right, $site_id = false)
2681 {
2682 global $DB;
2683
2684 $group_id = intval($group_id);
2685
2686 if (COption::GetOptionString("main", "event_log_module_access", "N") === "Y")
2687 {
2688 //get old value
2689 $sOldRight = "";
2690 $rsRight = $DB->Query("SELECT G_ACCESS FROM b_module_group WHERE MODULE_ID='" . $DB->ForSql($module_id, 50) . "' AND GROUP_ID=" . $group_id . " AND SITE_ID " . ($site_id ? "= '" . $DB->ForSql($site_id) . "'" : "IS NULL"));
2691 if ($arRight = $rsRight->Fetch())
2692 {
2693 $sOldRight = $arRight["G_ACCESS"];
2694 }
2695 if ($sOldRight <> $right)
2696 {
2697 $key = $module_id . ($site_id ? "/" . $site_id : "");
2698 CEventLog::Log(CEventLog::SEVERITY_SECURITY, "MODULE_RIGHTS_CHANGED", "main", $group_id, ['before' => [$key => $sOldRight], 'after' => [$key => $right]]);
2699 }
2700 }
2701
2702 $arFields = [
2703 "MODULE_ID" => "'" . $DB->ForSql($module_id, 50) . "'",
2704 "GROUP_ID" => $group_id,
2705 "G_ACCESS" => "'" . $DB->ForSql($right, 255) . "'",
2706 ];
2707
2708 $rows = $DB->Update("b_module_group", $arFields, "WHERE MODULE_ID='" . $DB->ForSql($module_id, 50) . "' AND GROUP_ID='" . $group_id . "' AND SITE_ID " . ($site_id ? "= '" . $DB->ForSql($site_id) . "'" : "IS NULL"));
2709 if (intval($rows) <= 0)
2710 {
2711 if ($site_id)
2712 {
2713 $arFields["SITE_ID"] = "'" . $DB->ForSql($site_id, 2) . "'";
2714 }
2715
2716 $DB->Insert("b_module_group", $arFields);
2717 }
2718
2719 ModuleGroupTable::cleanCache();
2720
2721 foreach (GetModuleEvents("main", "OnAfterSetGroupRight", true) as $arEvent)
2722 {
2723 ExecuteModuleEventEx($arEvent, [$module_id, $group_id]);
2724 }
2725 }
2726
2727 public static function DelGroupRight($module_id = '', $arGroups = [], $site_id = false)
2728 {
2729 global $DB;
2730
2731 $strSql = '';
2732
2733 $sGroups = '';
2734 if (is_array($arGroups) && !empty($arGroups))
2735 {
2736 foreach ($arGroups as $grp)
2737 {
2738 $sGroups .= ($sGroups <> '' ? ',' : '') . intval($grp);
2739 }
2740 }
2741
2742 if ($module_id <> '')
2743 {
2744 if ($sGroups <> '')
2745 {
2746 if (COption::GetOptionString("main", "event_log_module_access", "N") === "Y")
2747 {
2748 //get old value
2749 $rsRight = $DB->Query("SELECT GROUP_ID, G_ACCESS FROM b_module_group WHERE MODULE_ID='" . $DB->ForSql($module_id, 50) . "' AND GROUP_ID IN (" . $sGroups . ") AND SITE_ID " . ($site_id ? "= '" . $DB->ForSql($site_id) . "'" : "IS NULL"));
2750 while ($arRight = $rsRight->Fetch())
2751 {
2752 CEventLog::Log(CEventLog::SEVERITY_SECURITY, "MODULE_RIGHTS_CHANGED", "main", $arRight["GROUP_ID"], ['before' => [$module_id . ($site_id ? "/" . $site_id : "") => $arRight["G_ACCESS"]], 'after' => []]);
2753 }
2754 }
2755 $strSql = "DELETE FROM b_module_group WHERE MODULE_ID='" . $DB->ForSql($module_id, 50) . "' and GROUP_ID in (" . $sGroups . ") AND SITE_ID " . ($site_id ? "= '" . $DB->ForSql($site_id) . "'" : "IS NULL");
2756 }
2757 else
2758 {
2759 //on delete module
2760 $strSql = "DELETE FROM b_module_group WHERE MODULE_ID='" . $DB->ForSql($module_id, 50) . "' AND SITE_ID " . ($site_id ? "= '" . $DB->ForSql($site_id) . "'" : "IS NULL");
2761 }
2762 }
2763 elseif ($sGroups <> '')
2764 {
2765 //on delete user group
2766 $strSql = "DELETE FROM b_module_group WHERE GROUP_ID in (" . $sGroups . ") AND SITE_ID " . ($site_id ? "= '" . $DB->ForSql($site_id) . "'" : "IS NULL");
2767 }
2768
2769 if ($strSql <> '')
2770 {
2771 $DB->Query($strSql);
2772
2773 ModuleGroupTable::cleanCache();
2774
2775 foreach (GetModuleEvents("main", "OnAfterDelGroupRight", true) as $arEvent)
2776 {
2778 }
2779 }
2780 }
2781
2782 public static function GetMainRightList()
2783 {
2784 $arr = [
2785 "reference_id" => [
2786 "D",
2787 "P",
2788 "R",
2789 "T",
2790 "V",
2791 "W"],
2792 "reference" => [
2793 "[D] " . GetMessage("OPTION_DENIED"),
2794 "[P] " . GetMessage("OPTION_PROFILE"),
2795 "[R] " . GetMessage("OPTION_READ"),
2796 "[T] " . GetMessage("OPTION_READ_PROFILE_WRITE"),
2797 "[V] " . GetMessage("OPTION_READ_OTHER_PROFILES_WRITE"),
2798 "[W] " . GetMessage("OPTION_WRITE")],
2799 ];
2800 return $arr;
2801 }
2802
2803 public static function GetDefaultRightList()
2804 {
2805 $arr = [
2806 "reference_id" => ["D", "R", "W"],
2807 "reference" => [
2808 "[D] " . GetMessage("OPTION_DENIED"),
2809 "[R] " . GetMessage("OPTION_READ"),
2810 "[W] " . GetMessage("OPTION_WRITE")],
2811 ];
2812 return $arr;
2813 }
2814
2815 /*
2816 Returns a cookie value by the name
2817
2818 $name : cookie name (without prefix)
2819 $name_prefix : name prefix (if not set get from options)
2820 */
2821 public function get_cookie($name, $name_prefix = false)
2822 {
2823 if ($name_prefix === false)
2824 {
2825 $name = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_" . $name;
2826 }
2827 else
2828 {
2829 $name = $name_prefix . "_" . $name;
2830 }
2831 return ($_COOKIE[$name] ?? "");
2832 }
2833
2849 public function set_cookie($name, $value, $time = false, $folder = "/", $domain = false, $secure = false, $spread = true, $name_prefix = false, $httpOnly = false)
2850 {
2851 if ($time === false)
2852 {
2853 $time = null;
2854 }
2855
2856 $cookie = new Main\Web\Cookie($name, $value, $time);
2857
2858 if ($name_prefix !== false)
2859 {
2860 $cookie->setName($name_prefix . "_" . $name);
2861 }
2862
2863 if ($domain !== false)
2864 {
2865 $cookie->setDomain($domain);
2866 }
2867 $cookie->setPath($folder);
2868 $cookie->setSecure($secure);
2869 $cookie->setHttpOnly($httpOnly);
2870
2871 if ($spread === "Y" || $spread === true)
2872 {
2874 }
2875 elseif ($spread >= 1)
2876 {
2877 $spread_mode = $spread;
2878 }
2879 else
2880 {
2881 $spread_mode = Main\Web\Cookie::SPREAD_DOMAIN;
2882 }
2883 $cookie->setSpread($spread_mode);
2884
2885 Main\Context::getCurrent()->getResponse()->addCookie($cookie);
2886 }
2887
2892 public function GetCookieDomain()
2893 {
2895 }
2896
2897 public function StoreCookies()
2898 {
2900
2901 if ($application->getSessionLocalStorageManager()->isReady())
2902 {
2903 $response = Main\Context::getCurrent()->getResponse();
2904
2905 $localStorage = $application->getLocalSession('spreadCookies');
2906 $cookies = $localStorage->getData();
2907
2908 foreach ($cookies as $cookie)
2909 {
2910 if ($cookie instanceof Main\Web\Cookie)
2911 {
2912 $response->addCookie($cookie, false);
2913 }
2914 }
2915
2916 $localStorage->setData($response->getCookies());
2917
2918 $this->HoldSpreadCookieHTML(true);
2919 }
2920 }
2921
2922 public function HoldSpreadCookieHTML($bSet = false)
2923 {
2924 static $showed_already = false;
2925 $result = $showed_already;
2926 if ($bSet)
2927 {
2928 $showed_already = true;
2929 }
2930 return $result;
2931 }
2932
2933 // Returns string with images to spread cookies
2934 public function GetSpreadCookieHTML()
2935 {
2936 $res = '';
2937 $request = Main\Context::getCurrent()->getRequest();
2938
2939 if (
2940 $request->isHttps()
2941 && !$this->HoldSpreadCookieHTML()
2942 && COption::GetOptionString("main", "ALLOW_SPREAD_COOKIE", "Y") == "Y"
2943 )
2944 {
2945 foreach ($this->GetSpreadCookieUrls() as $url)
2946 {
2947 $res .= "new Image().src='" . CUtil::JSEscape($url) . "';\n";
2948 }
2949
2950 if ($res)
2951 {
2952 $this->HoldSpreadCookieHTML(true);
2953
2954 return '<script>' . $res . '</script>';
2955 }
2956 }
2957
2958 return '';
2959 }
2960
2966 public function GetSpreadCookieUrls()
2967 {
2968 $res = [];
2969 if (COption::GetOptionString("main", "ALLOW_SPREAD_COOKIE", "Y") == "Y")
2970 {
2971 $response = Main\Context::getCurrent()->getResponse();
2972 $request = Main\Context::getCurrent()->getRequest();
2973
2975 $localStorage = $application->getLocalSession('spreadCookies');
2976 $cookies = $localStorage->getData();
2977
2978 foreach ($cookies as $cookie)
2979 {
2980 if ($cookie instanceof Main\Web\Cookie)
2981 {
2982 $response->addCookie($cookie, false);
2983 }
2984 }
2985 $localStorage->clear();
2986
2987 $cookies = $response->getCookies();
2988
2989 if (!empty($cookies))
2990 {
2991 $params = "";
2992 foreach ($cookies as $cookie)
2993 {
2994 if ($cookie->getSpread() & Main\Web\Cookie::SPREAD_SITES)
2995 {
2996 $params .= $cookie->getName() . chr(1) .
2997 $cookie->getValue() . chr(1) .
2998 $cookie->getExpires() . chr(1) .
2999 $cookie->getPath() . chr(1) .
3000 chr(1) . //domain is empty
3001 $cookie->getSecure() . chr(1) .
3002 $cookie->getHttpOnly() . chr(2);
3003 }
3004 }
3005 $salt = $_SERVER["REMOTE_ADDR"] . "|" . @filemtime($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php") . "|" . $application->getLicense()->getKey();
3006 $params = "s=" . urlencode(base64_encode($params)) . "&k=" . urlencode(md5($params . $salt));
3007
3008 $arrDomain = [];
3009 $arrDomain[] = $request->getHttpHost();
3010
3011 $rs = CSite::GetList('', '', ["ACTIVE" => "Y"]);
3012 while ($ar = $rs->Fetch())
3013 {
3014 $arD = explode("\n", str_replace("\r", "\n", $ar["DOMAINS"]));
3015 if (is_array($arD))
3016 {
3017 foreach ($arD as $d)
3018 {
3019 if (trim($d) <> '')
3020 {
3021 $arrDomain[] = $d;
3022 }
3023 }
3024 }
3025 }
3026
3027 if (!empty($arrDomain))
3028 {
3029 $arUniqDomains = [];
3030 $arrDomain = array_unique($arrDomain);
3031 $arrDomain2 = array_unique($arrDomain);
3032 foreach ($arrDomain as $domain1)
3033 {
3034 $bGood = true;
3035 foreach ($arrDomain2 as $domain2)
3036 {
3037 if (mb_strlen($domain1) > mb_strlen($domain2) && str_ends_with($domain1, "." . $domain2))
3038 {
3039 $bGood = false;
3040 break;
3041 }
3042 }
3043 if ($bGood)
3044 {
3045 $arUniqDomains[] = $domain1;
3046 }
3047 }
3048
3049 $protocol = ($request->isHttps() ? "https://" : "http://");
3050 $arrCurUrl = parse_url($protocol . $request->getHttpHost() . "/");
3051 foreach ($arUniqDomains as $domain)
3052 {
3053 if (trim($domain) <> '')
3054 {
3055 $url = $protocol . $domain . "/bitrix/spread.php?" . $params;
3056 $arrUrl = parse_url($url);
3057 if ($arrUrl["host"] != $arrCurUrl["host"])
3058 {
3059 $res[] = $url;
3060 }
3061 }
3062 }
3063 }
3064 }
3065 }
3066
3067 return $res;
3068 }
3069
3070 public function ShowSpreadCookieHTML()
3071 {
3072 $this->AddBufferContent([&$this, "GetSpreadCookieHTML"]);
3073 }
3074
3075 public function AddPanelButton($arButton, $bReplace = false)
3076 {
3077 if (is_array($arButton) && !empty($arButton))
3078 {
3079 if (isset($arButton["ID"]) && $arButton["ID"] <> "")
3080 {
3081 if (!isset($this->arPanelButtons[$arButton["ID"]]))
3082 {
3083 $this->arPanelButtons[$arButton["ID"]] = $arButton;
3084 }
3085 elseif ($bReplace)
3086 {
3087 if (
3088 isset($this->arPanelButtons[$arButton["ID"]]["MENU"])
3089 && is_array($this->arPanelButtons[$arButton["ID"]]["MENU"])
3090 )
3091 {
3092 if (!isset($arButton["MENU"]) || !is_array($arButton["MENU"]))
3093 {
3094 $arButton["MENU"] = [];
3095 }
3096 $arButton["MENU"] = array_merge($this->arPanelButtons[$arButton["ID"]]["MENU"], $arButton["MENU"]);
3097 }
3098 $this->arPanelButtons[$arButton["ID"]] = $arButton;
3099 }
3100
3101 if (isset($this->arPanelFutureButtons[$arButton['ID']]))
3102 {
3103 if (
3104 isset($this->arPanelButtons[$arButton["ID"]]["MENU"])
3105 && is_array($this->arPanelButtons[$arButton["ID"]]["MENU"])
3106 )
3107 {
3108 $this->arPanelButtons[$arButton["ID"]]["MENU"] = array_merge(
3109 $this->arPanelButtons[$arButton["ID"]]["MENU"],
3110 $this->arPanelFutureButtons[$arButton["ID"]]
3111 );
3112 }
3113 else
3114 {
3115 $this->arPanelButtons[$arButton["ID"]]["MENU"] = $this->arPanelFutureButtons[$arButton["ID"]];
3116 }
3117 unset($this->arPanelFutureButtons[$arButton['ID']]);
3118 }
3119 }
3120 else
3121 {
3122 $this->arPanelButtons[] = $arButton;
3123 }
3124 }
3125 }
3126
3127 public function AddPanelButtonMenu($button_id, $arMenuItem)
3128 {
3129 if (isset($this->arPanelButtons[$button_id]))
3130 {
3131 if (!isset($this->arPanelButtons[$button_id]['MENU']))
3132 {
3133 $this->arPanelButtons[$button_id]['MENU'] = [];
3134 }
3135 $this->arPanelButtons[$button_id]['MENU'][] = $arMenuItem;
3136 }
3137 else
3138 {
3139 if (!isset($this->arPanelFutureButtons[$button_id]))
3140 {
3141 $this->arPanelFutureButtons[$button_id] = [];
3142 }
3143
3144 $this->arPanelFutureButtons[$button_id][] = $arMenuItem;
3145 }
3146 }
3147
3148 public function GetPanel()
3149 {
3150 global $USER;
3151
3153 if (isset($GLOBALS["USER"]) && is_object($USER) && $USER->IsAuthorized() && !isset($_REQUEST["bx_hit_hash"]) && !$isFrameAjax)
3154 {
3156 }
3157 }
3158
3159 public function ShowPanel()
3160 {
3161 global $USER;
3162
3164 if (isset($GLOBALS["USER"]) && is_object($USER) && $USER->IsAuthorized() && !isset($_REQUEST["bx_hit_hash"]) && !$isFrameAjax)
3165 {
3166 $this->showPanelWasInvoked = true;
3167
3168 AddEventHandler('main', 'OnBeforeEndBufferContent', ['CTopPanel', 'InitPanel']);
3169 $this->AddBufferContent(['CTopPanel', 'GetPanelHtml']);
3170
3171 //Prints global url classes and variables for HotKeys
3172 $this->AddBufferContent(['CMain', "PrintHKGlobalUrlVar"]);
3173
3174 if (Main\Loader::includeModule('fileman'))
3175 {
3176 //Prints global url classes and variables for Stickers
3177 $this->AddBufferContent(['CSticker', "InitJsAfter"]);
3178 }
3179
3180 $this->AddBufferContent(['CAdminInformer', "PrintHtmlPublic"]);
3181 }
3182 }
3183
3184 public static function PrintHKGlobalUrlVar()
3185 {
3186 return CHotKeys::GetInstance()->PrintGlobalUrlVar();
3187 }
3188
3192 public function GetLang()
3193 {
3194 $context = Main\Context::getCurrent();
3195 $culture = $context->getCulture();
3196 $site = $context->getSiteObject();
3197
3198 return [
3199 "LID" => ($site ? $site->getLid() : $context->getLanguage()),
3200 "DIR" => ($site ? $site->getDir() : ''),
3201 "SERVER_NAME" => ($site ? $site->getServerName() : ''),
3202 "CHARSET" => $culture->getCharset(),
3203 "FORMAT_DATE" => $culture->getFormatDate(),
3204 "FORMAT_DATETIME" => $culture->getFormatDatetime(),
3205 "LANGUAGE_ID" => $context->getLanguage(),
3206 ];
3207 }
3208
3212 public function GetSiteByDir()
3213 {
3214 return $this->GetLang();
3215 }
3216
3217 public function RestartWorkarea($start = false)
3218 {
3219 static $index = null;
3220 static $view = null;
3221
3222
3223
3224 if ($start)
3225 {
3226 $this->AddBufferContent("trim", ""); //Makes a placeholder after header.php
3227 $index = count($this->buffer_content);
3228 $view = $this->__view;
3229
3230 return true;
3231 }
3232 elseif (
3233 !isset($index) //Was not started
3234 || !isset($this->buffer_content_type[$index / 2 - 1]) //RestartBuffer was called
3235 || $this->buffer_content_type[$index / 2 - 1]["F"] !== "trim"
3236 )
3237 {
3238 return false;
3239 }
3240 else
3241 {
3243 $autoCompositeArea?->end();
3244
3245 $this->buffer_man = true;
3246 ob_end_clean();
3247 $this->buffer_man = false;
3248
3249 array_splice($this->buffer_content, $index);
3250 array_splice($this->buffer_content_type, $index / 2);
3251
3252 ob_start([&$this, "EndBufferContent"]);
3253
3254 $this->__view = $view;
3255
3256 return true;
3257 }
3258 }
3259
3260 public function AddBufferContent($callback)
3261 {
3262 $args = [];
3263 $args_num = func_num_args();
3264 if ($args_num > 1)
3265 {
3266 for ($i = 1; $i < $args_num; $i++)
3267 {
3268 $args[] = func_get_arg($i);
3269 }
3270 }
3271
3272 if (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)
3273 {
3274 echo call_user_func_array($callback, $args);
3275 return;
3276 }
3277 $this->buffer_content[] = ob_get_contents();
3278 $this->buffer_content[] = "";
3279 $this->buffer_content_type[] = ["F" => $callback, "P" => $args];
3280 $this->buffer_man = true;
3281 $this->auto_buffer_cleaned = false;
3282 ob_end_clean();
3283 $this->buffer_man = false;
3284 $this->buffered = true;
3285 if ($this->auto_buffer_cleaned) // cross buffer fix
3286 {
3287 ob_start([&$this, "EndBufferContent"]);
3288 }
3289 else
3290 {
3291 ob_start();
3292 }
3293 }
3294
3295 public function RestartBuffer()
3296 {
3297 $this->oAsset->setShowHeadString(false);
3298 $this->oAsset->setShowHeadScript(false);
3299 $this->buffer_man = true;
3300 ob_end_clean();
3301 $this->buffer_man = false;
3302 $this->buffer_content_type = [];
3303 $this->buffer_content = [];
3304
3305 if (function_exists("getmoduleevents"))
3306 {
3307 foreach (GetModuleEvents("main", "OnBeforeRestartBuffer", true) as $arEvent)
3308 {
3309 ExecuteModuleEventEx($arEvent);
3310 }
3311 }
3312
3313 ob_start([&$this, "EndBufferContent"]);
3314 }
3315
3316 public function &EndBufferContentMan()
3317 {
3318
3319
3320 $res = null;
3321
3322 if (!$this->buffered)
3323 {
3324 return $res;
3325 }
3326
3327 $content = ob_get_contents();
3328 $this->buffer_man = true;
3329 ob_end_clean();
3330 $this->buffered = false;
3331 $this->buffer_man = false;
3332
3333 $this->buffer_manual = true;
3334 $res = $this->EndBufferContent($content);
3335 $this->buffer_manual = false;
3336
3337 $this->buffer_content_type = [];
3338 $this->buffer_content = [];
3339
3340 return $res;
3341 }
3342
3343 public function EndBufferContent($content = "")
3344 {
3345 if ($this->buffer_man)
3346 {
3347 $this->auto_buffer_cleaned = true;
3348 return "";
3349 }
3350
3352
3353 if (function_exists("getmoduleevents"))
3354 {
3355 foreach (GetModuleEvents("main", "OnBeforeEndBufferContent", true) as $arEvent)
3356 {
3357 ExecuteModuleEventEx($arEvent);
3358 }
3359 }
3360
3361 $asset = Asset::getInstance();
3362 $asset->addString(CJSCore::GetCoreMessagesScript(), false, AssetLocation::AFTER_CSS, AssetMode::STANDARD);
3363 $asset->addString(CJSCore::GetCoreMessagesScript(true), false, AssetLocation::AFTER_CSS, AssetMode::COMPOSITE);
3364
3365 $asset->addString($this->GetSpreadCookieHTML(), false, AssetLocation::AFTER_JS, AssetMode::STANDARD);
3366 if ($asset->canMoveJsToBody() && CJSCore::IsCoreLoaded())
3367 {
3368 $asset->addString(CJSCore::GetInlineCoreJs(), false, AssetLocation::BEFORE_CSS, AssetMode::ALL);
3369 }
3370
3371 if (is_object($GLOBALS["APPLICATION"])) //php 5.1.6 fix: http://bugs.php.net/bug.php?id=40104
3372 {
3373 $cnt = count($this->buffer_content_type);
3374 for ($i = 0; $i < $cnt; $i++)
3375 {
3376 $this->buffer_content[$i * 2 + 1] = call_user_func_array($this->buffer_content_type[$i]["F"], $this->buffer_content_type[$i]["P"]);
3377 }
3378 }
3379
3380 $compositeContent = Composite\Engine::startBuffering($content);
3381 $content = implode("", $this->buffer_content) . $content;
3382
3383 if (function_exists("getmoduleevents"))
3384 {
3385 foreach (GetModuleEvents("main", "OnEndBufferContent", true) as $arEvent)
3386 {
3387 ExecuteModuleEventEx($arEvent, [&$content]);
3388 }
3389 }
3390
3391 $wasContentModified = Composite\Engine::endBuffering($content, $compositeContent);
3392 if (!$wasContentModified && $asset->canMoveJsToBody())
3393 {
3394 $asset->moveJsToBody($content);
3395 }
3396
3397 return $content;
3398 }
3399
3400 public function ResetException()
3401 {
3402 if ($this->LAST_ERROR)
3403 {
3404 $this->ERROR_STACK[] = $this->LAST_ERROR;
3405 }
3406 $this->LAST_ERROR = false;
3407 }
3408
3409 public function ThrowException($msg, $id = false)
3410 {
3411 $this->ResetException();
3412 if (is_object($msg) && (is_subclass_of($msg, 'CApplicationException') || (mb_strtolower(get_class($msg)) == 'capplicationexception')))
3413 {
3414 $this->LAST_ERROR = $msg;
3415 }
3416 else
3417 {
3418 $this->LAST_ERROR = new CApplicationException($msg, $id);
3419 }
3420 }
3421
3422 public function GetException()
3423 {
3424 return $this->LAST_ERROR;
3425 }
3426
3434 public function ConvertCharset($string, $charset_in, $charset_out)
3435 {
3436 return Main\Text\Encoding::convertEncoding($string, $charset_in, $charset_out);
3437 }
3438
3446 public function ConvertCharsetArray($arData, $charset_from, $charset_to)
3447 {
3448 return Main\Text\Encoding::convertEncoding($arData, $charset_from, $charset_to);
3449 }
3450
3451 public function CaptchaGetCode()
3452 {
3453 $cpt = new CCaptcha();
3454 $cpt->SetCode();
3455
3456 return $cpt->GetSID();
3457 }
3458
3459 public function CaptchaCheckCode($captcha_word, $captcha_sid)
3460 {
3461 $cpt = new CCaptcha();
3462 if ($cpt->CheckCode($captcha_word, $captcha_sid))
3463 {
3464 return true;
3465 }
3466 else
3467 {
3468 return false;
3469 }
3470 }
3471
3472 public function UnJSEscape($str)
3473 {
3474 if (str_contains($str, "%u"))
3475 {
3476 $str = preg_replace_callback(
3477 "'%u([0-9A-F]{2})([0-9A-F]{2})'i",
3478 function ($ch) {
3479 $res = chr(hexdec($ch[2])) . chr(hexdec($ch[1]));
3480 return \Bitrix\Main\Text\Encoding::convertEncoding($res, "UTF-16", LANG_CHARSET);
3481 },
3482 $str
3483 );
3484 }
3485 return $str;
3486 }
3487
3491 public static function ShowFileSelectDialog($event, $arResultDest, $arPath = [], $fileFilter = "", $bAllowFolderSelect = false)
3492 {
3494 "event" => $event,
3495 "arResultDest" => $arResultDest,
3496 "arPath" => $arPath,
3497 "select" => $bAllowFolderSelect ? 'DF' : 'F',
3498 "fileFilter" => $fileFilter,
3499 "operation" => 'O',
3500 "showUploadTab" => true,
3501 "showAddToMenuTab" => false,
3502 "allowAllFiles" => true,
3503 "SaveConfig" => true,
3504 ]);
3505 }
3506
3507 /*
3508 array(
3509 "URL"=> 'url to open'
3510 "PARAMS"=> array('param' => 'value') - additional params, 2nd argument of jsPopup.ShowDialog()
3511 ),
3512 */
3513 public function GetPopupLink($arUrl)
3514 {
3515 CUtil::InitJSCore(['window', 'ajax']);
3516
3517 if (
3518 class_exists('CUserOptions')
3519 && (
3520 !isset($arUrl['PARAMS'])
3521 || !is_array($arUrl['PARAMS'])
3522 || !isset($arUrl['PARAMS']['resizable'])
3523 || $arUrl['PARAMS']['resizable'] !== false
3524 )
3525 )
3526 {
3527 $pos = mb_strpos($arUrl['URL'], '?');
3528 if ($pos === false)
3529 {
3530 $check_url = $arUrl['URL'];
3531 }
3532 else
3533 {
3534 $check_url = mb_substr($arUrl['URL'], 0, $pos);
3535 }
3536
3537 if (defined('SITE_TEMPLATE_ID'))
3538 {
3539 $arUrl['URL'] = (new Uri($arUrl['URL']))
3540 ->addParams(['siteTemplateId' => SITE_TEMPLATE_ID])
3541 ->getUri()
3542 ;
3543 }
3544
3545 $arPos = CUtil::GetPopupSize($check_url);
3546
3547 if ($arPos['width'])
3548 {
3549 if (!is_array($arUrl['PARAMS']))
3550 {
3551 $arUrl['PARAMS'] = [];
3552 }
3553
3554 $arUrl['PARAMS']['width'] = $arPos['width'];
3555 $arUrl['PARAMS']['height'] = $arPos['height'];
3556 }
3557 }
3558
3559 $dialog_class = 'CDialog';
3560 if (isset($arUrl['PARAMS']['dialog_type']) && $arUrl['PARAMS']['dialog_type'])
3561 {
3562 switch ($arUrl['PARAMS']['dialog_type'])
3563 {
3564 case 'EDITOR':
3565 $dialog_class = 'CEditorDialog';
3566 break;
3567 case 'ADMIN':
3568 $dialog_class = 'CAdminDialog';
3569 break;
3570 }
3571 }
3572 elseif (str_contains($arUrl['URL'], 'bxpublic='))
3573 {
3574 $dialog_class = 'CAdminDialog';
3575 }
3576
3577 $arDialogParams = [
3578 'content_url' => $arUrl['URL'],
3579 'width' => null,
3580 'height' => null,
3581 ];
3582
3583 if (isset($arUrl['PARAMS']['width']))
3584 {
3585 $arDialogParams['width'] = intval($arUrl['PARAMS']['width']);
3586 }
3587 if (isset($arUrl['PARAMS']['height']))
3588 {
3589 $arDialogParams['height'] = intval($arUrl['PARAMS']['height']);
3590 }
3591 if (isset($arUrl['PARAMS']['min_width']))
3592 {
3593 $arDialogParams['min_width'] = intval($arUrl['PARAMS']['min_width']);
3594 }
3595 if (isset($arUrl['PARAMS']['min_height']))
3596 {
3597 $arDialogParams['min_height'] = intval($arUrl['PARAMS']['min_height']);
3598 }
3599 if (isset($arUrl['PARAMS']['resizable']) && $arUrl['PARAMS']['resizable'] === false)
3600 {
3601 $arDialogParams['resizable'] = false;
3602 }
3603 if (isset($arUrl['POST']) && $arUrl['POST'])
3604 {
3605 $arDialogParams['content_post'] = $arUrl['POST'];
3606 }
3607
3608 return '(new BX.' . $dialog_class . '(' . CUtil::PhpToJsObject($arDialogParams) . ')).Show()';
3609 }
3610
3611 public static function GetServerUniqID()
3612 {
3613 static $uniq = null;
3614 if ($uniq === null)
3615 {
3616 $uniq = COption::GetOptionString("main", "server_uniq_id", "");
3617 }
3618 if ($uniq == '')
3619 {
3621 COption::SetOptionString("main", "server_uniq_id", $uniq);
3622 }
3623 return $uniq;
3624 }
3625
3626 public static function PrologActions()
3627 {
3629 global $APPLICATION, $USER;
3630
3631 if (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)
3632 {
3633 ob_start([&$APPLICATION, "EndBufferContent"]);
3634 $APPLICATION->buffered = true;
3635 define("BX_BUFFER_USED", true);
3636
3637 register_shutdown_function(
3638 function () {
3639 define("BX_BUFFER_SHUTDOWN", true);
3640 for ($i = 0, $n = ob_get_level(); $i < $n; $i++)
3641 {
3642 ob_end_flush();
3643 }
3644 }
3645 );
3646 }
3647
3648 //session expander
3649 if ((!defined('PUBLIC_AJAX_MODE') || PUBLIC_AJAX_MODE !== true) && (!defined("BX_SKIP_SESSION_EXPAND") || BX_SKIP_SESSION_EXPAND === false))
3650 {
3651 if (COption::GetOptionString("main", "session_expand", "Y") <> "N")
3652 {
3653 //only for authorized
3654 if (COption::GetOptionString("main", "session_auth_only", "Y") <> "Y" || $USER->IsAuthorized())
3655 {
3657 }
3658 }
3659 }
3660
3661
3662
3663 //user auto time zone via js cookies
3664 if (CTimeZone::Enabled() && (!defined("BX_SKIP_TIMEZONE_COOKIE") || BX_SKIP_TIMEZONE_COOKIE === false))
3665 {
3666 CTimeZone::SetAutoCookie();
3667 }
3668
3669 // check user options set via cookie
3670 if ($USER->IsAuthorized())
3671 {
3672 $cookieName = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LAST_SETTINGS";
3673 if (!empty($_COOKIE[$cookieName]))
3674 {
3675 CUserOptions::SetCookieOptions($cookieName);
3676 }
3677 }
3678
3679 foreach (GetModuleEvents("main", "OnProlog", true) as $arEvent)
3680 {
3681 ExecuteModuleEventEx($arEvent);
3682 }
3683 }
3684
3690 public static function FinalActions($output = "")
3691 {
3692 global $APPLICATION;
3693
3694 if ($output === "")
3695 {
3696 $output = $APPLICATION->EndBufferContentMan();
3697 }
3698
3699 $response = Main\Context::getCurrent()->getResponse();
3700 $response->setContent($output);
3701
3703 }
3704
3708 public static function RunFinalActionsInternal()
3709 {
3710 global $DB;
3711
3712 if (!defined('BX_WITH_ON_AFTER_EPILOG'))
3713 {
3714 define('BX_WITH_ON_AFTER_EPILOG', true);
3715 }
3716
3717 $events = GetModuleEvents("main", "OnAfterEpilog", true);
3718
3719 define("START_EXEC_EVENTS_1", microtime());
3720
3721 if (!defined('BX_SENDPULL_COUNTER_QUEUE_DISABLE') || BX_SENDPULL_COUNTER_QUEUE_DISABLE !== true)
3722 {
3723 $DB->StartUsingMasterOnly();
3724 if (CUserCounter::CheckLiveMode())
3725 {
3727 }
3728 $DB->StopUsingMasterOnly();
3729 }
3730
3731 define("START_EXEC_EVENTS_2", microtime());
3732
3733 //OnAfterEpilog
3734 foreach ($events as $event)
3735 {
3737 }
3738 }
3739
3743 public static function EpilogActions()
3744 {
3745 }
3746
3753 public static function ForkActions($func = false, $args = [])
3754 {
3755 if ($func !== false)
3756 {
3757 Application::getInstance()->addBackgroundJob($func, $args);
3758 }
3759 return true;
3760 }
3761
3763 public static function __GetConditionFName()
3764 {
3766 $helper = $connection->getSqlHelper();
3767 return $helper->quote('CONDITION');
3768 }
3769}
3770
3771class CMain extends CAllMain
3772{
3773}
$arParams
Определения access_dialog.php:21
$path
Определения access_edit.php:21
$connection
Определения actionsdefinitions.php:38
$type
Определения options.php:106
$db_res
Определения options_user_settings.php:8
const BX_ROOT
Определения bx_root.php:3
global $APPLICATION
Определения include.php:80
$module_id
Определения options.php:6
const PUBLIC_AJAX_MODE
Определения catalog_reindex.php:6
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
change_password_forgot_link login popup forget pas AUTH_GOTO_FORGOT_FORM login btn wrap change_password_button login popup link login popup return auth javascript
Определения change_password.php:57
$login
Определения change_password.php:8
static resetAccelerator(string $filename=null)
Определения application.php:786
static getInstance()
Определения application.php:98
static getConnection($name="")
Определения application.php:638
static deleteByFilter($filter)
Определения parameters.php:99
static checkAdminPanel()
Определения engine.php:1227
static getUseHTMLCache()
Определения engine.php:182
static endBuffering(&$originalContent, $compositeContent)
Определения engine.php:400
static startBuffering($content)
Определения engine.php:331
static isAjaxRequest()
Определения engine.php:192
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
static getBackTrace($limit=0, $options=null, $skip=1)
Определения helper.php:26
static includeModule($moduleName)
Определения loader.php:67
static getString($length, $caseSensitive=false)
Определения random.php:76
static convertEncoding($data, $charsetFrom, $charsetTo)
Определения encoding.php:17
static delete($siteId, $filter)
Определения urlrewriter.php:262
static reindexFile($siteId, $rootPath, $path, $maxFileSize=0)
Определения urlrewriter.php:492
Определения uri.php:17
static ShowScript($arConfig)
Определения file_dialog.php:9
Определения main.php:22
GetMenuHtml($type="left", $bMenuExt=false, $template=false, $sInitDir=false)
Определения main.php:449
$arDirProperties
Определения main.php:29
GroupModuleCSS($from='', $to='')
Определения main.php:922
GetLang()
Определения main.php:3192
AuthForm($mess, $show_prolog=true, $show_epilog=true, $not_show_links="N", $do_die=true)
Определения main.php:221
__construct()
Определения main.php:75
GetProperty($PROPERTY_ID, $default_value=false)
Определения main.php:561
$auto_buffer_cleaned
Определения main.php:57
GetCurParam()
Определения main.php:152
$oAsset
Определения main.php:31
SetNeedCAPTHA($mode)
Определения main.php:362
$showPanelWasInvoked
Определения main.php:52
AddJSKernelInfo($module='', $arJS=[])
Определения main.php:904
GetNavChain($path=false, $iNumFrom=0, $sNavChainPath=false, $bIncludeOnce=false, $bShowIcons=true)
Определения main.php:1598
GetLangSwitcherArray()
Определения main.php:2382
$version
Определения main.php:45
static FinalActions($output="")
Определения main.php:3690
SetPageProperty($PROPERTY_ID, $PROPERTY_VALUE, $arOptions=null)
Определения main.php:537
SaveFileContent($abs_path, $strContent)
Определения main.php:2249
GetMenu($type="left", $bMenuExt=false, $template=false, $sInitDir=false)
Определения main.php:461
InitDirProperties($path)
Определения main.php:615
static IsHTTPS()
Определения main.php:479
GetTemplatePath($rel_path)
Определения main.php:1071
IncludeStringAfter($arIcons=false, $arParams=[])
Определения main.php:1061
GetLink($id, $rel=null, $bXhtmlStyle=true)
Определения main.php:746
static GetGroupRight($module_id, $arGroups=false, $use_default_level="Y", $max_right_for_super_admin="Y", $site_id=false)
Определения main.php:2675
static ProcessLPA($filesrc=false, $old_filesrc=false)
Определения main.php:2364
static PrintHKGlobalUrlVar()
Определения main.php:3184
$arPanelFutureButtons
Определения main.php:49
SetTemplateCSS($rel_path)
Определения main.php:1107
AddBufferContent($callback)
Определения main.php:3260
ShowPanel()
Определения main.php:3159
SetUniqueJS()
Определения main.php:936
$sDocTitle
Определения main.php:25
GetCookieDomain()
Определения main.php:2892
SetAuthResult($arAuthResult)
Определения main.php:216
GetFileAccessPermissionByUser($userID, $path, $groups=false, $task_mode=false)
Определения main.php:2233
GetHeadStrings($location=AssetLocation::AFTER_JS_KERNEL)
Определения main.php:838
ShowLink($id, $rel=null, $bXhtmlStyle=true)
Определения main.php:777
GetSiteByDir()
Определения main.php:3212
GetCSSArray()
Определения main.php:807
GetCSS($cMaxStylesCnt=true, $bXhtmlStyle=true, $assetTargetType=Main\Page\AssetShowTargetType::ALL)
Определения main.php:813
IncludeComponent($componentName, $componentTemplate, $arParams=[], $parentComponent=null, $arFunctionParams=[], $returnResult=false)
Определения main.php:1117
GetPageProperty($PROPERTY_ID, $default_value=false)
Определения main.php:547
AddCSSKernelInfo($module='', $arCSS=[])
Определения main.php:898
$__view
Определения main.php:67
$arHeadAdditionalStrings
Определения main.php:43
static GetDefaultRightList()
Определения main.php:2803
GetFileAccessPermission($path, $groups=false, $task_mode=false)
Определения main.php:1997
$buffer_content
Определения main.php:53
$sDirPath
Определения main.php:24
GetException()
Определения main.php:3422
$arHeadStrings
Определения main.php:36
AddPanelButton($arButton, $bReplace=false)
Определения main.php:3075
ShowViewContent($view)
Определения main.php:1264
static PrologActions()
Определения main.php:3626
$sDocPath2
Определения main.php:24
EndBufferContent($content="")
Определения main.php:3343
static GetUserRoles($module_id, $arGroups=false, $use_default_role="Y", $max_role_for_super_admin="Y", $site_id=false)
Определения main.php:2454
GetHeadScripts($type=0)
Определения main.php:942
GetPopupLink($arUrl)
Определения main.php:3513
SetDirProperty($PROPERTY_ID, $PROPERTY_VALUE, $path=false)
Определения main.php:594
& EndBufferContentMan()
Определения main.php:3316
HoldSpreadCookieHTML($bSet=false)
Определения main.php:2922
ConvertCharset($string, $charset_in, $charset_out)
Определения main.php:3434
GetSpreadCookieHTML()
Определения main.php:2934
$sPath2css
Определения main.php:35
$buffer_content_type
Определения main.php:54
static ShowFileSelectDialog($event, $arResultDest, $arPath=[], $fileFilter="", $bAllowFolderSelect=false)
Определения main.php:3491
set_cookie($name, $value, $time=false, $folder="/", $domain=false, $secure=false, $spread=true, $name_prefix=false, $httpOnly=false)
Определения main.php:2849
SetFileAccessPermission($path, $arPermissions, $bOverWrite=true)
Определения main.php:1756
GetMeta($id, $meta_name=false, $bXhtmlStyle=true)
Определения main.php:732
$arAdditionalChain
Определения main.php:46
static GetMainRightList()
Определения main.php:2782
$arComponentMatch
Определения main.php:71
GetFileContent($path)
Определения main.php:2342
ThrowException($msg, $id=false)
Определения main.php:3409
clearViewContent(string $view)
Определения main.php:1244
AddLangJS($content)
Определения main.php:881
GetSpreadCookieUrls()
Определения main.php:2966
ShowAuthForm($message)
Определения main.php:354
$arAuthResult
Определения main.php:72
IncludeStringBefore()
Определения main.php:1052
static GetUserRightArray($moduleId, $groups)
Определения main.php:2622
NeedCAPTHA()
Определения main.php:371
$bInAjax
Определения main.php:44
$FILE_PERMISSION_CACHE
Определения main.php:47
GetPanel()
Определения main.php:3148
StoreCookies()
Определения main.php:2897
RemoveFileAccessPermission($path, $arGroups=false)
Определения main.php:1881
$ShowIncludeStat
Определения main.php:65
SetPublicShowMode($mode)
Определения main.php:1027
ResetException()
Определения main.php:3400
ShowProperty($PROPERTY_ID, $default_value=false)
Определения main.php:556
ShowMeta($id, $meta_name=false, $bXhtmlStyle=true)
Определения main.php:772
GroupModuleJS($from='', $to='')
Определения main.php:910
ShowBodyScripts()
Определения main.php:953
$buffer_man
Определения main.php:55
GetMenuHtmlEx($type="left", $bMenuExt=false, $template=false, $sInitDir=false)
Определения main.php:455
static __GetConditionFName()
Определения main.php:3763
$aCachedComponents
Определения main.php:64
GetSiteSwitcherArray()
Определения main.php:2387
static GetGroupRightList($arFilter, $site_id=false)
Определения main.php:2649
GetCurUri($addParam="", $get_index_page=null)
Определения main.php:118
CaptchaGetCode()
Определения main.php:3451
IncludeAdminFile($strTitle, $filepath)
Определения main.php:195
ShowSpreadCookieHTML()
Определения main.php:3070
ShowHeadScripts()
Определения main.php:947
RestartWorkarea($start=false)
Определения main.php:3217
$PanelShowed
Определения main.php:51
get_cookie($name, $name_prefix=false)
Определения main.php:2821
GetCurPageParam($strParam="", $arParamKill=[], $get_index_page=null)
Определения main.php:133
$arPanelButtons
Определения main.php:48
ShowCSS($cMaxStylesCnt=true, $bXhtmlStyle=true)
Определения main.php:825
UnJSEscape($str)
Определения main.php:3472
$LAST_ERROR
Определения main.php:61
$editArea
Определения main.php:69
static IsExternalLink($src)
Определения main.php:892
$arIncludeDebug
Определения main.php:63
NeedCAPTHAForLogin($login)
Определения main.php:377
getComponentStack()
Определения main.php:1234
static ForkActions($func=false, $args=[])
Определения main.php:3753
GetFileRecursive($strFileName, $strDir=false)
Определения main.php:166
GetTitle($property_name=false, $strip_tags=false)
Определения main.php:484
static _ReplaceNonLatin($str)
Определения main.php:2377
AddAdditionalJS($content)
Определения main.php:887
AddViewContent($view, $content, $pos=500)
Определения main.php:1252
CopyFileAccessPermission($path_from, $path_to, $bOverWrite=false)
Определения main.php:1960
static EpilogActions()
Определения main.php:3743
GetAdditionalCSS()
Определения main.php:797
GetDirPropertyList($path=false)
Определения main.php:706
ShowAjaxHead($bXhtmlStyle=true, $showCSS=true, $showStrings=true, $showScripts=true)
Определения main.php:971
static InitPathVars(&$site, &$path)
Определения main.php:583
GetPublicShowMode()
Определения main.php:1032
GetCurDir()
Определения main.php:157
static RunFinalActionsInternal()
Определения main.php:3708
ShowTitle($property_name="title", $strip_tags=true)
Определения main.php:532
SetEditArea($areaId, $arIcons)
Определения main.php:1037
$sDocTitleChanger
Определения main.php:26
$arHeadAdditionalScripts
Определения main.php:42
getCurrentIncludedComponent()
Определения main.php:1225
MoveJSToBody($module='')
Определения main.php:916
SetShowIncludeAreas($bShow=true)
Определения main.php:1000
$arHeadScripts
Определения main.php:37
AddPanelButtonMenu($button_id, $arMenuItem)
Определения main.php:3127
$_menu_recalc_counter
Определения main.php:66
CaptchaCheckCode($captcha_word, $captcha_sid)
Определения main.php:3459
ShowHeadStrings()
Определения main.php:853
GetPagePropertyList()
Определения main.php:578
static OnChangeFileComponent($path, $site)
Определения main.php:1296
static ShowBanner($type, $html_before="", $html_after="")
Определения main.php:760
IncludeFile($rel_path, $arParams=[], $arFunctionParams=[])
Определения main.php:1316
static DelGroupRight($module_id='', $arGroups=[], $site_id=false)
Определения main.php:2727
$buffer_manual
Определения main.php:56
$ShowPanel
Определения main.php:50
$arPageProperties
Определения main.php:27
$arPagePropertiesChanger
Определения main.php:28
ConvertCharsetArray($arData, $charset_from, $charset_to)
Определения main.php:3446
static GetServerUniqID()
Определения main.php:3611
SetCurPage($page)
Определения main.php:112
GetViewContent($view)
Определения main.php:1269
$buffered
Определения main.php:57
$ERROR_STACK
Определения main.php:62
$ma
Определения main.php:23
$arHeadAdditionalCSS
Определения main.php:41
static SetGroupRight($module_id, $group_id, $right, $site_id=false)
Определения main.php:2680
IncludeString($string, $arIcons=false)
Определения main.php:1066
static GetUserRight($moduleId, $groups=false, $use_default_level='Y', $max_right_for_super_admin='Y', $siteId=false)
Определения main.php:2549
GetShowIncludeAreas()
Определения main.php:1005
AddHeadScript($src, $additional=false)
Определения main.php:863
AddHeadString($str, $bUnique=false, $location=AssetLocation::AFTER_JS_KERNEL)
Определения main.php:832
GetCurPage($get_index_page=null)
Определения main.php:80
static LPAComponentChecker(&$arParams, &$arPHPparams, $parentParamName=false)
Определения main.php:2372
SetAdditionalCSS($Path2css, $additional=false)
Определения main.php:782
GetDirProperty($PROPERTY_ID, $path=false, $default_value=false)
Определения main.php:679
SetUniqueCSS($id='', $cssType='page')
Определения main.php:928
ShowHead($bXhtmlStyle=true)
Определения main.php:959
RestartBuffer()
Определения main.php:3295
static GetLetter($ID)
Определения task.php:438
static GetIdByLetter($letter, $module, $binding='module')
Определения task.php:451
static GetInstance()
Определения virtual_io.php:60
Определения component.php:12
static clearComponentCache($componentName, $siteId="")
Определения component.php:1285
Определения edit_area.php:337
Определения debuginfo.php:17
Определения quota.php:6
Определения edit_area.php:16
const SEVERITY_SECURITY
Определения event_log.php:22
static Log($SEVERITY, $AUDIT_TYPE_ID, $MODULE_ID, $ITEM_ID, $DESCRIPTION=false, $SITE_ID=false)
Определения event_log.php:32
static GetInstance()
Определения hot_keys.php:435
static GetInlineCoreJs()
Определения jscore.php:283
static GetCoreMessagesScript($compositeMode=false)
Определения jscore.php:217
static IsCoreLoaded()
Определения jscore.php:199
Определения main.php:3772
Определения menu.php:13
static GetPanelHtml()
Определения top_panel.php:1139
static checkSendCounter()
Определения user_counter_page.php:75
Определения user.php:6037
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$right
Определения options.php:8
$str
Определения commerceml2.php:63
$contents
Определения commerceml2.php:57
$content
Определения commerceml.php:144
$componentTemplate
Определения component_props2.php:50
$abs_path
Определения component_props2.php:76
$componentName
Определения component_props2.php:49
$f
Определения component_props.php:52
$filesrc
Определения component_props.php:53
$arFields
Определения dblapprove.php:5
$DOC_ROOT
Определения file_edit.php:66
$arPath
Определения file_edit.php:72
$template
Определения file_edit.php:49
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
$arr
Определения file_new.php:624
while($group=$gr->Fetch()) $bAdmin
Определения file_new.php:154
$arGroups
Определения options.php:1766
$res
Определения filter_act.php:7
$perm
Определения options.php:169
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
$start
Определения get_search.php:9
$query
Определения get_search.php:11
$moduleId
else $ch
Определения group_list_element_edit.php:27
$p
Определения group_list_element_edit.php:23
$protocol
Определения .description.php:9
const BX_SKIP_SESSION_EXPAND
Определения headers.php:2
global $MESS
Определения bill.php:2
$output
Определения options.php:436
$docRoot
Определения options.php:20
$DOCUMENT_ROOT
Определения cron_frame.php:10
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$context
Определения csv_new_setup.php:223
$io
Определения csv_new_run.php:98
$application
Определения bitrix.php:23
const LANG_CHARSET
Определения include.php:65
$culture
Определения include.php:61
$kernelSession
Определения include.php:181
$groups
Определения options.php:30
$panel
Определения options.php:177
$arTasks
Определения options.php:777
$arOptions
Определения structure.php:223
$siteId
Определения ajax.php:8
EscapePHPString($str, $encloser='"')
Определения tools.php:4917
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
IsFileUnsafe($name)
Определения tools.php:3016
GetPagePath($page=false, $get_index_page=null)
Определения tools.php:3139
DeleteParam($ParamNames)
Определения tools.php:4548
bxstrrpos($haystack, $needle)
Определения tools.php:3292
IsModuleInstalled($module_id)
Определения tools.php:5301
TrimUnsafe($path)
Определения tools.php:2934
HasScriptExtension($check_name)
Определения tools.php:2956
GetDirPath($sPath)
Определения tools.php:3245
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
Определения tools.php:5165
htmlspecialcharsEx($str)
Определения tools.php:2685
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
Rel2Abs($curdir, $relpath)
Определения tools.php:3297
GetMessage($name, $aReplace=null)
Определения tools.php:3397
IsConfigFile(string $path)
Определения tools.php:3028
getLocalPath($path, $baseFolder="/bitrix")
Определения tools.php:5092
$name
Определения menu_edit.php:35
editArea(area, bSilent)
Определения menu_edit.php:538
Определения aliases.php:54
Определения cookie.php:3
$GLOBALS['____1690880296']
Определения license.php:1
$time
Определения payment.php:61
$message
Определения payment.php:8
$event
Определения prolog_after.php:141
$aUserOpt
Определения prolog_auth_admin.php:23
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
$dir
Определения quickway.php:303
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
lang
Определения options.php:182
const BX_SENDPULL_COUNTER_QUEUE_DISABLE
Определения index.php:5
const ADMIN_SECTION
Определения rss.php:2
$i
Определения factura.php:643
$page
Определения order_form.php:33
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
else $a
Определения template.php:137
$title
Определения pdf.php:123
$val
Определения options.php:1793
$location
Определения options.php:2729
$response
Определения result.php:21
const BX_BUFFER_USED
Определения smtpd.php:6
$arRes
Определения options.php:104
$site_id
Определения sonet_set_content_view.php:9
const SITE_ID
Определения sonet_set_content_view.php:12
$rows
Определения options.php:264
$rs
Определения action.php:82
path
Определения template_copy.php:201
$n
Определения update_log.php:107
$arFilter
Определения user_search.php:106
$url
Определения iframe.php:7
$site
Определения yandex_run.php:614
$fields
Определения yandex_run.php:501