diff options
author | sbeaver <sbeaver@netgate.com> | 2015-04-21 13:54:36 -0400 |
---|---|---|
committer | sbeaver <sbeaver@netgate.com> | 2015-04-21 13:54:36 -0400 |
commit | 33d52df1af3d8bd2d74686dd223044f2f10dcfbf (patch) | |
tree | 743167ee5c3ccb2a22b8dbbb216f4cc0bd6b9355 | |
parent | 2e101d899984ae789e045df383cf277670c506b4 (diff) | |
download | pfsense-33d52df1af3d8bd2d74686dd223044f2f10dcfbf.zip pfsense-33d52df1af3d8bd2d74686dd223044f2f10dcfbf.tar.gz |
daig_logs.php conversion complete
This conversion relies on a change to guiconfig.inc.
A new function was added: dump_clog_no_table() which performs the same
tasks as dump_clog() but does not output table elements.
This function can replace dump_clog() when all of the diag_log*.php
files have been converted.
-rwxr-xr-x | usr/local/www/diag_logs.php | 125 | ||||
-rw-r--r-- | usr/local/www/guiconfig.inc | 48 |
2 files changed, 107 insertions, 66 deletions
diff --git a/usr/local/www/diag_logs.php b/usr/local/www/diag_logs.php index cb76724..ae09d2b 100755 --- a/usr/local/www/diag_logs.php +++ b/usr/local/www/diag_logs.php @@ -66,73 +66,66 @@ if ($filtertext) $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("General")); include("head.inc"); -?> +$tab_array = array(); +$tab_array[] = array(gettext("System"), true, "diag_logs.php"); +$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php"); +$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php"); +$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php"); +$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php"); +$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php"); +$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php"); +$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php"); +$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php"); +$tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php"); +$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php"); +display_top_tabs($tab_array); + +$tab_array = array(); +$tab_array[] = array(gettext("General"), true, "/diag_logs.php"); +$tab_array[] = array(gettext("Gateways"), false, "/diag_logs_gateways.php"); +$tab_array[] = array(gettext("Routing"), false, "/diag_logs_routing.php"); +$tab_array[] = array(gettext("Resolver"), false, "/diag_logs_resolver.php"); +$tab_array[] = array(gettext("Wireless"), false, "/diag_logs_wireless.php"); +display_top_tabs($tab_array, false, 'nav nav-tabs'); + +require('classes/Form.class.php'); + +$form = new Form(false); + +$section = new Form_Section('Log file filter'); + +$section->addInput(new Form_Input( + 'filtertext', + 'Filter', + 'text', + $filtertext, + ['placeholder' => 'Filter text'] +)); + +$form->addGlobal(new Form_Button( + 'filtersubmit', + 'Filter' +))->removeClass('btn-primary')->addClass('btn-default'); + +$form->addGlobal(new Form_Button( + 'clear', + 'Clear log' +))->removeClass('btn-primary')->addClass('btn-danger'); + +$form->add($section); +print $form; -<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<?php include("fbegin.inc"); ?> -<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="logs system"> - <tr> - <td> -<?php - $tab_array = array(); - $tab_array[] = array(gettext("System"), true, "diag_logs.php"); - $tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php"); - $tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php"); - $tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php"); - $tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php"); - $tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php"); - $tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php"); - $tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php"); - $tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php"); - $tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php"); - $tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php"); - display_top_tabs($tab_array); ?> - </td> - </tr> - <tr><td class="tabnavtbl"> + <div class="panel panel-default"> + <div class="panel-heading"><?=gettext("Last ")?><?=$nentries?><?=gettext(" log entries")?></div> + <pre> <?php - $tab_array = array(); - $tab_array[] = array(gettext("General"), true, "/diag_logs.php"); - $tab_array[] = array(gettext("Gateways"), false, "/diag_logs_gateways.php"); - $tab_array[] = array(gettext("Routing"), false, "/diag_logs_routing.php"); - $tab_array[] = array(gettext("Resolver"), false, "/diag_logs_resolver.php"); - $tab_array[] = array(gettext("Wireless"), false, "/diag_logs_wireless.php"); - display_top_tabs($tab_array); + if($filtertext) + dump_clog_no_table($system_logfile, $nentries, true, array("$filtertext"), array("ppp")); + else + dump_clog_no_table($system_logfile, $nentries, true, array(), array("ppp")); ?> - </td> - </tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area"> - <tr> - <td colspan="2" class="listtopic"><?php printf(gettext("Last %s system log entries"),$nentries); ?></td> - </tr> - <?php - if($filtertext) - dump_clog($system_logfile, $nentries, true, array("$filtertext"), array("ppp")); - else - dump_clog($system_logfile, $nentries, true, array(), array("ppp")); - ?> - <tr> - <td align="left" valign="top"> - <form id="filterform" name="filterform" action="diag_logs.php" method="post" style="margin-top: 14px;"> - <input id="submit" name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log");?>" /> - </form> - </td> - <td align="right" valign="top" > - <form id="clearform" name="clearform" action="diag_logs.php" method="post" style="margin-top: 14px;"> - <input id="filtertext" name="filtertext" value="<?=$filtertext;?>" /> - <input id="filtersubmit" name="filtersubmit" type="submit" class="formbtn" value="<?=gettext("Filter");?>" /> - </form> - </td> - </tr> - </table> - </div> - </td> - </tr> -</table> -<?php include("fend.inc"); ?> -</body> -</html> + </pre> + </div> + +<?php include("foot.inc"); ?> diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index 9b8e7bd..6f37c2d 100644 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -551,6 +551,54 @@ function clear_all_log_files() { return; } +// This version of dump_clog() does not output <td></td> or any other table elements. It can be renamed +// and the dump_clog() removed once all of the diag_log*.php files have been converted to Bootstrap +function dump_clog_no_table($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 { + if(isset($config['system']['usefifolog'])) + exec("/usr/sbin/fifolog_reader " . 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); + } + } + echo "\n"; + + foreach ($logarr as $logent) { + $logent = preg_split("/\s+/", $logent, 6); + + if ($withorig) { + if(isset($config['system']['usefifolog'])) { + $entry_date_time = htmlspecialchars(date("F j, Y, g:i a","" . $logent[1] . "")); + $entry_text = htmlspecialchars($logent[5]); + } else { + $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}"; + echo " " . "{$entry_text}" . "\n"; + } else { + echo htmlspecialchars($logent[5]) . "\n"; + } + + } +} + function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") { global $g, $config; $sor = isset($config['syslog']['reverse']) ? "-r" : ""; |