Completed
Push — master ( 64b871...55f75d )
by Yannick
11:40
created
live-czml.php 1 patch
Braces   +108 added lines, -38 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;
@@ -167,8 +194,12 @@  discard block
 block discarded – undo
167 194
 	} else {
168 195
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
169 196
 	}
170
-	if ($flightcnt == '') $flightcnt = 0;
171
-} else $flightcnt = 0;
197
+	if ($flightcnt == '') {
198
+		$flightcnt = 0;
199
+	}
200
+	} else {
201
+	$flightcnt = 0;
202
+}
172 203
 
173 204
 $sqltime = round(microtime(true)-$begintime,2);
174 205
 $minitime = time();
@@ -192,7 +223,9 @@  discard block
 block discarded – undo
192 223
 $j = 0;
193 224
 $prev_flightaware_id = '';
194 225
 $speed = 1;
195
-if (isset($archivespeed)) $speed = $archivespeed;
226
+if (isset($archivespeed)) {
227
+	$speed = $archivespeed;
228
+}
196 229
 $output = '[';
197 230
 if ($tracker) {
198 231
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -226,9 +259,13 @@  discard block
 block discarded – undo
226 259
 			$image = "images/placeholder_thumb.png";
227 260
 		}
228 261
 
229
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
230
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
231
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
262
+                if (isset($spotter_item['flightaware_id'])) {
263
+                	$id = $spotter_item['flightaware_id'];
264
+                } elseif (isset($spotter_item['famtrackid'])) {
265
+                	$id = $spotter_item['famtrackid'];
266
+                } elseif (isset($spotter_item['fammarine_id'])) {
267
+                	$id = $spotter_item['fammarine_id'];
268
+                }
232 269
                 if ($prev_flightaware_id != $id) {
233 270
 			if ($prev_flightaware_id != '') {
234 271
 				$output .= ']';
@@ -267,7 +304,9 @@  discard block
 block discarded – undo
267 304
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
268 305
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
269 306
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
270
-						} else $aircraft_shadow = '';
307
+						} else {
308
+							$aircraft_shadow = '';
309
+						}
271 310
 	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
272 311
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] && isset($_COOKIE['IconColor'])) {
273 312
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
@@ -275,7 +314,9 @@  discard block
 block discarded – undo
275 314
 						}
276 315
 						$output .= '},';
277 316
 					}
278
-				} else $output .= ' "billboard" : {"image" : "data:image/png;base64,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","scale" : 0.5},';
317
+				} else {
318
+					$output .= ' "billboard" : {"image" : "data:image/png;base64,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","scale" : 0.5},';
319
+				}
279 320
 			} elseif ($one3dmodel) {
280 321
 				if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') {
281 322
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : 1.0,"minimumPixelSize": 20';
@@ -306,7 +347,9 @@  discard block
 block discarded – undo
306 347
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
307 348
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
308 349
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
309
-						} else $aircraft_shadow = '';
350
+						} else {
351
+							$aircraft_shadow = '';
352
+						}
310 353
 						if ($aircraft_shadow != '') {
311 354
 							if (isset($modelsdb[$aircraft_shadow])) {
312 355
 								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -443,7 +486,9 @@  discard block
 block discarded – undo
443 486
 								}
444 487
 								$output .= '},';
445 488
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
446
-								if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
489
+								if ($spotter_item['aircraft_icao'] != '') {
490
+									$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
491
+								}
447 492
 								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
448 493
 							}
449 494
 						} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -465,7 +510,9 @@  discard block
 block discarded – undo
465 510
 							}
466 511
 							$output .= '},';
467 512
 							//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
468
-							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
+							}
469 516
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
470 517
 						}
471 518
 					} else {
@@ -478,7 +525,9 @@  discard block
 block discarded – undo
478 525
 						}
479 526
 						$output .= '},';
480 527
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
481
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
528
+						if ($spotter_item['aircraft_icao'] != '') {
529
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
530
+						}
482 531
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
483 532
 					}
484 533
 				} elseif ($tracker && isset($spotter_item['type'])) {
@@ -533,8 +582,12 @@  discard block
 block discarded – undo
533 582
 	//		$output .= '"interpolationDegree" : 5,';
534 583
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
535 584
 			$output .= '"cartographicDegrees": [';
536
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
537
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
585
+			if ($minitime > strtotime($spotter_item['date'])) {
586
+				$minitime = strtotime($spotter_item['date']);
587
+			}
588
+			if ($maxitime < strtotime($spotter_item['date'])) {
589
+				$maxitime = strtotime($spotter_item['date']);
590
+			}
538 591
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
539 592
 			$output .= $spotter_item['longitude'].', ';
540 593
 			$output .= $spotter_item['latitude'];
@@ -548,19 +601,26 @@  discard block
 block discarded – undo
548 601
 					$output .= ', '.round($spotter_item['altitude']*30.48);
549 602
 					$prevalt = round($spotter_item['altitude']*30.48);
550 603
 				}
551
-			} else $output .= ', 0';
604
+			} else {
605
+				$output .= ', 0';
606
+			}
552 607
 			//$orientation = '"orientation" : { ';
553 608
 			//$orientation .= '"unitQuaternion": [';
554 609
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
555 610
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
556 611
 		} else {
557 612
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
558
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
613
+			if ($maxitime < strtotime($spotter_item['date'])) {
614
+				$maxitime = strtotime($spotter_item['date']);
615
+			}
559 616
 			if ($spotter_item['ground_speed'] == 0) {
560 617
 				$output .= $prevlong.', ';
561 618
 				$output .= $prevlat;
562
-				if (!$tracker && !$marine) $output .= ', '.$prevalt;
563
-				else $output .= ', 0';
619
+				if (!$tracker && !$marine) {
620
+					$output .= ', '.$prevalt;
621
+				} else {
622
+					$output .= ', 0';
623
+				}
564 624
 			} else {
565 625
 				$output .= $spotter_item['longitude'].', ';
566 626
 				$output .= $spotter_item['latitude'];
@@ -572,10 +632,15 @@  discard block
 block discarded – undo
572 632
 							$output .= ', 0';
573 633
 						}
574 634
 					} else {
575
-						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048);
576
-						else $output .= ', '.round($spotter_item['altitude']*30.48);
635
+						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
636
+							$output .= ', '.round($spotter_item['real_altitude']*0.3048);
637
+						} else {
638
+							$output .= ', '.round($spotter_item['altitude']*30.48);
639
+						}
577 640
 					}
578
-				} else $output .= ', 0';
641
+				} else {
642
+					$output .= ', 0';
643
+				}
579 644
 			}
580 645
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
581 646
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
@@ -588,9 +653,14 @@  discard block
 block discarded – undo
588 653
 }
589 654
 $output .= ']';
590 655
 if (isset($globalArchive) && $globalArchive === TRUE) {
591
-		if (time()-$globalLiveInterval < $minitime) $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
592
-		else $output = str_replace('%minitime%',date("c",$minitime),$output);
593
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
656
+		if (time()-$globalLiveInterval < $minitime) {
657
+			$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
658
+		} else {
659
+			$output = str_replace('%minitime%',date("c",$minitime),$output);
660
+		}
661
+		} else {
662
+	$output = str_replace('%minitime%',date("c",$minitime),$output);
663
+}
594 664
 $output = str_replace('%maxitime%',date("c",$maxitime),$output);
595 665
 print $output;
596 666
 ?>
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +383 added lines, -142 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1661,35 +1751,55 @@  discard block
 block discarded – undo
1661 1751
 		if ($globalDBdriver == 'mysql') {
1662 1752
 			if (!$Connection->tableExists('marine_image')) {
1663 1753
 				$error .= create_db::import_file('../db/marine_image.sql');
1664
-				if ($error != '') return $error;
1754
+				if ($error != '') {
1755
+					return $error;
1756
+				}
1665 1757
 			}
1666 1758
 			if (!$Connection->tableExists('marine_archive')) {
1667 1759
 				$error .= create_db::import_file('../db/marine_archive.sql');
1668
-				if ($error != '') return $error;
1760
+				if ($error != '') {
1761
+					return $error;
1762
+				}
1669 1763
 			}
1670 1764
 			if (!$Connection->tableExists('marine_archive_output')) {
1671 1765
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1672
-				if ($error != '') return $error;
1766
+				if ($error != '') {
1767
+					return $error;
1768
+				}
1673 1769
 			}
1674 1770
 			if (!$Connection->tableExists('tracker_archive')) {
1675 1771
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1676
-				if ($error != '') return $error;
1772
+				if ($error != '') {
1773
+					return $error;
1774
+				}
1677 1775
 			}
1678 1776
 			if (!$Connection->tableExists('marine_archive_output')) {
1679 1777
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1680
-				if ($error != '') return $error;
1778
+				if ($error != '') {
1779
+					return $error;
1780
+				}
1681 1781
 			}
1682 1782
 		} else {
1683 1783
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1684
-			if ($error != '') return $error;
1784
+			if ($error != '') {
1785
+				return $error;
1786
+			}
1685 1787
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1686
-			if ($error != '') return $error;
1788
+			if ($error != '') {
1789
+				return $error;
1790
+			}
1687 1791
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1688
-			if ($error != '') return $error;
1792
+			if ($error != '') {
1793
+				return $error;
1794
+			}
1689 1795
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1690
-			if ($error != '') return $error;
1796
+			if ($error != '') {
1797
+				return $error;
1798
+			}
1691 1799
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1692
-			if ($error != '') return $error;
1800
+			if ($error != '') {
1801
+				return $error;
1802
+			}
1693 1803
 		}
