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