Completed
Push — master ( f1954e...8053db )
by Yannick
07:25
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
 				if (isset($spotter_item['airline_name'])) {
519 519
 					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>';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 				print '</td>'."\n";
528 528
 			}
529 529
 		}
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"){
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 533
 			    $spotter_item['squawk'] = '-';
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
545 545
 					}
546 546
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
547
-						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>';
547
+						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>';
548 548
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
549
-						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>';
549
+						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>';
550 550
 					} elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) {
551
-						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>';
551
+						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>';
552 552
 					} else {
553
-						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>';
553
+						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>';
554 554
 					}
555 555
 				} else {
556 556
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
557
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
557
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
558 558
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
559 559
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
560 560
 						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>';
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 			{
588 588
 				print '<td class="aircraft_thumbnail">'."\n";
589 589
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
590
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
590
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
591 591
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
592 592
 				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>';
593 593
 				print '</td>'."\n";
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			{
602 602
 				print '<td class="aircraft_thumbnail">'."\n";
603 603
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
604
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
604
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
605 605
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
606 606
 				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>';
607 607
 				print '</td>'."\n";
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	}
673 673
 	print '</td>'."\n";
674 674
 	// Aircraft type
675
-	if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){
675
+	if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") {
676 676
 		print '<td class="type">'."\n";
677 677
 		if ($type == 'aircraft') {
678 678
 			if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) {
@@ -722,22 +722,22 @@  discard block
 block discarded – undo
722 722
 			}
723 723
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
724 724
 				if ($spotter_item['departure_airport_time'] > 2460) {
725
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
726
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
725
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
726
+				} else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
727 727
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
728
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
728
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
729 729
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
730 730
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
731 731
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
732 732
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
733
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
733
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
734 734
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
735 735
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
736 736
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
737 737
 				if ($spotter_item['departure_airport_time'] > 2460) {
738
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
738
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
739 739
 				} else {
740
-					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
740
+					$departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
741 741
 				}
742 742
 				print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n";
743 743
 			}
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 						$latitude = $spotter_item['latitude'];
753 753
 						$longitude = $spotter_item['longitude'];
754 754
 					}
755
-					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
755
+					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude);
756 756
 				} else $distance = '';
757 757
 				if ($distance != '') {
758 758
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -795,20 +795,20 @@  discard block
 block discarded – undo
795 795
 			}
796 796
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
797 797
 				if ($spotter_item['arrival_airport_time'] > 2460) {
798
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
798
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
799 799
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
800 800
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
801
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
801
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
802 802
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
803 803
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
804 804
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
805 805
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
806
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
806
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
807 807
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
808 808
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
809 809
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
810 810
 				if ($spotter_item['arrival_airport_time'] > 2460) {
811
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
811
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
812 812
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
813 813
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
814 814
 			}
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 						$latitude = $spotter_item['latitude'];
822 822
 						$longitude = $spotter_item['longitude'];
823 823
 					}
824
-					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
824
+					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude);
825 825
 				} else $distance = '';
826 826
 				if ($distance != '') {
827 827
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -864,19 +864,19 @@  discard block
 block discarded – undo
864 864
 				print '<span class="mobile">-</span>'."\n";
865 865
 			} else {
866 866
 				if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
867
-					print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
868
-					print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
867
+					print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
868
+					print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
869 869
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
870
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
871
-					print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
870
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
871
+					print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
872 872
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
873
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
874
-					print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
873
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
874
+					print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
875 875
 				}
876 876
 			}
877 877
 			print '</td>'."\n";
878 878
 		}
879
-		if(strtolower($current_page) != "upcoming"){
879
+		if (strtolower($current_page) != "upcoming") {
880 880
 			if ($type == 'aircraft') {
881 881
 				if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
882 882
 					print '<td class="pilot">'."\n";
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 		
913 913
 		if ($showRouteStop) {
914 914
 		// Route stop
915
-			if(strtolower($current_page) != "upcoming"){
915
+			if (strtolower($current_page) != "upcoming") {
916 916
 				print '<td class="route_stop">'."\n";
917 917
 				if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') {
918 918
 					print '<span class="nomobile">-</span>'."\n";
@@ -931,11 +931,11 @@  discard block
 block discarded – undo
931 931
 		}
932 932
 		if ($showDuration) {
933 933
 		// Duration
934
-			if(strtolower($current_page) != "upcoming"){
934
+			if (strtolower($current_page) != "upcoming") {
935 935
 				print '<td class="duration">'."\n";
936 936
 				if (isset($spotter_item['duration'])) {
937
-					print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
938
-					print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
937
+					print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
938
+					print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
939 939
 				} else {
940 940
 					print '<span class="nomobile">-</span>'."\n";
941 941
 					print '<span class="mobile">-</span>'."\n";
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
949 949
 		if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') {
950 950
 			print '<td class="message"><p>'."\n";
951
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
951
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
952 952
 			print '</p><p class="decode">';
953 953
 			$decode_array = json_decode($spotter_item['decode']);
954 954
 			foreach ($decode_array as $key => $value) {
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			print '</td>'."\n";
959 959
 		} else {
960 960
 			print '<td class="message">'."\n";
961
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
961
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
962 962
 			print '</td>'."\n";
963 963
 		}
964 964
 	}
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 		}
984 984
 		print '</td>'."\n";
985 985
 		print '<td class="message">'."\n";
986
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
986
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
987 987
 		print '</td>'."\n";
988 988
 	}
989 989
 	if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") {
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 		print '</td>'."\n";
1010 1010
 		*/
1011 1011
 		print '<td class="message">'."\n";
1012
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1012
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1013 1013
 		print '</td>'."\n";
1014 1014
 	}
1015 1015
 
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
 				if (isset($spotter_item['airline_name'])) {
519 532
 					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>';
520 533
 				} else {
@@ -537,8 +550,9 @@  discard block
 block discarded – undo
537 550
 				print '<td class="aircraft_thumbnail">'."\n";
538 551
 				//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>';
539 552
 				if ($spotter_item['image_source'] == 'planespotters') {
540
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
541
-					else {
553
+					if ($spotter_item['image_source_website'] != '') {
554
+						$image_src = $spotter_item['image_source_website'];
555
+					} else {
542 556
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
543 557
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
544 558
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -555,7 +569,9 @@  discard block
 block discarded – undo
555 569
 				} else {
556 570
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
557 571
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
558
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
572
+					} else {
573
+						$image_thumbnail = $spotter_item['image_thumbnail'];
574
+					}
559 575
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
560 576
 						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>';
561 577
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -588,7 +604,9 @@  discard block
 block discarded – undo
588 604
 				print '<td class="aircraft_thumbnail">'."\n";
589 605
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
590 606
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
591
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
607
+				} else {
608
+					$image_thumbnail = $spotter_item['image_thumbnail'];
609
+				}
592 610
 				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>';
593 611
 				print '</td>'."\n";
594 612
 			} else {
@@ -602,7 +620,9 @@  discard block
 block discarded – undo
602 620
 				print '<td class="aircraft_thumbnail">'."\n";
603 621
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
604 622
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
605
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
623
+				} else {
624
+					$image_thumbnail = $spotter_item['image_thumbnail'];
625
+				}
606 626
 				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>';
607 627
 				print '</td>'."\n";
608 628
 			} else {
@@ -723,15 +743,21 @@  discard block
 block discarded – undo
723 743
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
724 744
 				if ($spotter_item['departure_airport_time'] > 2460) {
725 745
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
726
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
746
+				} else {
747
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
748
+				}
727 749
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
728 750
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
729
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
751
+				} else {
752
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
753
+				}
730 754
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
731 755
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
732 756
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
733 757
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
734
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
758
+				} else {
759
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
760
+				}
735 761
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
736 762
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
737 763
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -753,7 +779,9 @@  discard block
 block discarded – undo
753 779
 						$longitude = $spotter_item['longitude'];
754 780
 					}
755 781
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
756
-				} else $distance = '';
782
+				} else {
783
+					$distance = '';
784
+				}
757 785
 				if ($distance != '') {
758 786
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
759 787
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -780,7 +808,9 @@  discard block
 block discarded – undo
780 808
 			} else {
781 809
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
782 810
 					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";
783
-					if (!isset($Spotter)) $Spotter = new Spotter();
811
+					if (!isset($Spotter)) {
812
+						$Spotter = new Spotter();
813
+					}
784 814
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
785 815
 					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";
786 816
 					print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -796,20 +826,28 @@  discard block
 block discarded – undo
796 826
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
797 827
 				if ($spotter_item['arrival_airport_time'] > 2460) {
798 828
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
799
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
829
+				} else {
830
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
831
+				}
800 832
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
801 833
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
802
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
834
+				} else {
835
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
836
+				}
803 837
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
804 838
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
805 839
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
806 840
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
807
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
841
+				} else {
842
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
843
+				}
808 844
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
809 845
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
810 846
 				if ($spotter_item['arrival_airport_time'] > 2460) {
811 847
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
812
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
848
+				} else {
849
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
850
+				}
813 851
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
814 852
 			}
815 853
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -822,7 +860,9 @@  discard block
 block discarded – undo
822 860
 						$longitude = $spotter_item['longitude'];
823 861
 					}
824 862
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
825
-				} else $distance = '';
863
+				} else {
864
+					$distance = '';
865
+				}
826 866
 				if ($distance != '') {
827 867
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
828 868
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
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
 if ($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   +9 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,14 @@  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
-if ($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
+}
53
+if ($type == 'tracker') {
54
+	print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
55
+} else {
56
+	print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
57
+}
53 58
 
54 59
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
55 60
 $sql_begin = microtime(true);
Please login to merge, or discard this patch.
ident-detailed.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Language.php');
4 4
 require_once('require/class.Translation.php');
5 5
 $type = '';
6
-$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
6
+$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
7 7
 if (isset($_GET['marine'])) {
8 8
 	require_once('require/class.Marine.php');
9 9
 	require_once('require/class.MarineLive.php');
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	$page_url = $globalURL.'/ident/'.$_GET['ident'];
31 31
 }
32 32
 
33
-if (!isset($_GET['ident'])){
33
+if (!isset($_GET['ident'])) {
34 34
 	header('Location: '.$globalURL.'');
35 35
 } else {
36 36
 	$Translation = new Translation();
37 37
 	//calculuation for the pagination
38
-	if(!isset($_GET['limit']))
38
+	if (!isset($_GET['limit']))
39 39
 	{
40 40
 		$limit_start = 0;
41 41
 		$limit_end = 25;
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
 	$limit_previous_1 = $limit_start - $absolute_difference;
55 55
 	$limit_previous_2 = $limit_end - $absolute_difference;
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 ($type == 'aircraft') {
59 59
 		if ($sort != '') 
60 60
 		{
61
-			$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
61
+			$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
62 62
 			if (empty($spotter_array)) {
63
-				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
63
+				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
64 64
 			}
65 65
 		} else {
66
-			$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
66
+			$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
67 67
 			if (empty($spotter_array)) {
68
-				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
68
+				$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
69 69
 			}
70 70
 		}
71 71
 		if (empty($spotter_array)) {
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 				$ident = $new_ident;
75 75
 				if ($sort != '') 
76 76
 				{
77
-					$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
77
+					$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
78 78
 					if (empty($spotter_array)) {
79
-						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
79
+						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
80 80
 					}
81 81
 				} else {
82
-					$spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
82
+					$spotter_array = $Spotter->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
83 83
 					if (empty($spotter_array)) {
84
-						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference);
84
+						$spotter_array = $SpotterArchive->getSpotterDataByIdent($ident, $limit_start.",".$absolute_difference);
85 85
 					}
86 86
 				}
87 87
 			}
@@ -89,34 +89,34 @@  discard block
 block discarded – undo
89 89
 	} elseif ($type == 'marine') {
90 90
 		if ($sort != '') 
91 91
 		{
92
-			$spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
92
+			$spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
93 93
 			if (empty($spotter_array)) {
94
-				$spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
94
+				$spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
95 95
 			}
96 96
 		} else {
97
-			$spotter_array = $Marine->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference);
97
+			$spotter_array = $Marine->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference);
98 98
 			if (empty($spotter_array)) {
99
-				$spotter_array = $MarineArchive->getMarineDataByIdent($ident,$limit_start.",".$absolute_difference);
99
+				$spotter_array = $MarineArchive->getMarineDataByIdent($ident, $limit_start.",".$absolute_difference);
100 100
 			}
101 101
 		}
102 102
 	} elseif ($type == 'tracker') {
103 103
 		if ($sort != '') 
104 104
 		{
105
-			$spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
105
+			$spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
106 106
 			if (empty($spotter_array)) {
107
-				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference, $sort);
107
+				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference, $sort);
108 108
 			}
109 109
 		} else {
110
-			$spotter_array = $Tracker->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference);
110
+			$spotter_array = $Tracker->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference);
111 111
 			if (empty($spotter_array)) {
112
-				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident,$limit_start.",".$absolute_difference);
112
+				$spotter_array = $TrackerArchive->getTrackerDataByIdent($ident, $limit_start.",".$absolute_difference);
113 113
 			}
