Completed
Push — master ( f64dc3...06e80e )
by Yannick
10:07
created
table-output.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 				print '<th class="arrival"><span class="nomobile">'._("Going to").'</span><span class="mobile">'._("To").'</span></th>';
265 265
 			}
266 266
 		}
267
-    		if ($type == 'aircraft') {
267
+			if ($type == 'aircraft') {
268 268
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalVAM) && $globalVAM) || (isset($globalphpVMS) && $globalphpVMS)) {
269 269
 				print '<th class="pilot"><span class="nomobile">'._("Pilot name").'</span><span class="mobile">'._("Pilot").'</span></a></th>';
270 270
 			} else {
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
531 531
 		if ($type == 'aircraft') {
532 532
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
533
-			    $spotter_item['squawk'] = '-';
533
+				$spotter_item['squawk'] = '-';
534 534
 			}
535 535
 			if ($spotter_item['image_thumbnail'] != "")
536 536
 			{
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 				print '</td>'."\n";
570 570
 			} else {
571 571
 				print '<td class="aircraft_thumbnail">'."\n";
572
-	       //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
572
+		   //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
573 573
 		//}
574 574
 				if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) {
575 575
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n";
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 
5 5
 require_once(dirname(__FILE__).'/require/class.Common.php');
6 6
 $Common = new Common();
7
-$showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8
-$showDuration = $Common->multiKeyExists($spotter_array,'duration');
7
+$showRouteStop = $Common->multiKeyExists($spotter_array, 'route_stop');
8
+$showDuration = $Common->multiKeyExists($spotter_array, 'duration');
9 9
 
10 10
 if (!isset($type)) $type = 'aircraft';
11 11
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 	print '<th class="more"></th>';
103 103
 	print '</thead>';
104
-} else if (strtolower($current_page) == "upcoming"){
104
+} else if (strtolower($current_page) == "upcoming") {
105 105
 	print '<thead>';
106 106
 	if ($_GET['sort'] == "airline_name_asc")
107 107
 	{
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 	*/
153 153
 	print '</thead>';
154
-} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){
154
+} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
155 155
 	print '<thead>';
156 156
 	print '<th class="aircraft_thumbnail"></th>';
157 157
 	print '<th class="logo">'._("Airline").'</th>';
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	print '</thead>';
189 189
 } else {
190 190
 
191
-	if ($hide_th_links === true){
191
+	if ($hide_th_links === true) {
192 192
 		print '<thead>';
193 193
 		print '<th class="aircraft_thumbnail"></th>';
194 194
 		if ($type == 'aircraft') {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 }
436 436
 
437 437
 print '<tbody>'."\n";
438
-foreach($spotter_array as $spotter_item)
438
+foreach ($spotter_array as $spotter_item)
439 439
 {
440 440
 	if (isset($globalTimezone))
441 441
 	{
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
471 471
 					}
472 472
 					if (isset($spotter_item['airline_name'])) {
473
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
473
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
474 474
 					} else {
475
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
475
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
476 476
 					}
477 477
 				} else {
478 478
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
479
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
479
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
480 480
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
481 481
 					if (isset($spotter_item['airline_name'])) {
482 482
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 			{
496 496
 				print '<td class="aircraft_thumbnail">'."\n";
497 497
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
498
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
498
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
499 499
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
500 500
 				if (isset($spotter_item['airline_name'])) {
501 501
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 			{
514 514
 				print '<td class="aircraft_thumbnail">'."\n";
515 515
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
516
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
516
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
517 517
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
518 518
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
519 519
 				print '</td>'."\n";
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 				print '</td>'."\n";
556 556
 			}
557 557
 		}
558
-	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
558
+	} elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") {
559 559
 		if ($type == 'aircraft') {
560 560
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
561 561
 			    $spotter_item['squawk'] = '-';
@@ -572,17 +572,17 @@  discard block
 block discarded – undo
572 572
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
573 573
 					}
574 574
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
575
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
575
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
576 576
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
577
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
577
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
578 578
 					} elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) {
579
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
579
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
580 580
 					} else {
581
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
581
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
582 582
 					}
583 583
 				} else {
584 584
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
585
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
585
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
586 586
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
587 587
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
588 588
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			{
616 616
 				print '<td class="aircraft_thumbnail">'."\n";
617 617
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
618
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
618
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
619 619
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
620 620
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
621 621
 				print '</td>'."\n";
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			{
630 630
 				print '<td class="aircraft_thumbnail">'."\n";
631 631
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
632
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
632
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
633 633
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
634 634
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
635 635
 				print '</td>'."\n";
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 	}
733 733
 	print '</td>'."\n";
734 734
 	// Aircraft type
735
-	if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){
735
+	if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") {
736 736
 		print '<td class="type">'."\n";
737 737
 		if ($type == 'aircraft') {
738 738
 			if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) {
@@ -782,22 +782,22 @@  discard block
 block discarded – undo
782 782
 			}
783 783
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
784 784
 				if ($spotter_item['departure_airport_time'] > 2460) {
785
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
786
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
785
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
786
+				} else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
787 787
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
788
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
788
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
789 789
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
790 790
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
791 791
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
792 792
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
793
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
793
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
794 794
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
795 795
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
796 796
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
797 797
 				if ($spotter_item['departure_airport_time'] > 2460) {
798
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
798
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
799 799
 				} else {
800
-					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
800
+					$departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
801 801
 				}
802 802
 				print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n";
803 803
 			}
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 						$latitude = $spotter_item['latitude'];
813 813
 						$longitude = $spotter_item['longitude'];
814 814
 					}
815
-					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
815
+					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude);
816 816
 				} else $distance = '';
817 817
 				if ($distance != '') {
818 818
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -855,20 +855,20 @@  discard block
 block discarded – undo
855 855
 			}
856 856
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
857 857
 				if ($spotter_item['arrival_airport_time'] > 2460) {
858
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
858
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
859 859
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
860 860
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
861
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
861
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
862 862
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
863 863
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
864 864
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
865 865
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
866
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
866
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
867 867
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
868 868
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
869 869
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
870 870
 				if ($spotter_item['arrival_airport_time'] > 2460) {
871
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
871
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
872 872
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
873 873
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
874 874
 			}
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 						$latitude = $spotter_item['latitude'];
882 882
 						$longitude = $spotter_item['longitude'];
883 883
 					}
884
-					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
884
+					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude);
885 885
 				} else $distance = '';
886 886
 				if ($distance != '') {
887 887
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -924,19 +924,19 @@  discard block
 block discarded – undo
924 924
 				print '<span class="mobile">-</span>'."\n";
925 925
 			} else {
926 926
 				if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
927
-					print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
928
-					print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
927
+					print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
928
+					print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
929 929
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
930
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
931
-					print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
930
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
931
+					print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
932 932
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
933
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
934
-					print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
933
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
934
+					print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
935 935
 				}
936 936
 			}
937 937
 			print '</td>'."\n";
938 938
 		}
939
-		if(strtolower($current_page) != "upcoming"){
939
+		if (strtolower($current_page) != "upcoming") {
940 940
 			if ($type == 'aircraft') {
941 941
 				if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
942 942
 					print '<td class="pilot">'."\n";
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 		
973 973
 		if ($showRouteStop) {
974 974
 		// Route stop
975
-			if(strtolower($current_page) != "upcoming"){
975
+			if (strtolower($current_page) != "upcoming") {
976 976
 				print '<td class="route_stop">'."\n";
977 977
 				if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') {
978 978
 					print '<span class="nomobile">-</span>'."\n";
@@ -991,11 +991,11 @@  discard block
 block discarded – undo
991 991
 		}
992 992
 		if ($showDuration) {
993 993
 		// Duration
994
-			if(strtolower($current_page) != "upcoming"){
994
+			if (strtolower($current_page) != "upcoming") {
995 995
 				print '<td class="duration">'."\n";
996 996
 				if (isset($spotter_item['duration'])) {
997
-					print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
998
-					print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
997
+					print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
998
+					print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
999 999
 				} else {
1000 1000
 					print '<span class="nomobile">-</span>'."\n";
1001 1001
 					print '<span class="mobile">-</span>'."\n";
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
1009 1009
 		if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') {
1010 1010
 			print '<td class="message"><p>'."\n";
1011
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1011
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1012 1012
 			print '</p><p class="decode">';
1013 1013
 			$decode_array = json_decode($spotter_item['decode']);
1014 1014
 			foreach ($decode_array as $key => $value) {
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 			print '</td>'."\n";
1019 1019
 		} else {
1020 1020
 			print '<td class="message">'."\n";
1021
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1021
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1022 1022
 			print '</td>'."\n";
1023 1023
 		}
1024 1024
 	}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 		print '</td>'."\n";
1045 1045
 		print '<td class="message">'."\n";
1046
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1046
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1047 1047
 		print '</td>'."\n";
1048 1048
 	}
1049 1049
 	if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") {
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 		print '</td>'."\n";
1070 1070
 		*/
1071 1071
 		print '<td class="message">'."\n";
1072
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1072
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1073 1073
 		print '</td>'."\n";
1074 1074
 	}
1075 1075
 
Please login to merge, or discard this patch.
Braces   +63 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8 8
 $showDuration = $Common->multiKeyExists($spotter_array,'duration');
9 9
 
10
-if (!isset($type)) $type = 'aircraft';
10
+if (!isset($type)) {
11
+	$type = 'aircraft';
12
+}
11 13
 
12 14
 if (!isset($_GET['sort'])) 
13 15
 {
@@ -440,7 +442,9 @@  discard block
 block discarded – undo
440 442
 	if (isset($globalTimezone))
441 443
 	{
442 444
 		date_default_timezone_set($globalTimezone);
443
-	} else date_default_timezone_set('UTC');
445
+	} else {
446
+		date_default_timezone_set('UTC');
447
+	}
444 448
 	if ($showSpecial === true)
445 449
 	{
446 450
 		print '<tr class="special">'."\n";
@@ -455,7 +459,9 @@  discard block
 block discarded – undo
455 459
 			print '<tr class="active">';
456 460
 		} elseif (isset($spotter_item['spotted_registration'])) {
457 461
 			print '<tr class="info">';
458
-		} else print '<tr>';
462
+		} else {
463
+			print '<tr>';
464
+		}
459 465
 	}
460 466
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") {
461 467
 		if ($type == 'aircraft') {
@@ -463,8 +469,9 @@  discard block
 block discarded – undo
463 469
 			{
464 470
 				print '<td class="aircraft_thumbnail">'."\n";
465 471
 				if ($spotter_item['image_source'] == 'planespotters') {
466
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
467
-					else {
472
+					if ($spotter_item['image_source_website'] != '') {
473
+						$image_src = $spotter_item['image_source_website'];
474
+					} else {
468 475
 						$planespotter_url_array = explode("_", $spotter_item['image']);
469 476
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
470 477
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -477,7 +484,9 @@  discard block
 block discarded – undo
477 484
 				} else {
478 485
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
479 486
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
480
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
487
+					} else {
488
+						$image_thumbnail = $spotter_item['image_thumbnail'];
489
+					}
481 490
 					if (isset($spotter_item['airline_name'])) {
482 491
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
483 492
 					} else {
@@ -496,7 +505,9 @@  discard block
 block discarded – undo
496 505
 				print '<td class="aircraft_thumbnail">'."\n";
497 506
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
498 507
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
499
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
508
+				} else {
509
+					$image_thumbnail = $spotter_item['image_thumbnail'];
510
+				}
500 511
 				if (isset($spotter_item['airline_name'])) {
501 512
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
502 513
 				} else {
@@ -514,7 +525,9 @@  discard block
 block discarded – undo
514 525
 				print '<td class="aircraft_thumbnail">'."\n";
515 526
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
516 527
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
517
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
528
+				} else {
529
+					$image_thumbnail = $spotter_item['image_thumbnail'];
530
+				}
518 531
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
519 532
 				print '</td>'."\n";
520 533
 			} else {
@@ -565,8 +578,9 @@  discard block
 block discarded – undo
565 578
 				print '<td class="aircraft_thumbnail">'."\n";
566 579
 				//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
567 580
 				if ($spotter_item['image_source'] == 'planespotters') {
568
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
569
-					else {
581
+					if ($spotter_item['image_source_website'] != '') {
582
+						$image_src = $spotter_item['image_source_website'];
583
+					} else {
570 584
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
571 585
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
572 586
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -583,7 +597,9 @@  discard block
 block discarded – undo
583 597
 				} else {
584 598
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
585 599
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
586
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
600
+					} else {
601
+						$image_thumbnail = $spotter_item['image_thumbnail'];
602
+					}
587 603
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
588 604
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
589 605
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -616,7 +632,9 @@  discard block
 block discarded – undo
616 632
 				print '<td class="aircraft_thumbnail">'."\n";
617 633
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
618 634
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
619
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
635
+				} else {
636
+					$image_thumbnail = $spotter_item['image_thumbnail'];
637
+				}
620 638
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
621 639
 				print '</td>'."\n";
622 640
 			} else {
@@ -630,7 +648,9 @@  discard block
 block discarded – undo
630 648
 				print '<td class="aircraft_thumbnail">'."\n";
631 649
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
632 650
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
633
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
651
+				} else {
652
+					$image_thumbnail = $spotter_item['image_thumbnail'];
653
+				}
634 654
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
635 655
 				print '</td>'."\n";
636 656
 			} else {
@@ -783,15 +803,21 @@  discard block
 block discarded – undo
783 803
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
784 804
 				if ($spotter_item['departure_airport_time'] > 2460) {
785 805
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
786
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
806
+				} else {
807
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
808
+				}
787 809
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
788 810
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
789
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
811
+				} else {
812
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
813
+				}
790 814
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
791 815
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
792 816
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
793 817
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
794
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
818
+				} else {
819
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
820
+				}
795 821
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
796 822
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
797 823
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -813,7 +839,9 @@  discard block
 block discarded – undo
813 839
 						$longitude = $spotter_item['longitude'];
814 840
 					}
815 841
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
816
-				} else $distance = '';
842
+				} else {
843
+					$distance = '';
844
+				}
817 845
 				if ($distance != '') {
818 846
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
819 847
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -840,7 +868,9 @@  discard block
 block discarded – undo
840 868
 			} else {
841 869
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
842 870
 					print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
843
-					if (!isset($Spotter)) $Spotter = new Spotter();
871
+					if (!isset($Spotter)) {
872
+						$Spotter = new Spotter();
873
+					}
844 874
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
845 875
 					print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
846 876
 					print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -856,20 +886,28 @@  discard block
 block discarded – undo
856 886
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
857 887
 				if ($spotter_item['arrival_airport_time'] > 2460) {
858 888
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
859
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
889
+				} else {
890
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
891
+				}
860 892
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
861 893
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
862
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
894
+				} else {
895
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
896
+				}
863 897
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
864 898
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
865 899
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
866 900
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
867
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
901
+				} else {
902
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
903
+				}
868 904
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
869 905
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
870 906
 				if ($spotter_item['arrival_airport_time'] > 2460) {
871 907
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
872
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
908
+				} else {
909
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
910
+				}
873 911
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
874 912
 			}
875 913
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -882,7 +920,9 @@  discard block
 block discarded – undo
882 920
 						$longitude = $spotter_item['longitude'];
883 921
 					}
884 922
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
885
-				} else $distance = '';
923
+				} else {
924
+					$distance = '';
925
+				}
886 926
 				if ($distance != '') {
887 927
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
888 928
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
currently.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,21 +4,21 @@  discard block
 block discarded – undo
4 4
 
5 5
 $type = '';
6 6
 if (isset($_GET['marine'])) {
7
-	require_once('require/class.Marine.php');;
7
+	require_once('require/class.Marine.php'); ;
8 8
 	require_once('require/class.MarineLive.php');
9
-	$MarineLive=new MarineLive();
9
+	$MarineLive = new MarineLive();
10 10
 	$type = 'marine';
11 11
 	$page_url = $globalURL.'/marine/currently';
12 12
 } elseif (isset($_GET['tracker'])) {
13
-	require_once('require/class.Tracker.php');;
13
+	require_once('require/class.Tracker.php'); ;
14 14
 	require_once('require/class.TrackerLive.php');
15
-	$TrackerLive=new TrackerLive();
15
+	$TrackerLive = new TrackerLive();
16 16
 	$type = 'tracker';
17 17
 	$page_url = $globalURL.'/tracker/currently';
18 18
 } else {
19
-	require_once('require/class.Spotter.php');;
19
+	require_once('require/class.Spotter.php'); ;
20 20
 	require_once('require/class.SpotterLive.php');
21
-	$SpotterLive=new SpotterLive();
21
+	$SpotterLive = new SpotterLive();
22 22
 	$type = 'aircraft';
23 23
 	$page_url = $globalURL.'/currently';
24 24
 }
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 $title = "Current Activity";
27 27
 require_once('header.php');
28 28
 //calculuation for the pagination
29
-if(!isset($_GET['limit']))
29
+if (!isset($_GET['limit']))
30 30
 {
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55 55
 elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
56 56
 
57
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
57
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
58 58
 if ($sort != '') {
59 59
 	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60 60
 	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -50,20 +50,32 @@  discard block
 block discarded – undo
50 50
 print '</div>';
51 51
 
52 52
 print '<div class="table column">';
53
-if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
54
-elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
53
+if ($type == 'aircraft') {
54
+	print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
55
+} elseif ($type == 'marine') {
56
+	print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
57
+} elseif ($type == 'tracker') {
58
+	print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
59
+}
56 60
 
57 61
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
58 62
 if ($sort != '') {
59
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
61
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
62
-} else {
63
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
64
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
65
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
66
-}
63
+	if ($type == 'aircraft') {
64
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
65
+	} elseif ($type == 'marine') {
66
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
67
+	} elseif ($type == 'tracker') {
68
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
69
+	}
70
+	} else {
71
+	if ($type == 'aircraft') {
72
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
73
+	} elseif ($type == 'marine') {
74
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
75
+	} elseif ($type == 'tracker') {
76
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
77
+	}
78
+	}
67 79
 
68 80
 if (!empty($spotter_array))
69 81
 {
Please login to merge, or discard this patch.
date.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 $type = 'aircraft';
4 4
 if (isset($_GET['marine'])) $type = 'marine';
5 5
 elseif (isset($_GET['tracker'])) $type = 'tracker';
6
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
6
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
7 7
 if ($date == '') $date = date('Y-m-d');
8 8
 if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9 9
 elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $type = 'aircraft';
4
-if (isset($_GET['marine'])) $type = 'marine';
5
-elseif (isset($_GET['tracker'])) $type = 'tracker';
4
+if (isset($_GET['marine'])) {
5
+	$type = 'marine';
6
+} elseif (isset($_GET['tracker'])) {
7
+	$type = 'tracker';
8
+}
6 9
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
7
-if ($date == '') $date = date('Y-m-d');
8
-if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9
-elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
10
-else header('Location: '.$globalURL.'/date/'.$date);
10
+if ($date == '') {
11
+	$date = date('Y-m-d');
12
+}
13
+if ($type == 'marine') {
14
+	header('Location: '.$globalURL.'/marine/date/'.$date);
15
+} elseif ($type == 'tracker') {
16
+	header('Location: '.$globalURL.'/tracker/date/'.$date);
17
+} else {
18
+	header('Location: '.$globalURL.'/date/'.$date);
19
+}
11 20
 ?>
12 21
\ No newline at end of file
Please login to merge, or discard this patch.
date-detailed.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,34 +2,34 @@  discard block
 block discarded – undo
2 2
 require_once('require/class.Connection.php');
3 3
 require_once('require/class.Language.php');
4 4
 $type = '';
5
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
5
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
6 6
 if (isset($_GET['marine'])) {
7
-	require_once('require/class.Marine.php');;
7
+	require_once('require/class.Marine.php'); ;
8 8
 	$Marine = new Marine();
9 9
 	$type = 'marine';
10 10
 	$page_url = $globalURL.'/marine/date/'.$date;
11 11
 } elseif (isset($_GET['tracker'])) {
12
-	require_once('require/class.Tracker.php');;
12
+	require_once('require/class.Tracker.php'); ;
13 13
 	$Tracker = new Tracker();
14 14
 	$type = 'tracker';
15 15
 	$page_url = $globalURL.'/tracker/date/'.$date;
16 16
 } else {
17
-	require_once('require/class.Spotter.php');;
17
+	require_once('require/class.Spotter.php'); ;
18 18
 	$Spotter = new Spotter();
19 19
 	$type = 'aircraft';
20 20
 	$page_url = $globalURL.'/date/'.$date;
21 21
 }
22 22
 
23
-if (!isset($_GET['date'])){
23
+if (!isset($_GET['date'])) {
24 24
 	header('Location: '.$globalURL.'');
25 25
 } else {
26 26
 	//calculuation for the pagination
27
-	if(!isset($_GET['limit']))
27
+	if (!isset($_GET['limit']))
28 28
 	{
29 29
 		$limit_start = 0;
30 30
 		$limit_end = 25;
31 31
 		$absolute_difference = 25;
32
-	}  else {
32
+	} else {
33 33
 		$limit_explode = explode(",", $_GET['limit']);
34 34
 		$limit_start = $limit_explode[0];
35 35
 		$limit_end = $limit_explode[1];
@@ -43,24 +43,24 @@  discard block
 block discarded – undo
43 43
 	$limit_previous_1 = $limit_start - $absolute_difference;
44 44
 	$limit_previous_2 = $limit_end - $absolute_difference;
45 45
 	
46
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
46
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
47 47
 	if ($sort != '') 
48 48
 	{
49
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
50
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
49
+		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference, $sort);
50
+		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference, $sort);
51
+		else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference, $sort);
52 52
 	} else {
53
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
54
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
55
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
53
+		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference);
54
+		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference);
55
+		else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference);
56 56
 	}
57 57
 	
58 58
 	if (!empty($spotter_array))
59 59
 	{
60 60
 		date_default_timezone_set($globalTimezone);
61
-		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
-		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
-		else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
61
+		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
+		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
+		else $title = sprintf(_("Detailed View for flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
64 64
 
65 65
 		require_once('header.php');
66 66
 		print '<div class="select-item">';
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 		print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
79 79
 		print '<br />';
80 80
 		print '<div class="info column">';
81
-		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
-		else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
81
+		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
+		else print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
83 83
 		print '</div>';
84 84
 
85 85
 		if ($type == 'aircraft') include('date-sub-menu.php');
86 86
 		print '<div class="table column">';
87
-		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
-		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
87
+		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
+		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
+		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
90 90
  
91 91
 		include('table-output.php');
92 92
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +37 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		$limit_start = 0;
30 30
 		$limit_end = 25;
31 31
 		$absolute_difference = 25;
32
-	}  else {
32
+	} else {
33 33
 		$limit_explode = explode(",", $_GET['limit']);
34 34
 		$limit_start = $limit_explode[0];
35 35
 		$limit_end = $limit_explode[1];
@@ -46,21 +46,33 @@  discard block
 block discarded – undo
46 46
 	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
47 47
 	if ($sort != '') 
48 48
 	{
49
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
50
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
49
+		if ($type == 'marine') {
50
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
+		} elseif ($type == 'tracker') {
52
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
53
+		} else {
54
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
55
+		}
52 56
 	} else {
53
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
54
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
55
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
57
+		if ($type == 'marine') {
58
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
59
+		} elseif ($type == 'tracker') {
60
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
61
+		} else {
62
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
63
+		}
56 64
 	}
57 65
 	
58 66
 	if (!empty($spotter_array))
59 67
 	{
60 68
 		date_default_timezone_set($globalTimezone);
61
-		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
-		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
-		else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
69
+		if ($type == 'marine') {
70
+			$title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
71
+		} elseif ($type == 'tracker') {
72
+			$title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
73
+		} else {
74
+			$title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
75
+		}
64 76
 
65 77
 		require_once('header.php');
66 78
 		print '<div class="select-item">';
@@ -78,15 +90,24 @@  discard block
 block discarded – undo
78 90
 		print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
79 91
 		print '<br />';
80 92
 		print '<div class="info column">';
81
-		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
-		else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
93
+		if ($type == 'marine') {
94
+			print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
95
+		} else {
96
+			print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
97
+		}
83 98
 		print '</div>';
84 99
 
85
-		if ($type == 'aircraft') include('date-sub-menu.php');
100
+		if ($type == 'aircraft') {
101
+			include('date-sub-menu.php');
102
+		}
86 103
 		print '<div class="table column">';
87
-		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
-		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
104
+		if ($type == 'marine') {
105
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
106
+		} elseif ($type == 'tracker') {
107
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
108
+		} else {
109
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
110
+		}
90 111
  
91 112
 		include('table-output.php');
92 113
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
latest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 require_once('header.php');
24 24
 
25 25
 //calculuation for the pagination
26
-if(!isset($_GET['limit']))
26
+if (!isset($_GET['limit']))
27 27
 {
28 28
 	$limit_start = 0;
29 29
 	$limit_end = 25;
30 30
 	$absolute_difference = 25;
31
-}  else {
31
+} else {
32 32
 	$limit_explode = explode(",", $_GET['limit']);
33 33
 	$limit_start = $limit_explode[0];
34 34
 	$limit_end = $limit_explode[1];
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
52 52
 else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
53 53
 
54
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
54
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
55 55
 $sql_begin = microtime(true);
56 56
 if ($type == 'marine') {
57 57
 	$spotter_array = $Marine->getLatestMarineData($limit_start.",".$absolute_difference, $sort);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 } else {
61 61
 	$spotter_array = $Spotter->getLatestSpotterData($limit_start.",".$absolute_difference, $sort);
62 62
 }
63
-$sql_time = microtime(true)-$sql_begin;
63
+$sql_time = microtime(true) - $sql_begin;
64 64
 $page_begin = microtime(true);
65 65
 if (!empty($spotter_array))
66 66
 {
@@ -77,6 +77,6 @@  discard block
 block discarded – undo
77 77
 	print '</div>';
78 78
 	print '</div>';
79 79
 }
80
-$page_time = microtime(true)-$page_begin;
80
+$page_time = microtime(true) - $page_begin;
81 81
 require_once('footer.php');
82 82
 ?>
83 83
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	$limit_start = 0;
29 29
 	$limit_end = 25;
30 30
 	$absolute_difference = 25;
31
-}  else {
31
+} else {
32 32
 	$limit_explode = explode(",", $_GET['limit']);
33 33
 	$limit_start = $limit_explode[0];
34 34
 	$limit_end = $limit_explode[1];
@@ -47,9 +47,13 @@  discard block
 block discarded – undo
47 47
 print '<h1>'._("Latest Activity").'</h1>';
48 48
 print '</div>';
49 49
 print '<div class="table column">';
50
-if ($type == 'marine') print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
51
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
52
-else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
50
+if ($type == 'marine') {
51
+	print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
52
+} elseif ($type == 'tracker') {
53
+	print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
54
+} else {
55
+	print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
56
+}
53 57
 
54 58
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
55 59
 $sql_begin = microtime(true);
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 	}
10 10
 
11 11
 	/**
12
-	* Get SQL query part for filter used
13
-	* @param Array $filter the filter
14
-	* @return Array the SQL part
15
-	*/
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16 16
 	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
@@ -108,44 +108,44 @@  discard block
 block discarded – undo
108 108
 	}
109 109
 
110 110
 
111
-        /**
112
-        * Gets all the spotter information based on a particular callsign
113
-        *
114
-        * @return Array the spotter information
115
-        *
116
-        */
117
-        public function getLastArchiveTrackerDataByIdent($ident)
118
-        {
111
+		/**
112
+		 * Gets all the spotter information based on a particular callsign
113
+		 *
114
+		 * @return Array the spotter information
115
+		 *
116
+		 */
117
+		public function getLastArchiveTrackerDataByIdent($ident)
118
+		{
119 119
 		$Tracker = new Tracker($this->db);
120
-                date_default_timezone_set('UTC');
120
+				date_default_timezone_set('UTC');
121 121
 
122
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
123
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
124
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
122
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
123
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
124
+				$query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
125 125
 
126
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
126
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
127 127
 
128
-                return $spotter_array;
129
-        }
128
+				return $spotter_array;
129
+		}
130 130
 
131 131
 
132
-        /**
133
-        * Gets last the spotter information based on a particular id
134
-        *
135
-        * @return Array the spotter information
136
-        *
137
-        */
138
-        public function getLastArchiveTrackerDataById($id)
139
-        {
140
-    		$Tracker = new Tracker($this->db);
141
-                date_default_timezone_set('UTC');
142
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
143
-                //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
144
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
145
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
132
+		/**
133
+		 * Gets last the spotter information based on a particular id
134
+		 *
135
+		 * @return Array the spotter information
136
+		 *
137
+		 */
138
+		public function getLastArchiveTrackerDataById($id)
139
+		{
140
+			$Tracker = new Tracker($this->db);
141
+				date_default_timezone_set('UTC');
142
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
143
+				//$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
144
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
145
+				$query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
146 146
 
147 147
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
148
-                  /*
148
+				  /*
149 149
                 try {
150 150
                         $Connection = new Connection();
151 151
                         $sth = Connection->$db->prepare($query);
@@ -155,232 +155,232 @@  discard block
 block discarded – undo
155 155
                 }
156 156
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
157 157
                 */
158
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
159
-
160
-                return $spotter_array;
161
-        }
162
-
163
-        /**
164
-        * Gets all the spotter information based on a particular id
165
-        *
166
-        * @return Array the spotter information
167
-        *
168
-        */
169
-        public function getAllArchiveTrackerDataById($id)
158
+				$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
159
+
160
+				return $spotter_array;
161
+		}
162
+
163
+		/**
164
+		 * Gets all the spotter information based on a particular id
165
+		 *
166
+		 * @return Array the spotter information
167
+		 *
168
+		 */
169
+		public function getAllArchiveTrackerDataById($id)
170 170
 	{
171
-                date_default_timezone_set('UTC');
172
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
173
-                $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
171
+				date_default_timezone_set('UTC');
172
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
173
+				$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
174 174
 
175 175
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
176 176
 
177
-                try {
178
-                        $sth = $this->db->prepare($query);
179
-                        $sth->execute(array(':id' => $id));
180
-                } catch(PDOException $e) {
181
-                        echo $e->getMessage();
182
-                        die;
183
-                }
184
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
185
-
186
-                return $spotter_array;
187
-        }
188
-
189
-        /**
190
-        * Gets coordinate & time spotter information based on a particular id
191
-        *
192
-        * @return Array the spotter information
193
-        *
194
-        */
195
-        public function getCoordArchiveTrackerDataById($id)
196
-        {
197
-                date_default_timezone_set('UTC');
198
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
199
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
177
+				try {
178
+						$sth = $this->db->prepare($query);
179
+						$sth->execute(array(':id' => $id));
180
+				} catch(PDOException $e) {
181
+						echo $e->getMessage();
182
+						die;
183
+				}
184
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
185
+
186
+				return $spotter_array;
187
+		}
188
+
189
+		/**
190
+		 * Gets coordinate & time spotter information based on a particular id
191
+		 *
192
+		 * @return Array the spotter information
193
+		 *
194
+		 */
195
+		public function getCoordArchiveTrackerDataById($id)
196
+		{
197
+				date_default_timezone_set('UTC');
198
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
199
+				$query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
200 200
 
201 201
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
202 202
 
203
-                try {
204
-                        $sth = $this->db->prepare($query);
205
-                        $sth->execute(array(':id' => $id));
206
-                } catch(PDOException $e) {
207
-                        echo $e->getMessage();
208
-                        die;
209
-                }
210
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
203
+				try {
204
+						$sth = $this->db->prepare($query);
205
+						$sth->execute(array(':id' => $id));
206
+				} catch(PDOException $e) {
207
+						echo $e->getMessage();
208
+						die;
209
+				}
210
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
211 211
 
212
-                return $spotter_array;
213
-        }
212
+				return $spotter_array;
213
+		}
214 214
 
215 215
 
216
-        /**
217
-        * Gets altitude information based on a particular callsign
218
-        *
219
-        * @return Array the spotter information
220
-        *
221
-        */
222
-        public function getAltitudeArchiveTrackerDataByIdent($ident)
223
-        {
216
+		/**
217
+		 * Gets altitude information based on a particular callsign
218
+		 *
219
+		 * @return Array the spotter information
220
+		 *
221
+		 */
222
+		public function getAltitudeArchiveTrackerDataByIdent($ident)
223
+		{
224 224
 
225
-                date_default_timezone_set('UTC');
225
+				date_default_timezone_set('UTC');
226 226
 
227
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
228
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
227
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
228
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
229 229
 
230
-                try {
231
-                        $sth = $this->db->prepare($query);
232
-                        $sth->execute(array(':ident' => $ident));
233
-                } catch(PDOException $e) {
234
-                        echo $e->getMessage();
235
-                        die;
236
-                }
237
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
230
+				try {
231
+						$sth = $this->db->prepare($query);
232
+						$sth->execute(array(':ident' => $ident));
233
+				} catch(PDOException $e) {
234
+						echo $e->getMessage();
235
+						die;
236
+				}
237
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
238 238
 
239
-                return $spotter_array;
240
-        }
239
+				return $spotter_array;
240
+		}
241 241
 
242
-        /**
243
-        * Gets altitude information based on a particular id
244
-        *
245
-        * @return Array the spotter information
246
-        *
247
-        */
248
-        public function getAltitudeArchiveTrackerDataById($id)
249
-        {
242
+		/**
243
+		 * Gets altitude information based on a particular id
244
+		 *
245
+		 * @return Array the spotter information
246
+		 *
247
+		 */
248
+		public function getAltitudeArchiveTrackerDataById($id)
249
+		{
250 250
 
251
-                date_default_timezone_set('UTC');
251
+				date_default_timezone_set('UTC');
252 252
 
253
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
254
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
253
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
254
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
255 255
 
256
-                try {
257
-                        $sth = $this->db->prepare($query);
258
-                        $sth->execute(array(':id' => $id));
259
-                } catch(PDOException $e) {
260
-                        echo $e->getMessage();
261
-                        die;
262
-                }
263
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
256
+				try {
257
+						$sth = $this->db->prepare($query);
258
+						$sth->execute(array(':id' => $id));
259
+				} catch(PDOException $e) {
260
+						echo $e->getMessage();
261
+						die;
262
+				}
263
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
 
265
-                return $spotter_array;
266
-        }
265
+				return $spotter_array;
266
+		}
267 267
 
268
-        /**
269
-        * Gets altitude & speed information based on a particular id
270
-        *
271
-        * @return Array the spotter information
272
-        *
273
-        */
274
-        public function getAltitudeSpeedArchiveTrackerDataById($id)
275
-        {
268
+		/**
269
+		 * Gets altitude & speed information based on a particular id
270
+		 *
271
+		 * @return Array the spotter information
272
+		 *
273
+		 */
274
+		public function getAltitudeSpeedArchiveTrackerDataById($id)
275
+		{
276 276
 
277
-                date_default_timezone_set('UTC');
277
+				date_default_timezone_set('UTC');
278 278
 
279
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
280
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
279
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
280
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
281 281
 
282
-                try {
283
-                        $sth = $this->db->prepare($query);
284
-                        $sth->execute(array(':id' => $id));
285
-                } catch(PDOException $e) {
286
-                        echo $e->getMessage();
287
-                        die;
288
-                }
289
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
282
+				try {
283
+						$sth = $this->db->prepare($query);
284
+						$sth->execute(array(':id' => $id));
285
+				} catch(PDOException $e) {
286
+						echo $e->getMessage();
287
+						die;
288
+				}
289
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
290 290
 
291
-                return $spotter_array;
292
-        }
291
+				return $spotter_array;
292
+		}
293 293
 
294 294
 
295
-        /**
296
-        * Gets altitude information based on a particular callsign
297
-        *
298
-        * @return Array the spotter information
299
-        *
300
-        */
301
-        public function getLastAltitudeArchiveTrackerDataByIdent($ident)
302
-        {
295
+		/**
296
+		 * Gets altitude information based on a particular callsign
297
+		 *
298
+		 * @return Array the spotter information
299
+		 *
300
+		 */
301
+		public function getLastAltitudeArchiveTrackerDataByIdent($ident)
302
+		{
303 303
 
304
-                date_default_timezone_set('UTC');
304
+				date_default_timezone_set('UTC');
305 305
 
306
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
307
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
306
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
307
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
308 308
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
309 309
 
310
-                try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute(array(':ident' => $ident));
313
-                } catch(PDOException $e) {
314
-                        echo $e->getMessage();
315
-                        die;
316
-                }
317
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
310
+				try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute(array(':ident' => $ident));
313
+				} catch(PDOException $e) {
314
+						echo $e->getMessage();
315
+						die;
316
+				}
317
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
318 318
 
319
-                return $spotter_array;
320
-        }
319
+				return $spotter_array;
320
+		}
321 321
 
