24 if (! defined(
'CSRFCHECK_WITH_TOKEN')) {
25 define(
'CSRFCHECK_WITH_TOKEN',
'1');
28 require
'../../main.inc.php';
29 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 $langs->load(
"admin");
33 $action =
GETPOST(
'action',
'aZ09');
34 $confirm =
GETPOST(
'confirm',
'alpha');
35 $choice =
GETPOST(
'choice',
'aZ09');
40 if (!empty($conf->syslog->enabled)) {
41 $filelog = $conf->global->SYSLOG_FILE;
42 $filelog = preg_replace(
'/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog);
54 if ($action ==
'purge' && !preg_match(
'/^confirm/i', $choice) && ($choice !=
'allfiles' || $confirm ==
'yes')) {
57 if (!empty($ExecTimeLimit)) {
58 $err = error_reporting();
61 @set_time_limit($ExecTimeLimit);
62 error_reporting($err);
65 require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
66 $utils =
new Utils($db);
67 $result = $utils->purgeFiles($choice);
69 $mesg = $utils->output;
84 print
'<span class="opacitymedium">'.$langs->trans(
"PurgeAreaDesc", $dolibarr_main_data_root).
'</span><br>';
88 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
89 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
90 print
'<input type="hidden" name="action" value="purge" />';
92 print
'<table class="border centpercent">';
94 print
'<tr class="border"><td style="padding: 4px">';
96 if (!empty($conf->syslog->enabled)) {
97 print
'<input type="radio" name="choice" id="choicelogfile" value="logfile"';
98 print ($choice && $choice ==
'logfile') ?
' checked' :
'';
99 $filelogparam = $filelog;
100 if ($user->admin && preg_match(
'/^dolibarr.*\.log$/', basename($filelog))) {
101 $filelogparam =
'<a class="wordbreak" href="'.DOL_URL_ROOT.
'/document.php?modulepart=logs&file=';
102 $filelogparam .= basename($filelog);
103 $filelogparam .=
'">'.$filelog.
'</a>';
105 $desc = $langs->trans(
"PurgeDeleteLogFile",
'{filelogparam}');
106 $desc = str_replace(
'{filelogparam}', $filelogparam, $desc);
107 print
'> <label for="choicelogfile">'.$desc.
'</label>';
111 print
'<input type="radio" name="choice" id="choicetempfiles" value="tempfiles"';
112 print (!$choice || $choice ==
'tempfiles' || $choice ==
'allfiles') ?
' checked' :
'';
113 print
'> <label for="choicetempfiles">'.$langs->trans(
"PurgeDeleteTemporaryFilesShort").
'</label><br><br>';
115 print
'<input type="radio" name="choice" id="choiceallfiles" value="confirm_allfiles"';
116 print ($choice && $choice ==
'confirm_allfiles') ?
' checked' :
'';
117 print
'> <label for="choiceallfiles">'.$langs->trans(
"PurgeDeleteAllFilesInDocumentsDir", $dolibarr_main_data_root).
'</label><br>';
119 print
'</td></tr></table>';
124 print
'<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"PurgeRunNow").
'"></div>';
129 if (preg_match(
'/^confirm/i', $choice)) {
131 $formquestion = array();
132 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?choice=allfiles', $langs->trans(
'Purge'), $langs->trans(
'ConfirmPurge').img_warning().
' ',
'purge', $formquestion,
'no', 2);