imgpaste/cleanup.php

28 lines
491 B
PHP

<?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);
}
}
?>