-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
executable file
·1157 lines (1108 loc) · 46.4 KB
/
functions.php
File metadata and controls
executable file
·1157 lines (1108 loc) · 46.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Wp<?php
$tgs = 0;
function getMMDVMConfig() {
// loads /etc/mmdvmhost 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;
}
function getYSFGatewayConfig() {
// loads /etc/ysfgateway 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);
}
return $conf;
}
function getP25GatewayConfig() {
// loads /etc/p25gateway into array for further use
$conf = array();
if ($configs = @fopen(P25GATEWAYINIPATH."/".P25GATEWAYINIFILENAME, 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
}
function getNXDNGatewayConfig() {
// loads /etc/nxdngateway into array for further use
$conf = array();
if ($configs = @fopen('/etc/nxdngateway', 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
}
function getDAPNETGatewayConfig() {
// loads /etc/dapnetgateway into array for further use
$conf = array();
if ($configs = @fopen('/etc/dapnetgateway', 'r')) {
while ($config = fgets($configs)) {
array_push($conf, trim ( $config, " \t\n\r\0\x0B"));
}
fclose($configs);
}
return $conf;
}
function getConfigItem($section, $key, $configs) {
// retrieves the corresponding config-entry within a [section]
$sectionpos = array_search("[" . $section . "]", $configs) + 1;
$len = count($configs);
while(startsWith($configs[$sectionpos],$key."=") === false && $sectionpos <= ($len) ) {
if (startsWith($configs[$sectionpos],"[")) {
return null;
}
$sectionpos++;
}
return substr($configs[$sectionpos], strlen($key) + 1);
}
function getEnabled ($mode, $mmdvmconfigs) {
// returns enabled/disabled-State of mode
return getConfigItem($mode, "Enable", $mmdvmconfigs);
}
function checkDMRLogin ($dmrDaemon) {
if ($dmrDaemon == "MMDVMHost") {
if (file_exists(MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d").".log")) {
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d").".log";
$logCheckMMDVMHostDMRLogin = `tail -n 5 $logPath | awk '/master/ && /successfully/ || /master/ && /failed/' | tail -n 1`;
if (strpos($logCheckMMDVMHostDMRLogin, "success")) { return 0; }
elseif (strpos($logCheckMMDVMHostDMRLogin, "fail")) { return 1; }
else { return 0; }
}
}
elseif ($dmrDaemon == "DMRGateway") {
if (file_exists("/var/log/pi-star/DMRGateway-".gmdate("Y-m-d").".log")) {
$logPath = "/var/log/pi-star/DMRGateway-".gmdate("Y-m-d").".log";
$logCheckDMRGatewayDMRLogin = `tail -n 5 $logPath | awk '/master/ && /successfully/ || /master/ && /failed/' | tail -n 1`;
if (strpos($logCheckDMRGatewayDMRLogin, "success")) { return 0; }
elseif (strpos($logCheckDMRGatewayDMRLogin, "fail")) { return 1; }
else { return 0; }
}
}
else {
return 0;
}
}
function showMode($mode, $mmdvmconfigs) {
// shows if mode is enabled or not.
if (getEnabled($mode, $mmdvmconfigs) == 1) {
if ($mode == "D-Star Network") {
if (isProcessRunning("ircddbgatewayd")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
elseif ($mode == "System Fusion Network") {
if (isProcessRunning("YSFGateway")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
elseif ($mode == "P25 Network") {
if (isProcessRunning("P25Gateway")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
elseif ($mode == "NXDN Network") {
if (isProcessRunning("NXDNGateway")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
elseif ($mode == "DAPNET Network") {
if (isProcessRunning("DAPNETGateway")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
elseif ($mode == "DMR Network") {
if (getConfigItem("DMR Network", "Address", $mmdvmconfigs) == '127.0.0.1') {
if (isProcessRunning("DMRGateway")) {
if (checkDMRLogin("DMRGateway") > 0) { echo "<td style=\"background:#ff9; color:#030; width:50%;\">"; }
else { echo "<td style=\"background:#0b0; color:#030; width:50%;\">"; }
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
else {
if (isProcessRunning("MMDVMHost")) {
if (checkDMRLogin("MMDVMHost") > 0) { echo "<td style=\"background:#ff9; color:#030; width:50%;\">"; }
else { echo "<td style=\"background:#0b0; color:#030; width:50%;\">"; }
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
}
else {
if ($mode == "D-Star" || $mode == "DMR" || $mode == "System Fusion" || $mode == "P25" || $mode == "NXDN" || $mode == "POCSAG") {
if (isProcessRunning("MMDVMHost")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#b00; color:#500; width:50%;\">";
}
}
}
}
elseif ( ($mode == "YSF XMode") && (getEnabled("System Fusion", $mmdvmconfigs) == 1) ) {
if ( (isProcessRunning("MMDVMHost")) && (isProcessRunning("YSF2DMR") || isProcessRunning("YSF2NXDN") || isProcessRunning("YSF2P25")) ) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
}
elseif ( ($mode == "DMR XMode") && (getEnabled("DMR", $mmdvmconfigs) == 1) ) {
if ( (isProcessRunning("MMDVMHost")) && (isProcessRunning("DMR2YSF") || isProcessRunning("DMR2NXDN")) ) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
}
elseif ( ($mode == "YSF2DMR Network") && (getEnabled("System Fusion", $mmdvmconfigs) == 1) ) {
if (isProcessRunning("YSF2DMR")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
}
elseif ( ($mode == "YSF2NXDN Network") && (getEnabled("System Fusion", $mmdvmconfigs) == 1) ) {
if (isProcessRunning("YSF2NXDN")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
}
elseif ( ($mode == "YSF2P25 Network") && (getEnabled("System Fusion", $mmdvmconfigs) == 1) ) {
if (isProcessRunning("YSF2P25")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
}
elseif ( ($mode == "DMR2NXDN Network") && (getEnabled("DMR", $mmdvmconfigs) == 1) ) {
if (isProcessRunning("DMR2NXDN")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
}
elseif ( ($mode == "DMR2YSF Network") && (getEnabled("DMR", $mmdvmconfigs) == 1) ) {
if (isProcessRunning("DMR2YSF")) {
echo "<td style=\"background:#0b0; color:#030; width:50%;\">";
} else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
}
else {
echo "<td style=\"background:#606060; color:#b0b0b0;\" aria-disabled=\"true>\">";
}
$mode = str_replace("System Fusion", "YSF", $mode);
$mode = str_replace("Network", "Net", $mode);
if (strpos($mode, 'YSF2') > -1) { $mode = str_replace(" Net", "", $mode); }
if (strpos($mode, 'DMR2') > -1) { $mode = str_replace(" Net", "", $mode); }
echo $mode."</td>\n";
}
function getMMDVMLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
$logLines1 = array();
$logLines2 = array();
if (file_exists(MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d").".log")) {
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d").".log";
$logLines1 = explode("\n", `egrep -h "from|end|watchdog|lost" $logPath | sed '/\(CSBK\|overflow\|Downlink\)/d' | tail -250`);
}
$logLines1 = array_slice($logLines1, -250);
if (sizeof($logLines1) < 250) {
if (file_exists(MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log")) {
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log";
$logLines2 = explode("\n", `egrep -h "from|end|watchdog|lost" $logPath | sed '/\(CSBK\|overflow\|Downlink\)/d' | tail -250`);
}
}
$logLines2 = array_slice($logLines2, -250);
$logLines = $logLines1 + $logLines2;
$logLines = array_slice($logLines, -250);
return $logLines;
}
function getYSFGatewayLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
$logLines1 = array();
$logLines2 = array();
if (file_exists(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d").".log")) {
$logPath1 = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d").".log";
//$logLines1 = explode("\n", `egrep -h "repeater|Starting|Opening YSF|Disconnect|Connect|Automatic|Disconnecting|Reverting|Linked" $logPath1 | tail -250`);
$logLines1 = preg_split('/\r\n|\r|\n/', `grep -E "onnection to|onnect to|ink|isconnect|Opening YSF network" $logPath1 | sed '/Linked to MMDVM/d' | sed '/Link successful to MMDVM/d' | sed '/\x2aLink/d' | tail -1`);
}
$logLines1 = array_filter($logLines1);
if (sizeof($logLines1) == 0) {
if (file_exists(YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log")) {
$logPath2 = YSFGATEWAYLOGPATH."/".YSFGATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log";
//$logLines2 = explode("\n", `egrep -h "repeater|Starting|Opening YSF|Disconnect|Connect|Automatic|Disconnecting|Reverting|Linked" $logPath2 | tail -250`);
$logLines1 = preg_split('/\r\n|\r|\n/', `grep -E "onnection to|onnect to|ink|isconnect|Opening YSF network" $logPath2 | sed '/Linked to MMDVM/d' | sed '/Link successful to MMDVM/d' | sed '/\x2aLink/d' | tail -1`);
}
$logLines2 = array_filter($logLines2);
}
if (sizeof($logLines1) == 0) { $logLines = $logLines2; } else { $logLines = $logLines1; }
return array_filter($logLines);
}
function getP25GatewayLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
$logLines1 = array();
$logLines2 = array();
if (file_exists(P25GATEWAYLOGPATH."/".P25GATEWAYLOGPREFIX."-".gmdate("Y-m-d").".log")) {
$logPath1 = P25GATEWAYLOGPATH."/".P25GATEWAYLOGPREFIX."-".gmdate("Y-m-d").".log";
$logLines1 = preg_split('/\r\n|\r|\n/', `egrep -h "ink|Starting|witched" $logPath1 | cut -d" " -f2- | tail -1`);
$tgs = preg_split('/\r\n|\r|\n/', `egrep -h "ink" $logPath1 | cut -d" " -f2- | tail -1 | cut -d" " -f6`);
// 2022-02-28 20:15:48.348 Linked at startup to reflector 10210
}
$logLines1 = array_filter($logLines1);
if (sizeof($logLines1) == 0) {
if (file_exists(P25GATEWAYLOGPATH."/".P25GATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log")) {
$logPath2 = P25GATEWAYLOGPATH."/".P25GATEWAYLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log";
$logLines2 = preg_split('/\r\n|\r|\n/', `egrep -h "ink|Starting|witched" $logPath2 | cut -d" " -f2- | tail -1`);
}
$logLines2 = array_filter($logLines2);
}
if (sizeof($logLines1) == 0) { $logLines = $logLines2; } else { $logLines = $logLines1; }
return array_filter($logLines);
}
function getNXDNGatewayLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
$logLines1 = array();
$logLines2 = array();
if (file_exists("/var/log/pi-star/NXDNGateway-".gmdate("Y-m-d").".log")) {
$logPath1 = "/var/log/pi-star/NXDNGateway-".gmdate("Y-m-d").".log";
$logLines1 = preg_split('/\r\n|\r|\n/', `egrep -h "ink|Starting|witched" $logPath1 | cut -d" " -f2- | tail -1`);
}
$logLines1 = array_filter($logLines1);
if (sizeof($logLines1) == 0) {
if (file_exists("/var/log/pi-star/NXDNGateway-".gmdate("Y-m-d", time() - 86340).".log")) {
$logPath2 = "/var/log/pi-star/NXDNGateway-".gmdate("Y-m-d", time() - 86340).".log";
$logLines2 = preg_split('/\r\n|\r|\n/', `egrep -h "ink|Starting|witched" $logPath2 | cut -d" " -f2- | tail -1`);
}
$logLines2 = array_filter($logLines2);
}
if (sizeof($logLines1) == 0) { $logLines = $logLines2; } else { $logLines = $logLines1; }
return array_filter($logLines);
}
function getDAPNETGatewayLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logLines = array();
$logLines1 = array();
$logLines2 = array();
if (file_exists("/var/log/pi-star/DAPNETGateway-".gmdate("Y-m-d").".log")) {
$logPath1 = "/var/log/pi-star/DAPNETGateway-".gmdate("Y-m-d").".log";
$logLines1 = preg_split('/\r\n|\r|\n/', `egrep -h "Sending message" $logPath1 | cut -d" " -f2- | tail -n 20 | tac`);
}
$logLines1 = array_filter($logLines1);
if (sizeof($logLines1) == 0) {
if (file_exists("/var/log/pi-star/DAPNETGateway-".gmdate("Y-m-d", time() - 86340).".log")) {
$logPath2 = "/var/log/pi-star/DAPNETGateway-".gmdate("Y-m-d", time() - 86340).".log";
$logLines2 = preg_split('/\r\n|\r|\n/', `egrep -h "Sending message" $logPath2 | cut -d" " -f2- | tail -n 20 | tac`);
}
$logLines2 = array_filter($logLines2);
}
$logLines = $logLines1 + $logLines2;
$logLines = array_slice($logLines, -20);
return array_filter($logLines);
}
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: DVMEGA HR3.14
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: MMDVM_HS-ADF7021 20170414 (D-Star/DMR/YSF/P25) (Build: 20:16:25 May 20 2017)
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: MMDVM 20170206 TCXO (D-Star/DMR/System Fusion/P25/RSSI/CW Id)
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: ZUMspot ADF7021 v1.0.0 20170728 (DStar/DMR/YSF/P25) GitID #c16dd5a
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: MMDVM_MDO ADF7021 v1.0.1 20170826 (DStar/DMR/YSF/P25) GitID #BD7KLE
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: ZUMspot-v1.0.3 20171226 ADF7021 FW by CA6JAU GitID #bfb82b4
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: MMDVM_HS_Hat-v1.0.3 20171226 ADF7021 FW by CA6JAU GitID #bfb82b4
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: MMDVM_HS-v1.0.3 20171226 ADF7021 FW by CA6JAU GitID #bfb82b4
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: MMDVM_HS_Dual_Hat-v1.3.6 20180521 dual ADF7021 FW by CA6JAU GitID #bd6217a
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: D2RG_MMDVM_HS-v1.4.17 20190529 14.7456MHz ADF7021 FW by CA6JAU GitID #cc451c4
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: Nano_hotSPOT-v1.3.3 20180224 ADF7021 FW by CA6JAU GitID #62323e7
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: Nano-Spot-v1.3.3 20180224 ADF7021 FW by CA6JAU GitID #62323e7
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: Nano_DV-v1.4.3 20180716 12.2880MHz ADF7021 FW by CA6JAU GitID #6729d23
// I: 1970-01-01 00:00:00.000 MMDVM protocol version: 1, description: SkyBridge-v1.5.2 20201108 14.7456MHz ADF7021 FW by CA6JAU GitID #89daa20
function getDVModemFirmware() {
$logMMDVMNow = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d").".log";
$logMMDVMPrevious = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log";
$logSearchString = "MMDVM protocol version";
$logLine = '';
$modemFirmware = '';
$logLine = exec("grep \"".$logSearchString."\" ".$logMMDVMNow." | tail -1");
if (!$logLine) { $logLine = exec("grep \"".$logSearchString."\" ".$logMMDVMPrevious." | tail -1"); }
if ($logLine) {
if (strpos($logLine, 'DVMEGA')) {
$modemFirmware = substr($logLine, 67, 15);
}
if (strpos($logLine, 'description: MMDVM_HS')) {
$modemFirmware = "MMDVM_HS:".ltrim(substr($logLine, 84, 8), 'v');
}
if (strpos($logLine, 'description: MMDVM ')) {
$modemFirmware = "MMDVM:".substr($logLine, 73, 8);
}
if (strpos($logLine, 'description: ZUMspot ')) {
$modemFirmware = "ZUMspot:".strtok(substr($logLine, 83, 12), ' ');
}
if (strpos($logLine, 'description: MMDVM_MDO ')) {
$modemFirmware = "MMDVM_MDO:".ltrim(strtok(substr($logLine, 85, 12), ' '), 'v');
}
if (strpos($logLine, 'description: ZUMspot-')) {
$modemFirmware = "ZUMspot:".strtok(substr($logLine, 75, 12), ' ');
}
if (strpos($logLine, 'description: MMDVM_HS_Hat-')) {
$modemFirmware = "HS_Hat:".strtok(substr($logLine, 80, 12), ' ');
}
if (strpos($logLine, 'description: MMDVM_HS_Dual_Hat-')) {
$modemFirmware = "HS_Hat:".strtok(substr($logLine, 85, 12), ' ');
}
if (strpos($logLine, 'description: D2RG_MMDVM_HS-')) {
$modemFirmware = "HS_Hat:".strtok(substr($logLine, 81, 12), ' ');
}
if (strpos($logLine, 'description: MMDVM_HS-')) {
$modemFirmware = "MMDVM_HS:".ltrim(strtok(substr($logLine, 76, 12), ' '), 'v');
}
if (strpos($logLine, 'description: Nano_hotSPOT-')) {
$modemFirmware = "MMDVM_HS:".ltrim(strtok(substr($logLine, 80, 12), ' '), 'v');
}
if (strpos($logLine, 'description: Nano-Spot-')) {
$modemFirmware = "NanoSpot:".strtok(substr($logLine, 77, 12), ' ');
}
if (strpos($logLine, 'description: Nano_DV-')) {
$modemFirmware = "NanoDV:".strtok(substr($logLine, 75, 12), ' ');
}
if (strpos($logLine, 'description: OpenGD77 Hotspot')) {
$modemFirmware = "OpenGD77:".strtok(substr($logLine, 83, 12), ' ');
}
if (strpos($logLine, 'description: OpenGD77_HS ')) {
$modemFirmware = "OpenGD77:".strtok(substr($logLine, 79, 12), ' ');
}
if (strpos($logLine, 'description: SkyBridge-')) {
$modemFirmware = "SkyBrg:".strtok(substr($logLine, 77, 12), ' ');
}
}
return $modemFirmware;
}
function getDVModemTCXOFreq() {
$logMMDVMNow = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d").".log";
$logMMDVMPrevious = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".gmdate("Y-m-d", time() - 86340).".log";
$logSearchString = "MMDVM protocol version";
$logLine = '';
$modemTCXOFreq = '';
$logLine = exec("grep \"".$logSearchString."\" ".$logMMDVMNow." | tail -1");
if (!$logLine) { $logLine = exec("grep \"".$logSearchString."\" ".$logMMDVMPrevious." | tail -1"); }
if ($logLine) {
if ((strpos($logLine, 'Mhz') !== false) or (strpos($logLine, 'MHz') !== false)) {
$modemTCXOFreq = $logLine;
$modemTCXOFreq = preg_replace('/.*(\d{2}\.\d{3,4}\s{0,1}M[Hh]z).*/', "$1", $modemTCXOFreq);
$modemTCXOFreq = str_replace("MHz"," MHz", $modemTCXOFreq);
}
}
return $modemTCXOFreq;
}
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// M: 2000-00-00 00:00:00.000 D-Star, received network header from M1ABC /ABCD to CQCQCQ via REF000 A
// M: 2000-00-00 00:00:00.000 DMR Slot 2, received network voice header from M1ABC to TG 1
// M: 2000-00-00 00:00:00.000 DMR Slot 2, received RF voice header from M1ABC to 5000
// M: 2000-00-00 00:00:00.000 DMR Slot 2, received RF end of voice transmission, 1.8 seconds, BER: 3.9%
// M: 2000-00-00 00:00:00.000 DMR Slot 2, received network end of voice transmission from M1ABC to TG 2, 0.0 seconds, 0% packet loss, BER: 0.0%
// M: 2000-00-00 00:00:00.000 DMR Slot 2, RF voice transmission lost, 1.1 seconds, BER: 6.5%
// M: 2000-00-00 00:00:00.000 DMR Slot 2, received RF CSBK Preamble CSBK (1 to follow) from M1ABC to TG 1
// M: 2000-00-00 00:00:00.000 DMR Slot 2, received network Data Preamble VSBK (11 to follow) from 123456 to TG 123456
// M: 2000-00-00 00:00:00.000 DMR Talker Alias (Data Format 1, Received 24/24 char): 'Hide the bottle from Ont'
// M: 2000-00-00 00:00:00.000 0000: 07 00 20 4F 6E 74 00 00 00 *.. Ont...*
// M: 2000-00-00 00:00:00.000 DMR Slot 2, Embedded Talker Alias Block 3
// M: 2000-00-00 00:00:00.000 DMR Slot 2, received network data header from 123999 to M1ABC, 0 blocks
// M: 2000-00-00 00:00:00.000 DMR Slot 2, ended network data transmission from 123999 to M1ABC
// M: 2000-00-00 00:00:00.000 P25, received RF transmission from M1ABC to TG 10200
// M: 2000-00-00 00:00:00.000 Debug: P25RX: pos/neg/centre/threshold 106 -105 0 106
// M: 2000-00-00 00:00:00.000 Debug: P25RX: sync found in Ldu pos/centre/threshold 3986 9 104
// M: 2000-00-00 00:00:00.000 Debug: P25RX: pos/neg/centre/threshold 267 -222 22 245
// M: 2000-00-00 00:00:00.000 Debug: P25RX: sync found in Ldu pos/centre/threshold 3986 10 112
// M: 2000-00-00 00:00:00.000 P25, received RF end of transmission, 0.4 seconds, BER: 0.0%
// M: 2000-00-00 00:00:00.000 P25, received network transmission from 10999 to TG 10200
// M: 2000-00-00 00:00:00.000 P25, network end of transmission, 1.8 seconds, 0% packet loss
// M: 2000-00-00 00:00:00.000 YSF, received RF data from MW0MWZ to ALL
// M: 2000-00-00 00:00:00.000 YSF, received RF end of transmission, 5.1 seconds, BER: 3.8%
// M: 2000-00-00 00:00:00.000 YSF, received network data from M1ABC to ALL at MB6IBK
// M: 2000-00-00 00:00:00.000 YSF, network watchdog has expired, 5.0 seconds, 0% packet loss, BER: 0.0%
// M: 2000-00-00 00:00:00.000 NXDN, received RF transmission from MW0MWZ to TG 65000
// M: 2000-00-00 00:00:00.000 Debug: NXDNRX: pos/neg/centre/threshold 106 -105 0 106
// M: 2000-00-00 00:00:00.000 Debug: NXDNRX: sync found in Ldu pos/centre/threshold 3986 9 104
// M: 2000-00-00 00:00:00.000 Debug: NXDNRX: pos/neg/centre/threshold 267 -222 22 245
// M: 2000-00-00 00:00:00.000 Debug: NXDNRX: sync found in Ldu pos/centre/threshold 3986 10 112
// M: 2000-00-00 00:00:00.000 NXDN, received RF end of transmission, 0.4 seconds, BER: 0.0%
// M: 2000-00-00 00:00:00.000 NXDN, received network transmission from 10999 to TG 65000
// M: 2000-00-00 00:00:00.000 NXDN, network end of transmission, 1.8 seconds, 0% packet loss
// M: 2000-00-00 00:00:00.000 POCSAG, transmitted 1 frame(s) of data from 1 message(s)
function getHeardList($logLines) {
//array_multisort($logLines,SORT_DESC);
$heardList = array();
$ts1duration = "";
$ts1loss = "";
$ts1ber = "";
$ts1rssi = "";
$ts2duration = "";
$ts2loss = "";
$ts2ber = "";
$ts2rssi = "";
$dstarduration = "";
$dstarloss = "";
$dstarber = "";
$dstarrssi = "";
$ysfduration = "";
$ysfloss = "";
$ysfber = "";
$ysfrssi = "";
$p25duration = "";
$p25loss = "";
$p25ber = "";
$p25rssi = "";
$nxdnduration = "";
$nxdnloss = "";
$nxdnber = "";
$nxdnrssi = "";
$pocsagduration = "";
foreach ($logLines as $logLine) {
$duration = "";
$loss = "";
$ber = "";
$rssi = "";
//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,"non repeater RF header received")) {
continue;
} else if(strpos($logLine,"Embedded Talker Alias")) {
continue;
} else if(strpos($logLine,"DMR Talker Alias")) {
continue;
} else if(strpos($logLine,"CSBK Preamble")) {
continue;
} else if(strpos($logLine,"Preamble CSBK")) {
continue;
}
if(strpos($logLine, "end of") || strpos($logLine, "watchdog has expired") || strpos($logLine, "ended RF data") || strpos($logLine, "d network data") || strpos($logLine, "RF user has timed out") || strpos($logLine, "transmission lost") || strpos($logLine, "POCSAG")) {
$lineTokens = explode(", ",$logLine);
if (array_key_exists(2,$lineTokens)) {
$duration = strtok($lineTokens[2], " ");
}
if (array_key_exists(3,$lineTokens)) {
$loss = $lineTokens[3];
}
// The change to this code was causing all FCS traffic to always show TOut rather than the timer.
// This version should still show time-out when needed, AND show the time if it exists.
if (strpos($logLine,"RF user has timed out") || strpos($logLine,"watchdog has expired")) {
if (array_key_exists(2,$lineTokens) && strpos($lineTokens[2], "seconds")) {
$duration = strtok($lineTokens[2], " ");
} else {
$duration = "TOut";
}
$ber = "??%";
}
// if RF-Packet with no BER reported (e.g. YSF Wires-X commands) then RSSI is in LOSS position
if (startsWith($loss,"RSSI")) {
$lineTokens[4] = $loss; //move RSSI to the position expected on code below
$loss = 'BER: ??%';
}
// if RF-Packet, no LOSS would be reported, so BER is in LOSS position
if (startsWith($loss,"BER")) {
$ber = substr($loss, 5);
$loss = "0%";
if (array_key_exists(4,$lineTokens) && startsWith($lineTokens[4],"RSSI")) {
$rssi = substr($lineTokens[4], 6);
$dBraw = substr($rssi, strrpos($rssi,'/')+1); //average only
$relint = intval($dBraw) + 93;
$signal = round(($relint/6)+9, 0);
if ($signal < 0) $signal = 0;
if ($signal > 9) $signal = 9;
if ($relint > 0) {
$rssi = "S{$signal}+{$relint}dB ({$dBraw})";
} else {
$rssi = "S{$signal} ({$dBraw})";
}
}
} else {
$loss = strtok($loss, " ");
if (array_key_exists(4,$lineTokens)) {
$ber = substr($lineTokens[4], 5);
}
}
if (strpos($logLine,"ended RF data") || strpos($logLine,"d network data")) {
switch (substr($logLine, 27, strpos($logLine,",") - 27)) {
case "DMR Slot 1":
$ts1duration = "DMR Data";
break;
case "DMR Slot 2":
$ts2duration = "DMR Data";
break;
}
} else {
switch (substr($logLine, 27, strpos($logLine,",") - 27)) {
case "D-Star":
$dstarduration = $duration;
$dstarloss = $loss;
$dstarber = $ber;
$dstarrssi = $rssi;
break;
case "DMR Slot 1":
$ts1duration = $duration;
$ts1loss = $loss;
$ts1ber = $ber;
$ts1rssi = $rssi;
break;
case "DMR Slot 2":
$ts2duration = $duration;
$ts2loss = $loss;
$ts2ber = $ber;
$ts2rssi = $rssi;
break;
case "YSF":
$ysfduration = $duration;
$ysfloss = $loss;
$ysfber = $ber;
$ysfrssi = $rssi;
break;
case "P25":
$p25duration = $duration;
$p25loss = $loss;
$p25ber = $ber;
$p25rssi = $rssi;
break;
case "NXDN":
$nxdnduration = $duration;
$nxdnloss = $loss;
$nxdnber = $ber;
$nxdnrssi = $rssi;
break;
case "POCSAG":
$pocsagduration = "POCSAG Data";
break;
}
}
}
$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);
$id ="";
if ($mode == "D-Star") {
$id = substr($callsign2, strpos($callsign2,"/") + 1);
}
$target = trim(substr($logLine, strpos($logLine, "to") + 3));
// Handle more verbose logging from MMDVMHost
if (strpos($target,",") !== 'false') { $target = explode(",", $target)[0]; }
$source = "RF";
if (strpos($logLine,"network") > 0 || strpos($logLine,"POCSAG") > 0) {
$source = "Net";
}
switch ($mode) {
case "D-Star":
$duration = $dstarduration;
$loss = $dstarloss;
$ber = $dstarber;
$rssi = $dstarrssi;
break;
case "DMR Slot 1":
$duration = $ts1duration;
$loss = $ts1loss;
$ber = $ts1ber;
$rssi = $ts1rssi;
break;
case "DMR Slot 2":
$duration = $ts2duration;
$loss = $ts2loss;
$ber = $ts2ber;
$rssi = $ts2rssi;
break;
case "YSF":
$duration = $ysfduration;
$loss = $ysfloss;
$ber = $ysfber;
$rssi = $ysfrssi;
$target = preg_replace('!\s+!', ' ', $target);
break;
case "P25":
if ($source == "Net" && $target == "TG 10") {$callsign = "PARROT";}
if ($source == "Net" && $callsign == "10999") {$callsign = "MMDVM";}
$duration = $p25duration;
$loss = $p25loss;
$ber = $p25ber;
$rssi = $p25rssi;
break;
case "NXDN":
if ($source == "Net" && $target == "TG 10") {$callsign = "PARROT";}
$duration = $nxdnduration;
$loss = $nxdnloss;
$ber = $nxdnber;
$rssi = $nxdnrssi;
break;
case "POCSAG":
$callsign = "DAPNET";
$target = "DAPNET User";
$duration = "POCSAG Data";
break;
}
// Callsign or ID should be less than 11 chars long, otherwise it could be errorneous
if ( strlen($callsign) < 11 ) {
array_push($heardList, array($timestamp, $mode, $callsign, $id, $target, $source, $duration, $loss, $ber, $rssi));
$duration = "";
$loss ="";
$ber = "";
$rssi = "";
}
}
return $heardList;
}
function getLastHeard($logLines) {
//returns last heard list from log
$lastHeard = array();
$heardCalls = array();
$heardList = getHeardList($logLines);
$counter = 0;
foreach ($heardList as $listElem) {
if ( ($listElem[1] == "D-Star") || ($listElem[1] == "YSF") || ($listElem[1] == "P25") || ($listElem[1] == "NXDN") || ($listElem[1] == "POCSAG") || (startsWith($listElem[1], "DMR")) ) {
$callUuid = $listElem[2]."#".$listElem[1].$listElem[3].$listElem[5];
if(!(array_search($callUuid, $heardCalls) > -1)) {
array_push($heardCalls, $callUuid);
array_push($lastHeard, $listElem);
$counter++;
}
}
}
return $lastHeard;
}
function getActualMode($metaLastHeard, $mmdvmconfigs) {
// returns mode of repeater actual working in
$utc_tz = new DateTimeZone('UTC');
$local_tz = new DateTimeZone(date_default_timezone_get ());
$listElem = $metaLastHeard[0];
$timestamp = new DateTime($listElem[0], $utc_tz);
$timestamp->setTimeZone($local_tz);
$mode = $listElem[1];
if (startsWith($mode, "DMR")) {
$mode = "DMR";
}
$now = new DateTime();
$hangtime = getConfigItem("General", "ModeHang", $mmdvmconfigs);
if ($hangtime != "") {
$timestamp->add(new DateInterval('PT' . $hangtime . 'S'));
} else {
$source = $listElem[5];
if ($source == "RF" && $mode === "D-Star") {
$hangtime = getConfigItem("D-Star", "ModeHang", $mmdvmconfigs);
}
else if ($source == "Net" && $mode === "D-Star") {
$hangtime = getConfigItem("D-Star Network", "ModeHang", $mmdvmconfigs);
}
else if ($source == "RF" && $mode === "DMR") {
$hangtime = getConfigItem("DMR", "ModeHang", $mmdvmconfigs);
}
else if ($source == "Net" && $mode === "DMR") {
$hangtime = getConfigItem("DMR Network", "ModeHang", $mmdvmconfigs);
}
else if ($source == "RF" && $mode === "YSF") {
$hangtime = getConfigItem("System Fusion", "ModeHang", $mmdvmconfigs);
}
else if ($source == "Net" && $mode === "YSF") {
$hangtime = getConfigItem("System Fusion Network", "ModeHang", $mmdvmconfigs);
}
else if ($source == "RF" && $mode === "P25") {
$hangtime = getConfigItem("P25", "ModeHang", $mmdvmconfigs);
}
else if ($source == "Net" && $mode === "P25") {
$hangtime = getConfigItem("P25 Network", "ModeHang", $mmdvmconfigs);
}
else if ($source == "RF" && $mode === "NXDN") {
$hangtime = getConfigItem("NXDN", "ModeHang", $mmdvmconfigs);
}
else if ($source == "Net" && $mode === "NXDN") {
$hangtime = getConfigItem("NXDN Network", "ModeHang", $mmdvmconfigs);
}
else if ($source == "Net" && $mode === "POCSAG") {
$hangtime = getConfigItem("POCSAG Network", "ModeHang", $mmdvmconfigs);
}
else {
$hangtime = getConfigItem("General", "RFModeHang", $mmdvmconfigs);
}
$timestamp->add(new DateInterval('PT' . $hangtime . 'S'));
}
if ($listElem[6] != null) { //if terminated, hangtime counts after end of transmission
$timestamp->add(new DateInterval('PT' . ceil($listElem[6]) . 'S'));
} else { //if not terminated, always return mode
return $mode;
}
if ($now->format('U') > $timestamp->format('U')) {
return "idle";
} else {
return $mode;
}
}
function getDSTARLinks() {
// returns link-states of all D-Star-modules
if (filesize(LINKLOGPATH."/Links.log") == 0) {
return "Not Linked";
}
if ($linkLog = fopen(LINKLOGPATH."/Links.log",'r')) {
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];
}
// Dongle-Link, sample:
// 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];
}
if (strtolower(substr($linkDir, 0, 2)) == "in") { $linkDir = "In"; }
if (strtolower(substr($linkDir, 0, 3)) == "out") { $linkDir = "Out"; }
$out = $linkDest." ".$protocol."/".$linkDir;
}
}
fclose($linkLog);
return $out;
}
function getActualLink($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
//M: 2017-09-03 08:10:42.862 DMR Slot 2, received network data header from M6JQD to TG 9, 5 blocks
switch ($mode) {
case "D-Star":
if (isProcessRunning(IRCDDBGATEWAY)) {
return getDSTARLinks();
} else {
return "No D-Star Network";
}
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));
}
if ($to !== "") {
if (substr($to, 0, 3) !== 'TG ') {
continue;
}
if ($to === "TG 4000") {
return "No TG";
}
if (strpos($to, ',') !== false) {
$to = substr($to, 0, strpos($to, ','));
}
return $to;
}
}
}
return "No TG";
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));
}
if ($to !== "") {
if (substr($to, 0, 3) !== 'TG ') {
continue;
}
if ($to === "TG 4000") {
return "No TG";
}
if (strpos($to, ',') !== false) {
$to = substr($to, 0, strpos($to, ','));
}
return $to;
}
}
}
return "No TG";
break;
case "YSF":
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// M: 0000-00-00 00:00:00.000 Connect to 62829 has been requested by M1ABC
// M: 0000-00-00 00:00:00.000 Automatic connection to 62829
// New YSFGateway Format
// M: 0000-00-00 00:00:00.000 Opening YSF network connection
// M: 0000-00-00 00:00:00.000 Automatic (re-)connection to 16710 - "GB SOUTH WEST "
// M: 0000-00-00 00:00:00.000 Automatic (re-)connection to FCS00290
// M: 0000-00-00 00:00:00.000 Linked to GB SOUTH WEST
// M: 0000-00-00 00:00:00.000 Linked to FCS002-90
// M: 0000-00-00 00:00:00.000 Disconnect via DTMF has been requested by M1ABC
// M: 0000-00-00 00:00:00.000 Connect to 00003 - "YSF2NXDN " has been requested by M1ABC
// M: 0000-00-00 00:00:00.000 Link has failed, polls lost
if (isProcessRunning("YSFGateway")) {
$to = "";
foreach($logLines as $logLine) {
if ( (strpos($logLine,"Linked to")) && (!strpos($logLine,"Linked to MMDVM")) ) {
$to = trim(substr($logLine, 37, 16));
if (substr($to, 0, 3) === "FCS") { $to = str_replace(' ', '', str_replace('-', '', $to)); }
}
if (strpos($logLine,"Automatic (re-)connection to")) {
if (strpos($logLine,"Automatic (re-)connection to FCS")) {
$to = substr($logLine, 56, 8);
}
else {
$to = substr($logLine, 56, 5);
}
}
if (strpos($logLine,"Connect to")) {
$to = substr($logLine, 38, 5);
}
if (strpos($logLine,"Automatic connection to")) {
$to = substr($logLine, 51, 5);
}
if (strpos($logLine,"Disconnect via DTMF")) {
$to = "Not Linked";
}
if (strpos($logLine,"Opening YSF network connection")) {
$to = "Not Linked";
}
if (strpos($logLine,"Link has failed")) {
$to = "Not Linked";
}
if (strpos($logLine,"DISCONNECT Reply")) {
$to = "Not Linked";
}
if ($to !== "") {
return $to;
}
}
return "Not Linked";
} else {
return "Service Not Started";
}
break;
case "NXDN":
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// 2000-01-01 00:00:00.000 Linked at startup to reflector 10100
// 2000-01-01 00:00:00.000 Unlinked from reflector 10100 by M1ABC
// 2000-01-01 00:00:00.000 Linked to reflector 10100 by M1ABC
// 2000-01-01 00:00:00.000 No response from 10200, unlinking
// 2000-01-01 00:00:00.000 Switched to reflector 10100 by remote command
// 2000-01-01 00:00:00.000 Unlinking from 10100 due to inactivity
// 2000-01-01 00:00:00.000 Statically linked to reflector 10100
if (isProcessRunning("NXDNGateway")) {
foreach($logLines as $logLine) {
$to = "";
if (strpos($logLine,"Linked to")) {