Completed
Push — master ( 0a71c8...58eab4 )
by Yannick
38:44
created
live-geojson.php 1 patch
Braces   +288 added lines, -113 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
@@ -162,20 +187,30 @@  discard block
 block discarded – undo
162 187
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
163 188
 		}
164 189
 	}
165
-	if ($flightcnt == '') $flightcnt = 0;
166
-} else $flightcnt = 0;
190
+	if ($flightcnt == '') {
191
+		$flightcnt = 0;
192
+	}
193
+	} else {
194
+	$flightcnt = 0;
195
+}
167 196
 
168 197
 $sqltime = round(microtime(true)-$begintime,2);
169 198
 
170
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
171
-else $usenextlatlon = true;
199
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
200
+	$usenextlatlon = false;
201
+} else {
202
+	$usenextlatlon = true;
203
+}
172 204
 $j = 0;
173 205
 $prev_flightaware_id = '';
174 206
 $aircrafts_shadow = array();
175 207
 $output = '{';
176 208
 	$output .= '"type": "FeatureCollection",';
177
-		if ($min) $output .= '"minimal": "true",';
178
-		else $output .= '"minimal": "false",';
209
+		if ($min) {
210
+			$output .= '"minimal": "true",';
211
+		} else {
212
+			$output .= '"minimal": "false",';
213
+		}
179 214
 		//$output .= '"fc": "'.$flightcnt.'",';
180 215
 		$output .= '"sqt": "'.$sqltime.'",';
181 216
 
@@ -219,18 +254,29 @@  discard block
 block discarded – undo
219 254
 						}
220 255
 						$output .= '"properties": {';
221 256
 						if (isset($spotter_item['flightaware_id'])) {
222
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
223
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
257
+							if ($compress) {
258
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
259
+							} else {
260
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
261
+							}
224 262
 						} elseif (isset($spotter_item['famtrackid'])) {
225
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
226
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
263
+							if ($compress) {
264
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
265
+							} else {
266
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
267
+							}
227 268
 						} elseif (isset($spotter_item['fammarine_id'])) {
228
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
229
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
269
+							if ($compress) {
270
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
271
+							} else {
272
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
273
+							}
230 274
 						}
231 275
 							$output .= '"fc": "'.$flightcnt.'",';
232 276
 							$output .= '"sqt": "'.$sqltime.'",';
233
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
277
+							if (isset($begindate)) {
278
+								$output .= '"archive_date": "'.$begindate.'",';
279
+							}
234 280
 
235 281
 /*
236 282
 							if ($min) $output .= '"minimal": "true",';
@@ -238,14 +284,22 @@  discard block
 block discarded – undo
238 284
 */
239 285
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
240 286
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
241
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
242
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
287
+							if ($compress) {
288
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
289
+							} else {
290
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
291
+							}
243 292
 							//"
244 293
 						} else {
245
-							if ($compress) $output .= '"c": "NA",';
246
-							else $output .= '"callsign": "NA",';
294
+							if ($compress) {
295
+								$output .= '"c": "NA",';
296
+							} else {
297
+								$output .= '"callsign": "NA",';
298
+							}
299
+						}
300
+						if (isset($spotter_item['registration'])) {
301
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
247 302
 						}
248
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
249 303
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
250 304
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
251 305
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -258,16 +312,23 @@  discard block
 block discarded – undo
258 312
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
259 313
 						}
260 314
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
261
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
262
-							else {
315
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
316
+								$spotter_item['aircraft_shadow'] = '';
317
+							} else {
263 318
 								$aircraft_icao = $spotter_item['aircraft_icao'];
264
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
265
-								else {
319
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
320
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
321
+								} else {
266 322
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
267
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
268
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
269
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
270
-									else $spotter_item['aircraft_shadow'] = '';
323
+									if (count($aircraft_info) > 0) {
324
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
325
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
326
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
327
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
328
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
329
+									} else {
330
+										$spotter_item['aircraft_shadow'] = '';
331
+									}
271 332
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
272 333
 								}
273 334
 							}
@@ -275,73 +336,139 @@  discard block
 block discarded – undo
275 336
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
276 337
 							if ($tracker) {
277 338
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
278
-									if ($compress) $output .= '"as": "ambulance.png",';
279
-									else $output .= '"aircraft_shadow": "ambulance.png",';
339
+									if ($compress) {
340
+										$output .= '"as": "ambulance.png",';
341
+									} else {
342
+										$output .= '"aircraft_shadow": "ambulance.png",';
343
+									}
280 344
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
281
-									if ($compress) $output .= '"as": "police.png",';
282
-									else $output .= '"aircraft_shadow": "police.png",';
345
+									if ($compress) {
346
+										$output .= '"as": "police.png",';
347
+									} else {
348
+										$output .= '"aircraft_shadow": "police.png",';
349
+									}
283 350
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
284
-									if ($compress) $output .= '"as": "ship.png",';
285
-									else $output .= '"aircraft_shadow": "ship.png",';
351
+									if ($compress) {
352
+										$output .= '"as": "ship.png",';
353
+									} else {
354
+										$output .= '"aircraft_shadow": "ship.png",';
355
+									}
286 356
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
287
-									if ($compress) $output .= '"as": "ship.png",';
288
-									else $output .= '"aircraft_shadow": "ship.png",';
357
+									if ($compress) {
358
+										$output .= '"as": "ship.png",';
359
+									} else {
360
+										$output .= '"aircraft_shadow": "ship.png",';
361
+									}
289 362
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
290
-									if ($compress) $output .= '"as": "ship.png",';
291
-									else $output .= '"aircraft_shadow": "ship.png",';
363
+									if ($compress) {
364
+										$output .= '"as": "ship.png",';
365
+									} else {
366
+										$output .= '"aircraft_shadow": "ship.png",';
367
+									}
292 368
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
293
-									if ($compress) $output .= '"as": "truck.png",';
294
-									else $output .= '"aircraft_shadow": "truck.png",';
369
+									if ($compress) {
370
+										$output .= '"as": "truck.png",';
371
+									} else {
372
+										$output .= '"aircraft_shadow": "truck.png",';
373
+									}
295 374
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
296
-									if ($compress) $output .= '"as": "truck.png",';
297
-									else $output .= '"aircraft_shadow": "truck.png",';
375
+									if ($compress) {
376
+										$output .= '"as": "truck.png",';
377
+									} else {
378
+										$output .= '"aircraft_shadow": "truck.png",';
379
+									}
298 380
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
299
-									if ($compress) $output .= '"as": "aircraft.png",';
300
-									else $output .= '"aircraft_shadow": "aircraft.png",';
381
+									if ($compress) {
382
+										$output .= '"as": "aircraft.png",';
383
+									} else {
384
+										$output .= '"aircraft_shadow": "aircraft.png",';
385
+									}
301 386
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
302
-									if ($compress) $output .= '"as": "aircraft.png",';
303
-									else $output .= '"aircraft_shadow": "aircraft.png",';
387
+									if ($compress) {
388
+										$output .= '"as": "aircraft.png",';
389
+									} else {
390
+										$output .= '"aircraft_shadow": "aircraft.png",';
391
+									}
304 392
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
305
-									if ($compress) $output .= '"as": "helico.png",';
306
-									else $output .= '"aircraft_shadow": "helico.png",';
393
+									if ($compress) {
394
+										$output .= '"as": "helico.png",';
395
+									} else {
396
+										$output .= '"aircraft_shadow": "helico.png",';
397
+									}
307 398
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
308
-									if ($compress) $output .= '"as": "rail.png",';
309
-									else $output .= '"aircraft_shadow": "rail.png",';
399
+									if ($compress) {
400
+										$output .= '"as": "rail.png",';
401
+									} else {
402
+										$output .= '"aircraft_shadow": "rail.png",';
403
+									}
310 404
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
311
-									if ($compress) $output .= '"as": "firetruck.png",';
312
-									else $output .= '"aircraft_shadow": "firetruck.png",';
405
+									if ($compress) {
406
+										$output .= '"as": "firetruck.png",';
407
+									} else {
408
+										$output .= '"aircraft_shadow": "firetruck.png",';
409
+									}
313 410
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
314
-									if ($compress) $output .= '"as": "bus.png",';
315
-									else $output .= '"aircraft_shadow": "bus.png",';
411
+									if ($compress) {
412
+										$output .= '"as": "bus.png",';
413
+									} else {
414
+										$output .= '"aircraft_shadow": "bus.png",';
415
+									}
316 416
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
317
-									if ($compress) $output .= '"as": "phone.png",';
318
-									else $output .= '"aircraft_shadow": "phone.png",';
417
+									if ($compress) {
418
+										$output .= '"as": "phone.png",';
419
+									} else {
420
+										$output .= '"aircraft_shadow": "phone.png",';
421
+									}
319 422
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
320
-									if ($compress) $output .= '"as": "jogger.png",';
321
-									else $output .= '"aircraft_shadow": "jogger.png",';
423
+									if ($compress) {
424
+										$output .= '"as": "jogger.png",';
425
+									} else {
426
+										$output .= '"aircraft_shadow": "jogger.png",';
427
+									}
322 428
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
323
-									if ($compress) $output .= '"as": "bike.png",';
324
-									else $output .= '"aircraft_shadow": "bike.png",';
429
+									if ($compress) {
430
+										$output .= '"as": "bike.png",';
431
+									} else {
432
+										$output .= '"aircraft_shadow": "bike.png",';
433
+									}
325 434
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
326
-									if ($compress) $output .= '"as": "motorcycle.png",';
327
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
435
+									if ($compress) {
436
+										$output .= '"as": "motorcycle.png",';
437
+									} else {
438
+										$output .= '"aircraft_shadow": "motorcycle.png",';
439
+									}
328 440
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
329
-									if ($compress) $output .= '"as": "balloon.png",';
330
-									else $output .= '"aircraft_shadow": "balloon.png",';
441
+									if ($compress) {
442
+										$output .= '"as": "balloon.png",';
443
+									} else {
444
+										$output .= '"aircraft_shadow": "balloon.png",';
445
+									}
331 446
 								} else {
332
-									if ($compress) $output .= '"as": "car.png",';
333
-									else $output .= '"aircraft_shadow": "car.png",';
447
+									if ($compress) {
448
+										$output .= '"as": "car.png",';
449
+									} else {
450
+										$output .= '"aircraft_shadow": "car.png",';
451
+									}
334 452
 								}
335 453
 							} elseif ($marine) {
336
-								if ($compress) $output .= '"as": "ship.png",';
337
-								else $output .= '"aircraft_shadow": "ship.png",';
454
+								if ($compress) {
455
+									$output .= '"as": "ship.png",';
456
+								} else {
457
+									$output .= '"aircraft_shadow": "ship.png",';
458
+								}
338 459
 							} else {
339
-								if ($compress) $output .= '"as": "default.png",';
340
-								else $output .= '"aircraft_shadow": "default.png",';
460
+								if ($compress) {
461
+									$output .= '"as": "default.png",';
462
+								} else {
463
+									$output .= '"aircraft_shadow": "default.png",';
464
+								}
341 465
 							}
342 466
 						} else {
343
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
344
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
467
+							if ($compress) {
468
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
469
+							} else {
470
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
471
+							}
345 472
 						}
346 473
 						if (isset($spotter_item['airline_name'])) {
347 474
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -349,8 +476,11 @@  discard block
 block discarded – undo
349 476
 							$output .= '"airline_name": "NA",';
350 477
 						}
351 478
 						if (isset($spotter_item['departure_airport'])) {
352
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
353
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
479
+							if ($compress) {
480
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
481
+							} else {
482
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
483
+							}
354 484
 						}
355 485
 						if (isset($spotter_item['departure_airport_city'])) {
356 486
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -362,8 +492,11 @@  discard block
 block discarded – undo
362 492
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
363 493
 						}
364 494
 						if (isset($spotter_item['arrival_airport'])) {
365
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
366
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
495
+							if ($compress) {
496
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
497
+							} else {
498
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
499
+							}
367 500
 						}
368 501
 						if (isset($spotter_item['arrival_airport_city'])) {
369 502
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -382,11 +515,17 @@  discard block
 block discarded – undo
382 515
 						}
383 516
 						
384 517
 						if (isset($spotter_item['altitude'])) {
385
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
386
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
518
+							if ($compress) {
519
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
520
+							} else {
521
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
522
+							}
523
+						}
524
+						if ($compress) {
525
+							$output .= '"h": "'.$spotter_item['heading'].'",';
526
+						} else {
527
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
387 528
 						}
388
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
389
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
390 529
 						
391 530
 						if (isset($archivespeed)) {
392 531
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -396,7 +535,9 @@  discard block
 block discarded – undo
396 535
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
397 536
 						}
398 537
 
399
-						if (!$min) $output .= '"image": "'.$image.'",';
538
+						if (!$min) {
539
+							$output .= '"image": "'.$image.'",';
540
+						}
400 541
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
401 542
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
402 543
 						}
@@ -404,8 +545,11 @@  discard block
 block discarded – undo
404 545
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
405 546
 						}
406 547
 						if (isset($spotter_item['squawk'])) {
407
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
408
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
548
+							if ($compress) {
549
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
550
+							} else {
551
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
552
+							}
409 553
 						}
410 554
 						if (isset($spotter_item['squawk_usage'])) {
411 555
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -424,14 +568,23 @@  discard block
 block discarded – undo
424 568
 						}
425 569
 						// type when not aircraft ?
426 570
 						if (isset($spotter_item['type'])) {
427
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
428
-							else $output .= '"type": "'.$spotter_item['type'].'"';
571
+							if ($compress) {
572
+								$output .= '"t": "'.$spotter_item['type'].'"';
573
+							} else {
574
+								$output .= '"type": "'.$spotter_item['type'].'"';
575
+							}
429 576
 						} elseif ($marine) {
430
-							if ($compress) $output .= '"t": "ship"';
431
-							else $output .= '"type": "ship"';
577
+							if ($compress) {
578
+								$output .= '"t": "ship"';
579
+							} else {
580
+								$output .= '"type": "ship"';
581
+							}
432 582
 						} else {
433
-							if ($compress) $output .= '"t": "aircraft"';
434
-							else $output .= '"type": "aircraft"';
583
+							if ($compress) {
584
+								$output .= '"t": "aircraft"';
585
+							} else {
586
+								$output .= '"type": "aircraft"';
587
+							}
435 588
 						}
436 589
 						$output .= '},';
437 590
 						$output .= '"geometry": {';
@@ -499,7 +652,9 @@  discard block
 block discarded – undo
499 652
 			}
500 653
 */
501 654
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
502
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
655
+				if ($history == '' && isset($_COOKIE['history'])) {
656
+					$history = $_COOKIE['history'];
657
+				}
503 658
 				
504 659
 				if (
505 660
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -543,8 +698,11 @@  discard block
 block discarded – undo
543 698
 									$output_history .= ']}},';
544 699
 									$output .= $output_history;
545 700
 								}
546
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
547
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
701
+								if ($compress) {
702
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
703
+								} else {
704
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
705
+								}
548 706
 							}
549 707
 							$output_history .= '[';
