From 46df12808f26c02394714baa487977e2064f5433 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Tue, 23 Jul 2013 21:35:20 -0300 Subject: Add limit and filter parameters to doCmdT --- config/openbgpd/openbgpd_status.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'config/openbgpd') diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php index dabcd605..d337858e 100644 --- a/config/openbgpd/openbgpd_status.php +++ b/config/openbgpd/openbgpd_status.php @@ -37,16 +37,24 @@ else include("head.inc"); -function doCmdT($command) { - $fd = popen("{$command} 2>&1", "r"); +function doCmdT($command, $limit = 0, $filter = "") { + $grepline = ""; + if (!empty($filter)) + $grepline = " | grep " . escapeshellarg(htmlspecialchars($filter)); + + $fd = popen("{$command}{$grepline} 2>&1", "r"); $ct = 0; + $cl = 0; $result = ""; while (($line = fgets($fd)) !== FALSE) { + if ($limit > 0 && $cl >= $limit) + break; $result .= htmlspecialchars($line, ENT_NOQUOTES); if ($ct++ > 1000) { ob_flush(); $ct = 0; } + $cl++; } pclose($fd); -- cgit v1.2.3