2016-04-30 15:38:12 +02:00
|
|
|
<?php
|
2016-05-09 22:39:47 +02:00
|
|
|
|
|
|
|
function getMMDVMHostVersion() {
|
2016-09-14 08:46:49 +02:00
|
|
|
// returns creation-time or version of MMDVMHost as version-number
|
2016-05-20 14:16:33 +02:00
|
|
|
$filename = MMDVMHOSTPATH."/MMDVMHost";
|
2016-05-15 17:05:52 +02:00
|
|
|
exec($filename." -v 2>&1", $output);
|
2016-05-19 22:38:24 +02:00
|
|
|
if (!startsWith(substr($output[0],18,8),"20")) {
|
2016-10-12 17:45:24 +02:00
|
|
|
showLapTime("getMMDVMHostVersion");
|
2016-05-15 20:45:23 +02:00
|
|
|
return getMMDVMHostFileVersion();
|
|
|
|
} else {
|
2016-10-12 17:45:24 +02:00
|
|
|
showLapTime("getMMDVMHostVersion");
|
2016-05-15 20:45:23 +02:00
|
|
|
return substr($output[0],18,8)." (compiled ".getMMDVMHostFileVersion().")";
|
|
|
|
}
|
2016-05-14 23:11:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getMMDVMHostFileVersion() {
|
2016-05-10 21:50:33 +02:00
|
|
|
// returns creation-time of MMDVMHost as version-number
|
2016-05-20 14:16:33 +02:00
|
|
|
$filename = MMDVMHOSTPATH."/MMDVMHost";
|
2016-05-09 22:39:47 +02:00
|
|
|
if (file_exists($filename)) {
|
2016-10-12 17:45:24 +02:00
|
|
|
showLapTime("getMMDVMHostFileVersion");
|
2016-09-15 22:19:12 +02:00
|
|
|
return date("d M Y", filectime($filename));
|
2016-05-09 22:39:47 +02:00
|
|
|
}
|
2016-05-13 18:02:21 +02:00
|
|
|
}
|
|
|
|
|
2016-10-13 21:34:29 +02:00
|
|
|
function getFirmwareVersion() {
|
|
|
|
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
|
|
|
|
$logLines = explode("\n", `grep "MMDVM protocol version" $logPath`);
|
|
|
|
$firmware = substr($logLines[count($logLines)-2], strpos($logLines[count($logLines)-2], "description")+13, strlen($logLines[count($logLines)-2])-strpos($logLines[count($logLines)-2], "description")+13);
|
|
|
|
if (strlen($firmware) > 0) {
|
|
|
|
$fp = fopen('/tmp/MMDVMFirmware.txt', 'w');
|
|
|
|
fwrite($fp, $firmware);
|
|
|
|
fclose($fp);
|
|
|
|
} else {
|
|
|
|
$fp = fopen('/tmp/MMDVMFirmware.txt', 'r');
|
|
|
|
$contents = fread($fp, filesize("/tmp/MMDVMFirmware.txt"));
|
|
|
|
$firmware = $contents;
|
|
|
|
}
|
|
|
|
echo $firmware;
|
|
|
|
}
|
|
|
|
|
2016-11-02 22:08:09 +01:00
|
|
|
function setDMRNetwork($network) {
|
|
|
|
$fp = fopen('/tmp/DMRNetwork.txt', 'w');
|
|
|
|
fwrite($fp, $network);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDMRNetwork() {
|
|
|
|
$fp = fopen('/tmp/DMRNetwork.txt', 'r');
|
|
|
|
$network = fread($fp, filesize("/tmp/DMRNetwork.txt"));
|
|
|
|
fclose($fp);
|
|
|
|
return $network;
|
|
|
|
}
|
|
|
|
|
2016-10-25 15:54:03 +02:00
|
|
|
function getDMRMasterState() {
|
|
|
|
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
|
|
|
|
$logLines = explode("\n", `egrep -h "(DMR, Logged into the master successfully)|(DMR, Closing DMR Network)" $logPath`);
|
|
|
|
$state = -1;
|
|
|
|
foreach($logLines as $logLine) {
|
|
|
|
if (strpos($logLine, "successfully") > 0) {
|
|
|
|
$state = 1;
|
2016-10-26 09:46:15 +02:00
|
|
|
}
|
2016-10-25 15:54:03 +02:00
|
|
|
if (strpos($logLine, "Closing") > 0) {
|
|
|
|
$state = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($state >= 0) {
|
|
|
|
$fp = fopen('/tmp/DMRMasterState.txt', 'w');
|
|
|
|
fwrite($fp, $state);
|
|
|
|
fclose($fp);
|
|
|
|
} else {
|
|
|
|
$fp = fopen('/tmp/DMRMasterState.txt', 'r');
|
|
|
|
$contents = fread($fp, filesize("/tmp/DMRMasterState.txt"));
|
|
|
|
$state = $contents;
|
|
|
|
}
|
|
|
|
return $state;
|
2016-10-26 09:46:15 +02:00
|
|
|
|
2016-10-25 15:54:03 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 22:39:47 +02:00
|
|
|
function getMMDVMConfig() {
|
2016-05-10 21:50:33 +02:00
|
|
|
// loads MMDVM.ini into array for further use
|
2016-06-11 22:30:40 +02:00
|
|
|
$conf = array();
|
2016-05-14 20:51:40 +02:00
|
|
|
if ($configs = fopen(MMDVMINIPATH."/".MMDVMINIFILENAME, 'r')) {
|
2016-05-09 22:39:47 +02:00
|
|
|
while ($config = fgets($configs)) {
|
2016-06-11 22:30:40 +02:00
|
|
|
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
|
2016-05-09 22:39:47 +02:00
|
|
|
}
|
|
|
|
fclose($configs);
|
|
|
|
}
|
2016-06-11 22:30:40 +02:00
|
|
|
return $conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getYSFGatewayConfig() {
|
2016-09-14 08:46:49 +02:00
|
|
|
// loads YSFGateway.ini into array for further use
|
2016-06-11 22:30:40 +02:00
|
|
|
$conf = array();
|
|
|
|
if ($configs = fopen(YSFGATEWAYINIPATH."/".YSFGATEWAYINIFILENAME, 'r')) {
|
|
|
|
while ($config = fgets($configs)) {
|
|
|
|
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
|
|
|
|
}
|
|
|
|
fclose($configs);
|
|
|
|
}
|
2016-10-12 17:45:24 +02:00
|
|
|
showLapTime("getYSFGatewayConfig");
|
2016-06-11 22:30:40 +02:00
|
|
|
return $conf;
|
2016-05-09 22:39:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCallsign($mmdvmconfigs) {
|
2016-05-10 21:50:33 +02:00
|
|
|
// returns Callsign from MMDVM-config
|
2016-05-10 17:57:05 +02:00
|
|
|
return getConfigItem("General", "Callsign", $mmdvmconfigs);
|
2016-05-10 09:17:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getConfigItem($section, $key, $configs) {
|
2016-05-10 21:50:33 +02:00
|
|
|
// retrieves the corresponding config-entry within a [section]
|
2016-05-10 09:17:50 +02:00
|
|
|
$sectionpos = array_search("[" . $section . "]", $configs) + 1;
|
|
|
|
$len = count($configs);
|
|
|
|
while(startsWith($configs[$sectionpos],$key."=") === false && $sectionpos <= ($len) ) {
|
|
|
|
if (startsWith($configs[$sectionpos],"[")) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$sectionpos++;
|
2016-05-09 22:39:47 +02:00
|
|
|
}
|
2016-05-10 09:17:50 +02:00
|
|
|
return substr($configs[$sectionpos], strlen($key) + 1);
|
2016-05-09 22:39:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getEnabled ($mode, $mmdvmconfigs) {
|
2016-05-10 21:50:33 +02:00
|
|
|
// returns enabled/disabled-State of mode
|
2016-05-10 09:17:50 +02:00
|
|
|
return getConfigItem($mode, "Enable", $mmdvmconfigs);
|
2016-05-09 22:39:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function showMode($mode, $mmdvmconfigs) {
|
2016-05-10 21:50:33 +02:00
|
|
|
// shows if mode is enabled or not.
|
2016-05-09 22:39:47 +02:00
|
|
|
?>
|
2016-09-20 12:57:17 +02:00
|
|
|
<td><span class="label <?php
|
2016-05-10 09:17:50 +02:00
|
|
|
if (getEnabled($mode, $mmdvmconfigs) == 1) {
|
2016-09-01 20:22:00 +02:00
|
|
|
switch ($mode) {
|
|
|
|
case "D-Star Network":
|
|
|
|
if (getConfigItem("D-Star Network", "GatewayAddress", $mmdvmconfigs) == "localhost" || getConfigItem("D-Star Network", "GatewayAddress", $mmdvmconfigs) == "127.0.0.1") {
|
|
|
|
if (isProcessRunning(IRCDDBGATEWAY)) {
|
2016-09-20 12:57:17 +02:00
|
|
|
echo "label-success";
|
2016-09-01 20:22:00 +02:00
|
|
|
} else {
|
|
|
|
echo "label-danger\" title=\"ircddbgateway is down!";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo "label-default\" title=\"Remote gateway configured - not checked!";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "System Fusion Network":
|
|
|
|
if (getConfigItem("System Fusion Network", "GwyAddress", $mmdvmconfigs) == "localhost" || getConfigItem("System Fusion Network", "GwyAddress", $mmdvmconfigs) == "127.0.0.1") {
|
|
|
|
if (isProcessRunning("YSFGateway")) {
|
2016-09-20 12:57:17 +02:00
|
|
|
echo "label-success";
|
2016-09-01 20:22:00 +02:00
|
|
|
} else {
|
|
|
|
echo "label-danger\" title=\"YSFGateway is down!";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo "label-default\" title=\"Remote gateway configured - not checked!";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2016-05-13 18:02:21 +02:00
|
|
|
if (isProcessRunning("MMDVMHost")) {
|
2016-09-20 12:57:17 +02:00
|
|
|
echo "label-success";
|
2016-05-13 18:02:21 +02:00
|
|
|
} else {
|
2016-05-15 23:12:57 +02:00
|
|
|
echo "label-danger\" title=\"MMDVMHost is down!";
|
2016-05-13 18:02:21 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-10 09:17:50 +02:00
|
|
|
} else {
|
2016-06-05 21:00:37 +02:00
|
|
|
echo "label-default";
|
2016-05-09 22:39:47 +02:00
|
|
|
}
|
|
|
|
?>"><?php echo $mode ?></span></td>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2016-09-14 08:46:49 +02:00
|
|
|
function getMMDVMLog() {
|
|
|
|
// Open Logfile and copy loglines into LogLines-Array()
|
|
|
|
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
|
2016-10-13 19:41:39 +02:00
|
|
|
//$logLines = explode("\n", `grep M: $logPath`);
|
|
|
|
$logLines = explode("\n", `egrep -h "from|end|watchdog|lost" $logPath`);
|
2016-09-14 08:46:49 +02:00
|
|
|
return $logLines;
|
|
|
|
}
|
2016-05-01 22:53:23 +02:00
|
|
|
|
2016-09-11 23:00:43 +02:00
|
|
|
function getShortMMDVMLog() {
|
|
|
|
// Open Logfile and copy loglines into LogLines-Array()
|
|
|
|
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
|
2016-09-25 17:53:46 +02:00
|
|
|
$logLines = explode("\n", `egrep -h "from|end|watchdog|lost" $logPath | tail -100`);
|
2016-09-11 23:00:43 +02:00
|
|
|
return $logLines;
|
|
|
|
}
|
|
|
|
|
2016-09-14 08:46:49 +02:00
|
|
|
function getYSFGatewayLog() {
|
|
|
|
// Open Logfile and copy loglines into LogLines-Array()
|
|
|
|
$logPath = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".date("Y-m-d").".log";
|
2016-10-13 19:41:39 +02:00
|
|
|
//$logLines = explode("\n", `egrep -h "D:|M:" $logPath`);
|
|
|
|
$logLines = explode("\n", `egrep -h "Starting|DISCONNECT|Connect|Automatic" $logPath`);
|
2016-09-14 08:46:49 +02:00
|
|
|
return $logLines;
|
|
|
|
}
|
2016-06-11 22:30:40 +02:00
|
|
|
|
2016-04-30 15:38:12 +02:00
|
|
|
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
|
|
|
|
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
|
|
|
|
// M: 2016-04-29 00:15:00.013 D-Star, received network header from DG9VH /ZEIT to CQCQCQ via DCS002 S
|
|
|
|
// M: 2016-04-29 19:43:21.839 DMR Slot 2, received network voice header from DL1ESZ to TG 9
|
2016-04-30 19:33:41 +02:00
|
|
|
// M: 2016-04-30 14:57:43.072 DMR Slot 2, received RF voice header from DG9VH to 5000
|
2016-09-20 13:16:04 +02:00
|
|
|
// M: 2016-09-16 09:14:12.886 P25, received RF from DF2ET to TG10100
|
2016-09-11 23:00:43 +02:00
|
|
|
function getHeardList($logLines, $onlyLast) {
|
2016-04-30 15:38:12 +02:00
|
|
|
$heardList = array();
|
2016-05-03 22:21:29 +02:00
|
|
|
$ts1duration = "";
|
|
|
|
$ts1loss = "";
|
|
|
|
$ts1ber = "";
|
|
|
|
$ts2duration = "";
|
|
|
|
$ts2loss = "";
|
|
|
|
$ts2ber = "";
|
|
|
|
$dstarduration = "";
|
|
|
|
$dstarloss = "";
|
|
|
|
$dstarber = "";
|
2016-05-04 21:37:24 +02:00
|
|
|
$ysfduration = "";
|
2016-09-20 12:54:02 +02:00
|
|
|
$ysfloss = "";
|
|
|
|
$ysfber = "";
|
2016-05-02 09:50:26 +02:00
|
|
|
foreach ($logLines as $logLine) {
|
2016-05-03 22:21:29 +02:00
|
|
|
$duration = "";
|
|
|
|
$loss = "";
|
|
|
|
$ber = "";
|
2016-05-02 09:50:26 +02:00
|
|
|
//removing invalid lines
|
|
|
|
if(strpos($logLine,"BS_Dwn_Act")) {
|
2016-05-03 06:50:49 +02:00
|
|
|
continue;
|
2016-05-02 09:50:26 +02:00
|
|
|
} else if(strpos($logLine,"invalid access")) {
|
2016-05-03 06:50:49 +02:00
|
|
|
continue;
|
2016-05-04 17:37:30 +02:00
|
|
|
} else if(strpos($logLine,"received RF header for wrong repeater")) {
|
|
|
|
continue;
|
2016-07-11 20:37:14 +02:00
|
|
|
} else if(strpos($logLine,"unable to decode the network CSBK")) {
|
|
|
|
continue;
|
2016-07-12 19:34:21 +02:00
|
|
|
} else if(strpos($logLine,"overflow in the DMR slot RF queue")) {
|
|
|
|
continue;
|
2016-10-19 20:43:46 +02:00
|
|
|
} else if(strpos($logLine,"bad LC received")) {
|
|
|
|
continue;
|
2016-05-02 09:50:26 +02:00
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-10-24 22:38:29 +02:00
|
|
|
if(strpos($logLine,"end of") || strpos($logLine,"watchdog has expired") || strpos($logLine,"ended RF data") || strpos($logLine,"ended network") || strpos($logLine,"RF transmission lost")) {
|
2016-05-03 21:36:47 +02:00
|
|
|
$lineTokens = explode(", ",$logLine);
|
2016-06-11 22:36:21 +02:00
|
|
|
if (array_key_exists(2,$lineTokens)) {
|
|
|
|
$duration = strtok($lineTokens[2], " ");
|
|
|
|
}
|
2016-05-25 15:44:49 +02:00
|
|
|
if (array_key_exists(3,$lineTokens)) {
|
|
|
|
$loss = $lineTokens[3];
|
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-05-05 22:45:33 +02:00
|
|
|
// if RF-Packet, no LOSS would be reported, so BER is in LOSS position
|
2016-05-03 21:36:47 +02:00
|
|
|
if (startsWith($loss,"BER")) {
|
|
|
|
$ber = substr($loss, 5);
|
|
|
|
$loss = "";
|
|
|
|
} else {
|
|
|
|
$loss = strtok($loss, " ");
|
2016-05-25 15:44:49 +02:00
|
|
|
if (array_key_exists(4,$lineTokens)) {
|
|
|
|
$ber = substr($lineTokens[4], 5);
|
|
|
|
}
|
2016-05-03 21:36:47 +02:00
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-05-19 22:24:59 +02:00
|
|
|
if (strpos($logLine,"ended RF data") || strpos($logLine,"ended network")) {
|
|
|
|
switch (substr($logLine, 27, strpos($logLine,",") - 27)) {
|
|
|
|
case "DMR Slot 1":
|
|
|
|
$ts1duration = "SMS";
|
|
|
|
break;
|
|
|
|
case "DMR Slot 2":
|
|
|
|
$ts2duration = "SMS";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (substr($logLine, 27, strpos($logLine,",") - 27)) {
|
|
|
|
case "D-Star":
|
|
|
|
$dstarduration = $duration;
|
|
|
|
$dstarloss = $loss;
|
|
|
|
$dstarber = $ber;
|
|
|
|
break;
|
|
|
|
case "DMR Slot 1":
|
|
|
|
$ts1duration = $duration;
|
|
|
|
$ts1loss = $loss;
|
|
|
|
$ts1ber = $ber;
|
|
|
|
break;
|
|
|
|
case "DMR Slot 2":
|
|
|
|
$ts2duration = $duration;
|
|
|
|
$ts2loss = $loss;
|
|
|
|
$ts2ber = $ber;
|
|
|
|
break;
|
2016-06-05 21:00:37 +02:00
|
|
|
case "YSF":
|
|
|
|
$ysfduration = $duration;
|
|
|
|
$ysfloss = $loss;
|
|
|
|
$ysfber = $ber;
|
|
|
|
break;
|
2016-09-20 13:41:15 +02:00
|
|
|
case "P25":
|
|
|
|
$p25duration = $duration;
|
|
|
|
$p25loss = $loss;
|
|
|
|
$p25ber = $ber;
|
|
|
|
break;
|
2016-05-19 22:24:59 +02:00
|
|
|
}
|
2016-05-03 22:21:29 +02:00
|
|
|
}
|
2016-05-03 21:36:47 +02:00
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-05-02 09:50:26 +02:00
|
|
|
$timestamp = substr($logLine, 3, 19);
|
|
|
|
$mode = substr($logLine, 27, strpos($logLine,",") - 27);
|
|
|
|
$callsign2 = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6);
|
|
|
|
$callsign = $callsign2;
|
|
|
|
if (strpos($callsign2,"/") > 0) {
|
|
|
|
$callsign = substr($callsign2, 0, strpos($callsign2,"/"));
|
|
|
|
}
|
|
|
|
$callsign = trim($callsign);
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-05-02 09:50:26 +02:00
|
|
|
$id ="";
|
|
|
|
if ($mode == "D-Star") {
|
|
|
|
$id = substr($callsign2, strpos($callsign2,"/") + 1);
|
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
|
|
|
$target = substr($logLine, strpos($logLine, "to") + 3);
|
2016-05-02 09:50:26 +02:00
|
|
|
$source = "RF";
|
|
|
|
if (strpos($logLine,"network") > 0 ) {
|
2016-06-23 21:13:53 +02:00
|
|
|
$source = "Net";
|
2016-05-02 09:50:26 +02:00
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-05-03 22:21:29 +02:00
|
|
|
switch ($mode) {
|
|
|
|
case "D-Star":
|
|
|
|
$duration = $dstarduration;
|
|
|
|
$loss = $dstarloss;
|
|
|
|
$ber = $dstarber;
|
|
|
|
break;
|
|
|
|
case "DMR Slot 1":
|
|
|
|
$duration = $ts1duration;
|
|
|
|
$loss = $ts1loss;
|
|
|
|
$ber = $ts1ber;
|
|
|
|
break;
|
|
|
|
case "DMR Slot 2":
|
|
|
|
$duration = $ts2duration;
|
|
|
|
$loss = $ts2loss;
|
|
|
|
$ber = $ts2ber;
|
|
|
|
break;
|
2016-05-04 21:37:24 +02:00
|
|
|
case "YSF":
|
2016-09-20 12:01:29 +02:00
|
|
|
$duration = $ysfduration;
|
|
|
|
$loss = $ysfloss;
|
|
|
|
$ber = $ysfber;
|
|
|
|
break;
|
2016-09-20 13:41:15 +02:00
|
|
|
case "P25":
|
|
|
|
$duration = $p25duration;
|
|
|
|
$loss = $p25loss;
|
|
|
|
$ber = $p25ber;
|
|
|
|
break;
|
2016-05-03 22:21:29 +02:00
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-06-05 19:54:50 +02:00
|
|
|
// Callsign or ID should be less than 11 chars long, otherwise it could be errorneous
|
|
|
|
if ( strlen($callsign) < 11 ) {
|
2016-10-12 17:45:24 +02:00
|
|
|
$name = "";
|
|
|
|
if (defined("ENABLEXTDLOOKUP")) {
|
2016-11-03 21:08:31 +01:00
|
|
|
array_push($heardList, array(convertTimezone($timestamp), $mode, $callsign, $name, $id, $target, $source, $duration, $loss, $ber));
|
2016-10-12 17:45:24 +02:00
|
|
|
} else {
|
2016-11-03 21:08:31 +01:00
|
|
|
array_push($heardList, array(convertTimezone($timestamp), $mode, $callsign, $id, $target, $source, $duration, $loss, $ber));
|
2016-10-12 17:45:24 +02:00
|
|
|
}
|
2016-06-05 12:26:39 +02:00
|
|
|
$duration = "";
|
|
|
|
$loss ="";
|
|
|
|
$ber = "";
|
2016-09-13 21:36:42 +02:00
|
|
|
if ($onlyLast && count($heardList )> 4) {
|
2016-09-11 23:00:43 +02:00
|
|
|
return $heardList;
|
|
|
|
}
|
2016-04-30 15:38:12 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-01 22:53:23 +02:00
|
|
|
return $heardList;
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:00:43 +02:00
|
|
|
function getLastHeard($logLines, $onlyLast) {
|
2016-05-10 21:50:33 +02:00
|
|
|
//returns last heard list from log
|
2016-05-01 22:53:23 +02:00
|
|
|
$lastHeard = array();
|
|
|
|
$heardCalls = array();
|
2016-09-11 23:00:43 +02:00
|
|
|
$heardList = getHeardList($logLines, $onlyLast);
|
2016-05-13 23:36:44 +02:00
|
|
|
$counter = 0;
|
2016-04-30 15:38:12 +02:00
|
|
|
foreach ($heardList as $listElem) {
|
2016-09-20 13:14:03 +02:00
|
|
|
if ( ($listElem[1] == "D-Star") || ($listElem[1] == "YSF") || ($listElem[1] == "P25") || (startsWith($listElem[1], "DMR")) ) {
|
2016-10-07 21:24:26 +02:00
|
|
|
if(!(array_search($listElem[2]."#".$listElem[1].$listElem[4], $heardCalls) > -1)) {
|
|
|
|
array_push($heardCalls, $listElem[2]."#".$listElem[1].$listElem[4]);
|
2016-10-12 17:45:24 +02:00
|
|
|
if (defined("ENABLEXTDLOOKUP")) {
|
|
|
|
if ($listElem[2] !== "??????????") {
|
|
|
|
//$listElem[3] = "Dummy"; //Should speed up this function - time-issue!
|
|
|
|
$listElem[3] = getName($listElem[2]); //Should speed up this function - time-issue!
|
|
|
|
} else {
|
|
|
|
$listElem[3] = "---";
|
|
|
|
}
|
2016-10-09 17:29:55 +02:00
|
|
|
}
|
2016-10-26 01:39:19 +02:00
|
|
|
if ($listElem[2] !== "??????????") {
|
|
|
|
if (!is_numeric($listElem[2])) {
|
|
|
|
if (constant("SHOWQRZ")) {
|
|
|
|
$listElem[2] = "<a target=\"_new\" href=\"https://qrz.com/db/$listElem[2]\">".str_replace("0","Ø",$listElem[2])."</a>";
|
|
|
|
} else {
|
|
|
|
$listElem[2] = "<a target=\"_new\" href=\"http://dmr.darc.de/dmr-userreg.php?callsign=$listElem[2]\">".$listElem[2]."</a>";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$listElem[2] = "<a target=\"_new\" href=\"http://dmr.darc.de/dmr-userreg.php?usrid=$listElem[2]\">".$listElem[2]."</a>";
|
|
|
|
}
|
2016-10-07 21:24:26 +02:00
|
|
|
}
|
2016-05-01 22:53:23 +02:00
|
|
|
array_push($lastHeard, $listElem);
|
2016-05-13 23:36:44 +02:00
|
|
|
$counter++;
|
2016-09-15 20:30:41 +02:00
|
|
|
}
|
2016-04-30 15:38:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $lastHeard;
|
|
|
|
}
|
2016-05-02 09:50:26 +02:00
|
|
|
|
2016-05-13 23:36:44 +02:00
|
|
|
function getActualMode($metaLastHeard, $mmdvmconfigs) {
|
2016-05-10 21:50:33 +02:00
|
|
|
// returns mode of repeater actual working in
|
2016-06-03 12:00:15 +02:00
|
|
|
$listElem = $metaLastHeard[0];
|
2016-05-12 15:55:02 +02:00
|
|
|
$timestamp = new DateTime($listElem[0]);
|
|
|
|
$mode = $listElem[1];
|
|
|
|
if (startsWith($mode, "DMR")) {
|
|
|
|
$mode = "DMR";
|
|
|
|
}
|
2016-11-03 10:12:23 +01:00
|
|
|
if (defined("ENABLEXTDLOOKUP") && $listElem[7] == null || !defined("ENABLEXTDLOOKUP") && $listElem[6] == null) {
|
2016-10-21 16:47:36 +02:00
|
|
|
return "<span class=\"label label-danger\">".$mode."</span>";
|
2016-06-26 18:50:04 +02:00
|
|
|
} else {
|
2016-08-10 22:25:48 +02:00
|
|
|
$now = new DateTime();
|
|
|
|
$hangtime = getConfigItem("General", "ModeHang", $mmdvmconfigs);
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-08-10 22:25:48 +02:00
|
|
|
if ($hangtime != "") {
|
|
|
|
$timestamp->add(new DateInterval('PT' . $hangtime . 'S'));
|
2016-06-26 18:50:04 +02:00
|
|
|
} else {
|
2016-08-10 22:25:48 +02:00
|
|
|
$source = $listElem[6];
|
|
|
|
if ($source === "Network") {
|
|
|
|
$hangtime = getConfigItem("General", "NetModeHang", $mmdvmconfigs);
|
|
|
|
} else {
|
|
|
|
$hangtime = getConfigItem("General", "RFModeHang", $mmdvmconfigs);
|
|
|
|
}
|
|
|
|
$timestamp->add(new DateInterval('PT' . $hangtime . 'S'));
|
|
|
|
}
|
|
|
|
if ($now->format('U') > $timestamp->format('U')) {
|
|
|
|
return "idle";
|
|
|
|
} else {
|
2016-10-21 16:47:36 +02:00
|
|
|
return "<span class=\"label label-warning\">".$mode."</span>";
|
2016-06-26 18:50:04 +02:00
|
|
|
}
|
2016-05-02 10:19:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 19:30:33 +02:00
|
|
|
function getDSTARLinks() {
|
2016-05-10 21:50:33 +02:00
|
|
|
// returns link-states of all D-Star-modules
|
2016-05-22 09:37:22 +02:00
|
|
|
if (filesize(LINKLOGPATH."/Links.log") == 0) {
|
2016-05-13 18:02:21 +02:00
|
|
|
return "not linked";
|
|
|
|
}
|
2016-05-06 20:39:29 +02:00
|
|
|
$out = "<table>";
|
2016-05-22 09:37:22 +02:00
|
|
|
if ($linkLog = fopen(LINKLOGPATH."/Links.log",'r')) {
|
2016-05-05 19:30:33 +02:00
|
|
|
while ($linkLine = fgets($linkLog)) {
|
|
|
|
$linkDate = " ";
|
|
|
|
$protocol = " ";
|
|
|
|
$linkType = " ";
|
|
|
|
$linkSource = " ";
|
|
|
|
$linkDest = " ";
|
|
|
|
$linkDir = " ";
|
|
|
|
// Reflector-Link, sample:
|
|
|
|
// 2011-09-22 02:15:06: DExtra link - Type: Repeater Rptr: DB0LJ B Refl: XRF023 A Dir: Outgoing
|
|
|
|
// 2012-04-03 08:40:07: DPlus link - Type: Dongle Rptr: DB0ERK B Refl: REF006 D Dir: Outgoing
|
|
|
|
// 2012-04-03 08:40:07: DCS link - Type: Repeater Rptr: DB0ERK C Refl: DCS001 C Dir: Outgoing
|
|
|
|
if(preg_match_all('/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*Rptr: (.{8}).*Refl: (.{8}).*Dir: (.{8})/',$linkLine,$linx) > 0){
|
|
|
|
$linkDate = $linx[1][0];
|
|
|
|
$protocol = $linx[2][0];
|
|
|
|
$linkType = $linx[3][0];
|
|
|
|
$linkSource = $linx[4][0];
|
|
|
|
$linkDest = $linx[5][0];
|
|
|
|
$linkDir = $linx[6][0];
|
|
|
|
}
|
|
|
|
// CCS-Link, sample:
|
|
|
|
// 2013-03-30 23:21:53: CCS link - Rptr: PE1AGO C Remote: PE1KZU Dir: Incoming
|
|
|
|
if(preg_match_all('/^(.{19}).*(CC[A-Za-z]*).*Rptr: (.{8}).*Remote: (.{8}).*Dir: (.{8})/',$linkLine,$linx) > 0){
|
|
|
|
$linkDate = $linx[1][0];
|
|
|
|
$protocol = $linx[2][0];
|
|
|
|
$linkType = $linx[2][0];
|
|
|
|
$linkSource = $linx[3][0];
|
|
|
|
$linkDest = $linx[4][0];
|
|
|
|
$linkDir = $linx[5][0];
|
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
// Dongle-Link, sample:
|
2016-05-05 19:30:33 +02:00
|
|
|
// 2011-09-24 07:26:59: DPlus link - Type: Dongle User: DC1PIA Dir: Incoming
|
|
|
|
// 2012-03-14 21:32:18: DPlus link - Type: Dongle User: DC1PIA Dir: Incoming
|
|
|
|
if(preg_match_all('/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*User: (.{6,8}).*Dir: (.*)$/',$linkLine,$linx) > 0){
|
|
|
|
$linkDate = $linx[1][0];
|
|
|
|
$protocol = $linx[2][0];
|
|
|
|
$linkType = $linx[3][0];
|
|
|
|
$linkSource = " ";
|
|
|
|
$linkDest = $linx[4][0];
|
|
|
|
$linkDir = $linx[5][0];
|
|
|
|
}
|
2016-05-07 19:43:22 +02:00
|
|
|
$out .= "<tr><td>" . $linkSource . "</td><td> " . $protocol . "-link</td><td> to </td><td>" . $linkDest . "</td><td> " . $linkDir . "</td></tr>";
|
2016-05-05 19:30:33 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-06 20:39:29 +02:00
|
|
|
$out .= "</table>";
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-06-03 21:38:26 +02:00
|
|
|
fclose($linkLog);
|
2016-05-05 19:30:33 +02:00
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
2016-05-02 10:19:08 +02:00
|
|
|
function getActualLink($logLines, $mode) {
|
2016-05-10 21:50:33 +02:00
|
|
|
// returns actual link state of specific mode
|
2016-05-02 10:19:08 +02:00
|
|
|
//M: 2016-05-02 07:04:10.504 D-Star link status set to "Verlinkt zu DCS002 S"
|
2016-05-02 17:36:19 +02:00
|
|
|
//M: 2016-04-03 16:16:18.638 DMR Slot 2, received network voice header from 4000 to 2625094
|
|
|
|
//M: 2016-04-03 19:30:03.099 DMR Slot 2, received network voice header from 4020 to 2625094
|
2016-05-02 10:19:08 +02:00
|
|
|
switch ($mode) {
|
2016-09-20 12:54:02 +02:00
|
|
|
case "D-Star":
|
|
|
|
if (isProcessRunning(IRCDDBGATEWAY)) {
|
|
|
|
return getDSTARLinks();
|
|
|
|
} else {
|
|
|
|
return "ircddbgateway not running!";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "DMR Slot 1":
|
|
|
|
foreach ($logLines as $logLine) {
|
|
|
|
if(strpos($logLine,"unable to decode the network CSBK")) {
|
|
|
|
continue;
|
|
|
|
} else if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 1") {
|
2016-09-20 12:57:17 +02:00
|
|
|
$to = "";
|
2016-09-20 12:54:02 +02:00
|
|
|
if (strpos($logLine,"to")) {
|
|
|
|
$to = trim(substr($logLine, strpos($logLine,"to") + 3));
|
|
|
|
}
|
|
|
|
if ($to !== "") {
|
|
|
|
return $to;
|
|
|
|
}
|
2016-05-14 20:51:40 +02:00
|
|
|
}
|
2016-09-20 12:54:02 +02:00
|
|
|
}
|
|
|
|
return "not linked";
|
|
|
|
break;
|
|
|
|
case "DMR Slot 2":
|
|
|
|
foreach ($logLines as $logLine) {
|
|
|
|
if(strpos($logLine,"unable to decode the network CSBK")) {
|
|
|
|
continue;
|
|
|
|
} else if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 2") {
|
2016-09-20 12:57:17 +02:00
|
|
|
$to = "";
|
2016-09-20 12:54:02 +02:00
|
|
|
if (strpos($logLine,"to")) {
|
|
|
|
$to = trim(substr($logLine, strpos($logLine,"to") + 3));
|
|
|
|
}
|
|
|
|
if ($to !== "") {
|
|
|
|
return $to;
|
|
|
|
}
|
2016-05-02 17:36:19 +02:00
|
|
|
}
|
2016-09-20 12:54:02 +02:00
|
|
|
}
|
|
|
|
return "not linked";
|
|
|
|
break;
|
2016-09-25 18:25:42 +02:00
|
|
|
case "YSF":
|
|
|
|
|
|
|
|
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
|
|
|
|
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
|
2016-10-01 20:22:59 +02:00
|
|
|
// M: 2016-09-25 16:08:05.811 Connect to 62829 has been requested by DG9VH
|
|
|
|
// M: 2016-10-01 17:52:36.586 Automatic connection to 62829
|
|
|
|
|
2016-10-20 21:42:58 +02:00
|
|
|
if (isProcessRunning("YSFGateway")) {
|
2016-10-13 21:58:20 +02:00
|
|
|
foreach($logLines as $logLine) {
|
|
|
|
$to = "";
|
|
|
|
if (strpos($logLine,"Connect to")) {
|
|
|
|
$to = substr($logLine, 38, 5);
|
|
|
|
}
|
|
|
|
if (strpos($logLine,"Automatic connection to")) {
|
|
|
|
$to = substr($logLine, 51, 5);
|
|
|
|
}
|
|
|
|
if ($to !== "") {
|
|
|
|
return $to;
|
|
|
|
}
|
2016-10-20 21:42:58 +02:00
|
|
|
if (strpos($logLine,"Starting YSFGateway")) {
|
|
|
|
$to = -1;
|
|
|
|
}
|
|
|
|
if (strpos($logLine,"DISCONNECT Reply")) {
|
|
|
|
$to = -1;
|
|
|
|
}
|
2016-09-25 18:25:42 +02:00
|
|
|
}
|
2016-10-13 21:58:20 +02:00
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
return -2;
|
|
|
|
break;
|
2016-09-25 18:25:42 +02:00
|
|
|
}
|
2016-10-26 09:46:15 +02:00
|
|
|
|
2016-05-02 17:36:19 +02:00
|
|
|
}
|
|
|
|
return "something went wrong!";
|
2016-05-02 10:19:08 +02:00
|
|
|
}
|
|
|
|
|
2016-05-14 20:51:40 +02:00
|
|
|
function getActualReflector($logLines, $mode) {
|
|
|
|
// returns actual link state of specific mode
|
|
|
|
//M: 2016-05-02 07:04:10.504 D-Star link status set to "Verlinkt zu DCS002 S"
|
|
|
|
//M: 2016-04-03 16:16:18.638 DMR Slot 2, received network voice header from 4000 to 2625094
|
|
|
|
//M: 2016-04-03 19:30:03.099 DMR Slot 2, received network voice header from 4020 to 2625094
|
2016-09-20 12:55:19 +02:00
|
|
|
foreach ($logLines as $logLine) {
|
|
|
|
if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 2") {
|
2016-06-05 21:00:37 +02:00
|
|
|
$from = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6);
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-05-14 20:51:40 +02:00
|
|
|
if (strlen($from) == 4 && startsWith($from,"4")) {
|
|
|
|
if ($from == "4000") {
|
|
|
|
return "Reflector not linked";
|
|
|
|
} else {
|
|
|
|
return "Reflector ".$from;
|
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
}
|
2016-09-15 20:30:41 +02:00
|
|
|
$source = "RF";
|
|
|
|
if (strpos($logLine,"network") > 0 ) {
|
|
|
|
$source = "Net";
|
|
|
|
}
|
2016-09-20 12:57:17 +02:00
|
|
|
|
2016-09-08 21:28:07 +02:00
|
|
|
if ( $source == "RF") {
|
|
|
|
$to = substr($logLine, strpos($logLine, "to") + 3);
|
2016-09-18 21:53:16 +02:00
|
|
|
if (strlen($to) < 6 && startsWith($to, "4")) {
|
2016-09-08 21:30:54 +02:00
|
|
|
return "Reflector ".$to." (not cfmd)";
|
2016-09-08 21:28:07 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-05 21:00:37 +02:00
|
|
|
}
|
2016-05-14 20:51:40 +02:00
|
|
|
}
|
|
|
|
return "Reflector not linked";
|
|
|
|
}
|
|
|
|
|
2016-09-30 23:17:02 +02:00
|
|
|
function getActiveYSFReflectors() {
|
|
|
|
$reflectorlist = Array();
|
|
|
|
$file = fopen(YSFHOSTSPATH."/".YSFHOSTSFILENAME, 'r');
|
2016-10-01 10:36:49 +02:00
|
|
|
if ($file) {
|
|
|
|
while (($line = fgetcsv($file, 1000, ";")) !== FALSE) {
|
|
|
|
array_push($reflectorlist, array($line[1], $line[2], $line[0], $line[5]));
|
|
|
|
}
|
2016-09-30 23:17:02 +02:00
|
|
|
}
|
|
|
|
fclose($file);
|
|
|
|
return $reflectorlist;
|
|
|
|
}
|
2016-10-12 17:45:24 +02:00
|
|
|
|
2016-09-25 18:25:42 +02:00
|
|
|
function getYSFReflectorById($id, $reflectors) {
|
2016-09-25 18:36:48 +02:00
|
|
|
if ($id ==-1) {
|
|
|
|
return "not linked";
|
2016-10-13 21:58:20 +02:00
|
|
|
} else if ($id == -2 ) {
|
|
|
|
return "YSFGateway not running";
|
2016-09-25 18:36:48 +02:00
|
|
|
} else {
|
|
|
|
foreach($reflectors as $reflector) {
|
|
|
|
if ($reflector[2] === $id) {
|
|
|
|
return $reflector[0];
|
|
|
|
}
|
2016-09-25 18:25:42 +02:00
|
|
|
}
|
|
|
|
}
|
2016-10-26 09:46:15 +02:00
|
|
|
}
|
2016-09-25 18:25:42 +02:00
|
|
|
|
2016-10-12 17:45:24 +02:00
|
|
|
/*
|
|
|
|
function getNames($delimiter) {
|
|
|
|
if (!isset($_SESSION['dmrIDs'])) {
|
|
|
|
$dmrIDs = Array();
|
|
|
|
$file = fopen(DMRIDDATPATH, 'r');
|
|
|
|
if ($file) {
|
|
|
|
while (($line = fgetcsv($file, 1000, $delimiter)) !== FALSE) {
|
|
|
|
array_push($dmrIDs, array('id'=>$line[0], 'callsign'=>$line[1], 'name'=>$line[2]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$_SESSION['dmrIDs'] = $dmrIDs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getName($callsign) {
|
|
|
|
$dmrIDs = $_SESSION['dmrIDs'];
|
|
|
|
$key = array_search("$callsign", array_column($dmrIDs, 'callsign'));
|
|
|
|
//return $key;
|
|
|
|
$dmrID = $_SESSION['dmrIDs'][$key];
|
|
|
|
//var_dump($dmrID);
|
|
|
|
return $dmrID['name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
function getName($callsign) {
|
|
|
|
// var_dump($_SESSION['dmrIDs']);
|
|
|
|
foreach ($_SESSION['dmrIDs'] as $dmrID) {
|
|
|
|
if ($dmrID[1] == $callsign) {
|
|
|
|
return $dmrID[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "---";
|
|
|
|
}
|
2016-10-26 09:46:15 +02:00
|
|
|
*/
|
2016-10-12 17:45:24 +02:00
|
|
|
|
2016-07-15 14:09:10 +02:00
|
|
|
function getName($callsign) {
|
2016-07-21 21:25:29 +02:00
|
|
|
if (is_numeric($callsign)) {
|
|
|
|
return "---";
|
|
|
|
}
|
2016-10-26 09:46:15 +02:00
|
|
|
|
2016-10-09 17:29:55 +02:00
|
|
|
if (file_exists(DMRIDDATPATH)) {
|
|
|
|
$callsign = trim($callsign);
|
|
|
|
if (strpos($callsign,"-")) {
|
|
|
|
$callsign = substr($callsign,0,strpos($callsign,"-"));
|
|
|
|
}
|
|
|
|
$delimiter =" ";
|
2016-08-28 21:46:08 +02:00
|
|
|
exec("grep -P '".$callsign.$delimiter."' ".DMRIDDATPATH, $output);
|
2016-10-09 17:29:55 +02:00
|
|
|
if (count($output) == 0) {
|
|
|
|
$delimiter = "\t";
|
|
|
|
exec("grep -P '".$callsign.$delimiter."' ".DMRIDDATPATH, $output);
|
|
|
|
}
|
2016-10-13 21:34:29 +02:00
|
|
|
if (count($output) !== 0) {
|
|
|
|
$name = substr($output[0], strpos($output[0],$delimiter)+1);
|
|
|
|
$name = substr($name, strpos($name,$delimiter)+1);
|
|
|
|
return $name;
|
|
|
|
} else
|
|
|
|
return "---";
|
2016-10-09 17:29:55 +02:00
|
|
|
} else {
|
|
|
|
return "DMRIDs.dat not correct!";
|
2016-07-15 23:35:59 +02:00
|
|
|
}
|
2016-07-15 14:09:10 +02:00
|
|
|
}
|
2016-10-12 17:45:24 +02:00
|
|
|
|
2016-05-15 17:05:52 +02:00
|
|
|
?>
|