expire files with no views after 1 day

This commit is contained in:
Kieran 2018-02-27 00:32:39 +08:00
parent db22059d10
commit 79cb22de9a

View File

@ -138,19 +138,26 @@
}
function GetExpiredFiles()
{
return $this->GetExpiredFilesT(_FILE_EXPIRE_TIME);
}
function GetExpiredFilesT($tt)
{
$res = array();
$stmt = $this->mysqli->prepare("select hash160, filename, path from files where date_add(lastview, INTERVAL " . _FILE_EXPIRE_TIME . " DAY) < CURRENT_TIMESTAMP");
$stmt = $this->mysqli->prepare("select hash160, filename, path, lastview, size from files where date_add(lastview, INTERVAL " . $tt . " DAY) < CURRENT_TIMESTAMP or (views = 0 and date_add(lastview, INTERVAL 1 DAY) < CURRENT_TIMESTAMP) order by lastview desc");
if($stmt)
{
$stmt->execute();
$stmt->bind_result($hash160, $filename, $path);
$stmt->bind_result($hash160, $filename, $path, $lastview, $size);
while($stmt->fetch()){
$nf = new FileUpload();
$nf->hash160 = $hash160;
$nf->filename = $filename;
$nf->path = $path;
$nf->lastview = $lastview;
$nf->size = $size;
array_push($res, $nf);
}
$stmt->close();