30require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47$action =
GETPOST(
'action',
'aZ09');
48$what =
GETPOST(
'what',
'alpha');
49$export_type =
GETPOST(
'export_type',
'alpha');
54$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
55$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
57if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
60$offset = $limit * $page;
83 header(
"Location: ".DOL_URL_ROOT.
'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"ExportMethod"))).(GETPOSTINT(
'page_y') ?
'&page_y='.GETPOSTINT(
'page_y') :
''));
87if ($action ==
'delete') {
98$_SESSION[
"commandbackuplastdone"] =
'';
99$_SESSION[
"commandbackuptorun"] =
'';
100$_SESSION[
"commandbackupresult"] =
'';
104if (!empty($ExecTimeLimit)) {
105 $err = error_reporting();
108 @set_time_limit($ExecTimeLimit);
109 error_reporting($err);
112if (!empty($MemoryLimit)) {
113 @ini_set(
'memory_limit', $MemoryLimit);
120$outputdir =
$conf->admin->dir_output.
'/backup';
124$lowmemorydump = (int) (GETPOSTISSET(
"lowmemorydump") ?
GETPOSTINT(
"lowmemorydump") :
getDolGlobalInt(
'MAIN_LOW_MEMORY_DUMP'));
128if ($what ==
'mysql') {
129 $cmddump =
GETPOST(
"mysqldump",
'none');
131 $basenamecmddump = basename(str_replace(
'\\',
'/', $cmddump));
134 if (preg_match(
'/\//', str_replace(
'\\',
'/', $cmddump))) {
137 if (preg_match(
'/mysqldump(\.exe)?$/', $cmddump, $reg)) {
138 $cmddump =
'mysqldump'.(empty($reg[1]) ?
'' : $reg[1]);
143 if (!empty($dolibarr_main_restrict_os_commands)) {
144 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
145 $arrayofallowedcommand = array_map(
'trim', $arrayofallowedcommand);
146 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$cmddump);
147 if (!in_array($basenamecmddump, $arrayofallowedcommand)) {
148 $langs->load(
"errors");
149 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
150 $errormsg .=
'<br>'.$langs->trans(
'ErrorCheckTheCommandInsideTheAdvancedOptions');
154 if (!$errormsg && $cmddump) {
159 $result = $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
161 $errormsg = $utils->error;
162 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
163 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
168if ($what ==
'mysqlnobin') {
169 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
171 $errormsg = $utils->error;
172 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
173 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
177if ($what ==
'postgresql') {
178 $cmddump =
GETPOST(
"postgresqldump",
'none');
194 if (!$errormsg && $cmddump) {
199 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
200 $errormsg = $utils->error;
201 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
202 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
213 $resultstring .=
'<div class="error">'.$langs->trans(
"Error").
" : ".$errormsg.
'</div>';
215 $_SESSION[
"commandbackupresult"] = $resultstring;
218 setEventMessages($langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>'.$langs->trans(
"YouCanDownloadBackupFile"),
null,
'mesgs');
220 $resultstring =
'<div class="ok">';
221 $resultstring .= $langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>';
222 $resultstring .= $langs->trans(
"YouCanDownloadBackupFile");
223 $resultstring .=
'</div>';
225 $_SESSION[
"commandbackupresult"] = $resultstring;
244header(
"Location: dolibarr_export.php".(
GETPOSTINT(
'page_y') ?
'?page_y='.
GETPOSTINT(
'page_y') :
''));
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.
dol_is_file($pathoffile)
Return if path is a file.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.