322 322
 
323 323
 
324
-       /**
325
-        * Gets all the archive spotter information
326
-        *
327
-        * @return Array the spotter information
328
-        *
329
-        */
330
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
331
-        {
332
-    		$Tracker = new Tracker($this->db);
333
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
324
+	   /**
325
+	    * Gets all the archive spotter information
326
+	    *
327
+	    * @return Array the spotter information
328
+	    *
329
+	    */
330
+		public function getTrackerArchiveData($ident,$famtrackid,$date)
331
+		{
332
+			$Tracker = new Tracker($this->db);
333
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
335 335
 
336
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
336
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
337 337
 
338
-                return $spotter_array;
339
-        }
338
+				return $spotter_array;
339
+		}
340 340
         
341
-        public function deleteTrackerArchiveTrackData()
342
-        {
341
+		public function deleteTrackerArchiveTrackData()
342
+		{
343 343
 		global $globalArchiveKeepTrackMonths;
344
-                date_default_timezone_set('UTC');
344
+				date_default_timezone_set('UTC');
345 345
 		$query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
346
-                try {
347
-                        $sth = $this->db->prepare($query);
348
-                        $sth->execute();
349
-                } catch(PDOException $e) {
350
-                        echo $e->getMessage();
351
-                        die;
352
-                }
346
+				try {
347
+						$sth = $this->db->prepare($query);
348
+						$sth->execute();
349
+				} catch(PDOException $e) {
350
+						echo $e->getMessage();
351
+						die;
352
+				}
353 353
 	}
354 354
 
355 355
 	/**
356
-        * Gets Minimal Live Tracker data
357
-        *
358
-        * @return Array the spotter information
359
-        *
360
-        */
361
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
362
-        {
363
-                global $globalDBdriver, $globalLiveInterval;
364
-                date_default_timezone_set('UTC');
365
-
366
-                $filter_query = '';
367
-                if (isset($filter['source']) && !empty($filter['source'])) {
368
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
369
-                }
370
-                // Use spotter_output also ?
371
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
372
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
373
-                }
374
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
375
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
376
-                }
377
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
378
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
379
-                }
356
+	 * Gets Minimal Live Tracker data
357
+	 *
358
+	 * @return Array the spotter information
359
+	 *
360
+	 */
361
+		public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
362
+		{
363
+				global $globalDBdriver, $globalLiveInterval;
364
+				date_default_timezone_set('UTC');
365
+
366
+				$filter_query = '';
367
+				if (isset($filter['source']) && !empty($filter['source'])) {
368
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
369
+				}
370
+				// Use spotter_output also ?
371
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
372
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
373
+				}
374
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
375
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
376
+				}
377
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
378
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
379
+				}
380 380
 
381
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
382
-                if ($globalDBdriver == 'mysql') {
383
-                        /*
381
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
382
+				if ($globalDBdriver == 'mysql') {
383
+						/*
384 384
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
385 385
                     		    FROM tracker_archive 
386 386
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -399,56 +399,56 @@  discard block
 block discarded – undo
399 399
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
400 400
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
401 401
                         	    '.$filter_query.' ORDER BY famtrackid';
402
-                } else {
403
-                        //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
404
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
402
+				} else {
403
+						//$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
404
+						$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
405 405
                         	    FROM tracker_archive 
406 406
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
407 407
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
408 408
                         	    '.$filter_query.' ORDER BY famtrackid';
409
-                }
410
-                //echo $query;
411
-                try {
412
-                        $sth = $this->db->prepare($query);
413
-                        $sth->execute();
414
-                } catch(PDOException $e) {
415
-                        echo $e->getMessage();
416
-                        die;
417
-                }
418
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
409
+				}
410
+				//echo $query;
411
+				try {
412
+						$sth = $this->db->prepare($query);
413
+						$sth->execute();
414
+				} catch(PDOException $e) {
415
+						echo $e->getMessage();
416
+						die;
417
+				}
418
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
419 419
 
420
-                return $spotter_array;
421
-        }
420
+				return $spotter_array;
421
+		}
422 422
 
423 423
 	/**
424
-        * Gets Minimal Live Tracker data
425
-        *
426
-        * @return Array the spotter information
427
-        *
428
-        */
429
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
430
-        {
431
-                global $globalDBdriver, $globalLiveInterval;
432
-                date_default_timezone_set('UTC');
433
-
434
-                $filter_query = '';
435
-                if (isset($filter['source']) && !empty($filter['source'])) {
436
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
437
-                }
438
-                // Should use spotter_output also ?
439
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
440
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
441
-                }
442
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
443
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
444
-                }
445
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
446
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
447
-                }
424
+	 * Gets Minimal Live Tracker data
425
+	 *
426
+	 * @return Array the spotter information
427
+	 *
428
+	 */
429
+		public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
430
+		{
431
+				global $globalDBdriver, $globalLiveInterval;
432
+				date_default_timezone_set('UTC');
433
+
434
+				$filter_query = '';
435
+				if (isset($filter['source']) && !empty($filter['source'])) {
436
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
437
+				}
438
+				// Should use spotter_output also ?
439
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
440
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
441
+				}
442
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
443
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
444
+				}
445
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
446
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
447
+				}
448 448
 
449
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
450
-                if ($globalDBdriver == 'mysql') {
451
-                        /*
449
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
450
+				if ($globalDBdriver == 'mysql') {
451
+						/*
452 452
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
453 453
                     		    FROM tracker_archive 
454 454
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -459,95 +459,95 @@  discard block
 block discarded – undo
459 459
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
460 460
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
461 461
 
462
-                } else {
463
-                        //$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
464
-                       /*
462
+				} else {
463
+						//$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
464
+					   /*
465 465
                         $query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
466 466
                         	    FROM tracker_archive_output 
467 467
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
468 468
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
469 469
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
470 470
                         */
471
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
471
+						$query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
472 472
                         	    FROM tracker_archive_output 
473 473
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
474 474
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
475 475
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
476 476
 //                        	    .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
477 477
                         	    
478
-                }
479
-                //echo $query;
480
-                try {
481
-                        $sth = $this->db->prepare($query);
482
-                        $sth->execute();
483
-                } catch(PDOException $e) {
484
-                        echo $e->getMessage();
485
-                        die;
486
-                }
487
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
478
+				}
479
+				//echo $query;
480
+				try {
481
+						$sth = $this->db->prepare($query);
482
+						$sth->execute();
483
+				} catch(PDOException $e) {
484
+						echo $e->getMessage();
485
+						die;
486
+				}
487
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
488 488
 
489
-                return $spotter_array;
490
-        }
489
+				return $spotter_array;
490
+		}
491 491
 
492 492
 	 /**
493
-        * Gets count Live Tracker data
494
-        *
495
-        * @return Array the spotter information
496
-        *
497
-        */
498
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
499
-        {
500
-                global $globalDBdriver, $globalLiveInterval;
501
-                date_default_timezone_set('UTC');
502
-
503
-                $filter_query = '';
504
-                if (isset($filter['source']) && !empty($filter['source'])) {
505
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
506
-                }
507
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
508
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
509
-                }
510
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
511
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
512
-                }
513
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
514
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
515
-                }
493
+	  * Gets count Live Tracker data
494
+	  *
495
+	  * @return Array the spotter information
496
+	  *
497
+	  */
498
+		public function getLiveTrackerCount($begindate,$enddate,$filter = array())
499
+		{
500
+				global $globalDBdriver, $globalLiveInterval;
501
+				date_default_timezone_set('UTC');
516 502
 
517
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
518
-                if ($globalDBdriver == 'mysql') {
503
+				$filter_query = '';
504
+				if (isset($filter['source']) && !empty($filter['source'])) {
505
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
506
+				}
507
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
508
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
509
+				}
510
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
511
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
512
+				}
513
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
514
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
515
+				}
516
+
517
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
518
+				if ($globalDBdriver == 'mysql') {
519 519
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
520 520
 			FROM tracker_archive l 
521 521
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
522
-                } else {
522
+				} else {
523 523
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
524
-                }
525
-                //echo $query;
526
-                try {
527
-                        $sth = $this->db->prepare($query);
528
-                        $sth->execute();
529
-                } catch(PDOException $e) {
530
-                        echo $e->getMessage();
531
-                        die;
532
-                }
524
+				}
525
+				//echo $query;
526
+				try {
527
+						$sth = $this->db->prepare($query);
528
+						$sth->execute();
529
+				} catch(PDOException $e) {
530
+						echo $e->getMessage();
531
+						die;
532
+				}
533 533
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
534 534
 		$sth->closeCursor();
535
-                return $result['nb'];
535
+				return $result['nb'];
536 536
 
537
-        }
537
+		}
538 538
 
539 539
 
540 540
 
541 541
 	// tracker_archive_output
542 542
 	
543
-    /**
544
-    * Gets all the spotter information
545
-    *
546
-    * @return Array the spotter information
547
-    *
548
-    */
549
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
550
-    {
543
+	/**
544
+	 * Gets all the spotter information
545
+	 *
546
+	 * @return Array the spotter information
547
+	 *
548
+	 */
549
+	public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
550
+	{
551 551
 	global $globalTimezone, $globalDBdriver;
552 552
 	require_once(dirname(__FILE__).'/class.Translation.php');
553 553
 	$Translation = new Translation();
@@ -561,159 +561,159 @@  discard block
 block discarded – undo
561 561
 	$filter_query = $this->getFilter($filters);
562 562
 	if ($q != "")
563 563
 	{
564
-	    if (!is_string($q))
565
-	    {
564
+		if (!is_string($q))
565
+		{
566 566
 		return false;
567
-	    } else {
567
+		} else {
568 568
 	        
569 569
 		$q_array = explode(" ", $q);
570 570
 		
571 571
 		foreach ($q_array as $q_item){
572
-		    $additional_query .= " AND (";
573
-		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
574
-		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
575
-		    $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
593
-		    $translate = $Translation->ident2icao($q_item);
594
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
595
-		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
596
-		    $additional_query .= ")";
572
+			$additional_query .= " AND (";
573
+			$additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
574
+			$additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
575
+			$additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
576
+			$additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
577
+			$additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
578
+			$additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
579
+			$additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
580
+			$additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
581
+			$additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
582
+			$additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
583
+			$additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
584
+			$additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
585
+			$additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
586
+			$additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
587
+			$additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
588
+			$additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
589
+			$additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
590
+			$additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
591
+			$additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
593
+			$translate = $Translation->ident2icao($q_item);
594
+			if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
595
+			$additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
596
+			$additional_query .= ")";
597
+		}
597 598
 		}
598
-	    }
599 599
 	}
600 600
 	
601 601
 	if ($registration != "")
602 602
 	{
603
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
604
-	    if (!is_string($registration))
605
-	    {
603
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
604
+		if (!is_string($registration))
605
+		{
606 606
 		return false;
607
-	    } else {
607
+		} else {
608 608
 		$additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
609
-	    }
609
+		}
610 610
 	}
611 611
 	
612 612
 	if ($aircraft_icao != "")
613 613
 	{
614
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
615
-	    if (!is_string($aircraft_icao))
616
-	    {
614
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
615
+		if (!is_string($aircraft_icao))
616
+		{
617 617
 		return false;
618
-	    } else {
618
+		} else {
619 619
 		$additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
620
-	    }
620
+		}
621 621
 	}
622 622
 	
623 623
 	if ($aircraft_manufacturer != "")
624 624
 	{
625
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
626
-	    if (!is_string($aircraft_manufacturer))
627
-	    {
625
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
626
+		if (!is_string($aircraft_manufacturer))
627
+		{
628 628
 		return false;
629
-	    } else {
629
+		} else {
630 630
 		$additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
631
-	    }
631
+		}
632 632
 	}
633 633
 	
634 634
 	if ($highlights == "true")
635 635
 	{
636
-	    if (!is_string($highlights))
637
-	    {
636
+		if (!is_string($highlights))
637
+		{
638 638
 		return false;
639
-	    } else {
639
+		} else {
640 640
 		$additional_query .= " AND (tracker_archive_output.highlight <> '')";
641
-	    }
641
+		}
642 642
 	}
643 643
 	
644 644
 	if ($airline_icao != "")
645 645
 	{
646
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
-	    if (!is_string($airline_icao))
648
-	    {
646
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
+		if (!is_string($airline_icao))
648
+		{
649 649
 		return false;
650
-	    } else {
650
+		} else {
651 651
 		$additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
652
-	    }
652
+		}
653 653
 	}
654 654
 	
655 655
 	if ($airline_country != "")
656 656
 	{
657
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
658
-	    if (!is_string($airline_country))
659
-	    {
657
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
658
+		if (!is_string($airline_country))
659
+		{
660 660
 		return false;
661
-	    } else {
661
+		} else {
662 662
 		$additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
663
-	    }
663
+		}
664 664
 	}
665 665
 	
666 666
 	if ($airline_type != "")
667 667
 	{
668
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
669
-	    if (!is_string($airline_type))
670
-	    {
668
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
669
+		if (!is_string($airline_type))
670
+		{
671 671
 		return false;
672
-	    } else {
672
+		} else {
673 673
 		if ($airline_type == "passenger")
674 674
 		{
675
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
675
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
676 676
 		}
677 677
 		if ($airline_type == "cargo")
678 678
 		{
679
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
679
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
680 680
 		}
681 681
 		if ($airline_type == "military")
682 682
 		{
683
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
683
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
684
+		}
684 685
 		}
685
-	    }
686 686
 	}
687 687
 	
688 688
 	if ($airport != "")
689 689
 	{
690
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
691
-	    if (!is_string($airport))
692
-	    {
690
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
691
+		if (!is_string($airport))
692
+		{
693 693
 		return false;
694
-	    } else {
694
+		} else {
695 695
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
696
-	    }
696
+		}
697 697
 	}
698 698
 	
699 699
 	if ($airport_country != "")
700 700
 	{
701
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
702
-	    if (!is_string($airport_country))
703
-	    {
701
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
702
+		if (!is_string($airport_country))
703
+		{
704 704
 		return false;
705
-	    } else {
705
+		} else {
706 706
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
707
-	    }
707
+		}
708 708
 	}
709 709
     
710 710
 	if ($callsign != "")
711 711
 	{
712
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
713
-	    if (!is_string($callsign))
714
-	    {
712
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
713
+		if (!is_string($callsign))
714
+		{
715 715
 		return false;
716
-	    } else {
716
+		} else {
717 717
 		$translate = $Translation->ident2icao($callsign);
718 718
 		if ($translate != $callsign) {
719 719
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
@@ -721,99 +721,99 @@  discard block
 block discarded – undo
721 721
 		} else {
722 722
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
723 723
 		}
724
-	    }
724
+		}
725 725
 	}
726 726
 
727 727
 	if ($owner != "")
728 728
 	{
729
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
730
-	    if (!is_string($owner))
731
-	    {
729
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
730
+		if (!is_string($owner))
731
+		{
732 732
 		return false;
733
-	    } else {
733
+		} else {
734 734
 		$additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
735
-	    }
735
+		}
736 736
 	}
737 737
 
738 738
 	if ($pilot_name != "")
739 739
 	{
740
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
741
-	    if (!is_string($pilot_name))
742
-	    {
740
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
741
+		if (!is_string($pilot_name))
742
+		{
743 743
 		return false;
744
-	    } else {
744
+		} else {
745 745
 		$additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
746
-	    }
746
+		}
747 747
 	}
748 748
 	
749 749
 	if ($pilot_id != "")
750 750
 	{
751
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
752
-	    if (!is_string($pilot_id))
753
-	    {
751
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
752
+		if (!is_string($pilot_id))
753
+		{
754 754
 		return false;
755
-	    } else {
755
+		} else {
756 756
 		$additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
757
-	    }
757
+		}
758 758
 	}
759 759
 	
760 760
 	if ($departure_airport_route != "")
761 761
 	{
762
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
763
-	    if (!is_string($departure_airport_route))
764
-	    {
762
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
763
+		if (!is_string($departure_airport_route))
764
+		{
765 765
 		return false;
766
-	    } else {
766
+		} else {
767 767
 		$additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
768
-	    }
768
+		}
769 769
 	}
770 770
 	
771 771
 	if ($arrival_airport_route != "")
772 772
 	{
773
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
774
-	    if (!is_string($arrival_airport_route))
775
-	    {
773
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
774
+		if (!is_string($arrival_airport_route))
775
+		{
776 776
 		return false;
777
-	    } else {
777
+		} else {
778 778
 		$additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
779
-	    }
779
+		}
780 780
 	}
781 781
 	
782 782
 	if ($altitude != "")
783 783
 	{
784
-	    $altitude_array = explode(",", $altitude);
784
+		$altitude_array = explode(",", $altitude);
785 785
 	    
786
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
786
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788 788
 	    
789 789
 
790
-	    if ($altitude_array[1] != "")
791
-	    {                
790
+		if ($altitude_array[1] != "")
791
+		{                
792 792
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
793 793
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
794 794
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
795
-	    } else {
795
+		} else {
796 796
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
797 797
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
798
-	    }
798
+		}
799 799
 	}
800 800
 	
801 801
 	if ($date_posted != "")
802 802
 	{
803
-	    $date_array = explode(",", $date_posted);
803
+		$date_array = explode(",", $date_posted);
804 804
 	    
805
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
806
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
805
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
806
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807 807
 	    
808
-	    if ($globalTimezone != '') {
808
+		if ($globalTimezone != '') {
809 809
 		date_default_timezone_set($globalTimezone);
810 810
 		$datetime = new DateTime();
811 811
 		$offset = $datetime->format('P');
812
-	    } else $offset = '+00:00';
812
+		} else $offset = '+00:00';
813 813
 
814 814
 
815
-	    if ($date_array[1] != "")
816
-	    {                
815
+		if ($date_array[1] != "")
816
+		{                
817 817
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
818 818
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
819 819
 		if ($globalDBdriver == 'mysql') {
@@ -821,28 +821,28 @@  discard block
 block discarded – undo
821 821
 		} else {
822 822
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
823 823
 		}
824
-	    } else {
824
+		} else {
825 825
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
826
-                if ($globalDBdriver == 'mysql') {
826
+				if ($globalDBdriver == 'mysql') {
827 827
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
828 828
 		} else {
829 829
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
830 830
 		}
831
-	    }
831
+		}
832 832
 	}
833 833
 	
834 834
 	if ($limit != "")
835 835
 	{
836
-	    $limit_array = explode(",", $limit);
836
+		$limit_array = explode(",", $limit);
837 837
 	    
838
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
839
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
838
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
839
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840 840
 	    
841
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
842
-	    {
841
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
842
+		{
843 843
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
844 844
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
845
-	    }
845
+		}
846 846
 	}
847 847
 	
848 848
 
@@ -873,33 +873,33 @@  discard block
 block discarded – undo
873 873
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
874 874
 
875 875
 	return $spotter_array;
876
-    }
876
+	}
877 877
 
878
-    public function deleteTrackerArchiveData()
879
-    {
878
+	public function deleteTrackerArchiveData()
879
+	{
880 880
 		global $globalArchiveKeepMonths, $globalDBdriver;
881
-                date_default_timezone_set('UTC');
882
-                if ($globalDBdriver == 'mysql') {
881
+				date_default_timezone_set('UTC');
882
+				if ($globalDBdriver == 'mysql') {
883 883
 			$query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
884 884
 		} else {
885 885
 			$query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
886 886
 		}
887
-                try {
888
-                        $sth = $this->db->prepare($query);
889
-                        $sth->execute();
890
-                } catch(PDOException $e) {
891
-                        return "error";
892
-                }
887
+				try {
888
+						$sth = $this->db->prepare($query);
889
+						$sth->execute();
890
+				} catch(PDOException $e) {
891
+						return "error";
892
+				}
893 893
 	}
894 894
 
895
-    /**
896
-    * Gets all the spotter information based on the callsign
897
-    *
898
-    * @return Array the spotter information
899
-    *
900
-    */
901
-    public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
902
-    {
895
+	/**
896
+	 * Gets all the spotter information based on the callsign
897
+	 *
898
+	 * @return Array the spotter information
899
+	 *
900
+	 */
901
+	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
902
+	{
903 903
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
904 904
 	
905 905
 	date_default_timezone_set('UTC');
@@ -911,35 +911,35 @@  discard block
 block discarded – undo
911 911
 	
912 912
 	if ($ident != "")
913 913
 	{
914
-	    if (!is_string($ident))
915
-	    {
914
+		if (!is_string($ident))
915
+		{
916 916
 		return false;
917
-	    } else {
917
+		} else {
918 918
 		$additional_query = " AND (tracker_archive_output.ident = :ident)";
919 919
 		$query_values = array(':ident' => $ident);
920
-	    }
920
+		}
921 921
 	}
922 922
 	
923 923
 	if ($limit != "")
924 924
 	{
925
-	    $limit_array = explode(",", $limit);
925
+		$limit_array = explode(",", $limit);
926 926
 	    
927
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
928
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
927
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
928
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929 929
 	    
930
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
931
-	    {
930
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
931
+		{
932 932
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
933 933
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
934
-	    }
934
+		}
935 935
 	}
936 936
 
937 937
 	if ($sort != "")
938 938
 	{
939
-	    $search_orderby_array = $Tracker->getOrderBy();
940
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
939
+		$search_orderby_array = $Tracker->getOrderBy();
940
+		$orderby_query = $search_orderby_array[$sort]['sql'];
941 941
 	} else {
942
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
942
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
943 943
 	}
944 944
 
945 945
 	$query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -947,17 +947,17 @@  discard block
 block discarded – undo
947 947
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
948 948
 
949 949
 	return $spotter_array;
950
-    }
950
+	}
951 951
 
952 952
 
953
-    /**
954
-    * Gets all the spotter information based on the owner
955
-    *
956
-    * @return Array the spotter information
957
-    *
958
-    */
959
-    public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
960
-    {
953
+	/**
954
+	 * Gets all the spotter information based on the owner
955
+	 *
956
+	 * @return Array the spotter information
957
+	 *
958
+	 */
959
+	public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
960
+	{
961 961
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
962 962
 	
963 963
 	date_default_timezone_set('UTC');
@@ -970,35 +970,35 @@  discard block
 block discarded – undo
970 970
 	
971 971
 	if ($owner != "")
972 972
 	{
973
-	    if (!is_string($owner))
974
-	    {
973
+		if (!is_string($owner))
974
+		{
975 975
 		return false;
976
-	    } else {
976
+		} else {
977 977
 		$additional_query = " AND (tracker_archive_output.owner_name = :owner)";
978 978
 		$query_values = array(':owner' => $owner);
979
-	    }
979
+		}
980 980
 	}
981 981
 	
982 982
 	if ($limit != "")
983 983
 	{
984
-	    $limit_array = explode(",", $limit);
984
+		$limit_array = explode(",", $limit);
985 985
 	    
986
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
986
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988 988
 	    
989
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990
-	    {
989
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990
+		{
991 991
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
992 992
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
993
-	    }
993
+		}
994 994
 	}
995 995
 
996 996
 	if ($sort != "")
997 997
 	{
998
-	    $search_orderby_array = $Tracker->getOrderBy();
999
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
998
+		$search_orderby_array = $Tracker->getOrderBy();
999
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1000 1000
 	} else {
1001
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1001
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1002 1002
 	}
1003 1003
 
1004 1004
 	$query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1006,16 +1006,16 @@  discard block
 block discarded – undo
1006 1006
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1007 1007
 
1008 1008
 	return $spotter_array;
1009
-    }
1010
-
1011
-    /**
1012
-    * Gets all the spotter information based on the pilot
1013
-    *
1014
-    * @return Array the spotter information
1015
-    *
1016
-    */
1017
-    public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1018
-    {
1009
+	}
1010
+
1011
+	/**
1012
+	 * Gets all the spotter information based on the pilot
1013
+	 *
1014
+	 * @return Array the spotter information
1015
+	 *
1016
+	 */
1017
+	public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1018
+	{
1019 1019
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1020 1020
 	
1021 1021
 	date_default_timezone_set('UTC');
@@ -1034,24 +1034,24 @@  discard block
 block discarded – undo
1034 1034
 	
1035 1035
 	if ($limit != "")
1036 1036
 	{
1037
-	    $limit_array = explode(",", $limit);
1037
+		$limit_array = explode(",", $limit);
1038 1038
 	    
1039
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1040
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1039
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1040
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041 1041
 	    
1042
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1043
-	    {
1042
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1043
+		{
1044 1044
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1045 1045
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1046
-	    }
1046
+		}
1047 1047
 	}
1048 1048
 
1049 1049
 	if ($sort != "")
1050 1050
 	{
1051
-	    $search_orderby_array = $Tracker->getOrderBy();
1052
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1051
+		$search_orderby_array = $Tracker->getOrderBy();
1052
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1053 1053
 	} else {
1054
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1054
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1055 1055
 	}
1056 1056
 
1057 1057
 	$query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1059,16 +1059,16 @@  discard block
 block discarded – undo
1059 1059
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1060 1060
 
1061 1061
 	return $spotter_array;
1062
-    }
1063
-
1064
-    /**
1065
-    * Gets all number of flight over countries
1066
-    *
1067
-    * @return Array the airline country list
1068
-    *
1069
-    */
1070
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1071
-    {
1062
+	}
1063
+
1064
+	/**
1065
+	 * Gets all number of flight over countries
1066
+	 *
1067
+	 * @return Array the airline country list
1068
+	 *
1069
+	 */
1070
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1071
+	{
1072 1072
 	global $globalDBdriver;
1073 1073
 	/*
1074 1074
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1078,14 +1078,14 @@  discard block
 block discarded – undo
1078 1078
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1079 1079
 		    FROM countries c, tracker_archive s
1080 1080
 		    WHERE c.iso2 = s.over_country ";
1081
-                if ($olderthanmonths > 0) {
1082
-            		if ($globalDBdriver == 'mysql') {
1081
+				if ($olderthanmonths > 0) {
1082
+					if ($globalDBdriver == 'mysql') {
1083 1083
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1084 1084
 			} else {
1085 1085
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1086 1086
 			}
1087 1087
 		}
1088
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1088
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1089 1089
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1090 1090
 	if ($limit) $query .= " LIMIT 0,10";
1091 1091
       
@@ -1098,23 +1098,23 @@  discard block
 block discarded – undo
1098 1098
         
1099 1099
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1100 1100
 	{
1101
-	    $temp_array['flight_count'] = $row['nb'];
1102
-	    $temp_array['flight_country'] = $row['name'];
1103
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1104
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1105
-	    $flight_array[] = $temp_array;
1101
+		$temp_array['flight_count'] = $row['nb'];
1102
+		$temp_array['flight_country'] = $row['name'];
1103
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1104
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1105
+		$flight_array[] = $temp_array;
1106 1106
 	}
1107 1107
 	return $flight_array;
1108
-    }
1109
-
1110
-    /**
1111
-    * Gets all number of flight over countries
1112
-    *
1113
-    * @return Array the airline country list
1114
-    *
1115
-    */
1116
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1117
-    {
1108
+	}
1109
+
1110
+	/**
1111
+	 * Gets all number of flight over countries
1112
+	 *
1113
+	 * @return Array the airline country list
1114
+	 *
1115
+	 */
1116
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1117
+	{
1118 1118
 	global $globalDBdriver;
1119 1119
 	/*
1120 1120
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1124,14 +1124,14 @@  discard block
 block discarded – undo
1124 1124
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1125 1125
 		    FROM countries c, tracker_archive s, spotter_output o
1126 1126
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid ";
1127
-                if ($olderthanmonths > 0) {
1128
-            		if ($globalDBdriver == 'mysql') {
1127
+				if ($olderthanmonths > 0) {
1128
+					if ($globalDBdriver == 'mysql') {
1129 1129
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1130 1130
 			} else {
1131 1131
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1132 1132
 			}
1133 1133
 		}
1134
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1134
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1135 1135
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1136 1136
 	if ($limit) $query .= " LIMIT 0,10";
1137 1137
       
@@ -1144,24 +1144,24 @@  discard block
 block discarded – undo
1144 1144
         
1145 1145
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1146 1146
 	{
1147
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1148
-	    $temp_array['flight_count'] = $row['nb'];
1149
-	    $temp_array['flight_country'] = $row['name'];
1150
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1151
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1152
-	    $flight_array[] = $temp_array;
1147
+		$temp_array['airline_icao'] = $row['airline_icao'];
1148
+		$temp_array['flight_count'] = $row['nb'];
1149
+		$temp_array['flight_country'] = $row['name'];
1150
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1151
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1152
+		$flight_array[] = $temp_array;
1153 1153
 	}
1154 1154
 	return $flight_array;
1155
-    }
1156
-
1157
-    /**
1158
-    * Gets last spotter information based on a particular callsign
1159
-    *
1160
-    * @return Array the spotter information
1161
-    *
1162
-    */
1163
-    public function getDateArchiveTrackerDataById($id,$date)
1164
-    {
1155
+	}
1156
+
1157
+	/**
1158
+	 * Gets last spotter information based on a particular callsign
1159
+	 *
1160
+	 * @return Array the spotter information
1161
+	 *
1162
+	 */
1163
+	public function getDateArchiveTrackerDataById($id,$date)
1164
+	{
1165 1165
 	$Tracker = new Tracker($this->db);
1166 1166
 	date_default_timezone_set('UTC');
1167 1167
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1169,16 +1169,16 @@  discard block
 block discarded – undo
1169 1169
 	$date = date('c',$date);
1170 1170
 	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1171 1171
 	return $spotter_array;
1172
-    }
1173
-
1174
-    /**
1175
-    * Gets all the spotter information based on a particular callsign
1176
-    *
1177
-    * @return Array the spotter information
1178
-    *
1179
-    */
1180
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1181
-    {
1172
+	}
1173
+
1174
+	/**
1175
+	 * Gets all the spotter information based on a particular callsign
1176
+	 *
1177
+	 * @return Array the spotter information
1178
+	 *
1179
+	 */
1180
+	public function getDateArchiveTrackerDataByIdent($ident,$date)
1181
+	{
1182 1182
 	$Tracker = new Tracker($this->db);
1183 1183
 	date_default_timezone_set('UTC');
1184 1184
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1186,16 +1186,16 @@  discard block
 block discarded – undo
1186 1186
 	$date = date('c',$date);
1187 1187
 	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1188 1188
 	return $spotter_array;
1189
-    }
1190
-
1191
-    /**
1192
-    * Gets all the spotter information based on the airport
1193
-    *
1194
-    * @return Array the spotter information
1195
-    *
1196
-    */
1197
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1198
-    {
1189
+	}
1190
+
1191
+	/**
1192
+	 * Gets all the spotter information based on the airport
1193
+	 *
1194
+	 * @return Array the spotter information
1195
+	 *
1196
+	 */
1197
+	public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1198
+	{
1199 1199
 	global $global_query;
1200 1200
 	$Tracker = new Tracker();
1201 1201
 	date_default_timezone_set('UTC');
@@ -1206,35 +1206,35 @@  discard block
 block discarded – undo
1206 1206
 	
1207 1207
 	if ($airport != "")
1208 1208
 	{
1209
-	    if (!is_string($airport))
1210
-	    {
1209
+		if (!is_string($airport))
1210
+		{
1211 1211
 		return false;
1212
-	    } else {
1212
+		} else {
1213 1213
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1214 1214
 		$query_values = array(':airport' => $airport);
1215
-	    }
1215
+		}
1216 1216
 	}
1217 1217
 	
1218 1218
 	if ($limit != "")
1219 1219
 	{
1220
-	    $limit_array = explode(",", $limit);
1220
+		$limit_array = explode(",", $limit);
1221 1221
 	    
1222
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1223
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1222
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1223
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224 1224
 	    
1225
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1226
-	    {
1225
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1226
+		{
1227 1227
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1228 1228
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1229
-	    }
1229
+		}
1230 1230
 	}
1231 1231
 	
1232 1232
 	if ($sort != "")
1233 1233
 	{
1234
-	    $search_orderby_array = $Tracker->getOrderBy();
1235
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1234
+		$search_orderby_array = $Tracker->getOrderBy();
1235
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1236 1236
 	} else {
1237
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1237
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1238 1238
 	}
1239 1239
 
1240 1240
 	$query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1242,6 +1242,6 @@  discard block
 block discarded – undo
1242 1242
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1243 1243
 
1244 1244
 	return $spotter_array;
1245
-    }
1245
+	}
1246 1246
 }
1247 1247
 ?>
1248 1248
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -13,33 +13,33 @@  discard block
 block discarded – undo
13 13
 	* @param Array $filter the filter
14 14
 	* @return Array the SQL part
15 15
 	*/
16
-	public function getFilter($filter = array(),$where = false,$and = false) {
16
+	public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
19 19
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 				$filters = $globalStatsFilters[$globalFilterName];
22 22
 			} else {
23
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 			}
25 25
 		}
26 26
 		if (isset($filter[0]['source'])) {
27
-			$filters = array_merge($filters,$filter);
27
+			$filters = array_merge($filters, $filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32
-		foreach($filters as $flt) {
32
+		foreach ($filters as $flt) {
33 33
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
34 34
 				if (isset($flt['source'])) {
35
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
35
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
36 36
 				} else {
37
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
37
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
38 38
 				}
39 39
 			}
40 40
 		}
41 41
 		if (isset($filter['source']) && !empty($filter['source'])) {
42
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
42
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
43 43
 		}
44 44
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
45 45
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -67,38 +67,38 @@  discard block
 block discarded – undo
67 67
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'";
68 68
 				}
69 69
 			}
70
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
70
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
71 71
 		}
72 72
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
73
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
74 74
 		}
75 75
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76 76
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77 77
 		if ($filter_query_where != '') {
78
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
79 79
 		}
80 80
 		$filter_query = $filter_query_join.$filter_query_where;
81 81
 		return $filter_query;
82 82
 	}