550 708
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -563,9 +721,14 @@  discard block
 block discarded – undo
563 721
 							$prev_alt = $alt;
564 722
 						} else {
565 723
 							if ($d == false) {
566
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
567
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
568
-							} else $d = true;
724
+								if ($compress) {
725
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
726
+								} else {
727
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
728
+								}
729
+							} else {
730
+								$d = true;
731
+							}
569 732
 							$output_history .= '[';
570 733
 							$output_history .=  $spotter_history['longitude'].', ';
571 734
 							$output_history .=  $spotter_history['latitude'];
@@ -586,7 +749,9 @@  discard block
 block discarded – undo
586 749
 							$output_historyd = '[';
587 750
 							$output_historyd .=  $spotter_item['longitude'].', ';
588 751
 							$output_historyd .=  $spotter_item['latitude'];
589
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
752
+							if (isset($spotter_history['altitude'])) {
753
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
754
+							}
590 755
 							$output_historyd .= '],';
591 756
 							//$output_history = $output_historyd.$output_history;
592 757
 							$output_history = $output_history.$output_historyd;
@@ -608,8 +773,11 @@  discard block
 block discarded – undo
608 773
 				        && $spotter_item['arrival_airport'] != 'NA' 
609 774
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
610 775
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
611
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
612
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
776
+				    if ($compress) {
777
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
778
+				    } else {
779
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
780
+				    }
613 781
 				    if (isset($spotter_item['departure_airport_latitude'])) {
614 782
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
615 783
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -642,8 +810,11 @@  discard block
 block discarded – undo
642 810
 				    	    || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) 
643 811
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
644 812
 				    $havedata = false;
645
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
646
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
813
+				    if ($compress) {
814
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
+				    } else {
816
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
817
+				    }
647 818
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
648 819
 
649 820
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -658,7 +829,9 @@  discard block
 block discarded – undo
658 829
 				    }
659 830
 				    //$output_dest  = substr($output_dest, 0, -1);
660 831
 				    $output_dest .= ']}},';
661
-				    if ($havedata) $output .= $output_dest;
832
+				    if ($havedata) {
833
+				    	$output .= $output_dest;
834
+				    }
662 835
 				    unset($output_dest);
663 836
 				}
664 837
 			}
@@ -666,7 +839,9 @@  discard block
 block discarded – undo
666 839
 			$output .= ']';
667 840
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
668 841
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
669
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
842
+			if (isset($begindate)) {
843
+				$output .= '"archive_date": "'.$begindate.'",';
844
+			}
670 845
 			$output .= '"fc": "'.$j.'"';
671 846
 		} else {
672 847
 			$output .= '"features": ';
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1056 added lines, -366 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 20);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 110
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 127
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		//print_r($mfr);
1117 1252
 		return '';
@@ -1136,11 +1271,15 @@  discard block
 block discarded – undo
1136 1271
 			$i = 0;
1137 1272
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1138 1273
 			//$Connection->db->beginTransaction();
1139
-			if ($globalTransaction) $Connection->db->beginTransaction();
1274
+			if ($globalTransaction) {
1275
+				$Connection->db->beginTransaction();
1276
+			}
1140 1277
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1141 1278
 			{
1142 1279
 				if ($i > 0) {
1143
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1280
+					if ($data[1] == 'NULL') {
1281
+						$data[1] = $data[0];
1282
+					}
1144 1283
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1145 1284
 					try {
1146 1285
 						$sth = $Connection->db->prepare($query);
@@ -1152,7 +1291,9 @@  discard block
 block discarded – undo
1152 1291
 				$i++;
1153 1292
 			}
1154 1293
 			fclose($handle);
1155
-			if ($globalTransaction) $Connection->db->commit();
1294
+			if ($globalTransaction) {
1295
+				$Connection->db->commit();
1296
+			}
1156 1297
 		}
1157 1298
 		return '';
1158 1299
         }
@@ -1173,7 +1314,9 @@  discard block
 block discarded – undo
1173 1314
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1174 1315
 		{
1175 1316
 			$i = 0;
1176
-			if ($globalTransaction) $Connection->db->beginTransaction();
1317
+			if ($globalTransaction) {
1318
+				$Connection->db->beginTransaction();
1319
+			}
1177 1320
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1178 1321
 			{
1179 1322
 				if ($i > 0) {
@@ -1189,7 +1332,9 @@  discard block
 block discarded – undo
1189 1332
 				$i++;
1190 1333
 			}
1191 1334
 			fclose($handle);
1192
-			if ($globalTransaction) $Connection->db->commit();
1335
+			if ($globalTransaction) {
1336
+				$Connection->db->commit();
1337
+			}
1193 1338
 		}
1194 1339
 		return '';
1195 1340
         }
@@ -1209,7 +1354,9 @@  discard block
 block discarded – undo
1209 1354
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1210 1355
 		{
1211 1356
 			$i = 0;
1212
-			if ($globalTransaction) $Connection->db->beginTransaction();
1357
+			if ($globalTransaction) {
1358
+				$Connection->db->beginTransaction();
1359
+			}
1213 1360
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1214 1361
 			{
1215 1362
 				if ($i > 0) {
@@ -1218,13 +1365,17 @@  discard block
 block discarded – undo
1218 1365
 						$sth = $Connection->db->prepare($query);
1219 1366
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1220 1367
 					} catch(PDOException $e) {
1221
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1368
+						if ($globalDebug) {
1369
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1370
+						}
1222 1371
 					}
1223 1372
 				}
1224 1373
 				$i++;
1225 1374
 			}
1226 1375
 			fclose($handle);
1227
-			if ($globalTransaction) $Connection->db->commit();
1376
+			if ($globalTransaction) {
1377
+				$Connection->db->commit();
1378
+			}
1228 1379
 		}
1229 1380
 		return '';
1230 1381
         }
@@ -1249,7 +1400,9 @@  discard block
 block discarded – undo
1249 1400
 			$i = 0;
1250 1401
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1251 1402
 			//$Connection->db->beginTransaction();
1252
-			if ($globalTransaction) $Connection->db->beginTransaction();
1403
+			if ($globalTransaction) {
1404
+				$Connection->db->beginTransaction();
1405
+			}
1253 1406
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1254 1407
 			{
1255 1408
 				if ($i > 0) {
@@ -1265,7 +1418,9 @@  discard block
 block discarded – undo
1265 1418
 				$i++;
1266 1419
 			}
1267 1420
 			fclose($handle);
1268
-			if ($globalTransaction) $Connection->db->commit();
1421
+			if ($globalTransaction) {
1422
+				$Connection->db->commit();
1423
+			}
1269 1424
 		}
1270 1425
 		return '';
1271 1426
         }
@@ -1285,7 +1440,9 @@  discard block
 block discarded – undo
1285 1440
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1286 1441
 		{
1287 1442
 			$i = 0;
1288
-			if ($globalTransaction) $Connection->db->beginTransaction();
1443
+			if ($globalTransaction) {
1444
+				$Connection->db->beginTransaction();
1445
+			}
1289 1446
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1290 1447
 			{
1291 1448
 				if ($i > 0) {
@@ -1302,7 +1459,9 @@  discard block
 block discarded – undo
1302 1459
 				$i++;
1303 1460
 			}
1304 1461
 			fclose($handle);
1305
-			if ($globalTransaction) $Connection->db->commit();
1462
+			if ($globalTransaction) {
1463
+				$Connection->db->commit();
1464
+			}
1306 1465
 		}
1307 1466
 		return '';
1308 1467
 	}
@@ -1321,7 +1480,9 @@  discard block
 block discarded – undo
1321 1480
 		$Connection = new Connection();
1322 1481
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1323 1482
 		{
1324
-			if ($globalTransaction) $Connection->db->beginTransaction();
1483
+			if ($globalTransaction) {
1484
+				$Connection->db->beginTransaction();
1485
+			}
1325 1486
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1326 1487
 			{
1327 1488
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1336,7 +1497,9 @@  discard block
 block discarded – undo
1336 1497
 				}
1337 1498
 			}
1338 1499
 			fclose($handle);
1339
-			if ($globalTransaction) $Connection->db->commit();
1500
+			if ($globalTransaction) {
1501
+				$Connection->db->commit();
1502
+			}
1340 1503
 		}
1341 1504
 		return '';
1342 1505
         }
@@ -1412,9 +1575,14 @@  discard block
 block discarded – undo
1412 1575
 				if ($i > 0 && $data[0] != '') {
1413 1576
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1414 1577
 					$period = str_replace(',','',$data[14]);
1415
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1416
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1417
-					else $launch_date = NULL;
1578
+					if (!empty($period) && strpos($period,'days')) {
1579
+						$period = str_replace(' days','',$period)*24*60;
1580
+					}
1581
+					if ($data[18] != '') {
1582
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1583
+					} else {
1584
+						$launch_date = NULL;
1585
+					}
1418 1586
 					$data = array_map(function($value) {
1419 1587
 						return trim($value) === '' ? null : $value;
1420 1588
 					}, $data);
@@ -1767,7 +1935,9 @@  discard block
 block discarded – undo
1767 1935
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1768 1936
 		{
1769 1937
 			$i = 0;
1770
-			if ($globalTransaction) $Connection->db->beginTransaction();
1938
+			if ($globalTransaction) {
1939
+				$Connection->db->beginTransaction();
1940
+			}
1771 1941
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1772 1942
 			{
1773 1943
 				$i++;
@@ -1795,7 +1965,9 @@  discard block
 block discarded – undo
1795 1965
 				}
1796 1966
 			}
1797 1967
 			fclose($handle);
1798
-			if ($globalTransaction) $Connection->db->commit();
1968
+			if ($globalTransaction) {
1969
+				$Connection->db->commit();
1970
+			}
1799 1971
 		}
1800 1972
 		return '';
1801 1973
         }
@@ -1818,7 +1990,9 @@  discard block
 block discarded – undo
1818 1990
 		$Connection = new Connection();
1819 1991
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1820 1992
 		{
1821
-			if ($globalTransaction) $Connection->db->beginTransaction();
1993
+			if ($globalTransaction) {
1994
+				$Connection->db->beginTransaction();
1995
+			}
1822 1996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1823 1997
 			{
1824 1998
 				if(count($row) > 1) {
@@ -1832,7 +2006,9 @@  discard block
 block discarded – undo
1832 2006
 				}
1833 2007
 			}
1834 2008
 			fclose($handle);
1835
-			if ($globalTransaction) $Connection->db->commit();
2009
+			if ($globalTransaction) {
2010
+				$Connection->db->commit();
2011
+			}
1836 2012
 		}
1837 2013
 		return '';
1838 2014
         }
@@ -1852,8 +2028,9 @@  discard block
 block discarded – undo
1852 2028
 	        }
1853 2029
 
1854 2030
 
1855
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1856
-		else {
2031
+		if ($globalDBdriver == 'mysql') {
2032
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2033
+		} else {
1857 2034
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1858 2035
 			$query = "CREATE EXTENSION postgis";
1859 2036
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1872,7 +2049,9 @@  discard block
 block discarded – undo
1872 2049
 		global $tmp_dir, $globalDebug;
1873 2050
 		include_once('class.create_db.php');
1874 2051
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1875
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2052
+		if ($globalDebug) {
2053
+			echo "NOTAM from FlightAirMap website : Download...";
2054
+		}
1876 2055
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1877 2056
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1878 2057
 		$error = '';
@@ -1880,17 +2059,27 @@  discard block
 block discarded – undo
1880 2059
 			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1881 2060
 			$notam_md5 = $notam_md5_file[0];
1882 2061
 			if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1883
-				if ($globalDebug) echo "Gunzip...";
2062
+				if ($globalDebug) {
2063
+					echo "Gunzip...";
2064
+				}
1884 2065
 				update_db::gunzip($tmp_dir.'notam.txt.gz');
1885
-				if ($globalDebug) echo "Add to DB...";
2066
+				if ($globalDebug) {
2067
+					echo "Add to DB...";
2068
+				}
1886 2069
 				//$error = create_db::import_file($tmp_dir.'notam.sql');
1887 2070
 				$NOTAM = new NOTAM();
1888 2071
 				$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1889
-			} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
1890
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2072
+			} else {
2073
+				$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2074
+			}
2075
+		} else {
2076
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2077
+		}
1891 2078
 		if ($error != '') {
1892 2079
 			return $error;
1893
-		} elseif ($globalDebug) echo "Done\n";
2080
+		} elseif ($globalDebug) {
2081
+			echo "Done\n";
2082
+		}
1894 2083
 		return '';
1895 2084
 	}
1896 2085
 
@@ -1945,68 +2134,114 @@  discard block
 block discarded – undo
1945 2134
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1946 2135
 		if (extension_loaded('zip')) {
1947 2136
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1948
-				if ($globalDebug) echo "Unzip...";
2137
+				if ($globalDebug) {
2138
+					echo "Unzip...";
2139
+				}
1949 2140
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1950
-				if ($globalDebug) echo "Add to DB...";
2141
+				if ($globalDebug) {
2142
+					echo "Add to DB...";
2143
+				}
1951 2144
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1952
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2145
+				if ($globalDebug) {
2146
+					echo "Copy airlines logos to airlines images directory...";
2147
+				}
1953 2148
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1954
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1955
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1956
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1957
-		} else $error = "ZIP module not loaded but required for IVAO.";
2149
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2150
+						$error = "Failed to copy airlines logo.";
2151
+					}
2152
+				} else {
2153
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2154
+				}
2155
+			} else {
2156
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2157
+			}
2158
+		} else {
2159
+			$error = "ZIP module not loaded but required for IVAO.";
2160
+		}
1958 2161
 		if ($error != '') {
1959 2162
 			return $error;
1960
-		} elseif ($globalDebug) echo "Done\n";
2163
+		} elseif ($globalDebug) {
2164
+			echo "Done\n";
2165
+		}
1961 2166
 		return '';
1962 2167
 	}
1963 2168
 
1964 2169
 	public static function update_routes() {
1965 2170
 		global $tmp_dir, $globalDebug;
1966 2171
 		$error = '';
1967
-		if ($globalDebug) echo "Routes : Download...";
2172
+		if ($globalDebug) {
2173
+			echo "Routes : Download...";
2174
+		}
1968 2175
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1969 2176
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1970
-			if ($globalDebug) echo "Gunzip...";
2177
+			if ($globalDebug) {
2178
+				echo "Gunzip...";
2179
+			}
1971 2180
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1972
-			if ($globalDebug) echo "Add to DB...";
2181
+			if ($globalDebug) {
2182
+				echo "Add to DB...";
2183
+			}
1973 2184
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1974
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2185
+		} else {
2186
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2187
+		}
1975 2188
 		if ($error != '') {
1976 2189
 			return $error;
1977
-		} elseif ($globalDebug) echo "Done\n";
2190
+		} elseif ($globalDebug) {
2191
+			echo "Done\n";
2192
+		}
1978 2193
 		return '';
1979 2194
 	}