114 114
 		}
115 115
 	}
116 116
 
117 117
 	if (!empty($spotter_array))
118 118
 	{
119
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']);
119
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['ident']);
120 120
 		$ident = $spotter_array[0]['ident'];
121 121
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
122 122
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
                         var data = google.visualization.arrayToDataTable([
138 138
                             ["Hour","'._("Altitude").'","'._("Speed").'"], ';
139 139
                             $altitude_data = '';
140
-				foreach($all_data as $data)
140
+				foreach ($all_data as $data)
141 141
 				{
142
-					$altitude_data .= '[ "'.date("G:i",strtotime($data['date']." UTC")).'",'.$data['altitude'].','.$data['ground_speed'].'],';
142
+					$altitude_data .= '[ "'.date("G:i", strtotime($data['date']." UTC")).'",'.$data['altitude'].','.$data['ground_speed'].'],';
143 143
 				}
144 144
 				$altitude_data = substr($altitude_data, 0, -1);
145 145
 				print $altitude_data.']);
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 	
180 180
 		if ($type == 'aircraft') include('ident-sub-menu.php');
181 181
 		print '<div class="table column">';
182
-		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
183
-		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
184
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
182
+		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
183
+		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
184
+		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
185 185
 
186 186
 		include('table-output.php'); 
187 187
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -118,8 +118,12 @@  discard block
 block discarded – undo
118 118
 	{
119 119
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']);
120 120
 		$ident = $spotter_array[0]['ident'];
121
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
122
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
121
+		if (isset($spotter_array[0]['latitude'])) {
122
+			$latitude = $spotter_array[0]['latitude'];
123
+		}
124
+		if (isset($spotter_array[0]['longitude'])) {
125
+			$longitude = $spotter_array[0]['longitude'];
126
+		}
123 127
 		require_once('header.php');
124 128
 		if (isset($globalArchive) && $globalArchive && $type == 'aircraft') {
125 129
 			// Requirement for altitude graph
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 			$all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']);
128 132
 			if (isset($globalTimezone)) {
129 133
 				date_default_timezone_set($globalTimezone);
130
-			} else date_default_timezone_set('UTC');
134
+			} else {
135
+				date_default_timezone_set('UTC');
136
+			}
131 137
 			if (count($all_data) > 0) {
132 138
 				print '<div id="chart6" class="chart" width="100%"></div>
133 139
                     <script> 
@@ -174,14 +180,22 @@  discard block
 block discarded – undo
174 180
 		if (isset($spotter_array[0]['airline_icao'])) {
175 181
 			print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; 
176 182
 		}
177
-		if ($type == 'aircraft') print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
183
+		if ($type == 'aircraft') {
184
+			print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
185
+		}
178 186
 		print '</div>';
179 187
 	
180
-		if ($type == 'aircraft') include('ident-sub-menu.php');
188
+		if ($type == 'aircraft') {
189
+			include('ident-sub-menu.php');
190
+		}
181 191
 		print '<div class="table column">';
182
-		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
183
-		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
184
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
192
+		if ($type == 'aircraft') {
193
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
194
+		} elseif ($type == 'marine') {
195
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
196
+		} elseif ($type == 'tracker') {
197
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
198
+		}
185 199
 
186 200
 		include('table-output.php'); 
187 201
 		print '<div class="pagination">';
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.
require/class.TrackerImport.php 3 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class TrackerImport {
12
-    private $all_tracked = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
12
+	private $all_tracked = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20 20
 
21
-    public function __construct($dbc = null) {
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -40,50 +40,50 @@  discard block
 block discarded – undo
40 40
 	    }
41 41
 	}
42 42
 	*/
43
-    }
43
+	}
44 44
 
45
-    public function checkAll() {
45
+	public function checkAll() {
46 46
 	global $globalDebug;
47 47
 	if ($globalDebug) echo "Update last seen tracked data...\n";
48 48
 	foreach ($this->all_tracked as $key => $flight) {
49
-	    if (isset($this->all_tracked[$key]['id'])) {
49
+		if (isset($this->all_tracked[$key]['id'])) {
50 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
51
-    		$Tracker = new Tracker($this->db);
52
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
53
-            }
51
+			$Tracker = new Tracker($this->db);
52
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
53
+			}
54
+	}
54 55
 	}
55
-    }
56 56
 
57
-    public function del() {
57
+	public function del() {
58 58
 	global $globalDebug;
59 59
 	// Delete old infos
60 60
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
61 61
 	foreach ($this->all_tracked as $key => $flight) {
62
-    	    if (isset($flight['lastupdate'])) {
63
-        	if ($flight['lastupdate'] < (time()-3000)) {
64
-            	    if (isset($this->all_tracked[$key]['id'])) {
65
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
62
+			if (isset($flight['lastupdate'])) {
63
+			if ($flight['lastupdate'] < (time()-3000)) {
64
+					if (isset($this->all_tracked[$key]['id'])) {
65
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
66 66
 			/*
67 67
 			$TrackerLive = new TrackerLive();
68 68
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
69 69
 			$TrackerLive->db = null;
70 70
 			*/
71
-            		//$real_arrival = $this->arrival($key);
72
-            		$Tracker = new Tracker($this->db);
73
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
71
+					//$real_arrival = $this->arrival($key);
72
+					$Tracker = new Tracker($this->db);
73
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74 74
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
75 75
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
76 76
 			}
77 77
 			// Put in archive
78 78
 //			$Tracker->db = null;
79
-            	    }
80
-            	    unset($this->all_tracked[$key]);
81
-    	        }
82
-	    }
83
-        }
84
-    }
79
+					}
80
+					unset($this->all_tracked[$key]);
81
+				}
82
+		}
83
+		}
84
+	}
85 85
 
86
-    public function add($line) {
86
+	public function add($line) {
87 87
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
88 88
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
89 89
 	date_default_timezone_set('UTC');
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	
93 93
 	// SBS format is CSV format
94 94
 	if(is_array($line) && isset($line['ident'])) {
95
-	    //print_r($line);
96
-  	    if (isset($line['ident'])) {
95
+		//print_r($line);
96
+  		if (isset($line['ident'])) {
97 97
 
98 98
 		/*
99 99
 		// Increment message number
@@ -109,29 +109,29 @@  discard block
 block discarded – undo
109 109
 		*/
110 110
 		
111 111
 		$Common = new Common();
112
-	        if (!isset($line['id'])) $id = trim($line['ident']);
113
-	        else $id = trim($line['id']);
112
+			if (!isset($line['id'])) $id = trim($line['ident']);
113
+			else $id = trim($line['id']);
114 114
 		
115 115
 		if (!isset($this->all_tracked[$id])) {
116
-		    $this->all_tracked[$id] = array();
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
119
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120
-		    if (!isset($line['id'])) {
116
+			$this->all_tracked[$id] = array();
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
119
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120
+			if (!isset($line['id'])) {
121 121
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
122 122
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
123
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
+			if ($globalAllTracked !== FALSE) $dataFound = true;
125 125
 		}
126 126
 		
127 127
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
128
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
129 129
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
130
-		    } else {
130
+			} else {
131 131
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
132 132
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
133 133
 				return '';
134
-		    }
134
+			}
135 135
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
136 136
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
137 137
 			return '';
@@ -148,38 +148,38 @@  discard block
 block discarded – undo
148 148
 		
149 149
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
150 150
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
151
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
152
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
151
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
152
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
153 153
 			$timeelapsed = microtime(true);
154
-            		$Tracker = new Tracker($this->db);
155
-            		$fromsource = NULL;
156
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
154
+					$Tracker = new Tracker($this->db);
155
+					$fromsource = NULL;
156
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
157 157
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
158 158
 			$Tracker->db = null;
159 159
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
160
-		    }
161
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+			}
161
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
162 162
 		}
163 163
 
164 164
 		if (isset($line['speed']) && $line['speed'] != '') {
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
167 167
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
168
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
169
-		    if ($distance > 1000 && $distance < 10000) {
168
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
169
+			if ($distance > 1000 && $distance < 10000) {
170 170
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
171 171
 			$speed = $speed*3.6;
172 172
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
173 173
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
174
-		    }
174
+			}
175 175
 		}
176 176
 
177
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
178
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
179
-	    	    else unset($timediff);
180
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
177
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
178
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
179
+				else unset($timediff);
180
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
181 181
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
182
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
182
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
183 183
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
184 184
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
185 185
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -193,120 +193,120 @@  discard block
 block discarded – undo
193 193
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
194 194
 				$this->tmd = 0;
195 195
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
196
-			    }
196
+				}
197 197
 			}
198 198
 
199 199
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
200 200
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
201 201
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
202
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
203
-				    $dataFound = true;
204
-				    $this->all_tracked[$id]['time_last_coord'] = time();
202
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
203
+					$dataFound = true;
204
+					$this->all_tracked[$id]['time_last_coord'] = time();
205 205
 				}
206 206
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
207 207
 			}
208 208
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
209
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
210 210
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
211 211
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
212
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
213
-				    $dataFound = true;
214
-				    $this->all_tracked[$id]['time_last_coord'] = time();
212
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
213
+					$dataFound = true;
214
+					$this->all_tracked[$id]['time_last_coord'] = time();
215 215
 				}
216 216
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
217 217
 			}
218 218
 
219
-		    } else if ($globalDebug && $timediff > 20) {
219
+			} else if ($globalDebug && $timediff > 20) {
220 220
 			$this->tmd = $this->tmd + 1;
221 221
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222 222
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223 223
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225
-		    }
225
+			}
226 226
 		}
227 227
 		if (isset($line['last_update']) && $line['last_update'] != '') {
228
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
229
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
228
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
229
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230 230
 		}
231 231
 		if (isset($line['format_source']) && $line['format_source'] != '') {
232
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
232
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233 233
 		}
234 234
 		if (isset($line['source_name']) && $line['source_name'] != '') {
235
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
235
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236 236
 		}
237 237
 		if (isset($line['comment']) && $line['comment'] != '') {
238
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
-		    //$dataFound = true;
238
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+			//$dataFound = true;
240 240
 		}
241 241
 		if (isset($line['type']) && $line['type'] != '') {
242
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
-		    //$dataFound = true;
242
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+			//$dataFound = true;
244 244
 		}
245 245
 
246 246
 		if (isset($line['altitude']) && $line['altitude'] != '') {
247
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
247
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248 248
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
249 249
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
251 251
 			//$dataFound = true;
252
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
252
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253 253
   		}
254 254
 
255 255
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
256
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257 257
 		}
258 258
 		
259 259
 		if (isset($line['heading']) && $line['heading'] != '') {
260
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
261
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
263
-		    //$dataFound = true;
260
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
261
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
263
+			//$dataFound = true;
264 264
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
265
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
266
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
267
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
268
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
265
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
266
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
267
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
268
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
269 269
   		}
270 270
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
271 271
 
272 272
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
273
-		    $this->all_tracked[$id]['lastupdate'] = time();
274
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
275
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
273
+			$this->all_tracked[$id]['lastupdate'] = time();
274
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
275
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
277 277
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
278 278
 				$timeelapsed = microtime(true);
279 279
 				$TrackerLive = new TrackerLive($this->db);
280 280
 				if (isset($line['id'])) {
281
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
282
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
281
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
282
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283 283
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
284
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
285
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
285
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286 286
 				} else $recent_ident = '';
287 287
 				$TrackerLive->db=null;
288 288
 