83 83
 
84 84
 	// tracker_archive
85
-	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
85
+	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
86 86
 		require_once(dirname(__FILE__).'/class.Tracker.php');
87 87
 		if ($over_country == '') {
88 88
 			$Tracker = new Tracker($this->db);
89
-			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
89
+			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude);
90 90
 			if (!empty($data_country)) $country = $data_country['iso2'];
91 91
 			else $country = '';
92 92
 		} else $country = $over_country;
93 93
 		// Route is not added in tracker_archive
94
-		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
94
+		$query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
95 95
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
96
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
96
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
97 97
 		try {
98 98
 			$sth = $this->db->prepare($query);
99 99
 			$sth->execute($query_values);
100 100
 			$sth->closeCursor();
101
-		} catch(PDOException $e) {
101
+		} catch (PDOException $e) {
102 102
 			return "error : ".$e->getMessage();
103 103
 		}
104 104
 		return "success";
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 
119 119
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
120 120
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
121
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
121
+                $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
122 122
 
123
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
123
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident));
124 124
 
125 125
                 return $spotter_array;
126 126
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
140 140
                 //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
141 141
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
142
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
142
+                $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
143 143
 
144 144
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
145 145
                   /*
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
                 }
153 153
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
154 154
                 */
155
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
155
+                $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id));
156 156
 
157 157
                 return $spotter_array;
158 158
         }
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 	{
168 168
                 date_default_timezone_set('UTC');
169 169
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
170
-                $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
170
+                $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
171 171
 
172 172
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
173 173
 
174 174
                 try {
175 175
                         $sth = $this->db->prepare($query);
176 176
                         $sth->execute(array(':id' => $id));
177
-                } catch(PDOException $e) {
177
+                } catch (PDOException $e) {
178 178
                         echo $e->getMessage();
179 179
                         die;
180 180
                 }
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
         {
194 194
                 date_default_timezone_set('UTC');
195 195
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
196
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
196
+                $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
197 197
 
198 198
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
199 199
 
200 200
                 try {
201 201
                         $sth = $this->db->prepare($query);
202 202
                         $sth->execute(array(':id' => $id));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         echo $e->getMessage();
205 205
                         die;
206 206
                 }
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
                 date_default_timezone_set('UTC');
223 223
 
224 224
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
225
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
225
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
226 226
 
227 227
                 try {
228 228
                         $sth = $this->db->prepare($query);
229 229
                         $sth->execute(array(':ident' => $ident));
230
-                } catch(PDOException $e) {
230
+                } catch (PDOException $e) {
231 231
                         echo $e->getMessage();
232 232
                         die;
233 233
                 }
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
                 date_default_timezone_set('UTC');
249 249
 
250 250
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
251
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
251
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
252 252
 
253 253
                 try {
254 254
                         $sth = $this->db->prepare($query);
255 255
                         $sth->execute(array(':id' => $id));
256
-                } catch(PDOException $e) {
256
+                } catch (PDOException $e) {
257 257
                         echo $e->getMessage();
258 258
                         die;
259 259
                 }
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
                 date_default_timezone_set('UTC');
275 275
 
276 276
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
277
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
277
+                $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
278 278
 
279 279
                 try {
280 280
                         $sth = $this->db->prepare($query);
281 281
                         $sth->execute(array(':id' => $id));
282
-                } catch(PDOException $e) {
282
+                } catch (PDOException $e) {
283 283
                         echo $e->getMessage();
284 284
                         die;
285 285
                 }
@@ -301,13 +301,13 @@  discard block
 block discarded – undo
301 301
                 date_default_timezone_set('UTC');
302 302
 
303 303
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
304
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
304
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
305 305
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
306 306
 
307 307
                 try {
308 308
                         $sth = $this->db->prepare($query);
309 309
                         $sth->execute(array(':ident' => $ident));
310
-                } catch(PDOException $e) {
310
+                } catch (PDOException $e) {
311 311
                         echo $e->getMessage();
312 312
                         die;
313 313
                 }
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
         * @return Array the spotter information
325 325
         *
326 326
         */
327
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
327
+        public function getTrackerArchiveData($ident, $famtrackid, $date)
328 328
         {
329 329
     		$Tracker = new Tracker($this->db);
330 330
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
331
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
331
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
332 332
 
333
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
333
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%'));
334 334
 
335 335
                 return $spotter_array;
336 336
         }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
                 try {
344 344
                         $sth = $this->db->prepare($query);
345 345
                         $sth->execute();
346
-                } catch(PDOException $e) {
346
+                } catch (PDOException $e) {
347 347
                         echo $e->getMessage();
348 348
                         die;
349 349
                 }
@@ -355,24 +355,24 @@  discard block
 block discarded – undo
355 355
         * @return Array the spotter information
356 356
         *
357 357
         */
358
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
358
+        public function getMinLiveTrackerData($begindate, $enddate, $filter = array())
359 359
         {
360 360
                 global $globalDBdriver, $globalLiveInterval;
361 361
                 date_default_timezone_set('UTC');
362 362
 
363 363
                 $filter_query = '';
364 364
                 if (isset($filter['source']) && !empty($filter['source'])) {
365
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
365
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
366 366
                 }
367 367
                 // Use spotter_output also ?
368 368
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
369
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
369
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
370 370
                 }
371 371
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
372 372
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
373 373
                 }
374 374
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
375
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
375
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
376 376
                 }
377 377
 
378 378
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
392 392
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
393 393
 */
394
-			$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
394
+			$query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
395 395
 				    FROM tracker_archive 
396 396
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
397 397
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
398 398
                         	    '.$filter_query.' ORDER BY famtrackid';
399 399
                 } else {
400 400
                         //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
401
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
401
+                        $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
402 402
                         	    FROM tracker_archive 
403 403
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
404 404
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
                 try {
409 409
                         $sth = $this->db->prepare($query);
410 410
                         $sth->execute();
411
-                } catch(PDOException $e) {
411
+                } catch (PDOException $e) {
412 412
                         echo $e->getMessage();
413 413
                         die;
414 414
                 }
@@ -423,24 +423,24 @@  discard block
 block discarded – undo
423 423
         * @return Array the spotter information
424 424
         *
425 425
         */
426
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
426
+        public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array())
427 427
         {
428 428
                 global $globalDBdriver, $globalLiveInterval;
429 429
                 date_default_timezone_set('UTC');
430 430
 
431 431
                 $filter_query = '';
432 432
                 if (isset($filter['source']) && !empty($filter['source'])) {
433
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
433
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
434 434
                 }
435 435
                 // Should use spotter_output also ?
436 436
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
437
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
437
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
438 438
                 }
439 439
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
440 440
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
441 441
                 }
442 442
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
443
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
443
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
444 444
                 }
445 445
 
446 446
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                     		    FROM tracker_archive 
451 451
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
452 452
 			*/
453
-			$query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
453
+			$query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
454 454
 				    FROM tracker_archive_output 
455 455
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
456 456
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
466 466
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
467 467
                         */
468
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
468
+                        $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
469 469
                         	    FROM tracker_archive_output 
470 470
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
471 471
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 try {
478 478
                         $sth = $this->db->prepare($query);
479 479
                         $sth->execute();
480
-                } catch(PDOException $e) {
480
+                } catch (PDOException $e) {
481 481
                         echo $e->getMessage();
482 482
                         die;
483 483
                 }
@@ -492,23 +492,23 @@  discard block
 block discarded – undo
492 492
         * @return Array the spotter information
493 493
         *
494 494
         */
495
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
495
+        public function getLiveTrackerCount($begindate, $enddate, $filter = array())
496 496
         {
497 497
                 global $globalDBdriver, $globalLiveInterval;
498 498
                 date_default_timezone_set('UTC');
499 499
 
500 500
                 $filter_query = '';
501 501
                 if (isset($filter['source']) && !empty($filter['source'])) {
502
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
502
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
503 503
                 }
504 504
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
505
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
505
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
506 506
                 }
507 507
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
508 508
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
509 509
                 }
510 510
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
511
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
511
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
512 512
                 }
513 513
 
514 514
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 try {
524 524
                         $sth = $this->db->prepare($query);
525 525
                         $sth->execute();
526
-                } catch(PDOException $e) {
526
+                } catch (PDOException $e) {
527 527
                         echo $e->getMessage();
528 528
                         die;
529 529
                 }
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
     * @return Array the spotter information
544 544
     *
545 545
     */
546
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
546
+    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
547 547
     {
548 548
 	global $globalTimezone, $globalDBdriver;
549 549
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	        
566 566
 		$q_array = explode(" ", $q);
567 567
 		
568
-		foreach ($q_array as $q_item){
568
+		foreach ($q_array as $q_item) {
569 569
 		    $additional_query .= " AND (";
570 570
 		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
571 571
 		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	
598 598
 	if ($registration != "")
599 599
 	{
600
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
600
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
601 601
 	    if (!is_string($registration))
602 602
 	    {
603 603
 		return false;
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	
609 609
 	if ($aircraft_icao != "")
610 610
 	{
611
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
611
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
612 612
 	    if (!is_string($aircraft_icao))
613 613
 	    {
614 614
 		return false;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	
620 620
 	if ($aircraft_manufacturer != "")
621 621
 	{
622
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
622
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
623 623
 	    if (!is_string($aircraft_manufacturer))
624 624
 	    {
625 625
 		return false;
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	
641 641
 	if ($airline_icao != "")
642 642
 	{
643
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
643
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
644 644
 	    if (!is_string($airline_icao))
645 645
 	    {
646 646
 		return false;
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	
652 652
 	if ($airline_country != "")
653 653
 	{
654
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
654
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
655 655
 	    if (!is_string($airline_country))
656 656
 	    {
657 657
 		return false;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	
663 663
 	if ($airline_type != "")
664 664
 	{
665
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
665
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
666 666
 	    if (!is_string($airline_type))
667 667
 	    {
668 668
 		return false;
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	
685 685
 	if ($airport != "")
686 686
 	{
687
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
687
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
688 688
 	    if (!is_string($airport))
689 689
 	    {
690 690
 		return false;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 	
696 696
 	if ($airport_country != "")
697 697
 	{
698
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
698
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
699 699
 	    if (!is_string($airport_country))
700 700
 	    {
701 701
 		return false;
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
     
707 707
 	if ($callsign != "")
708 708
 	{
709
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
709
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
710 710
 	    if (!is_string($callsign))
711 711
 	    {
712 712
 		return false;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		$translate = $Translation->ident2icao($callsign);
715 715
 		if ($translate != $callsign) {
716 716
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
717
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
717
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
718 718
 		} else {
719 719
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
720 720
 		}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 
724 724
 	if ($owner != "")
725 725
 	{
726
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
726
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
727 727
 	    if (!is_string($owner))
728 728
 	    {
729 729
 		return false;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 
735 735
 	if ($pilot_name != "")
736 736
 	{
737
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
737
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
738 738
 	    if (!is_string($pilot_name))
739 739
 	    {
740 740
 		return false;
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	
746 746
 	if ($pilot_id != "")
747 747
 	{
748
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
748
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
749 749
 	    if (!is_string($pilot_id))
750 750
 	    {
751 751
 		return false;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	
757 757
 	if ($departure_airport_route != "")
758 758
 	{
759
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
759
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
760 760
 	    if (!is_string($departure_airport_route))
761 761
 	    {
762 762
 		return false;
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 	
768 768
 	if ($arrival_airport_route != "")
769 769
 	{
770
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
770
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
771 771
 	    if (!is_string($arrival_airport_route))
772 772
 	    {
773 773
 		return false;
@@ -780,8 +780,8 @@  discard block
 block discarded – undo
780 780
 	{
781 781
 	    $altitude_array = explode(",", $altitude);
782 782
 	    
783
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
784
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
783
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
784
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
785 785
 	    
786 786
 
787 787
 	    if ($altitude_array[1] != "")
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	{
800 800
 	    $date_array = explode(",", $date_posted);
801 801
 	    
802
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
803
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
802
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
803
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
804 804
 	    
805 805
 	    if ($globalTimezone != '') {
806 806
 		date_default_timezone_set($globalTimezone);
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 	{
833 833
 	    $limit_array = explode(",", $limit);
834 834
 	    
835
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
836
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
835
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
836
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
837 837
 	    
838 838
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
839 839
 	    {
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 	
845 845
 
846 846
 	if ($origLat != "" && $origLon != "" && $dist != "") {
847
-		$dist = number_format($dist*0.621371,2,'.','');
848
-		$query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
847
+		$dist = number_format($dist*0.621371, 2, '.', '');
848
+		$query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
849 849
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
850 850
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
851 851
 	} else {
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
 			$additional_query .= " AND (tracker_archive_output.waypoints <> '')";
863 863
 		}
864 864
 
865
-		$query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
865
+		$query = "SELECT tracker_archive_output.* FROM tracker_archive_output 
866 866
 		    WHERE tracker_archive_output.ident <> '' 
867 867
 		    ".$additional_query."
868 868
 		    ".$filter_query.$orderby_query;
869 869
 	}
870
-	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
870
+	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
871 871
 
872 872
 	return $spotter_array;
873 873
     }
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
                 try {
885 885
                         $sth = $this->db->prepare($query);
886 886
                         $sth->execute();
887
-                } catch(PDOException $e) {
887
+                } catch (PDOException $e) {
888 888
                         return "error";
889 889
                 }
890 890
 	}
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 	{
922 922
 	    $limit_array = explode(",", $limit);
923 923
 	    
924
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
925
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
924
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
925
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
926 926
 	    
927 927
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
928 928
 	    {
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 	$query_values = array();
964 964
 	$limit_query = '';
965 965
 	$additional_query = '';
966
-	$filter_query = $this->getFilter($filter,true,true);
966
+	$filter_query = $this->getFilter($filter, true, true);
967 967
 	
968 968
 	if ($owner != "")
969 969
 	{
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
 	{
981 981
 	    $limit_array = explode(",", $limit);
982 982
 	    
983
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
984
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
983
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
984
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
985 985
 	    
986 986
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
987 987
 	    {
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 	$query_values = array();
1022 1022
 	$limit_query = '';
1023 1023
 	$additional_query = '';
1024
-	$filter_query = $this->getFilter($filter,true,true);
1024
+	$filter_query = $this->getFilter($filter, true, true);
1025 1025
 	
1026 1026
 	if ($pilot != "")
1027 1027
 	{
@@ -1033,8 +1033,8 @@  discard block
 block discarded – undo
1033 1033
 	{
1034 1034
 	    $limit_array = explode(",", $limit);
1035 1035
 	    
1036
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1037
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1036
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1037
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1038 1038
 	    
1039 1039
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1040 1040
 	    {
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
     * @return Array the airline country list
1065 1065
     *
1066 1066
     */
1067
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1067
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1068 1068
     {
1069 1069
 	global $globalDBdriver;
1070 1070
 	/*
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 	$flight_array = array();
1094 1094
 	$temp_array = array();
1095 1095
         
1096
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1096
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1097 1097
 	{
1098 1098
 	    $temp_array['flight_count'] = $row['nb'];
1099 1099
 	    $temp_array['flight_country'] = $row['name'];
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
     * @return Array the airline country list
1111 1111
     *
1112 1112
     */
1113
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1113
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1114 1114
     {
1115 1115
 	global $globalDBdriver;
1116 1116
 	/*
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	$flight_array = array();
1140 1140
 	$temp_array = array();
1141 1141
         
1142
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1142
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1143 1143
 	{
1144 1144
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1145 1145
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1157,14 +1157,14 @@  discard block
 block discarded – undo
1157 1157
     * @return Array the spotter information
1158 1158
     *
1159 1159
     */
1160
-    public function getDateArchiveTrackerDataById($id,$date)
1160
+    public function getDateArchiveTrackerDataById($id, $date)
1161 1161
     {
1162 1162
 	$Tracker = new Tracker($this->db);
1163 1163
 	date_default_timezone_set('UTC');
1164 1164
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1165
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1166
-	$date = date('c',$date);
1167
-	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1165
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1166
+	$date = date('c', $date);
1167
+	$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1168 1168
 	return $spotter_array;
1169 1169
     }
1170 1170
 
@@ -1174,14 +1174,14 @@  discard block
 block discarded – undo
1174 1174
     * @return Array the spotter information
1175 1175
     *
1176 1176
     */
1177
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1177
+    public function getDateArchiveTrackerDataByIdent($ident, $date)
1178 1178
     {
1179 1179
 	$Tracker = new Tracker($this->db);
1180 1180
 	date_default_timezone_set('UTC');
1181 1181
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1182
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1183
-	$date = date('c',$date);
1184
-	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1182
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1183
+	$date = date('c', $date);
1184
+	$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1185 1185
 	return $spotter_array;
1186 1186
     }
1187 1187
 
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
     * @return Array the spotter information
1192 1192
     *
1193 1193
     */
1194
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1194
+    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1195 1195
     {
1196 1196
 	global $global_query;
1197 1197
 	$Tracker = new Tracker();
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 	$query_values = array();
1200 1200
 	$limit_query = '';
1201 1201
 	$additional_query = '';
1202
-	$filter_query = $this->getFilter($filters,true,true);
1202
+	$filter_query = $this->getFilter($filters, true, true);
1203 1203
 	
1204 1204
 	if ($airport != "")
1205 1205
 	{
@@ -1216,8 +1216,8 @@  discard block
 block discarded – undo
1216 1216
 	{
1217 1217
 	    $limit_array = explode(",", $limit);
1218 1218
 	    
1219
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1220
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1219
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1220
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1221 1221
 	    
1222 1222
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1223 1223
 	    {
Please login to merge, or discard this patch.
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		if (isset($filter[0]['source'])) {
27 27
 			$filters = array_merge($filters,$filter);
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) {
30
+			$filter = array_merge($filter,$globalFilter);
31
+		}
30 32
 		$filter_query_join = '';
31 33
 		$filter_query_where = '';
32 34
 		foreach($filters as $flt) {
@@ -72,8 +74,11 @@  discard block
 block discarded – undo
72 74
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73 75
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74 76
 		}
75
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77
+		if ($filter_query_where == '' && $where) {
78
+			$filter_query_where = ' WHERE';
79
+		} elseif ($filter_query_where != '' && $and) {
80
+			$filter_query_where .= ' AND';
81
+		}
77 82
 		if ($filter_query_where != '') {
78 83
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79 84
 		}
@@ -87,9 +92,14 @@  discard block
 block discarded – undo
87 92
 		if ($over_country == '') {
88 93
 			$Tracker = new Tracker($this->db);
89 94
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
90
-			if (!empty($data_country)) $country = $data_country['iso2'];
91
-			else $country = '';
92
-		} else $country = $over_country;
95
+			if (!empty($data_country)) {
96
+				$country = $data_country['iso2'];
97
+			} else {
98
+				$country = '';
99
+			}
100
+		} else {
101
+			$country = $over_country;
102
+		}
93 103
 		// Route is not added in tracker_archive
94 104
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
95 105
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -588,7 +598,9 @@  discard block
 block discarded – undo
588 598
 		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
589 599
 		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
590 600
 		    $translate = $Translation->ident2icao($q_item);
591
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
601
+		    if ($translate != $q_item) {
602
+		    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
603
+		    }
592 604
 		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
593 605
 		    $additional_query .= ")";
594 606
 		}
@@ -806,7 +818,9 @@  discard block
 block discarded – undo
806 818
 		date_default_timezone_set($globalTimezone);
807 819
 		$datetime = new DateTime();
808 820
 		$offset = $datetime->format('P');
809
-	    } else $offset = '+00:00';
821
+	    } else {
822
+	    	$offset = '+00:00';
823
+	    }
810 824
 
811 825
 
812 826
 	    if ($date_array[1] != "")
@@ -1082,9 +1096,13 @@  discard block
 block discarded – undo
1082 1096
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1083 1097
 			}
1084 1098
 		}
1085
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1099
+                if ($sincedate != '') {
1100
+                	$query .= "AND date > '".$sincedate."' ";
1101
+                }
1086 1102
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1087
-	if ($limit) $query .= " LIMIT 0,10";
1103
+	if ($limit) {
1104
+		$query .= " LIMIT 0,10";
1105
+	}
1088 1106
       
1089 1107
 	
1090 1108
 	$sth = $this->db->prepare($query);
@@ -1128,9 +1146,13 @@  discard block
 block discarded – undo
1128 1146
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1129 1147
 			}
1130 1148
 		}
1131
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1149
+                if ($sincedate != '') {
1150
+                	$query .= "AND s.date > '".$sincedate."' ";
1151
+                }
1132 1152
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1133
-	if ($limit) $query .= " LIMIT 0,10";
1153
+	if ($limit) {
1154
+		$query .= " LIMIT 0,10";
1155
+	}
1134 1156
       
1135 1157
 	
1136 1158
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
header.php 3 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,31 +8,31 @@  discard block
 block discarded – undo
8 8
 if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9 9
 else $MapType = $globalMapProvider;
10 10
 if (isset($_GET['3d'])) {
11
-	setcookie('MapFormat','3d');
11
+	setcookie('MapFormat', '3d');
12 12
 } else if (isset($_GET['2d'])) {
13
-	setcookie('MapFormat','2d');
13
+	setcookie('MapFormat', '2d');
14 14
 }
15 15
 
16 16
 if (isset($_POST['archive'])) {
17
-	setcookie('archive','true');
18
-	setcookie('archive_begin',strtotime($_POST['start_date']));
19
-	setcookie('archive_end',strtotime($_POST['end_date']));
20
-	setcookie('archive_speed',$_POST['archivespeed']);
17
+	setcookie('archive', 'true');
18
+	setcookie('archive_begin', strtotime($_POST['start_date']));
19
+	setcookie('archive_end', strtotime($_POST['end_date']));
20
+	setcookie('archive_speed', $_POST['archivespeed']);
21 21
 }
22 22
 if (isset($_POST['noarchive'])) {
23
-	setcookie('archive','false',-1);
24
-	setcookie('archive_begin','',-1);
25
-	setcookie('archive_end','',-1);
26
-	setcookie('archive_speed','',-1);
23
+	setcookie('archive', 'false', -1);
24
+	setcookie('archive_begin', '', -1);
25
+	setcookie('archive_end', '', -1);
26
+	setcookie('archive_speed', '', -1);
27 27
 }
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
30
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
31
+	    return strpos($key, 'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
35
-		setcookie($filt,null,-1);
35
+		setcookie($filt, null, -1);
36 36
 	}
37 37
 }
38 38
 ?>
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
241 241
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
242 242
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
243
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
243
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
244 244
 <?php
245 245
 		if (!isset($type) || $type == 'aircraft') {
246 246
 ?>
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
311 311
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
312 312
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
313
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
313
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
314 314
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
315 315
 <?php
316 316
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 ?>
590 590
       <div class="search">
591 591
       <form action="<?php print $globalURL; ?>/search" method="get">
592
-		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
592
+		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
593 593
 	</form>
594 594
 	</div>
595 595
   	<div class="social">
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	print '</div>';
608 608
 }
609 609
 
610
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
610
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
611 611
 ?>
612 612
     <div class="top-header clear" role="main">
613 613
 <?php
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
     </div>
621 621
 <?php
622 622
 }
623
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
623
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
624 624
 {
625 625
     ?>
626 626
     <div class="top-header clear" role="main">
@@ -633,15 +633,15 @@  discard block
 block discarded – undo
633 633
         var zoom = 13;
634 634
 //create the map
635 635
 <?php
636
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
636
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
637 637
 ?>
638 638
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
639 639
 <?php
640
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
640
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
641 641
 ?>
642 642
   map = L.map('map', { zoomControl:true });
643 643
 <?php
644
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
644
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
645 645
 ?>
646 646
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
647 647
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
650 650
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
651 651
 <?php
652
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
652
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
653 653
 ?>
654 654
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
655 655
 <?php
Please login to merge, or discard this patch.
Braces   +52 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
6 6
 $current_page = $file_path['filename'];
7 7
 date_default_timezone_set($globalTimezone);
8
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9
-else $MapType = $globalMapProvider;
8
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
9
+	$MapType = $_COOKIE['MapType'];
10
+} else {
11
+	$MapType = $globalMapProvider;
12
+}
10 13
 if (isset($_GET['3d'])) {
11 14
 	setcookie('MapFormat','3d');
12 15
 } else if (isset($_GET['2d'])) {
@@ -240,7 +243,13 @@  discard block
 block discarded – undo
240 243
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
241 244
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
242 245
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
243
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
246
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
247
+	print '&latitude='.$latitude;
248
+}
249
+?><?php if(isset($longitude)) {
250
+	print '&longitude='.$longitude;
251
+}
252
+?>&<?php print time(); ?>"></script>
244 253
 <?php
245 254
 		if (!isset($type) || $type == 'aircraft') {
246 255
 ?>
@@ -310,7 +319,13 @@  discard block
 block discarded – undo
310 319
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
311 320
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
312 321
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
313
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
322
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
323
+	print '&latitude='.$latitude;
324
+}
325
+?><?php if(isset($longitude)) {
326
+	print '&longitude='.$longitude;
327
+}
328
+?>&<?php print time(); ?>"></script>
314 329
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
315 330
 <?php
316 331
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -384,7 +399,12 @@  discard block
 block discarded – undo
384 399
         <span class="icon-bar"></span>
385 400
       </button>
386 401
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a>
387
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
402
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
403
+	print '/';
404
+} else {
405
+	print $globalURL;
406
+}
407
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
388 408
     </div>
389 409
     <div class="collapse navbar-collapse">
390 410
 
@@ -410,7 +430,10 @@  discard block
 block discarded – undo
410 430
 <?php
411 431
     }
412 432
 ?>
413
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
433
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
434
+	echo 'right-';
435
+}
436
+?>caret"></b></a>
414 437
           <ul class="dropdown-menu">
415 438
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
416 439
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
@@ -467,8 +490,14 @@  discard block
 block discarded – undo
467 490
         </li>
468 491
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
469 492
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
470
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
471
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
493
+        <li class="dropdown<?php if ($sub) {
494
+	echo '-submenu';
495
+}
496
+?>">
497
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
498
+	echo 'right-';
499
+}
500
+?>caret"></b></a>
472 501
           <ul class="dropdown-menu">
473 502
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
474 503
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -497,7 +526,10 @@  discard block
 block discarded – undo
497 526
 <?php
498 527
 	}
499 528
 ?>
500
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
529
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
530
+	echo 'right-';
531
+}
532
+?>caret"></b></a>
501 533
 		<ul class="dropdown-menu">
502 534
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
503 535
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -528,7 +560,10 @@  discard block
 block discarded – undo
528 560
 <?php
529 561
 	}
530 562
 ?>
531
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
563
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
564
+	echo 'right-';
565
+}
566
+?>caret"></b></a>
532 567
 		<ul class="dropdown-menu">
533 568
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
534 569
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -577,7 +612,9 @@  discard block
 block discarded – undo
577 612
   		        $alllang = $Language->getLanguages();
578 613
   		        foreach ($alllang as $key => $lang) {
579 614
   		            print '<option value="'.$key.'"';
580
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
615
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
616
+  		            	print ' selected ';
617
+  		            }
581 618
   		            print '>'.$lang[0].'</option>';
582 619
   		        }
583 620
   		    ?>
@@ -730,4 +767,7 @@  discard block
 block discarded – undo
730 767
 
731 768
 ?>
732 769
 
733
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
770
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
771
+	print 'index ';
772
+}
773
+?>clear">
Please login to merge, or discard this patch.
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 ?>
169 169
 <?php 
170
-    if (isset($_POST['archive'])) {
170
+	if (isset($_POST['archive'])) {
171 171
 ?>
172 172
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
173 173
 <?php 
174
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
174
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
175 175
 ?>
176 176
 
177 177
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
178 178
 <?php    
179
-	    }
180
-    } else {
179
+		}
180
+	} else {
181 181
 ?>
182 182
 <?php
183 183
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 */
190 190
 ?>
191 191
 <?php 
192
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
192
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
193 193
 ?>
194 194
 <?php
195 195
 //		if (isset($globalBeta) && $globalBeta) {
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script>
217 217
 <?php
218 218
 		}
219
-	    }
219
+		}
220 220
 ?>
221 221
 <?php
222 222
 //	}
223 223
 ?>
224 224
 <?php
225
-    }
225
+	}
226 226
 }
227 227
 ?>
228 228
 <?php
@@ -391,24 +391,24 @@  discard block
 block discarded – undo
391 391
       <ul class="nav navbar-nav">
392 392
 
393 393
 <?php 
394
-    $sub = false;
395
-    if (((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))) || (isset($globalMarine) && $globalMarine === TRUE && isset($globalTracker) && $globalTracker === TRUE)) {
394
+	$sub = false;
395
+	if (((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))) || (isset($globalMarine) && $globalMarine === TRUE && isset($globalTracker) && $globalTracker === TRUE)) {
396 396
 	$sub = true;
397
-    }
397
+	}
398 398
 ?>
399 399
 <?php
400
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
400
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
401 401
 ?>
402 402
     <li class="dropdown">
403 403
 <?php
404
-    if ($sub) {
404
+	if ($sub) {
405 405
 ?>
406 406
       	<li class="dropdown">
407 407
           <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Aircrafts"); ?> <b class="caret"></b></a>
408 408
 	<ul class="dropdown-menu multi-level">
409 409
       	<li class="dropdown-submenu">
410 410
 <?php
411
-    }
411
+	}
412 412
 ?>
413 413
           <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
414 414
           <ul class="dropdown-menu">
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
417 417
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
418 418
 <?php
419
-    if ((!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
419
+	if ((!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
420 420
 ?>
421 421
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
422 422
 <?php
423
-    } else {
423
+	} else {
424 424
 ?>
425 425
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
426 426
 <?php
427
-    }
427
+	}
428 428
 ?>
429 429
 			<li><hr /></li>
430 430
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -432,34 +432,34 @@  discard block
 block discarded – undo
432 432
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
433 433
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
434 434
             <?php
435
-        	if ($globalACARS) {
436
-        	    if (isset($globalDemo) && $globalDemo) {
437
-    	    ?>
435
+			if ($globalACARS) {
436
+				if (isset($globalDemo) && $globalDemo) {
437
+			?>
438 438
             <li><hr /></li>
439 439
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
440 440
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
441 441
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
442 442
             <?php
443
-        	    } else {
444
-    	    ?>
443
+				} else {
444
+			?>
445 445
             <li><hr /></li>
446 446
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
447 447
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
448 448
             <?php
449
-        	    }
450
-        	}
451
-    	    ?>
449
+				}
450
+			}
451
+			?>
452 452
     	    <?php
453
-    	        if (isset($globalAccidents) && $globalAccidents) {
454
-    	    ?>
453
+				if (isset($globalAccidents) && $globalAccidents) {
454
+			?>
455 455
             <li><hr /></li>
456 456
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
457 457
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
458 458
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
459 459
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
460 460
             <?php
461
-        	}
462
-    	    ?>
461
+			}
462
+			?>
463 463
             <li><hr /></li>
464 464
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
465 465
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -482,14 +482,14 @@  discard block
 block discarded – undo
482 482
     </ul>
483 483
 <?php
484 484
 	}
485
-    }
485
+	}
486 486
 ?>
487 487
 <?php
488
-    if (isset($globalMarine) && $globalMarine) {
488
+	if (isset($globalMarine) && $globalMarine) {
489 489
 ?>
490 490
     <li class="dropdown">
491 491
 <?php
492
-        if ($sub) {
492
+		if ($sub) {
493 493
 ?>
494 494
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Vessels"); ?> <b class="caret"></b></a>
495 495
 	<ul class="dropdown-menu multi-level">
@@ -513,14 +513,14 @@  discard block
 block discarded – undo
513 513
 	}
514 514
 ?>
515 515
 <?php
516
-    }
516
+	}
517 517
 ?>
518 518
 <?php
519
-    if (isset($globalTracker) && $globalTracker) {
519
+	if (isset($globalTracker) && $globalTracker) {
520 520
 ?>
521 521
     <li class="dropdown">
522 522
 <?php
523
-        if ($sub) {
523
+		if ($sub) {
524 524
 ?>
525 525
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a>
526 526
 	<ul class="dropdown-menu multi-level">
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 	}
545 545
 ?>
546 546
 <?php
547
-    }
547
+	}
548 548
 ?>
549 549
 
550 550
         <li class="dropdown">
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
           	<li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li>
554 554
           	<li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li>
555 555
 <?php
556
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
556
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
557 557
 ?>
558 558
 		<li><hr /></li>
559 559
 		<li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li>
560 560
 <?php
561
-    }
561
+	}
562 562
 ?>
563 563
 	    <?php if (isset($globalContribute) && $globalContribute) { ?>
564 564
                 <li><hr /></li>
@@ -579,14 +579,14 @@  discard block
 block discarded – undo
579 579
   	    <form>
580 580
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
581 581
   		    <?php
582
-  		        $Language = new Language();
583
-  		        $alllang = $Language->getLanguages();
584
-  		        foreach ($alllang as $key => $lang) {
585
-  		            print '<option value="'.$key.'"';
586
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
587
-  		            print '>'.$lang[0].'</option>';
588
-  		        }
589
-  		    ?>
582
+  				$Language = new Language();
583
+  				$alllang = $Language->getLanguages();
584
+  				foreach ($alllang as $key => $lang) {
585
+  					print '<option value="'.$key.'"';
586
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
587
+  					print '>'.$lang[0].'</option>';
588
+  				}
589
+  			?>
590 590
   		</select>
591 591
   	    </form>
592 592
   	</div>
@@ -617,18 +617,18 @@  discard block
 block discarded – undo
617 617
 ?>
618 618
     <div class="top-header clear" role="main">
619 619
 <?php
620
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
620
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
621 621
 ?>
622 622
     <div id="archive-map"></div>
623 623
 <?php
624
-    }
624
+	}
625 625
 ?>
626 626
     </div>
627 627
 <?php
628 628
 }
629 629
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
630 630
 {
631
-    ?>
631
+	?>
632 632
     <div class="top-header clear" role="main">
633 633
         <div id="map"></div>
634 634
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -639,15 +639,15 @@  discard block
 block discarded – undo
639 639
         var zoom = 13;
640 640
 //create the map
641 641
 <?php
642
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
642
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
643 643
 ?>
644 644
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
645 645
 <?php
646
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
646
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
647 647
 ?>
648 648
   map = L.map('map', { zoomControl:true });
649 649
 <?php
650
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
650
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
651 651
 ?>
652 652
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
653 653
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -655,22 +655,22 @@  discard block
 block discarded – undo
655 655
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
656 656
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
657 657
 <?php
658
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
658
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
659 659
 ?>
660 660
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
661 661
 <?php
662
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
662
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
663 663
 ?>
664 664
   map = L.map('map', { zoomControl:true });
665 665
 <?php
666
-    }
666
+	}
667 667
 ?>
668 668
   //initialize the layer group for the aircrft markers
669 669
   var layer_data = L.layerGroup();
670 670
 
671 671
   //a few title layers
672 672
 <?php
673
-    if ($globalMapProvider == 'Mapbox') {
673
+	if ($globalMapProvider == 'Mapbox') {
674 674
 ?>
675 675
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
676 676
     maxZoom: 18,
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
     token : '<?php print $globalMapboxToken; ?>'
682 682
   }).addTo(map);
683 683
 <?php
684
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
684
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
685 685
 ?>
686 686
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
687 687
     maxZoom: 18,
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
690 690
   }).addTo(map);
691 691
 <?php
692
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
692
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
693 693
 ?>
694 694
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
695 695
     maxZoom: 18,
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
699 699
   }).addTo(map);
700 700
 <?php
701
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
701
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
702 702
 ?>
703 703
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
704 704
     maxZoom: 18,
@@ -707,27 +707,27 @@  discard block
 block discarded – undo
707 707
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
708 708
   }).addTo(map);
709 709
 <?php
710
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
710
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
711 711
 ?>
712 712
     var googleLayer = new L.Google('ROADMAP');
713 713
     map.addLayer(googleLayer);
714 714
 <?php
715
-    } elseif ($globalMapProvider == 'Google-Satellite') {
715
+	} elseif ($globalMapProvider == 'Google-Satellite') {
716 716
 ?>
717 717
     var googleLayer = new L.Google('SATELLITE');
718 718
     map.addLayer(googleLayer);
719 719
 <?php
720
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
720
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
721 721
 ?>
722 722
     var googleLayer = new L.Google('HYBRID');
723 723
     map.addLayer(googleLayer);
724 724
 <?php
725
-    } elseif ($globalMapProvider == 'Google-Terrain') {
725
+	} elseif ($globalMapProvider == 'Google-Terrain') {
726 726
 ?>
727 727
     var googleLayer = new L.Google('Terrain');
728 728
     map.addLayer(googleLayer);
729 729
 <?php
730
-    }
730
+	}
731 731
 ?>
732 732
         </script>
733 733
     </div>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Braces   +931 added lines, -320 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -54,35 +58,62 @@  discard block
 block discarded – undo
54 58
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 59
 if (isset($options['s'])) {
56 60
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
59
-} elseif (isset($options['source'])) {
61
+    if (isset($options['format'])) {
62
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+    } else {
64
+    	$globalSources[] = array('host' => $options['s']);
65
+    }
66
+    } elseif (isset($options['source'])) {
60 67
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
63
-}
68
+    if (isset($options['format'])) {
69
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
70
+    } else {
71
+    	$globalSources[] = array('host' => $options['source']);
72
+    }
73
+    }
64 74
 if (isset($options['aprsserverhost'])) {
65 75
 	$globalServerAPRS = TRUE;
66 76
 	$globalServerAPRShost = $options['aprsserverhost'];
67 77
 }
68
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
69
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
70
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
71
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
72
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
73
-if (isset($options['server'])) $globalServer = TRUE;
74
-if (isset($options['idsource'])) $id_source = $options['idsource'];
75
-else $id_source = 1;
78
+if (isset($options['aprsserverport'])) {
79
+	$globalServerAPRSport = $options['aprsserverport'];
80
+}
81
+if (isset($options['aprsserverssid'])) {
82
+	$globalServerAPRSssid = $options['aprsserverssid'];
83
+}
84
+if (isset($options['aprsserverpass'])) {
85
+	$globalServerAPRSpass = $options['aprsserverpass'];
86
+}
87
+if (isset($options['noaprsserver'])) {
88
+	$globalServerAPRS = FALSE;
89
+}
90
+if (isset($options['nodaemon'])) {
91
+	$globalDaemon = FALSE;
92
+}
93
+if (isset($options['server'])) {
94
+	$globalServer = TRUE;
95
+}
96
+if (isset($options['idsource'])) {
97
+	$id_source = $options['idsource'];
98
+} else {
99
+	$id_source = 1;
100
+}
76 101
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
102
+    if ($globalDebug) {
103
+    	echo "Using Server Mode\n";
104
+    }
78 105
     $SI=new SpotterServer();
79 106
 /*
80 107
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 108
     $SI = new adsb2aprs();
82 109
     $SI->connect();
83 110
 */
84
-} else $SI=new SpotterImport($Connection->db);
85
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
111
+} else {
112
+	$SI=new SpotterImport($Connection->db);
113
+}
114
+if (isset($globalTracker) && $globalTracker) {
115
+	$TI = new TrackerImport($Connection->db);
116
+}
86 117
 if (isset($globalMarine) && $globalMarine) {
87 118
     $AIS = new AIS();
88 119
     $MI = new MarineImport($Connection->db);
@@ -104,7 +135,9 @@  discard block
 block discarded – undo
104 135
 }
105 136
 
106 137
 // let's try and connect
107
-if ($globalDebug) echo "Connecting...\n";
138
+if ($globalDebug) {
139
+	echo "Connecting...\n";
140
+}
108 141
 $use_aprs = false;
109 142
 $aprs_full = false;
110 143
 $reset = 0;
@@ -113,7 +146,9 @@  discard block
 block discarded – undo
113 146
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114 147
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115 148
     $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
149
+    if ($globalDebug) {
150
+    	echo 'Connect to all...'."\n";
151
+    }
117 152
     foreach ($hosts as $id => $value) {
118 153
 	$host = $value['host'];
119 154
 	$globalSources[$id]['last_exec'] = 0;
@@ -123,27 +158,37 @@  discard block
 block discarded – undo
123 158
         	//$formats[$id] = 'deltadbtxt';
124 159
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 160
         	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to deltadb source (".$host.")...\n";
163
+        	}
127 164
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128 165
         	//$formats[$id] = 'vatsimtxt';
129 166
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 167
         	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to vatsim source (".$host.")...\n";
170
+        	}
132 171
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133 172
         	//$formats[$id] = 'aircraftlistjson';
134 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 174
         	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
175
+        	if ($globalDebug) {
176
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	}
137 178
     	    } else if (preg_match('/opensky/i',$host)) {
138 179
         	//$formats[$id] = 'aircraftlistjson';
139 180
         	$globalSources[$id]['format'] = 'opensky';
140 181
         	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to opensky source (".$host.")...\n";
184
+        	}
142 185
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143 186
         	//$formats[$id] = 'radarvirtueljson';
144 187
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 188
         	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
189
+        	if ($globalDebug) {
190
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
191
+        	}
147 192
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 194
         	    exit(0);
@@ -152,7 +197,9 @@  discard block
 block discarded – undo
152 197
         	//$formats[$id] = 'planeupdatefaa';
153 198
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 199
         	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
200
+        	if ($globalDebug) {
201
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
202
+        	}
156 203
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157 204
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 205
         	    exit(0);
@@ -161,26 +208,36 @@  discard block
 block discarded – undo
161 208
         	//$formats[$id] = 'phpvmacars';
162 209
         	$globalSources[$id]['format'] = 'phpvmacars';
163 210
         	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
211
+        	if ($globalDebug) {
212
+        		echo "Connect to phpvmacars source (".$host.")...\n";
213
+        	}
165 214
             } else if (preg_match('/VAM-json.php$/i',$host)) {
166 215
         	//$formats[$id] = 'phpvmacars';
167 216
         	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
217
+        	if ($globalDebug) {
218
+        		echo "Connect to Vam source (".$host.")...\n";
219
+        	}
169 220
             } else if (preg_match('/whazzup/i',$host)) {
170 221
         	//$formats[$id] = 'whazzup';
171 222
         	$globalSources[$id]['format'] = 'whazzup';
172 223
         	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
224
+        	if ($globalDebug) {
225
+        		echo "Connect to whazzup source (".$host.")...\n";
226
+        	}
174 227
             } else if (preg_match('/recentpireps/i',$host)) {
175 228
         	//$formats[$id] = 'pirepsjson';
176 229
         	$globalSources[$id]['format'] = 'pirepsjson';
177 230
         	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
231
+        	if ($globalDebug) {
232
+        		echo "Connect to pirepsjson source (".$host.")...\n";
233
+        	}
179 234
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180 235
         	//$formats[$id] = 'fr24json';
181 236
         	$globalSources[$id]['format'] = 'fr24json';
182 237
         	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to fr24 source (".$host.")...\n";
240
+        	}
184 241
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185 242
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186 243
         	    exit(0);
