';
diff --git a/require/class.APRS.php b/require/class.APRS.php
index 19dd99f6..3204b35d 100644
--- a/require/class.APRS.php
+++ b/require/class.APRS.php
@@ -1,6 +1,7 @@
convertDM($latitude,'latitude');
$longitude = $Common->convertDM($longitude,'longitude');
$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
@@ -674,6 +677,12 @@ public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,
$custom .= 'AI='.$aircraft_icao;
}
if ($custom != '') $custom = ' '.$custom;
+ /*
+ // Use AMSL altitude
+ $GeoidClass = new GeoidHeight();
+ $geoid= round($GeoidClass->get($lat,$long)*3.28084,2);
+ $altitude_real = round($altitude_real + $geoid);
+ */
$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
}
}
diff --git a/scripts/daemon-spotter.php b/scripts/daemon-spotter.php
index bdf51b61..9b605026 100755
--- a/scripts/daemon-spotter.php
+++ b/scripts/daemon-spotter.php
@@ -378,8 +378,14 @@ function connect_all($hosts) {
//foreach ($formats as $id => $value) {
foreach ($globalSources as $id => $value) {
date_default_timezone_set('UTC');
+ //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
- if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ if ($value['format'] == 'deltadbtxt' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id]);
$buffer = $Common->getData($value['host']);
if ($buffer != '') $reset = 0;
@@ -410,7 +416,12 @@ function connect_all($hosts) {
}
}
$last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
+ } elseif ($value['format'] == 'aisnmeatxt' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
+ )
+ ) {
date_default_timezone_set('CET');
$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
date_default_timezone_set('UTC');
@@ -507,7 +518,12 @@ function connect_all($hosts) {
}
}
}
- } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
+ } elseif ($value['format'] == 'myshiptracking' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
+ )
+ ) {
$buffer = $Common->getData($value['host'],'get','','','','','20');
if ($buffer != '') {
//echo $buffer;
@@ -537,7 +553,12 @@ function connect_all($hosts) {
}
}
$last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
+ } elseif ($value['format'] == 'boatbeaconapp' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
+ )
+ ) {
$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
if ($buffer != '') {
$all_data = json_decode($buffer,true);
@@ -566,7 +587,12 @@ function connect_all($hosts) {
}
$last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
+ } elseif ($value['format'] == 'boatnerd' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
+ )
+ ) {
$buffer = $Common->getData($value['host']);
if ($buffer != '') {
$all_data = json_decode($buffer,true);
@@ -595,7 +621,12 @@ function connect_all($hosts) {
}
$last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
+ } elseif ($value['format'] == 'shipplotter' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
+ )
+ ) {
echo 'download...';
$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
echo 'done !'."\n";
@@ -633,7 +664,21 @@ function connect_all($hosts) {
}
$last_exec[$id]['last'] = time();
//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
- } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
+ } elseif (
+ (
+ $value['format'] == 'whazzup' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) || (
+ $value['format'] == 'vatsimtxt' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id]);
$buffer = $Common->getData($value['host']);
$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
@@ -713,7 +758,12 @@ function connect_all($hosts) {
//if ($value == 'whazzup') $last_exec['whazzup'] = time();
//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
$last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ } elseif ($value['format'] == 'airwhere' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
if ($buffer != '') {
$all_data = simplexml_load_string($buffer);
@@ -760,67 +810,81 @@ function connect_all($hosts) {
}
}
$last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ /*
+ } if ($value['format'] == 'aircraftlistjson') {
+ print_r($globalSources);
+ print_r($last_exec);
+ echo $globalMinFetch;
+ */
+ } elseif ($value['format'] == 'aircraftlistjson' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
$buffer = $Common->getData($value['host'],'get','','','','','20');
if ($buffer != '') {
- $all_data = json_decode($buffer,true);
- if (isset($all_data['acList'])) {
- $reset = 0;
- foreach ($all_data['acList'] as $line) {
- $data = array();
- $data['hex'] = $line['Icao']; // hex
- if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
- if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
- if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
- if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
- if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
- if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
- //$data['verticalrate'] = $line['']; // verticale rate
- if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
- $data['emergency'] = ''; // emergency
- if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
-
- if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
- else $data['datetime'] = date('Y-m-d H:i:s');
-
- //$data['datetime'] = date('Y-m-d H:i:s');
- if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
- $data['format_source'] = 'aircraftlistjson';
- $data['id_source'] = $id_source;
- if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
- if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
- if (isset($data['latitude'])) $SI->add($data);
- unset($data);
- }
- } elseif (is_array($all_data)) {
- $reset = 0;
- foreach ($all_data as $line) {
- $data = array();
- $data['hex'] = $line['hex']; // hex
- $data['ident'] = $line['flight']; // ident
- $data['altitude'] = $line['altitude']; // altitude
- $data['speed'] = $line['speed']; // speed
- $data['heading'] = $line['track']; // heading
- $data['latitude'] = $line['lat']; // lat
- $data['longitude'] = $line['lon']; // long
- $data['verticalrate'] = $line['vrt']; // verticale rate
- $data['squawk'] = $line['squawk']; // squawk
- $data['emergency'] = ''; // emergency
- if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
- else $data['datetime'] = date('Y-m-d H:i:s');
- $data['format_source'] = 'aircraftlistjson';
- $data['id_source'] = $id_source;
- if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
- if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
- $SI->add($data);
- unset($data);
+ $all_data = json_decode($buffer,true);
+ if (isset($all_data['acList'])) {
+ $reset = 0;
+ foreach ($all_data['acList'] as $line) {
+ $data = array();
+ $data['hex'] = $line['Icao']; // hex
+ if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
+ if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
+ if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
+ if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
+ if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
+ if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
+ //$data['verticalrate'] = $line['']; // verticale rate
+ if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
+ $data['emergency'] = ''; // emergency
+ if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
+ if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
+ else $data['datetime'] = date('Y-m-d H:i:s');
+ //$data['datetime'] = date('Y-m-d H:i:s');
+ if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
+ $data['format_source'] = 'aircraftlistjson';
+ $data['id_source'] = $id_source;
+ if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
+ if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
+ if (isset($data['latitude'])) $SI->add($data);
+ unset($data);
+ }
+ } elseif (is_array($all_data)) {
+ $reset = 0;
+ foreach ($all_data as $line) {
+ $data = array();
+ $data['hex'] = $line['hex']; // hex
+ $data['ident'] = $line['flight']; // ident
+ $data['altitude'] = $line['altitude']; // altitude
+ $data['speed'] = $line['speed']; // speed
+ $data['heading'] = $line['track']; // heading
+ $data['latitude'] = $line['lat']; // lat
+ $data['longitude'] = $line['lon']; // long
+ $data['verticalrate'] = $line['vrt']; // verticale rate
+ $data['squawk'] = $line['squawk']; // squawk
+ $data['emergency'] = ''; // emergency
+ if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
+ else $data['datetime'] = date('Y-m-d H:i:s');
+ $data['format_source'] = 'aircraftlistjson';
+ $data['id_source'] = $id_source;
+ if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
+ if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
+ $SI->add($data);
+ unset($data);
+ }
}
- }
- }
+ } elseif ($globalDebug) echo 'No data'."\n";
//$last_exec['aircraftlistjson'] = time();
$last_exec[$id]['last'] = time();
//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
- } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ } elseif ($value['format'] == 'planeupdatefaa' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
$buffer = $Common->getData($value['host']);
$all_data = json_decode($buffer,true);
if (isset($all_data['planes'])) {
@@ -853,9 +917,14 @@ function connect_all($hosts) {
unset($data);
}
}
- //$last_exec['planeupdatefaa'] = time();
- $last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ //$last_exec['planeupdatefaa'] = time();
+ $last_exec[$id]['last'] = time();
+ } elseif ($value['format'] == 'opensky' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
$buffer = $Common->getData($value['host']);
$all_data = json_decode($buffer,true);
if (isset($all_data['states'])) {
@@ -875,17 +944,22 @@ function connect_all($hosts) {
//$data['registration'] = $line[2];
//$data['aircraft_icao'] = $line[0];
$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
- $data['format_source'] = 'opensky';
- $data['id_source'] = $id_source;
+ $data['format_source'] = 'opensky';
+ $data['id_source'] = $id_source;
if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
$SI->add($data);
unset($data);
}
}
- //$last_exec['planeupdatefaa'] = time();
- $last_exec[$id]['last'] = time();
- //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
- } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ //$last_exec['planeupdatefaa'] = time();
+ $last_exec[$id]['last'] = time();
+ //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
+ } elseif ($value['format'] == 'fr24json' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id]);
$buffer = $Common->getData($value['host']);
$all_data = json_decode($buffer,true);
@@ -916,10 +990,15 @@ function connect_all($hosts) {
unset($data);
}
}
- //$last_exec['fr24json'] = time();
- $last_exec[$id]['last'] = time();
- //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
- } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ //$last_exec['fr24json'] = time();
+ $last_exec[$id]['last'] = time();
+ //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
+ } elseif ($value['format'] == 'radarvirtueljson' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
$buffer = $Common->getData($value['host'],'get','','','','','150');
//echo $buffer;
@@ -958,10 +1037,15 @@ function connect_all($hosts) {
}
}
}
- //$last_exec['radarvirtueljson'] = time();
- $last_exec[$id]['last'] = time();
- //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
- } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ //$last_exec['radarvirtueljson'] = time();
+ $last_exec[$id]['last'] = time();
+ //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
+ } elseif ($value['format'] == 'pirepsjson' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id]);
$buffer = $Common->getData($value['host'].'?'.time());
$all_data = json_decode(utf8_encode($buffer),true);
@@ -1019,10 +1103,15 @@ function connect_all($hosts) {
unset($data);
}
}
- //$last_exec['pirepsjson'] = time();
- $last_exec[$id]['last'] = time();
- //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
- } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ //$last_exec['pirepsjson'] = time();
+ $last_exec[$id]['last'] = time();
+ //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
+ } elseif ($value['format'] == 'phpvmacars' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id]);
if ($globalDebug) echo 'Get Data...'."\n";
$buffer = $Common->getData($value['host']);
@@ -1082,9 +1171,14 @@ function connect_all($hosts) {
unset($buffer);
unset($all_data);
}
- //$last_exec['phpvmacars'] = time();
- $last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ //$last_exec['phpvmacars'] = time();
+ $last_exec[$id]['last'] = time();
+ } elseif ($value['format'] == 'vam' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id]);
if ($globalDebug) echo 'Get Data...'."\n";
$buffer = $Common->getData($value['host']);
@@ -1128,9 +1222,14 @@ function connect_all($hosts) {
unset($buffer);
unset($all_data);
}
- //$last_exec['phpvmacars'] = time();
- $last_exec[$id]['last'] = time();
- } elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
+ //$last_exec['phpvmacars'] = time();
+ $last_exec[$id]['last'] = time();
+ } elseif ($value['format'] == 'blitzortung' &&
+ (
+ (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
+ (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
+ )
+ ) {
//$buffer = $Common->getData($hosts[$id]);
if ($globalDebug) echo 'Get Data...'."\n";
$buffer = $Common->getData($value['host']);