289 289
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
290 290
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
291
-			    } else {
291
+				} else {
292 292
 				$recent_ident = '';
293 293
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
-			    }
295
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
296
-			    if($recent_ident == "")
297
-			    {
294
+				}
295
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
296
+				if($recent_ident == "")
297
+				{
298 298
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
299 299
 				//adds the spotter data for the archive
300
-				    $highlight = '';
301
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
-				    $timeelapsed = microtime(true);
303
-				    $Tracker = new Tracker($this->db);
304
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
-				    $Tracker->db = null;
306
-				    if ($globalDebug && isset($result)) echo $result."\n";
307
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300
+					$highlight = '';
301
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+					$timeelapsed = microtime(true);
303
+					$Tracker = new Tracker($this->db);
304
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+					$Tracker->db = null;
306
+					if ($globalDebug && isset($result)) echo $result."\n";
307
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308 308
 				    
309
-				    /*
309
+					/*
310 310
 				    // Add source stat in DB
311 311
 				    $Stats = new Stats($this->db);
312 312
 				    if (!empty($this->stats)) {
@@ -333,20 +333,20 @@  discard block
 block discarded – undo
333 333
 				    }
334 334
 				    $Stats->db = null;
335 335
 				    */
336
-				    $this->del();
336
+					$this->del();
337 337
 				//$ignoreImport = false;
338 338
 				$this->all_tracked[$id]['addedTracker'] = 1;
339 339
 				//print_r($this->all_tracked[$id]);
340 340
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
341
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
342
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
343
-				    $TrackerLive = new TrackerLive($this->db);
344
-				    $TrackerLive->deleteLiveTrackerData();
345
-				    $TrackerLive->db=null;
346
-				    if ($globalDebug) echo " Done\n";
347
-				    $this->last_delete = time();
341
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
342
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
343
+					$TrackerLive = new TrackerLive($this->db);
344
+					$TrackerLive->deleteLiveTrackerData();
345
+					$TrackerLive->db=null;
346
+					if ($globalDebug) echo " Done\n";
347
+					$this->last_delete = time();
348 348
 				}
349
-			    } else {
349
+				} else {
350 350
 				$this->all_tracked[$id]['id'] = $recent_ident;
351 351
 				$this->all_tracked[$id]['addedTracker'] = 1;
352 352
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
 					$Tracker->db = null;
356 356
 				}
357 357
 				
358
-			    }
358
+				}
359
+			}
359 360
 			}
360
-		    }
361
-		    //adds the spotter LIVE data
362
-		    if ($globalDebug) {
361
+			//adds the spotter LIVE data
362
+			if ($globalDebug) {
363 363
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
364
-		    }
365
-		    $ignoreImport = false;
364
+			}
365
+			$ignoreImport = false;
366 366
 
367
-		    if (!$ignoreImport) {
367
+			if (!$ignoreImport) {
368 368
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369 369
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
370 370
 				$timeelapsed = microtime(true);
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	    if (isset($this->all_tracked[$key]['id'])) {
50 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
51 51
     		$Tracker = new Tracker($this->db);
52
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
52
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
53 53
             }
54 54
 	}
55 55
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
61 61
 	foreach ($this->all_tracked as $key => $flight) {
62 62
     	    if (isset($flight['lastupdate'])) {
63
-        	if ($flight['lastupdate'] < (time()-3000)) {
63
+        	if ($flight['lastupdate'] < (time() - 3000)) {
64 64
             	    if (isset($this->all_tracked[$key]['id'])) {
65 65
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
66 66
 			/*
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             		//$real_arrival = $this->arrival($key);
72 72
             		$Tracker = new Tracker($this->db);
73 73
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
74
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
75 75
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
76 76
 			}
77 77
 			// Put in archive
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	$send = false;
92 92
 	
93 93
 	// SBS format is CSV format
94
-	if(is_array($line) && isset($line['ident'])) {
94
+	if (is_array($line) && isset($line['ident'])) {
95 95
 	    //print_r($line);
96 96
   	    if (isset($line['ident'])) {
97 97
 
@@ -114,33 +114,33 @@  discard block
 block discarded – undo
114 114
 		
115 115
 		if (!isset($this->all_tracked[$id])) {
116 116
 		    $this->all_tracked[$id] = array();
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
119
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
119
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
120 120
 		    if (!isset($line['id'])) {
121 121
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
122
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
122
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
123
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
124 124
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
125 125
 		}
126 126
 		
127
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
128 128
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
129
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
130 130
 		    } else {
131 131
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
132 132
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
133 133
 				return '';
134 134
 		    }
135
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
136 136
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
137 137
 			return '';
138
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
139 139
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
140 140
 			return '';
141 141
 		} elseif (!isset($line['datetime'])) {
142 142
 			date_default_timezone_set('UTC');
143
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
144 144
 		} else {
145 145
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
146 146
 			return '';
@@ -148,38 +148,38 @@  discard block
 block discarded – undo
148 148
 		
149 149
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
150 150
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
151
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
152 152
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
153 153
 			$timeelapsed = microtime(true);
154 154
             		$Tracker = new Tracker($this->db);
155 155
             		$fromsource = NULL;
156
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
157 157
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
158 158
 			$Tracker->db = null;
159
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
160 160
 		    }
161
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
162 162
 		}
163 163
 
164 164
 		if (isset($line['speed']) && $line['speed'] != '') {
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
166
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
167 167
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
168
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
169 169
 		    if ($distance > 1000 && $distance < 10000) {
170 170
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
171 171
 			$speed = $speed*3.6;
172
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
173 173
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
174 174
 		    }
175 175
 		}
176 176
 
177 177
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
178
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
179 179
 	    	    else unset($timediff);
180
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
181 181
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
182
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
182
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
183 183
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
184 184
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
185 185
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
188 188
 				$timeelapsed = microtime(true);
189 189
 				$Tracker = new Tracker($this->db);
190
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
191 191
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
192 192
 				$Tracker->db = null;
193
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
194 194
 				$this->tmd = 0;
195 195
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
196 196
 			    }
@@ -198,73 +198,73 @@  discard block
 block discarded – undo
198 198
 
199 199
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
200 200
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
201
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
202 202
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
203 203
 				    $dataFound = true;
204 204
 				    $this->all_tracked[$id]['time_last_coord'] = time();
205 205
 				}
206
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
207 207
 			}
208 208
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
209 209
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
210 210
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
211
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
212 212
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
213 213
 				    $dataFound = true;
214 214
 				    $this->all_tracked[$id]['time_last_coord'] = time();
215 215
 				}
216
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
217 217
 			}
218 218
 
219 219
 		    } else if ($globalDebug && $timediff > 20) {
220 220
 			$this->tmd = $this->tmd + 1;
221 221
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 		    }
226 226
 		}
227 227
 		if (isset($line['last_update']) && $line['last_update'] != '') {
228 228
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
229
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
230 230
 		}
231 231
 		if (isset($line['format_source']) && $line['format_source'] != '') {
232
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
232
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
233 233
 		}
234 234
 		if (isset($line['source_name']) && $line['source_name'] != '') {
235
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
235
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
236 236
 		}
237 237
 		if (isset($line['comment']) && $line['comment'] != '') {
238
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
238
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
239 239
 		    //$dataFound = true;
240 240
 		}
241 241
 		if (isset($line['type']) && $line['type'] != '') {
242
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
242
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
243 243
 		    //$dataFound = true;
244 244
 		}
245 245
 
246 246
 		if (isset($line['altitude']) && $line['altitude'] != '') {
247 247
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
249
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
248
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
249
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => round($line['altitude']/100)));
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
251 251
 			//$dataFound = true;
252 252
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253 253
   		}
254 254
 
255 255
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
256
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
257 257
 		}
258 258
 		
259 259
 		if (isset($line['heading']) && $line['heading'] != '') {
260
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
261
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
260
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
261
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
263 263
 		    //$dataFound = true;
264 264
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
265
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
266
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
267
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
265
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
266
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
267
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
268 268
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
269 269
   		}
270 270
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -272,39 +272,39 @@  discard block
 block discarded – undo
272 272
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
273 273
 		    $this->all_tracked[$id]['lastupdate'] = time();
274 274
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
275
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
275
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276 276
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
277 277
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
278 278
 				$timeelapsed = microtime(true);
279 279
 				$TrackerLive = new TrackerLive($this->db);
280 280
 				if (isset($line['id'])) {
281 281
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
282
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
283 283
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
284 284
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
285
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
286 286
 				} else $recent_ident = '';
287
-				$TrackerLive->db=null;
287
+				$TrackerLive->db = null;
288 288
 
289 289
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
290 290
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
291 291
 			    } else {
292 292
 				$recent_ident = '';
293
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
293
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
294 294
 			    }
295 295
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
296
-			    if($recent_ident == "")
296
+			    if ($recent_ident == "")
297 297
 			    {
298 298
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
299 299
 				//adds the spotter data for the archive
300 300
 				    $highlight = '';
301
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
301
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302 302
 				    $timeelapsed = microtime(true);
303 303
 				    $Tracker = new Tracker($this->db);
304
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
304
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
305 305
 				    $Tracker->db = null;
306 306
 				    if ($globalDebug && isset($result)) echo $result."\n";
307
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
307
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
308 308
 				    
309 309
 				    /*
310 310
 				    // Add source stat in DB
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
343 343
 				    $TrackerLive = new TrackerLive($this->db);
344 344
 				    $TrackerLive->deleteLiveTrackerData();
345
-				    $TrackerLive->db=null;
345
+				    $TrackerLive->db = null;
346 346
 				    if ($globalDebug) echo " Done\n";
347 347
 				    $this->last_delete = time();
348 348
 				}
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 				$this->all_tracked[$id]['addedTracker'] = 1;
352 352
 				if (isset($globalDaemon) && !$globalDaemon) {
353 353
 					$Tracker = new Tracker($this->db);
354
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
354
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
355 355
 					$Tracker->db = null;
356 356
 				}
357 357
 				
@@ -365,14 +365,14 @@  discard block
 block discarded – undo
365 365
 		    $ignoreImport = false;
366 366
 
367 367
 		    if (!$ignoreImport) {
368
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
368
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369 369
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
370 370
 				$timeelapsed = microtime(true);
371 371
 				$TrackerLive = new TrackerLive($this->db);
372
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
372
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
373 373
 				$TrackerLive->db = null;
374 374
 				$this->all_tracked[$id]['putinarchive'] = false;
375
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
375
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
376 376
 
377 377
 				// Put statistics in $this->stats variable
378 378
 				/*
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
Braces   +158 added lines, -54 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function checkAll() {
46 46
 	global $globalDebug;
47
-	if ($globalDebug) echo "Update last seen tracked data...\n";
47
+	if ($globalDebug) {
48
+		echo "Update last seen tracked data...\n";
49
+	}
48 50
 	foreach ($this->all_tracked as $key => $flight) {
49 51
 	    if (isset($this->all_tracked[$key]['id'])) {
50 52
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -57,12 +59,16 @@  discard block
 block discarded – undo
57 59
     public function del() {
58 60
 	global $globalDebug;
59 61
 	// Delete old infos
60
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
62
+	if ($globalDebug) {
63
+		echo 'Delete old values and update latest data...'."\n";
64
+	}
61 65
 	foreach ($this->all_tracked as $key => $flight) {
62 66
     	    if (isset($flight['lastupdate'])) {
63 67
         	if ($flight['lastupdate'] < (time()-3000)) {
64 68
             	    if (isset($this->all_tracked[$key]['id'])) {
65
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		if ($globalDebug) {
70
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
71
+            		}
66 72
 			/*
67 73
 			$TrackerLive = new TrackerLive();
68 74
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -72,7 +78,9 @@  discard block
 block discarded – undo
72 78
             		$Tracker = new Tracker($this->db);
73 79
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74 80
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
75
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
81
+				if ($globalDebug && $result != 'success') {
82
+					echo '!!! ERROR : '.$result."\n";
83
+				}
76 84
 			}
77 85
 			// Put in archive
78 86
 //			$Tracker->db = null;
@@ -85,7 +93,9 @@  discard block
 block discarded – undo
85 93
 
86 94
     public function add($line) {
87 95
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
88
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
96
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
97
+		$globalCoordMinChange = '0.02';
98
+	}
89 99
 	date_default_timezone_set('UTC');
90 100
 	$dataFound = false;
91 101
 	$send = false;
@@ -109,8 +119,11 @@  discard block
 block discarded – undo
109 119
 		*/
110 120
 		
111 121
 		$Common = new Common();
112
-	        if (!isset($line['id'])) $id = trim($line['ident']);
113
-	        else $id = trim($line['id']);
122
+	        if (!isset($line['id'])) {
123
+	        	$id = trim($line['ident']);
124
+	        } else {
125
+	        	$id = trim($line['id']);
126
+	        }
114 127
 		
115 128
 		if (!isset($this->all_tracked[$id])) {
116 129
 		    $this->all_tracked[$id] = array();
@@ -118,31 +131,46 @@  discard block
 block discarded – undo
118 131
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
119 132
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120 133
 		    if (!isset($line['id'])) {
121
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134
+			if (!isset($globalDaemon)) {
135
+				$globalDaemon = TRUE;
136
+			}
122 137
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
138
+		     } else {
139
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
140
+		     }
141
+		    if ($globalAllTracked !== FALSE) {
142
+		    	$dataFound = true;
143
+		    }
125 144
 		}
126 145
 		
127 146
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
128 147
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
129 148
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
130 149
 		    } else {
131
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
132
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
150
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
151
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
152
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
153
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
154
+				}
133 155
 				return '';
134 156
 		    }
135 157
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
136
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
158
+			if ($globalDebug) {
159
+				echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
160
+			}
137 161
 			return '';
138 162
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
139
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
163
+			if ($globalDebug) {
164
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
165
+			}
140 166
 			return '';
141 167
 		} elseif (!isset($line['datetime'])) {
142 168
 			date_default_timezone_set('UTC');
143 169
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
144 170
 		} else {
145
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
171
+			if ($globalDebug) {
172
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
173
+			}
146 174
 			return '';
147 175
 		}
148 176
 		
@@ -154,11 +182,17 @@  discard block
 block discarded – undo
154 182
             		$Tracker = new Tracker($this->db);
155 183
             		$fromsource = NULL;
156 184
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
157
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
185
+			if ($globalDebug && $result != 'success') {
186
+				echo '!!! ERROR : '.$result."\n";
187
+			}
158 188
 			$Tracker->db = null;
159
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
189
+			if ($globalDebugTimeElapsed) {
190
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
191
+			}
192
+		    }
193
+		    if (!isset($this->all_tracked[$id]['id'])) {
194
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160 195
 		    }
161
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
162 196
 		}
163 197
 
164 198
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -169,14 +203,21 @@  discard block
 block discarded – undo
169 203
 		    if ($distance > 1000 && $distance < 10000) {
170 204
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
171 205
 			$speed = $speed*3.6;
172
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
173
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
206
+			if ($speed < 1000) {
207
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
208
+			}
209
+  			if ($globalDebug) {
210
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
211
+  			}
174 212
 		    }
175 213
 		}