1980 2195
 	public static function update_oneworld() {
1981 2196
 		global $tmp_dir, $globalDebug;
1982 2197
 		$error = '';
1983
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2198
+		if ($globalDebug) {
2199
+			echo "Schedules Oneworld : Download...";
2200
+		}
1984 2201
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1985 2202
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1986
-			if ($globalDebug) echo "Gunzip...";
2203
+			if ($globalDebug) {
2204
+				echo "Gunzip...";
2205
+			}
1987 2206
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1988
-			if ($globalDebug) echo "Add to DB...";
2207
+			if ($globalDebug) {
2208
+				echo "Add to DB...";
2209
+			}
1989 2210
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1990
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2211
+		} else {
2212
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2213
+		}
1991 2214
 		if ($error != '') {
1992 2215
 			return $error;
1993
-		} elseif ($globalDebug) echo "Done\n";
2216
+		} elseif ($globalDebug) {
2217
+			echo "Done\n";
2218
+		}
1994 2219
 		return '';
1995 2220
 	}
1996 2221
 	public static function update_skyteam() {
1997 2222
 		global $tmp_dir, $globalDebug;
1998 2223
 		$error = '';
1999
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2224
+		if ($globalDebug) {
2225
+			echo "Schedules Skyteam : Download...";
2226
+		}
2000 2227
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2001 2228
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2002
-			if ($globalDebug) echo "Gunzip...";
2229
+			if ($globalDebug) {
2230
+				echo "Gunzip...";
2231
+			}
2003 2232
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2004
-			if ($globalDebug) echo "Add to DB...";
2233
+			if ($globalDebug) {
2234
+				echo "Add to DB...";
2235
+			}
2005 2236
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2006
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2237
+		} else {
2238
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2239
+		}
2007 2240
 		if ($error != '') {
2008 2241
 			return $error;
2009
-		} elseif ($globalDebug) echo "Done\n";
2242
+		} elseif ($globalDebug) {
2243
+			echo "Done\n";
2244
+		}
2010 2245
 		return '';
2011 2246
 	}
2012 2247
 	public static function update_ModeS() {
@@ -2023,336 +2258,586 @@  discard block
 block discarded – undo
2023 2258
 			exit;
2024 2259
 		} elseif ($globalDebug) echo "Done\n";
2025 2260
 */
2026
-		if ($globalDebug) echo "Modes : Download...";
2027
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2261
+		if ($globalDebug) {
2262
+			echo "Modes : Download...";
2263
+		}
2264
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2028 2265
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2029 2266
 
2030 2267
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2031 2268
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2032
-			if ($globalDebug) echo "Unzip...";
2033
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2269
+			if ($globalDebug) {
2270
+				echo "Unzip...";
2271
+			}
2272
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2034 2273
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2035
-			if ($globalDebug) echo "Add to DB...";
2274
+			if ($globalDebug) {
2275
+				echo "Add to DB...";
2276
+			}
2036 2277
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2037 2278
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2038
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2279
+		} else {
2280
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2281
+		}
2039 2282
 		if ($error != '') {
2040 2283
 			return $error;
2041
-		} elseif ($globalDebug) echo "Done\n";
2284
+		} elseif ($globalDebug) {
2285
+			echo "Done\n";
2286
+		}
2042 2287
 		return '';
2043 2288
 	}
2044 2289
 
2045 2290
 	public static function update_ModeS_faa() {
2046 2291
 		global $tmp_dir, $globalDebug;
2047
-		if ($globalDebug) echo "Modes FAA: Download...";
2292
+		if ($globalDebug) {
2293
+			echo "Modes FAA: Download...";
2294
+		}
2048 2295
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2049 2296
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2050
-			if ($globalDebug) echo "Unzip...";
2297
+			if ($globalDebug) {
2298
+				echo "Unzip...";
2299
+			}
2051 2300
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2052
-			if ($globalDebug) echo "Add to DB...";
2301
+			if ($globalDebug) {
2302
+				echo "Add to DB...";
2303
+			}
2053 2304
 			$error = update_db::modes_faa();
2054
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2305
+		} else {
2306
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2307
+		}
2055 2308
 		if ($error != '') {
2056 2309
 			return $error;
2057
-		} elseif ($globalDebug) echo "Done\n";
2310
+		} elseif ($globalDebug) {
2311
+			echo "Done\n";
2312
+		}
2058 2313
 		return '';
2059 2314
 	}
2060 2315
 
2061 2316
 	public static function update_ModeS_flarm() {
2062 2317
 		global $tmp_dir, $globalDebug;
2063
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2318
+		if ($globalDebug) {
2319
+			echo "Modes Flarmnet: Download...";
2320
+		}
2064 2321
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2065 2322
 		if (file_exists($tmp_dir.'data.fln')) {
2066
-			if ($globalDebug) echo "Add to DB...";
2323
+			if ($globalDebug) {
2324
+				echo "Add to DB...";
2325
+			}
2067 2326
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2068
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2327
+		} else {
2328
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2329
+		}
2069 2330
 		if ($error != '') {
2070 2331
 			return $error;
2071
-		} elseif ($globalDebug) echo "Done\n";
2332
+		} elseif ($globalDebug) {
2333
+			echo "Done\n";
2334
+		}
2072 2335
 		return '';
2073 2336
 	}
2074 2337
 
2075 2338
 	public static function update_ModeS_ogn() {
2076 2339
 		global $tmp_dir, $globalDebug;
2077
-		if ($globalDebug) echo "Modes OGN: Download...";
2340
+		if ($globalDebug) {
2341
+			echo "Modes OGN: Download...";
2342
+		}
2078 2343
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2079 2344
 		if (file_exists($tmp_dir.'ogn.csv')) {
2080
-			if ($globalDebug) echo "Add to DB...";
2345
+			if ($globalDebug) {
2346
+				echo "Add to DB...";
2347
+			}
2081 2348
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2082
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2349
+		} else {
2350
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2351
+		}
2083 2352
 		if ($error != '') {
2084 2353
 			return $error;
2085
-		} elseif ($globalDebug) echo "Done\n";
2354
+		} elseif ($globalDebug) {
2355
+			echo "Done\n";
2356
+		}
2086 2357
 		return '';
2087 2358
 	}
2088 2359
 
2089 2360
 	public static function update_owner() {
2090 2361
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2091 2362
 		
2092
-		if ($globalDebug) echo "Owner France: Download...";
2363
+		if ($globalDebug) {
2364
+			echo "Owner France: Download...";
2365
+		}
2093 2366
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2094 2367
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2095
-			if ($globalDebug) echo "Add to DB...";
2368
+			if ($globalDebug) {
2369
+				echo "Add to DB...";
2370
+			}
2096 2371
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2097
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2372
+		} else {
2373
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2374
+		}
2098 2375
 		if ($error != '') {
2099 2376
 			return $error;
2100
-		} elseif ($globalDebug) echo "Done\n";
2377
+		} elseif ($globalDebug) {
2378
+			echo "Done\n";
2379
+		}
2101 2380
 		
2102
-		if ($globalDebug) echo "Owner Ireland: Download...";
2381
+		if ($globalDebug) {
2382
+			echo "Owner Ireland: Download...";
2383
+		}
2103 2384
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2104 2385
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2105
-			if ($globalDebug) echo "Add to DB...";
2386
+			if ($globalDebug) {
2387
+				echo "Add to DB...";
2388
+			}
2106 2389
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2107
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2390
+		} else {
2391
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2392
+		}
2108 2393
 		if ($error != '') {
2109 2394
 			return $error;
2110
-		} elseif ($globalDebug) echo "Done\n";
2111
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2395
+		} elseif ($globalDebug) {
2396
+			echo "Done\n";
2397
+		}
2398
+		if ($globalDebug) {
2399
+			echo "Owner Switzerland: Download...";
2400
+		}
2112 2401
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2113 2402
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2114
-			if ($globalDebug) echo "Add to DB...";
2403
+			if ($globalDebug) {
2404
+				echo "Add to DB...";
2405
+			}
2115 2406
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2116
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2407
+		} else {
2408
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2409
+		}
2117 2410
 		if ($error != '') {
2118 2411
 			return $error;
2119
-		} elseif ($globalDebug) echo "Done\n";
2120
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2412
+		} elseif ($globalDebug) {
2413
+			echo "Done\n";
2414
+		}
2415
+		if ($globalDebug) {
2416
+			echo "Owner Czech Republic: Download...";
2417
+		}
2121 2418
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2122 2419
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2123
-			if ($globalDebug) echo "Add to DB...";
2420
+			if ($globalDebug) {
2421
+				echo "Add to DB...";
2422
+			}
2124 2423
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2125
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2424
+		} else {
2425
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2426
+		}
2126 2427
 		if ($error != '') {
2127 2428
 			return $error;
2128
-		} elseif ($globalDebug) echo "Done\n";
2129
-		if ($globalDebug) echo "Owner Australia: Download...";
2429
+		} elseif ($globalDebug) {
2430
+			echo "Done\n";
2431
+		}
2432
+		if ($globalDebug) {
2433
+			echo "Owner Australia: Download...";
2434
+		}
2130 2435
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2131 2436
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2132
-			if ($globalDebug) echo "Add to DB...";
2437
+			if ($globalDebug) {
2438
+				echo "Add to DB...";
2439
+			}
2133 2440
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2134
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2441
+		} else {
2442
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2443
+		}
2135 2444
 		if ($error != '') {
2136 2445
 			return $error;
2137
-		} elseif ($globalDebug) echo "Done\n";
2138
-		if ($globalDebug) echo "Owner Austria: Download...";
2446
+		} elseif ($globalDebug) {
2447
+			echo "Done\n";
2448
+		}
2449
+		if ($globalDebug) {
2450
+			echo "Owner Austria: Download...";
2451
+		}
2139 2452
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2140 2453
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2141
-			if ($globalDebug) echo "Add to DB...";
2454
+			if ($globalDebug) {
2455
+				echo "Add to DB...";
2456
+			}
2142 2457
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2143
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2458
+		} else {
2459
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2460
+		}
2144 2461
 		if ($error != '') {
2145 2462
 			return $error;
2146
-		} elseif ($globalDebug) echo "Done\n";
2147
-		if ($globalDebug) echo "Owner Chile: Download...";
2463
+		} elseif ($globalDebug) {
2464
+			echo "Done\n";
2465
+		}
2466
+		if ($globalDebug) {
2467
+			echo "Owner Chile: Download...";
2468
+		}
2148 2469
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2149 2470
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2150
-			if ($globalDebug) echo "Add to DB...";
2471
+			if ($globalDebug) {
2472
+				echo "Add to DB...";
2473
+			}
2151 2474
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2152
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2475
+		} else {
2476
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2477
+		}
2153 2478
 		if ($error != '') {
2154 2479
 			return $error;
2155
-		} elseif ($globalDebug) echo "Done\n";
2156
-		if ($globalDebug) echo "Owner Colombia: Download...";
2480
+		} elseif ($globalDebug) {
2481
+			echo "Done\n";
2482
+		}
2483
+		if ($globalDebug) {
2484
+			echo "Owner Colombia: Download...";
2485
+		}
2157 2486
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2158 2487
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2159
-			if ($globalDebug) echo "Add to DB...";
2488
+			if ($globalDebug) {
2489
+				echo "Add to DB...";
2490
+			}
2160 2491
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2161
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2492
+		} else {
2493
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2494
+		}
2162 2495
 		if ($error != '') {
2163 2496
 			return $error;
2164
-		} elseif ($globalDebug) echo "Done\n";
2165
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2497
+		} elseif ($globalDebug) {
2498
+			echo "Done\n";
2499
+		}
2500
+		if ($globalDebug) {
2501
+			echo "Owner Bosnia Herzegobina: Download...";
2502
+		}
2166 2503
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2167 2504
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2168
-			if ($globalDebug) echo "Add to DB...";
2505
+			if ($globalDebug) {
2506
+				echo "Add to DB...";
2507
+			}
2169 2508
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2170
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2509
+		} else {
2510
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2511
+		}
2171 2512
 		if ($error != '') {
2172 2513
 			return $error;
2173
-		} elseif ($globalDebug) echo "Done\n";
2174
-		if ($globalDebug) echo "Owner Brazil: Download...";
2514
+		} elseif ($globalDebug) {
2515
+			echo "Done\n";
2516
+		}
2517
+		if ($globalDebug) {
2518
+			echo "Owner Brazil: Download...";
2519
+		}
2175 2520
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2176 2521
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2177
-			if ($globalDebug) echo "Add to DB...";
2522
+			if ($globalDebug) {
2523
+				echo "Add to DB...";
2524
+			}
2178 2525
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2179
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2526
+		} else {
2527
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2528
+		}
2180 2529
 		if ($error != '') {
2181 2530
 			return $error;
2182
-		} elseif ($globalDebug) echo "Done\n";
2183
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2531
+		} elseif ($globalDebug) {
2532
+			echo "Done\n";
2533
+		}
2534
+		if ($globalDebug) {
2535
+			echo "Owner Cayman Islands: Download...";
2536
+		}
2184 2537
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2185 2538
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2186
-			if ($globalDebug) echo "Add to DB...";
2539
+			if ($globalDebug) {
2540
+				echo "Add to DB...";
2541
+			}
2187 2542
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2188
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2543
+		} else {
2544
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2545
+		}
2189 2546
 		if ($error != '') {
2190 2547
 			return $error;
2191
-		} elseif ($globalDebug) echo "Done\n";
2192
-		if ($globalDebug) echo "Owner Croatia: Download...";
2548
+		} elseif ($globalDebug) {
2549
+			echo "Done\n";
2550
+		}
2551
+		if ($globalDebug) {
2552
+			echo "Owner Croatia: Download...";
2553
+		}
2193 2554
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2194 2555
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2195
-			if ($globalDebug) echo "Add to DB...";
2556
+			if ($globalDebug) {
2557
+				echo "Add to DB...";
2558
+			}
2196 2559
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2197
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2560
+		} else {
2561
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2562
+		}
2198 2563
 		if ($error != '') {
2199 2564
 			return $error;
2200
-		} elseif ($globalDebug) echo "Done\n";
2201
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2565
+		} elseif ($globalDebug) {
2566
+			echo "Done\n";
2567
+		}
2568
+		if ($globalDebug) {
2569
+			echo "Owner Luxembourg: Download...";
2570
+		}
2202 2571
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2203 2572
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2204
-			if ($globalDebug) echo "Add to DB...";
2573
+			if ($globalDebug) {
2574
+				echo "Add to DB...";
2575
+			}
2205 2576
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2206
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2577
+		} else {
2578
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2579
+		}
2207 2580
 		if ($error != '') {
2208 2581
 			return $error;
2209
-		} elseif ($globalDebug) echo "Done\n";
2210
-		if ($globalDebug) echo "Owner Maldives: Download...";
2582
+		} elseif ($globalDebug) {
2583
+			echo "Done\n";
2584
+		}
2585
+		if ($globalDebug) {
2586
+			echo "Owner Maldives: Download...";
2587
+		}
2211 2588
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2212 2589
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2213
-			if ($globalDebug) echo "Add to DB...";
2590
+			if ($globalDebug) {
2591
+				echo "Add to DB...";
2592
+			}
2214 2593
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2215
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2594
+		} else {
2595
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2596
+		}
2216 2597
 		if ($error != '') {
2217 2598
 			return $error;
2218
-		} elseif ($globalDebug) echo "Done\n";
2219
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2599
+		} elseif ($globalDebug) {
2600
+			echo "Done\n";
2601
+		}
2602
+		if ($globalDebug) {
2603
+			echo "Owner New Zealand: Download...";
2604
+		}
2220 2605
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2221 2606
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2222
-			if ($globalDebug) echo "Add to DB...";
2607
+			if ($globalDebug) {
2608
+				echo "Add to DB...";
2609
+			}
2223 2610
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2224
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2611
+		} else {
2612
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2613
+		}
2225 2614
 		if ($error != '') {
2226 2615
 			return $error;
2227
-		} elseif ($globalDebug) echo "Done\n";
2228
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2616
+		} elseif ($globalDebug) {
2617
+			echo "Done\n";
2618
+		}
2619
+		if ($globalDebug) {
2620
+			echo "Owner Papua New Guinea: Download...";
2621
+		}
2229 2622
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2230 2623
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2231
-			if ($globalDebug) echo "Add to DB...";
2624
+			if ($globalDebug) {
2625
+				echo "Add to DB...";
2626
+			}
2232 2627
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2233
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2628
+		} else {
2629
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2630
+		}
2234 2631
 		if ($error != '') {
2235 2632
 			return $error;
2236
-		} elseif ($globalDebug) echo "Done\n";
2237
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2633
+		} elseif ($globalDebug) {
2634
+			echo "Done\n";
2635
+		}
2636
+		if ($globalDebug) {
2637
+			echo "Owner Slovakia: Download...";
2638
+		}
2238 2639
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2239 2640
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2240
-			if ($globalDebug) echo "Add to DB...";
2641
+			if ($globalDebug) {
2642
+				echo "Add to DB...";
2643
+			}
2241 2644
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2242
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2645
+		} else {
2646
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2647
+		}
2243 2648
 		if ($error != '') {
2244 2649
 			return $error;
2245
-		} elseif ($globalDebug) echo "Done\n";
2246
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2650
+		} elseif ($globalDebug) {
2651
+			echo "Done\n";
2652
+		}
2653
+		if ($globalDebug) {
2654
+			echo "Owner Ecuador: Download...";
2655
+		}
2247 2656
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2248 2657
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2249
-			if ($globalDebug) echo "Add to DB...";
2658
+			if ($globalDebug) {
2659
+				echo "Add to DB...";
2660
+			}
2250 2661
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2251
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2662
+		} else {
2663
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2664
+		}
2252 2665
 		if ($error != '') {
2253 2666
 			return $error;
2254
-		} elseif ($globalDebug) echo "Done\n";
2255
-		if ($globalDebug) echo "Owner Iceland: Download...";
2667
+		} elseif ($globalDebug) {
2668
+			echo "Done\n";
2669
+		}
2670
+		if ($globalDebug) {
2671
+			echo "Owner Iceland: Download...";
2672
+		}
2256 2673
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2257 2674
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2258
-			if ($globalDebug) echo "Add to DB...";
2675
+			if ($globalDebug) {
2676
+				echo "Add to DB...";
2677
+			}
2259 2678
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2260
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2679
+		} else {
2680
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2681
+		}
2261 2682
 		if ($error != '') {
2262 2683
 			return $error;
2263
-		} elseif ($globalDebug) echo "Done\n";
2264
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2684
+		} elseif ($globalDebug) {
2685
+			echo "Done\n";
2686
+		}
2687
+		if ($globalDebug) {
2688
+			echo "Owner Isle of Man: Download...";
2689
+		}
2265 2690
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2266 2691
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2267
-			if ($globalDebug) echo "Add to DB...";
2692
+			if ($globalDebug) {
2693
+				echo "Add to DB...";
2694
+			}
2268 2695
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2269
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2696
+		} else {
2697
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2698
+		}
2270 2699
 		if ($error != '') {
2271 2700
 			return $error;
2272
-		} elseif ($globalDebug) echo "Done\n";
2701
+		} elseif ($globalDebug) {
2702
+			echo "Done\n";
2703
+		}
2273 2704
 		if ($globalMasterSource) {
2274
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2705
+			if ($globalDebug) {
2706
+				echo "ModeS Netherlands: Download...";
2707
+			}
2275 2708
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2276 2709
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2277
-				if ($globalDebug) echo "Add to DB...";
2710
+				if ($globalDebug) {
2711
+					echo "Add to DB...";
2712
+				}
2278 2713
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2279
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2714
+			} else {
2715
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2716
+			}
2280 2717
 			if ($error != '') {
2281 2718
 				return $error;
2282
-			} elseif ($globalDebug) echo "Done\n";
2283
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2719
+			} elseif ($globalDebug) {
2720
+				echo "Done\n";
2721
+			}
2722
+			if ($globalDebug) {
2723
+				echo "ModeS Denmark: Download...";
2724
+			}
2284 2725
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2285 2726
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2286
-				if ($globalDebug) echo "Add to DB...";
2727
+				if ($globalDebug) {
2728
+					echo "Add to DB...";
2729
+				}
2287 2730
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2288
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2731
+			} else {
2732
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2733
+			}
2289 2734
 			if ($error != '') {
2290 2735
 				return $error;
2291
-			} elseif ($globalDebug) echo "Done\n";
2292
-		} elseif ($globalDebug) echo "Done\n";
2736
+			} elseif ($globalDebug) {
2737
+				echo "Done\n";
2738
+			}
2739
+		} elseif ($globalDebug) {
2740
+			echo "Done\n";
2741
+		}
2293 2742
 		return '';
