-
-
+
+
diff --git a/src/www/diag_logs_relayd.php b/src/www/diag_logs_relayd.php
index daf269efc..b7de84dc1 100644
--- a/src/www/diag_logs_relayd.php
+++ b/src/www/diag_logs_relayd.php
@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) {
}
if ($_POST['clear']) {
- clear_log_file($relayd_logfile);
+ clear_clog($relayd_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Load Balancer"));
diff --git a/src/www/diag_logs_resolver.php b/src/www/diag_logs_resolver.php
index 0e775e518..36cb19523 100644
--- a/src/www/diag_logs_resolver.php
+++ b/src/www/diag_logs_resolver.php
@@ -43,7 +43,7 @@ if (empty($config['syslog']['nentries'])) {
}
if ($_POST['clear']) {
- clear_log_file($system_logfile);
+ clear_clog($system_logfile);
}
if ($_GET['filtertext']) {
diff --git a/src/www/diag_logs_routing.php b/src/www/diag_logs_routing.php
index 857894c41..9dd92d6a4 100644
--- a/src/www/diag_logs_routing.php
+++ b/src/www/diag_logs_routing.php
@@ -40,7 +40,7 @@ if (empty($config['syslog']['nentries'])) {
}
if ($_POST['clear']) {
- clear_log_file($routing_logfile);
+ clear_clog($routing_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Routing"));
diff --git a/src/www/diag_logs_settings.php b/src/www/diag_logs_settings.php
index e9563ce5b..3be7ec358 100644
--- a/src/www/diag_logs_settings.php
+++ b/src/www/diag_logs_settings.php
@@ -1,4 +1,5 @@
+
+$active_tab = isset($active_tab) ? $active_tab : $_SERVER['PHP_SELF'];
+$tab_array = array();
+$tab_array[] = array(gettext("System"), $active_tab == "/diag_logs.php", "diag_logs.php");
+$tab_array[] = array(gettext("Firewall"), $active_tab == "/diag_logs_filter.php", "diag_logs_filter.php");
+$tab_array[] = array(gettext("DHCP"), $active_tab == "/diag_logs_dhcp.php", "diag_logs_dhcp.php");
+$tab_array[] = array(gettext("Portal Auth"), $active_tab == "/diag_logs_auth.php", "diag_logs_auth.php");
+$tab_array[] = array(gettext("IPsec"), $active_tab == "/diag_logs_ipsec.php", "diag_logs_ipsec.php");
+$tab_array[] = array(gettext("PPP"), $active_tab == "/diag_logs_ppp.php", "diag_logs_ppp.php");
+$tab_array[] = array(gettext("VPN"), $active_tab == "/diag_logs_vpn.php", "diag_logs_vpn.php");
+$tab_array[] = array(gettext("Load Balancer"), $active_tab == "/diag_logs_relayd.php", "diag_logs_relayd.php");
+$tab_array[] = array(gettext("OpenVPN"), $active_tab == "/diag_logs_openvpn.php", "diag_logs_openvpn.php");
+$tab_array[] = array(gettext("NTP"), $active_tab == "/diag_logs_ntpd.php", "diag_logs_ntpd.php");
+$tab_array[] = array(gettext("Proxy"), $active_tab == "/diag_logs_proxy.php", "diag_logs_proxy.php");
+$tab_array[] = array(gettext("Settings"), $active_tab == "/diag_logs_settings.php", "diag_logs_settings.php");
+display_top_tabs($tab_array);
diff --git a/src/www/diag_logs_vpn.php b/src/www/diag_logs_vpn.php
index 6ec4ff951..18e0484a5 100644
--- a/src/www/diag_logs_vpn.php
+++ b/src/www/diag_logs_vpn.php
@@ -66,10 +66,11 @@ switch ($vpntype) {
}
if ($_POST['clear']) {
- if ($mode != "raw")
- clear_log_file("/var/log/vpn.log");
- else
- clear_log_file("/var/log/{$logname}.log");
+ if ($mode != "raw") {
+ clear_clog("/var/log/vpn.log");
+ } else {
+ clear_clog("/var/log/{$logname}.log");
+ }
}
function dump_clog_vpn($logfile, $tail) {
diff --git a/src/www/diag_logs_wireless.php b/src/www/diag_logs_wireless.php
index 3e3de0c6b..b612de293 100644
--- a/src/www/diag_logs_wireless.php
+++ b/src/www/diag_logs_wireless.php
@@ -42,7 +42,7 @@ if (empty($config['syslog']['nentries'])) {
}
if ($_POST['clear']) {
- clear_log_file($wireless_logfile);
+ clear_clog($wireless_logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Wireless"));
diff --git a/src/www/guiconfig.inc b/src/www/guiconfig.inc
index e5eba28e0..9d64bd734 100644
--- a/src/www/guiconfig.inc
+++ b/src/www/guiconfig.inc
@@ -347,59 +347,121 @@ function update_changedesc($update) {
$changecount++;
}
-function clear_log_file($logfile = '/var/log/system.log', $restart_syslogd = true)
+function clear_log($logfile, $restart_syslogd = true)
{
- global $config, $g;
- if ($restart_syslogd)
- exec("/usr/bin/killall syslogd");
- if(isset($config['system']['disablesyslogclog'])) {
- unlink($logfile);
- touch($logfile);
- } else {
- $log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "511488";
- exec("/usr/local/sbin/clog -i -s {$log_size} " . escapeshellarg($logfile));
+ if ($restart_syslogd) {
+ killbyname('syslogd');
}
+
+ foreach (glob($logfile . '.*') as $rotated) {
+ @unlink($rotated);
+ }
+
+ /* preserve file ownership and permissions */
+ $handle = fopen($logfile, 'r+');
+ if ($handle) {
+ ftruncate($handle, 0);
+ fclose($handle);
+ }
+
if ($restart_syslogd) {
system_syslogd_start();
}
}
-function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
- global $g, $config;
- $sor = isset($config['syslog']['reverse']) ? "-r" : "";
- $logarr = "";
- $grepline = " ";
- if(is_array($grepfor))
- $grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
- if(is_array($grepinvert))
- $grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
- if (is_dir($logfile)) {
- $logarr = array("File $logfile is a directory.");
- } elseif (file_exists($logfile) && filesize($logfile) == 0) {
- $logarr = array("Log file started.");
- } else {
- if($config['system']['disablesyslogclog']) {
- exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
- } else {
- exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
- }
+function clear_clog($logfile, $restart_syslogd = true)
+{
+ global $config;
+
+ if ($restart_syslogd) {
+ killbyname('syslogd');
}
- foreach ($logarr as $logent) {
- $logent = preg_split("/\s+/", $logent, 6);
- echo "
\n";
- if ($withorig) {
- $entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
- $entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " ";
- $entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]);
- echo "| {$entry_date_time} | \n";
- echo "{$entry_text} | \n";
- } else {
- echo "" . htmlspecialchars($logent[5]) . " | \n";
- }
- echo "
\n";
+
+ $log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : '511488';
+ mwexecf('/usr/local/sbin/clog -i -s %s %s', array($log_size, $logfile));
+
+ if ($restart_syslogd) {
+ system_syslogd_start();
}
}
+function print_dump($logarr, $withorig)
+{
+ global $config;
+
+ foreach ($logarr as $logent) {
+ $logent = preg_split("/\s+/", $logent, 6);
+ echo "
\n";
+ if ($withorig) {
+ $entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
+ $entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " ";
+ $entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]);
+ echo "| {$entry_date_time} | \n";
+ echo "{$entry_text} | \n";
+ } else {
+ echo "" . htmlspecialchars($logent[5]) . " | \n";
+ }
+ echo "
\n";
+ }
+}
+
+function dump_clog($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert = '')
+{
+ global $config;
+
+ $sor = isset($config['syslog']['reverse']) ? '-r' : '';
+ $grepline = ' ';
+ $logarr = '';
+
+ if (is_array($grepfor)) {
+ $grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
+ }
+
+ if (is_array($grepinvert)) {
+ $grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
+ }
+
+ if (is_dir($logfile)) {
+ $logarr = array("File $logfile is a directory.");
+ } elseif (!file_exists($logfile)) {
+ $logarr = array("File $logfile doesn't exist.");
+ } elseif (filesize($logfile) == 0) {
+ $logarr = array("Log file started.");
+ } else {
+ exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
+ }
+
+ print_dump($logarr, $withorig);
+}
+
+function dump_log($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert = '')
+{
+ global $config;
+
+ $sor = isset($config['syslog']['reverse']) ? '-r' : '';
+ $grepline = ' ';
+ $logarr = '';
+
+ if (is_array($grepfor)) {
+ $grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
+ }
+
+ if (is_array($grepinvert)) {
+ $grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
+ }
+
+ if (is_dir($logfile)) {
+ $logarr = array("File $logfile is a directory.");
+ } elseif (!file_exists($logfile)) {
+ $logarr = array("File $logfile doesn't exist.");
+ } elseif (filesize($logfile) == 0) {
+ $logarr = array("Log file started.");
+ } else {
+ exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
+ }
+
+ print_dump($logarr, $withorig);
+}
/* Check if variable has changed, update and log if it has
* returns true if var changed
@@ -523,9 +585,10 @@ function is_specialnet($net) {
* RESULT
* null
******/
-function display_top_tabs(& $tab_array, $no_drop_down = false) {
+function display_top_tabs(& $tab_array, $no_drop_down = false)
+{
global $config;
- global $g;
+
$tab_array_char_limit = 92;
/* does the user have access to this tab?
@@ -583,9 +646,6 @@ function display_top_tabs(& $tab_array, $no_drop_down = false) {
}
}
-
-
-
$timezone = $config['system']['timezone'];
if (!$timezone) {
$timezone = 'Etc/UTC';