PHP_SMART_HOME_V3/app/models/managers/LogMaintainer.php

35 lines
825 B
PHP
Raw Normal View History

<?php
class LogMaintainer
{
private function cleaningDir ($dir, $seconds) {
$todayFileName = date ("Y-m-d").'.log';
$logFiles = scandir ($dir);
foreach ($logFiles as $key => $file) {
if (in_array ($file,array (".", "..", ".gitkeep", $todayFileName)))
{
continue;
}
if (!is_dir($dir . $file)) {
if (strtotime(str_replace(".log", "", $file)) < (strtotime("now") - $seconds)) {
unlink ($dir . $file);
}
} else {
2020-07-21 08:46:27 +00:00
<<<<<<< HEAD
$this->cleaningDir ($dir . $file . "/", $seconds);
2020-07-21 08:46:27 +00:00
=======
2020-07-21 08:34:15 +00:00
$this->cleaningDir ($path . $file . "/", $seconds);
2020-07-21 08:46:27 +00:00
>>>>>>> 1a448663f05f2b4ad7456a89d50312be302cd494
}
}
}
public function purge ($days) {
$seconds = $days * 86400;
$this->cleaningDir ('../logs/', $seconds);
}
2020-07-21 08:46:27 +00:00
<<<<<<< HEAD
}
2020-07-21 08:46:27 +00:00
=======
}
>>>>>>> 1a448663f05f2b4ad7456a89d50312be302cd494