2294 2743
 	}
2295 2744
 
2296 2745
 	public static function update_translation() {
2297 2746
 		global $tmp_dir, $globalDebug;
2298 2747
 		$error = '';
2299
-		if ($globalDebug) echo "Translation : Download...";
2748
+		if ($globalDebug) {
2749
+			echo "Translation : Download...";
2750
+		}
2300 2751
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2301 2752
 		if (file_exists($tmp_dir.'translation.zip')) {
2302
-			if ($globalDebug) echo "Unzip...";
2753
+			if ($globalDebug) {
2754
+				echo "Unzip...";
2755
+			}
2303 2756
 			update_db::unzip($tmp_dir.'translation.zip');
2304
-			if ($globalDebug) echo "Add to DB...";
2757
+			if ($globalDebug) {
2758
+				echo "Add to DB...";
2759
+			}
2305 2760
 			$error = update_db::translation();
2306
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2761
+		} else {
2762
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2763
+		}
2307 2764
 		if ($error != '') {
2308 2765
 			return $error;
2309
-		} elseif ($globalDebug) echo "Done\n";
2766
+		} elseif ($globalDebug) {
2767
+			echo "Done\n";
2768
+		}
2310 2769
 		return '';
2311 2770
 	}
2312 2771
 
2313 2772
 	public static function update_translation_fam() {
2314 2773
 		global $tmp_dir, $globalDebug;
2315
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2774
+		if ($globalDebug) {
2775
+			echo "Translation from FlightAirMap website : Download...";
2776
+		}
2316 2777
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2317 2778
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2318 2779
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2319 2780
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2320 2781
 			$translation_md5 = $translation_md5_file[0];
2321 2782
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2322
-				if ($globalDebug) echo "Gunzip...";
2783
+				if ($globalDebug) {
2784
+					echo "Gunzip...";
2785
+				}
2323 2786
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2324
-				if ($globalDebug) echo "Add to DB...";
2787
+				if ($globalDebug) {
2788
+					echo "Add to DB...";
2789
+				}
2325 2790
 				$error = update_db::translation_fam();
2326
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2327
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2791
+			} else {
2792
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2793
+			}
2794
+		} else {
2795
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2796
+		}
2328 2797
 		if ($error != '') {
2329 2798
 			return $error;
2330
-		} elseif ($globalDebug) echo "Done\n";
2799
+		} elseif ($globalDebug) {
2800
+			echo "Done\n";
2801
+		}
2331 2802
 		return '';
2332 2803
 	}
2333 2804
 	public static function update_ModeS_fam() {
2334 2805
 		global $tmp_dir, $globalDebug;
2335
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2806
+		if ($globalDebug) {
2807
+			echo "ModeS from FlightAirMap website : Download...";
2808
+		}
2336 2809
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2337 2810
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2338 2811
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2339 2812
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2340 2813
 			$modes_md5 = $modes_md5_file[0];
2341 2814
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2342
-				if ($globalDebug) echo "Gunzip...";
2815
+				if ($globalDebug) {
2816
+					echo "Gunzip...";
2817
+				}
2343 2818
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2344
-				if ($globalDebug) echo "Add to DB...";
2819
+				if ($globalDebug) {
2820
+					echo "Add to DB...";
2821
+				}
2345 2822
 				$error = update_db::modes_fam();
2346
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2347
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2823
+			} else {
2824
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2825
+			}
2826
+		} else {
2827
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2828
+		}
2348 2829
 		if ($error != '') {
2349 2830
 			return $error;
2350
-		} elseif ($globalDebug) echo "Done\n";
2831
+		} elseif ($globalDebug) {
2832
+			echo "Done\n";
2833
+		}
2351 2834
 		return '';
2352 2835
 	}
2353 2836
 	public static function update_owner_fam() {
2354 2837
 		global $tmp_dir, $globalDebug, $globalOwner;
2355
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2838
+		if ($globalDebug) {
2839
+			echo "owner from FlightAirMap website : Download...";
2840
+		}
2356 2841
 		if ($globalOwner === TRUE) {
2357 2842
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2358 2843
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
@@ -2364,35 +2849,57 @@  discard block
 block discarded – undo
2364 2849
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2365 2850
 			$owners_md5 = $owners_md5_file[0];
2366 2851
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2367
-				if ($globalDebug) echo "Gunzip...";
2852
+				if ($globalDebug) {
2853
+					echo "Gunzip...";
2854
+				}
2368 2855
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2369
-				if ($globalDebug) echo "Add to DB...";
2856
+				if ($globalDebug) {
2857
+					echo "Add to DB...";
2858
+				}
2370 2859
 				$error = update_db::owner_fam();
2371
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2372
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2860
+			} else {
2861
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2862
+			}
2863
+		} else {
2864
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2865
+		}
2373 2866
 		if ($error != '') {
2374 2867
 			return $error;
2375
-		} elseif ($globalDebug) echo "Done\n";
2868
+		} elseif ($globalDebug) {
2869
+			echo "Done\n";
2870
+		}
2376 2871
 		return '';
2377 2872
 	}
2378 2873
 	public static function update_routes_fam() {
2379 2874
 		global $tmp_dir, $globalDebug;
2380
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2875
+		if ($globalDebug) {
2876
+			echo "Routes from FlightAirMap website : Download...";
2877
+		}
2381 2878
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2382 2879
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2383 2880
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2384 2881
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2385 2882
 			$routes_md5 = $routes_md5_file[0];
2386 2883
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2387
-				if ($globalDebug) echo "Gunzip...";
2884
+				if ($globalDebug) {
2885
+					echo "Gunzip...";
2886
+				}
2388 2887
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2389
-				if ($globalDebug) echo "Add to DB...";
2888
+				if ($globalDebug) {
2889
+					echo "Add to DB...";
2890
+				}
2390 2891
 				$error = update_db::routes_fam();
2391
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2392
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2892
+			} else {
2893
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2894
+			}
2895
+		} else {
2896
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2897
+		}
2393 2898
 		if ($error != '') {
2394 2899
 			return $error;
2395
-		} elseif ($globalDebug) echo "Done\n";
2900
+		} elseif ($globalDebug) {
2901
+			echo "Done\n";
2902
+		}
2396 2903
 		return '';
2397 2904
 	}
2398 2905
 	public static function update_marine_identity_fam() {
@@ -2402,16 +2909,26 @@  discard block
 block discarded – undo
2402 2909
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2403 2910
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2404 2911
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2405
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2912
+				if ($globalDebug) {
2913
+					echo "Marine identity from FlightAirMap website : Download...";
2914
+				}
2406 2915
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2407 2916
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2408 2917
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2409
-						if ($globalDebug) echo "Gunzip...";
2918
+						if ($globalDebug) {
2919
+							echo "Gunzip...";
2920
+						}
2410 2921
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2411
-						if ($globalDebug) echo "Add to DB...";
2922
+						if ($globalDebug) {
2923
+							echo "Add to DB...";
2924
+						}
2412 2925
 						$error = update_db::marine_identity_fam();
2413
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2414
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2926
+					} else {
2927
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2928
+					}
2929
+				} else {
2930
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2931
+				}
2415 2932
 				if ($error != '') {
2416 2933
 					return $error;
2417 2934
 				} elseif ($globalDebug) {
@@ -2430,16 +2947,26 @@  discard block
 block discarded – undo
2430 2947
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2431 2948
 			$satellite_md5 = $satellite_md5_file[0];
2432 2949
 			if (!update_db::check_satellite_version($satellite_md5)) {
2433
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2950
+				if ($globalDebug) {
2951
+					echo "Satellite from FlightAirMap website : Download...";
2952
+				}
2434 2953
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2435 2954
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2436 2955
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2437
-						if ($globalDebug) echo "Gunzip...";
2956
+						if ($globalDebug) {
2957
+							echo "Gunzip...";
2958
+						}
2438 2959
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2439
-						if ($globalDebug) echo "Add to DB...";
2960
+						if ($globalDebug) {
2961
+							echo "Add to DB...";
2962
+						}
2440 2963
 						$error = update_db::satellite_fam();
2441
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2442
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2964
+					} else {
2965
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2966
+					}
2967
+				} else {
2968
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
2969
+				}
2443 2970
 				if ($error != '') {
2444 2971
 					return $error;
2445 2972
 				} elseif ($globalDebug) {
@@ -2452,17 +2979,25 @@  discard block
 block discarded – undo
2452 2979
 	}
2453 2980
 	public static function update_banned_fam() {
2454 2981
 		global $tmp_dir, $globalDebug;
2455
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2982
+		if ($globalDebug) {
2983
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2984
+		}
2456 2985
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2457 2986
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2458 2987
 			//if ($globalDebug) echo "Gunzip...";
2459 2988
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2460
-			if ($globalDebug) echo "Add to DB...";
2989
+			if ($globalDebug) {
2990
+				echo "Add to DB...";
2991
+			}
2461 2992
 			$error = update_db::banned_fam();
2462
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2993
+		} else {
2994
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2995
+		}
2463 2996
 		if ($error != '') {
2464 2997
 			return $error;
2465
-		} elseif ($globalDebug) echo "Done\n";
2998
+		} elseif ($globalDebug) {
2999
+			echo "Done\n";
3000
+		}
2466 3001
 		return '';
2467 3002
 	}
2468 3003
 
@@ -2470,7 +3005,9 @@  discard block
 block discarded – undo
2470 3005
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2471 3006
 		include_once('class.create_db.php');
2472 3007
 		$error = '';
2473
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3008
+		if ($globalDebug) {
3009
+			echo "Airspace from FlightAirMap website : Download...";
3010
+		}
2474 3011
 		if ($globalDBdriver == 'mysql') {
2475 3012
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2476 3013
 		} else {
@@ -2487,9 +3024,13 @@  discard block
 block discarded – undo
2487 3024
 				}
