Merge branch 'remastering' of https://git.steelants.cz/SImple-Home/PHP_SMART_HOME_V3 into remastering

This commit is contained in:
Václav Španinger 2020-07-27 16:57:06 +02:00
commit 5ee1af2571
2 changed files with 75 additions and 63 deletions

View File

@ -16,15 +16,7 @@ class Log extends Template
$template->prepare('title', 'Log'); $template->prepare('title', 'Log');
$result = array(); $result = array();
$cdir = scandir('../logs/'); $result = $this->logFinder ('../logs/', $result);
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..", ".gitkeep")))
{
$result[$value] = $value;
}
}
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('debugMod', DEBUGMOD); $template->prepare('debugMod', DEBUGMOD);
@ -35,4 +27,20 @@ class Log extends Template
$template->render(); $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;
}
} }

View File

@ -1,60 +1,64 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<?php <?php
$partial = new Partial('head'); $partial = new Partial('head');
$partial->prepare('baseDir', $BASEDIR); $partial->prepare('baseDir', $BASEDIR);
$partial->render(); $partial->render();
?> ?>
<title><?php echo $TITLE ?></title> <title><?php echo $TITLE ?></title>
</head> </head>
<body class="no-transitions"> <body class="no-transitions">
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<?php <?php
$partial = new Partial('menu'); $partial = new Partial('menu');
$partial->prepare('item', 'log'); $partial->prepare('item', 'log');
$partial->prepare('langMng',$LANGMNG); $partial->prepare('langMng',$LANGMNG);
$partial->prepare('debugMod',$DEBUGMOD); $partial->prepare('debugMod',$DEBUGMOD);
$partial->render(); $partial->render();
?> ?>
</div> </div>
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4"> <div class="col-12 col-sm-9 mx-auto mt-4">
<h1><?php echo $LANGMNG->get('t_Logs'); ?></h1> <h1><?php echo $LANGMNG->get('t_Logs'); ?></h1>
<label><?php echo $LANGMNG->get('l_logMaxLiveTime') . " " . $LOGTOLIVETIME . " days";?></label></br> <label><?php echo $LANGMNG->get('l_logMaxLiveTime') . " " . $LOGTOLIVETIME . " days";?></label></br>
<form method="post" action=""> <form method="post" action="">
<div class="field"> <div class="field">
<select class="input" name="LogFile"> <select class="input" name="LogFile">
<?php foreach ($LOGSFILES as $key => $value) { ?> <?php foreach ($LOGSFILES as $key => $value) { ?>
<option value="<?php echo $value; ?>"><?php echo $value; ?></option> <optgroup label="<?php echo str_replace("../", "", $key); ?>">
<?php } ?> <?php foreach ($value as $valueSub) { ?>
</select> <option value="<?php echo $key . $valueSub; ?>"><?php echo $valueSub; ?></option>
</div> <?php } ?>
<div class="field"> </optgroup>
<input type="submit" class="button" name="selectFile" value="<?php $LANGMNG->echo('b_select');?>"/> <?php } ?>
</div> </select>
</form> </div>
<?php <div class="field">
if (isset($_POST['LogFile'])) { <input type="submit" class="button" name="selectFile" value="<?php $LANGMNG->echo('b_select');?>"/>
$file_lines = file('../logs/' . $_POST['LogFile']); </div>
echo '<pre style="overflow: auto;">'; </form>
foreach ($file_lines as $line) { <?php
echo $line; if (isset($_POST['LogFile'])) {
} $file_lines = file($_POST['LogFile']);
echo '</pre>'; echo '<pre style="overflow: auto;">';
} foreach ($file_lines as $line) {
?> echo $line;
</div> }
</div> echo '</pre>';
}
?>
</div>
</div>
<?php <?php
$partial = new Partial('footer'); $partial = new Partial('footer');
$partial->prepare('baseDir', BASEDIR); $partial->prepare('baseDir', BASEDIR);
$partial->render(); $partial->render();
//TODO js do main.js //TODO js do main.js
?> ?>
</body> </body>
</html> </html>