Completed
Push — master ( 2ac5ee...afe259 )
by Yannick
05:58
created
live-geojson.php 1 patch
Braces   +136 added lines, -53 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
 $aircrafts_shadow = array();
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,25 +212,37 @@  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_icao = $spotter_item['aircraft_icao'];
174
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
175
-								else {
219
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
220
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
221
+								} else {
176 222
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
177
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
178
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
179
-									else $spotter_item['aircraft_shadow'] = '';
223
+									if (count($aircraft_info) > 0) {
224
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
225
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
226
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
227
+									} else {
228
+										$spotter_item['aircraft_shadow'] = '';
229
+									}
180 230
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
181 231
 								}
182 232
 							}
183 233
 						}
184 234
 						if ($spotter_item['aircraft_shadow'] == '') {
185
-							if ($compress) $output .= '"as": "default.png",';
186
-							else $output .= '"aircraft_shadow": "default.png",';
235
+							if ($compress) {
236
+								$output .= '"as": "default.png",';
237
+							} else {
238
+								$output .= '"aircraft_shadow": "default.png",';
239
+							}
187 240
 						} else {
188
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
189
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
241
+							if ($compress) {
242
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
243
+							} else {
244
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
245
+							}
190 246
 						}
191 247
 						if (isset($spotter_item['airline_name'])) {
192 248
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -194,8 +250,11 @@  discard block
 block discarded – undo
194 250
 							$output .= '"airline_name": "NA",';
195 251
 						}
196 252
 						if (isset($spotter_item['departure_airport'])) {
197
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
198
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
253
+							if ($compress) {
254
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
255
+							} else {
256
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
257
+							}
199 258
 						}
200 259
 						if (isset($spotter_item['departure_airport_city'])) {
201 260
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -207,8 +266,11 @@  discard block
 block discarded – undo
207 266
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
208 267
 						}
209 268
 						if (isset($spotter_item['arrival_airport'])) {
210
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
211
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
269
+							if ($compress) {
270
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
271
+							} else {
272
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
273
+							}
212 274
 						}
213 275
 						if (isset($spotter_item['arrival_airport_city'])) {
214 276
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -226,10 +288,16 @@  discard block
 block discarded – undo
226 288
 							$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
227 289
 						}
228 290
 						
229
-						if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
230
-						else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
231
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
232
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
291
+						if ($compress) {
292
+							$output .= '"a": "'.$spotter_item['altitude'].'",';
293
+						} else {
294
+							$output .= '"altitude": "'.$spotter_item['altitude'].'",';
295
+						}
296
+						if ($compress) {
297
+							$output .= '"h": "'.$spotter_item['heading'].'",';
298
+						} else {
299
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
300
+						}
233 301
 						
234 302
 						if (isset($archivespeed)) {
235 303
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -239,7 +307,9 @@  discard block
 block discarded – undo
239 307
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
240 308
 						}
241 309
 
242
-						if (!$min) $output .= '"image": "'.$image.'",';
310
+						if (!$min) {
311
+							$output .= '"image": "'.$image.'",';
312
+						}
243 313
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
244 314
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
245 315
 						}
@@ -247,8 +317,11 @@  discard block
 block discarded – undo
247 317
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
248 318
 						}
249 319
 						if (isset($spotter_item['squawk'])) {
250
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
251
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
320
+							if ($compress) {
321
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
322
+							} else {
323
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
324
+							}
252 325
 						}
253 326
 						if (isset($spotter_item['squawk_usage'])) {
254 327
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -266,8 +339,11 @@  discard block
 block discarded – undo
266 339
 							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
267 340
 						}
268 341
 						// type when not aircraft ?
269
-						if ($compress) $output .= '"t": "aircraft"';
270
-						else $output .= '"type": "aircraft"';
342
+						if ($compress) {
343
+							$output .= '"t": "aircraft"';
344
+						} else {
345
+							$output .= '"type": "aircraft"';
346
+						}
271 347
 						$output .= '},';
272 348
 						$output .= '"geometry": {';
273 349
 							$output .= '"type": "Point",';
@@ -334,7 +410,9 @@  discard block
 block discarded – undo
334 410
 			}
335 411
 */
336 412
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
337
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
413
+				if ($history == '' && isset($_COOKIE['history'])) {
414
+					$history = $_COOKIE['history'];
415
+				}
338 416
 				
339 417
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
340 418
 				|| (!isset($_COOKIE['flightpath']) 
@@ -356,8 +434,11 @@  discard block
 block discarded – undo
356 434
 						$output_history .= ']}},';
357 435
 						$output .= $output_history;
358 436
 					    }
359
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
360
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
437
+					    if ($compress) {
438
+					    	$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
439
+					    } else {
440
+					    	$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
441
+					    }
361 442
 					}
362 443
 					$output_history .= '[';
363 444
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -403,7 +484,9 @@  discard block
 block discarded – undo
403 484
 			$output .= ']';
404 485
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
405 486
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
406
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
487
+			if (isset($begindate)) {
488
+				$output .= '"archive_date": "'.$begindate.'",';
489
+			}
407 490
 			$output .= '"fc": "'.$j.'"';
408 491
 		} else {
409 492
 			$output .= '"features": ';
Please login to merge, or discard this patch.