예제 #1
0
파일: tar_gz.php 프로젝트: ASDAFF/open_bx
 public function __construct($strArchiveName, $bCompress = false, $start_time = -1, $max_exec_time = -1, $pos = 0, $stepped = false)
 {
     $this->io = CBXVirtualIo::GetInstance();
     $this->max_exec_time = $max_exec_time;
     $this->start_time = $start_time;
     $this->file_pos = $pos;
     $this->_bCompress = $bCompress;
     $this->stepped = $stepped;
     self::$bMbstring = extension_loaded("mbstring");
     if (!$bCompress) {
         if (@file_exists($this->io->GetPhysicalName($strArchiveName))) {
             if ($fp = @fopen($this->io->GetPhysicalName($strArchiveName), "rb")) {
                 $data = fread($fp, 2);
                 fclose($fp);
                 if ($data == "‹") {
                     $this->_bCompress = True;
                 }
             }
         } else {
             if (substr($strArchiveName, -2) == 'gz') {
                 $this->_bCompress = True;
             }
         }
     } else {
         $this->_bCompress = True;
     }
     $this->_strArchiveName = $strArchiveName;
     $this->_arErrors = array();
 }
예제 #2
0
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$ID = str_replace("\\", "", $_REQUEST["ID"]);
$ID = str_replace("/", "", $ID);
$bUseCompression = True;
if (!extension_loaded('zlib') || !function_exists("gzcompress")) {
    $bUseCompression = False;
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/tar_gz.php";
CheckDirPath($_SERVER['DOCUMENT_ROOT'] . BX_PERSONAL_ROOT . "/tmp/templates/");
$tmpfname = $_SERVER['DOCUMENT_ROOT'] . BX_PERSONAL_ROOT . "/tmp/templates/" . md5(uniqid(rand(), true) . ".tar.gz");
$HTTP_ACCEPT_ENCODING = "";
$strError = "";
$path = getLocalPath("templates/" . $ID, BX_PERSONAL_ROOT);
if (is_dir($_SERVER["DOCUMENT_ROOT"] . $path)) {
    $oArchiver = new CArchiver($tmpfname, $bUseCompression);
    $tres = $oArchiver->add("\"" . $_SERVER["DOCUMENT_ROOT"] . $path . "\"", false, $_SERVER["DOCUMENT_ROOT"] . $path);
    if (!$tres) {
        $strError = "Archiver error";
        $arErrors =& $oArchiver->GetErrors();
        if (count($arErrors) > 0) {
            $strError .= ":<br>";
            foreach ($arErrors as $value) {
                $strError .= "[" . $value[0] . "] " . $value[1] . "<br>";
            }
        } else {
            $strError .= ".<br>";
        }
    }
    header('Pragma: public');
    header('Cache-control: private');
예제 #3
0
 function UnpackFileArchive($strfile, $path_to)
 {
     global $APPLICATION;
     $res = true;
     $arcname = CTempFile::GetFileName(md5(uniqid(rand(), true)) . '.tar.gz');
     CheckDirPath($arcname);
     if (file_put_contents($arcname, $strfile) !== false) {
         include_once dirname(__FILE__) . '/tar_gz.php';
         $ob = new CArchiver($arcname);
         CheckDirPath($_SERVER['DOCUMENT_ROOT'] . $path_to);
         $res = $ob->extractFiles($_SERVER['DOCUMENT_ROOT'] . $path_to);
         if (!$res && is_object($APPLICATION)) {
             $arErrors = $ob->GetErrors();
             if (count($arErrors)) {
                 $strError = "";
                 foreach ($arErrors as $error) {
                     $strError .= $error[1] . "<br>";
                 }
                 $e = new CApplicationException($strError);
                 $APPLICATION->ThrowException($e);
             }
         }
     }
     return $res;
 }
예제 #4
0
if (!$USER->CanDoOperation('edit_other_settings') && !$USER->CanDoOperation('view_other_settings') || !check_bitrix_sessid()) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$ID = str_replace("\\", "", $ID);
$ID = str_replace("/", "", $ID);
$bUseCompression = True;
if (!extension_loaded('zlib') || !function_exists("gzcompress")) {
    $bUseCompression = False;
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/tar_gz.php";
CheckDirPath($_SERVER['DOCUMENT_ROOT'] . BX_PERSONAL_ROOT . "/tmp/templates/");
$tmpfname = $_SERVER['DOCUMENT_ROOT'] . BX_PERSONAL_ROOT . "/tmp/templates/" . md5(uniqid(rand(), true) . ".tar.gz");
$HTTP_ACCEPT_ENCODING = "";
$strError = "";
if (is_dir($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $ID)) {
    $oArchiver = new CArchiver($tmpfname, $bUseCompression);
    $tres = $oArchiver->add("\"" . $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $ID . "\"", false, $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/");
    if (!$tres) {
        $strError = "Archiver error";
        $arErrors =& $oArchiver->GetErrors();
        if (count($arErrors) > 0) {
            $strError .= ":<br>";
            foreach ($arErrors as $value) {
                $strError .= "[" . $value[0] . "] " . $value[1] . "<br>";
            }
        } else {
            $strError .= ".<br>";
        }
    }
    header('Pragma: public');
    header('Cache-control: private');
     $strErrorMessage .= GetMessage('TR_ERROR_SELECT_LANGUAGE') . '<br>';
 }
 $bConvert = isset($_REQUEST['convert_encoding']) && $_REQUEST['convert_encoding'] == 'Y';
 if ($butf && $bConvert && (!isset($encoding) || !in_array($encoding, $arrTransEncoding))) {
     $strErrorMessage .= GetMessage('TR_ERROR_ENCODING') . '<br>';
 }
 $tempLanguagePathNoRoot = '/bitrix/tmp/translate/' . time() . '/';
 $tempLanguagePath = $_SERVER["DOCUMENT_ROOT"] . $tempLanguagePathNoRoot;
 if (strlen($strErrorMessage) <= 0) {
     CheckDirPath($tempLanguagePath);
     if (!file_exists($tempLanguagePath) || !is_dir($tempLanguagePath)) {
         $strErrorMessage .= GetMessage('TR_ERROR_CREATE_TEMP_FOLDER', array('%PATH%' => $tempLanguagePath)) . '<br>';
     }
 }
 if (strlen($strErrorMessage) <= 0) {
     $oArc = new CArchiver($_FILES['tarfile']['tmp_name'], true);
     $oArc->_strSeparator = '|';
     $oArc->extractFiles($tempLanguagePath);
     if (count($oArc->_arErrors) > 0) {
         $strErrorMessage .= ": ";
         foreach ($oArc->_arErrors as $e) {
             $strErrorMessage .= $e[1] . ", ";
         }
     }
 }
 if (strlen($strErrorMessage) <= 0) {
     $bConvert = isset($_REQUEST['localize_encoding']) && $_REQUEST['localize_encoding'] == 'Y';
     if ($bConvert) {
         if ($butf) {
             $strEncodingIn = $encoding;
             $strEncodingOut = 'utf-8';
예제 #6
0
            $sGroups .= ($sGroups != '' ? ',' : '') . intval($gr);
        }
    }
    COption::SetOptionString('fileman', 'default_edit_groups', $sGroups);
    $archive_step_time = intVal($_POST['archive_step_time']);
    if ($archive_step_time <= 0) {
        $archive_step_time = 30;
    }
    COption::SetOptionString($module_id, "archive_step_time", $archive_step_time);
}
if ($REQUEST_METHOD == "GET" && isset($_GET['load_dic']) && $USER->CanDoOperation('fileman_edit_all_settings') && COption::GetOptionString($module_id, "use_editor_3", "N") == "Y") {
    if (isValidLang($_GET['load_dic'])) {
        $l_id = $_GET['load_dic'];
        require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/tar_gz.php";
        $indexedDicPath = $_SERVER['DOCUMENT_ROOT'] . $gzDicsRelPath . '/' . $l_id . '.tar.gz';
        $oArchiver = new CArchiver($indexedDicPath);
        if ($oArchiver->extractFiles($_SERVER['DOCUMENT_ROOT'] . $dicsRelPath . '/' . $l_id)) {
            COption::SetOptionString($module_id, $l_id . "_dic_indexed", "Y");
        }
    }
}
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "fileman_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")), array("DIV" => "edit2", "TAB" => GetMessage("MAIN_TAB_VISUAL_EDITOR"), "ICON" => "fileman_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_VIS_ED_SET")), array("DIV" => "edit5", "TAB" => GetMessage("MAIN_TAB_MEDIALIB"), "ICON" => "fileman_settings", "TITLE" => GetMessage("FILEMAN_SEC_MEDIALIB")));
if ($USER->isAdmin()) {
    $rightsTab = array("DIV" => "edit3", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "fileman_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS"));
    $aTabs[] = $rightsTab;
}
$siteList = array();
$rsSites = CSite::GetList($by = "sort", $order = "asc", array());
$i = 0;
while ($arRes = $rsSites->Fetch()) {
    $siteList[$i]["ID"] = $arRes["ID"];
예제 #7
0
/**
 * Imports an xml file into iblock. File may be an .tar.gz archive.
 *
 * @param string $file_name Name of the file to import
 * @param string $iblock_type IBlock type ID to import iblock to
 * @param string|array $site_id ID of the site or array of IDs to bind iblock to
 * @param string $section_action What to do with sections missed in the file. D - delete or A - deactivate.
 * @param string $element_action What to do with elements missed in the file. D - delete or A - deactivate.
 * @param bool $use_crc Whenever to use CRC check for optimizi=ation or force an update
 * @param bool $preview If true when use iblock settings to generate preview pictures from detail.
 * @param bool $sync If true uses alternative set of tables in order not to interfere with other import processes
 * @param bool $return_last_error If true will return string with error description in case of failure
 * @param bool $return_iblock_id If true will return iblock identifier (int) in case of success
 * @return bool|int|string
 */
function ImportXMLFile($file_name, $iblock_type = "-", $site_id = '', $section_action = "D", $element_action = "D", $use_crc = false, $preview = false, $sync = false, $return_last_error = false, $return_iblock_id = false)
{
    /** @global CMain $APPLICATION */
    global $APPLICATION;
    $ABS_FILE_NAME = false;
    if (strlen($file_name) > 0) {
        if (file_exists($file_name) && is_file($file_name) && (substr($file_name, -4) === ".xml" || substr($file_name, -7) === ".tar.gz")) {
            $ABS_FILE_NAME = $file_name;
        } else {
            $filename = trim(str_replace("\\", "/", trim($file_name)), "/");
            $FILE_NAME = rel2abs($_SERVER["DOCUMENT_ROOT"], "/" . $filename);
            if (strlen($FILE_NAME) > 1 && $FILE_NAME === "/" . $filename && $APPLICATION->GetFileAccessPermission($FILE_NAME) >= "W") {
                $ABS_FILE_NAME = $_SERVER["DOCUMENT_ROOT"] . $FILE_NAME;
            }
        }
    }
    if (!$ABS_FILE_NAME) {
        return GetMessage("IBLOCK_XML2_FILE_ERROR");
    }
    $WORK_DIR_NAME = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/") + 1);
    if (substr($ABS_FILE_NAME, -7) == ".tar.gz") {
        include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/tar_gz.php";
        $obArchiver = new CArchiver($ABS_FILE_NAME);
        if (!$obArchiver->ExtractFiles($WORK_DIR_NAME)) {
            $strError = "";
            if (is_object($APPLICATION)) {
                $arErrors = $obArchiver->GetErrors();
                if (count($arErrors)) {
                    foreach ($arErrors as $error) {
                        $strError .= $error[1] . "<br>";
                    }
                }
            }
            if ($strError != "") {
                return $strError;
            } else {
                return GetMessage("IBLOCK_XML2_FILE_ERROR");
            }
        }
        $IMP_FILE_NAME = substr($ABS_FILE_NAME, 0, -7) . ".xml";
    } else {
        $IMP_FILE_NAME = $ABS_FILE_NAME;
    }
    $fp = fopen($IMP_FILE_NAME, "rb");
    if (!$fp) {
        return GetMessage("IBLOCK_XML2_FILE_ERROR");
    }
    if ($sync) {
        $table_name = "b_xml_tree_sync";
    } else {
        $table_name = "b_xml_tree";
    }
    $NS = array("STEP" => 0);
    $obCatalog = new CIBlockCMLImport();
    $obCatalog->Init($NS, $WORK_DIR_NAME, $use_crc, $preview, false, false, false, $table_name);
    if ($sync) {
        if (!$obCatalog->StartSession(bitrix_sessid())) {
            return GetMessage("IBLOCK_XML2_TABLE_CREATE_ERROR");
        }
        $obCatalog->ReadXMLToDatabase($fp, $NS, 0, 1024);
        $xml_root = $obCatalog->GetSessionRoot();
        $bUpdateIBlock = false;
    } else {
        $obCatalog->DropTemporaryTables();
        if (!$obCatalog->CreateTemporaryTables()) {
            return GetMessage("IBLOCK_XML2_TABLE_CREATE_ERROR");
        }
        $obCatalog->ReadXMLToDatabase($fp, $NS, 0, 1024);
        if (!$obCatalog->IndexTemporaryTables()) {
            return GetMessage("IBLOCK_XML2_INDEX_ERROR");
        }
        $xml_root = 1;
        $bUpdateIBlock = true;
    }
    fclose($fp);
    $result = $obCatalog->ImportMetaData($xml_root, $iblock_type, $site_id, $bUpdateIBlock);
    if ($result !== true) {
        return GetMessage("IBLOCK_XML2_METADATA_ERROR") . implode("\n", $result);
    }
    $obCatalog->ImportSections();
    $obCatalog->DeactivateSections($section_action);
    $obCatalog->SectionsResort();
    $obCatalog = new CIBlockCMLImport();
    $obCatalog->Init($NS, $WORK_DIR_NAME, $use_crc, $preview, false, false, false, $table_name);
    if ($sync) {
        if (!$obCatalog->StartSession(bitrix_sessid())) {
            return GetMessage("IBLOCK_XML2_TABLE_CREATE_ERROR");
        }
    }
    $SECTION_MAP = false;
    $PRICES_MAP = false;
    $obCatalog->ReadCatalogData($SECTION_MAP, $PRICES_MAP);
    $obCatalog->ImportElements(time(), 0);
    $obCatalog->ImportProductSets();
    $obCatalog->DeactivateElement($element_action, time(), 0);
    if ($sync) {
        $obCatalog->EndSession();
    }
    if ($return_last_error) {
        if (strlen($obCatalog->LAST_ERROR)) {
            return $obCatalog->LAST_ERROR;
        }
    }
    if ($return_iblock_id) {
        return intval($NS["IBLOCK_ID"]);
    } else {
        return true;
    }
}
 function Export($documentId)
 {
     $work_dir = CTempFile::GetDirectoryName();
     CheckDirPath($work_dir);
     $file = "import";
     $file_name = $work_dir . $file . ".xml";
     $file_dir = $file . "_files/";
     $arcname = $work_dir . $file . '.tar.gz';
     if ($fp = fopen($file_name, "ab")) {
         $documentService = $this->workflow->GetService("DocumentService");
         $document = $documentService->GetDocument($documentId);
         $obExport = new CIBlockCMLExport();
         $step = array();
         $PROPERTY_MAP = array();
         $SECTION_MAP = array();
         if ($obExport->Init($fp, $document["IBLOCK_ID"], $step, true, $work_dir, $file_dir)) {
             $obExport->StartExport();
             $obExport->StartExportMetadata();
             $obExport->ExportProperties($PROPERTY_MAP);
             $obExport->ExportSections($SECTION_MAP, time(), 0);
             $obExport->EndExportMetadata();
             $obExport->StartExportCatalog(true, true);
             $obExport->ExportElements($PROPERTY_MAP, $SECTION_MAP, time(), 0, 0, array("SHOW_NEW" => "Y", "IBLOCK_ID" => $document["IBLOCK_ID"], "=ID" => $document["ID"]));
             $obExport->EndExportCatalog();
             $obExport->EndExport();
             fclose($fp);
             include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . '/modules/main/classes/general/tar_gz.php';
             $ob = new CArchiver($arcname);
             $res = $ob->Add('"' . $file_name . '"', false, $work_dir);
             if ($res) {
                 $res = $ob->Add('"' . $work_dir . $file_dir . '"', false, $work_dir);
             }
             if ($res) {
                 return $arcname;
             } else {
                 return '';
             }
         } else {
             return '';
         }
     } else {
         return '';
     }
 }
예제 #9
0
    if (!$res) {
        $txt = nl2br($strLog);
    } elseif ($res == 2) {
        $txt = $status;
        $script = "<script>GoToPage(\"" . $this_script_name . "?action=LOAD&edition=" . urlencode($_REQUEST['edition']) . "&url=" . urlencode($url) . "&lang=" . urlencode(LANG) . "&LICENSE_KEY=" . urlencode($_REQUEST["LICENSE_KEY"]) . "&action_next=" . urlencode($_REQUEST["action_next"]) . "&xz=" . rand(0, 32000) . "\");</script>\n";
    } else {
        $txt = $status;
        $script = "<script>GoToPage(\"" . $this_script_name . "?action=UNPACK&by_step=Y&filename=" . urlencode(basename($strRequestedUrl)) . "&lang=" . urlencode(LANG) . "&xz=" . rand(0, 32000) . "\");</script>\n";
    }
    $ar = array('FORM' => $form, 'TITLE' => LoaderGetMessage("LOADER_MENU_LOAD"), 'HEAD' => LoaderGetMessage("LOADER_MENU_LOAD"), 'TEXT' => $txt, 'BOTTOM' => '<input type="button" value="&nbsp;&nbsp;&nbsp;' . LoaderGetMessage("LOADER_BACK") . '&nbsp;&nbsp;&nbsp;" onclick="document.location=\'' . $this_script_name . '?action=LIST&lang=' . LANG . '\'">');
    /*********************************************************************/
} elseif ($strAction == "UNPACK") {
    /*********************************************************************/
    //	$iNumDistrFiles = 8000;
    SetCurrentStatus(LoaderGetMessage("LOADER_UNPACK_ACTION"));
    $oArchiver = new CArchiver($_SERVER["DOCUMENT_ROOT"] . "/" . $_REQUEST["filename"], true);
    $tres = $oArchiver->extractFiles($_SERVER["DOCUMENT_ROOT"]);
    SetCurrentProgress($oArchiver->iCurPos, $oArchiver->iArchSize, False);
    $txt = $status;
    if ($tres) {
        if (!$oArchiver->bFinish) {
            $script = "<script>GoToPage(\"" . $this_script_name . "?action=UNPACK&filename=" . urlencode(basename($oArchiver->_strArchiveName)) . "&by_step=Y&seek=" . $oArchiver->iCurPos . "\");</script>\n";
        } else {
            $res = unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $_REQUEST["filename"]) && unlink(__FILE__);
            @unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $_REQUEST["filename"] . '.log');
            @unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $_REQUEST["filename"] . '.tmp');
            @unlink($_SERVER['DOCUMENT_ROOT'] . '/restore.php');
            $strInstFile = "index.php";
            if (!$res) {
                SetCurrentStatus(LoaderGetMessage("LOADER_UNPACK_DELETE"));
            } elseif (!file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . $strInstFile)) {
예제 #10
0
	if (!is_uploaded_file($_FILES["wizardFile"]["tmp_name"]))
	{
		$strError .= GetMessage("MAIN_WIZARD_LOAD_ERROR_LOAD");
		break;
	}
	elseif(GetFileExtension(strtolower($_FILES["wizardFile"]["name"])) != "gz")
	{
		$strError .= GetMessage("MAIN_WIZARD_TAR_GZ");
		break;
	}

	$wizardPath = $_SERVER["DOCUMENT_ROOT"].CWizardUtil::GetRepositoryPath();

	require_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/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(count($arErrors)>0)
		{
			$strError .= ":<br>";
			foreach ($arErrors as $value)
				$strError .= "[".$value[0]."] ".$value[1]."<br>";
		}
		else
			$strError .= ".<br>";

		break;
예제 #11
0
	if(strlen($DATA_FILE_NAME)<=0)
	{
		if(strlen($tpath)>0 && file_exists($tpath) && is_file($tpath))
			$DATA_FILE_NAME = $tpath;
	}

	if(strlen($DATA_FILE_NAME)<=0)
		$strError .= GetMessage("MAIN_T_EDIT_IMP_FILE_NA")."<br>";

	if(strlen($ID)<=0)
		$strError .= GetMessage("MAIN_T_EDIT_IMP_ID_NA")."<br>";

	if(strlen($strError)<=0)
	{
		require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/tar_gz.php");
		$oArchiver = new CArchiver($DATA_FILE_NAME);
		$tres = $oArchiver->extractFiles($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$ID);
		if($tres)
			$strOK .= str_replace("#FILE#", $tpath, GetMessage("MAIN_T_EDIT_IMP_OK"))."<br>";
		else
		{
			$strError .= GetMessage("MAIN_T_EDIT_IMP_ERR");
			$arErrors = &$oArchiver->GetErrors();
			if(count($arErrors)>0)
			{
				$strError .= ":<br>";
				foreach ($arErrors as $value)
					$strError .= "[".$value[0]."] ".$value[1]."<br>";
			}
			else
				$strError .= ".<br>";
예제 #12
0
 public function extractGem($sGemName)
 {
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/tar_gz.php";
     $sArchiveName = $this->getGemArchieveNameForDownload($sGemName);
     if (!is_readable($sArchiveName)) {
         throw new Exception('Gem archieve for ' . $sGemName . ' not found in ' . $sArchiveName);
     }
     $sToFolder = dirname(__FILE__) . '/../../gems/';
     $oArchiver = new CArchiver($sArchiveName);
     $bResult = $oArchiver->extractFiles($sToFolder);
     $arErrors =& $oArchiver->GetErrors();
     $aErrors = array();
     if (count($arErrors) > 0) {
         foreach ($arErrors as $value) {
             $aErrors[] = "[" . $value[0] . "] " . $value[1];
         }
     }
     if (!empty($aErrors)) {
         throw new Exception('Errors during extracting Gem "' . $sGemName . '"! ' . implode(PHP_EOL, $aErrors));
     }
     $this->convertGemCharset(dirname(__FILE__) . '/../../gems/' . $sGemName . '/', $bToSite = true);
     return $sToFolder . $sGemName . '/';
 }
예제 #13
0
		<tr>
			<td colspan="6" class="tableborder1" height="1"></td>
		</tr>
		</table>
	<?
}
elseif($Step == 2)
{
	$arc_name = htmlspecialchars(@$_REQUEST["arc_name"]);
	$max_exec_time = intVal(@$_REQUEST["time"]);
	$pos = intVal(@$_REQUEST["pos"]);
	if ($pos < 0)
		$pos = 0;
	
	$oArc = new CArchiver($_SERVER["DOCUMENT_ROOT"]."/".$arc_name, true, START_EXEC_TIME, $max_exec_time, $pos);

	if(!$oArc->extractFiles($_SERVER["DOCUMENT_ROOT"]."/") && $oArc->end_time)
	{
		$pos = $oArc->getFilePos();
		?>
		
		<input type="hidden" name="time" id="time_id" value="<?php 
echo $max_exec_time;
?>
">
		<input type="hidden" name="pos" id="pos_id" value="<?php 
echo $pos;
?>
">
		<input type="hidden" name="arc_name" id="arc_name_id" value="<?php 
예제 #14
0
}
IncludeModuleLangFile(__FILE__);
$ID = $_REQUEST["ID"];
$ID = str_replace("\\", "", $ID);
$ID = str_replace("/", "", $ID);
$bUseCompression = true;
if (!extension_loaded('zlib') || !function_exists("gzcompress")) {
    $bUseCompression = false;
}
$HTTP_ACCEPT_ENCODING = "";
CheckDirPath($_SERVER['DOCUMENT_ROOT'] . BX_PERSONAL_ROOT . "/tmp/wizards/");
$tempFile = $_SERVER['DOCUMENT_ROOT'] . BX_PERSONAL_ROOT . "/tmp/wizards/" . md5(uniqid(rand(), true) . ".tar.gz");
$wizardPath = $_SERVER["DOCUMENT_ROOT"] . CWizardUtil::GetRepositoryPath() . CWizardUtil::MakeWizardPath($ID);
$strError = "";
if (is_dir($wizardPath)) {
    $oArchiver = new CArchiver($tempFile, $bUseCompression);
    $success = $oArchiver->add("\"" . $wizardPath . "\"", false, $_SERVER["DOCUMENT_ROOT"] . CWizardUtil::GetRepositoryPath());
    if ($success) {
        header('Pragma: public');
        header('Cache-control: private');
        header('Accept-Ranges: bytes');
        header("Content-Length: " . filesize($tempFile));
        header("Content-Type: application/x-force-download; filename=" . str_replace(":", "-", $ID) . ".tar.gz");
        header("Content-Disposition: attachment; filename=\"" . str_replace(":", "-", $ID) . ".tar.gz\"");
        header("Content-Transfer-Encoding: binary");
        readfile($tempFile);
        unlink($tempFile);
    } else {
        $strError .= GetMessage("MAIN_WIZARD_EXPORT_ERROR");
        $arErrors =& $oArchiver->GetErrors();
        if (count($arErrors) > 0) {
예제 #15
0
 if ($arCourse["SCORM"] == "Y") {
     $dir = "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/learning/scorm/" . $COURSE_ID . "/";
     $arc = new CArchiver($_SERVER["DOCUMENT_ROOT"] . $DATA_FILE_NAME, $bUseCompression);
     $res = $arc->Add("\"" . $_SERVER["DOCUMENT_ROOT"] . $dir . "\"", false, $_SERVER["DOCUMENT_ROOT"] . $dir);
     if (!$res) {
         $arErrors =& $arc->GetErrors();
         foreach ($arErrors as $value) {
             $strError .= "[" . $value[0] . "] " . $value[1] . "<br>";
         }
     }
 } else {
     $package = new CCoursePackage($COURSE_ID);
     if (strlen($package->LAST_ERROR) <= 0) {
         $success = $package->CreatePackage($tmp_dir);
         if ($success) {
             $arc = new CArchiver($_SERVER["DOCUMENT_ROOT"] . $DATA_FILE_NAME, $bUseCompression);
             $res = $arc->Add("\"" . $_SERVER['DOCUMENT_ROOT'] . $tmp_dir . "\"", false, $_SERVER['DOCUMENT_ROOT'] . $tmp_dir);
             if (!$res) {
                 $arErrors =& $arc->GetErrors();
                 foreach ($arErrors as $value) {
                     $strError .= "[" . $value[0] . "] " . $value[1] . "<br>";
                 }
             }
             DeleteDirFilesEx($tmp_dir);
         } else {
             $strError .= $package->LAST_ERROR;
         }
     } else {
         $strError .= $package->LAST_ERROR;
     }
 }