diff options
Diffstat (limited to 'usr/local/www/guiconfig.inc')
-rwxr-xr-x | usr/local/www/guiconfig.inc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index 4ba36d8..24656d5 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -588,6 +588,33 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert } } +function return_clog($logfile, $tail, $grepfor = "", $grepinvert = "", $grepreverse = false) { + global $g, $config; + $sor = isset($config['syslog']['reverse']) ? "-r" : ""; + $sor = isset($grepreverse) ? "-r" : ""; + $logarr = ""; + exec("/usr/sbin/clog {$logfile} | grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr); + + if(is_array($grepfor)) { + $i = 0; + foreach($grepfor as $agrep) { + $regexp = "/" . $agrep . "/i"; + if($grepinvert[$i]) { + $logarr = preg_grep($regexp, $logarr, PREG_GREP_INVERT); + } else { + $logarr = preg_grep($regexp, $logarr); + } + $i++; + } + } + $i = 0; + foreach ($logarr as $logent) { + $logarray[$i] = "$logent"; + $i++; + } + return($logarray); +} + /* Check if variable has changed, update and log if it has * returns true if var changed * varname = variable name in plain text |