Commit 0528a90a authored by Franco Fichtner's avatar Franco Fichtner

proxy: convert log file

While there, improve the logic for writing error messages for
log files, e.g. clog files would never be empty.  ;)
parent 120899b3
......@@ -59,9 +59,6 @@
<DHCP url="/diag_logs_dhcp.php"/>
<PPP url="/diag_logs_ppp.php"/>
<VPN url="/diag_logs_vpn.php*"/>
<Proxy url="/diag_logs_proxy.php">
<ProxyActions url="/diag_logs_proxy.php?*"/>
</Proxy>
</LogFiles>
<Settings cssClass="fa fa-cogs">
<General url="/system_general.php"/>
......@@ -243,7 +240,12 @@
<PPPoEServer VisibleName="PPPoE Server" url="/vpn_pppoe.php">
<PPPoeServerEdit url="/vpn_pppoe_edit.php"/>
</PPPoEServer>
<Proxy VisibleName="Proxy Server" url="/ui/proxy/"/>
<Proxy VisibleName="Proxy Server" cssClass="fa fa-bolt">
<Administration url="/ui/proxy/"/>
<Log VisibleName="Log File" url="/diag_logs_proxy.php?type=cache">
<More url="/diag_logs_proxy.php*"/>
</Log>
</Proxy>
<SNMP VisibleName="SNMP" url="/services_snmp.php"/>
<Status VisibleName="Status Overview" url="/status_services.php">
<ServicesActions url="/status_services.php?*"/>
......
......@@ -122,9 +122,6 @@
> a {
border-radius: $nav-pills-border-radius;
}
+ li {
margin-left: 2px;
}
// Active state
&.active > a {
......
......@@ -3443,8 +3443,6 @@ tbody.collapse.in {
float: left; }
.nav-pills > li > a {
border-radius: 0; }
.nav-pills > li + li {
margin-left: 2px; }
.nav-pills > li.active > a, .nav-pills > li.active > a:hover, .nav-pills > li.active > a:focus {
color: #fff;
background-color: #EA7105; }
......
......@@ -51,7 +51,7 @@ if ($tab_group == 'vpn') {
$tab_array[] = array(gettext("Wireless"), false, "/diag_logs_wireless.php");
}
?><ul class="nav nav-pills __mb" role="tablist">
?><ul class="nav nav-pills" role="tablist">
<? foreach ($tab_array as $tab): ?>
<li role="presentation" <? if (str_replace('amp;','', $tab[2]) == $_SERVER['REQUEST_URI']):?>class="active"<? endif; ?>><a href="<?=$tab[2];?>"><?=$tab[0];?></a></li>
<? endforeach; ?>
......
......@@ -46,7 +46,7 @@ if (isset($_GET['clear'])) {
clear_log($logfile);
}
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Proxy"));
$pgtitle = array(gettext('Services'), gettext('Proxy Server'), gettext('Log File'));
include("head.inc");
......@@ -58,20 +58,19 @@ include("head.inc");
<div class="container-fluid">
<div class="row">
<section class="col-xs-12">
<?php include('diag_logs_tabs.inc'); ?>
<div class="tab-content content-box col-xs-12">
<div class="container-fluid">
<?php $tab_group = 'proxy'; include('diag_logs_pills.inc'); ?>
<p><?php printf(gettext("Last %s Proxy log entries"), $nentries);?></p>
<div class="table-responsive">
<table class="table table-striped table-sort">
<?php dump_log($logfile, $nentries); ?>
</table>
</div>
<form method="get">
<input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" />
<input name="type" type="hidden" value="<?= $type ?>" />
</form>
<div class="table-responsive">
<table class="table table-striped table-sort">
<tr><td colspan="2"><?php $tab_group = 'proxy'; include('diag_logs_pills.inc'); ?></td></tr>
<tr><td colspan="2"><strong><?= sprintf(gettext("Last %s Proxy log entries"), $nentries);?></strong></td></tr>
<?php dump_log($logfile, $nentries); ?>
<tr><td colspan="2">
<form method="get">
<input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" />
<input name="type" type="hidden" value="<?= $type ?>" />
</form>
</td></tr>
</table>
</div>
</div>
</section>
......
......@@ -33,5 +33,4 @@ $tab_array[] = array(gettext("Firewall"), $active_tab == "/diag_logs_filter.php"
$tab_array[] = array(gettext("DHCP"), $active_tab == "/diag_logs_dhcp.php", "diag_logs_dhcp.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("Proxy"), $active_tab == "/diag_logs_proxy.php", "diag_logs_proxy.php?type=cache");
display_top_tabs($tab_array);
......@@ -385,7 +385,9 @@ function print_dump($logarr, $withorig)
foreach ($logarr as $logent) {
$logent = preg_split("/\s+/", $logent, 6);
echo "<tr valign=\"top\">\n";
if ($withorig) {
if ($logent[0] === 'File') {
echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars(join(' ', $logent)) . "</td>\n";
} elseif ($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]);
......@@ -418,12 +420,14 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert
$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);
}
if (!count($logarr)) {
$logarr[] = sprintf(gettext('File %s is empty.'), $logfile);
}
print_dump($logarr, $withorig);
}
......@@ -444,15 +448,17 @@ function dump_log($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert
}
if (is_dir($logfile)) {
$logarr = array("File $logfile is a directory.");
$logarr = array(sprintf(gettext('File %s is a directory.'), $logfile));
} elseif (!file_exists($logfile)) {
$logarr = array("File $logfile doesn't exist.");
} elseif (filesize($logfile) == 0) {
$logarr = array("Log file started.");
$logarr = array(sprintf(gettext('File %s doesn\'t exist.'), $logfile));
} else {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
if (!count($logarr)) {
$logarr[] = sprintf(gettext('File %s is empty.'), $logfile);
}
print_dump($logarr, $withorig);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment