diff --git a/package.json b/package.json index 5f88455..4c53a25 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uguu", - "version": "1.8.1", + "version": "1.8.2", "description": "Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.", "homepage": "https://uguu.se", "repository": { diff --git a/src/Classes/expireChecker.php b/src/Classes/expireChecker.php index d13662a..a66e2fd 100755 --- a/src/Classes/expireChecker.php +++ b/src/Classes/expireChecker.php @@ -37,6 +37,15 @@ public function checkDB(): bool | array { } } + public function cleanRateLimitDB(): void { + $query = match ($this->dbType) { + 'pgsql' => 'DELETE FROM ratelimit WHERE time < EXTRACT(epoch from NOW() - INTERVAL \'24 HOURS\')', + default => 'DELETE FROM ratelimit WHERE time <= strftime(\'%s\', datetime(\'now\', \'-24 HOURS\'));' + }; + $q = $this->DB->prepare($query); + $q->execute(); + $q->closeCursor(); + } public function deleteFiles(array $filenames): void { foreach ($filenames as $filename) { unlink($this->CONFIG['FILES_ROOT'] . $filename); diff --git a/src/config.json b/src/config.json index 1566a87..255e9f4 100755 --- a/src/config.json +++ b/src/config.json @@ -1,6 +1,6 @@ { "dest": "dist", - "pkgVersion": "1.8.1", + "pkgVersion": "1.8.2", "pages": [ "index.ejs", "faq.ejs", diff --git a/src/static/php/checkExpire.php b/src/static/php/checkExpire.php index 9544d2a..8199957 100755 --- a/src/static/php/checkExpire.php +++ b/src/static/php/checkExpire.php @@ -24,7 +24,7 @@ $check = new expireChecker(); $dbResult = $check->checkDB(); - +$check->cleanRateLimitDB(); if(empty($dbResult['ids'])){ echo "No file(s) expired, nothing to do."; } else {