require_once(__DIR__."/../include/prolog_admin_before.php");
require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/prolog.php");
define("HELP_FILE", "settings/wizard_load.php");
require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/classes/general/wizard.php");
if(!$USER->CanDoOperation('edit_php') && !$USER->CanDoOperation('view_other_settings'))
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
$isAdmin = $USER->CanDoOperation('edit_php');
IncludeModuleLangFile(__FILE__);
$strError = $strOK = "";
do
{
if ( !($_SERVER["REQUEST_METHOD"]=="POST" && $_POST["action"]=="import" && $isAdmin && check_bitrix_sessid()) )
break;
if (!is_uploaded_file($_FILES["wizardFile"]["tmp_name"]))
{
$strError .= GetMessage("MAIN_WIZARD_LOAD_ERROR_LOAD");
break;
}
elseif(GetFileExtension(mb_strtolower($_FILES["wizardFile"]["name"])) != "gz")
{
$strError .= GetMessage("MAIN_WIZARD_TAR_GZ");
break;
}
$wizardPath = $_SERVER["DOCUMENT_ROOT"].CWizardUtil::GetRepositoryPath();
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/tar_gz.php");
$oArchiver = new CArchiver($_FILES["wizardFile"]["tmp_name"]);
if (!$oArchiver->extractFiles($wizardPath))
{
$strError .= GetMessage("MAIN_WIZARD_IMPORT_ERROR");
$arErrors = &$oArchiver->GetErrors();
if(!empty($arErrors))
{
$strError .= ":
";
foreach ($arErrors as $value)
$strError .= "[".$value[0]."] ".$value[1]."
";
}
else
$strError .= ".
";
break;
}
$strOK .= GetMessage("MAIN_WIZARD_LOAD_OK");
} while (false);
$aTabs = Array(Array("DIV" => "edit1", "TAB" => GetMessage("MAIN_WIZARD_LOAD_TITLE"), "TITLE" => GetMessage("MAIN_WIZARD_LOAD_TITLE")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$APPLICATION->SetTitle(GetMessage("MAIN_WIZARD_LOAD_TITLE"));
require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/prolog_admin_after.php");
echo CAdminMessage::ShowMessage($strError);
echo CAdminMessage::ShowNote($strOK);
$arMenu = array(
array(
"TEXT" => GetMessage("MAIN_WIZARD_LOAD_LINK_LIST"),
"LINK" => "wizard_list.php?lang=".LANGUAGE_ID,
"TITLE" => GetMessage("MAIN_WIZARD_LOAD_LINK_LIST"),
"ICON" => "btn_list"
)
);
$context = new CAdminContextMenu($arMenu);
$context->Show();
?>