= 6) $pgtitle = array("OpenBGPD", "Status"); else $pgtitle = "OpenBGPD: Status"; include("head.inc"); function doCmdT($title, $command) { echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
" . $title . "
";		/* no newline after pre */

	if ($command == "dumpconfigxml") {
		$fd = @fopen("/conf/config.xml", "r");
		if ($fd) {
			while (!feof($fd)) {
				$line = fgets($fd);
				/* remove sensitive contents */
				$line = preg_replace("/.*?<\\/password>/", "xxxxx", $line);
				$line = preg_replace("/.*?<\\/pre-shared-key>/", "xxxxx", $line);
				$line = preg_replace("/.*?<\\/rocommunity>/", "xxxxx", $line);
				$line = str_replace("\t", "    ", $line);
				echo htmlspecialchars($line,ENT_NOQUOTES);
			}
		}
		fclose($fd);
	} else {
		$execOutput = "";
		$execStatus = "";
		exec ($command . " 2>&1", $execOutput, $execStatus);
		for ($i = 0; isset($execOutput[$i]); $i++) {
			if ($i > 0) {
				echo "\n";
			}
			echo htmlspecialchars($execOutput[$i],ENT_NOQUOTES);
		}
	}
    echo "
\n"; } /* Execute a command, giving it a title which is the same as the command. */ function doCmd($command) { doCmdT($command,$command); } /* Define a command, with a title, to be executed later. */ function defCmdT($title, $command) { global $commands; $title = htmlspecialchars($title,ENT_NOQUOTES); $commands[] = array($title, $command); } /* Define a command, with a title which is the same as the command, * to be executed later. */ function defCmd($command) { defCmdT($command,$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; for ($i = 0; isset($commands[$i]); $i++ ) { doCmdT($commands[$i][0], $commands[$i][1]); } } ?> ' . $pgtitle . '

'; ?>