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