aboutsummaryrefslogtreecommitdiffstats
path: root/config/unbound/unbound_status.php
diff options
context:
space:
mode:
Diffstat (limited to 'config/unbound/unbound_status.php')
-rw-r--r--config/unbound/unbound_status.php64
1 files changed, 35 insertions, 29 deletions
diff --git a/config/unbound/unbound_status.php b/config/unbound/unbound_status.php
index d011b109..d7371f29 100644
--- a/config/unbound/unbound_status.php
+++ b/config/unbound/unbound_status.php
@@ -31,6 +31,12 @@
require("guiconfig.inc");
+// Define basedir constant for unbound according to FreeBSD version (PBI support or no PBI)
+if (floatval(php_uname("r")) >= 8.3)
+ define("UNBOUND_BASE", "/usr/pbi/unbound-" . php_uname("m"));
+else
+ define("UNBOUND_BASE", "/usr/local");
+
if(!is_process_running("unbound")) {
Header("Location: /pkg_edit.php?xml=unbound.xml&id=0");
exit;
@@ -40,11 +46,11 @@ $pgtitle = "Services: Unbound DNS Forwarder: Status";
include("head.inc");
function doCmdT($title, $command, $rows) {
- echo "<p>\n";
- echo "<a name=\"" . $title . "\">\n";
- echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
- echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n";
- echo "<tr><td class=\"listlr\"><textarea style=\"font-family:courier\"cols=\"101\" rows=\"$rows\">"; /* no newline after pre */
+ echo "<p>\n";
+ echo "<a name=\"" . $title . "\">\n";
+ echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
+ echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n";
+ echo "<tr><td class=\"listlr\"><textarea style=\"font-family:courier\"cols=\"101\" rows=\"$rows\">"; /* no newline after pre */
if ($command == "dumpconfigxml") {
$fd = @fopen("/conf/config.xml", "r");
@@ -71,46 +77,46 @@ function doCmdT($title, $command, $rows) {
echo htmlspecialchars($execOutput[$i],ENT_NOQUOTES);
}
}
- echo "</textarea></tr>\n";
- echo "</table>\n";
+ echo "</textarea></tr>\n";
+ echo "</table>\n";
}
/* Execute a command, giving it a title which is the same as the command. */
function doCmd($command) {
- doCmdT($command,$command);
+ doCmdT($command,$command);
}
/* Define a command, with a title, to be executed later. */
function defCmdT($title, $command, $rows = "20") {
- global $commands;
- $title = htmlspecialchars($title,ENT_NOQUOTES);
- $commands[] = array($title, $command, $rows);
+ global $commands;
+ $title = htmlspecialchars($title,ENT_NOQUOTES);
+ $commands[] = array($title, $command, $rows);
}
/* Define a command, with a title which is the same as the command,
* to be executed later.
*/
function defCmd($command) {
- defCmdT($command,$command);
+ defCmdT($command,$command);
}
/* List all of the commands as an index. */
function listCmds() {
- global $commands;
- echo "<p>" . gettext("This status page includes the following information") . ":\n";
- echo "<ul width=\"100%\">\n";
- for ($i = 0; isset($commands[$i]); $i++ ) {
- echo "<li><strong><a href=\"#" . $commands[$i][0] . "\">" . $commands[$i][0] . "</a></strong>\n";
- }
- echo "</ul>\n";
+ global $commands;
+ echo "<p>" . gettext("This status page includes the following information") . ":\n";
+ echo "<ul width=\"100%\">\n";
+ for ($i = 0; isset($commands[$i]); $i++ ) {
+ echo "<li><strong><a href=\"#" . $commands[$i][0] . "\">" . $commands[$i][0] . "</a></strong>\n";
+ }
+ echo "</ul>\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], $commands[$i][2]);
- }
+ global $commands;
+ for ($i = 0; isset($commands[$i]); $i++ ) {
+ doCmdT($commands[$i][0], $commands[$i][1], $commands[$i][2]);
+ }
}
?>
@@ -135,10 +141,10 @@ function execCmds() {
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="tabcont" width="100%">
+ <tr>
+ <td class="tabcont" width="100%">
<?php
- $entries = trim(exec("/usr/local/sbin/unbound-control dump_cache | wc -l"));
+ $entries = trim(exec(UNBOUND_BASE . "/sbin/unbound-control dump_cache | wc -l"));
defCmdT("Unbound status", "unbound-control status", "6");
defCmdT("Unbound stats", "unbound-control stats_noreset");
defCmdT("Unbound stubs", "unbound-control list_stubs", "8");
@@ -146,12 +152,12 @@ function execCmds() {
defCmdT("Unbound local zones", "unbound-control list_local_zones");
defCmdT("Unbound local data", "unbound-control list_local_data");
defCmdT("Unbound cache ($entries entries)", "unbound-control dump_cache", "60");
- defCmdT("Unbound configuration", "/bin/cat /usr/local/etc/unbound/unbound.conf", "60");
+ defCmdT("Unbound configuration", "/bin/cat " . UNBOUND_BASE . "/etc/unbound/unbound.conf", "60");
listCmds();
execCmds();
?>
- </td>
- </tr>
+ </td>
+ </tr>
</table>
</div>
<?php include("fend.inc"); ?>