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";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,29 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* BrandMeister talkgroup link/unlink form (admin-only).
|
||||
*
|
||||
* Loaded inline by /index.php only on the admin path
|
||||
* (`$_SERVER["PHP_SELF"] == "/admin/index.php"` gate). Form fields:
|
||||
* tgNr — talkgroup number (numeric, sanitised)
|
||||
* TS — DMR slot 1 or 2
|
||||
* TGmgr — ADD or DEL (add/remove static)
|
||||
* dropDyn — drop dynamic TG (one-shot)
|
||||
* dropQso — drop active QSO (one-shot)
|
||||
*
|
||||
* On POST submit, makes HTTPS calls to https://api.brandmeister.network
|
||||
* (POST/GET/DELETE depending on TGmgr / drop* combination), using the
|
||||
* Bearer token loaded from /etc/bmapi.key (long-form v2 token only;
|
||||
* short-form v1.0 tokens are not used by the manage endpoints).
|
||||
*
|
||||
* Triggers a 3 s `setTimeout` reload after submit so the operator sees
|
||||
* the updated bm_links.php panel pick up the change on its next 180 s
|
||||
* refresh — without this, the result wouldn't show until the next
|
||||
* AJAX cycle naturally hit.
|
||||
*
|
||||
* NOTE for the security pass: this file does not call
|
||||
* setEmbeddableSecurityHeaders(). Coverage gap.
|
||||
*/
|
||||
|
||||
if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside of the admin page
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/config.php'; // MMDVMDash Config
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/mmdvmhost/tools.php'; // MMDVMDash Tools
|
||||
@@ -110,7 +85,7 @@ if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside o
|
||||
if ( (!isset($_POST["dropDyn"])) && (!isset($_POST["dropQso"])) && isset($targetTG) && $_POST["TGmgr"] == "ADD" ) {
|
||||
$postDataTG = array(
|
||||
'slot' => $targetSlot,
|
||||
'group' => $targetTG
|
||||
'group' => $targetTG
|
||||
);
|
||||
$postData = json_encode($postDataTG);
|
||||
$postHeaders[] = 'Content-Length: '.strlen($postData);
|
||||
@@ -136,7 +111,6 @@ if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside o
|
||||
if (isset($bmAPIkeyV2)) {
|
||||
echo '<b>BrandMeister Manager</b>'."\n";
|
||||
echo '<form action="'.htmlentities($_SERVER['PHP_SELF']).'" method="post">'."\n";
|
||||
echo csrf_field_html()."\n";
|
||||
echo '<table role="presentation">'."\n";
|
||||
echo '<tr>
|
||||
<th aria-hidden="true" id="lblTG" style="width:25%;"><a class=tooltip href="#">Static Talkgroup<span><b>Enter the Talkgroup number</b></span></a></th>
|
||||
@@ -161,4 +135,3 @@ if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside o
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
// Empty placeholder: presence prevents directory listing under Apache
|
||||
// when no DirectoryIndex match is found in this folder.
|
||||
|
||||
+60
-109
@@ -1,35 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Local TX list (MMDVMHost mode) — recent locally-originated RF
|
||||
* transmissions across every enabled mode. The "what THIS hotspot has
|
||||
* been keying up" view; complements lh.php which shows network traffic
|
||||
* too.
|
||||
*
|
||||
* AJAX-loaded partial; refreshed every 1.5 seconds by /index.php in
|
||||
* MMDVMHost mode. Same column layout as lh.php (time / mode / callsign /
|
||||
* target / source / duration / loss / BER) but filters `$lastHeard` for
|
||||
* RF-source rows only.
|
||||
*
|
||||
* In-progress RF calls (no end-of-transmission yet) get a red-cell
|
||||
* highlight and an infinity duration symbol to flag the live state.
|
||||
*
|
||||
* Callsign links use the operator's chosen lookup service (RadioID or
|
||||
* QRZ from /etc/pistar-css.ini's [Lookup] Service key) plus aprs.fi
|
||||
* for D-Star dPRS.
|
||||
*
|
||||
* Data flow: relies on `$lastHeard` populated by mmdvmhost/functions.php.
|
||||
*/
|
||||
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
|
||||
// AJAX-loaded partial — embeddable variant only. See the note in
|
||||
// mmdvmhost/lh.php for why the historical double-call was wrong.
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
$localTXList = $lastHeard;
|
||||
|
||||
// Check if the config file exists
|
||||
@@ -39,8 +12,8 @@ if (file_exists('/etc/pistar-css.ini')) {
|
||||
if (fopen($piStarCssFile,'r')) { $piStarCss = parse_ini_file($piStarCssFile, true); }
|
||||
|
||||
// Set the Values from the config file
|
||||
if (isset($piStarCss['Lookup']['Service'])) { $callsignLookupSvc = $piStarCss['Lookup']['Service']; } // Lookup Service "QRZ" or "RadioID"
|
||||
else { $callsignLookupSvc = "RadioID"; } // Set the default if its missing // Set the default if its missing
|
||||
if (isset($piStarCss['Lookup']['Service'])) { $callsignLookupSvc = $piStarCss['Lookup']['Service']; } // Lookup Service "QRZ" or "RadioID"
|
||||
else { $callsignLookupSvc = "RadioID"; } // Set the default if its missing // Set the default if its missing
|
||||
} else {
|
||||
// Default values
|
||||
$callsignLookupSvc = "RadioID";
|
||||
@@ -72,86 +45,64 @@ $counter = 0;
|
||||
$i = 0;
|
||||
$TXListLim = count($localTXList);
|
||||
for ($i = 0; $i < $TXListLim; $i++) {
|
||||
$listElem = $localTXList[$i];
|
||||
if ($listElem[5] == "RF" && ($listElem[1] == "D-Star" || startsWith($listElem[1], "DMR") || $listElem[1] == "YSF" || $listElem[1]== "P25" || $listElem[1]== "NXDN" || $listElem[1]== "M17")) {
|
||||
if ($counter <= 19) { //last 20 calls
|
||||
$utc_time = $listElem[0];
|
||||
$utc_tz = new DateTimeZone('UTC');
|
||||
$local_tz = new DateTimeZone(date_default_timezone_get ());
|
||||
$dt = new DateTime($utc_time, $utc_tz);
|
||||
$dt->setTimeZone($local_tz);
|
||||
$local_time = $dt->format('H:i:s M jS');
|
||||
$listElem = $localTXList[$i];
|
||||
if ($listElem[5] == "RF" && ($listElem[1] == "D-Star" || startsWith($listElem[1], "DMR") || $listElem[1] == "YSF" || $listElem[1]== "P25" || $listElem[1]== "NXDN" || $listElem[1]== "M17")) {
|
||||
if ($counter <= 19) { //last 20 calls
|
||||
$utc_time = $listElem[0];
|
||||
$utc_tz = new DateTimeZone('UTC');
|
||||
$local_tz = new DateTimeZone(date_default_timezone_get ());
|
||||
$dt = new DateTime($utc_time, $utc_tz);
|
||||
$dt->setTimeZone($local_tz);
|
||||
$local_time = $dt->format('H:i:s M jS');
|
||||
echo "<tr>";
|
||||
echo "<td align=\"left\">$local_time</td>";
|
||||
echo "<td align=\"left\">".str_replace('Slot ', 'TS', $listElem[1])."</td>";
|
||||
if (is_numeric($listElem[2])) {
|
||||
if ($listElem[2] > 9999) { echo "<td align=\"left\"><a href=\"".$idLookupUrl.$listElem[2]."\" target=\"_blank\">$listElem[2]</a></td>"; }
|
||||
else { echo "<td align=\"left\">".$listElem[2]."</td>"; }
|
||||
} elseif (!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $listElem[2])) {
|
||||
echo "<td align=\"left\">$listElem[2]</td>";
|
||||
} else {
|
||||
if (strpos($listElem[2],"-") > 0) { $listElem[2] = substr($listElem[2], 0, strpos($listElem[2],"-")); }
|
||||
if ($listElem[3] && $listElem[3] != ' ' ) {
|
||||
echo "<td align=\"left\"><div style=\"float:left;\"><a href=\"".$callsignLookupUrl.$listElem[2]."\" target=\"_blank\">$listElem[2]</a>/$listElem[3]</div> <div style=\"text-align:right;\">(<a href=\"https://aprs.fi/#!call=".$listElem[2]."*\" target=\"_blank\">GPS</a>)</div></td>";
|
||||
} else {
|
||||
echo "<td align=\"left\"><div style=\"float:left;\"><a href=\"".$callsignLookupUrl.$listElem[2]."\" target=\"_blank\">$listElem[2]</a></div> <div style=\"text-align:right;\">(<a href=\"https://aprs.fi/#!call=".$listElem[2]."*\" target=\"_blank\">GPS</a>)</div></td>";
|
||||
}
|
||||
}
|
||||
if (strlen($listElem[4]) == 1) { $listElem[4] = str_pad($listElem[4], 8, " ", STR_PAD_LEFT); }
|
||||
echo"<td align=\"left\">".str_replace(" "," ", $listElem[4])."</td>";
|
||||
if ($listElem[5] == "RF"){
|
||||
echo "<td style=\"background:#1d1;\">RF</td>";
|
||||
} else {
|
||||
echo "<td>$listElem[5]</td>";
|
||||
}
|
||||
if ($listElem[6] == null) {
|
||||
// Live duration
|
||||
$utc_time = $listElem[0];
|
||||
$utc_tz = new DateTimeZone('UTC');
|
||||
$now = new DateTime("now", $utc_tz);
|
||||
$dt = new DateTime($utc_time, $utc_tz);
|
||||
$duration = $now->getTimestamp() - $dt->getTimestamp();
|
||||
$duration_string = $duration<999 ? round($duration) . "+" : "∞";
|
||||
echo "<td colspan=\"3\" style=\"background:#f33;\">TX " . $duration_string . " sec</td>";
|
||||
} else if ($listElem[6] == "DMR Data") {
|
||||
echo "<td colspan=\"3\" style=\"background:#1d1;\">DMR Data</td>";
|
||||
} else {
|
||||
echo"<td>$listElem[6]</td>"; //duration
|
||||
|
||||
// Colour the BER Field
|
||||
if (floatval($listElem[8]) == 0) { echo "<td>$listElem[8]</td>"; }
|
||||
elseif (floatval($listElem[8]) >= 0.0 && floatval($listElem[8]) <= 1.9) { echo "<td style=\"background:#1d1;\">$listElem[8]</td>"; }
|
||||
elseif (floatval($listElem[8]) >= 2.0 && floatval($listElem[8]) <= 4.9) { echo "<td style=\"background:#fa0;\">$listElem[8]</td>"; }
|
||||
else { echo "<td style=\"background:#f33;\">$listElem[8]</td>"; }
|
||||
|
||||
// Same normalisation pattern as mmdvmhost/lh.php — every
|
||||
// value below comes from log-line parsing of RF traffic
|
||||
// and could carry hostile bytes from a transmitting
|
||||
// station. See the note in lh.php for the rationale.
|
||||
$modeHtml = htmlspecialchars(str_replace('Slot ', 'TS', $listElem[1]), ENT_QUOTES, 'UTF-8');
|
||||
$cs = htmlspecialchars((string)$listElem[2], ENT_QUOTES, 'UTF-8');
|
||||
$csUrl = rawurlencode((string)$listElem[2]);
|
||||
$csSuffix = htmlspecialchars((string)$listElem[3], ENT_QUOTES, 'UTF-8');
|
||||
$tgtRaw = (string)$listElem[4];
|
||||
if (strlen($tgtRaw) === 1) { $tgtRaw = str_pad($tgtRaw, 8, ' ', STR_PAD_LEFT); }
|
||||
$tgtHtml = htmlspecialchars($tgtRaw, ENT_QUOTES, 'UTF-8');
|
||||
$src = htmlspecialchars((string)$listElem[5], ENT_QUOTES, 'UTF-8');
|
||||
$dur = htmlspecialchars((string)$listElem[6], ENT_QUOTES, 'UTF-8');
|
||||
$ber = htmlspecialchars((string)(isset($listElem[8]) ? $listElem[8] : ''), ENT_QUOTES, 'UTF-8');
|
||||
$rssi = htmlspecialchars((string)(isset($listElem[9]) ? $listElem[9] : ''), ENT_QUOTES, 'UTF-8');
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td align=\"left\">$local_time</td>";
|
||||
echo "<td align=\"left\">$modeHtml</td>";
|
||||
if (is_numeric($listElem[2])) {
|
||||
if ($listElem[2] > 9999) { echo "<td align=\"left\"><a href=\"".$idLookupUrl.$csUrl."\" target=\"_blank\">$cs</a></td>"; }
|
||||
else { echo "<td align=\"left\">$cs</td>"; }
|
||||
} elseif (!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $listElem[2])) {
|
||||
echo "<td align=\"left\">$cs</td>";
|
||||
} else {
|
||||
$csTrim = (strpos($listElem[2], "-") > 0)
|
||||
? substr($listElem[2], 0, strpos($listElem[2], "-"))
|
||||
: (string)$listElem[2];
|
||||
$csTrimHtml = htmlspecialchars($csTrim, ENT_QUOTES, 'UTF-8');
|
||||
$csTrimUrl = rawurlencode($csTrim);
|
||||
if ($listElem[3] && $listElem[3] != ' ' ) {
|
||||
echo "<td align=\"left\"><div style=\"float:left;\"><a href=\"".$callsignLookupUrl.$csTrimUrl."\" target=\"_blank\">$csTrimHtml</a>/$csSuffix</div> <div style=\"text-align:right;\">(<a href=\"https://aprs.fi/#!call=".$csTrimUrl."*\" target=\"_blank\">GPS</a>)</div></td>";
|
||||
} else {
|
||||
echo "<td align=\"left\"><div style=\"float:left;\"><a href=\"".$callsignLookupUrl.$csTrimUrl."\" target=\"_blank\">$csTrimHtml</a></div> <div style=\"text-align:right;\">(<a href=\"https://aprs.fi/#!call=".$csTrimUrl."*\" target=\"_blank\">GPS</a>)</div></td>";
|
||||
}
|
||||
}
|
||||
echo "<td align=\"left\">".str_replace(' ', ' ', $tgtHtml)."</td>";
|
||||
if ($listElem[5] == "RF"){
|
||||
echo "<td style=\"background:#1d1;\">RF</td>";
|
||||
} else {
|
||||
echo "<td>$src</td>";
|
||||
}
|
||||
if ($listElem[6] == null) {
|
||||
// Live duration
|
||||
$utc_time = $listElem[0];
|
||||
$utc_tz = new DateTimeZone('UTC');
|
||||
$now = new DateTime("now", $utc_tz);
|
||||
$dt = new DateTime($utc_time, $utc_tz);
|
||||
$duration = $now->getTimestamp() - $dt->getTimestamp();
|
||||
$duration_string = $duration<999 ? round($duration) . "+" : "∞";
|
||||
echo "<td colspan=\"3\" style=\"background:#f33;\">TX " . $duration_string . " sec</td>";
|
||||
} else if ($listElem[6] == "DMR Data") {
|
||||
echo "<td colspan=\"3\" style=\"background:#1d1;\">DMR Data</td>";
|
||||
} else {
|
||||
echo "<td>$dur</td>"; //duration
|
||||
|
||||
// Colour the BER Field
|
||||
if (floatval($listElem[8]) == 0) { echo "<td>$ber</td>"; }
|
||||
elseif (floatval($listElem[8]) >= 0.0 && floatval($listElem[8]) <= 1.9) { echo "<td style=\"background:#1d1;\">$ber</td>"; }
|
||||
elseif (floatval($listElem[8]) >= 2.0 && floatval($listElem[8]) <= 4.9) { echo "<td style=\"background:#fa0;\">$ber</td>"; }
|
||||
else { echo "<td style=\"background:#f33;\">$ber</td>"; }
|
||||
|
||||
echo "<td>$rssi</td>"; //rssi
|
||||
}
|
||||
echo "</tr>\n";
|
||||
$counter++; }
|
||||
}
|
||||
}
|
||||
echo"<td>$listElem[9]</td>"; //rssi
|
||||
}
|
||||
echo "</tr>\n";
|
||||
$counter++; }
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
+136
-162
@@ -1,168 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* M17 reflector link/unlink form (admin-only).
|
||||
*
|
||||
* Loaded inline by /index.php only on the admin path
|
||||
* (`$_SERVER["PHP_SELF"] == "/admin/index.php"` gate). M17 is the only
|
||||
* protocol with a two-part link selector — host plus room letter.
|
||||
*
|
||||
* Form fields:
|
||||
* m17LinkHost — reflector host name (alphanumeric+dash, validated)
|
||||
* m17LinkRoom — single room letter A-Z (validated)
|
||||
* Link — LINK or UNLINK
|
||||
*
|
||||
* On submit, runs `sudo /usr/local/bin/RemoteCommand <port> Reflector
|
||||
* <host> <room|unlink>` against the M17Gateway remote-control port
|
||||
* configured in /etc/m17gateway. After action, triggers a 2 s
|
||||
* `setTimeout` reload.
|
||||
*
|
||||
* Inputs read at render time:
|
||||
* /etc/m17gateway Confirms the gateway is configured.
|
||||
* /usr/local/etc/M17Hosts.txt + optional /root/M17Hosts.txt for the
|
||||
* operator's reflector picklist.
|
||||
*
|
||||
* NOTE for the security pass: validation is whitelist-regex; no
|
||||
* setEmbeddableSecurityHeaders() call in this file. Coverage gap.
|
||||
*/
|
||||
|
||||
if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside of the admin page
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
// Check if M17 is Enabled
|
||||
$testMMDVModeM17 = getConfigItem("M17 Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeM17 == 1 ) {
|
||||
// Check if M17 is Enabled
|
||||
$testMMDVModeM17 = getConfigItem("M17 Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeM17 == 1 ) {
|
||||
|
||||
//Load the m17gateway config file
|
||||
$m17GatewayConfigFile = '/etc/m17gateway';
|
||||
if (fopen($m17GatewayConfigFile,'r')) { $configm17gateway = parse_ini_file($m17GatewayConfigFile, true); }
|
||||
//Load the m17gateway config file
|
||||
$m17GatewayConfigFile = '/etc/m17gateway';
|
||||
if (fopen($m17GatewayConfigFile,'r')) { $configm17gateway = parse_ini_file($m17GatewayConfigFile, true); }
|
||||
|
||||
// Check that the remote is enabled
|
||||
if ( $configm17gateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $configm17gateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["m17MgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9-]/',$_POST['m17LinkHost'])) { unset ($_POST['m17LinkHost']); unset ($_POST['m17LinkRoom']); }
|
||||
if (preg_match('/[^A-Z]/',$_POST['m17LinkRoom'])) { unset ($_POST['m17LinkHost']); unset ($_POST['m17LinkRoom']); }
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['m17LinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Reflector unlink";
|
||||
} else {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Reflector ".$_POST['m17LinkHost']." ".$_POST['m17LinkRoom'];
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Reflector unlink";
|
||||
} else {
|
||||
echo "<b>M17 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['m17LinkHost'])) {
|
||||
echo "<b>M17 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>M17 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo htmlspecialchars((string)exec($remoteCommand), ENT_QUOTES, 'UTF-8');
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>M17 Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<?php csrf_field(); ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="m17LinkHost">
|
||||
<?php
|
||||
$m17Hosts = fopen("/usr/local/etc/M17Hosts.txt", "r");
|
||||
if (isset($configm17gateway['Network']['Startup'])) { $testM17Host = explode("_", $configm17gateway['Network']['Startup'])[0]; } else { $testM17Host = ""; }
|
||||
if ($testM17Host == "") { echo " <option value=\"none\" selected=\"selected\">None</option>\n"; }
|
||||
else { echo " <option value=\".$testM17Host.\">None</option>\n"; }
|
||||
while (!feof($m17Hosts)) {
|
||||
$m17HostsLine = fgets($m17Hosts);
|
||||
$m17Host = preg_split('/\s+/', $m17HostsLine);
|
||||
if ((strpos($m17Host[0], '#') === FALSE ) && ($m17Host[0] != '')) {
|
||||
if ($testM17Host == $m17Host[0]) { echo " <option value=\"$m17Host[0]\" selected=\"selected\">$m17Host[0]</option>\n"; }
|
||||
else { echo " <option value=\"$m17Host[0]\">$m17Host[0]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($m17Hosts);
|
||||
if (file_exists('/root/M17Hosts.txt')) {
|
||||
$m17Hosts2 = fopen("/root/M17Hosts.txt", "r");
|
||||
while (!feof($m17Hosts2)) {
|
||||
$m17HostsLine2 = fgets($m17Hosts2);
|
||||
$m17Host2 = preg_split('/\s+/', $m17HostsLine2);
|
||||
if ((strpos($m17Host2[0], '#') === FALSE ) && ($m17Host2[0] != '')) {
|
||||
if ($testM17Host == $m17Host2[0]) { echo " <option value=\"$m17Host2[0]\" selected=\"selected\">$m17Host2[0]</option>\n"; }
|
||||
else { echo " <option value=\"$m17Host2[0]\">$m17Host2[0]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($m17Hosts2);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<select name="m17LinkRoom">
|
||||
<?php if (isset($configm17gateway['Network']['Startup'])) { echo "<option value=\"".substr($configm17gateway['Network']['Startup'], -1)."\" selected=\"selected\">".substr($configm17gateway['Network']['Startup'], -1)."</option>"; } ?>
|
||||
<option>A</option>
|
||||
<option>B</option>
|
||||
<option>C</option>
|
||||
<option>D</option>
|
||||
<option>E</option>
|
||||
<option>F</option>
|
||||
<option>G</option>
|
||||
<option>H</option>
|
||||
<option>I</option>
|
||||
<option>J</option>
|
||||
<option>K</option>
|
||||
<option>L</option>
|
||||
<option>M</option>
|
||||
<option>N</option>
|
||||
<option>O</option>
|
||||
<option>P</option>
|
||||
<option>Q</option>
|
||||
<option>R</option>
|
||||
<option>S</option>
|
||||
<option>T</option>
|
||||
<option>U</option>
|
||||
<option>V</option>
|
||||
<option>W</option>
|
||||
<option>X</option>
|
||||
<option>Y</option>
|
||||
<option>Z</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="m17MgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check that the remote is enabled
|
||||
if ( $configm17gateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $configm17gateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["m17MgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9-]/',$_POST['m17LinkHost'])) { unset ($_POST['m17LinkHost']); unset ($_POST['m17LinkRoom']); }
|
||||
if (preg_match('/[^A-Z]/',$_POST['m17LinkRoom'])) { unset ($_POST['m17LinkHost']); unset ($_POST['m17LinkRoom']); }
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['m17LinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Reflector unlink";
|
||||
} else {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Reflector ".$_POST['m17LinkHost']." ".$_POST['m17LinkRoom'];
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Reflector unlink";
|
||||
} else {
|
||||
echo "<b>M17 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['m17LinkHost'])) {
|
||||
echo "<b>M17 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>M17 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo exec($remoteCommand);
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>M17 Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="m17LinkHost">
|
||||
<?php
|
||||
$m17Hosts = fopen("/usr/local/etc/M17Hosts.txt", "r");
|
||||
if (isset($configm17gateway['Network']['Startup'])) { $testM17Host = explode("_", $configm17gateway['Network']['Startup'])[0]; } else { $testM17Host = ""; }
|
||||
if ($testM17Host == "") { echo " <option value=\"none\" selected=\"selected\">None</option>\n"; }
|
||||
else { echo " <option value=\".$testM17Host.\">None</option>\n"; }
|
||||
while (!feof($m17Hosts)) {
|
||||
$m17HostsLine = fgets($m17Hosts);
|
||||
$m17Host = preg_split('/\s+/', $m17HostsLine);
|
||||
if ((strpos($m17Host[0], '#') === FALSE ) && ($m17Host[0] != '')) {
|
||||
if ($testM17Host == $m17Host[0]) { echo " <option value=\"$m17Host[0]\" selected=\"selected\">$m17Host[0]</option>\n"; }
|
||||
else { echo " <option value=\"$m17Host[0]\">$m17Host[0]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($m17Hosts);
|
||||
if (file_exists('/root/M17Hosts.txt')) {
|
||||
$m17Hosts2 = fopen("/root/M17Hosts.txt", "r");
|
||||
while (!feof($m17Hosts2)) {
|
||||
$m17HostsLine2 = fgets($m17Hosts2);
|
||||
$m17Host2 = preg_split('/\s+/', $m17HostsLine2);
|
||||
if ((strpos($m17Host2[0], '#') === FALSE ) && ($m17Host2[0] != '')) {
|
||||
if ($testM17Host == $m17Host2[0]) { echo " <option value=\"$m17Host2[0]\" selected=\"selected\">$m17Host2[0]</option>\n"; }
|
||||
else { echo " <option value=\"$m17Host2[0]\">$m17Host2[0]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($m17Hosts2);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<select name="m17LinkRoom">
|
||||
<?php if (isset($configm17gateway['Network']['Startup'])) { echo "<option value=\"".substr($configm17gateway['Network']['Startup'], -1)."\" selected=\"selected\">".substr($configm17gateway['Network']['Startup'], -1)."</option>"; } ?>
|
||||
<option>A</option>
|
||||
<option>B</option>
|
||||
<option>C</option>
|
||||
<option>D</option>
|
||||
<option>E</option>
|
||||
<option>F</option>
|
||||
<option>G</option>
|
||||
<option>H</option>
|
||||
<option>I</option>
|
||||
<option>J</option>
|
||||
<option>K</option>
|
||||
<option>L</option>
|
||||
<option>M</option>
|
||||
<option>N</option>
|
||||
<option>O</option>
|
||||
<option>P</option>
|
||||
<option>Q</option>
|
||||
<option>R</option>
|
||||
<option>S</option>
|
||||
<option>T</option>
|
||||
<option>U</option>
|
||||
<option>V</option>
|
||||
<option>W</option>
|
||||
<option>X</option>
|
||||
<option>Y</option>
|
||||
<option>Z</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="m17MgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
+108
-132
@@ -1,138 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* NXDN reflector link/unlink form (admin-only).
|
||||
*
|
||||
* Loaded inline by /index.php only on the admin path
|
||||
* (`$_SERVER["PHP_SELF"] == "/admin/index.php"` gate).
|
||||
*
|
||||
* Form fields:
|
||||
* nxdnLinkHost — reflector identifier (alphanumeric, validated)
|
||||
* Link — LINK or UNLINK (UNLINK uses the literal "unlink"
|
||||
* target, distinct from P25 which uses TG 9999)
|
||||
*
|
||||
* On submit, runs `sudo /usr/local/bin/RemoteCommand <port> TalkGroup
|
||||
* <target|unlink>` against the NXDNGateway remote-control port
|
||||
* configured in /etc/nxdngateway. Triggers a 2 s `setTimeout` reload.
|
||||
*
|
||||
* Inputs:
|
||||
* /etc/nxdngateway Gateway config + remote port.
|
||||
* /usr/local/etc/NXDNHosts.txt Operator picklist.
|
||||
* /usr/local/etc/NXDNHostsLocal.txt Local additions (optional).
|
||||
*
|
||||
* NOTE for the security pass: validation is whitelist-regex; no
|
||||
* setEmbeddableSecurityHeaders() call in this file. Coverage gap.
|
||||
*/
|
||||
|
||||
if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside of the admin page
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
// Check if NXDN is Enabled
|
||||
$testMMDVModeNXDN = getConfigItem("NXDN Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeNXDN == 1 ) {
|
||||
// Check if NXDN is Enabled
|
||||
$testMMDVModeNXDN = getConfigItem("NXDN Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeNXDN == 1 ) {
|
||||
|
||||
//Load the nxdngateway config file
|
||||
$nxdnGatewayConfigFile = '/etc/nxdngateway';
|
||||
if (fopen($nxdnGatewayConfigFile,'r')) { $confignxdngateway = parse_ini_file($nxdnGatewayConfigFile, true); }
|
||||
//Load the nxdngateway config file
|
||||
$nxdnGatewayConfigFile = '/etc/nxdngateway';
|
||||
if (fopen($nxdnGatewayConfigFile,'r')) { $confignxdngateway = parse_ini_file($nxdnGatewayConfigFile, true); }
|
||||
|
||||
// Check that the remote is enabled
|
||||
if ( $confignxdngateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $confignxdngateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["nxdnMgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9]/',$_POST['nxdnLinkHost'])) { unset ($_POST['nxdnLinkHost']);}
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['nxdnLinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup unlink";
|
||||
} else {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup ".$_POST['nxdnLinkHost'];
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup unlink";
|
||||
} else {
|
||||
echo "<b>NXDN Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['nxdnLinkHost'])) {
|
||||
echo "<b>NXDN Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>NXDN Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo htmlspecialchars((string)exec($remoteCommand), ENT_QUOTES, 'UTF-8');
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>NXDN Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<?php csrf_field(); ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="nxdnLinkHost">
|
||||
<?php
|
||||
$nxdnHosts = fopen("/usr/local/etc/NXDNHosts.txt", "r");
|
||||
if (isset($confignxdngateway['Network']['Static'])) { $testNXDNHost = $confignxdngateway['Network']['Static']; } else { $testNXDNHost = ""; }
|
||||
if ($testNXDNHost == "") { echo " <option value=\"none\" selected=\"selected\">None</option>\n"; }
|
||||
else { echo " <option value=\"none\">None</option>\n"; }
|
||||
if ($testNXDNHost == "10") { echo " <option value=\"10\" selected=\"selected\">10 - Parrot</option>\n"; }
|
||||
else { echo " <option value=\"10\">10 - Parrot</option>\n"; }
|
||||
while (!feof($nxdnHosts)) {
|
||||
$nxdnHostsLine = fgets($nxdnHosts);
|
||||
$nxdnHost = preg_split('/\s+/', $nxdnHostsLine);
|
||||
if ((strpos($nxdnHost[0], '#') === FALSE ) && ($nxdnHost[0] != '')) {
|
||||
if ($testNXDNHost == $nxdnHost[0]) { echo " <option value=\"$nxdnHost[0]\" selected=\"selected\">$nxdnHost[0] - $nxdnHost[1]</option>\n"; }
|
||||
else { echo " <option value=\"$nxdnHost[0]\">$nxdnHost[0] - $nxdnHost[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($nxdnHosts);
|
||||
if (file_exists('/usr/local/etc/NXDNHostsLocal.txt')) {
|
||||
$nxdnHosts2 = fopen("/usr/local/etc/NXDNHostsLocal.txt", "r");
|
||||
while (!feof($nxdnHosts2)) {
|
||||
$nxdnHostsLine2 = fgets($nxdnHosts2);
|
||||
$nxdnHost2 = preg_split('/\s+/', $nxdnHostsLine2);
|
||||
if ((strpos($nxdnHost2[0], '#') === FALSE ) && ($nxdnHost2[0] != '')) {
|
||||
if ($testNXDNHost == $nxdnHost2[0]) { echo " <option value=\"$nxdnHost2[0]\" selected=\"selected\">$nxdnHost2[0] - $nxdnHost2[1]</option>\n"; }
|
||||
else { echo " <option value=\"$nxdnHost2[0]\">$nxdnHost2[0] - $nxdnHost2[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($nxdnHosts2);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="nxdnMgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check that the remote is enabled
|
||||
if ( $confignxdngateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $confignxdngateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["nxdnMgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9]/',$_POST['nxdnLinkHost'])) { unset ($_POST['nxdnLinkHost']);}
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['nxdnLinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup unlink";
|
||||
} else {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup ".$_POST['nxdnLinkHost'];
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup unlink";
|
||||
} else {
|
||||
echo "<b>NXDN Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['nxdnLinkHost'])) {
|
||||
echo "<b>NXDN Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>NXDN Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo exec($remoteCommand);
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>NXDN Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="nxdnLinkHost">
|
||||
<?php
|
||||
$nxdnHosts = fopen("/usr/local/etc/NXDNHosts.txt", "r");
|
||||
if (isset($confignxdngateway['Network']['Static'])) { $testNXDNHost = $confignxdngateway['Network']['Static']; } else { $testNXDNHost = ""; }
|
||||
if ($testNXDNHost == "") { echo " <option value=\"none\" selected=\"selected\">None</option>\n"; }
|
||||
else { echo " <option value=\"none\">None</option>\n"; }
|
||||
if ($testNXDNHost == "10") { echo " <option value=\"10\" selected=\"selected\">10 - Parrot</option>\n"; }
|
||||
else { echo " <option value=\"10\">10 - Parrot</option>\n"; }
|
||||
while (!feof($nxdnHosts)) {
|
||||
$nxdnHostsLine = fgets($nxdnHosts);
|
||||
$nxdnHost = preg_split('/\s+/', $nxdnHostsLine);
|
||||
if ((strpos($nxdnHost[0], '#') === FALSE ) && ($nxdnHost[0] != '')) {
|
||||
if ($testNXDNHost == $nxdnHost[0]) { echo " <option value=\"$nxdnHost[0]\" selected=\"selected\">$nxdnHost[0] - $nxdnHost[1]</option>\n"; }
|
||||
else { echo " <option value=\"$nxdnHost[0]\">$nxdnHost[0] - $nxdnHost[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($nxdnHosts);
|
||||
if (file_exists('/usr/local/etc/NXDNHostsLocal.txt')) {
|
||||
$nxdnHosts2 = fopen("/usr/local/etc/NXDNHostsLocal.txt", "r");
|
||||
while (!feof($nxdnHosts2)) {
|
||||
$nxdnHostsLine2 = fgets($nxdnHosts2);
|
||||
$nxdnHost2 = preg_split('/\s+/', $nxdnHostsLine2);
|
||||
if ((strpos($nxdnHost2[0], '#') === FALSE ) && ($nxdnHost2[0] != '')) {
|
||||
if ($testNXDNHost == $nxdnHost2[0]) { echo " <option value=\"$nxdnHost2[0]\" selected=\"selected\">$nxdnHost2[0] - $nxdnHost2[1]</option>\n"; }
|
||||
else { echo " <option value=\"$nxdnHost2[0]\">$nxdnHost2[0] - $nxdnHost2[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($nxdnHosts2);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="nxdnMgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
+109
-134
@@ -1,140 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* P25 reflector link/unlink form (admin-only).
|
||||
*
|
||||
* Loaded inline by /index.php only on the admin path
|
||||
* (`$_SERVER["PHP_SELF"] == "/admin/index.php"` gate).
|
||||
*
|
||||
* Form fields:
|
||||
* p25LinkHost — talkgroup number (numeric, validated)
|
||||
* Link — LINK or UNLINK (UNLINK targets TG 9999, the P25
|
||||
* parrot/disconnect TG, distinct from NXDN's literal
|
||||
* "unlink" target)
|
||||
*
|
||||
* On submit, runs `sudo /usr/local/bin/RemoteCommand <port> TalkGroup
|
||||
* <target|9999>` against the P25Gateway remote-control port configured
|
||||
* in /etc/p25gateway. Triggers a 2 s `setTimeout` reload.
|
||||
*
|
||||
* Inputs:
|
||||
* /etc/p25gateway Gateway config + remote port.
|
||||
* /usr/local/etc/P25Hosts.txt Operator picklist.
|
||||
* /usr/local/etc/P25HostsLocal.txt Local additions (optional).
|
||||
*
|
||||
* NOTE for the security pass: validation is whitelist-regex; no
|
||||
* setEmbeddableSecurityHeaders() call in this file. Coverage gap.
|
||||
*/
|
||||
|
||||
if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside of the admin page
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
// Check if P25 is Enabled
|
||||
$testMMDVModeP25 = getConfigItem("P25 Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeP25 == 1 ) {
|
||||
// Check if P25 is Enabled
|
||||
$testMMDVModeP25 = getConfigItem("P25 Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeP25 == 1 ) {
|
||||
|
||||
//Load the p25gateway config file
|
||||
$p25GatewayConfigFile = '/etc/p25gateway';
|
||||
if (fopen($p25GatewayConfigFile,'r')) { $configp25gateway = parse_ini_file($p25GatewayConfigFile, true); }
|
||||
//Load the p25gateway config file
|
||||
$p25GatewayConfigFile = '/etc/p25gateway';
|
||||
if (fopen($p25GatewayConfigFile,'r')) { $configp25gateway = parse_ini_file($p25GatewayConfigFile, true); }
|
||||
|
||||
// Check that the remote is enabled
|
||||
if ( $configp25gateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $configp25gateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["p25MgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9]/',$_POST['p25LinkHost'])) { unset ($_POST['p25LinkHost']);}
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['p25LinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup 9999";
|
||||
} else {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup ".$_POST['p25LinkHost'];
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup 9999";
|
||||
} else {
|
||||
echo "<b>P25 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['p25LinkHost'])) {
|
||||
echo "<b>P25 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>P25 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo htmlspecialchars((string)exec($remoteCommand), ENT_QUOTES, 'UTF-8');
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>P25 Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<?php csrf_field(); ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="p25LinkHost">
|
||||
<?php
|
||||
if (isset($configp25gateway['Network']['Startup'])) { $testP25Host = $configp25gateway['Network']['Startup']; }
|
||||
elseif (isset($configp25gateway['Network']['Static'])) { $testP25Host = $configp25gateway['Network']['Static']; }
|
||||
else { $testP25Host = "none"; }
|
||||
if ($testP25Host == "") { echo " <option value=\"none\" selected=\"selected\">None</option>\n"; }
|
||||
else { echo " <option value=\"none\">None</option>\n"; }
|
||||
if ($testP25Host == "10") { echo " <option value=\"10\" selected=\"selected\">10 - Parrot</option>\n"; }
|
||||
else { echo " <option value=\"10\">10 - Parrot</option>\n"; }
|
||||
$p25Hosts = fopen("/usr/local/etc/P25Hosts.txt", "r");
|
||||
while (!feof($p25Hosts)) {
|
||||
$p25HostsLine = fgets($p25Hosts);
|
||||
$p25Host = preg_split('/\s+/', $p25HostsLine);
|
||||
if ((strpos($p25Host[0], '#') === FALSE ) && ($p25Host[0] != '')) {
|
||||
if ($testP25Host == $p25Host[0]) { echo " <option value=\"$p25Host[0]\" selected=\"selected\">$p25Host[0] - $p25Host[1]</option>\n"; }
|
||||
else { echo " <option value=\"$p25Host[0]\">$p25Host[0] - $p25Host[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($p25Hosts);
|
||||
if (file_exists('/usr/local/etc/P25HostsLocal.txt')) {
|
||||
$p25Hosts2 = fopen("/usr/local/etc/P25HostsLocal.txt", "r");
|
||||
while (!feof($p25Hosts2)) {
|
||||
$p25HostsLine2 = fgets($p25Hosts2);
|
||||
$p25Host2 = preg_split('/\s+/', $p25HostsLine2);
|
||||
if ((strpos($p25Host2[0], '#') === FALSE ) && ($p25Host2[0] != '')) {
|
||||
if ($testP25Host == $p25Host2[0]) { echo " <option value=\"$p25Host2[0]\" selected=\"selected\">$p25Host2[0] - $p25Host2[1]</option>\n"; }
|
||||
else { echo " <option value=\"$p25Host2[0]\">$p25Host2[0] - $p25Host2[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($p25Hosts2);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="p25MgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check that the remote is enabled
|
||||
if ( $configp25gateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $configp25gateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["p25MgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9]/',$_POST['p25LinkHost'])) { unset ($_POST['p25LinkHost']);}
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['p25LinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup 9999";
|
||||
} else {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup ".$_POST['p25LinkHost'];
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." TalkGroup 9999";
|
||||
} else {
|
||||
echo "<b>P25 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['p25LinkHost'])) {
|
||||
echo "<b>P25 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>P25 Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo exec($remoteCommand);
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>P25 Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="p25LinkHost">
|
||||
<?php
|
||||
if (isset($configp25gateway['Network']['Startup'])) { $testP25Host = $configp25gateway['Network']['Startup']; }
|
||||
elseif (isset($configp25gateway['Network']['Static'])) { $testP25Host = $configp25gateway['Network']['Static']; }
|
||||
else { $testP25Host = "none"; }
|
||||
if ($testP25Host == "") { echo " <option value=\"none\" selected=\"selected\">None</option>\n"; }
|
||||
else { echo " <option value=\"none\">None</option>\n"; }
|
||||
if ($testP25Host == "10") { echo " <option value=\"10\" selected=\"selected\">10 - Parrot</option>\n"; }
|
||||
else { echo " <option value=\"10\">10 - Parrot</option>\n"; }
|
||||
$p25Hosts = fopen("/usr/local/etc/P25Hosts.txt", "r");
|
||||
while (!feof($p25Hosts)) {
|
||||
$p25HostsLine = fgets($p25Hosts);
|
||||
$p25Host = preg_split('/\s+/', $p25HostsLine);
|
||||
if ((strpos($p25Host[0], '#') === FALSE ) && ($p25Host[0] != '')) {
|
||||
if ($testP25Host == $p25Host[0]) { echo " <option value=\"$p25Host[0]\" selected=\"selected\">$p25Host[0] - $p25Host[1]</option>\n"; }
|
||||
else { echo " <option value=\"$p25Host[0]\">$p25Host[0] - $p25Host[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($p25Hosts);
|
||||
if (file_exists('/usr/local/etc/P25HostsLocal.txt')) {
|
||||
$p25Hosts2 = fopen("/usr/local/etc/P25HostsLocal.txt", "r");
|
||||
while (!feof($p25Hosts2)) {
|
||||
$p25HostsLine2 = fgets($p25Hosts2);
|
||||
$p25Host2 = preg_split('/\s+/', $p25HostsLine2);
|
||||
if ((strpos($p25Host2[0], '#') === FALSE ) && ($p25Host2[0] != '')) {
|
||||
if ($testP25Host == $p25Host2[0]) { echo " <option value=\"$p25Host2[0]\" selected=\"selected\">$p25Host2[0] - $p25Host2[1]</option>\n"; }
|
||||
else { echo " <option value=\"$p25Host2[0]\">$p25Host2[0] - $p25Host2[1]</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($p25Hosts2);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="p25MgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
+6
-36
@@ -1,33 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* POCSAG / DAPNET pager-message partial.
|
||||
*
|
||||
* AJAX-loaded partial; refreshed every 5 seconds by /index.php — only
|
||||
* when the POCSAG Network is enabled in /etc/mmdvmhost. Renders a
|
||||
* small table of recent paging messages with optional Skyper decoding
|
||||
* (the German weather-alert service that uses ROT-1 obfuscation, RIC
|
||||
* pre-amble bytes, and rubric / message-number indexing).
|
||||
*
|
||||
* Skyper decode logic (in this file) translates Skyper RICs into a
|
||||
* "[Skyper Rubric:N Msg:M] <decoded text>" preview where applicable.
|
||||
*
|
||||
* Data flow: parses the in-memory `$logLinesDAPNETGateway` array
|
||||
* populated by mmdvmhost/functions.php from
|
||||
* /var/log/pi-star/DAPNETGateway-YYYY-MM-DD.log.
|
||||
*
|
||||
* Most of the work here contributed by geeks4hire (Ben Horan); Skyper
|
||||
* decode added by Andy Taylor (MW0MWZ).
|
||||
*/
|
||||
|
||||
|
||||
// AJAX-loaded partial — embeddable variant only. The earlier
|
||||
// duplicate setSecurityHeaders() call has been removed; that
|
||||
// non-embeddable variant raced with this one and won via the
|
||||
// headers_sent() guard, so the file was effectively shipping
|
||||
// X-Frame-Options / frame-ancestors despite the embeddable
|
||||
// version being added below it.
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
|
||||
setEmbeddableSecurityHeaders();
|
||||
// Most of the work here contributed by geeks4hire (Ben Horan)
|
||||
// Skyper decode by Andy Taylor (MW0MWZ)
|
||||
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/config.php'; // MMDVMDash Config
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/mmdvmhost/tools.php'; // MMDVMDash Tools
|
||||
@@ -35,8 +8,7 @@ include_once $_SERVER['DOCUMENT_ROOT'].'/mmdvmhost/functions.php'; // MMDVMDa
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
// Function to reverse the ROT1 used for Skyper
|
||||
function un_rot($message)
|
||||
{
|
||||
function un_rot($message) {
|
||||
$output = "";
|
||||
$messageTextArray = str_split($message);
|
||||
|
||||
@@ -53,8 +25,7 @@ function un_rot($message)
|
||||
}
|
||||
|
||||
// Function to handle Skyper Messages
|
||||
function skyper($message, $pocsagric)
|
||||
{
|
||||
function skyper($message, $pocsagric) {
|
||||
$output = "";
|
||||
$messageTextArray = str_split($message);
|
||||
|
||||
@@ -93,7 +64,7 @@ function skyper($message, $pocsagric)
|
||||
$skyperMsgNr = ord($messageTextArray[1]) - 32;
|
||||
unset($messageTextArray[1]);
|
||||
}
|
||||
|
||||
|
||||
if (count($messageTextArray) >= 1) { // Check to see if there is a message to decode
|
||||
$output = "[Skyper Rubric:$skyperRubric Msg:$skyperMsgNr] ".un_rot(implode($messageTextArray));
|
||||
}
|
||||
@@ -149,7 +120,7 @@ function skyper($message, $pocsagric)
|
||||
if (isset($pocsag_timeslot)) { $pocsag_timeslot = htmlspecialchars($pocsag_timeslot, ENT_QUOTES, 'UTF-8'); }
|
||||
if (isset($pocsag_ric)) { $pocsag_ric = htmlspecialchars($pocsag_ric, ENT_QUOTES, 'UTF-8'); }
|
||||
if (isset($pocsag_msg)) { $pocsag_msg = htmlspecialchars($pocsag_msg, ENT_QUOTES, 'UTF-8'); }
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
@@ -164,4 +135,3 @@ function skyper($message, $pocsagric)
|
||||
?>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
+226
-289
@@ -1,44 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Repeater information sidebar (MMDVMHost mode).
|
||||
*
|
||||
* The heaviest partial in the dashboard — refreshed every 1 second by
|
||||
* /index.php to give the operator a live view of:
|
||||
* - "Modes Enabled" / "Net Status" — colour-coded grids painted via
|
||||
* {@see showMode()} from mmdvmhost/functions.php; one cell per
|
||||
* protocol covering D-Star, DMR, YSF, P25, NXDN, M17, FM, POCSAG
|
||||
* plus cross-mode bridges (DMR2YSF, DMR2NXDN, YSF2DMR, YSF2NXDN,
|
||||
* YSF2P25, "DMR XMode", "YSF XMode").
|
||||
* - Current TRX state (idle / listening / RX / TX) with mode-aware
|
||||
* colouring driven by {@see getActualMode()}.
|
||||
* - TX/RX frequencies, modem firmware, modem TCXO frequency.
|
||||
* - Per-protocol repeater info: D-Star module/IRC/APRS, DMR ID/CC
|
||||
* /TS1/TS2/master, YSF host, P25 NAC, NXDN RAN, M17 settings,
|
||||
* POCSAG frequency, DAPNET / APRS gateway state.
|
||||
*
|
||||
* Data sources: /etc/mmdvmhost (parsed INI), /etc/ircddbgateway (flat
|
||||
* key=value), /etc/{ysf,p25,nxdn,m17,dmr,dapnet,aprs,dgid,ysf2*}gateway,
|
||||
* /etc/dstar-radio.{mmdvmhost,dstarrepeater}, plus log tails for the
|
||||
* "currently linked to" cells.
|
||||
*
|
||||
* Heavy on log-parsing via mmdvmhost/functions.php helpers — see that
|
||||
* file for the underlying substr-offset parsers and example log lines.
|
||||
*
|
||||
* Includes a per-callsign aprspass() implementation (the standard
|
||||
* APRS-IS verification hash) used elsewhere via this file's include
|
||||
* chain.
|
||||
*/
|
||||
|
||||
// AJAX-loaded partial (1 s polling cadence) — embeddable variant
|
||||
// only. Omits the X-Frame-Options / frame-ancestors directives the
|
||||
// parent already asserts; they apply to iframe ancestry, not XHR.
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php');
|
||||
|
||||
@@ -58,12 +22,12 @@ if ($configfile = fopen($gatewayConfigPath,'r')) {
|
||||
$configdstar = array();
|
||||
if ($configdstarfile = fopen('/etc/dstarrepeater','r')) {
|
||||
while ($line1 = fgets($configdstarfile)) {
|
||||
if (strpos($line1, '=') !== false) {
|
||||
list($key1,$value1) = preg_split('/=/',$line1);
|
||||
$value1 = trim(str_replace('"','',$value1));
|
||||
if (strlen($value1) > 0)
|
||||
$configdstar[$key1] = $value1;
|
||||
}
|
||||
if (strpos($line1, '=') !== false) {
|
||||
list($key1,$value1) = preg_split('/=/',$line1);
|
||||
$value1 = trim(str_replace('"','',$value1));
|
||||
if (strlen($value1) > 0)
|
||||
$configdstar[$key1] = $value1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,28 +41,28 @@ if (fopen($dapnetGatewayConfigFile,'r')) { $configdapnetgateway = parse_ini_file
|
||||
|
||||
// Load the ysf2dmr config file
|
||||
if (file_exists('/etc/ysf2dmr')) {
|
||||
$ysf2dmrConfigFile = '/etc/ysf2dmr';
|
||||
if (fopen($ysf2dmrConfigFile,'r')) { $configysf2dmr = parse_ini_file($ysf2dmrConfigFile, true); }
|
||||
$ysf2dmrConfigFile = '/etc/ysf2dmr';
|
||||
if (fopen($ysf2dmrConfigFile,'r')) { $configysf2dmr = parse_ini_file($ysf2dmrConfigFile, true); }
|
||||
}
|
||||
// Load the ysf2nxdn config file
|
||||
if (file_exists('/etc/ysf2nxdn')) {
|
||||
$ysf2nxdnConfigFile = '/etc/ysf2nxdn';
|
||||
if (fopen($ysf2nxdnConfigFile,'r')) { $configysf2nxdn = parse_ini_file($ysf2nxdnConfigFile, true); }
|
||||
$ysf2nxdnConfigFile = '/etc/ysf2nxdn';
|
||||
if (fopen($ysf2nxdnConfigFile,'r')) { $configysf2nxdn = parse_ini_file($ysf2nxdnConfigFile, true); }
|
||||
}
|
||||
// Load the ysf2p25 config file
|
||||
if (file_exists('/etc/ysf2p25')) {
|
||||
$ysf2p25ConfigFile = '/etc/ysf2p25';
|
||||
if (fopen($ysf2p25ConfigFile,'r')) { $configysf2p25 = parse_ini_file($ysf2p25ConfigFile, true); }
|
||||
$ysf2p25ConfigFile = '/etc/ysf2p25';
|
||||
if (fopen($ysf2p25ConfigFile,'r')) { $configysf2p25 = parse_ini_file($ysf2p25ConfigFile, true); }
|
||||
}
|
||||
// Load the dmr2ysf config file
|
||||
if (file_exists('/etc/dmr2ysf')) {
|
||||
$dmr2ysfConfigFile = '/etc/dmr2ysf';
|
||||
if (fopen($dmr2ysfConfigFile,'r')) { $configdmr2ysf = parse_ini_file($dmr2ysfConfigFile, true); }
|
||||
$dmr2ysfConfigFile = '/etc/dmr2ysf';
|
||||
if (fopen($dmr2ysfConfigFile,'r')) { $configdmr2ysf = parse_ini_file($dmr2ysfConfigFile, true); }
|
||||
}
|
||||
// Load the dmr2nxdn config file
|
||||
if (file_exists('/etc/dmr2nxdn')) {
|
||||
$dmr2nxdnConfigFile = '/etc/dmr2nxdn';
|
||||
if (fopen($dmr2nxdnConfigFile,'r')) { $configdmr2nxdn = parse_ini_file($dmr2nxdnConfigFile, true); }
|
||||
$dmr2nxdnConfigFile = '/etc/dmr2nxdn';
|
||||
if (fopen($dmr2nxdnConfigFile,'r')) { $configdmr2nxdn = parse_ini_file($dmr2nxdnConfigFile, true); }
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -128,94 +92,80 @@ if (file_exists('/etc/dmr2nxdn')) {
|
||||
<tr><th>Trx</th><?php
|
||||
// TRX Status code
|
||||
if (isset($lastHeard[0])) {
|
||||
$listElem = $lastHeard[0];
|
||||
if ( $listElem[2] && $listElem[6] == null && $listElem[5] !== 'RF') {
|
||||
// $listElem[1] is the parsed mode string from the
|
||||
// last-heard log line — RF-controllable, so escape
|
||||
// before interpolating into HTML. (Same source as
|
||||
// the lh.php / localtx.php fixes in #21.)
|
||||
echo "<td style=\"background:#f33;\">TX " . htmlspecialchars((string)$listElem[1], ENT_QUOTES, 'UTF-8') . "</td>";
|
||||
}
|
||||
else {
|
||||
if (getActualMode($lastHeard, $mmdvmconfigs) === 'idle') {
|
||||
echo "<td style=\"background:#0b0; color:#030;\">Listening</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === NULL) {
|
||||
if (isProcessRunning("MMDVMHost")) { echo "<td style=\"background:#0b0; color:#030;\">Listening</td>"; } else { echo "<td style=\"background:#606060; color:#b0b0b0;\">OFFLINE</td>"; }
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'D-Star') {
|
||||
echo "<td style=\"background:#4aa361;\">RX D-Star</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'D-Star') {
|
||||
echo "<td style=\"background:#ade;\">Listening D-Star</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'DMR') {
|
||||
echo "<td style=\"background:#4aa361;\">RX DMR</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'DMR') {
|
||||
echo "<td style=\"background:#f93;\">Listening DMR</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'YSF') {
|
||||
echo "<td style=\"background:#4aa361;\">RX YSF</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'YSF') {
|
||||
echo "<td style=\"background:#ff9;\">Listening YSF</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'P25') {
|
||||
echo "<td style=\"background:#4aa361;\">RX P25</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'P25') {
|
||||
echo "<td style=\"background:#f9f;\">Listening P25</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'NXDN') {
|
||||
echo "<td style=\"background:#4aa361;\">RX NXDN</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'NXDN') {
|
||||
echo "<td style=\"background:#c9f;\">Listening NXDN</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'M17') {
|
||||
echo "<td style=\"background:#4aa361;\">RX M17</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'M17') {
|
||||
echo "<td style=\"background:#f9f;\">Listening M17</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'FM') {
|
||||
echo "<td style=\"background:#4aa361;\">RX FM</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'FM') {
|
||||
echo "<td style=\"background:#f9f;\">Listening FM</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'POCSAG') {
|
||||
echo "<td style=\"background:#4aa361;\">POCSAG</td>";
|
||||
}
|
||||
else {
|
||||
// getActualMode() returns log-derived strings;
|
||||
// escape before HTML interpolation.
|
||||
echo "<td>" . htmlspecialchars((string)getActualMode($lastHeard, $mmdvmconfigs), ENT_QUOTES, 'UTF-8') . "</td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$listElem = $lastHeard[0];
|
||||
if ( $listElem[2] && $listElem[6] == null && $listElem[5] !== 'RF') {
|
||||
echo "<td style=\"background:#f33;\">TX $listElem[1]</td>";
|
||||
}
|
||||
else {
|
||||
if (getActualMode($lastHeard, $mmdvmconfigs) === 'idle') {
|
||||
echo "<td style=\"background:#0b0; color:#030;\">Listening</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === NULL) {
|
||||
if (isProcessRunning("MMDVMHost")) { echo "<td style=\"background:#0b0; color:#030;\">Listening</td>"; } else { echo "<td style=\"background:#606060; color:#b0b0b0;\">OFFLINE</td>"; }
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'D-Star') {
|
||||
echo "<td style=\"background:#4aa361;\">RX D-Star</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'D-Star') {
|
||||
echo "<td style=\"background:#ade;\">Listening D-Star</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'DMR') {
|
||||
echo "<td style=\"background:#4aa361;\">RX DMR</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'DMR') {
|
||||
echo "<td style=\"background:#f93;\">Listening DMR</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'YSF') {
|
||||
echo "<td style=\"background:#4aa361;\">RX YSF</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'YSF') {
|
||||
echo "<td style=\"background:#ff9;\">Listening YSF</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'P25') {
|
||||
echo "<td style=\"background:#4aa361;\">RX P25</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'P25') {
|
||||
echo "<td style=\"background:#f9f;\">Listening P25</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'NXDN') {
|
||||
echo "<td style=\"background:#4aa361;\">RX NXDN</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'NXDN') {
|
||||
echo "<td style=\"background:#c9f;\">Listening NXDN</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'M17') {
|
||||
echo "<td style=\"background:#4aa361;\">RX M17</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'M17') {
|
||||
echo "<td style=\"background:#f9f;\">Listening M17</td>";
|
||||
}
|
||||
elseif ($listElem[2] && $listElem[6] == null && getActualMode($lastHeard, $mmdvmconfigs) === 'FM') {
|
||||
echo "<td style=\"background:#4aa361;\">RX FM</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'FM') {
|
||||
echo "<td style=\"background:#f9f;\">Listening FM</td>";
|
||||
}
|
||||
elseif (getActualMode($lastHeard, $mmdvmconfigs) === 'POCSAG') {
|
||||
echo "<td style=\"background:#4aa361;\">POCSAG</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td>".getActualMode($lastHeard, $mmdvmconfigs)."</td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "<td></td>";
|
||||
echo "<td></td>";
|
||||
}
|
||||
?></tr>
|
||||
<tr><th>Tx</th><td style="background: #ffffff;"><?php echo htmlspecialchars((string)getMHZ(getConfigItem("Info", "TXFrequency", $mmdvmconfigs)), ENT_QUOTES, 'UTF-8'); ?></td></tr>
|
||||
<tr><th>Rx</th><td style="background: #ffffff;"><?php echo htmlspecialchars((string)getMHZ(getConfigItem("Info", "RXFrequency", $mmdvmconfigs)), ENT_QUOTES, 'UTF-8'); ?></td></tr>
|
||||
<tr><th>Tx</th><td style="background: #ffffff;"><?php echo getMHZ(getConfigItem("Info", "TXFrequency", $mmdvmconfigs)); ?></td></tr>
|
||||
<tr><th>Rx</th><td style="background: #ffffff;"><?php echo getMHZ(getConfigItem("Info", "RXFrequency", $mmdvmconfigs)); ?></td></tr>
|
||||
<?php
|
||||
// Each of getDVModemFirmware()/getDVModemTCXOFreq() shells out to
|
||||
// `grep ... | tail -1` over the entire MMDVM-YYYY-MM-DD.log file,
|
||||
// which can be tens of MB late in a busy day. Capturing the
|
||||
// return into a local before the truthiness test halves the per-
|
||||
// request log-grep cost (was: one fork in the if(), one for the
|
||||
// echo's value).
|
||||
$fwVersion = getDVModemFirmware();
|
||||
if ($fwVersion) {
|
||||
echo '<tr><th>FW</th><td style="background: #ffffff;">'.htmlspecialchars((string)$fwVersion, ENT_QUOTES, 'UTF-8').'</td></tr>'."\n";
|
||||
if (getDVModemFirmware()) {
|
||||
echo '<tr><th>FW</th><td style="background: #ffffff;">'.getDVModemFirmware().'</td></tr>'."\n";
|
||||
} ?>
|
||||
<?php
|
||||
$tcxoFreq = getDVModemTCXOFreq();
|
||||
if ($tcxoFreq) {
|
||||
echo '<tr><th>TCXO</th><td style="background: #ffffff;">'.htmlspecialchars((string)$tcxoFreq, ENT_QUOTES, 'UTF-8').'</td></tr>'."\n";
|
||||
if (getDVModemTCXOFreq()) {
|
||||
echo '<tr><th>TCXO</th><td style="background: #ffffff;">'.getDVModemTCXOFreq().'</td></tr>'."\n";
|
||||
} ?>
|
||||
</table>
|
||||
|
||||
@@ -225,131 +175,117 @@ if ( $testMMDVModeDSTAR == 1 ) { //Hide the D-Star Reflector information when D-
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\">".$lang['dstar_repeater']."</th></tr>\n";
|
||||
// Config values from /etc/dstarrepeater and /etc/ircddbgateway
|
||||
// — operator-controlled, but defensive escape before HTML
|
||||
// interpolation. The legacy ` ` substitution stays but
|
||||
// runs AFTER the htmlspecialchars so the entity isn't double-
|
||||
// encoded.
|
||||
echo "<tr><th>RPT1</th><td style=\"background: #ffffff;\">".str_replace(' ', ' ', htmlspecialchars((string)$configdstar['callsign'], ENT_QUOTES, 'UTF-8'))."</td></tr>\n";
|
||||
echo "<tr><th>RPT2</th><td style=\"background: #ffffff;\">".str_replace(' ', ' ', htmlspecialchars((string)$configdstar['gateway'], ENT_QUOTES, 'UTF-8'))."</td></tr>\n";
|
||||
echo "<tr><th>RPT1</th><td style=\"background: #ffffff;\">".str_replace(' ', ' ', $configdstar['callsign'])."</td></tr>\n";
|
||||
echo "<tr><th>RPT2</th><td style=\"background: #ffffff;\">".str_replace(' ', ' ', $configdstar['gateway'])."</td></tr>\n";
|
||||
echo "<tr><th colspan=\"2\">".$lang['dstar_net']."</th></tr>\n";
|
||||
if ($configs['aprsEnabled']) {
|
||||
echo "<tr><th>APRS</th><td style=\"background: #ffffff;\">".htmlspecialchars(substr((string)$configs['aprsHostname'], 0, 16), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><th>APRS</th><td style=\"background: #ffffff;\">".substr($configs['aprsHostname'], 0, 16)."</td></tr>\n";
|
||||
}
|
||||
if ($configs['ircddbEnabled']) {
|
||||
echo "<tr><th>IRC</th><td style=\"background: #ffffff;\">".htmlspecialchars(substr((string)$configs['ircddbHostname'], 0, 16), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><th>IRC</th><td style=\"background: #ffffff;\">".substr($configs['ircddbHostname'], 0 ,16)."</td></tr>\n";
|
||||
}
|
||||
// getActualLink() returns log-parsed strings (DMR talkgroups,
|
||||
// D-Star reflector names, NXDN/M17 link state etc.) which can
|
||||
// carry RF-controllable bytes; escape before display.
|
||||
echo "<tr><td colspan=\"2\" style=\"background: #ffffff;\">".htmlspecialchars((string)getActualLink($reverseLogLinesMMDVM, "D-Star"), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><td colspan=\"2\" style=\"background: #ffffff;\">".getActualLink($reverseLogLinesMMDVM, "D-Star")."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
$testMMDVModeDMR = getConfigItem("DMR", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeDMR == 1 ) { //Hide the DMR information when DMR mode not enabled.
|
||||
// DMR_Hosts.txt: read once via getDMRHostsLines() (functions.php) and
|
||||
// cached for the request, so this scan and the YSF2DMR scan further
|
||||
// down both iterate the same in-memory line array instead of two
|
||||
// separate fopen/fgets passes over a 3-6K-line SD-card file.
|
||||
$dmrMasterFile = fopen("/usr/local/etc/DMR_Hosts.txt", "r");
|
||||
$dmrMasterHost = getConfigItem("DMR Network", "Address", $mmdvmconfigs);
|
||||
$dmrMasterPort = getConfigItem("DMR Network", "Port", $mmdvmconfigs);
|
||||
if ($dmrMasterHost == '127.0.0.1') {
|
||||
if (isset($configdmrgateway['XLX Network 1']['Address'])) { $xlxMasterHost1 = $configdmrgateway['XLX Network 1']['Address']; }
|
||||
else { $xlxMasterHost1 = ""; }
|
||||
$dmrMasterHost1 = $configdmrgateway['DMR Network 1']['Address'];
|
||||
$dmrMasterHost2 = $configdmrgateway['DMR Network 2']['Address'];
|
||||
$dmrMasterHost3 = str_replace('_', ' ', $configdmrgateway['DMR Network 3']['Name']);
|
||||
if (isset($configdmrgateway['DMR Network 4']['Name'])) {$dmrMasterHost4 = str_replace('_', ' ', $configdmrgateway['DMR Network 4']['Name']);}
|
||||
if (isset($configdmrgateway['DMR Network 5']['Name'])) {$dmrMasterHost5 = str_replace('_', ' ', $configdmrgateway['DMR Network 5']['Name']);}
|
||||
if (isset($configdmrgateway['DMR Network 6']['Name'])) {$dmrMasterHost6 = str_replace('_', ' ', $configdmrgateway['DMR Network 6']['Name']);}
|
||||
foreach (getDMRHostsLines() as $dmrMasterLine) {
|
||||
if (isset($configdmrgateway['XLX Network 1']['Address'])) { $xlxMasterHost1 = $configdmrgateway['XLX Network 1']['Address']; }
|
||||
else { $xlxMasterHost1 = ""; }
|
||||
$dmrMasterHost1 = $configdmrgateway['DMR Network 1']['Address'];
|
||||
$dmrMasterHost2 = $configdmrgateway['DMR Network 2']['Address'];
|
||||
$dmrMasterHost3 = str_replace('_', ' ', $configdmrgateway['DMR Network 3']['Name']);
|
||||
if (isset($configdmrgateway['DMR Network 4']['Name'])) {$dmrMasterHost4 = str_replace('_', ' ', $configdmrgateway['DMR Network 4']['Name']);}
|
||||
if (isset($configdmrgateway['DMR Network 5']['Name'])) {$dmrMasterHost5 = str_replace('_', ' ', $configdmrgateway['DMR Network 5']['Name']);}
|
||||
if (isset($configdmrgateway['DMR Network 6']['Name'])) {$dmrMasterHost6 = str_replace('_', ' ', $configdmrgateway['DMR Network 6']['Name']);}
|
||||
while (!feof($dmrMasterFile)) {
|
||||
$dmrMasterLine = fgets($dmrMasterFile);
|
||||
$dmrMasterHostF = preg_split('/\s+/', $dmrMasterLine);
|
||||
if ((count($dmrMasterHostF) >= 2) && (strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
|
||||
if ((strpos($dmrMasterHostF[0], 'XLX_') === 0) && ($xlxMasterHost1 == $dmrMasterHostF[2])) { $xlxMasterHost1 = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
if ((strpos($dmrMasterHostF[0], 'BM_') === 0) && ($dmrMasterHost1 == $dmrMasterHostF[2])) { $dmrMasterHost1 = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
if ((strpos($dmrMasterHostF[0], 'DMR+_') === 0) && ($dmrMasterHost2 == $dmrMasterHostF[2])) { $dmrMasterHost2 = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
}
|
||||
}
|
||||
if (strlen($xlxMasterHost1) > 19) { $xlxMasterHost1 = substr($xlxMasterHost1, 0, 17) . '..'; }
|
||||
if (strlen($dmrMasterHost1) > 19) { $dmrMasterHost1 = substr($dmrMasterHost1, 0, 17) . '..'; }
|
||||
if (strlen($dmrMasterHost2) > 19) { $dmrMasterHost2 = substr($dmrMasterHost2, 0, 17) . '..'; }
|
||||
if (strlen($dmrMasterHost3) > 19) { $dmrMasterHost3 = substr($dmrMasterHost3, 0, 17) . '..'; }
|
||||
if (isset($dmrMasterHost4)) { if (strlen($dmrMasterHost4) > 19) { $dmrMasterHost4 = substr($dmrMasterHost4, 0, 17) . '..'; } }
|
||||
if (isset($dmrMasterHost5)) { if (strlen($dmrMasterHost5) > 19) { $dmrMasterHost5 = substr($dmrMasterHost5, 0, 17) . '..'; } }
|
||||
if (isset($dmrMasterHost6)) { if (strlen($dmrMasterHost6) > 19) { $dmrMasterHost6 = substr($dmrMasterHost6, 0, 17) . '..'; } }
|
||||
if ((count($dmrMasterHostF) >= 2) && (strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
|
||||
if ((strpos($dmrMasterHostF[0], 'XLX_') === 0) && ($xlxMasterHost1 == $dmrMasterHostF[2])) { $xlxMasterHost1 = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
if ((strpos($dmrMasterHostF[0], 'CDN_') === 0) && ($dmrMasterHost1 == $dmrMasterHostF[2])) { $dmrMasterHost1 = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
if ((strpos($dmrMasterHostF[0], 'DMR+_') === 0) && ($dmrMasterHost2 == $dmrMasterHostF[2])) { $dmrMasterHost2 = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
}
|
||||
}
|
||||
if (strlen($xlxMasterHost1) > 19) { $xlxMasterHost1 = substr($xlxMasterHost1, 0, 17) . '..'; }
|
||||
if (strlen($dmrMasterHost1) > 19) { $dmrMasterHost1 = substr($dmrMasterHost1, 0, 17) . '..'; }
|
||||
if (strlen($dmrMasterHost2) > 19) { $dmrMasterHost2 = substr($dmrMasterHost2, 0, 17) . '..'; }
|
||||
if (strlen($dmrMasterHost3) > 19) { $dmrMasterHost3 = substr($dmrMasterHost3, 0, 17) . '..'; }
|
||||
if (isset($dmrMasterHost4)) { if (strlen($dmrMasterHost4) > 19) { $dmrMasterHost4 = substr($dmrMasterHost4, 0, 17) . '..'; } }
|
||||
if (isset($dmrMasterHost5)) { if (strlen($dmrMasterHost5) > 19) { $dmrMasterHost5 = substr($dmrMasterHost5, 0, 17) . '..'; } }
|
||||
if (isset($dmrMasterHost6)) { if (strlen($dmrMasterHost6) > 19) { $dmrMasterHost6 = substr($dmrMasterHost6, 0, 17) . '..'; } }
|
||||
}
|
||||
else {
|
||||
foreach (getDMRHostsLines() as $dmrMasterLine) {
|
||||
while (!feof($dmrMasterFile)) {
|
||||
$dmrMasterLine = fgets($dmrMasterFile);
|
||||
$dmrMasterHostF = preg_split('/\s+/', $dmrMasterLine);
|
||||
if ((count($dmrMasterHostF) >= 4) && (strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
|
||||
if (($dmrMasterHost == $dmrMasterHostF[2]) && ($dmrMasterPort == $dmrMasterHostF[4])) { $dmrMasterHost = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
}
|
||||
}
|
||||
if (strlen($dmrMasterHost) > 19) { $dmrMasterHost = substr($dmrMasterHost, 0, 17) . '..'; }
|
||||
if ((count($dmrMasterHostF) >= 4) && (strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
|
||||
if (($dmrMasterHost == $dmrMasterHostF[2]) && ($dmrMasterPort == $dmrMasterHostF[4])) { $dmrMasterHost = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
}
|
||||
}
|
||||
if (strlen($dmrMasterHost) > 19) { $dmrMasterHost = substr($dmrMasterHost, 0, 17) . '..'; }
|
||||
}
|
||||
fclose($dmrMasterFile);
|
||||
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\">".$lang['dmr_repeater']."</th></tr>\n";
|
||||
// All getConfigItem returns and $dmrMasterHost* values below
|
||||
// originate from /etc/mmdvmhost or /etc/dmrgateway (parse_ini)
|
||||
// or from log-parsed `exec(grep | awk)` pipelines. Escape every
|
||||
// echoed value so an editor-injected payload (closes the read
|
||||
// path of the M-3 stored XSS class) or a hostile log line can't
|
||||
// break out of the table cell.
|
||||
echo "<tr><th>DMR ID</th><td style=\"background: #ffffff;\">".htmlspecialchars((string)getConfigItem("General", "Id", $mmdvmconfigs), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><th>DMR CC</th><td style=\"background: #ffffff;\">".htmlspecialchars((string)getConfigItem("DMR", "ColorCode", $mmdvmconfigs), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><th>DMR ID</th><td style=\"background: #ffffff;\">".getConfigItem("General", "Id", $mmdvmconfigs)."</td></tr>\n";
|
||||
echo "<tr><th>DMR CC</th><td style=\"background: #ffffff;\">".getConfigItem("DMR", "ColorCode", $mmdvmconfigs)."</td></tr>\n";
|
||||
echo "<tr><th>TS1</th>";
|
||||
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == 1) { echo "<td style=\"background:#0b0;\">enabled</td></tr>\n"; } else { echo "<td style=\"background:#606060; color:#b0b0b0;\">disabled</td></tr>\n"; }
|
||||
echo "<tr><th>TS2</th>";
|
||||
if (getConfigItem("DMR Network", "Slot2", $mmdvmconfigs) == 1) { echo "<td style=\"background:#0b0;\">enabled</td></tr>\n"; } else { echo "<td style=\"background:#606060; color:#b0b0b0;\">disabled</td></tr>\n"; }
|
||||
echo "<tr><th colspan=\"2\">".$lang['dmr_master']."</th></tr>\n";
|
||||
if (getEnabled("DMR Network", $mmdvmconfigs) == 1) {
|
||||
if ($dmrMasterHost == '127.0.0.1') {
|
||||
if ((isset($configdmrgateway['XLX Network 1']['Enabled'])) && ($configdmrgateway['XLX Network 1']['Enabled'] == 1)) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$xlxMasterHost1, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
if ($dmrMasterHost == '127.0.0.1') {
|
||||
if ((isset($configdmrgateway['XLX Network 1']['Enabled'])) && ($configdmrgateway['XLX Network 1']['Enabled'] == 1)) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$xlxMasterHost1."</td></tr>\n";
|
||||
}
|
||||
if ( !isset($configdmrgateway['XLX Network 1']['Enabled']) && isset($configdmrgateway['XLX Network']['Enabled']) && $configdmrgateway['XLX Network']['Enabled'] == 1) {
|
||||
if (file_exists("/var/log/pi-star/DMRGateway-".gmdate("Y-m-d").".log")) { $xlxMasterHost1 = exec('grep \'XLX, Linking\|XLX, Unlinking\|XLX, Logged\' /var/log/pi-star/DMRGateway-'.gmdate("Y-m-d").'.log | tail -1 | awk \'{print $5 " " $8 " " $9}\''); }
|
||||
if (file_exists("/var/log/pi-star/DMRGateway-".gmdate("Y-m-d").".log")) { $xlxMasterHost1 = exec('grep \'XLX, Linking\|XLX, Unlinking\|XLX, Logged\' /var/log/pi-star/DMRGateway-'.gmdate("Y-m-d").'.log | tail -1 | awk \'{print $5 " " $8 " " $9}\''); }
|
||||
else { $xlxMasterHost1 = exec('grep \'XLX, Linking\|XLX, Unlinking\|XLX, Logged\' /var/log/pi-star/DMRGateway-'.gmdate("Y-m-d", time() - 86340).'.log | tail -1 | awk \'{print $5 " " $8 " " $9}\''); }
|
||||
if ( strpos($xlxMasterHost1, 'Linking') !== false ) { $xlxMasterHost1 = str_replace('Linking ', '', $xlxMasterHost1); }
|
||||
else if ( strpos($xlxMasterHost1, 'Unlinking') !== false ) { $xlxMasterHost1 = "XLX Not Linked"; }
|
||||
else if ( strpos($xlxMasterHost1, 'Logged') !== false ) { $xlxMasterHost1 = "XLX Not Linked"; }
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$xlxMasterHost1, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
if ( strpos($xlxMasterHost1, 'Linking') !== false ) { $xlxMasterHost1 = str_replace('Linking ', '', $xlxMasterHost1); }
|
||||
else if ( strpos($xlxMasterHost1, 'Unlinking') !== false ) { $xlxMasterHost1 = "XLX Not Linked"; }
|
||||
else if ( strpos($xlxMasterHost1, 'Logged') !== false ) { $xlxMasterHost1 = "XLX Not Linked"; }
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$xlxMasterHost1."</td></tr>\n";
|
||||
}
|
||||
if ($configdmrgateway['DMR Network 1']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$dmrMasterHost1, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
if ($configdmrgateway['DMR Network 2']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$dmrMasterHost2, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
if ($configdmrgateway['DMR Network 3']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$dmrMasterHost3, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 4']['Enabled'])) {
|
||||
if ($configdmrgateway['DMR Network 4']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$dmrMasterHost4, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 5']['Enabled'])) {
|
||||
if ($configdmrgateway['DMR Network 5']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$dmrMasterHost5, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 6']['Enabled'])) {
|
||||
if ($configdmrgateway['DMR Network 6']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$dmrMasterHost6, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".htmlspecialchars((string)$dmrMasterHost, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "<tr><td colspan=\"2\" style=\"background:#606060; color:#b0b0b0;\">No DMR Network</td></tr>\n";
|
||||
}
|
||||
if ($configdmrgateway['DMR Network 1']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$dmrMasterHost1."</td></tr>\n";
|
||||
}
|
||||
if ($configdmrgateway['DMR Network 2']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$dmrMasterHost2."</td></tr>\n";
|
||||
}
|
||||
if ($configdmrgateway['DMR Network 3']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$dmrMasterHost3."</td></tr>\n";
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 4']['Enabled'])) {
|
||||
if ($configdmrgateway['DMR Network 4']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$dmrMasterHost4."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 5']['Enabled'])) {
|
||||
if ($configdmrgateway['DMR Network 5']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$dmrMasterHost5."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 6']['Enabled'])) {
|
||||
if ($configdmrgateway['DMR Network 6']['Enabled'] == 1) {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$dmrMasterHost6."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "<tr><td style=\"background: #ffffff;\" colspan=\"2\">".$dmrMasterHost."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "<tr><td colspan=\"2\" style=\"background:#606060; color:#b0b0b0;\">No DMR Network</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
@@ -378,99 +314,100 @@ if ( $testMMDVModeYSF == 1 || $testDMR2YSF ) { //Hide the YSF information when S
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\">".$lang['ysf_net']."</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".htmlspecialchars((string)$ysfLinkedToTxt, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".$ysfLinkedToTxt."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
if ( isset($configysf2dmr['Enabled']['Enabled']) ) { $testYSF2DMR = $configysf2dmr['Enabled']['Enabled']; }
|
||||
if ( $testYSF2DMR ) { //Hide the YSF2DMR information when YSF2DMR Network mode not enabled.
|
||||
// Reuses the in-memory DMR_Hosts.txt line array cached by
|
||||
// getDMRHostsLines() — same data the DMR block above just
|
||||
// walked, no second SD-card read.
|
||||
$dmrMasterFile = fopen("/usr/local/etc/DMR_Hosts.txt", "r");
|
||||
$dmrMasterHost = $configysf2dmr['DMR Network']['Address'];
|
||||
foreach (getDMRHostsLines() as $dmrMasterLine) {
|
||||
while (!feof($dmrMasterFile)) {
|
||||
$dmrMasterLine = fgets($dmrMasterFile);
|
||||
$dmrMasterHostF = preg_split('/\s+/', $dmrMasterLine);
|
||||
if ((count($dmrMasterHostF) >= 2) && (strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
|
||||
if ((count($dmrMasterHostF) >= 2) && (strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
|
||||
if ($dmrMasterHost == $dmrMasterHostF[2]) { $dmrMasterHost = str_replace('_', ' ', $dmrMasterHostF[0]); }
|
||||
}
|
||||
}
|
||||
if (strlen($dmrMasterHost) > 19) { $dmrMasterHost = substr($dmrMasterHost, 0, 17) . '..'; }
|
||||
fclose($dmrMasterFile);
|
||||
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\">YSF2DMR</th></tr>\n";
|
||||
echo "<tr><th>DMR ID</th><td style=\"background: #ffffff;\">".htmlspecialchars((string)$configysf2dmr['DMR Network']['Id'], ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><th colspan=\"2\">YSF2".$lang['dmr_master']."</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".htmlspecialchars((string)$dmrMasterHost, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "<tr><th>DMR ID</th><td style=\"background: #ffffff;\">".$configysf2dmr['DMR Network']['Id']."</td></tr>\n";
|
||||
echo "<tr><th colspan=\"2\">YSF2".$lang['dmr_master']."</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".$dmrMasterHost."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
$testMMDVModeP25 = getConfigItem("P25 Network", "Enable", $mmdvmconfigs);
|
||||
if ( isset($configysf2p25['Enabled']['Enabled']) ) { $testYSF2P25 = $configysf2p25['Enabled']['Enabled']; }
|
||||
if ( $testMMDVModeP25 == 1 || $testYSF2P25 ) { //Hide the P25 information when P25 Network mode not enabled.
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
if (getConfigItem("P25", "NAC", $mmdvmconfigs)) {
|
||||
echo "<tr><th colspan=\"2\">".$lang['p25_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">NAC</th><td>".htmlspecialchars((string)getConfigItem("P25", "NAC", $mmdvmconfigs), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><th colspan=\"2\">".$lang['p25_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">NAC</th><td>0</td></tr>\n";
|
||||
}
|
||||
echo "<tr><th colspan=\"2\">".$lang['p25_net']."</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".htmlspecialchars((string)getActualLink($logLinesP25Gateway, "P25"), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
if (getConfigItem("P25", "NAC", $mmdvmconfigs)) {
|
||||
echo "<tr><th colspan=\"2\">".$lang['p25_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">NAC</th><td>".getConfigItem("P25", "NAC", $mmdvmconfigs)."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><th colspan=\"2\">".$lang['p25_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">NAC</th><td>0</td></tr>\n";
|
||||
}
|
||||
echo "<tr><th colspan=\"2\">".$lang['p25_net']."</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".getActualLink($logLinesP25Gateway, "P25")."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
$testMMDVModeNXDN = getConfigItem("NXDN Network", "Enable", $mmdvmconfigs);
|
||||
if ( isset($configysf2nxdn['Enabled']['Enabled']) ) { if ($configysf2nxdn['Enabled']['Enabled'] == 1) { $testYSF2NXDN = 1; } }
|
||||
if ( isset($configdmr2nxdn['Enabled']['Enabled']) ) { if ($configdmr2nxdn['Enabled']['Enabled'] == 1) { $testDMR2NXDN = 1; } }
|
||||
if ( $testMMDVModeNXDN == 1 || isset($testYSF2NXDN) || isset($testDMR2NXDN) ) { //Hide the NXDN information when NXDN Network mode not enabled.
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
if (getConfigItem("NXDN", "RAN", $mmdvmconfigs)) {
|
||||
echo "<tr><th colspan=\"2\">".$lang['nxdn_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">RAN</th><td>".htmlspecialchars((string)getConfigItem("NXDN", "RAN", $mmdvmconfigs), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><th colspan=\"2\">".$lang['nxdn_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">RAN</th><td>0</td></tr>\n";
|
||||
}
|
||||
echo "<tr><th colspan=\"2\">".$lang['nxdn_net']."</th></tr>\n";
|
||||
if (file_exists('/etc/nxdngateway')) {
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".htmlspecialchars((string)getActualLink($logLinesNXDNGateway, "NXDN"), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">TG 65000</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
if (getConfigItem("NXDN", "RAN", $mmdvmconfigs)) {
|
||||
echo "<tr><th colspan=\"2\">".$lang['nxdn_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">RAN</th><td>".getConfigItem("NXDN", "RAN", $mmdvmconfigs)."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><th colspan=\"2\">".$lang['nxdn_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">RAN</th><td>0</td></tr>\n";
|
||||
}
|
||||
echo "<tr><th colspan=\"2\">".$lang['nxdn_net']."</th></tr>\n";
|
||||
if (file_exists('/etc/nxdngateway')) {
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".getActualLink($logLinesNXDNGateway, "NXDN")."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">TG 65000</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
$testMMDVModeM17 = getConfigItem("M17 Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeM17 == 1 ) { //Hide the M17 information when P25 Network mode not enabled.
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
if (getConfigItem("M17", "CAN", $mmdvmconfigs)) {
|
||||
echo "<tr><th colspan=\"2\">".$lang['m17_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">CAN</th><td>".htmlspecialchars((string)getConfigItem("M17", "CAN", $mmdvmconfigs), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><th colspan=\"2\">".$lang['m17_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">CAN</th><td>0</td></tr>\n";
|
||||
}
|
||||
echo "<tr><th colspan=\"2\">".$lang['m17_net']."</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".htmlspecialchars((string)getActualLink($logLinesM17Gateway, "M17"), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
if (getConfigItem("M17", "CAN", $mmdvmconfigs)) {
|
||||
echo "<tr><th colspan=\"2\">".$lang['m17_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">CAN</th><td>".getConfigItem("M17", "CAN", $mmdvmconfigs)."</td></tr>\n";
|
||||
} else {
|
||||
echo "<tr><th colspan=\"2\">".$lang['m17_radio']."</th></tr>\n";
|
||||
echo "<tr><th style=\"width:70px\">CAN</th><td>0</td></tr>\n";
|
||||
}
|
||||
echo "<tr><th colspan=\"2\">".$lang['m17_net']."</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".getActualLink($logLinesM17Gateway, "M17")."</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
$testMMDVModePOCSAG = getConfigItem("POCSAG Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModePOCSAG == 1 ) { //Hide the POCSAG information when POCSAG Network mode not enabled.
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\">POCSAG</th></tr>\n";
|
||||
echo "<tr><th>Tx</th><td>".htmlspecialchars((string)getMHZ(getConfigItem("POCSAG", "Frequency", $mmdvmconfigs)), ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
if (isset($configdapnetgateway['DAPNET']['Address'])) {
|
||||
$dapnetGatewayRemoteAddr = $configdapnetgateway['DAPNET']['Address'];
|
||||
if (strlen($dapnetGatewayRemoteAddr) > 19) { $dapnetGatewayRemoteAddr = substr($dapnetGatewayRemoteAddr, 0, 17) . '..'; }
|
||||
echo "<tr><th colspan=\"2\">POCSAG Master</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".htmlspecialchars((string)$dapnetGatewayRemoteAddr, ENT_QUOTES, 'UTF-8')."</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\">POCSAG</th></tr>\n";
|
||||
echo "<tr><th>Tx</th><td>".getMHZ(getConfigItem("POCSAG", "Frequency", $mmdvmconfigs))."</td></tr>\n";
|
||||
if (isset($configdapnetgateway['DAPNET']['Address'])) {
|
||||
$dapnetGatewayRemoteAddr = $configdapnetgateway['DAPNET']['Address'];
|
||||
if (strlen($dapnetGatewayRemoteAddr) > 19) { $dapnetGatewayRemoteAddr = substr($dapnetGatewayRemoteAddr, 0, 17) . '..'; }
|
||||
echo "<tr><th colspan=\"2\">POCSAG Master</th></tr>\n";
|
||||
echo "<tr><td colspan=\"2\"style=\"background: #ffffff;\">".$dapnetGatewayRemoteAddr."</td></tr>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
// Set some Variable
|
||||
$repeaterid = "";
|
||||
$slot1tg = "";
|
||||
$slot2tg = "";
|
||||
$dmrID = "";
|
||||
|
||||
// Check if DMR is Enabled
|
||||
$testMMDVModeDMR = getConfigItem("DMR", "Enable", $mmdvmconfigs);
|
||||
|
||||
if ( $testMMDVModeDMR == 1 ) {
|
||||
//Load the dmrgateway config file
|
||||
$dmrGatewayConfigFile = '/etc/dmrgateway';
|
||||
if (fopen($dmrGatewayConfigFile,'r')) { $configdmrgateway = parse_ini_file($dmrGatewayConfigFile, true); }
|
||||
|
||||
// Get the current DMR Master from the config
|
||||
$dmrMasterHost = getConfigItem("DMR Network", "Address", $mmdvmconfigs);
|
||||
if ( $dmrMasterHost == '127.0.0.1' ) {
|
||||
// DMRGateway, need to check each config
|
||||
if (isset($configdmrgateway['DMR Network 1']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 1']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 1']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 1']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 2']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 2']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 2']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 2']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 3']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 3']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 3']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 3']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 4']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 4']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 4']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 4']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 5']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 5']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 5']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 5']['Id'];
|
||||
}
|
||||
}
|
||||
} else if ( $dmrMasterHost == 'tgif.network' ) {
|
||||
// MMDVMHost Connected directly to TGIF, get the ID form here
|
||||
if (getConfigItem("DMR", "Id", $mmdvmconfigs)) {
|
||||
$dmrID = getConfigItem("DMR", "Id", $mmdvmconfigs);
|
||||
} else {
|
||||
$dmrID = getConfigItem("General", "Id", $mmdvmconfigs);
|
||||
}
|
||||
}
|
||||
|
||||
// Use TGIF API to get information about current TGs
|
||||
$jsonContext = stream_context_create(array('http'=>array('timeout' => 2, 'header' => 'User-Agent: Pi-Star Dashboard for '.$dmrID) )); // Add Timout and User Agent to include DMRID
|
||||
$json_data = file_get_contents("http://tgif.network:5040/api/sessions", false, $jsonContext);
|
||||
$json = json_decode($json_data, false);
|
||||
|
||||
// Work out what session number we are using
|
||||
foreach($json as $key => $jsons) {
|
||||
foreach($jsons as $key => $value) {
|
||||
if ($json->sessions[$key]->repeater_id == $dmrID) { $session_nr = $key; }
|
||||
}
|
||||
}
|
||||
|
||||
// Pull the information from JSON
|
||||
if (isset($session_nr)) {
|
||||
$repeaterid = $json->sessions[$session_nr]->repeater_id;
|
||||
if ($json->sessions[$session_nr]->tg0 == "4000") { $slot1tg = "None"; } else { $slot1tg = "TG".$json->sessions[$session_nr]->tg0; }
|
||||
if ($json->sessions[$session_nr]->tg == "4000") { $slot2tg = "None"; } else { $slot2tg = "TG".$json->sessions[$session_nr]->tg; }
|
||||
|
||||
echo '<b>Active TGIF Connections</b>
|
||||
<table>
|
||||
<tr>
|
||||
<th style="width:25%;"><a class=tooltip href="#">DMR Master<span><b>Connected Master</b></span></a></th>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Repeater ID<span><b>The ID for this Repeater/Hotspot</b></span></a></th>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Slot1 TG<span><b>TG linked to Slot 1</b></span></a></th>
|
||||
<th><a class=tooltip href="#">Slot2 TG<span><b>TG linked to Slot 2</b></span></a></th>
|
||||
</tr>'."\n";
|
||||
|
||||
echo ' <tr>'."\n";
|
||||
echo ' <td>tgif.network</td>';
|
||||
echo '<td>'.$repeaterid.'</td>';
|
||||
echo '<td>'.$slot1tg.'</td>';
|
||||
echo '<td>'.$slot2tg.'</td>';
|
||||
echo '</tr>'."\n";
|
||||
echo ' </table>'."\n";
|
||||
echo ' <br />'."\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
+156
-183
@@ -1,192 +1,165 @@
|
||||
<?php
|
||||
/**
|
||||
* TGIF talkgroup link/unlink form (admin-only).
|
||||
*
|
||||
* Loaded inline by /index.php only on the admin path
|
||||
* (`$_SERVER["PHP_SELF"] == "/admin/index.php"` gate). Form fields:
|
||||
* tgifNumber — talkgroup number (numeric, validated)
|
||||
* tgifSlot — DMR slot 1 or 2
|
||||
* tgifAction — LINK or UNLINK (UNLINK uses default TG 4000)
|
||||
*
|
||||
* On submit, makes an HTTP GET to
|
||||
* http://tgif.network:5040/api/sessions/update/{id}/{slot}/{tg}
|
||||
* and triggers a 3 s `setTimeout` reload of the parent page.
|
||||
*
|
||||
* UPSTREAM API NOTE: TGIF retired the read-only `/api/sessions`
|
||||
* endpoint in late 2026 (now 404), and replaced active-TG visibility
|
||||
* with a Socket.IO + browser-session-token flow that doesn't fit a
|
||||
* backend-rendered hotspot dashboard. The live "Active TGIF
|
||||
* Connections" panel that used to sit above this form has been
|
||||
* removed for that reason. The link/unlink update endpoint this
|
||||
* file uses is still alive on plain HTTP — there's no HTTPS
|
||||
* variant on :5040, and tightening that side is gated on TGIF
|
||||
* shipping a documented replacement.
|
||||
*
|
||||
* Operators who want to see the current TG state should visit
|
||||
* https://tgif.network/profile.php?tab=SelfCare directly.
|
||||
*/
|
||||
|
||||
if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside of the admin page
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
function httpStatusText($code = 0) {
|
||||
// List of HTTP status codes.
|
||||
$statuslist = array(
|
||||
'100' => 'Continue',
|
||||
'101' => 'Switching Protocols',
|
||||
'200' => 'OK',
|
||||
'201' => 'Created',
|
||||
'202' => 'Accepted',
|
||||
'203' => 'Non-Authoritative Information',
|
||||
'204' => 'No Content',
|
||||
'205' => 'Reset Content',
|
||||
'206' => 'Partial Content',
|
||||
'300' => 'Multiple Choices',
|
||||
'302' => 'Found',
|
||||
'303' => 'See Other',
|
||||
'304' => 'Not Modified',
|
||||
'305' => 'Use Proxy',
|
||||
'400' => 'Bad Request',
|
||||
'401' => 'Unauthorized',
|
||||
'402' => 'Payment Required',
|
||||
'403' => 'Forbidden',
|
||||
'404' => 'Not Found',
|
||||
'405' => 'Method Not Allowed',
|
||||
'406' => 'Not Acceptable',
|
||||
'407' => 'Proxy Authentication Required',
|
||||
'408' => 'Request Timeout',
|
||||
'409' => 'Conflict',
|
||||
'410' => 'Gone',
|
||||
'411' => 'Length Required',
|
||||
'412' => 'Precondition Failed',
|
||||
'413' => 'Request Entity Too Large',
|
||||
'414' => 'Request-URI Too Long',
|
||||
'415' => 'Unsupported Media Type',
|
||||
'416' => 'Requested Range Not Satisfiable',
|
||||
'417' => 'Expectation Failed',
|
||||
'500' => 'Internal Server Error',
|
||||
'501' => 'Not Implemented',
|
||||
'502' => 'Bad Gateway',
|
||||
'503' => 'Service Unavailable',
|
||||
'504' => 'Gateway Timeout',
|
||||
'505' => 'HTTP Version Not Supported'
|
||||
);
|
||||
// Caste the status code to a string.
|
||||
$code = preg_replace("/[^0-9]/", "", $code);
|
||||
$code = (string)$code;
|
||||
// Determine if it exists in the array.
|
||||
if(array_key_exists($code, $statuslist) ) {
|
||||
// Return the status text
|
||||
return $statuslist[$code];
|
||||
} else {
|
||||
// If it doesn't exists, degrade by returning the code.
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
function httpStatusText($code = 0) {
|
||||
// List of HTTP status codes.
|
||||
$statuslist = array(
|
||||
'100' => 'Continue',
|
||||
'101' => 'Switching Protocols',
|
||||
'200' => 'OK',
|
||||
'201' => 'Created',
|
||||
'202' => 'Accepted',
|
||||
'203' => 'Non-Authoritative Information',
|
||||
'204' => 'No Content',
|
||||
'205' => 'Reset Content',
|
||||
'206' => 'Partial Content',
|
||||
'300' => 'Multiple Choices',
|
||||
'302' => 'Found',
|
||||
'303' => 'See Other',
|
||||
'304' => 'Not Modified',
|
||||
'305' => 'Use Proxy',
|
||||
'400' => 'Bad Request',
|
||||
'401' => 'Unauthorized',
|
||||
'402' => 'Payment Required',
|
||||
'403' => 'Forbidden',
|
||||
'404' => 'Not Found',
|
||||
'405' => 'Method Not Allowed',
|
||||
'406' => 'Not Acceptable',
|
||||
'407' => 'Proxy Authentication Required',
|
||||
'408' => 'Request Timeout',
|
||||
'409' => 'Conflict',
|
||||
'410' => 'Gone',
|
||||
'411' => 'Length Required',
|
||||
'412' => 'Precondition Failed',
|
||||
'413' => 'Request Entity Too Large',
|
||||
'414' => 'Request-URI Too Long',
|
||||
'415' => 'Unsupported Media Type',
|
||||
'416' => 'Requested Range Not Satisfiable',
|
||||
'417' => 'Expectation Failed',
|
||||
'500' => 'Internal Server Error',
|
||||
'501' => 'Not Implemented',
|
||||
'502' => 'Bad Gateway',
|
||||
'503' => 'Service Unavailable',
|
||||
'504' => 'Gateway Timeout',
|
||||
'505' => 'HTTP Version Not Supported'
|
||||
);
|
||||
// Caste the status code to a string.
|
||||
$code = preg_replace("/[^0-9]/", "", $code);
|
||||
$code = (string)$code;
|
||||
// Determine if it exists in the array.
|
||||
if(array_key_exists($code, $statuslist) ) {
|
||||
// Return the status text
|
||||
return $statuslist[$code];
|
||||
} else {
|
||||
// If it doesn't exists, degrade by returning the code.
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
// Set some Variable
|
||||
$dmrID = "";
|
||||
// Set some Variable
|
||||
$dmrID = "";
|
||||
|
||||
// Check if DMR is Enabled
|
||||
$testMMDVModeDMR = getConfigItem("DMR", "Enable", $mmdvmconfigs);
|
||||
// Check if DMR is Enabled
|
||||
$testMMDVModeDMR = getConfigItem("DMR", "Enable", $mmdvmconfigs);
|
||||
|
||||
if ( $testMMDVModeDMR == 1 ) {
|
||||
//Load the dmrgateway config file
|
||||
$dmrGatewayConfigFile = '/etc/dmrgateway';
|
||||
if (fopen($dmrGatewayConfigFile,'r')) { $configdmrgateway = parse_ini_file($dmrGatewayConfigFile, true); }
|
||||
if ( $testMMDVModeDMR == 1 ) {
|
||||
//Load the dmrgateway config file
|
||||
$dmrGatewayConfigFile = '/etc/dmrgateway';
|
||||
if (fopen($dmrGatewayConfigFile,'r')) { $configdmrgateway = parse_ini_file($dmrGatewayConfigFile, true); }
|
||||
|
||||
// Get the current DMR Master from the config
|
||||
$dmrMasterHost = getConfigItem("DMR Network", "Address", $mmdvmconfigs);
|
||||
if ( $dmrMasterHost == '127.0.0.1' ) {
|
||||
// DMRGateway, need to check each config
|
||||
if (isset($configdmrgateway['DMR Network 1']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 1']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 1']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 1']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 2']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 2']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 2']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 2']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 3']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 3']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 3']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 3']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 4']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 4']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 4']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 4']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 5']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 5']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 5']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 5']['Id'];
|
||||
}
|
||||
}
|
||||
} else if ( $dmrMasterHost == 'tgif.network' ) {
|
||||
// MMDVMHost Connected directly to TGIF, get the ID form here
|
||||
if (getConfigItem("DMR", "Id", $mmdvmconfigs)) {
|
||||
$dmrID = getConfigItem("DMR", "Id", $mmdvmconfigs);
|
||||
} else {
|
||||
$dmrID = getConfigItem("General", "Id", $mmdvmconfigs);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get the current DMR Master from the config
|
||||
$dmrMasterHost = getConfigItem("DMR Network", "Address", $mmdvmconfigs);
|
||||
if ( $dmrMasterHost == '127.0.0.1' ) {
|
||||
// DMRGateway, need to check each config
|
||||
if (isset($configdmrgateway['DMR Network 1']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 1']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 1']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 1']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 2']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 2']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 2']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 2']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 3']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 3']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 3']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 3']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 4']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 4']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 4']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 4']['Id'];
|
||||
}
|
||||
}
|
||||
if (isset($configdmrgateway['DMR Network 5']['Address'])) {
|
||||
if (($configdmrgateway['DMR Network 5']['Address'] == "tgif.network") && ($configdmrgateway['DMR Network 5']['Enabled'])) {
|
||||
$dmrID = $configdmrgateway['DMR Network 5']['Id'];
|
||||
}
|
||||
}
|
||||
} else if ( $dmrMasterHost == 'tgif.network' ) {
|
||||
// MMDVMHost Connected directly to TGIF, get the ID form here
|
||||
if (getConfigItem("DMR", "Id", $mmdvmconfigs)) {
|
||||
$dmrID = getConfigItem("DMR", "Id", $mmdvmconfigs);
|
||||
} else {
|
||||
$dmrID = getConfigItem("General", "Id", $mmdvmconfigs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $dmrID ) {
|
||||
// Work out if the data has been posted or not
|
||||
if ( !empty($_POST) && isset($_POST["tgifSubmit"]) ): // Data has been posted for this page
|
||||
// Are we a repeater
|
||||
if ( getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == "0" ) {
|
||||
$targetSlot = "1";
|
||||
} else {
|
||||
$targetSlot = preg_replace("/[^0-9]/", "", $_POST["tgifSlot"]);
|
||||
$targetSlot--;
|
||||
}
|
||||
// Figure out what has been posted
|
||||
if ( (isset($_POST["tgifNumber"])) && (isset($_POST["tgifSubmit"])) ) {
|
||||
$targetTG = preg_replace("/[^0-9]/", "", $_POST["tgifNumber"]);
|
||||
if ($targetTG < 1) { $targetTG = "4000"; }
|
||||
} else {
|
||||
$targetTG = "4000";
|
||||
}
|
||||
if ($_POST["tgifAction"] == "UNLINK") { $targetTG = "4000"; }
|
||||
// Perform the GET request
|
||||
$tgifApiUrl = "http://tgif.network:5040/api/sessions/update/".$dmrID."/".$targetSlot."/".$targetTG;
|
||||
$result = file_get_contents($tgifApiUrl);
|
||||
// Output to the browser
|
||||
echo '<b>TGIF Manager</b>'."\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
//echo "Sending command to TGIF API";
|
||||
echo "TGIF API: ";
|
||||
echo httpStatusText($result);
|
||||
echo "</td></tr>\n</table>\n";
|
||||
echo "<br />\n";
|
||||
// Clean up...
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},3000);</script>';
|
||||
else: // Do this when we are not handling post data
|
||||
echo '<b>TGIF Manager</b>'."\n";
|
||||
echo '<form action="'.htmlentities($_SERVER['PHP_SELF']).'" method="post">'."\n";
|
||||
echo csrf_field_html()."\n";
|
||||
echo '<table>
|
||||
<tr>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Talkgroup Number<span><b>Enter the Talkgroup number</b></span></a></th>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Slot<span><b>Where to link/unlink</b></span></a></th>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Link / Unlink<span><b>Link or unlink</b></span></a></th>
|
||||
<th><a class=tooltip href="#">Action<span><b>Take Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="tgifNumber" size="10" maxlength="7" /></td>
|
||||
<td><input type="radio" name="tgifSlot" value="1" />TS1 <input type="radio" name="tgifSlot" value="2" checked="checked" />TS2</td>
|
||||
<td><input type="radio" name="tgifAction" value="LINK" />Link <input type="radio" name="tgifAction" value="UNLINK" checked="checked" />UnLink</td>
|
||||
<td><input type="submit" value="Modify Static" name="tgifSubmit" /></td>
|
||||
</tr>
|
||||
</table><br />'."\n";
|
||||
endif;
|
||||
}
|
||||
if ( $dmrID ) {
|
||||
// Work out if the data has been posted or not
|
||||
if ( !empty($_POST) && isset($_POST["tgifSubmit"]) ): // Data has been posted for this page
|
||||
// Are we a repeater
|
||||
if ( getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == "0" ) {
|
||||
$targetSlot = "1";
|
||||
} else {
|
||||
$targetSlot = preg_replace("/[^0-9]/", "", $_POST["tgifSlot"]);
|
||||
$targetSlot--;
|
||||
}
|
||||
// Figure out what has been posted
|
||||
if ( (isset($_POST["tgifNumber"])) && (isset($_POST["tgifSubmit"])) ) {
|
||||
$targetTG = preg_replace("/[^0-9]/", "", $_POST["tgifNumber"]);
|
||||
if ($targetTG < 1) { $targetTG = "4000"; }
|
||||
} else {
|
||||
$targetTG = "4000";
|
||||
}
|
||||
if ($_POST["tgifAction"] == "UNLINK") { $targetTG = "4000"; }
|
||||
// Perform the GET request
|
||||
$tgifApiUrl = "http://tgif.network:5040/api/sessions/update/".$dmrID."/".$targetSlot."/".$targetTG;
|
||||
$result = file_get_contents($tgifApiUrl);
|
||||
// Output to the browser
|
||||
echo '<b>TGIF Manager</b>'."\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
//echo "Sending command to TGIF API";
|
||||
echo "TGIF API: ";
|
||||
echo httpStatusText($result);
|
||||
echo "</td></tr>\n</table>\n";
|
||||
echo "<br />\n";
|
||||
// Clean up...
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},3000);</script>';
|
||||
else: // Do this when we are not handling post data
|
||||
echo '<b>TGIF Manager</b>'."\n";
|
||||
echo '<form action="'.htmlentities($_SERVER['PHP_SELF']).'" method="post">'."\n";
|
||||
echo '<table>
|
||||
<tr>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Talkgroup Number<span><b>Enter the Talkgroup number</b></span></a></th>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Slot<span><b>Where to link/unlink</b></span></a></th>
|
||||
<th style="width:25%;"><a class=tooltip href="#">Link / Unlink<span><b>Link or unlink</b></span></a></th>
|
||||
<th><a class=tooltip href="#">Action<span><b>Take Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="tgifNumber" size="10" maxlength="7" /></td>
|
||||
<td><input type="radio" name="tgifSlot" value="1" />TS1 <input type="radio" name="tgifSlot" value="2" checked="checked" />TS2</td>
|
||||
<td><input type="radio" name="tgifAction" value="LINK" />Link <input type="radio" name="tgifAction" value="UNLINK" checked="checked" />UnLink</td>
|
||||
<td><input type="submit" value="Modify Static" name="tgifSubmit" /></td>
|
||||
</tr>
|
||||
</table><br />'."\n";
|
||||
endif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
+60
-96
@@ -1,73 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Small utility helpers used across the mmdvmhost partials and
|
||||
* functions.php. Procedural, no class wrapping — just standalone
|
||||
* functions included via `include_once` from many sites.
|
||||
*
|
||||
* Inventory:
|
||||
* - format_time() Pretty-print a duration in seconds as a
|
||||
* "Xd, Yhr, Zmin, Ws" string with HTML
|
||||
* non-breaking spaces (intended for the
|
||||
* dashboard table cells).
|
||||
* - startsWith() Substring "starts-with" check used by
|
||||
* getConfigItem() and the log parsers in
|
||||
* functions.php.
|
||||
* - getMHZ() Convert a 9-digit Hz integer (as written
|
||||
* into /etc/mmdvmhost) into "fff.ffffff MHz"
|
||||
* for display.
|
||||
* - isProcessRunning() Cheap pgrep-like check via `ps -eo args` /
|
||||
* `ps -eo comm`. Cached on first call so
|
||||
* subsequent calls in the same request hit
|
||||
* the cached process list. Pass refresh=true
|
||||
* to force a re-scan in long-running scripts.
|
||||
* - createConfigLines() Build PHP `define()` strings from $_GET
|
||||
* query-string parameters. Legacy helper;
|
||||
* not currently called from active code.
|
||||
* - getSize() Convert a byte count to a B/KB/MB/GB/...
|
||||
* friendly string.
|
||||
* - checkSetup() Diagnostic helper that flags an old config
|
||||
* format. Called from legacy install paths.
|
||||
*/
|
||||
function format_time($seconds) {
|
||||
$secs = intval($seconds % 60);
|
||||
$mins = intval($seconds / 60 % 60);
|
||||
$hours = intval($seconds / 3600 % 24);
|
||||
$days = intval($seconds / 86400);
|
||||
$uptimeString = "";
|
||||
|
||||
function format_time($seconds)
|
||||
{
|
||||
$secs = intval($seconds % 60);
|
||||
$mins = intval($seconds / 60 % 60);
|
||||
$hours = intval($seconds / 3600 % 24);
|
||||
$days = intval($seconds / 86400);
|
||||
$uptimeString = "";
|
||||
|
||||
if ($days > 0) {
|
||||
$uptimeString .= $days;
|
||||
$uptimeString .= (($days == 1) ? " day" : " days");
|
||||
}
|
||||
if ($hours > 0) {
|
||||
$uptimeString .= (($days > 0) ? ", " : "") . $hours;
|
||||
$uptimeString .= (($hours == 1) ? " hr" : " hrs");
|
||||
}
|
||||
if ($mins > 0) {
|
||||
$uptimeString .= (($days > 0 || $hours > 0) ? ", " : "") . $mins;
|
||||
$uptimeString .= (($mins == 1) ? " min" : " mins");
|
||||
}
|
||||
if ($secs > 0) {
|
||||
$uptimeString .= (($days > 0 || $hours > 0 || $mins > 0) ? ", " : "") . $secs;
|
||||
$uptimeString .= (($secs == 1) ? " s" : " s");
|
||||
}
|
||||
return $uptimeString;
|
||||
if ($days > 0) {
|
||||
$uptimeString .= $days;
|
||||
$uptimeString .= (($days == 1) ? " day" : " days");
|
||||
}
|
||||
if ($hours > 0) {
|
||||
$uptimeString .= (($days > 0) ? ", " : "") . $hours;
|
||||
$uptimeString .= (($hours == 1) ? " hr" : " hrs");
|
||||
}
|
||||
if ($mins > 0) {
|
||||
$uptimeString .= (($days > 0 || $hours > 0) ? ", " : "") . $mins;
|
||||
$uptimeString .= (($mins == 1) ? " min" : " mins");
|
||||
}
|
||||
if ($secs > 0) {
|
||||
$uptimeString .= (($days > 0 || $hours > 0 || $mins > 0) ? ", " : "") . $secs;
|
||||
$uptimeString .= (($secs == 1) ? " s" : " s");
|
||||
}
|
||||
return $uptimeString;
|
||||
}
|
||||
|
||||
function startsWith($haystack, $needle)
|
||||
{
|
||||
function startsWith($haystack, $needle) {
|
||||
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
|
||||
}
|
||||
|
||||
function getMHZ($freq)
|
||||
{
|
||||
return substr($freq,0,3) . "." . substr($freq,3,6) . " MHz";
|
||||
function getMHZ($freq) {
|
||||
return substr($freq,0,3) . "." . substr($freq,3,6) . " MHz";
|
||||
}
|
||||
|
||||
function isProcessRunning($processName, $full = false, $refresh = false)
|
||||
{
|
||||
function isProcessRunning($processName, $full = false, $refresh = false) {
|
||||
if ($full) {
|
||||
static $processes_full = array();
|
||||
if ($refresh) $processes_full = array();
|
||||
@@ -86,44 +52,42 @@ function isProcessRunning($processName, $full = false, $refresh = false)
|
||||
return false;
|
||||
}
|
||||
|
||||
function createConfigLines()
|
||||
{
|
||||
$out ="";
|
||||
foreach($_GET as $key=>$val) {
|
||||
if($key != "cmd") {
|
||||
$out .= "define(\"$key\", \"$val\");"."\n";
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
function createConfigLines() {
|
||||
$out ="";
|
||||
foreach($_GET as $key=>$val) {
|
||||
if($key != "cmd") {
|
||||
$out .= "define(\"$key\", \"$val\");"."\n";
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
function getSize($filesize, $precision = 2) {
|
||||
$units = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y');
|
||||
foreach ($units as $idUnit => $unit) {
|
||||
if ($filesize > 1024)
|
||||
$filesize /= 1024;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return round($filesize, $precision).' '.$units[$idUnit].'B';
|
||||
}
|
||||
|
||||
function getSize($filesize, $precision = 2)
|
||||
{
|
||||
$units = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y');
|
||||
foreach ($units as $idUnit => $unit) {
|
||||
if ($filesize > 1024)
|
||||
$filesize /= 1024;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return round($filesize, $precision).' '.$units[$idUnit].'B';
|
||||
}
|
||||
|
||||
function checkSetup()
|
||||
{
|
||||
$el = error_reporting();
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
if (defined(DISTRIBUTION)) {
|
||||
function checkSetup() {
|
||||
$el = error_reporting();
|
||||
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
||||
if (defined(DISTRIBUTION)) {
|
||||
?>
|
||||
<div class="alert alert-danger" role="alert">You are using an old config.php. Please configure your Dashboard by calling <a href="setup.php">setup.php</a>!</div>
|
||||
<?php
|
||||
|
||||
} else {
|
||||
if (file_exists ("setup.php")) {
|
||||
?>
|
||||
<div class="alert alert-danger" role="alert">You forgot to remove setup.php in root-directory of your dashboard or you forgot to configure it! Please delete the file or configure your Dashboard by calling <a href="setup.php">setup.php</a>!</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
error_reporting($el);
|
||||
|
||||
} else {
|
||||
if (file_exists ("setup.php")) {
|
||||
?>
|
||||
<div class="alert alert-danger" role="alert">You forgot to remove setup.php in root-directory of your dashboard or you forgot to configure it! Please delete the file or configure your Dashboard by calling <a href="setup.php">setup.php</a>!</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
error_reporting($el);
|
||||
}
|
||||
?>
|
||||
|
||||
+133
-160
@@ -1,166 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* YSF reflector link/unlink form (admin-only).
|
||||
*
|
||||
* Loaded inline by /index.php only on the admin path
|
||||
* (`$_SERVER["PHP_SELF"] == "/admin/index.php"` gate).
|
||||
*
|
||||
* Form fields:
|
||||
* ysfLinkHost — reflector identifier (alphanumeric, validated; YSF
|
||||
* hosts use 5-digit numeric IDs, FCS uses FCSnnn-mm
|
||||
* style)
|
||||
* Link — LINK or UNLINK
|
||||
*
|
||||
* On submit, runs `sudo /usr/local/bin/RemoteCommand <port> Link|UnLink
|
||||
* <target>` against the YSFGateway remote-control port configured in
|
||||
* /etc/ysfgateway. Triggers a 2 s `setTimeout` reload.
|
||||
*
|
||||
* Inputs:
|
||||
* /etc/ysfgateway Gateway config + remote port. Remote
|
||||
* Commands must be enabled there for
|
||||
* this form to do anything.
|
||||
* /usr/local/etc/YSFHosts.txt Reflector picklist.
|
||||
* /usr/local/etc/FCSHosts.txt Optional FCS rooms picklist.
|
||||
*
|
||||
* NOTE for the security pass: validation is whitelist-regex; no
|
||||
* setEmbeddableSecurityHeaders() call in this file. Coverage gap.
|
||||
*/
|
||||
|
||||
if ($_SERVER["PHP_SELF"] == "/admin/index.php") { // Stop this working outside of the admin page
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
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
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
|
||||
// Check if YSF is Enabled
|
||||
$testMMDVModeYSF = getConfigItem("System Fusion Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeYSF == 1 ) {
|
||||
// Check if YSF is Enabled
|
||||
$testMMDVModeYSF = getConfigItem("System Fusion Network", "Enable", $mmdvmconfigs);
|
||||
if ( $testMMDVModeYSF == 1 ) {
|
||||
|
||||
//Load the ysfgateway config file
|
||||
$ysfGatewayConfigFile = '/etc/ysfgateway';
|
||||
if (fopen($ysfGatewayConfigFile,'r')) { $configysfgateway = parse_ini_file($ysfGatewayConfigFile, true); }
|
||||
//Load the ysfgateway config file
|
||||
$ysfGatewayConfigFile = '/etc/ysfgateway';
|
||||
if (fopen($ysfGatewayConfigFile,'r')) { $configysfgateway = parse_ini_file($ysfGatewayConfigFile, true); }
|
||||
|
||||
// Check that the remote is enabled
|
||||
if ( $configysfgateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $configysfgateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["ysfMgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9]/',$_POST['ysfLinkHost'])) { unset ($_POST['ysfLinkHost']);}
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['ysfLinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." UnLink";
|
||||
} else {
|
||||
$formattedLinkTarget = preg_replace('/([a-zA-Z]+)([0-9]+)/', '$1 $2', $_POST['ysfLinkHost']);
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Link".$formattedLinkTarget;
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." UnLink";
|
||||
} else {
|
||||
echo "<b>YSF Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['ysfLinkHost'])) {
|
||||
echo "<b>YSF Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>YSF Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo htmlspecialchars((string)exec($remoteCommand), ENT_QUOTES, 'UTF-8');
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>YSF Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<?php csrf_field(); ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="ysfLinkHost">
|
||||
<?php
|
||||
if (isset($configysfgateway['Network']['Startup'])) {
|
||||
$testYSFHost = $configysfgateway['Network']['Startup'];
|
||||
echo " <option value=\"none\">None</option>\n";
|
||||
}
|
||||
else {
|
||||
$testYSFHost = "none";
|
||||
echo " <option value=\"none\" selected=\"selected\">None</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "ZZ Parrot") {
|
||||
echo " <option value=\"YSF00001\" selected=\"selected\">YSF00001 - Parrot</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00001\">YSF00001 - Parrot</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "YSF2DMR") {
|
||||
echo " <option value=\"YSF00002\" selected=\"selected\">YSF00002 - Link YSF2DMR</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00002\">YSF00002 - Link YSF2DMR</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "YSF2NXDN") {
|
||||
echo " <option value=\"YSF00003\" selected=\"selected\">YSF00003 - Link YSF2NXDN</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00003\">YSF00003 - Link YSF2NXDN</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "YSF2P25") {
|
||||
echo " <option value=\"YSF00004\" selected=\"selected\">YSF00004 - Link YSF2P25</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00004\">YSF00004 - Link YSF2P25</option>\n";
|
||||
}
|
||||
$ysfHosts = fopen("/usr/local/etc/YSFHosts.txt", "r");
|
||||
while (!feof($ysfHosts)) {
|
||||
$ysfHostsLine = fgets($ysfHosts);
|
||||
$ysfHost = preg_split('/;/', $ysfHostsLine);
|
||||
if ((strpos($ysfHost[0], '#') === FALSE ) && ($ysfHost[0] != '')) {
|
||||
if (strlen($ysfHost[1]) >= 30) { $ysfHost[1] = substr($ysfHost[1], 0, 27)."..."; }
|
||||
if ($testYSFHost == $ysfHost[1]) { echo " <option value=\"YSF$ysfHost[0]\" selected=\"selected\">YSF$ysfHost[0] - ".htmlspecialchars($ysfHost[1])." - ".htmlspecialchars($ysfHost[2])."</option>\n"; }
|
||||
else { echo " <option value=\"YSF$ysfHost[0]\">YSF$ysfHost[0] - ".htmlspecialchars($ysfHost[1])." - ".htmlspecialchars($ysfHost[2])."</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($ysfHosts);
|
||||
if (file_exists("/usr/local/etc/FCSHosts.txt")) {
|
||||
$fcsHosts = fopen("/usr/local/etc/FCSHosts.txt", "r");
|
||||
while (!feof($fcsHosts)) {
|
||||
$ysfHostsLine = fgets($fcsHosts);
|
||||
$ysfHost = preg_split('/;/', $ysfHostsLine);
|
||||
if (substr($ysfHost[0], 0, 3) == "FCS") {
|
||||
if (strlen($ysfHost[1]) >= 30) { $ysfHost[1] = substr($ysfHost[1], 0, 27)."..."; }
|
||||
if ($testYSFHost == $ysfHost[0]) { echo " <option value=\"$ysfHost[0]\" selected=\"selected\">$ysfHost[0] - ".htmlspecialchars($ysfHost[1])."</option>\n"; }
|
||||
else { echo " <option value=\"$ysfHost[0]\">$ysfHost[0] - ".htmlspecialchars($ysfHost[1])."</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($fcsHosts);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="ysfMgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check that the remote is enabled
|
||||
if ( $configysfgateway['Remote Commands']['Enable'] == 1 ) {
|
||||
$remotePort = $configysfgateway['Remote Commands']['Port'];
|
||||
if (!empty($_POST) && isset($_POST["ysfMgrSubmit"])) {
|
||||
// Handle Posted Data
|
||||
if (preg_match('/[^A-Za-z0-9]/',$_POST['ysfLinkHost'])) { unset ($_POST['ysfLinkHost']);}
|
||||
if ($_POST["Link"] == "LINK") {
|
||||
if ($_POST['ysfLinkHost'] == "none") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." UnLink";
|
||||
} else {
|
||||
$formattedLinkTarget = preg_replace('/([a-zA-Z]+)([0-9]+)/', '$1 $2', $_POST['ysfLinkHost']);
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." Link".$formattedLinkTarget;
|
||||
}
|
||||
} elseif ($_POST["Link"] == "UNLINK") {
|
||||
$remoteCommand = "cd /var/log/pi-star && sudo /usr/local/bin/RemoteCommand ".$remotePort." UnLink";
|
||||
} else {
|
||||
echo "<b>YSF Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (Neither Link nor Unlink Sent) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (empty($_POST['ysfLinkHost'])) {
|
||||
echo "<b>YSF Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo "Somthing wrong with your input, (No target specified) - please try again";
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
unset($_POST);
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
if (isset($remoteCommand)) {
|
||||
echo "<b>YSF Link Manager</b>\n";
|
||||
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
|
||||
echo exec($remoteCommand);
|
||||
echo "</td></tr>\n</table>\n<br />\n";
|
||||
echo '<script type="text/javascript">setTimeout(function() { window.location=window.location;},2000);</script>';
|
||||
}
|
||||
} else {
|
||||
// Output HTML
|
||||
?>
|
||||
<b>YSF Link Manager</b>
|
||||
<form action="//<?php echo htmlentities($_SERVER['HTTP_HOST']).htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<th width="150"><a class="tooltip" href="#">Reflector<span><b>Reflector</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Link / Un-Link<span><b>Link / Un-Link</b></span></a></th>
|
||||
<th width="150"><a class="tooltip" href="#">Action<span><b>Action</b></span></a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="ysfLinkHost">
|
||||
<?php
|
||||
if (isset($configysfgateway['Network']['Startup'])) {
|
||||
$testYSFHost = $configysfgateway['Network']['Startup'];
|
||||
echo " <option value=\"none\">None</option>\n";
|
||||
}
|
||||
else {
|
||||
$testYSFHost = "none";
|
||||
echo " <option value=\"none\" selected=\"selected\">None</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "ZZ Parrot") {
|
||||
echo " <option value=\"YSF00001\" selected=\"selected\">YSF00001 - Parrot</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00001\">YSF00001 - Parrot</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "YSF2DMR") {
|
||||
echo " <option value=\"YSF00002\" selected=\"selected\">YSF00002 - Link YSF2DMR</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00002\">YSF00002 - Link YSF2DMR</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "YSF2NXDN") {
|
||||
echo " <option value=\"YSF00003\" selected=\"selected\">YSF00003 - Link YSF2NXDN</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00003\">YSF00003 - Link YSF2NXDN</option>\n";
|
||||
}
|
||||
if ($testYSFHost == "YSF2P25") {
|
||||
echo " <option value=\"YSF00004\" selected=\"selected\">YSF00004 - Link YSF2P25</option>\n";
|
||||
} else {
|
||||
echo " <option value=\"YSF00004\">YSF00004 - Link YSF2P25</option>\n";
|
||||
}
|
||||
$ysfHosts = fopen("/usr/local/etc/YSFHosts.txt", "r");
|
||||
while (!feof($ysfHosts)) {
|
||||
$ysfHostsLine = fgets($ysfHosts);
|
||||
$ysfHost = preg_split('/;/', $ysfHostsLine);
|
||||
if ((strpos($ysfHost[0], '#') === FALSE ) && ($ysfHost[0] != '')) {
|
||||
if (strlen($ysfHost[1]) >= 30) { $ysfHost[1] = substr($ysfHost[1], 0, 27)."..."; }
|
||||
if ($testYSFHost == $ysfHost[1]) { echo " <option value=\"YSF$ysfHost[0]\" selected=\"selected\">YSF$ysfHost[0] - ".htmlspecialchars($ysfHost[1])." - ".htmlspecialchars($ysfHost[2])."</option>\n"; }
|
||||
else { echo " <option value=\"YSF$ysfHost[0]\">YSF$ysfHost[0] - ".htmlspecialchars($ysfHost[1])." - ".htmlspecialchars($ysfHost[2])."</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($ysfHosts);
|
||||
if (file_exists("/usr/local/etc/FCSHosts.txt")) {
|
||||
$fcsHosts = fopen("/usr/local/etc/FCSHosts.txt", "r");
|
||||
while (!feof($fcsHosts)) {
|
||||
$ysfHostsLine = fgets($fcsHosts);
|
||||
$ysfHost = preg_split('/;/', $ysfHostsLine);
|
||||
if (substr($ysfHost[0], 0, 3) == "FCS") {
|
||||
if (strlen($ysfHost[1]) >= 30) { $ysfHost[1] = substr($ysfHost[1], 0, 27)."..."; }
|
||||
if ($testYSFHost == $ysfHost[0]) { echo " <option value=\"$ysfHost[0]\" selected=\"selected\">$ysfHost[0] - ".htmlspecialchars($ysfHost[1])."</option>\n"; }
|
||||
else { echo " <option value=\"$ysfHost[0]\">$ysfHost[0] - ".htmlspecialchars($ysfHost[1])."</option>\n"; }
|
||||
}
|
||||
}
|
||||
fclose($fcsHosts);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<input type="radio" name="Link" value="LINK" checked="checked" />Link
|
||||
<input type="radio" name="Link" value="UNLINK" />UnLink
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" name="ysfMgrSubmit" value="Request Change" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user