I++
Письмо с ссылкой на архив с временем последнего падежа отправил вам на почту.
_____________
void x;
$current_size_cache_img = `du -s /var/www/kino/data/www/kino.ru/views/data/images/cache/`;
if (preg_match('#.*?(\d+).*#', $current_size_cache_img, $arrResult))
$current_size_cache_img = (int) $arrResult[1];
else
$current_size_cache_img = 0;
...
// Если $current_size_cache_img больше какой-то величины, то запускаю процедуру прореживания кэша картинок
class lib_TcleanCache extends gen_Tblk_ab {
/**
* public function perform()
*
* @param Iregister $register
* @param mixed $arrIn
*/
public function perform(Iregister $register = null, array $arrIn = array()) {
$dirCache = $arrIn[0];
$sizeDeleting = $arrIn[1];
if (empty($arrIn[2]))
return 0;
$currentSizeCache = $arrIn[2];
$nameFileMutex = $arrIn[3];
$timeLimit = $arrIn[4];
$nameProcess = '';
if (!empty($timeLimit))
$nameProcess = $register->getUniqueName(__CLASS__);
try {
if (is_dir($dirCache)) {
$dir = opendir($dirCache);
$countFiles = 0;
$sizeFiles = 0;
$sizeFile = 0;
$cycle = true;
while ((($file = readdir($dir)) !== false) && $cycle)
if (!preg_match('#^\..*#', $file)) {
$nameFile = $dirCache . $file;
if (is_file($nameFile)) {
if ($countFiles >= 99)
$cycle = false;
++$countFiles;
$sizeFile = filesize($nameFile);
$sizeFiles += ($sizeFile / 1000);
}
}
closedir($dir);
$sizeFile = ($sizeFiles / $countFiles);
$countFiles = (int) ($currentSizeCache / $sizeFile);
$countFilesDeleting = (int) ($sizeDeleting / $sizeFile);
$interval = (int) ($countFiles / $countFilesDeleting);
$sizeFiles = 0;
$cycle = true;
$condition = false;
$oldSizeFiles = 0;
self::setLimitTimeProcess($nameProcess, $timeLimit);
self::startProcess($nameProcess);
while ($cycle && (!self::endRuntimeProcess($nameProcess))) {
$i = 0;
$dir = opendir($dirCache);
while ((($file = readdir($dir)) !== false) && $cycle && (!self::endRuntimeProcess($nameProcess)))
if (!preg_match('#^\..*#', $file)) {
$nameFile = $dirCache . $file;
if (is_file($nameFile)) {
$sizeFile = filesize($nameFile);
if (!$condition) {
if ($i == 0) {
$i = $interval;
$sizeFiles += ($sizeFile / 1000);
if (
file_exists($nameFile) &&
is_readable($nameFile) &&
is_writable($nameFile)
)
@unlink($nameFile);
if ($sizeFiles >= $sizeDeleting)
$cycle = false;
}
--$i;
}
else {
$sizeFiles += ($sizeFile / 1000);
if (
file_exists($nameFile) &&
is_readable($nameFile) &&
is_writable($nameFile)
)
@unlink($nameFile);
if ($sizeFiles >= $sizeDeleting)
$cycle = false;
}
}
}
$condition = true;
if ($sizeFiles == $oldSizeFiles)
$cycle = false;
else
$oldSizeFiles = $sizeFiles;
closedir($dir);
}
self::deleteProcess($nameProcess);
return $sizeFiles;
}
return 0;
}
catch (gen_Texception $exp) {
self::deleteProcess($nameProcess);
if (file_exists($nameFileMutex))
@unlink($nameFileMutex);
return 0;
}
}
}