<?if(!check_bitrix_sessid()) return;
IncludeModuleLangFile(__FILE__);
$errors = false;
$btnName = GetMessage('MOD_BACK');
if ($errors === false){
	CopyDirFiles($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/admin/", $_SERVER["DOCUMENT_ROOT"]."/bitrix/admin", true, true);
	if(is_dir($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/components/")){
		CopyDirFiles($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/components/", $_SERVER["DOCUMENT_ROOT"]."/bitrix/components", true, true);
		CopyDirFiles($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/images/", $_SERVER["DOCUMENT_ROOT"]."/bitrix/images/directoriya.modulcreator", true, true);
	}
    if(is_dir($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/panel/")) {
        CopyDirFiles($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/panel/", $_SERVER["DOCUMENT_ROOT"]."/bitrix/panel/directoriya.modulcreator", true, true);
    }
    $errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/db/mysql/install_b_directoriya_modulcreator.sql");
	RegisterModule("directoriya.modulcreator");
	echo CAdminMessage::ShowNote(GetMessage("MOD_INST_OK"));
}else{
	for($i=0; $i<count($errors); $i++){
		$alErrors .= $errors[$i]."<br />";
	}
	echo CAdminMessage::ShowMessage(Array("TYPE"=>"ERROR", "MESSAGE" =>GetMessage("MOD_INST_ERR"), "DETAILS"=>$alErrors, "HTML"=>true));
}
?>
<form action="<?echo $APPLICATION->GetCurPage()?>">
<p>
	<input type="hidden" name="lang" value="<?echo LANG?>" />
	<input type="submit" name="" value="<?echo $btnName;?>" />
</p>
</form>