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);
129 if ($what ==
'mysql') {
130 $cmddump =
GETPOST(
"mysqldump",
'none');
133 if (!empty($dolibarr_main_restrict_os_commands)) {
134 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
135 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$cmddump);
136 $basenamecmddump = basename($cmddump);
137 if (!in_array($basenamecmddump, $arrayofallowedcommand)) {
138 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
142 if (!$errormsg && $cmddump) {
143 dolibarr_set_const($db,
'SYSTEMTOOLS_MYSQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
147 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file);
148 $errormsg = $utils->error;
149 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
150 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
155 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') {
165 $cmddump =
GETPOST(
"postgresqldump",
'none');
180 if (!$errormsg && $cmddump) {
181 dolibarr_set_const($db,
'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
185 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file);
186 $errormsg = $utils->error;
187 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
188 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
199 $resultstring .=
'<div class="error">'.$langs->trans(
"Error").
" : ".$errormsg.
'</div>';
201 $_SESSION[
"commandbackupresult"] = $resultstring;
204 setEventMessages($langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>'.$langs->trans(
"YouCanDownloadBackupFile"), null,
'mesgs');
206 $resultstring =
'<div class="ok">';
207 $resultstring .= $langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>';
208 $resultstring .= $langs->trans(
"YouCanDownloadBackupFile");
209 $resultstring .=
'<div>';
211 $_SESSION[
"commandbackupresult"] = $resultstring;
222 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.
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
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 from a POST of a form...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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_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.