29require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48$action =
GETPOST(
'action',
'aZ09');
50$allow_download_app =
GETPOSTINT(
'allow_download_app');
53$allowdownloadapp = ($allow_download_app && !empty($dolibarr_allow_download_app));
55$paramallowdownloadapp = ($allowdownloadapp ?
'&allow_download_app=1' :
'');
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66if (empty($page) || $page == -1) {
70$offset = $limit * $page;
81if ($action ==
'deletefile') {
82 if (preg_match(
'/^backup\//',
GETPOST(
'urlfile',
'alpha'))) {
83 $file =
$conf->admin->dir_output.
'/backup/'.basename(
GETPOST(
'urlfile',
'alpha'));
86 setEventMessages($langs->trans(
"FileWasRemoved",
GETPOST(
'urlfile')),
null,
'mesgs');
88 setEventMessages($langs->trans(
"ErrorFailToDeleteFile",
GETPOST(
'urlfile')),
null,
'errors');
90 } elseif (preg_match(
'/^backupapp\//',
GETPOST(
'urlfile',
'alpha'))) {
91 $file =
$conf->admin->dir_output.
'/backupapp/'.basename(
GETPOST(
'urlfile',
'alpha'));
94 setEventMessages($langs->trans(
"FileWasRemoved",
GETPOST(
'urlfile')),
null,
'mesgs');
96 setEventMessages($langs->trans(
"ErrorFailToDeleteFile",
GETPOST(
'urlfile')),
null,
'errors');
99 $file =
$conf->admin->dir_output.
'/documents/'.basename(
GETPOST(
'urlfile',
'alpha'));
102 setEventMessages($langs->trans(
"FileWasRemoved",
GETPOST(
'urlfile')),
null,
'mesgs');
104 setEventMessages($langs->trans(
"ErrorFailToDeleteFile",
GETPOST(
'urlfile')),
null,
'errors');
115$form =
new Form($db);
122$help_url =
'EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
123llxHeader(
'',
'', $help_url,
'', 0, 0,
'',
'',
'',
'mod-admin page-tools_dolibarr_export');
125print
'<script type="text/javascript">
126jQuery(document).ready(function() {';
129 function hideoptions () {
130 jQuery(
"#mysql_options").hide();
131 jQuery(
"#mysql_nobin_options").hide();
132 jQuery(
"#postgresql_options").hide();
136 jQuery(
"#radio_dump_mysql").click(
function() {
138 jQuery(
"#mysql_options").show();
140 jQuery(
"#radio_dump_mysql_nobin").click(
function() {
142 jQuery(
"#mysql_nobin_options").show();
144 jQuery(
"#radio_dump_postgresql").click(
function() {
146 jQuery(
"#postgresql_options").show();
148 jQuery(
"#select_sql_compat").click(
function() {
149 if (jQuery(
"#select_sql_compat").val() ==
'POSTGRESQL')
151 jQuery(
"#checkbox_dump_disable-add-locks").prop(
'checked',
true);
156if (in_array($type, array(
'mysql',
'mysqli'))) {
157 print
'jQuery("#radio_dump_mysql").click();';
159if (in_array($type, array(
'pgsql'))) {
160 print
'jQuery("#radio_dump_postgresql").click();';
165$title = $langs->trans(
"Backup");
169print
'<div class="center">';
170print $langs->trans(
"BackupDesc", $allowdownloadapp ? 4 : 3);
174print
"<!-- Dump of a server -->\n";
175print
'<form method="post" action="'.DOL_URL_ROOT.
'/admin/tools/export.php" name="dump" spellcheck="false">';
176print
'<input type="hidden" name="token" value="'.newToken().
'" />';
177print
'<input type="hidden" name="export_type" value="server" />';
178print
'<input type="hidden" name="page_y" value="" />';
179if ($allowdownloadapp) {
180 print
'<input type="hidden" name="allow_download_app" value="1" />';
183print
'<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>';
185print
'<div class="info">';
186print $langs->trans(
"BackupDesc3", $dolibarr_main_db_name).
'<br>';
187print $langs->trans(
"BackupDescY");
192print
'<div id="backupdatabaseleft" class="fichehalfleft" >';
194$title = $langs->trans(
"BackupDumpWizard");
205print
'<table class="centpercent noborderbottom">';
208print
'<td class="tdtop nopaddingleftimp">';
210print
'<div id="div_container_exportoptions">';
211print
'<fieldset id="exportoptions"><legend>'.$langs->trans(
"ExportMethod").
'</legend>';
212if (in_array($type, array(
'mysql',
'mysqli'))) {
213 print
'<div class="formelementrow"><input type="radio" name="what" value="mysql" id="radio_dump_mysql" />';
214 print
'<label for="radio_dump_mysql">MySQL Dump (mysqldump)</label>';
217 print
'<div class="formelementrow"><input type="radio" name="what" value="mysqlnobin" id="radio_dump_mysql_nobin" />';
218 print
'<label for="radio_dump_mysql_nobin">MySQL Dump (php) '.img_warning($langs->trans(
'BackupPHPWarning')).
'</label>';
220} elseif (in_array($type, array(
'pgsql'))) {
221 print
'<div class="formelementrow"><input type="radio" name="what" value="postgresql" id="radio_dump_postgresql" />';
222 print
'<label for="radio_dump_postgresql">PostgreSQL Dump (pg_dump)</label>';
225 print
'No method available with database '.dol_escape_htmltag($label);
234print
'<td class="tdtop nopaddingleftimp">';
236print
'<div class="centpercent center margintoponly marginbottomonly">';
237print img_picto(
'',
'setup',
'class="pictofixedwidth"').
'<a class="classlink cursorpointer" id="lnk">'.$langs->trans(
"ShowAdvancedOptions").
'...</a>';
240print
'<script type="text/javascript">
241jQuery(document).ready(function() {
242 jQuery("#lnk").click(function() {
243 console.log("We click on link");
248function hideoptions(domelem) {
249 const div = document.getElementById("div_container_sub_exportoptions");
251 if (div.style.display === "none") {
252 div.style.display = "block";
253 domelem.innerText=\''.dol_escape_js($langs->transnoentitiesnoconv(
"HideAdvancedoptions")).
'\';
255 div.style.display =
"none";
256 domelem.innerText=\
''.dol_escape_js($langs->transnoentitiesnoconv(
"ShowAdvancedOptions").
'...').
'\';
262print '<div
id=
"div_container_sub_exportoptions" style=
"display: none;">
';
264if (in_array($type, array('mysql
', 'mysqli
'))) {
265 print "<!-- Fieldset mysqldump -->\n";
266 print '<fieldset
id=
"mysql_options">
';
268 print '<fieldset
class=
"formelementrow"><legend>
'.$langs->trans("FullPathToMysqldumpCommand").'</legend>
';
269 if (!getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP
')) {
270 $fullpathofmysqldump = $db->getPathOfDump();
272 $fullpathofmysqldump = getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP
');
274 print '<input
type=
"text" name=
"mysqldump" style=
"width: 80%" value=
"'.$fullpathofmysqldump.'" spellcheck=
"false">
';
278 print '<fieldset><legend>
'.$langs->trans("ExportOptions").'</legend>
';
280 if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK
')) {
281 print '<div
class=
"formelementrow">
';
282 print '<input
type=
"checkbox" name=
"disable_fk" value=
"yes" id=
"checkbox_disable_fk" checked>
';
283 print '<label
for=
"checkbox_disable_fk">
'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning
')).'</label>
';
287 print '<label
for=
"select_sql_compat">
'.$langs->trans("ExportCompatibility").'</label>
';
289 print '<select
name=
"sql_compat" id=
"select_sql_compat" class=
"flat">
';
290 print '<option value=
"NONE" selected>NONE</option>
';
291 print '<option value=
"ANSI">ANSI</option>
';
292 print '<option value=
"DB2">DB2</option>
';
293 print '<option value=
"MAXDB">MAXDB</option>
';
294 print '<option value=
"MYSQL323">MYSQL323</option>
';
295 print '<option value=
"MYSQL40">MYSQL40</option>
';
296 print '<option value=
"MSSQL">MSSQL</option>
';
297 print '<option value=
"ORACLE">ORACLE</option>
';
298 print '<option value=
"POSTGRESQL">POSTGRESQL</option>
';
302 print '<div
class=
"formelementrow">
';
303 print '<input
type=
"checkbox" name=
"use_transaction" value=
"yes" id=
"checkbox_use_transaction" checked=
"checked">
';
304 print '<label
for=
"checkbox_use_transaction">
'.$langs->trans("UseTransactionnalMode").'</label>
';
307 print '<input
type=
"checkbox" name=
"use_mysql_quick_param" value=
"yes" id=
"checkbox_use_quick" checked=
"checked" />
';
308 print '<label
for=
"checkbox_use_quick">
';
309 print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter
'), $langs->trans('ExportUseMySQLQuickParameterHelp
'));
313 print '<input
type=
"checkbox" name=
"use_force" value=
"no" id=
"checkbox_use_force" />
';
314 print '<label
for=
"checkbox_use_force">
';
315 print $form->textwithpicto($langs->trans('ExportUseForce
'), $langs->trans('ExportUseForceHelp
'));
320 if (getDolGlobalString('MAIN_EXEC_USE_POPEN
')) {
321 $execmethod = getDolGlobalString('MAIN_EXEC_USE_POPEN
');
323 if (empty($execmethod)) {
326 if ($execmethod == 1) {
327 // If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode.
328 print '<input
type=
"checkbox" name=
"lowmemorydump" value=
"1" id=
"lowmemorydump"'.((GETPOSTISSET('lowmemorydump
') ? GETPOSTINT('lowmemorydump
') : getDolGlobalInt('MAIN_LOW_MEMORY_DUMP
')) ? ' checked=
"checked"' : '').'" />';
329 print '<label for="lowmemorydump
">';
330 print $form->textwithpicto($langs->trans('ExportUseLowMemoryMode'), $langs->trans('ExportUseLowMemoryModeHelp'));
335 print '<!-- <input type="checkbox
" name="drop_database
" value="yes
" id="checkbox_drop_database
" />';
336 print '<label for="checkbox_drop_database
">'.$langs->trans("AddDropDatabase
").'</label>';
343 print '<input type="checkbox
" name="sql_structure
" value="structure
" id="checkbox_sql_structure
" checked />';
344 print '<label for="checkbox_sql_structure
">'.$langs->trans('ExportStructure').'</label>';
347 print '<input type="checkbox
" name="drop
"'.((!GETPOSTISSET("drop
") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop
" />';
348 print '<label for="checkbox_dump_drop
">'.$langs->trans("AddDropTable
").'</label>';
355 print '<input type="checkbox
" name="sql_data
" value="data
" id="checkbox_sql_data
" checked />';
356 print '<label for="checkbox_sql_data
">'.$langs->trans("Datas
").'</label>';
358 print '<input type="checkbox
" name="showcolumns
" value="yes
" id="checkbox_dump_showcolumns
" checked />';
359 print '<label for="checkbox_dump_showcolumns
">'.$langs->trans("NameColumn
").'</label>';
362 print '<input type="checkbox
" name="extended_ins
" value="yes
" id="checkbox_dump_extended_ins
" checked />';
363 print '<label for="checkbox_dump_extended_ins
">'.$langs->trans("ExtendedInsert
").'</label>';
366 print '<input type="checkbox
" name="disable-add-locks
" value="no
" id="checkbox_dump_disable-add-locks
" />';
367 print '<label for="checkbox_dump_disable-add-locks
">'.$langs->trans("NoLockBeforeInsert
").'</label>';
370 print '<input type="checkbox
" name="delayed
" value="yes
" id="checkbox_dump_delayed
" />';
371 print '<label for="checkbox_dump_delayed
">'.$langs->trans("DelayedInsert
").'</label>';
374 print '<input type="checkbox
" name="sql_ignore
" value="yes
" id="checkbox_dump_ignore
" />';
375 print '<label for="checkbox_dump_ignore
">'.$langs->trans("IgnoreDuplicateRecords
").'</label>';
378 print '<input type="checkbox
" name="hexforbinary
" value="yes
" id="checkbox_hexforbinary
" checked />';
379 print '<label for="checkbox_hexforbinary
">'.$langs->trans("EncodeBinariesInHexa
").'</label>';
382 print '<input type="checkbox
" name="charset_utf8
" value="yes
" id="checkbox_charset_utf8
" checked disabled />';
383 print '<label for="checkbox_charset_utf8
">'.$langs->trans("UTF8
").'</label>';
390 print "<!-- Fieldset mysql_nobin -->\n
";
391 print '<fieldset id="mysql_nobin_options
">';
394 print '<legend>'.$langs->trans("ExportOptions
").'</legend>';
396 print '<div class="formelementrow
">';
397 print '<input type="checkbox
" name="nobin_use_transaction
" value="yes
" id="checkbox_use_transaction
" />';
398 print '<label for="checkbox_use_transaction
">'.$langs->trans("UseTransactionnalMode
").'</label>';
401 if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK')) {
402 print '<div class="formelementrow
">';
403 print '<input type="checkbox
" name="nobin_disable_fk
" value="yes
" id="checkbox_disable_fk
" checked />';
404 print '<label for="checkbox_disable_fk
">'.$langs->trans("CommandsToDisableForeignKeysForImport
").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
410 print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
411 print '<input type="checkbox
" name="nobin_drop
"'.((!GETPOSTISSET("nobin_drop
") || GETPOST('nobin_drop')) ? ' checked' : '').' id="checkbox_dump_drop
" />';
412 print '<label for="checkbox_dump_drop
">'.$langs->trans("AddDropTable
").'</label>';
418 print '<legend>'.$langs->trans("Datas
").'</legend>';
420 print '<input type="checkbox
" name="nobin_nolocks
" value="no
" id="checkbox_dump_disable-add-locks
" />';
421 print '<label for="checkbox_dump_disable-add-locks
">'.$langs->trans("NoLockBeforeInsert
").'</label>';
424 print '<input type="checkbox
" name="nobin_delayed
" value="yes
" id="checkbox_dump_delayed
" />';
425 print '<label for="checkbox_dump_delayed
">'.$langs->trans("DelayedInsert
").'</label>';
428 print '<input type="checkbox
" name="nobin_sql_ignore
" value="yes
" id="checkbox_dump_ignore
" />';
429 print '<label for="checkbox_dump_ignore
">'.$langs->trans("IgnoreDuplicateRecords
").'</label>';
432 print '<input type="checkbox
" name="nobin_charset_utf8
" value="yes
" id="checkbox_charset_utf8
" checked disabled />';
433 print '<label for="checkbox_charset_utf8
">'.$langs->trans("UTF8
").'</label>';
440if (in_array($type, array('pgsql'))) {
441 print "<!-- Fieldset pg_dump -->\n
";
442 print '<fieldset id="postgresql_options
">';
445 print '<fieldset class="formelementrow
"><legend>'.$langs->trans("FullPathToPostgreSQLdumpCommand
").'</legend>';
446 if (!getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP')) {
447 $fullpathofpgdump = $db->getPathOfDump();
449 $fullpathofpgdump = getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP');
452 print '<input type="text
" name="postgresqldump
" style="width: 80%
" value="'.$fullpathofpgdump.'" />';
457 print '<legend>'.$langs->trans("ExportOptions
").'</legend>';
458 print '<label for="select_sql_compat
">'.$langs->trans("ExportCompatibility
").'</label>';
459 print '<select name="sql_compat
" id="select_sql_compat
" class="flat
">';
460 print '<option value="POSTGRESQL
" selected>POSTGRESQL</option>';
461 print '<option value="ANSI
">ANSI</option>';
464 print '<!-- <input type="checkbox
" name="drop_database
" value="yes
" id="checkbox_drop_database
" />';
465 print '<label for="checkbox_drop_database
">'.$langs->trans("AddDropDatabase
").'</label>';
471 print '<input type="checkbox
" name="sql_structure
" value="structure
" id="checkbox_sql_structure
" checked />';
472 print '<label for="checkbox_sql_structure
">'.$langs->trans('ExportStructure').'</label>';
478 print '<input type="checkbox
" name="sql_data
" value="data
" id="checkbox_sql_data
" checked />';
479 print '<label for="checkbox_sql_data
">'.$langs->trans("Datas
").'</label>';
481 print '<input type="checkbox
" name="showcolumns
" value="yes
" id="checkbox_dump_showcolumns
" checked />';
482 print '<label for="checkbox_dump_showcolumns
">'.$langs->trans("NameColumn
").'</label>';
496print '<!--<fieldset>';
497print '<legend>'.$langs->trans("Destination
").'</legend> -->';
499print '<label for="filename_template
" class="line-height-large opacitymedium
">'.$langs->trans("FileNameToGenerate
").'</label>';
503if (in_array($type, array('mysql', 'mysqli'))) {
504 $prefix = 'mysqldump';
507//if ($label == 'PostgreSQL') {
511if (in_array($type, array('pgsql'))) {
515$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall
", 'tzuser').'.'.$ext;
516print '<input type="text
" name="filename_template
" style="width: 90%
" id="filename_template
" value="'.$file.'" />';
520// Define compressions array
521$compression = array();
522if (in_array($type, array('mysql', 'mysqli'))) {
523 $compression['gz'] = array(
524 'function' => 'gzopen',
525 'id' => 'radio_compression_gzip',
526 'label' => $langs->trans("Gzip
")
528 // Not open source format. Must implement dol_compress function
529 // $compression['zip']= array(
530 // 'function' => 'dol_compress',
531 // 'id' => 'radio_compression_zip',
532 // 'label' => $langs->trans("FormatZip
")
534 $compression['bz'] = array(
535 'function' => 'bzopen',
536 'id' => 'radio_compression_bzip',
537 'label' => $langs->trans("Bzip2
")
539 $compression['zstd'] = array(
540 'function' => 'zstd_compress',
541 'id' => 'radio_compression_zstd',
542 'label' => $langs->trans("Zstd
")
544 $compression['none'] = array(
546 'id' => 'radio_compression_none',
547 'label' => $langs->trans("None
")
550 $compression['none'] = array(
552 'id' => 'radio_compression_none',
553 'label' => $langs->trans("None
")
555 $compression['gz'] = array(
556 'function' => 'gzopen',
557 'id' => 'radio_compression_gzip',
558 'label' => $langs->trans("Gzip
")
562// Show compression choices
563print '<div class="formelementrow
">';
566print $langs->trans("Compression
").': ';
569foreach ($compression as $key => $val) {
570 if (!$val['function'] || function_exists($val['function'])) {
571 // Enabled export format
574 $checked = ' checked';
576 print '<input type="radio
" name="compression
" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
577 print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
579 // Disabled export format
580 print '<input type="radio
" name="compression
" value="'.$key.'" id="'.$val['id'].'" disabled>';
581 print ' '.$form->textwithpicto('<label class="opacitymedium
" for="'.$val['id'].'">'.$val['label'].'</label>', $langs->trans("NotAvailablePHPModuleNotInstalled
"), 1, 'info', '');
583 print ' ';
590print "<!--</fieldset>--> <!-- End destination -->\n
";
593print '<div class="center
">';
594print '<input type="submit
" class="button reposition
" value="'.$langs->trans("GenerateBackup").'" id="buttonGo
">';
598if (!empty($_SESSION["commandbackuplastdone
"])) {
599 print '<br><b>'.$langs->trans("RunCommandSummary
").':</b><br>'."\n
";
600 print '<textarea rows="'.ROWS_2.'" class="centpercent
">'.$_SESSION["commandbackuplastdone
"].'</textarea><br>'."\n
";
606 print '<b>'.$langs->trans("BackupResult
").':</b> ';
607 print $_SESSION["commandbackupresult
"];
609 $_SESSION["commandbackuplastdone
"] = '';
610 $_SESSION["commandbackuptorun
"] = '';
611 $_SESSION["commandbackupresult
"] = '';
613if (!empty($_SESSION["commandbackuptorun
"])) {
614 print '<br><span class="warning
">'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser
", $dolibarr_main_db_user, $dolibarr_main_db_user).':</span><br>'."\n
";
615 print '<textarea id="commandbackuptoruntext
" rows="'.ROWS_2.'" class="centpercent
">'.$_SESSION["commandbackuptorun
"].'</textarea><br>'."\n
";
616 print ajax_autoselect("commandbackuptoruntext
", '');
621 $_SESSION["commandbackuplastdone
"] = '';
622 $_SESSION["commandbackuptorun
"] = '';
623 $_SESSION["commandbackupresult
"] = '';
626print "</div> <!-- end div center
button -->\n
";
631print "</div> <!-- end div fichehalfleft -->\n
";
634print '<div id="backupdatabaseright
" class="fichehalfright
">';
636$filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
637$result = $formfile->list_of_documents($filearray, null, 'systemtools', $paramallowdownloadapp, 1, 'backup/', 1, 3, $langs->trans("NoBackupFileAvailable
"), 0, $langs->trans("PreviousDumpFiles
"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow:
auto; margin-top: 25px;
"');
645$title = $langs->trans("BackupZipWizard
");
648print "<!-- Dump of a server -->\n
";
650print '<form method="post
" action="'.DOL_URL_ROOT.'/admin/tools/export_files.php
" name="dump
" spellcheck="false">';
651print '<input type="hidden
" name="token
" value="'.newToken().'" />';
652print '<input type="hidden
" name="export_type
" value="server
" />';
653print '<input type="hidden
" name="page_y
" value="" />';
654if ($allowdownloadapp) {
655 print '<input type="hidden
" name="allow_download_app
" value="1
" />';
658print '<fieldset><legend class="legendforfieldsetstep
" style="font-size: 3em
">2</legend>';
660print '<div class="info
">';
661print $langs->trans("BackupDesc2
", DOL_DATA_ROOT).'<br>';
662print $langs->trans("BackupDescX
");
665print '<div id="backupfilesleft
" class="fichehalfleft
">';
667print load_fiche_titre($title);
669print '<label for="zipfilename_template
" class="line-height-large paddingbottom opacitymedium
">'.$langs->trans("FileNameToGenerate
").'</label><br>';
670$prefix = 'documents';
672$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall
", 'tzuser');
673print '<input type="text
" name="zipfilename_template
" style="width: 90%
" id="zipfilename_template
" value="'.$file.'" /> <br>';
677// Show compression choices
678// Example: With gz choice, you can compress in 5mn, a file of 2GB directory (after compression) with 10 Mb memory.
679print '<div class="formelementrow
">';
682print $langs->trans("Compression
").': ';
683$filecompression = $compression;
684unset($filecompression['none']);
685// The gz, bz and zstd archives are built with OS commands, not with PHP functions, so no PHP function is required
686foreach (array('gz', 'bz', 'zstd') as $key) {
687 if (isset($filecompression[$key])) {
688 $filecompression[$key]['function'] = '';
691$filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip
"));
693// The gz, bz and zstd formats are built by export_files.php with OS commands (tar then a compressor). When
694// $dolibarr_main_restrict_os_commands is set (default since 24.0.1), Utils::executeCLI() refuses any command not in
695// the list, so a format whose commands are not allowed must not be offered.
696$oscommandsforformat = array('gz' => array('tar', 'gzip'), 'bz' => array('tar', 'bzip2'), 'zstd' => array('tar', 'zstd'));
697$arrayofallowedcommand = array();
698if (!empty($dolibarr_main_restrict_os_commands)) {
699 $arrayofallowedcommand = array_map('trim', explode(',', $dolibarr_main_restrict_os_commands));
701$disabledbyrestriction = array();
702foreach ($oscommandsforformat as $key => $commands) {
703 if (!empty($arrayofallowedcommand) && array_diff($commands, $arrayofallowedcommand)) {
704 $disabledbyrestriction[$key] = implode(', ', array_diff($commands, $arrayofallowedcommand));
707$defaultcompression = empty($disabledbyrestriction['gz']) ? 'gz' : 'zip';
710foreach ($filecompression as $key => $val) {
711 if ((!$val['function'] || function_exists($val['function'])) && empty($disabledbyrestriction[$key])) { // Enabled export format
713 if ($key == $defaultcompression) {
714 $checked = ' checked';
716 print '<input type="radio
" name="compression
" value="'.$key.'" id="'.$val['id'].'2
"'.$checked.'>';
717 print ' <label for="'.$val['id'].'2
">'.$val['label'].'</label>';
718 } else { // Disabled export format
719 print '<input type="radio
" name="compression
" value="'.$key.'" id="'.$val['id'].'2
" disabled>';
720 if (!empty($disabledbyrestriction[$key])) {
721 $reasonnotavailable = $langs->trans("NotAvailableCommandNotAllowed
", $disabledbyrestriction[$key]);
723 $reasonnotavailable = $langs->trans("NotAvailablePHPModuleNotInstalled
");
725 print ' '.$form->textwithpicto('<label class="opacitymedium
" for="'.$val['id'].'2
">'.$val['label'].'</label>', $reasonnotavailable, 1, 'info', '');
727 print ' ';
730if (!empty($disabledbyrestriction)) {
731 print '<br><span class="opacitymedium small
">'.$langs->trans("RestrictOsCommandsHelp
", 'dolibarr_main_restrict_os_commands').'</span>';
738print '<div class="center
">';
739print '<input type="submit
" class="button reposition
" value="'.$langs->trans("GenerateBackup").'" id="buttonGo
" /><br>';
745print '<div id="backupfileright
" class="fichehalfright
">';
747$filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
748$result = $formfile->list_of_documents($filearray, null, 'systemtools', $paramallowdownloadapp, 1, 'documents/', 1, 3, $langs->trans("NoBackupFileAvailable
"), 0, $langs->trans("PreviousArchiveFiles
"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow:
auto; margin-top: 25px;
"');
759// Step 3 (optional): Export the application files (directory DOL_DOCUMENT_ROOT)
760if ($allowdownloadapp) {
761 print "<!-- Dump of the application directory -->\n
";
764 print '<form method="post
" action="'.DOL_URL_ROOT.'/admin/tools/export_files.php
" name="dumpapp
" spellcheck="false">';
765 print '<input type="hidden
" name="token
" value="'.newToken().'" />';
766 print '<input type="hidden
" name="export_type
" value="app
" />';
767 print '<input type="hidden
" name="page_y
" value="" />';
769 print '<fieldset><legend class="legendforfieldsetstep
" style="font-size: 3em
">3</legend>';
771 print '<div class="info
">';
772 print $langs->trans("BackupDescApp
", DOL_DOCUMENT_ROOT).'<br>';
773 print $langs->trans("BackupDescX
");
776 print '<div id="backupappfilesleft
" class="fichehalfleft
">';
778 $title = $langs->trans("BackupAppZipWizard
");
780 print load_fiche_titre($title);
782 print '<label for="appfilename_template
" class="line-height-large paddingbottom opacitymedium
">'.$langs->trans("FileNameToGenerate
").'</label><br>';
783 $prefix = 'application';
784 $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall
", 'tzuser');
785 print '<input type="text
" name="zipfilename_template
" style="width: 90%
" id="appfilename_template
" value="'.$file.'" /> <br>';
788 // Show compression choices (same choices than for the documents directory)
789 print '<div class="formelementrow
">';
791 print $langs->trans("Compression
").': ';
792 foreach ($filecompression as $key => $val) {
793 if ((empty($val['function']) || function_exists($val['function'])) && empty($disabledbyrestriction[$key])) { // Enabled export format
795 if ($key == $defaultcompression) {
796 $checked = ' checked';
798 print '<input type="radio
" name="compression
" value="'.$key.'" id="'.$val['id'].'3
"'.$checked.'>';
799 print ' <label for="'.$val['id'].'3
">'.$val['label'].'</label>';
800 } else { // Disabled export format
801 print '<input type="radio
" name="compression
" value="'.$key.'" id="'.$val['id'].'3
" disabled>';
802 if (!empty($disabledbyrestriction[$key])) {
803 $reasonnotavailable = $langs->trans("NotAvailableCommandNotAllowed
", $disabledbyrestriction[$key]);
805 $reasonnotavailable = $langs->trans("NotAvailablePHPModuleNotInstalled
");
807 print ' '.$form->textwithpicto('<label class="opacitymedium
" for="'.$val['id'].'3
">'.$val['label'].'</label>', $reasonnotavailable, 1, 'info', '');
809 print ' ';
811 if (!empty($disabledbyrestriction)) {
812 print '<br><span class="opacitymedium small
">'.$langs->trans("RestrictOsCommandsHelp
", 'dolibarr_main_restrict_os_commands').'</span>';
818 print '<div class="center
">';
819 print '<input type="submit
" class="button reposition
" value="'.$langs->trans("GenerateBackup").'" id="buttonGo3
" /><br>';
825 print '<div id="backupappfilesright
" class="fichehalfright
">';
827 $filearray = dol_dir_list($conf->admin->dir_output.'/backupapp', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
828 $result = $formfile->list_of_documents($filearray, null, 'systemtools', $paramallowdownloadapp, 1, 'backupapp/', 1, 3, $langs->trans("NoBackupFileAvailable
"), 0, $langs->trans("PreviousArchiveFiles
"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow:
auto; margin-top: 25px;
"');
835} elseif ($allow_download_app) {
836 // The parameter allow_download_app was provided but the option $dolibarr_allow_download_app
837 // is not set into the conf/conf.php file, so the step to export the application files is not shown.
839 print '<div class="center
"><span class="warning
">'.$langs->trans("DownloadOfAppFileDisallowed
").'</span></div>';
845print "<!-- Save setup
conf -->\n
";
847print '<fieldset><legend class="legendforfieldsetstep
" style="font-size: 3em
">'.($allowdownloadapp ? 4 : 3).'</legend>';
850print '<div class="info
">';
851print $langs->trans("BackupDesc4
", 'dolibarr_main_dolcrypt_key '.$langs->transnoentitiesnoconv("or
").' dolibarr_main_instance_unique_id');
856print '<div id="backupfileright
">';
858print $langs->trans("SeeValueIntoConfPhp
").'<br>';
859print $langs->trans("SeeValueIntoConfPhp2
");
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
conf($dolibarr_main_document_root, $realpathconf=null)
Load conf file (file must exists)
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button