Completed
Push — master ( 6950b6...2ac5ee )
by Yannick
05:48
created
live-geojson.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 $Common = new Common();
12 12
 
13 13
 if (isset($_GET['download'])) {
14
-    if ($_GET['download'] == "true")
15
-    {
14
+	if ($_GET['download'] == "true")
15
+	{
16 16
 	header('Content-disposition: attachment; filename="flightairmap.json"');
17
-    }
17
+	}
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
@@ -333,26 +333,26 @@  discard block
 block discarded – undo
333 333
 				
334 334
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
335 335
 				|| (!isset($_COOKIE['flightpath']) 
336
-				    && (!isset($globalMapHistory) || $globalMapHistory || $allhistory)
337
-				    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
336
+					&& (!isset($globalMapHistory) || $globalMapHistory || $allhistory)
337
+					|| (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
338 338
 				|| (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
339
-                                    if ($from_archive) {
340
-					    $spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']);
341
-                                    } else {
342
-					    $spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']);
343
-                                    }
344
-                            	$d = false;
339
+									if ($from_archive) {
340
+						$spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']);
341
+									} else {
342
+						$spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']);
343
+									}
344
+								$d = false;
345 345
 				foreach ($spotter_history_array as $key => $spotter_history)
346 346
 				{
347 347
 					$alt = round($spotter_history['altitude']/10)*10;
348 348
 					if (!isset($prev_alt) || $prev_alt != $alt) {
349
-					    if (isset($prev_alt)) {
349
+						if (isset($prev_alt)) {
350 350
 						$output_history .= '['.$spotter_history['longitude'].', '.$spotter_history['latitude'].', '.$spotter_history['altitude'].']';
351 351
 						$output_history .= ']}},';
352 352
 						$output .= $output_history;
353
-					    }
354
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
355
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
353
+						}
354
+						if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
355
+						else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
356 356
 					}
357 357
 					$output_history .= '[';
358 358
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -360,38 +360,38 @@  discard block
 block discarded – undo
360 360
 					$output_history .=  $spotter_history['altitude']*30.48;
361 361
 					$output_history .= '],';
362 362
 					$prev_alt = $alt;
363
-				    //}
363
+					//}
364 364
 				}
365 365
 				if (isset($output_history)) {
366
-				    $output_history  = substr($output_history, 0, -1);
367
-				    $output_history .= ']}},';
368
-				    $output .= $output_history;
369
-				    unset($prev_alt);
370
-				    unset($output_history);
366
+					$output_history  = substr($output_history, 0, -1);
367
+					$output_history .= ']}},';
368
+					$output .= $output_history;
369
+					unset($prev_alt);
370
+					unset($output_history);
371 371
 				}
372 372
 				}
373 373
 				
374 374
 				if (isset($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))))) {
375
-				    $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
376
-				    if (isset($spotter_item['departure_airport_latitude'])) {
375
+					$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
376
+					if (isset($spotter_item['departure_airport_latitude'])) {
377 377
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
378
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
378
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
379 379
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
380 380
 					if (isset($dairport[0]['latitude'])) {
381
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
381
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
382 382
 					}
383
-				    }
384
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
383
+					}
384
+					if (isset($spotter_item['arrival_airport_latitude'])) {
385 385
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
386
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
386
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
387 387
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
388 388
 					if (isset($aairport[0]['latitude'])) {
389
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
389
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
390 390
 					}
391
-				    }
392
-				    $output_air .= ']}},';
393
-				    $output .= $output_air;
394
-				    unset($output_air);
391
+					}
392
+					$output_air .= ']}},';
393
+					$output .= $output_air;
394
+					unset($output_air);
395 395
 				}
396 396
 			}
397 397
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,22 +25,22 @@  discard block
 block discarded – undo
25 25
 $min = false;
26 26
 $allhistory = false;
27 27
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
28
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
29
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
30
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
31
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs'));
32
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
33
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
34
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
35
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
36
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
37 37
 
38 38
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
39 39
 	$min = true;
40 40
 }
41 41
 