176 214
 
177 215
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
178
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
179
-	    	    else unset($timediff);
216
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
217
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
218
+	    	    } else {
219
+	    	    	unset($timediff);
220
+	    	    }
180 221
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
181 222
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
182 223
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -184,20 +225,30 @@  discard block
 block discarded – undo
184 225
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
185 226
 				$this->all_tracked[$id]['putinarchive'] = true;
186 227
 				
187
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
228
+				if ($globalDebug) {
229
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
230
+				}
188 231
 				$timeelapsed = microtime(true);
189 232
 				$Tracker = new Tracker($this->db);
190 233
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
191
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
234
+				if (!empty($all_country)) {
235
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
236
+				}
192 237
 				$Tracker->db = null;
193
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
238
+				if ($globalDebugTimeElapsed) {
239
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
240
+				}
194 241
 				$this->tmd = 0;
195
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
242
+				if ($globalDebug) {
243
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
244
+				}
196 245
 			    }
197 246
 			}
198 247
 
199 248
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
200
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
249
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
250
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
251
+				}
201 252
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
202 253
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
203 254
 				    $dataFound = true;
@@ -206,8 +257,12 @@  discard block
 block discarded – undo
206 257
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
207 258
 			}
208 259
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
209
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
210
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
260
+			    if ($line['longitude'] > 180) {
261
+			    	$line['longitude'] = $line['longitude'] - 360;
262
+			    }
263
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
264
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
265
+				}
211 266
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
212 267
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
213 268
 				    $dataFound = true;
@@ -225,7 +280,9 @@  discard block
 block discarded – undo
225 280
 		    }
226 281
 		}
227 282
 		if (isset($line['last_update']) && $line['last_update'] != '') {
228
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
283
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
284
+		    	$dataFound = true;
285
+		    }
229 286
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230 287
 		}
231 288
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -245,7 +302,9 @@  discard block
 block discarded – undo
245 302
 
246 303
 		if (isset($line['altitude']) && $line['altitude'] != '') {
247 304
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
305
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
306
+				$this->all_tracked[$id]['putinarchive'] = true;
307
+			}
249 308
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
250 309
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
251 310
 			//$dataFound = true;
@@ -257,15 +316,21 @@  discard block
 block discarded – undo
257 316
 		}
258 317
 		
259 318
 		if (isset($line['heading']) && $line['heading'] != '') {
260
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
320
+		    	$this->all_tracked[$id]['putinarchive'] = true;
321
+		    }
261 322
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
262 323
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
263 324
 		    //$dataFound = true;
264 325
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
265 326
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
266 327
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
267
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
268
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
328
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
329
+		    	$this->all_tracked[$id]['putinarchive'] = true;
330
+		    }
331
+  		    if ($globalDebug) {
332
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
333
+  		    }
269 334
   		}
270 335
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
271 336
 
@@ -274,20 +339,31 @@  discard block
 block discarded – undo
274 339
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
275 340
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276 341
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
277
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
342
+				if ($globalDebug) {
343
+					echo "Check if aircraft is already in DB...";
344
+				}
278 345
 				$timeelapsed = microtime(true);
279 346
 				$TrackerLive = new TrackerLive($this->db);
280 347
 				if (isset($line['id'])) {
281 348
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
282
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
349
+				    if ($globalDebugTimeElapsed) {
350
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
351
+				    }
283 352
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
284 353
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
285
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
-				} else $recent_ident = '';
354
+				    if ($globalDebugTimeElapsed) {
355
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
356
+				    }
357
+				} else {
358
+					$recent_ident = '';
359
+				}
287 360
 				$TrackerLive->db=null;
288 361
 
289
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
290
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
362
+				if ($globalDebug && $recent_ident == '') {
363
+					echo " Not in DB.\n";
364
+				} elseif ($globalDebug && $recent_ident != '') {
365
+					echo " Already in DB.\n";
366
+				}
291 367
 			    } else {
292 368
 				$recent_ident = '';
293 369
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -295,16 +371,24 @@  discard block
 block discarded – undo
295 371
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
296 372
 			    if($recent_ident == "")
297 373
 			    {
298
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
374
+				if ($globalDebug) {
375
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
376
+				}
299 377
 				//adds the spotter data for the archive
300 378
 				    $highlight = '';
301
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
379
+				    if (!isset($this->all_tracked[$id]['id'])) {
380
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
381
+				    }
302 382
 				    $timeelapsed = microtime(true);
303 383
 				    $Tracker = new Tracker($this->db);
304 384
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305 385
 				    $Tracker->db = null;
306
-				    if ($globalDebug && isset($result)) echo $result."\n";
307
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
386
+				    if ($globalDebug && isset($result)) {
387
+				    	echo $result."\n";
388
+				    }
389
+				    if ($globalDebugTimeElapsed) {
390
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
391
+				    }
308 392
 				    
309 393
 				    /*
310 394
 				    // Add source stat in DB
@@ -338,12 +422,16 @@  discard block
 block discarded – undo
338 422
 				$this->all_tracked[$id]['addedTracker'] = 1;
339 423
 				//print_r($this->all_tracked[$id]);
340 424
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
341
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
425
+				    if ($globalDebug) {
426
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
427
+				    }
342 428
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
343 429
 				    $TrackerLive = new TrackerLive($this->db);
344 430
 				    $TrackerLive->deleteLiveTrackerData();
345 431
 				    $TrackerLive->db=null;
346
-				    if ($globalDebug) echo " Done\n";
432
+				    if ($globalDebug) {
433
+				    	echo " Done\n";
434
+				    }
347 435
 				    $this->last_delete = time();
348 436
 				}
349 437
 			    } else {
@@ -366,13 +454,17 @@  discard block
 block discarded – undo
366 454
 
367 455
 		    if (!$ignoreImport) {
368 456
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
457
+				if ($globalDebug) {
458
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
459
+				}
370 460
 				$timeelapsed = microtime(true);
371 461
 				$TrackerLive = new TrackerLive($this->db);
372 462
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373 463
 				$TrackerLive->db = null;
374 464
 				$this->all_tracked[$id]['putinarchive'] = false;
375
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
465
+				if ($globalDebugTimeElapsed) {
466
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
467
+				}
376 468
 
377 469
 				// Put statistics in $this->stats variable
378 470
 				/*
@@ -429,19 +521,29 @@  discard block
 block discarded – undo
429 521
 				*/
430 522
 
431 523
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
524
+				if ($this->all_tracked[$id]['putinarchive']) {
525
+					$send = true;
526
+				}
527
+				if ($globalDebug) {
528
+					echo $result."\n";
529
+				}
530
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
531
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
532
+			}
435 533
 			//$this->del();
436 534
 			
437 535
 			
438 536
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
537
+			    if ($globalDebug) {
538
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
539
+			    }
440 540
 			    $TrackerLive = new TrackerLive($this->db);
441 541
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 542
 			    $TrackerLive->db = null;
443 543
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
544
+			    if ($globalDebug) {
545
+			    	echo " Done\n";
546
+			    }
445 547
 			    $this->last_delete_hourly = time();
446 548
 			}
447 549
 			
@@ -449,7 +551,9 @@  discard block
 block discarded – undo
449 551
 		    //$ignoreImport = false;
450 552
 		}
451 553
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
554
+		if ($send) {
555
+			return $this->all_tracked[$id];
556
+		}
453 557
 	    }
454 558
 	}
455 559
     }
Please login to merge, or discard this patch.
require/class.MarineImport.php 2 patches
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Stats.php');
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class MarineImport {
16
-    private $all_tracked = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_tracked = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
27 27
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
28
-	    $Connection = new Connection($dbc);
29
-	    $this->db = $Connection->db();
30
-	    date_default_timezone_set('UTC');
28
+		$Connection = new Connection($dbc);
29
+		$this->db = $Connection->db();
30
+		date_default_timezone_set('UTC');
31 31
 	}
32 32
 	// Get previous source stats
33 33
 	/*
@@ -46,55 +46,55 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	*/
48 48
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
49
-	    $APRSMarine = new APRSMarine();
50
-	    //$APRSSpotter->connect();
49
+		$APRSMarine = new APRSMarine();
50
+		//$APRSSpotter->connect();
51
+	}
51 52
 	}
52
-    }
53 53
 
54
-    public function checkAll() {
54
+	public function checkAll() {
55 55
 	global $globalDebug;
56 56
 	if ($globalDebug) echo "Update last seen tracked data...\n";
57 57
 	foreach ($this->all_tracked as $key => $flight) {
58
-	    if (isset($this->all_tracked[$key]['id'])) {
58
+		if (isset($this->all_tracked[$key]['id'])) {
59 59
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
60
-    		$Marine = new Marine($this->db);
61
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
62
-            }
60
+			$Marine = new Marine($this->db);
61
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
62
+			}
63
+	}
63 64
 	}
64
-    }
65 65
 
66
-    public function del() {
66
+	public function del() {
67 67
 	global $globalDebug, $globalNoDB, $globalNoImport;
68 68
 	// Delete old infos
69 69
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
70 70
 	foreach ($this->all_tracked as $key => $flight) {
71
-    	    if (isset($flight['lastupdate'])) {
72
-        	if ($flight['lastupdate'] < (time()-3000)) {
73
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74
-            		if (isset($this->all_tracked[$key]['id'])) {
75
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
76
-			    /*
71
+			if (isset($flight['lastupdate'])) {
72
+			if ($flight['lastupdate'] < (time()-3000)) {
73
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74
+					if (isset($this->all_tracked[$key]['id'])) {
75
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
76
+				/*
77 77
 			    $MarineLive = new MarineLive();
78 78
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
79 79
 			    $MarineLive->db = null;
80 80
 			    */
81
-            		    //$real_arrival = $this->arrival($key);
82
-            		    $Marine = new Marine($this->db);
83
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
81
+						//$real_arrival = $this->arrival($key);
82
+						$Marine = new Marine($this->db);
83
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84 84
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
85 85
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
86
-			    }
87
-			    // Put in archive
86
+				}
87
+				// Put in archive
88 88
 //				$Marine->db = null;
89 89
 			}
90
-            	    }
91
-            	    unset($this->all_tracked[$key]);
92
-    	        }
93
-	    }
94
-        }
95
-    }
90
+					}
91
+					unset($this->all_tracked[$key]);
92
+				}
93
+		}
94
+		}
95
+	}
96 96
 
