} $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'); header("Content-Type: application/force-download; name=\"" . $ID . ".tar.gz\"");
$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'); header("Content-Type: application/force-download; name=\"" . $ID . ".tar.gz\"");
clearstatcache(); } if (file_exists($tpath)) $strError .= str_replace("#FILE#", $tpath, GetMessage("MAIN_T_EDIT_FILE_EX"))."<br>"; } if (strlen($strError)<=0) { $bUseCompression = True; if (!extension_loaded('zlib') || !function_exists("gzcompress")) $bUseCompression = False; require_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/classes/general/tar_gz.php"); $oArchiver = new CArchiver($tpath, $bUseCompression); $tres = $oArchiver->add("\"".$_SERVER["DOCUMENT_ROOT"].$templFields["PATH"]."\"", false, $_SERVER["DOCUMENT_ROOT"].$templFields["PATH"]); if ($tres) { $strOK .= str_replace("#FILE#", $tpath, GetMessage("MAIN_T_EDIT_EXPORT_OK")); if (substr($tpath, 0, strlen($_SERVER["DOCUMENT_ROOT"]))==$_SERVER["DOCUMENT_ROOT"]) $strOK .= str_replace("#ADDR#", substr($tpath, strlen($_SERVER["DOCUMENT_ROOT"])), " ".GetMessage("MAIN_T_EDIT_EXPORT_AND_EXISTS")); $strOK .= ".<br>"; } else { $strError .= GetMessage("MAIN_T_EDIT_EXPORT_ERR"); $arErrors = &$oArchiver->GetErrors(); if (count($arErrors)>0) { $strError .= ":<br>"; foreach ($arErrors as $value)
public function archiveGem($sGemName) { if (!($oGem = $this->getGemInstance($sGemName))) { throw new Exception('Gem ' . $sGemName . ' not found!'); } require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/tar_gz.php"; $sArchiveName = $this->getGemArchieveNameForUpload($sGemName); if (file_exists($sArchiveName)) { if (!unlink($sArchiveName)) { throw new Exception("Can't remove previous version of file " . $sArchiveName); } } $sGemFolder = $oGem->getGemFolder(); $oArchiver = new CArchiver($sArchiveName, true); $this->convertGemCharset($sGemFolder, false); $bResult = $oArchiver->add($sGemFolder, $sGemName, $sGemFolder); $this->convertGemCharset($sGemFolder, true); $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 archiving Gem "' . $sGemName . '"! ' . implode(PHP_EOL, $aErrors)); } return $sArchiveName; }
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) { $strError .= ":<br>";