Completed
Push — master ( 2a2cc6...91b21c )
by Yannick
35:10
created
live-geojson.php 2 patches
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
 $min = true;
65 65
 $allhistory = false;
66 66
 $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);
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);
78 78
 
79 79
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
80 80
 	$min = true;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 $spotter_array = array();
84 84
 
85 85
 if (isset($_GET['ident'])) {
86
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
86
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
87 87
 	if ($tracker) {
88 88
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
89 89
 	} elseif ($marine) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 	$allhistory = true;
99 99
 } elseif (isset($_GET['flightaware_id'])) {
100
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
100
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
101 101
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
102 102
 	if (empty($spotter_array)) {
103 103
 		$from_archive = true;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	$allhistory = true;
107 107
 } elseif (isset($_GET['famtrack_id'])) {
108
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
108
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
109 109
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
110 110
 	$allhistory = true;
111 111
 } elseif (isset($_GET['fammarine_id'])) {
112
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
112
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
113 113
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
114 114
 	$allhistory = true;
115 115
 /*
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 */
130 130
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) {
131 131
 	$usecoord = true;
132
-	$coord = explode(',',$_GET['coord']);
133
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
132
+	$coord = explode(',', $_GET['coord']);
133
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
134 134
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
135 135
 		if ($tracker) {
136
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
136
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
137 137
 		} elseif ($marine) {
138
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
138
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
139 139
 		} else {
140
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
140
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
141 141
 		}
142 142
 	} else {
143 143
 		if ($tracker) {
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	$from_archive = true;
153 153
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
154 154
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
155
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
156
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
157
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
158
-	$begindate = date('Y-m-d H:i:s',$begindate);
159
-	$enddate = date('Y-m-d H:i:s',$enddate);
160
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
155
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
156
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
157
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
158
+	$begindate = date('Y-m-d H:i:s', $begindate);
159
+	$enddate = date('Y-m-d H:i:s', $enddate);
160
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
161 161
 } elseif ($min) {
162 162
 	if ($tracker) {
163 163
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 #	$min = true;
170 170
 } else {
171 171
 	if ($tracker) {
172
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
172
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
173 173
 	} elseif ($marine) {
174
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
174
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
175 175
 	} else {
176
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
176
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
177 177
 	}
178 178
 }
179 179
 
180 180
 if ($usecoord) {
181 181
 	if (isset($_GET['archive'])) {
182
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
182
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
183 183
 	} else {
184 184
 		if ($tracker) {
185 185
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	if ($flightcnt == '') $flightcnt = 0;
193 193
 } else $flightcnt = 0;
194 194
 
195
-$sqltime = round(microtime(true)-$begintime,2);
195
+$sqltime = round(microtime(true) - $begintime, 2);
196 196
 
197
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
197
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
198 198
 if ($currenttime != '') $currenttime = round($currenttime/1000);
199 199
 
200 200
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		if (!empty($spotter_array) && is_array($spotter_array))
214 214
 		{
215 215
 			$output .= '"features": [';
216
-			foreach($spotter_array as $spotter_item)
216
+			foreach ($spotter_array as $spotter_item)
217 217
 			{
218 218
 				$j++;
219 219
 				unset($idistance);
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 */
271 271
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 272
 						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'])).',';
273
+							if ($compress) $output .= '"c": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
274
+							else $output .= '"callsign": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
275 275
 							//'
276 276
 						} else {
277 277
 							if ($compress) $output .= '"c": "NA",';
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 						}
284 284
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
285 285
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
286
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
286
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
287 287
 						} elseif (isset($spotter_item['aircraft_type'])) {
288 288
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
289 289
 						} elseif (!$min) {
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
 						if (isset($archivespeed) || $usenextlatlon) {
431 431
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
432 432
 								if (isset($spotter_item['arrival_airport_latitude'])) {
433
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
434
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
433
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
434
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
435 435
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
436 436
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
437 437
 								} else {
438 438
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
439 439
 									if (isset($aairport[0]['latitude'])) {
440
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
441
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
440
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
441
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
442 442
 										$farr_lat = $aairport[0]['latitude'];
443 443
 										$farr_lon = $aairport[0]['longitude'];
444 444
 									}
@@ -451,59 +451,59 @@  discard block
 block discarded – undo
451 451
 						if ($currenttime != '') {
452 452
 							if (strtotime($spotter_item['date']) < $currenttime) {
453 453
 								if (isset($archivespeed)) {
454
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
455
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
454
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
455
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
456 456
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
457 457
 									else {
458
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
459
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
458
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
459
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
460 460
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
461 461
 										else {
462
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
462
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
463 463
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
464 464
 										}
465 465
 									}
466 466
 								} elseif ($usenextlatlon) {
467
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
468
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
467
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
468
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
469 469
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
470 470
 									else {
471
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
472
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
471
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
472
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
473 473
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
474 474
 										else {
475
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
475
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
476 476
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
477 477
 										}
478 478
 									}
479 479
 								}
480 480
 							} else {
481 481
 								if (isset($archivespeed)) {
482
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
482
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
483 483
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
484 484
 								} elseif ($usenextlatlon) {
485
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
485
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
486 486
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
487 487
 								}
488 488
 							}
489 489
 						} else {
490 490
 							if (isset($archivespeed)) {
491
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
492
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
491
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
492
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
493 493
 								if (!isset($idistance) || $fdistance < $idistance) {
494 494
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495 495
 								} else {
496
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
496
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
497 497
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
498 498
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
499 499
 								}
500 500
 							} elseif ($usenextlatlon) {
501
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
502
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
501
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
502
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
503 503
 								if (!isset($idistance) || $fdistance < $idistance) {
504 504
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
505 505
 								} else {
506
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
506
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
507 507
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
508 508
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
509 509
 								}
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
 						if (!$min) $output .= '"image": "'.$image.'",';
514 514
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
515
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
515
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
516 516
 						}
517 517
 						if (isset($spotter_item['image_source_website'])) {
518 518
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
535 535
 						}
536 536
 						if (isset($spotter_item['acars'])) {
537
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
537
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
538 538
 						}
539 539
 						// type when not aircraft ?
540 540
 						if (isset($spotter_item['type'])) {
@@ -554,12 +554,12 @@  discard block
 block discarded – undo
554 554
 								if ($currenttime != '') {
555 555
 									if (strtotime($spotter_item['date']) < $currenttime) {
556 556
 										if (!isset($archivespeed)) $archivespeed = 1;
557
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
558
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
557
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
558
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
559 559
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
560 560
 										else {
561
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
562
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
561
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
562
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
563 563
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
564 564
 											else {
565 565
 												$output .= $spotter_item['longitude'].', ';
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
                 
639 639
 			}
640 640
 */
641
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
641
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
642 642
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
643 643
 				
644 644
 				if (
@@ -646,11 +646,11 @@  discard block
 block discarded – undo
646 646
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
647 647
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
648 648
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
649
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
649
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
650 650
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
651
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
651
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
652 652
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
653
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
653
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
654 654
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
655 655
 				    ) {
656 656
 					if ($tracker) {
@@ -679,9 +679,9 @@  discard block
 block discarded – undo
679 679
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
680 680
 							$MapMatching = new MapMatching();
681 681
 							if (isset($spotter_item['date_iso_8601'])) {
682
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601'])))));
682
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601'])))));
683 683
 							} else {
684
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date'])))));
684
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date'])))));
685 685
 							}
686 686
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
687 687
 						}
@@ -713,9 +713,9 @@  discard block
 block discarded – undo
713 713
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
714 714
 							}
715 715
 							$output_history .= '[';
716
-							$output_history .=  $spotter_history['longitude'].', ';
717
-							$output_history .=  $spotter_history['latitude'].', ';
718
-							$output_history .=  $spotter_history['altitude']*30.48;
716
+							$output_history .= $spotter_history['longitude'].', ';
717
+							$output_history .= $spotter_history['latitude'].', ';
718
+							$output_history .= $spotter_history['altitude']*30.48;
719 719
 							$output_history .= '],';
720 720
 							/*
721 721
 							if ($from_archive === false) {
@@ -738,8 +738,8 @@  discard block
 block discarded – undo
738 738
 								$d = true;
739 739
 							}
740 740
 							$output_history .= '[';
741
-							$output_history .=  $spotter_history['longitude'].', ';
742
-							$output_history .=  $spotter_history['latitude'];
741
+							$output_history .= $spotter_history['longitude'].', ';
742
+							$output_history .= $spotter_history['latitude'];
743 743
 							$output_history .= '],';
744 744
 							/*
745 745
 							if ($from_archive === false) {
@@ -755,9 +755,9 @@  discard block
 block discarded – undo
755 755
 						//echo $output_history;
756 756
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
757 757
 							$output_historyd = '[';
758
-							$output_historyd .=  $spotter_item['longitude'].', ';
759
-							$output_historyd .=  $spotter_item['latitude'];
760
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
758
+							$output_historyd .= $spotter_item['longitude'].', ';
759
+							$output_historyd .= $spotter_item['latitude'];
760
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
761 761
 							$output_historyd .= '],';
762 762
 							//$output_history = $output_historyd.$output_history;
763 763
 							$output_history = $output_history.$output_historyd;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 							$last = array_pop($spotter_history_array);
766 766
 							$latitude = $last['latitude'];
767 767
 							$longitude = $last['longitude'];
768
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
768
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
769 769
 						}
770 770
 						
771 771
 						$output_history  = substr($output_history, 0, -1);
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 					}
777 777
 				}
778 778
 				
779
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
779
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
780 780
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
781 781
 				     && (isset($spotter_item['departure_airport']) 
782 782
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 
811 811
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
812 812
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
813
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
813
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
814 814
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
815 815
 				     && (isset($spotter_item['arrival_airport']) 
816 816
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -837,11 +837,11 @@  discard block
 block discarded – undo
837 837
 					}
838 838
 				    }
839 839
 				    if ($havedata) {
840
-					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
840
+					$line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon);
841 841
 					foreach ($line[0] as $coord) {
842 842
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
843 843
 					}
844
-					$output_dest  = substr($output_dest, 0, -1);
844
+					$output_dest = substr($output_dest, 0, -1);
845 845
 				    }
846 846
 				    $output_dest .= ']}},';
847 847
 				    if ($havedata) $output .= $output_dest;
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 			$output  = substr($output, 0, -1);
852 852
 			$output .= ']';
853 853
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
854
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
854
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
855 855
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
856 856
 			$output .= '"fc": "'.$j.'"';
857 857
 		} else {
Please login to merge, or discard this 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.