Completed
Push — master ( aed4ca...26c961 )
by Yannick
34:50
created
live-geojson.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 $min = true;
66 66
 $allhistory = false;
67 67
 $filter['source'] = array();
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
70
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
73
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
68
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
70
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
71
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
72
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
73
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
74
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
75
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
76
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
78
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
79
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'], FILTER_SANITIZE_NUMBER_INT);
80 80
 if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true;
81 81
 
82 82
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 
86 86
 
87 87
 if (isset($_COOKIE['map_2d_limit'])) {
88
-	$limit = filter_var($_COOKIE['map_2d_limit'],FILTER_SANITIZE_NUMBER_INT);
88
+	$limit = filter_var($_COOKIE['map_2d_limit'], FILTER_SANITIZE_NUMBER_INT);
89 89
 }
90 90
 
91 91
 $spotter_array = array();
92 92
 
93 93
 if (isset($_GET['ident'])) {
94
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
94
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
95 95
 	if ($tracker) {
96 96
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
97 97
 	} elseif ($marine) {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	$allhistory = true;
107 107
 } elseif (isset($_GET['flightaware_id'])) {
108
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
108
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
109 109
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
110 110
 	if (empty($spotter_array)) {
111 111
 		$from_archive = true;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 	$allhistory = true;
115 115
 } elseif (isset($_GET['famtrack_id'])) {
116
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
116
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
117 117
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
118 118
 	$allhistory = true;
119 119
 } elseif (isset($_GET['fammarine_id'])) {
120
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
120
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
121 121
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
122 122
 	$allhistory = true;
123 123
 /*
@@ -137,15 +137,15 @@  discard block
 block discarded – undo
137 137
 */
138 138
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min && !isset($_GET['archive'])) {
139 139
 	$usecoord = true;
140
-	$coord = explode(',',$_GET['coord']);
141
-	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) 
140
+	$coord = explode(',', $_GET['coord']);
141
+	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) 
142 142
 	    && $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) {
143 143
 		if ($tracker) {
144
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
144
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
145 145
 		} elseif ($marine) {
146
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
146
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
147 147
 		} else {
148
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$limit,$filter);
148
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $limit, $filter);
149 149
 		}
150 150
 	} else {
151 151
 		if ($tracker) {
@@ -153,41 +153,41 @@  discard block
 block discarded – undo
153 153
 		} elseif ($marine) {
154 154
 			$spotter_array = $MarineLive->getMinLiveMarineData($filter);
155 155
 		} else {
156
-			$spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter);
156
+			$spotter_array = $SpotterLive->getMinLiveSpotterData($limit, $filter);
157 157
 		}
158 158
 	}
159 159
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) {
160 160
 	$from_archive = true;
161 161
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
162 162
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
163
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
164
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
165
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
166
-	$begindate = date('Y-m-d H:i:s',$begindate);
167
-	$enddate = date('Y-m-d H:i:s',$enddate);
168
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
163
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
164
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
165
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
166
+	$begindate = date('Y-m-d H:i:s', $begindate);
167
+	$enddate = date('Y-m-d H:i:s', $enddate);
168
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
169 169
 } elseif ($min) {
170 170
 	if ($tracker) {
171 171
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
172 172
 	} elseif ($marine) {
173 173
 		$spotter_array = $MarineLive->getMinLiveMarineData($filter);
174 174
 	} else {
175
-		$spotter_array = $SpotterLive->getMinLiveSpotterData($limit,$filter);
175
+		$spotter_array = $SpotterLive->getMinLiveSpotterData($limit, $filter);
176 176
 	}
177 177
 #	$min = true;
178 178
 } else {
179 179
 	if ($tracker) {
180
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
180
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
181 181
 	} elseif ($marine) {
182
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
182
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
183 183
 	} else {
184
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
184
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
185 185
 	}
186 186
 }
187 187
 
