30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48$action =
GETPOST(
'action',
'aZ09');
49$what =
GETPOST(
'what',
'alpha');
50$export_type =
GETPOST(
'export_type',
'alpha');
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
61$offset = $limit * $page;
75$utils =
new Utils($db);
84 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') :
''));
88if ($action ==
'delete') {
99$_SESSION[
"commandbackuplastdone"] =
'';
100$_SESSION[
"commandbackuptorun"] =
'';
101$_SESSION[
"commandbackupresult"] =
'';
105if (!empty($ExecTimeLimit)) {
106 $err = error_reporting();
109 @set_time_limit($ExecTimeLimit);
110 error_reporting($err);
113if (!empty($MemoryLimit)) {
114 @ini_set(
'memory_limit', $MemoryLimit);
121$outputdir =
$conf->admin->dir_output.
'/backup';
125$lowmemorydump = (int) (GETPOSTISSET(
"lowmemorydump") ?
GETPOSTINT(
"lowmemorydump") :
getDolGlobalInt(
'MAIN_LOW_MEMORY_DUMP'));
129if ($what ==
'mysql') {
130 $cmddump =
GETPOST(
"mysqldump",
'none');
132 $basenamecmddump = basename(str_replace(
'\\',
'/', $cmddump));
135 if (preg_match(
'/\//', str_replace(
'\\',
'/', $cmddump))) {
138 if (preg_match(
'/mysqldump(\.exe)?$/', $cmddump, $reg)) {
139 $cmddump =
'mysqldump'.(empty($reg[1]) ?
'' : $reg[1]);
144 if (!empty($dolibarr_main_restrict_os_commands)) {
145 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
146 $arrayofallowedcommand = array_map(
'trim', $arrayofallowedcommand);
147 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$cmddump);
148 if (!in_array($basenamecmddump, $arrayofallowedcommand)) {
149 $langs->load(
"errors");
150 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
151 $errormsg .=
'<br>'.$langs->trans(
'ErrorCheckTheCommandInsideTheAdvancedOptions');
155 if (!$errormsg && $cmddump) {
160 $result = $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
162 $errormsg = $utils->error;
163 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
164 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
169if ($what ==
'mysqlnobin') {
170 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
172 $errormsg = $utils->error;
173 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
174 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
178if ($what ==
'postgresql') {
179 $cmddump =
GETPOST(
"postgresqldump",
'none');
195 if (!$errormsg && $cmddump) {
200 $utils->dumpDatabase(
GETPOST(
'compression',
'alpha'), $what, 0, $file, 0, 0, $lowmemorydump);
201 $errormsg = $utils->error;
202 $_SESSION[
"commandbackuplastdone"] = $utils->result[
'commandbackuplastdone'];
203 $_SESSION[
"commandbackuptorun"] = $utils->result[
'commandbackuptorun'];
214 $resultstring .=
'<div class="error">'.$langs->trans(
"Error").
" : ".$errormsg.
'</div>';
216 $_SESSION[
"commandbackupresult"] = $resultstring;
219 setEventMessages($langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>'.$langs->trans(
"YouCanDownloadBackupFile"),
null,
'mesgs');
221 $resultstring =
'<div class="ok">';
222 $resultstring .= $langs->trans(
"BackupFileSuccessfullyCreated").
'.<br>';
223 $resultstring .= $langs->trans(
"YouCanDownloadBackupFile");
224 $resultstring .=
'</div>';
226 $_SESSION[
"commandbackupresult"] = $resultstring;
245header(
"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.
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.