From f9d5f68afea91c3c482e244faa6f2beabc4b4ade Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Wed, 24 Jul 2013 09:25:10 -0300 Subject: Simplify a bit how it limit number of routes --- config/openbgpd/openbgpd_status.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'config/openbgpd') diff --git a/config/openbgpd/openbgpd_status.php b/config/openbgpd/openbgpd_status.php index 6c5628e1..a5bbc31c 100644 --- a/config/openbgpd/openbgpd_status.php +++ b/config/openbgpd/openbgpd_status.php @@ -58,20 +58,18 @@ function doCmdT($command, $limit = "all", $filter = "") { $grepline = ""; if (!empty($filter)) $grepline = " | grep " . escapeshellarg(htmlspecialchars($filter)); + if (is_numeric($limit) && $limit > 0) + $headline = " | head -n {$limit}"; - $fd = popen("{$command}{$grepline} 2>&1", "r"); + $fd = popen("{$command}{$grepline}{$headline} 2>&1", "r"); $ct = 0; - $cl = 0; $result = ""; while (($line = fgets($fd)) !== FALSE) { - if (is_numeric($limit) && $limit > 0 && $cl >= $limit) - break; $result .= htmlspecialchars($line, ENT_NOQUOTES); if ($ct++ > 1000) { ob_flush(); $ct = 0; } - $cl++; } pclose($fd); -- cgit v1.2.3