2488 3025
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2489 3026
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2490
-						if ($globalDebug) echo "Gunzip...";
3027
+						if ($globalDebug) {
3028
+							echo "Gunzip...";
3029
+						}
2491 3030
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2492
-						if ($globalDebug) echo "Add to DB...";
3031
+						if ($globalDebug) {
3032
+							echo "Add to DB...";
3033
+						}
2493 3034
 						$Connection = new Connection();
2494 3035
 						if ($Connection->tableExists('airspace')) {
2495 3036
 							$query = 'DROP TABLE airspace';
@@ -2502,20 +3043,30 @@  discard block
 block discarded – undo
2502 3043
 						}
2503 3044
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2504 3045
 						update_db::insert_airspace_version($airspace_md5);
2505
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2506
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3046
+					} else {
3047
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3048
+					}
3049
+				} else {
3050
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3051
+				}
2507 3052
 			}
2508
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3053
+		} else {
3054
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3055
+		}
2509 3056
 		if ($error != '') {
2510 3057
 			return $error;
2511
-		} elseif ($globalDebug) echo "Done\n";
3058
+		} elseif ($globalDebug) {
3059
+			echo "Done\n";
3060
+		}
2512 3061
 		return '';
2513 3062
 	}
2514 3063
 
2515 3064
 	public static function update_geoid_fam() {
2516 3065
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2517 3066
 		$error = '';
2518
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3067
+		if ($globalDebug) {
3068
+			echo "Geoid from FlightAirMap website : Download...";
3069
+		}
2519 3070
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2520 3071
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2521 3072
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2524,76 +3075,116 @@  discard block
 block discarded – undo
2524 3075
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2525 3076
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2526 3077
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2527
-						if ($globalDebug) echo "Gunzip...";
3078
+						if ($globalDebug) {
3079
+							echo "Gunzip...";
3080
+						}
2528 3081
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2529 3082
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2530 3083
 							update_db::insert_geoid_version($geoid_md5);
2531 3084
 						}
2532
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2533
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3085
+					} else {
3086
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3087
+					}
3088
+				} else {
3089
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3090
+				}
2534 3091
 			}
2535
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3092
+		} else {
3093
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3094
+		}
2536 3095
 		if ($error != '') {
2537 3096
 			return $error;
2538
-		} elseif ($globalDebug) echo "Done\n";
3097
+		} elseif ($globalDebug) {
3098
+			echo "Done\n";
3099
+		}
2539 3100
 		return '';
2540 3101
 	}
2541 3102
 
2542 3103
 	public static function update_tle() {
2543 3104
 		global $tmp_dir, $globalDebug;
2544
-		if ($globalDebug) echo "Download TLE : Download...";
3105
+		if ($globalDebug) {
3106
+			echo "Download TLE : Download...";
3107
+		}
2545 3108
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2546 3109
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2547 3110
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2548 3111
 		foreach ($alltle as $filename) {
2549
-			if ($globalDebug) echo "downloading ".$filename.'...';
3112
+			if ($globalDebug) {
3113
+				echo "downloading ".$filename.'...';
3114
+			}
2550 3115
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2551 3116
 			if (file_exists($tmp_dir.$filename)) {
2552
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3117
+				if ($globalDebug) {
3118
+					echo "Add to DB ".$filename."...";
3119
+				}
2553 3120
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2554
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3121
+			} else {
3122
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3123
+			}
2555 3124
 			if ($error != '') {
2556 3125
 				echo $error."\n";
2557
-			} elseif ($globalDebug) echo "Done\n";
3126
+			} elseif ($globalDebug) {
3127
+				echo "Done\n";
3128
+			}
2558 3129
 		}
2559 3130
 		return '';
2560 3131
 	}
2561 3132
 
2562 3133
 	public static function update_ucsdb() {
2563 3134
 		global $tmp_dir, $globalDebug;
2564
-		if ($globalDebug) echo "Download UCS DB : Download...";
3135
+		if ($globalDebug) {
3136
+			echo "Download UCS DB : Download...";
3137
+		}
2565 3138
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2566 3139
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2567
-			if ($globalDebug) echo "Add to DB...";
3140
+			if ($globalDebug) {
3141
+				echo "Add to DB...";
3142
+			}
2568 3143
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2569
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3144
+		} else {
3145
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3146
+		}
2570 3147
 		if ($error != '') {
2571 3148
 			echo $error."\n";
2572
-		} elseif ($globalDebug) echo "Done\n";
3149
+		} elseif ($globalDebug) {
3150
+			echo "Done\n";
3151
+		}
2573 3152
 		return '';
2574 3153
 	}
2575 3154
 
2576 3155
 	public static function update_celestrak() {
2577 3156
 		global $tmp_dir, $globalDebug;
2578
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3157
+		if ($globalDebug) {
3158
+			echo "Download Celestrak DB : Download...";
3159
+		}
2579 3160
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2580 3161
 		if (file_exists($tmp_dir.'satcat.txt')) {
2581
-			if ($globalDebug) echo "Add to DB...";
3162
+			if ($globalDebug) {
3163
+				echo "Add to DB...";
3164
+			}
2582 3165
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2583
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3166
+		} else {
3167
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3168
+		}
2584 3169
 		if ($error != '') {
2585 3170
 			echo $error."\n";
2586
-		} elseif ($globalDebug) echo "Done\n";
3171
+		} elseif ($globalDebug) {
3172
+			echo "Done\n";
3173
+		}
2587 3174
 		return '';
2588 3175
 	}
2589 3176
 
2590 3177
 	public static function update_models() {
2591 3178
 		global $tmp_dir, $globalDebug;
2592 3179
 		$error = '';
2593
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3180
+		if ($globalDebug) {
3181
+			echo "Models from FlightAirMap website : Download...";
3182
+		}
2594 3183
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2595 3184
 		if (file_exists($tmp_dir.'models.md5sum')) {
2596
-			if ($globalDebug) echo "Check files...\n";
3185
+			if ($globalDebug) {
3186
+				echo "Check files...\n";
3187
+			}
2597 3188
 			$newmodelsdb = array();
2598 3189
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2599 3190
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2612,25 +3203,35 @@  discard block
 block discarded – undo
2612 3203
 			}
2613 3204
 			$diff = array_diff($newmodelsdb,$modelsdb);
2614 3205
 			foreach ($diff as $key => $value) {
2615
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3206
+				if ($globalDebug) {
3207
+					echo 'Downloading model '.$key.' ...'."\n";
3208
+				}
2616 3209
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2617 3210
 				
2618 3211
 			}
2619 3212
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2620
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3213
+		} else {
3214
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3215
+		}
2621 3216
 		if ($error != '') {
2622 3217
 			return $error;
2623
-		} elseif ($globalDebug) echo "Done\n";
3218
+		} elseif ($globalDebug) {
3219
+			echo "Done\n";
3220
+		}
2624 3221
 		return '';
2625 3222
 	}
2626 3223
 
2627 3224
 	public static function update_space_models() {
2628 3225
 		global $tmp_dir, $globalDebug;
2629 3226
 		$error = '';
2630
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3227
+		if ($globalDebug) {
3228
+			echo "Space models from FlightAirMap website : Download...";
3229
+		}
2631 3230
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2632 3231
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2633
-			if ($globalDebug) echo "Check files...\n";
3232
+			if ($globalDebug) {
3233
+				echo "Check files...\n";
3234
+			}
2634 3235
 			$newmodelsdb = array();
2635 3236
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2636 3237
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2649,25 +3250,35 @@  discard block
 block discarded – undo
2649 3250
 			}
2650 3251
 			$diff = array_diff($newmodelsdb,$modelsdb);
2651 3252
 			foreach ($diff as $key => $value) {
2652
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3253
+				if ($globalDebug) {
3254
+					echo 'Downloading space model '.$key.' ...'."\n";
3255
+				}
2653 3256
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2654 3257
 				
2655 3258
 			}
2656 3259
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2657
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3260
+		} else {
3261
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3262
+		}
2658 3263
 		if ($error != '') {
2659 3264
 			return $error;
2660
-		} elseif ($globalDebug) echo "Done\n";
3265
+		} elseif ($globalDebug) {
3266
+			echo "Done\n";
3267
+		}
2661 3268
 		return '';
2662 3269
 	}
2663 3270
 
2664 3271
 	public static function update_vehicules_models() {
2665 3272
 		global $tmp_dir, $globalDebug;
2666 3273
 		$error = '';
2667
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3274
+		if ($globalDebug) {
3275
+			echo "Vehicules models from FlightAirMap website : Download...";
3276
+		}
2668 3277
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2669 3278
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2670
-			if ($globalDebug) echo "Check files...\n";
3279
+			if ($globalDebug) {
3280
+				echo "Check files...\n";
3281
+			}
2671 3282
 			$newmodelsdb = array();
2672 3283
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2673 3284
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2686,15 +3297,21 @@  discard block
 block discarded – undo
2686 3297
 			}
2687 3298
 			$diff = array_diff($newmodelsdb,$modelsdb);
2688 3299
 			foreach ($diff as $key => $value) {
2689
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3300
+				if ($globalDebug) {
3301
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3302
+				}
2690 3303
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2691 3304
 				
2692 3305
 			}
2693 3306
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2694
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3307
+		} else {
3308
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3309
+		}
2695 3310
 		if ($error != '') {
2696 3311
 			return $error;
2697
-		} elseif ($globalDebug) echo "Done\n";
3312
+		} elseif ($globalDebug) {
3313
+			echo "Done\n";
3314
+		}
2698 3315
 		return '';
2699 3316
 	}
2700 3317
 
@@ -2737,7 +3354,9 @@  discard block
 block discarded – undo
2737 3354
                 }
2738 3355
 
2739 3356
 		$error = '';
2740
-		if ($globalDebug) echo "Notam : Download...";
3357
+		if ($globalDebug) {
3358
+			echo "Notam : Download...";
3359
+		}
2741 3360
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2742 3361
 		if (file_exists($tmp_dir.'notam.rss')) {
2743 3362
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2752,14 +3371,30 @@  discard block
 block discarded – undo
2752 3371
 				$data['fir'] = $q[0];
2753 3372
 				$data['code'] = $q[1];
2754 3373
 				$ifrvfr = $q[2];
2755
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2756
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2757
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2758
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2759
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2760
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2761
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2762
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3374
+				if ($ifrvfr == 'IV') {
3375
+					$data['rules'] = 'IFR/VFR';
3376
+				}
3377
+				if ($ifrvfr == 'I') {
3378
+					$data['rules'] = 'IFR';
3379
+				}
3380
+				if ($ifrvfr == 'V') {
3381
+					$data['rules'] = 'VFR';
3382
+				}
3383
+				if ($q[4] == 'A') {
3384
+					$data['scope'] = 'Airport warning';
3385
+				}
3386
+				if ($q[4] == 'E') {
3387
+					$data['scope'] = 'Enroute warning';
3388
+				}
3389
+				if ($q[4] == 'W') {
3390
+					$data['scope'] = 'Navigation warning';
3391
+				}
3392
+				if ($q[4] == 'AE') {
3393
+					$data['scope'] = 'Airport/Enroute warning';
3394
+				}
3395
+				if ($q[4] == 'AW') {
3396
+					$data['scope'] = 'Airport/Navigation warning';
3397
+				}
2763 3398
 				//$data['scope'] = $q[4];
2764 3399
 				$data['lower_limit'] = $q[5];
2765 3400
 				$data['upper_limit'] = $q[6];
@@ -2767,8 +3402,12 @@  discard block
 block discarded – undo
2767 3402
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2768 3403
 				$latitude = $Common->convertDec($las,'latitude');
2769 3404
 				$longitude = $Common->convertDec($lns,'longitude');
2770
-				if ($lac == 'S') $latitude = '-'.$latitude;
2771
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3405
+				if ($lac == 'S') {
3406
+					$latitude = '-'.$latitude;
3407
+				}
3408
+				if ($lnc == 'W') {
3409
+					$longitude = '-'.$longitude;
3410
+				}
2772 3411
 				$data['center_latitude'] = $latitude;
2773 3412
 				$data['center_longitude'] = $longitude;
2774 3413
 				$data['radius'] = intval($radius);
@@ -2798,10 +3437,14 @@  discard block
 block discarded – undo
2798 3437
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2799 3438
 				unset($data);
2800 3439
 			} 
2801
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3440
+		} else {
3441
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3442
+		}
2802 3443
 		if ($error != '') {
2803 3444
 			return $error;
2804
-		} elseif ($globalDebug) echo "Done\n";
3445
+		} elseif ($globalDebug) {
3446
+			echo "Done\n";
3447
+		}
2805 3448
 		return '';
2806 3449
 	}
2807 3450
 	
@@ -2826,7 +3469,9 @@  discard block
 block discarded – undo
2826 3469
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2827 3470
 		$airspace_json = json_decode($airspace_lst,true);
2828 3471
 		foreach ($airspace_json['records'] as $airspace) {
2829
-			if ($globalDebug) echo $airspace['name']."...\n";
3472
+			if ($globalDebug) {
3473
+				echo $airspace['name']."...\n";
3474
+			}
2830 3475
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2831 3476
 			if (file_exists($tmp_dir.$airspace['name'])) {
2832 3477
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2870,8 +3515,11 @@  discard block
 block discarded – undo
2870 3515
                         return "error : ".$e->getMessage();
2871 3516
                 }
2872 3517
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2873
-                if ($row['nb'] > 0) return false;
2874
-                else return true;
3518
+                if ($row['nb'] > 0) {
3519
+                	return false;
3520
+                } else {
3521
+                	return true;
3522
+                }
2875 3523
 	}
2876 3524
 
2877 3525
 	public static function insert_last_update() {
@@ -2896,8 +3544,11 @@  discard block
 block discarded – undo
2896 3544
                         return "error : ".$e->getMessage();
2897 3545
                 }
2898 3546
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2899
-                if ($row['nb'] > 0) return true;
2900
-                else return false;
3547
+                if ($row['nb'] > 0) {
3548
+                	return true;
3549
+                } else {
3550
+                	return false;
3551
+                }
2901 3552
 	}
2902 3553
 
2903 3554
 	public static function check_geoid_version($version) {
@@ -2910,8 +3561,11 @@  discard block
 block discarded – undo
2910 3561
                         return "error : ".$e->getMessage();
2911 3562
                 }
2912 3563
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2913
-                if ($row['nb'] > 0) return true;
2914
-                else return false;
3564
+                if ($row['nb'] > 0) {
3565
+                	return true;
3566
+                } else {
3567
+                	return false;
3568
+                }
2915 3569
 	}
2916 3570
 
2917 3571
 	public static function check_marine_identity_version($version) {
@@ -2924,8 +3578,11 @@  discard block
 block discarded – undo
2924 3578
 			return "error : ".$e->getMessage();
2925 3579
 		}
2926 3580
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2927
-		if ($row['nb'] > 0) return true;
2928
-		else return false;
3581
+		if ($row['nb'] > 0) {
3582
+			return true;
3583
+		} else {
3584
+			return false;
3585
+		}
2929 3586
 	}