@@ -189,7 +246,9 @@  discard block
 block discarded – undo
189 246
         	//$formats[$id] = 'fr24json';
190 247
         	$globalSources[$id]['format'] = 'myshiptracking';
191 248
         	//$last_exec['fr24json'] = 0;
192
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to myshiptracking source (".$host.")...\n";
251
+        	}
193 252
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194 253
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195 254
         	    exit(0);
@@ -198,17 +257,24 @@  discard block
 block discarded – undo
198 257
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199 258
         	//$formats[$id] = 'tsv';
200 259
         	$globalSources[$id]['format'] = 'tsv';
201
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
+        	if ($globalDebug) {
261
+        		echo "Connect to tsv source (".$host.")...\n";
262
+        	}
202 263
             }
203 264
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204 265
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205 266
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
206 267
     		    if ($idf !== false) {
207 268
     			$httpfeeds[$id] = $idf;
208
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
+        		if ($globalDebug) {
270
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
271
+        		}
272
+    		    } elseif ($globalDebug) {
273
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
209 274
     		    }
210
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+    		} elseif ($globalDebug) {
276
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+    		}
212 278
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213 279
 	    $hostport = explode(':',$host);
214 280
 	    if (isset($hostport[1])) {
@@ -248,17 +314,25 @@  discard block
 block discarded – undo
248 314
         		//$formats[$id] = 'beast';
249 315
         		$globalSources[$id]['format'] = 'beast';
250 316
 		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
317
+		    } else {
318
+		    	$globalSources[$id]['format'] = 'sbs';
319
+		    }
252 320
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 321
 		}
254
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
322
+		if ($globalDebug) {
323
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
324
+		}
255 325
             } else {
256
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
326
+		if ($globalDebug) {
327
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
328
+		}
257 329
     	    }
258 330
         }
259 331
     }
260 332
 }
261
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
333
+if (!isset($globalMinFetch)) {
334
+	$globalMinFetch = 15;
335
+}
262 336
 
263 337
 // Initialize all
264 338
 $status = array();
@@ -267,13 +341,19 @@  discard block
 block discarded – undo
267 341
 $formats = array();
268 342
 $last_exec = array();
269 343
 $time = time();
270
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
271
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272
-else $timeout = 20;
344
+if (isset($globalSourcesTimeout)) {
345
+	$timeout = $globalSourcesTimeOut;
346
+} else if (isset($globalSBS1TimeOut)) {
347
+	$timeout = $globalSBS1TimeOut;
348
+} else {
349
+	$timeout = 20;
350
+}
273 351
 $errno = '';
274 352
 $errstr='';
275 353
 
276
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
354
+if (!isset($globalDaemon)) {
355
+	$globalDaemon = TRUE;
356
+}
277 357
 /* Initiate connections to all the hosts simultaneously */
278 358
 //connect_all($hosts);
279 359
 //connect_all($globalSources);
@@ -299,7 +379,9 @@  discard block
 block discarded – undo
299 379
     if (isset($source['format']) && $source['format'] == 'aprs') {
300 380
 	$aprs_connect = 0;
301 381
 	$use_aprs = true;
302
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
382
+	if (isset($source['port']) && $source['port'] == '10152') {
383
+		$aprs_full = true;
384
+	}
303 385
 	break;
304 386
     }
305 387
 }
@@ -310,25 +392,48 @@  discard block
 block discarded – undo
310 392
 	$aprs_connect = 0;
311 393
 	$aprs_keep = 120;
312 394
 	$aprs_last_tx = time();
313
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
315
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
317
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319
-	if ($aprs_full) $aprs_filter = '';
320
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
321
-	else $aprs_pass = '-1';
395
+	if (isset($globalAPRSversion)) {
396
+		$aprs_version = $globalAPRSversion;
397
+	} else {
398
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
399
+	}
400
+	if (isset($globalAPRSssid)) {
401
+		$aprs_ssid = $globalAPRSssid;
402
+	} else {
403
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
404
+	}
405
+	if (isset($globalAPRSfilter)) {
406
+		$aprs_filter = $globalAPRSfilter;
407
+	} else {
408
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
409
+	}
410
+	if ($aprs_full) {
411
+		$aprs_filter = '';
412
+	}
413
+	if (isset($globalAPRSpass)) {
414
+		$aprs_pass = $globalAPRSpass;
415
+	} else {
416
+		$aprs_pass = '-1';
417
+	}
322 418
 
323
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
324
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
325
-}
419
+	if ($aprs_filter != '') {
420
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
421
+	} else {
422
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
423
+	}
424
+	}
326 425
 
327 426
 // connected - lets do some work
328
-if ($globalDebug) echo "Connected!\n";
427
+if ($globalDebug) {
428
+	echo "Connected!\n";
429
+}
329 430
 sleep(1);
330
-if ($globalDebug) echo "SCAN MODE \n\n";
331
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
431
+if ($globalDebug) {
432
+	echo "SCAN MODE \n\n";
433
+}
434
+if (!isset($globalCronEnd)) {
435
+	$globalCronEnd = 60;
436
+}
332 437
 $endtime = time()+$globalCronEnd;
333 438
 $i = 1;
334 439
 $tt = array();
@@ -342,10 +447,14 @@  discard block
 block discarded – undo
342 447
 
343 448
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 449
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
450
+    if (!$globalDaemon) {
451
+    	$i = $endtime-time();
452
+    }
346 453
     // Delete old ATC
347 454
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
455
+	if ($globalDebug) {
456
+		echo 'Delete old ATC...'."\n";
457
+	}
349 458
         $ATC->deleteOldATC();
350 459
     }
351 460
     
@@ -353,10 +462,14 @@  discard block
 block discarded – undo
353 462
     if (count($last_exec) == count($globalSources)) {
354 463
 	$max = $globalMinFetch;
355 464
 	foreach ($last_exec as $last) {
356
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
465
+	    if ((time() - $last['last']) < $max) {
466
+	    	$max = time() - $last['last'];
467
+	    }
357 468
 	}
358 469
 	if ($max != $globalMinFetch) {
359
-	    if ($globalDebug) echo 'Sleeping...'."\n";
470
+	    if ($globalDebug) {
471
+	    	echo 'Sleeping...'."\n";
472
+	    }
360 473
 	    sleep($globalMinFetch-$max+2);
361 474
 	}
362 475
     }
@@ -365,11 +478,15 @@  discard block
 block discarded – undo
365 478
     //foreach ($formats as $id => $value) {
366 479
     foreach ($globalSources as $id => $value) {
367 480
 	date_default_timezone_set('UTC');
368
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
481
+	if (!isset($last_exec[$id]['last'])) {
482
+		$last_exec[$id]['last'] = 0;
483
+	}
369 484
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
370 485
 	    //$buffer = $Common->getData($hosts[$id]);
371 486
 	    $buffer = $Common->getData($value['host']);
372
-	    if ($buffer != '') $reset = 0;
487
+	    if ($buffer != '') {
488
+	    	$reset = 0;
489
+	    }
373 490
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374 491
 	    $buffer = explode('\n',$buffer);
375 492
 	    foreach ($buffer as $line) {
@@ -378,20 +495,41 @@  discard block
 block discarded – undo
378 495
 	            $data = array();
379 496
 	            $data['hex'] = $line[1]; // hex
380 497
 	            $data['ident'] = $line[2]; // ident
381
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
498
+	            if (isset($line[3])) {
499
+	            	$data['altitude'] = $line[3];
500
+	            }
501
+	            // altitude
502
+	            if (isset($line[4])) {
503
+	            	$data['speed'] = $line[4];
504
+	            }
505
+	            // speed
506
+	            if (isset($line[5])) {
507
+	            	$data['heading'] = $line[5];
508
+	            }
509
+	            // heading
510
+	            if (isset($line[6])) {
511
+	            	$data['latitude'] = $line[6];
512
+	            }
513
+	            // lat
514
+	            if (isset($line[7])) {
515
+	            	$data['longitude'] = $line[7];
516
+	            }
517
+	            // long
386 518
 	            $data['verticalrate'] = ''; // vertical rate
387 519
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388 520
 	            $data['emergency'] = ''; // emergency
389 521
 		    $data['datetime'] = date('Y-m-d H:i:s');
390 522
 		    $data['format_source'] = 'deltadbtxt';
391 523
     		    $data['id_source'] = $id_source;
392
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
524
+		    if (isset($value['name']) && $value['name'] != '') {
525
+		    	$data['source_name'] = $value['name'];
526
+		    }
527
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
528
+		    	$data['noarchive'] = true;
529
+		    }
530
+		    if (isset($value['sourcestats'])) {
531
+		    	$data['sourcestats'] = $value['sourcestats'];
532
+		    }
395 533
     		    $SI->add($data);
396 534
 		    unset($data);
397 535
     		}
@@ -401,7 +539,9 @@  discard block
 block discarded – undo
401 539
 	    date_default_timezone_set('CET');
402 540
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403 541
 	    date_default_timezone_set('UTC');
404
-	    if ($buffer != '') $reset = 0;
542
+	    if ($buffer != '') {
543
+	    	$reset = 0;
544
+	    }
405 545
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406 546
 	    $buffer = explode('\n',$buffer);
407 547
 	    foreach ($buffer as $line) {
@@ -410,16 +550,36 @@  discard block
 block discarded – undo
410 550
 		    $add = false;
411 551
 		    $ais_data = $AIS->parse_line(trim($line));
412 552
 		    $data = array();
413
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553
+		    if (isset($ais_data['ident'])) {
554
+		    	$data['ident'] = $ais_data['ident'];
555
+		    }
556
+		    if (isset($ais_data['mmsi'])) {
557
+		    	$data['mmsi'] = $ais_data['mmsi'];
558
+		    }
559
+		    if (isset($ais_data['speed'])) {
560
+		    	$data['speed'] = $ais_data['speed'];
561
+		    }
562
+		    if (isset($ais_data['heading'])) {
563
+		    	$data['heading'] = $ais_data['heading'];
564
+		    }
565
+		    if (isset($ais_data['latitude'])) {
566
+		    	$data['latitude'] = $ais_data['latitude'];
567
+		    }
568
+		    if (isset($ais_data['longitude'])) {
569
+		    	$data['longitude'] = $ais_data['longitude'];
570
+		    }
571
+		    if (isset($ais_data['status'])) {
572
+		    	$data['status'] = $ais_data['status'];
573
+		    }
574
+		    if (isset($ais_data['type'])) {
575
+		    	$data['type'] = $ais_data['type'];
576
+		    }
577
+		    if (isset($ais_data['imo'])) {
578
+		    	$data['imo'] = $ais_data['imo'];
579
+		    }
580
+		    if (isset($ais_data['callsign'])) {
581
+		    	$data['callsign'] = $ais_data['callsign'];
582
+		    }
423 583
 		    if (isset($ais_data['timestamp'])) {
424 584
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
425 585
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -433,8 +593,12 @@  discard block
 block discarded – undo
433 593
 		    $data['format_source'] = 'aisnmeatxt';
434 594
     		    $data['id_source'] = $id_source;
435 595
 		    //print_r($data);
436
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
437
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
596
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
597
+		    	$data['noarchive'] = true;
598
+		    }
599
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
600
+		    	$MI->add($data);
601
+		    }
438 602
 		    unset($data);
439 603
 		}
440 604
     	    }
@@ -454,20 +618,48 @@  discard block
 block discarded – undo
454 618
 			    if ($line != '') {
455 619
 				$ais_data = $AIS->parse_line(trim($line));
456 620
 				$data = array();
457
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
458
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
459
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
460
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
461
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
462
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
463
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
464
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
465
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
466
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
467
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
468
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
469
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
470
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
621
+				if (isset($ais_data['ident'])) {
622
+					$data['ident'] = $ais_data['ident'];
623
+				}
624
+				if (isset($ais_data['mmsi'])) {
625
+					$data['mmsi'] = $ais_data['mmsi'];
626
+				}
627
+				if (isset($ais_data['speed'])) {
628
+					$data['speed'] = $ais_data['speed'];
629
+				}
630
+				if (isset($ais_data['heading'])) {
631
+					$data['heading'] = $ais_data['heading'];
632
+				}
633
+				if (isset($ais_data['latitude'])) {
634
+					$data['latitude'] = $ais_data['latitude'];
635
+				}
636
+				if (isset($ais_data['longitude'])) {
637
+					$data['longitude'] = $ais_data['longitude'];
638
+				}
639
+				if (isset($ais_data['status'])) {
640
+					$data['status'] = $ais_data['status'];
641
+				}
642
+				if (isset($ais_data['statusid'])) {
643
+					$data['status_id'] = $ais_data['statusid'];
644
+				}
645
+				if (isset($ais_data['type'])) {
646
+					$data['type'] = $ais_data['type'];
647
+				}
648
+				if (isset($ais_data['typeid'])) {
649
+					$data['type_id'] = $ais_data['typeid'];
650
+				}
651
+				if (isset($ais_data['imo'])) {
652
+					$data['imo'] = $ais_data['imo'];
653
+				}
654
+				if (isset($ais_data['callsign'])) {
655
+					$data['callsign'] = $ais_data['callsign'];
656
+				}
657
+				if (isset($ais_data['destination'])) {
658
+					$data['arrival_code'] = $ais_data['destination'];
659
+				}
660
+				if (isset($ais_data['eta_ts'])) {
661
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
662
+				}
471 663
 				if (isset($ais_data['timestamp'])) {
472 664
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
473 665
 				} else {
@@ -475,18 +667,27 @@  discard block
 block discarded – undo
475 667
 				}
476 668
 				$data['format_source'] = 'aisnmeahttp';
477 669
 				$data['id_source'] = $id_source;
478
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
479
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
670
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
671
+					$data['noarchive'] = true;
672
+				}
673
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
674
+					$MI->add($data);
675
+				}
480 676
 				unset($data);
481 677
 			    }
482 678
 			}
483 679
 		    }
484 680
 		} else {
485 681
 		    $format = $value['format'];
486
-		    if (isset($tt[$format])) $tt[$format]++;
487
-		    else $tt[$format] = 0;
682
+		    if (isset($tt[$format])) {
683
+		    	$tt[$format]++;
684
+		    } else {
685
+		    	$tt[$format] = 0;
686
+		    }
488 687
 		    if ($tt[$format] > 30) {
489
-			if ($globalDebug) echo 'Reconnect...'."\n";
688
+			if ($globalDebug) {
689
+				echo 'Reconnect...'."\n";
690
+			}
490 691
 			sleep(2);
491 692
 			$sourceeen[] = $value;
492 693
 			connect_all($sourceeen);
@@ -516,7 +717,9 @@  discard block
 block discarded – undo
516 717
 			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
517 718
 			$data['format_source'] = 'myshiptracking';
518 719
 			$data['id_source'] = $id_source;
519
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
720
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
721
+				$data['noarchive'] = true;
722
+			}
520 723
 			$MI->add($data);
521 724
 			unset($data);
522 725
 		    }
@@ -537,7 +740,9 @@  discard block
 block discarded – undo
537 740
 			    $data['callsign'] = $line['callsign'];
538 741
 			    $data['mmsi'] = $line['mmsi'];
539 742
 			    $data['speed'] = $line['sog'];
540
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
743
+			    if ($line['heading'] != '511') {
744
+			    	$data['heading'] = $line['heading'];
745
+			    }
541 746
 			    $data['latitude'] = $line['latitude'];
542 747
 			    $data['longitude'] = $line['longitude'];
543 748
 			    $data['type_id'] = $line['shiptype'];
@@ -545,7 +750,9 @@  discard block
 block discarded – undo
545 750
 			    $data['datetime'] = $line['time'];
546 751
 			    $data['format_source'] = 'boatbeaconapp';
547 752
 			    $data['id_source'] = $id_source;
548
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
753
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
754
+			    	$data['noarchive'] = true;
755
+			    }
549 756
 			    $MI->add($data);
550 757
 			    unset($data);
551 758
 			}
@@ -558,7 +765,9 @@  discard block
 block discarded – undo
558 765
 	    echo 'download...';
559 766
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
560 767
 	    echo 'done !'."\n";
561
-	    if ($buffer != '') $reset = 0;
768
+	    if ($buffer != '') {
769
+	    	$reset = 0;
770
+	    }
562 771
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
563 772
 	    $buffer = explode('\n',$buffer);
564 773
 	    foreach ($buffer as $line) {
@@ -583,7 +792,9 @@  discard block
 block discarded – undo
583 792
 		    //$data['etaTime'] = substr($line,135,5);
584 793
 		    $data['format_source'] = 'shipplotter';
585 794
     		    $data['id_source'] = $id_source;
586
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
795
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
796
+		    	$data['noarchive'] = true;
797
+		    }
587 798
 		    //print_r($data);
588 799
 		    echo 'Add...'."\n";
589 800
 		    $MI->add($data);
@@ -603,16 +814,28 @@  discard block
 block discarded – undo
603 814
     		    $line = explode(':', $line);
604 815
     		    if (count($line) > 30 && $line[0] != 'callsign') {
605 816
 			$data = array();
606
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
607
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
817
+			if (isset($line[37]) && $line[37] != '') {
818
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
819
+			} else {
820
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
821
+			}
608 822
 			$data['pilot_id'] = $line[1];
609 823
 			$data['pilot_name'] = $line[2];
610 824
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
611 825
 			$data['ident'] = $line[0]; // ident
612
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
826
+			if ($line[7] != '' && $line[7] != 0) {
827
+				$data['altitude'] = $line[7];
828
+			}
829
+			// altitude
613 830
 			$data['speed'] = $line[8]; // speed
614
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
615
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
831
+			if (isset($line[45])) {
832
+				$data['heading'] = $line[45];
833
+			}
834
+			// heading
835
+			elseif (isset($line[38])) {
836
+				$data['heading'] = $line[38];
837
+			}
838
+			// heading
616 839
 			$data['latitude'] = $line[5]; // lat
617 840
 	        	$data['longitude'] = $line[6]; // long
618 841
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -628,7 +851,9 @@  discard block
 block discarded – undo
628 851
 			$data['frequency'] = $line[4];
629 852
 			$data['type'] = $line[18];
630 853
 			$data['range'] = $line[19];
631
-			if (isset($line[35])) $data['info'] = $line[35];
854
+			if (isset($line[35])) {
855
+				$data['info'] = $line[35];
856
+			}
632 857
     			$data['id_source'] = $id_source;
633 858
 	    		//$data['arrival_airport_time'] = ;
634 859
 	    		if ($line[9] != '') {
@@ -642,25 +867,44 @@  discard block
 block discarded – undo
642 867
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
643 868
 	    		*/
644 869
 	    		$data['format_source'] = $value['format'];
645
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
646
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
647
-    			if ($line[3] == 'PILOT') $SI->add($data);
648
-			elseif ($line[3] == 'ATC') {
870
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
871
+				$data['noarchive'] = true;
872
+			}
873
+			if (isset($value['name']) && $value['name'] != '') {
874
+				$data['source_name'] = $value['name'];
875
+			}
876
+    			if ($line[3] == 'PILOT') {
877
+    				$SI->add($data);
878
+    			} elseif ($line[3] == 'ATC') {
649 879
 				//print_r($data);
650 880
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
651 881
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
652 882
 				$typec = substr($data['ident'],-3);
653
-				if ($typec == 'APP') $data['type'] = 'Approach';
654
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
655
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
656
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
657
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
658
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
659
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
660
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
661
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
662
-				if (!isset($data['source_name'])) $data['source_name'] = '';
663
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
883
+				if ($typec == 'APP') {
884
+					$data['type'] = 'Approach';
885
+				} elseif ($typec == 'TWR') {
886
+					$data['type'] = 'Tower';
887
+				} elseif ($typec == 'OBS') {
888
+					$data['type'] = 'Observer';
889
+				} elseif ($typec == 'GND') {
890
+					$data['type'] = 'Ground';
891
+				} elseif ($typec == 'DEL') {
892
+					$data['type'] = 'Delivery';
893
+				} elseif ($typec == 'DEP') {
894
+					$data['type'] = 'Departure';
895
+				} elseif ($typec == 'FSS') {
896
+					$data['type'] = 'Flight Service Station';
897
+				} elseif ($typec == 'CTR') {
898
+					$data['type'] = 'Control Radar or Centre';
899
+				} elseif ($data['type'] == '') {
900
+					$data['type'] = 'Observer';
901
+				}
902
+				if (!isset($data['source_name'])) {
903
+					$data['source_name'] = '';
904
+				}
905
+				if (isset($ATC)) {
906
+					echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
907
+				}
664 908
 			}
665 909
     			unset($data);
666 910
     		    }
@@ -679,27 +923,61 @@  discard block
 block discarded – undo
679 923
 		foreach ($all_data['acList'] as $line) {
680 924
 		    $data = array();
681 925
 		    $data['hex'] = $line['Icao']; // hex
682
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
683
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
684
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
685
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
686
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
687
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
926
+		    if (isset($line['Call'])) {
927
+		    	$data['ident'] = $line['Call'];
928
+		    }
929
+		    // ident
930
+		    if (isset($line['Alt'])) {
931
+		    	$data['altitude'] = $line['Alt'];
932
+		    }
933
+		    // altitude
934
+		    if (isset($line['Spd'])) {
935
+		    	$data['speed'] = $line['Spd'];
936
+		    }
937
+		    // speed
938
+		    if (isset($line['Trak'])) {
939
+		    	$data['heading'] = $line['Trak'];
940
+		    }
941
+		    // heading
942
+		    if (isset($line['Lat'])) {
943
+		    	$data['latitude'] = $line['Lat'];
944
+		    }
945
+		    // lat
946
+		    if (isset($line['Long'])) {
947
+		    	$data['longitude'] = $line['Long'];
948
+		    }
949
+		    // long
688 950
 		    //$data['verticalrate'] = $line['']; // verticale rate
689
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
951
+		    if (isset($line['Sqk'])) {
952
+		    	$data['squawk'] = $line['Sqk'];
953
+		    }
954
+		    // squawk
690 955
 		    $data['emergency'] = ''; // emergency
691
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
956
+		    if (isset($line['Reg'])) {
957
+		    	$data['registration'] = $line['Reg'];
958
+		    }
692 959
 		    
693
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
694
-		    else $data['datetime'] = date('Y-m-d H:i:s');
960
+		    if (isset($line['PosTime'])) {
961
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
962
+		    } else {
963
+		    	$data['datetime'] = date('Y-m-d H:i:s');
964
+		    }
695 965
 		    
696 966
 		    //$data['datetime'] = date('Y-m-d H:i:s');
697
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
967
+		    if (isset($line['Type'])) {
968
+		    	$data['aircraft_icao'] = $line['Type'];
969
+		    }
698 970
 	    	    $data['format_source'] = 'aircraftlistjson';
699 971
 		    $data['id_source'] = $id_source;
700
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
701
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
-		    if (isset($data['latitude'])) $SI->add($data);
972
+		    if (isset($value['name']) && $value['name'] != '') {
973
+		    	$data['source_name'] = $value['name'];
974
+		    }
975
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
976
+		    	$data['noarchive'] = true;
977
+		    }
978
+		    if (isset($data['latitude'])) {
979
+		    	$SI->add($data);
980
+		    }
703 981
 		    unset($data);
704 982
 		}
705 983
 	    } elseif (is_array($all_data)) {
@@ -716,12 +994,19 @@  discard block
 block discarded – undo
716 994
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
717 995
 		    $data['squawk'] = $line['squawk']; // squawk
718 996
 		    $data['emergency'] = ''; // emergency
719
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
720
-		    else $data['datetime'] = date('Y-m-d H:i:s');
997
+		    if (isset($line['PosTime'])) {
998
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
999
+		    } else {
1000
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1001
+		    }
721 1002
 	    	    $data['format_source'] = 'aircraftlistjson';
722 1003
     		    $data['id_source'] = $id_source;
723
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
724
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1004
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1005
+		    	$data['noarchive'] = true;
1006
+		    }
1007
+		    if (isset($value['name']) && $value['name'] != '') {
1008
+		    	$data['source_name'] = $value['name'];
1009
+		    }
725 1010
 		    $SI->add($data);
726 1011
 		    unset($data);
727 1012
 		}
@@ -757,8 +1042,12 @@  discard block
 block discarded – undo
757 1042
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
758 1043
 	    	    $data['format_source'] = 'planeupdatefaa';
759 1044
     		    $data['id_source'] = $id_source;
760
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
761
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1045
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1046
+		    	$data['noarchive'] = true;
1047
+		    }
1048
+		    if (isset($value['name']) && $value['name'] != '') {
1049
+		    	$data['source_name'] = $value['name'];
1050
+		    }
762 1051
 		    $SI->add($data);
763 1052
 		    unset($data);
764 1053
 		}
@@ -787,7 +1076,9 @@  discard block
 block discarded – undo
787 1076
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
788 1077
 	    	    $data['format_source'] = 'opensky';
789 1078
     		    $data['id_source'] = $id_source;
790
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1079
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1080
+		    	$data['noarchive'] = true;
1081
+		    }
791 1082
 		    $SI->add($data);
792 1083
 		    unset($data);
793 1084
 		}
@@ -799,7 +1090,9 @@  discard block
 block discarded – undo
799 1090
 	    //$buffer = $Common->getData($hosts[$id]);
