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/utils.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31 $langs->load(
"admin");
33 $action =
GETPOST(
'action',
'aZ09');
34 $what =
GETPOST(
'what',
'alpha');
35 $export_type =
GETPOST(
'export_type',
'alpha');
36 $file =
GETPOST(
'filename_template',
'alpha');
39 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
40 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
41 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
43 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
44 $offset = $limit * $page;
45 if (!$sortorder) $sortorder =
"DESC";
46 if (!$sortfield) $sortfield =
"date";
53 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') :
''));
64 if ($action ==
'delete')
66 $file = $conf->admin->dir_output.
'/'.
GETPOST(
'urlfile');
78 $_SESSION[
"commandbackuplastdone"] =
'';
79 $_SESSION[
"commandbackuptorun"] =
'';
80 $_SESSION[
"commandbackupresult"] =
'';
84 if (!empty($ExecTimeLimit))
86 $err = error_reporting();
89 @set_time_limit($ExecTimeLimit);
90 error_reporting($err);
93 if (!empty($MemoryLimit))
95 @ini_set(
'memory_limit', $MemoryLimit);
98 $form =
new Form($db);
109 $dump_buffer_len = 0;
112 $time_start = time();
115 $outputdir = $conf->admin->dir_output.
'/backup';
119 $utils =
new Utils($db);
123 if ($what ==
'mysql')
125 $cmddump =
GETPOST(
"mysqldump",
'none');
128 if (!empty($dolibarr_main_restrict_os_commands))
130 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
131 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$cmddump);
132 $basenamecmddump = basename($cmddump);
133 if (!in_array($basenamecmddump, $arrayofallowedcommand))
135 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
139 if (!$errormsg && $cmddump)
141 dolibarr_set_const($db,
'SYSTEMTOOLS_MYSQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
146 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file);
147 $errormsg = $utils->error;
148 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
149 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
154 if ($what ==
'mysqlnobin')
156 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file);
158 $errormsg = $utils->error;
159 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
160 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
164 if ($what ==
'postgresql')
166 $cmddump =
GETPOST(
"postgresqldump",
'none');
181 if (!$errormsg && $cmddump)
183 dolibarr_set_const($db,
'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
188 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file);
189 $errormsg = $utils->error;
190 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
191 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
203 $resultstring .=
'<div class="error">'.$langs->trans(
"Error").
" : ".$errormsg.
'</div>';
205 $_SESSION[
"commandbackupresult"] = $resultstring;
209 setEventMessages($langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>'.$langs->trans(
"YouCanDownloadBackupFile"), null,
'mesgs');
211 $resultstring =
'<div class="ok">';
212 $resultstring .= $langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>';
213 $resultstring .= $langs->trans(
"YouCanDownloadBackupFile");
214 $resultstring .=
'<div>';
216 $_SESSION[
"commandbackupresult"] = $resultstring;
233 header(
"Location: dolibarr_export.php".(
GETPOST(
'page_y',
'int') ?
'?page_y='.
GETPOST(
'page_y',
'int') :
''));
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage utility methods.
dol_sanitizePathName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a path name.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
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 ...
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)