2930 3587
 
2931 3588
 	public static function check_satellite_version($version) {
@@ -2938,8 +3595,11 @@  discard block
 block discarded – undo
2938 3595
 			return "error : ".$e->getMessage();
2939 3596
 		}
2940 3597
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2941
-		if ($row['nb'] > 0) return true;
2942
-		else return false;
3598
+		if ($row['nb'] > 0) {
3599
+			return true;
3600
+		} else {
3601
+			return false;
3602
+		}
2943 3603
 	}
2944 3604
 
2945 3605
 
@@ -3006,8 +3666,11 @@  discard block
 block discarded – undo
3006 3666
                         return "error : ".$e->getMessage();
3007 3667
                 }
3008 3668
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3009
-                if ($row['nb'] > 0) return false;
3010
-                else return true;
3669
+                if ($row['nb'] > 0) {
3670
+                	return false;
3671
+                } else {
3672
+                	return true;
3673
+                }
3011 3674
 	}
3012 3675
 
3013 3676
 	public static function insert_last_notam_update() {
@@ -3037,8 +3700,11 @@  discard block
 block discarded – undo
3037 3700
                         return "error : ".$e->getMessage();
3038 3701
                 }
3039 3702
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3040
-                if ($row['nb'] > 0) return false;
3041
-                else return true;
3703
+                if ($row['nb'] > 0) {
3704
+                	return false;
3705
+                } else {
3706
+                	return true;
3707
+                }
3042 3708
 	}
3043 3709
 
3044 3710
 	public static function insert_last_airspace_update() {
@@ -3068,8 +3734,11 @@  discard block
 block discarded – undo
3068 3734
                         return "error : ".$e->getMessage();
3069 3735
                 }
3070 3736
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3071
-                if ($row['nb'] > 0) return false;
3072
-                else return true;
3737
+                if ($row['nb'] > 0) {
3738
+                	return false;
3739
+                } else {
3740
+                	return true;
3741
+                }
3073 3742
 	}
3074 3743
 
3075 3744
 	public static function insert_last_geoid_update() {
@@ -3099,8 +3768,11 @@  discard block
 block discarded – undo
3099 3768
                         return "error : ".$e->getMessage();
3100 3769
                 }
3101 3770
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3102
-                if ($row['nb'] > 0) return false;
3103
-                else return true;
3771
+                if ($row['nb'] > 0) {
3772
+                	return false;
3773
+                } else {
3774
+                	return true;
3775
+                }
3104 3776
 	}
3105 3777
 
3106 3778
 	public static function insert_last_owner_update() {
@@ -3129,8 +3801,11 @@  discard block
 block discarded – undo
3129 3801
                         return "error : ".$e->getMessage();
3130 3802
                 }
3131 3803
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3132
-                if ($row['nb'] > 0) return false;
3133
-                else return true;
3804
+                if ($row['nb'] > 0) {
3805
+                	return false;
3806
+                } else {
3807
+                	return true;
3808
+                }
3134 3809
 	}
3135 3810
 
3136 3811
 	public static function insert_last_schedules_update() {
@@ -3160,8 +3835,11 @@  discard block
 block discarded – undo
3160 3835
 			return "error : ".$e->getMessage();
3161 3836
 		}
3162 3837
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3163
-		if ($row['nb'] > 0) return false;
3164
-		else return true;
3838
+		if ($row['nb'] > 0) {
3839
+			return false;
3840
+		} else {
3841
+			return true;
3842
+		}
3165 3843
 	}
3166 3844
 
3167 3845
 	public static function insert_last_tle_update() {
@@ -3191,8 +3869,11 @@  discard block
 block discarded – undo
3191 3869
 			return "error : ".$e->getMessage();
3192 3870
 		}
3193 3871
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3194
-		if ($row['nb'] > 0) return false;
3195
-		else return true;
3872
+		if ($row['nb'] > 0) {
3873
+			return false;
3874
+		} else {
3875
+			return true;
3876
+		}
3196 3877
 	}
3197 3878
 
3198 3879
 	public static function insert_last_ucsdb_update() {
@@ -3222,8 +3903,11 @@  discard block
 block discarded – undo
3222 3903
 			return "error : ".$e->getMessage();
3223 3904
 		}
3224 3905
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3225
-		if ($row['nb'] > 0) return false;
3226
-		else return true;
3906
+		if ($row['nb'] > 0) {
3907
+			return false;
3908
+		} else {
3909
+			return true;
3910
+		}
3227 3911
 	}
3228 3912
 
3229 3913
 	public static function insert_last_celestrak_update() {
@@ -3253,8 +3937,11 @@  discard block
 block discarded – undo
3253 3937
 			return "error : ".$e->getMessage();
3254 3938
 		}
3255 3939
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3256
-		if ($row['nb'] > 0) return false;
3257
-		else return true;
3940
+		if ($row['nb'] > 0) {
3941
+			return false;
3942
+		} else {
3943
+			return true;
3944
+		}
3258 3945
 	}
3259 3946
 
3260 3947
 	public static function check_last_satellite_update() {
@@ -3272,8 +3959,11 @@  discard block
 block discarded – undo
3272 3959
 			return "error : ".$e->getMessage();
3273 3960
 		}
3274 3961
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3275
-		if ($row['nb'] > 0) return false;
3276
-		else return true;
3962
+		if ($row['nb'] > 0) {
3963
+			return false;
3964
+		} else {
3965
+			return true;
3966
+		}
3277 3967
 	}
3278 3968
 
3279 3969
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +122 added lines, -41 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection.');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection.');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -119,8 +123,11 @@  discard block
 block discarded – undo
119 123
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
120 124
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
121 125
 		}
122
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
123
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
126
+		if ($filter_query_where == '' && $where) {
127
+			$filter_query_where = ' WHERE';
128
+		} elseif ($filter_query_where != '' && $and) {
129
+			$filter_query_where .= ' AND';
130
+		}
124 131
 		if ($filter_query_where != '') {
125 132
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
126 133
 		}
@@ -161,9 +168,13 @@  discard block
 block discarded – undo
161 168
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
162 169
 			}
163 170
 		}
164
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
171
+		if ($orderby_query == '') {
172
+			$orderby_query = ' ORDER BY date DESC';
173
+		}
165 174
 
166
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
175
+		if (!isset($globalLiveInterval)) {
176
+			$globalLiveInterval = '200';
177
+		}
167 178
 		if ($globalDBdriver == 'mysql') {
168 179
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
169 180
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -186,7 +197,9 @@  discard block
 block discarded – undo
186 197
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
187 198
 		date_default_timezone_set('UTC');
188 199
 		$filter_query = $this->getFilter($filter,true,true);
189
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
200
+		if (!isset($globalLiveInterval)) {
201
+			$globalLiveInterval = '200';
202
+		}
190 203
 		if ($globalDBdriver == 'mysql') {
191 204
 			if (isset($globalArchive) && $globalArchive === TRUE) {
192 205
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -234,8 +247,12 @@  discard block
 block discarded – undo
234 247
 		}
235 248
 		$filter_query = $this->getFilter($filter,true,true);
236 249
 
237
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
238
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAicraftsLimit == '') $globalMap3DAircraftsLimit = '300';
250
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
251
+			$globalLiveInterval = '200';
252
+		}
253
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAicraftsLimit == '') {
254
+			$globalMap3DAircraftsLimit = '300';
255
+		}
239 256
 		if ($globalDBdriver == 'mysql') {
240 257
 			if (isset($globalArchive) && $globalArchive === TRUE) {
241 258
 				/*
@@ -246,22 +263,32 @@  discard block
 block discarded – undo
246 263
 				*/
247 264
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
248 265
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
249
-				if (isset($maxlat)) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
266
+				if (isset($maxlat)) {
267
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
268
+				}
250 269
 				$query .= "UNION
251 270
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
252 271
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
253
-				if (isset($maxlat)) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
272
+				if (isset($maxlat)) {
273
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
274
+				}
254 275
 				$query .= ") AS spotter 
255 276
 				WHERE latitude <> '0' AND longitude <> '0' 
256 277
 				ORDER BY flightaware_id, date";
257
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
278
+				if ($limit) {
279
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
280
+				}
258 281
 			} else {
259 282
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
260 283
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
261
-				if (isset($maxlat)) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
284
+				if (isset($maxlat)) {
285
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
286
+				}
262 287
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
263 288
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
264
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
289
+				if ($limit) {
290
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
291
+				}
265 292
 			}
266 293
 		} else {
267 294
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -273,21 +300,31 @@  discard block
 block discarded – undo
273 300
                                */
274 301
 				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
275 302
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
276
-				if (isset($maxlat)) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
303
+				if (isset($maxlat)) {
304
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
305
+				}
277 306
 				$query .= "UNION
278 307
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
279 308
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
280
-				if (isset($maxlat)) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
309
+				if (isset($maxlat)) {
310
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
311
+				}
281 312
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
282 313
 				$query .= "ORDER BY flightaware_id, date";
283
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
314
+				if ($limit) {
315
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
316
+				}
284 317
 			} else {
285 318
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
286 319
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
287
-				if (isset($maxlat)) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
320
+				if (isset($maxlat)) {
321
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
322
+				}
288 323
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
289 324
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
290
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
325
+				if ($limit) {
326
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
327
+				}
291 328
 			}
292 329
 		}
293 330
 		try {
@@ -312,7 +349,9 @@  discard block
 block discarded – undo
312 349
 		global $globalDBdriver, $globalLiveInterval;
313 350
 		$filter_query = $this->getFilter($filter,true,true);
314 351
 
315
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
352
+		if (!isset($globalLiveInterval)) {
353
+			$globalLiveInterval = '200';
354
+		}
316 355
 		if ($globalDBdriver == 'mysql') {
317 356
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
318 357
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -342,7 +381,9 @@  discard block
 block discarded – undo
342 381
 	{
343 382
 		global $globalDBdriver, $globalLiveInterval;
344 383
 		$Spotter = new Spotter($this->db);
345
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+		if (!isset($globalLiveInterval)) {
385
+			$globalLiveInterval = '200';
386
+		}
346 387
 		$filter_query = $this->getFilter($filter);
347 388
 
348 389
 		if (is_array($coord)) {
@@ -350,7 +391,9 @@  discard block
 block discarded – undo
350 391
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
351 392
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
352 393
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
353
-		} else return array();
394
+		} else {
395
+			return array();
396
+		}
354 397
 		if ($globalDBdriver == 'mysql') {
355 398
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
356 399
 		} else {
@@ -371,7 +414,9 @@  discard block
 block discarded – undo
371 414
 	{
372 415
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
373 416
 		$Spotter = new Spotter($this->db);
374
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
417
+		if (!isset($globalLiveInterval)) {
418
+			$globalLiveInterval = '200';
419
+		}
375 420
 		$filter_query = $this->getFilter($filter,true,true);
376 421
 
377 422
 		if (is_array($coord)) {
@@ -379,7 +424,9 @@  discard block
 block discarded – undo
379 424
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
380 425
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
381 426
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
382
-		} else return array();
427
+		} else {
428
+			return array();
429
+		}
383 430
 		if ($globalDBdriver == 'mysql') {
384 431
 			if (isset($globalArchive) && $globalArchive === TRUE) {
385 432
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -606,11 +653,15 @@  discard block
 block discarded – undo
606 653
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
607 654
 		if ($globalDBdriver == 'mysql') {
608 655
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
609
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
656
+			if ($liveinterval) {
657
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
658
+			}
610 659
 			$query .= ' ORDER BY date';
611 660
 		} else {
612 661
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
613
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
662
+			if ($liveinterval) {
663
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
664
+			}
614 665
 			$query .= ' ORDER BY date';
615 666
 		}
616 667
 
@@ -705,7 +756,9 @@  discard block
 block discarded – undo
705 756
 				$i++;
706 757
 				$j++;
707 758
 				if ($j == 30) {
708
-					if ($globalDebug) echo ".";
759
+					if ($globalDebug) {
760
+						echo ".";
761
+					}
709 762
 				    	try {
710 763
 						
711 764
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1012,7 +1065,9 @@  discard block
 block discarded – undo
1012 1065
 			{
1013 1066
 				return false;
1014 1067
 			}
1015
-		} else return '';
1068
+		} else {
1069
+			return '';
1070
+		}
1016 1071
 
1017 1072
 		if ($longitude != '')
1018 1073
 		{
@@ -1020,7 +1075,9 @@  discard block
 block discarded – undo
1020 1075
 			{
1021 1076
 				return false;
1022 1077
 			}
1023
-		} else return '';
1078
+		} else {
1079
+			return '';
1080
+		}
1024 1081
 
1025 1082
 		if ($waypoints != '')
1026 1083
 		{
@@ -1036,14 +1093,18 @@  discard block
 block discarded – undo
1036 1093
 			{
1037 1094
 				return false;
1038 1095
 			}
1039
-		} else $altitude = 0;
1096
+		} else {
1097
+			$altitude = 0;
1098
+		}
1040 1099
 		if ($altitude_real != '')
1041 1100
 		{
1042 1101
 			if (!is_numeric($altitude_real))
1043 1102
 			{
1044 1103
 				return false;
1045 1104
 			}
1046
-		} else $altitude_real = 0;
1105
+		} else {
1106
+			$altitude_real = 0;
1107
+		}
1047 1108
 
1048 1109
 		if ($heading != '')
1049 1110
 		{
@@ -1051,7 +1112,9 @@  discard block
 block discarded – undo
1051 1112
 			{
1052 1113
 				return false;
1053 1114
 			}
1054
-		} else $heading = 0;
1115
+		} else {
1116
+			$heading = 0;
1117
+		}
1055 1118
 
1056 1119
 		if ($groundspeed != '')
1057 1120
 		{
@@ -1059,9 +1122,13 @@  discard block
 block discarded – undo
1059 1122
 			{
1060 1123
 				return false;
1061 1124
 			}
1062
-		} else $groundspeed = 0;
1125
+		} else {
1126
+			$groundspeed = 0;
1127
+		}
1063 1128
 		date_default_timezone_set('UTC');
1064
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1129
+		if ($date == '') {
1130
+			$date = date("Y-m-d H:i:s", time());
1131
+		}
1065 1132
 
1066 1133
         
1067 1134
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1106,14 +1173,24 @@  discard block
 block discarded – undo
1106 1173
 		$arrival_airport_country = '';
1107 1174
 		
1108 1175
             	
1109
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1110
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1111
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1112
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1176
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1177
+            		$squawk = NULL;
1178
+            	}
1179
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1180
+            		$verticalrate = NULL;
1181
+            	}
1182
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1183
+            		$groundspeed = 0;
1184
+            	}
1185
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1186
+            		$heading = 0;
1187
+            	}
1113 1188
 		
1114 1189
 		$query = '';
1115 1190
 		if ($globalArchive) {
1116
-			if ($globalDebug) echo '-- Delete previous data -- ';
1191
+			if ($globalDebug) {
1192
+				echo '-- Delete previous data -- ';
1193
+			}
1117 1194
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1118 1195
 		}
