2016-04-30 15:38:12 +02:00
< ? php
2016-05-09 22:39:47 +02:00
function getMMDVMHostVersion () {
2017-01-10 15:04:51 +01:00
// returns creation-time or version of MMDVMHost as version-number
$filename = MMDVMHOSTPATH . " /MMDVMHost " ;
exec ( $filename . " -v 2>&1 " , $output );
if ( ! startsWith ( substr ( $output [ 0 ], 18 , 8 ), " 20 " )) {
showLapTime ( " getMMDVMHostVersion " );
return getMMDVMHostFileVersion ();
} else {
showLapTime ( " getMMDVMHostVersion " );
2017-03-13 21:04:38 +01:00
if ( strlen ( $output [ 0 ]) > 26 ) {
2017-04-12 16:02:04 +02:00
return substr ( $output [ 0 ], 18 , 8 ) . " ( " . _ ( " compiled " ) . " " . getMMDVMHostFileVersion () . " , GitID #<a href= \" https://github.com/g4klx/MMDVMHost/commit/ " . substr ( $output [ 0 ], 32 , 7 ) . " \" target= \" _blank \" > " . substr ( $output [ 0 ], 32 , 7 ) . " </a>) " ;
2017-03-13 20:47:20 +01:00
} else {
2017-03-14 20:54:07 +01:00
return substr ( $output [ 0 ], 18 , 8 ) . " ( " . _ ( " compiled " ) . " " . getMMDVMHostFileVersion () . " ) " ;
2017-03-13 20:47:20 +01:00
}
2017-01-10 15:04:51 +01:00
}
2016-05-14 23:11:33 +02:00
}
function getMMDVMHostFileVersion () {
2017-01-10 15:04:51 +01:00
// returns creation-time of MMDVMHost as version-number
$filename = MMDVMHOSTPATH . " /MMDVMHost " ;
if ( file_exists ( $filename )) {
showLapTime ( " getMMDVMHostFileVersion " );
return date ( " d M Y " , filectime ( $filename ));
}
2016-05-13 18:02:21 +02:00
}
2017-07-12 22:44:51 +02:00
function getDMRGatewayVersion () {
// returns creation-time or version of DMRGateway as version-number
$filename = DMRGATEWAYPATH . " /DMRGateway " ;
exec ( $filename . " -v 2>&1 " , $output );
if ( ! startsWith ( substr ( $output [ 0 ], 19 , 8 ), " 20 " )) {
showLapTime ( " getDMRGatewayVersion " );
return getDMRGatewayFileVersion ();
} else {
showLapTime ( " getDMRGatewayVersion " );
if ( strlen ( $output [ 0 ]) > 26 ) {
2017-07-14 20:04:40 +02:00
return substr ( $output [ 0 ], 19 , 8 ) . " ( " . _ ( " compiled " ) . " " . getDMRGatewayFileVersion () . " , GitID #<a href= \" https://github.com/g4klx/DMRGateway/commit/ " . substr ( $output [ 0 ], 33 , 7 ) . " \" target= \" _blank \" > " . substr ( $output [ 0 ], 33 , 7 ) . " </a>) " ;
2017-07-12 22:44:51 +02:00
} else {
return substr ( $output [ 0 ], 19 , 8 ) . " ( " . _ ( " compiled " ) . " " . getDMRGatewayFileVersion () . " ) " ;
}
}
}
function getDMRGatewayFileVersion () {
// returns creation-time of DMRGateway as version-number
$filename = DMRGATEWAYPATH . " /DMRGateway " ;
if ( file_exists ( $filename )) {
showLapTime ( " getDMRGatewayFileVersion " );
return date ( " d M Y " , filectime ( $filename ));
}
}
2016-10-13 21:34:29 +02:00
function getFirmwareVersion () {
2017-05-16 10:05:52 +02:00
$logPath = MMDVMLOGPATH . " / " . MMDVMLOGPREFIX . " - " . date ( " Y-m-d " ) . " .log " ;
$logLines = explode ( " \n " , `egrep "MMDVM protocol version" $logPath` );
$firmware = " n/a " ;
2017-01-10 21:04:23 +01:00
if ( count ( $logLines ) >= 2 ) {
$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 );
2020-03-21 22:05:08 +01:00
if ( 0 === strpos ( $firmware , 'MMDVM_HS_Dual_Hat' )) {
$firmware = preg_replace ( '/GitID #([0-9A-Fa-f]{7})/' , 'GitID #<a href="http://www.github.com/juribeparada/MMDVM_HS/commit/$1" target=\"_blank\">$1</a>' , $firmware );
} else if ( 0 === strpos ( $firmware , 'MMDVM' )) {
2017-08-21 14:20:34 +02:00
$firmware = preg_replace ( '/GitID #([0-9A-Fa-f]{7})/' , 'GitID #<a href="http://www.github.com/g4klx/MMDVM/commit/$1" target=\"_blank\">$1</a>' , $firmware );
} else if ( 0 === strpos ( $firmware , 'ZUMspot' )) {
$firmware = preg_replace ( '/GitID #([0-9A-Fa-f]{7})/' , 'GitID #<a href="http://www.github.com/juribeparada/MMDVM_HS/commit/$1" target=\"_blank\">$1</a>' , $firmware );
}
2017-01-10 21:04:23 +01:00
}
if ( $firmware != " n/a " ) {
2017-01-10 15:04:51 +01:00
$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-10-13 21:34:29 +02:00
}
2016-11-02 22:08:09 +01:00
function setDMRNetwork ( $network ) {
2017-01-10 15:04:51 +01:00
$fp = fopen ( '../config/DMRNetwork.txt' , 'w' );
fwrite ( $fp , $network );
fclose ( $fp );
2016-11-02 22:08:09 +01:00
}
function getDMRNetwork () {
2017-05-16 10:05:52 +02:00
$filename = 'config/DMRNetwork.txt' ;
$network = '' ;
2017-01-10 21:14:15 +01:00
if ( file_exists ( $filename )) {
$fp = fopen ( $filename , 'r' );
2017-01-10 21:16:22 +01:00
$network = fread ( $fp , filesize ( $filename ));
2017-01-10 21:14:15 +01:00
fclose ( $fp );
}
2017-01-10 15:04:51 +01:00
return $network ;
2016-11-02 22:08:09 +01:00
}
2016-11-07 08:23:05 +01:00
function getDMRNetwork2 () {
2017-05-16 10:05:52 +02:00
$filename = '../config/DMRNetwork.txt' ;
$network = '' ;
2017-01-10 21:14:15 +01:00
if ( file_exists ( $filename )) {
2017-01-10 21:16:22 +01:00
$fp = fopen ( $filename , 'r' );
$network = fread ( $fp , filesize ( $filename ));
2017-01-10 21:14:15 +01:00
fclose ( $fp );
}
2017-01-10 15:04:51 +01:00
return $network ;
2017-01-10 21:24:36 +01:00
2016-11-07 08:23:05 +01:00
}
2016-10-25 15:54:03 +02:00
function getDMRMasterState () {
2017-05-16 10:05:52 +02:00
$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 ;
2017-01-10 15:04:51 +01:00
foreach ( $logLines as $logLine ) {
if ( strpos ( $logLine , " successfully " ) > 0 ) {
$state = 1 ;
}
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-25 15:54:03 +02:00
}
2016-05-09 22:39:47 +02:00
function getMMDVMConfig () {
2017-01-10 15:04:51 +01:00
// loads MMDVM.ini into array for further use
$conf = array ();
if ( $configs = fopen ( MMDVMINIPATH . " / " . MMDVMINIFILENAME , 'r' )) {
while ( $config = fgets ( $configs )) {
array_push ( $conf , trim ( $config , " \t \n \r \0 \x0B " ));
}
fclose ( $configs );
}
return $conf ;
2016-06-11 22:30:40 +02:00
}
function getYSFGatewayConfig () {
2017-01-10 15:04:51 +01:00
// loads YSFGateway.ini into array for further use
$conf = array ();
if ( $configs = fopen ( YSFGATEWAYINIPATH . " / " . YSFGATEWAYINIFILENAME , 'r' )) {
while ( $config = fgets ( $configs )) {
array_push ( $conf , trim ( $config , " \t \n \r \0 \x0B " ));
}
fclose ( $configs );
}
showLapTime ( " getYSFGatewayConfig " );
return $conf ;
2016-05-09 22:39:47 +02:00
}
function getCallsign ( $mmdvmconfigs ) {
2017-01-10 15:04:51 +01:00
// returns Callsign from MMDVM-config
return getConfigItem ( " General " , " Callsign " , $mmdvmconfigs );
2016-05-10 09:17:50 +02:00
}
2017-07-27 08:42:29 +02:00
function getDMRId ( $mmdvmconfigs ) {
// returns DMRId from MMDVM-Config
2017-08-27 03:41:11 +02:00
return getConfigItem ( " General " , " Id " , $mmdvmconfigs );
2017-07-27 08:42:29 +02:00
}
2019-12-09 20:07:47 +01:00
2016-05-10 09:17:50 +02:00
function getConfigItem ( $section , $key , $configs ) {
2017-01-10 15:04:51 +01:00
// retrieves the corresponding config-entry within a [section]
$sectionpos = array_search ( " [ " . $section . " ] " , $configs ) + 1 ;
2017-05-16 10:05:52 +02:00
$len = count ( $configs );
2017-01-10 15:04:51 +01:00
while ( startsWith ( $configs [ $sectionpos ], $key . " = " ) === false && $sectionpos <= ( $len ) ) {
if ( startsWith ( $configs [ $sectionpos ], " [ " )) {
return null ;
}
$sectionpos ++ ;
}
return substr ( $configs [ $sectionpos ], strlen ( $key ) + 1 );
2016-05-09 22:39:47 +02:00
}
function getEnabled ( $mode , $mmdvmconfigs ) {
2017-01-10 15:04:51 +01:00
// returns enabled/disabled-State of mode
return getConfigItem ( $mode , " Enable " , $mmdvmconfigs );
2016-05-09 22:39:47 +02:00
}
function showMode ( $mode , $mmdvmconfigs ) {
2017-01-10 15:04:51 +01:00
// shows if mode is enabled or not.
2016-05-09 22:39:47 +02:00
?>
2018-02-11 22:59:54 +01:00
< td >< span class = " badge <?php
2017-01-10 15:04:51 +01:00
if ( getEnabled ( $mode , $mmdvmconfigs ) == 1 ) {
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 )) {
2018-02-11 22:59:54 +01:00
echo " badge-success " ;
2017-01-10 15:04:51 +01:00
} else {
2018-02-11 22:59:54 +01:00
echo " badge-danger \" title= \" " . _ ( " ircddbgateway is down! " );
2017-01-10 15:04:51 +01:00
}
} else {
2018-02-11 22:59:54 +01:00
echo " badge-default \" title= \" " . _ ( " Remote gateway configured - not checked! " );
2017-01-10 15:04:51 +01:00
}
break ;
case " System Fusion Network " :
2017-11-26 13:47:32 +01:00
if ( getConfigItem ( " System Fusion Network " , " GatewayAddress " , $mmdvmconfigs ) == " localhost " || getConfigItem ( " System Fusion Network " , " GatewayAddress " , $mmdvmconfigs ) == " 127.0.0.1 " ) {
2017-01-10 15:04:51 +01:00
if ( isProcessRunning ( " YSFGateway " )) {
2018-02-11 22:59:54 +01:00
echo " badge-success " ;
2017-01-10 15:04:51 +01:00
} else {
2018-02-11 22:59:54 +01:00
echo " badge-danger \" title= \" " . _ ( " YSFGateway is down! " );
2017-01-10 15:04:51 +01:00
}
} else {
2018-02-11 22:59:54 +01:00
echo " badge-default \" title= \" " . _ ( " Remote gateway configured - not checked! " );
2017-01-10 15:04:51 +01:00
}
break ;
default :
if ( isProcessRunning ( " MMDVMHost " )) {
2018-02-11 22:59:54 +01:00
echo " badge-success " ;
2017-01-10 15:04:51 +01:00
} else {
2018-02-11 22:59:54 +01:00
echo " badge-danger \" title= \" " . _ ( " MMDVMHost is down! " );
2017-01-10 15:04:51 +01:00
}
}
} else {
2018-02-11 22:59:54 +01:00
echo " badge-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 () {
2017-01-10 15:04:51 +01:00
// Open Logfile and copy loglines into LogLines-Array()
2017-05-16 10:05:52 +02:00
$logPath = MMDVMLOGPATH . " / " . MMDVMLOGPREFIX . " - " . date ( " Y-m-d " ) . " .log " ;
2019-12-09 20:07:47 +01:00
$logLines = explode ( " \n " , `egrep -h "end|watchdog|lost" $logPath` );
2017-01-10 15:04:51 +01:00
return $logLines ;
2016-09-14 08:46:49 +02:00
}
2016-05-01 22:53:23 +02:00
2016-09-11 23:00:43 +02:00
function getShortMMDVMLog () {
2017-01-10 15:04:51 +01:00
// Open Logfile and copy loglines into LogLines-Array()
2017-05-16 10:05:52 +02:00
$logPath = MMDVMLOGPATH . " / " . MMDVMLOGPREFIX . " - " . date ( " Y-m-d " ) . " .log " ;
2020-06-05 20:08:51 +02:00
$logLines = explode ( " \n " , `egrep -h "from|end|watchdog|lost|Alias|0000" $logPath | grep -v "data header" | tail -20` );
2017-01-10 15:04:51 +01:00
return $logLines ;
2016-09-11 23:00:43 +02:00
}
2016-09-14 08:46:49 +02:00
function getYSFGatewayLog () {
2017-01-10 15:04:51 +01:00
// Open Logfile and copy loglines into LogLines-Array()
2017-05-16 10:05:52 +02:00
$logPath = YSFGATEWAYLOGPATH . " / " . YSFGATEWAYLOGPREFIX . " - " . date ( " Y-m-d " ) . " .log " ;
2018-06-04 13:16:20 +02:00
$logLines = explode ( " \n " , `egrep -h "repeater|Startinf|Disconnect|Linked|Automatic|Reverting|No connection" $logPath` );
2017-01-10 15:04:51 +01:00
return $logLines ;
2016-09-14 08:46:49 +02:00
}
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
2019-12-09 20:07:47 +01:00
// M: 2019-12-09 18:56:46.947 DMR Slot 1, received RF voice header from 2625094 to TG 26266
2016-09-20 13:16:04 +02:00
// M: 2016-09-16 09:14:12.886 P25, received RF from DF2ET to TG10100
2017-02-13 21:48:20 +01:00
// M: 2017-02-13 15:53:30.990 DMR Slot 2, Embedded Talker Alias Header
// M: 2017-02-13 15:53:30.991 0000: 04 00 5E 49 57 38 44 59 94 *..^IW8DY.*
// M: 2017-02-13 15:53:31.252 DMR Slot 2, Embedded Talker Alias Block 1
// M: 2017-02-13 15:53:31.253 0000: 05 00 20 47 69 6F 76 61 DC *.. Giova.*
2016-09-11 23:00:43 +02:00
function getHeardList ( $logLines , $onlyLast ) {
2017-05-16 10:05:52 +02:00
$heardList = array ();
$ts1duration = " " ;
$ts1loss = " " ;
$ts1ber = " " ;
$ts1rssi = " " ;
$ts1alias = " --- " ;
$ts2duration = " " ;
$ts2loss = " " ;
$ts2ber = " " ;
$ts2rssi = " " ;
$ts2alias = " --- " ;
$dstarduration = " " ;
$dstarloss = " " ;
$dstarber = " " ;
$dstarrssi = " " ;
$ysfduration = " " ;
$ysfloss = " " ;
$ysfber = " " ;
$ysfrssi = " " ;
$alias = " " ;
2017-02-13 21:48:20 +01:00
2017-01-10 15:04:51 +01:00
foreach ( $logLines as $logLine ) {
2017-05-16 10:05:52 +02:00
$duration = " " ;
$loss = " " ;
$ber = " " ;
$rssi = " " ;
2017-01-10 15:04:51 +01:00
//removing invalid lines
if ( strpos ( $logLine , " BS_Dwn_Act " )) {
continue ;
} else if ( strpos ( $logLine , " invalid access " )) {
continue ;
} else if ( strpos ( $logLine , " received RF header for wrong repeater " )) {
continue ;
} else if ( strpos ( $logLine , " unable to decode the network CSBK " )) {
continue ;
} else if ( strpos ( $logLine , " overflow in the DMR slot RF queue " )) {
continue ;
} else if ( strpos ( $logLine , " bad LC received " )) {
continue ;
2017-08-12 15:27:10 +02:00
} else if ( strpos ( $logLine , " non repeater RF header received " )) {
continue ;
2017-01-10 15:04:51 +01:00
}
2017-03-02 18:48:38 +01:00
2017-03-07 01:11:49 +01:00
if ( strpos ( $logLine , " 0000 " )){
2017-03-06 23:26:15 +01:00
$decodedAlias = $decodedAlias = preg_replace ( '/[\x00-\x1F\x7F-\xA0\xAD]/u' , '' , decodeAlias ( $logLine ));
2017-03-07 01:11:49 +01:00
if ( $decodedAlias == " " && $alias == " " ) $decodedAlias = " --- " ;
else if ( $alias != " --- " ) $alias = str_replace ( " --- " , " " , $alias );
if ( $alias == " " )
$alias = $decodedAlias ;
2017-02-13 21:48:20 +01:00
else
2017-03-07 01:11:49 +01:00
$alias = $decodedAlias . $alias ;
2017-02-13 21:48:20 +01:00
}
if ( strpos ( $logLine , " Embedded Talker Alias " )) {
switch ( substr ( $logLine , 27 , strpos ( $logLine , " , " ) - 27 )) {
case " DMR Slot 1 " :
$ts1alias = $alias ;
break ;
case " DMR Slot 2 " :
$ts2alias = $alias ;
break ;
}
}
2017-01-10 15:04:51 +01:00
if ( strpos ( $logLine , " end of " ) || strpos ( $logLine , " watchdog has expired " ) || strpos ( $logLine , " ended RF data " ) || strpos ( $logLine , " ended network " ) || strpos ( $logLine , " transmission lost " )) {
$lineTokens = explode ( " , " , $logLine );
if ( array_key_exists ( 2 , $lineTokens )) {
$duration = strtok ( $lineTokens [ 2 ], " " );
}
if ( array_key_exists ( 3 , $lineTokens )) {
$loss = $lineTokens [ 3 ];
}
if ( array_key_exists ( 4 , $lineTokens )) {
$ber = $lineTokens [ 4 ];
}
// if RF-Packet, no LOSS would be reported, so BER is in LOSS position
// and RSSI in BER position
if ( startsWith ( $loss , " BER " )) {
if ( substr ( $ber , 6 ) != " -0/-0/-0 dBm " ) {
$rssiString = substr ( $ber , 6 );
2017-01-19 00:03:37 +01:00
if ( constant ( " RSSI " ) == " min " ) $rssiVal = preg_replace ( '/(-\d+)\/-\d+\/-\d+ dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " max " ) $rssiVal = preg_replace ( '/-\d+\/(-\d+)\/-\d+ dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " avg " ) $rssiVal = preg_replace ( '/-\d+\/-\d+\/(-\d+) dBm/' , " \\ 1 " , $rssiString );
2017-04-12 09:20:02 +02:00
else if ( constant ( " RSSI " ) == " all " ) $rssiVal = $rssiString ;
2017-01-19 00:03:37 +01:00
else $rssiVal = preg_replace ( '/-\d+\/-\d+\/(-\d+) dBm/' , " \\ 1 " , $rssiString );
2017-04-12 09:20:02 +02:00
if ( constant ( " RSSI " ) != " all " ) {
if ( $rssiVal > " -53 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +40dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
2017-05-16 10:05:52 +02:00
else if ( $rssiVal > " -63 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +30dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -73 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +20dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -83 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +10dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -93 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -99 " ) $rssi = " <img src= \" images/3.png \" \ > <div class= \" tooltip2 \" >S8 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -105 " ) $rssi = " <img src= \" images/3.png \" \ > <div class= \" tooltip2 \" >S7 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -111 " ) $rssi = " <img src= \" images/2.png \" \ > <div class= \" tooltip2 \" >S6 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -117 " ) $rssi = " <img src= \" images/2.png \" \ > <div class= \" tooltip2 \" >S5 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -123 " ) $rssi = " <img src= \" images/1.png \" \ > <div class= \" tooltip2 \" >S4 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -129 " ) $rssi = " <img src= \" images/1.png \" \ > <div class= \" tooltip2 \" >S3 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -135 " ) $rssi = " <img src= \" images/0.png \" \ > <div class= \" tooltip2 \" >S2 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -141 " ) $rssi = " <img src= \" images/0.png \" \ > <div class= \" tooltip2 \" >S1 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
2017-04-12 09:20:02 +02:00
} else {
$rssi = $rssiVal ;
}
2017-01-10 15:04:51 +01:00
}
2020-03-19 12:47:29 +01:00
$ber = substr ( $loss , 5 );
$loss = " " ;
} else if ( startsWith ( $loss , " RSSI: " )) { //for short RF packets and "X" button requests, BER sometimes in not showed. RSSI is in BER position
$loss = " " ;
$ber = " " ;
$rssiString = substr ( $lineTokens [ 3 ], 6 );
if ( constant ( " RSSI " ) == " min " ) $rssiVal = preg_replace ( '/(-\d+)\/-\d+\/-\d+ dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " max " ) $rssiVal = preg_replace ( '/-\d+\/(-\d+)\/-\d+ dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " avg " ) $rssiVal = preg_replace ( '/-\d+\/-\d+\/(-\d+) dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " all " ) $rssiVal = $rssiString ;
else $rssiVal = preg_replace ( '/-\d+\/-\d+\/(-\d+) dBm/' , " \\ 1 " , $rssiString );
if ( constant ( " RSSI " ) != " all " ) {
if ( $rssiVal > " -53 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +40dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -63 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +30dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -73 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +20dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -83 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +10dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -93 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -99 " ) $rssi = " <img src= \" images/3.png \" \ > <div class= \" tooltip2 \" >S8 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -105 " ) $rssi = " <img src= \" images/3.png \" \ > <div class= \" tooltip2 \" >S7 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -111 " ) $rssi = " <img src= \" images/2.png \" \ > <div class= \" tooltip2 \" >S6 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -117 " ) $rssi = " <img src= \" images/2.png \" \ > <div class= \" tooltip2 \" >S5 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -123 " ) $rssi = " <img src= \" images/1.png \" \ > <div class= \" tooltip2 \" >S4 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -129 " ) $rssi = " <img src= \" images/1.png \" \ > <div class= \" tooltip2 \" >S3 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -135 " ) $rssi = " <img src= \" images/0.png \" \ > <div class= \" tooltip2 \" >S2 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -141 " ) $rssi = " <img src= \" images/0.png \" \ > <div class= \" tooltip2 \" >S1 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
} else {
$rssi = $rssiVal ;
}
2020-03-19 10:52:54 +01:00
} else {
$loss = strtok ( $loss , " " );
if ( array_key_exists ( 4 , $lineTokens )) {
$ber = substr ( $lineTokens [ 4 ], 5 );
2020-03-19 12:47:29 +01:00
}
2020-03-19 10:52:54 +01:00
if ( array_key_exists ( 5 , $lineTokens ) && substr ( $lineTokens [ 5 ], 6 ) != " -0/-0/-0 dBm " ) {
2020-03-19 12:47:29 +01:00
$rssiString = substr ( $lineTokens [ 5 ], 6 );
if ( constant ( " RSSI " ) == " min " ) $rssiVal = preg_replace ( '/(-\d+)\/-\d+\/-\d+ dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " max " ) $rssiVal = preg_replace ( '/-\d+\/(-\d+)\/-\d+ dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " avg " ) $rssiVal = preg_replace ( '/-\d+\/-\d+\/(-\d+) dBm/' , " \\ 1 " , $rssiString );
else if ( constant ( " RSSI " ) == " all " ) $rssiVal = $rssiString ;
else $rssiVal = preg_replace ( '/-\d+\/-\d+\/(-\d+) dBm/' , " \\ 1 " , $rssiString );
if ( constant ( " RSSI " ) != " all " ) {
if ( $rssiVal > " -53 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +40dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -63 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +30dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -73 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +20dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -83 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9<sup> +10dB</sup> ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -93 " ) $rssi = " <img src= \" images/4.png \" \ > <div class= \" tooltip2 \" >S9 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -99 " ) $rssi = " <img src= \" images/3.png \" \ > <div class= \" tooltip2 \" >S8 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -105 " ) $rssi = " <img src= \" images/3.png \" \ > <div class= \" tooltip2 \" >S7 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -111 " ) $rssi = " <img src= \" images/2.png \" \ > <div class= \" tooltip2 \" >S6 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -117 " ) $rssi = " <img src= \" images/2.png \" \ > <div class= \" tooltip2 \" >S5 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -123 " ) $rssi = " <img src= \" images/1.png \" \ > <div class= \" tooltip2 \" >S4 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -129 " ) $rssi = " <img src= \" images/1.png \" \ > <div class= \" tooltip2 \" >S3 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -135 " ) $rssi = " <img src= \" images/0.png \" \ > <div class= \" tooltip2 \" >S2 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
else if ( $rssiVal > " -141 " ) $rssi = " <img src= \" images/0.png \" \ > <div class= \" tooltip2 \" >S1 ( $rssiVal dBm)<span class= \" tooltip2text \" >(min/max/avg)<br> $rssiString </span></div> " ;
} else {
$rssi = $rssiVal ;
}
2020-03-19 10:52:54 +01:00
}
}
2017-01-10 15:04:51 +01: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 " :
2017-05-16 10:05:52 +02:00
$dstarduration = $duration ;
$dstarloss = $loss ;
$dstarber = $ber ;
$dstarrssi = $rssi ;
2017-01-10 15:04:51 +01:00
break ;
case " DMR Slot 1 " :
2017-05-16 10:05:52 +02:00
$ts1duration = $duration ;
$ts1loss = $loss ;
$ts1ber = $ber ;
$ts1rssi = $rssi ;
2017-01-10 15:04:51 +01:00
break ;
case " DMR Slot 2 " :
2017-05-16 10:05:52 +02:00
$ts2duration = $duration ;
$ts2loss = $loss ;
$ts2ber = $ber ;
$ts2rssi = $rssi ;
2017-01-10 15:04:51 +01:00
break ;
case " YSF " :
2017-05-16 10:05:52 +02:00
$ysfduration = $duration ;
$ysfloss = $loss ;
$ysfber = $ber ;
$ysfrssi = $rssi ;
2017-01-10 15:04:51 +01:00
break ;
case " P25 " :
2017-05-16 10:05:52 +02:00
$p25duration = $duration ;
$p25loss = $loss ;
$p25ber = $ber ;
$p25rssi = $rssi ;
2017-01-10 15:04:51 +01:00
break ;
2018-02-19 09:56:19 +01:00
case " NXDN " :
$nxdnduration = $duration ;
$nxdnloss = $loss ;
$nxdnber = $ber ;
$nxdnrssi = $rssi ;
break ;
2017-01-10 15:04:51 +01:00
}
}
}
2017-02-14 15:46:37 +01:00
$timestamp = substr ( $logLine , 3 , 23 );
2017-01-10 15:04:51 +01:00
$mode = substr ( $logLine , 27 , strpos ( $logLine , " , " ) - 27 );
2017-01-20 16:00:44 +01:00
if ( $topos = strpos ( $logLine , " to follow) " )) {
$topos = strpos ( $logLine , " to " , $topos + 1 );
} else {
$topos = strpos ( $logLine , " to " );
2017-01-13 22:23:11 +01:00
}
$callsign2 = substr ( $logLine , strpos ( $logLine , " from " ) + 5 , $topos - strpos ( $logLine , " from " ) - 6 );
2017-01-10 15:04:51 +01:00
$callsign = $callsign2 ;
if ( strpos ( $callsign2 , " / " ) > 0 ) {
$callsign = substr ( $callsign2 , 0 , strpos ( $callsign2 , " / " ));
}
$callsign = trim ( $callsign );
2017-10-29 19:19:57 +01:00
if ( defined ( " USESQLITE " )) {
if ( is_numeric ( $callsign )) {
$callsign = getCallsignFromDB ( $callsign );
}
}
2017-01-10 15:04:51 +01:00
$id = " " ;
if ( $mode == " D-Star " ) {
$id = substr ( $callsign2 , strpos ( $callsign2 , " / " ) + 1 );
2017-08-12 15:27:10 +02:00
if ( ! $id )
$id = " " ;
2017-01-10 15:04:51 +01:00
}
2019-12-09 20:07:47 +01:00
2017-01-13 22:23:11 +01:00
$target = substr ( $logLine , $topos + 3 );
2019-12-09 20:07:47 +01:00
if ( strpos ( $target , " , " ) > 0 )
$target = substr ( $target , 0 , strpos ( $target , " , " ));
2017-01-16 18:17:05 +01:00
$target = preg_replace ( '/\s/' , ' ' , $target );
2018-04-04 22:37:11 +02:00
if ( defined ( " RESOLVETGS " )) {
$target = $target . " " . getTGName ( $target );
}
2019-12-09 20:07:47 +01:00
2017-01-10 15:04:51 +01:00
$source = " RF " ;
if ( strpos ( $logLine , " network " ) > 0 ) {
$source = " Net " ;
}
switch ( $mode ) {
case " D-Star " :
2017-05-16 10:05:52 +02:00
$duration = $dstarduration ;
$loss = $dstarloss ;
$ber = $dstarber ;
$rssi = $dstarrssi ;
2017-01-10 15:04:51 +01:00
break ;
case " DMR Slot 1 " :
2017-05-16 10:05:52 +02:00
$duration = $ts1duration ;
$loss = $ts1loss ;
$ber = $ts1ber ;
$rssi = $ts1rssi ;
2017-01-10 15:04:51 +01:00
break ;
case " DMR Slot 2 " :
2017-05-16 10:05:52 +02:00
$duration = $ts2duration ;
$loss = $ts2loss ;
$ber = $ts2ber ;
$rssi = $ts2rssi ;
2017-01-10 15:04:51 +01:00
break ;
case " YSF " :
2017-05-16 10:05:52 +02:00
$duration = $ysfduration ;
$loss = $ysfloss ;
$ber = $ysfber ;
$rssi = $ysfrssi ;
2017-01-10 15:04:51 +01:00
break ;
case " P25 " :
2017-05-16 10:05:52 +02:00
$duration = $p25duration ;
$loss = $p25loss ;
$ber = $p25ber ;
$rssi = $p25rssi ;
2017-01-10 15:04:51 +01:00
break ;
2018-02-19 09:56:19 +01:00
case " NXDN " :
$duration = $nxdnduration ;
$loss = $nxdnloss ;
$ber = $nxdnber ;
$rssi = $nxdnrssi ;
break ;
2017-01-10 15:04:51 +01:00
}
// Callsign or ID should be less than 11 chars long, otherwise it could be errorneous
if ( strlen ( $callsign ) < 11 ) {
$name = " " ;
if ( defined ( " ENABLEXTDLOOKUP " )) {
2017-02-13 21:48:20 +01:00
array_push ( $heardList , array ( convertTimezone ( $timestamp ), $mode , $callsign , $name , $id , $target , $source , $duration , $loss , $ber , $rssi , $alias ));
$alias = " " ;
2017-01-10 15:04:51 +01:00
} else {
2017-02-13 21:48:20 +01:00
array_push ( $heardList , array ( convertTimezone ( $timestamp ), $mode , $callsign , $id , $target , $source , $duration , $loss , $ber , $rssi , $alias ));
$alias = " " ;
2017-01-10 15:04:51 +01:00
}
2017-05-16 10:05:52 +02:00
$duration = " " ;
$loss = " " ;
$ber = " " ;
$rssi = " " ;
$ts1alias = " --- " ;
$ts2alias = " --- " ;
2017-03-22 22:42:29 +01:00
if ( $onlyLast && count ( $heardList ) > 20 ) {
2017-01-10 15:04:51 +01:00
return $heardList ;
}
}
}
return $heardList ;
2016-05-01 22:53:23 +02:00
}
2016-09-11 23:00:43 +02:00
function getLastHeard ( $logLines , $onlyLast ) {
2017-01-10 15:04:51 +01:00
//returns last heard list from log
2017-05-16 10:05:52 +02:00
$lastHeard = array ();
2017-01-10 15:04:51 +01:00
$heardCalls = array ();
2017-05-16 10:05:52 +02:00
$heardList = getHeardList ( $logLines , $onlyLast );
$counter = 0 ;
2017-01-10 15:04:51 +01:00
foreach ( $heardList as $listElem ) {
2018-02-19 09:56:19 +01:00
if ( ( $listElem [ 1 ] == " D-Star " ) || ( $listElem [ 1 ] == " YSF " ) || ( $listElem [ 1 ] == " P25 " ) || ( $listElem [ 1 ] == " NXDN " ) || ( startsWith ( $listElem [ 1 ], " DMR " )) ) {
2017-01-10 15:04:51 +01:00
if ( ! ( array_search ( $listElem [ 2 ] . " # " . $listElem [ 1 ] . $listElem [ 4 ], $heardCalls ) > - 1 )) {
2017-01-18 10:59:40 +01:00
// Generate a canonicalized call for QRZ and name lookups
$call_canon = preg_replace ( '/\s+\w$/' , '' , $listElem [ 2 ]);
2020-05-02 16:37:59 +02:00
//remove suffix used sometimes in YSF (es: -FT2 , -991)
if ( strpos ( $call_canon , " - " ) != false ) {
$call_canon = substr ( $call_canon , 0 , strpos ( $call_canon , " - " ));
}
2017-01-10 15:04:51 +01:00
array_push ( $heardCalls , $listElem [ 2 ] . " # " . $listElem [ 1 ] . $listElem [ 4 ]);
if ( defined ( " ENABLEXTDLOOKUP " )) {
if ( $listElem [ 2 ] !== " ?????????? " ) {
2017-01-18 10:59:40 +01:00
$listElem [ 3 ] = getName ( $call_canon ); //Should speed up this function - time-issue!
2017-01-10 15:04:51 +01:00
} else {
$listElem [ 3 ] = " --- " ;
}
}
if ( $listElem [ 2 ] !== " ?????????? " ) {
if ( ! is_numeric ( $listElem [ 2 ])) {
2017-01-10 20:38:44 +01:00
if ( defined ( " SHOWQRZ " )) {
2017-01-18 10:59:40 +01:00
$listElem [ 2 ] = " <a target= \" _new \" href= \" https://qrz.com/db/ $call_canon\ " > " .str_replace( " 0 " , " & Oslash ; " , $listElem[2] ). " </ a > " ;
2017-01-10 15:04:51 +01:00
} else {
2019-05-06 14:06:00 +02:00
$listElem [ 2 ] = " <a target= \" _new \" href= \" http://ham-digital.org/dmr-userreg.php?callsign= $call_canon\ " > " . $listElem[2] . " </ a > " ;
2017-01-10 15:04:51 +01:00
}
} else {
2019-05-06 14:06:00 +02:00
$listElem [ 2 ] = " <a target= \" _new \" href= \" http://ham-digital.org/dmr-userreg.php?usrid= $listElem[2] \" > " . $listElem [ 2 ] . " </a> " ;
2017-01-10 15:04:51 +01:00
}
}
array_push ( $lastHeard , $listElem );
$counter ++ ;
}
}
}
return $lastHeard ;
2016-04-30 15:38:12 +02:00
}
2016-05-02 09:50:26 +02:00
2016-05-13 23:36:44 +02:00
function getActualMode ( $metaLastHeard , $mmdvmconfigs ) {
2017-04-15 16:45:21 +02:00
if ( count ( $metaLastHeard ) == 0 )
return _ ( " idle " );
2017-01-10 15:04:51 +01:00
// returns mode of repeater actual working in
2017-05-16 10:05:52 +02:00
$listElem = $metaLastHeard [ 0 ];
$timestamp = new DateTime ( $listElem [ 0 ], new DateTimeZone ( TIMEZONE ));
$mode = $listElem [ 1 ];
2017-01-10 15:04:51 +01:00
if ( startsWith ( $mode , " DMR " )) {
$mode = " DMR " ;
}
if ( defined ( " ENABLEXTDLOOKUP " ) && $listElem [ 7 ] == null || ! defined ( " ENABLEXTDLOOKUP " ) && $listElem [ 6 ] == null ) {
2018-02-11 22:59:54 +01:00
return " <span class= \" badge badge-danger \" > " . $mode . " </span> " ;
2017-01-10 15:04:51 +01:00
} else {
2017-05-16 10:05:52 +02:00
$now = new DateTime ( 'NOW' , new DateTimeZone ( TIMEZONE ));
$hangtime = getConfigItem ( " General " , " ModeHang " , $mmdvmconfigs );
2017-01-10 15:04:51 +01:00
if ( $hangtime != " " ) {
$timestamp -> add ( new DateInterval ( 'PT' . $hangtime . 'S' ));
} else {
$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' )) {
2017-03-14 20:54:07 +01:00
return _ ( " idle " );
2017-01-10 15:04:51 +01:00
} else {
2018-02-11 22:59:54 +01:00
return " <span class= \" badge badge-warning \" > " . $mode . " </span> " ;
2017-01-10 15:04:51 +01:00
}
}
2016-05-02 10:19:08 +02:00
}
2016-05-05 19:30:33 +02:00
function getDSTARLinks () {
2017-01-10 15:04:51 +01:00
// returns link-states of all D-Star-modules
if ( filesize ( LINKLOGPATH . " /Links.log " ) == 0 ) {
return " not linked " ;
}
$out = " <table> " ;
if ( $linkLog = fopen ( LINKLOGPATH . " /Links.log " , 'r' )) {
while ( $linkLine = fgets ( $linkLog )) {
2017-05-16 10:05:52 +02:00
$linkDate = " " ;
$protocol = " " ;
$linkType = " " ;
2017-01-10 15:04:51 +01:00
$linkSource = " " ;
2017-05-16 10:05:52 +02:00
$linkDest = " " ;
$linkDir = " " ;
2016-05-05 19:30:33 +02:00
// Reflector-Link, sample:
2017-01-10 15:04:51 +01:00
// 2011-09-22 02:15:06: DExtra link - Type: Repeater Rptr: DB0LJ B Refl: XRF023 A Dir: Outgoing
2016-05-05 19:30:33 +02:00
// 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
2017-01-10 15:04:51 +01:00
if ( preg_match_all ( '/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*Rptr: (.{8}).*Refl: (.{8}).*Dir: (.{8})/' , $linkLine , $linx ) > 0 ){
2017-05-16 10:05:52 +02:00
$linkDate = $linx [ 1 ][ 0 ];
$protocol = $linx [ 2 ][ 0 ];
$linkType = $linx [ 3 ][ 0 ];
2017-01-10 15:04:51 +01:00
$linkSource = $linx [ 4 ][ 0 ];
2017-05-16 10:05:52 +02:00
$linkDest = $linx [ 5 ][ 0 ];
$linkDir = $linx [ 6 ][ 0 ];
2017-01-10 15:04:51 +01:00
}
2016-05-05 19:30:33 +02:00
// CCS-Link, sample:
2017-01-10 15:04:51 +01:00
// 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 ){
2017-05-16 10:05:52 +02:00
$linkDate = $linx [ 1 ][ 0 ];
$protocol = $linx [ 2 ][ 0 ];
$linkType = $linx [ 2 ][ 0 ];
2017-01-10 15:04:51 +01:00
$linkSource = $linx [ 3 ][ 0 ];
2017-05-16 10:05:52 +02:00
$linkDest = $linx [ 4 ][ 0 ];
$linkDir = $linx [ 5 ][ 0 ];
2017-01-10 15:04:51 +01:00
}
2016-09-20 12:57:17 +02:00
// Dongle-Link, sample:
2017-01-10 15:04:51 +01:00
// 2011-09-24 07:26:59: DPlus link - Type: Dongle User: DC1PIA Dir: Incoming
2016-05-05 19:30:33 +02:00
// 2012-03-14 21:32:18: DPlus link - Type: Dongle User: DC1PIA Dir: Incoming
2017-01-10 15:04:51 +01:00
if ( preg_match_all ( '/^(.{19}).*(D[A-Za-z]*).*Type: ([A-Za-z]*).*User: (.{6,8}).*Dir: (.*)$/' , $linkLine , $linx ) > 0 ){
2017-05-16 10:05:52 +02:00
$linkDate = $linx [ 1 ][ 0 ];
$protocol = $linx [ 2 ][ 0 ];
$linkType = $linx [ 3 ][ 0 ];
2017-01-10 15:04:51 +01:00
$linkSource = " " ;
2017-05-16 10:05:52 +02:00
$linkDest = $linx [ 4 ][ 0 ];
$linkDir = $linx [ 5 ][ 0 ];
2017-01-10 15:04:51 +01:00
}
2018-06-03 13:54:13 +02:00
$out .= " <tr> " . $linkSource . " " . $protocol . " -link to " . $linkDest . " " . $linkDir . " </tr> " ;
2017-01-10 15:04:51 +01:00
}
}
$out .= " </table> " ;
fclose ( $linkLog );
return $out ;
2016-05-05 19:30:33 +02:00
}
2016-05-02 10:19:08 +02:00
function getActualLink ( $logLines , $mode ) {
2017-01-10 15:04:51 +01: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
2017-04-28 22:04:49 +02:00
2017-01-10 15:04:51 +01:00
switch ( $mode ) {
case " D-Star " :
if ( isProcessRunning ( IRCDDBGATEWAY )) {
return getDSTARLinks ();
} else {
2017-03-14 20:54:07 +01:00
return _ ( " ircddbgateway not running! " );
2017-01-10 15:04:51 +01:00
}
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 " ) {
$to = " " ;
if ( strpos ( $logLine , " to " )) {
$to = trim ( substr ( $logLine , strpos ( $logLine , " to " ) + 3 ));
2019-12-09 20:07:47 +01:00
$to = substr ( $to , 0 , strpos ( $to , " , " ));
2017-01-10 15:04:51 +01:00
}
if ( $to !== " " ) {
2017-05-15 23:01:31 +02:00
$fp = fopen ( '/tmp/DMR1State.txt' , 'w' );
fwrite ( $fp , $to );
fclose ( $fp );
2017-01-10 15:04:51 +01:00
return $to ;
}
}
}
2017-05-15 23:01:31 +02:00
if ( file_exists ( '/tmp/DMR1State.txt' )) {
2017-05-16 10:05:52 +02:00
$fp = fopen ( '/tmp/DMR1State.txt' , 'r' );
$contents = fread ( $fp , filesize ( " /tmp/DMR1State.txt " ));
2017-05-15 23:01:31 +02:00
fclose ( $fp );
if ( count ( $contents ) > 0 ){
return $contents ;
} else {
return _ ( " not linked " );
}
} else {
return _ ( " not linked " );
}
2017-01-10 15:04:51 +01:00
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 " ) {
$to = " " ;
if ( strpos ( $logLine , " to " )) {
$to = trim ( substr ( $logLine , strpos ( $logLine , " to " ) + 3 ));
2019-12-09 20:07:47 +01:00
$to = trim ( substr ( $logLine , strpos ( $logLine , " to " ) + 3 ));
$to = substr ( $to , 0 , strpos ( $to , " , " ));
2017-01-10 15:04:51 +01:00
}
if ( $to !== " " ) {
2017-05-15 23:01:31 +02:00
$fp = fopen ( '/tmp/DMR2State.txt' , 'w' );
fwrite ( $fp , $to );
fclose ( $fp );
2017-01-10 15:04:51 +01:00
return $to ;
}
}
}
2017-05-15 23:01:31 +02:00
if ( file_exists ( '/tmp/DMR2State.txt' )) {
2017-05-16 10:05:52 +02:00
$fp = fopen ( '/tmp/DMR2State.txt' , 'r' );
$contents = fread ( $fp , filesize ( " /tmp/DMR2State.txt " ));
2017-05-15 23:01:31 +02:00
fclose ( $fp );
if ( count ( $contents ) > 0 ){
return $contents ;
} else {
return _ ( " not linked " );
}
} else {
return _ ( " not linked " );
}
2017-01-10 15:04:51 +01:00
break ;
case " YSF " :
2016-09-25 18:25:42 +02:00
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
2018-06-04 13:16:20 +02:00
//I: 2018-06-04 11:04:22.190 The ID of this repeater is 50735
//M: 2018-06-04 11:04:22.202 No connection startup
2019-12-09 20:07:47 +01:00
//M: 2018-06-04 11:04:24.005 Linked to IT C4FM Piemonte
2017-05-15 23:25:32 +02:00
2017-01-10 15:04:51 +01:00
if ( isProcessRunning ( " YSFGateway " )) {
foreach ( $logLines as $logLine ) {
$to = " " ;
2018-06-04 13:16:20 +02:00
if ( strpos ( $logLine , " Disconnect " ) || strpos ( $logLine , " Unknown reflector " ) || strpos ( $logLine , " Disconnecting due to inactivity " ) || strpos ( $logLine , " No connection startup " )) {
2018-06-03 13:54:13 +02:00
return _ ( " not linked " );
2017-04-28 22:04:49 +02:00
}
2018-06-04 13:16:20 +02:00
if ( strpos ( $logLine , " Linked to " )) {
$to = substr ( $logLine , 37 , 16 );
2018-06-04 14:45:48 +02:00
if ( $to == " MMDVM " )
continue ;
2017-01-10 15:04:51 +01:00
}
2017-04-28 22:04:49 +02:00
if ( $to !== " " ) {
2017-05-15 23:01:31 +02:00
$fp = fopen ( '/tmp/YSFState.txt' , 'w' );
fwrite ( $fp , $to );
fclose ( $fp );
2017-04-28 22:04:49 +02:00
return $to ;
2017-01-10 15:04:51 +01:00
}
}
2020-03-18 18:52:30 +01:00
if ( ( $to == " " ) && file_exists ( '/tmp/YSFState.txt' )) { // reflector is in yesterday's log
$logPath2 = YSFGATEWAYLOGPATH . " / " . YSFGATEWAYLOGPREFIX . " - " . date ( 'Y-m-d' , strtotime ( date ( 'Y-m-d' ) . ' -1 day' )) . " .log " ; //open yesterday's log
$logLines2 = explode ( " \n " , `egrep -h "Linked to" $logPath2` );
$to = " " ;
foreach ( $logLines2 as $logLine ) {
if ( $logLine !== '' ) {
$to = substr ( $logLine , 37 , 16 );
if ( $to == " MMDVM " )
continue ;
}
}
if ( $to !== " " ) {
$fp = fopen ( '/tmp/YSFState.txt' , 'w' );
fwrite ( $fp , $to );
fclose ( $fp );
return $to ;
}
}
} else {
2018-06-03 13:54:13 +02:00
return _ ( " YSFGateway not running " );
2017-01-10 15:04:51 +01:00
}
2017-05-15 23:01:31 +02:00
if ( file_exists ( '/tmp/YSFState.txt' )) {
2017-05-16 10:05:52 +02:00
$fp = fopen ( '/tmp/YSFState.txt' , 'r' );
$contents = fread ( $fp , filesize ( " /tmp/YSFState.txt " ));
2017-05-15 23:01:31 +02:00
fclose ( $fp );
if ( count ( $contents ) > 0 ){
return $contents ;
} else {
2018-06-03 13:54:13 +02:00
return _ ( " not linked " );
2017-05-15 23:01:31 +02:00
}
} else {
2018-06-03 13:54:13 +02:00
return _ ( " not linked " );
2017-05-15 23:01:31 +02:00
}
break ;
2017-01-10 15:04:51 +01:00
}
2017-03-14 20:54:07 +01: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 ) {
2017-05-15 23:01:31 +02:00
$to = getActualReflector2 ( $logLines , $mode );
if ( $to >= - 1 ) {
$fp = fopen ( '/tmp/DMR2RefState.txt' , 'w' );
fwrite ( $fp , $to );
fclose ( $fp );
if ( $to == - 1 ) {
return _ ( " Reflector not linked " );
} else {
return $to ;
}
}
2019-12-09 20:07:47 +01:00
2017-05-15 23:01:31 +02:00
if ( file_exists ( '/tmp/DMR2RefState.txt' )) {
2017-05-16 10:05:52 +02:00
$fp = fopen ( '/tmp/DMR2RefState.txt' , 'r' );
$contents = fread ( $fp , filesize ( " /tmp/DMR2RefState.txt " ));
2017-05-15 23:01:31 +02:00
fclose ( $fp );
if ( count ( $contents ) > 0 ){
return $contents ;
} else {
return _ ( " not linked " );
}
}
}
function getActualReflector2 ( $logLines , $mode ) {
2017-01-10 15:04:51 +01:00
// returns actual link state of specific mode
2016-05-14 20:51:40 +02:00
//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
2017-01-10 15:04:51 +01:00
foreach ( $logLines as $logLine ) {
if ( substr ( $logLine , 27 , strpos ( $logLine , " , " ) - 27 ) == " DMR Slot 2 " ) {
$from = substr ( $logLine , strpos ( $logLine , " from " ) + 5 , strpos ( $logLine , " to " ) - strpos ( $logLine , " from " ) - 6 );
if ( strlen ( $from ) == 4 && startsWith ( $from , " 4 " )) {
if ( $from == " 4000 " ) {
2017-05-15 23:01:31 +02:00
return - 1 ;
2017-01-10 15:04:51 +01:00
} else {
2017-03-14 20:54:07 +01:00
return _ ( " Reflector " ) . " " . $from ;
2017-01-10 15:04:51 +01:00
}
}
$source = " RF " ;
if ( strpos ( $logLine , " network " ) > 0 ) {
$source = " Net " ;
}
if ( $source == " RF " ) {
$to = substr ( $logLine , strpos ( $logLine , " to " ) + 3 );
if ( strlen ( $to ) < 6 && startsWith ( $to , " 4 " )) {
2017-03-14 20:54:07 +01:00
return _ ( " Reflector " ) . " " . $to . " ( " . _ ( " not cfmd " ) . " ) " ;
2017-01-10 15:04:51 +01:00
}
}
}
}
2017-05-15 23:01:31 +02:00
return - 1 ;
2016-05-14 20:51:40 +02:00
}
2016-09-30 23:17:02 +02:00
function getActiveYSFReflectors () {
2017-01-10 15:04:51 +01:00
$reflectorlist = Array ();
$file = fopen ( YSFHOSTSPATH . " / " . YSFHOSTSFILENAME , 'r' );
if ( $file ) {
while (( $line = fgetcsv ( $file , 1000 , " ; " )) !== FALSE ) {
2018-02-18 14:46:43 +01:00
array_push ( $reflectorlist , array ( $line [ 1 ], $line [ 6 ], $line [ 2 ], $line [ 0 ], $line [ 5 ]));
2017-01-10 15:04:51 +01:00
}
}
fclose ( $file );
return $reflectorlist ;
2016-09-30 23:17:02 +02:00
}
2016-10-12 17:45:24 +02:00
2016-07-15 14:09:10 +02:00
function getName ( $callsign ) {
2017-09-22 14:17:22 +02:00
if ( defined ( " USESQLITE " )) {
return resolveNameFromDB ( $callsign );
} else {
2017-10-29 19:19:57 +01:00
if ( is_numeric ( $callsign )) {
return " --- " ;
}
2017-09-22 14:17:22 +02:00
return resolveNameFromFile ( $callsign );
}
}
function resolveNameFromDB ( $callsign ) {
$db = new SQLite3 ( 'database/callsigns.db' );
2017-10-29 19:19:57 +01:00
if ( is_numeric ( $callsign ))
$results = $db -> query ( " SELECT distinct name FROM callsign where id = ' $callsign ' " );
else
$results = $db -> query ( " SELECT distinct name FROM callsign where callsign = ' $callsign ' " );
2017-09-22 14:17:22 +02:00
while ( $row = $results -> fetchArray ()) {
return $row [ 'name' ];
}
return " --- " ;
}
2017-01-10 15:04:51 +01:00
2017-09-22 14:17:22 +02:00
function resolveNameFromFile ( $callsign ) {
2017-02-28 03:43:56 +01:00
$TMP_CALL_NAME = " /tmp/Callsign_Name.txt " ;
if ( file_exists ( $TMP_CALL_NAME )) {
$callsign = trim ( $callsign );
if ( strpos ( $callsign , " - " )) {
$callsign = substr ( $callsign , 0 , strpos ( $callsign , " - " ));
}
$delimiter = " " ;
exec ( " egrep -m1 ' " . $callsign . $delimiter . " ' " . $TMP_CALL_NAME , $output );
if ( count ( $output ) !== 0 ) {
$name = substr ( $output [ 0 ], strpos ( $output [ 0 ], $delimiter ));
$name = substr ( $name , strpos ( $name , $delimiter ));
return $name ;
}
}
2017-01-10 15:04:51 +01:00
if ( file_exists ( DMRIDDATPATH )) {
$callsign = trim ( $callsign );
if ( strpos ( $callsign , " - " )) {
$callsign = substr ( $callsign , 0 , strpos ( $callsign , " - " ));
}
$delimiter = " " ;
2017-03-13 15:31:31 +01:00
exec ( " sed -e 's/[[:space:]] \ +/ /g' " . DMRIDDATPATH . " | grep -m1 ' " . $callsign . $delimiter . " ' " , $output );
2017-01-10 15:04:51 +01:00
if ( count ( $output ) !== 0 ) {
2017-03-13 15:31:31 +01:00
$name = preg_replace ( '/[\x00-\x1F\x7F-\xA0\xAD]/u' , '' , substr ( $output [ 0 ], strpos ( $output [ 0 ], $delimiter ) + 1 ));
2017-01-10 15:04:51 +01:00
$name = substr ( $name , strpos ( $name , $delimiter ) + 1 );
2017-02-28 03:43:56 +01:00
$fp = fopen ( $TMP_CALL_NAME . '.TMP' , 'a' );
$TMP_STRING = $callsign . ' ' . $name ;
fwrite ( $fp , $TMP_STRING . PHP_EOL );
fclose ( $fp );
exec ( 'sort ' . $TMP_CALL_NAME . '.TMP' . ' ' . $TMP_CALL_NAME . ' | uniq > ' . $TMP_CALL_NAME );
2017-01-10 15:04:51 +01:00
return $name ;
} else
return " --- " ;
} else {
2017-03-14 20:54:07 +01:00
return _ ( " DMRIDs.dat not correct! " );
2017-01-10 15:04:51 +01:00
}
2016-07-15 14:09:10 +02:00
}
2016-10-12 17:45:24 +02:00
2017-10-29 19:19:57 +01:00
function getCallsignFromDB ( $id ) {
$db = new SQLite3 ( 'database/callsigns.db' );
$results = $db -> query ( " SELECT distinct callsign FROM callsign where id = ' $id ' " );
while ( $row = $results -> fetchArray ()) {
return $row [ 'callsign' ];
}
return $id ;
}
2017-02-13 21:48:20 +01:00
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// M: 2017-02-13 15:53:30.991 0000: 04 00 5E 49 57 38 44 59 94 *..^IW8DY.*
// M: 2017-02-13 15:53:31.253 0000: 05 00 20 47 69 6F 76 61 DC *.. Giova.*
function decodeAlias ( $logLine ) {
2017-02-14 14:44:49 +01:00
if ( substr ( $logLine , 34 , 2 ) !== " 04 " )
$tok1 = encode ( substr ( $logLine , 40 , 2 ));
2017-03-04 18:04:14 +01:00
else
$tok1 = " " ;
$tok2 = encode ( substr ( $logLine , 43 , 2 ));
$tok3 = encode ( substr ( $logLine , 46 , 2 ));
$tok4 = encode ( substr ( $logLine , 49 , 2 ));
$tok5 = encode ( substr ( $logLine , 52 , 2 ));
$tok6 = encode ( substr ( $logLine , 55 , 2 ));
2017-04-05 23:53:56 +02:00
$tok7 = encode ( substr ( $logLine , 58 , 2 ));
2017-03-04 18:04:14 +01:00
return $tok1 . $tok2 . $tok3 . $tok4 . $tok5 . $tok6 . $tok7 ;
2017-02-13 21:48:20 +01:00
}
2017-03-15 18:17:47 +01:00
function getGitVersion (){
2017-03-28 10:29:35 +02:00
if ( file_exists ( " .git " )) {
2017-04-12 16:39:14 +02:00
exec ( " git rev-parse --short HEAD " , $output );
2017-04-12 16:43:12 +02:00
return 'GitID #<a href="https://github.com/dg9vh/MMDVMHost-Dashboard/commit/' . $output [ 0 ] . '" target="_blank">' . $output [ 0 ] . '</a>' ;
2017-03-28 10:29:35 +02:00
} else {
return 'GitID unknown' ;
}
2017-03-15 18:17:47 +01:00
}
2017-03-28 10:28:39 +02:00
2017-03-28 22:20:10 +02:00
function getDMRReflectors () {
2017-05-16 10:05:52 +02:00
$data = file_get_contents ( " http://ham-dmr.de/reflector.db " );
$rows = explode ( " \n " , $data );
$refls = array ();
2017-03-28 10:28:39 +02:00
foreach ( $rows as $row ) {
$refls [] = str_getcsv ( $row , " @ " , '' );
}
return $refls ;
}
2017-03-28 22:20:10 +02:00
2017-04-27 18:13:18 +02:00
function getDMRplusDMRMasterList () {
2017-05-16 10:05:52 +02:00
$data = file_get_contents ( " http://ham-dmr.de/dmr/dmrmaster2.php " );
$rows = explode ( " \n " , $data );
$s = array ();
2017-04-27 18:13:18 +02:00
foreach ( $rows as $row ) {
$s [] = str_getcsv ( $row , " @ " , '' );
}
return $s ;
2017-03-28 22:20:10 +02:00
}
2018-04-04 22:37:11 +02:00
function getTGList () {
$list = array_map ( 'str_getcsv' , file ( getcwd () . '/database/tgs.csv' ));
return $list ;
}
function getTGName ( $id ) {
global $tgList ;
$name = " " ;
if ( startsWith ( $id , " TG " )) {
$name = $tgList [ recursive_array_search ( substr ( $id , 8 ), $tgList )][ 2 ];
// $name = substr($id, 8);
return " ( " . $name . " ) " ;
} else {
return $name ;
}
}
2016-05-15 17:05:52 +02:00
?>