1694 1804
 		if ($globalDBdriver == 'mysql') {
1695 1805
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2062,8 +2172,11 @@  discard block
 block discarded – undo
2062 2172
     	    if ($Connection->tableExists('aircraft')) {
2063 2173
     		if (!$Connection->tableExists('config')) {
2064 2174
     		    $version = '1';
2065
-    		    if ($update) return self::update_from_1();
2066
-    		    else return $version;
2175
+    		    if ($update) {
2176
+    		    	return self::update_from_1();
2177
+    		    } else {
2178
+    		    	return $version;
2179
+    		    }
2067 2180
 		} else {
2068 2181
     		    $Connection = new Connection();
2069 2182
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -2077,174 +2190,302 @@  discard block
 block discarded – undo
2077 2190
     		    if ($update) {
2078 2191
     			if ($result['value'] == '2') {
2079 2192
     			    $error = self::update_from_2();
2080
-    			    if ($error != '') return $error;
2081
-    			    else return self::check_version(true);
2193
+    			    if ($error != '') {
2194
+    			    	return $error;
2195
+    			    } else {
2196
+    			    	return self::check_version(true);
2197
+    			    }
2082 2198
     			} elseif ($result['value'] == '3') {
2083 2199
     			    $error = self::update_from_3();
2084
-    			    if ($error != '') return $error;
2085
-    			    else return self::check_version(true);
2200
+    			    if ($error != '') {
2201
+    			    	return $error;
2202
+    			    } else {
2203
+    			    	return self::check_version(true);
2204
+    			    }
2086 2205
     			} elseif ($result['value'] == '4') {
2087 2206
     			    $error = self::update_from_4();
2088
-    			    if ($error != '') return $error;
2089
-    			    else return self::check_version(true);
2207
+    			    if ($error != '') {
2208
+    			    	return $error;
2209
+    			    } else {
2210
+    			    	return self::check_version(true);
2211
+    			    }
2090 2212
     			} elseif ($result['value'] == '5') {
2091 2213
     			    $error = self::update_from_5();
2092
-    			    if ($error != '') return $error;
2093
-    			    else return self::check_version(true);
2214
+    			    if ($error != '') {
2215
+    			    	return $error;
2216
+    			    } else {
2217
+    			    	return self::check_version(true);
2218
+    			    }
2094 2219
     			} elseif ($result['value'] == '6') {
2095 2220
     			    $error = self::update_from_6();
2096
-    			    if ($error != '') return $error;
2097
-    			    else return self::check_version(true);
2221
+    			    if ($error != '') {
2222
+    			    	return $error;
2223
+    			    } else {
2224
+    			    	return self::check_version(true);
2225
+    			    }
2098 2226
     			} elseif ($result['value'] == '7') {
2099 2227
     			    $error = self::update_from_7();
2100
-    			    if ($error != '') return $error;
2101
-    			    else return self::check_version(true);
2228
+    			    if ($error != '') {
2229
+    			    	return $error;
2230
+    			    } else {
2231
+    			    	return self::check_version(true);
2232
+    			    }
2102 2233
     			} elseif ($result['value'] == '8') {
2103 2234
     			    $error = self::update_from_8();
2104
-    			    if ($error != '') return $error;
2105
-    			    else return self::check_version(true);
2235
+    			    if ($error != '') {
2236
+    			    	return $error;
2237
+    			    } else {
2238
+    			    	return self::check_version(true);
2239
+    			    }
2106 2240
     			} elseif ($result['value'] == '9') {
2107 2241
     			    $error = self::update_from_9();
2108
-    			    if ($error != '') return $error;
2109
-    			    else return self::check_version(true);
2242
+    			    if ($error != '') {
2243
+    			    	return $error;
2244
+    			    } else {
2245
+    			    	return self::check_version(true);
2246
+    			    }
2110 2247
     			} elseif ($result['value'] == '10') {
2111 2248
     			    $error = self::update_from_10();
2112
-    			    if ($error != '') return $error;
2113
-    			    else return self::check_version(true);
2249
+    			    if ($error != '') {
2250
+    			    	return $error;
2251
+    			    } else {
2252
+    			    	return self::check_version(true);
2253
+    			    }
2114 2254
     			} elseif ($result['value'] == '11') {
2115 2255
     			    $error = self::update_from_11();
2116
-    			    if ($error != '') return $error;
2117
-    			    else return self::check_version(true);
2256
+    			    if ($error != '') {
2257
+    			    	return $error;
2258
+    			    } else {
2259
+    			    	return self::check_version(true);
2260
+    			    }
2118 2261
     			} elseif ($result['value'] == '12') {
2119 2262
     			    $error = self::update_from_12();
2120
-    			    if ($error != '') return $error;
2121
-    			    else return self::check_version(true);
2263
+    			    if ($error != '') {
2264
+    			    	return $error;
2265
+    			    } else {
2266
+    			    	return self::check_version(true);
2267
+    			    }
2122 2268
     			} elseif ($result['value'] == '13') {
2123 2269
     			    $error = self::update_from_13();
2124
-    			    if ($error != '') return $error;
2125
-    			    else return self::check_version(true);
2270
+    			    if ($error != '') {
2271
+    			    	return $error;
2272
+    			    } else {
2273
+    			    	return self::check_version(true);
2274
+    			    }
2126 2275
     			} elseif ($result['value'] == '14') {
2127 2276
     			    $error = self::update_from_14();
2128
-    			    if ($error != '') return $error;
2129
-    			    else return self::check_version(true);
2277
+    			    if ($error != '') {
2278
+    			    	return $error;
2279
+    			    } else {
2280
+    			    	return self::check_version(true);
2281
+    			    }
2130 2282
     			} elseif ($result['value'] == '15') {
2131 2283
     			    $error = self::update_from_15();
2132
-    			    if ($error != '') return $error;
2133
-    			    else return self::check_version(true);
2284
+    			    if ($error != '') {
2285
+    			    	return $error;
2286
+    			    } else {
2287
+    			    	return self::check_version(true);
2288
+    			    }
2134 2289
     			} elseif ($result['value'] == '16') {
2135 2290
     			    $error = self::update_from_16();
2136
-    			    if ($error != '') return $error;
2137
-    			    else return self::check_version(true);
2291
+    			    if ($error != '') {
2292
+    			    	return $error;
2293
+    			    } else {
2294
+    			    	return self::check_version(true);
2295
+    			    }
2138 2296
     			} elseif ($result['value'] == '17') {
2139 2297
     			    $error = self::update_from_17();
2140
-    			    if ($error != '') return $error;
2141
-    			    else return self::check_version(true);
2298
+    			    if ($error != '') {
2299
+    			    	return $error;
2300
+    			    } else {
2301
+    			    	return self::check_version(true);
2302
+    			    }
2142 2303
     			} elseif ($result['value'] == '18') {
2143 2304
     			    $error = self::update_from_18();
2144
-    			    if ($error != '') return $error;
2145
-    			    else return self::check_version(true);
2305
+    			    if ($error != '') {
2306
+    			    	return $error;
2307
+    			    } else {
2308
+    			    	return self::check_version(true);
2309
+    			    }
2146 2310
     			} elseif ($result['value'] == '19') {
2147 2311
     			    $error = self::update_from_19();
2148
-    			    if ($error != '') return $error;
2149
-    			    else return self::check_version(true);
2312
+    			    if ($error != '') {
2313
+    			    	return $error;
2314
+    			    } else {
2315
+    			    	return self::check_version(true);
2316
+    			    }
2150 2317
     			} elseif ($result['value'] == '20') {
2151 2318
     			    $error = self::update_from_20();
2152
-    			    if ($error != '') return $error;
2153
-    			    else return self::check_version(true);
2319
+    			    if ($error != '') {
2320
+    			    	return $error;
2321
+    			    } else {
2322
+    			    	return self::check_version(true);
2323
+    			    }
2154 2324
     			} elseif ($result['value'] == '21') {
2155 2325
     			    $error = self::update_from_21();
2156
-    			    if ($error != '') return $error;
2157
-    			    else return self::check_version(true);
2326
+    			    if ($error != '') {
2327
+    			    	return $error;
2328
+    			    } else {
2329
+    			    	return self::check_version(true);
2330
+    			    }
2158 2331
     			} elseif ($result['value'] == '22') {
2159 2332
     			    $error = self::update_from_22();
2160
-    			    if ($error != '') return $error;
2161
-    			    else return self::check_version(true);
2333
+    			    if ($error != '') {
2334
+    			    	return $error;
2335
+    			    } else {
2336
+    			    	return self::check_version(true);
2337
+    			    }
2162 2338
     			} elseif ($result['value'] == '23') {
2163 2339
     			    $error = self::update_from_23();
2164
-    			    if ($error != '') return $error;
2165
-    			    else return self::check_version(true);
2340
+    			    if ($error != '') {
2341
+    			    	return $error;
2342
+    			    } else {
2343
+    			    	return self::check_version(true);
2344
+    			    }
2166 2345
     			} elseif ($result['value'] == '24') {
2167 2346
     			    $error = self::update_from_24();
2168
-    			    if ($error != '') return $error;
2169
-    			    else return self::check_version(true);
2347
+    			    if ($error != '') {
2348
+    			    	return $error;
2349
+    			    } else {
2350
+    			    	return self::check_version(true);
2351
+    			    }
2170 2352
     			} elseif ($result['value'] == '25') {
2171 2353
     			    $error = self::update_from_25();
2172
-    			    if ($error != '') return $error;
2173
-    			    else return self::check_version(true);
2354
+    			    if ($error != '') {
2355
+    			    	return $error;
2356
+    			    } else {
2357
+    			    	return self::check_version(true);
2358
+    			    }
2174 2359
     			} elseif ($result['value'] == '26') {
2175 2360
     			    $error = self::update_from_26();
2176
-    			    if ($error != '') return $error;
2177
-    			    else return self::check_version(true);
2361
+    			    if ($error != '') {
2362
+    			    	return $error;
2363
+    			    } else {
2364
+    			    	return self::check_version(true);
2365
+    			    }
2178 2366
     			} elseif ($result['value'] == '27') {
2179 2367
     			    $error = self::update_from_27();
2180
-    			    if ($error != '') return $error;
2181
-    			    else return self::check_version(true);
2368
+    			    if ($error != '') {
2369
+    			    	return $error;
2370
+    			    } else {
2371
+    			    	return self::check_version(true);
2372
+    			    }
2182 2373
     			} elseif ($result['value'] == '28') {
2183 2374
     			    $error = self::update_from_28();
2184
-    			    if ($error != '') return $error;
2185
-    			    else return self::check_version(true);
2375
+    			    if ($error != '') {
2376
+    			    	return $error;
2377
+    			    } else {
2378
+    			    	return self::check_version(true);
2379
+    			    }
2186 2380
     			} elseif ($result['value'] == '29') {
2187 2381
     			    $error = self::update_from_29();
2188
-    			    if ($error != '') return $error;
2189
-    			    else return self::check_version(true);
2382
+    			    if ($error != '') {
2383
+    			    	return $error;
2384
+    			    } else {
2385
+    			    	return self::check_version(true);
2386
+    			    }
2190 2387
     			} elseif ($result['value'] == '30') {
2191 2388
     			    $error = self::update_from_30();
2192
-    			    if ($error != '') return $error;
2193
-    			    else return self::check_version(true);
2389
+    			    if ($error != '') {
2390
+    			    	return $error;
2391
+    			    } else {
2392
+    			    	return self::check_version(true);
2393
+    			    }
2194 2394
     			} elseif ($result['value'] == '31') {
2195 2395
     			    $error = self::update_from_31();
2196
-    			    if ($error != '') return $error;
2197
-    			    else return self::check_version(true);
2396
+    			    if ($error != '') {
2397
+    			    	return $error;
2398
+    			    } else {
2399
+    			    	return self::check_version(true);
2400
+    			    }
2198 2401
     			} elseif ($result['value'] == '32') {
2199 2402
     			    $error = self::update_from_32();
2200
-    			    if ($error != '') return $error;
2201
-    			    else return self::check_version(true);
2403
+    			    if ($error != '') {
2404
+    			    	return $error;
2405
+    			    } else {
2406
+    			    	return self::check_version(true);
2407
+    			    }
2202 2408
     			} elseif ($result['value'] == '33') {
2203 2409
     			    $error = self::update_from_33();
2204
-    			    if ($error != '') return $error;
2205
-    			    else return self::check_version(true);
2410
+    			    if ($error != '') {
2411
+    			    	return $error;
2412
+    			    } else {
2413
+    			    	return self::check_version(true);
2414
+    			    }
2206 2415
     			} elseif ($result['value'] == '34') {
2207 2416
     			    $error = self::update_from_34();
2208
-    			    if ($error != '') return $error;
2209
-    			    else return self::check_version(true);
2417
+    			    if ($error != '') {
2418
+    			    	return $error;
2419
+    			    } else {
2420
+    			    	return self::check_version(true);
2421
+    			    }
2210 2422
     			} elseif ($result['value'] == '35') {
2211 2423
     			    $error = self::update_from_35();
2212
-    			    if ($error != '') return $error;
2213
-    			    else return self::check_version(true);
2424
+    			    if ($error != '') {
2425
+    			    	return $error;
2426
+    			    } else {
2427
+    			    	return self::check_version(true);
2428
+    			    }
2214 2429
     			} elseif ($result['value'] == '36') {
2215 2430
     			    $error = self::update_from_36();
2216
-    			    if ($error != '') return $error;
2217
-    			    else return self::check_version(true);
2431
+    			    if ($error != '') {
2432
+    			    	return $error;
2433
+    			    } else {
2434
+    			    	return self::check_version(true);
2435
+    			    }
2218 2436
     			} elseif ($result['value'] == '37') {
2219 2437
     			    $error = self::update_from_37();
2220
-    			    if ($error != '') return $error;
2221
-    			    else return self::check_version(true);
2438
+    			    if ($error != '') {
2439
+    			    	return $error;
2440
+    			    } else {
2441
+    			    	return self::check_version(true);
2442
+    			    }
2222 2443
     			} elseif ($result['value'] == '38') {
2223 2444
     			    $error = self::update_from_38();
2224
-    			    if ($error != '') return $error;
2225
-    			    else return self::check_version(true);
2445
+    			    if ($error != '') {
2446
+    			    	return $error;
2447
+    			    } else {
2448
+    			    	return self::check_version(true);
2449
+    			    }
2226 2450
     			} elseif ($result['value'] == '39') {
2227 2451
     			    $error = self::update_from_39();
2228
-    			    if ($error != '') return $error;
2229
-    			    else return self::check_version(true);
2452
+    			    if ($error != '') {
2453
+    			    	return $error;
2454
+    			    } else {
2455
+    			    	return self::check_version(true);
2456
+    			    }
2230 2457
     			} elseif ($result['value'] == '40') {
2231 2458
     			    $error = self::update_from_40();
2232
-    			    if ($error != '') return $error;
2233
-    			    else return self::check_version(true);
2459
+    			    if ($error != '') {
2460
+    			    	return $error;
2461
+    			    } else {
2462
+    			    	return self::check_version(true);
2463
+    			    }
2234 2464
     			} elseif ($result['value'] == '41') {
2235 2465
     			    $error = self::update_from_41();
2236
-    			    if ($error != '') return $error;
2237
-    			    else return self::check_version(true);
2466
+    			    if ($error != '') {
2467
+    			    	return $error;
2468
+    			    } else {
2469
+    			    	return self::check_version(true);
2470
+    			    }
2238 2471
     			} elseif ($result['value'] == '42') {
2239 2472
     			    $error = self::update_from_42();
2240
-    			    if ($error != '') return $error;
2241
-    			    else return self::check_version(true);
2242
-    			} else return '';
2473
+    			    if ($error != '') {
2474
+    			    	return $error;
2475
+    			    } else {
2476
+    			    	return self::check_version(true);
2477
+    			    }
2478
+    			} else {
2479
+    				return '';
2480
+    			}
2481
+    		    } else {
2482
+    		    	return $result['value'];
2243 2483
     		    }
2244
-    		    else return $result['value'];
2245 2484
 		}
2246 2485
 		
2247
-	    } else return $version;
2486
+	    } else {
2487
+	    	return $version;
2488
+	    }
2248 2489
     	}
