Permalink
Browse files

Merge pull request #14 from pd1acf/master

added function to show only number of historic log files
  • Loading branch information...
dg9vh committed Sep 5, 2018
2 parents 146b2d2 + 318c8bd commit 9319310593bc9556f7b46e7129159f5659b76dee
Showing with 40 additions and 19 deletions.
  1. +5 −0 README.md
  2. +33 −17 include/functions.php
  3. +2 −2 setup.php
@@ -26,6 +26,11 @@ Installation

For detailled installation see `linux-step-by-step.md` within this repository.

Note
============
* You might need to implement a logrotate mechanism for the YSFReflector log files to prevent it to fill your filesystem. This directory is normally configured with 'FilePath=' in /etc/YSFReflector.ini


Contact
=======
Feel free to contact the author via email: dg9vh@darc.de
@@ -68,28 +68,44 @@ function getYSFReflectorLog() {
}
function listdir_by_date($path){
$dir = opendir($path);
$list = array();
while($file = readdir($dir)){
if ($file != '.' and $file != '..'){
$ctime = filectime($data_path . $file) . ',' . $file;
$list[$ctime] = $file;
}
}
closedir($dir);
krsort($list);
return $list;
}
function getOldYSFReflectorLog() {
// first loop through the directory to find all log files for this year
$dir = YSFREFLECTORLOGPATH;
$files = scandir($dir, 1);
$dir = YSFREFLECTORLOGPATH;
$scanlogs = SHOWOLDMHEARD;
$oldlogLines = array();
$dir_files = listdir_by_date($dir);
foreach ($files as $file) {
foreach ($dir_files as $file) {
if ( $file != "." && $file != ".." ) {
if ( $scanlogs >= 0 ) {
if ($log = fopen(YSFREFLECTORLOGPATH."/".$file, 'r')) {
while ($oldlogLine = fgets($log)) {
if (strpos($oldlogLine, 'Received data from') !== false) {
array_push($oldlogLines, $oldlogLine);
}
// Open older Logfiles and copy loglines into oldLogLines-Array()
if ($log = fopen(YSFREFLECTORLOGPATH."/".$file, 'r')) {
while ($oldlogLine = fgets($log)) {
if (strpos($oldlogLine, 'Received data from') !== false) {
array_push($oldlogLines, $oldlogLine);
}
// if (startsWith($oldlogLine, "M:"))
// array_push($oldlogLines, $oldlogLine);
}
fclose($log);
}
}
fclose($log);
}
$scanlogs = $scanlogs - 1;
}
}
}
return $oldlogLines;
@@ -151,8 +151,8 @@ function timezonechoice($selectedzone) {
<div class="panel-body"><input type="checkbox" <?php if (defined("SHOWPROGRESSBARS")) echo "checked" ?> name="SHOWPROGRESSBARS"></div>
</div>
<div class="input-group">
<span class="input-group-addon" id="SHOWOLDMHEARD" style="width: 300px">Show historic heard logs</span>
<div class="panel-body"><input type="checkbox" <?php if (defined("SHOWOLDMHEARD")) echo "checked" ?> name="SHOWOLDMHEARD"></div>
<span class="input-group-addon" id="SHOWOLDMHEARD" style="width: 300px">Show historic heard logs, in days</span>
<input type="text" value="<?php echo constant("SHOWOLDMHEARD") ?>" name="SHOWOLDMHEARD" class="form-control" placeholder="60" aria-describedby="SHOWOLDMHEARD" required data-fv-notempty-message="Value is required">
</div>
<div class="input-group">
<span class="input-group-addon" id="TEMPERATUREALERT" style="width: 300px">Enable CPU-temperature-warning</span>

0 comments on commit 9319310

Please sign in to comment.