1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
checklist.php
См. документацию.
1<?php
8
13
14IncludeModuleLangFile(__FILE__);
15
17{
18 function __construct($ID = false)
19 {
20 $this->current_result = false;
21 $this->started = false;
22 $this->report_id = false;
23 $this->report_info = "";
24 $this->checklist_path = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/checklist_structure.php";
25 if (file_exists($this->checklist_path))
26 {
27 $arCheckList = include($this->checklist_path);
28 }
29 else
30 {
31 return;
32 }
33 //bind custom checklist
34 foreach (GetModuleEvents('main', 'OnCheckListGet', true) as $arEvent)
35 {
36 $arCustomChecklist = ExecuteModuleEventEx($arEvent, [$arCheckList]);
37
38 if (is_array($arCustomChecklist["CATEGORIES"]))
39 {
40 foreach ($arCustomChecklist["CATEGORIES"] as $section_id => $arSectionFields)
41 {
42 if (!$arCheckList["CATEGORIES"][$section_id])
43 {
44 $arCheckList["CATEGORIES"][$section_id] = $arSectionFields;
45 }
46 }
47 }
48 if (is_array($arCustomChecklist["POINTS"]))
49 {
50 foreach ($arCustomChecklist["POINTS"] as $point_id => $arPointFields)
51 {
52 $parent = $arCustomChecklist["POINTS"][$point_id]["PARENT"];
53 if (!$arCheckList["POINTS"][$point_id] && array_key_exists($parent, $arCheckList["CATEGORIES"]))
54 {
55 $arCheckList["POINTS"][$point_id] = $arPointFields;
56 }
57 }
58 }
59 }
60 //end bind custom checklist
61 $this->checklist = $arCheckList;
62 $arFilter["REPORT"] = "N";
63 if (intval($ID) > 0)
64 {
65 $arFilter["ID"] = $ID;
66 $arFilter["REPORT"] = "Y";
67 }
68
70 if ($arCurrentResult = $dbResult->Fetch())
71 {
72 $this->current_result = unserialize($arCurrentResult["STATE"], ['allowed_classes' => false]);
73 if (intval($ID) > 0)
74 {
75 $this->report_id = intval($ID);
76 unset($arCurrentResult["STATE"]);
77 $this->report_info = $arCurrentResult;
78 }
79
80 foreach ($arCheckList["POINTS"] as $key => $arFields)
81 {
82 if (empty($this->current_result[$key]))
83 {
84 if ($this->report_id)
85 {
86 unset($this->checklist["POINTS"][$key]);
87 }
88 else
89 {
90 $this->current_result[$key] = [
91 "STATUS" => "W"];
92 }
93 }
95 }
96 }
97 if ($this->current_result != false && $this->report_id == false)
98 {
99 $this->started = true;
100 }
101 }
102
103 function GetSections()
104 {
105 $arSections = $this->checklist["CATEGORIES"];
106 $arResult = [];
107 foreach ($arSections as $key => $arFields)
108 {
109 $arResult[$key] = array_merge($this->GetDescription($key), $arFields);
110 $arResult[$key]["STATS"] = $this->GetSectionStat($key);
111 }
112 return $arResult;
113 }
114
115 //getting sections statistic
116 function GetSectionStat($ID = false)
117 {
118 $arResult = [
119 "CHECK" => 0,
120 "CHECK_R" => 0,
121 "FAILED" => 0,
122 "WAITING" => 0,
123 "TOTAL" => 0,
124 "REQUIRE_CHECK" => 0,
125 "REQUIRE_SKIP" => 0,
126 "NOT_REQUIRE_CHECK" => 0,
127 "NOT_REQUIRE_SKIP" => 0,
128 "CHECKED" => "N",
129 "REQUIRE" => 0,
130 ];
131
132 if (($ID != false && array_key_exists($ID, $this->checklist["CATEGORIES"])) || $ID == false)
133 {
134 $arPoints = $this->GetPoints($ID);
135 $arSections = $this->checklist["CATEGORIES"];
136 if (!empty($arPoints))
137 {
138 foreach ($arPoints as $arPointFields)
139 {
140 if ($arPointFields["STATE"]["STATUS"] == "A")
141 {
142 $arResult["CHECK"]++;
143 if (isset($arPointFields['REQUIRE']) && $arPointFields['REQUIRE'] == 'Y')
144 {
145 $arResult["CHECK_R"]++;
146 }
147 }
148 if ($arPointFields["STATE"]["STATUS"] == "F")
149 {
150 $arResult["FAILED"]++;
151 }
152 if ($arPointFields["STATE"]["STATUS"] == "W")
153 {
154 $arResult["WAITING"]++;
155 }
156 if (isset($arPointFields["REQUIRE"]) && $arPointFields["REQUIRE"] == "Y")
157 {
158 $arResult["REQUIRE"]++;
159 if ($arPointFields["STATE"]["STATUS"] == "A")
160 {
161 $arResult["REQUIRE_CHECK"]++;
162 }
163 elseif ($arPointFields["STATE"]["STATUS"] == "S")
164 {
165 $arResult["REQUIRE_SKIP"]++;
166 }
167 }
168 else
169 {
170 if ($arPointFields["STATE"]["STATUS"] == "A")
171 {
172 $arResult["NOT_REQUIRE_CHECK"]++;
173 }
174 elseif ($arPointFields["STATE"]["STATUS"] == "S")
175 {
176 $arResult["NOT_REQUIRE_SKIP"]++;
177 }
178 }
179 }
180 }
181 $arResult["TOTAL"] = count($arPoints);
182
183 if ($ID)
184 {
185 foreach ($arSections as $key => $arFields)
186 {
187 if (isset($arFields["PARENT"]) && $arFields["PARENT"] == $ID)
188 {
189 $arSubSectionStat = $this->GetSectionStat($key);
190 $arResult["TOTAL"] += $arSubSectionStat["TOTAL"];
191 $arResult["CHECK"] += $arSubSectionStat["CHECK"];
192 $arResult["FAILED"] += $arSubSectionStat["FAILED"];
193 $arResult["WAITING"] += $arSubSectionStat["WAITING"];
194 $arResult["REQUIRE"] += $arSubSectionStat["REQUIRE"];
195 $arResult["REQUIRE_CHECK"] += $arSubSectionStat["REQUIRE_CHECK"];
196 $arResult["REQUIRE_SKIP"] += $arSubSectionStat["REQUIRE_SKIP"];
197 }
198 }
199 }
200 if (
201 ($arResult["REQUIRE"] > 0 && $arResult["FAILED"] == 0 && $arResult["REQUIRE"] == $arResult["REQUIRE_CHECK"])
202 || ($arResult["REQUIRE"] == 0 && $arResult["FAILED"] == 0 && $arResult["TOTAL"] > 0)
203 || ($arResult["CHECK"] == $arResult["TOTAL"] && $arResult["TOTAL"] > 0)
204 )
205 {
206 $arResult["CHECKED"] = "Y";
207 }
208 }
209
210 return $arResult;
211 }
212
213 function GetPoints($arSectionCode = false)
214 {
215 $arCheckList = $this->GetCurrentState();
216 $arResult = [];
217 if (is_array($arCheckList) && !empty($arCheckList))
218 {
219 foreach ($arCheckList["POINTS"] as $key => $arFields)
220 {
221 $arFields = array_merge($this->GetDescription($key), $arFields);
222
223 if ($arFields["PARENT"] == $arSectionCode || $arSectionCode == false)
224 {
226 }
227 if (isset($arResult[$key]["STATE"]['COMMENTS']) && is_array($arResult[$key]["STATE"]['COMMENTS']))
228 {
229 $arResult[$key]["STATE"]['COMMENTS_COUNT'] = count($arResult[$key]["STATE"]['COMMENTS']);
230 }
231 }
232 }
233
234 return $arResult;
235 }
236
237 function GetStructure()
238 { //build checklist stucture with section statistic & status info
239 $arSections = $this->GetSections();
240 foreach ($arSections as $key => $arSectionFields)
241 {
242 if (empty($arSectionFields["CATEGORIES"]))
243 {
244 $arSections[$key]["CATEGORIES"] = [];
245 $arSectionFields["CATEGORIES"] = [];
246 }
247 if (empty($arSectionFields["PARENT"]))
248 {
249 $arSections[$key]["POINTS"] = $this->GetPoints($key);
250 $arSections[$key] = array_merge($arSections[$key], $this->GetSectionStat($key));
251 continue;
252 }
253
254 $arFields = $arSectionFields;
255 $arFields["POINTS"] = $this->GetPoints($key);
256 $arFields = array_merge($arFields, $this->GetSectionStat($key));
257 $arSections[$arFields["PARENT"]]["CATEGORIES"][$key] = $arFields;
258 unset($arSections[$key]);
259 }
260
261 $arResult["STRUCTURE"] = $arSections;
262 $arResult["STAT"] = $this->GetSectionStat();
263 return $arResult;
264 }
265
266 function PointUpdate($arTestID, $arPointFields = [])
267 {//update test info in the object property
268 if (!$arTestID || empty($arPointFields) || $this->report_id)
269 {
270 return false;
271 }
272
273 $currentFields =
274 is_array($this->current_result) && isset($this->current_result[$arTestID])
275 ? $this->current_result[$arTestID]
276 : [];
277
278 if (!$arPointFields["STATUS"])
279 {
280 $arPointFields["STATUS"] = $currentFields["STATUS"];
281 }
282
283 $this->current_result[$arTestID] = $arPointFields;
284
285 return true;
286 }
287
289 {
290 //getting description of sections and points
291 $file = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/lang/" . LANG . "/admin/checklist/" . $ID . ".html";
292 $howTo = "";
293 if (file_exists($file))
294 {
295 $howTo = file_get_contents($file);
296 }
297
299 if ($convertEncoding)
300 {
303 if ($targetEncoding !== 'utf-8' || !preg_match('//u', $howTo))
304 {
305 $howTo = \Bitrix\Main\Text\Encoding::convertEncoding($howTo, $sourceEncoding, $targetEncoding);
306 }
307 }
308
309 $arDesc = [
310 "NAME" => GetMessage("CL_" . $ID),
311 "DESC" => GetMessage("CL_" . $ID . "_DESC", ['#LANG#' => LANG]),
312 "AUTOTEST_DESC" => GetMessage("CL_" . $ID . "_AUTOTEST_DESC"),
313 "HOWTO" => ($howTo <> '') ? (str_ireplace('#LANG#', LANG, $howTo)) : "",
314 "LINKS" => GetMessage("CL_" . $ID . "_LINKS"),
315 ];
316
317 return $arDesc;
318 }
319
320 function Save()
321 {//saving current state
322 if (!$this->report_id)
323 {
324 $res = CCheckListResult::Save(["STATE" => $this->current_result]);
325 if (!is_array($res))
326 {
327 CUserOptions::SetOption("checklist", "autotest_start", "Y", true, false);
328 }
329 return $res;
330 }
331 return false;
332 }
333
335 {//getting current state
336 $arCheckList = $this->checklist;
337 $currentState = $this->current_result;
338 foreach ($arCheckList["POINTS"] as $testID => $arTestFields)
339 {
340 if (!empty($currentState[$testID]))
341 {
342 $arCheckList["POINTS"][$testID]["STATE"] = $currentState[$testID];
343 }
344 else
345 {
346 $arCheckList["POINTS"][$testID]["STATE"] = [
347 "STATUS" => "W",
348 ];
349 }
350 }
351
352 return $arCheckList;
353 }
354
355 function AutoCheck($arTestID, $arParams = [])
356 {//execute point autotest
357 $arParams["TEST_ID"] = $arTestID;
358 $arPoints = $this->GetPoints();
359 $arPoint = $arPoints[$arTestID];
360 $result = false;
361 if (!$arPoint || $arPoint["AUTO"] != "Y")
362 {
363 return false;
364 }
365 if (isset($arPoints[$arTestID]["PARAMS"]) && is_array($arPoints[$arTestID]["PARAMS"]))
366 {
367 $arParams = array_merge($arParams, $arPoints[$arTestID]["PARAMS"]);
368 }
369 $arClass = $arPoint["CLASS_NAME"];
370 $arMethod = $arPoint["METHOD_NAME"];
371
372 if (!empty($arPoint["FILE_PATH"]) && file_exists($_SERVER["DOCUMENT_ROOT"] . $arPoint["FILE_PATH"]))
373 {
374 include($_SERVER["DOCUMENT_ROOT"] . $arPoint["FILE_PATH"]);
375 }
376
377 if (is_callable([$arClass, $arMethod]))
378 {
379 $result = call_user_func_array([$arClass, $arMethod], [$arParams]);
380 }
381
382 $arResult = [];
383 if ($result && is_array($result))
384 {
385 if (array_key_exists("STATUS", $result))
386 {
387 $arFields["STATUS"] = "F";
388 if ($result['STATUS'] == "true")
389 {
390 $arFields["STATUS"] = "A";
391 }
392
393 $arFields["COMMENTS"] = $arPoint["STATE"]["COMMENTS"] ?? [];
394 $arFields["COMMENTS"]["SYSTEM"] = [];
395 if (isset($result["MESSAGE"]["PREVIEW"]))
396 {
397 $arFields["COMMENTS"]["SYSTEM"]["PREVIEW"] = $result["MESSAGE"]["PREVIEW"];
398 }
399 if (isset($result["MESSAGE"]["DETAIL"]))
400 {
401 $arFields["COMMENTS"]["SYSTEM"]["DETAIL"] = $result["MESSAGE"]["DETAIL"];
402 }
403
404 if ($this->PointUpdate($arTestID, $arFields))
405 {
406 if ($this->Save())
407 {
408 $arResult = [
409 "STATUS" => $arFields["STATUS"],
410 "COMMENTS_COUNT" => count($arFields["COMMENTS"] ?? []),
411 "ERROR" => $result["ERROR"] ?? null,
412 "SYSTEM_MESSAGE" => $arFields["COMMENTS"]["SYSTEM"] ?? '',
413 ];
414 }
415 }
416 }
417 elseif ($result["IN_PROGRESS"] == "Y")
418 {
419 $arResult = [
420 "IN_PROGRESS" => "Y",
421 "PERCENT" => $result["PERCENT"],
422 ];
423 }
424 }
425 else
426 {
427 $arResult = ["STATUS" => "W"];
428 }
429
430 return $arResult;
431 }
432
433 function AddReport($arReportFields = [], $errorCheck = false)
434 {//saving current state to a report
435 if ($this->report_id)
436 {
437 return false;
438 }
439
440 if ($errorCheck && !$arReportFields["TESTER"] && !$arReportFields["COMPANY_NAME"])
441 {
442 return ["ERROR" => GetMessage("EMPTY_NAME")];
443 }
444
445 $arStats = $this->GetSectionStat();
446 $arFields = [
447 "TESTER" => $arReportFields["TESTER"],
448 "COMPANY_NAME" => $arReportFields["COMPANY_NAME"],
449 "PHONE" => $arReportFields["PHONE"],
450 "EMAIL" => $arReportFields["EMAIL"],
451 "PICTURE" => $arReportFields["PICTURE"],
452 "REPORT_COMMENT" => $arReportFields["COMMENT"],
453 "STATE" => $this->current_result,
454 "TOTAL" => $arStats["TOTAL"],
455 "SUCCESS" => $arStats["CHECK"],
456 "SUCCESS_R" => $arStats["CHECK_R"],
457 "FAILED" => $arStats["FAILED"],
458 "PENDING" => $arStats["WAITING"],
459 "REPORT" => true,
460 ];
461
462 $arReportID = CCheckListResult::Save($arFields);
463 if ($arReportID > 0)
464 {
465 $dbres = CCheckListResult::GetList([], ["REPORT" => "N"]);
466 if ($res = $dbres->Fetch())
467 {
469 CUserOptions::SetOption("checklist", "autotest_start", "N", true, false);
470 }
471 return $arReportID;
472 }
473
474 return false;
475 }
476
477 function GetReportInfo()
478 {//getting report information
479 if ($this->report_id)
480 {
481 $checklist = new CCheckList($this->report_id);
482 if ($checklist->current_result == false)
483 {
484 return false;
485 }
486 $arResult = $checklist->GetStructure();
487
488 //removing empty sections
489 /*foreach($arResult["STRUCTURE"] as $key => $rFields)
490 {
491 $arsCategories = array();
492 foreach ($rFields["CATEGORIES"] as $skey => $sFields)
493 {
494 if (count($sFields["POINTS"])>0)
495 $arsCategories[$skey] = $sFields;
496 }
497 if (count($arsCategories)>0)
498 {
499 $rFields["CATEGORIES"] = $arsCategories;
500 $arTmpStructure[$key] = $rFields;
501 }
502 }
503 $arResult["STRUCTURE"] = $arTmpStructure;*/
504 $arResult["POINTS"] = $checklist->GetPoints();
505 $arResult["INFO"] = $checklist->report_info;
506
507 return $arResult;
508 }
509 return false;
510 }
511}
512
514{
515 public static function Save($arFields = [])
516 {
517 global $DB;
518
519 $arResult = [];
520 if ($arFields["STATE"] && is_array($arFields["STATE"]))
521 {
522 $arFields["STATE"] = serialize($arFields["STATE"]);
523 }
524 else
525 {
526 $arResult["ERRORS"][] = GetMessage("ERROR_DATA_RECEIVED");
527 }
528
529 $currentState = false;
530 if (!isset($arFields["REPORT"]) || $arFields["REPORT"] != true)
531 {
532 $arFields["REPORT"] = "N";
533 $db_result = $DB->Query("SELECT ID FROM b_checklist WHERE REPORT <> 'Y'");
534 $currentState = $db_result->Fetch();
535 }
536 else
537 {
538 $arFields["REPORT"] = "Y";
539 }
540
541 if (!empty($arResult["ERRORS"]))
542 {
543 return $arResult;
544 }
545
546 if ($currentState)
547 {
548 $strUpdate = $DB->PrepareUpdate("b_checklist", $arFields);
549 $strSql = "UPDATE b_checklist SET " . $strUpdate . " WHERE ID=" . $currentState["ID"];
550 }
551 else
552 {
553 $arInsert = $DB->PrepareInsert("b_checklist", $arFields);
554 $strSql = "INSERT INTO b_checklist(" . $arInsert[0] . ", DATE_CREATE) " .
555 "VALUES(" . $arInsert[1] . ", '" . ConvertTimeStamp(time(), "FULL") . "')";
556 }
557
558 $arBinds = [
559 "STATE" => $arFields["STATE"],
560 ];
561 $arResult = $DB->QueryBind($strSql, $arBinds);
562
563 return $arResult;
564 }
565
566 public static function GetList($arOrder = [], $arFilter = [])
567 {
568 global $DB;
569
570 $arSqlWhereStr = '';
571 if (is_array($arFilter) && !empty($arFilter))
572 {
573 $arSqlWhere = [];
574 $arSqlFields = ["ID", "REPORT", "HIDDEN", "SENDED_TO_BITRIX"];
575 foreach ($arFilter as $key => $value)
576 {
577 if (in_array($key, $arSqlFields))
578 {
579 $arSqlWhere[] = $key . "='" . $DB->ForSql($value) . "'";
580 }
581 }
582 $arSqlWhereStr = GetFilterSqlSearch($arSqlWhere);
583 }
584
585 $strSql = "SELECT * FROM b_checklist";
586 if ($arSqlWhereStr <> '')
587 {
588 $strSql .= " WHERE " . $arSqlWhereStr;
589 }
590 $strSql .= " ORDER BY ID desc";
591 $arResult = $DB->Query($strSql);
592
593 return $arResult;
594 }
595
596 public static function Update($ID, $arFields)
597 {
598 global $DB;
599 $ID = intval($ID);
600
601 $strUpdate = $DB->PrepareUpdate("b_checklist", $arFields);
602
603 $strSql =
604 "UPDATE b_checklist SET " . $strUpdate . " WHERE ID = " . $ID . " ";
605 $DB->Query($strSql);
606 return $ID;
607 }
608
609 public static function Delete($ID)
610 {
611 global $DB;
612 $ID = intval($ID);
613 if (!$ID > 0)
614 {
615 return false;
616 }
617 $strSql = "DELETE FROM b_checklist where ID=" . $ID;
618 if ($arResult = $DB->Query($strSql))
619 {
620 return true;
621 }
622 return false;
623 }
624}
625
627{
628 public static function CheckCustomComponents($arParams)
629 {
630 $arResult["STATUS"] = false;
631 $arComponentFolders = [
632 "/bitrix/components",
633 "/local/components",
634 ];
635 $components = [];
636 foreach ($arComponentFolders as $componentFolder)
637 {
638 if (file_exists($_SERVER['DOCUMENT_ROOT'] . $componentFolder) && ($handle = opendir($_SERVER['DOCUMENT_ROOT'] . $componentFolder)))
639 {
640 while (($file = readdir($handle)) !== false)
641 {
642 if ($file == "bitrix" || $file == ".." || $file == ".")
643 {
644 continue;
645 }
646
647 $dir = $componentFolder . "/" . $file;
648 if (is_dir($_SERVER['DOCUMENT_ROOT'] . $dir))
649 {
651 {
652 $components[] = [
653 "path" => $dir,
654 "name" => $file,
655 ];
656 }
657 elseif ($comp_handle = opendir($_SERVER['DOCUMENT_ROOT'] . $dir))
658 {
659 while (($subdir = readdir($comp_handle)) !== false)
660 {
661 if ($subdir == ".." || $subdir == "." || $subdir == ".svn")
662 {
663 continue;
664 }
665
666 if (CComponentUtil::isComponent($dir . "/" . $subdir))
667 {
668 $components[] = [
669 "path" => $dir . "/" . $subdir,
670 "name" => $file . ":" . $subdir,
671 ];
672 }
673 }
674 closedir($comp_handle);
675 }
676 }
677 }
678 closedir($handle);
679 }
680 }
681 if (isset($arParams["ACTION"]) && $arParams["ACTION"] == "FIND")
682 {
683 foreach ($components as $component)
684 {
685 $arResult["MESSAGE"]["DETAIL"] .= $component["name"] . " \n";
686 }
687
688 if ($arResult["MESSAGE"]["DETAIL"] == '')
689 {
690 $arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_HAVE_NO_CUSTOM_COMPONENTS");
691 }
692 else
693 {
694 $arResult = [
695 "STATUS" => true,
696 "MESSAGE" => [
697 "PREVIEW" => GetMessage("CL_HAVE_CUSTOM_COMPONENTS") . " (" . count($components) . ")",
698 "DETAIL" => $arResult["MESSAGE"]["DETAIL"],
699 ],
700 ];
701 }
702 }
703 else
704 {
705 foreach ($components as $component)
706 {
707 $desc = $_SERVER['DOCUMENT_ROOT'] . $component["path"] . "/.description.php";
708 if (!file_exists($desc) || filesize($desc) === 0)
709 {
710 $arResult["MESSAGE"]["DETAIL"] .= GetMessage("CL_EMPTY_DESCRIPTION") . " " . $component["name"] . " \n";
711 }
712 }
713
714 if (!isset($arResult["MESSAGE"]["DETAIL"]) || $arResult["MESSAGE"]["DETAIL"] == '')
715 {
716 $arResult["STATUS"] = true;
717 $arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_HAVE_CUSTOM_COMPONENTS_DESC");
718 }
719 else
720 {
721 $arResult = [
722 "STATUS" => false,
723 "MESSAGE" => [
724 "PREVIEW" => GetMessage("CL_ERROR_FOUND_SHORT"),
725 "DETAIL" => $arResult["MESSAGE"]["DETAIL"],
726 ],
727 ];
728 }
729 }
730 return $arResult;
731 }
732
733 public static function CheckBackup()
734 {
735 $arCount = 0;
736 $arResult = [];
737 $arResult["STATUS"] = false;
738 $bBitrixCloud = function_exists('openssl_encrypt') && CModule::IncludeModule('bitrixcloud') && CModule::IncludeModule('clouds');
739
740 $site = CSite::GetSiteByFullPath($_SERVER['DOCUMENT_ROOT']);
741 $path = BX_ROOT . "/backup";
742 $arTmpFiles = [];
743 $arFilter = [];
744 GetDirList([$site, $path], $arDir, $arTmpFiles, $arFilter, ['sort' => 'asc'], "F");
745
746 foreach ($arTmpFiles as $ar)
747 {
748 if (mb_strpos($ar['NAME'], ".enc.gz") || mb_strpos($ar['NAME'], ".tar.gz") || mb_strpos($ar['NAME'], ".tar") || mb_strpos($ar['NAME'], ".enc"))
749 {
750 $arCount++;
751 }
752 }
753
754 if ($bBitrixCloud)
755 {
757 try
758 {
759 foreach ($backup->listFiles() as $ar)
760 {
761 if (mb_strpos($ar['FILE_NAME'], ".enc.gz") || mb_strpos($ar['FILE_NAME'], ".tar.gz") || mb_strpos($ar['FILE_NAME'], ".tar") || mb_strpos($ar['FILE_NAME'], ".enc"))
762 {
763 $arCount++;
764 }
765 }
766 }
767 catch (Exception $e)
768 {
769 }
770 }
771 if ($arCount > 0)
772 {
773 $arResult["STATUS"] = true;
774 $arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_FOUND_BACKUP", ["#count#" => $arCount]);
775 }
776 else
777 {
778 $arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_NOT_FOUND_BACKUP");
779 }
780 return $arResult;
781 }
782
783 public static function CheckTemplates()
784 {
785 $arFolders = [
786 $_SERVER['DOCUMENT_ROOT'] . "/bitrix/templates",
787 $_SERVER['DOCUMENT_ROOT'] . "/local/templates",
788 ];
789 $arResult["STATUS"] = false;
790 $arCount = 0;
791 $arRequireFiles = ["header.php", "footer.php"];
792 $arFilter = [".svn", ".", ".."];
793 $arMessage = '';
794 foreach ($arFolders as $folder)
795 {
796 if (file_exists($folder) && ($arTemplates = scandir($folder)))
797 {
798 foreach ($arTemplates as $dir)
799 {
800 $arTemplateFolder = $folder . "/" . $dir;
801 if (in_array($dir, $arFilter) || !is_dir($arTemplateFolder))
802 {
803 continue;
804 }
805 $arRequireFilesTmp = $arRequireFiles;
806
807 foreach ($arRequireFilesTmp as $k => $file)
808 {
809 if (!file_exists($arTemplateFolder . "/" . $file))
810 {
811 $arMessage .= GetMessage("NOT_FOUND_FILE", ["#template#" => $dir, "#file_name#" => $file]) . "\n";
812 unset($arRequireFilesTmp[$k]);
813 }
814 }
815
816 if (in_array("header.php", $arRequireFilesTmp))
817 {
818 if (file_exists($arTemplateFolder . '/header.php'))
819 {
820 $header = file_get_contents($arTemplateFolder . '/header.php');
821
822 if ($header != '')
823 {
824 preg_match('/\$APPLICATION->ShowHead\‍(/im', $header, $arShowHead);
825 preg_match('/\$APPLICATION->ShowTitle\‍(/im', $header, $arShowTitle);
826 preg_match('/\$APPLICATION->ShowPanel\‍(/im', $header, $arShowPanel);
827 if (!in_array($dir, ['mail_join']) && empty($arShowHead))
828 {
829 preg_match_all('/\$APPLICATION->(ShowCSS|ShowHeadScripts|ShowHeadStrings)\‍(/im', $header, $arShowHead);
830 if (!$arShowHead[0] || count($arShowHead[0]) != 3)
831 {
832 $arMessage .= GetMessage("NO_SHOWHEAD", ["#template#" => $dir]) . "\n";
833 }
834 }
835 if (!in_array($dir, ['empty', 'mail_join']) && empty($arShowTitle))
836 {
837 $arMessage .= GetMessage("NO_SHOWTITLE", ["#template#" => $dir]) . "\n";
838 }
839 if (!in_array($dir, ['mobile_app', 'desktop_app', 'empty', 'learning_10_0_0', 'call_app', 'mail_join', 'dashboard_detail', 'booking_pub']) && empty($arShowPanel))
840 {
841 $arMessage .= GetMessage("NO_SHOWPANEL", ["#template#" => $dir]) . "\n";
842 }
843 }
844 }
845 }
846
847 $arCount++;
848 }
849 }
850 }
851
852 if ($arCount == 0)
853 {
854 $arResult["MESSAGE"]["PREVIEW"] = GetMessage("NOT_FOUND_TEMPLATE");
855 }
856 elseif ($arMessage == '')
857 {
858 $arResult["STATUS"] = true;
859 }
860
861 $arResult["MESSAGE"] = [
862 "PREVIEW" => GetMessage("TEMPLATE_CHECK_COUNT", ["#count#" => $arCount]),
863 "DETAIL" => $arMessage,
864 ];
865
866 return $arResult;
867 }
868
869 public static function CheckKernel($arParams)
870 {
871 global $DB;
872
873 $startTime = time();
874 $installFilesMapping = [
875 "install/components/bitrix/" => "/bitrix/components/bitrix/",
876 "install/js/" => "/bitrix/js/",
877 "install/activities/" => "/bitrix/activities/",
878 "install/admin/" => "/bitrix/admin/",
879 "install/wizards/" => "/bitrix/wizards/",
880 ];
881
882 $events = \Bitrix\Main\EventManager::getInstance()->findEventHandlers("main", "onKernelCheckInstallFilesMappingGet");
883 foreach ($events as $event)
884 {
885 $pathList = ExecuteModuleEventEx($event);
886 if (is_array($pathList))
887 {
888 foreach ($pathList as $pathFrom => $pathTo)
889 {
890 if (!array_key_exists($pathFrom, $installFilesMapping))
891 {
892 $installFilesMapping[$pathFrom] = $pathTo;
893 }
894 }
895 }
896 }
897
898 if (empty(\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"][$arParams["TEST_ID"]]))
899 {
900 \Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"][$arParams["TEST_ID"]] = [];
901 }
902 $NS = &\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"][$arParams["TEST_ID"]];
903 if ($arParams["STEP"] == false)
904 {
905 $NS = [];
906 $rsInstalledModules = CModule::GetList();
907 while ($ar = $rsInstalledModules->Fetch())
908 {
909 if (!mb_strpos($ar["ID"], "."))
910 {
911 $NS["MLIST"][] = $ar["ID"];
912 }
913 }
914 $NS["MNUM"] = 0;
915 $NS["FILE_LIST"] = [];
916 $NS["FILES_COUNT"] = 0;
917 $NS["MODFILES_COUNT"] = 0;
918 }
919
920 $arError = false;
921 $moduleId = $NS["MLIST"][$NS["MNUM"]];
922 $moduleFolder = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/" . $moduleId . "/";
923 $dbtype = mb_strtolower($DB->type);
924 $fileCount = 0;
925 $modifiedFileCount = 0;
926 $state = [];
927 $skip = false;
928
930 if ($ver === false)
931 {
932 $state = [
933 "STATUS" => false,
934 "MESSAGE" => GetMessage("CL_MODULE_VERSION_ERROR", ["#module_id#" => $moduleId]) . "\n",
935 ];
936 $arError = true;
937 }
938 else
939 {
940 if (empty($NS["FILE_LIST"]))
941 {
942 $sHost = COption::GetOptionString("main", "update_site", "www.1c-bitrix.ru");
943 $proxyAddr = COption::GetOptionString("main", "update_site_proxy_addr", "");
944 $proxyPort = COption::GetOptionString("main", "update_site_proxy_port", "");
945 $proxyUserName = COption::GetOptionString("main", "update_site_proxy_user", "");
946 $proxyPassword = COption::GetOptionString("main", "update_site_proxy_pass", "");
947
948 $http = new \Bitrix\Main\Web\HttpClient();
949 $http->setProxy($proxyAddr, $proxyPort, $proxyUserName, $proxyPassword);
950
951 $data = $http->get("https://" . $sHost . "/bitrix/updates/checksum.php?check_sum=Y&module_id=" . $moduleId . "&ver=" . $ver . "&dbtype=" . $dbtype . "&mode=2");
952
953 $result = unserialize(gzinflate($data), ['allowed_classes' => false]);
954 if (is_array($result))
955 {
956 $NS["FILE_LIST"] = $result;
957 }
958 $NS["MODULE_FILES_COUNT"] = count($NS["FILE_LIST"]);
959 }
960 else
961 {
962 $result = $NS["FILE_LIST"];
963 }
964
965 $message = "";
966 $timeout = COption::GetOptionString("main", "update_load_timeout", "30");
967 if (is_array($result) && empty($result["error"]))
968 {
969 foreach ($result as $file => $checksum)
970 {
971 $filePath = $moduleFolder . $file;
972 unset($NS["FILE_LIST"][$file]);
973
974 if (!file_exists($filePath))
975 {
976 continue;
977 }
978
979 $fileCount++;
980 if (md5_file($filePath) != $checksum)
981 {
982 $message .= str_replace(["//", "\\\\"], ["/", "\\"], $filePath) . "\n";
983 $modifiedFileCount++;
984 }
985
986 foreach ($installFilesMapping as $key => $value)
987 {
988 if (mb_strpos($file, $key) === 0)
989 {
990 $filePath = str_replace($key, $_SERVER["DOCUMENT_ROOT"] . $value, $file);
991 if (file_exists($filePath) && md5_file($filePath) != $checksum)
992 {
993 $modifiedFileCount++;
994 $message .= str_replace(["//", "\\\\"], ["/", "\\"], $filePath) . "\n";
995 }
996 $fileCount++;
997 }
998 }
999
1000 if ((time() - $startTime) >= $timeout)
1001 {
1002 break;
1003 }
1004 }
1005 if ($message <> '')
1006 {
1007 $state = [
1008 "MESSAGE" => $message,
1009 "STATUS" => false,
1010 ];
1011 }
1012 }
1013 else
1014 {
1015 if ($result["error"] != "unknow module id")
1016 {
1017 $state["MESSAGE"] = GetMessage("CL_CANT_CHECK", ["#module_id#" => $moduleId]) . "\n";
1018 $arError = true;
1019 }
1020 else
1021 {
1022 $skip = true;
1023 }
1024 }
1025 }
1026 if (!empty($state["MESSAGE"]))
1027 {
1028 if (!isset($NS["MESSAGE"][$moduleId]))
1029 {
1030 $NS["MESSAGE"][$moduleId] = '';
1031 }
1032
1033 $NS["MESSAGE"][$moduleId] .= $state["MESSAGE"];
1034 }
1035 if (!$arError && !$skip)
1036 {
1037 if (empty($NS["FILE_LIST"]))
1038 {
1039 if (!isset($NS["MESSAGE"][$moduleId]) || $NS["MESSAGE"][$moduleId] == '')
1040 {
1041 $NS["MESSAGE"][$moduleId] = GetMessage("CL_NOT_MODIFIED", ["#module_id#" => $moduleId]) . "\n";
1042 }
1043 else
1044 {
1045 $NS["MESSAGE"][$moduleId] = GetMessage("CL_MODIFIED_FILES", ["#module_id#" => $moduleId]) . "\n" . $NS["MESSAGE"][$moduleId];
1046 }
1047 }
1048 $NS["FILES_COUNT"] += $fileCount;
1049 $NS["MODFILES_COUNT"] += $modifiedFileCount;
1050 }
1051 if ((isset($state["STATUS"]) && $state["STATUS"] === false) || $arError == true || $skip)
1052 {
1053 if ((isset($state["STATUS"]) && $state["STATUS"] === false) || $arError == true)
1054 {
1055 $NS["STATUS"] = false;
1056 }
1057 $NS["FILE_LIST"] = [];
1058 $NS["MODULE_FILES_COUNT"] = 0;
1059 }
1060
1061 if (($NS["MNUM"] + 1) >= (count($NS["MLIST"])) && empty($NS["LAST_FILE"]))
1062 {
1063 $arDetailReport = "";
1064 foreach ($NS["MESSAGE"] as $module_message)
1065 {
1066 $arDetailReport .= "<div class=\"checklist-dot-line\"></div>" . $module_message;
1067 }
1068 $arResult = [
1069 "MESSAGE" => [
1070 "PREVIEW" => GetMessage("CL_KERNEL_CHECK_FILES") . $NS["FILES_COUNT"] . "\n" .
1071 GetMessage("CL_KERNEL_CHECK_MODULE") . count($NS["MLIST"]) . "\n" .
1072 GetMessage("CL_KERNEL_CHECK_MODIFIED") . $NS["MODFILES_COUNT"],
1073 "DETAIL" => $arDetailReport,
1074 ],
1075 "STATUS" => ($NS["STATUS"] === false ? false : true),
1076 ];
1077 }
1078 else
1079 {
1080 $percent = round(($NS["MNUM"]) / (count($NS["MLIST"]) * 0.01), 0);
1081 $module_percent = 0;
1082 if ($NS["MODULE_FILES_COUNT"] > 0)
1083 {
1084 $module_percent = (1 / (count($NS["MLIST"]) * 0.01)) * ((($NS["MODULE_FILES_COUNT"] - count($NS["FILE_LIST"])) / ($NS["MODULE_FILES_COUNT"] * 0.01)) * 0.01);
1085 }
1086 $percent += $module_percent;
1087 $arResult = [
1088 "IN_PROGRESS" => "Y",
1089 "PERCENT" => number_format($percent, 2),
1090 ];
1091 if (empty($NS["FILE_LIST"]))
1092 {
1093 $NS["MNUM"]++;
1094 $NS["MODULE_FILES_COUNT"] = 0;
1095 }
1096 }
1097 return $arResult;
1098 }
1099
1100 public static function CheckSecurity($arParams)
1101 {
1102 global $DB;
1103 $err = 0;
1104 $arResult['STATUS'] = false;
1105 $arMessage = '';
1106 switch ($arParams["ACTION"])
1107 {
1108 case "SECURITY_LEVEL":
1109 if (CModule::IncludeModule("security"))
1110 {
1111 if ($arMask = CSecurityFilterMask::GetList()->Fetch())
1112 {
1113 $arMessage .= (++$err) . ". " . GetMessage("CL_FILTER_EXEPTION_FOUND") . "\n";
1114 }
1115 if (!CSecurityFilter::IsActive())
1116 {
1117 $arMessage .= (++$err) . ". " . GetMessage("CL_FILTER_NON_ACTIVE") . "\n";
1118 }
1119 if (COption::GetOptionString("main", "captcha_registration", "N") == "N")
1120 {
1121 $arMessage .= (++$err) . ". " . GetMessage("CL_CAPTCHA_NOT_USE") . "\n";
1122 }
1123
1124 if (CCheckListTools::AdminPolicyLevel() != "high")
1125 {
1126 $arMessage .= (++$err) . ". " . GetMessage("CL_ADMIN_SECURITY_LEVEL") . "\n";
1127 }
1128 if (COption::GetOptionInt("main", "error_reporting", E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_PARSE) != (E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_PARSE) && COption::GetOptionString("main", "error_reporting", "") != 0)
1129 {
1130 $arMessage .= (++$err) . ". " . GetMessage("CL_ERROR_REPORTING_LEVEL") . "\n";
1131 }
1132 if ($DB->debug)
1133 {
1134 $arMessage .= (++$err) . ". " . GetMessage("CL_DBDEBUG_TURN_ON") . "\n";
1135 }
1136 if ($arMessage)
1137 {
1138 $arResult["STATUS"] = false;
1139 $arResult["MESSAGE"] = [
1140 "PREVIEW" => GetMessage("CL_MIN_LEVEL_SECURITY"),
1141 "DETAIL" => GetMessage("CL_ERROR_FOUND") . "\n" . $arMessage,
1142 ];
1143 }
1144 else
1145 {
1146 $arResult["STATUS"] = true;
1147 $arResult["MESSAGE"] = [
1148 "PREVIEW" => GetMessage("CL_LEVEL_SECURITY") . "\n",
1149 ];
1150 }
1151 }
1152 else
1153 {
1154 $arResult = [
1155 "STATUS" => false,
1156 "MESSAGE" => [
1157 "PREVIEW" => GetMessage("CL_SECURITY_MODULE_NOT_INSTALLED") . "\n",
1158 ],
1159 ];
1160 }
1161 break;
1162 case "ADMIN_POLICY":
1163 if (CCheckListTools::AdminPolicyLevel() != "high")
1164 {
1165 $arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_ADMIN_SECURITY_LEVEL") . "\n";
1166 }
1167 else
1168 {
1169 $arResult = [
1170 "STATUS" => true,
1171 "MESSAGE" => [
1172 "PREVIEW" => GetMessage("CL_ADMIN_SECURITY_LEVEL_IS_HIGH") . "\n",
1173 ],
1174 ];
1175 }
1176 break;
1177 }
1178
1179 return $arResult;
1180 }
1181
1182 public static function CheckErrorReport()
1183 {
1184 global $DBDebug;
1185 $err = 0;
1186 $arResult["STATUS"] = true;
1187 $arMessage = '';
1188 if ($DBDebug)
1189 {
1190 $arMessage .= (++$err) . ". " . GetMessage("CL_DBDEBUG_TURN_ON") . "\n";
1191 }
1192 if (COption::GetOptionString("main", "error_reporting", "") != 0 && ini_get("display_errors"))
1193 {
1194 $arMessage .= (++$err) . ". " . GetMessage("CL_ERROR_REPORT_TURN_ON") . "\n";
1195 }
1196
1197 if ($arMessage)
1198 {
1199 $arResult["STATUS"] = false;
1200 $arResult["MESSAGE"] = [
1201 "PREVIEW" => GetMessage("CL_ERROR_FOUND_SHORT") . "\n",
1202 "DETAIL" => $arMessage,
1203 ];
1204 }
1205 return $arResult;
1206 }
1207
1208 public static function IsCacheOn()
1209 {
1210 $arResult["STATUS"] = true;
1211 if (COption::GetOptionString("main", "component_cache_on", "Y") == "N")
1212 {
1213 $arResult["STATUS"] = false;
1214 $arResult["MESSAGE"] = [
1215 "PREVIEW" => GetMessage("CL_TURNOFF_AUTOCACHE") . "\n",
1216 ];
1217 }
1218 else
1219 {
1220 $arResult["MESSAGE"] = [
1221 "PREVIEW" => GetMessage("CL_TURNON_AUTOCACHE") . "\n",
1222 ];
1223 }
1224
1225 return $arResult;
1226 }
1227
1228 public static function CheckDBPassword()
1229 {
1230 $err = 0;
1231 $arMessage = "";
1232 $sign = ",.#!*%$:-^@{}[]()'\"-+=<>?`&;";
1233 $dit = "1234567890";
1234 $have_sign = false;
1235 $have_dit = false;
1236 $arResult["STATUS"] = true;
1237
1238 $connection = Main\Application::getInstance()->getConnection();
1239 $password = $connection->getPassword();
1240
1241 if ($password == '')
1242 {
1243 $arMessage .= GetMessage("CL_EMPTY_PASS") . "\n";
1244 }
1245 else
1246 {
1247 if ($password == mb_strtolower($password))
1248 {
1249 $arMessage .= (++$err) . ". " . GetMessage("CL_SAME_REGISTER") . "\n";
1250 }
1251
1252 for ($j = 0, $c = mb_strlen($password); $j < $c; $j++)
1253 {
1254 if (mb_strpos($sign, $password[$j]) !== false)
1255 {
1256 $have_sign = true;
1257 }
1258 if (mb_strpos($dit, $password[$j]) !== false)
1259 {
1260 $have_dit = true;
1261 }
1262 if ($have_dit == true && $have_sign == true)
1263 {
1264 break;
1265 }
1266 }
1267
1268 if (!$have_dit)
1269 {
1270 $arMessage .= (++$err) . ". " . GetMessage("CL_HAVE_NO_DIT") . "\n";
1271 }
1272 if (!$have_sign)
1273 {
1274 $arMessage .= (++$err) . ". " . GetMessage("CL_HAVE_NO_SIGN") . "\n";
1275 }
1276 if (mb_strlen($password) < 8)
1277 {
1278 $arMessage .= (++$err) . ". " . GetMessage("CL_LEN_MIN") . "\n";
1279 }
1280 }
1281 if ($arMessage)
1282 {
1283 $arResult["STATUS"] = false;
1284 $arResult["MESSAGE"] = [
1285 "PREVIEW" => GetMessage("CL_ERROR_FOUND_SHORT"),
1286 "DETAIL" => $arMessage,
1287 ];
1288 }
1289 else
1290 {
1291 $arResult["MESSAGE"] = [
1292 "PREVIEW" => GetMessage("CL_NO_ERRORS"),
1293 ];
1294 }
1295 return $arResult;
1296 }
1297
1298 public static function CheckPerfomance($arParams)
1299 {
1300 if (!IsModuleInstalled("perfmon"))
1301 {
1302 return [
1303 "STATUS" => false,
1304 "MESSAGE" => [
1305 "PREVIEW" => GetMessage("CL_CHECK_PERFOM_NOT_INSTALLED"),
1306 ],
1307 ];
1308 }
1309 $arResult = [
1310 "STATUS" => true,
1311 ];
1312 switch ($arParams["ACTION"])
1313 {
1314 case "PHPCONFIG":
1315 if (COption::GetOptionString("perfmon", "mark_php_is_good", "N") == "N")
1316 {
1317 $arResult["STATUS"] = false;
1318 $arResult["MESSAGE"] = [
1319 "PREVIEW" => GetMessage("CL_PHP_NOT_OPTIMAL", ["#LANG#" => LANG]) . "\n",
1320 ];
1321 }
1322 else
1323 {
1324 $arResult["MESSAGE"] = [
1325 "PREVIEW" => GetMessage("CL_PHP_OPTIMAL") . "\n",
1326 ];
1327 }
1328 break;
1329 case "PERF_INDEX":
1330 $arPerfIndex = COption::GetOptionString("perfmon", "mark_php_page_rate", "N");
1331 if ($arPerfIndex == "N")
1332 {
1333 $arResult["STATUS"] = false;
1334 $arResult["MESSAGE"] = [
1335 "PREVIEW" => GetMessage("CL_CHECK_PERFOM_FAILED", ["#LANG#" => LANG]) . "\n",
1336 ];
1337 }
1338 elseif ($arPerfIndex < 15)
1339 {
1340 $arResult["STATUS"] = false;
1341 $arResult["MESSAGE"] = [
1342 "PREVIEW" => GetMessage("CL_CHECK_PERFOM_LOWER_OPTIMAL", ["#LANG#" => LANG]) . "\n",
1343 ];
1344 }
1345 else
1346 {
1347 $arResult["MESSAGE"] = [
1348 "PREVIEW" => GetMessage("CL_CHECK_PERFOM_PASSED") . "\n",
1349 ];
1350 }
1351 break;
1352 }
1353 return $arResult;
1354 }
1355
1356 public static function CheckQueryString($arParams = [])
1357 {
1358 $time = time();
1359 $arPath = [
1360 $_SERVER["DOCUMENT_ROOT"],
1361 $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/",
1362 $_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/",
1363 $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components/",
1364 ];
1365 $arExept = [
1366 "FOLDERS" => ["images", "bitrix", "upload", ".svn"],
1367 "EXT" => ["php"],
1368 "FILES" => [
1369 $_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/dbconn.php",
1370 "after_connect.php",
1371 ],
1372 ];
1373
1374 $arParams["STEP"] = (intval($arParams["STEP"]) >= 0) ? intval($arParams["STEP"]) : 0;
1375 if (!\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"] || $arParams["STEP"] == 0)
1376 {
1377 \Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"] = [
1378 "LAST_FILE" => "",
1379 "FOUND" => "",
1380 "PERCENT" => 0,
1381 ];
1382 $files = [];
1383 $arPathTmp = $arPath;
1384 foreach ($arPathTmp as $path)
1385 {
1387 }
1388 \Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["COUNT"] = count($files);
1389 }
1390
1391 $arFileNum = 0;
1392 foreach ($arPath as $namespace)
1393 {
1394 $files = [];
1395 CCheckListTools::__scandir($namespace, $files, $arExept);
1396 foreach ($files as $file)
1397 {
1398 $arFileNum++;
1399 //this is not first step?
1400 if (\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["LAST_FILE"] <> '')
1401 {
1402 if (\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["LAST_FILE"] == $file)
1403 {
1404 \Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["LAST_FILE"] = "";
1405 }
1406 continue;
1407 }
1408
1409 if ($content = file_get_contents($file))
1410 {
1411 $queries = [];
1412 preg_match('/((?:mysql_query|mysqli_query|odbc_exec|oci_execute|odbc_execute)\‍(.*\‍))/ism', $content, $queries);
1413
1414 if ($queries && !empty($queries[0]))
1415 {
1416 \Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["FOUND"] .= str_replace(["//", "\\\\"], ["/", "\\"], $file) . "\n";
1417 }
1418 }
1419
1420 if (time() - $time >= 20)
1421 {
1422 \Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["LAST_FILE"] = $file;
1423 return [
1424 "IN_PROGRESS" => "Y",
1425 "PERCENT" => round($arFileNum / (\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["COUNT"] * 0.01), 2),
1426 ];
1427 }
1428 }
1429 }
1430 $arResult = ["STATUS" => true];
1431 if (\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["FOUND"] <> '')
1432 {
1433 $arResult["STATUS"] = false;
1434 $arResult["MESSAGE"] = [
1435 "PREVIEW" => GetMessage("CL_KERNEL_CHECK_FILES") . $arFileNum . ".\n" . GetMessage("CL_ERROR_FOUND_SHORT") . "\n",
1436 "DETAIL" => GetMessage("CL_DIRECT_QUERY_TO_DB") . "\n" . \Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]["FOUND"],
1437 ];
1438 }
1439 else
1440 {
1441 $arResult["MESSAGE"] = [
1442 "PREVIEW" => GetMessage("CL_KERNEL_CHECK_FILES") . $arFileNum . "\n",
1443 ];
1444 }
1445 unset(\Bitrix\Main\Application::getInstance()->getSession()["BX_CHECKLIST"]);
1446 return $arResult;
1447 }
1448
1449 public static function KeyCheck()
1450 {
1451 $arResult = ["STATUS" => false];
1452 $arUpdateList = CUpdateClient::GetUpdatesList($errorMessage, LANG);
1453 if (array_key_exists("CLIENT", $arUpdateList) && $arUpdateList["CLIENT"][0]["@"]["RESERVED"] == "N")
1454 {
1455 $arResult = [
1456 "STATUS" => true,
1457 "MESSAGE" => ["PREVIEW" => GetMessage("CL_LICENSE_KEY_ACTIVATE")],
1458 ];
1459 }
1460 else
1461 {
1462 $arResult["MESSAGE"] = ["PREVIEW" => GetMessage("CL_LICENSE_KEY_NONE_ACTIVATE", ["#LANG#" => LANG])];
1463 }
1464
1465 return $arResult;
1466 }
1467
1468 public static function CheckVMBitrix()
1469 {
1470 $arResult = ["STATUS" => true];
1471
1472 $vm = new BitrixVm();
1473 $ver = $vm->getVersion();
1474
1475 if ($ver)
1476 {
1477 if (version_compare($ver, $vm->getAvailableVersion()) >= 0)
1478 {
1479 $arResult["MESSAGE"] = [
1480 'PREVIEW' => GetMessage("CL_VMBITRIX_ACTUAL"),
1481 ];
1482 }
1483 else
1484 {
1485 $arResult["STATUS"] = false;
1486 $arResult["MESSAGE"] = [
1487 'PREVIEW' => GetMessage("CL_VMBITRIX_NOT_ACTUAL"),
1488 ];
1489 }
1490 }
1491
1492 return $arResult;
1493 }
1494
1495 public static function CheckSiteCheckerStatus()
1496 {
1497 $arResult = [];
1498 $arResult["STATUS"] = false;
1499
1500 $checkerStatus = COption::GetOptionString('main', 'site_checker_success', 'N');
1501 if ($checkerStatus == 'Y')
1502 {
1503 $arResult["STATUS"] = true;
1504 $arResult["MESSAGE"] = [
1505 'PREVIEW' => GetMessage("CL_SITECHECKER_OK", ["#LANG#" => LANG]),
1506 ];
1507 }
1508 else
1509 {
1510 $arResult["MESSAGE"] = [
1511 'PREVIEW' => GetMessage("CL_SITECHECKER_NOT_OK", ["#LANG#" => LANG]),
1512 ];
1513 }
1514
1515 return $arResult;
1516 }
1517
1518 public static function CheckSecurityScannerStatus()
1519 {
1520 $arResult = [];
1521 $arResult["STATUS"] = false;
1522
1523 if (!Loader::includeModule('security'))
1524 {
1525 return $arResult;
1526 }
1527
1528 $lastTestingInfo = CSecuritySiteChecker::getLastTestingInfo();
1529 $criticalResultsCount = CSecuritySiteChecker::calculateCriticalResults($lastTestingInfo["results"] ?? []);
1530
1531 if ((time() - MakeTimeStamp($lastTestingInfo['test_date'] ?? '', FORMAT_DATE)) > 60 * 60 * 24 * 30)
1532 {
1533 $arResult["MESSAGE"] = [
1534 'PREVIEW' => GetMessage("CL_SECURITYSCANNER_OLD", ["#LANG#" => LANG]),
1535 ];
1536 }
1537 elseif ($criticalResultsCount === 0)
1538 {
1539 $arResult["STATUS"] = true;
1540 $arResult["MESSAGE"] = [
1541 'PREVIEW' => GetMessage("CL_SECURITYSCANNER_OK"),
1542 ];
1543 }
1544 else
1545 {
1546 $arResult["MESSAGE"] = [
1547 'PREVIEW' => GetMessage("CL_SECURITYSCANNER_NOT_OK", ["#LANG#" => LANG]),
1548 ];
1549 }
1550
1551 return $arResult;
1552 }
1553}
1554
1556{
1557 public static function __scandir($pwd, &$arFiles, $arExept = false)
1558 {
1559 if (file_exists($pwd))
1560 {
1561 $dir = scandir($pwd);
1562 foreach ($dir as $file)
1563 {
1564 if ($file == ".." || $file == ".")
1565 {
1566 continue;
1567 }
1568 if (is_dir($pwd . "$file"))
1569 {
1570 if (!in_array($file, $arExept["FOLDERS"]))
1571 {
1572 CCheckListTools::__scandir($pwd . "$file/", $arFiles, $arExept);
1573 }
1574 }
1575 elseif (in_array(mb_substr(strrchr($file, '.'), 1), $arExept["EXT"])
1576 && !in_array($pwd . $file, $arExept["FILES"])
1577 && !in_array($file, $arExept["FILES"])
1578 )
1579 {
1580 $arFiles[] = $pwd . "/$file";
1581 }
1582 }
1583 }
1584 }
1585
1589 public static function AdminPolicyLevel()
1590 {
1591 $policy = CUser::getPolicy(1);
1592
1594 if ($policy->compare($preset))
1595 {
1596 // middle preset is stronger than the current
1597 return 'low';
1598 }
1599
1601 if ($policy->compare($preset))
1602 {
1603 // high preset is stronger than the current
1604 return 'middle';
1605 }
1606
1607 return 'high';
1608 }
1609}
$arParams
Определения access_dialog.php:21
$path
Определения access_edit.php:21
$connection
Определения actionsdefinitions.php:38
const BX_ROOT
Определения bx_root.php:3
$arResult
Определения generate_coupon.php:16
static getInstance()
Определения application.php:98
static createByPreset($preset=self::PRESET_DEFAULT)
Определения rulescollection.php:86
static getInstance()
Определения eventmanager.php:31
Определения loader.php:13
static includeModule($moduleName)
Определения loader.php:67
static getSourceEncoding($lang)
Определения translation.php:59
static getCurrentEncoding()
Определения translation.php:104
static needConvertEncoding($language, $targetEncoding=null)
Определения translation.php:122
static getVersion($moduleName)
Определения modulemanager.php:89
static convertEncoding($data, $charsetFrom, $charsetTo)
Определения encoding.php:17
Определения checklist.php:627
static CheckKernel($arParams)
Определения checklist.php:869
static CheckSecurityScannerStatus()
Определения checklist.php:1518
static KeyCheck()
Определения checklist.php:1449
static CheckVMBitrix()
Определения checklist.php:1468
static CheckPerfomance($arParams)
Определения checklist.php:1298
static CheckQueryString($arParams=[])
Определения checklist.php:1356
static CheckSiteCheckerStatus()
Определения checklist.php:1495
static CheckCustomComponents($arParams)
Определения checklist.php:628
static IsCacheOn()
Определения checklist.php:1208
static CheckDBPassword()
Определения checklist.php:1228
static CheckErrorReport()
Определения checklist.php:1182
static CheckSecurity($arParams)
Определения checklist.php:1100
static CheckBackup()
Определения checklist.php:733
static CheckTemplates()
Определения checklist.php:783
static getInstance()
Определения backup.php:19
Определения checklist.php:17
GetPoints($arSectionCode=false)
Определения checklist.php:213
GetReportInfo()
Определения checklist.php:477
PointUpdate($arTestID, $arPointFields=[])
Определения checklist.php:266
GetCurrentState()
Определения checklist.php:334
GetSections()
Определения checklist.php:103
GetStructure()
Определения checklist.php:237
AutoCheck($arTestID, $arParams=[])
Определения checklist.php:355
GetDescription($ID)
Определения checklist.php:288
GetSectionStat($ID=false)
Определения checklist.php:116
AddReport($arReportFields=[], $errorCheck=false)
Определения checklist.php:433
__construct($ID=false)
Определения checklist.php:18
Save()
Определения checklist.php:320
Определения checklist.php:514
static GetList($arOrder=[], $arFilter=[])
Определения checklist.php:566
static Delete($ID)
Определения checklist.php:609
static Save($arFields=[])
Определения checklist.php:515
static Update($ID, $arFields)
Определения checklist.php:596
Определения checklist.php:1556
static AdminPolicyLevel()
Определения checklist.php:1589
static __scandir($pwd, &$arFiles, $arExept=false)
Определения checklist.php:1557
static isComponent($componentPath)
Определения component_util.php:130
static GetList()
Определения filter_mask.php:63
static getLastTestingInfo()
Определения site_checker.php:178
static calculateCriticalResults($pResults=array())
Определения site_checker.php:321
$startTime
Определения sync.php:69
$content
Определения commerceml.php:144
$arFields
Определения dblapprove.php:5
$data['IS_AVAILABLE']
Определения .description.php:13
$arPath
Определения file_edit.php:72
$res
Определения filter_act.php:7
GetFilterSqlSearch($arSqlSearch=array(), $FilterLogic="FILTER_logic")
Определения filter_tools.php:397
$handle
Определения include.php:55
$result
Определения get_property_values.php:14
if($ajaxMode) $ID
Определения get_user.php:27
$moduleId
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
GetDirList($path, &$arDirs, &$arFiles, $arFilter=array(), $sort=array(), $type="DF", $bLogical=false, $task_mode=false)
Определения admin_tools.php:214
const FORMAT_DATE
Определения include.php:63
global $DBDebug
Определения start.php:35
$bBitrixCloud
Определения backup.php:171
if(!defined('NOT_CHECK_PERMISSIONS')) $NS
Определения backup.php:24
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
IsModuleInstalled($module_id)
Определения tools.php:5301
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
MakeTimeStamp($datetime, $format=false)
Определения tools.php:538
$password
Определения mysql_to_pgsql.php:34
$files
Определения mysql_to_pgsql.php:30
$time
Определения payment.php:61
$sign
Определения payment.php:69
if(mb_strlen($order)< 6) $desc
Определения payment.php:44
$message
Определения payment.php:8
$arFiles
Определения options.php:60
$event
Определения prolog_after.php:141
return false
Определения prolog_main_admin.php:185
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
</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
$sHost
Определения result.php:13
$k
Определения template_pdf.php:567
$dbResult
Определения updtr957.php:3
$arFilter
Определения user_search.php:106
$arSections
Определения yandex_run.php:805
$site
Определения yandex_run.php:614