42 42
 if (isset($_GET['ident'])) {
43
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
43
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
44 44
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
45 45
 	if (empty($spotter_array)) {
46 46
 		$from_archive = true;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 	$allhistory = true;
50 50
 } elseif (isset($_GET['flightaware_id'])) {
51
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
51
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
52 52
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
53 53
 	if (empty($spotter_array)) {
54 54
 		$from_archive = true;
@@ -57,25 +57,25 @@  discard block
 block discarded – undo
57 57
 	$allhistory = true;
58 58
 } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) {
59 59
 //if (isset($_GET['coord'])) {
60
-	$coord = explode(',',$_GET['coord']);
61
-	$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
60
+	$coord = explode(',', $_GET['coord']);
61
+	$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);
62 62
 
63 63
 #} elseif (isset($globalMapPopup) && !$globalMapPopup) {
64 64
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed'])) {
65 65
 	$from_archive = true;
66 66
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
67 67
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
68
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
69
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
70
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
71
-	$begindate = date('Y-m-d H:i:s',$begindate);
72
-	$enddate = date('Y-m-d H:i:s',$enddate);
73
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
68
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
69
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
70
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
71
+	$begindate = date('Y-m-d H:i:s', $begindate);
72
+	$enddate = date('Y-m-d H:i:s', $enddate);
73
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
74 74
 } elseif ($min) {
75 75
 	$spotter_array = $SpotterLive->getMinLiveSpotterData($filter);
76 76
 #	$min = true;
77 77
 } else {
78
-	$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
78
+	$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
79 79
 }
80 80
 
81 81
 if (!empty($spotter_array)) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	if ($flightcnt == '') $flightcnt = 0;
91 91
 } else $flightcnt = 0;
92 92
 
93
-$sqltime = round(microtime(true)-$begintime,2);
93
+$sqltime = round(microtime(true) - $begintime, 2);
94 94
 
95 95
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
96 96
 else $usenextlatlon = true;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		if (!empty($spotter_array) && is_array($spotter_array))
108 108
 		{
109 109
 			$output .= '"features": [';
110
-			foreach($spotter_array as $spotter_item)
110
+			foreach ($spotter_array as $spotter_item)
111 111
 			{
112 112
 				$j++;
113 113
 				date_default_timezone_set('UTC');
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
159 159
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
160 160
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
161
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
161
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
162 162
 						} elseif (isset($spotter_item['aircraft_type'])) {
163 163
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
164 164
 						} elseif (!$min) {
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 						else $output .= '"heading": "'.$spotter_item['heading'].'",';
228 228
 						
229 229
 						if (isset($archivespeed)) {
230
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
230
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
231 231
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
232 232
 						} elseif ($usenextlatlon) {
233
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
233
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
234 234
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
235 235
 						}
236 236
 
237 237
 						if (!$min) $output .= '"image": "'.$image.'",';
238 238
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
239
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
239
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
240 240
 						}
241 241
 						if (isset($spotter_item['image_source_website'])) {
242 242
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
259 259
 						}
260 260
 						if (isset($spotter_item['acars'])) {
261
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
261
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
262 262
 						}
263 263
 						// type when not aircraft ?
264 264
 						if ($compress) $output .= '"t": "aircraft"';
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                 
329 329
 			}
330 330
 */
331
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
331
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
332 332
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
333 333
 				
334 334
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
356 356
 					}
357 357
 					$output_history .= '[';
358
-					$output_history .=  $spotter_history['longitude'].', ';
359
-					$output_history .=  $spotter_history['latitude'].', ';
360
-					$output_history .=  $spotter_history['altitude']*30.48;
358
+					$output_history .= $spotter_history['longitude'].', ';
359
+					$output_history .= $spotter_history['latitude'].', ';
360
+					$output_history .= $spotter_history['altitude']*30.48;
361 361
 					$output_history .= '],';
362 362
 					$prev_alt = $alt;
363 363
 				    //}
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 			$output  = substr($output, 0, -1);
398 398
 			$output .= ']';
399 399
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
400
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
400
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
401 401
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
402 402
 			$output .= '"fc": "'.$j.'"';
403 403
 		} else {
Please login to merge, or discard this patch.
Braces   +133 added lines, -51 removed lines patch added patch discarded remove patch
@@ -18,22 +18,43 @@  discard block
 block discarded – undo
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
21
-if (!isset($globalJsonCompress)) $compress = true;
22
-else $compress = $globalJsonCompress;
21
+if (!isset($globalJsonCompress)) {
22
+	$compress = true;
23
+} else {
24
+	$compress = $globalJsonCompress;
25
+}
23 26
 
24 27
 $from_archive = false;
25 28
 $min = false;
26 29
 $allhistory = false;
27 30
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
31
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
32
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
33
+}
34
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
35
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
36
+}
37
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
38
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
39
+}
40
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
41
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
42
+}
43
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
44
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
45
+}
46
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
47
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
48
+}
49
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
50
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
51
+}
52
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
53
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
54
+}
55
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
56
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
57
+}
37 58
 
