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/utils.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32 $langs->load(
"admin");
34 $action =
GETPOST(
'action',
'aZ09');
35 $what =
GETPOST(
'what',
'alpha');
36 $export_type =
GETPOST(
'export_type',
'alpha');
37 $file =
GETPOST(
'filename_template',
'alpha');
40 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
41 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
42 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
44 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
47 $offset = $limit * $page;
59 if ($file && !$what) {
61 header(
"Location: ".DOL_URL_ROOT.
'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ExportMethod"))).(GETPOST(
'page_y',
'int') ?
'&page_y='.GETPOST(
'page_y',
'int') :
''));
72 if ($action ==
'delete') {
73 $file = $conf->admin->dir_output.
'/'.
GETPOST(
'urlfile');
88 $_SESSION[
"commandbackuplastdone"] =
'';
89 $_SESSION[
"commandbackuptorun"] =
'';
90 $_SESSION[
"commandbackupresult"] =
'';
94 if (!empty($ExecTimeLimit)) {
95 $err = error_reporting();
98 @set_time_limit($ExecTimeLimit);
99 error_reporting($err);
102 if (!empty($MemoryLimit)) {
103 @ini_set(
'memory_limit', $MemoryLimit);
115 $dump_buffer_len = 0;
118 $time_start = time();
121 $outputdir = $conf->admin->dir_output.
'/backup';
125 $utils =
new Utils($db);
130 if ($what ==
'mysql') {
131 $cmddump =
GETPOST(
"mysqldump",
'none');
134 if (!empty($dolibarr_main_restrict_os_commands)) {
135 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
136 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$cmddump);
137 $basenamecmddump = basename($cmddump);
138 if (!in_array($basenamecmddump, $arrayofallowedcommand)) {
139 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
143 if (!$errormsg && $cmddump) {
144 dolibarr_set_const($db,
'SYSTEMTOOLS_MYSQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
148 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
149 $errormsg = $utils->error;
150 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
151 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
156 if ($what ==
'mysqlnobin') {
157 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
159 $errormsg = $utils->error;
160 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
161 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
165 if ($what ==
'postgresql') {
166 $cmddump =
GETPOST(
"postgresqldump",
'none');
181 if (!$errormsg && $cmddump) {
182 dolibarr_set_const($db,
'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
186 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
187 $errormsg = $utils->error;
188 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
189 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
200 $resultstring .=
'<div class="error">'.$langs->trans(
"Error").
" : ".$errormsg.
'</div>';
202 $_SESSION[
"commandbackupresult"] = $resultstring;
205 setEventMessages($langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>'.$langs->trans(
"YouCanDownloadBackupFile"),
null,
'mesgs');
207 $resultstring =
'<div class="ok">';
208 $resultstring .= $langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>';
209 $resultstring .= $langs->trans(
"YouCanDownloadBackupFile");
210 $resultstring .=
'<div>';
212 $_SESSION[
"commandbackupresult"] = $resultstring;
223 header(
"Location: dolibarr_export.php".(
GETPOST(
'page_y',
'int') ?
'?page_y='.
GETPOST(
'page_y',
'int') :
''));