97
-    public function add($line) {
97
+	public function add($line) {
98 98
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
99 99
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
100 100
 	date_default_timezone_set('UTC');
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	
104 104
 	// SBS format is CSV format
105 105
 	if(is_array($line) && isset($line['mmsi'])) {
106
-	    //print_r($line);
107
-  	    if (isset($line['mmsi'])) {
106
+		//print_r($line);
107
+  		if (isset($line['mmsi'])) {
108 108
 
109 109
 		/*
110 110
 		// Increment message number
@@ -121,64 +121,64 @@  discard block
 block discarded – undo
121 121
 		
122 122
 		$Common = new Common();
123 123
 		$AIS = new AIS();
124
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
125
-	        else $id = trim($line['id']);
124
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
125
+			else $id = trim($line['id']);
126 126
 		
127 127
 		if (!isset($this->all_tracked[$id])) {
128
-		    $this->all_tracked[$id] = array();
129
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
130
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132
-		    if (!isset($line['id'])) {
128
+			$this->all_tracked[$id] = array();
129
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
130
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132
+			if (!isset($line['id'])) {
133 133
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134 134
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
136
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
135
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
136
+			if ($globalAllTracked !== FALSE) $dataFound = true;
137 137
 		}
138 138
 		
139 139
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
140
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
141
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
140
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
141
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
142 142
 			$Marine = new Marine($this->db);
143 143
 			$identity = $Marine->getIdentity($line['mmsi']);
144 144
 			if (!empty($identity)) {
145
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
146
-			    $this->all_tracked[$id]['type'] = $identity['type'];
145
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
146
+				$this->all_tracked[$id]['type'] = $identity['type'];
147 147
 			}
148 148
 			//print_r($identity);
149 149
 			unset($Marine);
150 150
 			//$dataFound = true;
151
-		    }
151
+			}
152 152
 		}
153 153
 		if (isset($line['type_id'])) {
154
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
154
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
155 155
 		}
156 156
 		if (isset($line['type']) && $line['type'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
157
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
158 158
 		}
159 159
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
160
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
160
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
161 161
 		}
162 162
 		if (isset($line['imo']) && $line['imo'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
164 164
 		}
165 165
 		if (isset($line['callsign']) && $line['callsign'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
167 167
 		}
168 168
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
169
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
170 170
 		}
171 171
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
172
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
173 173
 		}
174 174
 
175 175
 
176 176
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
177 177
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
178
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
179
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
178
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
179
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
180 180
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
181
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
181
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
182 182
 				$timeelapsed = microtime(true);
183 183
 				$Marine = new Marine($this->db);
184 184
 				$fromsource = NULL;
@@ -186,20 +186,20 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
187 187
 				$Marine->db = null;
188 188
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
189
-			    }
189
+				}
190
+			}
190 191
 			}
191
-		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
192
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
193 193
 		}
194 194
 
195 195
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
196
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
196
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
197 197
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
198
-		    } else {
198
+			} else {
199 199
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
200 200
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
201 201
 				return '';
202
-		    }
202
+			}
203 203
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
204 204
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
205 205
 			return '';
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 		if (isset($line['speed'])) {
219
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
219
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
220
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
221 221
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
222
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
223
-		    if ($distance > 1000 && $distance < 10000) {
222
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
223
+			if ($distance > 1000 && $distance < 10000) {
224 224
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
225 225
 			$speed = $speed*3.6;
226 226
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
227 227
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
228
-		    }
228
+			}
229 229
 		}
230 230
 
231
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
232
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
233
-	    	    else unset($timediff);
234
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
231
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
232
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
233
+				else unset($timediff);
234
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
235 235
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
236
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
236
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
237 237
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
238 238
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
239 239
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -241,135 +241,135 @@  discard block
 block discarded – undo
241 241
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
242 242
 				$timeelapsed = microtime(true);
243 243
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
244
-				    $Marine = new Marine($this->db);
245
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
246
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
247
-				    $Marine->db = null;
248
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+					$Marine = new Marine($this->db);
245
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
246
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
247
+					$Marine->db = null;
248
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
249 249
 				}
250 250
 				$this->tmd = 0;
251 251
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
252
-			    }
252
+				}
253 253
 			}
254 254
 
255 255
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
256 256
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257 257
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
258
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
259
-				    $dataFound = true;
260
-				    $this->all_tracked[$id]['time_last_coord'] = time();
258
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
259
+					$dataFound = true;
260
+					$this->all_tracked[$id]['time_last_coord'] = time();
261 261
 				}
262 262
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
263 263
 			}
264 264
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
265
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
265
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
266 266
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
267 267
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
268
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
269
-				    $dataFound = true;
270
-				    $this->all_tracked[$id]['time_last_coord'] = time();
268
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
269
+					$dataFound = true;
270
+					$this->all_tracked[$id]['time_last_coord'] = time();
271 271
 				}
272 272
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
273 273
 			}
274 274
 
275
-		    } else if ($globalDebug && $timediff > 20) {
275
+			} else if ($globalDebug && $timediff > 20) {
276 276
 			$this->tmd = $this->tmd + 1;
277 277
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
278 278
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
279 279
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
280 280
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
281
-		    }
281
+			}
282 282
 		}
283 283
 		if (isset($line['last_update']) && $line['last_update'] != '') {
284
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
285
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
284
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
285
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
286 286
 		}
287 287
 		if (isset($line['format_source']) && $line['format_source'] != '') {
288
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
288
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
289 289
 		}
290 290
 		if (isset($line['source_name']) && $line['source_name'] != '') {
291
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
291
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
292 292
 		}
293 293
 		if (isset($line['status']) && $line['status'] != '') {
294
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
294
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
295 295
 		}
296 296
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
297
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
298
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
297
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
298
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
299 299
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
300
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
300
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
301 301
 				$Marine = new Marine($this->db);
302 302
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
303 303
 				unset($Marine);
304
-			    }
304
+				}
305
+			}
305 306
 			}
306
-		    }
307 307
 		}
308 308
 
309 309
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
310
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
310
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
311 311
 		}
312 312
 		
313 313
 		if (isset($line['heading']) && $line['heading'] != '') {
314
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
315
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
316
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
317
-		    //$dataFound = true;
314
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
315
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
316
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
317
+			//$dataFound = true;
318 318
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
319
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
320
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
321
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
322
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
319
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
320
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
321
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
322
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
323 323
   		}
324 324
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
325 325
 
326 326
 
327 327
 
328 328
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
329
-		    $this->all_tracked[$id]['lastupdate'] = time();
330
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
331
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
332
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
329
+			$this->all_tracked[$id]['lastupdate'] = time();
330
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
331
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
332
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
333 333
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
334
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
335
-				    $timeelapsed = microtime(true);
336
-				    $MarineLive = new MarineLive($this->db);
337
-				    if (isset($line['id'])) {
334
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
335
+					$timeelapsed = microtime(true);
336
+					$MarineLive = new MarineLive($this->db);
337
+					if (isset($line['id'])) {
338 338
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
339 339
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
340
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
340
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
341 341
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
342 342
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
343
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
343
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
344 344
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
345 345
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
346
-				    } else $recent_ident = '';
347
-				    $MarineLive->db=null;
348
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
349
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
346
+					} else $recent_ident = '';
347
+					$MarineLive->db=null;
348
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
349
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
350 350
 				} else $recent_ident = '';
351
-			    } else {
351
+				} else {
352 352
 				$recent_ident = '';
353 353
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
354
-			    }
355
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
356
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
357
-			    {
354
+				}
355
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
356
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
357
+				{
358 358
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
359 359
 				//adds the spotter data for the archive
360
-				    $highlight = '';
361
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
362
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
360
+					$highlight = '';
361
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
362
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
363 363
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
364
-					    $timeelapsed = microtime(true);
365
-					    $Marine = new Marine($this->db);
366
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
367
-					    $Marine->db = null;
368
-					    if ($globalDebug && isset($result)) echo $result."\n";
369
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+						$timeelapsed = microtime(true);
365
+						$Marine = new Marine($this->db);
366
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
367
+						$Marine->db = null;
368
+						if ($globalDebug && isset($result)) echo $result."\n";
369
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
370 370
 					}
371
-				    }
372
-				    /*
371
+					}
372
+					/*
373 373
 				    // Add source stat in DB
374 374
 				    $Stats = new Stats($this->db);
375 375
 				    if (!empty($this->stats)) {
@@ -396,56 +396,56 @@  discard block
 block discarded – undo
396 396
 				    }
397 397
 				    $Stats->db = null;
398 398
 				    */
399
-				    $this->del();
399
+					$this->del();
400 400
 				//$ignoreImport = false;
401 401
 				$this->all_tracked[$id]['addedMarine'] = 1;
402 402
 				//print_r($this->all_tracked[$id]);
403 403
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
404
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
405
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
406
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
405
+					//MarineLive->deleteLiveMarineDataNotUpdated();
406
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
407 407
 					$MarineLive = new MarineLive($this->db);
408 408
 					$MarineLive->deleteLiveMarineData();
409 409
 					$MarineLive->db=null;
410 410
 					if ($globalDebug) echo " Done\n";
411
-				    }
412
-				    $this->last_delete = time();
411
+					}
412
+					$this->last_delete = time();
413 413
 				}
414
-			    } elseif ($recent_ident != '') {
414
+				} elseif ($recent_ident != '') {
415 415
 				$this->all_tracked[$id]['id'] = $recent_ident;
416 416
 				$this->all_tracked[$id]['addedMarine'] = 1;
417 417
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
418
-				    if (isset($globalDaemon) && !$globalDaemon) {
418
+					if (isset($globalDaemon) && !$globalDaemon) {
419 419
 					$Marine = new Marine($this->db);
420 420
 					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
421 421
 					$Marine->db = null;
422
-				    }
422
+					}
423 423
 				}
424 424
 				
425
-			    }
425
+				}
426
+			}
426 427
 			}
427
-		    }
428
-		    //adds the spotter LIVE data
429
-		    if ($globalDebug) {
428
+			//adds the spotter LIVE data
429
+			if ($globalDebug) {
430 430
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
431
-		    }
432
-		    $ignoreImport = false;
431
+			}
432
+			$ignoreImport = false;
433 433
 
434
-		    if (!$ignoreImport) {
434
+			if (!$ignoreImport) {
435 435
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
436 436
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
437 437
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
438
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
438
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
439 439
 					$timeelapsed = microtime(true);
440 440
 					$MarineLive = new MarineLive($this->db);
441 441
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
442 442
 					$MarineLive->db = null;
443 443
 					if ($globalDebug) echo $result."\n";
444 444
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
445
-				    }
445
+					}
446 446
 				}
447 447
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
448
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
448
+					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
449 449
 				}
450 450
 				$this->all_tracked[$id]['putinarchive'] = false;
451 451
 
@@ -510,24 +510,24 @@  discard block
 block discarded – undo
510 510
 			
511 511
 			
512 512
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
513
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
513
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
514 514
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
515 515
 				$MarineLive = new MarineLive($this->db);
516 516
 				$MarineLive->deleteLiveMarineDataNotUpdated();
517 517
 				$MarineLive->db = null;
518 518
 				//MarineLive->deleteLiveMarineData();
519 519
 				if ($globalDebug) echo " Done\n";
520
-			    }
521
-			    $this->last_delete_hourly = time();
520
+				}
521
+				$this->last_delete_hourly = time();
522 522
 			}
523 523
 			
524
-		    }
525
-		    //$ignoreImport = false;
524
+			}
525
+			//$ignoreImport = false;
526 526
 		}
527 527
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
528 528
 		if ($send) return $this->all_tracked[$id];
529
-	    }
529
+		}
530
+	}
530 531
 	}
531
-    }
532 532
 }
533 533
 ?>
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	    if (isset($this->all_tracked[$key]['id'])) {
59 59
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
60 60
     		$Marine = new Marine($this->db);
61
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
61
+        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
62 62
             }
63 63
 	}
