Log page, 404 page

This commit is contained in:
JonatanRek 2019-09-01 15:55:33 +02:00
parent aa8235c1bf
commit f1feee4e21
4 changed files with 114 additions and 0 deletions

View File

@ -20,7 +20,11 @@ class Route{
if ($urlValue === $urlGetParam) {
$useView = $this->views[$urlKey];
new $useView();
die();
}
}
echo 'Not Fount 404';
die();
//TODO: 404 přidělat
}
}

View File

@ -43,6 +43,8 @@ $userManager = new UserManager();
if (isset($_POST['username']) && isset($_POST['password']) ) {
$userManager->login($_POST['username'], $_POST['password'], $_POST['remember']);
}
$logManager = new LogManager();
/*
$form = new Form('name','1','POST','');
$form->addInput(InputTypes::TEXT,'nadpis','','Label','');
@ -70,6 +72,7 @@ $route->add('/dashboard', 'Dashboard');
$route->add('/setting', 'Setting');
$route->add('/scene', 'Scene');
$route->add('/ajax', 'Ajax');
$route->add('/log', 'Log');
$route->add('/rooms', 'Rooms');
$route->submit();

73
templates/log.phtml Normal file
View File

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$partial = new Partial('head');
$partial->render();
?>
<title><?php echo $TITLE ?></title>
</head>
<body class="no-transitions">
<div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container">
<div class="nav">
<div class="nav-item">
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a>
</div>
<div class="nav-item">
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a>
</div>
<div class="nav-item is-active">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div>
<div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4">
<form method="post" action="">
<div class="field">
<div class="label">LOG:CZ</div>
<select class="input" name="LogFile">
<?php foreach ($LOGSFILES as $key => $value) { ?>
<option value="<?php echo $value; ?>"><?php echo $value; ?></option>
<?php } ?>
</select>
<input type="submit" class="button" name="selectFile" value="file"/>
</div>
</form>
<?php
if (isset($_POST['LogFile'])) {
$file_lines = file('./logs/' . $_POST['LogFile']);
foreach ($file_lines as $line) {
echo $line . '</br>';
}
}
?>
</div>
</div>
<?php
$partial = new Partial('footer');
$partial->render();
//TODO js do main.js
?>
<script>
$( "#enable-features" ).click(function(e) {
var selectRoomId = localStorage.getItem("enableFeature");
if (selectRoomId){
localStorage.setItem("enableFeature", true);
}else {
localStorage.setItem("enableFeature", false);
}
});
</script>
</body>
</html>

34
views/Log.php Normal file
View File

@ -0,0 +1,34 @@
<?php
class Log extends Template
{
function __construct()
{
global $userManager;
global $lang;
if (!$userManager->isLogin()){
header('Location: ./login');
}
$template = new Template('log');
$template->prepare('title', 'Log');
$result = array();
$cdir = scandir('./logs/');
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..")))
{
$result[$value] = $value;
}
}
$template->prepare('logsFiles', $result);
$template->prepare('lang', $lang);
$template->render();
}
}