@@ -3,18 +3,31 @@ discard block |
||
3 | 3 | require_once('../require/class.Language.php'); |
4 | 4 | |
5 | 5 | // Compressed GeoJson is used if true |
6 | -if (!isset($globalJsonCompress)) $compress = true; |
|
7 | -else $compress = $globalJsonCompress; |
|
6 | +if (!isset($globalJsonCompress)) { |
|
7 | + $compress = true; |
|
8 | +} else { |
|
9 | + $compress = $globalJsonCompress; |
|
10 | +} |
|
8 | 11 | |
9 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
10 | -if (isset($_GET['flightaware_id'])) $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
12 | +if (isset($_GET['ident'])) { |
|
13 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
14 | +} |
|
15 | +if (isset($_GET['flightaware_id'])) { |
|
16 | + $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
17 | +} |
|
11 | 18 | $archive = false; |
12 | -if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') $archive = true; |
|
19 | +if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') { |
|
20 | + $archive = true; |
|
21 | +} |
|
13 | 22 | ?> |
14 | 23 | <?php |
15 | -if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor']; |
|
16 | -elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor; |
|
17 | -else $IconColor = '1a3151'; |
|
24 | +if (isset($_COOKIE['IconColor'])) { |
|
25 | + $IconColor = $_COOKIE['IconColor']; |
|
26 | +} elseif (isset($globalAircraftIconColor)) { |
|
27 | + $IconColor = $globalAircraftIconColor; |
|
28 | +} else { |
|
29 | + $IconColor = '1a3151'; |
|
30 | +} |
|
18 | 31 | ?> |
19 | 32 | <?php |
20 | 33 | if (isset($globalDebug) && $globalDebug === TRUE) { |
@@ -92,9 +105,12 @@ discard block |
||
92 | 105 | |
93 | 106 | function update_airportsLayer() { |
94 | 107 | <?php |
95 | - if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom']; |
|
96 | - else $getZoom = '7'; |
|
97 | -?> |
|
108 | + if (isset($_COOKIE['AirportZoom'])) { |
|
109 | + $getZoom = $_COOKIE['AirportZoom']; |
|
110 | + } else { |
|
111 | + $getZoom = '7'; |
|
112 | + } |
|
113 | + ?> |
|
98 | 114 | if (typeof airportsLayer != 'undefined') { |
99 | 115 | if (map.hasLayer(airportsLayer) == true) { |
100 | 116 | map.removeLayer(airportsLayer); |
@@ -378,7 +394,12 @@ discard block |
||
378 | 394 | <?php |
379 | 395 | } else { |
380 | 396 | ?> |
381 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
397 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
398 | + print $archiveupdatetime*1000; |
|
399 | +} else { |
|
400 | + print $globalMapRefresh*1000+20000; |
|
401 | +} |
|
402 | +?>+feature.properties.sqt*1000); |
|
382 | 403 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
383 | 404 | <?php |
384 | 405 | } |
@@ -428,7 +449,12 @@ discard block |
||
428 | 449 | <?php |
429 | 450 | } else { |
430 | 451 | ?> |
431 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
452 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
453 | + print $archiveupdatetime*1000; |
|
454 | +} else { |
|
455 | + print $globalMapRefresh*1000+20000; |
|
456 | +} |
|
457 | +?>+feature.properties.sqt*1000); |
|
432 | 458 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
433 | 459 | <?php |
434 | 460 | } |
@@ -475,7 +501,12 @@ discard block |
||
475 | 501 | <?php |
476 | 502 | } else { |
477 | 503 | ?> |
478 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
504 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
505 | + print $archiveupdatetime*1000; |
|
506 | +} else { |
|
507 | + print $globalMapRefresh*1000+20000; |
|
508 | +} |
|
509 | +?>+feature.properties.sqt*1000); |
|
479 | 510 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
480 | 511 | <?php |
481 | 512 | } |
@@ -981,7 +1012,12 @@ discard block |
||
981 | 1012 | } else { |
982 | 1013 | ?> |
983 | 1014 | //then load it again every 30 seconds |
984 | - reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
1015 | + reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { |
|
1016 | + print $globalMapRefresh*1000; |
|
1017 | +} else { |
|
1018 | + print '30000'; |
|
1019 | +} |
|
1020 | +?>); |
|
985 | 1021 | var currentdate = new Date(); |
986 | 1022 | var currentyear = new Date().getFullYear(); |
987 | 1023 | var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0)); |
@@ -993,7 +1029,12 @@ discard block |
||
993 | 1029 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
994 | 1030 | ?> |
995 | 1031 | update_polarLayer(); |
996 | - setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
1032 | + setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
1033 | + print $globalMapRefresh*1000*2; |
|
1034 | +} else { |
|
1035 | + print '60000'; |
|
1036 | +} |
|
1037 | +?>); |
|
997 | 1038 | <?php |
998 | 1039 | } |
999 | 1040 | ?> |
@@ -1008,7 +1049,12 @@ discard block |
||
1008 | 1049 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
1009 | 1050 | ?> |
1010 | 1051 | update_atcLayer(); |
1011 | - setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
1052 | + setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
1053 | + print $globalMapRefresh*1000*2; |
|
1054 | +} else { |
|
1055 | + print '60000'; |
|
1056 | +} |
|
1057 | +?>); |
|
1012 | 1058 | <?php |
1013 | 1059 | } |
1014 | 1060 | ?> |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | $tracker = false; |
13 | 13 | $marine = false; |
14 | 14 | $usecoord = false; |
15 | -if (isset($_GET['test'])) exit(); |
|
15 | +if (isset($_GET['test'])) { |
|
16 | + exit(); |
|
17 | +} |
|
16 | 18 | if (isset($_GET['tracker'])) { |
17 | 19 | $tracker = true; |
18 | 20 | } |
@@ -57,28 +59,55 @@ discard block |
||
57 | 59 | } |
58 | 60 | header('Content-Type: text/javascript'); |
59 | 61 | |
60 | -if (!isset($globalJsonCompress)) $compress = true; |
|
61 | -else $compress = $globalJsonCompress; |
|
62 | +if (!isset($globalJsonCompress)) { |
|
63 | + $compress = true; |
|
64 | +} else { |
|
65 | + $compress = $globalJsonCompress; |
|
66 | +} |
|
62 | 67 | |
63 | 68 | $from_archive = false; |
64 | 69 | $min = true; |
65 | 70 | $allhistory = false; |
66 | 71 | $filter['source'] = array(); |
67 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
68 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
69 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
70 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
71 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
72 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
73 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
74 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
75 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
76 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
72 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
73 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
74 | +} |
|
75 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
76 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
77 | +} |
|
78 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
79 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
80 | +} |
|
81 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
82 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
83 | +} |
|
84 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
85 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
86 | +} |
|
87 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
88 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
89 | +} |
|
90 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') { |
|
91 | + $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
92 | +} |
|
93 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
94 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
95 | +} |
|
96 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
97 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
98 | +} |
|
99 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
100 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
101 | +} |
|
102 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
103 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
104 | +} |
|
78 | 105 | |
79 | 106 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
80 | 107 | $min = true; |
81 | -} else $min = false; |
|
108 | +} else { |
|
109 | + $min = false; |
|
110 | +} |
|
82 | 111 | |
83 | 112 | $spotter_array = array(); |
84 | 113 | |
@@ -189,24 +218,38 @@ discard block |
||
189 | 218 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
190 | 219 | } |
191 | 220 | } |
192 | - if ($flightcnt == '') $flightcnt = 0; |
|
193 | -} else $flightcnt = 0; |
|
221 | + if ($flightcnt == '') { |
|
222 | + $flightcnt = 0; |
|
223 | + } |
|
224 | + } else { |
|
225 | + $flightcnt = 0; |
|
226 | +} |
|
194 | 227 | |
195 | 228 | $sqltime = round(microtime(true)-$begintime,2); |
196 | 229 | |
197 | 230 | $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
198 | -if ($currenttime != '') $currenttime = round($currenttime/1000); |
|
231 | +if ($currenttime != '') { |
|
232 | + $currenttime = round($currenttime/1000); |
|
233 | +} |
|
199 | 234 | |
200 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
201 | -else $usenextlatlon = true; |
|
202 | -if ($usenextlatlon === false) $currenttime = ''; |
|
235 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
236 | + $usenextlatlon = false; |
|
237 | +} else { |
|
238 | + $usenextlatlon = true; |
|
239 | +} |
|
240 | +if ($usenextlatlon === false) { |
|
241 | + $currenttime = ''; |
|
242 | +} |
|
203 | 243 | $j = 0; |
204 | 244 | $prev_flightaware_id = ''; |
205 | 245 | $aircrafts_shadow = array(); |
206 | 246 | $output = '{'; |
207 | 247 | $output .= '"type": "FeatureCollection",'; |
208 | - if ($min) $output .= '"minimal": "true",'; |
|
209 | - else $output .= '"minimal": "false",'; |
|
248 | + if ($min) { |
|
249 | + $output .= '"minimal": "true",'; |
|
250 | + } else { |
|
251 | + $output .= '"minimal": "false",'; |
|
252 | + } |
|
210 | 253 | //$output .= '"fc": "'.$flightcnt.'",'; |
211 | 254 | $output .= '"sqt": "'.$sqltime.'",'; |
212 | 255 | |
@@ -251,18 +294,29 @@ discard block |
||
251 | 294 | } |
252 | 295 | $output .= '"properties": {'; |
253 | 296 | if (isset($spotter_item['flightaware_id'])) { |
254 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
255 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
297 | + if ($compress) { |
|
298 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
299 | + } else { |
|
300 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
301 | + } |
|
256 | 302 | } elseif (isset($spotter_item['famtrackid'])) { |
257 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
258 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
303 | + if ($compress) { |
|
304 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
305 | + } else { |
|
306 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
307 | + } |
|
259 | 308 | } elseif (isset($spotter_item['fammarine_id'])) { |
260 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
261 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
309 | + if ($compress) { |
|
310 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
311 | + } else { |
|
312 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
313 | + } |
|
262 | 314 | } |
263 | 315 | $output .= '"fc": "'.$flightcnt.'",'; |
264 | 316 | $output .= '"sqt": "'.$sqltime.'",'; |
265 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
317 | + if (isset($begindate)) { |
|
318 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
319 | + } |
|
266 | 320 | |
267 | 321 | /* |
268 | 322 | if ($min) $output .= '"minimal": "true",'; |
@@ -270,14 +324,22 @@ discard block |
||
270 | 324 | */ |
271 | 325 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
272 | 326 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
273 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
274 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
327 | + if ($compress) { |
|
328 | + $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
329 | + } else { |
|
330 | + $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
331 | + } |
|
275 | 332 | //" |
276 | 333 | } else { |
277 | - if ($compress) $output .= '"c": "NA",'; |
|
278 | - else $output .= '"callsign": "NA",'; |
|
334 | + if ($compress) { |
|
335 | + $output .= '"c": "NA",'; |
|
336 | + } else { |
|
337 | + $output .= '"callsign": "NA",'; |
|
338 | + } |
|
339 | + } |
|
340 | + if (isset($spotter_item['registration'])) { |
|
341 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
279 | 342 | } |
280 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
281 | 343 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
282 | 344 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
283 | 345 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -290,16 +352,23 @@ discard block |
||
290 | 352 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
291 | 353 | } |
292 | 354 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) { |
293 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
294 | - else { |
|
355 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
356 | + $spotter_item['aircraft_shadow'] = ''; |
|
357 | + } else { |
|
295 | 358 | $aircraft_icao = $spotter_item['aircraft_icao']; |
296 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
297 | - else { |
|
359 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
360 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
361 | + } else { |
|
298 | 362 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
299 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
300 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
301 | - elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
302 | - else $spotter_item['aircraft_shadow'] = ''; |
|
363 | + if (count($aircraft_info) > 0) { |
|
364 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
365 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
366 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
367 | + } elseif ($aircraft_icao == 'PARAGLIDER') { |
|
368 | + $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png'; |
|
369 | + } else { |
|
370 | + $spotter_item['aircraft_shadow'] = ''; |
|
371 | + } |
|
303 | 372 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
304 | 373 | } |
305 | 374 | } |
@@ -307,73 +376,139 @@ discard block |
||
307 | 376 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
308 | 377 | if ($tracker) { |
309 | 378 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
310 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
311 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
379 | + if ($compress) { |
|
380 | + $output .= '"as": "ambulance.png",'; |
|
381 | + } else { |
|
382 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
383 | + } |
|
312 | 384 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
313 | - if ($compress) $output .= '"as": "police.png",'; |
|
314 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
385 | + if ($compress) { |
|
386 | + $output .= '"as": "police.png",'; |
|
387 | + } else { |
|
388 | + $output .= '"aircraft_shadow": "police.png",'; |
|
389 | + } |
|
315 | 390 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
316 | - if ($compress) $output .= '"as": "ship.png",'; |
|
317 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
391 | + if ($compress) { |
|
392 | + $output .= '"as": "ship.png",'; |
|
393 | + } else { |
|
394 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
395 | + } |
|
318 | 396 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
319 | - if ($compress) $output .= '"as": "ship.png",'; |
|
320 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
397 | + if ($compress) { |
|
398 | + $output .= '"as": "ship.png",'; |
|
399 | + } else { |
|
400 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
401 | + } |
|
321 | 402 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
322 | - if ($compress) $output .= '"as": "ship.png",'; |
|
323 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
403 | + if ($compress) { |
|
404 | + $output .= '"as": "ship.png",'; |
|
405 | + } else { |
|
406 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
407 | + } |
|
324 | 408 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
325 | - if ($compress) $output .= '"as": "truck.png",'; |
|
326 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
409 | + if ($compress) { |
|
410 | + $output .= '"as": "truck.png",'; |
|
411 | + } else { |
|
412 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
413 | + } |
|
327 | 414 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
328 | - if ($compress) $output .= '"as": "truck.png",'; |
|
329 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
415 | + if ($compress) { |
|
416 | + $output .= '"as": "truck.png",'; |
|
417 | + } else { |
|
418 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
419 | + } |
|
330 | 420 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
331 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
332 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
421 | + if ($compress) { |
|
422 | + $output .= '"as": "aircraft.png",'; |
|
423 | + } else { |
|
424 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
425 | + } |
|
333 | 426 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
334 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
335 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
427 | + if ($compress) { |
|
428 | + $output .= '"as": "aircraft.png",'; |
|
429 | + } else { |
|
430 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
431 | + } |
|
336 | 432 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
337 | - if ($compress) $output .= '"as": "helico.png",'; |
|
338 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
433 | + if ($compress) { |
|
434 | + $output .= '"as": "helico.png",'; |
|
435 | + } else { |
|
436 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
437 | + } |
|
339 | 438 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
340 | - if ($compress) $output .= '"as": "rail.png",'; |
|
341 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
439 | + if ($compress) { |
|
440 | + $output .= '"as": "rail.png",'; |
|
441 | + } else { |
|
442 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
443 | + } |
|
342 | 444 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
343 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
344 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
445 | + if ($compress) { |
|
446 | + $output .= '"as": "firetruck.png",'; |
|
447 | + } else { |
|
448 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
449 | + } |
|
345 | 450 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
346 | - if ($compress) $output .= '"as": "bus.png",'; |
|
347 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
451 | + if ($compress) { |
|
452 | + $output .= '"as": "bus.png",'; |
|
453 | + } else { |
|
454 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
455 | + } |
|
348 | 456 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
349 | - if ($compress) $output .= '"as": "phone.png",'; |
|
350 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
457 | + if ($compress) { |
|
458 | + $output .= '"as": "phone.png",'; |
|
459 | + } else { |
|
460 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
461 | + } |
|
351 | 462 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
352 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
353 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
463 | + if ($compress) { |
|
464 | + $output .= '"as": "jogger.png",'; |
|
465 | + } else { |
|
466 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
467 | + } |
|
354 | 468 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
355 | - if ($compress) $output .= '"as": "bike.png",'; |
|
356 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
469 | + if ($compress) { |
|
470 | + $output .= '"as": "bike.png",'; |
|
471 | + } else { |
|
472 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
473 | + } |
|
357 | 474 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
358 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
359 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
475 | + if ($compress) { |
|
476 | + $output .= '"as": "motorcycle.png",'; |
|
477 | + } else { |
|
478 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
479 | + } |
|
360 | 480 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
361 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
362 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
481 | + if ($compress) { |
|
482 | + $output .= '"as": "balloon.png",'; |
|
483 | + } else { |
|
484 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
485 | + } |
|
363 | 486 | } else { |
364 | - if ($compress) $output .= '"as": "car.png",'; |
|
365 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
487 | + if ($compress) { |
|
488 | + $output .= '"as": "car.png",'; |
|
489 | + } else { |
|
490 | + $output .= '"aircraft_shadow": "car.png",'; |
|
491 | + } |
|
366 | 492 | } |
367 | 493 | } elseif ($marine) { |
368 | - if ($compress) $output .= '"as": "ship.png",'; |
|
369 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
494 | + if ($compress) { |
|
495 | + $output .= '"as": "ship.png",'; |
|
496 | + } else { |
|
497 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
498 | + } |
|
370 | 499 | } else { |
371 | - if ($compress) $output .= '"as": "default.png",'; |
|
372 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
500 | + if ($compress) { |
|
501 | + $output .= '"as": "default.png",'; |
|
502 | + } else { |
|
503 | + $output .= '"aircraft_shadow": "default.png",'; |
|
504 | + } |
|
373 | 505 | } |
374 | 506 | } else { |
375 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
376 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
507 | + if ($compress) { |
|
508 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
509 | + } else { |
|
510 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
511 | + } |
|
377 | 512 | } |
378 | 513 | if (isset($spotter_item['airline_name'])) { |
379 | 514 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -381,8 +516,11 @@ discard block |
||
381 | 516 | $output .= '"airline_name": "NA",'; |
382 | 517 | } |
383 | 518 | if (isset($spotter_item['departure_airport'])) { |
384 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
385 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
519 | + if ($compress) { |
|
520 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
521 | + } else { |
|
522 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
523 | + } |
|
386 | 524 | } |
387 | 525 | if (isset($spotter_item['departure_airport_city'])) { |
388 | 526 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -394,8 +532,11 @@ discard block |
||
394 | 532 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
395 | 533 | } |
396 | 534 | if (isset($spotter_item['arrival_airport'])) { |
397 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
398 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
535 | + if ($compress) { |
|
536 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
537 | + } else { |
|
538 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
539 | + } |
|
399 | 540 | } |
400 | 541 | if (isset($spotter_item['arrival_airport_city'])) { |
401 | 542 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -414,11 +555,17 @@ discard block |
||
414 | 555 | } |
415 | 556 | |
416 | 557 | if (isset($spotter_item['real_altitude'])) { |
417 | - if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",'; |
|
418 | - else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",'; |
|
558 | + if ($compress) { |
|
559 | + $output .= '"a": "'.($spotter_item['real_altitude']/100).'",'; |
|
560 | + } else { |
|
561 | + $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",'; |
|
562 | + } |
|
419 | 563 | } elseif (isset($spotter_item['altitude'])) { |
420 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
421 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
564 | + if ($compress) { |
|
565 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
566 | + } else { |
|
567 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
568 | + } |
|
422 | 569 | } |
423 | 570 | |
424 | 571 | $heading = $spotter_item['heading']; |
@@ -442,19 +589,24 @@ discard block |
||
442 | 589 | } |
443 | 590 | } |
444 | 591 | |
445 | - if ($compress)$output .= '"h": "'.$heading.'",'; |
|
446 | - else $output .= '"heading": "'.$heading.'",'; |
|
592 | + if ($compress) { |
|
593 | + $output .= '"h": "'.$heading.'",'; |
|
594 | + } else { |
|
595 | + $output .= '"heading": "'.$heading.'",'; |
|
596 | + } |
|
447 | 597 | if ($currenttime != '') { |
448 | 598 | if (strtotime($spotter_item['date']) < $currenttime) { |
449 | 599 | if (isset($archivespeed)) { |
450 | 600 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
451 | 601 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
452 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
453 | - else { |
|
602 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
603 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
604 | + } else { |
|
454 | 605 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
455 | 606 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
456 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
457 | - else { |
|
607 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
608 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
609 | + } else { |
|
458 | 610 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed); |
459 | 611 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
460 | 612 | } |
@@ -462,12 +614,14 @@ discard block |
||
462 | 614 | } elseif ($usenextlatlon) { |
463 | 615 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
464 | 616 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
465 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
466 | - else { |
|
617 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
618 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
619 | + } else { |
|
467 | 620 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh)); |
468 | 621 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
469 | - if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
470 | - else { |
|
622 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
623 | + $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
|
624 | + } else { |
|
471 | 625 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading); |
472 | 626 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
473 | 627 | } |
@@ -506,7 +660,9 @@ discard block |
||
506 | 660 | } |
507 | 661 | } |
508 | 662 | |
509 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
663 | + if (!$min) { |
|
664 | + $output .= '"image": "'.$image.'",'; |
|
665 | + } |
|
510 | 666 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
511 | 667 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
512 | 668 | } |
@@ -514,8 +670,11 @@ discard block |
||
514 | 670 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
515 | 671 | } |
516 | 672 | if (isset($spotter_item['squawk'])) { |
517 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
518 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
673 | + if ($compress) { |
|
674 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
675 | + } else { |
|
676 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
677 | + } |
|
519 | 678 | } |
520 | 679 | if (isset($spotter_item['squawk_usage'])) { |
521 | 680 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -534,14 +693,23 @@ discard block |
||
534 | 693 | } |
535 | 694 | // type when not aircraft ? |
536 | 695 | if (isset($spotter_item['type'])) { |
537 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
538 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
696 | + if ($compress) { |
|
697 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
698 | + } else { |
|
699 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
700 | + } |
|
539 | 701 | } elseif ($marine) { |
540 | - if ($compress) $output .= '"t": "ship"'; |
|
541 | - else $output .= '"type": "ship"'; |
|
702 | + if ($compress) { |
|
703 | + $output .= '"t": "ship"'; |
|
704 | + } else { |
|
705 | + $output .= '"type": "ship"'; |
|
706 | + } |
|
542 | 707 | } else { |
543 | - if ($compress) $output .= '"t": "aircraft"'; |
|
544 | - else $output .= '"type": "aircraft"'; |
|
708 | + if ($compress) { |
|
709 | + $output .= '"t": "aircraft"'; |
|
710 | + } else { |
|
711 | + $output .= '"type": "aircraft"'; |
|
712 | + } |
|
545 | 713 | } |
546 | 714 | $output .= '},'; |
547 | 715 | $output .= '"geometry": {'; |
@@ -549,15 +717,19 @@ discard block |
||
549 | 717 | $output .= '"coordinates": ['; |
550 | 718 | if ($currenttime != '') { |
551 | 719 | if (strtotime($spotter_item['date']) < $currenttime) { |
552 | - if (!isset($archivespeed)) $archivespeed = 1; |
|
720 | + if (!isset($archivespeed)) { |
|
721 | + $archivespeed = 1; |
|
722 | + } |
|
553 | 723 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
554 | 724 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
555 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
556 | - else { |
|
725 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
726 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
727 | + } else { |
|
557 | 728 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date']))); |
558 | 729 | $fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']); |
559 | - if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
560 | - else { |
|
730 | + if (!isset($idistance) || $fdistance < $idistance) { |
|
731 | + $output .= $nextcoord['longitude'].','.$nextcoord['latitude']; |
|
732 | + } else { |
|
561 | 733 | $output .= $spotter_item['longitude'].', '; |
562 | 734 | $output .= $spotter_item['latitude']; |
563 | 735 | } |
@@ -635,7 +807,9 @@ discard block |
||
635 | 807 | } |
636 | 808 | */ |
637 | 809 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
638 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
810 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
811 | + $history = $_COOKIE['history']; |
|
812 | + } |
|
639 | 813 | |
640 | 814 | if ( |
641 | 815 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -705,8 +879,11 @@ discard block |
||
705 | 879 | $output_history .= ']}},'; |
706 | 880 | $output .= $output_history; |
707 | 881 | } |
708 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
709 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
882 | + if ($compress) { |
|
883 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
884 | + } else { |
|
885 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
886 | + } |
|
710 | 887 | } |
711 | 888 | $output_history .= '['; |
712 | 889 | $output_history .= $spotter_history['longitude'].', '; |
@@ -727,10 +904,15 @@ discard block |
||
727 | 904 | if ($d == false) { |
728 | 905 | if ($compress) { |
729 | 906 | $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",'; |
730 | - if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
731 | - elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
907 | + if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') { |
|
908 | + $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
909 | + } elseif (isset($spotter_history_array[0]['mapmatching_engine'])) { |
|
910 | + $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",'; |
|
911 | + } |
|
732 | 912 | $output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
733 | - } else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
913 | + } else { |
|
914 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
915 | + } |
|
734 | 916 | $d = true; |
735 | 917 | } |
736 | 918 | $output_history .= '['; |
@@ -753,7 +935,9 @@ discard block |
||
753 | 935 | $output_historyd = '['; |
754 | 936 | $output_historyd .= $spotter_item['longitude'].', '; |
755 | 937 | $output_historyd .= $spotter_item['latitude']; |
756 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
938 | + if (isset($spotter_history['altitude'])) { |
|
939 | + $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
940 | + } |
|
757 | 941 | $output_historyd .= '],'; |
758 | 942 | //$output_history = $output_historyd.$output_history; |
759 | 943 | $output_history = $output_history.$output_historyd; |
@@ -780,8 +964,11 @@ discard block |
||
780 | 964 | && $spotter_item['arrival_airport'] != 'NA' |
781 | 965 | && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") |
782 | 966 | || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) { |
783 | - if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
784 | - else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
967 | + if ($compress) { |
|
968 | + $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
969 | + } else { |
|
970 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
971 | + } |
|
785 | 972 | if (isset($spotter_item['departure_airport_latitude'])) { |
786 | 973 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
787 | 974 | } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
@@ -814,8 +1001,11 @@ discard block |
||
814 | 1001 | || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) |
815 | 1002 | || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) { |
816 | 1003 | $havedata = false; |
817 | - if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
818 | - else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
1004 | + if ($compress) { |
|
1005 | + $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
1006 | + } else { |
|
1007 | + $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": ['; |
|
1008 | + } |
|
819 | 1009 | |
820 | 1010 | //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],'; |
821 | 1011 | if (isset($spotter_item['arrival_airport_latitude'])) { |
@@ -840,7 +1030,9 @@ discard block |
||
840 | 1030 | $output_dest = substr($output_dest, 0, -1); |
841 | 1031 | } |
842 | 1032 | $output_dest .= ']}},'; |
843 | - if ($havedata) $output .= $output_dest; |
|
1033 | + if ($havedata) { |
|
1034 | + $output .= $output_dest; |
|
1035 | + } |
|
844 | 1036 | unset($output_dest); |
845 | 1037 | } |
846 | 1038 | } |
@@ -848,7 +1040,9 @@ discard block |
||
848 | 1040 | $output .= ']'; |
849 | 1041 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
850 | 1042 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
851 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
1043 | + if (isset($begindate)) { |
|
1044 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
1045 | + } |
|
852 | 1046 | $output .= '"fc": "'.$j.'"'; |
853 | 1047 | } else { |
854 | 1048 | $output .= '"features": '; |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (SpotterLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -126,8 +130,11 @@ discard block |
||
126 | 130 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
127 | 131 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
128 | 132 | } |
129 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
130 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
133 | + if ($filter_query_where == '' && $where) { |
|
134 | + $filter_query_where = ' WHERE'; |
|
135 | + } elseif ($filter_query_where != '' && $and) { |
|
136 | + $filter_query_where .= ' AND'; |
|
137 | + } |
|
131 | 138 | if ($filter_query_where != '') { |
132 | 139 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
133 | 140 | } |
@@ -168,9 +175,13 @@ discard block |
||
168 | 175 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
169 | 176 | } |
170 | 177 | } |
171 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
178 | + if ($orderby_query == '') { |
|
179 | + $orderby_query = ' ORDER BY date DESC'; |
|
180 | + } |
|
172 | 181 | |
173 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
182 | + if (!isset($globalLiveInterval)) { |
|
183 | + $globalLiveInterval = '200'; |
|
184 | + } |
|
174 | 185 | if ($globalDBdriver == 'mysql') { |
175 | 186 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
176 | 187 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -193,7 +204,9 @@ discard block |
||
193 | 204 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
194 | 205 | date_default_timezone_set('UTC'); |
195 | 206 | $filter_query = $this->getFilter($filter,true,true); |
196 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
207 | + if (!isset($globalLiveInterval)) { |
|
208 | + $globalLiveInterval = '200'; |
|
209 | + } |
|
197 | 210 | if ($globalDBdriver == 'mysql') { |
198 | 211 | if (isset($globalArchive) && $globalArchive === TRUE) { |
199 | 212 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -244,8 +257,12 @@ discard block |
||
244 | 257 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
245 | 258 | $filter_query = $this->getFilter($filter,true,true); |
246 | 259 | |
247 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
248 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
260 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
261 | + $globalLiveInterval = '200'; |
|
262 | + } |
|
263 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
264 | + $globalMap3DAircraftsLimit = '300'; |
|
265 | + } |
|
249 | 266 | if ($globalDBdriver == 'mysql') { |
250 | 267 | if (isset($globalArchive) && $globalArchive === TRUE) { |
251 | 268 | /* |
@@ -256,25 +273,41 @@ discard block |
||
256 | 273 | */ |
257 | 274 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
258 | 275 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
259 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
260 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
276 | + if ($usecoord) { |
|
277 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
278 | + } |
|
279 | + if ($id != '') { |
|
280 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
281 | + } |
|
261 | 282 | $query .= "UNION |
262 | 283 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
263 | 284 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
264 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
265 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
285 | + if ($usecoord) { |
|
286 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
287 | + } |
|
288 | + if ($id != '') { |
|
289 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
290 | + } |
|
266 | 291 | $query .= ") AS spotter |
267 | 292 | WHERE latitude <> '0' AND longitude <> '0' |
268 | 293 | ORDER BY flightaware_id, date"; |
269 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
294 | + if ($limit) { |
|
295 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
296 | + } |
|
270 | 297 | } else { |
271 | 298 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
272 | 299 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
273 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
274 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
300 | + if ($usecoord) { |
|
301 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
302 | + } |
|
303 | + if ($id != '') { |
|
304 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
305 | + } |
|
275 | 306 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
276 | 307 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
277 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
308 | + if ($limit) { |
|
309 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
310 | + } |
|
278 | 311 | } |
279 | 312 | } else { |
280 | 313 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -286,28 +319,46 @@ discard block |
||
286 | 319 | */ |
287 | 320 | $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
288 | 321 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
289 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
290 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
322 | + if ($usecoord) { |
|
323 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
324 | + } |
|
325 | + if ($id != '') { |
|
326 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
327 | + } |
|
291 | 328 | $query .= "UNION |
292 | 329 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
293 | 330 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
294 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
295 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
331 | + if ($usecoord) { |
|
332 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
333 | + } |
|
334 | + if ($id != '') { |
|
335 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
336 | + } |
|
296 | 337 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
297 | 338 | $query .= "ORDER BY flightaware_id, date"; |
298 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
339 | + if ($limit) { |
|
340 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
341 | + } |
|
299 | 342 | } else { |
300 | 343 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
301 | 344 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
302 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
303 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
345 | + if ($usecoord) { |
|
346 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
347 | + } |
|
348 | + if ($id != '') { |
|
349 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
350 | + } |
|
304 | 351 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
305 | 352 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
306 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
353 | + if ($limit) { |
|
354 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
355 | + } |
|
307 | 356 | } |
308 | 357 | } |
309 | 358 | $query_values = array(); |
310 | - if ($id != '') $query_values = array(':id' => $id); |
|
359 | + if ($id != '') { |
|
360 | + $query_values = array(':id' => $id); |
|
361 | + } |
|
311 | 362 | try { |
312 | 363 | $sth = $this->db->prepare($query); |
313 | 364 | $sth->execute($query_values); |
@@ -330,7 +381,9 @@ discard block |
||
330 | 381 | global $globalDBdriver, $globalLiveInterval; |
331 | 382 | $filter_query = $this->getFilter($filter,true,true); |
332 | 383 | |
333 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | + if (!isset($globalLiveInterval)) { |
|
385 | + $globalLiveInterval = '200'; |
|
386 | + } |
|
334 | 387 | if ($globalDBdriver == 'mysql') { |
335 | 388 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
336 | 389 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -360,7 +413,9 @@ discard block |
||
360 | 413 | { |
361 | 414 | global $globalDBdriver, $globalLiveInterval; |
362 | 415 | $Spotter = new Spotter($this->db); |
363 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
416 | + if (!isset($globalLiveInterval)) { |
|
417 | + $globalLiveInterval = '200'; |
|
418 | + } |
|
364 | 419 | $filter_query = $this->getFilter($filter); |
365 | 420 | |
366 | 421 | if (is_array($coord)) { |
@@ -368,7 +423,9 @@ discard block |
||
368 | 423 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
369 | 424 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
370 | 425 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
371 | - } else return array(); |
|
426 | + } else { |
|
427 | + return array(); |
|
428 | + } |
|
372 | 429 | if ($globalDBdriver == 'mysql') { |
373 | 430 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
374 | 431 | } else { |
@@ -389,7 +446,9 @@ discard block |
||
389 | 446 | { |
390 | 447 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
391 | 448 | $Spotter = new Spotter($this->db); |
392 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
449 | + if (!isset($globalLiveInterval)) { |
|
450 | + $globalLiveInterval = '200'; |
|
451 | + } |
|
393 | 452 | $filter_query = $this->getFilter($filter,true,true); |
394 | 453 | |
395 | 454 | if (is_array($coord)) { |
@@ -397,7 +456,9 @@ discard block |
||
397 | 456 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
398 | 457 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
399 | 458 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
400 | - } else return array(); |
|
459 | + } else { |
|
460 | + return array(); |
|
461 | + } |
|
401 | 462 | if ($globalDBdriver == 'mysql') { |
402 | 463 | if (isset($globalArchive) && $globalArchive === TRUE) { |
403 | 464 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -624,11 +685,15 @@ discard block |
||
624 | 685 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
625 | 686 | if ($globalDBdriver == 'mysql') { |
626 | 687 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
627 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
688 | + if ($liveinterval) { |
|
689 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
690 | + } |
|
628 | 691 | $query .= ' ORDER BY date'; |
629 | 692 | } else { |
630 | 693 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
631 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
694 | + if ($liveinterval) { |
|
695 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
696 | + } |
|
632 | 697 | $query .= ' ORDER BY date'; |
633 | 698 | } |
634 | 699 | |
@@ -723,7 +788,9 @@ discard block |
||
723 | 788 | $i++; |
724 | 789 | $j++; |
725 | 790 | if ($j == 30) { |
726 | - if ($globalDebug) echo "."; |
|
791 | + if ($globalDebug) { |
|
792 | + echo "."; |
|
793 | + } |
|
727 | 794 | try { |
728 | 795 | |
729 | 796 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1076,7 +1143,9 @@ discard block |
||
1076 | 1143 | { |
1077 | 1144 | return false; |
1078 | 1145 | } |
1079 | - } else return ''; |
|
1146 | + } else { |
|
1147 | + return ''; |
|
1148 | + } |
|
1080 | 1149 | |
1081 | 1150 | if ($longitude != '') |
1082 | 1151 | { |
@@ -1084,7 +1153,9 @@ discard block |
||
1084 | 1153 | { |
1085 | 1154 | return false; |
1086 | 1155 | } |
1087 | - } else return ''; |
|
1156 | + } else { |
|
1157 | + return ''; |
|
1158 | + } |
|
1088 | 1159 | |
1089 | 1160 | if ($waypoints != '') |
1090 | 1161 | { |
@@ -1100,14 +1171,18 @@ discard block |
||
1100 | 1171 | { |
1101 | 1172 | return false; |
1102 | 1173 | } |
1103 | - } else $altitude = 0; |
|
1174 | + } else { |
|
1175 | + $altitude = 0; |
|
1176 | + } |
|
1104 | 1177 | if ($altitude_real != '') |
1105 | 1178 | { |
1106 | 1179 | if (!is_numeric($altitude_real)) |
1107 | 1180 | { |
1108 | 1181 | return false; |
1109 | 1182 | } |
1110 | - } else $altitude_real = 0; |
|
1183 | + } else { |
|
1184 | + $altitude_real = 0; |
|
1185 | + } |
|
1111 | 1186 | |
1112 | 1187 | if ($heading != '') |
1113 | 1188 | { |
@@ -1115,7 +1190,9 @@ discard block |
||
1115 | 1190 | { |
1116 | 1191 | return false; |
1117 | 1192 | } |
1118 | - } else $heading = 0; |
|
1193 | + } else { |
|
1194 | + $heading = 0; |
|
1195 | + } |
|
1119 | 1196 | |
1120 | 1197 | if ($groundspeed != '') |
1121 | 1198 | { |
@@ -1123,9 +1200,13 @@ discard block |
||
1123 | 1200 | { |
1124 | 1201 | return false; |
1125 | 1202 | } |
1126 | - } else $groundspeed = 0; |
|
1203 | + } else { |
|
1204 | + $groundspeed = 0; |
|
1205 | + } |
|
1127 | 1206 | date_default_timezone_set('UTC'); |
1128 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1207 | + if ($date == '') { |
|
1208 | + $date = date("Y-m-d H:i:s", time()); |
|
1209 | + } |
|
1129 | 1210 | |
1130 | 1211 | |
1131 | 1212 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1170,14 +1251,24 @@ discard block |
||
1170 | 1251 | $arrival_airport_country = ''; |
1171 | 1252 | |
1172 | 1253 | |
1173 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1174 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1175 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1176 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1254 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1255 | + $squawk = NULL; |
|
1256 | + } |
|
1257 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1258 | + $verticalrate = NULL; |
|
1259 | + } |
|
1260 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1261 | + $groundspeed = 0; |
|
1262 | + } |
|
1263 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1264 | + $heading = 0; |
|
1265 | + } |
|
1177 | 1266 | |
1178 | 1267 | $query = ''; |
1179 | 1268 | if ($globalArchive) { |
1180 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1269 | + if ($globalDebug) { |
|
1270 | + echo '-- Delete previous data -- '; |
|
1271 | + } |
|
1181 | 1272 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1182 | 1273 | } |
1183 | 1274 | |
@@ -1194,10 +1285,14 @@ discard block |
||
1194 | 1285 | return "error : ".$e->getMessage(); |
1195 | 1286 | } |
1196 | 1287 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1197 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1288 | + if ($globalDebug) { |
|
1289 | + echo '(Add to SBS archive : '; |
|
1290 | + } |
|
1198 | 1291 | $SpotterArchive = new SpotterArchive($this->db); |
1199 | 1292 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1200 | - if ($globalDebug) echo $result.')'; |
|
1293 | + if ($globalDebug) { |
|
1294 | + echo $result.')'; |
|
1295 | + } |
|
1201 | 1296 | } elseif ($globalDebug && $putinarchive !== true) { |
1202 | 1297 | echo '(Not adding to archive)'; |
1203 | 1298 | } elseif ($globalDebug && $noarchive === true) { |