Completed
Push — master ( 2a2cc6...91b21c )
by Yannick
35:10
created
live-geojson.php 1 patch
Braces   +333 added lines, -135 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,16 +324,25 @@  discard block
 block discarded – undo
270 324
 */
271 325
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 326
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
273
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
274
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
327
+							if ($compress) {
328
+								$output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
329
+							} else {
330
+								$output .= '"callsign": '.json_encode(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
+							}
279 339
 						}
280 340
 						if (isset($spotter_item['registration'])) {
281
-							if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).',';
282
-							else $output .= '"registration": '.json_encode($spotter_item['registration']).',';
341
+							if ($compress) {
342
+								$output .= '"reg": '.json_encode($spotter_item['registration']).',';
343
+							} else {
344
+								$output .= '"registration": '.json_encode($spotter_item['registration']).',';
345
+							}
283 346
 						}
284 347
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
285 348
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
@@ -290,20 +353,30 @@  discard block
 block discarded – undo
290 353
 							$output .= '"aircraft_name": "NA",';
291 354
 						}
292 355
 						if (isset($spotter_item['aircraft_icao'])) {
293
-							if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
294
-							else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
356
+							if ($compress) {
357
+								$output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
358
+							} else {
359
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
360
+							}
295 361
 						}
296 362
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) {
297
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
298
-							else {
363
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
364
+								$spotter_item['aircraft_shadow'] = '';
365
+							} else {
299 366
 								$aircraft_icao = $spotter_item['aircraft_icao'];
300
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
301
-								else {
367
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
368
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
369
+								} else {
302 370
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
303
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
304
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
305
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
306
-									else $spotter_item['aircraft_shadow'] = '';
371
+									if (count($aircraft_info) > 0) {
372
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
373
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
374
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
375
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
376
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
377
+									} else {
378
+										$spotter_item['aircraft_shadow'] = '';
379
+									}
307 380
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
308 381
 								}
309 382
 							}
@@ -311,73 +384,139 @@  discard block
 block discarded – undo
311 384
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
312 385
 							if ($tracker) {
313 386
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
314
-									if ($compress) $output .= '"as": "ambulance.png",';
315
-									else $output .= '"aircraft_shadow": "ambulance.png",';
387
+									if ($compress) {
388
+										$output .= '"as": "ambulance.png",';
389
+									} else {
390
+										$output .= '"aircraft_shadow": "ambulance.png",';
391
+									}
316 392
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
317
-									if ($compress) $output .= '"as": "police.png",';
318
-									else $output .= '"aircraft_shadow": "police.png",';
393
+									if ($compress) {
394
+										$output .= '"as": "police.png",';
395
+									} else {
396
+										$output .= '"aircraft_shadow": "police.png",';
397
+									}
319 398
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
320
-									if ($compress) $output .= '"as": "ship.png",';
321
-									else $output .= '"aircraft_shadow": "ship.png",';
399
+									if ($compress) {
400
+										$output .= '"as": "ship.png",';
401
+									} else {
402
+										$output .= '"aircraft_shadow": "ship.png",';
403
+									}
322 404
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
323
-									if ($compress) $output .= '"as": "ship.png",';
324
-									else $output .= '"aircraft_shadow": "ship.png",';
405
+									if ($compress) {
406
+										$output .= '"as": "ship.png",';
407
+									} else {
408
+										$output .= '"aircraft_shadow": "ship.png",';
409
+									}
325 410
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
326
-									if ($compress) $output .= '"as": "ship.png",';
327
-									else $output .= '"aircraft_shadow": "ship.png",';
411
+									if ($compress) {
412
+										$output .= '"as": "ship.png",';
413
+									} else {
414
+										$output .= '"aircraft_shadow": "ship.png",';
415
+									}
328 416
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
329
-									if ($compress) $output .= '"as": "truck.png",';
330
-									else $output .= '"aircraft_shadow": "truck.png",';
417
+									if ($compress) {
418
+										$output .= '"as": "truck.png",';
419
+									} else {
420
+										$output .= '"aircraft_shadow": "truck.png",';
421
+									}
331 422
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
332
-									if ($compress) $output .= '"as": "truck.png",';
333
-									else $output .= '"aircraft_shadow": "truck.png",';
423
+									if ($compress) {
424
+										$output .= '"as": "truck.png",';
425
+									} else {
426
+										$output .= '"aircraft_shadow": "truck.png",';
427
+									}
334 428
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
335
-									if ($compress) $output .= '"as": "aircraft.png",';
336
-									else $output .= '"aircraft_shadow": "aircraft.png",';
429
+									if ($compress) {
430
+										$output .= '"as": "aircraft.png",';
431
+									} else {
432
+										$output .= '"aircraft_shadow": "aircraft.png",';
433
+									}
337 434
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
338
-									if ($compress) $output .= '"as": "aircraft.png",';
339
-									else $output .= '"aircraft_shadow": "aircraft.png",';
435
+									if ($compress) {
436
+										$output .= '"as": "aircraft.png",';
437
+									} else {
438
+										$output .= '"aircraft_shadow": "aircraft.png",';
439
+									}
340 440
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
341
-									if ($compress) $output .= '"as": "helico.png",';
342
-									else $output .= '"aircraft_shadow": "helico.png",';
441
+									if ($compress) {
442
+										$output .= '"as": "helico.png",';
443
+									} else {
444
+										$output .= '"aircraft_shadow": "helico.png",';
445
+									}
343 446
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
344
-									if ($compress) $output .= '"as": "rail.png",';
345
-									else $output .= '"aircraft_shadow": "rail.png",';
447
+									if ($compress) {
448
+										$output .= '"as": "rail.png",';
449
+									} else {
450
+										$output .= '"aircraft_shadow": "rail.png",';
451
+									}
346 452
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
347
-									if ($compress) $output .= '"as": "firetruck.png",';
348
-									else $output .= '"aircraft_shadow": "firetruck.png",';
453
+									if ($compress) {
454
+										$output .= '"as": "firetruck.png",';
455
+									} else {
456
+										$output .= '"aircraft_shadow": "firetruck.png",';
457
+									}
349 458
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
350
-									if ($compress) $output .= '"as": "bus.png",';
351
-									else $output .= '"aircraft_shadow": "bus.png",';
459
+									if ($compress) {
460
+										$output .= '"as": "bus.png",';
461
+									} else {
462
+										$output .= '"aircraft_shadow": "bus.png",';
463
+									}
352 464
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
353
-									if ($compress) $output .= '"as": "phone.png",';
354
-									else $output .= '"aircraft_shadow": "phone.png",';
465
+									if ($compress) {
466
+										$output .= '"as": "phone.png",';
467
+									} else {
468
+										$output .= '"aircraft_shadow": "phone.png",';
469
+									}
355 470
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
356
-									if ($compress) $output .= '"as": "jogger.png",';
357
-									else $output .= '"aircraft_shadow": "jogger.png",';
471
+									if ($compress) {
472
+										$output .= '"as": "jogger.png",';
473
+									} else {
474
+										$output .= '"aircraft_shadow": "jogger.png",';
475
+									}
358 476
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
359
-									if ($compress) $output .= '"as": "bike.png",';
360
-									else $output .= '"aircraft_shadow": "bike.png",';
477
+									if ($compress) {
478
+										$output .= '"as": "bike.png",';
479
+									} else {
480
+										$output .= '"aircraft_shadow": "bike.png",';
481
+									}
361 482
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
362
-									if ($compress) $output .= '"as": "motorcycle.png",';
363
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
483
+									if ($compress) {
484
+										$output .= '"as": "motorcycle.png",';
485
+									} else {
486
+										$output .= '"aircraft_shadow": "motorcycle.png",';
487
+									}
364 488
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
365
-									if ($compress) $output .= '"as": "balloon.png",';
366
-									else $output .= '"aircraft_shadow": "balloon.png",';
489
+									if ($compress) {
490
+										$output .= '"as": "balloon.png",';
491
+									} else {
492
+										$output .= '"aircraft_shadow": "balloon.png",';
493
+									}
367 494
 								} else {
368
-									if ($compress) $output .= '"as": "car.png",';
369
-									else $output .= '"aircraft_shadow": "car.png",';
495
+									if ($compress) {
496
+										$output .= '"as": "car.png",';
497
+									} else {
498
+										$output .= '"aircraft_shadow": "car.png",';
499
+									}
370 500
 								}
371 501
 							} elseif ($marine) {
372
-								if ($compress) $output .= '"as": "ship.png",';
373
-								else $output .= '"aircraft_shadow": "ship.png",';
502
+								if ($compress) {
503
+									$output .= '"as": "ship.png",';
504
+								} else {
505
+									$output .= '"aircraft_shadow": "ship.png",';
506
+								}
374 507
 							} else {
375
-								if ($compress) $output .= '"as": "default.png",';
376
-								else $output .= '"aircraft_shadow": "default.png",';
508
+								if ($compress) {
509
+									$output .= '"as": "default.png",';
510
+								} else {
511
+									$output .= '"aircraft_shadow": "default.png",';
512
+								}
377 513
 							}