800 1091
 	    $buffer = $Common->getData($value['host']);
801 1092
 	    $all_data = json_decode($buffer,true);
802
-	    if (!empty($all_data)) $reset = 0;
1093
+	    if (!empty($all_data)) {
1094
+	    	$reset = 0;
1095
+	    }
803 1096
 	    foreach ($all_data as $key => $line) {
804 1097
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
805 1098
 		    $data = array();
@@ -820,8 +1113,12 @@  discard block
 block discarded – undo
820 1113
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
821 1114
 	    	    $data['format_source'] = 'fr24json';
822 1115
     		    $data['id_source'] = $id_source;
823
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
824
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1116
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1117
+		    	$data['noarchive'] = true;
1118
+		    }
1119
+		    if (isset($value['name']) && $value['name'] != '') {
1120
+		    	$data['source_name'] = $value['name'];
1121
+		    }
825 1122
 		    $SI->add($data);
826 1123
 		    unset($data);
827 1124
 		}
@@ -845,24 +1142,42 @@  discard block
 block discarded – undo
845 1142
 		    if (isset($line['inf'])) {
846 1143
 			$data = array();
847 1144
 			$data['hex'] = $line['inf']['ia'];
848
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1145
+			if (isset($line['inf']['cs'])) {
1146
+				$data['ident'] = $line['inf']['cs'];
1147
+			}
1148
+			//$line[13]
849 1149
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
850
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
851
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1150
+	    		if (isset($line['inf']['gs'])) {
1151
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1152
+	    		}
1153
+	    		// speed
1154
+	    		if (isset($line['inf']['tr'])) {
1155
+	    			$data['heading'] = $line['inf']['tr'];
1156
+	    		}
1157
+	    		// heading
852 1158
 	    		$data['latitude'] = $line['pt'][0]; // lat
853 1159
 	    		$data['longitude'] = $line['pt'][1]; // long
854 1160
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
855
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1161
+	    		if (isset($line['inf']['sq'])) {
1162
+	    			$data['squawk'] = $line['inf']['sq'];
1163
+	    		}
1164
+	    		// squawk
856 1165
 	    		//$data['aircraft_icao'] = $line[8];
857
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1166
+	    		if (isset($line['inf']['rc'])) {
1167
+	    			$data['registration'] = $line['inf']['rc'];
1168
+	    		}
858 1169
 			//$data['departure_airport_iata'] = $line[11];
859 1170
 			//$data['arrival_airport_iata'] = $line[12];
860 1171
 	    		//$data['emergency'] = ''; // emergency
861 1172
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
862 1173
 	    		$data['format_source'] = 'radarvirtueljson';
863 1174
     			$data['id_source'] = $id_source;
864
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
865
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1175
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1176
+				$data['noarchive'] = true;
1177
+			}
1178
+			if (isset($value['name']) && $value['name'] != '') {
1179
+				$data['source_name'] = $value['name'];
1180
+			}
866 1181
 			$SI->add($data);
867 1182
 			unset($data);
868 1183
 		    }
@@ -883,30 +1198,65 @@  discard block
 block discarded – undo
883 1198
 		    $data['id'] = $line['id'];
884 1199
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
885 1200
 		    $data['ident'] = $line['callsign']; // ident
886
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
887
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
888
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
889
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
890
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
891
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1201
+		    if (isset($line['pilotid'])) {
1202
+		    	$data['pilot_id'] = $line['pilotid'];
1203
+		    }
1204
+		    // pilot id
1205
+		    if (isset($line['name'])) {
1206
+		    	$data['pilot_name'] = $line['name'];
1207
+		    }
1208
+		    // pilot name
1209
+		    if (isset($line['alt'])) {
1210
+		    	$data['altitude'] = $line['alt'];
1211
+		    }
1212
+		    // altitude
1213
+		    if (isset($line['gs'])) {
1214
+		    	$data['speed'] = $line['gs'];
1215
+		    }
1216
+		    // speed
1217
+		    if (isset($line['heading'])) {
1218
+		    	$data['heading'] = $line['heading'];
1219
+		    }
1220
+		    // heading
1221
+		    if (isset($line['route'])) {
1222
+		    	$data['waypoints'] = $line['route'];
1223
+		    }
1224
+		    // route
892 1225
 		    $data['latitude'] = $line['lat']; // lat
893 1226
 		    $data['longitude'] = $line['lon']; // long
894 1227
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
895 1228
 		    //$data['squawk'] = $line['squawk']; // squawk
896 1229
 		    //$data['emergency'] = ''; // emergency
897
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
898
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
899
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1230
+		    if (isset($line['depicao'])) {
1231
+		    	$data['departure_airport_icao'] = $line['depicao'];
1232
+		    }
1233
+		    if (isset($line['deptime'])) {
1234
+		    	$data['departure_airport_time'] = $line['deptime'];
1235
+		    }
1236
+		    if (isset($line['arricao'])) {
1237
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1238
+		    }
900 1239
 		    //$data['arrival_airport_time'] = $line['arrtime'];
901
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
902
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
903
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
904
-		    else $data['info'] = '';
1240
+		    if (isset($line['aircraft'])) {
1241
+		    	$data['aircraft_icao'] = $line['aircraft'];
1242
+		    }
1243
+		    if (isset($line['transponder'])) {
1244
+		    	$data['squawk'] = $line['transponder'];
1245
+		    }
1246
+		    if (isset($line['atis'])) {
1247
+		    	$data['info'] = $line['atis'];
1248
+		    } else {
1249
+		    	$data['info'] = '';
1250
+		    }
905 1251
 		    $data['format_source'] = 'pireps';
906 1252
     		    $data['id_source'] = $id_source;
907 1253
 		    $data['datetime'] = date('Y-m-d H:i:s');
908
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
909
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1254
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1255
+		    	$data['noarchive'] = true;
1256
+		    }
1257
+		    if (isset($value['name']) && $value['name'] != '') {
1258
+		    	$data['source_name'] = $value['name'];
1259
+		    }
910 1260
 		    if ($line['icon'] == 'plane') {
911 1261
 			$SI->add($data);
912 1262
 		    //    print_r($data);
@@ -915,16 +1265,28 @@  discard block
 block discarded – undo
915 1265
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
916 1266
 			$typec = substr($data['ident'],-3);
917 1267
 			$data['type'] = '';
918
-			if ($typec == 'APP') $data['type'] = 'Approach';
919
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
920
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
921
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
922
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
923
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
924
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
925
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
926
-			else $data['type'] = 'Observer';
927
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1268
+			if ($typec == 'APP') {
1269
+				$data['type'] = 'Approach';
1270
+			} elseif ($typec == 'TWR') {
1271
+				$data['type'] = 'Tower';
1272
+			} elseif ($typec == 'OBS') {
1273
+				$data['type'] = 'Observer';
1274
+			} elseif ($typec == 'GND') {
1275
+				$data['type'] = 'Ground';
1276
+			} elseif ($typec == 'DEL') {
1277
+				$data['type'] = 'Delivery';
1278
+			} elseif ($typec == 'DEP') {
1279
+				$data['type'] = 'Departure';
1280
+			} elseif ($typec == 'FSS') {
1281
+				$data['type'] = 'Flight Service Station';
1282
+			} elseif ($typec == 'CTR') {
1283
+				$data['type'] = 'Control Radar or Centre';
1284
+			} else {
1285
+				$data['type'] = 'Observer';
1286
+			}
1287
+			if (isset($ATC)) {
1288
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1289
+			}
928 1290
 		    }
929 1291
 		    unset($data);
930 1292
 		}
@@ -934,7 +1296,9 @@  discard block
 block discarded – undo
934 1296
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
935 1297
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
936 1298
 	    //$buffer = $Common->getData($hosts[$id]);
937
-	    if ($globalDebug) echo 'Get Data...'."\n";
1299
+	    if ($globalDebug) {
1300
+	    	echo 'Get Data...'."\n";
1301
+	    }
938 1302
 	    $buffer = $Common->getData($value['host']);
939 1303
 	    $all_data = json_decode($buffer,true);
940 1304
 	    if ($buffer != '' && is_array($all_data)) {
@@ -942,10 +1306,16 @@  discard block
 block discarded – undo
942 1306
 		foreach ($all_data as $line) {
943 1307
 	    	    $data = array();
944 1308
 	    	    //$data['id'] = $line['id']; // id not usable
945
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1309
+	    	    if (isset($line['pilotid'])) {
1310
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1311
+	    	    }
946 1312
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
947
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
948
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1313
+	    	    if (isset($line['pilotname'])) {
1314
+	    	    	$data['pilot_name'] = $line['pilotname'];
1315
+	    	    }
1316
+	    	    if (isset($line['pilotid'])) {
1317
+	    	    	$data['pilot_id'] = $line['pilotid'];
1318
+	    	    }
949 1319
 	    	    $data['ident'] = $line['flightnum']; // ident
950 1320
 	    	    $data['altitude'] = $line['alt']; // altitude
951 1321
 	    	    $data['speed'] = $line['gs']; // speed
@@ -963,28 +1333,44 @@  discard block
 block discarded – undo
963 1333
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
964 1334
     		    $data['arrival_airport_time'] = $line['arrtime'];
965 1335
     		    $data['registration'] = $line['aircraft'];
966
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1336
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1337
+		    	$data['noarchive'] = true;
1338
+		    }
1339
+		    if (isset($line['route'])) {
1340
+		    	$data['waypoints'] = $line['route'];
1341
+		    }
1342
+		    // route
968 1343
 		    if (isset($line['aircraftname'])) {
969 1344
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
970 1345
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
971 1346
 	    		$aircraft_data = explode('-',$line['aircraftname']);
972
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
973
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
974
-	    		else {
1347
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1348
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1349
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1350
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1351
+	    		} else {
975 1352
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
976
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
977
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1353
+	    		    if (isset($aircraft_data[1])) {
1354
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1355
+	    		    } else {
1356
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1357
+	    		    }
978 1358
 	    		}
979 1359
 	    	    }
980
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1360
+    		    if (isset($line['route'])) {
1361
+    		    	$data['waypoints'] = $line['route'];
1362
+    		    }
981 1363
     		    $data['id_source'] = $id_source;
982 1364
 	    	    $data['format_source'] = 'phpvmacars';
983
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1365
+		    if (isset($value['name']) && $value['name'] != '') {
1366
+		    	$data['source_name'] = $value['name'];
1367
+		    }
984 1368
 		    $SI->add($data);
985 1369
 		    unset($data);
986 1370
 		}
987
-		if ($globalDebug) echo 'No more data...'."\n";
1371
+		if ($globalDebug) {
1372
+			echo 'No more data...'."\n";
1373
+		}
988 1374
 		unset($buffer);
989 1375
 		unset($all_data);
990 1376
 	    }
@@ -992,7 +1378,9 @@  discard block
 block discarded – undo
992 1378
     	    $last_exec[$id]['last'] = time();
993 1379
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
994 1380
 	    //$buffer = $Common->getData($hosts[$id]);
995
-	    if ($globalDebug) echo 'Get Data...'."\n";
1381
+	    if ($globalDebug) {
1382
+	    	echo 'Get Data...'."\n";
1383
+	    }
996 1384
 	    $buffer = $Common->getData($value['host']);
997 1385
 	    $all_data = json_decode($buffer,true);
998 1386
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1021,16 +1409,25 @@  discard block
 block discarded – undo
1021 1409
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1022 1410
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1023 1411
     		    //$data['registration'] = $line['aircraft'];
1024
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1412
+		    if (isset($line['route'])) {
1413
+		    	$data['waypoints'] = $line['route'];
1414
+		    }
1415
+		    // route
1025 1416
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1026 1417
     		    $data['id_source'] = $id_source;
1027 1418
 	    	    $data['format_source'] = 'vam';
1028
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1029
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1419
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1420
+		    	$data['noarchive'] = true;
1421
+		    }
1422
+		    if (isset($value['name']) && $value['name'] != '') {
1423
+		    	$data['source_name'] = $value['name'];
1424
+		    }
1030 1425
 		    $SI->add($data);
1031 1426
 		    unset($data);
1032 1427
 		}
1033
-		if ($globalDebug) echo 'No more data...'."\n";
1428
+		if ($globalDebug) {
1429
+			echo 'No more data...'."\n";
1430
+		}
1034 1431
 		unset($buffer);
1035 1432
 		unset($all_data);
1036 1433
 	    }
@@ -1038,7 +1435,9 @@  discard block
 block discarded – undo
1038 1435
     	    $last_exec[$id]['last'] = time();
1039 1436
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1040 1437
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1041
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1438
+	    if (function_exists('pcntl_fork')) {
1439
+	    	pcntl_signal_dispatch();
1440
+	    }
1042 1441
     	    //$last_exec[$id]['last'] = time();
1043 1442
 
1044 1443
 	    //$read = array( $sockets[$id] );
@@ -1046,7 +1445,9 @@  discard block
 block discarded – undo
1046 1445
 	    $write = NULL;
1047 1446
 	    $e = NULL;
1048 1447
 	    $n = socket_select($read, $write, $e, $timeout);
1049
-	    if ($e != NULL) var_dump($e);
1448
+	    if ($e != NULL) {
1449
+	    	var_dump($e);
1450
+	    }
1050 1451
 	    if ($n > 0) {
1051 1452
 		$reset = 0;
1052 1453
 		foreach ($read as $nb => $r) {
@@ -1067,12 +1468,16 @@  discard block
 block discarded – undo
1067 1468
 		    //$SI::del();
1068 1469
 		    if ($format == 'vrstcp') {
1069 1470
 			$buffer = explode('},{',$buffer);
1070
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1471
+		    } else {
1472
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1473
+		    }
1071 1474
 		    // SBS format is CSV format
1072 1475
 		    if ($buffer !== FALSE && $buffer != '') {
1073 1476
 			$tt[$format] = 0;
1074 1477
 			if ($format == 'acarssbs3') {
1075
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1478
+			    if ($globalDebug) {
1479
+			    	echo 'ACARS : '.$buffer."\n";
1480
+			    }
1076 1481
 			    $ACARS->add(trim($buffer));
1077 1482
 			    $ACARS->deleteLiveAcarsData();
1078 1483
 			} elseif ($format == 'raw') {
@@ -1081,28 +1486,64 @@  discard block
 block discarded – undo
1081 1486
 			    if (is_array($data)) {
1082 1487
 				$data['datetime'] = date('Y-m-d H:i:s');
1083 1488
 				$data['format_source'] = 'raw';
1084
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1085
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1086
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1087
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1489
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1490
+					$data['source_name'] = $globalSources[$nb]['name'];
1491
+				}
1492
+				if (isset($globalSources[$nb]['sourcestats'])) {
1493
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1494
+				}
1495
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1496
+					$data['noarchive'] = true;
1497
+				}
1498
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1499
+					$SI->add($data);
1500
+				}
1088 1501
 			    }
1089 1502
 			} elseif ($format == 'ais') {
1090 1503
 			    $ais_data = $AIS->parse_line(trim($buffer));
1091 1504
 			    $data = array();
1092
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1093
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1094
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1095
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1096
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1097
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1098
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1099
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1100
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1101
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1102
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1103
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1104
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1105
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1505
+			    if (isset($ais_data['ident'])) {
1506
+			    	$data['ident'] = $ais_data['ident'];
1507
+			    }
1508
+			    if (isset($ais_data['mmsi'])) {
1509
+			    	$data['mmsi'] = $ais_data['mmsi'];
1510
+			    }
1511
+			    if (isset($ais_data['speed'])) {
1512
+			    	$data['speed'] = $ais_data['speed'];
1513
+			    }
1514
+			    if (isset($ais_data['heading'])) {
1515
+			    	$data['heading'] = $ais_data['heading'];
1516
+			    }
1517
+			    if (isset($ais_data['latitude'])) {
1518
+			    	$data['latitude'] = $ais_data['latitude'];
1519
+			    }
1520
+			    if (isset($ais_data['longitude'])) {
1521
+			    	$data['longitude'] = $ais_data['longitude'];
1522
+			    }
1523
+			    if (isset($ais_data['status'])) {
1524
+			    	$data['status'] = $ais_data['status'];
1525
+			    }
1526
+			    if (isset($ais_data['statusid'])) {
1527
+			    	$data['status_id'] = $ais_data['statusid'];
1528
+			    }
1529
+			    if (isset($ais_data['type'])) {
1530
+			    	$data['type'] = $ais_data['type'];
1531
+			    }
1532
+			    if (isset($ais_data['imo'])) {
1533
+			    	$data['imo'] = $ais_data['imo'];
1534
+			    }
1535
+			    if (isset($ais_data['callsign'])) {
1536
+			    	$data['callsign'] = $ais_data['callsign'];
1537
+			    }
1538
+			    if (isset($ais_data['destination'])) {
1539
+			    	$data['arrival_code'] = $ais_data['destination'];
1540
+			    }
1541
+			    if (isset($ais_data['eta_ts'])) {
1542
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1543
+			    }
1544
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1545
+			    	$data['noarchive'] = true;
1546
+			    }
1106 1547
 
1107 1548
 			    if (isset($ais_data['timestamp'])) {
1108 1549
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1111,7 +1552,9 @@  discard block
 block discarded – undo
1111 1552
 			    }
1112 1553
 			    $data['format_source'] = 'aisnmea';
1113 1554
     			    $data['id_source'] = $id_source;
1114
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1555
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1556
+			    	$MI->add($data);
1557
+			    }
1115 1558
 			    unset($data);
1116 1559
                         } elseif ($format == 'flightgearsp') {
1117 1560
                     	    //echo $buffer."\n";
@@ -1129,12 +1572,18 @@  discard block
 block discarded – undo
1129 1572
 				$data['speed'] = round($line[5]*1.94384);
1130 1573
 				$data['datetime'] = date('Y-m-d H:i:s');
1131 1574
 				$data['format_source'] = 'flightgearsp';
1132
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1133
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1575
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1576
+					$data['noarchive'] = true;
1577
+				}
1578
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1579
+					$SI->add($data);
1580
+				}
1134 1581
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1135 1582
 			    }
1136 1583
                         } elseif ($format == 'acars') {
1137
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1584
+                    	    if ($globalDebug) {
1585
+                    	    	echo 'ACARS : '.$buffer."\n";
1586
+                    	    }
1138 1587
 			    $ACARS->add(trim($buffer));
1139 1588
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1140 1589
 			    $ACARS->deleteLiveAcarsData();
@@ -1155,8 +1604,12 @@  discard block
 block discarded – undo
1155 1604
 				    $aircraft_type = $line[10];
1156 1605
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1157 1606
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1158
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1159
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1607
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1608
+				    	$data['noarchive'] = true;
1609
+				    }
1610
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1611
+				    	$SI->add($data);
1612
+				    }
1160 1613
 				}
1161 1614
 			    }
1162 1615
 			} elseif ($format == 'beast') {
@@ -1166,28 +1619,62 @@  discard block
 block discarded – undo
1166 1619
 			    foreach($buffer as $all_data) {
1167 1620
 				$line = json_decode('{'.$all_data.'}',true);
1168 1621
 				$data = array();
1169
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1170
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1171
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1172
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1173
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1174
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1175
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1622
+				if (isset($line['Icao'])) {
1623
+					$data['hex'] = $line['Icao'];
1624
+				}
1625
+				// hex
1626
+				if (isset($line['Call'])) {
1627
+					$data['ident'] = $line['Call'];
1628
+				}
1629
+				// ident
1630
+				if (isset($line['Alt'])) {
1631
+					$data['altitude'] = $line['Alt'];
1632
+				}
1633
+				// altitude
1634
+				if (isset($line['Spd'])) {
1635
+					$data['speed'] = $line['Spd'];
1636
+				}
1637
+				// speed
1638
+				if (isset($line['Trak'])) {
1639
+					$data['heading'] = $line['Trak'];
1640
+				}
1641
+				// heading
1642
+				if (isset($line['Lat'])) {
1643
+					$data['latitude'] = $line['Lat'];
1644
+				}
1645
+				// lat
1646
+				if (isset($line['Long'])) {
1647
+					$data['longitude'] = $line['Long'];
1648
+				}
1649
+				// long
1176 1650
 				//$data['verticalrate'] = $line['']; // verticale rate
1177
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1651
+				if (isset($line['Sqk'])) {
1652
+					$data['squawk'] = $line['Sqk'];
1653
+				}
1654
+				// squawk
1178 1655
 				$data['emergency'] = ''; // emergency
1179
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1656
+				if (isset($line['Reg'])) {
1657
+					$data['registration'] = $line['Reg'];
1658
+				}
1180 1659
 				/*
1181 1660
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1182 1661
 				else $data['datetime'] = date('Y-m-d H:i:s');
1183 1662
 				*/
1184 1663
 				$data['datetime'] = date('Y-m-d H:i:s');
1185
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1664
+				if (isset($line['Type'])) {
1665
+					$data['aircraft_icao'] = $line['Type'];
1666
+				}
1186 1667
 		    		$data['format_source'] = 'vrstcp';
1187 1668
 				$data['id_source'] = $id_source;
1188
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1189
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1190
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1669
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1670
+					$data['noarchive'] = true;
1671
+				}
1672
+				if (isset($value['name']) && $value['name'] != '') {
1673
+					$data['source_name'] = $value['name'];
1674
+				}
1675
+				if (isset($data['latitude']) && isset($data['hex'])) {
1676
+					$SI->add($data);
1677
+				}
1191 1678
 				unset($data);
1192 1679
 			    }
1193 1680
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1200,22 +1687,46 @@  discard block
 block discarded – undo
1200 1687
     				$data['hex'] = $lined['hexid'];
1201 1688
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1202 1689
     				$data['datetime'] = date('Y-m-d H:i:s');;
1203
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1204
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1205
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1206
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1207
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1208
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1209
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1690
+    				if (isset($lined['ident'])) {
1691
+    					$data['ident'] = $lined['ident'];
1692
+    				}
1693
+    				if (isset($lined['lat'])) {
1694
+    					$data['latitude'] = $lined['lat'];
1695
+    				}
1696
+    				if (isset($lined['lon'])) {
1697
+    					$data['longitude'] = $lined['lon'];
1698
+    				}
1699
+    				if (isset($lined['speed'])) {
1700
+    					$data['speed'] = $lined['speed'];
1701
+    				}
1702
+    				if (isset($lined['squawk'])) {
1703
+    					$data['squawk'] = $lined['squawk'];
1704
+    				}
1705
+    				if (isset($lined['alt'])) {
1706
+    					$data['altitude'] = $lined['alt'];
1707
+    				}
1708
+    				if (isset($lined['heading'])) {
1709
+    					$data['heading'] = $lined['heading'];
1710
+    				}
1210 1711
     				$data['id_source'] = $id_source;
1211 1712
     				$data['format_source'] = 'tsv';
1212
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1213
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1214
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1215
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1713
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1714
+    					$data['source_name'] = $globalSources[$nb]['name'];
1715
+    				}
1716
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1717
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1718
+    				}
1719
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1720
+					$data['noarchive'] = true;
1721
+				}
1722
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1723
+    					$SI->add($data);
1724
+    				}
1216 1725
     				unset($lined);
1217 1726
     				unset($data);
1218
-    			    } else $error = true;
1727
+    			    } else {
1728
+    			    	$error = true;
1729
+    			    }
1219 1730
 			} elseif ($format == 'aprs' && $use_aprs) {
1220 1731
 			    if ($aprs_connect == 0) {
1221 1732
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1240,39 +1751,86 @@  discard block
 block discarded – undo
1240 1751
 				    $aprs_last_tx = time();
1241 1752
 				    $data = array();
1242 1753
 				    //print_r($line);
1243
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1244
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1245
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1246
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1247
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1248
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1249
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1250
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1251
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1252
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1754
+				    if (isset($line['address'])) {
1755
+				    	$data['hex'] = $line['address'];
1756
+				    }
1757
+				    if (isset($line['mmsi'])) {
1758
+				    	$data['mmsi'] = $line['mmsi'];
1759
+				    }
1760
+				    if (isset($line['imo'])) {
1761
+				    	$data['imo'] = $line['imo'];
1762
+				    }
1763
+				    if (isset($line['squawk'])) {
1764
+				    	$data['squawk'] = $line['squawk'];
1765
+				    }
1766
+				    if (isset($line['arrival_code'])) {
1767
+				    	$data['arrical_code'] = $line['arrival_code'];
1768
+				    }
1769
+				    if (isset($line['arrival_date'])) {
1770
+				    	$data['arrical_date'] = $line['arrival_date'];
1771
+				    }
1772
+				    if (isset($line['type_id'])) {
1773
+				    	$data['type_id'] = $line['typeid'];
1774
+				    }
1775
+				    if (isset($line['status_id'])) {
1776
+				    	$data['status_id'] = $line['statusid'];
1777
+				    }
1778
+				    if (isset($line['timestamp'])) {
1779
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1780
+				    } else {
1781
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1782
+				    }
1253 1783
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1254
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1784
+				    if (isset($line['ident'])) {
1785
+				    	$data['ident'] = $line['ident'];
1786
+				    }
1255 1787
 				    $data['latitude'] = $line['latitude'];
1256 1788
 				    $data['longitude'] = $line['longitude'];
1257 1789
 				    //$data['verticalrate'] = $line[16];
1258
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1259
-				    else $data['speed'] = 0;
1260
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1261
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1262
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1263
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1790
+				    if (isset($line['speed'])) {
1791
+				    	$data['speed'] = $line['speed'];
1792
+				    } else {
1793
+				    	$data['speed'] = 0;
1794
+				    }
1795
+				    if (isset($line['altitude'])) {
1796
+				    	$data['altitude'] = $line['altitude'];
1797
+				    }
1798
+				    if (isset($line['comment'])) {
1799
+				    	$data['comment'] = $line['comment'];
1800
+				    }
1801
+				    if (isset($line['symbol'])) {
1802
+				    	$data['type'] = $line['symbol'];
1803
+				    }
1804
+				    if (isset($line['heading'])) {
1805
+				    	$data['heading'] = $line['heading'];
1806
+				    }
1264 1807
 				    //else $data['heading'] = 0;
1265
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1266
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1267
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1268
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1808
+				    if (isset($line['stealth'])) {
1809
+				    	$data['aircraft_type'] = $line['stealth'];
1810
+				    }
1811
+				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) {
1812
+				    	$data['noarchive'] = true;
1813
+				    }
1814
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1815
+				    	$data['noarchive'] = true;
1816
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1817
+				    	$data['noarchive'] = false;
1818
+				    }
1269 1819
     				    $data['id_source'] = $id_source;
1270
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1271
-				    else $data['format_source'] = 'aprs';
1820
+    				    if (isset($line['format_source'])) {
1821
+    				    	$data['format_source'] = $line['format_source'];
1822
+    				    } else {
1823
+				    	$data['format_source'] = 'aprs';
1824
+				    }
1272 1825
 				    $data['source_name'] = $line['source'];
1273
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1274
-				    else $data['source_type'] = 'flarm';
1275
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1826
+				    if (isset($line['source_type'])) {
1827
+				    	$data['source_type'] = $line['source_type'];
1828
+				    } else {
1829
+				    	$data['source_type'] = 'flarm';
1830
+				    }
1831
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1832
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1833
+    				    }
1276 1834
 				    $currentdate = date('Y-m-d H:i:s');
1277 1835
 				    $aprsdate = strtotime($data['datetime']);
1278 1836
 				    // Accept data if time <= system time + 20s
@@ -1280,21 +1838,26 @@  discard block
 block discarded – undo
1280 1838
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1281 1839
 					$send = $SI->add($data);
1282 1840
 				    } elseif ($data['source_type'] == 'ais') {
1283
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1841
+					if (isset($globalMarine) && $globalMarine) {
1842
+						$send = $MI->add($data);
1843
+					}
1284 1844
 				    } elseif (isset($line['stealth'])) {
1285
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1286
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1845
+					if ($line['stealth'] != 0) {
1846
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1847
+					} else {
1848
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1849
+					}
1287 1850
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1288 1851
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1289 1852
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1290
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1853
+					if (isset($globalTracker) && $globalTracker) {
1854
+						$send = $TI->add($data);
1855
+					}
1291 1856
 				    }
1292 1857
 				    unset($data);
1293
-				} 
1294
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1858
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1295 1859
 					echo '!! Weather Station not yet supported'."\n";
1296
-				}
1297
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1860
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1298 1861
 					echo '!! Car & Trucks not yet supported'."\n";
1299 1862
 				}
1300 1863
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1327,26 +1890,45 @@  discard block
 block discarded – undo
1327 1890
     				$data['ground'] = $line[21];
1328 1891
     				$data['emergency'] = $line[19];
1329 1892
     				$data['format_source'] = 'sbs';
1330
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1331
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1332
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1893
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1894
+					$data['source_name'] = $globalSources[$nb]['name'];
1895
+				}
1896
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1897
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1898
+    				}
1899
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1900
+					$data['noarchive'] = true;
1901
+				}
1333 1902
     				$data['id_source'] = $id_source;
1334
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1335
-    				else $error = true;
1903
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1904
+    					$send = $SI->add($data);
1905
+    				} else {
1906
+    					$error = true;
1907
+    				}
1336 1908
     				unset($data);
1337
-    			    } else $error = true;
1909
+    			    } else {
1910
+    			    	$error = true;
1911
+    			    }
1338 1912
 			    if ($error) {
1339 1913
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1340
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1914
+					if ($globalDebug) {
1915
+						echo "Not a message. Ignoring... \n";
1916
+					}
1341 1917
 				} else {
1342
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1918
+					if ($globalDebug) {
1919
+						echo "Wrong line format. Ignoring... \n";
1920
+					}
1343 1921
 					if ($globalDebug) {
1344 1922
 						echo $buffer;
1345 1923
 						//print_r($line);
1346 1924
 					}
1347 1925
 					//socket_close($r);
1348
-					if ($globalDebug) echo "Reconnect after an error...\n";
1349
-					if ($format == 'aprs') $aprs_connect = 0;
1926
+					if ($globalDebug) {
1927
+						echo "Reconnect after an error...\n";
1928
+					}
1929
+					if ($format == 'aprs') {
1930
+						$aprs_connect = 0;
1931
+					}
1350 1932
 					$sourceer[$nb] = $globalSources[$nb];
1351 1933
 					connect_all($sourceer);
1352 1934
 					$sourceer = array();
@@ -1354,10 +1936,14 @@  discard block
 block discarded – undo
1354 1936
 			    }
1355 1937
 			}
1356 1938
 			// Sleep for xxx microseconds
1357
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1939
+			if (isset($globalSBSSleep)) {
1940
+				usleep($globalSBSSleep);
1941
+			}
1358 1942
 		    } else {
1359 1943
 			if ($format == 'flightgearmp') {
1360
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1944
+			    	if ($globalDebug) {
1945
+			    		echo "Reconnect FlightGear MP...";
1946
+			    	}
1361 1947
 				//@socket_close($r);
1362 1948
 				sleep($globalMinFetch);
1363 1949
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1366,10 +1952,15 @@  discard block
 block discarded – undo
1366 1952
 				break;
1367 1953
 				
1368 1954
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1369
-			    if (isset($tt[$format])) $tt[$format]++;
1370
-			    else $tt[$format] = 0;
1955
+			    if (isset($tt[$format])) {
1956
+			    	$tt[$format]++;
1957
+			    } else {
1958
+			    	$tt[$format] = 0;
1959
+			    }
1371 1960
 			    if ($tt[$format] > 30) {
1372
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1961
+				if ($globalDebug) {
1962
+					echo "ERROR : Reconnect ".$format."...";
1963
+				}
1373 1964
 				//@socket_close($r);
1374 1965
 				sleep(2);
1375 1966
 				$aprs_connect = 0;
@@ -1386,11 +1977,17 @@  discard block
 block discarded – undo
1386 1977
 	    } else {
1387 1978
 		$error = socket_strerror(socket_last_error());
1388 1979
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1389
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1390
-			if (isset($globalDebug)) echo "Restarting...\n";
1980
+			if ($globalDebug) {
1981
+				echo "ERROR : socket_select give this error ".$error . "\n";
1982
+			}
1983
+			if (isset($globalDebug)) {
1984
+				echo "Restarting...\n";
1985
+			}
1391 1986
 			// Restart the script if possible
1392 1987
 			if (is_array($sockets)) {
1393
-			    if ($globalDebug) echo "Shutdown all sockets...";
1988
+			    if ($globalDebug) {
1989
+			    	echo "Shutdown all sockets...";
1990
+			    }
1394 1991
 			    
1395 1992
 			    foreach ($sockets as $sock) {
1396 1993
 				@socket_shutdown($sock,2);
@@ -1398,22 +1995,36 @@  discard block
 block discarded – undo
1398 1995
 			    }
1399 1996
 			    
1400 1997
 			}
1401
-			if ($globalDebug) echo "Waiting...";
1998
+			if ($globalDebug) {
1999
+				echo "Waiting...";
2000
+			}
1402 2001
 			sleep(2);
1403 2002
 			$time = time();
1404 2003
 			//connect_all($hosts);
1405 2004
 			$aprs_connect = 0;
1406
-			if ($reset%5 == 0) sleep(20);
1407
-			if ($reset%10 == 0) sleep(100);
1408
-			if ($reset%20 == 0) sleep(200);
1409
-			if ($reset > 100) exit('Too many attempts...');
1410
-			if ($globalDebug) echo "Restart all connections...";
2005
+			if ($reset%5 == 0) {
2006
+				sleep(20);
2007
+			}
2008
+			if ($reset%10 == 0) {
2009
+				sleep(100);
2010
+			}
2011
+			if ($reset%20 == 0) {
2012
+				sleep(200);
2013
+			}
2014
+			if ($reset > 100) {
2015
+				exit('Too many attempts...');
2016
+			}
2017
+			if ($globalDebug) {
2018
+				echo "Restart all connections...";
2019
+			}
1411 2020
 			connect_all($globalSources);
1412 2021
 		}
1413 2022
 	    }
1414 2023
 	}
1415 2024
 	if ($globalDaemon === false) {
1416
-	    if ($globalDebug) echo 'Check all...'."\n";
2025
+	    if ($globalDebug) {
2026
+	    	echo 'Check all...'."\n";
2027
+	    }
1417 2028
 	    $SI->checkAll();
1418 2029
 	}
1419 2030
     }
Please login to merge, or discard this patch.
Indentation   +867 added lines, -867 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,42 +24,42 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+	else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60
-    $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
60
+	$globalSources = array();
61
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+	else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
65 65
 	$globalServerAPRS = TRUE;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 if (isset($options['idsource'])) $id_source = $options['idsource'];
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
77
+	if ($globalDebug) echo "Using Server Mode\n";
78
+	$SI=new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 } else $SI=new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87
-    $AIS = new AIS();
88
-    $MI = new MarineImport($Connection->db);
87
+	$AIS = new AIS();
88
+	$MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91 91
 $SBS=new SBS();
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
99
-        global $sockets;
100
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
-        die("Bye!\n");
102
-    });
103
-    pcntl_signal_dispatch();
98
+	pcntl_signal(SIGINT,  function() {
99
+		global $sockets;
100
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
+		die("Bye!\n");
102
+	});
103
+	pcntl_signal_dispatch();
104 104
 }
