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