1119 1196
 
@@ -1130,10 +1207,14 @@  discard block
 block discarded – undo
1130 1207
 			return "error : ".$e->getMessage();
1131 1208
 		}
1132 1209
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1133
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1210
+		    if ($globalDebug) {
1211
+		    	echo '(Add to SBS archive : ';
1212
+		    }
1134 1213
 		    $SpotterArchive = new SpotterArchive($this->db);
1135 1214
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1136
-		    if ($globalDebug) echo $result.')';
1215
+		    if ($globalDebug) {
1216
+		    	echo $result.')';
1217
+		    }
1137 1218
 		} elseif ($globalDebug && $putinarchive !== true) {
1138 1219
 			echo '(Not adding to archive)';
1139 1220
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +110 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection.');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection.');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -188,50 +199,74 @@  discard block
 block discarded – undo
188 199
 		}
189 200
 		$filter_query = $this->getFilter($filter,true,true);
190 201
 
191
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
192
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
202
+		if (!isset($globalLiveInterval)) {
203
+			$globalLiveInterval = '200';
204
+		}
205
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
206
+			$globalMap3DTrackersLimit = '300';
207
+		}
193 208
 		if ($globalDBdriver == 'mysql') {
194 209
 			if (isset($globalArchive) && $globalArchive) {
195 210
 				$query  = "SELECT * FROM (
196 211
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
197 212
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
198
-				if (isset($maxlat)) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
213
+				if (isset($maxlat)) {
214
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				}
199 216
 				$query .= "UNION
200 217
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
201 218
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
202
-				if (isset($maxlat)) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
219
+				if (isset($maxlat)) {
220
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				}
203 222
 				$query .= ") AS tracker
204 223
 				    WHERE latitude <> '0' AND longitude <> '0' 
205 224
 				    ORDER BY famtrackid, date";
206
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
225
+				if ($limit) {
226
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				}
207 228
 			} else {
208 229
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
209 230
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
210
-				if (isset($maxlat)) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
231
+				if (isset($maxlat)) {
232
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				}
211 234
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
212 235
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
213
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
236
+				if ($limit) {
237
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				}
214 239
 			}
215 240
 		} else {
216 241
 			if (isset($globalArchive) && $globalArchive) {
217 242
 				$query  = "SELECT * FROM (
218 243
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
219 244
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
220
-				if (isset($maxlat)) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
245
+				if (isset($maxlat)) {
246
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				}
221 248
 				$query .= "UNION
222 249
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
223 250
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
224
-				if (isset($maxlat)) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
251
+				if (isset($maxlat)) {
252
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				}
225 254
 				$query .= ") AS tracker
226 255
 				    WHERE latitude <> '0' AND longitude <> '0' 
227 256
 				    ORDER BY famtrackid, date";
228
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
257
+				if ($limit) {
258
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				}
229 260
 			} else {
230 261
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
231 262
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
232
-				if (isset($maxlat)) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
263
+				if (isset($maxlat)) {
264
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				}
233 266
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
234
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
267
+				if ($limit) {
268
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				}
235 270
 			}
236 271
 		}
237 272
 
@@ -257,7 +292,9 @@  discard block
 block discarded – undo
257 292
 		global $globalDBdriver, $globalLiveInterval;
258 293
 		$filter_query = $this->getFilter($filter,true,true);
259 294
 
260
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
295
+		if (!isset($globalLiveInterval)) {
296
+			$globalLiveInterval = '200';
297
+		}
261 298
 		if ($globalDBdriver == 'mysql') {
262 299
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
263 300
 		} else {
@@ -285,7 +322,9 @@  discard block
 block discarded – undo
285 322
 	{
286 323
 		global $globalDBdriver, $globalLiveInterval;
287 324
 		$Spotter = new Spotter($this->db);
288
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
325
+		if (!isset($globalLiveInterval)) {
326
+			$globalLiveInterval = '200';
327
+		}
289 328
 		$filter_query = $this->getFilter($filter);
290 329
 
291 330
 		if (is_array($coord)) {
@@ -293,7 +332,9 @@  discard block
 block discarded – undo
293 332
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
294 333
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
295 334
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296
-		} else return array();
335
+		} else {
336
+			return array();
337
+		}
297 338
 		if ($globalDBdriver == 'mysql') {
298 339
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
299 340
 		} else {
@@ -313,7 +354,9 @@  discard block
 block discarded – undo
313 354
 	{
314 355
 		global $globalDBdriver, $globalLiveInterval;
315 356
 		$Spotter = new Spotter($this->db);
316
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
357
+		if (!isset($globalLiveInterval)) {
358
+			$globalLiveInterval = '200';
359
+		}
317 360
 		$filter_query = $this->getFilter($filter);
318 361
 
319 362
 		if (is_array($coord)) {
@@ -321,7 +364,9 @@  discard block
 block discarded – undo
321 364
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
322 365
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
323 366
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
-		} else return array();
367
+		} else {
368
+			return array();
369
+		}
325 370
 		if ($globalDBdriver == 'mysql') {
326 371
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
327 372
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -514,11 +559,15 @@  discard block
 block discarded – undo
514 559
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
515 560
 		if ($globalDBdriver == 'mysql') {
516 561
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
517
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
562
+			if ($liveinterval) {
563
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
564
+			}
518 565
 			$query .= ' ORDER BY date';
519 566
 		} else {
520 567
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
521
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
568
+			if ($liveinterval) {
569
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
570
+			}
522 571
 			$query .= ' ORDER BY date';
523 572
 		}
524 573
 
@@ -613,7 +662,9 @@  discard block
 block discarded – undo
613 662
 				$i++;
614 663
 				$j++;
615 664
 				if ($j == 30) {
616
-					if ($globalDebug) echo ".";
665
+					if ($globalDebug) {
666
+						echo ".";
667
+					}
617 668
 				    	try {
618 669
 						
619 670
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -860,7 +911,9 @@  discard block
 block discarded – undo
860 911
 			{
861 912
 				return false;
862 913
 			}
863
-		} else return '';
914
+		} else {
915
+			return '';
916
+		}
864 917
 
865 918
 		if ($longitude != '')
866 919
 		{
@@ -868,7 +921,9 @@  discard block
 block discarded – undo
868 921
 			{
869 922
 				return false;
870 923
 			}
871
-		} else return '';
924
+		} else {
925
+			return '';
926
+		}
872 927
 
873 928
 		if ($altitude != '')
874 929
 		{
@@ -876,7 +931,9 @@  discard block
 block discarded – undo
876 931
 			{
877 932
 				return false;
878 933
 			}
879
-		} else $altitude = 0;
934
+		} else {
935
+			$altitude = 0;
936
+		}
880 937
 
881 938
 		if ($heading != '')
882 939
 		{
@@ -884,7 +941,9 @@  discard block
 block discarded – undo
884 941
 			{
885 942
 				return false;
886 943
 			}
887
-		} else $heading = 0;
944
+		} else {
945
+			$heading = 0;
946
+		}
888 947
 
889 948
 		if ($groundspeed != '')
890 949
 		{
@@ -892,9 +951,13 @@  discard block
 block discarded – undo
892 951
 			{
893 952
 				return false;
894 953
 			}
895
-		} else $groundspeed = 0;
954
+		} else {
955
+			$groundspeed = 0;
956
+		}
896 957
 		date_default_timezone_set('UTC');
897
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
958
+		if ($date == '') {
959
+			$date = date("Y-m-d H:i:s", time());
960
+		}
898 961
 
899 962
         
900 963
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -910,12 +973,18 @@  discard block
 block discarded – undo
910 973
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
911 974
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
912 975
 
913
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
914
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
976
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
977
+            		$groundspeed = 0;
978
+            	}
979
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
980
+            		$heading = 0;
981
+            	}
915 982
             	
916 983
 		$query = '';
917 984
 		if ($globalArchive) {
918
-			if ($globalDebug) echo '-- Delete previous data -- ';
985
+			if ($globalDebug) {
986
+				echo '-- Delete previous data -- ';
987
+			}
919 988
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
920 989
 		}
921 990
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -934,10 +1003,14 @@  discard block
 block discarded – undo
934 1003
                 echo 'noarchive : '.$noarchive."\n";
935 1004
                 */
936 1005
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
937
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1006
+		    if ($globalDebug) {
1007
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1008
+		    }
938 1009
 		    $TrackerArchive = new TrackerArchive($this->db);
939 1010
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
940
-		    if ($globalDebug) echo $result.')';
1011
+		    if ($globalDebug) {
1012
+		    	echo $result.')';
1013
+		    }
941 1014
 		}
942 1015
 
943 1016
 		return "success";
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Braces   +113 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection.');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection.');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -119,9 +126,13 @@  discard block
 block discarded – undo
119 126
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
120 127
 			}
121 128
 		}
122
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
129
+		if ($orderby_query == '') {
130
+			$orderby_query= ' ORDER BY date DESC';
131
+		}
123 132
 
124
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
133
+		if (!isset($globalLiveInterval)) {
134
+			$globalLiveInterval = '200';
135
+		}
125 136
 		if ($globalDBdriver == 'mysql') {
126 137
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
127 138
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -146,7 +157,9 @@  discard block
 block discarded – undo
146 157
 
147 158
 		$filter_query = $this->getFilter($filter,true,true);
148 159
 
149
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
160
+		if (!isset($globalLiveInterval)) {
161
+			$globalLiveInterval = '200';
162
+		}
150 163
 		if ($globalDBdriver == 'mysql') {
151 164
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
152 165
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -185,48 +198,72 @@  discard block
 block discarded – undo
185 198
 		}
186 199
 		$filter_query = $this->getFilter($filter,true,true);
187 200
 
188
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
189
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
201
+		if (!isset($globalLiveInterval)) {
202
+			$globalLiveInterval = '200';
203
+		}
204
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
205
+			$globalMap3DMarinesLimit = '300';
206
+		}
190 207
 		if ($globalDBdriver == 'mysql') {
191 208
 			if (isset($globalArchive) && $globalArchive === TRUE) {
192 209
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source 
193 210
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.flightaware_id = marine_archive.flightaware_id ";
194
-				if (isset($maxlat)) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
211
+				if (isset($maxlat)) {
212
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
213
+				}
195 214
 				$query .= "UNION
196 215
 				    SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
197 216
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
198
-				if (isset($maxlat)) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
217
+				if (isset($maxlat)) {
218
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
219
+				}
199 220
 				$query .= ") AS marine 
200 221
 				    WHERE latitude <> '0' AND longitude <> '0' 
201 222
 				    ORDER BY fammarine_id, date";
202
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
223
+				if ($limit) {
224
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
225
+				}
203 226
 			} else {
204 227
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
205 228
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
206
-				if (isset($maxlat)) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
229
+				if (isset($maxlat)) {
230
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
231
+				}
207 232
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
208 233
 				ORDER BY marine_live.fammarine_id, marine_live.date";
209
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
234
+				if ($limit) {
235
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
236
+				}
210 237
 			}
211 238
 		} else {
212 239
 			if (isset($globalArchive) && $globalArchive === TRUE) {
213 240
 				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source 
214 241
 				    FROM marine_archive INNER JOIN (SELECT flightaware_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.flightaware_id = marine_archive.flightaware_id ";
215
-				if (isset($maxlat)) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
242
+				if (isset($maxlat)) {
243
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
244
+				}
216 245
 				$query .= "UNION
217 246
 				    SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
218 247
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
219
-				if (isset($maxlat)) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
248
+				if (isset($maxlat)) {
249
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
250
+				}
220 251
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
221 252
 				$query .= "ORDER BY fammarine_id, date";
222
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
253
+				if ($limit) {
254
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
255
+				}
223 256
 			} else {
224 257
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
225 258
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
226
-				if (isset($maxlat)) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
259
+				if (isset($maxlat)) {
260
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
261
+				}
227 262
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
228 263
 				ORDER BY marine_live.fammarine_id, marine_live.date";
229
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
264
+				if ($limit) {
265
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
266
+				}
230 267
 			}
231 268
 		}
232 269
 		try {
@@ -251,7 +288,9 @@  discard block
 block discarded – undo
251 288
 		global $globalDBdriver, $globalLiveInterval;
252 289
 		$filter_query = $this->getFilter($filter,true,true);
253 290
 
254
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291
+		if (!isset($globalLiveInterval)) {
292
+			$globalLiveInterval = '200';
293
+		}
255 294
 		if ($globalDBdriver == 'mysql') {
256 295
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
257 296
 		} else {
@@ -279,7 +318,9 @@  discard block
 block discarded – undo
279 318
 	{
280 319
 		global $globalDBdriver, $globalLiveInterval;
281 320
 		$Spotter = new Spotter($this->db);
282
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
321
+		if (!isset($globalLiveInterval)) {
322
+			$globalLiveInterval = '200';
323
+		}
283 324
 		$filter_query = $this->getFilter($filter);
284 325
 
285 326
 		if (is_array($coord)) {
@@ -287,7 +328,9 @@  discard block
 block discarded – undo
287 328
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
288 329
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
289 330
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
290
-		} else return array();
331
+		} else {
332
+			return array();
333
+		}
291 334
 		if ($globalDBdriver == 'mysql') {
292 335
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
293 336
 		} else {
@@ -307,7 +350,9 @@  discard block
 block discarded – undo
307 350
 	{
308 351
 		global $globalDBdriver, $globalLiveInterval;
309 352
 		$Spotter = new Spotter($this->db);
310
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
353
+		if (!isset($globalLiveInterval)) {
354
+			$globalLiveInterval = '200';
355
+		}
311 356
 		$filter_query = $this->getFilter($filter);
312 357
 
313 358
 		if (is_array($coord)) {
@@ -315,7 +360,9 @@  discard block
 block discarded – undo
315 360
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
316 361
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
317 362
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
318
-		} else return array();
363
+		} else {
364
+			return array();
365
+		}
319 366
 		if ($globalDBdriver == 'mysql') {
320 367
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
321 368
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -483,11 +530,15 @@  discard block
 block discarded – undo
483 530
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
484 531
 		if ($globalDBdriver == 'mysql') {
485 532
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
486
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
533
+			if ($liveinterval) {
534
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
535
+			}
487 536
 			$query .= ' ORDER BY date';
488 537
 		} else {
489 538
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
490
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
539
+			if ($liveinterval) {
540
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
541
+			}
491 542
 			$query .= ' ORDER BY date';
492 543
 		}
493 544
 
@@ -582,7 +633,9 @@  discard block
 block discarded – undo
582 633
 				$i++;
583 634
 				$j++;
584 635
 				if ($j == 30) {
585
-					if ($globalDebug) echo ".";
636
+					if ($globalDebug) {
637
+						echo ".";
638
+					}
586 639
 				    	try {
587 640
 						
588 641
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -862,7 +915,9 @@  discard block
 block discarded – undo
862 915
 			{
863 916
 				return false;
864 917
 			}
865
-		} else return '';
918
+		} else {
919
+			return '';
920
+		}
866 921
 
867 922
 		if ($longitude != '')
868 923
 		{
@@ -870,7 +925,9 @@  discard block
 block discarded – undo
870 925
 			{
871 926
 				return false;
872 927
 			}
873
-		} else return '';
928
+		} else {
929
+			return '';
930
+		}
874 931
 
875 932
 
876 933
 		if ($heading != '')
@@ -879,7 +936,9 @@  discard block
 block discarded – undo
879 936
 			{
880 937
 				return false;
881 938
 			}
882
-		} else $heading = 0;
939
+		} else {
940
+			$heading = 0;
941
+		}
883 942
 
884 943
 		if ($groundspeed != '')
885 944
 		{
@@ -887,9 +946,13 @@  discard block
 block discarded – undo
887 946
 			{
888 947
 				return false;
889 948
 			}
890
-		} else $groundspeed = 0;
949
+		} else {
950
+			$groundspeed = 0;
951
+		}
891 952
 		date_default_timezone_set('UTC');
892
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
953
+		if ($date == '') {
954
+			$date = date("Y-m-d H:i:s", time());
955
+		}
893 956
 
894 957
         
895 958
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -910,12 +973,20 @@  discard block
 block discarded – undo
910 973
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
911 974
 		
912 975
 
913
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
914
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
915
-            	if ($arrival_date == '') $arrival_date = NULL;
976
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
977
+            		$groundspeed = 0;
978
+            	}
979
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
980
+            		$heading = 0;
981
+            	}
982
+            	if ($arrival_date == '') {
983
+            		$arrival_date = NULL;
984
+            	}
916 985
             	$query = '';
