Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #14 from pd1acf/master
added function to show only number of historic log files
Loading branch information
Showing
3 changed files
with
40 additions
and
19 deletions .
+5
−0
README.md
+33
−17
include/functions.php
+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 >
Toggle all file notes