forked from Wavyzz/dolibarr
Prepare code to zip a module
This commit is contained in:
@@ -145,6 +145,8 @@ print "<!-- Dump of a server -->\n";
|
|||||||
print '<form method="post" action="export.php" name="dump">';
|
print '<form method="post" action="export.php" name="dump">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'" />';
|
print '<input type="hidden" name="token" value="'.newToken().'" />';
|
||||||
print '<input type="hidden" name="export_type" value="server" />';
|
print '<input type="hidden" name="export_type" value="server" />';
|
||||||
|
print '<input type="hidden" name="page_y" value="" />';
|
||||||
|
|
||||||
print '<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>';
|
print '<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>';
|
||||||
|
|
||||||
print '<span class="opacitymedium">';
|
print '<span class="opacitymedium">';
|
||||||
@@ -498,7 +500,6 @@ print "<!--</fieldset>--> <!-- End destination -->\n";
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
print '<div class="center">';
|
print '<div class="center">';
|
||||||
print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo">';
|
print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo">';
|
||||||
print '<input type="hidden" name="page_y" value="'.GETPOST('page_y', 'int').'">';
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|||||||
@@ -216,8 +216,7 @@ if ($errormsg) {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
// Redirect to backup page
|
// Redirect to backup page
|
||||||
header("Location: dolibarr_export.php".(GETPOST('page_y', 'int') ? '?page_y='.GETPOST('page_y', 'int') : ''));
|
header("Location: dolibarr_export.php".(GETPOST('page_y', 'int') ? '?page_y='.GETPOST('page_y', 'int') : ''));
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|||||||
@@ -127,10 +127,18 @@ $result = dol_mkdir($outputdir);
|
|||||||
|
|
||||||
$utils = new Utils($db);
|
$utils = new Utils($db);
|
||||||
|
|
||||||
|
if ($export_type == 'externalmodule' && ! empty($what)) {
|
||||||
|
$fulldirtocompress = DOL_DOCUMENT_ROOT.'/custom/'.dol_sanitizeFileName($what);
|
||||||
|
} else {
|
||||||
|
$fulldirtocompress = DOL_DATA_ROOT;
|
||||||
|
}
|
||||||
|
$dirtoswitch = dirname($fulldirtocompress);
|
||||||
|
$dirtocompress = basename($fulldirtocompress);
|
||||||
|
|
||||||
if ($compression == 'zip') {
|
if ($compression == 'zip') {
|
||||||
$file .= '.zip';
|
$file .= '.zip';
|
||||||
$excludefiles = '/(\.back|\.old|\.log|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
|
$excludefiles = '/(\.back|\.old|\.log|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
|
||||||
$ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, $excludefiles);
|
$ret = dol_compress_dir($fulldirtocompress, $outputdir."/".$file, $compression, $excludefiles);
|
||||||
if ($ret < 0) {
|
if ($ret < 0) {
|
||||||
if ($ret == -2) {
|
if ($ret == -2) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
@@ -147,7 +155,7 @@ if ($compression == 'zip') {
|
|||||||
|
|
||||||
$file .= '.tar';
|
$file .= '.tar';
|
||||||
// We also exclude '/temp/' dir and 'documents/admin/documents'
|
// We also exclude '/temp/' dir and 'documents/admin/documents'
|
||||||
$cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT);
|
$cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dol_sanitizePathName($dirtoswitch)." ".dol_sanitizeFileName($dirtocompress);
|
||||||
|
|
||||||
$result = $utils->executeCLI($cmd, $outputfile);
|
$result = $utils->executeCLI($cmd, $outputfile);
|
||||||
|
|
||||||
@@ -177,11 +185,13 @@ if ($compression == 'zip') {
|
|||||||
|
|
||||||
if ($errormsg) {
|
if ($errormsg) {
|
||||||
setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors');
|
setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors');
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.<br>'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
// Redirect to calling page
|
// Redirect to calling page
|
||||||
$returnto = 'dolibarr_export.php';
|
$returnto = 'dolibarr_export.php';
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
header("Location: ".$returnto);
|
header("Location: ".$returnto);
|
||||||
|
|||||||
Reference in New Issue
Block a user