378 514
 						} else {
379
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
380
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
515
+							if ($compress) {
516
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
517
+							} else {
518
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
519
+							}
381 520
 						}
382 521
 						if (isset($spotter_item['airline_name'])) {
383 522
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -385,8 +524,11 @@  discard block
 block discarded – undo
385 524
 							$output .= '"airline_name": "NA",';
386 525
 						}
387 526
 						if (isset($spotter_item['departure_airport'])) {
388
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
389
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
527
+							if ($compress) {
528
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
529
+							} else {
530
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
531
+							}
390 532
 						}
391 533
 						if (isset($spotter_item['departure_airport_city'])) {
392 534
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -398,8 +540,11 @@  discard block
 block discarded – undo
398 540
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
399 541
 						}
400 542
 						if (isset($spotter_item['arrival_airport'])) {
401
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
402
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
543
+							if ($compress) {
544
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
545
+							} else {
546
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
547
+							}
403 548
 						}
404 549
 						if (isset($spotter_item['arrival_airport_city'])) {
405 550
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -418,11 +563,17 @@  discard block
 block discarded – undo
418 563
 						}
419 564
 						
420 565
 						if (isset($spotter_item['real_altitude'])) {
421
-							if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
422
-							else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
566
+							if ($compress) {
567
+								$output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
568
+							} else {
569
+								$output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
570
+							}
423 571
 						} elseif (isset($spotter_item['altitude'])) {
424
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
425
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
572
+							if ($compress) {
573
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
574
+							} else {
575
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
576
+							}
426 577
 						}
