@@ -5,23 +5,23 @@ discard block |
||
5 | 5 | $marine = false; |
6 | 6 | $usecoord = false; |
7 | 7 | if (isset($_GET['tracker'])) { |
8 | - $tracker = true; |
|
8 | + $tracker = true; |
|
9 | 9 | } |
10 | 10 | if (isset($_GET['marine'])) { |
11 | - $marine = true; |
|
11 | + $marine = true; |
|
12 | 12 | } |
13 | 13 | if ($tracker) { |
14 | - require_once('require/class.Tracker.php'); |
|
15 | - require_once('require/class.TrackerLive.php'); |
|
16 | - require_once('require/class.TrackerArchive.php'); |
|
14 | + require_once('require/class.Tracker.php'); |
|
15 | + require_once('require/class.TrackerLive.php'); |
|
16 | + require_once('require/class.TrackerArchive.php'); |
|
17 | 17 | } elseif ($marine) { |
18 | - require_once('require/class.Marine.php'); |
|
19 | - require_once('require/class.MarineLive.php'); |
|
20 | - require_once('require/class.MarineArchive.php'); |
|
18 | + require_once('require/class.Marine.php'); |
|
19 | + require_once('require/class.MarineLive.php'); |
|
20 | + require_once('require/class.MarineArchive.php'); |
|
21 | 21 | } else { |
22 | - require_once('require/class.Spotter.php'); |
|
23 | - require_once('require/class.SpotterLive.php'); |
|
24 | - require_once('require/class.SpotterArchive.php'); |
|
22 | + require_once('require/class.Spotter.php'); |
|
23 | + require_once('require/class.SpotterLive.php'); |
|
24 | + require_once('require/class.SpotterArchive.php'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $begintime = microtime(true); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $Common = new Common(); |
42 | 42 | |
43 | 43 | if (isset($_GET['download'])) { |
44 | - if ($_GET['download'] == "true") |
|
45 | - { |
|
44 | + if ($_GET['download'] == "true") |
|
45 | + { |
|
46 | 46 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
47 | - } |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
@@ -497,17 +497,17 @@ discard block |
||
497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
498 | 498 | |
499 | 499 | if ( |
500 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
501 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
500 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
501 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
504 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
506 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
508 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
510 | - ) { |
|
504 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
506 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
508 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
510 | + ) { |
|
511 | 511 | if ($tracker) { |
512 | 512 | if ($from_archive || $globalArchive) { |
513 | 513 | $spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']); |
@@ -596,26 +596,26 @@ discard block |
||
596 | 596 | } |
597 | 597 | |
598 | 598 | if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
599 | - $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
600 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
599 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
600 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
601 | 601 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
602 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
602 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
603 | 603 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
604 | 604 | if (isset($dairport[0]['latitude'])) { |
605 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
605 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
606 | 606 | } |
607 | - } |
|
608 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
607 | + } |
|
608 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
609 | 609 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
610 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
610 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
611 | 611 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
612 | 612 | if (isset($aairport[0]['latitude'])) { |
613 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
613 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
614 | 614 | } |
615 | - } |
|
616 | - $output_air .= ']}},'; |
|
617 | - $output .= $output_air; |
|
618 | - unset($output_air); |
|
615 | + } |
|
616 | + $output_air .= ']}},'; |
|
617 | + $output .= $output_air; |
|
618 | + unset($output_air); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | $output = substr($output, 0, -1); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveTrackerData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets Minimal Live Spotter data since xx seconds |
|
174 | - * |
|
175 | - * @return Array the spotter information |
|
176 | - * |
|
177 | - */ |
|
173 | + * Gets Minimal Live Spotter data since xx seconds |
|
174 | + * |
|
175 | + * @return Array the spotter information |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
179 | 179 | { |
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | - } else { |
|
190 | + } else { |
|
191 | 191 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
195 | 195 | |
196 | - try { |
|
196 | + try { |
|
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | 199 | } catch(PDOException $e) { |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Gets number of latest data entry |
|
209 | - * |
|
210 | - * @return String number of entry |
|
211 | - * |
|
212 | - */ |
|
208 | + * Gets number of latest data entry |
|
209 | + * |
|
210 | + * @return String number of entry |
|
211 | + * |
|
212 | + */ |
|
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | - * Gets all the spotter information based on the latest data entry and coord |
|
238 | - * |
|
239 | - * @return Array the spotter information |
|
240 | - * |
|
241 | - */ |
|
237 | + * Gets all the spotter information based on the latest data entry and coord |
|
238 | + * |
|
239 | + * @return Array the spotter information |
|
240 | + * |
|
241 | + */ |
|
242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
243 | 243 | { |
244 | 244 | global $globalDBdriver, $globalLiveInterval; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets all the spotter information based on the latest data entry and coord |
|
266 | - * |
|
267 | - * @return Array the spotter information |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets all the spotter information based on the latest data entry and coord |
|
266 | + * |
|
267 | + * @return Array the spotter information |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | - * Gets all the spotter information based on a user's latitude and longitude |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
296 | + * Gets all the spotter information based on a user's latitude and longitude |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | 301 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
302 | 302 | { |
303 | 303 | $Tracker = new Tracker($this->db); |
@@ -310,142 +310,142 @@ discard block |
||
310 | 310 | if ($lng != '') |
311 | 311 | { |
312 | 312 | if (!is_numeric($lng)) |
313 | - { |
|
314 | - return false; |
|
315 | - } |
|
316 | - } |
|
317 | - |
|
318 | - if ($radius != '') |
|
319 | - { |
|
320 | - if (!is_numeric($radius)) |
|
321 | - { |
|
322 | - return false; |
|
323 | - } |
|
324 | - } |
|
313 | + { |
|
314 | + return false; |
|
315 | + } |
|
316 | + } |
|
317 | + |
|
318 | + if ($radius != '') |
|
319 | + { |
|
320 | + if (!is_numeric($radius)) |
|
321 | + { |
|
322 | + return false; |
|
323 | + } |
|
324 | + } |
|
325 | 325 | $additional_query = ''; |
326 | 326 | if ($interval != '') |
327 | - { |
|
328 | - if (!is_string($interval)) |
|
329 | - { |
|
330 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
331 | - return false; |
|
332 | - } else { |
|
333 | - if ($interval == '1m') |
|
334 | - { |
|
335 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
336 | - } else if ($interval == '15m'){ |
|
337 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
338 | - } |
|
339 | - } |
|
340 | - } else { |
|
341 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
342 | - } |
|
343 | - |
|
344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
327 | + { |
|
328 | + if (!is_string($interval)) |
|
329 | + { |
|
330 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
331 | + return false; |
|
332 | + } else { |
|
333 | + if ($interval == '1m') |
|
334 | + { |
|
335 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
336 | + } else if ($interval == '15m'){ |
|
337 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
338 | + } |
|
339 | + } |
|
340 | + } else { |
|
341 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
342 | + } |
|
343 | + |
|
344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
345 | 345 | WHERE tracker_live.latitude <> '' |
346 | 346 | AND tracker_live.longitude <> '' |
347 | 347 | ".$additional_query." |
348 | 348 | HAVING distance < :radius |
349 | 349 | ORDER BY distance"; |
350 | 350 | |
351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
352 | 352 | |
353 | - return $spotter_array; |
|
354 | - } |
|
353 | + return $spotter_array; |
|
354 | + } |
|
355 | 355 | |
356 | 356 | |
357 | - /** |
|
358 | - * Gets all the spotter information based on a particular callsign |
|
359 | - * |
|
360 | - * @return Array the spotter information |
|
361 | - * |
|
362 | - */ |
|
357 | + /** |
|
358 | + * Gets all the spotter information based on a particular callsign |
|
359 | + * |
|
360 | + * @return Array the spotter information |
|
361 | + * |
|
362 | + */ |
|
363 | 363 | public function getLastLiveTrackerDataByIdent($ident) |
364 | 364 | { |
365 | 365 | $Tracker = new Tracker($this->db); |
366 | 366 | date_default_timezone_set('UTC'); |
367 | 367 | |
368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
370 | 370 | |
371 | 371 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
372 | 372 | |
373 | 373 | return $spotter_array; |
374 | 374 | } |
375 | 375 | |
376 | - /** |
|
377 | - * Gets all the spotter information based on a particular callsign |
|
378 | - * |
|
379 | - * @return Array the spotter information |
|
380 | - * |
|
381 | - */ |
|
376 | + /** |
|
377 | + * Gets all the spotter information based on a particular callsign |
|
378 | + * |
|
379 | + * @return Array the spotter information |
|
380 | + * |
|
381 | + */ |
|
382 | 382 | public function getDateLiveTrackerDataByIdent($ident,$date) |
383 | 383 | { |
384 | 384 | $Tracker = new Tracker($this->db); |
385 | 385 | date_default_timezone_set('UTC'); |
386 | 386 | |
387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
389 | 389 | |
390 | - $date = date('c',$date); |
|
390 | + $date = date('c',$date); |
|
391 | 391 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
392 | 392 | |
393 | 393 | return $spotter_array; |
394 | 394 | } |
395 | 395 | |
396 | - /** |
|
397 | - * Gets last spotter information based on a particular callsign |
|
398 | - * |
|
399 | - * @return Array the spotter information |
|
400 | - * |
|
401 | - */ |
|
396 | + /** |
|
397 | + * Gets last spotter information based on a particular callsign |
|
398 | + * |
|
399 | + * @return Array the spotter information |
|
400 | + * |
|
401 | + */ |
|
402 | 402 | public function getLastLiveTrackerDataById($id) |
403 | 403 | { |
404 | 404 | $Tracker = new Tracker($this->db); |
405 | 405 | date_default_timezone_set('UTC'); |
406 | 406 | |
407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
409 | 409 | |
410 | 410 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
411 | 411 | |
412 | 412 | return $spotter_array; |
413 | 413 | } |
414 | 414 | |
415 | - /** |
|
416 | - * Gets last spotter information based on a particular callsign |
|
417 | - * |
|
418 | - * @return Array the spotter information |
|
419 | - * |
|
420 | - */ |
|
415 | + /** |
|
416 | + * Gets last spotter information based on a particular callsign |
|
417 | + * |
|
418 | + * @return Array the spotter information |
|
419 | + * |
|
420 | + */ |
|
421 | 421 | public function getDateLiveTrackerDataById($id,$date) |
422 | 422 | { |
423 | 423 | $Tracker = new Tracker($this->db); |
424 | 424 | date_default_timezone_set('UTC'); |
425 | 425 | |
426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | - $date = date('c',$date); |
|
427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | + $date = date('c',$date); |
|
429 | 429 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
430 | 430 | |
431 | 431 | return $spotter_array; |
432 | 432 | } |
433 | 433 | |
434 | - /** |
|
435 | - * Gets altitude information based on a particular callsign |
|
436 | - * |
|
437 | - * @return Array the spotter information |
|
438 | - * |
|
439 | - */ |
|
434 | + /** |
|
435 | + * Gets altitude information based on a particular callsign |
|
436 | + * |
|
437 | + * @return Array the spotter information |
|
438 | + * |
|
439 | + */ |
|
440 | 440 | public function getAltitudeLiveTrackerDataByIdent($ident) |
441 | 441 | { |
442 | 442 | |
443 | 443 | date_default_timezone_set('UTC'); |
444 | 444 | |
445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
447 | 447 | |
448 | - try { |
|
448 | + try { |
|
449 | 449 | |
450 | 450 | $sth = $this->db->prepare($query); |
451 | 451 | $sth->execute(array(':ident' => $ident)); |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | return $spotter_array; |
459 | 459 | } |
460 | 460 | |
461 | - /** |
|
462 | - * Gets all the spotter information based on a particular id |
|
463 | - * |
|
464 | - * @return Array the spotter information |
|
465 | - * |
|
466 | - */ |
|
461 | + /** |
|
462 | + * Gets all the spotter information based on a particular id |
|
463 | + * |
|
464 | + * @return Array the spotter information |
|
465 | + * |
|
466 | + */ |
|
467 | 467 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
468 | 468 | { |
469 | 469 | global $globalDBdriver, $globalLiveInterval; |
@@ -491,18 +491,18 @@ discard block |
||
491 | 491 | return $spotter_array; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Gets all the spotter information based on a particular ident |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
494 | + /** |
|
495 | + * Gets all the spotter information based on a particular ident |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | 500 | public function getAllLiveTrackerDataByIdent($ident) |
501 | 501 | { |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
504 | 504 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
505 | - try { |
|
505 | + try { |
|
506 | 506 | |
507 | 507 | $sth = $this->db->prepare($query); |
508 | 508 | $sth->execute(array(':ident' => $ident)); |
@@ -516,23 +516,23 @@ discard block |
||
516 | 516 | |
517 | 517 | |
518 | 518 | /** |
519 | - * Deletes all info in the table |
|
520 | - * |
|
521 | - * @return String success or false |
|
522 | - * |
|
523 | - */ |
|
519 | + * Deletes all info in the table |
|
520 | + * |
|
521 | + * @return String success or false |
|
522 | + * |
|
523 | + */ |
|
524 | 524 | public function deleteLiveTrackerData() |
525 | 525 | { |
526 | 526 | global $globalDBdriver; |
527 | 527 | if ($globalDBdriver == 'mysql') { |
528 | 528 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
529 | 529 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
530 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
530 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
531 | 531 | } else { |
532 | 532 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
533 | 533 | } |
534 | 534 | |
535 | - try { |
|
535 | + try { |
|
536 | 536 | |
537 | 537 | $sth = $this->db->prepare($query); |
538 | 538 | $sth->execute(); |
@@ -544,18 +544,18 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
547 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
548 | - * |
|
549 | - * @return String success or false |
|
550 | - * |
|
551 | - */ |
|
547 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
548 | + * |
|
549 | + * @return String success or false |
|
550 | + * |
|
551 | + */ |
|
552 | 552 | public function deleteLiveTrackerDataNotUpdated() |
553 | 553 | { |
554 | 554 | global $globalDBdriver, $globalDebug; |
555 | 555 | if ($globalDBdriver == 'mysql') { |
556 | 556 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
557 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
558 | - try { |
|
557 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
558 | + try { |
|
559 | 559 | |
560 | 560 | $sth = $this->db->prepare($query); |
561 | 561 | $sth->execute(); |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | return "error"; |
564 | 564 | } |
565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
566 | - $i = 0; |
|
567 | - $j =0; |
|
566 | + $i = 0; |
|
567 | + $j =0; |
|
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | 569 | foreach($all as $row) |
570 | 570 | { |
@@ -572,20 +572,20 @@ discard block |
||
572 | 572 | $j++; |
573 | 573 | if ($j == 30) { |
574 | 574 | if ($globalDebug) echo "."; |
575 | - try { |
|
575 | + try { |
|
576 | 576 | |
577 | 577 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
578 | 578 | $sth->execute(); |
579 | 579 | } catch(PDOException $e) { |
580 | 580 | return "error"; |
581 | 581 | } |
582 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
583 | - $j = 0; |
|
582 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
583 | + $j = 0; |
|
584 | 584 | } |
585 | 585 | $query_delete .= "'".$row['famtrackid']."',"; |
586 | 586 | } |
587 | 587 | if ($i > 0) { |
588 | - try { |
|
588 | + try { |
|
589 | 589 | |
590 | 590 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
591 | 591 | $sth->execute(); |
@@ -596,9 +596,9 @@ discard block |
||
596 | 596 | return "success"; |
597 | 597 | } elseif ($globalDBdriver == 'pgsql') { |
598 | 598 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
599 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
600 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
601 | - try { |
|
599 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
600 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
601 | + try { |
|
602 | 602 | |
603 | 603 | $sth = $this->db->prepare($query); |
604 | 604 | $sth->execute(); |
@@ -642,17 +642,17 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
645 | - * Deletes all info in the table for an ident |
|
646 | - * |
|
647 | - * @return String success or false |
|
648 | - * |
|
649 | - */ |
|
645 | + * Deletes all info in the table for an ident |
|
646 | + * |
|
647 | + * @return String success or false |
|
648 | + * |
|
649 | + */ |
|
650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
651 | 651 | { |
652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
653 | 653 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
654 | 654 | |
655 | - try { |
|
655 | + try { |
|
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(array(':ident' => $ident)); |
@@ -664,17 +664,17 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
667 | - * Deletes all info in the table for an id |
|
668 | - * |
|
669 | - * @return String success or false |
|
670 | - * |
|
671 | - */ |
|
667 | + * Deletes all info in the table for an id |
|
668 | + * |
|
669 | + * @return String success or false |
|
670 | + * |
|
671 | + */ |
|
672 | 672 | public function deleteLiveTrackerDataById($id) |
673 | 673 | { |
674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
675 | 675 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
676 | 676 | |
677 | - try { |
|
677 | + try { |
|
678 | 678 | |
679 | 679 | $sth = $this->db->prepare($query); |
680 | 680 | $sth->execute(array(':id' => $id)); |
@@ -687,11 +687,11 @@ discard block |
||
687 | 687 | |
688 | 688 | |
689 | 689 | /** |
690 | - * Gets the aircraft ident within the last hour |
|
691 | - * |
|
692 | - * @return String the ident |
|
693 | - * |
|
694 | - */ |
|
690 | + * Gets the aircraft ident within the last hour |
|
691 | + * |
|
692 | + * @return String the ident |
|
693 | + * |
|
694 | + */ |
|
695 | 695 | public function getIdentFromLastHour($ident) |
696 | 696 | { |
697 | 697 | global $globalDBdriver, $globalTimezone; |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | $ident_result = $row['ident']; |
718 | 718 | } |
719 | 719 | return $ident_result; |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | 722 | /** |
723 | - * Check recent aircraft |
|
724 | - * |
|
725 | - * @return String the ident |
|
726 | - * |
|
727 | - */ |
|
723 | + * Check recent aircraft |
|
724 | + * |
|
725 | + * @return String the ident |
|
726 | + * |
|
727 | + */ |
|
728 | 728 | public function checkIdentRecent($ident) |
729 | 729 | { |
730 | 730 | global $globalDBdriver, $globalTimezone; |
@@ -750,14 +750,14 @@ discard block |
||
750 | 750 | $ident_result = $row['famtrackid']; |
751 | 751 | } |
752 | 752 | return $ident_result; |
753 | - } |
|
753 | + } |
|
754 | 754 | |
755 | 755 | /** |
756 | - * Check recent aircraft by id |
|
757 | - * |
|
758 | - * @return String the ident |
|
759 | - * |
|
760 | - */ |
|
756 | + * Check recent aircraft by id |
|
757 | + * |
|
758 | + * @return String the ident |
|
759 | + * |
|
760 | + */ |
|
761 | 761 | public function checkIdRecent($id) |
762 | 762 | { |
763 | 763 | global $globalDBdriver, $globalTimezone; |
@@ -783,19 +783,19 @@ discard block |
||
783 | 783 | $ident_result = $row['famtrackid']; |
784 | 784 | } |
785 | 785 | return $ident_result; |
786 | - } |
|
786 | + } |
|
787 | 787 | |
788 | 788 | /** |
789 | - * Adds a new spotter data |
|
790 | - * |
|
791 | - * @param String $famtrackid the ID from flightaware |
|
792 | - * @param String $ident the flight ident |
|
793 | - * @param String $aircraft_icao the aircraft type |
|
794 | - * @param String $departure_airport_icao the departure airport |
|
795 | - * @param String $arrival_airport_icao the arrival airport |
|
796 | - * @return String success or false |
|
797 | - * |
|
798 | - */ |
|
789 | + * Adds a new spotter data |
|
790 | + * |
|
791 | + * @param String $famtrackid the ID from flightaware |
|
792 | + * @param String $ident the flight ident |
|
793 | + * @param String $aircraft_icao the aircraft type |
|
794 | + * @param String $departure_airport_icao the departure airport |
|
795 | + * @param String $arrival_airport_icao the arrival airport |
|
796 | + * @return String success or false |
|
797 | + * |
|
798 | + */ |
|
799 | 799 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
800 | 800 | { |
801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
869 | 869 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
870 | 870 | |
871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
873 | 873 | |
874 | 874 | $query = ''; |
875 | 875 | if ($globalArchive) { |
@@ -884,16 +884,16 @@ discard block |
||
884 | 884 | |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_values); |
887 | - } catch(PDOException $e) { |
|
888 | - return "error : ".$e->getMessage(); |
|
889 | - } |
|
890 | - echo 'putinarchive : '.$putinarchive."\n"; |
|
891 | - echo 'noarchive : '.$noarchive."\n"; |
|
887 | + } catch(PDOException $e) { |
|
888 | + return "error : ".$e->getMessage(); |
|
889 | + } |
|
890 | + echo 'putinarchive : '.$putinarchive."\n"; |
|
891 | + echo 'noarchive : '.$noarchive."\n"; |
|
892 | 892 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
893 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
894 | - $TrackerArchive = new TrackerArchive($this->db); |
|
895 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
896 | - if ($globalDebug) echo $result.')'; |
|
893 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
894 | + $TrackerArchive = new TrackerArchive($this->db); |
|
895 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
896 | + if ($globalDebug) echo $result.')'; |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | return "success"; |
@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | <footer class="container"> |
4 | 4 | <?php |
5 | - if (isset($sql_time)) { |
|
5 | + if (isset($sql_time)) { |
|
6 | 6 | ?> |
7 | 7 | <i><?php echo _("Page generated in").' '.round($sql_time+$page_time,2); ?>s (<?php print round($page_time,2); ?>ms PHP - <?php print round($sql_time,2); ?>ms SQL)</i> |
8 | 8 | <br /> |
9 | 9 | <?php |
10 | - } |
|
10 | + } |
|
11 | 11 | ?> |
12 | 12 | <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source & Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span> |
13 | 13 | </footer> |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | require_once(dirname(__FILE__).'/class.Source.php'); |
8 | 8 | |
9 | 9 | class TrackerImport { |
10 | - private $all_tracked = array(); |
|
11 | - private $last_delete_hourly = 0; |
|
12 | - private $last_delete = 0; |
|
13 | - private $stats = array(); |
|
14 | - private $tmd = 0; |
|
15 | - private $source_location = array(); |
|
16 | - public $db = null; |
|
17 | - public $nb = 0; |
|
10 | + private $all_tracked = array(); |
|
11 | + private $last_delete_hourly = 0; |
|
12 | + private $last_delete = 0; |
|
13 | + private $stats = array(); |
|
14 | + private $tmd = 0; |
|
15 | + private $source_location = array(); |
|
16 | + public $db = null; |
|
17 | + public $nb = 0; |
|
18 | 18 | |
19 | - public function __construct($dbc = null) { |
|
19 | + public function __construct($dbc = null) { |
|
20 | 20 | global $globalBeta; |
21 | 21 | $Connection = new Connection($dbc); |
22 | 22 | $this->db = $Connection->db(); |
@@ -38,50 +38,50 @@ discard block |
||
38 | 38 | } |
39 | 39 | } |
40 | 40 | */ |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - public function checkAll() { |
|
43 | + public function checkAll() { |
|
44 | 44 | global $globalDebug; |
45 | 45 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
46 | 46 | foreach ($this->all_tracked as $key => $flight) { |
47 | - if (isset($this->all_tracked[$key]['id'])) { |
|
47 | + if (isset($this->all_tracked[$key]['id'])) { |
|
48 | 48 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
49 | - $Tracker = new Tracker($this->db); |
|
50 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | - } |
|
49 | + $Tracker = new Tracker($this->db); |
|
50 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
51 | + } |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | |
55 | - public function del() { |
|
55 | + public function del() { |
|
56 | 56 | global $globalDebug; |
57 | 57 | // Delete old infos |
58 | 58 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
59 | 59 | foreach ($this->all_tracked as $key => $flight) { |
60 | - if (isset($flight['lastupdate'])) { |
|
61 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | - if (isset($this->all_tracked[$key]['id'])) { |
|
63 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
60 | + if (isset($flight['lastupdate'])) { |
|
61 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
62 | + if (isset($this->all_tracked[$key]['id'])) { |
|
63 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
64 | 64 | /* |
65 | 65 | $TrackerLive = new TrackerLive(); |
66 | 66 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
67 | 67 | $TrackerLive->db = null; |
68 | 68 | */ |
69 | - //$real_arrival = $this->arrival($key); |
|
70 | - $Tracker = new Tracker($this->db); |
|
71 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
69 | + //$real_arrival = $this->arrival($key); |
|
70 | + $Tracker = new Tracker($this->db); |
|
71 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
72 | 72 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
73 | 73 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
74 | 74 | } |
75 | 75 | // Put in archive |
76 | 76 | // $Tracker->db = null; |
77 | - } |
|
78 | - unset($this->all_tracked[$key]); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
77 | + } |
|
78 | + unset($this->all_tracked[$key]); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - public function add($line) { |
|
84 | + public function add($line) { |
|
85 | 85 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
86 | 86 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
87 | 87 | date_default_timezone_set('UTC'); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | |
91 | 91 | // SBS format is CSV format |
92 | 92 | if(is_array($line) && isset($line['ident'])) { |
93 | - //print_r($line); |
|
94 | - if (isset($line['ident'])) { |
|
93 | + //print_r($line); |
|
94 | + if (isset($line['ident'])) { |
|
95 | 95 | |
96 | 96 | /* |
97 | 97 | // Increment message number |
@@ -107,29 +107,29 @@ discard block |
||
107 | 107 | */ |
108 | 108 | |
109 | 109 | $Common = new Common(); |
110 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
111 | - else $id = trim($line['id']); |
|
110 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
111 | + else $id = trim($line['id']); |
|
112 | 112 | |
113 | 113 | if (!isset($this->all_tracked[$id])) { |
114 | - $this->all_tracked[$id] = array(); |
|
115 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
116 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
118 | - if (!isset($line['id'])) { |
|
114 | + $this->all_tracked[$id] = array(); |
|
115 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
116 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
118 | + if (!isset($line['id'])) { |
|
119 | 119 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
120 | 120 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
121 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
122 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
121 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
122 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
126 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
126 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
127 | 127 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
128 | - } else { |
|
128 | + } else { |
|
129 | 129 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
130 | 130 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
131 | 131 | return ''; |
132 | - } |
|
132 | + } |
|
133 | 133 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
134 | 134 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!"; |
135 | 135 | return ''; |
@@ -146,38 +146,38 @@ discard block |
||
146 | 146 | |
147 | 147 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
148 | 148 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
149 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
150 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
149 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
150 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
151 | 151 | $timeelapsed = microtime(true); |
152 | - $Tracker = new Tracker($this->db); |
|
153 | - $fromsource = NULL; |
|
154 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
152 | + $Tracker = new Tracker($this->db); |
|
153 | + $fromsource = NULL; |
|
154 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
155 | 155 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
156 | 156 | $Tracker->db = null; |
157 | 157 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
158 | - } |
|
159 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
158 | + } |
|
159 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | if (isset($line['speed']) && $line['speed'] != '') { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
165 | 165 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
166 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
167 | - if ($distance > 100 && $distance < 10000) { |
|
166 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
167 | + if ($distance > 100 && $distance < 10000) { |
|
168 | 168 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
169 | 169 | $speed = $speed*3.6; |
170 | 170 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
171 | 171 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
172 | - } |
|
172 | + } |
|
173 | 173 | } |
174 | 174 | |
175 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
176 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
177 | - else unset($timediff); |
|
178 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
175 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
176 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
177 | + else unset($timediff); |
|
178 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
179 | 179 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
180 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
180 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
181 | 181 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
182 | 182 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
183 | 183 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -191,120 +191,120 @@ discard block |
||
191 | 191 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
192 | 192 | $this->tmd = 0; |
193 | 193 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
194 | - } |
|
194 | + } |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
198 | 198 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
199 | 199 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
200 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
201 | - $dataFound = true; |
|
202 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
200 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
201 | + $dataFound = true; |
|
202 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
203 | 203 | } |
204 | 204 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
205 | 205 | } |
206 | 206 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
207 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
207 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
208 | 208 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
209 | 209 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
210 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
211 | - $dataFound = true; |
|
212 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
210 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
211 | + $dataFound = true; |
|
212 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
213 | 213 | } |
214 | 214 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
215 | 215 | } |
216 | 216 | |
217 | - } else if ($globalDebug && $timediff > 20) { |
|
217 | + } else if ($globalDebug && $timediff > 20) { |
|
218 | 218 | $this->tmd = $this->tmd + 1; |
219 | 219 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
220 | 220 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
221 | 221 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
222 | 222 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
223 | - } |
|
223 | + } |
|
224 | 224 | } |
225 | 225 | if (isset($line['last_update']) && $line['last_update'] != '') { |
226 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
227 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
226 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
227 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
228 | 228 | } |
229 | 229 | if (isset($line['format_source']) && $line['format_source'] != '') { |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['source_name']) && $line['source_name'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['comment']) && $line['comment'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
237 | - //$dataFound = true; |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
237 | + //$dataFound = true; |
|
238 | 238 | } |
239 | 239 | if (isset($line['type']) && $line['type'] != '') { |
240 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
241 | - //$dataFound = true; |
|
240 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
241 | + //$dataFound = true; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | if (isset($line['altitude']) && $line['altitude'] != '') { |
245 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
245 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
246 | 246 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
247 | 247 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
248 | 248 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
249 | 249 | //$dataFound = true; |
250 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
250 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | if (isset($line['heading']) && $line['heading'] != '') { |
258 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
261 | - //$dataFound = true; |
|
258 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
261 | + //$dataFound = true; |
|
262 | 262 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
263 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
264 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
265 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
263 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
264 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
265 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
267 | 267 | } |
268 | 268 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
269 | 269 | |
270 | 270 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
271 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
272 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
273 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
274 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
271 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
272 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
273 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
274 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
275 | 275 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
276 | 276 | $timeelapsed = microtime(true); |
277 | 277 | $TrackerLive = new TrackerLive($this->db); |
278 | 278 | if (isset($line['id'])) { |
279 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
280 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
279 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
280 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
281 | 281 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
282 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
282 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
284 | 284 | } else $recent_ident = ''; |
285 | 285 | $TrackerLive->db=null; |
286 | 286 | |
287 | 287 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
288 | 288 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
289 | - } else { |
|
289 | + } else { |
|
290 | 290 | $recent_ident = ''; |
291 | 291 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
292 | - } |
|
293 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
294 | - if($recent_ident == "") |
|
295 | - { |
|
292 | + } |
|
293 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
294 | + if($recent_ident == "") |
|
295 | + { |
|
296 | 296 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
297 | 297 | //adds the spotter data for the archive |
298 | - $highlight = ''; |
|
299 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
300 | - $timeelapsed = microtime(true); |
|
301 | - $Tracker = new Tracker($this->db); |
|
302 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
303 | - $Tracker->db = null; |
|
304 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
305 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
298 | + $highlight = ''; |
|
299 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
300 | + $timeelapsed = microtime(true); |
|
301 | + $Tracker = new Tracker($this->db); |
|
302 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
303 | + $Tracker->db = null; |
|
304 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
305 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
306 | 306 | |
307 | - /* |
|
307 | + /* |
|
308 | 308 | // Add source stat in DB |
309 | 309 | $Stats = new Stats($this->db); |
310 | 310 | if (!empty($this->stats)) { |
@@ -331,20 +331,20 @@ discard block |
||
331 | 331 | } |
332 | 332 | $Stats->db = null; |
333 | 333 | */ |
334 | - $this->del(); |
|
334 | + $this->del(); |
|
335 | 335 | //$ignoreImport = false; |
336 | 336 | $this->all_tracked[$id]['addedTracker'] = 1; |
337 | 337 | //print_r($this->all_tracked[$id]); |
338 | 338 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
339 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
340 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
341 | - $TrackerLive = new TrackerLive($this->db); |
|
342 | - $TrackerLive->deleteLiveTrackerData(); |
|
343 | - $TrackerLive->db=null; |
|
344 | - if ($globalDebug) echo " Done\n"; |
|
345 | - $this->last_delete = time(); |
|
339 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
340 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
341 | + $TrackerLive = new TrackerLive($this->db); |
|
342 | + $TrackerLive->deleteLiveTrackerData(); |
|
343 | + $TrackerLive->db=null; |
|
344 | + if ($globalDebug) echo " Done\n"; |
|
345 | + $this->last_delete = time(); |
|
346 | 346 | } |
347 | - } else { |
|
347 | + } else { |
|
348 | 348 | $this->all_tracked[$id]['id'] = $recent_ident; |
349 | 349 | $this->all_tracked[$id]['addedTracker'] = 1; |
350 | 350 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -353,16 +353,16 @@ discard block |
||
353 | 353 | $Tracker->db = null; |
354 | 354 | } |
355 | 355 | |
356 | - } |
|
356 | + } |
|
357 | + } |
|
357 | 358 | } |
358 | - } |
|
359 | - //adds the spotter LIVE data |
|
360 | - if ($globalDebug) { |
|
359 | + //adds the spotter LIVE data |
|
360 | + if ($globalDebug) { |
|
361 | 361 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
362 | - } |
|
363 | - $ignoreImport = false; |
|
362 | + } |
|
363 | + $ignoreImport = false; |
|
364 | 364 | |
365 | - if (!$ignoreImport) { |
|
365 | + if (!$ignoreImport) { |
|
366 | 366 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
367 | 367 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
368 | 368 | $timeelapsed = microtime(true); |
@@ -434,22 +434,22 @@ discard block |
||
434 | 434 | |
435 | 435 | |
436 | 436 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
437 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
438 | - $TrackerLive = new TrackerLive($this->db); |
|
439 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
440 | - $TrackerLive->db = null; |
|
441 | - //TrackerLive->deleteLiveTrackerData(); |
|
442 | - if ($globalDebug) echo " Done\n"; |
|
443 | - $this->last_delete_hourly = time(); |
|
437 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
438 | + $TrackerLive = new TrackerLive($this->db); |
|
439 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
440 | + $TrackerLive->db = null; |
|
441 | + //TrackerLive->deleteLiveTrackerData(); |
|
442 | + if ($globalDebug) echo " Done\n"; |
|
443 | + $this->last_delete_hourly = time(); |
|
444 | 444 | } |
445 | 445 | |
446 | - } |
|
447 | - //$ignoreImport = false; |
|
446 | + } |
|
447 | + //$ignoreImport = false; |
|
448 | 448 | } |
449 | 449 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
450 | 450 | if ($send) return $this->all_tracked[$id]; |
451 | - } |
|
451 | + } |
|
452 | + } |
|
452 | 453 | } |
453 | - } |
|
454 | 454 | } |
455 | 455 | ?> |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('!' => 'Police', |
|
8 | + protected $symbols = array('!' => 'Police', |
|
9 | 9 | '#' => 'DIGI', |
10 | 10 | '$' => 'Phone', |
11 | 11 | '%' => 'DX Cluster', |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | 'y' => 'Yagi At QTH'); |
90 | 90 | |
91 | 91 | |
92 | - private function urshift($n, $s) { |
|
92 | + private function urshift($n, $s) { |
|
93 | 93 | return ($n >= 0) ? ($n >> $s) : |
94 | - (($n & 0x7fffffff) >> $s) | |
|
94 | + (($n & 0x7fffffff) >> $s) | |
|
95 | 95 | (0x40000000 >> ($s - 1)); |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - public function parse($input) { |
|
98 | + public function parse($input) { |
|
99 | 99 | global $globalDebug; |
100 | 100 | $debug = false; |
101 | 101 | $result = array(); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | - return false; |
|
110 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | + return false; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($debug) echo 'input : '.$input."\n"; |
@@ -122,31 +122,31 @@ discard block |
||
122 | 122 | /* Parse source, target and path. */ |
123 | 123 | //FLRDF0A52>APRS,qAS,LSTB |
124 | 124 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
125 | - $ident = $matches[1]; |
|
126 | - $all_elements = $matches[2]; |
|
127 | - if ($ident == 'AIRCRAFT') { |
|
125 | + $ident = $matches[1]; |
|
126 | + $all_elements = $matches[2]; |
|
127 | + if ($ident == 'AIRCRAFT') { |
|
128 | 128 | $result['format_source'] = 'famaprs'; |
129 | 129 | $result['source_type'] = 'modes'; |
130 | - } elseif ($ident == 'MARINE') { |
|
130 | + } elseif ($ident == 'MARINE') { |
|
131 | 131 | $result['format_source'] = 'famaprs'; |
132 | 132 | $result['source_type'] = 'ais'; |
133 | - } else { |
|
133 | + } else { |
|
134 | 134 | if ($debug) echo 'ident : '.$ident."\n"; |
135 | 135 | $result['ident'] = $ident; |
136 | - } |
|
136 | + } |
|
137 | 137 | } else return false; |
138 | 138 | $elements = explode(',',$all_elements); |
139 | 139 | $source = end($elements); |
140 | 140 | $result['source'] = $source; |
141 | 141 | foreach ($elements as $element) { |
142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | - //echo "ok"; |
|
144 | - //if ($element == 'TCPIP*') return false; |
|
145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
142 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | + //echo "ok"; |
|
144 | + //if ($element == 'TCPIP*') return false; |
|
145 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
146 | 146 | if ($debug) echo 'element : '.$element."\n"; |
147 | 147 | return false; |
148 | - } |
|
149 | - /* |
|
148 | + } |
|
149 | + /* |
|
150 | 150 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
151 | 151 | //echo "ok"; |
152 | 152 | } else { |
@@ -173,49 +173,49 @@ discard block |
||
173 | 173 | $body_parse = substr($body,1); |
174 | 174 | //echo 'Body : '.$body."\n"; |
175 | 175 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
176 | - $body_parse = substr($body_parse,10); |
|
177 | - $find = true; |
|
178 | - //echo $body_parse."\n"; |
|
176 | + $body_parse = substr($body_parse,10); |
|
177 | + $find = true; |
|
178 | + //echo $body_parse."\n"; |
|
179 | 179 | } |
180 | 180 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
181 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
182 | - $find = true; |
|
183 | - //echo $body_parse."\n"; |
|
181 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
182 | + $find = true; |
|
183 | + //echo $body_parse."\n"; |
|
184 | 184 | } |
185 | 185 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
186 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
187 | - $find = true; |
|
188 | - //echo $body_parse."\n"; |
|
186 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
187 | + $find = true; |
|
188 | + //echo $body_parse."\n"; |
|
189 | 189 | } |
190 | 190 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
191 | - $find = true; |
|
192 | - //print_r($matches); |
|
193 | - $timestamp = $matches[0]; |
|
194 | - if ($matches[4] == 'h') { |
|
191 | + $find = true; |
|
192 | + //print_r($matches); |
|
193 | + $timestamp = $matches[0]; |
|
194 | + if ($matches[4] == 'h') { |
|
195 | 195 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
196 | 196 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
197 | 197 | /* |
198 | 198 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
199 | 199 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
200 | 200 | */ |
201 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
201 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
202 | 202 | // This work or not ? |
203 | 203 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
204 | - } |
|
205 | - $body_parse = substr($body_parse,7); |
|
206 | - $result['timestamp'] = $timestamp; |
|
207 | - //echo date('Ymd H:i:s',$timestamp); |
|
204 | + } |
|
205 | + $body_parse = substr($body_parse,7); |
|
206 | + $result['timestamp'] = $timestamp; |
|
207 | + //echo date('Ymd H:i:s',$timestamp); |
|
208 | 208 | } |
209 | 209 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
210 | - $find = true; |
|
211 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
212 | - $body_parse = substr($body_parse,8); |
|
213 | - $result['timestamp'] = $timestamp; |
|
214 | - //echo date('Ymd H:i:s',$timestamp); |
|
210 | + $find = true; |
|
211 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
212 | + $body_parse = substr($body_parse,8); |
|
213 | + $result['timestamp'] = $timestamp; |
|
214 | + //echo date('Ymd H:i:s',$timestamp); |
|
215 | 215 | } |
216 | 216 | //if (strlen($body_parse) > 19) { |
217 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
218 | - $find = true; |
|
217 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
218 | + $find = true; |
|
219 | 219 | // 4658.70N/00707.78Ez |
220 | 220 | //print_r(str_split($body_parse)); |
221 | 221 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $lon = intval($lon_deg); |
233 | 233 | if ($lat > 89 || $lon > 179) return false; |
234 | 234 | |
235 | - /* |
|
235 | + /* |
|
236 | 236 | $tmp_5b = str_replace('.','',$lat_min); |
237 | 237 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
238 | 238 | print_r($matches); |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | $result['longitude'] = $longitude; |
247 | 247 | $body_parse = substr($body_parse,18); |
248 | 248 | $body_parse_len = strlen($body_parse); |
249 | - } |
|
250 | - $body_parse_len = strlen($body_parse); |
|
251 | - if ($body_parse_len > 0) { |
|
249 | + } |
|
250 | + $body_parse_len = strlen($body_parse); |
|
251 | + if ($body_parse_len > 0) { |
|
252 | 252 | /* |
253 | 253 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
254 | 254 | $body_split = str_split($body); |
@@ -278,95 +278,95 @@ discard block |
||
278 | 278 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
279 | 279 | if ($symbol_code != '_') { |
280 | 280 | } |
281 | - //$body_parse = substr($body_parse,1); |
|
282 | - //$body_parse = trim($body_parse); |
|
283 | - //$body_parse_len = strlen($body_parse); |
|
284 | - if ($body_parse_len >= 7) { |
|
281 | + //$body_parse = substr($body_parse,1); |
|
282 | + //$body_parse = trim($body_parse); |
|
283 | + //$body_parse_len = strlen($body_parse); |
|
284 | + if ($body_parse_len >= 7) { |
|
285 | 285 | |
286 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
287 | - $course = substr($body_parse,0,3); |
|
288 | - $tmp_s = intval($course); |
|
289 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
290 | - $speed = substr($body_parse,4,3); |
|
291 | - if ($speed != '...') { |
|
292 | - //$result['speed'] = round($speed*1.852); |
|
293 | - $result['speed'] = intval($speed); |
|
294 | - } |
|
295 | - $body_parse = substr($body_parse,7); |
|
296 | - } |
|
297 | - // Check PHGR, PHG, RNG |
|
298 | - } |
|
299 | - /* |
|
286 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
287 | + $course = substr($body_parse,0,3); |
|
288 | + $tmp_s = intval($course); |
|
289 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
290 | + $speed = substr($body_parse,4,3); |
|
291 | + if ($speed != '...') { |
|
292 | + //$result['speed'] = round($speed*1.852); |
|
293 | + $result['speed'] = intval($speed); |
|
294 | + } |
|
295 | + $body_parse = substr($body_parse,7); |
|
296 | + } |
|
297 | + // Check PHGR, PHG, RNG |
|
298 | + } |
|
299 | + /* |
|
300 | 300 | else if ($body_parse_len > 0) { |
301 | 301 | $rest = $body_parse; |
302 | 302 | } |
303 | 303 | */ |
304 | - if (strlen($body_parse) > 0) { |
|
305 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
306 | - $altitude = intval($matches[1]); |
|
307 | - //$result['altitude'] = round($altitude*0.3048); |
|
308 | - $result['altitude'] = $altitude; |
|
309 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
310 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
311 | - } |
|
312 | - } |
|
304 | + if (strlen($body_parse) > 0) { |
|
305 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
306 | + $altitude = intval($matches[1]); |
|
307 | + //$result['altitude'] = round($altitude*0.3048); |
|
308 | + $result['altitude'] = $altitude; |
|
309 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
310 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | - // Telemetry |
|
315 | - /* |
|
314 | + // Telemetry |
|
315 | + /* |
|
316 | 316 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
317 | 317 | // Nothing yet... |
318 | 318 | } |
319 | 319 | */ |
320 | - // DAO |
|
320 | + // DAO |
|
321 | 321 | |
322 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
322 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
323 | 323 | |
324 | - $dao = $matches[1]; |
|
325 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
324 | + $dao = $matches[1]; |
|
325 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
326 | 326 | $dao_split = str_split($dao); |
327 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
328 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
327 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
328 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
329 | 329 | |
330 | 330 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
331 | 331 | else $result['latitude'] += $lat_off; |
332 | 332 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
333 | 333 | else $result['longitude'] += $lon_off; |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | - $body_parse = substr($body_parse,6); |
|
337 | - } |
|
336 | + $body_parse = substr($body_parse,6); |
|
337 | + } |
|
338 | 338 | |
339 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
339 | + if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
340 | 340 | $result['ident'] = str_replace('_',' ',$matches[1]); |
341 | - } |
|
342 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
341 | + } |
|
342 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
343 | 343 | $result['squawk'] = $matches[1]; |
344 | - } |
|
345 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
344 | + } |
|
345 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
346 | 346 | $result['aircraft_icao'] = $matches[1]; |
347 | - } |
|
348 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
347 | + } |
|
348 | + if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
349 | 349 | $result['verticalrate'] = $matches[1]; |
350 | - } |
|
351 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
350 | + } |
|
351 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
352 | 352 | $result['typeid'] = $matches[1]; |
353 | - } |
|
354 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
353 | + } |
|
354 | + if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
355 | 355 | $result['statusid'] = $matches[1]; |
356 | - } |
|
357 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
356 | + } |
|
357 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
358 | 358 | $result['imo'] = $matches[1]; |
359 | - } |
|
360 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
359 | + } |
|
360 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
361 | 361 | $result['arrival_date'] = $matches[1]; |
362 | - } |
|
363 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
362 | + } |
|
363 | + if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
364 | 364 | $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
365 | - } |
|
366 | - // OGN comment |
|
365 | + } |
|
366 | + // OGN comment |
|
367 | 367 | // echo "Before OGN : ".$body_parse."\n"; |
368 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
369 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
368 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
369 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
370 | 370 | $id = $matches[1]; |
371 | 371 | //$mode = substr($id,0,2); |
372 | 372 | $address = substr($id,2); |
@@ -396,53 +396,53 @@ discard block |
||
396 | 396 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
397 | 397 | $result['stealth'] = $stealth; |
398 | 398 | $result['address'] = $address; |
399 | - } |
|
399 | + } |
|
400 | 400 | |
401 | - //Comment |
|
402 | - $result['comment'] = trim($body_parse); |
|
401 | + //Comment |
|
402 | + $result['comment'] = trim($body_parse); |
|
403 | 403 | } else { |
404 | - // parse weather |
|
405 | - //$body_parse = substr($body_parse,1); |
|
406 | - //$body_parse_len = strlen($body_parse); |
|
404 | + // parse weather |
|
405 | + //$body_parse = substr($body_parse,1); |
|
406 | + //$body_parse_len = strlen($body_parse); |
|
407 | 407 | |
408 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
409 | - $result['wind_dir'] = intval($matches[1]); |
|
410 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
411 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
412 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
413 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
414 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
408 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
409 | + $result['wind_dir'] = intval($matches[1]); |
|
410 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
411 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
412 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
413 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
414 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
415 | 415 | $result['wind_dir'] = intval($matches[1]); |
416 | 416 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
417 | 417 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
418 | 418 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
419 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
420 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
419 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
420 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
421 | 421 | $result['wind_dir'] = intval($matches[1]); |
422 | 422 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
423 | 423 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
424 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
425 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
424 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
425 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
426 | 426 | $result['wind_dir'] = intval($matches[1]); |
427 | 427 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
428 | 428 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
429 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
430 | - } |
|
431 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
429 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
430 | + } |
|
431 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
432 | 432 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
433 | - } |
|
433 | + } |
|
434 | 434 | } |
435 | 435 | } else $result['comment'] = trim($body_parse); |
436 | 436 | |
437 | - } |
|
437 | + } |
|
438 | 438 | //} |
439 | 439 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
440 | 440 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
441 | 441 | if ($debug) print_r($result); |
442 | 442 | return $result; |
443 | - } |
|
443 | + } |
|
444 | 444 | |
445 | - public function connect() { |
|
445 | + public function connect() { |
|
446 | 446 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
447 | 447 | $aprs_connect = 0; |
448 | 448 | $aprs_keep = 120; |
@@ -465,32 +465,32 @@ discard block |
||
465 | 465 | $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
466 | 466 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
467 | 467 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
468 | - echo 'APRS user verified !'."\n"; |
|
469 | - $this->connected = true; |
|
470 | - return true; |
|
471 | - break; |
|
468 | + echo 'APRS user verified !'."\n"; |
|
469 | + $this->connected = true; |
|
470 | + return true; |
|
471 | + break; |
|
472 | 472 | } |
473 | 473 | if (time()-$authstart > 5) { |
474 | - echo 'APRS timeout'."\n"; |
|
475 | - break; |
|
474 | + echo 'APRS timeout'."\n"; |
|
475 | + break; |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE); |
479 | 479 | } |
480 | - } |
|
480 | + } |
|
481 | 481 | |
482 | - public function disconnect() { |
|
482 | + public function disconnect() { |
|
483 | 483 | socket_close($this->socket); |
484 | - } |
|
484 | + } |
|
485 | 485 | |
486 | - public function send($data) { |
|
486 | + public function send($data) { |
|
487 | 487 | if ($this->connected === false) $this->connect(); |
488 | 488 | $send = socket_send( $this->socket , $data , strlen($data),0); |
489 | 489 | if ($send === FALSE) { |
490 | 490 | socket_close($this->socket); |
491 | 491 | $this->connect(); |
492 | 492 | } |
493 | - } |
|
493 | + } |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | class APRSSpotter extends APRS { |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class SBS { |
3 | - static $latlon = array(); |
|
3 | + static $latlon = array(); |
|
4 | 4 | |
5 | - public function parse($buffer) { |
|
5 | + public function parse($buffer) { |
|
6 | 6 | // Not yet finished, no CRC checks |
7 | 7 | //echo $buffer."\n"; |
8 | 8 | $data = array(); |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | $bin = gmp_strval( gmp_init($hex,16), 2); |
14 | 14 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
15 | 15 | if (strlen($hex) == 28) { |
16 | - $df = intval(substr($bin,0,5),2); |
|
17 | - //$ca = intval(substr($bin,5,3),2); |
|
18 | - // Only support DF17 for now |
|
19 | - //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
|
20 | - if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
16 | + $df = intval(substr($bin,0,5),2); |
|
17 | + //$ca = intval(substr($bin,5,3),2); |
|
18 | + // Only support DF17 for now |
|
19 | + //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
|
20 | + if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
21 | 21 | $icao = substr($hex,2,6); |
22 | 22 | $data['hex'] = $icao; |
23 | 23 | $tc = intval(substr($bin,32,5),2); |
24 | 24 | if ($tc >= 1 && $tc <= 4) { |
25 | - //callsign |
|
26 | - $csbin = substr($bin,40,56); |
|
27 | - $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
|
28 | - $cs = ''; |
|
29 | - $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
30 | - $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
31 | - $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
32 | - $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
33 | - $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
34 | - $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
35 | - $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
36 | - $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
37 | - $cs = str_replace('_','',$cs); |
|
38 | - $cs = str_replace('#','',$cs); |
|
39 | - $callsign = $cs; |
|
40 | - $data['ident'] = $callsign; |
|
25 | + //callsign |
|
26 | + $csbin = substr($bin,40,56); |
|
27 | + $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
|
28 | + $cs = ''; |
|
29 | + $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
30 | + $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
31 | + $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
32 | + $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
33 | + $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
34 | + $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
35 | + $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
36 | + $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
37 | + $cs = str_replace('_','',$cs); |
|
38 | + $cs = str_replace('#','',$cs); |
|
39 | + $callsign = $cs; |
|
40 | + $data['ident'] = $callsign; |
|
41 | 41 | } elseif ($tc >= 9 && $tc <= 18) { |
42 | - // Check Q-bit |
|
43 | - $q = substr($bin,47,1); |
|
44 | - if ($q) { |
|
42 | + // Check Q-bit |
|
43 | + $q = substr($bin,47,1); |
|
44 | + if ($q) { |
|
45 | 45 | $n = intval(substr($bin,40,7).substr($bin,48,4),2); |
46 | 46 | $alt = $n*25-1000; |
47 | 47 | $data['altitude'] = $alt; |
48 | - } |
|
49 | - // Check odd/even flag |
|
50 | - $oe = substr($bin,53,1); |
|
51 | - //if ($oe) => odd else even |
|
52 | - // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
|
53 | - $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
54 | - $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
55 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
56 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
48 | + } |
|
49 | + // Check odd/even flag |
|
50 | + $oe = substr($bin,53,1); |
|
51 | + //if ($oe) => odd else even |
|
52 | + // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
|
53 | + $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
54 | + $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
55 | + if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
56 | + elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
57 | 57 | $cprlat_odd = $cprlat; |
58 | 58 | $cprlon_odd = $cprlon; |
59 | 59 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -66,53 +66,53 @@ discard block |
||
66 | 66 | if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
67 | 67 | // check latitude zone |
68 | 68 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
69 | - if ($this::$latlon[$icao]['created'] > time()) { |
|
69 | + if ($this::$latlon[$icao]['created'] > time()) { |
|
70 | 70 | $ni = $this->cprN($lat_even,0); |
71 | 71 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
72 | 72 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
73 | 73 | $lat = $lat_even; |
74 | 74 | if ($lon > 180) $lon = $lon -360; |
75 | 75 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
76 | - //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
|
77 | - $data['latitude'] = $lat; |
|
78 | - $data['longitude'] = $lon; |
|
76 | + //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
|
77 | + $data['latitude'] = $lat; |
|
78 | + $data['longitude'] = $lon; |
|
79 | 79 | } |
80 | - } else { |
|
80 | + } else { |
|
81 | 81 | $ni = $this->cprN($lat_odd,1); |
82 | 82 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
83 | 83 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
84 | 84 | $lat = $lat_odd; |
85 | 85 | if ($lon > 180) $lon = $lon -360; |
86 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
87 | - //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
|
88 | - $data['latitude'] = $lat; |
|
89 | - $data['longitude'] = $lon; |
|
87 | + //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
|
88 | + $data['latitude'] = $lat; |
|
89 | + $data['longitude'] = $lon; |
|
90 | + } |
|
90 | 91 | } |
91 | - } |
|
92 | 92 | } else echo "Not cprNL"; |
93 | 93 | unset($this::$latlon[$icao]); |
94 | - } |
|
94 | + } |
|
95 | 95 | } elseif ($tc == 19) { |
96 | - // speed & heading |
|
97 | - $v_ew_dir = intval(substr($bin,45,1)); |
|
98 | - $v_ew = intval(substr($bin,46,10),2); |
|
99 | - $v_ns_dir = intval(substr($bin,56,1)); |
|
100 | - $v_ns = intval(substr($bin,57,10),2); |
|
101 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
102 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
103 | - $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
104 | - $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
105 | - if ($heading <0) $heading = $heading+360; |
|
106 | - $data['speed'] = $speed; |
|
107 | - $data['heading'] = $heading; |
|
96 | + // speed & heading |
|
97 | + $v_ew_dir = intval(substr($bin,45,1)); |
|
98 | + $v_ew = intval(substr($bin,46,10),2); |
|
99 | + $v_ns_dir = intval(substr($bin,56,1)); |
|
100 | + $v_ns = intval(substr($bin,57,10),2); |
|
101 | + if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
102 | + if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
103 | + $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
104 | + $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
105 | + if ($heading <0) $heading = $heading+360; |
|
106 | + $data['speed'] = $speed; |
|
107 | + $data['heading'] = $heading; |
|
108 | + } |
|
108 | 109 | } |
109 | - } |
|
110 | - if (isset($data)) { |
|
110 | + if (isset($data)) { |
|
111 | 111 | //print_r($data); |
112 | 112 | return $data; |
113 | - } |
|
114 | - } |
|
115 | - } |
|
113 | + } |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | 118 | public function cprNL($lat) { |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | if ($lat < 86.53536998) return 3; |
178 | 178 | if ($lat < 87.00000000) return 2; |
179 | 179 | return 1; |
180 | - } |
|
180 | + } |
|
181 | 181 | |
182 | - public function cprN($lat,$isodd) { |
|
182 | + public function cprN($lat,$isodd) { |
|
183 | 183 | $nl = $this->cprNL($lat) - $isodd; |
184 | 184 | if ($nl > 1) return $nl; |
185 | 185 | else return 1; |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | 188 | |
189 | - function parityCheck($msg, $bin) { |
|
189 | + function parityCheck($msg, $bin) { |
|
190 | 190 | $modes_checksum_table = array( |
191 | 191 | 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178, |
192 | 192 | 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14, |
@@ -208,75 +208,75 @@ discard block |
||
208 | 208 | $checksum = intval(substr($msg,22,6),16); |
209 | 209 | |
210 | 210 | for ($j = 0; $j < strlen($bin); $j++) { |
211 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
211 | + if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
212 | 212 | } |
213 | 213 | if ($crc == $checksum) return true; |
214 | 214 | else { |
215 | - //echo "**** CRC ERROR ****\n"; |
|
216 | - return false; |
|
215 | + //echo "**** CRC ERROR ****\n"; |
|
216 | + return false; |
|
217 | + } |
|
217 | 218 | } |
218 | - } |
|
219 | 219 | |
220 | - public function famaprs_to_basestation($data) { |
|
220 | + public function famaprs_to_basestation($data) { |
|
221 | 221 | $result = array(); |
222 | - if (isset($data['ident']) && $data['ident'] != '') { |
|
223 | - $msg = array(); |
|
224 | - $msg['msg_type'] = 'MSG'; |
|
225 | - $msg['transmission_type'] = 1; |
|
226 | - $msg['session_id'] = 5; |
|
227 | - $msg['aircraftid'] = hexdec($data['address']); |
|
228 | - $msg['hex'] = $data['address']; |
|
229 | - $msg['flightid'] = hexdec($data['address']); |
|
230 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
231 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
232 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
233 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
234 | - $msg['callsign'] = $data['ident']; |
|
235 | - $msg['altitude'] = ''; |
|
236 | - $msg['speed'] = ''; |
|
237 | - $msg['track'] = ''; |
|
238 | - $msg['latitude'] = ''; |
|
239 | - $msg['longitude'] = ''; |
|
240 | - $msg['verticalrate'] = ''; |
|
241 | - $msg['squawk'] = ''; |
|
242 | - $msg['alert'] = ''; |
|
243 | - $msg['emergency'] = ''; |
|
244 | - $msg['SPI'] = ''; |
|
245 | - $msg['ground'] = ''; |
|
246 | - $result[] = implode(',',$msg); |
|
247 | - } |
|
248 | - if (isset($data['latitude']) && $data['latitude'] != 0) { |
|
249 | - $msg = array(); |
|
250 | - $msg['msg_type'] = 'MSG'; |
|
251 | - $msg['transmission_type'] = 2; |
|
252 | - $msg['session_id'] = 5; |
|
253 | - $msg['aircraftid'] = hexdec($data['address']); |
|
254 | - $msg['hex'] = $data['address']; |
|
255 | - $msg['flightid'] = hexdec($data['address']); |
|
256 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
257 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
258 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
259 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
260 | - $msg['callsign'] = ''; |
|
261 | - if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
|
262 | - else $msg['altitude'] = ''; |
|
263 | - $msg['speed'] = $data['speed']; |
|
264 | - if (isset($data['heading'])) $msg['track'] = $data['heading']; |
|
265 | - else $msg['track'] = ''; |
|
266 | - $msg['latitude'] = $data['latitude']; |
|
267 | - $msg['longitude'] = $data['longitude']; |
|
268 | - if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate']; |
|
269 | - else $msg['verticalrate'] = ''; |
|
270 | - if (isset($data['squawk'])) $msg['squawk'] = $data['squawk']; |
|
271 | - else $msg['squawk'] = 0; |
|
272 | - $msg['alert'] = 0; |
|
273 | - $msg['emergency'] = 0; |
|
274 | - $msg['SPI'] = 0; |
|
275 | - if (isset($data['ground'])) $msg['ground'] = 1; |
|
276 | - else $msg['ground'] = 0; |
|
277 | - $result[] = implode(',',$msg); |
|
278 | - } |
|
279 | - return $result; |
|
280 | - } |
|
222 | + if (isset($data['ident']) && $data['ident'] != '') { |
|
223 | + $msg = array(); |
|
224 | + $msg['msg_type'] = 'MSG'; |
|
225 | + $msg['transmission_type'] = 1; |
|
226 | + $msg['session_id'] = 5; |
|
227 | + $msg['aircraftid'] = hexdec($data['address']); |
|
228 | + $msg['hex'] = $data['address']; |
|
229 | + $msg['flightid'] = hexdec($data['address']); |
|
230 | + $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
231 | + $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
232 | + $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
233 | + $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
234 | + $msg['callsign'] = $data['ident']; |
|
235 | + $msg['altitude'] = ''; |
|
236 | + $msg['speed'] = ''; |
|
237 | + $msg['track'] = ''; |
|
238 | + $msg['latitude'] = ''; |
|
239 | + $msg['longitude'] = ''; |
|
240 | + $msg['verticalrate'] = ''; |
|
241 | + $msg['squawk'] = ''; |
|
242 | + $msg['alert'] = ''; |
|
243 | + $msg['emergency'] = ''; |
|
244 | + $msg['SPI'] = ''; |
|
245 | + $msg['ground'] = ''; |
|
246 | + $result[] = implode(',',$msg); |
|
247 | + } |
|
248 | + if (isset($data['latitude']) && $data['latitude'] != 0) { |
|
249 | + $msg = array(); |
|
250 | + $msg['msg_type'] = 'MSG'; |
|
251 | + $msg['transmission_type'] = 2; |
|
252 | + $msg['session_id'] = 5; |
|
253 | + $msg['aircraftid'] = hexdec($data['address']); |
|
254 | + $msg['hex'] = $data['address']; |
|
255 | + $msg['flightid'] = hexdec($data['address']); |
|
256 | + $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
257 | + $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
258 | + $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
259 | + $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
260 | + $msg['callsign'] = ''; |
|
261 | + if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
|
262 | + else $msg['altitude'] = ''; |
|
263 | + $msg['speed'] = $data['speed']; |
|
264 | + if (isset($data['heading'])) $msg['track'] = $data['heading']; |
|
265 | + else $msg['track'] = ''; |
|
266 | + $msg['latitude'] = $data['latitude']; |
|
267 | + $msg['longitude'] = $data['longitude']; |
|
268 | + if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate']; |
|
269 | + else $msg['verticalrate'] = ''; |
|
270 | + if (isset($data['squawk'])) $msg['squawk'] = $data['squawk']; |
|
271 | + else $msg['squawk'] = 0; |
|
272 | + $msg['alert'] = 0; |
|
273 | + $msg['emergency'] = 0; |
|
274 | + $msg['SPI'] = 0; |
|
275 | + if (isset($data['ground'])) $msg['ground'] = 1; |
|
276 | + else $msg['ground'] = 0; |
|
277 | + $result[] = implode(',',$msg); |
|
278 | + } |
|
279 | + return $result; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | <?php }; if (isset($globalTracker) && $globalTracker) { ?><td><div id="ibxtracker"><h4><?php echo _("Trackers Detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?> |
41 | 41 | </tr></table></div> |
42 | 42 | <?php |
43 | - if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
43 | + if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) { |
|
44 | 44 | |
45 | 45 | ?> |
46 | 46 | <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script> |
61 | 61 | <?php |
62 | 62 | } |
63 | - } |
|
63 | + } |
|
64 | 64 | ?> |
65 | 65 | <div id="dialog" title="<?php echo _("Session has timed-out"); ?>"> |
66 | 66 | <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p> |
@@ -74,34 +74,34 @@ discard block |
||
74 | 74 | <li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li> |
75 | 75 | <li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li> |
76 | 76 | <?php |
77 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
77 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
78 | 78 | if (isset($globalArchive) && $globalArchive == TRUE) { |
79 | 79 | ?> |
80 | 80 | <li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li> |
81 | 81 | <?php |
82 | 82 | } |
83 | - } |
|
83 | + } |
|
84 | 84 | ?> |
85 | 85 | <li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li> |
86 | 86 | <li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li> |
87 | 87 | <li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li> |
88 | 88 | <?php |
89 | - if (isset($globalMap3D) && $globalMap3D) { |
|
89 | + if (isset($globalMap3D) && $globalMap3D) { |
|
90 | 90 | if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
91 | 91 | ?> |
92 | 92 | <li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li> |
93 | 93 | <?php |
94 | - } else { |
|
95 | - if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
94 | + } else { |
|
95 | + if (isset($globalMapSatellites) && $globalMapSatellites) { |
|
96 | 96 | ?> |
97 | 97 | <li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li> |
98 | 98 | <?php |
99 | - } |
|
99 | + } |
|
100 | 100 | ?> |
101 | 101 | <li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li> |
102 | 102 | <?php |
103 | 103 | } |
104 | - } |
|
104 | + } |
|
105 | 105 | ?> |
106 | 106 | </ul> |
107 | 107 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | ?> |
176 | 176 | </div> |
177 | 177 | <?php |
178 | - if (isset($globalArchive) && $globalArchive == TRUE) { |
|
178 | + if (isset($globalArchive) && $globalArchive == TRUE) { |
|
179 | 179 | ?> |
180 | 180 | <div class="sidebar-pane" id="archive"> |
181 | 181 | <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | </form> |
236 | 236 | </div> |
237 | 237 | <?php |
238 | - } |
|
238 | + } |
|
239 | 239 | ?> |
240 | 240 | <div class="sidebar-pane" id="settings"> |
241 | 241 | <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -246,56 +246,56 @@ discard block |
||
246 | 246 | <?php |
247 | 247 | if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider; |
248 | 248 | else $MapType = $_COOKIE['MapType']; |
249 | - ?> |
|
249 | + ?> |
|
250 | 250 | <?php |
251 | 251 | if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
252 | - ?> |
|
252 | + ?> |
|
253 | 253 | <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option> |
254 | 254 | <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option> |
255 | 255 | <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option> |
256 | 256 | <?php |
257 | 257 | } |
258 | - ?> |
|
258 | + ?> |
|
259 | 259 | <?php |
260 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
261 | - ?> |
|
260 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
261 | + ?> |
|
262 | 262 | <?php |
263 | - if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
264 | - ?> |
|
263 | + if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') { |
|
264 | + ?> |
|
265 | 265 | <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option> |
266 | 266 | <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option> |
267 | 267 | <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option> |
268 | 268 | <?php |
269 | - } |
|
270 | - ?> |
|
269 | + } |
|
270 | + ?> |
|
271 | 271 | <?php |
272 | - if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
273 | - ?> |
|
272 | + if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') { |
|
273 | + ?> |
|
274 | 274 | <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option> |
275 | 275 | <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option> |
276 | 276 | <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option> |
277 | 277 | <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option> |
278 | 278 | <?php |
279 | - } |
|
280 | - ?> |
|
279 | + } |
|
280 | + ?> |
|
281 | 281 | <?php |
282 | - if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
283 | - ?> |
|
282 | + if (isset($globalMapQuestKey) && $globalMapQuestKey != '') { |
|
283 | + ?> |
|
284 | 284 | <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option> |
285 | 285 | <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option> |
286 | 286 | <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option> |
287 | 287 | <?php |
288 | - } |
|
289 | - ?> |
|
288 | + } |
|
289 | + ?> |
|
290 | 290 | <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option> |
291 | 291 | <?php |
292 | 292 | } |
293 | - ?> |
|
293 | + ?> |
|
294 | 294 | <?php |
295 | - if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
295 | + if (isset($globalMapboxToken) && $globalMapboxToken != '') { |
|
296 | 296 | if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default'; |
297 | 297 | else $MapBoxId = $_COOKIE['MapTypeId']; |
298 | - ?> |
|
298 | + ?> |
|
299 | 299 | <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option> |
300 | 300 | <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option> |
301 | 301 | <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option> |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option> |
310 | 310 | <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option> |
311 | 311 | <?php |
312 | - } |
|
313 | - ?> |
|
312 | + } |
|
313 | + ?> |
|
314 | 314 | <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option> |
315 | 315 | </select> |
316 | 316 | </li> |
317 | 317 | <?php |
318 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
318 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
319 | 319 | ?> |
320 | 320 | <li><?php echo _("Type of Terrain:"); ?> |
321 | 321 | <select class="selectpicker" onchange="terrainType(this);"> |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | </select> |
326 | 326 | </li> |
327 | 327 | <?php |
328 | - } |
|
328 | + } |
|
329 | 329 | ?> |
330 | 330 | <?php |
331 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
331 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
332 | 332 | ?> |
333 | 333 | |
334 | 334 | <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li> |
@@ -336,75 +336,75 @@ discard block |
||
336 | 336 | <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li> |
337 | 337 | <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li> |
338 | 338 | <?php |
339 | - } |
|
339 | + } |
|
340 | 340 | ?> |
341 | 341 | <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li> |
342 | 342 | <?php |
343 | - if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
343 | + if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
344 | 344 | ?> |
345 | 345 | <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li> |
346 | 346 | <?php |
347 | - } |
|
348 | - if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
347 | + } |
|
348 | + if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) { |
|
349 | 349 | ?> |
350 | 350 | <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li> |
351 | 351 | <?php |
352 | - } |
|
352 | + } |
|
353 | 353 | ?> |
354 | 354 | |
355 | 355 | <?php |
356 | 356 | if (function_exists('array_column')) { |
357 | - if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
358 | - ?> |
|
357 | + if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) { |
|
358 | + ?> |
|
359 | 359 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
360 | 360 | <?php |
361 | - } |
|
361 | + } |
|
362 | 362 | } elseif (isset($globalSources)) { |
363 | - $dispolar = false; |
|
364 | - foreach ($globalSources as $testsource) { |
|
365 | - if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
366 | - } |
|
367 | - if ($dispolar) { |
|
368 | - ?> |
|
363 | + $dispolar = false; |
|
364 | + foreach ($globalSources as $testsource) { |
|
365 | + if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true; |
|
366 | + } |
|
367 | + if ($dispolar) { |
|
368 | + ?> |
|
369 | 369 | <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li> |
370 | 370 | <?php |
371 | - } |
|
372 | - } |
|
373 | - ?> |
|
371 | + } |
|
372 | + } |
|
373 | + ?> |
|
374 | 374 | <?php |
375 | - if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
375 | + if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') { |
|
376 | 376 | ?> |
377 | 377 | |
378 | 378 | <?php |
379 | 379 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
380 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
381 | - ?> |
|
380 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
381 | + ?> |
|
382 | 382 | <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li> |
383 | 383 | <?php |
384 | 384 | if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') { |
385 | - ?> |
|
385 | + ?> |
|
386 | 386 | <li><?php echo _("Aircraft icon color:"); ?> |
387 | 387 | <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"> |
388 | 388 | </li> |
389 | 389 | <?php |
390 | 390 | } |
391 | - } |
|
392 | - } |
|
393 | - ?> |
|
391 | + } |
|
392 | + } |
|
393 | + ?> |
|
394 | 394 | <?php |
395 | 395 | if (isset($globalMarine) && $globalMarine === TRUE) { |
396 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
397 | - ?> |
|
396 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
397 | + ?> |
|
398 | 398 | <li><?php echo _("Marine icon color:"); ?> |
399 | 399 | <input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>"> |
400 | 400 | </li> |
401 | 401 | <?php |
402 | - } |
|
403 | - } |
|
404 | - ?> |
|
402 | + } |
|
403 | + } |
|
404 | + ?> |
|
405 | 405 | <?php |
406 | 406 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
407 | - ?> |
|
407 | + ?> |
|
408 | 408 | <li><?php echo _("Show airport icon at zoom level:"); ?> |
409 | 409 | <div class="range"> |
410 | 410 | <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>"> |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | </li> |
414 | 414 | <?php |
415 | 415 | } |
416 | - ?> |
|
416 | + ?> |
|
417 | 417 | <?php |
418 | - } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
418 | + } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') { |
|
419 | 419 | ?> |
420 | 420 | <?php |
421 | 421 | if (!isset($globalAircraft) || $globalAircraft === TRUE) { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | </li> |
437 | 437 | <?php |
438 | 438 | } |
439 | - } |
|
439 | + } |
|
440 | 440 | ?> |
441 | 441 | <li><?php echo _("Distance unit:"); ?> |
442 | 442 | <select class="selectpicker" onchange="unitdistance(this);"> |
@@ -469,19 +469,19 @@ discard block |
||
469 | 469 | <ul> |
470 | 470 | <?php |
471 | 471 | if (!isset($globalAircraft) || $globalAircraft) { |
472 | - ?> |
|
472 | + ?> |
|
473 | 473 | <?php |
474 | 474 | if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) { |
475 | - ?> |
|
475 | + ?> |
|
476 | 476 | <?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?> |
477 | 477 | <?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?> |
478 | 478 | <?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?> |
479 | 479 | <?php |
480 | 480 | } |
481 | - ?> |
|
481 | + ?> |
|
482 | 482 | <?php |
483 | 483 | if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) { |
484 | - ?> |
|
484 | + ?> |
|
485 | 485 | <?php if (isset($globalSBS1) && $globalSBS1) { ?> |
486 | 486 | <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li> |
487 | 487 | <?php } ?> |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | <?php } ?> |
491 | 491 | <?php |
492 | 492 | } |
493 | - ?> |
|
493 | + ?> |
|
494 | 494 | <li><?php echo _("Display airlines:"); ?> |
495 | 495 | <br/> |
496 | 496 | <select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines"> |
@@ -510,14 +510,14 @@ discard block |
||
510 | 510 | echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>'; |
511 | 511 | } |
512 | 512 | } |
513 | - ?> |
|
513 | + ?> |
|
514 | 514 | </select> |
515 | 515 | </li> |
516 | 516 | <?php |
517 | 517 | $Spotter = new Spotter(); |
518 | 518 | $allalliancenames = $Spotter->getAllAllianceNames(); |
519 | 519 | if (!empty($allalliancenames)) { |
520 | - ?> |
|
520 | + ?> |
|
521 | 521 | <li><?php echo _("Display alliance:"); ?> |
522 | 522 | <br/> |
523 | 523 | <select class="selectpicker" onchange="alliance(this);" id="display_alliance"> |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>'; |
532 | 532 | } |
533 | 533 | } |
534 | - ?> |
|
534 | + ?> |
|
535 | 535 | </select> |
536 | 536 | </li> |
537 | 537 | <?php |
538 | 538 | } |
539 | - ?> |
|
539 | + ?> |
|
540 | 540 | <?php |
541 | 541 | } |
542 | - ?> |
|
542 | + ?> |
|
543 | 543 | <?php |
544 | 544 | if (isset($globalAPRS) && $globalAPRS) { |
545 | - ?> |
|
545 | + ?> |
|
546 | 546 | <li><?php echo _("Display APRS sources name:"); ?> |
547 | 547 | <select class="selectpicker" multiple onchange="sources(this);"> |
548 | 548 | <?php |
@@ -554,18 +554,18 @@ discard block |
||
554 | 554 | echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>'; |
555 | 555 | } |
556 | 556 | } |
557 | - ?> |
|
557 | + ?> |
|
558 | 558 | </select> |
559 | 559 | </li> |
560 | 560 | <?php |
561 | 561 | } |
562 | - ?> |
|
562 | + ?> |
|
563 | 563 | <?php |
564 | 564 | if (!isset($globalAircraft) && $globalAircraft) { |
565 | - ?> |
|
565 | + ?> |
|
566 | 566 | <?php |
567 | 567 | if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) { |
568 | - ?> |
|
568 | + ?> |
|
569 | 569 | <li><?php echo _("Display airlines of type:"); ?><br/> |
570 | 570 | <select class="selectpicker" onchange="airlinestype(this);"> |
571 | 571 | <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option> |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | </li> |
577 | 577 | <?php |
578 | 578 | } |
579 | - ?> |
|
579 | + ?> |
|
580 | 580 | <li> |
581 | 581 | <?php echo _("Display flight with ident:"); ?> |
582 | 582 | <input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" /> |
583 | 583 | </li> |
584 | 584 | <?php |
585 | 585 | } |
586 | - ?> |
|
586 | + ?> |
|
587 | 587 | </ul> |
588 | 588 | </form> |
589 | 589 | <form method="post"> |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | </form> |
593 | 593 | </div> |
594 | 594 | <?php |
595 | - if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
595 | + if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') { |
|
596 | 596 | ?> |
597 | 597 | <div class="sidebar-pane" id="satellites"> |
598 | 598 | <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1> |
@@ -632,14 +632,14 @@ discard block |
||
632 | 632 | print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>'; |
633 | 633 | } |
634 | 634 | } |
635 | - ?> |
|
635 | + ?> |
|
636 | 636 | </select> |
637 | 637 | </li> |
638 | 638 | </ul> |
639 | 639 | </form> |
640 | 640 | </div> |
641 | 641 | <?php |
642 | - } |
|
642 | + } |
|
643 | 643 | ?> |
644 | 644 | </div> |
645 | 645 | </div> |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,42 +24,42 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | - else $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + else $globalSources[] = array('host' => $options['s']); |
|
59 | 59 | } elseif (isset($options['source'])) { |
60 | - $globalSources = array(); |
|
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | - else $globalSources[] = array('host' => $options['source']); |
|
60 | + $globalSources = array(); |
|
61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + else $globalSources[] = array('host' => $options['source']); |
|
63 | 63 | } |
64 | 64 | if (isset($options['aprsserverhost'])) { |
65 | 65 | $globalServerAPRS = TRUE; |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
75 | 75 | else $id_source = 1; |
76 | 76 | if (isset($globalServer) && $globalServer) { |
77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | - $SI=new SpotterServer(); |
|
77 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | + $SI=new SpotterServer(); |
|
79 | 79 | /* |
80 | 80 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 81 | $SI = new adsb2aprs(); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | } else $SI=new SpotterImport($Connection->db); |
85 | 85 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
86 | 86 | if (isset($globalMarine) && $globalMarine) { |
87 | - $AIS = new AIS(); |
|
88 | - $MI = new MarineImport($Connection->db); |
|
87 | + $AIS = new AIS(); |
|
88 | + $MI = new MarineImport($Connection->db); |
|
89 | 89 | } |
90 | 90 | //$APRS=new APRS($Connection->db); |
91 | 91 | $SBS=new SBS(); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | //$servertz = system('date +%Z'); |
96 | 96 | // signal handler - playing nice with sockets and dump1090 |
97 | 97 | if (function_exists('pcntl_fork')) { |
98 | - pcntl_signal(SIGINT, function() { |
|
99 | - global $sockets; |
|
100 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | - die("Bye!\n"); |
|
102 | - }); |
|
103 | - pcntl_signal_dispatch(); |
|
98 | + pcntl_signal(SIGINT, function() { |
|
99 | + global $sockets; |
|
100 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | + die("Bye!\n"); |
|
102 | + }); |
|
103 | + pcntl_signal_dispatch(); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // let's try and connect |
@@ -110,153 +110,153 @@ discard block |
||
110 | 110 | $reset = 0; |
111 | 111 | |
112 | 112 | function connect_all($hosts) { |
113 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | - $reset++; |
|
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | - foreach ($hosts as $id => $value) { |
|
113 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | + $reset++; |
|
116 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | + foreach ($hosts as $id => $value) { |
|
118 | 118 | $host = $value['host']; |
119 | 119 | $globalSources[$id]['last_exec'] = 0; |
120 | 120 | // Here we check type of source(s) |
121 | 121 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | - //$formats[$id] = 'deltadbtxt'; |
|
124 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | - //$last_exec['deltadbtxt'] = 0; |
|
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | - //$formats[$id] = 'vatsimtxt'; |
|
129 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | - //$last_exec['vatsimtxt'] = 0; |
|
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | - //$formats[$id] = 'aircraftlistjson'; |
|
134 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | - //$last_exec['aircraftlistjson'] = 0; |
|
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | - } else if (preg_match('/opensky/i',$host)) { |
|
138 | - //$formats[$id] = 'aircraftlistjson'; |
|
139 | - $globalSources[$id]['format'] = 'opensky'; |
|
140 | - //$last_exec['aircraftlistjson'] = 0; |
|
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
143 | - //$formats[$id] = 'radarvirtueljson'; |
|
144 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
145 | - //$last_exec['radarvirtueljson'] = 0; |
|
146 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
147 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
148 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
149 | - exit(0); |
|
150 | - } |
|
151 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
152 | - //$formats[$id] = 'planeupdatefaa'; |
|
153 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
154 | - //$last_exec['planeupdatefaa'] = 0; |
|
155 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
156 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
157 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
158 | - exit(0); |
|
159 | - } |
|
160 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
161 | - //$formats[$id] = 'phpvmacars'; |
|
162 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
163 | - //$last_exec['phpvmacars'] = 0; |
|
164 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
165 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'vam'; |
|
168 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
169 | - } else if (preg_match('/whazzup/i',$host)) { |
|
170 | - //$formats[$id] = 'whazzup'; |
|
171 | - $globalSources[$id]['format'] = 'whazzup'; |
|
172 | - //$last_exec['whazzup'] = 0; |
|
173 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
175 | - //$formats[$id] = 'pirepsjson'; |
|
176 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
177 | - //$last_exec['pirepsjson'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
179 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
180 | - //$formats[$id] = 'fr24json'; |
|
181 | - $globalSources[$id]['format'] = 'fr24json'; |
|
182 | - //$last_exec['fr24json'] = 0; |
|
183 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
184 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
185 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
186 | - exit(0); |
|
187 | - } |
|
188 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
189 | - //$formats[$id] = 'fr24json'; |
|
190 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
191 | - //$last_exec['fr24json'] = 0; |
|
192 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
193 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
194 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
195 | - exit(0); |
|
196 | - } |
|
197 | - //} else if (preg_match('/10001/',$host)) { |
|
198 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
199 | - //$formats[$id] = 'tsv'; |
|
200 | - $globalSources[$id]['format'] = 'tsv'; |
|
201 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
202 | - } |
|
203 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
204 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
205 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
206 | - if ($idf !== false) { |
|
207 | - $httpfeeds[$id] = $idf; |
|
208 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
209 | - } |
|
210 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
211 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
213 | - $hostport = explode(':',$host); |
|
214 | - if (isset($hostport[1])) { |
|
122 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + //$formats[$id] = 'deltadbtxt'; |
|
124 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | + //$last_exec['deltadbtxt'] = 0; |
|
126 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | + //$formats[$id] = 'vatsimtxt'; |
|
129 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | + //$last_exec['vatsimtxt'] = 0; |
|
131 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | + //$formats[$id] = 'aircraftlistjson'; |
|
134 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | + //$last_exec['aircraftlistjson'] = 0; |
|
136 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | + } else if (preg_match('/opensky/i',$host)) { |
|
138 | + //$formats[$id] = 'aircraftlistjson'; |
|
139 | + $globalSources[$id]['format'] = 'opensky'; |
|
140 | + //$last_exec['aircraftlistjson'] = 0; |
|
141 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
143 | + //$formats[$id] = 'radarvirtueljson'; |
|
144 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
145 | + //$last_exec['radarvirtueljson'] = 0; |
|
146 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
147 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
148 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
149 | + exit(0); |
|
150 | + } |
|
151 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
152 | + //$formats[$id] = 'planeupdatefaa'; |
|
153 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
154 | + //$last_exec['planeupdatefaa'] = 0; |
|
155 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
156 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
157 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
158 | + exit(0); |
|
159 | + } |
|
160 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
161 | + //$formats[$id] = 'phpvmacars'; |
|
162 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
163 | + //$last_exec['phpvmacars'] = 0; |
|
164 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
165 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'vam'; |
|
168 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
169 | + } else if (preg_match('/whazzup/i',$host)) { |
|
170 | + //$formats[$id] = 'whazzup'; |
|
171 | + $globalSources[$id]['format'] = 'whazzup'; |
|
172 | + //$last_exec['whazzup'] = 0; |
|
173 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
175 | + //$formats[$id] = 'pirepsjson'; |
|
176 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
177 | + //$last_exec['pirepsjson'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
179 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
180 | + //$formats[$id] = 'fr24json'; |
|
181 | + $globalSources[$id]['format'] = 'fr24json'; |
|
182 | + //$last_exec['fr24json'] = 0; |
|
183 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
184 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
185 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
186 | + exit(0); |
|
187 | + } |
|
188 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
189 | + //$formats[$id] = 'fr24json'; |
|
190 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
191 | + //$last_exec['fr24json'] = 0; |
|
192 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
193 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
194 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
195 | + exit(0); |
|
196 | + } |
|
197 | + //} else if (preg_match('/10001/',$host)) { |
|
198 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
199 | + //$formats[$id] = 'tsv'; |
|
200 | + $globalSources[$id]['format'] = 'tsv'; |
|
201 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
202 | + } |
|
203 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
204 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
205 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
206 | + if ($idf !== false) { |
|
207 | + $httpfeeds[$id] = $idf; |
|
208 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
209 | + } |
|
210 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
211 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
213 | + $hostport = explode(':',$host); |
|
214 | + if (isset($hostport[1])) { |
|
215 | 215 | $port = $hostport[1]; |
216 | 216 | $hostn = $hostport[0]; |
217 | - } else { |
|
217 | + } else { |
|
218 | 218 | $port = $globalSources[$id]['port']; |
219 | 219 | $hostn = $globalSources[$id]['host']; |
220 | - } |
|
221 | - $Common = new Common(); |
|
222 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
223 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
224 | - } else { |
|
225 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
226 | - } |
|
227 | - if ($s) { |
|
228 | - $sockets[$id] = $s; |
|
229 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
230 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
220 | + } |
|
221 | + $Common = new Common(); |
|
222 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
223 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
224 | + } else { |
|
225 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
226 | + } |
|
227 | + if ($s) { |
|
228 | + $sockets[$id] = $s; |
|
229 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
230 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
231 | 231 | //$formats[$id] = 'aprs'; |
232 | 232 | $globalSources[$id]['format'] = 'aprs'; |
233 | 233 | //$aprs_connect = 0; |
234 | 234 | //$use_aprs = true; |
235 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
235 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
236 | 236 | $globalSources[$id]['format'] = 'vrstcp'; |
237 | - } elseif ($port == '10001') { |
|
238 | - //$formats[$id] = 'tsv'; |
|
239 | - $globalSources[$id]['format'] = 'tsv'; |
|
240 | - } elseif ($port == '30002') { |
|
241 | - //$formats[$id] = 'raw'; |
|
242 | - $globalSources[$id]['format'] = 'raw'; |
|
243 | - } elseif ($port == '5001') { |
|
244 | - //$formats[$id] = 'raw'; |
|
245 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
246 | - } elseif ($port == '30005') { |
|
237 | + } elseif ($port == '10001') { |
|
238 | + //$formats[$id] = 'tsv'; |
|
239 | + $globalSources[$id]['format'] = 'tsv'; |
|
240 | + } elseif ($port == '30002') { |
|
241 | + //$formats[$id] = 'raw'; |
|
242 | + $globalSources[$id]['format'] = 'raw'; |
|
243 | + } elseif ($port == '5001') { |
|
244 | + //$formats[$id] = 'raw'; |
|
245 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
246 | + } elseif ($port == '30005') { |
|
247 | 247 | // Not yet supported |
248 | - //$formats[$id] = 'beast'; |
|
249 | - $globalSources[$id]['format'] = 'beast'; |
|
250 | - //} else $formats[$id] = 'sbs'; |
|
251 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
252 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
248 | + //$formats[$id] = 'beast'; |
|
249 | + $globalSources[$id]['format'] = 'beast'; |
|
250 | + //} else $formats[$id] = 'sbs'; |
|
251 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
252 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
253 | 253 | } |
254 | 254 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
255 | - } else { |
|
255 | + } else { |
|
256 | 256 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
257 | - } |
|
258 | - } |
|
259 | - } |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
262 | 262 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | //connect_all($globalSources); |
280 | 280 | |
281 | 281 | if (isset($globalProxy) && $globalProxy) { |
282 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
282 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
283 | 283 | } else { |
284 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
284 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // APRS Configuration |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | die; |
291 | 291 | } |
292 | 292 | foreach ($globalSources as $key => $source) { |
293 | - if (!isset($source['format'])) { |
|
294 | - $globalSources[$key]['format'] = 'auto'; |
|
295 | - } |
|
293 | + if (!isset($source['format'])) { |
|
294 | + $globalSources[$key]['format'] = 'auto'; |
|
295 | + } |
|
296 | 296 | } |
297 | 297 | connect_all($globalSources); |
298 | 298 | foreach ($globalSources as $key => $source) { |
299 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
299 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
300 | 300 | $aprs_connect = 0; |
301 | 301 | $use_aprs = true; |
302 | 302 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
303 | 303 | break; |
304 | - } |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | if ($use_aprs) { |
@@ -342,116 +342,116 @@ discard block |
||
342 | 342 | |
343 | 343 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
344 | 344 | while ($i > 0) { |
345 | - if (!$globalDaemon) $i = $endtime-time(); |
|
346 | - // Delete old ATC |
|
347 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
345 | + if (!$globalDaemon) $i = $endtime-time(); |
|
346 | + // Delete old ATC |
|
347 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
348 | 348 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
349 | - $ATC->deleteOldATC(); |
|
350 | - } |
|
349 | + $ATC->deleteOldATC(); |
|
350 | + } |
|
351 | 351 | |
352 | - //if (count($last_exec) > 0) { |
|
353 | - if (count($last_exec) == count($globalSources)) { |
|
352 | + //if (count($last_exec) > 0) { |
|
353 | + if (count($last_exec) == count($globalSources)) { |
|
354 | 354 | $max = $globalMinFetch; |
355 | 355 | foreach ($last_exec as $last) { |
356 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
356 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
357 | 357 | } |
358 | 358 | if ($max != $globalMinFetch) { |
359 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
360 | - sleep($globalMinFetch-$max+2); |
|
359 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
360 | + sleep($globalMinFetch-$max+2); |
|
361 | + } |
|
361 | 362 | } |
362 | - } |
|
363 | 363 | |
364 | 364 | |
365 | - //foreach ($formats as $id => $value) { |
|
366 | - foreach ($globalSources as $id => $value) { |
|
365 | + //foreach ($formats as $id => $value) { |
|
366 | + foreach ($globalSources as $id => $value) { |
|
367 | 367 | date_default_timezone_set('UTC'); |
368 | 368 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
369 | 369 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
370 | - //$buffer = $Common->getData($hosts[$id]); |
|
371 | - $buffer = $Common->getData($value['host']); |
|
372 | - if ($buffer != '') $reset = 0; |
|
373 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
374 | - $buffer = explode('\n',$buffer); |
|
375 | - foreach ($buffer as $line) { |
|
376 | - if ($line != '' && count($line) > 7) { |
|
377 | - $line = explode(',', $line); |
|
378 | - $data = array(); |
|
379 | - $data['hex'] = $line[1]; // hex |
|
380 | - $data['ident'] = $line[2]; // ident |
|
381 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
382 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
383 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
384 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
385 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
386 | - $data['verticalrate'] = ''; // vertical rate |
|
387 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
388 | - $data['emergency'] = ''; // emergency |
|
389 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
390 | - $data['format_source'] = 'deltadbtxt'; |
|
391 | - $data['id_source'] = $id_source; |
|
392 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
393 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
394 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
395 | - $SI->add($data); |
|
396 | - unset($data); |
|
397 | - } |
|
398 | - } |
|
399 | - $last_exec[$id]['last'] = time(); |
|
370 | + //$buffer = $Common->getData($hosts[$id]); |
|
371 | + $buffer = $Common->getData($value['host']); |
|
372 | + if ($buffer != '') $reset = 0; |
|
373 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
374 | + $buffer = explode('\n',$buffer); |
|
375 | + foreach ($buffer as $line) { |
|
376 | + if ($line != '' && count($line) > 7) { |
|
377 | + $line = explode(',', $line); |
|
378 | + $data = array(); |
|
379 | + $data['hex'] = $line[1]; // hex |
|
380 | + $data['ident'] = $line[2]; // ident |
|
381 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
382 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
383 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
384 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
385 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
386 | + $data['verticalrate'] = ''; // vertical rate |
|
387 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
388 | + $data['emergency'] = ''; // emergency |
|
389 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
390 | + $data['format_source'] = 'deltadbtxt'; |
|
391 | + $data['id_source'] = $id_source; |
|
392 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
393 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
394 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
395 | + $SI->add($data); |
|
396 | + unset($data); |
|
397 | + } |
|
398 | + } |
|
399 | + $last_exec[$id]['last'] = time(); |
|
400 | 400 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
401 | - date_default_timezone_set('CET'); |
|
402 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
403 | - date_default_timezone_set('UTC'); |
|
404 | - if ($buffer != '') $reset = 0; |
|
405 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
406 | - $buffer = explode('\n',$buffer); |
|
407 | - foreach ($buffer as $line) { |
|
401 | + date_default_timezone_set('CET'); |
|
402 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
403 | + date_default_timezone_set('UTC'); |
|
404 | + if ($buffer != '') $reset = 0; |
|
405 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
406 | + $buffer = explode('\n',$buffer); |
|
407 | + foreach ($buffer as $line) { |
|
408 | 408 | if ($line != '') { |
409 | - echo "'".$line."'\n"; |
|
410 | - $add = false; |
|
411 | - $ais_data = $AIS->parse_line(trim($line)); |
|
412 | - $data = array(); |
|
413 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
414 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
415 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
416 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
417 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
418 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
419 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
420 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
421 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
422 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
423 | - if (isset($ais_data['timestamp'])) { |
|
409 | + echo "'".$line."'\n"; |
|
410 | + $add = false; |
|
411 | + $ais_data = $AIS->parse_line(trim($line)); |
|
412 | + $data = array(); |
|
413 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
414 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
415 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
416 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
417 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
418 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
419 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
420 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
421 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
422 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
423 | + if (isset($ais_data['timestamp'])) { |
|
424 | 424 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
425 | 425 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
426 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
427 | - $add = true; |
|
426 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
427 | + $add = true; |
|
428 | 428 | } |
429 | - } else { |
|
429 | + } else { |
|
430 | 430 | $data['datetime'] = date('Y-m-d H:i:s'); |
431 | 431 | $add = true; |
432 | - } |
|
433 | - $data['format_source'] = 'aisnmeatxt'; |
|
434 | - $data['id_source'] = $id_source; |
|
435 | - //print_r($data); |
|
436 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
437 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
438 | - unset($data); |
|
432 | + } |
|
433 | + $data['format_source'] = 'aisnmeatxt'; |
|
434 | + $data['id_source'] = $id_source; |
|
435 | + //print_r($data); |
|
436 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
437 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
438 | + unset($data); |
|
439 | 439 | } |
440 | - } |
|
441 | - $last_exec[$id]['last'] = time(); |
|
440 | + } |
|
441 | + $last_exec[$id]['last'] = time(); |
|
442 | 442 | } elseif ($value['format'] == 'aisnmeahttp') { |
443 | - $arr = $httpfeeds; |
|
444 | - $w = $e = null; |
|
443 | + $arr = $httpfeeds; |
|
444 | + $w = $e = null; |
|
445 | 445 | |
446 | - if (isset($arr[$id])) { |
|
446 | + if (isset($arr[$id])) { |
|
447 | 447 | $nn = stream_select($arr,$w,$e,$timeout); |
448 | 448 | if ($nn > 0) { |
449 | - foreach ($httpfeeds as $feed) { |
|
449 | + foreach ($httpfeeds as $feed) { |
|
450 | 450 | $buffer = stream_get_line($feed,2000,"\n"); |
451 | 451 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
452 | 452 | $buffer = explode('\n',$buffer); |
453 | 453 | foreach ($buffer as $line) { |
454 | - if ($line != '') { |
|
454 | + if ($line != '') { |
|
455 | 455 | $ais_data = $AIS->parse_line(trim($line)); |
456 | 456 | $data = array(); |
457 | 457 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -469,40 +469,40 @@ discard block |
||
469 | 469 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
470 | 470 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
471 | 471 | if (isset($ais_data['timestamp'])) { |
472 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
472 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
473 | 473 | } else { |
474 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
474 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
475 | 475 | } |
476 | 476 | $data['format_source'] = 'aisnmeahttp'; |
477 | 477 | $data['id_source'] = $id_source; |
478 | 478 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
479 | 479 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
480 | 480 | unset($data); |
481 | - } |
|
481 | + } |
|
482 | + } |
|
482 | 483 | } |
483 | - } |
|
484 | 484 | } else { |
485 | - $format = $value['format']; |
|
486 | - if (isset($tt[$format])) $tt[$format]++; |
|
487 | - else $tt[$format] = 0; |
|
488 | - if ($tt[$format] > 30) { |
|
485 | + $format = $value['format']; |
|
486 | + if (isset($tt[$format])) $tt[$format]++; |
|
487 | + else $tt[$format] = 0; |
|
488 | + if ($tt[$format] > 30) { |
|
489 | 489 | if ($globalDebug) echo 'Reconnect...'."\n"; |
490 | 490 | sleep(2); |
491 | 491 | $sourceeen[] = $value; |
492 | 492 | connect_all($sourceeen); |
493 | 493 | $sourceeen = array(); |
494 | - } |
|
494 | + } |
|
495 | + } |
|
495 | 496 | } |
496 | - } |
|
497 | 497 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
498 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
499 | - if ($buffer != '') { |
|
498 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
499 | + if ($buffer != '') { |
|
500 | 500 | //echo $buffer; |
501 | 501 | $all_data = json_decode($buffer,true); |
502 | 502 | //print_r($all_data); |
503 | 503 | if (isset($all_data[0]['DATA'])) { |
504 | 504 | foreach ($all_data[0]['DATA'] as $line) { |
505 | - if ($line != '') { |
|
505 | + if ($line != '') { |
|
506 | 506 | $data = array(); |
507 | 507 | $data['ident'] = $line['NAME']; |
508 | 508 | $data['mmsi'] = $line['MMSI']; |
@@ -519,89 +519,89 @@ discard block |
||
519 | 519 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
520 | 520 | $MI->add($data); |
521 | 521 | unset($data); |
522 | - } |
|
522 | + } |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
526 | - } |
|
527 | - $last_exec[$id]['last'] = time(); |
|
526 | + } |
|
527 | + $last_exec[$id]['last'] = time(); |
|
528 | 528 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
529 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
530 | - if ($buffer != '') { |
|
529 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
530 | + if ($buffer != '') { |
|
531 | 531 | $all_data = json_decode($buffer,true); |
532 | 532 | if (isset($all_data[0]['mmsi'])) { |
533 | - foreach ($all_data as $line) { |
|
533 | + foreach ($all_data as $line) { |
|
534 | 534 | if ($line != '') { |
535 | - $data = array(); |
|
536 | - $data['ident'] = $line['shipname']; |
|
537 | - $data['callsign'] = $line['callsign']; |
|
538 | - $data['mmsi'] = $line['mmsi']; |
|
539 | - $data['speed'] = $line['sog']; |
|
540 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
541 | - $data['latitude'] = $line['latitude']; |
|
542 | - $data['longitude'] = $line['longitude']; |
|
543 | - $data['type_id'] = $line['shiptype']; |
|
544 | - $data['arrival_code'] = $line['destination']; |
|
545 | - $data['datetime'] = $line['time']; |
|
546 | - $data['format_source'] = 'boatbeaconapp'; |
|
547 | - $data['id_source'] = $id_source; |
|
548 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
549 | - $MI->add($data); |
|
550 | - unset($data); |
|
535 | + $data = array(); |
|
536 | + $data['ident'] = $line['shipname']; |
|
537 | + $data['callsign'] = $line['callsign']; |
|
538 | + $data['mmsi'] = $line['mmsi']; |
|
539 | + $data['speed'] = $line['sog']; |
|
540 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
541 | + $data['latitude'] = $line['latitude']; |
|
542 | + $data['longitude'] = $line['longitude']; |
|
543 | + $data['type_id'] = $line['shiptype']; |
|
544 | + $data['arrival_code'] = $line['destination']; |
|
545 | + $data['datetime'] = $line['time']; |
|
546 | + $data['format_source'] = 'boatbeaconapp'; |
|
547 | + $data['id_source'] = $id_source; |
|
548 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
549 | + $MI->add($data); |
|
550 | + unset($data); |
|
551 | + } |
|
551 | 552 | } |
552 | - } |
|
553 | 553 | } |
554 | 554 | |
555 | - } |
|
556 | - $last_exec[$id]['last'] = time(); |
|
555 | + } |
|
556 | + $last_exec[$id]['last'] = time(); |
|
557 | 557 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
558 | - echo 'download...'; |
|
559 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
560 | - echo 'done !'."\n"; |
|
561 | - if ($buffer != '') $reset = 0; |
|
562 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
563 | - $buffer = explode('\n',$buffer); |
|
564 | - foreach ($buffer as $line) { |
|
558 | + echo 'download...'; |
|
559 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
560 | + echo 'done !'."\n"; |
|
561 | + if ($buffer != '') $reset = 0; |
|
562 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
563 | + $buffer = explode('\n',$buffer); |
|
564 | + foreach ($buffer as $line) { |
|
565 | 565 | if ($line != '') { |
566 | - $data = array(); |
|
567 | - $data['mmsi'] = (int)substr($line,0,9); |
|
568 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
569 | - //$data['status'] = substr($line,21,2); |
|
570 | - //$data['type'] = substr($line,24,3); |
|
571 | - $data['latitude'] = substr($line,29,9); |
|
572 | - $data['longitude'] = substr($line,41,9); |
|
573 | - $data['speed'] = round(substr($line,51,5)); |
|
574 | - //$data['course'] = substr($line,57,5); |
|
575 | - $data['heading'] = round(substr($line,63,3)); |
|
576 | - //$data['draft'] = substr($line,67,4); |
|
577 | - //$data['length'] = substr($line,72,3); |
|
578 | - //$data['beam'] = substr($line,76,2); |
|
579 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
580 | - //$data['callsign'] = trim(substr($line,100,7); |
|
581 | - //$data['dest'] = substr($line,108,20); |
|
582 | - //$data['etaDate'] = substr($line,129,5); |
|
583 | - //$data['etaTime'] = substr($line,135,5); |
|
584 | - $data['format_source'] = 'shipplotter'; |
|
585 | - $data['id_source'] = $id_source; |
|
586 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
587 | - //print_r($data); |
|
588 | - echo 'Add...'."\n"; |
|
589 | - $MI->add($data); |
|
590 | - unset($data); |
|
566 | + $data = array(); |
|
567 | + $data['mmsi'] = (int)substr($line,0,9); |
|
568 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
569 | + //$data['status'] = substr($line,21,2); |
|
570 | + //$data['type'] = substr($line,24,3); |
|
571 | + $data['latitude'] = substr($line,29,9); |
|
572 | + $data['longitude'] = substr($line,41,9); |
|
573 | + $data['speed'] = round(substr($line,51,5)); |
|
574 | + //$data['course'] = substr($line,57,5); |
|
575 | + $data['heading'] = round(substr($line,63,3)); |
|
576 | + //$data['draft'] = substr($line,67,4); |
|
577 | + //$data['length'] = substr($line,72,3); |
|
578 | + //$data['beam'] = substr($line,76,2); |
|
579 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
580 | + //$data['callsign'] = trim(substr($line,100,7); |
|
581 | + //$data['dest'] = substr($line,108,20); |
|
582 | + //$data['etaDate'] = substr($line,129,5); |
|
583 | + //$data['etaTime'] = substr($line,135,5); |
|
584 | + $data['format_source'] = 'shipplotter'; |
|
585 | + $data['id_source'] = $id_source; |
|
586 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
587 | + //print_r($data); |
|
588 | + echo 'Add...'."\n"; |
|
589 | + $MI->add($data); |
|
590 | + unset($data); |
|
591 | 591 | } |
592 | - } |
|
593 | - $last_exec[$id]['last'] = time(); |
|
592 | + } |
|
593 | + $last_exec[$id]['last'] = time(); |
|
594 | 594 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
595 | 595 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
596 | - //$buffer = $Common->getData($hosts[$id]); |
|
597 | - $buffer = $Common->getData($value['host']); |
|
598 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
599 | - $buffer = explode('\n',$buffer); |
|
600 | - $reset = 0; |
|
601 | - foreach ($buffer as $line) { |
|
602 | - if ($line != '') { |
|
603 | - $line = explode(':', $line); |
|
604 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
596 | + //$buffer = $Common->getData($hosts[$id]); |
|
597 | + $buffer = $Common->getData($value['host']); |
|
598 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
599 | + $buffer = explode('\n',$buffer); |
|
600 | + $reset = 0; |
|
601 | + foreach ($buffer as $line) { |
|
602 | + if ($line != '') { |
|
603 | + $line = explode(':', $line); |
|
604 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
605 | 605 | $data = array(); |
606 | 606 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
607 | 607 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -614,37 +614,37 @@ discard block |
||
614 | 614 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
615 | 615 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
616 | 616 | $data['latitude'] = $line[5]; // lat |
617 | - $data['longitude'] = $line[6]; // long |
|
618 | - $data['verticalrate'] = ''; // vertical rate |
|
619 | - $data['squawk'] = ''; // squawk |
|
620 | - $data['emergency'] = ''; // emergency |
|
621 | - $data['waypoints'] = $line[30]; |
|
617 | + $data['longitude'] = $line[6]; // long |
|
618 | + $data['verticalrate'] = ''; // vertical rate |
|
619 | + $data['squawk'] = ''; // squawk |
|
620 | + $data['emergency'] = ''; // emergency |
|
621 | + $data['waypoints'] = $line[30]; |
|
622 | 622 | $data['datetime'] = date('Y-m-d H:i:s'); |
623 | 623 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
624 | 624 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
625 | - $data['departure_airport_icao'] = $line[11]; |
|
626 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
627 | - $data['arrival_airport_icao'] = $line[13]; |
|
625 | + $data['departure_airport_icao'] = $line[11]; |
|
626 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
627 | + $data['arrival_airport_icao'] = $line[13]; |
|
628 | 628 | $data['frequency'] = $line[4]; |
629 | 629 | $data['type'] = $line[18]; |
630 | 630 | $data['range'] = $line[19]; |
631 | 631 | if (isset($line[35])) $data['info'] = $line[35]; |
632 | - $data['id_source'] = $id_source; |
|
633 | - //$data['arrival_airport_time'] = ; |
|
634 | - if ($line[9] != '') { |
|
635 | - $aircraft_data = explode('/',$line[9]); |
|
636 | - if (isset($aircraft_data[1])) { |
|
637 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
638 | - } |
|
639 | - } |
|
640 | - /* |
|
632 | + $data['id_source'] = $id_source; |
|
633 | + //$data['arrival_airport_time'] = ; |
|
634 | + if ($line[9] != '') { |
|
635 | + $aircraft_data = explode('/',$line[9]); |
|
636 | + if (isset($aircraft_data[1])) { |
|
637 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
638 | + } |
|
639 | + } |
|
640 | + /* |
|
641 | 641 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
642 | 642 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
643 | 643 | */ |
644 | - $data['format_source'] = $value['format']; |
|
644 | + $data['format_source'] = $value['format']; |
|
645 | 645 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
646 | 646 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
647 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
647 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
648 | 648 | elseif ($line[3] == 'ATC') { |
649 | 649 | //print_r($data); |
650 | 650 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -662,255 +662,255 @@ discard block |
||
662 | 662 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
663 | 663 | if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
664 | 664 | } |
665 | - unset($data); |
|
666 | - } |
|
667 | - } |
|
668 | - } |
|
669 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
670 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
671 | - $last_exec[$id]['last'] = time(); |
|
672 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
673 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
674 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
675 | - if ($buffer != '') { |
|
676 | - $all_data = json_decode($buffer,true); |
|
677 | - if (isset($all_data['acList'])) { |
|
665 | + unset($data); |
|
666 | + } |
|
667 | + } |
|
668 | + } |
|
669 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
670 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
671 | + $last_exec[$id]['last'] = time(); |
|
672 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
673 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
674 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
675 | + if ($buffer != '') { |
|
676 | + $all_data = json_decode($buffer,true); |
|
677 | + if (isset($all_data['acList'])) { |
|
678 | 678 | $reset = 0; |
679 | 679 | foreach ($all_data['acList'] as $line) { |
680 | - $data = array(); |
|
681 | - $data['hex'] = $line['Icao']; // hex |
|
682 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
683 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
684 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
685 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
686 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
687 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
688 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
689 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
690 | - $data['emergency'] = ''; // emergency |
|
691 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
680 | + $data = array(); |
|
681 | + $data['hex'] = $line['Icao']; // hex |
|
682 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
683 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
684 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
685 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
686 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
687 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
688 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
689 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
690 | + $data['emergency'] = ''; // emergency |
|
691 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
692 | 692 | |
693 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
694 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
693 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
694 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
695 | 695 | |
696 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
697 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
698 | - $data['format_source'] = 'aircraftlistjson'; |
|
699 | - $data['id_source'] = $id_source; |
|
700 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
701 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
702 | - if (isset($data['latitude'])) $SI->add($data); |
|
703 | - unset($data); |
|
696 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
697 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
698 | + $data['format_source'] = 'aircraftlistjson'; |
|
699 | + $data['id_source'] = $id_source; |
|
700 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
701 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
702 | + if (isset($data['latitude'])) $SI->add($data); |
|
703 | + unset($data); |
|
704 | 704 | } |
705 | - } elseif (is_array($all_data)) { |
|
705 | + } elseif (is_array($all_data)) { |
|
706 | 706 | $reset = 0; |
707 | 707 | foreach ($all_data as $line) { |
708 | - $data = array(); |
|
709 | - $data['hex'] = $line['hex']; // hex |
|
710 | - $data['ident'] = $line['flight']; // ident |
|
711 | - $data['altitude'] = $line['altitude']; // altitude |
|
712 | - $data['speed'] = $line['speed']; // speed |
|
713 | - $data['heading'] = $line['track']; // heading |
|
714 | - $data['latitude'] = $line['lat']; // lat |
|
715 | - $data['longitude'] = $line['lon']; // long |
|
716 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
717 | - $data['squawk'] = $line['squawk']; // squawk |
|
718 | - $data['emergency'] = ''; // emergency |
|
719 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
720 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
721 | - $data['format_source'] = 'aircraftlistjson'; |
|
722 | - $data['id_source'] = $id_source; |
|
723 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
724 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
725 | - $SI->add($data); |
|
726 | - unset($data); |
|
708 | + $data = array(); |
|
709 | + $data['hex'] = $line['hex']; // hex |
|
710 | + $data['ident'] = $line['flight']; // ident |
|
711 | + $data['altitude'] = $line['altitude']; // altitude |
|
712 | + $data['speed'] = $line['speed']; // speed |
|
713 | + $data['heading'] = $line['track']; // heading |
|
714 | + $data['latitude'] = $line['lat']; // lat |
|
715 | + $data['longitude'] = $line['lon']; // long |
|
716 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
717 | + $data['squawk'] = $line['squawk']; // squawk |
|
718 | + $data['emergency'] = ''; // emergency |
|
719 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
720 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
721 | + $data['format_source'] = 'aircraftlistjson'; |
|
722 | + $data['id_source'] = $id_source; |
|
723 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
724 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
725 | + $SI->add($data); |
|
726 | + unset($data); |
|
727 | + } |
|
727 | 728 | } |
728 | - } |
|
729 | - } |
|
730 | - //$last_exec['aircraftlistjson'] = time(); |
|
731 | - $last_exec[$id]['last'] = time(); |
|
732 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
733 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
734 | - $buffer = $Common->getData($value['host']); |
|
735 | - $all_data = json_decode($buffer,true); |
|
736 | - if (isset($all_data['planes'])) { |
|
729 | + } |
|
730 | + //$last_exec['aircraftlistjson'] = time(); |
|
731 | + $last_exec[$id]['last'] = time(); |
|
732 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
733 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
734 | + $buffer = $Common->getData($value['host']); |
|
735 | + $all_data = json_decode($buffer,true); |
|
736 | + if (isset($all_data['planes'])) { |
|
737 | 737 | $reset = 0; |
738 | 738 | foreach ($all_data['planes'] as $key => $line) { |
739 | - $data = array(); |
|
740 | - $data['hex'] = $key; // hex |
|
741 | - $data['ident'] = $line[3]; // ident |
|
742 | - $data['altitude'] = $line[6]; // altitude |
|
743 | - $data['speed'] = $line[8]; // speed |
|
744 | - $data['heading'] = $line[7]; // heading |
|
745 | - $data['latitude'] = $line[4]; // lat |
|
746 | - $data['longitude'] = $line[5]; // long |
|
747 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
748 | - $data['squawk'] = $line[10]; // squawk |
|
749 | - $data['emergency'] = ''; // emergency |
|
750 | - $data['registration'] = $line[2]; |
|
751 | - $data['aircraft_icao'] = $line[0]; |
|
752 | - $deparr = explode('-',$line[1]); |
|
753 | - if (count($deparr) == 2) { |
|
739 | + $data = array(); |
|
740 | + $data['hex'] = $key; // hex |
|
741 | + $data['ident'] = $line[3]; // ident |
|
742 | + $data['altitude'] = $line[6]; // altitude |
|
743 | + $data['speed'] = $line[8]; // speed |
|
744 | + $data['heading'] = $line[7]; // heading |
|
745 | + $data['latitude'] = $line[4]; // lat |
|
746 | + $data['longitude'] = $line[5]; // long |
|
747 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
748 | + $data['squawk'] = $line[10]; // squawk |
|
749 | + $data['emergency'] = ''; // emergency |
|
750 | + $data['registration'] = $line[2]; |
|
751 | + $data['aircraft_icao'] = $line[0]; |
|
752 | + $deparr = explode('-',$line[1]); |
|
753 | + if (count($deparr) == 2) { |
|
754 | 754 | $data['departure_airport_icao'] = $deparr[0]; |
755 | 755 | $data['arrival_airport_icao'] = $deparr[1]; |
756 | - } |
|
757 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
758 | - $data['format_source'] = 'planeupdatefaa'; |
|
759 | - $data['id_source'] = $id_source; |
|
760 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
761 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
762 | - $SI->add($data); |
|
763 | - unset($data); |
|
756 | + } |
|
757 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
758 | + $data['format_source'] = 'planeupdatefaa'; |
|
759 | + $data['id_source'] = $id_source; |
|
760 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
761 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
762 | + $SI->add($data); |
|
763 | + unset($data); |
|
764 | + } |
|
764 | 765 | } |
765 | - } |
|
766 | - //$last_exec['planeupdatefaa'] = time(); |
|
767 | - $last_exec[$id]['last'] = time(); |
|
768 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
769 | - $buffer = $Common->getData($value['host']); |
|
770 | - $all_data = json_decode($buffer,true); |
|
771 | - if (isset($all_data['states'])) { |
|
766 | + //$last_exec['planeupdatefaa'] = time(); |
|
767 | + $last_exec[$id]['last'] = time(); |
|
768 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
769 | + $buffer = $Common->getData($value['host']); |
|
770 | + $all_data = json_decode($buffer,true); |
|
771 | + if (isset($all_data['states'])) { |
|
772 | 772 | $reset = 0; |
773 | 773 | foreach ($all_data['states'] as $key => $line) { |
774 | - $data = array(); |
|
775 | - $data['hex'] = $line[0]; // hex |
|
776 | - $data['ident'] = trim($line[1]); // ident |
|
777 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
778 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
779 | - $data['heading'] = round($line[10]); // heading |
|
780 | - $data['latitude'] = $line[5]; // lat |
|
781 | - $data['longitude'] = $line[6]; // long |
|
782 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
783 | - //$data['squawk'] = $line[10]; // squawk |
|
784 | - //$data['emergency'] = ''; // emergency |
|
785 | - //$data['registration'] = $line[2]; |
|
786 | - //$data['aircraft_icao'] = $line[0]; |
|
787 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
788 | - $data['format_source'] = 'opensky'; |
|
789 | - $data['id_source'] = $id_source; |
|
790 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
791 | - $SI->add($data); |
|
792 | - unset($data); |
|
774 | + $data = array(); |
|
775 | + $data['hex'] = $line[0]; // hex |
|
776 | + $data['ident'] = trim($line[1]); // ident |
|
777 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
778 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
779 | + $data['heading'] = round($line[10]); // heading |
|
780 | + $data['latitude'] = $line[5]; // lat |
|
781 | + $data['longitude'] = $line[6]; // long |
|
782 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
783 | + //$data['squawk'] = $line[10]; // squawk |
|
784 | + //$data['emergency'] = ''; // emergency |
|
785 | + //$data['registration'] = $line[2]; |
|
786 | + //$data['aircraft_icao'] = $line[0]; |
|
787 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
788 | + $data['format_source'] = 'opensky'; |
|
789 | + $data['id_source'] = $id_source; |
|
790 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
791 | + $SI->add($data); |
|
792 | + unset($data); |
|
793 | + } |
|
793 | 794 | } |
794 | - } |
|
795 | - //$last_exec['planeupdatefaa'] = time(); |
|
796 | - $last_exec[$id]['last'] = time(); |
|
797 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
798 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
799 | - //$buffer = $Common->getData($hosts[$id]); |
|
800 | - $buffer = $Common->getData($value['host']); |
|
801 | - $all_data = json_decode($buffer,true); |
|
802 | - if (!empty($all_data)) $reset = 0; |
|
803 | - foreach ($all_data as $key => $line) { |
|
795 | + //$last_exec['planeupdatefaa'] = time(); |
|
796 | + $last_exec[$id]['last'] = time(); |
|
797 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
798 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
799 | + //$buffer = $Common->getData($hosts[$id]); |
|
800 | + $buffer = $Common->getData($value['host']); |
|
801 | + $all_data = json_decode($buffer,true); |
|
802 | + if (!empty($all_data)) $reset = 0; |
|
803 | + foreach ($all_data as $key => $line) { |
|
804 | 804 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
805 | - $data = array(); |
|
806 | - $data['hex'] = $line[0]; |
|
807 | - $data['ident'] = $line[16]; //$line[13] |
|
808 | - $data['altitude'] = $line[4]; // altitude |
|
809 | - $data['speed'] = $line[5]; // speed |
|
810 | - $data['heading'] = $line[3]; // heading |
|
811 | - $data['latitude'] = $line[1]; // lat |
|
812 | - $data['longitude'] = $line[2]; // long |
|
813 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
814 | - $data['squawk'] = $line[6]; // squawk |
|
815 | - $data['aircraft_icao'] = $line[8]; |
|
816 | - $data['registration'] = $line[9]; |
|
817 | - $data['departure_airport_iata'] = $line[11]; |
|
818 | - $data['arrival_airport_iata'] = $line[12]; |
|
819 | - $data['emergency'] = ''; // emergency |
|
820 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
821 | - $data['format_source'] = 'fr24json'; |
|
822 | - $data['id_source'] = $id_source; |
|
823 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
824 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
825 | - $SI->add($data); |
|
826 | - unset($data); |
|
805 | + $data = array(); |
|
806 | + $data['hex'] = $line[0]; |
|
807 | + $data['ident'] = $line[16]; //$line[13] |
|
808 | + $data['altitude'] = $line[4]; // altitude |
|
809 | + $data['speed'] = $line[5]; // speed |
|
810 | + $data['heading'] = $line[3]; // heading |
|
811 | + $data['latitude'] = $line[1]; // lat |
|
812 | + $data['longitude'] = $line[2]; // long |
|
813 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
814 | + $data['squawk'] = $line[6]; // squawk |
|
815 | + $data['aircraft_icao'] = $line[8]; |
|
816 | + $data['registration'] = $line[9]; |
|
817 | + $data['departure_airport_iata'] = $line[11]; |
|
818 | + $data['arrival_airport_iata'] = $line[12]; |
|
819 | + $data['emergency'] = ''; // emergency |
|
820 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
821 | + $data['format_source'] = 'fr24json'; |
|
822 | + $data['id_source'] = $id_source; |
|
823 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
824 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
825 | + $SI->add($data); |
|
826 | + unset($data); |
|
827 | + } |
|
827 | 828 | } |
828 | - } |
|
829 | - //$last_exec['fr24json'] = time(); |
|
830 | - $last_exec[$id]['last'] = time(); |
|
831 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
832 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
833 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
834 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
835 | - //echo $buffer; |
|
836 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
837 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
838 | - $all_data = json_decode($buffer,true); |
|
839 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
829 | + //$last_exec['fr24json'] = time(); |
|
830 | + $last_exec[$id]['last'] = time(); |
|
831 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
832 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
833 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
834 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
835 | + //echo $buffer; |
|
836 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
837 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
838 | + $all_data = json_decode($buffer,true); |
|
839 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
840 | 840 | die(json_last_error_msg()); |
841 | - } |
|
842 | - if (isset($all_data['mrkrs'])) { |
|
841 | + } |
|
842 | + if (isset($all_data['mrkrs'])) { |
|
843 | 843 | $reset = 0; |
844 | 844 | foreach ($all_data['mrkrs'] as $key => $line) { |
845 | - if (isset($line['inf'])) { |
|
845 | + if (isset($line['inf'])) { |
|
846 | 846 | $data = array(); |
847 | 847 | $data['hex'] = $line['inf']['ia']; |
848 | 848 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
849 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
850 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
851 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
852 | - $data['latitude'] = $line['pt'][0]; // lat |
|
853 | - $data['longitude'] = $line['pt'][1]; // long |
|
854 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
855 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
856 | - //$data['aircraft_icao'] = $line[8]; |
|
857 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
849 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
850 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
851 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
852 | + $data['latitude'] = $line['pt'][0]; // lat |
|
853 | + $data['longitude'] = $line['pt'][1]; // long |
|
854 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
855 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
856 | + //$data['aircraft_icao'] = $line[8]; |
|
857 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
858 | 858 | //$data['departure_airport_iata'] = $line[11]; |
859 | 859 | //$data['arrival_airport_iata'] = $line[12]; |
860 | - //$data['emergency'] = ''; // emergency |
|
860 | + //$data['emergency'] = ''; // emergency |
|
861 | 861 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
862 | - $data['format_source'] = 'radarvirtueljson'; |
|
863 | - $data['id_source'] = $id_source; |
|
862 | + $data['format_source'] = 'radarvirtueljson'; |
|
863 | + $data['id_source'] = $id_source; |
|
864 | 864 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
865 | 865 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
866 | 866 | $SI->add($data); |
867 | 867 | unset($data); |
868 | - } |
|
868 | + } |
|
869 | + } |
|
869 | 870 | } |
870 | - } |
|
871 | - //$last_exec['radarvirtueljson'] = time(); |
|
872 | - $last_exec[$id]['last'] = time(); |
|
873 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
874 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
875 | - //$buffer = $Common->getData($hosts[$id]); |
|
876 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
877 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
871 | + //$last_exec['radarvirtueljson'] = time(); |
|
872 | + $last_exec[$id]['last'] = time(); |
|
873 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
874 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
875 | + //$buffer = $Common->getData($hosts[$id]); |
|
876 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
877 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
878 | 878 | |
879 | - if (isset($all_data['pireps'])) { |
|
879 | + if (isset($all_data['pireps'])) { |
|
880 | 880 | $reset = 0; |
881 | - foreach ($all_data['pireps'] as $line) { |
|
882 | - $data = array(); |
|
883 | - $data['id'] = $line['id']; |
|
884 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
885 | - $data['ident'] = $line['callsign']; // ident |
|
886 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
887 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
888 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
889 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
890 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
891 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
892 | - $data['latitude'] = $line['lat']; // lat |
|
893 | - $data['longitude'] = $line['lon']; // long |
|
894 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
895 | - //$data['squawk'] = $line['squawk']; // squawk |
|
896 | - //$data['emergency'] = ''; // emergency |
|
897 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
898 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
899 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
900 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
901 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
902 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
903 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
904 | - else $data['info'] = ''; |
|
905 | - $data['format_source'] = 'pireps'; |
|
906 | - $data['id_source'] = $id_source; |
|
907 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
908 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
909 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
910 | - if ($line['icon'] == 'plane') { |
|
881 | + foreach ($all_data['pireps'] as $line) { |
|
882 | + $data = array(); |
|
883 | + $data['id'] = $line['id']; |
|
884 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
885 | + $data['ident'] = $line['callsign']; // ident |
|
886 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
887 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
888 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
889 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
890 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
891 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
892 | + $data['latitude'] = $line['lat']; // lat |
|
893 | + $data['longitude'] = $line['lon']; // long |
|
894 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
895 | + //$data['squawk'] = $line['squawk']; // squawk |
|
896 | + //$data['emergency'] = ''; // emergency |
|
897 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
898 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
899 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
900 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
901 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
902 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
903 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
904 | + else $data['info'] = ''; |
|
905 | + $data['format_source'] = 'pireps'; |
|
906 | + $data['id_source'] = $id_source; |
|
907 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
908 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
909 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
910 | + if ($line['icon'] == 'plane') { |
|
911 | 911 | $SI->add($data); |
912 | - // print_r($data); |
|
913 | - } elseif ($line['icon'] == 'ct') { |
|
912 | + // print_r($data); |
|
913 | + } elseif ($line['icon'] == 'ct') { |
|
914 | 914 | $data['info'] = str_replace('^§','<br />',$data['info']); |
915 | 915 | $data['info'] = str_replace('&sect;','',$data['info']); |
916 | 916 | $typec = substr($data['ident'],-3); |
@@ -925,197 +925,197 @@ discard block |
||
925 | 925 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
926 | 926 | else $data['type'] = 'Observer'; |
927 | 927 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
928 | - } |
|
929 | - unset($data); |
|
928 | + } |
|
929 | + unset($data); |
|
930 | 930 | } |
931 | - } |
|
932 | - //$last_exec['pirepsjson'] = time(); |
|
933 | - $last_exec[$id]['last'] = time(); |
|
934 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
935 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
936 | - //$buffer = $Common->getData($hosts[$id]); |
|
937 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
938 | - $buffer = $Common->getData($value['host']); |
|
939 | - $all_data = json_decode($buffer,true); |
|
940 | - if ($buffer != '' && is_array($all_data)) { |
|
931 | + } |
|
932 | + //$last_exec['pirepsjson'] = time(); |
|
933 | + $last_exec[$id]['last'] = time(); |
|
934 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
935 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
936 | + //$buffer = $Common->getData($hosts[$id]); |
|
937 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
938 | + $buffer = $Common->getData($value['host']); |
|
939 | + $all_data = json_decode($buffer,true); |
|
940 | + if ($buffer != '' && is_array($all_data)) { |
|
941 | 941 | $reset = 0; |
942 | 942 | foreach ($all_data as $line) { |
943 | - $data = array(); |
|
944 | - //$data['id'] = $line['id']; // id not usable |
|
945 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
946 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
947 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
948 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
949 | - $data['ident'] = $line['flightnum']; // ident |
|
950 | - $data['altitude'] = $line['alt']; // altitude |
|
951 | - $data['speed'] = $line['gs']; // speed |
|
952 | - $data['heading'] = $line['heading']; // heading |
|
953 | - $data['latitude'] = $line['lat']; // lat |
|
954 | - $data['longitude'] = $line['lng']; // long |
|
955 | - $data['verticalrate'] = ''; // verticale rate |
|
956 | - $data['squawk'] = ''; // squawk |
|
957 | - $data['emergency'] = ''; // emergency |
|
958 | - //$data['datetime'] = $line['lastupdate']; |
|
959 | - $data['last_update'] = $line['lastupdate']; |
|
960 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
961 | - $data['departure_airport_icao'] = $line['depicao']; |
|
962 | - $data['departure_airport_time'] = $line['deptime']; |
|
963 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
964 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
965 | - $data['registration'] = $line['aircraft']; |
|
966 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
967 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
968 | - if (isset($line['aircraftname'])) { |
|
943 | + $data = array(); |
|
944 | + //$data['id'] = $line['id']; // id not usable |
|
945 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
946 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
947 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
948 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
949 | + $data['ident'] = $line['flightnum']; // ident |
|
950 | + $data['altitude'] = $line['alt']; // altitude |
|
951 | + $data['speed'] = $line['gs']; // speed |
|
952 | + $data['heading'] = $line['heading']; // heading |
|
953 | + $data['latitude'] = $line['lat']; // lat |
|
954 | + $data['longitude'] = $line['lng']; // long |
|
955 | + $data['verticalrate'] = ''; // verticale rate |
|
956 | + $data['squawk'] = ''; // squawk |
|
957 | + $data['emergency'] = ''; // emergency |
|
958 | + //$data['datetime'] = $line['lastupdate']; |
|
959 | + $data['last_update'] = $line['lastupdate']; |
|
960 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
961 | + $data['departure_airport_icao'] = $line['depicao']; |
|
962 | + $data['departure_airport_time'] = $line['deptime']; |
|
963 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
964 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
965 | + $data['registration'] = $line['aircraft']; |
|
966 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
967 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
968 | + if (isset($line['aircraftname'])) { |
|
969 | 969 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
970 | 970 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
971 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
972 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
973 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
974 | - else { |
|
975 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
976 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
977 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
978 | - } |
|
979 | - } |
|
980 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
981 | - $data['id_source'] = $id_source; |
|
982 | - $data['format_source'] = 'phpvmacars'; |
|
983 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
984 | - $SI->add($data); |
|
985 | - unset($data); |
|
971 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
972 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
973 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
974 | + else { |
|
975 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
976 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
977 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
978 | + } |
|
979 | + } |
|
980 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
981 | + $data['id_source'] = $id_source; |
|
982 | + $data['format_source'] = 'phpvmacars'; |
|
983 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
984 | + $SI->add($data); |
|
985 | + unset($data); |
|
986 | 986 | } |
987 | 987 | if ($globalDebug) echo 'No more data...'."\n"; |
988 | 988 | unset($buffer); |
989 | 989 | unset($all_data); |
990 | - } |
|
991 | - //$last_exec['phpvmacars'] = time(); |
|
992 | - $last_exec[$id]['last'] = time(); |
|
993 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
994 | - //$buffer = $Common->getData($hosts[$id]); |
|
995 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
996 | - $buffer = $Common->getData($value['host']); |
|
997 | - $all_data = json_decode($buffer,true); |
|
998 | - if ($buffer != '' && is_array($all_data)) { |
|
990 | + } |
|
991 | + //$last_exec['phpvmacars'] = time(); |
|
992 | + $last_exec[$id]['last'] = time(); |
|
993 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
994 | + //$buffer = $Common->getData($hosts[$id]); |
|
995 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
996 | + $buffer = $Common->getData($value['host']); |
|
997 | + $all_data = json_decode($buffer,true); |
|
998 | + if ($buffer != '' && is_array($all_data)) { |
|
999 | 999 | $reset = 0; |
1000 | 1000 | foreach ($all_data as $line) { |
1001 | - $data = array(); |
|
1002 | - //$data['id'] = $line['id']; // id not usable |
|
1003 | - $data['id'] = trim($line['flight_id']); |
|
1004 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1005 | - $data['pilot_name'] = $line['pilot_name']; |
|
1006 | - $data['pilot_id'] = $line['pilot_id']; |
|
1007 | - $data['ident'] = trim($line['callsign']); // ident |
|
1008 | - $data['altitude'] = $line['altitude']; // altitude |
|
1009 | - $data['speed'] = $line['gs']; // speed |
|
1010 | - $data['heading'] = $line['heading']; // heading |
|
1011 | - $data['latitude'] = $line['latitude']; // lat |
|
1012 | - $data['longitude'] = $line['longitude']; // long |
|
1013 | - $data['verticalrate'] = ''; // verticale rate |
|
1014 | - $data['squawk'] = ''; // squawk |
|
1015 | - $data['emergency'] = ''; // emergency |
|
1016 | - //$data['datetime'] = $line['lastupdate']; |
|
1017 | - $data['last_update'] = $line['last_update']; |
|
1018 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1019 | - $data['departure_airport_icao'] = $line['departure']; |
|
1020 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1021 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1022 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1023 | - //$data['registration'] = $line['aircraft']; |
|
1024 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1025 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1026 | - $data['id_source'] = $id_source; |
|
1027 | - $data['format_source'] = 'vam'; |
|
1028 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1029 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1030 | - $SI->add($data); |
|
1031 | - unset($data); |
|
1001 | + $data = array(); |
|
1002 | + //$data['id'] = $line['id']; // id not usable |
|
1003 | + $data['id'] = trim($line['flight_id']); |
|
1004 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1005 | + $data['pilot_name'] = $line['pilot_name']; |
|
1006 | + $data['pilot_id'] = $line['pilot_id']; |
|
1007 | + $data['ident'] = trim($line['callsign']); // ident |
|
1008 | + $data['altitude'] = $line['altitude']; // altitude |
|
1009 | + $data['speed'] = $line['gs']; // speed |
|
1010 | + $data['heading'] = $line['heading']; // heading |
|
1011 | + $data['latitude'] = $line['latitude']; // lat |
|
1012 | + $data['longitude'] = $line['longitude']; // long |
|
1013 | + $data['verticalrate'] = ''; // verticale rate |
|
1014 | + $data['squawk'] = ''; // squawk |
|
1015 | + $data['emergency'] = ''; // emergency |
|
1016 | + //$data['datetime'] = $line['lastupdate']; |
|
1017 | + $data['last_update'] = $line['last_update']; |
|
1018 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1019 | + $data['departure_airport_icao'] = $line['departure']; |
|
1020 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1021 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1022 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1023 | + //$data['registration'] = $line['aircraft']; |
|
1024 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1025 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1026 | + $data['id_source'] = $id_source; |
|
1027 | + $data['format_source'] = 'vam'; |
|
1028 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1029 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1030 | + $SI->add($data); |
|
1031 | + unset($data); |
|
1032 | 1032 | } |
1033 | 1033 | if ($globalDebug) echo 'No more data...'."\n"; |
1034 | 1034 | unset($buffer); |
1035 | 1035 | unset($all_data); |
1036 | - } |
|
1037 | - //$last_exec['phpvmacars'] = time(); |
|
1038 | - $last_exec[$id]['last'] = time(); |
|
1036 | + } |
|
1037 | + //$last_exec['phpvmacars'] = time(); |
|
1038 | + $last_exec[$id]['last'] = time(); |
|
1039 | 1039 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1040 | 1040 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1041 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1042 | - //$last_exec[$id]['last'] = time(); |
|
1041 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1042 | + //$last_exec[$id]['last'] = time(); |
|
1043 | 1043 | |
1044 | - //$read = array( $sockets[$id] ); |
|
1045 | - $read = $sockets; |
|
1046 | - $write = NULL; |
|
1047 | - $e = NULL; |
|
1048 | - $n = socket_select($read, $write, $e, $timeout); |
|
1049 | - if ($e != NULL) var_dump($e); |
|
1050 | - if ($n > 0) { |
|
1044 | + //$read = array( $sockets[$id] ); |
|
1045 | + $read = $sockets; |
|
1046 | + $write = NULL; |
|
1047 | + $e = NULL; |
|
1048 | + $n = socket_select($read, $write, $e, $timeout); |
|
1049 | + if ($e != NULL) var_dump($e); |
|
1050 | + if ($n > 0) { |
|
1051 | 1051 | $reset = 0; |
1052 | 1052 | foreach ($read as $nb => $r) { |
1053 | - //$value = $formats[$nb]; |
|
1054 | - $format = $globalSources[$nb]['format']; |
|
1055 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1053 | + //$value = $formats[$nb]; |
|
1054 | + $format = $globalSources[$nb]['format']; |
|
1055 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1056 | 1056 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1057 | - } elseif ($format == 'vrstcp') { |
|
1057 | + } elseif ($format == 'vrstcp') { |
|
1058 | 1058 | $buffer = @socket_read($r, 6000); |
1059 | - } else { |
|
1059 | + } else { |
|
1060 | 1060 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1061 | - } |
|
1062 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1063 | - //echo $buffer."\n"; |
|
1064 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1065 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1066 | - $error = false; |
|
1067 | - //$SI::del(); |
|
1068 | - if ($format == 'vrstcp') { |
|
1061 | + } |
|
1062 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1063 | + //echo $buffer."\n"; |
|
1064 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1065 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1066 | + $error = false; |
|
1067 | + //$SI::del(); |
|
1068 | + if ($format == 'vrstcp') { |
|
1069 | 1069 | $buffer = explode('},{',$buffer); |
1070 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1071 | - // SBS format is CSV format |
|
1072 | - if ($buffer !== FALSE && $buffer != '') { |
|
1070 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1071 | + // SBS format is CSV format |
|
1072 | + if ($buffer !== FALSE && $buffer != '') { |
|
1073 | 1073 | $tt[$format] = 0; |
1074 | 1074 | if ($format == 'acarssbs3') { |
1075 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1076 | - $ACARS->add(trim($buffer)); |
|
1077 | - $ACARS->deleteLiveAcarsData(); |
|
1075 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1076 | + $ACARS->add(trim($buffer)); |
|
1077 | + $ACARS->deleteLiveAcarsData(); |
|
1078 | 1078 | } elseif ($format == 'raw') { |
1079 | - // AVR format |
|
1080 | - $data = $SBS->parse($buffer); |
|
1081 | - if (is_array($data)) { |
|
1079 | + // AVR format |
|
1080 | + $data = $SBS->parse($buffer); |
|
1081 | + if (is_array($data)) { |
|
1082 | 1082 | $data['datetime'] = date('Y-m-d H:i:s'); |
1083 | 1083 | $data['format_source'] = 'raw'; |
1084 | 1084 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1085 | 1085 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1086 | 1086 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1087 | 1087 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1088 | - } |
|
1088 | + } |
|
1089 | 1089 | } elseif ($format == 'ais') { |
1090 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1091 | - $data = array(); |
|
1092 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1093 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1094 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1095 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1096 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1097 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1098 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1099 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1100 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1101 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1102 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1103 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1104 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1105 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1090 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1091 | + $data = array(); |
|
1092 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1093 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1094 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1095 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1096 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1097 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1098 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1099 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1100 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1101 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1102 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1103 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1104 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1105 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1106 | 1106 | |
1107 | - if (isset($ais_data['timestamp'])) { |
|
1107 | + if (isset($ais_data['timestamp'])) { |
|
1108 | 1108 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1109 | - } else { |
|
1109 | + } else { |
|
1110 | 1110 | $data['datetime'] = date('Y-m-d H:i:s'); |
1111 | - } |
|
1112 | - $data['format_source'] = 'aisnmea'; |
|
1113 | - $data['id_source'] = $id_source; |
|
1114 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1115 | - unset($data); |
|
1116 | - } elseif ($format == 'flightgearsp') { |
|
1117 | - //echo $buffer."\n"; |
|
1118 | - if (strlen($buffer) > 5) { |
|
1111 | + } |
|
1112 | + $data['format_source'] = 'aisnmea'; |
|
1113 | + $data['id_source'] = $id_source; |
|
1114 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1115 | + unset($data); |
|
1116 | + } elseif ($format == 'flightgearsp') { |
|
1117 | + //echo $buffer."\n"; |
|
1118 | + if (strlen($buffer) > 5) { |
|
1119 | 1119 | $line = explode(',',$buffer); |
1120 | 1120 | $data = array(); |
1121 | 1121 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1132,38 +1132,38 @@ discard block |
||
1132 | 1132 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1133 | 1133 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1134 | 1134 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1135 | - } |
|
1136 | - } elseif ($format == 'acars') { |
|
1137 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1138 | - $ACARS->add(trim($buffer)); |
|
1139 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1140 | - $ACARS->deleteLiveAcarsData(); |
|
1135 | + } |
|
1136 | + } elseif ($format == 'acars') { |
|
1137 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1138 | + $ACARS->add(trim($buffer)); |
|
1139 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1140 | + $ACARS->deleteLiveAcarsData(); |
|
1141 | 1141 | } elseif ($format == 'flightgearmp') { |
1142 | - if (substr($buffer,0,1) != '#') { |
|
1142 | + if (substr($buffer,0,1) != '#') { |
|
1143 | 1143 | $data = array(); |
1144 | 1144 | //echo $buffer."\n"; |
1145 | 1145 | $line = explode(' ',$buffer); |
1146 | 1146 | if (count($line) == 11) { |
1147 | - $userserver = explode('@',$line[0]); |
|
1148 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1149 | - $data['ident'] = $userserver[0]; |
|
1150 | - $data['registration'] = $userserver[0]; |
|
1151 | - $data['latitude'] = $line[4]; |
|
1152 | - $data['longitude'] = $line[5]; |
|
1153 | - $data['altitude'] = $line[6]; |
|
1154 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1155 | - $aircraft_type = $line[10]; |
|
1156 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1157 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1158 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1159 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1147 | + $userserver = explode('@',$line[0]); |
|
1148 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1149 | + $data['ident'] = $userserver[0]; |
|
1150 | + $data['registration'] = $userserver[0]; |
|
1151 | + $data['latitude'] = $line[4]; |
|
1152 | + $data['longitude'] = $line[5]; |
|
1153 | + $data['altitude'] = $line[6]; |
|
1154 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1155 | + $aircraft_type = $line[10]; |
|
1156 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1157 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1158 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1159 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1160 | + } |
|
1160 | 1161 | } |
1161 | - } |
|
1162 | 1162 | } elseif ($format == 'beast') { |
1163 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1164 | - die; |
|
1163 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1164 | + die; |
|
1165 | 1165 | } elseif ($format == 'vrstcp') { |
1166 | - foreach($buffer as $all_data) { |
|
1166 | + foreach($buffer as $all_data) { |
|
1167 | 1167 | $line = json_decode('{'.$all_data.'}',true); |
1168 | 1168 | $data = array(); |
1169 | 1169 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1183,113 +1183,113 @@ discard block |
||
1183 | 1183 | */ |
1184 | 1184 | $data['datetime'] = date('Y-m-d H:i:s'); |
1185 | 1185 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1186 | - $data['format_source'] = 'vrstcp'; |
|
1186 | + $data['format_source'] = 'vrstcp'; |
|
1187 | 1187 | $data['id_source'] = $id_source; |
1188 | 1188 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1189 | 1189 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1190 | 1190 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1191 | 1191 | unset($data); |
1192 | - } |
|
1192 | + } |
|
1193 | 1193 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1194 | - $line = explode("\t", $buffer); |
|
1195 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1194 | + $line = explode("\t", $buffer); |
|
1195 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1196 | 1196 | $key = $line[$k]; |
1197 | - $lined[$key] = $line[$k+1]; |
|
1198 | - } |
|
1199 | - if (count($lined) > 3) { |
|
1200 | - $data['hex'] = $lined['hexid']; |
|
1201 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1202 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1203 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1204 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1205 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1206 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1207 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1208 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1209 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1210 | - $data['id_source'] = $id_source; |
|
1211 | - $data['format_source'] = 'tsv'; |
|
1212 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1213 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1197 | + $lined[$key] = $line[$k+1]; |
|
1198 | + } |
|
1199 | + if (count($lined) > 3) { |
|
1200 | + $data['hex'] = $lined['hexid']; |
|
1201 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1202 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1203 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1204 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1205 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1206 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1207 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1208 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1209 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1210 | + $data['id_source'] = $id_source; |
|
1211 | + $data['format_source'] = 'tsv'; |
|
1212 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1213 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1214 | 1214 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1215 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1216 | - unset($lined); |
|
1217 | - unset($data); |
|
1218 | - } else $error = true; |
|
1215 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1216 | + unset($lined); |
|
1217 | + unset($data); |
|
1218 | + } else $error = true; |
|
1219 | 1219 | } elseif ($format == 'aprs' && $use_aprs) { |
1220 | - if ($aprs_connect == 0) { |
|
1220 | + if ($aprs_connect == 0) { |
|
1221 | 1221 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1222 | 1222 | $aprs_connect = 1; |
1223 | - } |
|
1223 | + } |
|
1224 | 1224 | |
1225 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1225 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1226 | 1226 | $aprs_last_tx = time(); |
1227 | 1227 | $data_aprs = "# Keep alive"; |
1228 | 1228 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1229 | - } |
|
1229 | + } |
|
1230 | 1230 | |
1231 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1232 | - //echo 'APRS data : '.$buffer."\n"; |
|
1233 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1234 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1235 | - //echo $buffer."\n"; |
|
1236 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1231 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1232 | + //echo 'APRS data : '.$buffer."\n"; |
|
1233 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1234 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1235 | + //echo $buffer."\n"; |
|
1236 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1237 | 1237 | $line = $APRS->parse($buffer); |
1238 | 1238 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1239 | 1239 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1240 | - $aprs_last_tx = time(); |
|
1241 | - $data = array(); |
|
1242 | - //print_r($line); |
|
1243 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1244 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1245 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1246 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1247 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1248 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1249 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1250 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1251 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1252 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1253 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1254 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1255 | - $data['latitude'] = $line['latitude']; |
|
1256 | - $data['longitude'] = $line['longitude']; |
|
1257 | - //$data['verticalrate'] = $line[16]; |
|
1258 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1259 | - else $data['speed'] = 0; |
|
1260 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1261 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1262 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1263 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1264 | - //else $data['heading'] = 0; |
|
1265 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1266 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1267 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1268 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1269 | - $data['id_source'] = $id_source; |
|
1270 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1271 | - else $data['format_source'] = 'aprs'; |
|
1272 | - $data['source_name'] = $line['source']; |
|
1273 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1274 | - else $data['source_type'] = 'flarm'; |
|
1275 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1276 | - $currentdate = date('Y-m-d H:i:s'); |
|
1277 | - $aprsdate = strtotime($data['datetime']); |
|
1278 | - // Accept data if time <= system time + 20s |
|
1279 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1280 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1240 | + $aprs_last_tx = time(); |
|
1241 | + $data = array(); |
|
1242 | + //print_r($line); |
|
1243 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1244 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1245 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1246 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1247 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; |
|
1248 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
|
1249 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
|
1250 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
|
1251 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1252 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1253 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1254 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1255 | + $data['latitude'] = $line['latitude']; |
|
1256 | + $data['longitude'] = $line['longitude']; |
|
1257 | + //$data['verticalrate'] = $line[16]; |
|
1258 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1259 | + else $data['speed'] = 0; |
|
1260 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1261 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1262 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1263 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1264 | + //else $data['heading'] = 0; |
|
1265 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1266 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1267 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1268 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1269 | + $data['id_source'] = $id_source; |
|
1270 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1271 | + else $data['format_source'] = 'aprs'; |
|
1272 | + $data['source_name'] = $line['source']; |
|
1273 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1274 | + else $data['source_type'] = 'flarm'; |
|
1275 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1276 | + $currentdate = date('Y-m-d H:i:s'); |
|
1277 | + $aprsdate = strtotime($data['datetime']); |
|
1278 | + // Accept data if time <= system time + 20s |
|
1279 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1280 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1281 | 1281 | $send = $SI->add($data); |
1282 | - } elseif ($data['source_type'] == 'ais') { |
|
1282 | + } elseif ($data['source_type'] == 'ais') { |
|
1283 | 1283 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1284 | - } elseif (isset($line['stealth'])) { |
|
1284 | + } elseif (isset($line['stealth'])) { |
|
1285 | 1285 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1286 | 1286 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1287 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1288 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1287 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1288 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1289 | 1289 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1290 | 1290 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1291 | - } |
|
1292 | - unset($data); |
|
1291 | + } |
|
1292 | + unset($data); |
|
1293 | 1293 | } |
1294 | 1294 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1295 | 1295 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1299,12 +1299,12 @@ discard block |
||
1299 | 1299 | } |
1300 | 1300 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1301 | 1301 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1302 | - } |
|
1302 | + } |
|
1303 | 1303 | } else { |
1304 | - $line = explode(',', $buffer); |
|
1305 | - if (count($line) > 20) { |
|
1306 | - $data['hex'] = $line[4]; |
|
1307 | - /* |
|
1304 | + $line = explode(',', $buffer); |
|
1305 | + if (count($line) > 20) { |
|
1306 | + $data['hex'] = $line[4]; |
|
1307 | + /* |
|
1308 | 1308 | $data['datetime'] = $line[6].' '.$line[7]; |
1309 | 1309 | date_default_timezone_set($globalTimezone); |
1310 | 1310 | $datetime = new DateTime($data['datetime']); |
@@ -1312,30 +1312,30 @@ discard block |
||
1312 | 1312 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1313 | 1313 | date_default_timezone_set('UTC'); |
1314 | 1314 | */ |
1315 | - // Force datetime to current UTC datetime |
|
1316 | - date_default_timezone_set('UTC'); |
|
1317 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1318 | - $data['ident'] = trim($line[10]); |
|
1319 | - $data['latitude'] = $line[14]; |
|
1320 | - $data['longitude'] = $line[15]; |
|
1321 | - $data['verticalrate'] = $line[16]; |
|
1322 | - $data['emergency'] = $line[20]; |
|
1323 | - $data['speed'] = $line[12]; |
|
1324 | - $data['squawk'] = $line[17]; |
|
1325 | - $data['altitude'] = $line[11]; |
|
1326 | - $data['heading'] = $line[13]; |
|
1327 | - $data['ground'] = $line[21]; |
|
1328 | - $data['emergency'] = $line[19]; |
|
1329 | - $data['format_source'] = 'sbs'; |
|
1315 | + // Force datetime to current UTC datetime |
|
1316 | + date_default_timezone_set('UTC'); |
|
1317 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1318 | + $data['ident'] = trim($line[10]); |
|
1319 | + $data['latitude'] = $line[14]; |
|
1320 | + $data['longitude'] = $line[15]; |
|
1321 | + $data['verticalrate'] = $line[16]; |
|
1322 | + $data['emergency'] = $line[20]; |
|
1323 | + $data['speed'] = $line[12]; |
|
1324 | + $data['squawk'] = $line[17]; |
|
1325 | + $data['altitude'] = $line[11]; |
|
1326 | + $data['heading'] = $line[13]; |
|
1327 | + $data['ground'] = $line[21]; |
|
1328 | + $data['emergency'] = $line[19]; |
|
1329 | + $data['format_source'] = 'sbs'; |
|
1330 | 1330 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1331 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1331 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1332 | 1332 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1333 | - $data['id_source'] = $id_source; |
|
1334 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1335 | - else $error = true; |
|
1336 | - unset($data); |
|
1337 | - } else $error = true; |
|
1338 | - if ($error) { |
|
1333 | + $data['id_source'] = $id_source; |
|
1334 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1335 | + else $error = true; |
|
1336 | + unset($data); |
|
1337 | + } else $error = true; |
|
1338 | + if ($error) { |
|
1339 | 1339 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1340 | 1340 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1341 | 1341 | } else { |
@@ -1351,13 +1351,13 @@ discard block |
||
1351 | 1351 | connect_all($sourceer); |
1352 | 1352 | $sourceer = array(); |
1353 | 1353 | } |
1354 | - } |
|
1354 | + } |
|
1355 | 1355 | } |
1356 | 1356 | // Sleep for xxx microseconds |
1357 | 1357 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1358 | - } else { |
|
1358 | + } else { |
|
1359 | 1359 | if ($format == 'flightgearmp') { |
1360 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1360 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1361 | 1361 | //@socket_close($r); |
1362 | 1362 | sleep($globalMinFetch); |
1363 | 1363 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1366,9 +1366,9 @@ discard block |
||
1366 | 1366 | break; |
1367 | 1367 | |
1368 | 1368 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1369 | - if (isset($tt[$format])) $tt[$format]++; |
|
1370 | - else $tt[$format] = 0; |
|
1371 | - if ($tt[$format] > 30) { |
|
1369 | + if (isset($tt[$format])) $tt[$format]++; |
|
1370 | + else $tt[$format] = 0; |
|
1371 | + if ($tt[$format] > 30) { |
|
1372 | 1372 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1373 | 1373 | //@socket_close($r); |
1374 | 1374 | sleep(2); |
@@ -1379,23 +1379,23 @@ discard block |
||
1379 | 1379 | //connect_all($globalSources); |
1380 | 1380 | $tt[$format]=0; |
1381 | 1381 | break; |
1382 | - } |
|
1382 | + } |
|
1383 | + } |
|
1383 | 1384 | } |
1384 | - } |
|
1385 | 1385 | } |
1386 | - } else { |
|
1386 | + } else { |
|
1387 | 1387 | $error = socket_strerror(socket_last_error()); |
1388 | 1388 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1389 | 1389 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1390 | 1390 | if (isset($globalDebug)) echo "Restarting...\n"; |
1391 | 1391 | // Restart the script if possible |
1392 | 1392 | if (is_array($sockets)) { |
1393 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1393 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1394 | 1394 | |
1395 | - foreach ($sockets as $sock) { |
|
1395 | + foreach ($sockets as $sock) { |
|
1396 | 1396 | @socket_shutdown($sock,2); |
1397 | 1397 | @socket_close($sock); |
1398 | - } |
|
1398 | + } |
|
1399 | 1399 | |
1400 | 1400 | } |
1401 | 1401 | if ($globalDebug) echo "Waiting..."; |
@@ -1410,13 +1410,13 @@ discard block |
||
1410 | 1410 | if ($globalDebug) echo "Restart all connections..."; |
1411 | 1411 | connect_all($globalSources); |
1412 | 1412 | } |
1413 | - } |
|
1413 | + } |
|
1414 | 1414 | } |
1415 | 1415 | if ($globalDaemon === false) { |
1416 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1417 | - $SI->checkAll(); |
|
1416 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1417 | + $SI->checkAll(); |
|
1418 | + } |
|
1418 | 1419 | } |
1419 | - } |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | ?> |
@@ -21,7 +21,7 @@ |
||
21 | 21 | } |
22 | 22 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
23 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
24 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
24 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | require_once('header.php'); |