2249 2490
     	
2250 2491
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +462 added lines, -124 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -239,42 +287,86 @@  discard block
 block discarded – undo
239 287
 			<legend>Coverage area</legend>
240 288
 			<p>
241 289
 				<label for="latitudemax">The maximum latitude (north)</label>
242
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
290
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
291
+	print $globalLatitudeMax;
292
+}
293
+?>" />
243 294
 			</p>
244 295
 			<p>
245 296
 				<label for="latitudemin">The minimum latitude (south)</label>
246
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
297
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
298
+	print $globalLatitudeMin;
299
+}
300
+?>" />
247 301
 			</p>
248 302
 			<p>
249 303
 				<label for="longitudemax">The maximum longitude (west)</label>
250
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
304
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
305
+	print $globalLongitudeMax;
306
+}
307
+?>" />
251 308
 			</p>
252 309
 			<p>
253 310
 				<label for="longitudemin">The minimum longitude (east)</label>
254
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
311
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
312
+	print $globalLongitudeMin;
313
+}
314
+?>" />
255 315
 			</p>
256 316
 			<p>
257 317
 				<label for="latitudecenter">The latitude center</label>
258
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
318
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
319
+	print $globalCenterLatitude;
320
+}
321
+?>" />
259 322
 			</p>
260 323
 			<p>
261 324
 				<label for="longitudecenter">The longitude center</label>
262
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
325
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
326
+	print $globalCenterLongitude;
327
+}
328
+?>" />
263 329
 			</p>
264 330
 			<p>
265 331
 				<label for="livezoom">Default Zoom on live map</label>
266
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
333
+	print $globalLiveZoom;
334
+} else {
335
+	print '9';
336
+}
337
+?>" />
267 338
 			</p>
268 339
 			<p>
269 340
 				<label for="squawk_country">Country for squawk usage</label>
270 341
 				<select name="squawk_country" id="squawk_country">
271
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
272
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
273
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
274
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
275
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
276
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
277
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
342
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
343
+	print ' selected ';
344
+}
345
+?>>UK</option>
346
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
347
+	print ' selected ';
348
+}
349
+?>>NZ</option>
350
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
351
+	print ' selected ';
352
+}
353
+?>>US</option>
354
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
355
+	print ' selected ';
356
+}
357
+?>>AU</option>
358
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
359
+	print ' selected ';
360
+}
361
+?>>NL</option>
362
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
363
+	print ' selected ';
364
+}
365
+?>>FR</option>
366
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
367
+	print ' selected ';
368
+}
369
+?>>TR</option>
278 370
 				</select>
279 371
 			</p>
280 372
 		</fieldset>
@@ -283,15 +375,24 @@  discard block
 block discarded – undo
283 375
 			<p><i>Only put in DB flights that are inside a circle</i></p>
284 376
 			<p>
285 377
 				<label for="latitude">Center latitude</label>
286
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
378
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
379
+	echo $globalDistanceIgnore['latitude'];
380
+}
381
+?>" />
287 382
 			</p>
288 383
 			<p>
289 384
 				<label for="longitude">Center longitude</label>
290
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
385
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
386
+	echo $globalDistanceIgnore['longitude'];
387
+}
388
+?>" />
291 389
 			</p>
292 390
 			<p>
293 391
 				<label for="Distance">Distance (in km)</label>
294
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
392
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
393
+	echo $globalDistanceIgnore['distance'];
394
+}
395
+?>" />
295 396
 			</p>
296 397
 		</fieldset>
297 398
 		<fieldset id="sourceloc">
@@ -400,11 +501,17 @@  discard block
 block discarded – undo
400 501
 			<div id="flightaware_data">
401 502
 				<p>
402 503
 					<label for="flightawareusername">FlightAware username</label>
403
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
504
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
505
+	print $globalFlightAwareUsername;
506
+}
507
+?>" />
404 508
 				</p>
405 509
 				<p>
406 510
 					<label for="flightawarepassword">FlightAware password/API key</label>
407
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
511
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
512
+	print $globalFlightAwarePassword;
513
+}
514
+?>" />
408 515
 				</p>
409 516
 			</div>
410 517
 -->
@@ -464,29 +571,92 @@  discard block
 block discarded – undo
464 571
 								?>
465 572
 								<td>
466 573
 									<select name="format[]" id="format">
467
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
468
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
469
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
470
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
471
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
472
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
473
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
474
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
475
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
476
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
477
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
478
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
479
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
480
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
481
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
482
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
483
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
484
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
574
+										<option value="auto" <?php if (!isset($source['format'])) {
575
+	print 'selected';
576
+}
577
+?>>Auto</option>
578
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
579
+	print 'selected';
580
+}
581
+?>>SBS</option>
582
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
583
+	print 'selected';
584
+}
585
+?>>TSV</option>
586
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
587
+	print 'selected';
588
+}
589
+?>>Raw</option>
590
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
591
+	print 'selected';
592
+}
593
+?>>APRS</option>
594
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
595
+	print 'selected';
596
+}
597
+?>>Radarcape deltadb.txt</option>
598
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
599
+	print 'selected';
600
+}
601
+?>>Vatsim</option>
602
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
603
+	print 'selected';
604
+}
605
+?>>Virtual Radar Server AircraftList.json</option>
606
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
607
+	print 'selected';
608
+}
609
+?>>Virtual Radar Server TCP</option>
610
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
611
+	print 'selected';
612
+}
613
+?>>phpVMS</option>
614
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
615
+	print 'selected';
616
+}
617
+?>>Virtual Airlines Manager</option>
618
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
619
+	print 'selected';
620
+}
621
+?>>IVAO</option>
622
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
623
+	print 'selected';
624
+}
625
+?>>FlightGear Multiplayer</option>
626
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
627
+	print 'selected';
628
+}
629
+?>>FlightGear Singleplayer</option>
630
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
631
+	print 'selected';
632
+}
633
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
634
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
635
+	print 'selected';
636
+}
637
+?>>ACARS SBS-3 over TCP</option>
638
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
639
+	print 'selected';
640
+}
641
+?>>NMEA AIS over TCP</option>
642
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
643
+	print 'selected';
644
+}
645
+?>>AirWhere website</option>
485 646
 									</select>
