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