mirror of
https://github.com/nokonoko/Uguu.git
synced 2024-01-06 13:35:15 +00:00
add cleanup for ratelimit table
This commit is contained in:
parent
0206604aec
commit
f195c753f5
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "uguu",
|
"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.",
|
"description": "Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.",
|
||||||
"homepage": "https://uguu.se",
|
"homepage": "https://uguu.se",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -37,6 +37,15 @@ class expireChecker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
public function deleteFiles(array $filenames): void {
|
||||||
foreach ($filenames as $filename) {
|
foreach ($filenames as $filename) {
|
||||||
unlink($this->CONFIG['FILES_ROOT'] . $filename);
|
unlink($this->CONFIG['FILES_ROOT'] . $filename);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dest": "dist",
|
"dest": "dist",
|
||||||
"pkgVersion": "1.8.1",
|
"pkgVersion": "1.8.2",
|
||||||
"pages": [
|
"pages": [
|
||||||
"index.ejs",
|
"index.ejs",
|
||||||
"faq.ejs",
|
"faq.ejs",
|
||||||
|
@ -24,7 +24,7 @@ use Pomf\Uguu\Classes\expireChecker;
|
|||||||
|
|
||||||
$check = new expireChecker();
|
$check = new expireChecker();
|
||||||
$dbResult = $check->checkDB();
|
$dbResult = $check->checkDB();
|
||||||
|
$check->cleanRateLimitDB();
|
||||||
if(empty($dbResult['ids'])){
|
if(empty($dbResult['ids'])){
|
||||||
echo "No file(s) expired, nothing to do.";
|
echo "No file(s) expired, nothing to do.";
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user