486 647
 								</td>
487
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
488
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
489
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
648
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
649
+	print $source['name'];
650
+}
651
+?>" /></td>
652
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
653
+	print 'checked';
654
+}
655
+?> /></td>
656
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
657
+	print 'checked';
658
+}
659
+?> /></td>
490 660
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
491 661
 							</tr>
492 662
 <?php
@@ -536,11 +706,17 @@  discard block
 block discarded – undo
536 706
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
537 707
 					<p>
538 708
 						<label for="acarshost">ACARS UDP host</label>
539
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
709
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
710
+	print $globalACARSHost;
711
+}
712
+?>" />
540 713
 					</p>
541 714
 					<p>
542 715
 						<label for="acarsport">ACARS UDP port</label>
543
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
716
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
717
+	print $globalACARSPort;
718
+}
719
+?>" />
544 720
 					</p>
545 721
 				</fieldset>
546 722
 			</div>
@@ -620,13 +796,19 @@  discard block
 block discarded – undo
620 796
 			<div id="schedules_options">
621 797
 				<p>
622 798
 					<label for="britishairways">British Airways API Key</label>
623
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
799
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
800
+	print $globalBritishAirwaysKey;
801
+}
802
+?>" />
624 803
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
625 804
 				</p>
626 805
 				<!--
627 806
 				<p>
628 807
 					<label for="transavia">Transavia Test API Consumer Key</label>
629
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
808
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
809
+	print $globalTransaviaKey;
810
+}
811
+?>" />
630 812
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
631 813
 				</p>
632 814
 				-->
@@ -635,10 +817,16 @@  discard block
 block discarded – undo
635 817
 						<b>Lufthansa API Key</b>
636 818
 						<p>
637 819
 							<label for="lufthansakey">Key</label>
638
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
820
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
821
+	print $globalLufthansaKey['key'];
822
+}
823
+?>" />
639 824
 						</p><p>
640 825
 							<label for="lufthansasecret">Secret</label>
641
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
826
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
827
+	print $globalLufthansaKey['secret'];
828
+}
829
+?>" />
642 830
 						</p>
643 831
 					</div>
644 832
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -658,7 +846,10 @@  discard block
 block discarded – undo
658 846
 			</p>
659 847
 			<p>
660 848
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
661
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
849
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
850
+	print $globalNOTAMSource;
851
+}
852
+?>" />
662 853
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
663 854
 			</p>
664 855
 			<br />
@@ -674,14 +865,20 @@  discard block
 block discarded – undo
674 865
 			<div id="metarsrc">
675 866
 				<p>
676 867
 					<label for="metarsource">URL of your METAR source</label>
677
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
868
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
869
+	print $globalMETARurl;
870
+}
871
+?>" />
678 872
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
679 873
 				</p>
680 874
 			</div>
681 875
 			<br />
682 876
 			<p>
683 877
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
684
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
878
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
879
+	print $globalBitlyAccessToken;
880
+}
881
+?>" />
685 882
 			</p>
686 883
 			<br />
687 884
 			<p>
@@ -701,7 +898,12 @@  discard block
 block discarded – undo
701 898
 			</p>
702 899
 			<p>
703 900
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
704
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
901
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
902
+	print $globalArchiveMonths;
903
+} else {
904
+	echo '0';
905
+}
906
+?>" />
705 907
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
706 908
 			</p>
707 909
 			<p>
@@ -711,12 +913,22 @@  discard block
 block discarded – undo
711 913
 			</p>
712 914
 			<p>
713 915
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
714
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
916
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
917
+	print $globalArchiveKeepMonths;
918
+} else {
919
+	echo '0';
920
+}
921
+?>" />
715 922
 				<p class="help-block">0 to disable</p>
716 923
 			</p>
717 924
 			<p>
718 925
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
719
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
926
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
927
+	print $globalArchiveKeepTrackMonths;
928
+} else {
929
+	echo '0';
930
+}
931
+?>" />
720 932
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
721 933
 			</p>
722 934
 			<br />
@@ -726,7 +938,12 @@  discard block
 block discarded – undo
726 938
 				<p class="help-block">Uncheck if the script is running as cron job</p>
727 939
 				<div id="cronends"> 
728 940
 					<label for="cronend">Run script for xx seconds</label>
729
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
941
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
942
+	print $globalCronEnd;
943
+} else {
944
+	print '0';
945
+}
946
+?>" />
730 947
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
731 948
 				</div>
732 949
 			</p>
@@ -779,15 +996,30 @@  discard block
 block discarded – undo
779 996
 			<br />
780 997
 			<p>
781 998
 				<label for="refresh">Show flights detected since xxx seconds</label>
782
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
999
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1000
+	echo $globalLiveInterval;
1001
+} else {
1002
+	echo '200';
1003
+}
1004
+?>" />
783 1005
 			</p>
784 1006
 			<p>
785 1007
 				<label for="maprefresh">Live map refresh (in seconds)</label>
786
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1008
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1009
+	echo $globalMapRefresh;
1010
+} else {
1011
+	echo '30';
1012
+}
1013
+?>" />
787 1014
 			</p>
788 1015
 			<p>
789 1016
 				<label for="mapidle">Map idle timeout (in minutes)</label>
790
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1017
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1018
+	echo $globalMapIdleTimeout;
1019
+} else {
1020
+	echo '30';
1021
+}
1022
+?>" />
791 1023
 				<p class="help-block">0 to disable</p>
792 1024
 			</p>
793 1025
 			<p>
@@ -797,12 +1029,20 @@  discard block
 block discarded – undo
797 1029
 			<br />
798 1030
 			<p>
799 1031
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
800
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1032
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1033
+	echo $globalClosestMinDist;
1034
+} else {
1035
+	echo '50';
1036
+}
1037
+?>" />
801 1038
 			</p>
802 1039
 			<br />
803 1040
 			<p>
804 1041
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
805
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1042
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1043
+	echo $globalAircraftSize;
1044
+}
1045
+?>" />
806 1046
 			</p>
807 1047
 			<br />
808 1048
 			<p>
@@ -815,7 +1055,12 @@  discard block
 block discarded – undo
815 1055
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
816 1056
 			?>
817 1057
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
818
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1058
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1059
+	echo $globalAircraftIconColor;
1060
+} else {
1061
+	echo '1a3151';
1062
+}
1063
+?>" />
819 1064
 			<?php
820 1065
 				if (!is_writable('../cache')) {
821 1066
 			?>
@@ -833,14 +1078,27 @@  discard block
 block discarded – undo
833 1078
 			<p>
834 1079
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
835 1080
 				<div class="range">
836
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
837
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1081
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1082
+	echo $globalAirportZoom;
1083
+} else {
1084
+	echo '7';
1085
+}
1086
+?>" />
1087
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1088
+	echo $globalAirportZoom;
1089
+} else {
1090
+	echo '7';
1091
+}
1092
+?></output>
838 1093
 				</div>
839 1094
 			</p>
840 1095
 			<br />
841 1096
 			<p>
842 1097
 				<label for="customcss">Custom CSS web path</label>
843
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1098
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1099
+	echo $globalCustomCSS;
1100
+}
1101
+?>" />
844 1102
 			</p>
845 1103
 		</fieldset>
846 1104
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -867,8 +1125,12 @@  discard block
 block discarded – undo
867 1125
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
868 1126
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
869 1127
 
870
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
871
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1128
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1129
+		$error .= 'Mysql driver for PDO must be loaded';
1130
+	}
1131
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1132
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1133
+	}
872 1134
 	
873 1135
 	$_SESSION['database_root'] = $dbroot;
874 1136
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -935,15 +1197,23 @@  discard block
 block discarded – undo
935 1197
 	$source_city = $_POST['source_city'];
936 1198
 	$source_country = $_POST['source_country'];
937 1199
 	$source_ref = $_POST['source_ref'];
938
-	if (isset($source_id)) $source_id = $_POST['source_id'];
939
-	else $source_id = array();
1200
+	if (isset($source_id)) {
1201
+		$source_id = $_POST['source_id'];
1202
+	} else {
1203
+		$source_id = array();
1204
+	}
940 1205
 	
941 1206
 	$sources = array();
942 1207
 	foreach ($source_name as $keys => $name) {
943
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
944
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1208
+	    if (isset($source_id[$keys])) {
1209
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1210
+	    } else {
1211
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1212
+	    }
1213
+	}
1214
+	if (count($sources) > 0) {
1215
+		$_SESSION['sources'] = $sources;
945 1216
 	}
946
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
947 1217
 
948 1218
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
949 1219
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -964,14 +1234,23 @@  discard block
 block discarded – undo
964 1234
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
965 1235
 
966 1236
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
967
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
968
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1237
+	if ($globalaircraft == 'aircraft') {
1238
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1239
+	} else {
1240
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1241
+	}
969 1242
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
970
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
971
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1243
+	if ($globaltracker == 'tracker') {
1244
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1245
+	} else {
1246
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1247
+	}
972 1248
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
973
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
974
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1249
+	if ($globalmarine == 'marine') {
1250
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1251
+	} else {
1252
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1253
+	}
975 1254
 
