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