= 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 showCmdT($idx, $title, $command) {
echo "
\n";
echo " \n";
echo "
\n";
echo "" . $title . " |
\n";
echo ""; /* no newline after pre */
echo doCmdT($command);
echo " |
\n";
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 . '';
?>