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 '<div class="info">';
186print $langs->trans("BackupDesc3", $dolibarr_main_db_name).'<br>';
187print $langs->trans("BackupDescY");
188print '</div>';
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">';
201//print '</td>';
202//print '</tr>';
203//print '<tr class="oddeven nohover"><td class="nohover">';
204
205print '<table class="centpercent noborderbottom">';
206
207print '<tr>';
208print '<td class="tdtop nopaddingleftimp">';
209
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>';
215 print '</div>';
216 print '<br>';
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>';
219 print '</div>';
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>';
223 print '</div>';
224} else {
225 print 'No method available with database '.dol_escape_htmltag($label);
226}
227print '</fieldset>';
228print '</div>';
229
230print '</td>';
231print '</tr>';
232
233print '<tr>';
234print '<td class="tdtop nopaddingleftimp">';
235
236print '<div class="centpercent center margintoponly marginbottomonly">';
237print img_picto('', 'setup', 'class="pictofixedwidth"').'<a class="classlink cursorpointer" id="lnk">'.$langs->trans("ShowAdvancedOptions").'...</a>';
238print '</div>';
239
240print '<script type="text/javascript">
241jQuery(document).ready(function() {
242 jQuery("#lnk").click(function() {
243 console.log("We click on link");
244 hideoptions(this);
245 });
246});
247
248function hideoptions(domelem) {
249 const div = document.getElementById("div_container_sub_exportoptions");
250
251 if (div.style.display === "none") {
252 div.style.display = "block";
253 domelem.innerText=\''.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'\';
254 } else {
255 div.style.display = "none";
256 domelem.innerText=\''.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions").'...').'\';
257 }
258}
259</script>';
260
261
262print '<div id="div_container_sub_exportoptions" style="display: none;">';
263
264if (in_array($type, array('mysql', 'mysqli'))) {
265 print "<!-- Fieldset mysqldump -->\n";
266 print '<fieldset id="mysql_options">';
267
268 print '<fieldset class="formelementrow"><legend>'.$langs->trans("FullPathToMysqldumpCommand").'</legend>';
269 if (!getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP')) {
270 $fullpathofmysqldump = $db->getPathOfDump();
271 } else {
272 $fullpathofmysqldump = getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP');
273 }
274 print '<input type="text" name="mysqldump" style="width: 80%" value="'.$fullpathofmysqldump.'" spellcheck="false">';
275 print '</fieldset>';
276
277 print '<br>';
278 print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>';
279
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>';
284 print '</div>';
285 }
286
287 print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
288
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>';
299 print '</select>';
300 print '<br><br>';
301
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>';
305 print '</div>';
306
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'));
310 print '</label>';
311 print '<br>';
312
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'));
316 print '</label>';
317 print '<br>';
318
319 $execmethod = 0;
320 if (getDolGlobalString('MAIN_EXEC_USE_POPEN')) {
321 $execmethod = getDolGlobalString('MAIN_EXEC_USE_POPEN');
322 }
323 if (empty($execmethod)) {
324 $execmethod = 1;
325 }
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'));
331 print '</label>';
332 print '<br>';
333 }
334
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>';
337 print '-->';
338 print '</fieldset>';
339
340 print '<br>';
341 print '<fieldset>';
342 print '<legend>';
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>';
345 print '</legend>';
346
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>';
349 print '<br>';
350 print '</fieldset>';
351
352 print '<br>';
353 print '<fieldset>';
354 print '<legend>';
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>';
357 print '</legend>';
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>';
360 print '<br>';
361
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>';
364 print '<br>';
365
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>';
368 print '<br>';
369
370 print '<input type="checkbox" name="delayed" value="yes" id="checkbox_dump_delayed" />';
371 print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
372 print '<br>';
373
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>';
376 print '<br>';
377
378 print '<input type="checkbox" name="hexforbinary" value="yes" id="checkbox_hexforbinary" checked />';
379 print '<label for="checkbox_hexforbinary">'.$langs->trans("EncodeBinariesInHexa").'</label>';
380 print '<br>';
381
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>';
384 print '<br>';
385
386 print '</fieldset>';
387 print '</fieldset>';
388
389 // Export mysql bin
390 print "<!-- Fieldset mysql_nobin -->\n";
391 print '<fieldset id="mysql_nobin_options">';
392
393 print '<fieldset>';
394 print '<legend>'.$langs->trans("ExportOptions").'</legend>';
395
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>';
399 print '</div>';
400
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>';
405 print '</div>';
406 }
407 print '</fieldset>';
408
409 print '<br>';
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>';
413 print '<br>';
414 print '</fieldset>';
415
416 print '<br>';
417 print '<fieldset>';
418 print '<legend>'.$langs->trans("Datas").'</legend>';
419
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>';
422 print '<br>';
423
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>';
426 print '<br>';
427
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>';
430 print '<br>';
431
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>';
434 print '<br>';
435
436 print '</fieldset>';
437 print '</fieldset>';
438}
439
440if (in_array($type, array('pgsql'))) {
441 print "<!-- Fieldset pg_dump -->\n";
442 print '<fieldset id="postgresql_options">';
443
444
445 print '<fieldset class="formelementrow"><legend>'.$langs->trans("FullPathToPostgreSQLdumpCommand").'</legend>';
446 if (!getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP')) {
447 $fullpathofpgdump = $db->getPathOfDump();
448 } else {
449 $fullpathofpgdump = getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP');
450 }
451 print '<br>';
452 print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" />';
453 print '</fieldset>';
454
455 print '<br>';
456 print '<fieldset>';
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>';
462 print '</select>';
463 print '<br>';
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>';
466 print '-->';
467 print '</fieldset>';
468 print '<br>';
469 print '<fieldset>';
470 print '<legend>';
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>';
473 print '</legend>';
474 print '</fieldset>';
475 print '<br>';
476 print '<fieldset>';
477 print '<legend>';
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>';
480 print '</legend>';
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>';
483 print '<br>';
484 print '</fieldset>';
485 print '</fieldset>';
486}
487print '</div>';
488
489print '</td>';
490print '</tr>';
491print '</table>';
492
493
494
495
496print '<!--<fieldset>';
497print '<legend>'.$langs->trans("Destination").'</legend> -->';
498print '<br>';
499print '<label for="filename_template" class="line-height-large opacitymedium">'.$langs->trans("FileNameToGenerate").'</label>';
500print '<br>';
501$prefix = 'dump';
502$ext = '.sql';
503if (in_array($type, array('mysql', 'mysqli'))) {
504 $prefix = 'mysqldump';
505 $ext = 'sql';
506}
507//if ($label == 'PostgreSQL') {
508// $prefix='pg_dump';
509// $ext='dump';
510//}
511if (in_array($type, array('pgsql'))) {
512 $prefix = 'pg_dump';
513 $ext = 'sql';
514}
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.'" />';
517print '<br>';
518print '<br>';
519
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")
527 );
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")
533 // );
534 $compression['bz'] = array(
535 'function' => 'bzopen',
536 'id' => 'radio_compression_bzip',
537 'label' => $langs->trans("Bzip2")
538 );
539 $compression['zstd'] = array(
540 'function' => 'zstd_compress',
541 'id' => 'radio_compression_zstd',
542 'label' => $langs->trans("Zstd")
543 );
544 $compression['none'] = array(
545 'function' => '',
546 'id' => 'radio_compression_none',
547 'label' => $langs->trans("None")
548 );
549} else {
550 $compression['none'] = array(
551 'function' => '',
552 'id' => 'radio_compression_none',
553 'label' => $langs->trans("None")
554 );
555 $compression['gz'] = array(
556 'function' => 'gzopen',
557 'id' => 'radio_compression_gzip',
558 'label' => $langs->trans("Gzip")
559 );
560}
561
562// Show compression choices
563print '<div class="formelementrow">';
564print "\n";
565
566print $langs->trans("Compression").': &nbsp; ';
567
568$i = 0;
569foreach ($compression as $key => $val) {
570 if (!$val['function'] || function_exists($val['function'])) {
571 // Enabled export format
572 $checked = '';
573 if ($key == 'gz') {
574 $checked = ' checked';
575 }
576 print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
577 print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
578 } else {
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', '');
582 }
583 print ' &nbsp; &nbsp; ';
584 $i++;
585}
586
587print '</div>';
588print "\n";
589
590print "<!--</fieldset>--> <!-- End destination -->\n";
591
592print '<br>';
593print '<div class="center">';
594print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo">';
595print '<br>';
596print '<br>';
597
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";
601 print '<br>';
602
603 //print $paramclear;
604
605 // Now show result
606 print '<b>'.$langs->trans("BackupResult").':</b> ';
607 print $_SESSION["commandbackupresult"];
608
609 $_SESSION["commandbackuplastdone"] = '';
610 $_SESSION["commandbackuptorun"] = '';
611 $_SESSION["commandbackupresult"] = '';
612}
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", '');
617 print '<br>';
618
619 //print $paramclear;
620
621 $_SESSION["commandbackuplastdone"] = '';
622 $_SESSION["commandbackuptorun"] = '';
623 $_SESSION["commandbackupresult"] = '';
624}
625
626print "</div> <!-- end div center button -->\n";
627
628//print '</td></tr>';
629//print '</table>';
630
631print "</div> <!-- end div fichehalfleft -->\n";
632
633
634print '<div id="backupdatabaseright" class="fichehalfright">';
635
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;"');
638print '<br>';
639
640print '</div>';
641print '</form>';
642print '</fieldset>';
643
644
645$title = $langs->trans("BackupZipWizard");
646
647print "<br>\n";
648print "<!-- Dump of a server -->\n";
649
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" />';
656}
657
658print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">2</legend>';
659
660print '<div class="info">';
661print $langs->trans("BackupDesc2", DOL_DATA_ROOT).'<br>';
662print $langs->trans("BackupDescX");
663print '</div>';
664
665print '<div id="backupfilesleft" class="fichehalfleft">';
666
667print load_fiche_titre($title);
668
669print '<label for="zipfilename_template" class="line-height-large paddingbottom opacitymedium">'.$langs->trans("FileNameToGenerate").'</label><br>';
670$prefix = 'documents';
671$ext = 'zip';
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>';
674print '<br>';
675
676
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">';
680print "\n";
681
682print $langs->trans("Compression").': &nbsp; ';
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'] = '';
689 }
690}
691$filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip"));
692
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));
700}
701$disabledbyrestriction = array();
702foreach ($oscommandsforformat as $key => $commands) {
703 if (!empty($arrayofallowedcommand) && array_diff($commands, $arrayofallowedcommand)) {
704 $disabledbyrestriction[$key] = implode(', ', array_diff($commands, $arrayofallowedcommand));
705 }
706}
707$defaultcompression = empty($disabledbyrestriction['gz']) ? 'gz' : 'zip';
708
709$i = 0;
710foreach ($filecompression as $key => $val) {
711 if ((!$val['function'] || function_exists($val['function'])) && empty($disabledbyrestriction[$key])) { // Enabled export format
712 $checked = '';
713 if ($key == $defaultcompression) {
714 $checked = ' checked';
715 }
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]);
722 } else {
723 $reasonnotavailable = $langs->trans("NotAvailablePHPModuleNotInstalled");
724 }
725 print ' '.$form->textwithpicto('<label class="opacitymedium" for="'.$val['id'].'2">'.$val['label'].'</label>', $reasonnotavailable, 1, 'info', '');
726 }
727 print ' &nbsp; &nbsp; ';
728 $i++;
729}
730if (!empty($disabledbyrestriction)) {
731 print '<br><span class="opacitymedium small">'.$langs->trans("RestrictOsCommandsHelp", 'dolibarr_main_restrict_os_commands').'</span>';
732}
733
734print '</div>';
735print "\n";
736
737print '<br>';
738print '<div class="center">';
739print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo" /><br>';
740print '<br>';
741print '</div>';
742
743print '</div>';
744
745print '<div id="backupfileright" class="fichehalfright">';
746
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;"');
749print '<br>';
750
751print '</div>';
752
753print '</fieldset>';
754print '</form>';
755
756print '<br>';
757
758
759// Step 3 (optional): Export the application files (directory DOL_DOCUMENT_ROOT)
760if ($allowdownloadapp) {
761 print "<!-- Dump of the application directory -->\n";
762 print '<br>';
763
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="" />';
768
769 print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">3</legend>';
770
771 print '<div class="info">';
772 print $langs->trans("BackupDescApp", DOL_DOCUMENT_ROOT).'<br>';
773 print $langs->trans("BackupDescX");
774 print '</div>';
775
776 print '<div id="backupappfilesleft" class="fichehalfleft">';
777
778 $title = $langs->trans("BackupAppZipWizard");
779
780 print load_fiche_titre($title);
781
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>';
786 print '<br>';
787
788 // Show compression choices (same choices than for the documents directory)
789 print '<div class="formelementrow">';
790 print "\n";
791 print $langs->trans("Compression").': &nbsp; ';
792 foreach ($filecompression as $key => $val) {
793 if ((empty($val['function']) || function_exists($val['function'])) && empty($disabledbyrestriction[$key])) { // Enabled export format
794 $checked = '';
795 if ($key == $defaultcompression) {
796 $checked = ' checked';
797 }
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]);
804 } else {
805 $reasonnotavailable = $langs->trans("NotAvailablePHPModuleNotInstalled");
806 }
807 print ' '.$form->textwithpicto('<label class="opacitymedium" for="'.$val['id'].'3">'.$val['label'].'</label>', $reasonnotavailable, 1, 'info', '');
808 }
809 print ' &nbsp; &nbsp; ';
810 }
811 if (!empty($disabledbyrestriction)) {
812 print '<br><span class="opacitymedium small">'.$langs->trans("RestrictOsCommandsHelp", 'dolibarr_main_restrict_os_commands').'</span>';
813 }
814 print '</div>';
815 print "\n";
816
817 print '<br>';
818 print '<div class="center">';
819 print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo3" /><br>';
820 print '<br>';
821 print '</div>';
822
823 print '</div>';
824
825 print '<div id="backupappfilesright" class="fichehalfright">';
826
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;"');
829 print '<br>';
830
831 print '</div>';
832
833 print '</fieldset>';
834 print '</form>';
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.
838 print '<br>';
839 print '<div class="center"><span class="warning">'.$langs->trans("DownloadOfAppFileDisallowed").'</span></div>';
840 print '<br>';
841}
842
843
844print "<br>\n";
845print "<!-- Save setup conf -->\n";
846
847print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">'.($allowdownloadapp ? 4 : 3).'</legend>';
848
849
850print '<div class="info">';
851print $langs->trans("BackupDesc4", 'dolibarr_main_dolcrypt_key '.$langs->transnoentitiesnoconv("or").' dolibarr_main_instance_unique_id');
852print '</div>';
853
854print '<br>';
855
856print '<div id="backupfileright">';
857
858print $langs->trans("SeeValueIntoConfPhp").'<br>';
859print $langs->trans("SeeValueIntoConfPhp2");
860print '<br>';
861
862print '<br>';
863
864print '</div>';
865
866print '</fieldset>';
867
868print '<br><br>';
869
870// End of page
871llxFooter();
872$db->close();
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:281
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
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)
Definition inc.php:431
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:165
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