976 1255
 /*	
977 1256
 	$globalSBS1Hosts = array();
@@ -992,19 +1271,35 @@  discard block
 block discarded – undo
992 1271
 	$port = $_POST['port'];
993 1272
 	$name = $_POST['name'];
994 1273
 	$format = $_POST['format'];
995
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
996
-	else $sourcestats = array();
997
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
998
-	else $noarchive = array();
1274
+	if (isset($_POST['sourcestats'])) {
1275
+		$sourcestats = $_POST['sourcestats'];
1276
+	} else {
1277
+		$sourcestats = array();
1278
+	}
1279
+	if (isset($_POST['noarchive'])) {
1280
+		$noarchive = $_POST['noarchive'];
1281
+	} else {
1282
+		$noarchive = array();
1283
+	}
999 1284
 	$gSources = array();
1000 1285
 	$forcepilots = false;
1001 1286
 	foreach ($host as $key => $h) {
1002
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1003
-		else $cov = 'FALSE';
1004
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1005
-		else $arch = 'FALSE';
1006
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch);
1007
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1287
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1288
+			$cov = 'TRUE';
1289
+		} else {
1290
+			$cov = 'FALSE';
1291
+		}
1292
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1293
+			$arch = 'TRUE';
1294
+		} else {
1295
+			$arch = 'FALSE';
1296
+		}
1297
+		if ($h != '') {
1298
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch);
1299
+		}
1300
+		if ($format[$key] == 'airwhere') {
1301
+			$forcepilots = true;
1302
+		}
1008 1303
 	}
1009 1304
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1010 1305
 
@@ -1032,7 +1327,9 @@  discard block
 block discarded – undo
1032 1327
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1033 1328
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1034 1329
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1035
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1330
+	} else {
1331
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1332
+	}
1036 1333
 
1037 1334
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1038 1335
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1071,7 +1368,9 @@  discard block
 block discarded – undo
1071 1368
 
1072 1369
 	// Create in settings.php keys not yet configurable if not already here
1073 1370
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1074
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1371
+	if (!isset($globalDebug)) {
1372
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1373
+	}
1075 1374
 
1076 1375
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1077 1376
 	if ($resetyearstats == 'resetyearstats') {
@@ -1108,37 +1407,56 @@  discard block
 block discarded – undo
1108 1407
 	}
1109 1408
 */
1110 1409
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1111
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1112
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1113
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1114
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1410
+	if ($globalsbs == 'sbs') {
1411
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1412
+	} else {
1413
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1414
+	}
1415
+	if ($globalaprs == 'aprs') {
1416
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1417
+	} else {
1418
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1419
+	}
1115 1420
 	$va = false;
1116 1421
 	if ($globalivao == 'ivao') {
1117 1422
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1118 1423
 		$va = true;
1119
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1424
+	} else {
1425
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1426
+	}
1120 1427
 	if ($globalvatsim == 'vatsim') {
1121 1428
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1122 1429
 		$va = true;
1123
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1430
+	} else {
1431
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1432
+	}
1124 1433
 	if ($globalphpvms == 'phpvms') {
1125 1434
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1126 1435
 		$va = true;
1127
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1436
+	} else {
1437
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1438
+	}
1128 1439
 	if ($globalvam == 'vam') {
1129 1440
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1130 1441
 		$va = true;
1131
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1442
+	} else {
1443
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1444
+	}
1132 1445
 	if ($va) {
1133 1446
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1134
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1447
+	} else {
1448
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1449
+	}
1135 1450
 	if ($globalva == 'va' || $va) {
1136 1451
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1137 1452
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1138 1453
 	} else {
1139 1454
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1140
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1141
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1455
+		if ($forcepilots) {
1456
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1457
+		} else {
1458
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1459
+		}
1142 1460
 	}
1143 1461
 	
1144 1462
 	
@@ -1299,7 +1617,9 @@  discard block
 block discarded – undo
1299 1617
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1300 1618
 	}
1301 1619
 
1302
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1620
+	if (!isset($globalTransaction)) {
1621
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1622
+	}
1303 1623
 
1304 1624
 	// Set some defaults values...
1305 1625
 	if (!isset($globalAircraftImageSources)) {
@@ -1314,15 +1634,23 @@  discard block
 block discarded – undo
1314 1634
 
1315 1635
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1316 1636
 
1317
-	if ($error == '') settings::modify_settings($settings);
1318
-	if ($error == '') settings::comment_settings($settings_comment);
1637
+	if ($error == '') {
1638
+		settings::modify_settings($settings);
1639
+	}
1640
+	if ($error == '') {
1641
+		settings::comment_settings($settings_comment);
1642
+	}
1319 1643
 	if ($error != '') {
1320 1644
 		print '<div class="info column">'.$error.'</div>';
1321 1645
 		require('../footer.php');
1322 1646
 		exit;
1323 1647
 	} else {
1324
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1325
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1648
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1649
+			$_SESSION['waypoints'] = 1;
1650
+		}
1651
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1652
+			$_SESSION['owner'] = 1;
1653
+		}
1326 1654
 		if (isset($_POST['createdb'])) {
1327 1655
 			$_SESSION['install'] = 'database_create';
1328 1656
 		} else {
@@ -1363,10 +1691,18 @@  discard block
 block discarded – undo
1363 1691
 	$popw = false;
1364 1692
 	foreach ($_SESSION['done'] as $done) {
1365 1693
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1366
-	    if ($done == 'Create database') $pop = true;
1367
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1368
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1369
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1694
+	    if ($done == 'Create database') {
1695
+	    	$pop = true;
1696
+	    }
1697
+	    if ($_SESSION['install'] == 'database_create') {
1698
+	    	$pop = true;
1699
+	    }
1700
+	    if ($_SESSION['install'] == 'database_import') {
1701
+	    	$popi = true;
1702
+	    }
1703
+	    if ($_SESSION['install'] == 'waypoints') {
1704
+	    	$popw = true;
1705
+	    }
1370 1706
 	}
1371 1707
 	if ($pop) {
1372 1708
 	    sleep(5);
@@ -1377,7 +1713,9 @@  discard block
 block discarded – undo
1377 1713
 	} else if ($popw) {
1378 1714
 	    sleep(5);
1379 1715
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1380
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1716
+	} else {
1717
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1718
+	}
1381 1719
 	print '</div></ul>';
1382 1720
 	print '<div id="error"></div>';
1383 1721
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +396 added lines, -141 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,7 +213,9 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
 	    if (isset($flight['lastupdate'])) {
187 221
 		if ($flight['lastupdate'] < (time()-5900)) {
@@ -195,13 +229,17 @@  discard block
 block discarded – undo
195 229
 	global $globalDebug, $globalNoImport, $globalNoDB;
196 230
 	// Delete old infos
197 231
 	if (isset($this->all_flights[$key]['id'])) {
198
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
232
+		if ($globalDebug) {
233
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
234
+		}
199 235
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
200 236
 			$real_arrival = $this->arrival($key);
201 237
 			$Spotter = new Spotter($this->db);
202 238
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
203 239
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
204
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
240
+				if ($globalDebug && $result != 'success') {
241
+					echo '!!! ERROR : '.$result."\n";
242
+				}
205 243
 			}
206 244
 		}
207 245
 	}
@@ -211,9 +249,13 @@  discard block
 block discarded – undo
211 249
     public function add($line) {
212 250
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate;
213 251
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
214
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
215
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 2300;
216
-/*
252
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
253
+		$globalCoordMinChange = '0.02';
254
+	}
255
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
256
+		$globalAircraftMaxUpdate = 2300;
257
+	}
258
+	/*
217 259
 	$Spotter = new Spotter();
218 260
 	$dbc = $Spotter->db;
219 261
 	$SpotterLive = new SpotterLive($dbc);
@@ -235,19 +277,28 @@  discard block
 block discarded – undo
235 277
 	// SBS format is CSV format
236 278
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 279
 	    //print_r($line);
238
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
280
+	    if (isset($line['hex'])) {
281
+	    	$line['hex'] = strtoupper($line['hex']);
282
+	    }
239 283
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
240 284
 
241 285
 		// Increment message number
242 286
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
243 287
 		    $current_date = date('Y-m-d');
244
-		    if (isset($line['source_name'])) $source = $line['source_name'];
245
-		    else $source = '';
246
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
288
+		    if (isset($line['source_name'])) {
289
+		    	$source = $line['source_name'];
290
+		    } else {
291
+		    	$source = '';
292
+		    }
293
+		    if ($source == '' || $line['format_source'] == 'aprs') {
294
+		    	$source = $line['format_source'];
295
+		    }
247 296
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
248 297
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
249 298
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
250
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
299
+		    } else {
300
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
301
+		    }
251 302
 		}
252 303
 		
253 304
 		/*
@@ -263,22 +314,35 @@  discard block
 block discarded – undo
263 314
 		//$this->db = $dbc;
264 315
 
265 316
 		//$hex = trim($line['hex']);
266
-	        if (!isset($line['id'])) $id = trim($line['hex']);
267
-	        else $id = trim($line['id']);
317
+	        if (!isset($line['id'])) {
318
+	        	$id = trim($line['hex']);
319
+	        } else {
320
+	        	$id = trim($line['id']);
321
+	        }
268 322
 		
269 323
 		if (!isset($this->all_flights[$id])) {
270 324
 		    $this->all_flights[$id] = array();
271 325
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
272 326
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
273
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
327
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
328
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
329
+		    }
274 330
 		    if (!isset($line['id'])) {
275
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
276
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
331
+			if (!isset($globalDaemon)) {
332
+				$globalDaemon = TRUE;
333
+			}
334
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
277 335
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
278
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
336
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
337
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
338
+			}
279 339
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
280
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
281
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
340
+		     } else {
341
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
342
+		     }
343
+		    if ($globalAllFlights !== FALSE) {
344
+		    	$dataFound = true;
345
+		    }
282 346
 		}
283 347
 		if (isset($line['source_type']) && $line['source_type'] != '') {
284 348
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -300,12 +364,20 @@  discard block
 block discarded – undo
300 364
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
301 365
 			    }
302 366
 			    $Spotter->db = null;
303
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
304
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
367
+			    if ($globalDebugTimeElapsed) {
368
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
369
+			    }
370
+			    if ($aircraft_icao != '') {
371
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
372
+			    }
305 373
 			}
306 374
 		    }
307
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
308
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
375
+		    if ($globalAllFlights !== FALSE) {
376
+		    	$dataFound = true;
377
+		    }
378
+		    if ($globalDebug) {
379
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
380
+		    }
309 381
 		}
310 382
 	        if (isset($line['id']) && !isset($line['hex'])) {
311 383
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -313,7 +385,9 @@  discard block
 block discarded – undo
313 385
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
314 386
 			$icao = $line['aircraft_icao'];
315 387
 			$Spotter = new Spotter($this->db);
316
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
388
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
389
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
390
+			}
317 391
 			$Spotter->db = null;
318 392
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
319 393
 		}
@@ -323,15 +397,24 @@  discard block
 block discarded – undo
323 397
 				$Spotter = new Spotter($this->db);
324 398
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
325 399
 				$Spotter->db = null;
326
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
400
+				if ($aircraft_icao != '') {
401
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
402
+				}
327 403
 			}
328 404
 		}
329 405
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
330
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
331
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
332
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
333
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
334
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
406
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
407
+				$aircraft_icao = 'GLID';
408
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
409
+				$aircraft_icao = 'UHEL';
410
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
411
+				$aircraft_icao = 'TOWPLANE';
412
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
413
+				$aircraft_icao = 'POWAIRC';
414
+			}
415
+			if (isset($aircraft_icao)) {
416
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
417
+			}
335 418
 		}
336 419
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
337 420
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -341,8 +424,11 @@  discard block
 block discarded – undo
341 424
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
342 425
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
343 426
 		    } else {
344
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
345
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
427
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
428
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
429
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
430
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
431
+				}
346 432
 				/*
347 433
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
348 434
 				print_r($this->all_flights[$id]);
@@ -351,17 +437,23 @@  discard block
 block discarded – undo
351 437
 				return '';
352 438
 		    }
353 439
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
354
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
440
+			if ($globalDebug) {
441
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
442
+			}
355 443
 			return '';
356 444
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
357
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
445
+			if ($globalDebug) {
446
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
358 447
 			";
448
+			}
359 449
 			return '';
360 450
 		} elseif (!isset($line['datetime'])) {
361 451
 			date_default_timezone_set('UTC');
362 452
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
363 453
 		} else {
364
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
454
+			if ($globalDebug) {
455
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
456
+			}
365 457
 			return '';
366 458
 		}
367 459
 
@@ -382,30 +474,48 @@  discard block
 block discarded – undo
382 474
 
383 475
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
384 476
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
385
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
477
+				if ($globalDebug) {
478
+					echo '---!!!! New ident, reset aircraft data...'."\n";
479
+				}
386 480
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
387 481
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
388
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
389
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
390
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
482
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
483
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
484
+				} elseif (isset($line['id'])) {
485
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
486
+				} elseif (isset($this->all_flights[$id]['ident'])) {
487
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
488
+				}
391 489
 			} else {
392 490
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
393 491
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
394 492
 				$timeelapsed = microtime(true);
395 493
             			$Spotter = new Spotter($this->db);
396 494
             			$fromsource = NULL;
397
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
398
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
399
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
400
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
401
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
495
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
496
+            				$fromsource = $globalAirlinesSource;
497
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
498
+            				$fromsource = 'vatsim';
499
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
500
+					$fromsource = 'ivao';
501
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
502
+					$fromsource = 'vatsim';
503
+				} elseif (isset($globalIVAO) && $globalIVAO) {
504
+					$fromsource = 'ivao';
505
+				}
402 506
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
403
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
507
+				if ($globalDebug && $result != 'success') {
508
+					echo '!!! ERROR : '.$result."\n";
509
+				}
404 510
 				$Spotter->db = null;
405
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
511
+				if ($globalDebugTimeElapsed) {
512
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
513
+				}
406 514
 			    }
407 515
 			}
408
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
516
+		    } else {
517
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
518
+		    }
409 519
 		    
410 520
 /*
411 521
 		    if (!isset($line['id'])) {
@@ -415,7 +525,9 @@  discard block
 block discarded – undo
415 525
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
416 526
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
417 527
   */
418
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
528
+		    if (!isset($this->all_flights[$id]['id'])) {
529
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
530
+		    }
419 531
 
420 532
 		    //$putinarchive = true;
421 533
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -433,7 +545,9 @@  discard block
 block discarded – undo
433 545
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
434 546
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
435 547
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
436
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
548
+				if ($globalDebugTimeElapsed) {
549
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
550
+				}
437 551
                         }
438 552
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
439 553
 			$timeelapsed = microtime(true);
@@ -447,7 +561,9 @@  discard block
 block discarded – undo
447 561
 				$Translation->db = null;
448 562
 			    }
