Files
H1502_website/wsenlog.php
2019-08-14 15:01:16 +02:00

56 lines
1.7 KiB
PHP

<?php include('partialpage/header.php');?>
<?php include('partialpage/sidebar.php');?>
<?php
$filename = "/var/log/wsen.log";
if($_SERVER['REQUEST_METHOD'] == 'POST' ){
if ($_POST['filename']){
if(strpos($_POST['filename'], '-') == false){
$filename = "/var/log/".$_POST['filename'];
}else{
$filename = "/wsen-log/".$_POST['filename'];
}
}
};
?>
<!-- !PAGE CONTENT! -->
<div class="w3-main" style="margin-left:340px;margin-right:40px">
<!-- wsenlog output -->
<div class="w3-container" id="wsenlog" style="margin-top:75px">
<h1 class="w3-jumbo"><b>WSEN Logging</b></h1>
<br>
<div style="border:5px solid red; width:100px" class="w3-round"></div>
<div class="w3-container" id="filelist" style="margin-top:75px">
<div class="w3-col l6">
<form action="wsenlog.php" method="post">
<div class="w3-section">
<select name="filename" class="w3-select">
<?php foreach (glob("/wsen-log/*.*") as $filelistname) {
echo "<option value='".basename($filelistname)."'>".basename($filelistname)."</option>";
}?>
</select>
</div>
<button type="submit" class="w3-button w3-block w3-padding-large w3-red w3-margin-bottom">Read logfile</button>
</form>
</div>
</div>
<p>Logfile from WSEN (<?php echo $filename;?>).</p>
<div class="w3-section">
<textarea class="w3-input w3-border" type="text" name="wsenlog" rows="50">
<?php if (file_exists($filename)) {
echo file_get_contents($filename);
} else {
echo "File ".$filename." not found";
}?></textarea>
</div>
</div>
<!-- End page content -->
</div>
<?php include('partialpage/footer.php');?>