merge fix

This commit is contained in:
Haitem 2020-07-21 10:46:27 +02:00
commit 5ba86edb69
4 changed files with 17 additions and 26 deletions

View File

@ -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');

7
app/api/CronApi.php Normal file
View File

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

View File

@ -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

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
{