917 986
 		if ($globalArchive) {
918
-			if ($globalDebug) echo '-- Delete previous data -- ';
987
+			if ($globalDebug) {
988
+				echo '-- Delete previous data -- ';
989
+			}
919 990
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
920 991
 		}
921 992
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
@@ -930,10 +1001,14 @@  discard block
 block discarded – undo
930 1001
 		}
931 1002
 		
932 1003
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
933
-			if ($globalDebug) echo '(Add to Marine archive : ';
1004
+			if ($globalDebug) {
1005
+				echo '(Add to Marine archive : ';
1006
+			}
934 1007
 			$MarineArchive = new MarineArchive($this->db);
935 1008
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
936
-			if ($globalDebug) echo $result.')';
1009
+			if ($globalDebug) {
1010
+				echo $result.')';
1011
+			}
937 1012
 		}
938 1013
 		return "success";
939 1014
 	}
Please login to merge, or discard this patch.
live-czml.php 1 patch
Braces   +108 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,8 +8,12 @@  discard block
 block discarded – undo
8 8
 }
9 9
 $tracker = false;
10 10
 $marine = false;
11
-if (isset($_GET['tracker'])) $tracker = true;
12
-if (isset($_GET['marine'])) $marine = true;
11
+if (isset($_GET['tracker'])) {
12
+	$tracker = true;
13
+}
14
+if (isset($_GET['marine'])) {
15
+	$marine = true;
16
+}
13 17
 if ($tracker) {
14 18
 	require_once('require/class.Tracker.php');
15 19
 	require_once('require/class.TrackerLive.php');
@@ -66,23 +70,46 @@  discard block
 block discarded – undo
66 70
 }
67 71
 header('Content-Type: text/javascript');
68 72
 
69
-if (!isset($globalJsonCompress)) $compress = true;
70
-else $compress = $globalJsonCompress;
73
+if (!isset($globalJsonCompress)) {
74
+	$compress = true;
75
+} else {
76
+	$compress = $globalJsonCompress;
77
+}
71 78
 
72 79
 $from_archive = false;
73 80
 $min = false;
74 81
 $allhistory = false;
75 82
 $filter['source'] = array();
76
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
77
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
78
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
79
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
81
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
82
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
83
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
85
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
83
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
84
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
85
+}
86
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
87
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
88
+}
89
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
90
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
91
+}
92
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
93
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
94
+}
95
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
96
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
97
+}
98
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
99
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
100
+}
101
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
102
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
103
+}
104
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
105
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
106
+}
107
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
108
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
109
+}
110
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
111
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
112
+}
86 113
 /*
87 114
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
88 115
 	$min = true;
@@ -179,8 +206,12 @@  discard block
 block discarded – undo
179 206
 	} else {
180 207
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
181 208
 	}
182
-	if ($flightcnt == '') $flightcnt = 0;
183
-} else $flightcnt = 0;
209
+	if ($flightcnt == '') {
210
+		$flightcnt = 0;
211
+	}
212
+	} else {
213
+	$flightcnt = 0;
214
+}
184 215
 
185 216
 $sqltime = round(microtime(true)-$begintime,2);
186 217
 $minitime = time();
@@ -203,7 +234,9 @@  discard block
 block discarded – undo
203 234
 $j = 0;
204 235
 $prev_flightaware_id = '';
205 236
 $speed = 1;
206
-if (isset($archivespeed)) $speed = $archivespeed;
237
+if (isset($archivespeed)) {
238
+	$speed = $archivespeed;
239
+}
207 240
 $output = '[';
208 241
 if ($tracker) {
209 242
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -238,9 +271,13 @@  discard block
 block discarded – undo
238 271
 			$image = "images/placeholder_thumb.png";
239 272
 		}
240 273
 
241
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
242
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
243
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
274
+                if (isset($spotter_item['flightaware_id'])) {
275
+                	$id = $spotter_item['flightaware_id'];
276
+                } elseif (isset($spotter_item['famtrackid'])) {
277
+                	$id = $spotter_item['famtrackid'];
278
+                } elseif (isset($spotter_item['fammarine_id'])) {
279
+                	$id = $spotter_item['fammarine_id'];
280
+                }
244 281
                 if ($prev_flightaware_id != $id) {
245 282
 			if ($prev_flightaware_id != '') {
246 283
 				$output .= ']';
@@ -291,7 +328,9 @@  discard block
 block discarded – undo
291 328
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
292 329
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
293 330
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
294
-						} else $aircraft_shadow = '';
331
+						} else {
332
+							$aircraft_shadow = '';
333
+						}
295 334
 	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
296 335
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) {
297 336
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
@@ -299,7 +338,9 @@  discard block
 block discarded – undo
299 338
 						}
300 339
 						$output .= '},';
301 340
 					}
302
-				} else $output .= ' "billboard" : {"image" : "data:image/png;base64,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","scale" : 0.5},';
341
+				} else {
342
+					$output .= ' "billboard" : {"image" : "data:image/png;base64,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","scale" : 0.5},';
343
+				}
303 344
 			} elseif ($one3dmodel) {
304 345
 				if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') {
305 346
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20';
@@ -330,7 +371,9 @@  discard block
 block discarded – undo
330 371
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
331 372
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
332 373
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
333
-						} else $aircraft_shadow = '';
374
+						} else {
375
+							$aircraft_shadow = '';
376
+						}
334 377
 						if ($aircraft_shadow != '') {
335 378
 							if (isset($modelsdb[$aircraft_shadow])) {
336 379
 								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -467,7 +510,9 @@  discard block
 block discarded – undo
467 510
 								}
468 511
 								$output .= '},';
469 512
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
470
-								if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
513
+								if ($spotter_item['aircraft_icao'] != '') {
514
+									$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
515
+								}
471 516
 								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
472 517
 							}
473 518
 						} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -489,7 +534,9 @@  discard block
 block discarded – undo
489 534
 							}
490 535
 							$output .= '},';
491 536
 							//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
492
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
537
+							if ($spotter_item['aircraft_icao'] != '') {
538
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
539
+							}
493 540
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
494 541
 						}
495 542
 					} else {
@@ -502,7 +549,9 @@  discard block
 block discarded – undo
502 549
 						}
503 550
 						$output .= '},';
504 551
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
505
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
552
+						if ($spotter_item['aircraft_icao'] != '') {
553
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
554
+						}
506 555
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
507 556
 					}
508 557
 				} elseif ($tracker && isset($spotter_item['type'])) {
@@ -606,8 +655,11 @@  discard block
 block discarded – undo
606 655
 					$output .= '},';
607 656
 				}
608 657
 			}
609
-			if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output);
610
-			else $output = str_replace('%onground%','false',$output);
658
+			if (isset($onground) && $onground) {
659
+				$output = str_replace('%onground%','true',$output);
660
+			} else {
661
+				$output = str_replace('%onground%','false',$output);
662
+			}
611 663
 
612 664
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
613 665
 			//$output .= '"heightReference": "'.$heightrelative.'",';
@@ -620,8 +672,12 @@  discard block
 block discarded – undo
620 672
 	//		$output .= '"interpolationDegree" : 5,';
621 673
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
622 674
 			$output .= '"cartographicDegrees": [';
623
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
624
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
675
+			if ($minitime > strtotime($spotter_item['date'])) {
676
+				$minitime = strtotime($spotter_item['date']);
677
+			}
678
+			if ($maxitime < strtotime($spotter_item['date'])) {
679
+				$maxitime = strtotime($spotter_item['date']);
680
+			}
625 681
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
626 682
 			$output .= $spotter_item['longitude'].', ';
627 683
 			$output .= $spotter_item['latitude'];
@@ -644,20 +700,27 @@  discard block
 block discarded – undo
644 700
 					$output .= ', '.round($spotter_item['altitude']*30.48);
645 701
 					$prevalt = round($spotter_item['altitude']*30.48);
646 702
 				}
647
-			} else $output .= ', 0';
703
+			} else {
704
+				$output .= ', 0';
705
+			}
648 706
 			//$orientation = '"orientation" : { ';
649 707
 			//$orientation .= '"unitQuaternion": [';
650 708
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
651 709
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
652 710
 		} else {
653 711
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
654
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
712
+			if ($maxitime < strtotime($spotter_item['date'])) {
713
+				$maxitime = strtotime($spotter_item['date']);
714
+			}
655 715
 			if ($spotter_item['ground_speed'] == 0) {
656 716
 				$output .= $prevlong.', ';
657 717
 				$output .= $prevlat;
658 718
 				//if (!$marine && (!isset($onground) || !$onground)) $output .= ', '.$prevalt;
659
-				if (!$marine) $output .= ', '.$prevalt;
660
-				else $output .= ', 0';
719
+				if (!$marine) {
720
+					$output .= ', '.$prevalt;
721
+				} else {
722
+					$output .= ', 0';
723
+				}
661 724
 			} else {
662 725
 				$output .= $spotter_item['longitude'].', ';
663 726
 				$output .= $spotter_item['latitude'];
@@ -670,14 +733,17 @@  discard block
 block discarded – undo
670 733
 							$output .= ', 0';
671 734
 						}
672 735
 					} else {
673
-						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048);
674
-						elseif ($tracker) {
736
+						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
737
+							$output .= ', '.round($spotter_item['real_altitude']*0.3048);
738
+						} elseif ($tracker) {
675 739
 							$output .= ', '.round($spotter_item['altitude']*0.3048);
676 740
 						} else {
677 741
 							$output .= ', '.round($spotter_item['altitude']*30.48);
678 742
 						}
679 743
 					}
680
-				} else $output .= ', 0';
744
+				} else {
745
+					$output .= ', 0';
746
+				}
681 747
 			}
682 748
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
683 749
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
@@ -696,9 +762,12 @@  discard block
 block discarded – undo
696 762
 		} else {
697 763
 			$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
698 764
 		}
765
+	} else {
766
+		$output = str_replace('%minitime%',date("c",$minitime),$output);
699 767
 	}
700
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
701
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
768
+	} else {
769
+	$output = str_replace('%minitime%',date("c",$minitime),$output);
770
+}
702 771
 $output = str_replace('%maxitime%',date("c",$maxitime),$output);
703 772
 print $output;
704 773
 ?>
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 1 patch
Braces   +24 added lines, -4 removed lines patch added patch discarded remove patch
@@ -218,7 +218,12 @@  discard block
 block discarded – undo
218 218
 			<?php
219 219
 			    } else {
220 220
 			?>
221
-			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
221
+			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
222
+	print $globalMapRefresh*2000;
223
+} else {
224
+	print '60000';
225
+}
226
+?>)) {
222 227
 				viewer.dataSources.get(dsn).entities.remove(entity);
223 228
 				czmlds.entities.removeById(entityid);
224 229
 			}
@@ -502,7 +507,12 @@  discard block
 block discarded – undo
502 507
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
503 508
 ?>
504 509
 update_polarLayer();
505
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
510
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
511
+	print $globalMapRefresh*1000*2;
512
+} else {
513
+	print '60000';
514
+}
515
+?>);
506 516
 <?php
507 517
 		}
508 518
 ?>
@@ -613,7 +623,12 @@  discard block
 block discarded – undo
613 623
 				}
614 624
 			}
615 625
 		}
616
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
626
+	,<?php if (isset($globalMapRefresh)) {
627
+	print $globalMapRefresh*1000;
628
+} else {
629
+	print '30000';
630
+}
631
+?>);
617 632
 } else {
618 633
 	//var widget = new Cesium.CesiumWidget('archivebox');
619 634
 //	var timeline = new Cesium.Timeline(viewer);
@@ -632,7 +647,12 @@  discard block
 block discarded – undo
632 647
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
633 648
 ?>
634 649
 update_atcLayer();
635
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
650
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
651
+	print $globalMapRefresh*1000*2;
652
+} else {
653
+	print '60000';
654
+}
655
+?>);
636 656
 <?php
637 657
     }
638 658
 ?>
Please login to merge, or discard this patch.
js/map-marine.3d.js.php 1 patch
Braces   +12 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,12 @@  discard block
 block discarded – undo
47 47
 			<?php
48 48
 			    } else {
49 49
 			?>
50
-			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
50
+			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
51
+	print $globalMapRefresh*2000;
52
+} else {
53
+	print '60000';
54
+}
55
+?>)) {
51 56
 				viewer.dataSources.get(dsn).entities.remove(entity);
52 57
 			}
53 58
 			<?php
@@ -129,7 +134,12 @@  discard block
 block discarded – undo
129 134
 		function(){
130 135
 			updateMarineData();
131 136
 		}
132
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
137
+	,<?php if (isset($globalMapRefresh)) {
138
+	print $globalMapRefresh*1000;
139
+} else {
140
+	print '30000';
141
+}
142
+?>);
133 143
 } else {
134 144
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
135 145
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
Please login to merge, or discard this patch.
js/map-tracker.3d.js.php 1 patch
Braces   +12 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,12 @@  discard block
 block discarded – undo
90 90
 			<?php
91 91
 			    } else {
92 92
 			?>
93
-			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
93
+			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
94
+	print $globalMapRefresh*2000;
95
+} else {
96
+	print '60000';
97
+}
98
+?>)) {
94 99
 				viewer.dataSources.get(dsn).entities.remove(entity);
95 100
 				czmldstracker.entities.removeById(entityid);
96 101
 			}
@@ -173,7 +178,12 @@  discard block
 block discarded – undo
173 178
 		function(){
174 179
 			updateTrackerData();
175 180
 		}
176
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
181
+	,<?php if (isset($globalMapRefresh)) {
182
+	print $globalMapRefresh*1000;
183
+} else {
184
+	print '30000';
185
+}
186
+?>);
177 187
 } else {
178 188
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
179 189
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
Please login to merge, or discard this patch.