449 563
 			    $Spotter->db = null;
450
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
564
+			    if ($globalDebugTimeElapsed) {
565
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
566
+			    }
451 567
                     	}
452 568
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
453 569
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -456,9 +572,13 @@  discard block
 block discarded – undo
456 572
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
457 573
 		    	    }
458 574
 			}
459
-			if (!isset($globalFork)) $globalFork = TRUE;
575
+			if (!isset($globalFork)) {
576
+				$globalFork = TRUE;
577
+			}
460 578
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
461
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
579
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
580
+					$this->get_Schedule($id,trim($line['ident']));
581
+				}
462 582
 			}
463 583
 		    }
464 584
 		}
@@ -474,8 +594,12 @@  discard block
 block discarded – undo
474 594
 		    // use datetime
475 595
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
476 596
 			$speed = $speed*3.6;
477
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
478
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
597
+			if ($speed < 1000) {
598
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
599
+			}
600
+  			if ($globalDebug) {
601
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
602
+  			}
479 603
 		    }
480 604
 		}
481 605
 
@@ -483,11 +607,16 @@  discard block
 block discarded – undo
483 607
 
484 608
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) {
485 609
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
486
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
610
+	    	    	if ($globalDebug) {
611
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
612
+	    	    	}
487 613
 	    	    	return false;
488 614
 	    	    }
489
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
490
-	    	    else unset($timediff);
615
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
616
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
617
+	    	    } else {
618
+	    	    	unset($timediff);
619
+	    	    }
491 620
 	    	    if ($this->tmd > 5 || isset($line['format_source']) && $line['format_source'] == 'airwhere' && ((!isset($this->all_flights[$id]['latitude']) || !isset($this->all_flights[$id]['longitude'])) || (isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $this->all_flights[$id]['latitude'] != $line['latitude'] && $this->all_flights[$id]['longitude'] != $line['longitude'])) || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
492 621
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
493 622
 			    if ((isset($timediff) && $timediff > $globalAircraftMaxUpdate) || isset($line['format_source']) && $line['format_source'] == 'airwhere' || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -496,16 +625,25 @@  discard block
 block discarded – undo
496 625
 				$this->all_flights[$id]['putinarchive'] = true;
497 626
 				$this->tmd = 0;
498 627
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
499
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
628
+				    if ($globalDebug) {
629
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
630
+				    }
500 631
 				    $timeelapsed = microtime(true);
501 632
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
502 633
 					$Spotter = new Spotter($this->db);
503 634
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
504
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
505
-					else $this->all_flights[$id]['over_country'] = '';
635
+					if (!empty($all_country)) {
636
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
637
+					} else {
638
+						$this->all_flights[$id]['over_country'] = '';
639
+					}
506 640
 					$Spotter->db = null;
507
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
508
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
641
+					if ($globalDebugTimeElapsed) {
642
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
643
+					}
644
+					if ($globalDebug) {
645
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
646
+					}
509 647
 				    }
510 648
 				}
511 649
 			    }
@@ -513,7 +651,9 @@  discard block
 block discarded – undo
513 651
 
514 652
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
515 653
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
516
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
654
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
655
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
656
+				}
517 657
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || $this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001) {
518 658
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
519 659
 				    $dataFound = true;
@@ -535,9 +675,13 @@  discard block
 block discarded – undo
535 675
 			    */
536 676
 			}
537 677
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
538
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
678
+			    if ($line['longitude'] > 180) {
679
+			    	$line['longitude'] = $line['longitude'] - 360;
680
+			    }
539 681
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
540
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
682
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
683
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
684
+				}
541 685
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || $this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001) {
542 686
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
543 687
 				    $dataFound = true;
@@ -568,7 +712,9 @@  discard block
 block discarded – undo
568 712
 		    }
569 713
 		}
570 714
 		if (isset($line['last_update']) && $line['last_update'] != '') {
571
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
715
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
716
+		    	$dataFound = true;
717
+		    }
572 718
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
573 719
 		}
574 720
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -590,53 +736,79 @@  discard block
 block discarded – undo
590 736
 			// Here we force archive of flight because after ground it's a new one (or should be)
591 737
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
592 738
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
593
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
594
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
595
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
739
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
740
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
741
+			} elseif (isset($line['id'])) {
742
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
743
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
744
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
745
+			}
746
+		    }
747
+		    if ($line['ground'] != 1) {
748
+		    	$line['ground'] = 0;
596 749
 		    }
597
-		    if ($line['ground'] != 1) $line['ground'] = 0;
598 750
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
599 751
 		    //$dataFound = true;
600 752
 		}
601 753
 		if (isset($line['squawk']) && $line['squawk'] != '') {
602 754
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
603
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
755
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
756
+			    	$this->all_flights[$id]['putinarchive'] = true;
757
+			    }
604 758
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
605 759
 			    $highlight = '';
606
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
607
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
608
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
760
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
761
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
762
+			    }
763
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
764
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
765
+			    }
766
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
767
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
768
+			    }
609 769
 			    if ($highlight != '') {
610 770
 				$timeelapsed = microtime(true);
611 771
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
612 772
 				    $Spotter = new Spotter($this->db);
613 773
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
614 774
 				    $Spotter->db = null;
615
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
775
+				    if ($globalDebugTimeElapsed) {
776
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
777
+				    }
616 778
 				}
617 779
 				//$putinarchive = true;
618 780
 				//$highlight = '';
619 781
 			    }
620 782
 			    
621
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
783
+		    } else {
784
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
785
+		    }
622 786
 		    //$dataFound = true;
623 787
 		}
624 788
 
625 789
 		if (isset($line['altitude']) && $line['altitude'] != '') {
626 790
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
627
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
791
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
792
+				$this->all_flights[$id]['putinarchive'] = true;
793
+			}
628 794
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
629 795
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
630 796
 			//$dataFound = true;
631 797
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
632 798
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
633 799
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
634
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
800
+				if ($globalDebug) {
801
+					echo '--- Reset because of altitude'."\n";
802
+				}
635 803
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
636 804
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
637
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
638
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
639
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
805
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
806
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
807
+				} elseif (isset($line['id'])) {
808
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
809
+				} elseif (isset($this->all_flights[$id]['ident'])) {
810
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
811
+				}
640 812
 			}
641 813
 		    }
642 814
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -647,22 +819,32 @@  discard block
 block discarded – undo
647 819
 		}
648 820
 		
649 821
 		if (isset($line['heading']) && $line['heading'] != '') {
650
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
822
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
823
+		    	$this->all_flights[$id]['putinarchive'] = true;
824
+		    }
651 825
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
652 826
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
653 827
 		    //$dataFound = true;
654 828
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
655 829
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
656 830
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
657
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
658
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
831
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
832
+		    	$this->all_flights[$id]['putinarchive'] = true;
833
+		    }
834
+  		    if ($globalDebug) {
835
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
836
+  		    }
659 837
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
660 838
   		    // If not enough messages and ACARS set heading to 0
