diff options
author | Colin Smith <colin@pfsense.org> | 2005-04-05 00:45:13 +0000 |
---|---|---|
committer | Colin Smith <colin@pfsense.org> | 2005-04-05 00:45:13 +0000 |
commit | 2c64eed71bea98db80752c89a504c0d9302015c5 (patch) | |
tree | f80057bf9679ddf606ef38fcd37e83394f38bff3 | |
parent | fb8d451e70a18be9901f4bea76955453983b90e6 (diff) | |
download | pfsense-2c64eed71bea98db80752c89a504c0d9302015c5.zip pfsense-2c64eed71bea98db80752c89a504c0d9302015c5.tar.gz |
Make dump_clog more versatile and move it to guiconfig.inc.
-rwxr-xr-x | usr/local/www/guiconfig.inc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index 5a218f9..39e9e7c 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -452,6 +452,34 @@ function update_changedesc($update) { $changecount++; } +function dump_clog($logfile, $tail, $grepfor, $grepinvert = false, $withorig = true) { + global $g, $config; + + $sor = isset($config['syslog']['reverse']) ? "-r" : ""; + + if($grepfor <> "") { + if($grepinvert == true) { + exec("/usr/sbin/clog {$logfile} | /usr/bin/grep -v {$grepfor} | /usr/bin/tail {$sor} -n {$tail}", $logarr); + } else { + exec("/usr/sbin/clog {$logfile} | /usr/bin/grep {$grepfor} | /usr/bin/tail {$sor} -n {$tail}", $logarr); + } + } else { + exec("/usr/sbin/clog {$logfile} | /usr/bin/tail {$sor} -n {$tail}", $logarr); + } + foreach ($logarr as $logent) { + $logent = preg_split("/\s+/", $logent, 6); + echo "<tr valign=\"top\">\n"; + + if ($withorig) { + echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n"; + echo "<td class=\"listr\">" . htmlspecialchars($logent[4] . " " . $logent[5]) . "</td>\n"; + } else { + echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n"; + } + echo "</tr>\n"; + } +} + /* Check if variable has changed, update and log if it has * returns true if var changed * varname = variable name in plain text |