-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaprsquery.php
executable file
·60 lines (49 loc) · 1.43 KB
/
aprsquery.php
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
#!/usr/bin/php
<?php
$lat = 0;
$lng = 0;
$mode = "Aprs";
// $err = false;
global $err;
$config2 = parse_ini_file('/etc/mmdvmhost', true);
$lat = $config2['Info']['Latitude'];
$lng = $config2['Info']['Longitude'];
$config = parse_ini_file('/etc/nextionbrightness', true);
$apik = $config['General']['ApiKey'];
$call = $config['General']['Call'];
$mode = $config['General']['Mode'];
function customError($errno, $errstr) {
global $lat, $lng;
echo "".$lat." ".$lng."", " MMDVM\n";
die();
}
set_error_handler("customError");
function display_APRS() {
global $lat, $lng ;
$config = parse_ini_file('/etc/nextionbrightness', true);
$apik = $config['General']['ApiKey'];
$call = $config['General']['Call'];
$mode = $config['General']['Mode'];
$json_url = "http://api.aprs.fi/api/get?apikey=${apik}&name=${call}&what=loc&format=json";
$json = file_get_contents( $json_url, 0, null, null );
$json_output = json_decode( $json, true);
$station_array = $json_output[ 'entries' ];
$station = $station_array[0];
$lat = $station[ 'lat' ];
$lng = $station[ 'lng' ];
echo "".$lat." ".$lng."", " Aprs\n";
}
function getlatlonfrommmdvm(){
global $lat, $lng;
$config2 = parse_ini_file('/etc/mmdvmhost', true);
$lat = $config2['Info']['Latitude'];
$lng = $config2['Info']['Longitude'];
// echo "".$lat." ".$lng."\n";
echo "".$lat." ".$lng."", " MMDVM\n";
}
if ($mode == "Aprs") {
display_APRS();
}else {
getlatlonfrommmdvm();
}
?>