105 105
 
106 106
 // let's try and connect
@@ -110,153 +110,153 @@  discard block
 block discarded – undo
110 110
 $reset = 0;
111 111
 
112 112
 function connect_all($hosts) {
113
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
-    $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
117
-    foreach ($hosts as $id => $value) {
113
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
+	$reset++;
116
+	if ($globalDebug) echo 'Connect to all...'."\n";
117
+	foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121 121
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
-        	//$formats[$id] = 'deltadbtxt';
124
-        	$globalSources[$id]['format'] = 'deltadbtxt';
125
-        	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
-        	//$formats[$id] = 'vatsimtxt';
129
-        	$globalSources[$id]['format'] = 'vatsimtxt';
130
-        	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133
-        	//$formats[$id] = 'aircraftlistjson';
134
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
135
-        	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
138
-        	//$formats[$id] = 'aircraftlistjson';
139
-        	$globalSources[$id]['format'] = 'opensky';
140
-        	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
-        	//$formats[$id] = 'radarvirtueljson';
144
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
145
-        	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
-        	    exit(0);
150
-        	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
-        	//$formats[$id] = 'planeupdatefaa';
153
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
154
-        	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
-        	    exit(0);
159
-        	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
-        	//$formats[$id] = 'phpvmacars';
162
-        	$globalSources[$id]['format'] = 'phpvmacars';
163
-        	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
170
-        	//$formats[$id] = 'whazzup';
171
-        	$globalSources[$id]['format'] = 'whazzup';
172
-        	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
175
-        	//$formats[$id] = 'pirepsjson';
176
-        	$globalSources[$id]['format'] = 'pirepsjson';
177
-        	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
-        	//$formats[$id] = 'fr24json';
181
-        	$globalSources[$id]['format'] = 'fr24json';
182
-        	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
-        	    exit(0);
187
-        	}
188
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
189
-        	//$formats[$id] = 'fr24json';
190
-        	$globalSources[$id]['format'] = 'myshiptracking';
191
-        	//$last_exec['fr24json'] = 0;
192
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
193
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195
-        	    exit(0);
196
-        	}
197
-            //} else if (preg_match('/10001/',$host)) {
198
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199
-        	//$formats[$id] = 'tsv';
200
-        	$globalSources[$id]['format'] = 'tsv';
201
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202
-            }
203
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
206
-    		    if ($idf !== false) {
207
-    			$httpfeeds[$id] = $idf;
208
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209
-    		    }
210
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
-	    $hostport = explode(':',$host);
214
-	    if (isset($hostport[1])) {
122
+			if (preg_match('/deltadb.txt$/i',$host)) {
123
+			//$formats[$id] = 'deltadbtxt';
124
+			$globalSources[$id]['format'] = 'deltadbtxt';
125
+			//$last_exec['deltadbtxt'] = 0;
126
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
+			//$formats[$id] = 'vatsimtxt';
129
+			$globalSources[$id]['format'] = 'vatsimtxt';
130
+			//$last_exec['vatsimtxt'] = 0;
131
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
133
+			//$formats[$id] = 'aircraftlistjson';
134
+			$globalSources[$id]['format'] = 'aircraftlistjson';
135
+			//$last_exec['aircraftlistjson'] = 0;
136
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
+			} else if (preg_match('/opensky/i',$host)) {
138
+			//$formats[$id] = 'aircraftlistjson';
139
+			$globalSources[$id]['format'] = 'opensky';
140
+			//$last_exec['aircraftlistjson'] = 0;
141
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
+			//$formats[$id] = 'radarvirtueljson';
144
+			$globalSources[$id]['format'] = 'radarvirtueljson';
145
+			//$last_exec['radarvirtueljson'] = 0;
146
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
+				exit(0);
150
+			}
151
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
+			//$formats[$id] = 'planeupdatefaa';
153
+			$globalSources[$id]['format'] = 'planeupdatefaa';
154
+			//$last_exec['planeupdatefaa'] = 0;
155
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
+				exit(0);
159
+			}
160
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
+			//$formats[$id] = 'phpvmacars';
162
+			$globalSources[$id]['format'] = 'phpvmacars';
163
+			//$last_exec['phpvmacars'] = 0;
164
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'vam';
168
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
+			} else if (preg_match('/whazzup/i',$host)) {
170
+			//$formats[$id] = 'whazzup';
171
+			$globalSources[$id]['format'] = 'whazzup';
172
+			//$last_exec['whazzup'] = 0;
173
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
+			} else if (preg_match('/recentpireps/i',$host)) {
175
+			//$formats[$id] = 'pirepsjson';
176
+			$globalSources[$id]['format'] = 'pirepsjson';
177
+			//$last_exec['pirepsjson'] = 0;
178
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
+			//$formats[$id] = 'fr24json';
181
+			$globalSources[$id]['format'] = 'fr24json';
182
+			//$last_exec['fr24json'] = 0;
183
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
+				exit(0);
187
+			}
188
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
189
+			//$formats[$id] = 'fr24json';
190
+			$globalSources[$id]['format'] = 'myshiptracking';
191
+			//$last_exec['fr24json'] = 0;
192
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
193
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195
+				exit(0);
196
+			}
197
+			//} else if (preg_match('/10001/',$host)) {
198
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199
+			//$formats[$id] = 'tsv';
200
+			$globalSources[$id]['format'] = 'tsv';
201
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202
+			}
203
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
206
+				if ($idf !== false) {
207
+				$httpfeeds[$id] = $idf;
208
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209
+				}
210
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
+		$hostport = explode(':',$host);
214
+		if (isset($hostport[1])) {
215 215
 		$port = $hostport[1];
216 216
 		$hostn = $hostport[0];
217
-	    } else {
217
+		} else {
218 218
 		$port = $globalSources[$id]['port'];
219 219
 		$hostn = $globalSources[$id]['host'];
220
-	    }
221
-	    $Common = new Common();
222
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
224
-    	    } else {
225
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
226
-	    }
227
-	    if ($s) {
228
-    	        $sockets[$id] = $s;
229
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
220
+		}
221
+		$Common = new Common();
222
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
224
+			} else {
225
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
226
+		}
227
+		if ($s) {
228
+				$sockets[$id] = $s;
229
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
231 231
 			//$formats[$id] = 'aprs';
232 232
 			$globalSources[$id]['format'] = 'aprs';
233 233
 			//$aprs_connect = 0;
234 234
 			//$use_aprs = true;
235
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
235
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
236 236
 			$globalSources[$id]['format'] = 'vrstcp';
237
-    		    } elseif ($port == '10001') {
238
-        		//$formats[$id] = 'tsv';
239
-        		$globalSources[$id]['format'] = 'tsv';
240
-		    } elseif ($port == '30002') {
241
-        		//$formats[$id] = 'raw';
242
-        		$globalSources[$id]['format'] = 'raw';
243
-		    } elseif ($port == '5001') {
244
-        		//$formats[$id] = 'raw';
245
-        		$globalSources[$id]['format'] = 'flightgearmp';
246
-		    } elseif ($port == '30005') {
237
+				} elseif ($port == '10001') {
238
+				//$formats[$id] = 'tsv';
239
+				$globalSources[$id]['format'] = 'tsv';
240
+			} elseif ($port == '30002') {
241
+				//$formats[$id] = 'raw';
242
+				$globalSources[$id]['format'] = 'raw';
243
+			} elseif ($port == '5001') {
244
+				//$formats[$id] = 'raw';
245
+				$globalSources[$id]['format'] = 'flightgearmp';
246
+			} elseif ($port == '30005') {
247 247
 			// Not yet supported
248
-        		//$formats[$id] = 'beast';
249
-        		$globalSources[$id]['format'] = 'beast';
250
-		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
252
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
248
+				//$formats[$id] = 'beast';
249
+				$globalSources[$id]['format'] = 'beast';
250
+			//} else $formats[$id] = 'sbs';
251
+			} else $globalSources[$id]['format'] = 'sbs';
252
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 253
 		}
254 254
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
255
-            } else {
255
+			} else {
256 256
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
257
-    	    }
258
-        }
259
-    }
257
+			}
258
+		}
259
+	}
260 260
 }
261 261
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
262 262
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 //connect_all($globalSources);
280 280
 
281 281
 if (isset($globalProxy) && $globalProxy) {
282
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
282
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
283 283
 } else {
284
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
284
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
285 285
 }
286 286
 
287 287
 // APRS Configuration
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
 	die;
291 291
 }
292 292
 foreach ($globalSources as $key => $source) {
293
-    if (!isset($source['format'])) {
294
-        $globalSources[$key]['format'] = 'auto';
295
-    }
293
+	if (!isset($source['format'])) {
294
+		$globalSources[$key]['format'] = 'auto';
295
+	}
296 296
 }
297 297
 connect_all($globalSources);
298 298
 foreach ($globalSources as $key => $source) {
299
-    if (isset($source['format']) && $source['format'] == 'aprs') {
299
+	if (isset($source['format']) && $source['format'] == 'aprs') {
300 300
 	$aprs_connect = 0;
301 301
 	$use_aprs = true;
302 302
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
303 303
 	break;
304
-    }
304
+	}
305 305
 }
306 306
 
307 307
 if ($use_aprs) {
@@ -342,116 +342,116 @@  discard block
 block discarded – undo
342 342
 
343 343
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 344
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
346
-    // Delete old ATC
347
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
345
+	if (!$globalDaemon) $i = $endtime-time();
346
+	// Delete old ATC
347
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
349
-        $ATC->deleteOldATC();
350
-    }
349
+		$ATC->deleteOldATC();
350
+	}
351 351
     
352
-    //if (count($last_exec) > 0) {
353
-    if (count($last_exec) == count($globalSources)) {
352
+	//if (count($last_exec) > 0) {
353
+	if (count($last_exec) == count($globalSources)) {
354 354
 	$max = $globalMinFetch;
355 355
 	foreach ($last_exec as $last) {
356
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
356
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
357 357
 	}
358 358
 	if ($max != $globalMinFetch) {
359
-	    if ($globalDebug) echo 'Sleeping...'."\n";
360
-	    sleep($globalMinFetch-$max+2);
359
+		if ($globalDebug) echo 'Sleeping...'."\n";
360
+		sleep($globalMinFetch-$max+2);
361
+	}
361 362
 	}
362
-    }
363 363
 
364 364
     
365
-    //foreach ($formats as $id => $value) {
366
-    foreach ($globalSources as $id => $value) {
365
+	//foreach ($formats as $id => $value) {
366
+	foreach ($globalSources as $id => $value) {
367 367
 	date_default_timezone_set('UTC');
368 368
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
369 369
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
370
-	    //$buffer = $Common->getData($hosts[$id]);
371
-	    $buffer = $Common->getData($value['host']);
372
-	    if ($buffer != '') $reset = 0;
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
375
-	    foreach ($buffer as $line) {
376
-    		if ($line != '' && count($line) > 7) {
377
-    		    $line = explode(',', $line);
378
-	            $data = array();
379
-	            $data['hex'] = $line[1]; // hex
380
-	            $data['ident'] = $line[2]; // ident
381
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
386
-	            $data['verticalrate'] = ''; // vertical rate
387
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388
-	            $data['emergency'] = ''; // emergency
389
-		    $data['datetime'] = date('Y-m-d H:i:s');
390
-		    $data['format_source'] = 'deltadbtxt';
391
-    		    $data['id_source'] = $id_source;
392
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
395
-    		    $SI->add($data);
396
-		    unset($data);
397
-    		}
398
-    	    }
399
-    	    $last_exec[$id]['last'] = time();
370
+		//$buffer = $Common->getData($hosts[$id]);
371
+		$buffer = $Common->getData($value['host']);
372
+		if ($buffer != '') $reset = 0;
373
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
+		$buffer = explode('\n',$buffer);
375
+		foreach ($buffer as $line) {
376
+			if ($line != '' && count($line) > 7) {
377
+				$line = explode(',', $line);
378
+				$data = array();
379
+				$data['hex'] = $line[1]; // hex
380
+				$data['ident'] = $line[2]; // ident
381
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
386
+				$data['verticalrate'] = ''; // vertical rate
387
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388
+				$data['emergency'] = ''; // emergency
389
+			$data['datetime'] = date('Y-m-d H:i:s');
390
+			$data['format_source'] = 'deltadbtxt';
391
+				$data['id_source'] = $id_source;
392
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
395
+				$SI->add($data);
396
+			unset($data);
397
+			}
398
+			}
399
+			$last_exec[$id]['last'] = time();
400 400
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
401
-	    date_default_timezone_set('CET');
402
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403
-	    date_default_timezone_set('UTC');
404
-	    if ($buffer != '') $reset = 0;
405
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
-	    $buffer = explode('\n',$buffer);
407
-	    foreach ($buffer as $line) {
401
+		date_default_timezone_set('CET');
402
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403
+		date_default_timezone_set('UTC');
404
+		if ($buffer != '') $reset = 0;
405
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
+		$buffer = explode('\n',$buffer);
407
+		foreach ($buffer as $line) {
408 408
 		if ($line != '') {
409
-		    echo "'".$line."'\n";
410
-		    $add = false;
411
-		    $ais_data = $AIS->parse_line(trim($line));
412
-		    $data = array();
413
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423
-		    if (isset($ais_data['timestamp'])) {
409
+			echo "'".$line."'\n";
410
+			$add = false;
411
+			$ais_data = $AIS->parse_line(trim($line));
412
+			$data = array();
413
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423
+			if (isset($ais_data['timestamp'])) {
424 424
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
425 425
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
426
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427
-			    $add = true;
426
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427
+				$add = true;
428 428
 			}
429
-		    } else {
429
+			} else {
430 430
 			$data['datetime'] = date('Y-m-d H:i:s');
431 431
 			$add = true;
432
-		    }
433
-		    $data['format_source'] = 'aisnmeatxt';
434
-    		    $data['id_source'] = $id_source;
435
-		    //print_r($data);
436
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
437
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
438
-		    unset($data);
432
+			}
433
+			$data['format_source'] = 'aisnmeatxt';
434
+				$data['id_source'] = $id_source;
435
+			//print_r($data);
436
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
437
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
438
+			unset($data);
439 439
 		}
440
-    	    }
441
-    	    $last_exec[$id]['last'] = time();
440
+			}
441
+			$last_exec[$id]['last'] = time();
442 442
 	} elseif ($value['format'] == 'aisnmeahttp') {
443
-	    $arr = $httpfeeds;
444
-	    $w = $e = null;
443
+		$arr = $httpfeeds;
444
+		$w = $e = null;
445 445
 	    
446
-	    if (isset($arr[$id])) {
446
+		if (isset($arr[$id])) {
447 447
 		$nn = stream_select($arr,$w,$e,$timeout);
448 448
 		if ($nn > 0) {
449
-		    foreach ($httpfeeds as $feed) {
449
+			foreach ($httpfeeds as $feed) {
450 450
 			$buffer = stream_get_line($feed,2000,"\n");
451 451
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
452 452
 			$buffer = explode('\n',$buffer);
453 453
 			foreach ($buffer as $line) {
454
-			    if ($line != '') {
454
+				if ($line != '') {
455 455
 				$ais_data = $AIS->parse_line(trim($line));
456 456
 				$data = array();
457 457
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -469,40 +469,40 @@  discard block
 block discarded – undo
469 469
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
470 470
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
471 471
 				if (isset($ais_data['timestamp'])) {
472
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
472
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
473 473
 				} else {
474
-				    $data['datetime'] = date('Y-m-d H:i:s');
474
+					$data['datetime'] = date('Y-m-d H:i:s');
475 475
 				}
476 476
 				$data['format_source'] = 'aisnmeahttp';
477 477
 				$data['id_source'] = $id_source;
478 478
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
479 479
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
480 480
 				unset($data);
481
-			    }
481
+				}
482
+			}
482 483
 			}
483
-		    }
484 484
 		} else {
485
-		    $format = $value['format'];
486
-		    if (isset($tt[$format])) $tt[$format]++;
487
-		    else $tt[$format] = 0;
488
-		    if ($tt[$format] > 30) {
485
+			$format = $value['format'];
486
+			if (isset($tt[$format])) $tt[$format]++;
487
+			else $tt[$format] = 0;
488
+			if ($tt[$format] > 30) {
489 489
 			if ($globalDebug) echo 'Reconnect...'."\n";
490 490
 			sleep(2);
491 491
 			$sourceeen[] = $value;
492 492
 			connect_all($sourceeen);
493 493
 			$sourceeen = array();
494
-		    }
494
+			}
495
+		}
495 496
 		}
496
-	    }
497 497
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
498
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
499
-	    if ($buffer != '') {
498
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
499
+		if ($buffer != '') {
500 500
 		//echo $buffer;
501 501
 		$all_data = json_decode($buffer,true);
502 502
 		//print_r($all_data);
503 503
 		if (isset($all_data[0]['DATA'])) {
504 504
 		foreach ($all_data[0]['DATA'] as $line) {
505
-		    if ($line != '') {
505
+			if ($line != '') {
506 506
 			$data = array();
507 507
 			$data['ident'] = $line['NAME'];
508 508
 			$data['mmsi'] = $line['MMSI'];
@@ -519,89 +519,89 @@  discard block
 block discarded – undo
519 519
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520 520
 			$MI->add($data);
521 521
 			unset($data);
522
-		    }
522
+			}
523 523
 		}
524 524
 		}
525 525
 		
526
-	    }
527
-    	    $last_exec[$id]['last'] = time();
526
+		}
527
+			$last_exec[$id]['last'] = time();
528 528
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
529
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
530
-	    if ($buffer != '') {
529
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
530
+		if ($buffer != '') {
531 531
 		$all_data = json_decode($buffer,true);
532 532
 		if (isset($all_data[0]['mmsi'])) {
533
-		    foreach ($all_data as $line) {
533
+			foreach ($all_data as $line) {
534 534
 			if ($line != '') {
535
-			    $data = array();
536
-			    $data['ident'] = $line['shipname'];
537
-			    $data['callsign'] = $line['callsign'];
538
-			    $data['mmsi'] = $line['mmsi'];
539
-			    $data['speed'] = $line['sog'];
540
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
541
-			    $data['latitude'] = $line['latitude'];
542
-			    $data['longitude'] = $line['longitude'];
543
-			    $data['type_id'] = $line['shiptype'];
544
-			    $data['arrival_code'] = $line['destination'];
545
-			    $data['datetime'] = $line['time'];
546
-			    $data['format_source'] = 'boatbeaconapp';
547
-			    $data['id_source'] = $id_source;
548
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
549
-			    $MI->add($data);
550
-			    unset($data);
535
+				$data = array();
536
+				$data['ident'] = $line['shipname'];
537
+				$data['callsign'] = $line['callsign'];
538
+				$data['mmsi'] = $line['mmsi'];
539
+				$data['speed'] = $line['sog'];
540
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
541
+				$data['latitude'] = $line['latitude'];
542
+				$data['longitude'] = $line['longitude'];
543
+				$data['type_id'] = $line['shiptype'];
544
+				$data['arrival_code'] = $line['destination'];
545
+				$data['datetime'] = $line['time'];
546
+				$data['format_source'] = 'boatbeaconapp';
547
+				$data['id_source'] = $id_source;
548
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
549
+				$MI->add($data);
550
+				unset($data);
551
+			}
551 552
 			}
552
-		    }
553 553
 		}
554 554
 		
555
-	    }
556
-    	    $last_exec[$id]['last'] = time();
555
+		}
556
+			$last_exec[$id]['last'] = time();
557 557
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
558
-	    echo 'download...';
559
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
560
-	    echo 'done !'."\n";
561
-	    if ($buffer != '') $reset = 0;
562
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
563
-	    $buffer = explode('\n',$buffer);
564
-	    foreach ($buffer as $line) {
558
+		echo 'download...';
559
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
560
+		echo 'done !'."\n";
561
+		if ($buffer != '') $reset = 0;
562
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
563
+		$buffer = explode('\n',$buffer);
564
+		foreach ($buffer as $line) {
565 565
 		if ($line != '') {
566
-		    $data = array();
567
-		    $data['mmsi'] = (int)substr($line,0,9);
568
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
569
-		    //$data['status'] = substr($line,21,2);
570
-		    //$data['type'] = substr($line,24,3);
571
-		    $data['latitude'] = substr($line,29,9);
572
-		    $data['longitude'] = substr($line,41,9);
573
-		    $data['speed'] = round(substr($line,51,5));
574
-		    //$data['course'] = substr($line,57,5);
575
-		    $data['heading'] = round(substr($line,63,3));
576
-		    //$data['draft'] = substr($line,67,4);
577
-		    //$data['length'] = substr($line,72,3);
578
-		    //$data['beam'] = substr($line,76,2);
579
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
580
-		    //$data['callsign'] = trim(substr($line,100,7);
581
-		    //$data['dest'] = substr($line,108,20);
582
-		    //$data['etaDate'] = substr($line,129,5);
583
-		    //$data['etaTime'] = substr($line,135,5);
584
-		    $data['format_source'] = 'shipplotter';
585
-    		    $data['id_source'] = $id_source;
586
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
587
-		    //print_r($data);
588
-		    echo 'Add...'."\n";
589
-		    $MI->add($data);
590
-		    unset($data);
566
+			$data = array();
567
+			$data['mmsi'] = (int)substr($line,0,9);
568
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
569
+			//$data['status'] = substr($line,21,2);
570
+			//$data['type'] = substr($line,24,3);
571
+			$data['latitude'] = substr($line,29,9);
572
+			$data['longitude'] = substr($line,41,9);
573
+			$data['speed'] = round(substr($line,51,5));
574
+			//$data['course'] = substr($line,57,5);
575
+			$data['heading'] = round(substr($line,63,3));
576
+			//$data['draft'] = substr($line,67,4);
577
+			//$data['length'] = substr($line,72,3);
578
+			//$data['beam'] = substr($line,76,2);
579
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
580
+			//$data['callsign'] = trim(substr($line,100,7);
581
+			//$data['dest'] = substr($line,108,20);
582
+			//$data['etaDate'] = substr($line,129,5);
583
+			//$data['etaTime'] = substr($line,135,5);
584
+			$data['format_source'] = 'shipplotter';
585
+				$data['id_source'] = $id_source;
586
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
587
+			//print_r($data);
588
+			echo 'Add...'."\n";
589
+			$MI->add($data);
590
+			unset($data);
591 591
 		}
592
-    	    }
593
-    	    $last_exec[$id]['last'] = time();
592
+			}
593
+			$last_exec[$id]['last'] = time();
594 594
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
595 595
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
596
-	    //$buffer = $Common->getData($hosts[$id]);
597
-	    $buffer = $Common->getData($value['host']);
598
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
599
-	    $buffer = explode('\n',$buffer);
600
-	    $reset = 0;
601
-	    foreach ($buffer as $line) {
602
-    		if ($line != '') {
603
-    		    $line = explode(':', $line);
604
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
596
+		//$buffer = $Common->getData($hosts[$id]);
597
+		$buffer = $Common->getData($value['host']);
598
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
599
+		$buffer = explode('\n',$buffer);
600
+		$reset = 0;
601
+		foreach ($buffer as $line) {
602
+			if ($line != '') {
603
+				$line = explode(':', $line);
604
+				if (count($line) > 30 && $line[0] != 'callsign') {
605 605
 			$data = array();
606 606
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
607 607
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -614,37 +614,37 @@  discard block
 block discarded – undo
614 614
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
615 615
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
616 616
 			$data['latitude'] = $line[5]; // lat
617
-	        	$data['longitude'] = $line[6]; // long
618
-	        	$data['verticalrate'] = ''; // vertical rate
619
-	        	$data['squawk'] = ''; // squawk
620
-	        	$data['emergency'] = ''; // emergency
621
-	        	$data['waypoints'] = $line[30];
617
+				$data['longitude'] = $line[6]; // long
618
+				$data['verticalrate'] = ''; // vertical rate
619
+				$data['squawk'] = ''; // squawk
620
+				$data['emergency'] = ''; // emergency
621
+				$data['waypoints'] = $line[30];
622 622
 			$data['datetime'] = date('Y-m-d H:i:s');
623 623
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
624 624
 			//if (isset($line[37])) $data['last_update'] = $line[37];
625
-		        $data['departure_airport_icao'] = $line[11];
626
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
627
-		        $data['arrival_airport_icao'] = $line[13];
625
+				$data['departure_airport_icao'] = $line[11];
626
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
627
+				$data['arrival_airport_icao'] = $line[13];
628 628
 			$data['frequency'] = $line[4];
629 629
 			$data['type'] = $line[18];
630 630
 			$data['range'] = $line[19];
631 631
 			if (isset($line[35])) $data['info'] = $line[35];
632
-    			$data['id_source'] = $id_source;
633
-	    		//$data['arrival_airport_time'] = ;
634
-	    		if ($line[9] != '') {
635
-	    		    $aircraft_data = explode('/',$line[9]);
636
-	    		    if (isset($aircraft_data[1])) {
637
-	    			$data['aircraft_icao'] = $aircraft_data[1];
638
-	    		    }
639
-        		}
640
-	    		/*
632
+				$data['id_source'] = $id_source;
633
+				//$data['arrival_airport_time'] = ;
634
+				if ($line[9] != '') {
635
+					$aircraft_data = explode('/',$line[9]);
636
+					if (isset($aircraft_data[1])) {
637
+					$data['aircraft_icao'] = $aircraft_data[1];
638
+					}
639
+				}
640
+				/*
641 641
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
642 642
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
643 643
 	    		*/
644
-	    		$data['format_source'] = $value['format'];
644
+				$data['format_source'] = $value['format'];
645 645
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
646 646
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
647
-    			if ($line[3] == 'PILOT') $SI->add($data);
647
+				if ($line[3] == 'PILOT') $SI->add($data);
648 648
 			elseif ($line[3] == 'ATC') {
649 649
 				//print_r($data);
650 650
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -662,255 +662,255 @@  discard block
 block discarded – undo
662 662
 				if (!isset($data['source_name'])) $data['source_name'] = '';
663 663
 				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
664 664
 			}
665
-    			unset($data);
666
-    		    }
667
-    		}
668
-    	    }
669
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
670
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
671
-    	    $last_exec[$id]['last'] = time();
672
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
673
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
674
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
675
-	    if ($buffer != '') {
676
-	    $all_data = json_decode($buffer,true);
677
-	    if (isset($all_data['acList'])) {
665
+				unset($data);
666
+				}
667
+			}
668
+			}
669
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
670
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
671
+			$last_exec[$id]['last'] = time();
672
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
673
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
674
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
675
+		if ($buffer != '') {
676
+		$all_data = json_decode($buffer,true);
677
+		if (isset($all_data['acList'])) {
678 678
 		$reset = 0;
679 679
 		foreach ($all_data['acList'] as $line) {
680
-		    $data = array();
681
-		    $data['hex'] = $line['Icao']; // hex
682
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
683
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
684
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
685
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
686
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
687
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
688
-		    //$data['verticalrate'] = $line['']; // verticale rate
689
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
690
-		    $data['emergency'] = ''; // emergency
691
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
680
+			$data = array();
681
+			$data['hex'] = $line['Icao']; // hex
682
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
683
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
684
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
685
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
686
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
687
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
688
+			//$data['verticalrate'] = $line['']; // verticale rate
689
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
690
+			$data['emergency'] = ''; // emergency
691
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
692 692
 		    
693
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
694
-		    else $data['datetime'] = date('Y-m-d H:i:s');
693
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
694
+			else $data['datetime'] = date('Y-m-d H:i:s');
695 695
 		    
696
-		    //$data['datetime'] = date('Y-m-d H:i:s');
697
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
698
-	    	    $data['format_source'] = 'aircraftlistjson';
699
-		    $data['id_source'] = $id_source;
700
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
701
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
-		    if (isset($data['latitude'])) $SI->add($data);
703
-		    unset($data);
696
+			//$data['datetime'] = date('Y-m-d H:i:s');
697
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
698
+				$data['format_source'] = 'aircraftlistjson';
699
+			$data['id_source'] = $id_source;
700
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
701
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
+			if (isset($data['latitude'])) $SI->add($data);
703
+			unset($data);
704 704
 		}
705
-	    } elseif (is_array($all_data)) {
705
+		} elseif (is_array($all_data)) {
706 706
 		$reset = 0;
707 707
 		foreach ($all_data as $line) {
708
-		    $data = array();
709
-		    $data['hex'] = $line['hex']; // hex
710
-		    $data['ident'] = $line['flight']; // ident
711
-		    $data['altitude'] = $line['altitude']; // altitude
712
-		    $data['speed'] = $line['speed']; // speed
713
-		    $data['heading'] = $line['track']; // heading
714
-		    $data['latitude'] = $line['lat']; // lat
715
-		    $data['longitude'] = $line['lon']; // long
716
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
717
-		    $data['squawk'] = $line['squawk']; // squawk
718
-		    $data['emergency'] = ''; // emergency
719
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
720
-		    else $data['datetime'] = date('Y-m-d H:i:s');
721
-	    	    $data['format_source'] = 'aircraftlistjson';
722
-    		    $data['id_source'] = $id_source;
723
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
724
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
725
-		    $SI->add($data);
726
-		    unset($data);
708
+			$data = array();
709
+			$data['hex'] = $line['hex']; // hex
710
+			$data['ident'] = $line['flight']; // ident
711
+			$data['altitude'] = $line['altitude']; // altitude
712
+			$data['speed'] = $line['speed']; // speed
713
+			$data['heading'] = $line['track']; // heading
714
+			$data['latitude'] = $line['lat']; // lat
715
+			$data['longitude'] = $line['lon']; // long
716
+			$data['verticalrate'] = $line['vrt']; // verticale rate
717
+			$data['squawk'] = $line['squawk']; // squawk
718
+			$data['emergency'] = ''; // emergency
719
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
720
+			else $data['datetime'] = date('Y-m-d H:i:s');
721
+				$data['format_source'] = 'aircraftlistjson';
722
+				$data['id_source'] = $id_source;
723
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
724
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
725
+			$SI->add($data);
726
+			unset($data);
727
+		}
727 728
 		}
728
-	    }
729
-	    }
730
-    	    //$last_exec['aircraftlistjson'] = time();
731
-    	    $last_exec[$id]['last'] = time();
732
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
733
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
734
-	    $buffer = $Common->getData($value['host']);
735
-	    $all_data = json_decode($buffer,true);
736
-	    if (isset($all_data['planes'])) {
729
+		}
730
+			//$last_exec['aircraftlistjson'] = time();
731
+			$last_exec[$id]['last'] = time();
732
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
733
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
734
+		$buffer = $Common->getData($value['host']);
735
+		$all_data = json_decode($buffer,true);
736
+		if (isset($all_data['planes'])) {
737 737
 		$reset = 0;
738 738
 		foreach ($all_data['planes'] as $key => $line) {
739
-		    $data = array();
740
-		    $data['hex'] = $key; // hex
741
-		    $data['ident'] = $line[3]; // ident
742
-		    $data['altitude'] = $line[6]; // altitude
743
-		    $data['speed'] = $line[8]; // speed
744
-		    $data['heading'] = $line[7]; // heading
745
-		    $data['latitude'] = $line[4]; // lat
746
-		    $data['longitude'] = $line[5]; // long
747
-		    //$data['verticalrate'] = $line[]; // verticale rate
748
-		    $data['squawk'] = $line[10]; // squawk
749
-		    $data['emergency'] = ''; // emergency
750
-		    $data['registration'] = $line[2];
751
-		    $data['aircraft_icao'] = $line[0];
752
-		    $deparr = explode('-',$line[1]);
753
-		    if (count($deparr) == 2) {
739
+			$data = array();
740
+			$data['hex'] = $key; // hex
741
+			$data['ident'] = $line[3]; // ident
742
+			$data['altitude'] = $line[6]; // altitude
743
+			$data['speed'] = $line[8]; // speed
744
+			$data['heading'] = $line[7]; // heading
745
+			$data['latitude'] = $line[4]; // lat
746
+			$data['longitude'] = $line[5]; // long
747
+			//$data['verticalrate'] = $line[]; // verticale rate
748
+			$data['squawk'] = $line[10]; // squawk
749
+			$data['emergency'] = ''; // emergency
750
+			$data['registration'] = $line[2];
751
+			$data['aircraft_icao'] = $line[0];
752
+			$deparr = explode('-',$line[1]);
753
+			if (count($deparr) == 2) {
754 754
 			$data['departure_airport_icao'] = $deparr[0];
755 755
 			$data['arrival_airport_icao'] = $deparr[1];
756
-		    }
757
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
758
-	    	    $data['format_source'] = 'planeupdatefaa';
759
-    		    $data['id_source'] = $id_source;
760
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
761
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
762
-		    $SI->add($data);
763
-		    unset($data);
756
+			}
757
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
758
+				$data['format_source'] = 'planeupdatefaa';
759
+				$data['id_source'] = $id_source;
760
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
761
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
762
+			$SI->add($data);
763
+			unset($data);
764
+		}
764 765
 		}
765
-	    }
766
-    	    //$last_exec['planeupdatefaa'] = time();
767
-    	    $last_exec[$id]['last'] = time();
768
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
769
-	    $buffer = $Common->getData($value['host']);
770
-	    $all_data = json_decode($buffer,true);
771
-	    if (isset($all_data['states'])) {
766
+			//$last_exec['planeupdatefaa'] = time();
767
+			$last_exec[$id]['last'] = time();
768
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
769
+		$buffer = $Common->getData($value['host']);
770
+		$all_data = json_decode($buffer,true);
771
+		if (isset($all_data['states'])) {
772 772
 		$reset = 0;
773 773
 		foreach ($all_data['states'] as $key => $line) {
774
-		    $data = array();
775
-		    $data['hex'] = $line[0]; // hex
776
-		    $data['ident'] = trim($line[1]); // ident
777
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
778
-		    $data['speed'] = round($line[9]*1.94384); // speed
779
-		    $data['heading'] = round($line[10]); // heading
780
-		    $data['latitude'] = $line[5]; // lat
781
-		    $data['longitude'] = $line[6]; // long
782
-		    $data['verticalrate'] = $line[11]; // verticale rate
783
-		    //$data['squawk'] = $line[10]; // squawk
784
-		    //$data['emergency'] = ''; // emergency
785
-		    //$data['registration'] = $line[2];
786
-		    //$data['aircraft_icao'] = $line[0];
787
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
788
-	    	    $data['format_source'] = 'opensky';
789
-    		    $data['id_source'] = $id_source;
790
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
791
-		    $SI->add($data);
792
-		    unset($data);
774
+			$data = array();
775
+			$data['hex'] = $line[0]; // hex
776
+			$data['ident'] = trim($line[1]); // ident
777
+			$data['altitude'] = round($line[7]*3.28084); // altitude
778
+			$data['speed'] = round($line[9]*1.94384); // speed
779
+			$data['heading'] = round($line[10]); // heading
780
+			$data['latitude'] = $line[5]; // lat
781
+			$data['longitude'] = $line[6]; // long
782
+			$data['verticalrate'] = $line[11]; // verticale rate
783
+			//$data['squawk'] = $line[10]; // squawk
784
+			//$data['emergency'] = ''; // emergency
785
+			//$data['registration'] = $line[2];
786
+			//$data['aircraft_icao'] = $line[0];
787
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
788
+				$data['format_source'] = 'opensky';
789
+				$data['id_source'] = $id_source;
790
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
791
+			$SI->add($data);
792
+			unset($data);
793
+		}
793 794
 		}
794
-	    }
795
-    	    //$last_exec['planeupdatefaa'] = time();
796
-    	    $last_exec[$id]['last'] = time();
797
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
798
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
799
-	    //$buffer = $Common->getData($hosts[$id]);
800
-	    $buffer = $Common->getData($value['host']);
801
-	    $all_data = json_decode($buffer,true);
802
-	    if (!empty($all_data)) $reset = 0;
803
-	    foreach ($all_data as $key => $line) {
795
+			//$last_exec['planeupdatefaa'] = time();
796
+			$last_exec[$id]['last'] = time();
797
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
798
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
799
+		//$buffer = $Common->getData($hosts[$id]);
800
+		$buffer = $Common->getData($value['host']);
801
+		$all_data = json_decode($buffer,true);
802
+		if (!empty($all_data)) $reset = 0;
803
+		foreach ($all_data as $key => $line) {
804 804
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
805
-		    $data = array();
806
-		    $data['hex'] = $line[0];
807
-		    $data['ident'] = $line[16]; //$line[13]
808
-	    	    $data['altitude'] = $line[4]; // altitude
809
-	    	    $data['speed'] = $line[5]; // speed
810
-	    	    $data['heading'] = $line[3]; // heading
811
-	    	    $data['latitude'] = $line[1]; // lat
812
-	    	    $data['longitude'] = $line[2]; // long
813
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
814
-	    	    $data['squawk'] = $line[6]; // squawk
815
-	    	    $data['aircraft_icao'] = $line[8];
816
-	    	    $data['registration'] = $line[9];
817
-		    $data['departure_airport_iata'] = $line[11];
818
-		    $data['arrival_airport_iata'] = $line[12];
819
-	    	    $data['emergency'] = ''; // emergency
820
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
821
-	    	    $data['format_source'] = 'fr24json';
822
-    		    $data['id_source'] = $id_source;
823
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
824
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
825
-		    $SI->add($data);
826
-		    unset($data);
805
+			$data = array();
806
+			$data['hex'] = $line[0];
807
+			$data['ident'] = $line[16]; //$line[13]
808
+				$data['altitude'] = $line[4]; // altitude
809
+				$data['speed'] = $line[5]; // speed
810
+				$data['heading'] = $line[3]; // heading
811
+				$data['latitude'] = $line[1]; // lat
812
+				$data['longitude'] = $line[2]; // long
813
+				$data['verticalrate'] = $line[15]; // verticale rate
814
+				$data['squawk'] = $line[6]; // squawk
815
+				$data['aircraft_icao'] = $line[8];
816
+				$data['registration'] = $line[9];
817
+			$data['departure_airport_iata'] = $line[11];
818
+			$data['arrival_airport_iata'] = $line[12];
819
+				$data['emergency'] = ''; // emergency
820
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
821
+				$data['format_source'] = 'fr24json';
822
+				$data['id_source'] = $id_source;
823
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
824
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
825
+			$SI->add($data);
826
+			unset($data);
827
+		}
827 828
 		}
