= 6) $pgtitle = array("OpenBGPD", "Status"); else $pgtitle = "OpenBGPD: Status"; include("head.inc"); function doCmdT($command, $limit = "all", $filter = "", $header_size = 0) { $grepline = ""; if (!empty($filter)) $grepline = " | /usr/bin/grep " . escapeshellarg(htmlspecialchars($filter)); if (is_numeric($limit) && $limit > 0) { $limit += $header_size; $headline = " | /usr/bin/head -n {$limit}"; } $fd = popen("{$command}{$grepline}{$headline} 2>&1", "r"); $ct = 0; $result = ""; while (($line = fgets($fd)) !== FALSE) { $result .= htmlspecialchars($line, ENT_NOQUOTES); if ($ct++ > 1000) { ob_flush(); $ct = 0; } } pclose($fd); return $result; } function countCmdT($command) { $fd = popen("{$command} 2>&1", "r"); $c = 0; while (fgets($fd) !== FALSE) $c++; pclose($fd); return $c; } function showCmdT($idx, $data) { echo "

\n"; echo " \n"; echo "\n"; echo "\n"; $limit_default = "all"; if ($data['has_filter']) { $limit_options = array("10", "50", "100", "200", "500", "1000", "all"); $limit_default = "100"; echo "\n"; echo "\n"; } echo "\n"; echo "
" . $data['title'] . "
\n"; echo "Display itemsFilter expression: \n"; echo "\n"; echo "\n"; echo "
";	/* no newline after pre */
	echo "Gathering data, please wait...\n";
	echo "
\n"; } /* Define a command, with a title, to be executed later. */ function defCmdT($idx, $title, $command, $has_filter = false, $header_size = 0) { global $commands; $title = htmlspecialchars($title,ENT_NOQUOTES); $commands[$idx] = array( 'title' => $title, 'command' => $command, 'has_filter' => $has_filter, 'header_size' => $header_size); } /* 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); } ?> ' . $pgtitle . '

'; ?>