Fixes Of Autoloader
This commit is contained in:
parent
1a27993a94
commit
1a448663f0
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class CronApi extends ApiController {
|
class CronApi extends ApiController {
|
||||||
public function clean(){
|
public function clean(){
|
||||||
$logKeeper = new LogKeeper();
|
$logKeeper = new LogMaintainer();
|
||||||
$logKeeper->purge(LOGTIMOUT);
|
$logKeeper->purge(LOGTIMOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
26
app/models/managers/LogMaintainer.php
Normal file
26
app/models/managers/LogMaintainer.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -9,32 +9,6 @@ class LogRecordType{
|
|||||||
const INFO = 'info';
|
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
|
class LogManager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user