dolibarr  20.0.0-beta
dolibarr_export.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2006-2021 Regis Houssin <regis.houssin@inodbox.com>
4  *
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') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
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 = GETPOSTINT('limit') ? GETPOSTINT('limit') : $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 '<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 
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 '.dol_escape_htmltag($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 margintoponly marginbottomonly">';
206 print img_picto('', 'setup', 'class="pictofixedwidth"').'<a class="classlink" id="lnk">'.$langs->trans("ShowAdvancedOptions").'...</a>';
207 print '</div>';
208 
209 print '<script type="text/javascript">
210 jQuery(document).ready(function() {
211  jQuery("#lnk").click(function() {
212  console.log("We click on link");
213  hideoptions(this);
214  });
215 });
216 
217 function 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 
231 print '<div id="div_container_sub_exportoptions" style="display: none;">';
232 
233 if (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 (!getDolGlobalString('SYSTEMTOOLS_MYSQLDUMP')) {
239  $fullpathofmysqldump = $db->getPathOfDump();
240  } else {
241  $fullpathofmysqldump = getDolGlobalString('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 (getDolGlobalString('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  print '<input type="checkbox" name="use_force" value="no" id="checkbox_use_force" />';
283  print '<label for="checkbox_use_force">';
284  print $form->textwithpicto($langs->trans('ExportUseForce'), $langs->trans('ExportUseForceHelp'));
285  print '</label>';
286  print '<br>';
287 
288  $execmethod = 0;
289  if (getDolGlobalString('MAIN_EXEC_USE_POPEN')) {
290  $execmethod = getDolGlobalString('MAIN_EXEC_USE_POPEN');
291  }
292  if (empty($execmethod)) {
293  $execmethod = 1;
294  }
295  if ($execmethod == 1) {
296  // If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode.
297  print '<input type="checkbox" name="lowmemorydump" value="yes" id="lowmemorydump"'.((GETPOSTISSET('lowmemorydump') ? GETPOST('lowmemorydump', 'alpha') : getDolGlobalString('MAIN_LOW_MEMORY_DUMP')) ? ' checked="checked"' : '').'" />';
298  print '<label for="lowmemorydump">';
299  print $form->textwithpicto($langs->trans('ExportUseLowMemoryMode'), $langs->trans('ExportUseLowMemoryModeHelp'));
300  print '</label>';
301  print '<br>';
302  }
303 
304  print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
305  print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
306  print '-->';
307  print '</fieldset>';
308 
309  print '<br>';
310  print '<fieldset>';
311  print '<legend>';
312  print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
313  print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
314  print '</legend>';
315 
316  print '<input type="checkbox" name="drop"'.((!GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
317  print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
318  print '<br>';
319  print '</fieldset>';
320 
321  print '<br>';
322  print '<fieldset>';
323  print '<legend>';
324  print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
325  print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
326  print '</legend>';
327  print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
328  print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
329  print '<br>';
330 
331  print '<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" checked />';
332  print '<label for="checkbox_dump_extended_ins">'.$langs->trans("ExtendedInsert").'</label>';
333  print '<br>';
334 
335  print '<input type="checkbox" name="disable-add-locks" value="no" id="checkbox_dump_disable-add-locks" />';
336  print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
337  print '<br>';
338 
339  print '<input type="checkbox" name="delayed" value="yes" id="checkbox_dump_delayed" />';
340  print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
341  print '<br>';
342 
343  print '<input type="checkbox" name="sql_ignore" value="yes" id="checkbox_dump_ignore" />';
344  print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
345  print '<br>';
346 
347  print '<input type="checkbox" name="hexforbinary" value="yes" id="checkbox_hexforbinary" checked />';
348  print '<label for="checkbox_hexforbinary">'.$langs->trans("EncodeBinariesInHexa").'</label>';
349  print '<br>';
350 
351  print '<input type="checkbox" name="charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
352  print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
353  print '<br>';
354 
355  print '</fieldset>';
356  print '</fieldset>';
357 
358  // Export mysql bin
359  print "<!-- Fieldset mysql_nobin -->\n";
360  print '<fieldset id="mysql_nobin_options">';
361 
362  print '<fieldset>';
363  print '<legend>'.$langs->trans("ExportOptions").'</legend>';
364 
365  print '<div class="formelementrow">';
366  print '<input type="checkbox" name="nobin_use_transaction" value="yes" id="checkbox_use_transaction" />';
367  print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
368  print '</div>';
369 
370  if (getDolGlobalString('MYSQL_OLD_OPTION_DISABLE_FK')) {
371  print '<div class="formelementrow">';
372  print '<input type="checkbox" name="nobin_disable_fk" value="yes" id="checkbox_disable_fk" checked />';
373  print '<label for="checkbox_disable_fk">'.$langs->trans("CommandsToDisableForeignKeysForImport").' '.img_info($langs->trans('CommandsToDisableForeignKeysForImportWarning')).'</label>';
374  print '</div>';
375  }
376  print '</fieldset>';
377 
378  print '<br>';
379  print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
380  print '<input type="checkbox" name="nobin_drop"'.((!GETPOSTISSET("nobin_drop") || GETPOST('nobin_drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
381  print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
382  print '<br>';
383  print '</fieldset>';
384 
385  print '<br>';
386  print '<fieldset>';
387  print '<legend>'.$langs->trans("Datas").'</legend>';
388 
389  print '<input type="checkbox" name="nobin_nolocks" value="no" id="checkbox_dump_disable-add-locks" />';
390  print '<label for="checkbox_dump_disable-add-locks">'.$langs->trans("NoLockBeforeInsert").'</label>';
391  print '<br>';
392 
393  print '<input type="checkbox" name="nobin_delayed" value="yes" id="checkbox_dump_delayed" />';
394  print '<label for="checkbox_dump_delayed">'.$langs->trans("DelayedInsert").'</label>';
395  print '<br>';
396 
397  print '<input type="checkbox" name="nobin_sql_ignore" value="yes" id="checkbox_dump_ignore" />';
398  print '<label for="checkbox_dump_ignore">'.$langs->trans("IgnoreDuplicateRecords").'</label>';
399  print '<br>';
400 
401  print '<input type="checkbox" name="nobin_charset_utf8" value="yes" id="checkbox_charset_utf8" checked disabled />';
402  print '<label for="checkbox_charset_utf8">'.$langs->trans("UTF8").'</label>';
403  print '<br>';
404 
405  print '</fieldset>';
406  print '</fieldset>';
407 }
408 
409 if (in_array($type, array('pgsql'))) {
410  print "<!-- Fieldset pg_dump -->\n";
411  print '<fieldset id="postgresql_options">';
412 
413 
414  print '<fieldset class="formelementrow"><legend>'.$langs->trans("FullPathToPostgreSQLdumpCommand").'</legend>';
415  if (!getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP')) {
416  $fullpathofpgdump = $db->getPathOfDump();
417  } else {
418  $fullpathofpgdump = getDolGlobalString('SYSTEMTOOLS_POSTGRESQLDUMP');
419  }
420  print '<br>';
421  print '<input type="text" name="postgresqldump" style="width: 80%" value="'.$fullpathofpgdump.'" />';
422  print '</fieldset>';
423 
424  print '<br>';
425  print '<fieldset>';
426  print '<legend>'.$langs->trans("ExportOptions").'</legend>';
427  print '<label for="select_sql_compat">'.$langs->trans("ExportCompatibility").'</label>';
428  print '<select name="sql_compat" id="select_sql_compat" class="flat">';
429  print '<option value="POSTGRESQL" selected>POSTGRESQL</option>';
430  print '<option value="ANSI">ANSI</option>';
431  print '</select>';
432  print '<br>';
433  print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
434  print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
435  print '-->';
436  print '</fieldset>';
437  print '<br>';
438  print '<fieldset>';
439  print '<legend>';
440  print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
441  print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
442  print '</legend>';
443  print '</fieldset>';
444  print '<br>';
445  print '<fieldset>';
446  print '<legend>';
447  print '<input type="checkbox" name="sql_data" value="data" id="checkbox_sql_data" checked />';
448  print '<label for="checkbox_sql_data">'.$langs->trans("Datas").'</label>';
449  print '</legend>';
450  print '<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" checked />';
451  print '<label for="checkbox_dump_showcolumns">'.$langs->trans("NameColumn").'</label>';
452  print '<br>';
453  print '</fieldset>';
454  print '</fieldset>';
455 }
456 print '</div>';
457 
458 print '</td>';
459 print '</tr>';
460 print '</table>';
461 
462 
463 
464 
465 print '<!--<fieldset>';
466 print '<legend>'.$langs->trans("Destination").'</legend> -->';
467 print '<br>';
468 print '<label for="filename_template" class="line-height-large opacitymedium">'.$langs->trans("FileNameToGenerate").'</label>';
469 print '<br>';
470 $prefix = 'dump';
471 $ext = '.sql';
472 if (in_array($type, array('mysql', 'mysqli'))) {
473  $prefix = 'mysqldump';
474  $ext = 'sql';
475 }
476 //if ($label == 'PostgreSQL') {
477 // $prefix='pg_dump';
478 // $ext='dump';
479 //}
480 if (in_array($type, array('pgsql'))) {
481  $prefix = 'pg_dump';
482  $ext = 'sql';
483 }
484 $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext;
485 print '<input type="text" name="filename_template" style="width: 90%" id="filename_template" value="'.$file.'" />';
486 print '<br>';
487 print '<br>';
488 
489 // Define compressions array
490 $compression = array();
491 if (in_array($type, array('mysql', 'mysqli'))) {
492  $compression['gz'] = array(
493  'function' => 'gzopen',
494  'id' => 'radio_compression_gzip',
495  'label' => $langs->trans("Gzip")
496  );
497  // Not open source format. Must implement dol_compress function
498  // $compression['zip']= array(
499  // 'function' => 'dol_compress',
500  // 'id' => 'radio_compression_zip',
501  // 'label' => $langs->trans("FormatZip")
502  // );
503  $compression['bz'] = array(
504  'function' => 'bzopen',
505  'id' => 'radio_compression_bzip',
506  'label' => $langs->trans("Bzip2")
507  );
508  $compression['zstd'] = array(
509  'function' => 'zstd_compress',
510  'id' => 'radio_compression_zstd',
511  'label' => $langs->trans("Zstd")
512  );
513  $compression['none'] = array(
514  'function' => '',
515  'id' => 'radio_compression_none',
516  'label' => $langs->trans("None")
517  );
518 } else {
519  $compression['none'] = array(
520  'function' => '',
521  'id' => 'radio_compression_none',
522  'label' => $langs->trans("None")
523  );
524  $compression['gz'] = array(
525  'function' => 'gzopen',
526  'id' => 'radio_compression_gzip',
527  'label' => $langs->trans("Gzip")
528  );
529 }
530 
531 // Show compression choices
532 print '<div class="formelementrow">';
533 print "\n";
534 
535 print $langs->trans("Compression").': &nbsp; ';
536 
537 $i = 0;
538 foreach ($compression as $key => $val) {
539  if (!$val['function'] || function_exists($val['function'])) {
540  // Enabled export format
541  $checked = '';
542  if ($key == 'gz') {
543  $checked = ' checked';
544  }
545  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'"'.$checked.'>';
546  print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
547  } else {
548  // Disabled export format
549  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'" disabled>';
550  print ' <label for="'.$val['id'].'">'.$val['label'].'</label>';
551  print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
552  }
553  print ' &nbsp; &nbsp; ';
554  $i++;
555 }
556 
557 print '</div>';
558 print "\n";
559 
560 print "<!--</fieldset>--> <!-- End destination -->\n";
561 
562 print '<br>';
563 print '<div class="center">';
564 print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo">';
565 print '<br>';
566 print '<br>';
567 
568 if (!empty($_SESSION["commandbackuplastdone"])) {
569  print '<br><b>'.$langs->trans("RunCommandSummary").':</b><br>'."\n";
570  print '<textarea rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuplastdone"].'</textarea><br>'."\n";
571  print '<br>';
572 
573  //print $paramclear;
574 
575  // Now show result
576  print '<b>'.$langs->trans("BackupResult").':</b> ';
577  print $_SESSION["commandbackupresult"];
578 
579  $_SESSION["commandbackuplastdone"] = '';
580  $_SESSION["commandbackuptorun"] = '';
581  $_SESSION["commandbackupresult"] = '';
582 }
583 if (!empty($_SESSION["commandbackuptorun"])) {
584  print '<br><span class="warning">'.$langs->trans("YouMustRunCommandFromCommandLineAfterLoginToUser", $dolibarr_main_db_user, $dolibarr_main_db_user).':</span><br>'."\n";
585  print '<textarea id="commandbackuptoruntext" rows="'.ROWS_2.'" class="centpercent">'.$_SESSION["commandbackuptorun"].'</textarea><br>'."\n";
586  print ajax_autoselect("commandbackuptoruntext", 0);
587  print '<br>';
588 
589  //print $paramclear;
590 
591  $_SESSION["commandbackuplastdone"] = '';
592  $_SESSION["commandbackuptorun"] = '';
593  $_SESSION["commandbackupresult"] = '';
594 }
595 
596 print "</div> <!-- end div center button -->\n";
597 
598 //print '</td></tr>';
599 //print '</table>';
600 
601 print "</div> <!-- end div fichehalfleft -->\n";
602 
603 
604 print '<div id="backupdatabaseright" class="fichehalfright">';
605 
606 $filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
607 $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;"');
608 print '<br>';
609 
610 print '</div>';
611 print '</form>';
612 print '</fieldset>';
613 
614 
615 $title = $langs->trans("BackupZipWizard");
616 
617 print "<br>\n";
618 print "<!-- Dump of a server -->\n";
619 
620 print '<form method="post" action="export_files.php" name="dump">';
621 print '<input type="hidden" name="token" value="'.newToken().'" />';
622 print '<input type="hidden" name="export_type" value="server" />';
623 print '<input type="hidden" name="page_y" value="" />';
624 
625 print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">2</legend>';
626 
627 print '<span class="opacitymedium">';
628 print $langs->trans("BackupDesc2", DOL_DATA_ROOT).'<br>';
629 print $langs->trans("BackupDescX").'<br><br>';
630 print '</span>';
631 
632 print '<div id="backupfilesleft" class="fichehalfleft">';
633 
634 print load_fiche_titre($title);
635 
636 print '<label for="zipfilename_template" class="line-height-large paddingbottom opacitymedium">'.$langs->trans("FileNameToGenerate").'</label><br>';
637 $prefix = 'documents';
638 $ext = 'zip';
639 $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser');
640 print '<input type="text" name="zipfilename_template" style="width: 90%" id="zipfilename_template" value="'.$file.'" /> <br>';
641 print '<br>';
642 
643 
644 // Show compression choices
645 // Example: With gz choice, you can compress in 5mn, a file of 2GB directory (after compression) with 10 Mb memory.
646 print '<div class="formelementrow">';
647 print "\n";
648 
649 print $langs->trans("Compression").': &nbsp; ';
650 $filecompression = $compression;
651 unset($filecompression['none']);
652 $filecompression['zip'] = array('function' => 'dol_compress_dir', 'id' => 'radio_compression_zip', 'label' => $langs->trans("FormatZip"));
653 
654 $i = 0;
655 foreach ($filecompression as $key => $val) {
656  if (!$val['function'] || function_exists($val['function'])) { // Enabled export format
657  $checked = '';
658  if ($key == 'gz') {
659  $checked = ' checked';
660  }
661  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'2"'.$checked.'>';
662  print ' <label for="'.$val['id'].'2">'.$val['label'].'</label>';
663  } else { // Disabled export format
664  print '<input type="radio" name="compression" value="'.$key.'" id="'.$val['id'].'2" disabled>';
665  print ' <label for="'.$val['id'].'2">'.$val['label'].'</label>';
666  print ' <span class="opacitymedium">('.$langs->trans("NotAvailable").')</span>';
667  }
668  print ' &nbsp; &nbsp; ';
669  $i++;
670 }
671 
672 print '</div>';
673 print "\n";
674 
675 print '<br>';
676 print '<div class="center">';
677 print '<input type="submit" class="button reposition" value="'.$langs->trans("GenerateBackup").'" id="buttonGo" /><br>';
678 print '<br>';
679 print '</div>';
680 
681 print '</div>';
682 
683 print '<div id="backupfileright" class="fichehalfright">';
684 
685 $filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
686 $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;"');
687 print '<br>';
688 
689 print '</div>';
690 
691 print '</fieldset>';
692 print '</form>';
693 
694 print '<br>';
695 
696 // End of page
697 llxFooter();
698 $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:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
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.
Definition: files.lib.php:1458
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.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.