64 64
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
70 70
 	foreach ($this->all_tracked as $key => $flight) {
71 71
     	    if (isset($flight['lastupdate'])) {
72
-        	if ($flight['lastupdate'] < (time()-3000)) {
72
+        	if ($flight['lastupdate'] < (time() - 3000)) {
73 73
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74 74
             		if (isset($this->all_tracked[$key]['id'])) {
75 75
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             		    //$real_arrival = $this->arrival($key);
82 82
             		    $Marine = new Marine($this->db);
83 83
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84
-				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
84
+				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
85 85
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
86 86
 			    }
87 87
 			    // Put in archive
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
     }
96 96
 
97 97
     public function add($line) {
98
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
98
+	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine;
99 99
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
100 100
 	date_default_timezone_set('UTC');
101 101
 	$dataFound = false;
102 102
 	$send = false;
103 103
 	
104 104
 	// SBS format is CSV format
105
-	if(is_array($line) && isset($line['mmsi'])) {
105
+	if (is_array($line) && isset($line['mmsi'])) {
106 106
 	    //print_r($line);
107 107
   	    if (isset($line['mmsi'])) {
108 108
 
@@ -126,18 +126,18 @@  discard block
 block discarded – undo
126 126
 		
127 127
 		if (!isset($this->all_tracked[$id])) {
128 128
 		    $this->all_tracked[$id] = array();
129
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
130
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
129
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
130
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => ''));
131
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
132 132
 		    if (!isset($line['id'])) {
133 133
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
134
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
135
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
136 136
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
137 137
 		}
138 138
 		
139 139
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
140
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
140
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
141 141
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
142 142
 			$Marine = new Marine($this->db);
143 143
 			$identity = $Marine->getIdentity($line['mmsi']);
@@ -151,64 +151,64 @@  discard block
 block discarded – undo
151 151
 		    }
152 152
 		}
153 153
 		if (isset($line['type_id'])) {
154
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
154
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
155 155
 		}
156 156
 		if (isset($line['type']) && $line['type'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
158 158
 		}
159 159
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
160
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
160
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
161 161
 		}
162 162
 		if (isset($line['imo']) && $line['imo'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
164 164
 		}
165 165
 		if (isset($line['callsign']) && $line['callsign'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
166
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
167 167
 		}
168 168
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
169
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
170 170
 		}
171 171
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
172
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
173 173
 		}
174 174
 
175 175
 
176 176
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
177 177
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
178
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
178
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
179 179
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
180 180
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
181 181
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
182 182
 				$timeelapsed = microtime(true);
183 183
 				$Marine = new Marine($this->db);
184 184
 				$fromsource = NULL;
185
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
185
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
186 186
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
187 187
 				$Marine->db = null;
188
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
188
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
189 189
 			    }
190 190
 			}
191 191
 		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
192
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
193 193
 		}
194 194
 
195
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
195
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
196 196
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
197
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
197
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
198 198
 		    } else {
199 199
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
200 200
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
201 201
 				return '';
202 202
 		    }
203
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
203
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
204 204
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
205 205
 			return '';
206
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
206
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
207 207
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
208 208
 			return '';
209 209
 		} elseif (!isset($line['datetime'])) {
210 210
 			date_default_timezone_set('UTC');
211
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
211
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
212 212
 		} else {
213 213
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
214 214
 			return '';
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 		if (isset($line['speed'])) {
219
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
219
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
220
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
221 221
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
222
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
222
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
223 223
 		    if ($distance > 1000 && $distance < 10000) {
224 224
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
225 225
 			$speed = $speed*3.6;
226
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
226
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
227 227
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
228 228
 		    }
229 229
 		}
230 230
 
231 231
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
232
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
232
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
233 233
 	    	    else unset($timediff);
234
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
234
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
235 235
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
236
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
236
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
237 237
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
238 238
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
239 239
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 				$timeelapsed = microtime(true);
243 243
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
244 244
 				    $Marine = new Marine($this->db);
245
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
245
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
246 246
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
247 247
 				    $Marine->db = null;
248
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
248
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
249 249
 				}
250 250
 				$this->tmd = 0;
251 251
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -254,52 +254,52 @@  discard block
 block discarded – undo
254 254
 
255 255
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
256 256
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
257
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
258 258
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
259 259
 				    $dataFound = true;
260 260
 				    $this->all_tracked[$id]['time_last_coord'] = time();
261 261
 				}
262
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
262
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
263 263
 			}
264 264
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
265 265
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
266 266
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
267
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
267
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
268 268
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
269 269
 				    $dataFound = true;
270 270
 				    $this->all_tracked[$id]['time_last_coord'] = time();
271 271
 				}
272
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
272
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
273 273
 			}
274 274
 
275 275
 		    } else if ($globalDebug && $timediff > 20) {
276 276
 			$this->tmd = $this->tmd + 1;
277 277
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
278
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
279
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
278
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
279
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
280 280
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
281 281
 		    }
282 282
 		}
283 283
 		if (isset($line['last_update']) && $line['last_update'] != '') {
284 284
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
285
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
285
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
286 286
 		}
287 287
 		if (isset($line['format_source']) && $line['format_source'] != '') {
288
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
288
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
289 289
 		}
290 290
 		if (isset($line['source_name']) && $line['source_name'] != '') {
291
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
291
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
292 292
 		}
293 293
 		if (isset($line['status']) && $line['status'] != '') {
294
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
294
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
295 295
 		}
296 296
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
297
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
297
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
298 298
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
299 299
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
300 300
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
301 301
 				$Marine = new Marine($this->db);
302
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
302
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
303 303
 				unset($Marine);
304 304
 			    }
305 305
 			}
@@ -307,18 +307,18 @@  discard block
 block discarded – undo
307 307
 		}
308 308
 
309 309
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
310
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
310
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
311 311
 		}
312 312
 		
313 313
 		if (isset($line['heading']) && $line['heading'] != '') {
314
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
315
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
316
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
314
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
315
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
316
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
317 317
 		    //$dataFound = true;
318 318
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
319
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
320
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
321
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
320
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
321
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
322 322
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
323 323
   		}
324 324
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
329 329
 		    $this->all_tracked[$id]['lastupdate'] = time();
330 330
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
331
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
331
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
332 332
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
333 333
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
334 334
 				    if ($globalDebug) echo "Check if aircraft is already in DB...";
@@ -336,37 +336,37 @@  discard block
 block discarded – undo
336 336
 				    $MarineLive = new MarineLive($this->db);
337 337
 				    if (isset($line['id'])) {
338 338
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
339
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
339
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
340 340
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
341 341
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
342
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
342
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
343 343
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
344 344
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
345
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
345
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
346 346
 				    } else $recent_ident = '';
347
-				    $MarineLive->db=null;
347
+				    $MarineLive->db = null;
348 348
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
349 349
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
350 350
 				} else $recent_ident = '';
351 351
 			    } else {
352 352
 				$recent_ident = '';
353
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
353
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
354 354
 			    }
355 355
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
356
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
356
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
357 357
 			    {
358 358
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
359 359
 				//adds the spotter data for the archive
360 360
 				    $highlight = '';
361
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
361
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
362 362
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
363 363
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
364 364
 					    $timeelapsed = microtime(true);
365 365
 					    $Marine = new Marine($this->db);
366
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
366
+					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
367 367
 					    $Marine->db = null;
368 368
 					    if ($globalDebug && isset($result)) echo $result."\n";
369
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
369
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
370 370
 					}
371 371
 				    }
372 372
 				    /*
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
407 407
 					$MarineLive = new MarineLive($this->db);
408 408
 					$MarineLive->deleteLiveMarineData();
409
-					$MarineLive->db=null;
409
+					$MarineLive->db = null;
410 410
 					if ($globalDebug) echo " Done\n";
411 411
 				    }
412 412
 				    $this->last_delete = time();
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
418 418
 				    if (isset($globalDaemon) && !$globalDaemon) {
419 419
 					$Marine = new Marine($this->db);
420
-					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
420
+					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
421 421
 					$Marine->db = null;
422 422
 				    }
423 423
 				}
@@ -432,20 +432,20 @@  discard block
 block discarded – undo
432 432
 		    $ignoreImport = false;
433 433
 
434 434
 		    if (!$ignoreImport) {
435
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
435
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
436 436
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
437 437
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
438 438
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
439 439
 					$timeelapsed = microtime(true);
440 440
 					$MarineLive = new MarineLive($this->db);
441
-					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
441
+					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
442 442
 					$MarineLive->db = null;
443 443
 					if ($globalDebug) echo $result."\n";
444
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
444
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
445 445
 				    }
446 446
 				}
447 447
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
448
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
448
+				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
449 449
 				}
450 450
 				$this->all_tracked[$id]['putinarchive'] = false;
451 451
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
 				$this->all_tracked[$id]['lastupdate'] = time();
507 507
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
508
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
508
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
509 509
 			//$this->del();
510 510
 			
511 511
 			
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT tracker_output.* FROM tracker_output";
6 6
 
7
-class Tracker{
7
+class Tracker {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 	* @return Array the SQL part
19 19
 	*/
20 20
 	
21
-	public function getFilter($filter = array(),$where = false,$and = false) {
21
+	public function getFilter($filter = array(), $where = false, $and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
23 23
 		$filters = array();
24 24
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
25 25
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
26 26
 				$filters = $globalStatsFilters[$globalFilterName];
27 27
 			} else {
28
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
28
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
29 29
 			}
30 30
 		}
31 31
 		if (isset($filter[0]['source'])) {
32
-			$filters = array_merge($filters,$filter);
32
+			$filters = array_merge($filters, $filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
35 35
 		$filter_query_join = '';
36 36
 		$filter_query_where = '';
37
-		foreach($filters as $flt) {
37
+		foreach ($filters as $flt) {
38 38
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
39 39
 				if (isset($flt['source'])) {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
41 41
 				} else {
42
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
42
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid";
43 43
 				}
44 44
 			}
45 45
 		}
46 46
 		if (isset($filter['source']) && !empty($filter['source'])) {
47
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
47
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
48 48
 		}
49 49
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
50 50
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74 74
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75 75
 		if ($filter_query_where != '') {
76
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
77 77
 		}
78 78
 		$filter_query = $filter_query_join.$filter_query_where;
79 79
 		return $filter_query;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	* @return Array the spotter information
89 89
 	*
90 90
 	*/
91
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
91
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
94 94
 		if (!is_string($query))
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 			$sth = $this->db->prepare($query.$limitQuery);
109 109
 			$sth->execute($params);
110 110
 		} catch (PDOException $e) {
111
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
111
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
112 112
 			exit();
113 113
 		}
114 114
 		
115 115
 		$num_rows = 0;
116 116
 		$spotter_array = array();
117
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
117
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
118 118
 		{
119 119
 			$num_rows++;
120 120
 			$temp_array = array();
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 				{
171 171
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
172 172
 				} else {
173
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
173
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
174 174
 				}
175 175
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
176
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
177
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
176
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
177
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
178 178
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
179 179
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
180 180
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
181 181
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
182
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
183
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
182
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
183
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
184 184
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
185 185
 					}
186 186
 				}
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 		{
218 218
 			$limit_array = explode(",", $limit);
219 219
 			
220
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
221
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
220
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
221
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
222 222
 			
223 223
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
224 224
 			{
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 			$orderby_query = " ORDER BY tracker_output.date DESC";
236 236
 		}
237 237
 
238
-		$query  = $global_query.$filter_query." ".$orderby_query;
238
+		$query = $global_query.$filter_query." ".$orderby_query;
239 239
 
240
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
240
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
241 241
 
242 242
 		return $spotter_array;
243 243
 	}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 		if ($id == '') return array();
257 257
 		$additional_query = "tracker_output.famtrackid = :id";
258 258
 		$query_values = array(':id' => $id);
259
-		$query  = $global_query." WHERE ".$additional_query." ";
260
-		$spotter_array = $this->getDataFromDB($query,$query_values);
259
+		$query = $global_query." WHERE ".$additional_query." ";
260
+		$spotter_array = $this->getDataFromDB($query, $query_values);
261 261
 		return $spotter_array;
262 262
 	}
263 263
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		$query_values = array();
277 277
 		$limit_query = '';
278 278
 		$additional_query = '';
279
-		$filter_query = $this->getFilter($filter,true,true);
279
+		$filter_query = $this->getFilter($filter, true, true);
280 280
 		if ($ident != "")