38 59
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
39 60
 	$min = true;
@@ -87,20 +108,30 @@  discard block
 block discarded – undo
87 108
 	}
88 109
 */
89 110
 	$flightcnt = count($spotter_array);
90
-	if ($flightcnt == '') $flightcnt = 0;
91
-} else $flightcnt = 0;
111
+	if ($flightcnt == '') {
112
+		$flightcnt = 0;
113
+	}
114
+	} else {
115
+	$flightcnt = 0;
116
+}
92 117
 
93 118
 $sqltime = round(microtime(true)-$begintime,2);
94 119
 
95
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
96
-else $usenextlatlon = true;
120
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
121
+	$usenextlatlon = false;
122
+} else {
123
+	$usenextlatlon = true;
124
+}
97 125
 $j = 0;
98 126
 $prev_flightaware_id = '';
99 127
 
100 128
 $output = '{';
101 129
 	$output .= '"type": "FeatureCollection",';
102
-		if ($min) $output .= '"minimal": "true",';
103
-		else $output .= '"minimal": "false",';
130
+		if ($min) {
131
+			$output .= '"minimal": "true",';
132
+		} else {
133
+			$output .= '"minimal": "false",';
134
+		}
104 135
 		$output .= '"fc": "'.$flightcnt.'",';
105 136
 		$output .= '"sqt": "'.$sqltime.'",';
106 137
 
@@ -137,11 +168,16 @@  discard block
 block discarded – undo
137 168
 						//$output .= '"sqt": "'.$sqltime.'",';
138 169
 						$output .= '"id": "'.$spotter_item['flightaware_id'].'",';
139 170
 						$output .= '"properties": {';
140
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
141
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
171
+							if ($compress) {
172
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
173
+							} else {
174
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
175
+							}
142 176
 							$output .= '"fc": "'.$flightcnt.'",';
143 177
 							$output .= '"sqt": "'.$sqltime.'",';
144
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
178
+							if (isset($begindate)) {
179
+								$output .= '"archive_date": "'.$begindate.'",';
180
+							}
145 181
 
146 182
 /*
147 183
 							if ($min) $output .= '"minimal": "true",';
@@ -149,13 +185,21 @@  discard block
 block discarded – undo
149 185
 */
150 186
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
151 187
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
152
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
153
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
188
+							if ($compress) {
189
+								$output .= '"c": "'.$spotter_item['ident'].'",';
190
+							} else {
191
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
192
+							}
154 193
 						} else {
155
-							if ($compress) $output .= '"c": "NA",';
156
-							else $output .= '"callsign": "NA",';
194
+							if ($compress) {
195
+								$output .= '"c": "NA",';
196
+							} else {
197
+								$output .= '"callsign": "NA",';
198
+							}
199
+						}
200
+						if (isset($spotter_item['registration'])) {
201
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
157 202
 						}
158
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
159 203
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
160 204
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
161 205
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -168,20 +212,31 @@  discard block
 block discarded – undo
168 212
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
169 213
 						}
170 214
 						if (!isset($spotter_item['aircraft_shadow'])) {
171
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
172
-							else {
215
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
216
+								$spotter_item['aircraft_shadow'] = '';
217
+							} else {
173 218
 								$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
174
-								if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
175
-								elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
176
-								else $spotter_item['aircraft_shadow'] = '';
219
+								if (count($aircraft_info) > 0) {
220
+									$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
221
+								} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
222
+									$spotter_item['aircraft_shadow'] = 'PA18.png';
223
+								} else {
224
+									$spotter_item['aircraft_shadow'] = '';
225
+								}
177 226
 							}
178 227
 						}
