27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35$action =
GETPOST(
'action',
'aZ09');
36$what =
GETPOST(
'what',
'alpha');
37$export_type =
GETPOST(
'export_type',
'alpha');
41$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
42$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
44$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
45if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
48$offset = $limit * $page;
62$utils =
new Utils($db);
71 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') :
''));
75if ($action ==
'delete') {
86$_SESSION[
"commandbackuplastdone"] =
'';
87$_SESSION[
"commandbackuptorun"] =
'';
88$_SESSION[
"commandbackupresult"] =
'';
92if (!empty($ExecTimeLimit)) {
93 $err = error_reporting();
96 @set_time_limit($ExecTimeLimit);
97 error_reporting($err);
100if (!empty($MemoryLimit)) {
101 @ini_set(
'memory_limit', $MemoryLimit);
112$outputdir = $conf->admin->dir_output.
'/backup';
120if ($what ==
'mysql') {
121 $cmddump =
GETPOST(
"mysqldump",
'none');
124 if (!empty($dolibarr_main_restrict_os_commands)) {
125 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
126 $arrayofallowedcommand = array_map(
'trim', $arrayofallowedcommand);
127 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$cmddump);
128 $basenamecmddump = basename(str_replace(
'\\',
'/', $cmddump));
129 if (!in_array($basenamecmddump, $arrayofallowedcommand)) {
130 $langs->load(
"errors");
131 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
132 $errormsg .=
'<br>'.$langs->trans(
'ErrorCheckTheCommandInsideTheAdvancedOptions');
136 if (!$errormsg && $cmddump) {
137 dolibarr_set_const($db,
'SYSTEMTOOLS_MYSQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
141 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
142 $errormsg = $utils->error;
143 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
144 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
149if ($what ==
'mysqlnobin') {
150 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
152 $errormsg = $utils->error;
153 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
154 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
158if ($what ==
'postgresql') {
159 $cmddump =
GETPOST(
"postgresqldump",
'none');
175 if (!$errormsg && $cmddump) {
176 dolibarr_set_const($db,
'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump,
'chaine', 0,
'', $conf->entity);
180 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
181 $errormsg = $utils->error;
182 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
183 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
194 $resultstring .=
'<div class="error">'.$langs->trans(
"Error").
" : ".$errormsg.
'</div>';
196 $_SESSION[
"commandbackupresult"] = $resultstring;
199 setEventMessages($langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>'.$langs->trans(
"YouCanDownloadBackupFile"),
null,
'mesgs');
201 $resultstring =
'<div class="ok">';
202 $resultstring .= $langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>';
203 $resultstring .= $langs->trans(
"YouCanDownloadBackupFile");
204 $resultstring .=
'</div>';
206 $_SESSION[
"commandbackupresult"] = $resultstring;
225header(
"Location: dolibarr_export.php".(
GETPOST(
'page_y',
'int') ?
'?page_y='.
GETPOST(
'page_y',
'int') :
''));
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).
Class to manage utility methods.
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.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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)
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.