= 6) $pgtitle = array("OpenBGPD", "Status"); else $pgtitle = "OpenBGPD: Status"; include("head.inc"); function doCmdT($command, $limit = "all", $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 (is_numeric($limit) && $limit > 0 && $cl >= $limit) break; $result .= htmlspecialchars($line, ENT_NOQUOTES); if ($ct++ > 1000) { ob_flush(); $ct = 0; } $cl++; } pclose($fd); return $result; } function countCmdT($command) { $fd = popen("{$command} 2>&1", "r"); $c = 0; while (fgets($fd) !== FALSE) $c++; return $c; } function showCmdT($idx, $title, $command) { echo "

\n"; echo " \n"; echo "\n"; echo "\n"; if ($idx == "routing") { $limit_options = array("10", "50", "100", "200", "500", "1000", "all"); $limit_default = "100"; echo "\n"; echo "\n"; } echo "\n"; echo "
" . $title . "
\n"; echo "Display of " . countCmdT($command) . " routesFilter expression: \n"; echo "\n"; echo "\n"; echo "
";	/* no newline after pre */
	echo doCmdT($command);
	echo "
\n"; } /* Define a command, with a title, to be executed later. */ function defCmdT($idx, $title, $command) { global $commands; $title = htmlspecialchars($title,ENT_NOQUOTES); $commands[$idx] = array($title, $command); } /* List all of the commands as an index. */ function listCmds() { global $commands; echo "

This status page includes the following information:\n"; echo "

\n"; } /* Execute all of the commands which were defined by a call to defCmd. */ function execCmds() { global $commands; foreach ($commands as $idx => $command) showCmdT($idx, $command[0], $command[1]); } ?> ' . $pgtitle . '

'; ?>