661 839
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
662 840
   		}
663
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
664
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
665
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
841
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
842
+			$dataFound = false;
843
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
844
+			$dataFound = false;
845
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) {
846
+			$dataFound = false;
847
+		}
666 848
 
667 849
 //		print_r($this->all_flights[$id]);
668 850
 		//gets the callsign from the last hour
@@ -679,23 +861,38 @@  discard block
 block discarded – undo
679 861
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
680 862
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
681 863
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
682
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
864
+				    if ($globalDebug) {
865
+				    	echo "Check if aircraft is already in DB...";
866
+				    }
683 867
 				    $timeelapsed = microtime(true);
684 868
 				    $SpotterLive = new SpotterLive($this->db);
685 869
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
686 870
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
687
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
871
+					if ($globalDebugTimeElapsed) {
872
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
873
+					}
688 874
 				    } elseif (isset($line['id'])) {
689 875
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
690
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
876
+					if ($globalDebugTimeElapsed) {
877
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
878
+					}
691 879
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
692 880
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
693
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
694
-				    } else $recent_ident = '';
881
+					if ($globalDebugTimeElapsed) {
882
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
883
+					}
884
+				    } else {
885
+				    	$recent_ident = '';
886
+				    }
695 887
 				    $SpotterLive->db=null;
696
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
697
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
698
-				} else $recent_ident = '';
888
+				    if ($globalDebug && $recent_ident == '') {
889
+				    	echo " Not in DB.\n";
890
+				    } elseif ($globalDebug && $recent_ident != '') {
891
+				    	echo " Already in DB.\n";
892
+				    }
893
+				} else {
894
+					$recent_ident = '';
895
+				}
699 896
 			    } else {
700 897
 				$recent_ident = '';
701 898
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -703,7 +900,9 @@  discard block
 block discarded – undo
703 900
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
704 901
 			    if($recent_ident == "")
705 902
 			    {
706
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
903
+				if ($globalDebug) {
904
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
905
+				}
707 906
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
708 907
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
709 908
 				//adds the spotter data for the archive
@@ -747,31 +946,49 @@  discard block
 block discarded – undo
747 946
 				
748 947
 				if (!$ignoreImport) {
749 948
 				    $highlight = '';
750
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
751
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
752
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
753
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
949
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
950
+				    	$highlight = 'Squawk 7500 : Hijack';
951
+				    }
952
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
953
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
954
+				    }
955
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
956
+				    	$highlight = 'Squawk 7700 : Emergency';
957
+				    }
958
+				    if (!isset($this->all_flights[$id]['id'])) {
959
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
960
+				    }
754 961
 				    $timeelapsed = microtime(true);
755 962
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
756 963
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
757 964
 					    $Spotter = new Spotter($this->db);
758 965
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
759 966
 					    $Spotter->db = null;
760
-					    if ($globalDebug && isset($result)) echo $result."\n";
967
+					    if ($globalDebug && isset($result)) {
968
+					    	echo $result."\n";
969
+					    }
761 970
 					}
762 971
 				    }
763
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
972
+				    if ($globalDebugTimeElapsed) {
973
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
974
+				    }
764 975
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
765 976
 
766 977
 				    // Add source stat in DB
767 978
 				    $Stats = new Stats($this->db);
768 979
 				    if (!empty($this->stats)) {
769
-					if ($globalDebug) echo 'Add source stats : ';
980
+					if ($globalDebug) {
981
+						echo 'Add source stats : ';
982
+					}
770 983
 				        foreach($this->stats as $date => $data) {
771 984
 					    foreach($data as $source => $sourced) {
772 985
 					        //print_r($sourced);
773
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
774
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
986
+				    	        if (isset($sourced['polar'])) {
987
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
988
+				    	        }
989
+				    	        if (isset($sourced['hist'])) {
990
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
991
+				    	        }
775 992
 				    		if (isset($sourced['msg'])) {
776 993
 				    		    if (time() - $sourced['msg']['date'] > 10) {
777 994
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -784,13 +1001,17 @@  discard block
 block discarded – undo
784 1001
 			    			unset($this->stats[$date]);
785 1002
 			    		    }
786 1003
 				    	}
787
-				    	if ($globalDebug) echo 'Done'."\n";
1004
+				    	if ($globalDebug) {
1005
+				    		echo 'Done'."\n";
1006
+				    	}
788 1007
 
789 1008
 				    }
790 1009
 				    $Stats->db = null;
791 1010
 				    }
792 1011
 				    $this->del();
793
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1012
+				} elseif ($globalDebug) {
1013
+					echo 'Ignore data'."\n";
1014
+				}
794 1015
 				//$ignoreImport = false;
795 1016
 				$this->all_flights[$id]['addedSpotter'] = 1;
796 1017
 				//print_r($this->all_flights[$id]);
@@ -807,7 +1028,9 @@  discard block
 block discarded – undo
807 1028
 			*/
808 1029
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
809 1030
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
810
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1031
+				    if ($globalDebug) {
1032
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1033
+				    }
811 1034
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
812 1035
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
813 1036
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -816,7 +1039,9 @@  discard block
 block discarded – undo
816 1039
 					    $SpotterLive->db=null;
817 1040
 					}
818 1041
 				    }
819
-				    if ($globalDebug) echo " Done\n";
1042
+				    if ($globalDebug) {
1043
+				    	echo " Done\n";
1044
+				    }
820 1045
 				    $this->last_delete = time();
821 1046
 				}
822 1047
 			    } else {
@@ -843,11 +1068,17 @@  discard block
 block discarded – undo
843 1068
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
844 1069
 		    if ($globalDebug) {
845 1070
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
846
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
847
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1071
+				if (isset($this->all_flights[$id]['source_name'])) {
1072
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1073
+				} else {
1074
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1075
+				}
848 1076
 			} else {
849
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
850
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1077
+				if (isset($this->all_flights[$id]['source_name'])) {
1078
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1079
+				} else {
1080
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1081
+				}
851 1082
 			}
852 1083
 		    }
853 1084
 		    $ignoreImport = false;
@@ -893,22 +1124,30 @@  discard block
 block discarded – undo
893 1124
 
894 1125
 		    if (!$ignoreImport) {
895 1126
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
896
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1127
+				if (!isset($this->all_flights[$id]['id'])) {
1128
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1129
+				}
897 1130
 				$timeelapsed = microtime(true);
898 1131
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
899 1132
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
900
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1133
+					if ($globalDebug) {
1134
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1135
+					}
901 1136
 					$SpotterLive = new SpotterLive($this->db);
902 1137
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
903 1138
 					$SpotterLive->db = null;
904
-					if ($globalDebug) echo $result."\n";
1139
+					if ($globalDebug) {
1140
+						echo $result."\n";
1141
+					}
905 1142
 				    }
906 1143
 				}
907 1144
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
908 1145
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
909 1146
 				}
910 1147
 				$this->all_flights[$id]['putinarchive'] = false;
911
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1148
+				if ($globalDebugTimeElapsed) {
1149
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1150
+				}
912 1151
 
913 1152
 				// Put statistics in $this->stats variable
914 1153
 				//if ($line['format_source'] != 'aprs') {
@@ -916,7 +1155,9 @@  discard block
 block discarded – undo
916 1155
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
917 1156
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
918 1157
 					$source = $this->all_flights[$id]['source_name'];
919
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1158
+					if ($source == '') {
1159
+						$source = $this->all_flights[$id]['format_source'];
1160
+					}
920 1161
 					if (!isset($this->source_location[$source])) {
921 1162
 						$Location = new Source();
922 1163
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -937,7 +1178,9 @@  discard block
 block discarded – undo
937 1178
 					$stats_heading = round($stats_heading/22.5);
938 1179
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
939 1180
 					$current_date = date('Y-m-d');
940
-					if ($stats_heading == 16) $stats_heading = 0;
1181
+					if ($stats_heading == 16) {
1182
+						$stats_heading = 0;
1183
+					}
941 1184
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
942 1185
 						for ($i=0;$i<=15;$i++) {
943 1186
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -955,7 +1198,9 @@  discard block
 block discarded – undo
955 1198
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
956 1199
 						    end($this->stats[$current_date][$source]['hist']);
957 1200
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
958
-						} else $mini = 0;
1201
+						} else {
1202
+							$mini = 0;
1203
+						}
959 1204
 						for ($i=$mini;$i<=$distance;$i+=10) {
960 1205
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
961 1206
 						}
@@ -967,19 +1212,27 @@  discard block
 block discarded – undo
967 1212
 				}
968 1213
 
969 1214
 				$this->all_flights[$id]['lastupdate'] = time();
970
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1215
+				if ($this->all_flights[$id]['putinarchive']) {
1216
+					$send = true;
1217
+				}
971 1218
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
972
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1219
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1220
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1221
+			}
973 1222
 			//$this->del();
974 1223
 			
975 1224
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
976 1225
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
977
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1226
+				if ($globalDebug) {
1227
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1228
+				}
978 1229
 				$SpotterLive = new SpotterLive($this->db);
979 1230
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
980 1231
 				$SpotterLive->db = null;
981 1232
 				//SpotterLive->deleteLiveSpotterData();
982
-				if ($globalDebug) echo " Done\n";
1233
+				if ($globalDebug) {
1234
+					echo " Done\n";
1235
+				}
983 1236
 				$this->last_delete_hourly = time();
984 1237
 			    } else {
985 1238
 				$this->del();
@@ -991,7 +1244,9 @@  discard block
 block discarded – undo
991 1244
 		    //$ignoreImport = false;
992 1245
 		}
993 1246
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
994
-		if ($send) return $this->all_flights[$id];
1247
+		if ($send) {
1248
+			return $this->all_flights[$id];
1249
+		}
995 1250
 	    }
996 1251
 	}
997 1252
     }
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +83 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -118,8 +120,11 @@  discard block
 block discarded – undo
118 120
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119 121
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
120 122
 		}
121
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123
+		if ($filter_query_where == '' && $where) {
124
+			$filter_query_where = ' WHERE';
125
+		} elseif ($filter_query_where != '' && $and) {
126
+			$filter_query_where .= ' AND';
127
+		}
123 128
 		if ($filter_query_where != '') {
124 129
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
125 130
 		}
@@ -160,9 +165,13 @@  discard block
 block discarded – undo
160 165
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
161 166
 			}
162 167
 		}
