Completed
Push — master ( 2a2cc6...91b21c )
by Yannick
35:10
created
live-geojson.php 1 patch
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.