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