main
This commit is contained in:
+17
-60
@@ -1,34 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* BrandMeister active-connections panel.
|
||||
*
|
||||
* AJAX-loaded partial; refreshed every 180 seconds by /index.php (slow
|
||||
* cadence on purpose — hits the BrandMeister HTTPS API). Renders a
|
||||
* read-only table of static and dynamic talkgroup subscriptions for the
|
||||
* configured DMR ID.
|
||||
*
|
||||
* Inputs:
|
||||
* - /etc/dmrgateway DMR network configuration; figures
|
||||
* out which slot is on BrandMeister and
|
||||
* the DMR ID.
|
||||
* - /etc/bmapi.key BrandMeister API token. Length sniff
|
||||
* picks endpoint version: short → v1.0,
|
||||
* long → v2 with Bearer auth.
|
||||
* - /usr/local/etc/DMR_Hosts.txt Master name lookup for display.
|
||||
* - https://api.brandmeister.network Live API for TG state.
|
||||
*
|
||||
* Display-only. The companion bm_manager.php provides the link/unlink
|
||||
* form.
|
||||
*
|
||||
* AJAX-loaded partial — embeddable variant only. Omits the
|
||||
* X-Frame-Options / frame-ancestors directives the parent already
|
||||
* asserts; they apply to iframe ancestry, not XHR responses.
|
||||
*/
|
||||
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
|
||||
setEmbeddableSecurityHeaders();
|
||||
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/config.php'; // MMDVMDash Config
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/mmdvmhost/tools.php'; // MMDVMDash Tools
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/mmdvmhost/functions.php'; // MMDVMDash Functions
|
||||
@@ -46,7 +16,7 @@ if ( $testMMDVModeDMR == 1 ) {
|
||||
if ( strlen($bmAPIkey) <= 20 ) { unset($bmAPIkey); }
|
||||
if ( strlen($bmAPIkey) >= 200 ) { $bmAPIkeyV2 = $bmAPIkey; unset($bmAPIkey); }
|
||||
}
|
||||
|
||||
|
||||
//Load the dmrgateway config file
|
||||
$dmrGatewayConfigFile = '/etc/dmrgateway';
|
||||
if (fopen($dmrGatewayConfigFile,'r')) { $configdmrgateway = parse_ini_file($dmrGatewayConfigFile, true); }
|
||||
@@ -89,24 +59,17 @@ if ( $testMMDVModeDMR == 1 ) {
|
||||
$bmStaticTGList = "";
|
||||
$bmDynamicTGList = "";
|
||||
|
||||
// Pull the information from JSON. talkgroup/slot are documented
|
||||
// as integers in the BrandMeister API but PHP's json_decode
|
||||
// doesn't enforce that — cast to (int) so a hostile / compromised
|
||||
// upstream response can't smuggle HTML/JS into the rendered <td>
|
||||
// bytes below. (int) of a non-numeric string is 0, which renders
|
||||
// as plain "0" — predictable, inert.
|
||||
// Pull the information form JSON
|
||||
if (isset($json->staticSubscriptions)) { $bmStaticTGListJson = $json->staticSubscriptions;
|
||||
foreach($bmStaticTGListJson as $staticTG) {
|
||||
$tgNum = (int)$staticTG->talkgroup;
|
||||
$tgSlot = (int)$staticTG->slot;
|
||||
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) && $tgSlot === 1) {
|
||||
$bmStaticTGList .= "TG".$tgNum."(".$tgSlot.") ";
|
||||
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) && $staticTG->slot == "1") {
|
||||
$bmStaticTGList .= "TG".$staticTG->talkgroup."(".$staticTG->slot.") ";
|
||||
}
|
||||
else if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $tgSlot === 2) {
|
||||
$bmStaticTGList .= "TG".$tgNum."(".$tgSlot.") ";
|
||||
else if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $staticTG->slot == "2") {
|
||||
$bmStaticTGList .= "TG".$staticTG->talkgroup."(".$staticTG->slot.") ";
|
||||
}
|
||||
else if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == "0" && getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $tgSlot === 0) {
|
||||
$bmStaticTGList .= "TG".$tgNum." ";
|
||||
else if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == "0" && getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $staticTG->slot == "0") {
|
||||
$bmStaticTGList .= "TG".$staticTG->talkgroup." ";
|
||||
}
|
||||
}
|
||||
$bmStaticTGList = wordwrap($bmStaticTGList, 15, "<br />\n");
|
||||
@@ -114,16 +77,14 @@ if ( $testMMDVModeDMR == 1 ) {
|
||||
} else { $bmStaticTGList = "None"; }
|
||||
if (isset($json->dynamicSubscriptions)) { $bmDynamicTGListJson = $json->dynamicSubscriptions;
|
||||
foreach($bmDynamicTGListJson as $dynamicTG) {
|
||||
$tgNum = (int)$dynamicTG->talkgroup;
|
||||
$tgSlot = (int)$dynamicTG->slot;
|
||||
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) && $tgSlot === 1) {
|
||||
$bmDynamicTGList .= "TG".$tgNum."(".$tgSlot.") ";
|
||||
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) && $dynamicTG->slot == "1") {
|
||||
$bmDynamicTGList .= "TG".$dynamicTG->talkgroup."(".$dynamicTG->slot.") ";
|
||||
}
|
||||
else if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $tgSlot === 2) {
|
||||
$bmDynamicTGList .= "TG".$tgNum."(".$tgSlot.") ";
|
||||
else if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $dynamicTG->slot == "2") {
|
||||
$bmDynamicTGList .= "TG".$dynamicTG->talkgroup."(".$dynamicTG->slot.") ";
|
||||
}
|
||||
else if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == "0" && getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $tgSlot === 0) {
|
||||
$bmDynamicTGList .= "TG".$tgNum." ";
|
||||
else if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == "0" && getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) && $dynamicTG->slot == "0") {
|
||||
$bmDynamicTGList .= "TG".$dynamicTG->talkgroup." ";
|
||||
}
|
||||
}
|
||||
$bmDynamicTGList = wordwrap($bmDynamicTGList, 15, "<br />\n");
|
||||
@@ -140,13 +101,8 @@ if ( $testMMDVModeDMR == 1 ) {
|
||||
</tr>'."\n";
|
||||
|
||||
echo ' <tr>'."\n";
|
||||
// $dmrMasterHost / $dmrID come from /etc/dmrgateway — operator
|
||||
// edits via the expert editor. htmlspecialchars defence-in-depth.
|
||||
// $bmStatic/DynamicTGList already contain wordwrap-injected `<br />`
|
||||
// tags by design, so they intentionally aren't escaped here; the
|
||||
// talkgroup/slot integers inside them were cast to (int) above.
|
||||
echo ' <td>'.htmlspecialchars((string)$dmrMasterHost, ENT_QUOTES, 'UTF-8').'</td>';
|
||||
echo '<td>'.htmlspecialchars((string)$dmrID, ENT_QUOTES, 'UTF-8').'</td>';
|
||||
echo ' <td>'.$dmrMasterHost.'</td>';
|
||||
echo '<td>'.$dmrID.'</td>';
|
||||
echo '<td>'.$bmStaticTGList.'</td>';
|
||||
echo '<td>'.$bmDynamicTGList.'</td>';
|
||||
echo '</tr>'."\n";
|
||||
@@ -154,3 +110,4 @@ if ( $testMMDVModeDMR == 1 ) {
|
||||
echo ' <br />'."\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user