From 1a27993a940d7e1285577fefc7c6712b7c73f472 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 21 Jul 2020 10:29:26 +0200 Subject: [PATCH 1/2] Crone Controlls Commit --- app/Routes.php | 2 ++ app/api/CronApi.php | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 app/api/CronApi.php 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..486d5a9 --- /dev/null +++ b/app/api/CronApi.php @@ -0,0 +1,7 @@ +purge(LOGTIMOUT); + } +} \ No newline at end of file From 1a448663f05f2b4ad7456a89d50312be302cd494 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 21 Jul 2020 10:34:15 +0200 Subject: [PATCH 2/2] Fixes Of Autoloader --- app/api/CronApi.php | 2 +- app/models/managers/LogMaintainer.php | 26 ++++++++++++++++++++++++++ app/models/managers/LogManager.php | 26 -------------------------- 3 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 app/models/managers/LogMaintainer.php diff --git a/app/api/CronApi.php b/app/api/CronApi.php index 486d5a9..2505b60 100644 --- a/app/api/CronApi.php +++ b/app/api/CronApi.php @@ -1,7 +1,7 @@ purge(LOGTIMOUT); } } \ No newline at end of file diff --git a/app/models/managers/LogMaintainer.php b/app/models/managers/LogMaintainer.php new file mode 100644 index 0000000..401e1a1 --- /dev/null +++ b/app/models/managers/LogMaintainer.php @@ -0,0 +1,26 @@ + $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); + } +} \ No newline at end of file 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 {