dolibarr 25.0.0-alpha
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';
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';
45
46$langs->load("admin");
47
48$action = GETPOST('action', 'aZ09');
49
50$allow_download_app = GETPOSTINT('allow_download_app');
51// The optional step to export the application files is shown only if the parameter allow_download_app is provided
52// and the option $dolibarr_allow_download_app is set into the conf/conf.php file.
53$allowdownloadapp = ($allow_download_app && !empty($dolibarr_allow_download_app));
54// Parameter to add to the URLs and forms of the page to keep the step to export the application files visible
55$paramallowdownloadapp = ($allowdownloadapp ? '&allow_download_app=1' : '');
56
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$sortorder = GETPOST('sortorder', 'aZ09comma');
59$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
60if (!$sortorder) {
61 $sortorder = "DESC";
62}
63if (!$sortfield) {
64 $sortfield = "date";
65}
66if (empty($page) || $page == -1) {
67 $page = 0;
68}
69$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
70$offset = $limit * $page;
71
72if (!$user->admin) {
74}
75
76
77/*
78 * Actions
79 */
80
81if ($action == 'deletefile') {
82 if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) {
83 $file = $conf->admin->dir_output.'/backup/'.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 } elseif (preg_match('/^backupapp\//', GETPOST('urlfile', 'alpha'))) {
91 $file = $conf->admin->dir_output.'/backupapp/'.basename(GETPOST('urlfile', 'alpha'));
92 $ret = dol_delete_file($file, 1);
93 if ($ret) {
94 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
95 } else {
96 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
97 }
98 } else {
99 $file = $conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha'));
100 $ret = dol_delete_file($file, 1);
101 if ($ret) {
102 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
103 } else {
104 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
105 }
106 }
107 $action = '';
108}
109
110
111/*
112 * View
113 */
114
115$form = new Form($db);
116$formfile = new FormFile($db);
117
118$label = $db::LABEL;
119$type = $db->type;
120//var_dump($db);
121
122$help_url = 'EN:Backups|FR:Sauvegardes|ES:Copias_de_seguridad';
123llxHeader('', '', $help_url, '', 0, 0, '', '', '', 'mod-admin page-tools_dolibarr_export');
124
125print '<script type="text/javascript">
126jQuery(document).ready(function() {';
127?>
128
129 function hideoptions () {
130 jQuery("#mysql_options").hide();
131 jQuery("#mysql_nobin_options").hide();
132 jQuery("#postgresql_options").hide();
133 }
134
135 hideoptions();
136 jQuery("#radio_dump_mysql").click(function() {
137 hideoptions();
138 jQuery("#mysql_options").show();
139 });
140 jQuery("#radio_dump_mysql_nobin").click(function() {
141 hideoptions();
142 jQuery("#mysql_nobin_options").show();
143 });
144 jQuery("#radio_dump_postgresql").click(function() {
145 hideoptions();
146 jQuery("#postgresql_options").show();
147 });
148 jQuery("#select_sql_compat").click(function() {
149 if (jQuery("#select_sql_compat").val() == 'POSTGRESQL')
150 {
151 jQuery("#checkbox_dump_disable-add-locks").prop('checked',true);
152 }
153 });
154
155<?php
156if (in_array($type, array('mysql', 'mysqli'))) {
157 print 'jQuery("#radio_dump_mysql").click();';
158}
159if (in_array($type, array('pgsql'))) {
160 print 'jQuery("#radio_dump_postgresql").click();';
161}
162print "});\n";
163print "</script>\n";
164
165$title = $langs->trans("Backup");
166
167print load_fiche_titre($title, '', 'title_setup');
168
169print '<div class="center">';
170print $langs->trans("BackupDesc", $allowdownloadapp ? 4 : 3);
171print '</div>';
172print '<br>';
173
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" />';
181}
182
183print '<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>';
184
185print '<span class="opacitymedium">';
186print $langs->trans("BackupDesc3", $dolibarr_main_db_name).'<br>';
187print $langs->trans("BackupDescY").'<br>';
188print '</span>';
189
190print '<br>';
191
192print '<div id="backupdatabaseleft" class="fichehalfleft" >';
193
194$title = $langs->trans("BackupDumpWizard");
195
196print load_fiche_titre($title);
197
198//print '<table class="liste nohover centpercent noborderbottom">';
199//print '<tr class="liste_titre">';
200//print '<td class="liste_titre">';
201print '<span class="opacitymedium">'.$langs->trans("DatabaseName").' : </span><b>'.$dolibarr_main_db_name.'</b><br><br>';
202//print '</td>';
203//print '</tr>';
204//print '<tr class="oddeven nohover"><td class="nohover">';
205
206print '<table class="centpercent noborderbottom">';
207
208print '<tr>';
209print '<td class="tdtop nopaddingleftimp">';
210
211print '<div id="div_container_exportoptions">';
212print '<fieldset id="exportoptions"><legend>'.$langs->trans("ExportMethod").'</legend>';
213if (in_array($type, array('mysql', 'mysqli'))) {
214 print '<div class="formelementrow"><input type="radio" name="what" value="mysql" id="radio_dump_mysql" />';
215 print '<label for="radio_dump_mysql">MySQL Dump (mysqldump)</label>';
216 print '</div>';
217 print '<br>';
218 print '<div class="formelementrow"><input type="radio" name="what" value="mysqlnobin" id="radio_dump_mysql_nobin" />';
219 print '<label for="radio_dump_mysql_nobin">MySQL Dump (php) '.img_warning($langs->trans('BackupPHPWarning')).'</label>';
220 print '</div>';
221} elseif (in_array($type, array('pgsql'))) {
222 print '<div class="formelementrow"><input type="radio" name="what" value="postgresql" id="radio_dump_postgresql" />';
223 print '<label for="radio_dump_postgresql">PostgreSQL Dump (pg_dump)</label>';
224 print '</div>';
225} else {
226 print 'No method available with database '.dol_escape_htmltag($label);
227}
228print '</fieldset>';
229print '</div>';
230
231print '</td>';
232print '</tr>';
233
234print '<tr>';
235print '<td class="tdtop nopaddingleftimp">';
236
237print '<div class="centpercent center margintoponly marginbottomonly">';
238print img_picto('', 'setup', 'class="pictofixedwidth"').'<a class="classlink" id="lnk">'.$langs->trans("ShowAdvancedOptions").'...</a>';
239print '</div>';
240
241print '<script type="text/javascript">
242jQuery(document).ready(function() {
243 jQuery("#lnk").click(function() {
244 console.log("We click on link");
245 hideoptions(this);
246 });
247});
248
249function hideoptions(domelem) {
250 const div = document.getElementById("div_container_sub_exportoptions");
251
252 if (div.style.display === "none") {
253 div.style.display = "block";
254 domelem.innerText=\''.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'\';
255 } else {
256 div.style.display = "none";
257 domelem.innerText=\''.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions").'...').'\';
258 }
259}
260</script>';
261
262
263print '<div id="div_container_sub_exportoptions" style="display: none;">';
264
265if (in_array($type, array('mysql', 'mysqli'))) {
266 print "<!-- Fieldset mysqldump -->\n";
267 print '<fieldset id="mysql_options">';
268
269 print '<fieldset class="formelementrow"><legend>'.$langs->trans("FullPathToMysqldumpCommand").'</legend>';
270 if (!getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP')) {
271 $fullpathofmysqldump = $db->getPathOfDump();
272 } else {
273 $fullpathofmysqldump = getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP');
274 }
275 print '<input type="text" name="mysqldump" style="width: 80%" value="'.$fullpathofmysqldump.'" spellcheck="false">';
276 print '</fieldset>';
277
278 print '<br>';
279 print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>';
280
281 if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK')) {
282 print '<div class="formelementrow">';
283 print '<input type="checkbox" name="disable_fk" value="yes" id="checkbox_disable_fk" checked>';
284 print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
285 print '</div>';
286 }
287
288 print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
289
290 print '<select name="sql_compat" id="select_sql_compat" class="flat">';
291 print '<option value="NONE" selected>NONE</option>';
292 print '<option value="ANSI">ANSI</option>';
293 print '<option value="DB2">DB2</option>';
294 print '<option value="MAXDB">MAXDB</option>';
295 print '<option value="MYSQL323">MYSQL323</option>';
296 print '<option value="MYSQL40">MYSQL40</option>';
297 print '<option value="MSSQL">MSSQL</option>';
298 print '<option value="ORACLE">ORACLE</option>';
299 print '<option value="POSTGRESQL">POSTGRESQL</option>';
300 print '</select>';
301 print '<br><br>';
302
303 print '<div class="formelementrow">';
304 print '<input type="checkbox" name="use_transaction" value="yes" id="checkbox_use_transaction" checked="checked">';
305 print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
306 print '</div>';
307
308 print '<input type="checkbox" name="use_mysql_quick_param" value="yes" id="checkbox_use_quick" checked="checked" />';
309 print '<label for="checkbox_use_quick">';
310 print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp'));
311 print '</label>';
312 print '<br>';
313
314 print '<input type="checkbox" name="use_force" value="no" id="checkbox_use_force" />';
315 print '<label for="checkbox_use_force">';
316 print $form->textwithpicto($langs->trans('ExportUseForce'), $langs->trans('ExportUseForceHelp'));
317 print '</label>';
318 print '<br>';
319
320 $execmethod = 0;
321 if (getDolGlobalString('MAIN_EXEC_USE_POPEN')) {
322 $execmethod = getDolGlobalString('MAIN_EXEC_USE_POPEN');
323 }
324 if (empty($execmethod)) {
325 $execmethod = 1;
326 }
327 if ($execmethod == 1) {
328 // If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode.
329 print '<input type="checkbox" name="lowmemorydump" value="1" id="lowmemorydump"'.((GETPOSTISSET('lowmemorydump') ? GETPOSTINT('lowmemorydump') : getDolGlobalInt('MAIN_LOW_MEMORY_DUMP')) ? ' checked="checked"' : '').'" />';
330 print '<label for="lowmemorydump">';
331 print $form->textwithpicto($langs->trans('ExportUseLowMemoryMode'), $langs->trans('ExportUseLowMemoryModeHelp'));
332 print '</label>';
333 print '<br>';
334 }
335
336 print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
337 print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
338 print '-->';
339 print '</fieldset>';
340
341 print '<br>';
342 print '<fieldset>';
343 print '<legend>';
344 print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
345 print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
346 print '</legend>';
347
348 print '<input type="checkbox" name="drop"'.((!GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
349 print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
350 print '<br>';
351 print '</fieldset>';
352
353 print '<br>';
354 print '<fieldset>';
355 print '<legend>';
356 print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
357 print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
358 print '</legend>';
359 print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
360 print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
361 print '<br>';
362
363 print '<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" checked />';
364 print '<label for="checkbox_dump_extended_ins">'.$langs->trans("ExtendedInsert").'</label>';
365 print '<br>';
366
367 print '<input type="checkbox" name="disable-add-locks" value="no" id="checkbox_dump_disable-add-locks" />';
368 print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
369 print '<br>';
370
371 print '<input type="checkbox" name="delayed" value="yes" id="checkbox_dump_delayed" />';
372 print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
373 print '<br>';
374
375 print '<input type="checkbox" name="sql_ignore" value="yes" id="checkbox_dump_ignore" />';
376 print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
377 print '<br>';
378
379 print '<input type="checkbox" name="hexforbinary" value="yes" id="checkbox_hexforbinary" checked />';
380 print '<label for="checkbox_hexforbinary">'.$langs->trans("EncodeBinariesInHexa").'</label>';
381 print '<br>';
382
383 print '<input type="checkbox" name="charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
384 print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
385 print '<br>';
386
387 print '</fieldset>';
388 print '</fieldset>';
389
390 // Export mysql bin
391 print "<!-- Fieldset mysql_nobin -->\n";
392 print '<fieldset id="mysql_nobin_options">';
393
394 print '<fieldset>';
395 print '<legend>'.$langs->trans("ExportOptions").'</legend>';
396
397 print '<div class="formelementrow">';
398 print '<input type="checkbox" name="nobin_use_transaction" value="yes" id="checkbox_use_transaction" />';
399 print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
400 print '</div>';
401
402 if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK')) {
403 print '<div class="formelementrow">';
404 print '<input type="checkbox" name="nobin_disable_fk" value="yes" id="checkbox_disable_fk" checked />';
405 print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
406 print '</div>';
407 }
408 print '</fieldset>';
409
410 print '<br>';
411 print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
412 print '<input type="checkbox" name="nobin_drop"'.((!GETPOSTISSET("nobin_drop") || GETPOST('nobin_drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
413 print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
414 print '<br>';
415 print '</fieldset>';
416
417 print '<br>';
418 print '<fieldset>';
419 print '<legend>'.$langs->trans("Datas").'</legend>';
420
421 print '<input type="checkbox" name="nobin_nolocks" value="no" id="checkbox_dump_disable-add-locks" />';
422 print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
423 print '<br>';
424
425 print '<input type="checkbox" name="nobin_delayed" value="yes" id="checkbox_dump_delayed" />';
426 print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
427 print '<br>';
428
429 print '<input type="checkbox" name="nobin_sql_ignore" value="yes" id="checkbox_dump_ignore" />';
430 print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
431 print '<br>';
432
433 print '<input type="checkbox" name="nobin_charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
434 print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
435 print '<br>';
436
437 print '</fieldset>';
438 print '</fieldset>';
439}
440
441if (in_array($type, array('pgsql'))) {
442 print "<!-- Fieldset pg_dump -->\n";
443 print '<fieldset id="postgresql_options">';
444
445
446 print '<fieldset class="formelementrow"><legend>'.$langs->trans("FullPathToPostgreSQLdumpCommand").'</legend>';
447 if (!getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP')) {
448 $fullpathofpgdump = $db->getPathOfDump();
449 } else {
450 $fullpathofpgdump = getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP');
451 }
452 print '<br>';
453 print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" />';
454 print '</fieldset>';
455
456 print '<br>';
457 print '<fieldset>';
458 print '<legend>'.$langs->trans("ExportOptions").'</legend>';
459 print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
460 print '<select name="sql_compat" id="select_sql_compat" class="flat">';
461 print '<option value="POSTGRESQL" selected>POSTGRESQL</option>';
462 print '<option value="ANSI">ANSI</option>';
463 print '</select>';
464 print '<br>';
465 print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
466 print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
467 print '-->';
468 print '</fieldset>';
469 print '<br>';
470 print '<fieldset>';
471 print '<legend>';
472 print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
473 print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
474 print '</legend>';
475 print '</fieldset>';
476 print '<br>';
477 print '<fieldset>';
478 print '<legend>';
479 print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
480 print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
481 print '</legend>';
482 print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
483 print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
484 print '<br>';
485 print '</fieldset>';
486 print '</fieldset>';
487}
488print '</div>';
489
490print '</td>';
491print '</tr>';
492print '</table>';
493
494
495
496
497print '<!--<fieldset>';
498print '<legend>'.$langs->trans("Destination").'</legend> -->';
499print '<br>';
500print '<label for="filename_template" class="line-height-large opacitymedium">'.$langs->trans("FileNameToGenerate").'</label>';
501print '<br>';
502$prefix = 'dump';
503$ext = '.sql';
504if (in_array($type, array('mysql', 'mysqli'))) {
505 $prefix = 'mysqldump';
506 $ext = 'sql';
507}
508//if ($label == 'PostgreSQL') {
509// $prefix='pg_dump';
510// $ext='dump';
511//}
512if (in_array($type, array('pgsql'))) {
513 $prefix = 'pg_dump';
514 $ext = 'sql';
515}
516$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext;
517print '<input type="text" name="filename_template" style="width: 90%" id="filename_template" value="'.$file.'" />';
518print '<br>';
519print '<br>';
520
521// Define compressions array
522$compression = array();
523if (in_array($type, array('mysql', 'mysqli'))) {
524 $compression['gz'] = array(
525 'function' => 'gzopen',
526 'id' => 'radio_compression_gzip',
527 'label' => $langs->trans("Gzip")
528 );
529 // Not open source format. Must implement dol_compress function
530 // $compression['zip']= array(
531 // 'function' => 'dol_compress',
532 // 'id' => 'radio_compression_zip',
533 // 'label' => $langs->trans("FormatZip")
534 // );
535 $compression['bz'] = array(
536 'function' => 'bzopen',
537 'id' => 'radio_compression_bzip',
538 'label' => $langs->trans("Bzip2")
539 );
540 $compression['zstd'] = array(
541 'function' => 'zstd_compress',
542 'id' => 'radio_compression_zstd',
543 'label' => $langs->trans("Zstd")
544 );
545 $compression['none'] = array(
546 'function' => '',
547 'id' => 'radio_compression_none',
548 'label' => $langs->trans("None")
549 );
550} else {
551 $compression['none'] = array(
552 'function' => '',
553 'id' => 'radio_compression_none',
554 'label' => $langs->trans("None")
555 );
556 $compression['gz'] = array(
557 'function' => 'gzopen',
558 'id' => 'radio_compression_gzip',
559 'label' => $langs->trans("Gzip")
560 );
561}
562
563// Show compression choices
564print '<div class="formelementrow">';
565print "\n";
566
567print $langs->trans("Compression").': &nbsp; ';
568
569$i = 0;
570foreach ($compression as $key => $val) {
571 if (!$val['function'] || function_exists($val['function'])) {
572 // Enabled export format
573 $checked = '';
574 if ($key == 'gz') {
575 $checked = ' checked';
576 }
577 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
578 print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
579 } else {
580 // Disabled export format
581 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'" disabled>';
582 print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
583 print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
584 }
585 print ' &nbsp; &nbsp; ';
586 $i++;
587}
588
589print '</div>';
590print "\n";
591
592print "<!--</fieldset>--> <!-- End destination -->\n";
593
594print '<br>';
595print '<div class="center">';
596print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo">';
597print '<br>';
598print '<br>';
599
600if (!empty($_SESSION["commandbackuplastdone"])) {
601 print '<br><b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n";
602 print '<textarea rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuplastdone"].'</textarea><br>'."\n";
603 print '<br>';
604
605 //print $paramclear;
606
607 // Now show result
608 print '<b>'.$langs->trans("BackupResult").':</b> ';
609 print $_SESSION["commandbackupresult"];
610
611 $_SESSION["commandbackuplastdone"] = '';
612 $_SESSION["commandbackuptorun"] = '';
613 $_SESSION["commandbackupresult"] = '';
614}
615if (!empty($_SESSION["commandbackuptorun"])) {
616 print '<br><span class="warning">'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser", $dolibarr_main_db_user, $dolibarr_main_db_user).':</span><br>'."\n";
617 print '<textarea id="commandbackuptoruntext" rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuptorun"].'</textarea><br>'."\n";
618 print ajax_autoselect("commandbackuptoruntext", '');
619 print '<br>';
620
621 //print $paramclear;
622
623 $_SESSION["commandbackuplastdone"] = '';
624 $_SESSION["commandbackuptorun"] = '';
625 $_SESSION["commandbackupresult"] = '';
626}
627
628print "</div> <!-- end div center button -->\n";
629
630//print '</td></tr>';
631//print '</table>';
632
633print "</div> <!-- end div fichehalfleft -->\n";
634
635
636print '<div id="backupdatabaseright" class="fichehalfright">';
637
638$filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
639$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;"');
640print '<br>';
641
642print '</div>';
643print '</form>';
644print '</fieldset>';
645
646
647$title = $langs->trans("BackupZipWizard");
648
649print "<br>\n";
650print "<!-- Dump of a server -->\n";
651
652print '<form method="post" action="'.DOL_URL_ROOT.'/admin/tools/export_files.php" name="dump" spellcheck="false">';
653print '<input type="hidden" name="token" value="'.newToken().'" />';
654print '<input type="hidden" name="export_type" value="server" />';
655print '<input type="hidden" name="page_y" value="" />';
656if ($allowdownloadapp) {
657 print '<input type="hidden" name="allow_download_app" value="1" />';
658}
659
660print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">2</legend>';
661
662print '<span class="opacitymedium">';
663print $langs->trans("BackupDesc2", DOL_DATA_ROOT).'<br>';
664print $langs->trans("BackupDescX").'<br><br>';
665print '</span>';
666
667print '<div id="backupfilesleft" class="fichehalfleft">';
668
669print load_fiche_titre($title);
670
671print '<label for="zipfilename_template" class="line-height-large paddingbottom opacitymedium">'.$langs->trans("FileNameToGenerate").'</label><br>';
672$prefix = 'documents';
673$ext = 'zip';
674$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser');
675print '<input type="text" name="zipfilename_template" style="width: 90%" id="zipfilename_template" value="'.$file.'" /> <br>';
676print '<br>';
677
678
679// Show compression choices
680// Example: With gz choice, you can compress in 5mn, a file of 2GB directory (after compression) with 10 Mb memory.
681print '<div class="formelementrow">';
682print "\n";
683
684print $langs->trans("Compression").': &nbsp; ';
685$filecompression = $compression;
686unset($filecompression['none']);
687$filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip"));
688
689// The gz, bz and zstd formats are built by export_files.php with OS commands (tar then a compressor). When
690// $dolibarr_main_restrict_os_commands is set (default since 24.0.1), Utils::executeCLI() refuses any command not in
691// the list, so a format whose commands are not allowed must not be offered.
692$oscommandsforformat = array('gz' => array('tar', 'gzip'), 'bz' => array('tar', 'bzip2'), 'zstd' => array('tar', 'zstd'));
693$arrayofallowedcommand = array();
694if (!empty($dolibarr_main_restrict_os_commands)) {
695 $arrayofallowedcommand = array_map('trim', explode(',', $dolibarr_main_restrict_os_commands));
696}
697$disabledbyrestriction = array();
698foreach ($oscommandsforformat as $key => $commands) {
699 if (!empty($arrayofallowedcommand) && array_diff($commands, $arrayofallowedcommand)) {
700 $disabledbyrestriction[$key] = implode(', ', array_diff($commands, $arrayofallowedcommand));
701 }
702}
703$defaultcompression = empty($disabledbyrestriction['gz']) ? 'gz' : 'zip';
704
705$i = 0;
706foreach ($filecompression as $key => $val) {
707 if ((!$val['function'] || function_exists($val['function'])) && empty($disabledbyrestriction[$key])) { // Enabled export format
708 $checked = '';
709 if ($key == $defaultcompression) {
710 $checked = ' checked';
711 }
712 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'2"'.$checked.'>';
713 print ' <label for="'.$val['id'].'2">'.$val['label'].'</label>';
714 } else { // Disabled export format
715 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'2" disabled>';
716 print ' <label for="'.$val['id'].'2">'.$val['label'].'</label>';
717 if (!empty($disabledbyrestriction[$key])) {
718 print ' <span class="opacitymedium">('.$langs->trans("NotAvailableCommandNotAllowed", $disabledbyrestriction[$key]).')</span>';
719 } else {
720 print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
721 }
722 }
723 print ' &nbsp; &nbsp; ';
724 $i++;
725}
726if (!empty($disabledbyrestriction)) {
727 print '<br><span class="opacitymedium small">'.$langs->trans("RestrictOsCommandsHelp", 'dolibarr_main_restrict_os_commands').'</span>';
728}
729
730print '</div>';
731print "\n";
732
733print '<br>';
734print '<div class="center">';
735print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo" /><br>';
736print '<br>';
737print '</div>';
738
739print '</div>';
740
741print '<div id="backupfileright" class="fichehalfright">';
742
743$filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
744$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;"');
745print '<br>';
746
747print '</div>';
748
749print '</fieldset>';
750print '</form>';
751
752print '<br>';
753
754
755// Step 3 (optional): Export the application files (directory DOL_DOCUMENT_ROOT)
756if ($allowdownloadapp) {
757 print "<!-- Dump of the application directory -->\n";
758 print '<br>';
759
760 print '<form method="post" action="'.DOL_URL_ROOT.'/admin/tools/export_files.php" name="dumpapp" spellcheck="false">';
761 print '<input type="hidden" name="token" value="'.newToken().'" />';
762 print '<input type="hidden" name="export_type" value="app" />';
763 print '<input type="hidden" name="page_y" value="" />';
764
765 print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">3</legend>';
766
767 print '<span class="opacitymedium">';
768 print $langs->trans("BackupDescApp", DOL_DOCUMENT_ROOT).'<br>';
769 print $langs->trans("BackupDescX").'<br><br>';
770 print '</span>';
771
772 print '<div id="backupappfilesleft" class="fichehalfleft">';
773
774 $title = $langs->trans("BackupAppZipWizard");
775
776 print load_fiche_titre($title);
777
778 print '<label for="appfilename_template" class="line-height-large paddingbottom opacitymedium">'.$langs->trans("FileNameToGenerate").'</label><br>';
779 $prefix = 'application';
780 $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser');
781 print '<input type="text" name="zipfilename_template" style="width: 90%" id="appfilename_template" value="'.$file.'" /> <br>';
782 print '<br>';
783
784 // Show compression choices (same choices than for the documents directory)
785 print '<div class="formelementrow">';
786 print "\n";
787 print $langs->trans("Compression").': &nbsp; ';
788 foreach ($filecompression as $key => $val) {
789 if ((empty($val['function']) || function_exists($val['function'])) && empty($disabledbyrestriction[$key])) { // Enabled export format
790 $checked = '';
791 if ($key == $defaultcompression) {
792 $checked = ' checked';
793 }
794 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'3"'.$checked.'>';
795 print ' <label for="'.$val['id'].'3">'.$val['label'].'</label>';
796 } else { // Disabled export format
797 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'3" disabled>';
798 print ' <label for="'.$val['id'].'3">'.$val['label'].'</label>';
799 if (!empty($disabledbyrestriction[$key])) {
800 print ' <span class="opacitymedium">('.$langs->trans("NotAvailableCommandNotAllowed", $disabledbyrestriction[$key]).')</span>';
801 } else {
802 print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
803 }
804 }
805 print ' &nbsp; &nbsp; ';
806 }
807 if (!empty($disabledbyrestriction)) {
808 print '<br><span class="opacitymedium small">'.$langs->trans("RestrictOsCommandsHelp", 'dolibarr_main_restrict_os_commands').'</span>';
809 }
810 print '</div>';
811 print "\n";
812
813 print '<br>';
814 print '<div class="center">';
815 print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo3" /><br>';
816 print '<br>';
817 print '</div>';
818
819 print '</div>';
820
821 print '<div id="backupappfilesright" class="fichehalfright">';
822
823 $filearray = dol_dir_list($conf->admin->dir_output.'/backupapp', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
824 $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;"');
825 print '<br>';
826
827 print '</div>';
828
829 print '</fieldset>';
830 print '</form>';
831} elseif ($allow_download_app) {
832 // The parameter allow_download_app was provided but the option $dolibarr_allow_download_app
833 // is not set into the conf/conf.php file, so the step to export the application files is not shown.
834 print '<br>';
835 print '<div class="center"><span class="warning">'.$langs->trans("DownloadOfAppFileDisallowed").'</span></div>';
836 print '<br>';
837}
838
839
840print "<br>\n";
841print "<!-- Save setup conf -->\n";
842
843print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">'.($allowdownloadapp ? 4 : 3).'</legend>';
844
845print '<br>';
846
847print '<span class="opacitymedium">';
848print $langs->trans("BackupDesc4", 'dolibarr_main_dolcrypt_key '.$langs->transnoentitiesnoconv("or").' dolibarr_main_instance_unique_id').'<br>';
849print '</span>';
850
851print '<br>';
852
853print '<div id="backupfileright">';
854
855print $langs->trans("SeeValueIntoConfPhp").'<br>';
856print $langs->trans("SeeValueIntoConfPhp2");
857print '<br>';
858
859print '<br>';
860
861print '</div>';
862
863print '</fieldset>';
864
865print '<br><br>';
866
867// End of page
868llxFooter();
869$db->close();
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:280
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:
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.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
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)
Definition inc.php:431
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:140
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.