PHP_SMART_HOME_V3/app/views/Log.php
2020-07-24 18:21:11 +02:00

47 lines
1.0 KiB
PHP

<?php
class Log extends Template
{
function __construct()
{
$userManager = new UserManager();
$langMng = new LanguageManager('en');
if (!$userManager->isLogin()){
header('Location: ' . BASEURL . 'login');
}
$template = new Template('log');
$template->prepare('title', 'Log');
$result = array();
$result = $this->logFinder ('../logs/', $result);
$template->prepare('baseDir', BASEDIR);
$template->prepare('debugMod', DEBUGMOD);
$template->prepare('logToLiveTime', LOGTIMOUT);
$template->prepare('title', 'Logy');
$template->prepare('logsFiles', $result);
$template->prepare('langMng', $langMng);
$template->render();
}
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;
}
}