merge fix
This commit is contained in:
commit
5ba86edb69
@ -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
7
app/api/CronApi.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
class CronApi extends ApiController {
|
||||
public function clean(){
|
||||
$logKeeper = new LogMaintainer();
|
||||
$logKeeper->purge(LOGTIMOUT);
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user