From 5bab233252f907a20496a164c2652e67106b2901 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Thu, 22 Aug 2019 13:19:45 +0200 Subject: [PATCH 1/7] Delete action correction for documents backup. correction of delete action always trying to delete files in document/admin/backup directory. Documents backups are stored in documents/admin/documents directory. If preg_match is too "heavy" it can be replaced by strpos. --- htdocs/admin/tools/dolibarr_export.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index c06314daa9a..f445c7eb791 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,11 +50,21 @@ if (! $user->admin) if ($action == 'delete') { - $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); - $ret=dol_delete_file($file, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $action=''; + if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + { + $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + else + { + $file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + $action=''; } From 9d3b4eb6994a6963c56fba85c7e32be861e5aa30 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 08:05:44 +0200 Subject: [PATCH 2/7] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index f445c7eb791..d3996d44a31 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,21 +50,21 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) - { - $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); - $ret=dol_delete_file($file, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - else - { - $file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha')); - $ret=dol_delete_file($file, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - $action=''; + if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + { + $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + else + { + $file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + $action=''; } From 264763f6b7f5813293268d3d6487607737426681 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 08:31:50 +0200 Subject: [PATCH 3/7] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index d3996d44a31..82554aaf490 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -67,7 +67,6 @@ if ($action == 'delete') $action=''; } - /* * View */ From 3c706ae28ac98e3377da27e2de7af51b027df5ff Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 08:53:43 +0200 Subject: [PATCH 4/7] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 82554aaf490..65a2c40d363 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,7 +50,7 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) { $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $ret=dol_delete_file($file, 1); From 22c661be9f43d68614e88eec7ab6b293776d5f77 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 10:26:07 +0200 Subject: [PATCH 5/7] Update stripe.class.php removed space in line 95 --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 5dda24a763e..cf683671c5d 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -92,7 +92,7 @@ class Stripe extends CommonObject if ($fk_soc > 0) { $sql.= " AND fk_soc = ".$fk_soc; } - else { + else { $sql.= " AND fk_soc IS NULL"; } $sql.= " AND fk_user IS NULL AND fk_adherent IS NULL"; From 6771af4565eda5ad2c7d1722c93222ef32fd1990 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:33:22 +0200 Subject: [PATCH 6/7] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 65a2c40d363..50a590d636b 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,7 +50,7 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + if (preg_match('/backup\//', GETPOST('urlfile', 'alpha'))) { $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $ret=dol_delete_file($file, 1); From 5c13f5d397d13f4a5e299027d1007d6613b33250 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:33:38 +0200 Subject: [PATCH 7/7] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 50a590d636b..e07e7999414 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,7 +50,7 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('/backup\//', GETPOST('urlfile', 'alpha'))) + if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) { $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $ret=dol_delete_file($file, 1);