188 188
 if ($usecoord) {
189 189
 	if (isset($_GET['archive'])) {
190
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
190
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
191 191
 	} else {
192 192
 		if ($tracker) {
193 193
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	if ($flightcnt == '') $flightcnt = 0;
201 201
 } else $flightcnt = 0;
202 202
 
203
-$sqltime = round(microtime(true)-$begintime,2);
203
+$sqltime = round(microtime(true) - $begintime, 2);
204 204
 
205
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
205
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
206 206
 if ($currenttime != '') $currenttime = round($currenttime/1000);
207 207
 
208 208
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation === FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		if (!empty($spotter_array) && is_array($spotter_array))
222 222
 		{
223 223
 			$output .= '"features": [';
224
-			foreach($spotter_array as $spotter_item)
224
+			foreach ($spotter_array as $spotter_item)
225 225
 			{
226 226
 				$j++;
227 227
 				unset($idistance);
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 */
279 279
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
280 280
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
281
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
282
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
281
+							if ($compress) $output .= '"c": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
282
+							else $output .= '"callsign": '.json_encode(str_replace('\\', '', $spotter_item['ident'])).',';
283 283
 							//'
284 284
 						} else {
285 285
 							if ($compress) $output .= '"c": "NA",';
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 						}
292 292
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
293 293
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
294
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
294
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
295 295
 						} elseif (isset($spotter_item['aircraft_type'])) {
296 296
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
297 297
 						} elseif (!$min) {
@@ -377,22 +377,22 @@  discard block
 block discarded – undo
377 377
 									else $output .= '"aircraft_shadow": "car.png",';
378 378
 								}
379 379
 							} elseif ($marine) {
380
-								if (isset($spotter_item['type']) && ($spotter_item['type']  == '50&#39; Performance Cruiser' || $spotter_item['type']  == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
380
+								if (isset($spotter_item['type']) && ($spotter_item['type'] == '50&#39; Performance Cruiser' || $spotter_item['type'] == '50\' Performance Cruiser' || $spotter_item['type'] == 'Sail')) {
381 381
 									if ($compress) $output .= '"as": "50perfcruiser.png",';
382 382
 									else $output .= '"aircraft_shadow": "50perfcruiser.png",';
383
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Sailaway Cruiser 38') {
383
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Sailaway Cruiser 38') {
384 384
 									if ($compress) $output .= '"as": "cruiser38.png",';
385 385
 									else $output .= '"aircraft_shadow": "cruiser38.png",';
386
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Mini Transat') {
386
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Mini Transat') {
387 387
 									if ($compress) $output .= '"as": "transat.png",';
388 388
 									else $output .= '"aircraft_shadow": "transat.png",';
389
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == '52&#39; Cruising Cat') {
389
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == '52&#39; Cruising Cat') {
390 390
 									if ($compress) $output .= '"as": "catamaran.png",';
391 391
 									else $output .= '"aircraft_shadow": "catamaran.png",';
392
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Caribbean Rose') {
392
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Caribbean Rose') {
393 393
 									if ($compress) $output .= '"as": "carib.png",';
394 394
 									else $output .= '"aircraft_shadow": "carib.png",';
395
-								} elseif (isset($spotter_item['type']) && $spotter_item['type']  == 'Nordic Folkboat') {
395
+								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Nordic Folkboat') {
396 396
 									if ($compress) $output .= '"as": "nordic.png",';
397 397
 									else $output .= '"aircraft_shadow": "nordic.png",';
398 398
 								} else {
@@ -458,15 +458,15 @@  discard block
 block discarded – undo
458 458
 						if (isset($archivespeed) || $usenextlatlon) {
459 459
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
460 460
 								if (isset($spotter_item['arrival_airport_latitude'])) {
461
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
462
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
461
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
462
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
463 463
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
464 464
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
465 465
 								} else {
466 466
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
467 467
 									if (isset($aairport[0]['latitude'])) {
468
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
469
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
468
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
469
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
470 470
 										$farr_lat = $aairport[0]['latitude'];
471 471
 										$farr_lon = $aairport[0]['longitude'];
472 472
 									}
@@ -479,59 +479,59 @@  discard block
 block discarded – undo
479 479
 						if ($currenttime != '') {
480 480
 							if (strtotime($spotter_item['date']) < $currenttime) {
481 481
 								if (isset($archivespeed)) {
482
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
483
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
482
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
483
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
484 484
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
485 485
 									else {
486
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
487
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
486
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
487
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
488 488
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
489 489
 										else {
490
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
490
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
491 491
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
492 492
 										}
493 493
 									}
494 494
 								} elseif ($usenextlatlon) {
495
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
496
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
495
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
496
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
497 497
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
498 498
 									else {
499
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
500
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
499
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
500
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
501 501
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 502
 										else {
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
 								}
508 508
 							} else {
509 509
 								if (isset($archivespeed)) {
510
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
510
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
511 511
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
512 512
 								} elseif ($usenextlatlon) {
513
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
513
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
514 514
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
515 515
 								}
516 516
 							}
517 517
 						} else {
518 518
 							if (isset($archivespeed)) {
519
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
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, $archivespeed);
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,$archivespeed);
524
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
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
 								}
528 528
 							} elseif ($usenextlatlon) {
529
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
530
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
529
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
530
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
531 531
 								if (!isset($idistance) || $fdistance < $idistance) {
532 532
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
533 533
 								} else {
534
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
534
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
535 535
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
536 536
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
537 537
 								}
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 
541 541
 						if (!$min) $output .= '"image": "'.$image.'",';
542 542
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
543
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
543
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
544 544
 						}
545 545
 						if (isset($spotter_item['image_source_website'])) {
546 546
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
575 575
 						}
576 576
 						if (isset($spotter_item['acars'])) {
577
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
577
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
578 578
 						}
579 579
 						// type when not aircraft ?
580 580
 						if (isset($spotter_item['type'])) {
@@ -594,12 +594,12 @@  discard block
 block discarded – undo
594 594
 								if ($currenttime != '') {
595 595
 									if (strtotime($spotter_item['date']) < $currenttime) {
596 596
 										if (!isset($archivespeed)) $archivespeed = 1;
597
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
598
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
597
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
598
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
599 599
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
600 600
 										else {
601
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
602
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
601
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
602
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
603 603
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
604 604
 											else {
605 605
 												$output .= $spotter_item['longitude'].', ';
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
                 
679 679
 			}
680 680
 */
681
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
681
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
682 682
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
683 683
 				
684 684
 				if (
@@ -686,11 +686,11 @@  discard block
 block discarded – undo
686 686
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
687 687
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
688 688
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
689
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
689
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
690 690
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
691
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
691
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
692 692
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
693
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
693
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
694 694
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
695 695
 				    ) {
696 696
 					if ($tracker) {
@@ -719,9 +719,9 @@  discard block
 block discarded – undo
719 719
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
720 720
 							$MapMatching = new MapMatching();
721 721
 							if (isset($spotter_item['date_iso_8601'])) {
722
-								$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'])))));
722
+								$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'])))));
723 723
 							} else {
724
-								$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'])))));
724
+								$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'])))));
725 725
 							}
726 726
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
727 727
 						}
@@ -754,9 +754,9 @@  discard block
 block discarded – undo
754 754
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
755 755
 							}
756 756
 							$output_history .= '[';
757
-							$output_history .=  $spotter_history['longitude'].', ';
758
-							$output_history .=  $spotter_history['latitude'].', ';
759
-							$output_history .=  $spotter_history['altitude']*30.48;
757
+							$output_history .= $spotter_history['longitude'].', ';
758
+							$output_history .= $spotter_history['latitude'].', ';
759
+							$output_history .= $spotter_history['altitude']*30.48;
760 760
 							$output_history .= '],';
761 761
 							/*
762 762
 							if ($from_archive === false) {
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
 								$d = true;
780 780
 							}
781 781
 							$output_history .= '[';
782
-							$output_history .=  $spotter_history['longitude'].', ';
783
-							$output_history .=  $spotter_history['latitude'];
782
+							$output_history .= $spotter_history['longitude'].', ';
783
+							$output_history .= $spotter_history['latitude'];
784 784
 							$output_history .= '],';
785 785
 							/*
786 786
 							if ($from_archive === false) {
@@ -796,9 +796,9 @@  discard block
 block discarded – undo
796 796
 						//echo $output_history;
797 797
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
798 798
 							$output_historyd = '[';
799
-							$output_historyd .=  $spotter_item['longitude'].', ';
800
-							$output_historyd .=  $spotter_item['latitude'];
801
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
799
+							$output_historyd .= $spotter_item['longitude'].', ';
800
+							$output_historyd .= $spotter_item['latitude'];
801
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
802 802
 							$output_historyd .= '],';
803 803
 							//$output_history = $output_historyd.$output_history;
804 804
 							$output_history = $output_history.$output_historyd;
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 							$last = array_pop($spotter_history_array);
807 807
 							$latitude = $last['latitude'];
808 808
 							$longitude = $last['longitude'];
809
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
809
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
810 810
 						}
811 811
 						
812 812
 						$output_history  = substr($output_history, 0, -1);
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 					
819 819
 				}
820 820
 				
821
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
821
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
822 822
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
823 823
 				     && (isset($spotter_item['departure_airport']) 
824 824
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 
853 853
 				//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))))) {
854 854
 				//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))))) {
855
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
855
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
856 856
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
857 857
 				     && (isset($spotter_item['arrival_airport']) 
858 858
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 					}
880 880
 				    }
881 881
 				    if ($havedata) {
882
-					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
882
+					$line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon);
883 883
 					foreach ($line[0] as $coord) {
884 884
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
885 885
 					}
886
-					$output_dest  = substr($output_dest, 0, -1);
886
+					$output_dest = substr($output_dest, 0, -1);
887 887
 				    }
888 888
 				    $output_dest .= ']}},';
889 889
 				    if ($havedata) $output .= $output_dest;
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 			$output  = substr($output, 0, -1);
894 894
 			$output .= ']';
895 895
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
896
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
896
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
897 897
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
898 898
 			$output .= '"fc": "'.$j.'"';
899 899
 		} else {
Please login to merge, or discard this patch.