163
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
168
+		if ($orderby_query == '') {
169
+			$orderby_query = ' ORDER BY date DESC';
170
+		}
164 171
 
165
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
172
+		if (!isset($globalLiveInterval)) {
173
+			$globalLiveInterval = '200';
174
+		}
166 175
 		if ($globalDBdriver == 'mysql') {
167 176
 			//$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";
168 177
 			$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;
@@ -185,7 +194,9 @@  discard block
 block discarded – undo
185 194
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
186 195
 		date_default_timezone_set('UTC');
187 196
 		$filter_query = $this->getFilter($filter,true,true);
188
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
197
+		if (!isset($globalLiveInterval)) {
198
+			$globalLiveInterval = '200';
199
+		}
189 200
 		if ($globalDBdriver == 'mysql') {
190 201
 			if (isset($globalArchive) && $globalArchive === TRUE) {
191 202
 				$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 
@@ -228,7 +239,9 @@  discard block
 block discarded – undo
228 239
 
229 240
 		$filter_query = $this->getFilter($filter,true,true);
230 241
 
231
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
242
+		if (!isset($globalLiveInterval)) {
243
+			$globalLiveInterval = '200';
244
+		}
232 245
 		if ($globalDBdriver == 'mysql') {
233 246
 			if (isset($globalArchive) && $globalArchive === TRUE) {
234 247
 				$query  = '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 
@@ -274,7 +287,9 @@  discard block
 block discarded – undo
274 287
 		global $globalDBdriver, $globalLiveInterval;
275 288
 		$filter_query = $this->getFilter($filter,true,true);
276 289
 
277
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
290
+		if (!isset($globalLiveInterval)) {
291
+			$globalLiveInterval = '200';
292
+		}
278 293
 		if ($globalDBdriver == 'mysql') {
279 294
 			//$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;
280 295
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -304,7 +319,9 @@  discard block
 block discarded – undo
304 319
 	{
305 320
 		global $globalDBdriver, $globalLiveInterval;
306 321
 		$Spotter = new Spotter($this->db);
307
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
322
+		if (!isset($globalLiveInterval)) {
323
+			$globalLiveInterval = '200';
324
+		}
308 325
 		$filter_query = $this->getFilter($filter);
309 326
 
310 327
 		if (is_array($coord)) {
@@ -312,7 +329,9 @@  discard block
 block discarded – undo
312 329
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
313 330
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
314 331
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
315
-		} else return array();
332
+		} else {
333
+			return array();
334
+		}
316 335
 		if ($globalDBdriver == 'mysql') {
317 336
 			$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;
318 337
 		} else {
@@ -333,7 +352,9 @@  discard block
 block discarded – undo
333 352
 	{
334 353
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
335 354
 		$Spotter = new Spotter($this->db);
336
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
355
+		if (!isset($globalLiveInterval)) {
356
+			$globalLiveInterval = '200';
357
+		}
337 358
 		$filter_query = $this->getFilter($filter,true,true);
338 359
 
339 360
 		if (is_array($coord)) {
@@ -341,7 +362,9 @@  discard block
 block discarded – undo
341 362
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
342 363
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
343 364
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
344
-		} else return array();
365
+		} else {
366
+			return array();
367
+		}
345 368
 		if ($globalDBdriver == 'mysql') {
346 369
 			if (isset($globalArchive) && $globalArchive === TRUE) {
347 370
 				$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 
@@ -571,11 +594,15 @@  discard block
 block discarded – undo
571 594
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
572 595
 		if ($globalDBdriver == 'mysql') {
573 596
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
574
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
597
+			if ($liveinterval) {
598
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
599
+			}
575 600
 			$query .= ' ORDER BY date';
576 601
 		} else {
577 602
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
578
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
603
+			if ($liveinterval) {
604
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
605
+			}
579 606
 			$query .= ' ORDER BY date';
580 607
 		}
581 608
 
@@ -670,7 +697,9 @@  discard block
 block discarded – undo
670 697
 				$i++;
671 698
 				$j++;
672 699
 				if ($j == 30) {
673
-					if ($globalDebug) echo ".";
700
+					if ($globalDebug) {
701
+						echo ".";
702
+					}
674 703
 				    	try {
675 704
 						
676 705
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -977,7 +1006,9 @@  discard block
 block discarded – undo
977 1006
 			{
978 1007
 				return false;
979 1008
 			}
980
-		} else return '';
1009
+		} else {
1010
+			return '';
1011
+		}
981 1012
 
982 1013
 		if ($longitude != '')
983 1014
 		{
@@ -985,7 +1016,9 @@  discard block
 block discarded – undo
985 1016
 			{
986 1017
 				return false;
987 1018
 			}
988
-		} else return '';
1019
+		} else {
1020
+			return '';
1021
+		}
989 1022
 
990 1023
 		if ($waypoints != '')
991 1024
 		{
@@ -1001,7 +1034,9 @@  discard block
 block discarded – undo
1001 1034
 			{
1002 1035
 				return false;
1003 1036
 			}
1004
-		} else $altitude = 0;
1037
+		} else {
1038
+			$altitude = 0;
1039
+		}
1005 1040
 
1006 1041
 		if ($heading != '')
1007 1042
 		{
@@ -1009,7 +1044,9 @@  discard block
 block discarded – undo
1009 1044
 			{
1010 1045
 				return false;
1011 1046
 			}
1012
-		} else $heading = 0;
1047
+		} else {
1048
+			$heading = 0;
1049
+		}
1013 1050
 
1014 1051
 		if ($groundspeed != '')
1015 1052
 		{
@@ -1017,9 +1054,13 @@  discard block
 block discarded – undo
1017 1054
 			{
1018 1055
 				return false;
1019 1056
 			}
1020
-		} else $groundspeed = 0;
1057
+		} else {
1058
+			$groundspeed = 0;
1059
+		}
1021 1060
 		date_default_timezone_set('UTC');
1022
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1061
+		if ($date == '') {
1062
+			$date = date("Y-m-d H:i:s", time());
1063
+		}
1023 1064
 
1024 1065
         
1025 1066
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1064,14 +1105,24 @@  discard block
 block discarded – undo
1064 1105
 		$arrival_airport_country = '';
1065 1106
 		
1066 1107
             	
1067
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1068
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1069
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1070
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1108
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1109
+            		$squawk = NULL;
1110
+            	}
1111
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1112
+            		$verticalrate = NULL;
1113
+            	}
1114
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1115
+            		$groundspeed = 0;
1116
+            	}
1117
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1118
+            		$heading = 0;
1119
+            	}
1071 1120
 		
1072 1121
 		$query = '';
1073 1122
 		if ($globalArchive) {
1074
-			if ($globalDebug) echo '-- Delete previous data -- ';
1123
+			if ($globalDebug) {
1124
+				echo '-- Delete previous data -- ';
1125
+			}
1075 1126
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1076 1127
 		}
1077 1128
 
@@ -1088,10 +1139,14 @@  discard block
 block discarded – undo
1088 1139
 			return "error : ".$e->getMessage();
1089 1140
 		}
1090 1141
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1091
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1142
+		    if ($globalDebug) {
1143
+		    	echo '(Add to SBS archive : ';
1144
+		    }
1092 1145
 		    $SpotterArchive = new SpotterArchive($this->db);
1093 1146
 		    $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);
1094
-		    if ($globalDebug) echo $result.')';
1147
+		    if ($globalDebug) {
1148
+		    	echo $result.')';
1149
+		    }
1095 1150
 		}
1096 1151
 		return "success";
1097 1152
 
Please login to merge, or discard this patch.
aircraft-data.php 1 patch
Braces   +52 added lines, -20 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 {
56 56
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
57 57
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
58
-	} else $image = $spotter_item['image_thumbnail'];
58
+	} else {
59
+		$image = $spotter_item['image_thumbnail'];
60
+	}
59 61
 
60 62
 }
61 63
 /* else {
@@ -68,8 +70,12 @@  discard block
 block discarded – undo
68 70
 }
69 71
 print '<div class="right">';
70 72
 print '<div class="callsign-details">';
71
-if ($spotter_item['ident'] != 'Not Available') print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
72
-if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
73
+if ($spotter_item['ident'] != 'Not Available') {
74
+	print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
75
+}
76
+if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') {
77
+	print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
78
+}
73 79
 print '</div>';
74 80
 if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') {
75 81
 	print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
@@ -101,21 +107,36 @@  discard block
 block discarded – undo
101 107
 print '</div>';
102 108
 print '<div id="aircraft">';
103 109
 print '<span>'._("Aircraft").'</span>';
104
-if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
105
-if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
106
-if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
107
-else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
110
+if (isset($spotter_item['aircraft_wiki'])) {
111
+	print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
112
+}
113
+if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') {
114
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
115
+}
116
+if (isset($spotter_item['aircraft_type'])) {
117
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
118
+} else {
119
+	print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
120
+}
108 121
 print '</div>';
109 122
 print '<div id ="altitude"><span>'._("Altitude").'</span>';
110 123
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
111
-	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
112
-	else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
113
-} else {
114
-	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
115
-	else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
116
-}
124
+	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
125
+		print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
126
+	} else {
127
+		print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
128
+	}
129
+	} else {
130
+	if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
131
+		print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
132
+	} else {
133
+		print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
134
+	}
135
+	}
117 136
 print '</div>';
118
-if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
137
+if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
138
+	print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
139
+}
119 140
 print '<div id="speed"><span>'._("Speed").'</span>';
120 141
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
121 142
 	print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -129,8 +150,11 @@  discard block
 block discarded – undo
129 150
 print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
130 151
 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
131 152
 	print '<div id="pilot"><span>'._("Pilot").'</span>';
132
-	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
133
-	else print $spotter_item['pilot_name'];
153
+	if (isset($spotter_item['pilot_id'])) {
154
+		print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
155
+	} else {
156
+		print $spotter_item['pilot_name'];
157
+	}
134 158
 	print '</div>';
135 159
 }
136 160
 
@@ -158,10 +182,18 @@  discard block
 block discarded – undo
158 182
 print '</div>';
159 183
 print '</div>';
160 184
 
161
-if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
162
-if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
163
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
164
-if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
185
+if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
186
+	print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
187
+}
188
+if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
189
+	print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
190
+}
191
+if (isset($spotter_item['acars']['message'])) {
192
+	print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
193
+}
194
+if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
195
+	print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
196
+}
165 197
 print '</div>';
166 198
 ?>
167 199
 </div>
168 200
\ No newline at end of file
Please login to merge, or discard this patch.