Fixes Of Autoloader

This commit is contained in:
Václav Španinger 2020-07-21 10:34:15 +02:00
parent 1a27993a94
commit 1a448663f0
3 changed files with 27 additions and 27 deletions

View File

@ -1,7 +1,7 @@
<?php
class CronApi extends ApiController {
public function clean(){
$logKeeper = new LogKeeper();
$logKeeper = new LogMaintainer();
$logKeeper->purge(LOGTIMOUT);
}
}

View File

@ -0,0 +1,26 @@
<?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 {
$this->cleaningDir ($path . $file . "/", $seconds);
}
}
}
public function purge ($days) {
$seconds = $days * 86400;
$this->cleaningDir ('../logs/', $seconds);
}
}

View File

@ -9,32 +9,6 @@ class LogRecordType{
const INFO = 'info';
}
class LogKeeper
{
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 {
$this->cleaningDir ($path . $file . "/", $seconds);
}
}
}
function purge ($days) {
$seconds = $days * 86400;
$this->cleaningDir ('../logs/', $seconds);
}
}
class LogManager
{