Cleanup Script hinzugefügt

This commit is contained in:
root 2023-03-23 12:41:28 +00:00
parent 16ca95dcd3
commit 2b6e2311c0
2 changed files with 30 additions and 0 deletions

27
cleanup.php Normal file
View File

@ -0,0 +1,27 @@
<?php
if(is_file('config.php')) {
include('config.php');
} else {
include('config.dist.php');
}
$abspath = realpath(dirname(__FILE__));
$temp = scandir($abspath . '/' . $datadir);
$images = array();
foreach($temp as $item) {
if($item != '.' && $item != '..') {
array_push($images, $item);
}
}
foreach($images as $image) {
$diff = time() - filemtime($abspath . '/' . $datadir . '/' . $image);
if($diff >= $lifetime) {
unlink($abspath . '/' . $datadir . '/' . $image);
}
}
?>

View File

@ -12,4 +12,7 @@ $datadir = "i";
// Length of the generated file names
$length = 8;
// Image lifetime in seconds
$lifetime = 3600;
?>