dolibarr  17.0.4
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
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29 require_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');
38 if (!$sortorder) {
39  $sortorder = "DESC";
40 }
41 if (!$sortfield) {
42  $sortfield = "date";
43 }
44 if (empty($page) || $page == -1) {
45  $page = 0;
46 }
47 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
48 $offset = $limit * $page;
49 
50 if (!$user->admin) {
52 }
53 
54 
55 /*
56  * Actions
57  */
58 
59 if ($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';
93 llxHeader('', '', $help_url);
94 
95 print '<script type="text/javascript">
96 jQuery(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
126 if (in_array($type, array('mysql', 'mysqli'))) {
127  print 'jQuery("#radio_dump_mysql").click();';
128 }
129 if (in_array($type, array('pgsql'))) {
130  print 'jQuery("#radio_dump_postgresql").click();';
131 }
132 print "});\n";
133 print "</script>\n";
134 
135 $title = $langs->trans("Backup");
136 
137 print load_fiche_titre($title, '', 'title_setup');
138 //print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup');
139 
140 print '<div class="center">';
141 print $langs->trans("BackupDesc", DOL_DATA_ROOT);
142 print '</div>';
143 print '<br>';
144 
145 print "<!-- Dump of a server -->\n";
146 print '<form method="post" action="export.php" name="dump">';
147 print '<input type="hidden" name="token" value="'.newToken().'" />';
148 print '<input type="hidden" name="export_type" value="server" />';
149 print '<input type="hidden" name="page_y" value="" />';
150 
151 print '<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>';
152 
153 print '<span class="opacitymedium">';
154 print $langs->trans("BackupDesc3", $dolibarr_main_db_name).'<br>';
155 //print $langs->trans("BackupDescY").'<br>';
156 print '</span>';
157 
158 print '<br>';
159 
160 print '<div id="backupdatabaseleft" class="fichehalfleft" >';
161 
162 $title = $langs->trans("BackupDumpWizard");
163 
164 print 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">';
169 print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b><br>';
170 print '</td>';
171 print '</tr>';
172 print '<tr class="oddeven nohover"><td style="class="nohover">';
173 
174 print '<table class="centpercent noborderbottom">';
175 
176 print '<tr>';
177 print '<td class="tdtop nopaddingleftimp">';
178 
179 print '<div id="div_container_exportoptions">';
180 print '<fieldset id="exportoptions"><legend>'.$langs->trans("ExportMethod").'</legend>';
181 if (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 }
196 print '</fieldset>';
197 print '</div>';
198 
199 print '</td>';
200 print '</tr>';
201 
202 print '<tr>';
203 print '<td class="tdtop nopaddingleftimp">';
204 
205 print '<div class="centpercent center"><a id="lnk" href="javascript:hideoptions()"> '.$langs->trans("ShowAdvancedOptions").'...</a></div>';
206 
207 print '<script type="text/javascript">
208 
209 function hideoptions(){
210  const lnk = document.getElementById("lnk");
211  const div = document.getElementById("div_container_sub_exportoptions");
212 
213  if (div.style.display === "none") {
214  div.style.display = "block";
215  lnk.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'";
216  } else {
217  div.style.display = "none";
218  lnk.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions")).'...";
219  }
220 }
221 </script>';
222 
223 print '<div id="div_container_sub_exportoptions" style="display: none;">';
224 print '<br>';
225 if (in_array($type, array('mysql', 'mysqli'))) {
226  print "<!-- Fieldset mysqldump -->\n";
227  print '<fieldset id="mysql_options"><legend>'.$langs->trans("MySqlExportParameters").'</legend>';
228 
229  print '<div class="formelementrow">'.$langs->trans("FullPathToMysqldumpCommand");
230  if (empty($conf->global->SYSTEMTOOLS_MYSQLDUMP)) {
231  $fullpathofmysqldump = $db->getPathOfDump();
232  } else {
233  $fullpathofmysqldump = $conf->global->SYSTEMTOOLS_MYSQLDUMP;
234  }
235  print '<br>';
236  print '<input type="text" name="mysqldump" style="width: 80%" value="'.$fullpathofmysqldump.'" /></div>';
237 
238  print '<br>';
239  print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>';
240 
241  if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
242  print '<div class="formelementrow">';
243  print '<input type="checkbox" name="disable_fk" value="yes" id="checkbox_disable_fk" checked />';
244  print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
245  print '</div>';
246  }
247 
248  print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
249 
250  print '<select name="sql_compat" id="select_sql_compat" class="flat">';
251  print '<option value="NONE" selected>NONE</option>';
252  print '<option value="ANSI">ANSI</option>';
253  print '<option value="DB2">DB2</option>';
254  print '<option value="MAXDB">MAXDB</option>';
255  print '<option value="MYSQL323">MYSQL323</option>';
256  print '<option value="MYSQL40">MYSQL40</option>';
257  print '<option value="MSSQL">MSSQL</option>';
258  print '<option value="ORACLE">ORACLE</option>';
259  print '<option value="POSTGRESQL">POSTGRESQL</option>';
260  print '</select>';
261  print '<br><br>';
262 
263  print '<div class="formelementrow">';
264  print '<input type="checkbox" name="use_transaction" value="yes" id="checkbox_use_transaction" checked="checked" />';
265  print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
266  print '</div>';
267 
268  print '<input type="checkbox" name="use_mysql_quick_param" value="yes" id="checkbox_use_quick" checked="checked" />';
269  print '<label for="checkbox_use_quick">';
270  print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp'));
271  print '</label>';
272  print '<br>';
273 
274  $execmethod = 0;
275  if (!empty($conf->global->MAIN_EXEC_USE_POPEN)) {
276  $execmethod = $conf->global->MAIN_EXEC_USE_POPEN;
277  }
278  if (empty($execmethod)) {
279  $execmethod = 1;
280  }
281  if ($execmethod == 1) {
282  // If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode.
283  print '<input type="checkbox" name="lowmemorydump" value="yes" id="lowmemorydump"'.((GETPOSTISSET('lowmemorydump') ? GETPOST('lowmemorydump', 'alpha') : getDolGlobalString('MAIN_LOW_MEMORY_DUMP')) ? ' checked="checked"' : '').'" />';
284  print '<label for="lowmemorydump">';
285  print $form->textwithpicto($langs->trans('ExportUseLowMemoryMode'), $langs->trans('ExportUseLowMemoryModeHelp'));
286  print '</label>';
287  print '<br>';
288  }
289 
290  print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
291  print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
292  print '-->';
293  print '</fieldset>';
294 
295  print '<br>';
296  print '<fieldset>';
297  print '<legend>';
298  print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
299  print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
300  print '</legend>';
301 
302  print '<input type="checkbox" name="drop"'.((!GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
303  print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
304  print '<br>';
305  print '</fieldset>';
306 
307  print '<br>';
308  print '<fieldset>';
309  print '<legend>';
310  print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
311  print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
312  print '</legend>';
313  print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
314  print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
315  print '<br>';
316 
317  print '<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" checked />';
318  print '<label for="checkbox_dump_extended_ins">'.$langs->trans("ExtendedInsert").'</label>';
319  print '<br>';
320 
321  print '<input type="checkbox" name="disable-add-locks" value="no" id="checkbox_dump_disable-add-locks" />';
322  print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
323  print '<br>';
324 
325  print '<input type="checkbox" name="delayed" value="yes" id="checkbox_dump_delayed" />';
326  print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
327  print '<br>';
328 
329  print '<input type="checkbox" name="sql_ignore" value="yes" id="checkbox_dump_ignore" />';
330  print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
331  print '<br>';
332 
333  print '<input type="checkbox" name="hexforbinary" value="yes" id="checkbox_hexforbinary" checked />';
334  print '<label for="checkbox_hexforbinary">'.$langs->trans("EncodeBinariesInHexa").'</label>';
335  print '<br>';
336 
337  print '<input type="checkbox" name="charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
338  print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
339  print '<br>';
340 
341  print '</fieldset>';
342  print '</fieldset>';
343  print "<!-- Fieldset mysql_nobin -->\n";
344  print '<fieldset id="mysql_nobin_options">';
345  print '<legend>'.$langs->trans("MySqlExportParameters").'</legend>';
346  print '<fieldset>';
347  print '<legend>'.$langs->trans("ExportOptions").'</legend>';
348  print '<div class="formelementrow">';
349  print '<input type="checkbox" name="nobin_use_transaction" value="yes" id="checkbox_use_transaction" />';
350  print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
351 
352  print '</div>';
353  if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
354  print '<div class="formelementrow">';
355  print '<input type="checkbox" name="nobin_disable_fk" value="yes" id="checkbox_disable_fk" checked />';
356  print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
357  print '</div>';
358  }
359  print '</fieldset>';
360 
361  print '<br>';
362  print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
363  print '<input type="checkbox" name="nobin_drop"'.((!GETPOSTISSET("nobin_drop") || GETPOST('nobin_drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
364  print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
365  print '<br>';
366  print '</fieldset>';
367 
368  print '<br>';
369  print '<fieldset>';
370  print '<legend>'.$langs->trans("Datas").'</legend>';
371 
372  print '<input type="checkbox" name="nobin_nolocks" value="no" id="checkbox_dump_disable-add-locks" />';
373  print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
374  print '<br>';
375 
376  print '<input type="checkbox" name="nobin_delayed" value="yes" id="checkbox_dump_delayed" />';
377  print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
378  print '<br>';
379 
380  print '<input type="checkbox" name="nobin_sql_ignore" value="yes" id="checkbox_dump_ignore" />';
381  print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
382  print '<br>';
383 
384  print '<input type="checkbox" name="nobin_charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
385  print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
386  print '<br>';
387 
388  print '</fieldset>';
389  print '</fieldset>';
390 }
391 
392 if (in_array($type, array('pgsql'))) {
393  print "<!-- Fieldset pg_dump -->\n";
394  print '<fieldset id="postgresql_options"><legend>'.$langs->trans("PostgreSqlExportParameters").'</legend>';
395 
396  print '<div class="formelementrow">'.$langs->trans("FullPathToPostgreSQLdumpCommand");
397  if (empty($conf->global->SYSTEMTOOLS_POSTGRESQLDUMP)) {
398  $fullpathofpgdump = $db->getPathOfDump();
399  } else {
400  $fullpathofpgdump = $conf->global->SYSTEMTOOLS_POSTGRESQLDUMP;
401  }
402  print '<br>';
403  print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" /></div>';
404 
405  print '<br>';
406  print '<fieldset>';
407  print '<legend>'.$langs->trans("ExportOptions").'</legend>';
408  print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
409  print '<select name="sql_compat" id="select_sql_compat" class="flat">';
410  print '<option value="POSTGRESQL" selected>POSTGRESQL</option>';
411  print '<option value="ANSI">ANSI</option>';
412  print '</select>';
413  print '<br>';
414  print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
415  print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
416  print '-->';
417  print '</fieldset>';
418  print '<br>';
419  print '<fieldset>';
420  print '<legend>';
421  print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
422  print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
423  print '</legend>';
424  print '</fieldset>';
425  print '<br>';
426  print '<fieldset>';
427  print '<legend>';
428  print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
429  print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
430  print '</legend>';
431  print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
432  print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
433  print '<br>';
434  print '</fieldset>';
435  print '</fieldset>';
436 }
437 print '</div>';
438 
439 print '</td>';
440 print '</tr>';
441 print '</table>';
442 
443 
444 
445 
446 print '<!--<fieldset>';
447 print '<legend>'.$langs->trans("Destination").'</legend> -->';
448 print '<br>';
449 print '<label for="filename_template" class="line-height-large">'.$langs->trans("FileNameToGenerate").'</label>';
450 print '<br>';
451 $prefix = 'dump';
452 $ext = '.sql';
453 if (in_array($type, array('mysql', 'mysqli'))) {
454  $prefix = 'mysqldump';
455  $ext = 'sql';
456 }
457 //if ($label == 'PostgreSQL') {
458 // $prefix='pg_dump';
459 // $ext='dump';
460 //}
461 if (in_array($type, array('pgsql'))) {
462  $prefix = 'pg_dump';
463  $ext = 'sql';
464 }
465 $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext;
466 print '<input type="text" name="filename_template" style="width: 90%" id="filename_template" value="'.$file.'" />';
467 print '<br>';
468 print '<br>';
469 
470 // Define compressions array
471 $compression = array();
472 if (in_array($type, array('mysql', 'mysqli'))) {
473  $compression['gz'] = array(
474  'function' => 'gzopen',
475  'id' => 'radio_compression_gzip',
476  'label' => $langs->trans("Gzip")
477  );
478  // Not open source format. Must implement dol_compress function
479  // $compression['zip']= array(
480  // 'function' => 'dol_compress',
481  // 'id' => 'radio_compression_zip',
482  // 'label' => $langs->trans("FormatZip")
483  // );
484  $compression['bz'] = array(
485  'function' => 'bzopen',
486  'id' => 'radio_compression_bzip',
487  'label' => $langs->trans("Bzip2")
488  );
489  $compression['zstd'] = array(
490  'function' => 'zstd_compress',
491  'id' => 'radio_compression_zstd',
492  'label' => $langs->trans("Zstd")
493  );
494  $compression['none'] = array(
495  'function' => '',
496  'id' => 'radio_compression_none',
497  'label' => $langs->trans("None")
498  );
499 } else {
500  $compression['none'] = array(
501  'function' => '',
502  'id' => 'radio_compression_none',
503  'label' => $langs->trans("None")
504  );
505  $compression['gz'] = array(
506  'function' => 'gzopen',
507  'id' => 'radio_compression_gzip',
508  'label' => $langs->trans("Gzip")
509  );
510 }
511 
512 // Show compression choices
513 print '<div class="formelementrow">';
514 print "\n";
515 
516 print $langs->trans("Compression").': &nbsp; ';
517 
518 $i = 0;
519 foreach ($compression as $key => $val) {
520  if (!$val['function'] || function_exists($val['function'])) {
521  // Enabled export format
522  $checked = '';
523  if ($key == 'gz') {
524  $checked = ' checked';
525  }
526  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
527  print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
528  } else {
529  // Disabled export format
530  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'" disabled>';
531  print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
532  print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
533  }
534  print ' &nbsp; &nbsp; ';
535  $i++;
536 }
537 
538 print '</div>';
539 print "\n";
540 
541 print "<!--</fieldset>--> <!-- End destination -->\n";
542 
543 print '<br>';
544 print '<div class="center">';
545 print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo">';
546 print '<br>';
547 print '<br>';
548 
549 if (!empty($_SESSION["commandbackuplastdone"])) {
550  print '<br><b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n";
551  print '<textarea rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuplastdone"].'</textarea><br>'."\n";
552  print '<br>';
553 
554  //print $paramclear;
555 
556  // Now show result
557  print '<b>'.$langs->trans("BackupResult").':</b> ';
558  print $_SESSION["commandbackupresult"];
559 
560  $_SESSION["commandbackuplastdone"] = '';
561  $_SESSION["commandbackuptorun"] = '';
562  $_SESSION["commandbackupresult"] = '';
563 }
564 if (!empty($_SESSION["commandbackuptorun"])) {
565  print '<br><span class="warning">'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser", $dolibarr_main_db_user, $dolibarr_main_db_user).':</span><br>'."\n";
566  print '<textarea id="commandbackuptoruntext" rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuptorun"].'</textarea><br>'."\n";
567  print ajax_autoselect("commandbackuptoruntext", 0);
568  print '<br>';
569 
570  //print $paramclear;
571 
572  $_SESSION["commandbackuplastdone"] = '';
573  $_SESSION["commandbackuptorun"] = '';
574  $_SESSION["commandbackupresult"] = '';
575 }
576 
577 print "</div> <!-- end div center button -->\n";
578 
579 print '</td></tr>';
580 print '</table>';
581 
582 print "</div> <!-- end div fichehalfleft -->\n";
583 
584 
585 print '<div id="backupdatabaseright" class="fichehalfright">';
586 
587 $filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1);
588 $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:480px; overflow: auto;"');
589 print '<br>';
590 
591 print '</div>';
592 print '</form>';
593 print '</fieldset>';
594 
595 
596 $title = $langs->trans("BackupZipWizard");
597 
598 print "<br>\n";
599 print "<!-- Dump of a server -->\n";
600 
601 print '<form method="post" action="export_files.php" name="dump">';
602 print '<input type="hidden" name="token" value="'.newToken().'" />';
603 print '<input type="hidden" name="export_type" value="server" />';
604 print '<input type="hidden" name="page_y" value="" />';
605 
606 print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">2</legend>';
607 
608 print '<span class="opacitymedium">';
609 print $langs->trans("BackupDesc2", DOL_DATA_ROOT).'<br>';
610 print $langs->trans("BackupDescX").'<br><br>';
611 print '</span>';
612 
613 print '<div id="backupfilesleft" class="fichehalfleft">';
614 
615 print load_fiche_titre($title);
616 
617 print '<label for="zipfilename_template" class="line-height-large paddingbottom">'.$langs->trans("FileNameToGenerate").'</label><br>';
618 $prefix = 'documents';
619 $ext = 'zip';
620 $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser');
621 print '<input type="text" name="zipfilename_template" style="width: 90%" id="zipfilename_template" value="'.$file.'" /> <br>';
622 print '<br>';
623 
624 
625 // Show compression choices
626 // Example: With gz choice, you can compress in 5mn, a file of 2GB directory (after compression) with 10 Mb memory.
627 print '<div class="formelementrow">';
628 print "\n";
629 
630 print $langs->trans("Compression").': &nbsp; ';
631 $filecompression = $compression;
632 unset($filecompression['none']);
633 $filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip"));
634 
635 $i = 0;
636 foreach ($filecompression as $key => $val) {
637  if (!$val['function'] || function_exists($val['function'])) { // Enabled export format
638  $checked = '';
639  if ($key == 'gz') {
640  $checked = ' checked';
641  }
642  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
643  print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
644  } else // Disabled export format
645  {
646  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'" disabled>';
647  print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
648  print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
649  }
650  print ' &nbsp; &nbsp; ';
651  $i++;
652 }
653 
654 print '</div>';
655 print "\n";
656 
657 print '<br>';
658 print '<div class="center">';
659 print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo" /><br>';
660 print '<br>';
661 print '</div>';
662 
663 print '</div>';
664 
665 print '<div id="backupfileright" class="fichehalfright">';
666 
667 $filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1);
668 $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;"');
669 print '<br>';
670 
671 print '</div>';
672 
673 print '</fieldset>';
674 print '</form>';
675 
676 // End of page
677 llxFooter();
678 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
Definition: files.lib.php:1251
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:61
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.