1
0
Fork 0
Manager/cron/assetChecker.php

30 lines
1.1 KiB
PHP

<?php
$statement = $RUNTIME['PDO']->prepare("SELECT id,hash FROM fsassets ORDER BY create_time DESC");
$statement->execute();
$count = 0;
while($row = $statement->fetch())
{
$fileNameParts = array();
$fileNameParts[0] = substr($row['hash'], 0, 2);
$fileNameParts[1] = substr($row['hash'], 2, 2);
$fileNameParts[2] = substr($row['hash'], 4, 2);
$fileNameParts[3] = substr($row['hash'], 6, 4);
$fileNameParts[4] = $row['hash'].".gz";
//$fileNameParts['Time'] = time();
$fileNameParts['UUID'] = $row['id'];
$fileNameParts['FilePath'] = "/data/assets/base/".$fileNameParts[0]."/".$fileNameParts[1]."/".$fileNameParts[2]."/".$fileNameParts[3]."/".$fileNameParts[4];
$fileNameParts['FileSize'] = @filesize($fileNameParts['FilePath']);
$fileNameParts['Count'] = $count++;
if($fileNameParts['FileSize'] == 0 || !file_exists($fileNameParts['FilePath']))
{
$add = $RUNTIME['PDO']->prepare('DELETE FROM fsassets WHERE hash = :fileHash');
$add->execute(['fileHash' => $row['hash']]);
}
}
?>