From d9e65f4b5df5f0c8d73cafd496cc12566e90fea7 Mon Sep 17 00:00:00 2001 From: Krombel Date: Tue, 24 Apr 2018 14:55:40 +0200 Subject: [PATCH] make cleanup of database database independent --- cron.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cron.php b/cron.php index b208958..d8d2ff1 100644 --- a/cron.php +++ b/cron.php @@ -125,17 +125,19 @@ foreach ($mx_db->query($sql) as $row) { try { //cleanup: all finished entries older than one month + $timestamp = date('Y-m-d H:m:s',strtotime("-1 month")); $mx_db->query("DELETE FROM registrations " - . "WHERE request_date < (datetime('now', '-1 month')) " + . "WHERE request_date < '$timestamp'" . " AND (state = " . RegisterState::RegistrationDeclined . " OR state = " . RegisterState::AllDone . " );" ); //cleanup: all entries which are pending email registration older than two days + $timestamp = date('Y-m-d H:m:s',strtotime("-2 days")); $mx_db->query("DELETE FROM registrations " - . "WHERE request_date < (datetime('now', '-2 days')) " + . "WHERE request_date < '$timestamp'" . " AND state = " . RegisterState::PendingEmailVerify . ";" ); -} catch (Exception $ex) { +} catch (Exception $e) { print("Error while database cleanup\n"); print($e->getMessage()); }