- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/update_class.php
- Класс: CUpdateSystem
- Вызов: CUpdateSystem::LoadSources
static function LoadSources(&$strError, $lang = false, $stableVersionsOnly = "Y")
{
$strError_tmp = "";
CUpdateSystem::AddMessage2Log("exec CUpdateSystem::LoadSources");
if ($lang===false)
$lang = LANGUAGE_ID;
$stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
$arClientModules = CUpdateSystem::GetModules($strError_tmp);
if ($strError_tmp == '')
{
$GLOBALS["DB"]->GetVersion();
$strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
"&lang=".urlencode($lang).
"&UTYPES=".urlencode("S").
"&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
"&COUNT_ONLY=".urlencode("F").
"&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
"&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
"&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
"&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
"&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
"&CLIENT_PHPVER=".urlencode(phpversion()).
"&stable=".urlencode($stableVersionsOnly).
"&".CUpdateSystem::ModulesArray2Query($arClientModules, "bitm_");
CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
$stime = CUpdateSystem::getmicrotime();
$fcontent = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
CUpdateSystem::AddMessage2Log("TIME LoadSources.getHTTPPage ".Round(CUpdateSystem::getmicrotime()-$stime, 3)." sec");
if ($fcontent == '')
$strError_tmp .= "[ULS01] ".GetMessage("SUPP_AS_EMPTY_RESP").".
";
}
if ($strError_tmp == '')
{
if (!($fp1 = fopen($_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", "wb")))
$strError_tmp .= "[ULS02] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates", GetMessage("SUPP_RV_ER_TEMP_FILE")).".
";
}
if ($strError_tmp == '')
{
if (!fwrite($fp1, $fcontent))
$strError_tmp .= "[ULS03] ".str_replace("#FILE#", $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/update_archive.gz", GetMessage("SUPP_RV_WRT_TEMP_FILE")).".
";
@fclose($fp1);
}
if ($strError_tmp == '')
{
$temporary_updates_dir = "";
if (!CUpdateSystem::UnGzipArchive($temporary_updates_dir, $strError_tmp, "Y"))
$strError_tmp .= "[ULS04] ".GetMessage("SUPP_LS_LOAD_BREAK").".
";
}
if ($strError_tmp == '')
{
$updates_dir_full = $_SERVER["DOCUMENT_ROOT"]."/bitrix/updates/".$temporary_updates_dir;
if (!file_exists($updates_dir_full."/update_info.xml") || !is_file($updates_dir_full."/update_info.xml"))
$strError_tmp .= "[ULS05] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_ER_DESCR_FILE")).".
";
}
if ($strError_tmp == '')
{
if (!is_readable($updates_dir_full."/update_info.xml"))
$strError_tmp .= "[ULS06] ".str_replace("#FILE#", $updates_dir_full."/update_info.xml", GetMessage("SUPP_RV_READ_DESCR_FILE")).".
";
}
if ($strError_tmp == '')
{
$content = file_get_contents($updates_dir_full."/update_info.xml");
}
if ($strError_tmp == '')
{
$arRes = Array();
CUpdateSystem::ParseServerData($content, $arRes, $strError_tmp);
}
if ($strError_tmp == '')
{
if (isset($arRes["DATA"]["#"]["ERROR"])
&& is_array($arRes["DATA"]["#"]["ERROR"])
&& !empty($arRes["DATA"]["#"]["ERROR"]))
{
for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
{
if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
$strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
$strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].".
";
}
}
}
if ($strError_tmp == '')
{
if (!CUpdateSystem::CheckUpdatability($temporary_updates_dir, $strError_tmp))
$strError_tmp .= "[ULS07] ".GetMessage("SUPP_LS_LOAD_BREAK").".
";
}
if ($strError_tmp == '')
{
foreach ($arClientModules as $module_id => $version)
{
$strError_tmp1 = "";
$from_dir = $updates_dir_full."/".$module_id;
$to_dir = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$module_id;
if (!file_exists($to_dir) || !is_dir($to_dir))
{
$strError_tmp1 .= "[ULS08] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_NO_MOD_CAT")).".
";
}
elseif (!is_writable($to_dir))
{
$strError_tmp1 .= "[ULS09] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_WR_MOD_CAT")).".
";
}
if (!file_exists($from_dir) || !is_dir($from_dir))
{
$strError_tmp1 .= "[ULS10] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_NO_SRC_MOD")).".
";
}
elseif (!is_readable($from_dir))
{
$strError_tmp1 .= "[ULS11] ".str_replace("#MODULE#", $module_id, GetMessage("SUPP_LS_RD_SRC_MOD")).".
";
}
if ($strError_tmp1 == '')
{
CUpdateSystem::CopyDirFiles($from_dir, $to_dir, $strError_tmp1);
}
if ($strError_tmp1 <> '')
{
CUpdateSystem::AddMessage2Log("Error loading sources for ".$module_id."!", "CULS");
$strError_tmp .= $strError_tmp1;
}
else
{
CUpdateSystem::AddMessage2Log("Sources loaded for ".$module_id."!", "CULS");
}
}
}
if ($strError_tmp == '')
{
CUpdateSystem::DeleteDirFilesEx($updates_dir_full);
}
if ($strError_tmp <> '')
{
CUpdateSystem::AddMessage2Log($strError_tmp, "CULS");
$strError .= $strError_tmp;
return false;
}
else
return true;
}