This commit is contained in:
2026-07-19 18:27:27 +08:00
parent fe4b286ce1
commit 0febcf69f4
170 changed files with 19490 additions and 11878 deletions
-1
View File
@@ -1 +0,0 @@
../mmdvmhost/
+113
View File
@@ -0,0 +1,113 @@
<?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
// Check if DMR is Enabled
$testMMDVModeDMR = getConfigItem("DMR", "Enable", $mmdvmconfigs);
if ( $testMMDVModeDMR == 1 ) {
//setup BM API Key
$bmAPIkeyFile = '/etc/bmapi.key';
if (file_exists($bmAPIkeyFile) && fopen($bmAPIkeyFile,'r')) { $configBMapi = parse_ini_file($bmAPIkeyFile, true);
$bmAPIkey = $configBMapi['key']['apikey'];
// Check the BM API Key
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); }
// Get the current DMR Master from the config
$dmrMasterHost = getConfigItem("DMR Network", "Address", $mmdvmconfigs);
if ( $dmrMasterHost == '127.0.0.1' ) {
$dmrMasterHost = $configdmrgateway['DMR Network 1']['Address'];
if (isset($configdmrgateway['DMR Network 1']['Id'])) { $dmrID = $configdmrgateway['DMR Network 1']['Id']; }
} elseif (getConfigItem("DMR", "Id", $mmdvmconfigs)) {
$dmrID = getConfigItem("DMR", "Id", $mmdvmconfigs);
} else {
$dmrID = getConfigItem("General", "Id", $mmdvmconfigs);
}
// Store the DMR Master IP, we will need this for the JSON lookup
$dmrMasterHostIP = $dmrMasterHost;
// Make sure the master is a BrandMeister Master
$dmrMasterFile = fopen("/usr/local/etc/DMR_Hosts.txt", "r");
while (!feof($dmrMasterFile)) {
$dmrMasterLine = fgets($dmrMasterFile);
$dmrMasterHostF = preg_split('/\s+/', $dmrMasterLine);
if ((strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
if ($dmrMasterHost == $dmrMasterHostF[2]) { $dmrMasterHost = str_replace('_', ' ', $dmrMasterHostF[0]); }
}
}
if (substr($dmrMasterHost, 0, 2) == "BM") {
// Use BM 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
if (isset($bmAPIkeyV2)) {
$json = json_decode(@file_get_contents("https://api.brandmeister.network/v2/device/$dmrID/profile", true, $jsonContext));
} else {
$json = json_decode(@file_get_contents("https://api.brandmeister.network/v1.0/repeater/?action=PROFILE&q=$dmrID", true, $jsonContext));
}
// Set some Variable
$bmStaticTGList = "";
$bmDynamicTGList = "";
// Pull the information form JSON
if (isset($json->staticSubscriptions)) { $bmStaticTGListJson = $json->staticSubscriptions;
foreach($bmStaticTGListJson as $staticTG) {
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) && $staticTG->slot == "1") {
$bmStaticTGList .= "TG".$staticTG->talkgroup."(".$staticTG->slot.") ";
}
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) && $staticTG->slot == "0") {
$bmStaticTGList .= "TG".$staticTG->talkgroup." ";
}
}
$bmStaticTGList = wordwrap($bmStaticTGList, 15, "<br />\n");
if (preg_match('/TG/', $bmStaticTGList) == false) { $bmStaticTGList = "None"; }
} else { $bmStaticTGList = "None"; }
if (isset($json->dynamicSubscriptions)) { $bmDynamicTGListJson = $json->dynamicSubscriptions;
foreach($bmDynamicTGListJson as $dynamicTG) {
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) && $dynamicTG->slot == "1") {
$bmDynamicTGList .= "TG".$dynamicTG->talkgroup."(".$dynamicTG->slot.") ";
}
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) && $dynamicTG->slot == "0") {
$bmDynamicTGList .= "TG".$dynamicTG->talkgroup." ";
}
}
$bmDynamicTGList = wordwrap($bmDynamicTGList, 15, "<br />\n");
if (preg_match('/TG/', $bmDynamicTGList) == false) { $bmDynamicTGList = "None"; }
} else { $bmDynamicTGList = "None"; }
echo '<b>Active BrandMeister Connections</b>
<table>
<tr>
<th><a class=tooltip href="#">'.$lang['bm_master'].'<span><b>Connected Master</b></span></a></th>
<th><a class=tooltip href="#">Repeater ID<span><b>The ID for this Repeater/Hotspot</b></span></a></th>
<th><a class=tooltip href="#">Static TGs<span><b>Statically linked talkgroups</b></span></a></th>
<th><a class=tooltip href="#">Dynamic TGs<span><b>Dynamically linked talkgroups</b></span></a></th>
</tr>'."\n";
echo ' <tr>'."\n";
echo ' <td>'.$dmrMasterHost.'</td>';
echo '<td>'.$dmrID.'</td>';
echo '<td>'.$bmStaticTGList.'</td>';
echo '<td>'.$bmDynamicTGList.'</td>';
echo '</tr>'."\n";
echo ' </table>'."\n";
echo ' <br />'."\n";
}
}
?>
+137
View File
@@ -0,0 +1,137 @@
<?php
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
// Check if DMR is Enabled
$testMMDVModeDMR = getConfigItem("DMR", "Enable", $mmdvmconfigs);
if ( $testMMDVModeDMR == 1 ) {
//setup BM API Key
$bmAPIkeyFile = '/etc/bmapi.key';
if (file_exists($bmAPIkeyFile) && fopen($bmAPIkeyFile,'r')) {
$configBMapi = parse_ini_file($bmAPIkeyFile, true);
$bmAPIkey = $configBMapi['key']['apikey'];
// Check the BM API Key
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); }
// Get the current DMR Master from the config
$dmrMasterHost = getConfigItem("DMR Network", "Address", $mmdvmconfigs);
if ( $dmrMasterHost == '127.0.0.1' ) {
$dmrMasterHost = $configdmrgateway['DMR Network 1']['Address'];
if (isset($configdmrgateway['DMR Network 1']['Id'])) { $dmrID = $configdmrgateway['DMR Network 1']['Id']; }
} elseif (getConfigItem("DMR", "Id", $mmdvmconfigs)) {
$dmrID = getConfigItem("DMR", "Id", $mmdvmconfigs);
} else {
$dmrID = getConfigItem("General", "Id", $mmdvmconfigs);
}
// Store the DMR Master IP, we will need this for the JSON lookup
$dmrMasterHostIP = $dmrMasterHost;
// Make sure the master is a BrandMeister Master
$dmrMasterFile = fopen("/usr/local/etc/DMR_Hosts.txt", "r");
while (!feof($dmrMasterFile)) {
$dmrMasterLine = fgets($dmrMasterFile);
$dmrMasterHostF = preg_split('/\s+/', $dmrMasterLine);
if ((strpos($dmrMasterHostF[0], '#') === FALSE) && ($dmrMasterHostF[0] != '')) {
if ($dmrMasterHost == $dmrMasterHostF[2]) { $dmrMasterHost = str_replace('_', ' ', $dmrMasterHostF[0]); }
}
}
if (substr($dmrMasterHost, 0, 2) == "BM") {
if (isset($bmAPIkeyV2) && !empty($_POST) && (isset($_POST["dropDyn"]) || isset($_POST["dropQso"]) || isset($_POST["tgSubmit"]))) : // Data has been posted for this page
$bmAPIurl = 'https://api.brandmeister.network/v2/device/';
// Are we a repeater
if ( getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == "0" ) {
unset($_POST["TS"]);
$targetSlot = "0";
} else {
$targetSlot = $_POST["TS"];
}
// Set the API URLs
if (isset($_POST["dropDyn"])) { $bmAPIurl = $bmAPIurl.$dmrID."/action/dropDynamicGroups/".$targetSlot; $method = "GET"; }
if (isset($_POST["dropQso"])) { $bmAPIurl = $bmAPIurl.$dmrID."/action/dropCallRoute/".$targetSlot; $method = "GET"; }
if ( (isset($_POST["tgNr"])) && (isset($_POST["tgSubmit"])) ) { $targetTG = preg_replace("/[^0-9]/", "", $_POST["tgNr"]); }
if ( ($_POST["TGmgr"] == "ADD") && (isset($_POST["tgSubmit"])) ) { $bmAPIurl = $bmAPIurl.$dmrID."/talkgroup/"; $method = "POST"; }
if ( ($_POST["TGmgr"] == "DEL") && (isset($_POST["tgSubmit"])) ) { $bmAPIurl = $bmAPIurl.$dmrID."/talkgroup/".$targetSlot."/".$targetTG; $method = "DELETE"; }
// Build the Data
$postHeaders = array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer '.$bmAPIkeyV2,
'User-Agent: Pi-Star Dashboard for '.$dmrID,
);
$opts = array(
'http' => array(
'method' => $method,
//'header' => $postHeaders,
'header' => implode("\r\n", $postHeaders),
'password' => '',
'success' => '',
'timeout' => 2,
),
);
// If we are adding a TG
if ( (!isset($_POST["dropDyn"])) && (!isset($_POST["dropQso"])) && isset($targetTG) && $_POST["TGmgr"] == "ADD" ) {
$postDataTG = array(
'slot' => $targetSlot,
'group' => $targetTG
);
$postData = json_encode($postDataTG);
$postHeaders[] = 'Content-Length: '.strlen($postData);
$opts['http']['content'] = $postData;
}
// Make the request
$context = stream_context_create($opts);
$result = @file_get_contents($bmAPIurl, false, $context);
$feeback=json_decode($result);
// Output to the browser
echo '<b>BrandMeister Manager</b>'."\n";
echo "<table>\n<tr><th>Command Output</th></tr>\n<tr><td>";
if (isset($feeback)) { print "BrandMeister APIv2: OK"; } else { print "BrandMeister APIv2: No Response"; }
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
// If there is a BM API Key
if (isset($bmAPIkeyV2)) {
echo '<b>BrandMeister Manager</b>'."\n";
echo '<form action="'.htmlentities($_SERVER['PHP_SELF']).'" method="post">'."\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>
<th aria-hidden="true" id="lblSlot" style="width:25%;"><a class=tooltip href="#">Slot<span><b>Where to link/unlink</b></span></a></th>
<th aria-hidden="true" id="addRemove" style="width:25%;"><a class=tooltip href="#">Add / Remove<span><b>Add or Remove</b></span></a></th>
<th><a class=tooltip href="#">Action<span><b>Take Action</b></span></a></th>
</tr>'."\n";
echo ' <tr>';
echo '<td><input aria-labelledby="lblTG" type="text" name="tgNr" size="10" maxlength="7" /></td>';
echo '<td role="radiogroup" aria-labelledby="lblTS"><input id="rbTS1" type="radio" name="TS" value="1" /><label for="rbTS1">TS1</label> <input id="rbTS2" type="radio" name="TS" value="2" checked="checked" /><label for="rbTS2">TS2</label></td>';
echo '<td role="radiogroup" aria-labelledby="lblAddRemove"><input id="rbAdd" type="radio" name="TGmgr" value="ADD" checked="checked" /><label for="rbAdd">Add</label> <input id="rbDelete" type="radio" name="TGmgr" value="DEL" /><label for="rbDelete">Delete</label></td>';
echo '<td><input type="submit" value="Modify Static" name="tgSubmit" /></td>';
echo '</tr>'."\n";
echo ' <tr>';
echo '<td colspan="4" style="background: #ffffff;"><input type="submit" value="Drop QSO" name="dropQso" /> <input type="submit" value="Drop All Dynamic" name="dropDyn" /></td>';
echo '</tr>'."\n";
echo ' </table>'."\n";
echo ' <br />'."\n";
}
endif;
}
}
}
File diff suppressed because it is too large Load Diff
View File
+201
View File
@@ -0,0 +1,201 @@
<?php
/**
* Last-heard list (MMDVMHost mode) — last 20 unique transmissions across
* every enabled mode (D-Star / DMR / YSF / P25 / NXDN / M17 / POCSAG).
*
* AJAX-loaded partial; refreshed every 1.5 seconds by /index.php in
* MMDVMHost mode. Renders columns: time (UTC → local), mode, callsign,
* target, source (RF / Net), duration, loss, BER. 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.
*
* Data flow: relies on `$lastHeard` populated by mmdvmhost/functions.php
* (which parses /var/log/pi-star/MMDVM-YYYY-MM-DD.log via shell
* pipelines). This file just renders the array — see functions.php
* for the parsing logic and log-line offset comments.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
// AJAX-loaded partial; the parent page (index.php) sets the full
// security headers. setEmbeddableSecurityHeaders() ships the
// non-frame-related security headers without locking frame-
// ancestors, so the partial can be loaded into the parent via
// $.load(). Calling setSecurityHeaders() before this would emit
// X-Frame-Options + frame-ancestors 'self', which makes the
// embeddable variant a no-op (headers_sent() === true) — fixes
// the historical bug where the wrong variant won.
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
// Check if the config file exists
if (file_exists('/etc/pistar-css.ini')) {
// Use the values from the file
$piStarCssFile = '/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
} else {
// Default values
$callsignLookupSvc = "RadioID";
}
// Safety net
if (($callsignLookupSvc != "RadioID") && ($callsignLookupSvc != "QRZ")) { $callsignLookupSvc = "RadioID"; }
// Setup the URL(s)
$idLookupUrl = "https://database.radioid.net/database/view?id=";
if ($callsignLookupSvc == "RadioID") { $callsignLookupUrl = "https://database.radioid.net/database/view?callsign="; }
if ($callsignLookupSvc == "QRZ") { $callsignLookupUrl = "https://www.qrz.com/db/"; }
?>
<b><?php echo $lang['last_heard_list'];?></b>
<table>
<tr>
<th><a class="tooltip" href="#"><?php echo $lang['time'];?> (<?php echo date('T')?>)<span><b>Time in <?php echo date('T')?> time zone</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['mode'];?><span><b>Transmitted Mode</b></span></a></th>
<th style="min-width:14ch"><a class="tooltip" href="#"><?php echo $lang['callsign'];?><span><b>Callsign</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['target'];?><span><b>Target, D-Star Reflector, DMR Talk Group etc</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['src'];?><span><b>Received from source</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['dur'];?>(s)<span><b>Duration in Seconds</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['loss'];?><span><b>Packet Loss</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['ber'];?><span><b>Bit Error Rate</b></span></a></th>
</tr>
<?php
$i = 0;
for ($i = 0; ($i <= 19); $i++) { //Last 20 calls
if (isset($lastHeard[$i])) {
$listElem = $lastHeard[$i];
if ( $listElem[2] ) {
$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');
// Every value below comes from log-line parsing in
// mmdvmhost/functions.php, which in turn parses log lines
// produced by RF traffic. A station transmitting on RF
// can put almost any byte sequence into the callsign or
// target field; without escaping it lands in the
// dashboard's HTML refresh every 1.5s. Normalise once
// here so every echo below works on safe values.
//
// $modeHtml — "Slot 1" -> "TS1" cosmetic + escape
// $cs — callsign (HTML-safe text)
// $csUrl — callsign URL-encoded for href= path
// $csSuffix — D-Star station ID after `/` (HTML-safe)
// $tgt — target callsign / talkgroup (HTML-safe)
// $src — source ("RF"/"Net"/etc.; HTML-safe)
// $dur, $loss, $ber — numeric; HTML-safe defensively.
//
// The downstream str_replace ' '->'&nbsp;' has to run
// AFTER htmlspecialchars; the entity reference `&nbsp;`
// is intentional raw HTML output, not data.
$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');
// Target normalisation: if it's a single character left-pad
// it to 8 spaces (cosmetic, matches legacy layout). The
// visible value is HTML-escaped, then spaces become
// non-breaking-space entities AFTER the escape so the
// entity isn't double-encoded.
$tgtRaw = (string)$listElem[4];
// Append this operator's own alias in parentheses when the
// target is a plain "TG <id>" and TGList_CN.json has a name for
// it — MMDVMHost's log never carries a name, only the numeric
// ID, so without this lookup the column can only ever show
// digits (see getTGNameMap() in functions.php).
if (preg_match('/^TG\s+(\d+)$/', trim($tgtRaw), $tgMatch)) {
$tgName = getTGNameMap()[(int)$tgMatch[1]] ?? null;
if ($tgName !== null) { $tgtRaw .= " ($tgName)"; }
}
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');
$loss = htmlspecialchars((string)(isset($listElem[7]) ? $listElem[7] : ''), ENT_QUOTES, 'UTF-8');
$ber = htmlspecialchars((string)(isset($listElem[8]) ? $listElem[8] : ''), 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 {
// Strip any "-suffix" before linking — re-derive the
// url-encoded form from the trimmed value.
$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;\">&#40;<a href=\"https://aprs.fi/#!call=".$csTrimUrl."*\" target=\"_blank\">GPS</a>&#41;</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;\">&#40;<a href=\"https://aprs.fi/#!call=".$csTrimUrl."*\" target=\"_blank\">GPS</a>&#41;</div></td>";
}
}
if ( substr($tgtRaw, 0, 6) === 'CQCQCQ' ) {
echo "<td align=\"left\">$tgtHtml</td>";
} else {
echo "<td align=\"left\">".str_replace(' ', '&nbsp;', $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) . "+" : "&infin;";
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 if ($listElem[6] == "POCSAG Data") {
echo "<td colspan =\"3\" style=\"background:#1d1;\">POCSAG Data</td>";
} else {
echo "<td>$dur</td>";
// Colour the Loss Field
if (floatval($listElem[7]) < 1) { echo "<td>$loss</td>"; }
elseif (floatval($listElem[7]) == 1) { echo "<td style=\"background:#1d1;\">$loss</td>"; }
elseif (floatval($listElem[7]) > 1 && floatval($listElem[7]) <= 3) { echo "<td style=\"background:#fa0;\">$loss</td>"; }
else { echo "<td style=\"background:#f33;\">$loss</td>"; }
// 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 "</tr>\n";
}
}
}
?>
</table>
+108
View File
@@ -0,0 +1,108 @@
<?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
$localTXList = $lastHeard;
// Check if the config file exists
if (file_exists('/etc/pistar-css.ini')) {
// Use the values from the file
$piStarCssFile = '/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
} else {
// Default values
$callsignLookupSvc = "RadioID";
}
// Safety net
if (($callsignLookupSvc != "RadioID") && ($callsignLookupSvc != "QRZ")) { $callsignLookupSvc = "RadioID"; }
// Setup the URL(s)
$idLookupUrl = "https://database.radioid.net/database/view?id=";
if ($callsignLookupSvc == "RadioID") { $callsignLookupUrl = "https://database.radioid.net/database/view?callsign="; }
if ($callsignLookupSvc == "QRZ") { $callsignLookupUrl = "https://www.qrz.com/db/"; }
?>
<b><?php echo $lang['local_tx_list'];?></b>
<table>
<tr>
<th><a class="tooltip" href="#"><?php echo $lang['time'];?> (<?php echo date('T')?>)<span><b>Time in <?php echo date('T')?> time zone</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['mode'];?><span><b>Transmitted Mode</b></span></a></th>
<th style="min-width:14ch"><a class="tooltip" href="#"><?php echo $lang['callsign'];?><span><b>Callsign</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['target'];?><span><b>Target, D-Star Reflector, DMR Talk Group etc</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['src'];?><span><b>Received from source</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['dur'];?>(s)<span><b>Duration in Seconds</b></span></a></th>
<th style="min-width:5ch"><a class="tooltip" href="#"><?php echo $lang['ber'];?><span><b>Bit Error Rate</b></span></a></th>
<th style="min-width:8ch"><a class="tooltip" href="#">RSSI<span><b>Received Signal Strength Indication</b></span></a></th>
</tr>
<?php
$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');
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;\">&#40;<a href=\"https://aprs.fi/#!call=".$listElem[2]."*\" target=\"_blank\">GPS</a>&#41;</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;\">&#40;<a href=\"https://aprs.fi/#!call=".$listElem[2]."*\" target=\"_blank\">GPS</a>&#41;</div></td>";
}
}
if (strlen($listElem[4]) == 1) { $listElem[4] = str_pad($listElem[4], 8, " ", STR_PAD_LEFT); }
echo"<td align=\"left\">".str_replace(" ","&nbsp;", $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) . "+" : "&infin;";
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>"; }
echo"<td>$listElem[9]</td>"; //rssi
}
echo "</tr>\n";
$counter++; }
}
}
?>
</table>
+142
View File
@@ -0,0 +1,142 @@
<?php
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
// 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); }
// 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
}
}
}
}
?>
+114
View File
@@ -0,0 +1,114 @@
<?php
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
// 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); }
// 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
}
}
}
}
?>
+115
View File
@@ -0,0 +1,115 @@
<?php
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
// 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); }
// 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
}
}
}
}
?>
+137
View File
@@ -0,0 +1,137 @@
<?php
// 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
include_once $_SERVER['DOCUMENT_ROOT'].'/mmdvmhost/functions.php'; // MMDVMDash Functions
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
// Function to reverse the ROT1 used for Skyper
function un_rot($message) {
$output = "";
$messageTextArray = str_split($message);
// ROT -1
foreach($messageTextArray as $asciiChar) {
$asciiAsInt = ord($asciiChar);
$convretedAsciiAsInt = $asciiAsInt -1;
$convertedAsciiChar = chr($convretedAsciiAsInt);
$output .= $convertedAsciiChar;
}
// Return the clear text
return $output;
}
// Function to handle Skyper Messages
function skyper($message, $pocsagric) {
$output = "";
$messageTextArray = str_split($message);
if ($pocsagric == "0002504") { // Skyper OTA TimeSync Messages
$output = "[Skyper OTA Time] ".$message;
return $output;
}
if ($pocsagric == "0004512") { // Skyper Rubric Index
if (isset($messageTextArray[0])) { // This is hard coded to 1 for rubric index
unset($messageTextArray[0]);
}
if (isset($messageTextArray[1])) { // Rubric Number
$skyperRubric = ord($messageTextArray[1]) - 31;
unset($messageTextArray[1]);
}
if (isset($messageTextArray[2])) { // Message number, hard coded to 10 for Rubric Index
unset($messageTextArray[2]);
}
if (count($messageTextArray) >= 1) { // Check to see if there is a message to decode
$output = "[Skyper Index Rubric:$skyperRubric] ".un_rot(implode($messageTextArray));
}
else {
$output = "[Skyper Index Rubric:$skyperRubric] No Name";
}
return $output;
}
if ($pocsagric == "0004520") { // Skyper Message
if (isset($messageTextArray[0])) { // Rubric Number
$skyperRubric = ord($messageTextArray[0]) - 31;
unset($messageTextArray[0]);
}
if (isset($messageTextArray[1])) { // Message number
$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));
}
else {
$output = "[Skyper Rubric:$skyperRubric] No Message";
}
return $output;
}
}
?>
<b><?php echo $lang['pocsag_list'];?></b>
<table>
<tr>
<th><a class="tooltip" href="#"><?php echo $lang['time'];?> (<?php echo date('T')?>)<span><b>Time in <?php echo date('T')?> time zone</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['pocsag_timeslot'];?><span><b>Message Mode</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['target'];?><span><b>RIC / CapCode of the receiving Pager</b></span></a></th>
<th><a class="tooltip" href="#"><?php echo $lang['pocsag_msg'];?><span><b>Message contents</b></span></a></th>
</tr>
<?php
foreach ($logLinesDAPNETGateway as $dapnetMessageLine) {
$dapnetMessageArr = explode(" ", $dapnetMessageLine);
$dapnetMessageTxtArr = explode('"', $dapnetMessageLine);
$utc_time = $dapnetMessageArr["0"]." ".substr($dapnetMessageArr["1"],0,-4);
$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');
$pocsag_timeslot = $dapnetMessageArr["6"];
$pocsag_ric = str_replace(',', '', $dapnetMessageArr["8"]);
// Fix incorrectly truncated strings containing double quotes
unset($dapnetMessageTxtArr[0]);
if (count($dapnetMessageTxtArr) > 2) {
unset($dapnetMessageTxtArr[count($dapnetMessageTxtArr)]);
$pocsag_msg = implode('"', $dapnetMessageTxtArr);
} else {
$pocsag_msg = $dapnetMessageTxtArr[1];
}
// Decode Skyper Messages
if ( ($pocsag_ric == "0004520") || ($pocsag_ric == "0004512") || ($pocsag_ric == "0002504") ) {
$pocsag_msg = skyper($pocsag_msg, $pocsag_ric);
}
// Formatting long messages without spaces
if (strpos($pocsag_msg, ' ') == 0 && strlen($pocsag_msg) >= 45) {
$pocsag_msg = wordwrap($pocsag_msg, 45, ' ', true);
}
// Sanitise the data before displaying the HTML
if (isset($local_time)) { $local_time = htmlspecialchars($local_time, ENT_QUOTES, 'UTF-8'); }
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>
<td style="width: 140px; vertical-align: top; text-align: left;"><?php echo $local_time; ?></td>
<td style="width: 70px; vertical-align: top; text-align: center;"><?php echo "Slot ".$pocsag_timeslot; ?></td>
<td style="width: 70px; vertical-align: top; text-align: center;"><?php echo $pocsag_ric; ?></td>
<td style="width: max-content; vertical-align: top; text-align: left; word-wrap: break-word; white-space: normal !important;"><?php echo $pocsag_msg; ?></td>
</tr>
<?php
} // foreach
?>
</table>
+413
View File
@@ -0,0 +1,413 @@
<?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
require_once($_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php');
//Load the ircDDBGateway config file
$configs = array();
if ($configfile = fopen($gatewayConfigPath,'r')) {
while ($line = fgets($configfile)) {
list($key,$value) = preg_split('/=/',$line);
$value = trim(str_replace('"','',$value));
if ($key != 'ircddbPassword' && strlen($value) > 0)
$configs[$key] = $value;
}
}
//Load the DStarRepeater config file
$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;
}
}
}
//Load the dmrgateway config file
$dmrGatewayConfigFile = '/etc/dmrgateway';
if (fopen($dmrGatewayConfigFile,'r')) { $configdmrgateway = parse_ini_file($dmrGatewayConfigFile, true); }
//Load the dapnetgateway config file
$dapnetGatewayConfigFile = '/etc/dapnetgateway';
if (fopen($dapnetGatewayConfigFile,'r')) { $configdapnetgateway = parse_ini_file($dapnetGatewayConfigFile, true); }
// Load the ysf2dmr config file
if (file_exists('/etc/ysf2dmr')) {
$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); }
}
// Load the ysf2p25 config file
if (file_exists('/etc/ysf2p25')) {
$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); }
}
// Load the dmr2nxdn config file
if (file_exists('/etc/dmr2nxdn')) {
$dmr2nxdnConfigFile = '/etc/dmr2nxdn';
if (fopen($dmr2nxdnConfigFile,'r')) { $configdmr2nxdn = parse_ini_file($dmr2nxdnConfigFile, true); }
}
?>
<table>
<tr><th colspan="2"><?php echo $lang['modes_enabled'];?></th></tr>
<tr><?php showMode("D-Star", $mmdvmconfigs);?><?php showMode("DMR", $mmdvmconfigs);?></tr>
<tr><?php showMode("M17", $mmdvmconfigs);?><?php showMode("NXDN", $mmdvmconfigs);?></tr>
<tr><?php showMode("P25", $mmdvmconfigs);?><?php showMode("System Fusion", $mmdvmconfigs);?></tr>
<tr><?php showMode("DMR XMode", $mmdvmconfigs);?><?php showMode("YSF XMode", $mmdvmconfigs);?></tr>
<tr><?php showMode("FM", $mmdvmconfigs);?><?php showMode("POCSAG", $mmdvmconfigs);?></tr>
</table>
<br />
<table>
<tr><th colspan="2"><?php echo $lang['net_status'];?></th></tr>
<tr><?php showMode("D-Star Network", $mmdvmconfigs);?><?php showMode("DMR Network", $mmdvmconfigs);?></tr>
<tr><?php showMode("M17 Network", $mmdvmconfigs);?><?php showMode("NXDN Network", $mmdvmconfigs);?></tr>
<tr><?php showMode("P25 Network", $mmdvmconfigs);?><?php showMode("System Fusion Network", $mmdvmconfigs);?></tr>
<tr><?php showMode("DMR2NXDN Network", $mmdvmconfigs);?><?php showMode("DMR2YSF Network", $mmdvmconfigs);?></tr>
<tr><?php showMode("YSF2DMR Network", $mmdvmconfigs);?><?php showMode("YSF2NXDN Network", $mmdvmconfigs);?></tr>
<tr><?php showMode("YSF2P25 Network", $mmdvmconfigs);?><?php showMode("POCSAG Network", $mmdvmconfigs);?></tr>
</table>
<br />
<table>
<tr><th colspan="2"><?php echo $lang['radio_info'];?></th></tr>
<tr><th>Trx</th><?php
// TRX Status code
if (isset($lastHeard[0])) {
$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>";
}
?></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
if (getDVModemFirmware()) {
echo '<tr><th>FW</th><td style="background: #ffffff;">'.getDVModemFirmware().'</td></tr>'."\n";
} ?>
<?php
if (getDVModemTCXOFreq()) {
echo '<tr><th>TCXO</th><td style="background: #ffffff;">'.getDVModemTCXOFreq().'</td></tr>'."\n";
} ?>
</table>
<?php
$testMMDVModeDSTAR = getConfigItem("D-Star", "Enable", $mmdvmconfigs);
if ( $testMMDVModeDSTAR == 1 ) { //Hide the D-Star Reflector information when D-Star Network not enabled.
echo "<br />\n";
echo "<table>\n";
echo "<tr><th colspan=\"2\">".$lang['dstar_repeater']."</th></tr>\n";
echo "<tr><th>RPT1</th><td style=\"background: #ffffff;\">".str_replace(' ', '&nbsp;', $configdstar['callsign'])."</td></tr>\n";
echo "<tr><th>RPT2</th><td style=\"background: #ffffff;\">".str_replace(' ', '&nbsp;', $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;\">".substr($configs['aprsHostname'], 0, 16)."</td></tr>\n";
}
if ($configs['ircddbEnabled']) {
echo "<tr><th>IRC</th><td style=\"background: #ffffff;\">".substr($configs['ircddbHostname'], 0 ,16)."</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.
$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']);}
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], '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 {
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) . '..'; }
}
fclose($dmrMasterFile);
echo "<br />\n";
echo "<table>\n";
echo "<tr><th colspan=\"2\">".$lang['dmr_repeater']."</th></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\">".$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}\''); }
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\">".$xlxMasterHost1."</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";
}
$testMMDVModeYSF = getConfigItem("System Fusion Network", "Enable", $mmdvmconfigs);
if ( isset($configdmr2ysf['Enabled']['Enabled']) ) { $testDMR2YSF = $configdmr2ysf['Enabled']['Enabled']; }
if ( $testMMDVModeYSF == 1 || $testDMR2YSF ) { //Hide the YSF information when System Fusion Network mode not enabled.
$ysfLinkedTo = getActualLink($reverseLogLinesYSFGateway, "YSF");
if ($ysfLinkedTo == 'Not Linked' || $ysfLinkedTo == 'Service Not Started') {
$ysfLinkedToTxt = $ysfLinkedTo;
} else {
$ysfHostFile = fopen("/usr/local/etc/YSFHosts.txt", "r");
$ysfLinkedToTxt = "null";
while (!feof($ysfHostFile)) {
$ysfHostFileLine = fgets($ysfHostFile);
$ysfRoomTxtLine = preg_split('/;/', $ysfHostFileLine);
if (empty($ysfRoomTxtLine[0]) || empty($ysfRoomTxtLine[1])) continue;
if (($ysfRoomTxtLine[0] == $ysfLinkedTo) || ($ysfRoomTxtLine[1] == $ysfLinkedTo)) {
$ysfLinkedToTxt = $ysfRoomTxtLine[1];
break;
}
}
if ($ysfLinkedToTxt != "null") { $ysfLinkedToTxt = $ysfLinkedToTxt; } else { $ysfLinkedToTxt = $ysfLinkedTo; }
$ysfLinkedToTxt = str_replace('_', ' ', $ysfLinkedToTxt);
}
if (strlen($ysfLinkedToTxt) > 19) { $ysfLinkedToTxt = substr($ysfLinkedToTxt, 0, 17) . '..'; }
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;\">".$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.
$dmrMasterFile = fopen("/usr/local/etc/DMR_Hosts.txt", "r");
$dmrMasterHost = $configysf2dmr['DMR Network']['Address'];
while (!feof($dmrMasterFile)) {
$dmrMasterLine = fgets($dmrMasterFile);
$dmrMasterHostF = preg_split('/\s+/', $dmrMasterLine);
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;\">".$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>".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>".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>".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>".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";
}
?>
+96
View File
@@ -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";
}
}
?>
+165
View File
@@ -0,0 +1,165 @@
<?php
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
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 = "";
// 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);
}
}
}
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;
}
}
?>
+93
View File
@@ -0,0 +1,93 @@
<?php
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) ? "&nbsp;day" : "&nbsp;days");
}
if ($hours > 0) {
$uptimeString .= (($days > 0) ? ", " : "") . $hours;
$uptimeString .= (($hours == 1) ? "&nbsp;hr" : "&nbsp;hrs");
}
if ($mins > 0) {
$uptimeString .= (($days > 0 || $hours > 0) ? ", " : "") . $mins;
$uptimeString .= (($mins == 1) ? "&nbsp;min" : "&nbsp;mins");
}
if ($secs > 0) {
$uptimeString .= (($days > 0 || $hours > 0 || $mins > 0) ? ", " : "") . $secs;
$uptimeString .= (($secs == 1) ? "&nbsp;s" : "&nbsp;s");
}
return $uptimeString;
}
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 isProcessRunning($processName, $full = false, $refresh = false) {
if ($full) {
static $processes_full = array();
if ($refresh) $processes_full = array();
if (empty($processes_full))
exec('ps -eo args', $processes_full);
} else {
static $processes = array();
if ($refresh) $processes = array();
if (empty($processes))
exec('ps -eo comm', $processes);
}
foreach (($full ? $processes_full : $processes) as $processString) {
if (strpos($processString, $processName) !== false)
return true;
}
return false;
}
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 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);
}
?>
+139
View File
@@ -0,0 +1,139 @@
<?php
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
// 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); }
// 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
}
}
}
}
?>