dolibarr 24.0.2
dolibarr_export.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2006-2021 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33
45$langs->load("admin");
46
47$action = GETPOST('action', 'aZ09');
48
49$sortfield = GETPOST('sortfield', 'aZ09comma');
50$sortorder = GETPOST('sortorder', 'aZ09comma');
51$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
52if (!$sortorder) {
53 $sortorder = "DESC";
54}
55if (!$sortfield) {
56 $sortfield = "date";
57}
58if (empty($page) || $page == -1) {
59 $page = 0;
60}
61$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
62$offset = $limit * $page;
63
64if (!$user->admin) {
66}
67
68
69/*
70 * Actions
71 */
72
73if ($action == 'deletefile') {
74 if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) {
75 $file = $conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha'));
76 $ret = dol_delete_file($file, 1);
77 if ($ret) {
78 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
79 } else {
80 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
81 }
82 } else {
83 $file = $conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha'));
84 $ret = dol_delete_file($file, 1);
85 if ($ret) {
86 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
87 } else {
88 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
89 }
90 }
91 $action = '';
92}
93
94
95/*
96 * View
97 */
98
99$form = new Form($db);
100$formfile = new FormFile($db);
101
102$label = $db::LABEL;
103$type = $db->type;
104//var_dump($db);
105
106$help_url = 'EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
107llxHeader('', '', $help_url, '', 0, 0, '', '', '', 'mod-admin page-tools_dolibarr_export');
108
109print '<script type="text/javascript">
110jQuery(document).ready(function() {';
111?>
112
113 function hideoptions () {
114 jQuery("#mysql_options").hide();
115 jQuery("#mysql_nobin_options").hide();
116 jQuery("#postgresql_options").hide();
117 }
118
119 hideoptions();
120 jQuery("#radio_dump_mysql").click(function() {
121 hideoptions();
122 jQuery("#mysql_options").show();
123 });
124 jQuery("#radio_dump_mysql_nobin").click(function() {
125 hideoptions();
126 jQuery("#mysql_nobin_options").show();
127 });
128 jQuery("#radio_dump_postgresql").click(function() {
129 hideoptions();
130 jQuery("#postgresql_options").show();
131 });
132 jQuery("#select_sql_compat").click(function() {
133 if (jQuery("#select_sql_compat").val() == 'POSTGRESQL')
134 {
135 jQuery("#checkbox_dump_disable-add-locks").prop('checked',true);
136 }
137 });
138
139<?php
140if (in_array($type, array('mysql', 'mysqli'))) {
141 print 'jQuery("#radio_dump_mysql").click();';
142}
143if (in_array($type, array('pgsql'))) {
144 print 'jQuery("#radio_dump_postgresql").click();';
145}
146print "});\n";
147print "</script>\n";
148
149$title = $langs->trans("Backup");
150
151print load_fiche_titre($title, '', 'title_setup');
152
153print '<div class="center">';
154print $langs->trans("BackupDesc", 3);
155print '</div>';
156print '<br>';
157
158print "<!-- Dump of a server -->\n";
159print '<form method="post" action="'.DOL_URL_ROOT.'/admin/tools/export.php" name="dump" spellcheck="false">';
160print '<input type="hidden" name="token" value="'.newToken().'" />';
161print '<input type="hidden" name="export_type" value="server" />';
162print '<input type="hidden" name="page_y" value="" />';
163
164print '<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>';
165
166print '<span class="opacitymedium">';
167print $langs->trans("BackupDesc3", $dolibarr_main_db_name).'<br>';
168print $langs->trans("BackupDescY").'<br>';
169print '</span>';
170
171print '<br>';
172
173print '<div id="backupdatabaseleft" class="fichehalfleft" >';
174
175$title = $langs->trans("BackupDumpWizard");
176
177print load_fiche_titre($title);
178
179//print '<table class="liste nohover centpercent noborderbottom">';
180//print '<tr class="liste_titre">';
181//print '<td class="liste_titre">';
182print '<span class="opacitymedium">'.$langs->trans("DatabaseName").' : </span><b>'.$dolibarr_main_db_name.'</b><br><br>';
183//print '</td>';
184//print '</tr>';
185//print '<tr class="oddeven nohover"><td class="nohover">';
186
187print '<table class="centpercent noborderbottom">';
188
189print '<tr>';
190print '<td class="tdtop nopaddingleftimp">';
191
192print '<div id="div_container_exportoptions">';
193print '<fieldset id="exportoptions"><legend>'.$langs->trans("ExportMethod").'</legend>';
194if (in_array($type, array('mysql', 'mysqli'))) {
195 print '<div class="formelementrow"><input type="radio" name="what" value="mysql" id="radio_dump_mysql" />';
196 print '<label for="radio_dump_mysql">MySQL Dump (mysqldump)</label>';
197 print '</div>';
198 print '<br>';
199 print '<div class="formelementrow"><input type="radio" name="what" value="mysqlnobin" id="radio_dump_mysql_nobin" />';
200 print '<label for="radio_dump_mysql_nobin">MySQL Dump (php) '.img_warning($langs->trans('BackupPHPWarning')).'</label>';
201 print '</div>';
202} elseif (in_array($type, array('pgsql'))) {
203 print '<div class="formelementrow"><input type="radio" name="what" value="postgresql" id="radio_dump_postgresql" />';
204 print '<label for="radio_dump_postgresql">PostgreSQL Dump (pg_dump)</label>';
205 print '</div>';
206} else {
207 print 'No method available with database '.dol_escape_htmltag($label);
208}
209print '</fieldset>';
210print '</div>';
211
212print '</td>';
213print '</tr>';
214
215print '<tr>';
216print '<td class="tdtop nopaddingleftimp">';
217
218print '<div class="centpercent center margintoponly marginbottomonly">';
219print img_picto('', 'setup', 'class="pictofixedwidth"').'<a class="classlink" id="lnk">'.$langs->trans("ShowAdvancedOptions").'...</a>';
220print '</div>';
221
222print '<script type="text/javascript">
223jQuery(document).ready(function() {
224 jQuery("#lnk").click(function() {
225 console.log("We click on link");
226 hideoptions(this);
227 });
228});
229
230function hideoptions(domelem) {
231 const div = document.getElementById("div_container_sub_exportoptions");
232
233 if (div.style.display === "none") {
234 div.style.display = "block";
235 domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'";
236 } else {
237 div.style.display = "none";
238 domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions")).'...";
239 }
240}
241</script>';
242
243
244print '<div id="div_container_sub_exportoptions" style="display: none;">';
245
246if (in_array($type, array('mysql', 'mysqli'))) {
247 print "<!-- Fieldset mysqldump -->\n";
248 print '<fieldset id="mysql_options">';
249
250 print '<fieldset class="formelementrow"><legend>'.$langs->trans("FullPathToMysqldumpCommand").'</legend>';
251 if (!getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP')) {
252 $fullpathofmysqldump = $db->getPathOfDump();
253 } else {
254 $fullpathofmysqldump = getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP');
255 }
256 print '<input type="text" name="mysqldump" style="width: 80%" value="'.$fullpathofmysqldump.'" spellcheck="false">';
257 print '</fieldset>';
258
259 print '<br>';
260 print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>';
261
262 if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK')) {
263 print '<div class="formelementrow">';
264 print '<input type="checkbox" name="disable_fk" value="yes" id="checkbox_disable_fk" checked>';
265 print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
266 print '</div>';
267 }
268
269 print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
270
271 print '<select name="sql_compat" id="select_sql_compat" class="flat">';
272 print '<option value="NONE" selected>NONE</option>';
273 print '<option value="ANSI">ANSI</option>';
274 print '<option value="DB2">DB2</option>';
275 print '<option value="MAXDB">MAXDB</option>';
276 print '<option value="MYSQL323">MYSQL323</option>';
277 print '<option value="MYSQL40">MYSQL40</option>';
278 print '<option value="MSSQL">MSSQL</option>';
279 print '<option value="ORACLE">ORACLE</option>';
280 print '<option value="POSTGRESQL">POSTGRESQL</option>';
281 print '</select>';
282 print '<br><br>';
283
284 print '<div class="formelementrow">';
285 print '<input type="checkbox" name="use_transaction" value="yes" id="checkbox_use_transaction" checked="checked">';
286 print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
287 print '</div>';
288
289 print '<input type="checkbox" name="use_mysql_quick_param" value="yes" id="checkbox_use_quick" checked="checked" />';
290 print '<label for="checkbox_use_quick">';
291 print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp'));
292 print '</label>';
293 print '<br>';
294
295 print '<input type="checkbox" name="use_force" value="no" id="checkbox_use_force" />';
296 print '<label for="checkbox_use_force">';
297 print $form->textwithpicto($langs->trans('ExportUseForce'), $langs->trans('ExportUseForceHelp'));
298 print '</label>';
299 print '<br>';
300
301 $execmethod = 0;
302 if (getDolGlobalString('MAIN_EXEC_USE_POPEN')) {
303 $execmethod = getDolGlobalString('MAIN_EXEC_USE_POPEN');
304 }
305 if (empty($execmethod)) {
306 $execmethod = 1;
307 }
308 if ($execmethod == 1) {
309 // If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode.
310 print '<input type="checkbox" name="lowmemorydump" value="1" id="lowmemorydump"'.((GETPOSTISSET('lowmemorydump') ? GETPOSTINT('lowmemorydump') : getDolGlobalInt('MAIN_LOW_MEMORY_DUMP')) ? ' checked="checked"' : '').'" />';
311 print '<label for="lowmemorydump">';
312 print $form->textwithpicto($langs->trans('ExportUseLowMemoryMode'), $langs->trans('ExportUseLowMemoryModeHelp'));
313 print '</label>';
314 print '<br>';
315 }
316
317 print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
318 print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
319 print '-->';
320 print '</fieldset>';
321
322 print '<br>';
323 print '<fieldset>';
324 print '<legend>';
325 print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
326 print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
327 print '</legend>';
328
329 print '<input type="checkbox" name="drop"'.((!GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
330 print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
331 print '<br>';
332 print '</fieldset>';
333
334 print '<br>';
335 print '<fieldset>';
336 print '<legend>';
337 print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
338 print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
339 print '</legend>';
340 print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
341 print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
342 print '<br>';
343
344 print '<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" checked />';
345 print '<label for="checkbox_dump_extended_ins">'.$langs->trans("ExtendedInsert").'</label>';
346 print '<br>';
347
348 print '<input type="checkbox" name="disable-add-locks" value="no" id="checkbox_dump_disable-add-locks" />';
349 print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
350 print '<br>';
351
352 print '<input type="checkbox" name="delayed" value="yes" id="checkbox_dump_delayed" />';
353 print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
354 print '<br>';
355
356 print '<input type="checkbox" name="sql_ignore" value="yes" id="checkbox_dump_ignore" />';
357 print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
358 print '<br>';
359
360 print '<input type="checkbox" name="hexforbinary" value="yes" id="checkbox_hexforbinary" checked />';
361 print '<label for="checkbox_hexforbinary">'.$langs->trans("EncodeBinariesInHexa").'</label>';
362 print '<br>';
363
364 print '<input type="checkbox" name="charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
365 print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
366 print '<br>';
367
368 print '</fieldset>';
369 print '</fieldset>';
370
371 // Export mysql bin
372 print "<!-- Fieldset mysql_nobin -->\n";
373 print '<fieldset id="mysql_nobin_options">';
374
375 print '<fieldset>';
376 print '<legend>'.$langs->trans("ExportOptions").'</legend>';
377
378 print '<div class="formelementrow">';
379 print '<input type="checkbox" name="nobin_use_transaction" value="yes" id="checkbox_use_transaction" />';
380 print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
381 print '</div>';
382
383 if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK')) {
384 print '<div class="formelementrow">';
385 print '<input type="checkbox" name="nobin_disable_fk" value="yes" id="checkbox_disable_fk" checked />';
386 print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
387 print '</div>';
388 }
389 print '</fieldset>';
390
391 print '<br>';
392 print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
393 print '<input type="checkbox" name="nobin_drop"'.((!GETPOSTISSET("nobin_drop") || GETPOST('nobin_drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
394 print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
395 print '<br>';
396 print '</fieldset>';
397
398 print '<br>';
399 print '<fieldset>';
400 print '<legend>'.$langs->trans("Datas").'</legend>';
401
402 print '<input type="checkbox" name="nobin_nolocks" value="no" id="checkbox_dump_disable-add-locks" />';
403 print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
404 print '<br>';
405
406 print '<input type="checkbox" name="nobin_delayed" value="yes" id="checkbox_dump_delayed" />';
407 print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
408 print '<br>';
409
410 print '<input type="checkbox" name="nobin_sql_ignore" value="yes" id="checkbox_dump_ignore" />';
411 print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
412 print '<br>';
413
414 print '<input type="checkbox" name="nobin_charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
415 print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
416 print '<br>';
417
418 print '</fieldset>';
419 print '</fieldset>';
420}
421
422if (in_array($type, array('pgsql'))) {
423 print "<!-- Fieldset pg_dump -->\n";
424 print '<fieldset id="postgresql_options">';
425
426
427 print '<fieldset class="formelementrow"><legend>'.$langs->trans("FullPathToPostgreSQLdumpCommand").'</legend>';
428 if (!getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP')) {
429 $fullpathofpgdump = $db->getPathOfDump();
430 } else {
431 $fullpathofpgdump = getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP');
432 }
433 print '<br>';
434 print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" />';
435 print '</fieldset>';
436
437 print '<br>';
438 print '<fieldset>';
439 print '<legend>'.$langs->trans("ExportOptions").'</legend>';
440 print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
441 print '<select name="sql_compat" id="select_sql_compat" class="flat">';
442 print '<option value="POSTGRESQL" selected>POSTGRESQL</option>';
443 print '<option value="ANSI">ANSI</option>';
444 print '</select>';
445 print '<br>';
446 print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
447 print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
448 print '-->';
449 print '</fieldset>';
450 print '<br>';
451 print '<fieldset>';
452 print '<legend>';
453 print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
454 print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
455 print '</legend>';
456 print '</fieldset>';
457 print '<br>';
458 print '<fieldset>';
459 print '<legend>';
460 print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
461 print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
462 print '</legend>';
463 print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
464 print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
465 print '<br>';
466 print '</fieldset>';
467 print '</fieldset>';
468}
469print '</div>';
470
471print '</td>';
472print '</tr>';
473print '</table>';
474
475
476
477
478print '<!--<fieldset>';
479print '<legend>'.$langs->trans("Destination").'</legend> -->';
480print '<br>';
481print '<label for="filename_template" class="line-height-large opacitymedium">'.$langs->trans("FileNameToGenerate").'</label>';
482print '<br>';
483$prefix = 'dump';
484$ext = '.sql';
485if (in_array($type, array('mysql', 'mysqli'))) {
486 $prefix = 'mysqldump';
487 $ext = 'sql';
488}
489//if ($label == 'PostgreSQL') {
490// $prefix='pg_dump';
491// $ext='dump';
492//}
493if (in_array($type, array('pgsql'))) {
494 $prefix = 'pg_dump';
495 $ext = 'sql';
496}
497$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext;
498print '<input type="text" name="filename_template" style="width: 90%" id="filename_template" value="'.$file.'" />';
499print '<br>';
500print '<br>';
501
502// Define compressions array
503$compression = array();
504if (in_array($type, array('mysql', 'mysqli'))) {
505 $compression['gz'] = array(
506 'function' => 'gzopen',
507 'id' => 'radio_compression_gzip',
508 'label' => $langs->trans("Gzip")
509 );
510 // Not open source format. Must implement dol_compress function
511 // $compression['zip']= array(
512 // 'function' => 'dol_compress',
513 // 'id' => 'radio_compression_zip',
514 // 'label' => $langs->trans("FormatZip")
515 // );
516 $compression['bz'] = array(
517 'function' => 'bzopen',
518 'id' => 'radio_compression_bzip',
519 'label' => $langs->trans("Bzip2")
520 );
521 $compression['zstd'] = array(
522 'function' => 'zstd_compress',
523 'id' => 'radio_compression_zstd',
524 'label' => $langs->trans("Zstd")
525 );
526 $compression['none'] = array(
527 'function' => '',
528 'id' => 'radio_compression_none',
529 'label' => $langs->trans("None")
530 );
531} else {
532 $compression['none'] = array(
533 'function' => '',
534 'id' => 'radio_compression_none',
535 'label' => $langs->trans("None")
536 );
537 $compression['gz'] = array(
538 'function' => 'gzopen',
539 'id' => 'radio_compression_gzip',
540 'label' => $langs->trans("Gzip")
541 );
542}
543
544// Show compression choices
545print '<div class="formelementrow">';
546print "\n";
547
548print $langs->trans("Compression").': &nbsp; ';
549
550$i = 0;
551foreach ($compression as $key => $val) {
552 if (!$val['function'] || function_exists($val['function'])) {
553 // Enabled export format
554 $checked = '';
555 if ($key == 'gz') {
556 $checked = ' checked';
557 }
558 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
559 print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
560 } else {
561 // Disabled export format
562 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'" disabled>';
563 print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
564 print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
565 }
566 print ' &nbsp; &nbsp; ';
567 $i++;
568}
569
570print '</div>';
571print "\n";
572
573print "<!--</fieldset>--> <!-- End destination -->\n";
574
575print '<br>';
576print '<div class="center">';
577print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo">';
578print '<br>';
579print '<br>';
580
581if (!empty($_SESSION["commandbackuplastdone"])) {
582 print '<br><b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n";
583 print '<textarea rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuplastdone"].'</textarea><br>'."\n";
584 print '<br>';
585
586 //print $paramclear;
587
588 // Now show result
589 print '<b>'.$langs->trans("BackupResult").':</b> ';
590 print $_SESSION["commandbackupresult"];
591
592 $_SESSION["commandbackuplastdone"] = '';
593 $_SESSION["commandbackuptorun"] = '';
594 $_SESSION["commandbackupresult"] = '';
595}
596if (!empty($_SESSION["commandbackuptorun"])) {
597 print '<br><span class="warning">'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser", $dolibarr_main_db_user, $dolibarr_main_db_user).':</span><br>'."\n";
598 print '<textarea id="commandbackuptoruntext" rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuptorun"].'</textarea><br>'."\n";
599 print ajax_autoselect("commandbackuptoruntext", '');
600 print '<br>';
601
602 //print $paramclear;
603
604 $_SESSION["commandbackuplastdone"] = '';
605 $_SESSION["commandbackuptorun"] = '';
606 $_SESSION["commandbackupresult"] = '';
607}
608
609print "</div> <!-- end div center button -->\n";
610
611//print '</td></tr>';
612//print '</table>';
613
614print "</div> <!-- end div fichehalfleft -->\n";
615
616
617print '<div id="backupdatabaseright" class="fichehalfright">';
618
619$filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
620$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 3, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow: auto;"');
621print '<br>';
622
623print '</div>';
624print '</form>';
625print '</fieldset>';
626
627
628$title = $langs->trans("BackupZipWizard");
629
630print "<br>\n";
631print "<!-- Dump of a server -->\n";
632
633print '<form method="post" action="'.DOL_URL_ROOT.'/admin/tools/export_files.php" name="dump" spellcheck="false">';
634print '<input type="hidden" name="token" value="'.newToken().'" />';
635print '<input type="hidden" name="export_type" value="server" />';
636print '<input type="hidden" name="page_y" value="" />';
637
638print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">2</legend>';
639
640print '<span class="opacitymedium">';
641print $langs->trans("BackupDesc2", DOL_DATA_ROOT).'<br>';
642print $langs->trans("BackupDescX").'<br><br>';
643print '</span>';
644
645print '<div id="backupfilesleft" class="fichehalfleft">';
646
647print load_fiche_titre($title);
648
649print '<label for="zipfilename_template" class="line-height-large paddingbottom opacitymedium">'.$langs->trans("FileNameToGenerate").'</label><br>';
650$prefix = 'documents';
651$ext = 'zip';
652$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser');
653print '<input type="text" name="zipfilename_template" style="width: 90%" id="zipfilename_template" value="'.$file.'" /> <br>';
654print '<br>';
655
656
657// Show compression choices
658// Example: With gz choice, you can compress in 5mn, a file of 2GB directory (after compression) with 10 Mb memory.
659print '<div class="formelementrow">';
660print "\n";
661
662print $langs->trans("Compression").': &nbsp; ';
663$filecompression = $compression;
664unset($filecompression['none']);
665$filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip"));
666
667// The gz, bz and zstd formats are built by export_files.php with OS commands (tar then a compressor). When
668// $dolibarr_main_restrict_os_commands is set (default since 24.0.1), Utils::executeCLI() refuses any command not in
669// the list, so a format whose commands are not allowed must not be offered.
670$oscommandsforformat = array('gz' => array('tar', 'gzip'), 'bz' => array('tar', 'bzip2'), 'zstd' => array('tar', 'zstd'));
671$arrayofallowedcommand = array();
672if (!empty($dolibarr_main_restrict_os_commands)) {
673 $arrayofallowedcommand = array_map('trim', explode(',', $dolibarr_main_restrict_os_commands));
674}
675$disabledbyrestriction = array();
676foreach ($oscommandsforformat as $key => $commands) {
677 if (!empty($arrayofallowedcommand) && array_diff($commands, $arrayofallowedcommand)) {
678 $disabledbyrestriction[$key] = implode(', ', array_diff($commands, $arrayofallowedcommand));
679 }
680}
681$defaultcompression = empty($disabledbyrestriction['gz']) ? 'gz' : 'zip';
682
683$i = 0;
684foreach ($filecompression as $key => $val) {
685 if ((!$val['function'] || function_exists($val['function'])) && empty($disabledbyrestriction[$key])) { // Enabled export format
686 $checked = '';
687 if ($key == $defaultcompression) {
688 $checked = ' checked';
689 }
690 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'2"'.$checked.'>';
691 print ' <label for="'.$val['id'].'2">'.$val['label'].'</label>';
692 } else { // Disabled export format
693 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'2" disabled>';
694 print ' <label for="'.$val['id'].'2">'.$val['label'].'</label>';
695 if (!empty($disabledbyrestriction[$key])) {
696 print ' <span class="opacitymedium">('.$langs->trans("NotAvailableCommandNotAllowed", $disabledbyrestriction[$key]).')</span>';
697 } else {
698 print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
699 }
700 }
701 print ' &nbsp; &nbsp; ';
702 $i++;
703}
704if (!empty($disabledbyrestriction)) {
705 print '<br><span class="opacitymedium small">'.$langs->trans("RestrictOsCommandsHelp", 'dolibarr_main_restrict_os_commands').'</span>';
706}
707
708print '</div>';
709print "\n";
710
711print '<br>';
712print '<div class="center">';
713print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo" /><br>';
714print '<br>';
715print '</div>';
716
717print '</div>';
718
719print '<div id="backupfileright" class="fichehalfright">';
720
721$filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
722$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 3, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow: auto;"');
723print '<br>';
724
725print '</div>';
726
727print '</fieldset>';
728print '</form>';
729
730print '<br>';
731
732
733print "<br>\n";
734print "<!-- Save setup conf -->\n";
735
736print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">3</legend>';
737
738print '<br>';
739
740print '<span class="opacitymedium">';
741print $langs->trans("BackupDesc4", 'dolibarr_main_dolcrypt_key '.$langs->transnoentitiesnoconv("or").' dolibarr_main_instance_unique_id').'<br>';
742print '</span>';
743
744print '<br>';
745
746print '<div id="backupfileright">';
747
748print $langs->trans("SeeValueIntoConfPhp").'<br>';
749print $langs->trans("SeeValueIntoConfPhp2");
750print '<br>';
751
752print '<br>';
753
754print '</div>';
755
756print '</fieldset>';
757
758print '<br><br>';
759
760// End of page
761llxFooter();
762$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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.
Definition wrapper.php:73
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:64
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_info($titlealt='default')
Show info logo.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.