281 281
 		{
282 282
 			if (!is_string($ident))
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 		{
293 293
 			$limit_array = explode(",", $limit);
294 294
 			
295
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
296
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
295
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
296
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
297 297
 			
298 298
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
299 299
 			{
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		return $spotter_array;
318 318
 	}
319 319
 	
320
-	public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array())
320
+	public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array())
321 321
 	{
322 322
 		global $global_query, $globalTimezone, $globalDBdriver;
323 323
 		
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		$limit_query = '';
326 326
 		$additional_query = '';
327 327
 
328
-		$filter_query = $this->getFilter($filter,true,true);
328
+		$filter_query = $this->getFilter($filter, true, true);
329 329
 		
330 330
 		if ($date != "")
331 331
 		{
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 		{
352 352
 			$limit_array = explode(",", $limit);
353 353
 			
354
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
355
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
354
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
355
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
356 356
 			
357 357
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
358 358
 			{
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	* @return Array list of source name
384 384
 	*
385 385
 	*/
386
-	public function getAllSourceName($type = '',$filters = array())
386
+	public function getAllSourceName($type = '', $filters = array())
387 387
 	{
388
-		$filter_query = $this->getFilter($filters,true,true);
388
+		$filter_query = $this->getFilter($filters, true, true);
389 389
 		$query_values = array();
390
-		$query  = "SELECT DISTINCT tracker_output.source_name 
390
+		$query = "SELECT DISTINCT tracker_output.source_name 
391 391
 				FROM tracker_output".$filter_query." tracker_output.source_name <> ''";
392 392
 		if ($type != '') {
393 393
 			$query_values = array(':type' => $type);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		$source_array = array();
403 403
 		$temp_array = array();
404 404
 		
405
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
405
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
406 406
 		{
407 407
 			$temp_array['source_name'] = $row['source_name'];
408 408
 			$source_array[] = $temp_array;
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 	*/
420 420
 	public function getAllIdents($filters = array())
421 421
 	{
422
-		$filter_query = $this->getFilter($filters,true,true);
423
-		$query  = "SELECT DISTINCT tracker_output.ident
422
+		$filter_query = $this->getFilter($filters, true, true);
423
+		$query = "SELECT DISTINCT tracker_output.ident
424 424
 								FROM tracker_output".$filter_query." tracker_output.ident <> '' 
425 425
 								ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0";
426 426
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 		$ident_array = array();
431 431
 		$temp_array = array();
432 432
 		
433
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
433
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
434 434
 		{
435 435
 			$temp_array['ident'] = $row['ident'];
436 436
 			$ident_array[] = $temp_array;
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
 		} else $offset = '+00:00';
456 456
 
457 457
 		if ($globalDBdriver == 'mysql') {
458
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
458
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
459 459
 								FROM tracker_output
460 460
 								WHERE tracker_output.date <> '' 
461 461
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
462 462
 		} else {
463
-			$query  = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
463
+			$query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
464 464
 								FROM tracker_output
465 465
 								WHERE tracker_output.date <> '' 
466 466
 								ORDER BY tracker_output.date ASC LIMIT 0,200";
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		$date_array = array();
473 473
 		$temp_array = array();
474 474
 		
475
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
475
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
476 476
 		{
477 477
 			$temp_array['date'] = $row['date'];
478 478
 
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	* @return String success or false
492 492
 	*
493 493
 	*/	
494
-	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
494
+	public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL)
495 495
 	{
496 496
 
497 497
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
498
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
498
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident);
499 499
 
500 500
 		try {
501 501
 			$sth = $this->db->prepare($query);
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
520 520
 	{
521 521
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
522
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
522
+                $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
523 523
 
524 524
 		try {
525 525
 			$sth = $this->db->prepare($query);
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	* @param String $verticalrate vertival rate of flight
560 560
 	* @return String success or false
561 561
 	*/
562
-	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
562
+	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '')
563 563
 	{
564 564
 		global $globalURL;
565 565
 		
@@ -627,21 +627,21 @@  discard block
 block discarded – undo
627 627
 		}
628 628
 
629 629
     
630
-		if ($date == "" || strtotime($date) < time()-20*60)
630
+		if ($date == "" || strtotime($date) < time() - 20*60)
631 631
 		{
632 632
 			$date = date("Y-m-d H:i:s", time());
633 633
 		}
634 634
 
635
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
636
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
637
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
638
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
639
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
640
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
641
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
642
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
643
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
644
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
635
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
636
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
637
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
638
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
639
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
640
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
641
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
642
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
643
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
644
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
645 645
 	
646 646
                 if ($latitude == '' && $longitude == '') {
647 647
             		$latitude = 0;
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
             	}
650 650
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651 651
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
652
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
652
+                $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 653
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 654
 
655
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
655
+                $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type);
656 656
 
657 657
 		try {
658 658
 		        
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		global $globalDBdriver, $globalTimezone;
680 680
 		if ($globalDBdriver == 'mysql') {
681
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
681
+			$query = "SELECT tracker_output.ident FROM tracker_output 
682 682
 								WHERE tracker_output.ident = :ident 
683 683
 								AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
684 684
 								AND tracker_output.date < UTC_TIMESTAMP()";
685 685
 			$query_data = array(':ident' => $ident);
686 686
 		} else {
687
-			$query  = "SELECT tracker_output.ident FROM tracker_output 
687
+			$query = "SELECT tracker_output.ident FROM tracker_output 
688 688
 								WHERE tracker_output.ident = :ident 
689 689
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
690 690
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 		
694 694
 		$sth = $this->db->prepare($query);
695 695
 		$sth->execute($query_data);
696
-    		$ident_result='';
697
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
696
+    		$ident_result = '';
697
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
698 698
 		{
699 699
 			$ident_result = $row['ident'];
700 700
 		}
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 				return false;
721 721
 			} else {
722 722
 				$q_array = explode(" ", $q);
723
-				foreach ($q_array as $q_item){
724
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
723
+				foreach ($q_array as $q_item) {
724
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
725 725
 					$additional_query .= " AND (";
726 726
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%')";
727 727
 					$additional_query .= ")";
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 			}
730 730
 		}
731 731
 		if ($globalDBdriver == 'mysql') {
732
-			$query  = "SELECT tracker_output.* FROM tracker_output 
732
+			$query = "SELECT tracker_output.* FROM tracker_output 
733 733
 				WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
734 734
 				AND tracker_output.date < UTC_TIMESTAMP()";
735 735
 		} else {
736
-			$query  = "SELECT tracker_output.* FROM tracker_output 
736
+			$query = "SELECT tracker_output.* FROM tracker_output 
737 737
 				WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
738 738
 				AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
739 739
 		}
@@ -806,11 +806,11 @@  discard block
 block discarded – undo
806 806
 	* @return Array the callsign list
807 807
 	*
808 808
 	*/
809
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
809
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
810 810
 	{
811 811
 		global $globalDBdriver;
812
-		$filter_query = $this->getFilter($filters,true,true);
813
-		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
812
+		$filter_query = $this->getFilter($filters, true, true);
813
+		$query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
814 814
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
815 815
 		 if ($olderthanmonths > 0) {
816 816
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -824,28 +824,28 @@  discard block
 block discarded – undo
824 824
 		if ($year != '') {
825 825
 			if ($globalDBdriver == 'mysql') {
826 826
 				$query .= " AND YEAR(tracker_output.date) = :year";
827
-				$query_values = array_merge($query_values,array(':year' => $year));
827
+				$query_values = array_merge($query_values, array(':year' => $year));
828 828
 			} else {
829 829
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
830
-				$query_values = array_merge($query_values,array(':year' => $year));
830
+				$query_values = array_merge($query_values, array(':year' => $year));
831 831
 			}
832 832
 		}
833 833
 		if ($month != '') {
834 834
 			if ($globalDBdriver == 'mysql') {
835 835
 				$query .= " AND MONTH(tracker_output.date) = :month";
836
-				$query_values = array_merge($query_values,array(':month' => $month));
836
+				$query_values = array_merge($query_values, array(':month' => $month));
837 837
 			} else {
838 838
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
839
-				$query_values = array_merge($query_values,array(':month' => $month));
839
+				$query_values = array_merge($query_values, array(':month' => $month));
840 840
 			}
841 841
 		}
842 842
 		if ($day != '') {
843 843
 			if ($globalDBdriver == 'mysql') {
844 844
 				$query .= " AND DAY(tracker_output.date) = :day";
845
-				$query_values = array_merge($query_values,array(':day' => $day));
845
+				$query_values = array_merge($query_values, array(':day' => $day));
846 846
 			} else {
847 847
 				$query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day";
848
-				$query_values = array_merge($query_values,array(':day' => $day));
848
+				$query_values = array_merge($query_values, array(':day' => $day));
849 849
 			}
850 850
 		}
851 851
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 		$callsign_array = array();
858 858
 		$temp_array = array();
859 859
         
860
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
860
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
861 861
 		{
862 862
 			$temp_array['callsign_icao'] = $row['ident'];
863 863
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 		$date_array = array();
910 910
 		$temp_array = array();
911 911
         
912
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
912
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
913 913
 		{
914 914
 			$temp_array['date_name'] = $row['date_name'];
915 915
 			$temp_array['date_count'] = $row['date_count'];
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 			$datetime = new DateTime();
936 936
 			$offset = $datetime->format('P');
937 937
 		} else $offset = '+00:00';
938
-		$filter_query = $this->getFilter($filters,true,true);
938
+		$filter_query = $this->getFilter($filters, true, true);
939 939
 		if ($globalDBdriver == 'mysql') {
940 940
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
941 941
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 		$date_array = array();
957 957
 		$temp_array = array();
958 958
         
959
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
959
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
960 960
 		{
961 961
 			$temp_array['date_name'] = $row['date_name'];
962 962
 			$temp_array['date_count'] = $row['date_count'];
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 			$datetime = new DateTime();
982 982
 			$offset = $datetime->format('P');
983 983
 		} else $offset = '+00:00';
984
-		$filter_query = $this->getFilter($filters,true,true);
984
+		$filter_query = $this->getFilter($filters, true, true);
985 985
 		if ($globalDBdriver == 'mysql') {
986 986
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
987 987
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 		$date_array = array();
1003 1003
 		$temp_array = array();
1004 1004
         
1005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1006 1006
 		{
1007 1007
 			$temp_array['date_name'] = $row['date_name'];
1008 1008
 			$temp_array['date_count'] = $row['date_count'];
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 		$date_array = array();
1050 1050
 		$temp_array = array();
1051 1051
         
1052
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1052
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1053 1053
 		{
1054 1054
 			$temp_array['month_name'] = $row['month_name'];
1055 1055
 			$temp_array['year_name'] = $row['year_name'];
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 			$datetime = new DateTime();
1079 1079
 			$offset = $datetime->format('P');
1080 1080
 		} else $offset = '+00:00';
1081
-		$filter_query = $this->getFilter($filters,true,true);
1081
+		$filter_query = $this->getFilter($filters, true, true);
1082 1082
 		if ($globalDBdriver == 'mysql') {
1083 1083
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1084 1084
 								FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		$date_array = array();
1100 1100
 		$temp_array = array();
1101 1101
         
1102
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1103 1103
 		{
1104 1104
 			$temp_array['year_name'] = $row['year_name'];
1105 1105
 			$temp_array['month_name'] = $row['month_name'];
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 	* @return Array the hour list
1120 1120
 	*
1121 1121
 	*/
1122
-	public function countAllHours($orderby,$filters = array())
1122
+	public function countAllHours($orderby, $filters = array())
1123 1123
 	{
1124 1124
 		global $globalTimezone, $globalDBdriver;
1125 1125
 		if ($globalTimezone != '') {
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 		$hour_array = array();
1168 1168
 		$temp_array = array();
1169 1169
         
1170
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1170
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1171 1171
 		{
1172 1172
 			$temp_array['hour_name'] = $row['hour_name'];
1173 1173
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1189,8 +1189,8 @@  discard block
 block discarded – undo
1189 1189
 	public function countAllHoursByDate($date, $filters = array())
1190 1190
 	{
1191 1191
 		global $globalTimezone, $globalDBdriver;
1192
-		$filter_query = $this->getFilter($filters,true,true);
1193
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1192
+		$filter_query = $this->getFilter($filters, true, true);
1193
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1194 1194
 		if ($globalTimezone != '') {
1195 1195
 			date_default_timezone_set($globalTimezone);
1196 1196
 			$datetime = new DateTime($date);
@@ -1198,12 +1198,12 @@  discard block
 block discarded – undo
1198 1198
 		} else $offset = '+00:00';
1199 1199
 
1200 1200
 		if ($globalDBdriver == 'mysql') {
1201
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1201
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1202 1202
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date
1203 1203
 								GROUP BY hour_name 
1204 1204
 								ORDER BY hour_name ASC";
1205 1205
 		} else {
1206
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1206
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1207 1207
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1208 1208
 								GROUP BY hour_name 
1209 1209
 								ORDER BY hour_name ASC";
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 		$hour_array = array();
1216 1216
 		$temp_array = array();
1217 1217
         
1218
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1218
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1219 1219
 		{
1220 1220
 			$temp_array['hour_name'] = $row['hour_name'];
1221 1221
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 	public function countAllHoursByIdent($ident, $filters = array())
1238 1238
 	{
1239 1239
 		global $globalTimezone, $globalDBdriver;
1240
-		$filter_query = $this->getFilter($filters,true,true);
1241
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1240
+		$filter_query = $this->getFilter($filters, true, true);
1241
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1242 1242
 		if ($globalTimezone != '') {
1243 1243
 			date_default_timezone_set($globalTimezone);
1244 1244
 			$datetime = new DateTime();
@@ -1246,12 +1246,12 @@  discard block
 block discarded – undo
1246 1246
 		} else $offset = '+00:00';
1247 1247
 
1248 1248
 		if ($globalDBdriver == 'mysql') {
1249
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1249
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1250 1250
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1251 1251
 								GROUP BY hour_name 
1252 1252
 								ORDER BY hour_name ASC";
1253 1253
 		} else {
1254
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1254
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1255 1255
 								FROM tracker_output".$filter_query." tracker_output.ident = :ident 
1256 1256
 								GROUP BY hour_name 
1257 1257
 								ORDER BY hour_name ASC";
@@ -1259,12 +1259,12 @@  discard block
 block discarded – undo
1259 1259
       
1260 1260
 		
1261 1261
 		$sth = $this->db->prepare($query);
1262
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1262
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1263 1263
       
1264 1264
 		$hour_array = array();
1265 1265
 		$temp_array = array();
1266 1266
         
1267
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1267
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1268 1268
 		{
1269 1269
 			$temp_array['hour_name'] = $row['hour_name'];
1270 1270
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1283,32 +1283,32 @@  discard block
 block discarded – undo
1283 1283
 	* @return Integer the number of flights
1284 1284
 	*
1285 1285
 	*/
1286
-	public function countOverallTracked($filters = array(),$year = '',$month = '')
1286
+	public function countOverallTracked($filters = array(), $year = '', $month = '')
1287 1287
 	{
1288 1288
 		global $globalDBdriver;
1289
-		$queryi  = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1289
+		$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output";
1290 1290
 		$query_values = array();
1291 1291
 		$query = '';
1292 1292
 		if ($year != '') {
1293 1293
 			if ($globalDBdriver == 'mysql') {
1294 1294
 				$query .= " AND YEAR(tracker_output.date) = :year";
1295
-				$query_values = array_merge($query_values,array(':year' => $year));
1295
+				$query_values = array_merge($query_values, array(':year' => $year));
1296 1296
 			} else {
1297 1297
 				$query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year";
1298
-				$query_values = array_merge($query_values,array(':year' => $year));
1298
+				$query_values = array_merge($query_values, array(':year' => $year));
1299 1299
 			}
1300 1300
 		}
1301 1301
 		if ($month != '') {
1302 1302
 			if ($globalDBdriver == 'mysql') {
1303 1303
 				$query .= " AND MONTH(tracker_output.date) = :month";
1304
-				$query_values = array_merge($query_values,array(':month' => $month));
1304
+				$query_values = array_merge($query_values, array(':month' => $month));
1305 1305
 			} else {
1306 1306
 				$query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month";
1307
-				$query_values = array_merge($query_values,array(':month' => $month));
1307
+				$query_values = array_merge($query_values, array(':month' => $month));
1308 1308
 			}
1309 1309
 		}
1310 1310
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1311
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1311
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1312 1312
 		
1313 1313
 		$sth = $this->db->prepare($queryi);
1314 1314
 		$sth->execute($query_values);
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 	public function countAllHoursFromToday($filters = array())
1326 1326
 	{
1327 1327
 		global $globalTimezone, $globalDBdriver;
1328
-		$filter_query = $this->getFilter($filters,true,true);
1328
+		$filter_query = $this->getFilter($filters, true, true);
1329 1329
 		if ($globalTimezone != '') {
1330 1330
 			date_default_timezone_set($globalTimezone);
1331 1331
 			$datetime = new DateTime();
@@ -1333,12 +1333,12 @@  discard block
 block discarded – undo
1333 1333
 		} else $offset = '+00:00';
1334 1334
 
1335 1335
 		if ($globalDBdriver == 'mysql') {
1336
-			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1336
+			$query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1337 1337
 								FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE()
1338 1338
 								GROUP BY hour_name 
1339 1339
 								ORDER BY hour_name ASC";
1340 1340
 		} else {
1341
-			$query  = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1341
+			$query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1342 1342
 								FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1343 1343
 								GROUP BY hour_name 
1344 1344
 								ORDER BY hour_name ASC";
@@ -1350,7 +1350,7 @@  discard block
 block discarded – undo
1350 1350
 		$hour_array = array();
1351 1351
 		$temp_array = array();
1352 1352
         
1353
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1353
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1354 1354
 		{
1355 1355
 			$temp_array['hour_name'] = $row['hour_name'];
1356 1356
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1369,9 +1369,9 @@  discard block
 block discarded – undo
1369 1369
 	*/
1370 1370
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1371 1371
 	{
1372
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
1372
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
1373 1373
 
1374
-		$query  = "SELECT tracker_output.tracker_id
1374
+		$query = "SELECT tracker_output.tracker_id
1375 1375
 				FROM tracker_output 
1376 1376
 				WHERE tracker_output.famtrackid = '".$famtrackid."'";
1377 1377
         
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 		$sth = $this->db->prepare($query);
1380 1380
 		$sth->execute();
1381 1381
 
1382
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1382
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1383 1383
 		{
1384 1384
 			return $row['tracker_id'];
1385 1385
 		}
@@ -1404,23 +1404,23 @@  discard block
 block discarded – undo
1404 1404
 		}
1405 1405
 		
1406 1406
 		$current_date = date("Y-m-d H:i:s");
1407
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1407
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1408 1408
 		
1409 1409
 		$diff = abs(strtotime($current_date) - strtotime($date));
1410 1410
 
1411
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1411
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1412 1412
 		$years = $time_array['years'];
1413 1413
 		
1414
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1414
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1415 1415
 		$months = $time_array['months'];
1416 1416
 		
1417
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1417
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1418 1418
 		$days = $time_array['days'];
1419
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1419
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1420 1420
 		$hours = $time_array['hours'];
1421
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1421
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1422 1422
 		$minutes = $time_array['minutes'];
1423
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1423
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1424 1424
 		
1425 1425
 		return $time_array;
1426 1426
 	}
@@ -1443,63 +1443,63 @@  discard block
 block discarded – undo
1443 1443
 			$temp_array['direction_degree'] = $direction;
1444 1444
 			$temp_array['direction_shortname'] = "N";
1445 1445
 			$temp_array['direction_fullname'] = "North";
1446
-		} elseif ($direction >= 22.5 && $direction < 45){
1446
+		} elseif ($direction >= 22.5 && $direction < 45) {
1447 1447
 			$temp_array['direction_degree'] = $direction;
1448 1448
 			$temp_array['direction_shortname'] = "NNE";
1449 1449
 			$temp_array['direction_fullname'] = "North-Northeast";
1450
-		} elseif ($direction >= 45 && $direction < 67.5){
1450
+		} elseif ($direction >= 45 && $direction < 67.5) {
1451 1451
 			$temp_array['direction_degree'] = $direction;
1452 1452
 			$temp_array['direction_shortname'] = "NE";
1453 1453
 			$temp_array['direction_fullname'] = "Northeast";
1454
-		} elseif ($direction >= 67.5 && $direction < 90){
1454
+		} elseif ($direction >= 67.5 && $direction < 90) {
1455 1455
 			$temp_array['direction_degree'] = $direction;
1456 1456
 			$temp_array['direction_shortname'] = "ENE";
1457 1457
 			$temp_array['direction_fullname'] = "East-Northeast";
1458
-		} elseif ($direction >= 90 && $direction < 112.5){
1458
+		} elseif ($direction >= 90 && $direction < 112.5) {
1459 1459
 			$temp_array['direction_degree'] = $direction;
1460 1460
 			$temp_array['direction_shortname'] = "E";
1461 1461
 			$temp_array['direction_fullname'] = "East";
1462
-		} elseif ($direction >= 112.5 && $direction < 135){
1462
+		} elseif ($direction >= 112.5 && $direction < 135) {
1463 1463
 			$temp_array['direction_degree'] = $direction;
1464 1464
 			$temp_array['direction_shortname'] = "ESE";
1465 1465
 			$temp_array['direction_fullname'] = "East-Southeast";
1466
-		} elseif ($direction >= 135 && $direction < 157.5){
1466
+		} elseif ($direction >= 135 && $direction < 157.5) {
1467 1467
 			$temp_array['direction_degree'] = $direction;
1468 1468
 			$temp_array['direction_shortname'] = "SE";
1469 1469
 			$temp_array['direction_fullname'] = "Southeast";
1470
-		} elseif ($direction >= 157.5 && $direction < 180){
1470
+		} elseif ($direction >= 157.5 && $direction < 180) {
1471 1471
 			$temp_array['direction_degree'] = $direction;
1472 1472
 			$temp_array['direction_shortname'] = "SSE";
1473 1473
 			$temp_array['direction_fullname'] = "South-Southeast";
1474
-		} elseif ($direction >= 180 && $direction < 202.5){
1474
+		} elseif ($direction >= 180 && $direction < 202.5) {
1475 1475
 			$temp_array['direction_degree'] = $direction;
1476 1476
 			$temp_array['direction_shortname'] = "S";
1477 1477
 			$temp_array['direction_fullname'] = "South";
1478
-		} elseif ($direction >= 202.5 && $direction < 225){
1478
+		} elseif ($direction >= 202.5 && $direction < 225) {
1479 1479
 			$temp_array['direction_degree'] = $direction;
1480 1480
 			$temp_array['direction_shortname'] = "SSW";
1481 1481
 			$temp_array['direction_fullname'] = "South-Southwest";
1482
-		} elseif ($direction >= 225 && $direction < 247.5){
1482
+		} elseif ($direction >= 225 && $direction < 247.5) {
1483 1483
 			$temp_array['direction_degree'] = $direction;
1484 1484
 			$temp_array['direction_shortname'] = "SW";
1485 1485
 			$temp_array['direction_fullname'] = "Southwest";
1486
-		} elseif ($direction >= 247.5 && $direction < 270){
1486
+		} elseif ($direction >= 247.5 && $direction < 270) {
1487 1487
 			$temp_array['direction_degree'] = $direction;
1488 1488
 			$temp_array['direction_shortname'] = "WSW";
1489 1489
 			$temp_array['direction_fullname'] = "West-Southwest";
1490
-		} elseif ($direction >= 270 && $direction < 292.5){
1490
+		} elseif ($direction >= 270 && $direction < 292.5) {
1491 1491
 			$temp_array['direction_degree'] = $direction;
1492 1492
 			$temp_array['direction_shortname'] = "W";
1493 1493
 			$temp_array['direction_fullname'] = "West";
1494
-		} elseif ($direction >= 292.5 && $direction < 315){
1494
+		} elseif ($direction >= 292.5 && $direction < 315) {
1495 1495
 			$temp_array['direction_degree'] = $direction;
1496 1496
 			$temp_array['direction_shortname'] = "WNW";
1497 1497
 			$temp_array['direction_fullname'] = "West-Northwest";
1498
-		} elseif ($direction >= 315 && $direction < 337.5){
1498
+		} elseif ($direction >= 315 && $direction < 337.5) {
1499 1499
 			$temp_array['direction_degree'] = $direction;
1500 1500
 			$temp_array['direction_shortname'] = "NW";
1501 1501
 			$temp_array['direction_fullname'] = "Northwest";
1502
-		} elseif ($direction >= 337.5 && $direction < 360){
1502
+		} elseif ($direction >= 337.5 && $direction < 360) {
1503 1503
 			$temp_array['direction_degree'] = $direction;
1504 1504
 			$temp_array['direction_shortname'] = "NNW";
1505 1505
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1516,11 +1516,11 @@  discard block
 block discarded – undo
1516 1516
 	* @param Float $longitude longitute of the flight
1517 1517
 	* @return String the countrie
1518 1518
 	*/
1519
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1519
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1520 1520
 	{
1521 1521
 		global $globalDBdriver, $globalDebug;
1522
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1523
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1522
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1523
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1524 1524
 	
1525 1525
 		$Connection = new Connection($this->db);
1526 1526
 		if (!$Connection->tableExists('countries')) return '';
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
 	public function getCountryFromISO2($iso2)
1561 1561
 	{
1562 1562
 		global $globalDBdriver, $globalDebug;
1563
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1563
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1564 1564
 	
1565 1565
 		$Connection = new Connection($this->db);
1566 1566
 		if (!$Connection->tableExists('countries')) return '';
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 		
1609 1609
 		$bitly_data = json_decode($bitly_data);
1610 1610
 		$bitly_url = '';
1611
-		if ($bitly_data->status_txt = "OK"){
1611
+		if ($bitly_data->status_txt = "OK") {
1612 1612
 			$bitly_url = $bitly_data->data->url;
1613 1613
 		}
1614 1614
 
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
 
1619 1619
 	public function getOrderBy()
1620 1620
 	{
1621
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1621
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1622 1622
 		
1623 1623
 		return $orderby;
1624 1624
 		
Please login to merge, or discard this patch.