Completed
Push — master ( d97822...cc50d0 )
by Yannick
07:18
created
live-czml.php 1 patch
Braces   +84 added lines, -29 removed lines patch added patch discarded remove patch
@@ -2,7 +2,9 @@  discard block
 block discarded – undo
2 2
 require_once('require/class.Connection.php');
3 3
 require_once('require/class.Common.php');
4 4
 $tracker = false;
5
-if (isset($_GET['tracker'])) $tracker = true;
5
+if (isset($_GET['tracker'])) {
6
+	$tracker = true;
7
+}
6 8
 if ($tracker) {
7 9
 	require_once('require/class.Tracker.php');
8 10
 	require_once('require/class.TrackerLive.php');
@@ -52,23 +54,46 @@  discard block
 block discarded – undo
52 54
 }
53 55
 header('Content-Type: text/javascript');
54 56
 
55
-if (!isset($globalJsonCompress)) $compress = true;
56
-else $compress = $globalJsonCompress;
57
+if (!isset($globalJsonCompress)) {
58
+	$compress = true;
59
+} else {
60
+	$compress = $globalJsonCompress;
61
+}
57 62
 
58 63
 $from_archive = false;
59 64
 $min = false;
60 65
 $allhistory = false;
61 66
 $filter['source'] = array();
62
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
64
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
65
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
66
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
67
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
68
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
69
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
70
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
71
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
69
+}
70
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
72
+}
73
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
75
+}
76
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
77
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
78
+}
79
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
80
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
81
+}
82
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
83
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
86
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
89
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
90
+}
91
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
92
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
93
+}
94
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
95
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
96
+}
72 97
 /*
73 98
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
74 99
 	$min = true;
@@ -149,8 +174,12 @@  discard block
 block discarded – undo
149 174
 	} else {
150 175
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
151 176
 	}
152
-	if ($flightcnt == '') $flightcnt = 0;
153
-} else $flightcnt = 0;
177
+	if ($flightcnt == '') {
178
+		$flightcnt = 0;
179
+	}
180
+	} else {
181
+	$flightcnt = 0;
182
+}
154 183
 
155 184
 $sqltime = round(microtime(true)-$begintime,2);
156 185
 $minitime = time();
@@ -173,7 +202,9 @@  discard block
 block discarded – undo
173 202
 $j = 0;
174 203
 $prev_flightaware_id = '';
175 204
 $speed = 1;
176
-if (isset($archivespeed)) $speed = $archivespeed;
205
+if (isset($archivespeed)) {
206
+	$speed = $archivespeed;
207
+}
177 208
 $output = '[';
178 209
 if ($tracker) {
179 210
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -205,8 +236,11 @@  discard block
 block discarded – undo
205 236
 			$image = "images/placeholder_thumb.png";
206 237
 		}
207 238
 
208
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
209
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
239
+                if (isset($spotter_item['flightaware_id'])) {
240
+                	$id = $spotter_item['flightaware_id'];
241
+                } elseif (isset($spotter_item['famtrackid'])) {
242
+                	$id = $spotter_item['famtrackid'];
243
+                }
210 244
 		if ($prev_flightaware_id != $id) {
211 245
 			if ($prev_flightaware_id != '') {
212 246
 				$output .= ']';
@@ -248,7 +282,9 @@  discard block
 block discarded – undo
248 282
 						$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
249 283
 						$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
250 284
 						$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
251
-					} else $aircraft_shadow = '';
285
+					} else {
286
+						$aircraft_shadow = '';
287
+					}
252 288
 					if ($aircraft_shadow != '') {
253 289
 						if (isset($modelsdb[$aircraft_shadow])) {
254 290
 							$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -353,7 +389,9 @@  discard block
 block discarded – undo
353 389
 							$output .= ',"heightReference": "'.$heightrelative.'"';
354 390
 							$output .= '},';
355 391
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
356
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
392
+							if ($spotter_item['aircraft_icao'] != '') {
393
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
394
+							}
357 395
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
358 396
 						}
359 397
 					} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -367,7 +405,9 @@  discard block
 block discarded – undo
367 405
 						$output .= ',"heightReference": "'.$heightrelative.'"';
368 406
 						$output .= '},';
369 407
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
370
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
408
+						if ($spotter_item['aircraft_icao'] != '') {
409
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
410
+						}
371 411
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
372 412
 					}
373 413
 				} else {
@@ -375,7 +415,9 @@  discard block
 block discarded – undo
375 415
 					$output .= ',"heightReference": "'.$heightrelative.'"';
376 416
 					$output .= '},';
377 417
 					//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
378
-					if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
418
+					if ($spotter_item['aircraft_icao'] != '') {
419
+						$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
420
+					}
379 421
 					$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
380 422
 				}
381 423
 			} elseif ($tracker && isset($spotter_item['type'])) {
@@ -426,8 +468,12 @@  discard block
 block discarded – undo
426 468
 	//		$output .= '"interpolationDegree" : 5,';
427 469
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
428 470
 			$output .= '"cartographicDegrees": [';
429
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
430
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
471
+			if ($minitime > strtotime($spotter_item['date'])) {
472
+				$minitime = strtotime($spotter_item['date']);
473
+			}
474
+			if ($maxitime < strtotime($spotter_item['date'])) {
475
+				$maxitime = strtotime($spotter_item['date']);
476
+			}
431 477
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
432 478
 			$output .= $spotter_item['longitude'].', ';
433 479
 			$output .= $spotter_item['latitude'];
@@ -436,19 +482,26 @@  discard block
 block discarded – undo
436 482
 			if (!$tracker) {
437 483
 				$output .= ', '.round($spotter_item['altitude']*30.48);
438 484
 				$prevalt = round($spotter_item['altitude']*30.48);
439
-			} else $output .= ', 0';
485
+			} else {
486
+				$output .= ', 0';
487
+			}
440 488
 			//$orientation = '"orientation" : { ';
441 489
 			//$orientation .= '"unitQuaternion": [';
442 490
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
443 491
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
444 492
 		} else {
445 493
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
446
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
494
+			if ($maxitime < strtotime($spotter_item['date'])) {
495
+				$maxitime = strtotime($spotter_item['date']);
496
+			}
447 497
 			if ($spotter_item['ground_speed'] == 0) {
448 498
 				$output .= $prevlong.', ';
449 499
 				$output .= $prevlat;
450
-				if (!$tracker) $output .= ', '.$prevalt;
451
-				else $output .= ', 0';
500
+				if (!$tracker) {
501
+					$output .= ', '.$prevalt;
502
+				} else {
503
+					$output .= ', 0';
504
+				}
452 505
 			} else {
453 506
 				$output .= $spotter_item['longitude'].', ';
454 507
 				$output .= $spotter_item['latitude'];
@@ -462,7 +515,9 @@  discard block
 block discarded – undo
462 515
 					} else {
463 516
 						$output .= ', '.round($spotter_item['altitude']*30.48);
464 517
 					}
465
-				} else $output .= ', 0';
518
+				} else {
519
+					$output .= ', 0';
520
+				}
466 521
 			}
467 522
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
468 523
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
Please login to merge, or discard this patch.