Completed
Push — master ( 8b0949...4e1c61 )
by Yannick
55:45 queued 25:25
created
live-geojson.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -64,18 +64,18 @@  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);
78
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
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
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'], FILTER_SANITIZE_NUMBER_INT);
79 79
 
80 80
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
81 81
 	$min = true;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 $spotter_array = array();
85 85
 
86 86
 if (isset($_GET['ident'])) {
87
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
87
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
88 88
 	if ($tracker) {
89 89
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
90 90
 	} elseif ($marine) {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 	$allhistory = true;
100 100
 } elseif (isset($_GET['flightaware_id'])) {
101
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
101
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
102 102
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
103 103
 	if (empty($spotter_array)) {
104 104
 		$from_archive = true;
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 	$allhistory = true;
108 108
 } elseif (isset($_GET['famtrack_id'])) {
109
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
109
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
110 110
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
111 111
 	$allhistory = true;
112 112
 } elseif (isset($_GET['fammarine_id'])) {
113
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
113
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
114 114
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
115 115
 	$allhistory = true;
116 116
 /*
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 */
131 131
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) {
132 132
 	$usecoord = true;
133
-	$coord = explode(',',$_GET['coord']);
134
-	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) 
133
+	$coord = explode(',', $_GET['coord']);
134
+	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) 
135 135
 	    && $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) {
136 136
 		if ($tracker) {
137
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
137
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
138 138
 		} elseif ($marine) {
139
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
139
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
140 140
 		} else {
141
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
141
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
142 142
 		}
143 143
 	} else {
144 144
 		if ($tracker) {
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	$from_archive = true;
154 154
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
155 155
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
156
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
157
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
158
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
159
-	$begindate = date('Y-m-d H:i:s',$begindate);
160
-	$enddate = date('Y-m-d H:i:s',$enddate);
161
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
156
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
157
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
158
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
159
+	$begindate = date('Y-m-d H:i:s', $begindate);
160
+	$enddate = date('Y-m-d H:i:s', $enddate);
161
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
162 162
 } elseif ($min) {
163 163
 	if ($tracker) {
164 164
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 #	$min = true;
171 171
 } else {
172 172
 	if ($tracker) {
173
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
173
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
174 174
 	} elseif ($marine) {
175
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
175
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
176 176
 	} else {
177
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
177
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
178 178
 	}
179 179
 }
180 180
 
181 181
 if ($usecoord) {
182 182
 	if (isset($_GET['archive'])) {
183
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
183
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
184 184
 	} else {
185 185
 		if ($tracker) {
186 186
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	if ($flightcnt == '') $flightcnt = 0;
194 194
 } else $flightcnt = 0;
195 195
 
196
-$sqltime = round(microtime(true)-$begintime,2);
196
+$sqltime = round(microtime(true) - $begintime, 2);
197 197
 
198
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
198
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
199 199
 if ($currenttime != '') $currenttime = round($currenttime/1000);
200 200
 
201 201
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		if (!empty($spotter_array) && is_array($spotter_array))
215 215
 		{
216 216
 			$output .= '"features": [';
217
-			foreach($spotter_array as $spotter_item)
217
+			foreach ($spotter_array as $spotter_item)
218 218
 			{
219 219
 				$j++;
220 220
 				unset($idistance);
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 */
272 272
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
273 273
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
274
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
275
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
274
+							if ($compress) $output .= '"c": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
275
+							else $output .= '"callsign": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
276 276
 							//'
277 277
 						} else {
278 278
 							if ($compress) $output .= '"c": "NA",';
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 						}
285 285
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
286 286
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
287
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
287
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
288 288
 						} elseif (isset($spotter_item['aircraft_type'])) {
289 289
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
290 290
 						} elseif (!$min) {
@@ -370,19 +370,19 @@  discard block
 block discarded – undo
370 370
 									else $output .= '"aircraft_shadow": "car.png",';
371 371
 								}
372 372
 							} elseif ($marine) {
373
-								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
373
+								if (isset($spotter_item['type']) && ($spotter_item['type'] == '50&#39; Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
374 374
 									if ($compress) $output .= '"as": "50perfcruiser.png",';
375 375
 									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
376
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
376
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Sailaway Cruiser 38') {
377 377
 									if ($compress) $output .= '"as": "cruiser38.png",';
378 378
 									else $output .= '"aircraft_shadow": "cruiser38.png",';
379
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
379
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Mini Transat') {
380 380
 									if ($compress) $output .= '"as": "transat.png",';
381 381
 									else $output .= '"aircraft_shadow": "transat.png",';
382
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
382
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == '52&#39; Cruising Cat') {
383 383
 									if ($compress) $output .= '"as": "catamaran.png",';
384 384
 									else $output .= '"aircraft_shadow": "catamaran.png",';
385
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
385
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Caribbean Rose') {
386 386
 									if ($compress) $output .= '"as": "carib.png",';
387 387
 									else $output .= '"aircraft_shadow": "carib.png",';
388 388
 								} else {
@@ -448,15 +448,15 @@  discard block
 block discarded – undo
448 448
 						if (isset($archivespeed) || $usenextlatlon) {
449 449
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
450 450
 								if (isset($spotter_item['arrival_airport_latitude'])) {
451
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
452
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
451
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
452
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
453 453
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
454 454
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
455 455
 								} else {
456 456
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
457 457
 									if (isset($aairport[0]['latitude'])) {
458
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
459
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
458
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
459
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
460 460
 										$farr_lat = $aairport[0]['latitude'];
461 461
 										$farr_lon = $aairport[0]['longitude'];
462 462
 									}
@@ -469,59 +469,59 @@  discard block
 block discarded – undo
469 469
 						if ($currenttime != '') {
470 470
 							if (strtotime($spotter_item['date']) < $currenttime) {
471 471
 								if (isset($archivespeed)) {
472
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
473
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
472
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
473
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
474 474
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
475 475
 									else {
476
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
477
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
476
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
477
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
478 478
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
479 479
 										else {
480
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
480
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
481 481
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
482 482
 										}
483 483
 									}
484 484
 								} elseif ($usenextlatlon) {
485
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
486
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
485
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
486
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
487 487
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
488 488
 									else {
489
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
490
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
489
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
490
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
491 491
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
492 492
 										else {
493
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
493
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
494 494
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
495 495
 										}
496 496
 									}
497 497
 								}
498 498
 							} else {
499 499
 								if (isset($archivespeed)) {
500
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
500
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
501 501
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 502
 								} elseif ($usenextlatlon) {
503
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
503
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
504 504
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
505 505
 								}
506 506
 							}
507 507
 						} else {
508 508
 							if (isset($archivespeed)) {
509
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
510
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
509
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
510
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
511 511
 								if (!isset($idistance) || $fdistance < $idistance) {
512 512
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
513 513
 								} else {
514
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
514
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
515 515
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
516 516
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
517 517
 								}
518 518
 							} elseif ($usenextlatlon) {
519
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
520
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
519
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
520
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
521 521
 								if (!isset($idistance) || $fdistance < $idistance) {
522 522
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
523 523
 								} else {
524
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
524
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
525 525
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
526 526
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
527 527
 								}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 
531 531
 						if (!$min) $output .= '"image": "'.$image.'",';
532 532
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
533
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
533
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
534 534
 						}
535 535
 						if (isset($spotter_item['image_source_website'])) {
536 536
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
559 559
 						}
560 560
 						if (isset($spotter_item['acars'])) {
561
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
561
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
562 562
 						}
563 563
 						// type when not aircraft ?
564 564
 						if (isset($spotter_item['type'])) {
@@ -578,12 +578,12 @@  discard block
 block discarded – undo
578 578
 								if ($currenttime != '') {
579 579
 									if (strtotime($spotter_item['date']) < $currenttime) {
580 580
 										if (!isset($archivespeed)) $archivespeed = 1;
581
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
582
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
581
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
582
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
583 583
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
584 584
 										else {
585
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
586
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
585
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
586
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
587 587
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
588 588
 											else {
589 589
 												$output .= $spotter_item['longitude'].', ';
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
                 
663 663
 			}
664 664
 */
665
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
665
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
666 666
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
667 667
 				
668 668
 				if (
@@ -670,11 +670,11 @@  discard block
 block discarded – undo
670 670
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
671 671
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
672 672
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
673
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
673
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
674 674
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
675
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
675
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
676 676
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
677
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
677
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
678 678
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
679 679
 				    ) {
680 680
 					if ($tracker) {
@@ -703,9 +703,9 @@  discard block
 block discarded – undo
703 703
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
704 704
 							$MapMatching = new MapMatching();
705 705
 							if (isset($spotter_item['date_iso_8601'])) {
706
-								$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'])))));
706
+								$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'])))));
707 707
 							} else {
708
-								$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'])))));
708
+								$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'])))));
709 709
 							}
710 710
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
711 711
 						}
@@ -737,9 +737,9 @@  discard block
 block discarded – undo
737 737
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
738 738
 							}
739 739
 							$output_history .= '[';
740
-							$output_history .=  $spotter_history['longitude'].', ';
741
-							$output_history .=  $spotter_history['latitude'].', ';
742
-							$output_history .=  $spotter_history['altitude']*30.48;
740
+							$output_history .= $spotter_history['longitude'].', ';
741
+							$output_history .= $spotter_history['latitude'].', ';
742
+							$output_history .= $spotter_history['altitude']*30.48;
743 743
 							$output_history .= '],';
744 744
 							/*
745 745
 							if ($from_archive === false) {
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 								$d = true;
763 763
 							}
764 764
 							$output_history .= '[';
765
-							$output_history .=  $spotter_history['longitude'].', ';
766
-							$output_history .=  $spotter_history['latitude'];
765
+							$output_history .= $spotter_history['longitude'].', ';
766
+							$output_history .= $spotter_history['latitude'];
767 767
 							$output_history .= '],';
768 768
 							/*
769 769
 							if ($from_archive === false) {
@@ -779,9 +779,9 @@  discard block
 block discarded – undo
779 779
 						//echo $output_history;
780 780
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
781 781
 							$output_historyd = '[';
782
-							$output_historyd .=  $spotter_item['longitude'].', ';
783
-							$output_historyd .=  $spotter_item['latitude'];
784
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
782
+							$output_historyd .= $spotter_item['longitude'].', ';
783
+							$output_historyd .= $spotter_item['latitude'];
784
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
785 785
 							$output_historyd .= '],';
786 786
 							//$output_history = $output_historyd.$output_history;
787 787
 							$output_history = $output_history.$output_historyd;
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 							$last = array_pop($spotter_history_array);
790 790
 							$latitude = $last['latitude'];
791 791
 							$longitude = $last['longitude'];
792
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
792
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
793 793
 						}
794 794
 						
795 795
 						$output_history  = substr($output_history, 0, -1);
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 					
802 802
 				}
803 803
 				
804
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
804
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
805 805
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
806 806
 				     && (isset($spotter_item['departure_airport']) 
807 807
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 
836 836
 				//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))))) {
837 837
 				//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))))) {
838
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
838
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
839 839
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
840 840
 				     && (isset($spotter_item['arrival_airport']) 
841 841
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -862,11 +862,11 @@  discard block
 block discarded – undo
862 862
 					}
863 863
 				    }
864 864
 				    if ($havedata) {
865
-					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
865
+					$line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon);
866 866
 					foreach ($line[0] as $coord) {
867 867
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
868 868
 					}
869
-					$output_dest  = substr($output_dest, 0, -1);
869
+					$output_dest = substr($output_dest, 0, -1);
870 870
 				    }
871 871
 				    $output_dest .= ']}},';
872 872
 				    if ($havedata) $output .= $output_dest;
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 			$output  = substr($output, 0, -1);
877 877
 			$output .= ']';
878 878
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
879
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
879
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
880 880
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
881 881
 			$output .= '"fc": "'.$j.'"';
882 882
 		} else {
Please login to merge, or discard this patch.