828
-	    }
829
-    	    //$last_exec['fr24json'] = time();
830
-    	    $last_exec[$id]['last'] = time();
831
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
832
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
833
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
834
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
835
-	    //echo $buffer;
836
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
837
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
838
-	    $all_data = json_decode($buffer,true);
839
-	    if (json_last_error() != JSON_ERROR_NONE) {
829
+			//$last_exec['fr24json'] = time();
830
+			$last_exec[$id]['last'] = time();
831
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
832
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
833
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
834
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
835
+		//echo $buffer;
836
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
837
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
838
+		$all_data = json_decode($buffer,true);
839
+		if (json_last_error() != JSON_ERROR_NONE) {
840 840
 		die(json_last_error_msg());
841
-	    }
842
-	    if (isset($all_data['mrkrs'])) {
841
+		}
842
+		if (isset($all_data['mrkrs'])) {
843 843
 		$reset = 0;
844 844
 		foreach ($all_data['mrkrs'] as $key => $line) {
845
-		    if (isset($line['inf'])) {
845
+			if (isset($line['inf'])) {
846 846
 			$data = array();
847 847
 			$data['hex'] = $line['inf']['ia'];
848 848
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
849
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
850
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
851
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
852
-	    		$data['latitude'] = $line['pt'][0]; // lat
853
-	    		$data['longitude'] = $line['pt'][1]; // long
854
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
855
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
856
-	    		//$data['aircraft_icao'] = $line[8];
857
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
849
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
850
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
851
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
852
+				$data['latitude'] = $line['pt'][0]; // lat
853
+				$data['longitude'] = $line['pt'][1]; // long
854
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
855
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
856
+				//$data['aircraft_icao'] = $line[8];
857
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
858 858
 			//$data['departure_airport_iata'] = $line[11];
859 859
 			//$data['arrival_airport_iata'] = $line[12];
860
-	    		//$data['emergency'] = ''; // emergency
860
+				//$data['emergency'] = ''; // emergency
861 861
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
862
-	    		$data['format_source'] = 'radarvirtueljson';
863
-    			$data['id_source'] = $id_source;
862
+				$data['format_source'] = 'radarvirtueljson';
863
+				$data['id_source'] = $id_source;
864 864
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
865 865
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
866 866
 			$SI->add($data);
867 867
 			unset($data);
868
-		    }
868
+			}
869
+		}
869 870
 		}
870
-	    }
871
-    	    //$last_exec['radarvirtueljson'] = time();
872
-    	    $last_exec[$id]['last'] = time();
873
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
874
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
875
-	    //$buffer = $Common->getData($hosts[$id]);
876
-	    $buffer = $Common->getData($value['host'].'?'.time());
877
-	    $all_data = json_decode(utf8_encode($buffer),true);
871
+			//$last_exec['radarvirtueljson'] = time();
872
+			$last_exec[$id]['last'] = time();
873
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
874
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
875
+		//$buffer = $Common->getData($hosts[$id]);
876
+		$buffer = $Common->getData($value['host'].'?'.time());
877
+		$all_data = json_decode(utf8_encode($buffer),true);
878 878
 	    
879
-	    if (isset($all_data['pireps'])) {
879
+		if (isset($all_data['pireps'])) {
880 880
 		$reset = 0;
881
-	        foreach ($all_data['pireps'] as $line) {
882
-		    $data = array();
883
-		    $data['id'] = $line['id'];
884
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
885
-		    $data['ident'] = $line['callsign']; // ident
886
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
887
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
888
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
889
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
890
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
891
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
892
-		    $data['latitude'] = $line['lat']; // lat
893
-		    $data['longitude'] = $line['lon']; // long
894
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
895
-		    //$data['squawk'] = $line['squawk']; // squawk
896
-		    //$data['emergency'] = ''; // emergency
897
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
898
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
899
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
900
-		    //$data['arrival_airport_time'] = $line['arrtime'];
901
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
902
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
903
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
904
-		    else $data['info'] = '';
905
-		    $data['format_source'] = 'pireps';
906
-    		    $data['id_source'] = $id_source;
907
-		    $data['datetime'] = date('Y-m-d H:i:s');
908
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
909
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
910
-		    if ($line['icon'] == 'plane') {
881
+			foreach ($all_data['pireps'] as $line) {
882
+			$data = array();
883
+			$data['id'] = $line['id'];
884
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
885
+			$data['ident'] = $line['callsign']; // ident
886
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
887
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
888
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
889
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
890
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
891
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
892
+			$data['latitude'] = $line['lat']; // lat
893
+			$data['longitude'] = $line['lon']; // long
894
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
895
+			//$data['squawk'] = $line['squawk']; // squawk
896
+			//$data['emergency'] = ''; // emergency
897
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
898
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
899
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
900
+			//$data['arrival_airport_time'] = $line['arrtime'];
901
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
902
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
903
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
904
+			else $data['info'] = '';
905
+			$data['format_source'] = 'pireps';
906
+				$data['id_source'] = $id_source;
907
+			$data['datetime'] = date('Y-m-d H:i:s');
908
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
909
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
910
+			if ($line['icon'] == 'plane') {
911 911
 			$SI->add($data);
912
-		    //    print_r($data);
913
-    		    } elseif ($line['icon'] == 'ct') {
912
+			//    print_r($data);
913
+				} elseif ($line['icon'] == 'ct') {
914 914
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
915 915
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
916 916
 			$typec = substr($data['ident'],-3);
@@ -925,197 +925,197 @@  discard block
 block discarded – undo
925 925
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
926 926
 			else $data['type'] = 'Observer';
927 927
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
928
-		    }
929
-		    unset($data);
928
+			}
929
+			unset($data);
930 930
 		}
931
-	    }
932
-    	    //$last_exec['pirepsjson'] = time();
933
-    	    $last_exec[$id]['last'] = time();
934
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
935
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
936
-	    //$buffer = $Common->getData($hosts[$id]);
937
-	    if ($globalDebug) echo 'Get Data...'."\n";
938
-	    $buffer = $Common->getData($value['host']);
939
-	    $all_data = json_decode($buffer,true);
940
-	    if ($buffer != '' && is_array($all_data)) {
931
+		}
932
+			//$last_exec['pirepsjson'] = time();
933
+			$last_exec[$id]['last'] = time();
934
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
935
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
936
+		//$buffer = $Common->getData($hosts[$id]);
937
+		if ($globalDebug) echo 'Get Data...'."\n";
938
+		$buffer = $Common->getData($value['host']);
939
+		$all_data = json_decode($buffer,true);
940
+		if ($buffer != '' && is_array($all_data)) {
941 941
 		$reset = 0;
942 942
 		foreach ($all_data as $line) {
943
-	    	    $data = array();
944
-	    	    //$data['id'] = $line['id']; // id not usable
945
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
946
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
947
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
948
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
949
-	    	    $data['ident'] = $line['flightnum']; // ident
950
-	    	    $data['altitude'] = $line['alt']; // altitude
951
-	    	    $data['speed'] = $line['gs']; // speed
952
-	    	    $data['heading'] = $line['heading']; // heading
953
-	    	    $data['latitude'] = $line['lat']; // lat
954
-	    	    $data['longitude'] = $line['lng']; // long
955
-	    	    $data['verticalrate'] = ''; // verticale rate
956
-	    	    $data['squawk'] = ''; // squawk
957
-	    	    $data['emergency'] = ''; // emergency
958
-	    	    //$data['datetime'] = $line['lastupdate'];
959
-	    	    $data['last_update'] = $line['lastupdate'];
960
-		    $data['datetime'] = date('Y-m-d H:i:s');
961
-	    	    $data['departure_airport_icao'] = $line['depicao'];
962
-	    	    $data['departure_airport_time'] = $line['deptime'];
963
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
964
-    		    $data['arrival_airport_time'] = $line['arrtime'];
965
-    		    $data['registration'] = $line['aircraft'];
966
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
968
-		    if (isset($line['aircraftname'])) {
943
+				$data = array();
944
+				//$data['id'] = $line['id']; // id not usable
945
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
946
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
947
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
948
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
949
+				$data['ident'] = $line['flightnum']; // ident
950
+				$data['altitude'] = $line['alt']; // altitude
951
+				$data['speed'] = $line['gs']; // speed
952
+				$data['heading'] = $line['heading']; // heading
953
+				$data['latitude'] = $line['lat']; // lat
954
+				$data['longitude'] = $line['lng']; // long
955
+				$data['verticalrate'] = ''; // verticale rate
956
+				$data['squawk'] = ''; // squawk
957
+				$data['emergency'] = ''; // emergency
958
+				//$data['datetime'] = $line['lastupdate'];
959
+				$data['last_update'] = $line['lastupdate'];
960
+			$data['datetime'] = date('Y-m-d H:i:s');
961
+				$data['departure_airport_icao'] = $line['depicao'];
962
+				$data['departure_airport_time'] = $line['deptime'];
963
+				$data['arrival_airport_icao'] = $line['arricao'];
964
+				$data['arrival_airport_time'] = $line['arrtime'];
965
+				$data['registration'] = $line['aircraft'];
966
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
968
+			if (isset($line['aircraftname'])) {
969 969
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
970 970
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
971
-	    		$aircraft_data = explode('-',$line['aircraftname']);
972
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
973
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
974
-	    		else {
975
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
976
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
977
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
978
-	    		}
979
-	    	    }
980
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
981
-    		    $data['id_source'] = $id_source;
982
-	    	    $data['format_source'] = 'phpvmacars';
983
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
984
-		    $SI->add($data);
985
-		    unset($data);
971
+				$aircraft_data = explode('-',$line['aircraftname']);
972
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
973
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
974
+				else {
975
+					$aircraft_data = explode(' ',$line['aircraftname']);
976
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
977
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
978
+				}
979
+				}
980
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
981
+				$data['id_source'] = $id_source;
982
+				$data['format_source'] = 'phpvmacars';
983
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
984
+			$SI->add($data);
985
+			unset($data);
986 986
 		}
987 987
 		if ($globalDebug) echo 'No more data...'."\n";
988 988
 		unset($buffer);
989 989
 		unset($all_data);
990
-	    }
991
-    	    //$last_exec['phpvmacars'] = time();
992
-    	    $last_exec[$id]['last'] = time();
993
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
994
-	    //$buffer = $Common->getData($hosts[$id]);
995
-	    if ($globalDebug) echo 'Get Data...'."\n";
996
-	    $buffer = $Common->getData($value['host']);
997
-	    $all_data = json_decode($buffer,true);
998
-	    if ($buffer != '' && is_array($all_data)) {
990
+		}
991
+			//$last_exec['phpvmacars'] = time();
992
+			$last_exec[$id]['last'] = time();
993
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
994
+		//$buffer = $Common->getData($hosts[$id]);
995
+		if ($globalDebug) echo 'Get Data...'."\n";
996
+		$buffer = $Common->getData($value['host']);
997
+		$all_data = json_decode($buffer,true);
998
+		if ($buffer != '' && is_array($all_data)) {
999 999
 		$reset = 0;
1000 1000
 		foreach ($all_data as $line) {
1001
-	    	    $data = array();
1002
-	    	    //$data['id'] = $line['id']; // id not usable
1003
-	    	    $data['id'] = trim($line['flight_id']);
1004
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1005
-	    	    $data['pilot_name'] = $line['pilot_name'];
1006
-	    	    $data['pilot_id'] = $line['pilot_id'];
1007
-	    	    $data['ident'] = trim($line['callsign']); // ident
1008
-	    	    $data['altitude'] = $line['altitude']; // altitude
1009
-	    	    $data['speed'] = $line['gs']; // speed
1010
-	    	    $data['heading'] = $line['heading']; // heading
1011
-	    	    $data['latitude'] = $line['latitude']; // lat
1012
-	    	    $data['longitude'] = $line['longitude']; // long
1013
-	    	    $data['verticalrate'] = ''; // verticale rate
1014
-	    	    $data['squawk'] = ''; // squawk
1015
-	    	    $data['emergency'] = ''; // emergency
1016
-	    	    //$data['datetime'] = $line['lastupdate'];
1017
-	    	    $data['last_update'] = $line['last_update'];
1018
-		    $data['datetime'] = date('Y-m-d H:i:s');
1019
-	    	    $data['departure_airport_icao'] = $line['departure'];
1020
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1021
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1022
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1023
-    		    //$data['registration'] = $line['aircraft'];
1024
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1025
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1026
-    		    $data['id_source'] = $id_source;
1027
-	    	    $data['format_source'] = 'vam';
1028
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1029
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1030
-		    $SI->add($data);
1031
-		    unset($data);
1001
+				$data = array();
1002
+				//$data['id'] = $line['id']; // id not usable
1003
+				$data['id'] = trim($line['flight_id']);
1004
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1005
+				$data['pilot_name'] = $line['pilot_name'];
1006
+				$data['pilot_id'] = $line['pilot_id'];
1007
+				$data['ident'] = trim($line['callsign']); // ident
1008
+				$data['altitude'] = $line['altitude']; // altitude
1009
+				$data['speed'] = $line['gs']; // speed
1010
+				$data['heading'] = $line['heading']; // heading
1011
+				$data['latitude'] = $line['latitude']; // lat
1012
+				$data['longitude'] = $line['longitude']; // long
1013
+				$data['verticalrate'] = ''; // verticale rate
1014
+				$data['squawk'] = ''; // squawk
1015
+				$data['emergency'] = ''; // emergency
1016
+				//$data['datetime'] = $line['lastupdate'];
1017
+				$data['last_update'] = $line['last_update'];
1018
+			$data['datetime'] = date('Y-m-d H:i:s');
1019
+				$data['departure_airport_icao'] = $line['departure'];
1020
+				//$data['departure_airport_time'] = $line['departure_time'];
1021
+				$data['arrival_airport_icao'] = $line['arrival'];
1022
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1023
+				//$data['registration'] = $line['aircraft'];
1024
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1025
+				$data['aircraft_icao'] = $line['plane_type'];
1026
+				$data['id_source'] = $id_source;
1027
+				$data['format_source'] = 'vam';
1028
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1029
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1030
+			$SI->add($data);
1031
+			unset($data);
1032 1032
 		}
1033 1033
 		if ($globalDebug) echo 'No more data...'."\n";
1034 1034
 		unset($buffer);
1035 1035
 		unset($all_data);
1036
-	    }
1037
-    	    //$last_exec['phpvmacars'] = time();
1038
-    	    $last_exec[$id]['last'] = time();
1036
+		}
1037
+			//$last_exec['phpvmacars'] = time();
1038
+			$last_exec[$id]['last'] = time();
1039 1039
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1040 1040
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1041
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1042
-    	    //$last_exec[$id]['last'] = time();
1041
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1042
+			//$last_exec[$id]['last'] = time();
1043 1043
 
1044
-	    //$read = array( $sockets[$id] );
1045
-	    $read = $sockets;
1046
-	    $write = NULL;
1047
-	    $e = NULL;
1048
-	    $n = socket_select($read, $write, $e, $timeout);
1049
-	    if ($e != NULL) var_dump($e);
1050
-	    if ($n > 0) {
1044
+		//$read = array( $sockets[$id] );
1045
+		$read = $sockets;
1046
+		$write = NULL;
1047
+		$e = NULL;
1048
+		$n = socket_select($read, $write, $e, $timeout);
1049
+		if ($e != NULL) var_dump($e);
1050
+		if ($n > 0) {
1051 1051
 		$reset = 0;
1052 1052
 		foreach ($read as $nb => $r) {
1053
-		    //$value = $formats[$nb];
1054
-		    $format = $globalSources[$nb]['format'];
1055
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1053
+			//$value = $formats[$nb];
1054
+			$format = $globalSources[$nb]['format'];
1055
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1056 1056
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1057
-		    } elseif ($format == 'vrstcp') {
1057
+			} elseif ($format == 'vrstcp') {
1058 1058
 			$buffer = @socket_read($r, 6000);
1059
-		    } else {
1059
+			} else {
1060 1060
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1061
-		    }
1062
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1063
-		    //echo $buffer."\n";
1064
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1065
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1066
-		    $error = false;
1067
-		    //$SI::del();
1068
-		    if ($format == 'vrstcp') {
1061
+			}
1062
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1063
+			//echo $buffer."\n";
1064
+			// lets play nice and handle signals such as ctrl-c/kill properly
1065
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1066
+			$error = false;
1067
+			//$SI::del();
1068
+			if ($format == 'vrstcp') {
1069 1069
 			$buffer = explode('},{',$buffer);
1070
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1071
-		    // SBS format is CSV format
1072
-		    if ($buffer !== FALSE && $buffer != '') {
1070
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1071
+			// SBS format is CSV format
1072
+			if ($buffer !== FALSE && $buffer != '') {
1073 1073
 			$tt[$format] = 0;
1074 1074
 			if ($format == 'acarssbs3') {
1075
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1076
-			    $ACARS->add(trim($buffer));
1077
-			    $ACARS->deleteLiveAcarsData();
1075
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1076
+				$ACARS->add(trim($buffer));
1077
+				$ACARS->deleteLiveAcarsData();
1078 1078
 			} elseif ($format == 'raw') {
1079
-			    // AVR format
1080
-			    $data = $SBS->parse($buffer);
1081
-			    if (is_array($data)) {
1079
+				// AVR format
1080
+				$data = $SBS->parse($buffer);
1081
+				if (is_array($data)) {
1082 1082
 				$data['datetime'] = date('Y-m-d H:i:s');
1083 1083
 				$data['format_source'] = 'raw';
1084 1084
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1085 1085
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1086 1086
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1087 1087
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1088
-			    }
1088
+				}
1089 1089
 			} elseif ($format == 'ais') {
1090
-			    $ais_data = $AIS->parse_line(trim($buffer));
1091
-			    $data = array();
1092
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1093
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1094
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1095
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1096
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1097
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1098
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1099
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1100
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1101
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1102
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1103
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1104
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1105
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1090
+				$ais_data = $AIS->parse_line(trim($buffer));
1091
+				$data = array();
1092
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1093
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1094
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1095
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1096
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1097
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1098
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1099
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1100
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1101
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1102
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1103
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1104
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1105
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1106 1106
 
1107
-			    if (isset($ais_data['timestamp'])) {
1107
+				if (isset($ais_data['timestamp'])) {
1108 1108
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1109
-			    } else {
1109
+				} else {
1110 1110
 				$data['datetime'] = date('Y-m-d H:i:s');
1111
-			    }
1112
-			    $data['format_source'] = 'aisnmea';
1113
-    			    $data['id_source'] = $id_source;
1114
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1115
-			    unset($data);
1116
-                        } elseif ($format == 'flightgearsp') {
1117
-                    	    //echo $buffer."\n";
1118
-                    	    if (strlen($buffer) > 5) {
1111
+				}
1112
+				$data['format_source'] = 'aisnmea';
1113
+					$data['id_source'] = $id_source;
1114
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1115
+				unset($data);
1116
+						} elseif ($format == 'flightgearsp') {
1117
+							//echo $buffer."\n";
1118
+							if (strlen($buffer) > 5) {
1119 1119
 				$line = explode(',',$buffer);
1120 1120
 				$data = array();
1121 1121
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1132,38 +1132,38 @@  discard block
 block discarded – undo
1132 1132
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1133 1133
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1134 1134
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1135
-			    }
1136
-                        } elseif ($format == 'acars') {
1137
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1138
-			    $ACARS->add(trim($buffer));
1139
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1140
-			    $ACARS->deleteLiveAcarsData();
1135
+				}
1136
+						} elseif ($format == 'acars') {
1137
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1138
+				$ACARS->add(trim($buffer));
1139
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1140
+				$ACARS->deleteLiveAcarsData();
1141 1141
 			} elseif ($format == 'flightgearmp') {
1142
-			    if (substr($buffer,0,1) != '#') {
1142
+				if (substr($buffer,0,1) != '#') {
1143 1143
 				$data = array();
1144 1144
 				//echo $buffer."\n";
1145 1145
 				$line = explode(' ',$buffer);
1146 1146
 				if (count($line) == 11) {
1147
-				    $userserver = explode('@',$line[0]);
1148
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1149
-				    $data['ident'] = $userserver[0];
1150
-				    $data['registration'] = $userserver[0];
1151
-				    $data['latitude'] = $line[4];
1152
-				    $data['longitude'] = $line[5];
1153
-				    $data['altitude'] = $line[6];
1154
-				    $data['datetime'] = date('Y-m-d H:i:s');
1155
-				    $aircraft_type = $line[10];
1156
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1157
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1158
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1159
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1147
+					$userserver = explode('@',$line[0]);
1148
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1149
+					$data['ident'] = $userserver[0];
1150
+					$data['registration'] = $userserver[0];
1151
+					$data['latitude'] = $line[4];
1152
+					$data['longitude'] = $line[5];
1153
+					$data['altitude'] = $line[6];
1154
+					$data['datetime'] = date('Y-m-d H:i:s');
1155
+					$aircraft_type = $line[10];
1156
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1157
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1158
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1159
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1160
+				}
1160 1161
 				}
1161
-			    }
1162 1162
 			} elseif ($format == 'beast') {
1163
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1164
-			    die;
1163
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1164
+				die;
1165 1165
 			} elseif ($format == 'vrstcp') {
1166
-			    foreach($buffer as $all_data) {
1166
+				foreach($buffer as $all_data) {
1167 1167
 				$line = json_decode('{'.$all_data.'}',true);
1168 1168
 				$data = array();
1169 1169
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1183,113 +1183,113 @@  discard block
 block discarded – undo
1183 1183
 				*/
1184 1184
 				$data['datetime'] = date('Y-m-d H:i:s');
1185 1185
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1186
-		    		$data['format_source'] = 'vrstcp';
1186
+					$data['format_source'] = 'vrstcp';
1187 1187
 				$data['id_source'] = $id_source;
1188 1188
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1189 1189
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1190 1190
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1191 1191
 				unset($data);
1192
-			    }
1192
+				}
1193 1193
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1194
-			    $line = explode("\t", $buffer);
1195
-			    for($k = 0; $k < count($line); $k=$k+2) {
1194
+				$line = explode("\t", $buffer);
1195
+				for($k = 0; $k < count($line); $k=$k+2) {
1196 1196
 				$key = $line[$k];
1197
-			        $lined[$key] = $line[$k+1];
1198
-			    }
1199
-    			    if (count($lined) > 3) {
1200
-    				$data['hex'] = $lined['hexid'];
1201
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1202
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1203
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1204
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1205
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1206
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1207
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1208
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1209
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1210
-    				$data['id_source'] = $id_source;
1211
-    				$data['format_source'] = 'tsv';
1212
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1213
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1197
+					$lined[$key] = $line[$k+1];
1198
+				}
1199
+					if (count($lined) > 3) {
1200
+					$data['hex'] = $lined['hexid'];
1201
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1202
+					$data['datetime'] = date('Y-m-d H:i:s');;
1203
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1204
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1205
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1206
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1207
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1208
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1209
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1210
+					$data['id_source'] = $id_source;
1211
+					$data['format_source'] = 'tsv';
1212
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1213
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1214 1214
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1215
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1216
-    				unset($lined);
1217
-    				unset($data);
1218
-    			    } else $error = true;
1215
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1216
+					unset($lined);
1217
+					unset($data);
1218
+					} else $error = true;
1219 1219
 			} elseif ($format == 'aprs' && $use_aprs) {
1220
-			    if ($aprs_connect == 0) {
1220
+				if ($aprs_connect == 0) {
1221 1221
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1222 1222
 				$aprs_connect = 1;
1223
-			    }
1223
+				}
1224 1224
 			    
1225
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1225
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1226 1226
 				$aprs_last_tx = time();
1227 1227
 				$data_aprs = "# Keep alive";
1228 1228
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1229
-			    }
1229
+				}
1230 1230
 			    
1231
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1232
-			    //echo 'APRS data : '.$buffer."\n";
1233
-			    $buffer = str_replace('APRS <- ','',$buffer);
1234
-			    $buffer = str_replace('APRS -> ','',$buffer);
1235
-			    //echo $buffer."\n";
1236
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1231
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1232
+				//echo 'APRS data : '.$buffer."\n";
1233
+				$buffer = str_replace('APRS <- ','',$buffer);
1234
+				$buffer = str_replace('APRS -> ','',$buffer);
1235
+				//echo $buffer."\n";
1236
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1237 1237
 				$line = $APRS->parse($buffer);
1238 1238
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1239 1239
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1240
-				    $aprs_last_tx = time();
1241
-				    $data = array();
1242
-				    //print_r($line);
1243
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1244
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1245
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1246
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1247
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1248
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1249
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1250
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1251
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1252
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1253
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1254
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1255
-				    $data['latitude'] = $line['latitude'];
1256
-				    $data['longitude'] = $line['longitude'];
1257
-				    //$data['verticalrate'] = $line[16];
1258
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1259
-				    else $data['speed'] = 0;
1260
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1261
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1262
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1263
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1264
-				    //else $data['heading'] = 0;
1265
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1266
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1267
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1268
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1269
-    				    $data['id_source'] = $id_source;
1270
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1271
-				    else $data['format_source'] = 'aprs';
1272
-				    $data['source_name'] = $line['source'];
1273
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1274
-				    else $data['source_type'] = 'flarm';
1275
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
-				    $currentdate = date('Y-m-d H:i:s');
1277
-				    $aprsdate = strtotime($data['datetime']);
1278
-				    // Accept data if time <= system time + 20s
1279
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1280
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1240
+					$aprs_last_tx = time();
1241
+					$data = array();
1242
+					//print_r($line);
1243
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1244
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1245
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1246
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1247
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1248
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1249
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1250
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1251
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1252
+					else $data['datetime'] = date('Y-m-d H:i:s');
1253
+					//$data['datetime'] = date('Y-m-d H:i:s');
1254
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1255
+					$data['latitude'] = $line['latitude'];
1256
+					$data['longitude'] = $line['longitude'];
1257
+					//$data['verticalrate'] = $line[16];
1258
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1259
+					else $data['speed'] = 0;
1260
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1261
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1262
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1263
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1264
+					//else $data['heading'] = 0;
1265
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1266
+					if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1267
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1268
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1269
+						$data['id_source'] = $id_source;
1270
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1271
+					else $data['format_source'] = 'aprs';
1272
+					$data['source_name'] = $line['source'];
1273
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1274
+					else $data['source_type'] = 'flarm';
1275
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
+					$currentdate = date('Y-m-d H:i:s');
1277
+					$aprsdate = strtotime($data['datetime']);
1278
+					// Accept data if time <= system time + 20s
1279
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1280
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1281 1281
 					$send = $SI->add($data);
1282
-				    } elseif ($data['source_type'] == 'ais') {
1282
+					} elseif ($data['source_type'] == 'ais') {
1283 1283
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1284
-				    } elseif (isset($line['stealth'])) {
1284
+					} elseif (isset($line['stealth'])) {
1285 1285
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1286 1286
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1287
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1288
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1287
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1288
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1289 1289
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1290 1290
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1291
-				    }
1292
-				    unset($data);
1291
+					}
1292
+					unset($data);
1293 1293
 				} 
1294 1294
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1295 1295
 					echo '!! Weather Station not yet supported'."\n";
@@ -1299,12 +1299,12 @@  discard block
 block discarded – undo
1299 1299
 				}
1300 1300
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1301 1301
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1302
-			    }
1302
+				}
1303 1303
 			} else {
1304
-			    $line = explode(',', $buffer);
1305
-    			    if (count($line) > 20) {
1306
-    			    	$data['hex'] = $line[4];
1307
-    				/*
1304
+				$line = explode(',', $buffer);
1305
+					if (count($line) > 20) {
1306
+						$data['hex'] = $line[4];
1307
+					/*
1308 1308
     				$data['datetime'] = $line[6].' '.$line[7];
1309 1309
     					date_default_timezone_set($globalTimezone);
1310 1310
     					$datetime = new DateTime($data['datetime']);
@@ -1312,30 +1312,30 @@  discard block
 block discarded – undo
1312 1312
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1313 1313
     					date_default_timezone_set('UTC');
1314 1314
     				*/
1315
-    				// Force datetime to current UTC datetime
1316
-    				date_default_timezone_set('UTC');
1317
-    				$data['datetime'] = date('Y-m-d H:i:s');
1318
-    				$data['ident'] = trim($line[10]);
1319
-    				$data['latitude'] = $line[14];
1320
-    				$data['longitude'] = $line[15];
1321
-    				$data['verticalrate'] = $line[16];
1322
-    				$data['emergency'] = $line[20];
1323
-    				$data['speed'] = $line[12];
1324
-    				$data['squawk'] = $line[17];
1325
-    				$data['altitude'] = $line[11];
1326
-    				$data['heading'] = $line[13];
1327
-    				$data['ground'] = $line[21];
1328
-    				$data['emergency'] = $line[19];
1329
-    				$data['format_source'] = 'sbs';
1315
+					// Force datetime to current UTC datetime
1316
+					date_default_timezone_set('UTC');
1317
+					$data['datetime'] = date('Y-m-d H:i:s');
1318
+					$data['ident'] = trim($line[10]);
1319
+					$data['latitude'] = $line[14];
1320
+					$data['longitude'] = $line[15];
1321
+					$data['verticalrate'] = $line[16];
1322
+					$data['emergency'] = $line[20];
1323
+					$data['speed'] = $line[12];
1324
+					$data['squawk'] = $line[17];
1325
+					$data['altitude'] = $line[11];
1326
+					$data['heading'] = $line[13];
1327
+					$data['ground'] = $line[21];
1328
+					$data['emergency'] = $line[19];
1329
+					$data['format_source'] = 'sbs';
1330 1330
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1331
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1331
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1332 1332
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1333
-    				$data['id_source'] = $id_source;
1334
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1335
-    				else $error = true;
1336
-    				unset($data);
1337
-    			    } else $error = true;
1338
-			    if ($error) {
1333
+					$data['id_source'] = $id_source;
1334
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1335
+					else $error = true;
1336
+					unset($data);
1337
+					} else $error = true;
1338
+				if ($error) {
1339 1339
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1340 1340
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1341 1341
 				} else {
@@ -1351,13 +1351,13 @@  discard block
 block discarded – undo
1351 1351
 					connect_all($sourceer);
1352 1352
 					$sourceer = array();
1353 1353
 				}
1354
-			    }
1354
+				}
1355 1355
 			}
1356 1356
 			// Sleep for xxx microseconds
