From 26ad6199e55d56a22ccf43f4693aa3732271bd64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Sep 2022 15:33:55 +0200 Subject: [PATCH] NEW The purge of iles can purge only if older than a number of seconds --- htdocs/admin/tools/purge.php | 15 ++++++++---- htdocs/core/class/utils.class.php | 36 +++++++++++++++++++---------- htdocs/core/lib/files.lib.php | 38 +++++++++++++++++-------------- 3 files changed, 55 insertions(+), 34 deletions(-) diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index f6ce58a40c0..4b31d98490e 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -33,7 +33,7 @@ $langs->load("admin"); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $choice = GETPOST('choice', 'aZ09'); - +$nbsecondsold = GETPOSTINT('nbsecondsold'); // Define filelog to discard it from purge $filelog = ''; @@ -42,6 +42,7 @@ if (!empty($conf->syslog->enabled)) { $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); } +// Security if (!$user->admin) { accessforbidden(); } @@ -64,7 +65,8 @@ if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'al require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; $utils = new Utils($db); - $result = $utils->purgeFiles($choice); + + $result = $utils->purgeFiles($choice, $nbsecondsold); $mesg = $utils->output; setEventMessages($mesg, null, 'mesgs'); @@ -114,8 +116,11 @@ print '>