diff --git a/app/Routes.php b/app/Routes.php index 9a68dbc..6d5509b 100644 --- a/app/Routes.php +++ b/app/Routes.php @@ -26,6 +26,8 @@ $router->post('/api/widgets/{widgetId}/run', 'WidgetApi@run'); $router->post('/api/widgets/{widgetId}/check', 'WidgetApi@check'); $router->post('/api/widgets/{widgetId}/detail', 'WidgetApi@detail'); +//cron +$router->post('/cron/clean', 'CronApi@clean'); //Google Home - API $router->any('/api/HA/auth', 'Oauth'); diff --git a/app/api/CronApi.php b/app/api/CronApi.php new file mode 100644 index 0000000..2505b60 --- /dev/null +++ b/app/api/CronApi.php @@ -0,0 +1,7 @@ +purge(LOGTIMOUT); + } +} \ No newline at end of file diff --git a/app/models/managers/LogMaintainer.php b/app/models/managers/LogMaintainer.php index b852d7c..f2b5941 100644 --- a/app/models/managers/LogMaintainer.php +++ b/app/models/managers/LogMaintainer.php @@ -14,7 +14,11 @@ class LogMaintainer unlink ($dir . $file); } } else { +<<<<<<< HEAD $this->cleaningDir ($dir . $file . "/", $seconds); +======= + $this->cleaningDir ($path . $file . "/", $seconds); +>>>>>>> 1a448663f05f2b4ad7456a89d50312be302cd494 } } } @@ -23,4 +27,8 @@ class LogMaintainer $seconds = $days * 86400; $this->cleaningDir ('../logs/', $seconds); } +<<<<<<< HEAD } +======= +} +>>>>>>> 1a448663f05f2b4ad7456a89d50312be302cd494 diff --git a/app/models/managers/LogManager.php b/app/models/managers/LogManager.php index cb0931d..70354bc 100644 --- a/app/models/managers/LogManager.php +++ b/app/models/managers/LogManager.php @@ -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 {