• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/update_class.php
  • Класс: CUpdateSystem
  • Вызов: CUpdateSystem::UpdateKernel
static function UpdateKernel($updates_dir, $arModules, &$strError, &$arErrorModules, &$arSuccessModules)
{
	global $DB;
	$strError_tmp = "";

	$stime = CUpdateSystem::getmicrotime();

	$updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$updates_dir;

	if (!file_exists($updates_dir_full) || !is_dir($updates_dir_full))
	{
		$strError_tmp .= "[UUK01] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_NO_TMP_CAT")).".
"; } if (!is_array($arModules) || empty($arModules)) { $strError_tmp .= "[UUK02] ".GetMessage("SUPP_UK_NO_MODS").".
"; } if ($strError_tmp == '') { if (!is_readable($updates_dir_full)) $strError_tmp .= "[UUK03] ".str_replace("#FILE#", $updates_dir_full, GetMessage("SUPP_CU_RD_TMP_CAT")).".
"; } if ($strError_tmp == '') { for ($i = 0, $ni = count($arModules); $i < $ni; $i++) { $strError_tmp1 = ""; $from_dir = $updates_dir_full."/".$arModules[$i]; $to_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$arModules[$i]; CUpdateSystem::CheckDirPath($to_dir."/", true); if (!file_exists($to_dir) || !is_dir($to_dir)) { $strError_tmp1 .= "[UUK04] ".str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_NO_MODIR")).".
"; $arErrorModules[$arModules[$i]] = str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_NO_MODIR"))." [UUK04]. "; } if ($strError_tmp1 == '') { if (!is_writable($to_dir)) { $strError_tmp1 .= "[UUK05] ".str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_WR_MODIR")).".
"; $arErrorModules[$arModules[$i]] = str_replace("#MODULE_DIR#", $to_dir, GetMessage("SUPP_UK_WR_MODIR"))." [UUK05]. "; } } if ($strError_tmp1 == '') { if (!file_exists($from_dir) || !is_dir($from_dir)) { $strError_tmp1 .= "[UUK06] ".str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_NO_FDIR")).".
"; $arErrorModules[$arModules[$i]] = str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_NO_FDIR"))." [UUK06]. "; } } if ($strError_tmp1 == '') { if (!is_readable($from_dir)) { $strError_tmp1 .= "[UUK07] ".str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_READ_FDIR")).".
"; $arErrorModules[$arModules[$i]] = str_replace("#DIR#", $from_dir, GetMessage("SUPP_UK_READ_FDIR"))." [UUK07]. "; } } if ($strError_tmp1 == '') { $handle = @opendir($from_dir); $arUpdaters = array(); if ($handle) { while (false !== ($dir = readdir($handle))) { if (substr($dir, 0, 7)=="updater") { $bPostUpdater = "N"; if (is_file($from_dir."/".$dir)) { $num = substr($dir, 7, strlen($dir)-11); if (substr($dir, strlen($dir) - 9) == "_post.php") { $bPostUpdater = "Y"; $num = substr($dir, 7, strlen($dir)-16); } $arUpdaters[] = array("/".$dir, trim($num), $bPostUpdater); } elseif (file_exists($from_dir."/".$dir."/index.php")) { $num = substr($dir, 7); if (substr($dir, strlen($dir) - 5) == "_post") { $bPostUpdater = "Y"; $num = substr($dir, 7, strlen($dir)-12); } $arUpdaters[] = array("/".$dir."/index.php", trim($num), $bPostUpdater); } } } closedir($handle); } for ($i1 = 0, $nij = count($arUpdaters); $i1 < $nij-1; $i1++) { for ($j1 = $i1 + 1; $j1 < $nij; $j1++) { if (CUpdateSystem::CompareVersions($arUpdaters[$i1][1], $arUpdaters[$j1][1])>0) { $tmp1 = $arUpdaters[$i1]; $arUpdaters[$i1] = $arUpdaters[$j1]; $arUpdaters[$j1] = $tmp1; } } } } if ($strError_tmp1 == '') { if (strtolower($DB->type)=="mysql" && defined("MYSQL_TABLE_TYPE") && MYSQL_TABLE_TYPE <> '') { $DB->Query("SET storage_engine = '".MYSQL_TABLE_TYPE."'", true); } } if ($strError_tmp1 == '') { for ($i1 = 0, $ni1 = count($arUpdaters); $i1 < $ni1; $i1++) { if ($arUpdaters[$i1][2]=="N") { $strError_tmp2 = ""; CUpdateSystem::RunUpdaterScript($from_dir.$arUpdaters[$i1][0], $strError_tmp2, "/bitrix/updates/".$updates_dir."/".$arModules[$i], $arModules[$i]); if ($strError_tmp2 <> '') { $strError_tmp1 .= str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDN_ERR"))).": ". $strError_tmp2.".
"; $arErrorModules[$arModules[$i]] = str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDN_ERR"))).": ". $strError_tmp2.".
"; $strError_tmp1 .= str_replace("#MODULE#", $arModules[$i], GetMessage("SUPP_UK_UPDN_ERR_BREAK"))." "; break; } } } } if ($strError_tmp1 == '') { CUpdateSystem::CopyDirFiles($from_dir, $to_dir, $strError_tmp1); } if ($strError_tmp1 == '') { for ($i1 = 0, $ni1 = count($arUpdaters); $i1 < $ni1; $i1++) { if ($arUpdaters[$i1][2]=="Y") { $strError_tmp2 = ""; CUpdateSystem::RunUpdaterScript($from_dir.$arUpdaters[$i1][0], $strError_tmp2, "/bitrix/updates/".$updates_dir."/".$arModules[$i], $arModules[$i]); if ($strError_tmp2 <> '') { $strError_tmp1 .= str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDY_ERR"))).": ". $strError_tmp2.".
"; $arErrorModules[$arModules[$i]] = str_replace("#MODULE#", $arModules[$i], str_replace("#VER#", $arUpdaters[$i1][1], GetMessage("SUPP_UK_UPDY_ERR"))).": ". $strError_tmp2.".
"; $strError_tmp1 .= str_replace("#MODULE#", $arModules[$i], GetMessage("SUPP_UK_UPDN_ERR_BREAK"))." "; break; } } } } if ($strError_tmp1 <> '') { $strError_tmp .= $strError_tmp1; $arErrorModules[$arModules[$i]] .= str_replace("#MODULE#", $arModules[$i], GetMessage("SUPP_UK_UPDN_ERR_BREAK1"))." "; } else { $arSuccessModules[$arModules[$i]] = "Y"; } } CUpdateSystem::DeleteDirFilesEx($updates_dir_full); } CUpdateSystem::AddMessage2Log("TIME UpdateKernel ".Round(CUpdateSystem::getmicrotime()-$stime, 3)." sec"); if ($strError_tmp <> '') { CUpdateSystem::AddMessage2Log($strError_tmp, "CUUK"); $strError .= $strError_tmp; return false; } else return true; }