427 578
 						
428 579
 						$heading = $spotter_item['heading'];
@@ -446,19 +597,24 @@  discard block
 block discarded – undo
446 597
 							}
447 598
 						}
448 599
 						
449
-						if ($compress)$output .= '"h": "'.$heading.'",';
450
-						else $output .= '"heading": "'.$heading.'",';
600
+						if ($compress) {
601
+							$output .= '"h": "'.$heading.'",';
602
+						} else {
603
+							$output .= '"heading": "'.$heading.'",';
604
+						}
451 605
 						if ($currenttime != '') {
452 606
 							if (strtotime($spotter_item['date']) < $currenttime) {
453 607
 								if (isset($archivespeed)) {
454 608
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
455 609
 									$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 {
610
+									if (!isset($idistance) || $fdistance < $idistance) {
611
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
612
+									} else {
458 613
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
459 614
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
460
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
461
-										else {
615
+										if (!isset($idistance) || $fdistance < $idistance) {
616
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
617
+										} else {
462 618
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
463 619
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
464 620
 										}
@@ -466,12 +622,14 @@  discard block
 block discarded – undo
466 622
 								} elseif ($usenextlatlon) {
467 623
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
468 624
 									$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 {
625
+									if (!isset($idistance) || $fdistance < $idistance) {
626
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
627
+									} else {
471 628
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
472 629
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
473
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
474
-										else {
630
+										if (!isset($idistance) || $fdistance < $idistance) {
631
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
632
+										} else {
475 633
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
476 634
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
477 635
 										}
@@ -510,7 +668,9 @@  discard block
 block discarded – undo
510 668
 							}
511 669
 						}
512 670
 
513
-						if (!$min) $output .= '"image": "'.$image.'",';
671
+						if (!$min) {
672
+							$output .= '"image": "'.$image.'",';
673
+						}
514 674
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
515 675
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
516 676
 						}
@@ -518,8 +678,11 @@  discard block
 block discarded – undo
518 678
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
519 679
 						}
520 680
 						if (isset($spotter_item['squawk'])) {
521
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
522
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
681
+							if ($compress) {
682
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
683
+							} else {
684
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
685
+							}
523 686
 						}
524 687
 						if (isset($spotter_item['squawk_usage'])) {
525 688
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -538,14 +701,23 @@  discard block
 block discarded – undo
538 701
 						}
539 702
 						// type when not aircraft ?
540 703
 						if (isset($spotter_item['type'])) {
541
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
542
-							else $output .= '"type": "'.$spotter_item['type'].'"';
704
+							if ($compress) {
705
+								$output .= '"t": "'.$spotter_item['type'].'"';
706
+							} else {
707
+								$output .= '"type": "'.$spotter_item['type'].'"';
708
+							}
543 709
 						} elseif ($marine) {
544
-							if ($compress) $output .= '"t": "ship"';
545
-							else $output .= '"type": "ship"';
710
+							if ($compress) {
711
+								$output .= '"t": "ship"';
712
+							} else {
713
+								$output .= '"type": "ship"';
714
+							}
546 715
 						} else {
547
-							if ($compress) $output .= '"t": "aircraft"';
548
-							else $output .= '"type": "aircraft"';
716
+							if ($compress) {
717
+								$output .= '"t": "aircraft"';
718
+							} else {
719
+								$output .= '"type": "aircraft"';
720
+							}
549 721
 						}
550 722
 						$output .= '},';
551 723
 						$output .= '"geometry": {';
@@ -553,15 +725,19 @@  discard block
 block discarded – undo
553 725
 								$output .= '"coordinates": [';
554 726
 								if ($currenttime != '') {
555 727
 									if (strtotime($spotter_item['date']) < $currenttime) {
556
-										if (!isset($archivespeed)) $archivespeed = 1;
728
+										if (!isset($archivespeed)) {
729
+											$archivespeed = 1;
730
+										}
557 731
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
558 732
 										$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 {
733
+										if (!isset($idistance) || $fdistance < $idistance) {
734
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
735
+										} else {
561 736
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
562 737
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
563
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
564
-											else {
738
+											if (!isset($idistance) || $fdistance < $idistance) {
739
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
740
+											} else {
565 741
 												$output .= $spotter_item['longitude'].', ';
566 742
 												$output .= $spotter_item['latitude'];
567 743
 											}
@@ -639,7 +815,9 @@  discard block
 block discarded – undo
639 815
 			}
640 816
 */
641 817
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
642
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
818
+				if ($history == '' && isset($_COOKIE['history'])) {
819
+					$history = $_COOKIE['history'];
820
+				}
643 821
 				
644 822
 				if (
645 823
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -709,8 +887,11 @@  discard block
 block discarded – undo
709 887
 									$output_history .= ']}},';
710 888
 									$output .= $output_history;
711 889
 								}
712
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
713
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
890
+								if ($compress) {
891
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
892
+								} else {
893
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
894
+								}
714 895
 							}
715 896
 							$output_history .= '[';
716 897
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -731,10 +912,15 @@  discard block
 block discarded – undo
731 912
 							if ($d == false) {
732 913
 								if ($compress) {
733 914
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
734
-									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>",';
735
-									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>",';
915
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
916
+										$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>",';
917
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
918
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
919
+									}
736 920
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
737
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
921
+								} else {
922
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
923
+								}
738 924
 								$d = true;
739 925
 							}
740 926
 							$output_history .= '[';
@@ -757,7 +943,9 @@  discard block
 block discarded – undo
757 943
 							$output_historyd = '[';
758 944
 							$output_historyd .=  $spotter_item['longitude'].', ';
759 945
 							$output_historyd .=  $spotter_item['latitude'];
760
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
946
+							if (isset($spotter_history['altitude'])) {
947
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
948
+							}
761 949
 							$output_historyd .= '],';
762 950
 							//$output_history = $output_historyd.$output_history;
763 951
 							$output_history = $output_history.$output_historyd;
@@ -784,8 +972,11 @@  discard block
 block discarded – undo
784 972
 				        && $spotter_item['arrival_airport'] != 'NA' 
785 973
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
786 974
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
787
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
788
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
975
+				    if ($compress) {
976
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
977
+				    } else {
978
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
979
+				    }
789 980
 				    if (isset($spotter_item['departure_airport_latitude'])) {
790 981
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
791 982
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -818,8 +1009,11 @@  discard block
 block discarded – undo
818 1009
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
819 1010
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
820 1011
 				    $havedata = false;
821
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
822
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1012
+				    if ($compress) {
1013
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1014
+				    } else {
1015
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1016
+				    }
823 1017
 				    
824 1018
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
825 1019
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -844,7 +1038,9 @@  discard block
 block discarded – undo
844 1038
 					$output_dest  = substr($output_dest, 0, -1);
845 1039
 				    }
846 1040
 				    $output_dest .= ']}},';
847
-				    if ($havedata) $output .= $output_dest;
1041
+				    if ($havedata) {
1042
+				    	$output .= $output_dest;
1043
+				    }
848 1044
 				    unset($output_dest);
849 1045
 				}
850 1046
 			}
@@ -852,7 +1048,9 @@  discard block
 block discarded – undo
852 1048
 			$output .= ']';
853 1049
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
854 1050
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
855
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1051
+			if (isset($begindate)) {
1052
+				$output .= '"archive_date": "'.$begindate.'",';
1053
+			}
856 1054
 			$output .= '"fc": "'.$j.'"';
857 1055
 		} else {
858 1056
 			$output .= '"features": ';
Please login to merge, or discard this patch.