get($agencyId);
if ($agency) {
$tarif = new \Tarif;
$tarif->get($agency->id_tarif);
$date_tarif = strtotime($agency->date_tarif);
$date_end = $date_tarif + $tarif->period * 3600 * 24;
$date_end_f = date("d.m.Y H:i", $date_end);
$dney = ceil(($date_end - time()) / 24 / 3600);
echo " Удаляем файлы агентства " . $agencyId . "
";
echo $dney . "
";;
if ($dney < -90) {
$userActive = false;
}
} else {
echo "Не найдено агентство " . $agencyId . "
";
$userActive = false;
}
} else {
echo "Не найдено агентство для пользователя " . $userId . "
";
$agency = new User();
$agency->get($userId);
if ($agency && isset($agency->id_tarif)) {
$tarif = new \Tarif;
$tarif->get($agency->id_tarif);
$date_tarif = strtotime($agency->date_tarif);
$date_end = $date_tarif + $tarif->period * 3600 * 24;
$date_end_f = date("d.m.Y H:i", $date_end);
$dney = ceil(($date_end - time()) / 24 / 3600);
echo " Удаляем файлы агента " . $userId . "
";
echo $dney . "
";;
if ($dney < -90) {
$userActive = false;
}
} else {
echo "Не найден агент " . $userId . "
";
$userActive = false;
}
}
if (!$userActive) {
$countDel++;
echo " Удаляем файл " . $obj['user_id'] . " " . $obj['path'] . "
";
$path = $_SERVER['DOCUMENT_ROOT'] . $obj['path'];
if (file_exists($path)) {
$size = filesize($path);
$sum = $sum + $size;
echo $path . " " . date("d.m.Y H:i:s.", filemtime($path)) . " size: " . formatSizeUnits($size) . "
";
//unlink($path);
}
}
}
}
echo "
".formatSizeUnits($sum);
function formatSizeUnits($bytes)
{
if ($bytes >= 1073741824)
{
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
}
elseif ($bytes >= 1048576)
{
$bytes = number_format($bytes / 1048576, 2) . ' MB';
}
elseif ($bytes >= 1024)
{
$bytes = number_format($bytes / 1024, 2) . ' kB';
}
elseif ($bytes > 1)
{
$bytes = $bytes . ' bytes';
}
elseif ($bytes == 1)
{
$bytes = $bytes . ' byte';
}
else
{
$bytes = '0 bytes';
}
return $bytes;
}