38 $this->step = intval(
$step);
41 $this->arTestVars[
'site_checker_success'] =
'Y';
44 $this->cafile =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/tmp/cacert.pem';
45 $this->force_repair = defined(
'SITE_CHECKER_FORCE_REPAIR') && SITE_CHECKER_FORCE_REPAIR ===
true;
50 if (!preg_match(
'/^[a-z0-9.\-]+$/i', $this->host))
53 $this->host = $converter->Encode($this->host);
63 $arGroupDesc[1] =
GetMessage(
"MAIN_SC_REQUIRED_MODS_DESC");
65 [
'check_php_modules' =>
GetMessage(
'SC_T_MODULES')],
66 [
'check_php_settings' =>
GetMessage(
'SC_T_PHP')],
67 [
'check_security' =>
GetMessage(
'SC_T_APACHE')],
68 [
'check_server_vars' =>
GetMessage(
'SC_T_SERVER')],
70 [
'check_mbstring' =>
GetMessage(
'SC_T_MBSTRING')],
71 [
'check_install_scripts' =>
GetMessage(
'SC_T_INSTALL_SCRIPTS')],
73 [
'check_bx_crontab' =>
GetMessage(
"MAIN_SC_AGENTS_CRON")],
76 $arGroupName[2] =
GetMessage(
"MAIN_SC_BUSINESS");
77 $arGroupDesc[2] =
GetMessage(
"MAIN_SC_CORRECT_DESC");
79 [
'check_pull_stream' =>
GetMessage(
"MAIN_SC_TEST_PUSH_SERVER")],
80 [
'check_pull_comments' =>
GetMessage(
"MAIN_SC_TEST_COMMENTS")],
81 [
'check_turn' =>
GetMessage(
"MAIN_SC_TEST_VIDEO")],
82 [
'check_access_mobile' =>
GetMessage(
"MAIN_SC_TEST_MOBILE")],
83 [
'check_push_bitrix' =>
GetMessage(
"MAIN_SC_TEST_PUSH")],
84 [
'check_access_docs' =>
GetMessage(
"MAIN_SC_TEST_DOCS")],
85 [
'check_fast_download' =>
GetMessage(
"MAIN_SC_TEST_FAST_FILES_MSGVER_1")],
86 [
'check_search' =>
GetMessage(
"MAIN_SC_TEST_SEARCH_CONTENTS")],
87 [
'check_mail' =>
GetMessage(
"MAIN_SC_MAIL_TEST")],
88 [
'check_ca_file' =>
GetMessage(
"MAIN_SC_CLOUD_TEST")],
89 [
'check_connect_mail' =>
GetMessage(
"MAIN_SC_TEST_MAIL_INTEGRATION")],
90 [
'check_socnet' =>
GetMessage(
"MAIN_SC_TEST_SOCNET_INTEGRATION")],
91 [
'check_rest' =>
GetMessage(
"MAIN_SC_TEST_REST")],
92 [
'check_mail_push' =>
GetMessage(
"MAIN_SC_TEST_MAIL_PUSH")],
96 $arTestGroup[2][] = [
'check_extranet' =>
GetMessage(
"MAIN_SC_EXTRANET_ACCESS")];
99 $arGroupName[4] =
GetMessage(
"MAIN_SC_WINDOWS_ENV");
100 $arGroupDesc[4] =
'';
102 [
'check_webdav' =>
GetMessage(
"MAIN_SC_DOCS_EDIT_MS_OFFICE")],
103 [
'check_socket_ssl' =>
GetMessage(
"MAIN_SC_EXTERNAL_APPS_TEST")],
104 [
'check_ad' =>
GetMessage(
"MAIN_SC_TEST_LDAP")],
105 [
'check_ntlm' =>
GetMessage(
"MAIN_SC_TEST_NTLM")],
108 $arGroupName[8] =
GetMessage(
"MAIN_SC_PERFORM");
109 $arGroupDesc[8] =
'';
111 [
'check_perf' =>
GetMessage(
"MAIN_SC_PERF_TEST")],
112 [
'check_compression' =>
GetMessage(
"MAIN_SC_COMPRESSION_TEST")],
115 $arGroupName[16] =
GetMessage(
'SC_GR_EXTENDED');
117 [
'check_dbconn' =>
GetMessage(
'SC_T_DBCONN')],
118 [
'check_session_ua' =>
GetMessage(
'SC_T_SESS_UA')],
121 [
'check_pcre_recursion' =>
GetMessage(
'SC_T_RECURSION')],
123 [
'check_upload' =>
GetMessage(
'SC_T_UPLOAD')],
124 [
'check_upload_big' =>
GetMessage(
'SC_T_UPLOAD_BIG')],
125 [
'check_upload_raw' =>
GetMessage(
'SC_T_UPLOAD_RAW')],
129 [
'check_mail_big' =>
GetMessage(
'SC_T_MAIL_BIG')],
130 [
'check_mail_b_event' =>
GetMessage(
'SC_T_MAIL_B_EVENT')],
132 [
'check_localredirect' =>
GetMessage(
'SC_T_REDIRECT')],
133 [
'check_memory_limit' =>
GetMessage(
'SC_T_MEMORY')],
136 [
'check_update' =>
GetMessage(
'SC_UPDATE_ACCESS')],
137 [
'check_http_auth' =>
GetMessage(
'SC_T_AUTH')],
139 [
'check_getimagesize' =>
GetMessage(
'SC_T_GETIMAGESIZE')],
144 [
'check_mysql_bug_version' =>
GetMessage(
'SC_T_MYSQL_VER')],
145 [
'check_mysql_time' =>
GetMessage(
'SC_T_TIME')],
146 [
'check_mysql_mode' =>
GetMessage(
'SC_T_SQL_MODE')],
147 [
'check_mysql_connection_charset' =>
GetMessage(
'SC_CONNECTION_CHARSET')],
148 [
'check_mysql_db_charset' =>
GetMessage(
'SC_DB_CHARSET')],
149 [
'check_mysql_table_format' =>
GetMessage(
'SC_T_FORMAT')],
150 [
'check_mysql_table_charset' =>
GetMessage(
'SC_T_CHARSET')],
151 [
'check_mysql_table_structure' =>
GetMessage(
'SC_T_STRUCTURE')],
156 [
'check_pgsql_version' =>
GetMessage(
'SC_T_PGSQL_VER')],
157 [
'check_mysql_time' =>
GetMessage(
'SC_T_TIME')],
158 [
'check_pgsql_db_charset' =>
GetMessage(
'SC_DB_CHARSET')],
159 [
'check_pgsql_connection_charset' =>
GetMessage(
'SC_CONNECTION_CHARSET')],
164 switch ($this->fix_mode)
168 [
'check_mysql_table_status' =>
GetMessage(
'SC_T_CHECK')],
173 [
'check_mysql_connection_charset' =>
GetMessage(
'SC_CONNECTION_CHARSET')],
174 [
'check_mysql_db_charset' =>
GetMessage(
'SC_DB_CHARSET')],
175 [
'check_mysql_table_format' =>
GetMessage(
'SC_T_FORMAT')],
176 [
'check_mysql_table_charset' =>
GetMessage(
'SC_T_CHARSET')],
177 [
'check_mysql_table_structure' =>
GetMessage(
'SC_T_STRUCTURE')],
182 [
'check_mysql_table_structure' =>
GetMessage(
'SC_T_STRUCTURE')],
187 [
'check_mbstring' =>
GetMessage(
'SC_T_MBSTRING')],
192 [
'check_server_vars' =>
GetMessage(
'SC_T_SERVER')],
212 switch (Application::getConnection()->getType())
224 foreach ($arTestGroup as
$i =>
$ar)
228 if (!$this->group_name)
237 $this->group_name = $arGroupName[
$i] ??
'';
238 $this->group_desc = $arGroupDesc[
$i] ??
'';
241 $this->arTest = array_merge($this->arTest,
$ar);
246 $this->
function = key($this->arTest[$this->step]);
247 $this->strCurrentTestName = current($this->arTest[$this->step]);
251 if (file_exists($file =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix' .
'/license_key.php'))
255 if ($LICENSE_KEY ==
'')
257 $LICENSE_KEY =
'DEMO';
259 if (!defined(
'LICENSE_HASH'))
261 define(
'LICENSE_HASH', md5(
'CONNECTION_TEST'));
263 $this->LogFile =
'/bitrix' .
'/site_checker_' . md5(
'SITE_CHECKER' . $LICENSE_KEY) .
'.log';
269 foreach (get_class_methods(
'CSiteCheckerTest') as
$method)
271 if (str_starts_with(
$method,
'check_'))
281 $this->test_percent = 100;
286 if ($this->fix_mode && (!isset($this->arTestVars[
'start_function']) || $this->arTestVars[
'start_function'] != $this->
function))
290 $this->test_percent = 0;
291 $this->result =
true;
295 $this->result = call_user_func([$this, $this->
function]);
301 echo $e->getMessage();
303 $this->strError = ob_get_clean();
305 if (!$this->strResult)
307 $this->
Result($this->result);
310 if (!$this->fix_mode)
315 $text = date(
'Y-M-d H:i:s') .
' ' . $this->strCurrentTestName .
' (' . $this->
function .
"): " . $this->LogResult .
"\n";
316 if ($this->test_percent < 100)
318 $text .= $this->test_percent .
'% done' .
"\n";
323 $text .= str_replace(
'<br>',
"\n", $this->strError) .
"\n";
326 if ($this->test_percent >= 100)
328 $text .= preg_replace(
'#<[^<>]+>#',
'', $this->strResult) .
"\n";
333 fwrite($this->LogResourse,
$text);
338 $this->percent = floor(($this->step + $this->test_percent / 100) /
count($this->arTest) * 100);
340 if ($this->test_percent >= 100)
342 if ($this->step + 1 <
count($this->arTest))
345 $this->test_percent = 0;
346 $this->arTestVars[
'last_value'] =
'';
347 $this->
function = key($this->arTest[$this->step]);
348 $this->strNextTestName = current($this->arTest[$this->step]);
352 if (!$this->fix_mode)
354 COption::SetOptionString(
'main',
'site_checker_success', $this->arTestVars[
'site_checker_success'] ??
'');
355 if (isset($this->arTestVars[
'site_checker_success']) && $this->arTestVars[
'site_checker_success'] ==
'Y')
362 elseif ($this->result ===
true)
364 $this->strResult =
'';
367 if ($this->result ===
false)
369 $this->arTestVars[
'site_checker_success'] =
'N';
377 $this->LogResult =
'Ok';
381 $this->LogResult =
'Warning';
385 $this->LogResult =
'Fail';
401 $this->strResult =
$text;
407 $continue = $this->step > 0;
408 if (!$this->LogResourse = fopen(
$_SERVER[
'DOCUMENT_ROOT'] . $this->LogFile, $continue ?
'ab' :
'wb'))
410 $this->arTestVars[
'site_checker_success'] =
'N';
419 if (!empty($this->arTestVars[
'check_socket_fail']))
426 $ssl = $this->ssl ?
'ssl://' :
'';
429 echo
"Connection to $ssl$host:$port ";
442 echo
"Socket error [$errno]: $errstr" .
"\n";
443 return $this->
Result(
false);
454 $suffix = substr(
$str, -1);
465 $res *= 1048576 * 1024;
476 if (
$f[
'Type'] == str_replace([
'long',
'medium'],
'', $f_tmp[
'Type']) || $this->force_repair)
481 preg_match(
'#^([a-z]+)\(([0-9]+)\)(.*)$#i',
$f[
'Type'], $regs)
483 preg_match(
'#^([a-z]+)\(([0-9]+)\)(.*)$#i', $f_tmp[
'Type'], $regs_tmp)
485 str_replace(
'varchar',
'char', strtolower($regs[1])) == str_replace(
'varchar',
'char', strtolower($regs_tmp[1]))
487 $regs[2] <= $regs_tmp[2]
489 $regs[3] == $regs_tmp[3]
505 'xml_parser_create' =>
GetMessage(
"SC_MOD_XML"),
506 'imagettftext' =>
"Free Type Text",
507 'gzcompress' =>
"Zlib",
508 'imagecreatetruecolor' =>
GetMessage(
"SC_MOD_GD"),
509 'imagecreatefromjpeg' =>
GetMessage(
"SC_MOD_GD_JPEG"),
511 'highlight_file' =>
'PHP Syntax Highlight',
515 foreach ($arMods as $func =>
$desc)
517 if (!function_exists($func))
523 if (!function_exists(
'openssl_encrypt'))
528 if (!function_exists(
'mb_substr'))
533 if (!in_array(
'ssl', stream_get_transports()))
545 if (!class_exists(
'DOMDocument') || !class_exists(
'ZipArchive'))
556 if (version_compare($v = phpversion(), self::MIN_PHP_VER,
'<'))
558 $strError =
GetMessage(
'SC_VER_ERR', [
'#CUR#' => $v,
'#REQ#' => self::MIN_PHP_VER]) .
"<br>";
561 $arRequiredParams = [
564 'session.auto_start' => 0,
565 'magic_quotes_runtime' => 0,
566 'magic_quotes_sybase' => 0,
567 'magic_quotes_gpc' => 0,
568 'arg_separator.output' =>
'&',
569 'register_globals' => 0,
570 'zend.multibyte' => 0,
573 if (extension_loaded(
'xcache'))
575 $arRequiredParams[
'xcache.cacher'] = 0;
576 $arRequiredParams[
'xcache.stat'] = 1;
579 foreach ($arRequiredParams as $param =>
$val)
581 $cur = ini_get($param);
582 if (strtolower($cur) ==
'on')
586 elseif (strtolower($cur) ==
'off')
597 $param =
'opcache.revalidate_freq';
598 if (($cur = ini_get($param)) <> 0)
603 $param =
'default_socket_timeout';
604 if (($cur = ini_get($param)) < 60)
609 if (($m = ini_get(
'max_input_vars')) && $m < 10000)
611 $strError .=
GetMessage(
'ERR_MAX_INPUT_VARS', [
'#MIN#' => 10000,
'#CURRENT#' => $m]) .
"<br>";
617 $vmVer = $vm->getVersion();
624 $vmAvailableVer = $vm->getAvailableVersion();
625 if (version_compare($vmVer, $vmAvailableVer,
'<'))
627 $strError .=
GetMessage(
'ERR_OLD_VM', [
'#CURRENT#' => $vmVer,
'#LAST_VERSION#' => $vmAvailableVer]) .
"<br>";
633 $locale_info = localeconv();
634 $delimiter = $locale_info[
'decimal_point'];
635 if ($delimiter !=
'.')
641 if (1234567891 != (
string)doubleval(1234567891))
647 if (in_array(
'suhosin', get_loaded_extensions()) && !ini_get(
'suhosin.simulation'))
649 $strError .=
GetMessage(
'SC_WARN_SUHOSIN', [
'#VAL#' => ini_get(
'suhosin.simulation') ? 1 : 0]) .
'<br>';
653 $param =
'pcre.backtrack_limit';
655 ini_set($param, $cur + 1);
656 $new = ini_get($param);
657 if (
$new != $cur + 1)
673 if (
$host !=
'localhost' && !preg_match(
'#^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$#',
$host))
675 if (!preg_match(
'#^[a-z0-9\-.]{1,192}\.(xn--)?[a-z0-9]{2,63}$#i',
$host))
690 $body =
"Test message. Delete it.{$eol}";
693 $body = str_repeat($body, 8000);
699 $val = mail(
"hosting_test@bitrixsoft.com",
"Bitrix site checker" . $eol .
"\tmultiline subject", $body,
'BCC: noreply@bitrixsoft.com');
703 $val = mail(
"hosting_test@bitrixsoft.com",
"Bitrix site checker", $body);
705 $endTime = microtime(
true);
731 $res =
$DB->Query(
"SELECT COUNT(1) AS A FROM b_event WHERE SUCCESS_EXEC = 'N'");
735 $info = defined(
'BX_CRONTAB_SUPPORT') && BX_CRONTAB_SUPPORT ?
'<br> ' .
GetMessage(
'SC_CRON_WARN') :
'';
736 if (CACHED_b_event !==
false &&
$CACHE_MANAGER->Read(CACHED_b_event,
"events"))
747 if (!CModule::IncludeModule(
'mail'))
751 $rs = CMailBox::GetList([], [
'SERVER_TYPE' =>
'imap']);
761 if (!CModule::IncludeModule(
'socialservices'))
767 if (!empty($arActiveSocServ))
769 if (is_array($arActiveSocServ[
'Bitrix24Net']))
780 if (!CModule::IncludeModule(
'rest'))
790 'select' => [
'LID',
'NAME',
'SERVER_NAME'],
791 'order' => [
'DEF' =>
'DESC',
'SORT' =>
'ASC'],
794 $domain =
$site[
'SERVER_NAME'] ?: COption::getOptionString(
'main',
'server_name',
'');
796 if (preg_match(
'/^(?<domain>.+):(?<port>\d+)$/', $domain,
$matches))
800 if (!getmxrr($domain, $mxhosts) || !
count($mxhosts))
802 return $this->
Result(
null,
GetMessage(
'SC_ERR_DNS', [
'#DOMAIN#' => $domain]));
805 $region = Application::getInstance()->getLicense()->getRegion();
807 if (in_array(
$region, [
'ru',
'by',
'kz']))
809 $host =
"mail-001.bitrix24.ru";
813 $host =
"mail-us.bitrix24.com";
816 foreach ($mxhosts as $mx)
821 return $this->
Result(
null,
GetMessage(
'SC_ERR_DNS_WRONG', [
'#DOMAIN#' => $mx]));
831 fwrite(
$res,
"HELO " . $domain .
"\r\n");
833 fwrite(
$res,
"MAIL FROM: sitecheckerfrom@" . $domain .
"\r\n");
835 fwrite(
$res,
"RCPT TO: rplsitecheckerto@" . $domain .
"\r\n");
837 fwrite(
$res,
"DATA\r\n");
840 "From: sitecheckerfrom@" . $domain .
"\r\n" .
841 "To: rplsitecheckerto@" . $domain .
"\r\n" .
842 "Subject: Site checker mail test\r\n" .
843 "Content-type: text/plain\r\n" .
844 "MIME-Version: 1.0\r\n" .
849 if (preg_match(
'#\(Bad Request 400\)#i',
$str))
854 return $this->
Result(
null,
GetMessage(
'SC_ERR_TEST_MAIL_PUSH', [
'#DOMAIN#' => $domain]));
859 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=socket_test&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
860 $strRequest .=
"Host: " . $this->host .
"\r\n";
861 $strRequest .=
"\r\n";
872 $this->arTestVars[
'check_socket_fail'] = 1;
879 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=compression&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
880 $strRequest .=
"Host: " . $this->host .
"\r\n";
881 $strRequest .=
"Accept-Encoding: gzip, deflate\r\n";
882 $strRequest .=
"\r\n";
891 if (preg_match(
'#gzip|deflate#mi', $strHeaders) && strlen($strRes) < 64 * 1024)
903 if (!file_exists($this->cafile) || filesize($this->cafile) == 0)
908 if (!
$context = stream_context_create(
911 'verify_peer' =>
true,
912 'allow_self_signed' =>
false,
913 'cafile' => $this->cafile,
921 echo
"Connection to ssl://{$this->host}:443 (certificate check enabled) ";
922 if (
$res = stream_socket_client(
'ssl://' . $this->host .
':443', $errno, $errstr, 10, STREAM_CLIENT_CONNECT,
$context))
930 if (!
$context = stream_context_create(
933 'verify_peer' =>
false,
934 'allow_self_signed' =>
true,
935 'cafile' => $this->cafile,
943 echo
"Connection to ssl://{$this->host}:443 ";
944 if (
$res = stream_socket_client(
'ssl://' . $this->host .
':443', $errno, $errstr, 10, STREAM_CLIENT_CONNECT,
$context))
951 return $this->
Result(
null,
GetMessage(
"MAIN_SC_NO_CONNECTTO", [
'#HOST#' =>
'https://' . $this->host]));
956 if (!CModule::IncludeModule(
'ldap'))
970 if (!CModule::IncludeModule(
'ldap'))
974 if (COption::GetOptionString(
'ldap',
'use_ntlm',
'N') !=
'Y')
978 if (COption::GetOptionString(
'ldap',
'bitrixvm_auth_support',
'N') ==
'Y')
982 if (($ntlm_varname = COption::GetOptionString(
'ldap',
'ntlm_varname',
'REMOTE_USER')) && ($user = trim(
$_SERVER[$ntlm_varname])))
991 if (file_exists($this->cafile))
993 unlink($this->cafile);
997 $region = Application::getInstance()->getLicense()->getRegion();
999 if (in_array(
$region, [
'ru',
'by',
'kz']))
1001 $url =
'https://www.1c-bitrix.ru/upload/lib/cafile.pem';
1005 $url =
'https://www.bitrixsoft.com/upload/lib/cafile.pem';
1008 $http = new \Bitrix\Main\Web\HttpClient([
1009 "socketTimeout" => 5,
1010 "streamTimeout" => 5,
1012 if ($http->download(
$url, $this->cafile) && is_file($this->cafile) && filesize($this->cafile) > 0)
1022 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=dbconn_test&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
1023 $strRequest .=
"Host: " . $this->host .
"\r\n";
1024 $strRequest .=
"\r\n";
1030 $file = COption::GetOptionString(
"security",
"ipcheck_disable_file",
"");
1031 COption::SetOptionString(
"security",
"ipcheck_disable_file", $this->LogFile);
1039 COption::SetOptionString(
"security",
"ipcheck_disable_file", $file);
1046 if (($sp = ini_get(
"upload_tmp_dir")))
1048 if (!file_exists($sp))
1052 elseif (!is_writable($sp))
1058 if (defined(
'BX_TEMPORARY_FILES_DIRECTORY'))
1060 $sp = BX_TEMPORARY_FILES_DIRECTORY;
1061 if (!file_exists($sp))
1065 elseif (!is_writable($sp))
1072 for (
$i = 40;
$i < 240;
$i++)
1074 $binaryData .= chr(
$i);
1078 $binaryData = str_repeat($binaryData, 21000);
1083 $POST = $binaryData;
1089 $POST =
"--$boundary\r\n";
1090 $POST .=
'Content-Disposition: form-data; name="test_file"; filename="site_checker.bin"' .
"\r\n";
1091 $POST .=
'Content-Type: image/gif' .
"\r\n";
1093 $POST .= $binaryData .
"\r\n";
1094 $POST .=
"--$boundary\r\n";
1097 $strRequest =
"POST " .
"/bitrix/admin/site_checker.php?test_type=upload_test&unique_id=" .
checker_get_unique_id() .
"&big=" . ($big ? 1 : 0) .
"&raw=" . ($raw ? 1 : 0) .
" HTTP/1.1\r\n";
1098 $strRequest .=
"Host: " . $this->host .
"\r\n";
1101 $strRequest .=
"Content-Type: multipart/form-data; boundary=$boundary\r\n";
1103 $strRequest .=
"Content-Length: " . strlen($POST) .
"\r\n";
1104 $strRequest .=
"\r\n";
1105 $strRequest .= $POST;
1127 for (
$i = 0;
$i < 201;
$i++)
1129 $POST .=
'i' .
$i .
'=' . md5(
$i) .
'&';
1132 $strRequest =
"POST " .
"/bitrix/admin/site_checker.php?test_type=post_test&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
1133 $strRequest .=
"Host: " . $this->host .
"\r\n";
1134 $strRequest .=
"Content-Length: " . strlen($POST) .
"\r\n";
1135 $strRequest .=
"Content-Type: application/x-www-form-urlencoded\r\n";
1137 $strRequest .=
"\r\n";
1138 $strRequest .= $POST;
1151 if (!$this->arTestVars[
'last_value'])
1163 [$last_success,
$max,
$step] = unserialize($this->arTestVars[
'last_value'], [
'allowed_classes' =>
false]);
1166 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=memory_test&unique_id=" .
checker_get_unique_id() .
"&max=" . (
$max - 1) .
" HTTP/1.1\r\n";
1167 $strRequest .=
"Host: " . $this->host .
"\r\n";
1168 $strRequest .=
"\r\n";
1177 $last_success =
$max;
1182 $max = floor(($last_success +
$max) / 2);
1190 if (
$step < $total_steps)
1192 $this->test_percent = floor(100 / $total_steps *
$step);
1194 $this->arTestVars[
'last_value'] = serialize([$last_success,
$max,
$step]);
1200 $last_success = (int)$last_success;
1201 if ($last_success > 32)
1205 if ($cur > 0 && $cur < $last_success * 1024 * 1024)
1207 $res .=
'<br> ' .
GetMessage(
'SC_MEMORY_CHANGED', [
'#VAL0#' => ini_get(
'memory_limit'),
'#VAL1#' =>
'512M']);
1216 if (!$this->arTestVars[
'last_value'])
1218 $_SESSION[
'CHECKER_CHECK_SESSION'] =
'SUCCESS';
1219 $this->test_percent = 50;
1220 $this->arTestVars[
'last_value'] =
'Y';
1224 if ($_SESSION[
'CHECKER_CHECK_SESSION'] !=
'SUCCESS')
1228 unset($_SESSION[
'CHECKER_CHECK_SESSION']);
1235 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=session_test&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
1236 $strRequest .=
"Host: " . $this->host .
"\r\n";
1238 if ($this->arTestVars[
'last_value'])
1240 $strRequest .=
"Cookie: " . $this->arTestVars[
'last_value'] .
"\r\n";
1243 $strRequest .=
"\r\n";
1250 if (!$this->arTestVars[
'last_value'])
1253 if (!preg_match(
'#Set-Cookie: (' . session_name() .
'=[a-z0-9\-_]+?);#i', $strHeaders, $regs))
1255 PrintHTTP($strRequest, $strHeaders, $strRes);
1259 $this->arTestVars[
'last_value'] = $regs[1];
1260 $this->test_percent = 50;
1271 $file =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/.settings.php';
1273 if ($this->fix_mode)
1275 if (!file_exists($file))
1278 Application::resetAccelerator();
1280 return $this->
Result(file_exists($file));
1283 if (!file_exists($file))
1285 $this->arTestVars[
'check_mbstring_fail'] =
true;
1287 $link =
' <a href="javascript:show_popup(\'' .
GetMessageJS(
'SC_FIX_MBSTRING') .
'\', \
'?fix_mode=' . $mode .
'\', \
'' .
GetMessageJS(
'SC_FIX_MBSTRING_CONFIRM') .
'\')
">' . GetMessage('SC_FIX') . '</a>';
1288 return $this->Result(false, GetMessage('SC_ERR_NO_SETTINGS') . $link);
1291 $encoding = strtolower(ini_get('mbstring.internal_encoding'));
1292 $default = strtolower(ini_get('default_charset'));
1296 return $this->Result(false, GetMessage("MAIN_SC_DEFAULT_CHARSET
"));
1299 if ($encoding <> '' && $encoding <> $default)
1301 return $this->Result(false, GetMessage("MAIN_SC_ENC_EQUAL
"));
1304 if (ini_get('mbstring.func_overload') > 0)
1306 //should be non-existent
1307 return $this->Result(false, GetMessage("MAIN_SC_FUNC_OVERLOAD
"));
1313 $rs = CSite::GetList('', '', ['ACTIVE' => 'Y']);
1314 while ($f = $rs->Fetch())
1316 if (str_contains(strtolower($f['CHARSET']), 'utf'))
1325 $text = GetMessage('SC_MB_UTF');
1327 if ($default <> "utf-8
")
1330 $text .= '<br>' . GetMessage("MAIN_SC_ENC_UTF
");
1331 $this->arTestVars['check_mbstring_fail'] = true;
1336 $text = GetMessage('SC_MB_NOT_UTF');
1341 $retVal = (strlen("\xd0\xa2
") == 2);
1344 $text = GetMessage('SC_STRLEN_FAIL_PHP56');
1348 return $this->Result($retVal, ($retVal ? GetMessage("MAIN_SC_CORRECT
") . '. ' : '') . $text);
1351 function check_http_auth()
1353 $strRequest = "GET
" . "/bitrix/admin/site_checker.php?test_type=auth_test&unique_id=
" . checker_get_unique_id() . " HTTP/1.1\r\n
";
1354 $strRequest .= "Host:
" . $this->host . "\r\n
";
1355 $strRequest .= "Authorization: Basic dGVzdF91c2VyOnRlc3RfcGFzc3dvcmQ=\r\n
";
1356 $strRequest .= "\r\n
";
1358 if ($res = $this->ConnectToHost())
1360 return IsHttpResponseSuccess($res, $strRequest);
1365 function check_update()
1367 $ServerIP = COption::GetOptionString("main
", "update_site
", "www.1c-bitrix.ru
");
1370 $proxyAddr = COption::GetOptionString("main
", "update_site_proxy_addr
", "");
1371 $proxyPort = COption::GetOptionString("main
", "update_site_proxy_port
", "");
1372 $proxyUserName = COption::GetOptionString("main
", "update_site_proxy_user
", "");
1373 $proxyPassword = COption::GetOptionString("main
", "update_site_proxy_pass
", "");
1375 $bUseProxy = !$this->arTestVars['last_value'] && $proxyAddr <> '' && $proxyPort <> '';
1379 $proxyPort = intval($proxyPort);
1380 if ($proxyPort <= 0)
1385 $requestIP = $proxyAddr;
1386 $requestPort = $proxyPort;
1390 $requestIP = $ServerIP;
1391 $requestPort = $ServerPort;
1395 $page = "us_updater_list.php
";
1398 $strRequest .= "POST
http:
1399 if ($proxyUserName <>
'')
1401 $strRequest .=
"Proxy-Authorization: Basic " . base64_encode($proxyUserName .
":" . $proxyPassword) .
"\r\n";
1406 $strRequest .=
"POST /bitrix/updates/" .
$page .
" HTTP/1.0\r\n";
1409 $strRequest .=
"User-Agent: BitrixSMUpdater\r\n";
1410 $strRequest .=
"Accept: */*\r\n";
1411 $strRequest .=
"Host: " . $ServerIP .
"\r\n";
1412 $strRequest .=
"Accept-Language: en\r\n";
1413 $strRequest .=
"Content-type: application/x-www-form-urlencoded\r\n";
1414 $strRequest .=
"Content-length: 7\r\n\r\n";
1415 $strRequest .=
"lang=en";
1416 $strRequest .=
"\r\n";
1421 $res = fsockopen($requestIP, $requestPort, $errno, $errstr, 5);
1423 catch (Exception $e)
1425 echo $e->getMessage() .
"\n";
1432 return $this->
Result(
false,
GetMessage(
'SC_NO_PROXY') .
' (' . $errstr .
')');
1436 return $this->
Result(
false,
GetMessage(
'SC_UPDATE_ERROR') .
' (' . $errstr .
')');
1441 if (\Bitrix\Main\Config\Option::get(
"updateserverlight",
"is_turned_on",
"N") ===
"Y")
1448 if ((str_contains($strRes,
"EMPTY_LICENSE_KEY"))
1449 || (str_contains($strRes,
"LICENSE_KEY_REQUIRED")))
1455 $strRes = mb_strtolower(strip_tags($strRes));
1456 PrintHTTP($strRequest, $strHeaders, $strRes);
1471 if (CModule::IncludeModule(
'pull'))
1473 $text = md5(mt_rand(100000, 999999));
1476 if (CPullOptions::GetQueueServerStatus())
1478 $isServerShared = CPullOptions::IsServerShared();
1479 if ($isServerShared && !\
Bitrix\Pull\SharedServer\Config::isRegistered())
1481 $this->arTestVars[
'push_stream_fail'] =
true;
1486 if (CPullOptions::GetQueueServerVersion() < 4)
1488 $this->arTestVars[
'push_stream_warn'] =
true;
1489 return $this->
Result(
null,
GetMessage(
"MAIN_SC_PULL_UNSUPPORTED_VERSION"));
1493 if (!
$ar = parse_url(str_replace(
'#DOMAIN#', $this->host, \
Bitrix\Pull\Config::getPublishUrl($id))))
1498 $pub_domain =
$ar[
'host'];
1499 $pub_host = (
$ar[
'scheme'] ==
'https' ?
'ssl://' :
'') . $pub_domain;
1500 $pub =
$ar[
'path'] .
'?' .
$ar[
'query'];
1501 $pub_port =
$ar[
'port'];
1504 $pub_port =
$ar[
'scheme'] ==
'https' ? 443 : 80;
1507 if ($isServerShared)
1514 $listenUrl = $this->ssl ? CPullOptions::GetListenSecureUrl($id) : CPullOptions::GetListenUrl($id);
1517 if (!
$ar = parse_url(str_replace(
'#DOMAIN#', $this->host, $listenUrl)))
1522 $sub_domain =
$ar[
'host'];
1523 $sub_host = (
$ar[
'scheme'] ==
'https' ?
'ssl://' :
'') . $sub_domain;
1524 $sub =
$ar[
'path'] .
'?' .
$ar[
'query'];
1525 $sub_port =
$ar[
'port'] ??
null;
1528 $sub_port =
$ar[
'scheme'] ==
'https' ? 443 : 80;
1535 $this->arTestVars[
'push_stream_fail'] =
true;
1541 $this->arTestVars[
'push_stream_fail'] =
true;
1545 $ver = CPullOptions::GetQueueServerVersion();
1546 $bNodeJS = $ver > 2;
1547 echo
'Server version: ' . $ver . ($bNodeJS ?
' (Bitrix Push server)' :
' (nginx-push-stream-module)') .
"\n";
1549 $strRequest0 =
'POST ' . $pub .
' HTTP/1.0' .
"\r\n" .
1550 'Host: ' . $pub_domain .
"\r\n" .
1551 'Content-Length: ' . strlen(
$text) .
"\r\n" .
1554 $strRequest1 =
'GET ' . $sub .
' HTTP/1.0' .
"\r\n" .
1555 'If-Modified-Since: ' . date(
'r', time() - 86400) .
"\r\n" .
1556 'Host: ' . $sub_domain .
"\r\n\r\n";
1557 $strRequest2 =
'DELETE ' . $pub .
' HTTP/1.0' .
"\r\n" .
1558 'Host: ' . $sub_domain .
"\r\n\r\n";
1565 $this->arTestVars[
'push_stream_fail'] =
true;
1566 return $this->
Result(
false,
GetMessage(
"MAIN_SC_NO_PUSH_STREAM_CONNECTION"));
1568 fwrite($res0, $strRequest0);
1575 $this->arTestVars[
'push_stream_fail'] =
true;
1578 fwrite($res1, $strRequest1);
1585 $this->arTestVars[
'push_stream_fail'] =
true;
1586 return $this->
Result(
false,
GetMessage(
"MAIN_SC_NO_PUSH_STREAM_CONNECTION"));
1590 $strRes1 = fread($res1, 4096);
1593 if (!str_contains($strRes1,
$text))
1596 $this->arTestVars[
'push_stream_fail'] =
true;
1597 $retVal = $this->
Result(
false,
GetMessage(
"MAIN_SC_PUSH_INCORRECT", [
'#MODULE#' => $bNodeJS ?
'Bitrix Push server' :
'nginx-push-stream-module']));
1603 $this->arTestVars[
'push_stream_fail'] =
true;
1604 return $this->
Result(
false,
GetMessage(
"MAIN_SC_NO_PUSH_STREAM_CONNECTION_2"));
1606 fwrite($res2, $strRequest2);
1609 if ($retVal && COption::GetOptionString(
'main',
'session_expand',
'Y') <>
'N' && (!defined(
"BX_SKIP_SESSION_EXPAND") ||
BX_SKIP_SESSION_EXPAND ===
false))
1619 if (!empty($this->arTestVars[
'push_stream_warn']))
1625 if (!empty($this->arTestVars[
'push_stream_fail']))
1640 if (!empty($this->arTestVars[
'push_stream_warn']))
1646 if (!empty($this->arTestVars[
'push_stream_fail']))
1652 if (COption::GetOptionString(
"call",
"turn_server_self") ==
'Y')
1654 $host = COption::GetOptionString(
"call",
"turn_server");
1658 $region = Application::getInstance()->getLicense()->getRegion();
1660 if (in_array(
$region, [
'ru',
'by',
'kz']))
1662 $host =
"turn.bitrix24.tech";
1666 $host =
'turn.calls.bitrix24.com';
1686 if (!CModule::IncludeModule(
'pull'))
1690 if (!CPullOptions::GetPushStatus())
1695 if ($this->arTestVars[
'check_access_fail'])
1700 $region = Application::getInstance()->getLicense()->getRegion();
1702 if (in_array(
$region, [
'ru',
'by',
'kz']))
1704 $host =
'cloud-messaging.bitrix24.tech';
1708 $host =
'cloud-messaging.bitrix24.com';
1711 $POST =
'Action=SendMessage&MessageBody=batch';
1713 $strRequest =
"POST /send/?key=" . md5(
'key') .
" HTTP/1.1\r\n";
1714 $strRequest .=
"User-Agent: BitrixCloud SiteChecker\r\n";
1715 $strRequest .=
"Host: " .
$host .
"\r\n";
1716 $strRequest .=
"Content-type: application/x-www-form-urlencoded\r\n";
1717 $strRequest .=
"Content-length: " . strlen($POST) .
"\r\n";
1718 $strRequest .=
"\r\n" . $POST .
"\r\n";
1726 if (str_contains($strRes,
'xml version='))
1731 PrintHTTP($strRequest, $strHeaders, $strRes);
1737 if ($this->arTestVars[
'check_access_fail'])
1746 if ($this->arTestVars[
'check_access_fail'])
1755 if (!CModule::IncludeModule(
'webdav') && !CModule::IncludeModule(
'disk'))
1760 if ($this->arTestVars[
'check_socket_fail'])
1766 "PUT" => [
"rights" =>
"U",
"min_rights" =>
"U"],
1767 "LOCK" => [
"rights" =>
"U",
"min_rights" =>
"U"],
1768 "MOVE" => [
"rights" =>
"W",
"min_rights" =>
"U"],
1769 "MKCOL" => [
"rights" =>
"W",
"min_rights" =>
"W"],
1770 "PROPFIND" => [
"rights" =>
"R",
"min_rights" =>
"R"],
1775 $strRequest =
$method .
" /bitrix/admin/site_checker.php?test_type=webdav_test&method=$method&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
1776 $strRequest .=
"Host: " . $this->host .
"\r\n";
1777 $strRequest .=
"\r\n";
1784 if (trim($strRes) !=
'SUCCESS')
1786 PrintHTTP($strRequest, $strHeaders, $strRes);
1795 if (!CModule::IncludeModule(
'intranet'))
1800 $tmp =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/tmp/success.doc';
1806 $res = CIntranetSearchConverters::OnSearchGetFileContent(
$tmp);
1809 if (is_array(
$res) && str_contains(
$res[
'CONTENT'],
'SUCCESS'))
1815 if (
$res ===
false && function_exists(
'exec'))
1817 exec(
'catdoc -V',
$output, $return_var);
1818 if ($return_var === 0)
1821 if (str_contains($version,
'0.94.4') || str_contains($version,
'0.94.3'))
1833 $tmp =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/tmp/success.txt';
1839 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=fast_download&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
1840 $strRequest .=
"Host: " . $this->host .
"\r\n";
1841 $strRequest .=
"\r\n";
1849 $retVal = COption::GetOptionString(
'main',
'bx_fast_download',
'N') ==
'Y' ? true : $this->
Result(
false,
GetMessage(
"MAIN_FAST_DOWNLOAD_SUPPORT"));
1853 $retVal = COption::GetOptionString(
'main',
'bx_fast_download',
'N') ==
'N' ? $this->
Result(
false,
GetMessage(
"MAIN_SC_NOT_SUPPORTED")) : $this->
Result(
false,
GetMessage(
"MAIN_FAST_DOWNLOAD_ERROR"));
1861 $region = Application::getInstance()->getLicense()->getRegion();
1863 if (in_array(
$region, [
'ru',
'by',
'kz']))
1865 $checker =
'checker.bitrix24.tech';
1869 $checker =
'checker.internal.bitrix24.com';
1875 if (preg_match(
'#^(127|10|172\.16|192\.168)\.#', $this->host))
1882 'GET /check/?license_hash=' . LICENSE_HASH .
'&host=' . urlencode($this->host) .
'&port=' . urlencode($this->port) .
'&https=' . ($this->ssl ?
'Y' :
'N') .
' HTTP/1.1' .
"\r\n" .
1883 'host: ' . $checker .
"\r\n" .
1888 $this->arTestVars[
'check_access_fail'] =
true;
1889 return $this->
Result($retVal,
GetMessage(
"MAIN_SC_NO_CONNECTTO", [
'#HOST#' => $checker]));
1893 PrintHTTP($strRequest, $strHeaders, $strRes);
1894 if (!preg_match(
'#^Status: (.+)$#m', $strRes, $regs))
1896 $this->arTestVars[
'check_access_fail'] =
true;
1897 return $this->
Result($retVal,
GetMessage(
"MAIN_SC_UNKNOWN_ANSWER", [
'#HOST#' => $checker]));
1904 $this->arTestVars[
'check_access_fail'] =
true;
1905 return $this->
Result($retVal,
GetMessage(
"MAIN_SC_NO_EXTERNAL_CONNECT_WARN"));
1910 $this->arTestVars[
'check_access_fail'] =
true;
1912 return $this->
Result($retVal,
GetMessage(
"MAIN_SC_EXTERNAL_ANSWER_INCORRECT"));
1915 if (!CModule::IncludeModule(
'pull'))
1919 if (!CPullOptions::GetPushStatus())
1923 if (!
$ar = parse_url(str_replace(
'#DOMAIN#', $this->host, COption::GetOptionString(
'pull',
'path_to_mobile_listener' . ($this->ssl ?
'_secure' :
'')))))
1927 $sub_port =
$ar[
'port'];
1932 if ($sub_port != $this->port)
1935 'GET /check/?license_hash=' . LICENSE_HASH .
'&host=' . urlencode($this->host) .
'&port=' . urlencode($sub_port) .
'&https=' . (
$ar[
'scheme'] ==
'https' ?
'Y' :
'N') .
' HTTP/1.1' .
"\r\n" .
1936 'host: ' . $checker .
"\r\n" .
1941 return $this->
Result($retVal,
GetMessage(
"MAIN_SC_NO_CONNECTTO", [
'#HOST#' => $checker]));
1944 PrintHTTP($strRequest, $strHeaders, $strRes);
1945 if (!preg_match(
'#^Status: (.+)$#m', $strRes, $regs))
1947 return $this->
Result($retVal,
GetMessage(
"MAIN_SC_UNKNOWN_ANSWER", [
'#HOST#' => $checker]));
1973 $file = COption::GetOptionString(
"security",
"ipcheck_disable_file",
"");
1974 COption::SetOptionString(
"security",
"ipcheck_disable_file", $this->LogFile);
1976 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=perf&unique_id=" .
checker_get_unique_id() .
"&i=" .
$i .
" HTTP/1.1\r\n";
1977 $strRequest .=
"Host: " . $this->host .
"\r\n";
1978 $strRequest .=
"\r\n";
1984 COption::SetOptionString(
"security",
"ipcheck_disable_file", $file);
1987 if (!is_numeric($strRes))
1989 PrintHTTP($strRequest, $strHeaders, $strRes);
1993 $arTime[] = doubleval($strRes);
1996 $r = doubleval(
$count) / array_sum($arTime);
2013 return $this->
Result($r >= 10,
$strResult .
' (' . number_format($r, 2,
".",
" ") .
' ' .
GetMessage(
"MAIN_PAGES_PER_SECOND") .
')');
2018 $dir =
$_SERVER[
"DOCUMENT_ROOT"] . BX_PERSONAL_ROOT .
"/cache";
2019 $file0 =
$dir .
"/" . md5(mt_rand());
2020 $file1 = $file0 .
".tmp";
2021 $file2 = $file0 .
".php";
2022 if (!file_exists(
$dir))
2024 mkdir(
$dir, BX_DIR_PERMISSIONS);
2027 return (
$f = fopen($file1,
'wb')) && (fclose(
$f)) && (rename($file1, $file2)) && (unlink($file2));
2032 $path =
'/bitrix' .
'/site_check_exec.php';
2038 chmod(
$_SERVER[
'DOCUMENT_ROOT'] .
$path, BX_FILE_PERMISSIONS);
2040 fwrite(
$f,
'<' .
'? echo "SUCCESS"; ?' .
'>');
2043 $strRequest =
"GET " .
$path .
" HTTP/1.1\r\n";
2044 $strRequest .=
"Host: " . $this->host .
"\r\n";
2045 $strRequest .=
"\r\n";
2063 if (function_exists(
'apache_get_modules'))
2065 $arLoaded = apache_get_modules();
2067 if (!in_array(
'mod_rewrite', $arLoaded))
2073 if (in_array(
'mod_security', $arLoaded))
2077 if (in_array(
'mod_dav', $arLoaded) || in_array(
'mod_dav_fs', $arLoaded))
2095 'bitrix_server_test.php',
2097 'bitrix_install.php',
2106 if (file_exists(
$_SERVER[
'DOCUMENT_ROOT'] .
'/' . $file))
2110 if (file_exists(
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/' . $file))
2114 if (file_exists(
$_SERVER[
'DOCUMENT_ROOT'] .
'/upload/' . $file))
2128 $file =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/modules/fileman/install/components/bitrix/player/mediaplayer/player';
2129 if (!file_exists($file))
2131 return $this->
Result(
null,
"File not found: " . $file);
2134 if (
false === getimagesize($file))
2144 foreach ([
'SERVER_PORT',
'HTTPS',
'FCGI_ROLE',
'HTTP_HOST',
'SERVER_PROTOCOL'] as
$var)
2149 if (!$this->arTestVars[
'last_value'])
2151 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=redirect_test&unique_id=" .
checker_get_unique_id() . $strSERVER .
" HTTP/1.1\r\n";
2152 $strRequest .=
"Host: " . $this->host .
"\r\n";
2153 $strRequest .=
"\r\n";
2162 if (preg_match(
'#Location: (.+)#i', $strHeaders, $regs))
2164 $url = trim($regs[1]);
2167 PrintHTTP($strRequest, $strHeaders, $strRes);
2171 $this->arTestVars[
'last_value'] =
$url;
2172 $this->test_percent = 50;
2177 PrintHTTP($strRequest, $strHeaders, $strRes);
2182 $url = $this->arTestVars[
'last_value'];
2191 $ssl =
$ar[
'scheme'] ==
'https' ?
'ssl://' :
'';
2194 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=redirect_test&unique_id=" .
checker_get_unique_id() . $strSERVER .
"&done=Y HTTP/1.1\r\n";
2195 $strRequest .=
"Host: " .
$host .
"\r\n";
2196 $strRequest .=
"\r\n";
2213 $rs = CSite::GetList(
'',
'', [
'ACTIVE' =>
'Y']);
2214 while (
$f =
$rs->Fetch())
2216 $arDocRoot[] = trim(
$f[
'DOC_ROOT']);
2217 $bFound = str_contains(strtolower(
$f[
'CHARSET']),
'utf');
2223 if (
count($arDocRoot) == 1)
2225 if ($root = $arDocRoot[0])
2232 foreach ($arDocRoot as $root)
2236 if (!is_readable($root .
'/bitrix'))
2244 if ($bUtf && $bChar)
2259 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=pcre_recursion_test&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
2260 $strRequest .=
"Host: " . $this->host .
"\r\n";
2261 $strRequest .=
"\r\n";
2269 if ($strRes ==
'CLEAN')
2279 $strRequest =
"GET " .
"/bitrix/admin/site_checker.php?test_type=method_exists&unique_id=" .
checker_get_unique_id() .
" HTTP/1.1\r\n";
2280 $strRequest .=
"Host: " . $this->host .
"\r\n";
2281 $strRequest .=
"\r\n";
2295 $this->arTestVars[
'check_bx_crontab'] =
false;
2296 if (defined(
'BX_CRONTAB'))
2301 $bCron = COption::GetOptionString(
"main",
"agents_use_crontab",
"N") ==
'Y' || defined(
'BX_CRONTAB_SUPPORT') && BX_CRONTAB_SUPPORT ===
true || COption::GetOptionString(
"main",
"check_agents",
"Y") !=
'Y';
2304 if (!
$connection->query(
'SELECT LAST_EXEC FROM b_agent WHERE LAST_EXEC > ' . $helper->addDaysToDateTime(-1) .
' AND IS_PERIOD = \'N\' LIMIT 1')->fetch())
2308 $this->arTestVars[
'check_bx_crontab'] =
true;
2318 $PgSql_vercheck_min =
'11.0.0';
2321 if (version_compare($ver, $PgSql_vercheck_min,
'<'))
2325 '#REQ#' => $PgSql_vercheck_min,
2338 $f =
$connection->query(
'select datctype as LC_CTYPE from pg_database where datname = \'' . $helper->forSql(
$connection->getDatabase()) .
'\'')->fetch();
2339 $collation_database =
$f[
'LC_CTYPE'];
2341 if (!preg_match(
'/\.(UTF-8|UTF8)$/i', $collation_database))
2351 $this->arTestVars[
'db_charset_fail'] =
true;
2360 if ($this->arTestVars[
'check_mbstring_fail'])
2366 $character_set_connection =
$f[
'CLIENT_ENCODING'];
2368 if ($character_set_connection !=
'UTF8')
2370 $strError =
GetMessage(
'SC_CONNECTION_CHARSET_WRONG', [
'#VAL#' =>
'utf8',
'#VAL1#' => $character_set_connection]);
2373 echo
'character_set_connection=' . $character_set_connection;
2380 $this->arTestVars[
'check_connection_charset_fail'] =
true;
2385 ##############################
2386 # MYSQL Tests follow
2387 ##############################
2392 $MySql_vercheck_min =
"5.0.0";
2394 $ver =
$DB->GetVersion();
2395 if (version_compare($ver, $MySql_vercheck_min,
'<'))
2397 return $this->
Result(
false,
GetMessage(
'SC_MYSQL_ERR_VER', [
'#CUR#' => $ver,
'#REQ#' => $MySql_vercheck_min]));
2400 if ($ver ==
'4.1.21'
2418 $f =
$DB->Query(
'SHOW VARIABLES LIKE \'innodb_strict_mode\'')->Fetch();
2419 if (strtoupper(
$f[
'Value']) !=
'OFF')
2424 $f =
$DB->Query(
'SHOW VARIABLES LIKE \'sql_mode\'')->Fetch();
2425 if (
$f[
'Value'] <>
'')
2430 $f =
$DB->Query(
'SHOW VARIABLES LIKE \'innodb_large_prefix\'')->Fetch();
2433 if (
$f[
'Value'] ===
'0' ||
$f[
'Value'] ===
'OFF')
2439 $f =
$DB->Query(
'SHOW VARIABLES LIKE \'innodb_default_row_format\'')->Fetch();
2442 if (strtolower(
$f[
'Value']) !==
'dynamic')
2444 $errors[] =
GetMessage(
'SC_DB_ERR_INNODB_DEFAULT_ROW_FORMAT', [
'#VALUE#' =>
$f[
'Value']]);
2448 $f =
$DB->Query(
'SHOW VARIABLES LIKE \'default_storage_engine\'')->Fetch();
2451 if (strtolower(
$f[
'Value']) !==
'innodb')
2465 while ($s == time())
2470 $res =
$DB->Query(
'SELECT NOW() AS A');
2472 if (($diff = abs($s - strtotime(
$f[
'A']))) <= 1)
2476 return $this->
Result(
false,
GetMessage(
'SC_TIME_DIFF', [
'#VAL#' => $diff]));
2486 $res =
$DB->Query(
'SHOW TABLES');
2487 $cnt =
$res->SelectedRowsCount();
2488 while (
$f =
$res->Fetch())
2491 $table = current(
$f);
2493 if ($this->arTestVars[
'last_value'])
2495 if ($this->arTestVars[
'last_value'] == $table)
2497 unset($this->arTestVars[
'last_value']);
2502 if (!$this->fix_mode)
2504 $res0 =
$DB->Query(
'CHECK TABLE ' .
$DB->quote($table));
2508 $res0 =
$DB->Query(
'REPAIR TABLE ' .
$DB->quote($table));
2511 $f0 = $res0->Fetch();
2512 if ($f0[
'Msg_type'] ==
'error' || $f0[
'Msg_type'] ==
'warning')
2514 $strError .=
GetMessage(
'SC_TABLE_ERR', [
'#VAL#' => $table]) .
' ' . $f0[
'Msg_text'] .
"\n<br>";
2517 if (time() -
$time >= $this->timeout)
2519 $this->arTestVars[
'last_value'] = $table;
2520 $this->test_percent = floor(
$i / $cnt * 100);
2530 if (!$this->fix_mode)
2532 $this->arTestVars[
'check_table_status_fail'] =
true;
2545 if (!empty($this->arTestVars[
'check_mbstring_fail']))
2550 $res =
$DB->Query(
'SHOW VARIABLES LIKE "character_set_connection"');
2552 $character_set_connection =
$f[
'Value'];
2554 $res =
$DB->Query(
'SHOW VARIABLES LIKE "character_set_results"');
2556 $character_set_results =
$f[
'Value'];
2558 $res =
$DB->Query(
'SHOW VARIABLES LIKE "collation_connection"');
2560 $collation_connection =
$f[
'Value'];
2562 if (!in_array($character_set_connection, [
'utf8',
'utf8mb3',
'utf8mb4']))
2564 $strError =
GetMessage(
"SC_CONNECTION_CHARSET_WRONG", [
'#VAL#' =>
'utf8',
'#VAL1#' => $character_set_connection]);
2566 elseif (!preg_match(
'/^(utf8|utf8mb3|utf8mb4)_/', $collation_connection))
2568 $strError =
GetMessage(
"SC_CONNECTION_COLLATION_WRONG_UTF", [
'#VAL#' => $collation_connection]);
2571 if (!
$strError && $character_set_connection != $character_set_results)
2573 $strError =
GetMessage(
'SC_CHARSET_CONN_VS_RES', [
'#CONN#' => $character_set_connection,
'#RES#' => $character_set_results]);
2576 echo
'character_set_connection=' . $character_set_connection .
', collation_connection=' . $collation_connection .
', character_set_results=' . $character_set_results;
2583 $this->arTestVars[
'check_connection_charset_fail'] =
true;
2591 if (!empty($this->arTestVars[
'check_mbstring_fail']))
2595 elseif (!empty($this->arTestVars[
'check_table_status_fail']))
2599 elseif (!empty($this->arTestVars[
'check_connection_charset_fail']))
2606 $res =
$DB->Query(
'SHOW VARIABLES LIKE \'character_set_connection\'');
2608 $character_set_connection =
$f[
'Value'];
2610 $res =
$DB->Query(
'SHOW VARIABLES LIKE \'collation_connection\'');
2612 $collation_connection =
$f[
'Value'];
2614 $res =
$DB->Query(
'SHOW VARIABLES LIKE \'character_set_database\'');
2616 $character_set_database =
$f[
'Value'];
2618 $res =
$DB->Query(
'SHOW VARIABLES LIKE \'collation_database\'');
2620 $collation_database =
$f[
'Value'];
2622 if ($this->fix_mode)
2624 if (!
$DB->Query($sql =
'ALTER DATABASE ' .
$DB->quote(
$DB->DBName) .
' DEFAULT CHARACTER SET ' . $character_set_connection .
' COLLATE ' . $collation_connection,
true))
2631 if ($character_set_connection != $character_set_database)
2633 $strError =
GetMessage(
'SC_DATABASE_CHARSET_DIFF', [
'#VAL0#' => $character_set_connection,
'#VAL1#' => $character_set_database]) .
fix_link();
2635 elseif ($collation_database != $collation_connection)
2637 $strError =
GetMessage(
'SC_DATABASE_COLLATION_DIFF', [
'#VAL0#' => $collation_connection,
'#VAL1#' => $collation_database]) .
fix_link();
2641 echo
'CHARSET=' . $character_set_database .
', COLLATION=' . $collation_database;
2648 $this->arTestVars[
'db_charset_fail'] =
true;
2662 information_schema.TABLES
2664 TABLE_SCHEMA = '" .
$DB->ForSql(
$DB->DBName) .
"'
2665 and TABLE_TYPE = 'BASE TABLE'
2666 and TABLE_NAME like 'b\_%'
2667 and CREATE_OPTIONS <> _ascii'row_format=DYNAMIC'
2669 UPPER(ROW_FORMAT) in ('REDUNDANT', 'COMPACT')
2670 or ENGINE <> 'InnoDB'
2673 while (
$f =
$res->Fetch())
2675 if ($this->fix_mode)
2677 $alter =
'ALTER TABLE ' .
$DB->quote(
$f[
'TABLE_NAME']) .
' ROW_FORMAT=Dynamic ENGINE=InnoDB';
2678 $res0 =
$DB->Query($alter,
true);
2688 $this->arTestVars[
'iError']++;
2689 $this->arTestVars[
'iErrorAutoFix']++;
2698 $this->arTestVars[
'table_format_fail'] =
true;
2700 if ($this->fix_mode)
2708 '#VAL#' => intval($this->arTestVars[
'iError']),
2709 '#VAL1#' => intval($this->arTestVars[
'iErrorAutoFix']),
2710 ]) . ($this->arTestVars[
'iErrorAutoFix'] > 0 ?
fix_link() :
''));
2719 if (!empty($this->arTestVars[
'check_mbstring_fail']))
2723 elseif (!empty($this->arTestVars[
'check_table_status_fail']))
2727 elseif (!empty($this->arTestVars[
'check_connection_charset_fail']))
2731 elseif (!empty($this->arTestVars[
'db_charset_fail']))
2735 elseif (!empty($this->arTestVars[
'table_format_fail']))
2740 $res =
$DB->Query(
'SHOW VARIABLES LIKE "character_set_database"');
2742 $charset = trim(
$f[
'Value']);
2744 $res =
$DB->Query(
'SHOW VARIABLES LIKE "collation_database"');
2746 $collation = trim(
$f[
'Value']);
2750 $res =
$DB->Query(
'SHOW TABLES LIKE \'b\_%\'');
2751 $cnt =
$res->SelectedRowsCount();
2754 'b_sale_loc_search_word' =>
'WORD',
2755 'b_search_content_stem' =>
'STEM',
2756 'b_search_content_freq' =>
'STEM',
2757 'b_search_stem' =>
'STEM',
2758 'b_search_tags' =>
'NAME',
2759 'b_translate_path' =>
'NAME',
2760 'b_translate_phrase' =>
'CODE',
2762 while (
$f =
$res->Fetch())
2765 $table = current(
$f);
2767 if (!empty($this->arTestVars[
'last_value']))
2769 if ($this->arTestVars[
'last_value'] == $table)
2771 unset($this->arTestVars[
'last_value']);
2776 $res0 =
$DB->Query(
'SHOW CREATE TABLE ' .
$DB->quote($table),
true);
2777 if ($res0 ===
false)
2779 if ($this->fix_mode)
2781 $DB->Query(
'DROP TABLE ' .
$DB->quote($table),
true);
2786 $this->arTestVars[
'iError']++;
2787 $this->arTestVars[
'iErrorAutoFix']++;
2791 $f0 = $res0->Fetch();
2793 if (preg_match(
'/DEFAULT CHARSET=([a-z0-9\-_]+)/i', $f0[
'Create Table'], $regs))
2795 $t_charset = $regs[1];
2796 if (preg_match(
'/COLLATE=([a-z0-9\-_]+)/i', $f0[
'Create Table'], $regs))
2798 $t_collation = $regs[1];
2802 $res0 =
$DB->Query(
'SHOW CHARSET LIKE \'' .
$DB->ForSql(str_replace(
'_',
'\_', $t_charset)) .
'\'');
2803 $f0 = $res0->Fetch();
2804 $t_collation = $f0[
'Default collation'];
2809 $res0 =
$DB->Query(
'SHOW TABLE STATUS LIKE \'' .
$DB->ForSql(str_replace(
'_',
'\_', $table)) .
'\'');
2810 $f0 = $res0->Fetch();
2811 if (!$t_collation = $f0[
'Collation'])
2818 if ($charset != $t_charset)
2821 if (!$this->fix_mode)
2823 $strError .=
GetMessage(
'SC_DB_MISC_CHARSET', [
'#TABLE#' => $table,
'#VAL1#' => $t_charset,
'#VAL0#' => $charset]) .
"<br>";
2824 $this->arTestVars[
'iError']++;
2825 if ($this->force_repair)
2827 $this->arTestVars[
'iErrorAutoFix']++;
2830 elseif ($this->force_repair && !
$DB->Query($sql =
'ALTER TABLE ' .
$DB->quote($table) .
' CHARACTER SET ' . $charset,
true))
2836 elseif ($t_collation != $collation)
2838 if (!$this->fix_mode)
2840 $strError .=
GetMessage(
'SC_COLLATE_WARN', [
'#TABLE#' => $table,
'#VAL1#' => $t_collation,
'#VAL0#' => $collation]) .
"<br>";
2841 $this->arTestVars[
'iError']++;
2842 $this->arTestVars[
'iErrorAutoFix']++;
2844 elseif (!
$DB->Query($sql =
'ALTER TABLE ' .
$DB->quote($table) .
' COLLATE ' . $collation,
true))
2853 $res0 =
$DB->Query(
"SHOW FULL COLUMNS FROM " .
$DB->quote($table));
2854 while ($f0 = $res0->Fetch())
2856 $f_collation = $f0[
'Collation'];
2857 if ($f_collation ===
null || $f_collation ===
"NULL")
2864 if ($charset != $f_charset)
2867 if (!$this->fix_mode)
2869 $strError .=
GetMessage(
'SC_TABLE_CHARSET_WARN', [
'#TABLE#' => $table,
'#VAL0#' => $charset,
'#VAL1#' => $f_charset,
'#FIELD#' => $f0[
'Field']]) .
"<br>";
2870 $this->arTestVars[
'iError']++;
2871 if ($this->force_repair)
2873 $this->arTestVars[
'iErrorAutoFix']++;
2876 elseif ($this->force_repair)
2878 $arFix[] =
' MODIFY ' .
$DB->quote($f0[
'Field'])
2880 .
' CHARACTER SET ' . $charset
2881 . ($f0[
'Null'] ==
'YES' ?
' NULL' :
' NOT NULL')
2882 . ($f0[
'Default'] ===
null ? ($f0[
'Null'] ==
'YES' ?
' DEFAULT NULL ' :
'') :
' DEFAULT ' . ($f0[
'Type'] ==
'timestamp' && $f0[
'Default'] ? $f0[
'Default'] :
'"' .
$DB->ForSQL($f0[
'Default']) .
'"'))
2883 .
' ' . str_ireplace(
'DEFAULT_GENERATED',
'', $f0[
'Extra'])
2884 . ($f0[
'Comment'] ?
' COMMENT \'' .
$DB->ForSql($f0[
'Comment']) .
'\'' :
'');
2887 elseif ($collation != $f_collation)
2889 if (!empty($arExclusion[$table]) && strtoupper($f0[
'Field']) == $arExclusion[$table])
2895 if (!$this->fix_mode)
2897 $strError .=
GetMessage(
'SC_FIELDS_COLLATE_WARN', [
'#TABLE#' => $table,
'#VAL0#' => $collation,
'#VAL1#' => $f_collation,
'#FIELD#' => $f0[
'Field']]) .
"<br>";
2899 if (!isset($this->arTestVars[
'iError']))
2901 $this->arTestVars[
'iError'] = 0;
2903 $this->arTestVars[
'iError']++;
2905 if (!isset($this->arTestVars[
'iErrorAutoFix']))
2907 $this->arTestVars[
'iErrorAutoFix'] = 0;
2909 $this->arTestVars[
'iErrorAutoFix']++;
2913 $arFix[] =
' MODIFY ' .
$DB->quote($f0[
'Field'])
2915 .
' COLLATE ' . $collation . ($f0[
'Null'] ==
'YES' ?
' NULL' :
' NOT NULL')
2916 . ($f0[
'Default'] ===
null ? ($f0[
'Null'] ==
'YES' ?
' DEFAULT NULL ' :
'') :
' DEFAULT ' . ($f0[
'Type'] ==
'timestamp' && $f0[
'Default'] ? $f0[
'Default'] :
'"' .
$DB->ForSQL($f0[
'Default']) .
'"'))
2917 .
' ' . str_ireplace(
'DEFAULT_GENERATED',
'', $f0[
'Extra'])
2918 . ($f0[
'Comment'] ?
' COMMENT \'' .
$DB->ForSql($f0[
'Comment']) .
'\'' :
'');
2923 if ($this->fix_mode &&
count($arFix))
2925 if (!
$DB->Query($sql =
'ALTER TABLE ' .
$DB->quote($table) .
' ' . implode(
",\n", $arFix),
true))
2932 if (time() -
$time >= $this->timeout)
2934 $this->arTestVars[
'last_value'] = $table;
2935 $this->test_percent = floor(
$i / $cnt * 100);
2945 $this->arTestVars[
'table_charset_fail'] =
true;
2947 if ($this->fix_mode)
2954 return $this->
Result(
false,
GetMessage(
'SC_CHECK_TABLES_ERRORS', [
'#VAL#' => intval($this->arTestVars[
'iError']),
'#VAL1#' => intval($this->arTestVars[
'iErrorAutoFix'])]) . ($this->arTestVars[
'iErrorAutoFix'] > 0 ?
fix_link() :
''));
2963 $arInsertExclude = [
2964 'b_seo_search_engine' => 1,
2965 'b_hot_keys_code' => 1,
2968 if (!empty($this->arTestVars[
'table_charset_fail']))
2972 elseif (!empty($this->arTestVars[
'table_format_fail']))
2977 $DB->Query(
"SET SQL_MODE=''");
2980 $cnt = $iCurrent = 0;
2981 if (
$dir = opendir(
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/modules'))
2983 while (
false !== ($item = readdir(
$dir)))
2985 if (str_contains($item,
'.'))
2992 if (!empty($this->arTestVars[
'last_value']))
2995 if ($this->arTestVars[
'last_value'] == $item)
2997 unset($this->arTestVars[
'last_value']);
3012 $file =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/modules/' . $module .
'/install/db/mysql/install.sql';
3013 if (!file_exists($file))
3015 $file =
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/modules/' . $module .
'/install/mysql/install.sql';
3017 if (file_exists($file))
3019 $arTableColumns = [];
3020 $bModuleInstalled = ModuleTable::getById($module)->fetch();
3022 if (
false === (
$query = file_get_contents($file)))
3028 $arQuery =
$DB->ParseSQLBatch(str_replace(
"\r",
"",
$query));
3029 foreach ($arQuery as $sql)
3031 if (preg_match(
'#^(CREATE TABLE )(IF NOT EXISTS)? *`?([a-z0-9_]+)`?(.*);?$#mis', $sql, $regs))
3034 if (str_starts_with($table,
'site_checker_'))
3039 $bTableExists =
$DB->Query(
'SHOW TABLES LIKE \'' .
$DB->ForSql(str_replace(
'_',
'\_', $table)) .
'\'')->Fetch();
3040 if (!$bTableExists && $bModuleInstalled)
3042 if ($this->fix_mode)
3044 if (!
$DB->Query($sql,
true))
3046 return $this->
Result(
false,
'Mysql Query Error: ' . $sql .
' [' .
$DB->db_Error .
']');
3052 Application::getInstance()->getSession()[
'FixQueryList'][] = $sql;
3053 $this->arTestVars[
'iError'] = ($this->arTestVars[
'iError'] ?? 0) + 1;
3054 $this->arTestVars[
'iErrorAutoFix'] = ($this->arTestVars[
'iErrorAutoFix'] ?? 0) + 1;
3055 $this->arTestVars[
'cntNoTables'] = ($this->arTestVars[
'cntNoTables'] ?? 0) + 1;
3060 if ($bTableExists || $bModuleInstalled)
3062 $arTables[$table] = $sql;
3063 $tmp_table =
'site_checker_' . $table;
3064 $DB->Query(
'DROP TABLE IF EXISTS ' .
$DB->quote($tmp_table));
3065 $DB->Query($regs[1] .
' ' .
$DB->quote($tmp_table) . $regs[4]);
3068 elseif (preg_match(
'#^(ALTER TABLE)( )?`?([a-z0-9_]+)`?(.*);?$#mis', $sql, $regs))
3071 if (!$arTables[$table])
3075 $tmp_table =
'site_checker_' . $table;
3076 $DB->Query($regs[1] .
' ' .
$DB->quote($tmp_table) . $regs[4]);
3078 elseif (preg_match(
'#^INSERT INTO *`?([a-z0-9_]+)`?[^(]*\(?([^)]*)\)?[^V]*VALUES[^(]*\((.+)\);?$#mis', $sql, $regs))
3081 if (!$arTables[$table] || !empty($arInsertExclude[$table]))
3085 $tmp_table =
'site_checker_' . $table;
3089 $arColumns = explode(
',', $regs[2]);
3093 if (!$arTableColumns[$tmp_table])
3095 $rs =
$DB->Query(
'SHOW COLUMNS FROM ' .
$DB->quote($tmp_table));
3096 while (
$f =
$rs->Fetch())
3098 $arTableColumns[$tmp_table][] =
$f[
'Field'];
3101 $arColumns = $arTableColumns[$tmp_table];
3104 $strValues = $regs[3];
3105 $ar = explode(
",", $strValues);
3112 if (preg_match(
'#^ *(-?[0-9]+|\'.*\'|".*"|null|now\(\)) *$#i',
$str))
3122 $sqlSelect =
'SELECT * FROM ' .
$DB->quote($table) .
' WHERE 1=1 ';
3123 foreach ($arColumns as
$k => $c)
3126 if (!preg_match(
'#null|now\(\)#i', $v))
3128 $sqlSelect .=
' AND ' . $c .
'=' . $v;
3131 $rs =
$DB->Query($sqlSelect);
3134 if ($this->fix_mode)
3136 if (!
$DB->Query($sql,
true))
3138 return $this->
Result(
false,
'Mysql Query Error: ' . $sql .
' [' .
$DB->db_Error .
']');
3143 $strError .=
GetMessage(
'SC_ERR_NO_VALUE', [
'#TABLE#' => $table,
'#SQL#' => $sql]) .
"<br>";
3144 Application::getInstance()->getSession()[
'FixQueryList'][] = $sql;
3145 $this->arTestVars[
'iError'] = ($this->arTestVars[
'iError'] ?? 0) + 1;
3146 $this->arTestVars[
'iErrorAutoFix'] = ($this->arTestVars[
'iErrorAutoFix'] ?? 0) + 1;
3147 $this->arTestVars[
'cntNoValues'] = ($this->arTestVars[
'cntNoValues'] ?? 0) + 1;
3153 echo
"Error parsing SQL:\n" . $sql .
"\n";
3158 if (file_exists($file = str_replace(
'/install.sql',
'/install_ft.sql', $file)))
3160 if (
false === (
$query = file_get_contents($file)))
3164 $query = preg_replace(
'# on +([a-z_0-9]+) \(#i',
' on site_checker_\\1 (',
$query);
3165 $arQuery =
$DB->ParseSQLBatch(str_replace(
"\r",
"",
$query));
3166 foreach ($arQuery as $sql)
3168 if (!
$DB->Query($sql,
true))
3175 foreach ($arTables as $table => $sql)
3178 $rs =
$DB->Query(
'SHOW INDEXES FROM ' .
$DB->quote($table));
3179 while (
$f =
$rs->Fetch())
3181 $column = strtolower(
$f[
'Column_name'] . (
$f[
'Sub_part'] ?
'(' .
$f[
'Sub_part'] .
')' :
''));
3182 if (!empty($arIndexes[
$f[
'Key_name']]))
3184 $arIndexes[
$f[
'Key_name']] .=
',' . $column;
3188 $arIndexes[
$f[
'Key_name']] = $column;
3192 $tmp_table =
'site_checker_' . $table;
3193 $arIndexes_tmp = [];
3196 $rs =
$DB->Query(
'SHOW INDEXES FROM ' .
$DB->quote($tmp_table));
3197 while (
$f =
$rs->Fetch())
3199 $column = strtolower(
$f[
'Column_name'] . (
$f[
'Sub_part'] ?
'(' .
$f[
'Sub_part'] .
')' :
''));
3200 if (!empty($arIndexes_tmp[
$f[
'Key_name']]))
3202 $arIndexes_tmp[
$f[
'Key_name']] .=
',' . $column;
3206 $arIndexes_tmp[
$f[
'Key_name']] = $column;
3208 if (
$f[
'Index_type'] ==
'FULLTEXT')
3210 $arFT[
$f[
'Key_name']] =
true;
3212 if (
$f[
'Non_unique'] == 0)
3214 $arUnique[
$f[
'Key_name']] =
true;
3218 foreach ($arIndexes_tmp as
$name => $ix)
3220 if (!in_array($ix, $arIndexes))
3222 if (!empty($arIndexes[
$name]))
3224 if (
$name ==
'PRIMARY')
3229 $sql =
'ALTER TABLE ' .
$DB->quote($table) .
' DROP INDEX ' .
$DB->quote(
$name);
3230 if ($this->fix_mode)
3232 if (!
$DB->Query($sql,
true))
3234 return $this->
Result(
false,
'Mysql Query Error: ' . $sql .
' [' .
$DB->db_Error .
']');
3239 Application::getInstance()->getSession()[
'FixQueryList'][] = $sql;
3240 $this->arTestVars[
'iError'] = ($this->arTestVars[
'iError'] ?? 0) + 1;
3241 $this->arTestVars[
'iErrorAutoFix'] = ($this->arTestVars[
'iErrorAutoFix'] ?? 0) + 1;
3248 $rs =
$DB->Query(
'SHOW COLUMNS FROM ' .
$DB->quote($table));
3249 while (
$f =
$rs->Fetch())
3251 $arColumns[strtolower(
$f[
'Field'])] =
$f;
3254 $rs =
$DB->Query(
'SHOW COLUMNS FROM ' .
$DB->quote($tmp_table));
3255 while ($f_tmp =
$rs->Fetch())
3258 if (isset($arColumns[strtolower($f_tmp[
'Field'])]))
3260 $f = $arColumns[strtolower($f_tmp[
'Field'])];
3263 $sql =
'ALTER TABLE ' .
$DB->quote($table) .
' CHANGE ' .
$DB->quote(
$f[
'Field']) .
' ' .
$tmp;
3264 if ($this->fix_mode)
3268 if (!
$DB->Query($sql,
true))
3270 return $this->
Result(
false,
'Mysql Query Error: ' . $sql .
' [' .
$DB->db_Error .
']');
3275 $this->arTestVars[
'iErrorFix'] = ($this->arTestVars[
'iErrorFix'] ?? 0) + 1;
3280 Application::getInstance()->getSession()[
'FixQueryList'][] = $sql;
3281 $strError .=
GetMessage(
'SC_ERR_FIELD_DIFFERS', [
'#TABLE#' => $table,
'#FIELD#' =>
$f[
'Field'],
'#CUR#' => $cur,
'#NEW#' =>
$tmp]) .
"<br>";
3282 $this->arTestVars[
'iError'] = ($this->arTestVars[
'iError'] ?? 0) + 1;
3285 $this->arTestVars[
'iErrorAutoFix'] = ($this->arTestVars[
'iErrorAutoFix'] ?? 0) + 1;
3287 $this->arTestVars[
'cntDiffFields'] = ($this->arTestVars[
'cntDiffFields'] ?? 0) + 1;
3293 $sql =
'ALTER TABLE ' .
$DB->quote($table) .
' ADD ' . preg_replace(
'#auto_increment#i',
'',
$tmp);
3294 if ($this->fix_mode)
3296 if (!
$DB->Query($sql,
true))
3298 return $this->
Result(
false,
'Mysql Query Error: ' . $sql .
' [' .
$DB->db_Error .
']');
3303 Application::getInstance()->getSession()[
'FixQueryList'][] = $sql;
3304 $strError .=
GetMessage(
'SC_ERR_NO_FIELD', [
'#TABLE#' => $table,
'#FIELD#' => $f_tmp[
'Field']]) .
"<br>";
3305 $this->arTestVars[
'iError'] = ($this->arTestVars[
'iError'] ?? 0) + 1;
3306 $this->arTestVars[
'iErrorAutoFix'] = ($this->arTestVars[
'iErrorAutoFix'] ?? 0) + 1;
3307 $this->arTestVars[
'cntNoFields'] = ($this->arTestVars[
'cntNoFields'] ?? 0) + 1;
3312 foreach ($arIndexes_tmp as
$name => $ix)
3314 if (!in_array($ix, $arIndexes))
3316 if (
$name ==
'PRIMARY' && $arIndexes[
'PRIMARY'])
3318 $this->arTestVars[
'iError'] = ($this->arTestVars[
'iError'] ?? 0) + 1;
3323 if (
$name ==
'PRIMARY')
3325 $sql =
'ALTER TABLE ' .
$DB->quote($table) .
' ADD PRIMARY KEY (' . $ix .
')';
3330 if (!empty($arFT[
$name]))
3332 $indexType =
'FULLTEXT ';
3336 $indexType =
'UNIQUE ';
3338 $sql =
'CREATE ' . $indexType .
'INDEX ' .
$DB->quote(
$name) .
' ON ' .
$DB->quote($table) .
' (' . $ix .
')';
3340 if ($this->fix_mode)
3342 if (!
$DB->Query($sql,
true))
3344 return $this->
Result(
false,
'Mysql Query Error: ' . $sql .
' [' .
$DB->db_Error .
']');
3349 Application::getInstance()->getSession()[
'FixQueryList'][] = $sql;
3351 $this->arTestVars[
'iError'] = ($this->arTestVars[
'iError'] ?? 0) + 1;
3352 $this->arTestVars[
'iErrorAutoFix'] = ($this->arTestVars[
'iErrorAutoFix'] ?? 0) + 1;
3353 $this->arTestVars[
'cntNoIndexes'] = ($this->arTestVars[
'cntNoIndexes'] ?? 0) + 1;
3358 $DB->Query(
'DROP TABLE ' .
$DB->quote($tmp_table));
3364 if ($iCurrent < $cnt)
3366 $this->arTestVars[
'last_value'] = $module;
3367 $this->test_percent = floor($iCurrent / $cnt * 100);
3371 if ($this->fix_mode)
3373 if (!empty($this->arTestVars[
'iErrorFix']))
3377 '#VAL#' => intval($this->arTestVars[
'iErrorFix']),
3383 if (isset($this->arTestVars[
'iError']) && $this->arTestVars[
'iError'] > 0)
3385 if (is_array(Application::getInstance()->getSession()[
'FixQueryList']) &&
count(Application::getInstance()->getSession()[
'FixQueryList']))
3387 echo implode(
";\n", Application::getInstance()->getSession()[
'FixQueryList']) .
';';
3389 Application::getInstance()->getSession()[
'FixQueryList'] = [];
3392 GetMessage(
'SC_CHECK_TABLES_STRUCT_ERRORS', [
3393 '#VAL#' => intval($this->arTestVars[
'iError'] ?? 0),
3394 '#VAL1#' => intval($this->arTestVars[
'iErrorAutoFix'] ?? 0),
3395 '#NO_TABLES#' => intval($this->arTestVars[
'cntNoTables'] ?? 0),
3396 '#NO_FIELDS#' => intval($this->arTestVars[
'cntNoFields'] ?? 0),
3397 '#DIFF_FIELDS#' => intval($this->arTestVars[
'cntDiffFields'] ?? 0),
3398 '#NO_INDEXES#' => intval($this->arTestVars[
'cntNoIndexes'] ?? 0),
3399 '#NO_VALUES#' => intval($this->arTestVars[
'cntNoValues'] ?? 0),
3400 ]) . (!empty($this->arTestVars[
'iErrorAutoFix']) ?
fix_link(3) :
'')
3413 defined(
'BX_CRONTAB')
3414 || (defined(
'CHK_EVENT') && CHK_EVENT ===
true)
3419 return "CSiteCheckerTest::CommonTest();";
3423 ($ntlm_varname = COption::GetOptionString(
'ldap',
'ntlm_varname',
'REMOTE_USER'))
3424 && (trim(
$_SERVER[$ntlm_varname] ??
''))
3428 return "CSiteCheckerTest::CommonTest();";
3441 $oTest->arTestVars =
$ar;
3445 || (isset(
$_SERVER[
'HTTP_X_FORWARDED_PROTO']) &&
$_SERVER[
'HTTP_X_FORWARDED_PROTO'] ==
'https')
3448 if (preg_match(
'#^(.+):([0-9]+)$#',
$_SERVER[
'HTTP_HOST'], $regs))
3450 $oTest->host = $regs[1];
3451 $oTest->port = $regs[2];
3452 if ($oTest->port == 443)
3459 $oTest->host =
$_SERVER[
'HTTP_HOST'];
3460 $oTest->port = isset(
$_SERVER[
'SERVER_PORT']) &&
$_SERVER[
'SERVER_PORT'] ?
$_SERVER[
'SERVER_PORT'] : ($oTest->ssl ? 443 : 80);
3463 if ($oTest->result ===
false)
3469 GetMessage(
"MAIN_SC_GOT_ERRORS", [
'#LINK#' =>
"/bitrix/admin/site_checker.php?lang=" . LANGUAGE_ID .
"&express_test=Y"]) :
3470 GetMessage(
"MAIN_SC_SITE_GOT_ERRORS", [
'#LINK#' =>
"/bitrix/admin/site_checker.php?lang=" . LANGUAGE_ID .
"&start_test=Y"])
3472 "TAG" =>
"SITE_CHECKER",
3473 "MODULE_ID" =>
"MAIN",
3482 if ($oTest->percent >= 100)
3489 $ar = $oTest->arTestVars;
3492 $REMOTE_ADDR =
$_SERVER[
'REMOTE_ADDR'];
3493 $HTTP_USER_AGENT =
$_SERVER[
'HTTP_USER_AGENT'];
3497 "SEVERITY" =>
"WARNING",
3498 "AUDIT_TYPE_ID" =>
$success ?
'SITE_CHECKER_SUCCESS' :
'SITE_CHECKER_ERROR',
3499 "MODULE_ID" =>
"main",
3500 "ITEM_ID" =>
'CSiteCheckerTest::CommonTest();',
3502 "DESCRIPTION" =>
'',
3504 $_SERVER[
'REMOTE_ADDR'] = $REMOTE_ADDR;
3505 $_SERVER[
'HTTP_USER_AGENT'] = $HTTP_USER_AGENT;
3507 return "CSiteCheckerTest::CommonTest();";
3514 if (version_compare($v = phpversion(), self::MIN_PHP_VER,
'<'))
3517 'MESSAGE' =>
GetMessage(
'PHP_VER_NOTIFY', [
'#CUR#' => $v,
'#REQ#' => self::MIN_PHP_VER]),
3518 'TAG' =>
'PHP_VERSION',
3519 'MODULE_ID' =>
'MAIN',
3523 return "CSiteCheckerTest::PhpTestAgent();";
3544 $this->StartTime = time();
3549 if (time() - $this->StartTime > $this->TimeLimit)
3551 $this->BreakPoint =
$path;
3552 return empty($this->arFail);
3555 if (
count($this->arFail) > $this->MaxFail)
3560 if ($this->SkipPath)
3562 if (!str_starts_with($this->SkipPath, dirname(
$path)))
3567 if ($this->SkipPath ==
$path)
3569 $this->SkipPath =
null;
3575 if (is_readable(
$path))
3577 if (!is_writable(
$path))
3579 $this->arFail[] =
$path;
3584 while (
false !== $item = readdir(
$dir))
3586 if ($item ==
'.' || $item ==
'..')
3592 if ($this->BreakPoint)
3602 $this->arFail[] =
$path;
3605 elseif (!$this->SkipPath)
3607 $this->FilesCount++;
3608 if (!is_readable(
$path) || !is_writable(
$path))
3610 $this->arFail[] =
$path;
3613 return empty($this->arFail);
3622 include_once(
$path);
3625 $i = array_search(
"modules",
$arr);
3626 $class_name =
$arr[
$i + 1];
3628 return CModule::CreateModuleObject($class_name);
3634 if (trim($strRes) ==
'SUCCESS')
3640 PrintHTTP($strRequest, $strHeaders, $strRes);
3647 fputs(
$res, $strRequest);
3651 $Content_Length =
false;
3652 while (!feof(
$res) && ($line = fgets(
$res, 4096)) && $line !=
"\r\n")
3654 $strHeaders .= $line;
3655 if (preg_match(
"/Transfer-Encoding: +chunked/i", $line))
3660 if (preg_match(
"/Content-Length: +([0-9]+)/i", $line, $regs))
3662 $Content_Length = $regs[1];
3669 $maxReadSize = 4096;
3671 $line = fgets(
$res, $maxReadSize);
3672 $line = strtolower($line);
3676 while (
$i < strlen($line) && in_array($line[
$i], [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f"]))
3678 $strChunkSize .= $line[
$i];
3682 $chunkSize = hexdec($strChunkSize);
3684 while ($chunkSize > 0)
3687 $readSize = (($chunkSize > $maxReadSize) ? $maxReadSize : $chunkSize);
3689 while ($readSize > 0 && $line = fread(
$res, $readSize))
3692 $processedSize += strlen($line);
3693 $newSize = $chunkSize - $processedSize;
3694 $readSize = (($newSize > $maxReadSize) ? $maxReadSize : $newSize);
3697 $line = fgets(
$res, $maxReadSize);
3698 $line = strtolower($line);
3702 while (
$i < strlen($line) && in_array($line[
$i], [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f"]))
3704 $strChunkSize .= $line[
$i];
3708 $chunkSize = hexdec($strChunkSize);
3711 elseif ($Content_Length !==
false)
3713 if ($Content_Length > 0)
3715 $strRes = fread(
$res, $Content_Length);
3720 while ($line = fread(
$res, 4096))
3733 @include(
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/license_key.php');
3734 if ($LICENSE_KEY ==
'')
3736 $LICENSE_KEY =
'DEMO';
3738 return md5(
$_SERVER[
'DOCUMENT_ROOT'] . filemtime(
$_SERVER[
'DOCUMENT_ROOT'] .
'/bitrix/modules/main/admin/site_checker.php') . $LICENSE_KEY);
3745 if (!$c = &$CACHE[$collation])
3747 $res0 =
$DB->Query(
'SHOW COLLATION LIKE "' . $collation .
'"');
3748 $f0 = $res0->Fetch();
3749 $c = $f0[
'Charset'];
3754function InitPureDB()
3756 require_once(
$_SERVER[
"DOCUMENT_ROOT"] .
"/bitrix/modules/main/bx_root.php");
3757 require_once(
$_SERVER[
"DOCUMENT_ROOT"] .
"/bitrix/modules/main/lib/loader.php");
3758 require_once(
$_SERVER[
"DOCUMENT_ROOT"] .
"/bitrix/modules/main/include/autoload.php");
3759 require_once(
$_SERVER[
"DOCUMENT_ROOT"] .
"/bitrix/modules/main/tools.php");
3768 require_once
$_SERVER[
"DOCUMENT_ROOT"] .
getLocalPath(
'php_interface/dbconn.php', BX_PERSONAL_ROOT);
3770 require_once(
$_SERVER[
"DOCUMENT_ROOT"] .
"/bitrix/modules/main/include/constants.php");
3775 $DB =
new CDatabase;
3779 if (!
$DB->DoConnect())
3790 $tmp =
$DB->quote($field[
'Field']) .
' ';
3792 if (preg_match(
"/^(TINYINT|SMALLINT|MEDIUMINT|INT|BIGINT)\\(\d+\\)(.*)/i", $field[
'Type'],
$matches))
3799 $tmp .= $field[
'Type'];
3802 if ($field[
'Null'] ==
'YES')
3808 $tmp .=
' NOT NULL';
3811 if ($field[
'Default'] ===
null)
3813 if ($field[
'Null'] ==
'YES')
3815 $tmp .=
' DEFAULT NULL ';
3820 $tmp .=
' DEFAULT ';
3821 if (($field[
'Type'] ==
'timestamp' || $field[
'Type'] ==
'datetime') && !preg_match(
'#^\d{4}#', $field[
'Default']))
3823 $tmp .= $field[
'Default'];
3825 elseif ($field[
'Type'] ==
'text' && preg_match(
"/^'.*'$/", $field[
'Default']))
3828 $tmp .= $field[
'Default'];
3832 $tmp .=
"'" .
$DB->ForSQL($field[
'Default']) .
"'";
3836 $tmp .=
' ' . str_ireplace(
'DEFAULT_GENERATED',
'', $field[
'Extra']);
3843 return ' <a href="javascript:show_popup(\'' .
GetMessageJS(
'SC_FIX_DATABASE') .
'\', \
'?fix_mode=' . $mode .
'\', \
'' .
GetMessageJS(
'SC_FIX_DATABASE_CONFIRM') .
'\')
">' . GetMessage('SC_FIX') . '</a>';
3846function PrintHTTP($strRequest, $strHeaders, $strRes)
3850 (($l = strlen($strRequest)) > 1000 ? substr($strRequest, 0, 1000) . ' ... (' . $l . ' bytes)' : $strRequest) . "\n
" .
3851 "== Response ==\n
" .
3852 $strHeaders . "\n
" .
3854 (($l = strlen($strRes)) > 1000 ? substr($strRes, 0, 1000) . ' ... (' . $l . ' bytes)' : $strRes) . "\n
" .
if(empty( $fields)) foreach($fields as $field) $channelId
static getInt(string $param)
static getList(array $parameters=array())
static getPublicLicenseCode()
static getLongPollingUrl()
static DeleteByTag($tagId)
static showConnectionError()
static registerAutoload(?string $connectionType=null)
static GetList($arOrder=Array(), $arFilter=Array())
static Send($channelId, $message, $options=array())
static SignChannel($channelId)
ConnectToHost($host=false, $port=false, $ssl=false)
check_mysql_table_status()
check_mysql_bug_version()
check_mysql_table_format()
check_mysql_connection_charset()
__construct($step=0, $fast=0, $fix_mode=0)
Result($result, $text='')
check_pgsql_connection_charset()
check_mysql_table_charset()
check_mysql_table_structure()
TableFieldCanBeAltered($f, $f_tmp)
check_upload($big=false, $raw=false)
if(!is_array($prop["VALUES"])) $tmp
<? if( $useEditor3):?>< tr class="heading">< td colspan="2"><? echo GetMessage("FILEMAN_OPTION_SPELL_SET");?></td ></tr ><? if(function_exists( 'pspell_config_create')):$use_pspell_checked=(COption::GetOptionString( $module_id, "use_pspell", "Y")=="Y") ? "checked" :"";?>< tr >< td valign="top">< label for="use_pspell"><?echo GetMessage("FILEMAN_OPTION_USE_PSPELL");?></label >< br >< a title="<?echo GetMessage("FILEMAN_OPTION_ADDISH_DICS_TITLE");?> http
$_SERVER["DOCUMENT_ROOT"]
IsHttpResponseSuccess($res, $strRequest)
getCharsetByCollation($collation)
GetHttpResponse($res, $strRequest, &$strHeaders)
PrintHTTP($strRequest, $strHeaders, $strRes)
CheckGetModuleInfo($path)
TableFieldConstruct($field)
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
CheckSerializedData($str, $max_depth=200)
IsModuleInstalled($module_id)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
getLocalPath($path, $baseFolder="/bitrix")
GetMessageJS($name, $aReplace=false)
if(mb_strlen($order)< 6) $desc
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</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."%"
while($arSite=$dbSites->Fetch()) $oAuthManager