179 228
 						if ($spotter_item['aircraft_shadow'] == '') {
180
-							if ($compress) $output .= '"as": "default.png",';
181
-							else $output .= '"aircraft_shadow": "default.png",';
229
+							if ($compress) {
230
+								$output .= '"as": "default.png",';
231
+							} else {
232
+								$output .= '"aircraft_shadow": "default.png",';
233
+							}
182 234
 						} else {
183
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
184
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
235
+							if ($compress) {
236
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
237
+							} else {
238
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
239
+							}
185 240
 						}
186 241
 						if (isset($spotter_item['airline_name'])) {
187 242
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -189,8 +244,11 @@  discard block
 block discarded – undo
189 244
 							$output .= '"airline_name": "NA",';
190 245
 						}
191 246
 						if (isset($spotter_item['departure_airport'])) {
192
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
193
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
247
+							if ($compress) {
248
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
249
+							} else {
250
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
251
+							}
194 252
 						}
195 253
 						if (isset($spotter_item['departure_airport_city'])) {
196 254
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -202,8 +260,11 @@  discard block
 block discarded – undo
202 260
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
203 261
 						}
204 262
 						if (isset($spotter_item['arrival_airport'])) {
205
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
206
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
263
+							if ($compress) {
264
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
265
+							} else {
266
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
267
+							}
207 268
 						}
208 269
 						if (isset($spotter_item['arrival_airport_city'])) {
209 270
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -221,10 +282,16 @@  discard block
 block discarded – undo
221 282
 							$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
222 283
 						}
223 284
 						
224
-						if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
225
-						else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
226
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
227
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
285
+						if ($compress) {
286
+							$output .= '"a": "'.$spotter_item['altitude'].'",';
287
+						} else {
288
+							$output .= '"altitude": "'.$spotter_item['altitude'].'",';
289
+						}
290
+						if ($compress) {
291
+							$output .= '"h": "'.$spotter_item['heading'].'",';
292
+						} else {
293
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
294
+						}
228 295
 						
229 296
 						if (isset($archivespeed)) {
230 297
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -234,7 +301,9 @@  discard block
 block discarded – undo
234 301
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
235 302
 						}
236 303
 
237
-						if (!$min) $output .= '"image": "'.$image.'",';
304
+						if (!$min) {
305
+							$output .= '"image": "'.$image.'",';
306
+						}
238 307
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
239 308
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
240 309
 						}
@@ -242,8 +311,11 @@  discard block
 block discarded – undo
242 311
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
243 312
 						}
244 313
 						if (isset($spotter_item['squawk'])) {
245
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
246
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
314
+							if ($compress) {
315
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
316
+							} else {
317
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
318
+							}
247 319
 						}
248 320
 						if (isset($spotter_item['squawk_usage'])) {
249 321
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -261,8 +333,11 @@  discard block
 block discarded – undo
261 333
 							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
262 334
 						}
263 335
 						// type when not aircraft ?
264
-						if ($compress) $output .= '"t": "aircraft"';
265
-						else $output .= '"type": "aircraft"';
336
+						if ($compress) {
337
+							$output .= '"t": "aircraft"';
338
+						} else {
339
+							$output .= '"type": "aircraft"';
340
+						}
266 341
 						$output .= '},';
267 342
 						$output .= '"geometry": {';
268 343
 							$output .= '"type": "Point",';
@@ -329,7 +404,9 @@  discard block
 block discarded – undo
329 404
 			}
330 405
 */
331 406
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
332
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
407
+				if ($history == '' && isset($_COOKIE['history'])) {
408
+					$history = $_COOKIE['history'];
409
+				}
333 410
 				
334 411
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
335 412
 				|| (!isset($_COOKIE['flightpath']) 
@@ -351,8 +428,11 @@  discard block
 block discarded – undo
351 428
 						$output_history .= ']}},';
352 429
 						$output .= $output_history;
353 430
 					    }
354
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
355
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
431
+					    if ($compress) {
432
+					    	$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
433
+					    } else {
434
+					    	$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
435
+					    }
356 436
 					}
357 437
 					$output_history .= '[';
358 438
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -398,7 +478,9 @@  discard block
 block discarded – undo
398 478
 			$output .= ']';
399 479
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
400 480
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
401
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
481
+			if (isset($begindate)) {
482
+				$output .= '"archive_date": "'.$begindate.'",';
483
+			}
402 484
 			$output .= '"fc": "'.$j.'"';
403 485
 		} else {
404 486
 			$output .= '"features": ';
Please login to merge, or discard this patch.