1357 1357
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1358
-		    } else {
1358
+			} else {
1359 1359
 			if ($format == 'flightgearmp') {
1360
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1360
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1361 1361
 				//@socket_close($r);
1362 1362
 				sleep($globalMinFetch);
1363 1363
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1366,9 +1366,9 @@  discard block
 block discarded – undo
1366 1366
 				break;
1367 1367
 				
1368 1368
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1369
-			    if (isset($tt[$format])) $tt[$format]++;
1370
-			    else $tt[$format] = 0;
1371
-			    if ($tt[$format] > 30) {
1369
+				if (isset($tt[$format])) $tt[$format]++;
1370
+				else $tt[$format] = 0;
1371
+				if ($tt[$format] > 30) {
1372 1372
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1373 1373
 				//@socket_close($r);
1374 1374
 				sleep(2);
@@ -1379,23 +1379,23 @@  discard block
 block discarded – undo
1379 1379
 				//connect_all($globalSources);
1380 1380
 				$tt[$format]=0;
1381 1381
 				break;
1382
-			    }
1382
+				}
1383
+			}
1383 1384
 			}
1384
-		    }
1385 1385
 		}
1386
-	    } else {
1386
+		} else {
1387 1387
 		$error = socket_strerror(socket_last_error());
1388 1388
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1389 1389
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1390 1390
 			if (isset($globalDebug)) echo "Restarting...\n";
1391 1391
 			// Restart the script if possible
1392 1392
 			if (is_array($sockets)) {
1393
-			    if ($globalDebug) echo "Shutdown all sockets...";
1393
+				if ($globalDebug) echo "Shutdown all sockets...";
1394 1394
 			    
1395
-			    foreach ($sockets as $sock) {
1395
+				foreach ($sockets as $sock) {
1396 1396
 				@socket_shutdown($sock,2);
1397 1397
 				@socket_close($sock);
1398
-			    }
1398
+				}
1399 1399
 			    
1400 1400
 			}
1401 1401
 			if ($globalDebug) echo "Waiting...";
@@ -1410,13 +1410,13 @@  discard block
 block discarded – undo
1410 1410
 			if ($globalDebug) echo "Restart all connections...";
1411 1411
 			connect_all($globalSources);
1412 1412
 		}
1413
-	    }
1413
+		}
1414 1414
 	}
1415 1415
 	if ($globalDaemon === false) {
1416
-	    if ($globalDebug) echo 'Check all...'."\n";
1417
-	    $SI->checkAll();
1416
+		if ($globalDebug) echo 'Check all...'."\n";
1417
+		$SI->checkAll();
1418
+	}
1418 1419
 	}
1419
-    }
1420 1420
 }
1421 1421
 
1422 1422
 ?>
Please login to merge, or discard this patch.
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 	    die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
48
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
49 49
     }
50 50
 }
51 51
 
52
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
52
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56 56
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
57
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
58 58
     else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60 60
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
61
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
62 62
     else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77 77
     if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
78
+    $SI = new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
82 82
     $SI->connect();
83 83
 */
84
-} else $SI=new SpotterImport($Connection->db);
84
+} else $SI = new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87 87
     $AIS = new AIS();
88 88
     $MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91
-$SBS=new SBS();
92
-$ACARS=new ACARS($Connection->db);
93
-$Common=new Common();
91
+$SBS = new SBS();
92
+$ACARS = new ACARS($Connection->db);
93
+$Common = new Common();
94 94
 date_default_timezone_set('UTC');
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
98
+    pcntl_signal(SIGINT, function() {
99 99
         global $sockets;
100 100
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101 101
         die("Bye!\n");
@@ -111,35 +111,35 @@  discard block
 block discarded – undo
111 111
 
112 112
 function connect_all($hosts) {
113 113
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
114
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
115 115
     $reset++;
116 116
     if ($globalDebug) echo 'Connect to all...'."\n";
117 117
     foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
121
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
+            if (preg_match('/deltadb.txt$/i', $host)) {
123 123
         	//$formats[$id] = 'deltadbtxt';
124 124
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 125
         	//$last_exec['deltadbtxt'] = 0;
126 126
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
127
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
128 128
         	//$formats[$id] = 'vatsimtxt';
129 129
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 130
         	//$last_exec['vatsimtxt'] = 0;
131 131
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
132
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
133 133
         	//$formats[$id] = 'aircraftlistjson';
134 134
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 135
         	//$last_exec['aircraftlistjson'] = 0;
136 136
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
137
+    	    } else if (preg_match('/opensky/i', $host)) {
138 138
         	//$formats[$id] = 'aircraftlistjson';
139 139
         	$globalSources[$id]['format'] = 'opensky';
140 140
         	//$last_exec['aircraftlistjson'] = 0;
141 141
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
142
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
143 143
         	//$formats[$id] = 'radarvirtueljson';
144 144
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 145
         	//$last_exec['radarvirtueljson'] = 0;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 149
         	    exit(0);
150 150
         	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
151
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
152 152
         	//$formats[$id] = 'planeupdatefaa';
153 153
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 154
         	//$last_exec['planeupdatefaa'] = 0;
@@ -157,26 +157,26 @@  discard block
 block discarded – undo
157 157
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 158
         	    exit(0);
159 159
         	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
160
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
161 161
         	//$formats[$id] = 'phpvmacars';
162 162
         	$globalSources[$id]['format'] = 'phpvmacars';
163 163
         	//$last_exec['phpvmacars'] = 0;
164 164
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
165
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'vam';
168 168
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
169
+            } else if (preg_match('/whazzup/i', $host)) {
170 170
         	//$formats[$id] = 'whazzup';
171 171
         	$globalSources[$id]['format'] = 'whazzup';
172 172
         	//$last_exec['whazzup'] = 0;
173 173
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
174
+            } else if (preg_match('/recentpireps/i', $host)) {
175 175
         	//$formats[$id] = 'pirepsjson';
176 176
         	$globalSources[$id]['format'] = 'pirepsjson';
177 177
         	//$last_exec['pirepsjson'] = 0;
178 178
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
179
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
180 180
         	//$formats[$id] = 'fr24json';
181 181
         	$globalSources[$id]['format'] = 'fr24json';
182 182
         	//$last_exec['fr24json'] = 0;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186 186
         	    exit(0);
187 187
         	}
188
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
188
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
189 189
         	//$formats[$id] = 'fr24json';
190 190
         	$globalSources[$id]['format'] = 'myshiptracking';
191 191
         	//$last_exec['fr24json'] = 0;
@@ -195,22 +195,22 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
             //} else if (preg_match('/10001/',$host)) {
198
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
198
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199 199
         	//$formats[$id] = 'tsv';
200 200
         	$globalSources[$id]['format'] = 'tsv';
201 201
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202 202
             }
203
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
203
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
204 204
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
205
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
206 206
     		    if ($idf !== false) {
207 207
     			$httpfeeds[$id] = $idf;
208 208
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209 209
     		    }
210 210
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211 211
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
-	    $hostport = explode(':',$host);
212
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
213
+	    $hostport = explode(':', $host);
214 214
 	    if (isset($hostport[1])) {
215 215
 		$port = $hostport[1];
216 216
 		$hostn = $hostport[0];
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
 	    }
221 221
 	    $Common = new Common();
222 222
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
223
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
224 224
     	    } else {
225
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
225
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
226 226
 	    }
227 227
 	    if ($s) {
228 228
     	        $sockets[$id] = $s;
229 229
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
230
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
231 231
 			//$formats[$id] = 'aprs';
232 232
 			$globalSources[$id]['format'] = 'aprs';
233 233
 			//$aprs_connect = 0;
234 234
 			//$use_aprs = true;
235
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
235
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
236 236
 			$globalSources[$id]['format'] = 'vrstcp';
237 237
     		    } elseif ($port == '10001') {
238 238
         		//$formats[$id] = 'tsv';
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272 272
 else $timeout = 20;
273 273
 $errno = '';
274
-$errstr='';
274
+$errstr = '';
275 275
 
276 276
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
277 277
 /* Initiate connections to all the hosts simultaneously */
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 //connect_all($globalSources);
280 280
 
281 281
 if (isset($globalProxy) && $globalProxy) {
282
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
282
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
283 283
 } else {
284 284
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
285 285
 }
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 
307 307
 if ($use_aprs) {
308 308
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
309
-	$APRS=new APRS();
309
+	$APRS = new APRS();
310 310
 	$aprs_connect = 0;
311 311
 	$aprs_keep = 120;
312 312
 	$aprs_last_tx = time();
313 313
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
314
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
315 315
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
316
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
317 317
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
318
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319 319
 	if ($aprs_full) $aprs_filter = '';
320 320
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
321 321
 	else $aprs_pass = '-1';
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 sleep(1);
330 330
 if ($globalDebug) echo "SCAN MODE \n\n";
331 331
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
332
-$endtime = time()+$globalCronEnd;
332
+$endtime = time() + $globalCronEnd;
333 333
 $i = 1;
334 334
 $tt = array();
335 335
 // Delete all ATC
336 336
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
337
-	$ATC=new ATC($Connection->db);
337
+	$ATC = new ATC($Connection->db);
338 338
 }
339 339
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
340 340
 	$ATC->deleteAll();
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 344
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
345
+    if (!$globalDaemon) $i = $endtime - time();
346 346
     // Delete old ATC
347 347
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	}
358 358
 	if ($max != $globalMinFetch) {
359 359
 	    if ($globalDebug) echo 'Sleeping...'."\n";
360
-	    sleep($globalMinFetch-$max+2);
360
+	    sleep($globalMinFetch - $max + 2);
361 361
 	}
362 362
     }
363 363
 
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	    //$buffer = $Common->getData($hosts[$id]);
371 371
 	    $buffer = $Common->getData($value['host']);
372 372
 	    if ($buffer != '') $reset = 0;
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
373
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
374
+	    $buffer = explode('\n', $buffer);
375 375
 	    foreach ($buffer as $line) {
376 376
     		if ($line != '' && count($line) > 7) {
377 377
     		    $line = explode(',', $line);
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     	    $last_exec[$id]['last'] = time();
400 400
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
401 401
 	    date_default_timezone_set('CET');
402
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
402
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
403 403
 	    date_default_timezone_set('UTC');
404 404
 	    if ($buffer != '') $reset = 0;
405
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
-	    $buffer = explode('\n',$buffer);
405
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
406
+	    $buffer = explode('\n', $buffer);
407 407
 	    foreach ($buffer as $line) {
408 408
 		if ($line != '') {
409 409
 		    echo "'".$line."'\n";
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422 422
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423 423
 		    if (isset($ais_data['timestamp'])) {
424
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
424
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
425 425
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
426 426
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427 427
 			    $add = true;
@@ -444,12 +444,12 @@  discard block
 block discarded – undo
444 444
 	    $w = $e = null;
445 445
 	    
446 446
 	    if (isset($arr[$id])) {
447
-		$nn = stream_select($arr,$w,$e,$timeout);
447
+		$nn = stream_select($arr, $w, $e, $timeout);
448 448
 		if ($nn > 0) {
449 449
 		    foreach ($httpfeeds as $feed) {
450
-			$buffer = stream_get_line($feed,2000,"\n");
451
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
452
-			$buffer = explode('\n',$buffer);
450
+			$buffer = stream_get_line($feed, 2000, "\n");
451
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
452
+			$buffer = explode('\n', $buffer);
453 453
 			foreach ($buffer as $line) {
454 454
 			    if ($line != '') {
455 455
 				$ais_data = $AIS->parse_line(trim($line));
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
468 468
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
469 469
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
470
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
470
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
471 471
 				if (isset($ais_data['timestamp'])) {
472
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
472
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
473 473
 				} else {
474 474
 				    $data['datetime'] = date('Y-m-d H:i:s');
475 475
 				}
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
 		}
496 496
 	    }
497 497
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
498
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
498
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
499 499
 	    if ($buffer != '') {
500 500
 		//echo $buffer;
501
-		$all_data = json_decode($buffer,true);
501
+		$all_data = json_decode($buffer, true);
502 502
 		//print_r($all_data);
503 503
 		if (isset($all_data[0]['DATA'])) {
504 504
 		foreach ($all_data[0]['DATA'] as $line) {
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 			//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
514 514
 			$data['imo'] = $line['IMO'];
515 515
 			//$data['arrival_code'] = $ais_data['destination'];
516
-			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
516
+			$data['datetime'] = date('Y-m-d H:i:s', $line['T']);
517 517
 			$data['format_source'] = 'myshiptracking';
518 518
 			$data['id_source'] = $id_source;
519 519
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 	    }
527 527
     	    $last_exec[$id]['last'] = time();
528 528
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
529
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
529
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
530 530
 	    if ($buffer != '') {
531
-		$all_data = json_decode($buffer,true);
531
+		$all_data = json_decode($buffer, true);
532 532
 		if (isset($all_data[0]['mmsi'])) {
533 533
 		    foreach ($all_data as $line) {
534 534
 			if ($line != '') {
@@ -556,27 +556,27 @@  discard block
 block discarded – undo
556 556
     	    $last_exec[$id]['last'] = time();
557 557
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
558 558
 	    echo 'download...';
559
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
559
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
560 560
 	    echo 'done !'."\n";
561 561
 	    if ($buffer != '') $reset = 0;
562
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
563
-	    $buffer = explode('\n',$buffer);
562
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
563
+	    $buffer = explode('\n', $buffer);
564 564
 	    foreach ($buffer as $line) {
565 565
 		if ($line != '') {
566 566
 		    $data = array();
567
-		    $data['mmsi'] = (int)substr($line,0,9);
568
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
567
+		    $data['mmsi'] = (int) substr($line, 0, 9);
568
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
569 569
 		    //$data['status'] = substr($line,21,2);
570 570
 		    //$data['type'] = substr($line,24,3);
571
-		    $data['latitude'] = substr($line,29,9);
572
-		    $data['longitude'] = substr($line,41,9);
573
-		    $data['speed'] = round(substr($line,51,5));
571
+		    $data['latitude'] = substr($line, 29, 9);
572
+		    $data['longitude'] = substr($line, 41, 9);
573
+		    $data['speed'] = round(substr($line, 51, 5));
574 574
 		    //$data['course'] = substr($line,57,5);
575
-		    $data['heading'] = round(substr($line,63,3));
575
+		    $data['heading'] = round(substr($line, 63, 3));
576 576
 		    //$data['draft'] = substr($line,67,4);
577 577
 		    //$data['length'] = substr($line,72,3);
578 578
 		    //$data['beam'] = substr($line,76,2);
579
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
579
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
580 580
 		    //$data['callsign'] = trim(substr($line,100,7);
581 581
 		    //$data['dest'] = substr($line,108,20);
582 582
 		    //$data['etaDate'] = substr($line,129,5);
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
596 596
 	    //$buffer = $Common->getData($hosts[$id]);
597 597
 	    $buffer = $Common->getData($value['host']);
598
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
599
-	    $buffer = explode('\n',$buffer);
598
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
599
+	    $buffer = explode('\n', $buffer);
600 600
 	    $reset = 0;
601 601
 	    foreach ($buffer as $line) {
602 602
     		if ($line != '') {
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
608 608
 			$data['pilot_id'] = $line[1];
609 609
 			$data['pilot_name'] = $line[2];
610
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
610
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
611 611
 			$data['ident'] = $line[0]; // ident
612 612
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
613 613
 			$data['speed'] = $line[8]; // speed
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
624 624
 			//if (isset($line[37])) $data['last_update'] = $line[37];
625 625
 		        $data['departure_airport_icao'] = $line[11];
626
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
626
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
627 627
 		        $data['arrival_airport_icao'] = $line[13];
628 628
 			$data['frequency'] = $line[4];
629 629
 			$data['type'] = $line[18];
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
     			$data['id_source'] = $id_source;
633 633
 	    		//$data['arrival_airport_time'] = ;
634 634
 	    		if ($line[9] != '') {
635
-	    		    $aircraft_data = explode('/',$line[9]);
635
+	    		    $aircraft_data = explode('/', $line[9]);
636 636
 	    		    if (isset($aircraft_data[1])) {
637 637
 	    			$data['aircraft_icao'] = $aircraft_data[1];
638 638
 	    		    }
@@ -647,9 +647,9 @@  discard block
 block discarded – undo
647 647
     			if ($line[3] == 'PILOT') $SI->add($data);
648 648
 			elseif ($line[3] == 'ATC') {
649 649
 				//print_r($data);
650
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
651
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
652
-				$typec = substr($data['ident'],-3);
650
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
651
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
652
+				$typec = substr($data['ident'], -3);
653 653
 				if ($typec == 'APP') $data['type'] = 'Approach';
654 654
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
655 655
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
661 661
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
662 662
 				if (!isset($data['source_name'])) $data['source_name'] = '';
663
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
663
+				if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
664 664
 			}
665 665
     			unset($data);
666 666
     		    }
@@ -671,9 +671,9 @@  discard block
 block discarded – undo
671 671
     	    $last_exec[$id]['last'] = time();
672 672
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
673 673
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
674
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
674
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
675 675
 	    if ($buffer != '') {
676
-	    $all_data = json_decode($buffer,true);
676
+	    $all_data = json_decode($buffer, true);
677 677
 	    if (isset($all_data['acList'])) {
678 678
 		$reset = 0;
679 679
 		foreach ($all_data['acList'] as $line) {
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 		    $data['emergency'] = ''; // emergency
691 691
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
692 692
 		    
693
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
693
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
694 694
 		    else $data['datetime'] = date('Y-m-d H:i:s');
695 695
 		    
696 696
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
717 717
 		    $data['squawk'] = $line['squawk']; // squawk
718 718
 		    $data['emergency'] = ''; // emergency
719
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
719
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
720 720
 		    else $data['datetime'] = date('Y-m-d H:i:s');
721 721
 	    	    $data['format_source'] = 'aircraftlistjson';
722 722
     		    $data['id_source'] = $id_source;
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
733 733
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
734 734
 	    $buffer = $Common->getData($value['host']);
735
-	    $all_data = json_decode($buffer,true);
735
+	    $all_data = json_decode($buffer, true);
736 736
 	    if (isset($all_data['planes'])) {
737 737
 		$reset = 0;
738 738
 		foreach ($all_data['planes'] as $key => $line) {
@@ -749,12 +749,12 @@  discard block
 block discarded – undo
749 749
 		    $data['emergency'] = ''; // emergency
750 750
 		    $data['registration'] = $line[2];
751 751
 		    $data['aircraft_icao'] = $line[0];
752
-		    $deparr = explode('-',$line[1]);
752
+		    $deparr = explode('-', $line[1]);
753 753
 		    if (count($deparr) == 2) {
754 754
 			$data['departure_airport_icao'] = $deparr[0];
755 755
 			$data['arrival_airport_icao'] = $deparr[1];
756 756
 		    }
757
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
757
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
758 758
 	    	    $data['format_source'] = 'planeupdatefaa';
759 759
     		    $data['id_source'] = $id_source;
760 760
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
     	    $last_exec[$id]['last'] = time();
768 768
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
769 769
 	    $buffer = $Common->getData($value['host']);
770
-	    $all_data = json_decode($buffer,true);
770
+	    $all_data = json_decode($buffer, true);
771 771
 	    if (isset($all_data['states'])) {
772 772
 		$reset = 0;
773 773
 		foreach ($all_data['states'] as $key => $line) {
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 		    //$data['emergency'] = ''; // emergency
785 785
 		    //$data['registration'] = $line[2];
786 786
 		    //$data['aircraft_icao'] = $line[0];
787
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
787
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
788 788
 	    	    $data['format_source'] = 'opensky';
789 789
     		    $data['id_source'] = $id_source;
790 790
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
799 799
 	    //$buffer = $Common->getData($hosts[$id]);
800 800
 	    $buffer = $Common->getData($value['host']);
801
-	    $all_data = json_decode($buffer,true);
801
+	    $all_data = json_decode($buffer, true);
802 802
 	    if (!empty($all_data)) $reset = 0;
803 803
 	    foreach ($all_data as $key => $line) {
804 804
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -831,11 +831,11 @@  discard block
 block discarded – undo
831 831
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
832 832
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
833 833
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
834
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
834
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
835 835
 	    //echo $buffer;
836
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
837
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
838
-	    $all_data = json_decode($buffer,true);
836
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
837
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
838
+	    $all_data = json_decode($buffer, true);
839 839
 	    if (json_last_error() != JSON_ERROR_NONE) {
840 840
 		die(json_last_error_msg());
841 841
 	    }
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 			//$data['departure_airport_iata'] = $line[11];
859 859
 			//$data['arrival_airport_iata'] = $line[12];
860 860
 	    		//$data['emergency'] = ''; // emergency
861
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
861
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
862 862
 	    		$data['format_source'] = 'radarvirtueljson';
863 863
     			$data['id_source'] = $id_source;
864 864
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
875 875
 	    //$buffer = $Common->getData($hosts[$id]);
876 876
 	    $buffer = $Common->getData($value['host'].'?'.time());
877
-	    $all_data = json_decode(utf8_encode($buffer),true);
877
+	    $all_data = json_decode(utf8_encode($buffer), true);
878 878
 	    
879 879
 	    if (isset($all_data['pireps'])) {
880 880
 		$reset = 0;
881 881
 	        foreach ($all_data['pireps'] as $line) {
882 882
 		    $data = array();
883 883
 		    $data['id'] = $line['id'];
884
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
884
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
885 885
 		    $data['ident'] = $line['callsign']; // ident
886 886
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
887 887
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -911,9 +911,9 @@  discard block
 block discarded – undo
911 911
 			$SI->add($data);
912 912
 		    //    print_r($data);
913 913
     		    } elseif ($line['icon'] == 'ct') {
914
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
915
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
916
-			$typec = substr($data['ident'],-3);
914
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
915
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
916
+			$typec = substr($data['ident'], -3);
917 917
 			$data['type'] = '';
918 918
 			if ($typec == 'APP') $data['type'] = 'Approach';
919 919
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
925 925
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
926 926
 			else $data['type'] = 'Observer';
927
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
927
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
928 928
 		    }
929 929
 		    unset($data);
930 930
 		}
@@ -936,14 +936,14 @@  discard block
 block discarded – undo
936 936
 	    //$buffer = $Common->getData($hosts[$id]);
937 937
 	    if ($globalDebug) echo 'Get Data...'."\n";
938 938
 	    $buffer = $Common->getData($value['host']);
939
-	    $all_data = json_decode($buffer,true);
939
+	    $all_data = json_decode($buffer, true);
940 940
 	    if ($buffer != '' && is_array($all_data)) {
941 941
 		$reset = 0;
942 942
 		foreach ($all_data as $line) {
943 943
 	    	    $data = array();
944 944
 	    	    //$data['id'] = $line['id']; // id not usable
945 945
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
946
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
946
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
947 947
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
948 948
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
949 949
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
968 968
 		    if (isset($line['aircraftname'])) {
969 969
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
970
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
971
-	    		$aircraft_data = explode('-',$line['aircraftname']);
970
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
971
+	    		$aircraft_data = explode('-', $line['aircraftname']);
972 972
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
973 973
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
974 974
 	    		else {
975
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
976
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
977
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
975
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
976
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
977
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
978 978
 	    		}
979 979
 	    	    }
980 980
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -994,14 +994,14 @@  discard block
 block discarded – undo
994 994
 	    //$buffer = $Common->getData($hosts[$id]);
995 995
 	    if ($globalDebug) echo 'Get Data...'."\n";
996 996
 	    $buffer = $Common->getData($value['host']);
997
-	    $all_data = json_decode($buffer,true);
997
+	    $all_data = json_decode($buffer, true);
998 998
 	    if ($buffer != '' && is_array($all_data)) {
999 999
 		$reset = 0;
1000 1000
 		foreach ($all_data as $line) {
1001 1001
 	    	    $data = array();
1002 1002
 	    	    //$data['id'] = $line['id']; // id not usable
1003 1003
 	    	    $data['id'] = trim($line['flight_id']);
1004
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1004
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1005 1005
 	    	    $data['pilot_name'] = $line['pilot_name'];
1006 1006
 	    	    $data['pilot_id'] = $line['pilot_id'];
1007 1007
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1053,11 +1053,11 @@  discard block
 block discarded – undo
1053 1053
 		    //$value = $formats[$nb];
1054 1054
 		    $format = $globalSources[$nb]['format'];
1055 1055
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1056
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1056
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1057 1057
 		    } elseif ($format == 'vrstcp') {
1058 1058
 			$buffer = @socket_read($r, 6000);
1059 1059
 		    } else {
1060
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1060
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1061 1061
 		    }
1062 1062
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1063 1063
 		    //echo $buffer."\n";
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
 		    $error = false;
1067 1067
 		    //$SI::del();
1068 1068
 		    if ($format == 'vrstcp') {
1069
-			$buffer = explode('},{',$buffer);
1070
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1069
+			$buffer = explode('},{', $buffer);
1070
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1071 1071
 		    // SBS format is CSV format
1072 1072
 		    if ($buffer !== FALSE && $buffer != '') {
1073 1073
 			$tt[$format] = 0;
@@ -1101,11 +1101,11 @@  discard block
 block discarded – undo
1101 1101
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1102 1102
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1103 1103
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1104
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1104
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1105 1105
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1106 1106
 
1107 1107
 			    if (isset($ais_data['timestamp'])) {
1108
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1108
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1109 1109
 			    } else {
1110 1110
 				$data['datetime'] = date('Y-m-d H:i:s');
1111 1111
 			    }
@@ -1116,10 +1116,10 @@  discard block
 block discarded – undo
1116 1116
                         } elseif ($format == 'flightgearsp') {
1117 1117
                     	    //echo $buffer."\n";
1118 1118
                     	    if (strlen($buffer) > 5) {
1119
-				$line = explode(',',$buffer);
1119
+				$line = explode(',', $buffer);
1120 1120
 				$data = array();
1121 1121
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1122
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1122
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1123 1123
 				$data['ident'] = $line[6];
1124 1124
 				$data['aircraft_name'] = $line[7];
1125 1125
 				$data['longitude'] = $line[1];
@@ -1131,21 +1131,21 @@  discard block
 block discarded – undo
1131 1131
 				$data['format_source'] = 'flightgearsp';
1132 1132
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1133 1133
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1134
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1134
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1135 1135
 			    }
1136 1136
                         } elseif ($format == 'acars') {
1137 1137
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1138 1138
 			    $ACARS->add(trim($buffer));
1139
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1139
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1140 1140
 			    $ACARS->deleteLiveAcarsData();
1141 1141
 			} elseif ($format == 'flightgearmp') {
1142
-			    if (substr($buffer,0,1) != '#') {
1142
+			    if (substr($buffer, 0, 1) != '#') {
1143 1143
 				$data = array();
1144 1144
 				//echo $buffer."\n";
1145
-				$line = explode(' ',$buffer);
1145
+				$line = explode(' ', $buffer);
1146 1146
 				if (count($line) == 11) {
1147
-				    $userserver = explode('@',$line[0]);
1148
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1147
+				    $userserver = explode('@', $line[0]);
1148
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1149 1149
 				    $data['ident'] = $userserver[0];
1150 1150
 				    $data['registration'] = $userserver[0];
1151 1151
 				    $data['latitude'] = $line[4];
@@ -1153,8 +1153,8 @@  discard block
 block discarded – undo
1153 1153
 				    $data['altitude'] = $line[6];
1154 1154
 				    $data['datetime'] = date('Y-m-d H:i:s');
1155 1155
 				    $aircraft_type = $line[10];
1156
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1157
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1156
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1157
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1158 1158
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1159 1159
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1160 1160
 				}
@@ -1163,8 +1163,8 @@  discard block
 block discarded – undo
1163 1163
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1164 1164
 			    die;
1165 1165
 			} elseif ($format == 'vrstcp') {
1166
-			    foreach($buffer as $all_data) {
1167
-				$line = json_decode('{'.$all_data.'}',true);
1166
+			    foreach ($buffer as $all_data) {
1167
+				$line = json_decode('{'.$all_data.'}', true);
1168 1168
 				$data = array();
1169 1169
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1170 1170
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1190,16 +1190,16 @@  discard block
 block discarded – undo
1190 1190
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1191 1191
 				unset($data);
1192 1192
 			    }
1193
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1193
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1194 1194
 			    $line = explode("\t", $buffer);
1195
-			    for($k = 0; $k < count($line); $k=$k+2) {
1195
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1196 1196
 				$key = $line[$k];
1197
-			        $lined[$key] = $line[$k+1];
1197
+			        $lined[$key] = $line[$k + 1];
1198 1198
 			    }
1199 1199
     			    if (count($lined) > 3) {
1200 1200
     				$data['hex'] = $lined['hexid'];
1201 1201
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1202
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1202
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1203 1203
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1204 1204
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1205 1205
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1218,22 +1218,22 @@  discard block
 block discarded – undo
1218 1218
     			    } else $error = true;
1219 1219
 			} elseif ($format == 'aprs' && $use_aprs) {
1220 1220
 			    if ($aprs_connect == 0) {
1221
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1221
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1222 1222
 				$aprs_connect = 1;
1223 1223
 			    }
1224 1224
 			    
1225
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1225
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1226 1226
 				$aprs_last_tx = time();
1227 1227
 				$data_aprs = "# Keep alive";
1228
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1228
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1229 1229
 			    }
1230 1230
 			    
1231 1231
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1232 1232
 			    //echo 'APRS data : '.$buffer."\n";
1233
-			    $buffer = str_replace('APRS <- ','',$buffer);
1234
-			    $buffer = str_replace('APRS -> ','',$buffer);
1233
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1234
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1235 1235
 			    //echo $buffer."\n";
1236
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1236
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1237 1237
 				$line = $APRS->parse($buffer);
1238 1238
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1239 1239
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1249 1249
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1250 1250
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1251
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1251
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1252 1252
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1253 1253
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1254 1254
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 				connect_all($sourceee);
1378 1378
 				$sourceee = array();
1379 1379
 				//connect_all($globalSources);
1380
-				$tt[$format]=0;
1380
+				$tt[$format] = 0;
1381 1381
 				break;
1382 1382
 			    }
1383 1383
 			}
@@ -1386,14 +1386,14 @@  discard block
 block discarded – undo
1386 1386
 	    } else {
1387 1387
 		$error = socket_strerror(socket_last_error());
1388 1388
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1389
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1389
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1390 1390
 			if (isset($globalDebug)) echo "Restarting...\n";
1391 1391
 			// Restart the script if possible
1392 1392
 			if (is_array($sockets)) {
1393 1393
 			    if ($globalDebug) echo "Shutdown all sockets...";
1394 1394
 			    
1395 1395
 			    foreach ($sockets as $sock) {
1396
-				@socket_shutdown($sock,2);
1396
+				@socket_shutdown($sock, 2);
1397 1397
 				@socket_close($sock);
1398 1398
 			    }
1399 1399
 			    
Please login to merge, or discard this patch.
pilot-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 //require_once('require/class.SpotterLive.php');
8 8
 require_once('require/class.SpotterArchive.php');
9 9
 
10
-if (!isset($_GET['pilot'])){
10
+if (!isset($_GET['pilot'])) {
11 11
 	header('Location: '.$globalURL.'/');
12 12
 } else {
13 13
 	$Spotter = new Spotter();
14 14
 	$SpotterArchive = new SpotterArchive();
15 15
 	$Translation = new Translation();
16 16
 	//calculuation for the pagination
17
-	if(!isset($_GET['limit']))
17
+	if (!isset($_GET['limit']))
18 18
 	{
19 19
 		$limit_start = 0;
20 20
 		$limit_end = 25;
@@ -35,29 +35,29 @@  discard block
 block discarded – undo
35 35
 	
36 36
 	$page_url = $globalURL.'/pilot/'.$_GET['pilot'];
37 37
 	
38
-	$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
39
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
40
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
38
+	$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING);
39
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
40
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
41
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
44
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
45 45
 	if ($sort != '') 
46 46
 	{
47
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
47
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
48 48
 		if (empty($spotter_array)) {
49
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
49
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
50 50
 		}
51 51
 	} else {
52
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
52
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
53 53
 		if (empty($spotter_array)) {
54
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
54
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
55 55
 		}
56 56
 	}
57 57
 
58 58
 	if (!empty($spotter_array))
59 59
 	{
60
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
60
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['pilot_name']);
61 61
 		$ident = $spotter_array[0]['ident'];
62 62
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63 63
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -118,23 +118,23 @@  discard block
 block discarded – undo
118 118
 			$Stats = new Stats();
119 119
 			$flights = $Stats->getStatsPilot($pilot);
120 120
 		} else $flights = 0;
121
-		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
121
+		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot, $filter);
122 122
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
123
-		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
123
+		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot, $filter));
124 124
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
125
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot,$filter));
125
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot, $filter));
126 126
 		print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>';
127
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot,$filter));
127
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot, $filter));
128 128
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
129
-		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
129
+		$airlines = count($Spotter->countAllAirlinesByPilot($pilot, $filter));
130 130
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
131
-		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
131
+		$duration = $Spotter->getFlightDurationByPilot($pilot, $filter);
132 132
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
133 133
 		print '</div>';
134 134
 	
135 135
 		include('owner-sub-menu.php');
136 136
 		print '<div class="table column">';
137
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
137
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>';
138 138
 
139 139
 		include('table-output.php'); 
140 140
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41 41
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') {
44
+		$filter = array_merge($filter,array('year' => $year));
45
+	}
46
+	if ($month != '') {
47
+		$filter = array_merge($filter,array('month' => $month));
48
+	}
45 49
 	if ($sort != '') 
46 50
 	{
47 51
 		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -59,8 +63,12 @@  discard block
 block discarded – undo
59 63
 	{
60 64
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
61 65
 		$ident = $spotter_array[0]['ident'];
62
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
66
+		if (isset($spotter_array[0]['latitude'])) {
67
+			$latitude = $spotter_array[0]['latitude'];
68
+		}
69
+		if (isset($spotter_array[0]['longitude'])) {
70
+			$longitude = $spotter_array[0]['longitude'];
71
+		}
64 72
 		require_once('header.php');
65 73
 		/*
66 74
 		if (isset($globalArchive) && $globalArchive) {
@@ -113,12 +121,18 @@  discard block
 block discarded – undo
113 121
 		*/
114 122
 		print '<div class="info column">';
115 123
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
116
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
124
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
125
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
126
+		}
117 127
 		if ($year == '' && $month == '') {
118 128
 			$Stats = new Stats();
119 129
 			$flights = $Stats->getStatsPilot($pilot);
120
-		} else $flights = 0;
121
-		if ($flights == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
130
+		} else {
131
+			$flights = 0;
132
+		}
133
+		if ($flights == 0) {
134
+			$flights = $Spotter->countFlightsByPilot($pilot,$filter);
135
+		}
122 136
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
123 137
 		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
124 138
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
@@ -129,7 +143,9 @@  discard block
 block discarded – undo
129 143
 		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
130 144
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
131 145
 		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
132
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
146
+		if ($duration != '0') {
147
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
148
+		}
133 149
 		print '</div>';
134 150
 	
135 151
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.