PHP_SMART_HOME_V3/app/views/Log.php

49 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2020-05-16 15:18:27 +00:00
<?php
class Log extends Template
{
function __construct()
{
$userManager = new UserManager();
2020-07-23 13:16:44 +00:00
$langMng = new LanguageManager('en');
2020-05-16 15:18:27 +00:00
if (!$userManager->isLogin()){
header('Location: ' . BASEURL . 'login');
}
$template = new Template('log');
$template->prepare('title', 'Log');
$result = array();
2020-07-24 16:21:11 +00:00
$result = $this->logFinder ('../logs/', $result);
2020-05-16 15:18:27 +00:00
$template->prepare('baseDir', BASEDIR);
2020-12-09 11:19:19 +00:00
$template->prepare('baseUrl', BASEURL);
2020-05-16 15:18:27 +00:00
$template->prepare('debugMod', DEBUGMOD);
$template->prepare('logToLiveTime', LOGTIMOUT);
$template->prepare('title', 'Logy');
2020-07-30 14:31:25 +00:00
$template->prepare('logStats', LogMaintainer::getStats());
2020-05-16 15:18:27 +00:00
$template->prepare('logsFiles', $result);
$template->prepare('langMng', $langMng);
$template->render();
}
2020-07-24 16:21:11 +00:00
private function logFinder ($dir, $result) {
$logFiles = scandir ($dir);
foreach ($logFiles as $key => $file) {
if (in_array ($file,array (".", "..", ".gitkeep")))
{
continue;
}
if (!is_dir($dir . $file)) {
$result[$dir][] = $file;
} else {
$result = $this->logFinder ($dir . $file . "/", $result);
}
}
return $result;
}
2020-05-16 15:18:27 +00:00
}