Completed
Push — master ( 8d4415...1bf6ad )
by Yannick
72:06 queued 32:47
created
require/class.SpotterLive.php 1 patch
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	}
137 137
 
138 138
 	/**
139
-	* Gets all the spotter information based on the latest data entry
140
-	*
141
-	* @return Array the spotter information
142
-	*
143
-	*/
139
+	 * Gets all the spotter information based on the latest data entry
140
+	 *
141
+	 * @return Array the spotter information
142
+	 *
143
+	 */
144 144
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
145 145
 	{
146 146
 		global $globalDBdriver, $globalLiveInterval;
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	}
184 184
 
185 185
 	/**
186
-	* Gets Minimal Live Spotter data
187
-	*
188
-	* @return Array the spotter information
189
-	*
190
-	*/
186
+	 * Gets Minimal Live Spotter data
187
+	 *
188
+	 * @return Array the spotter information
189
+	 *
190
+	 */
191 191
 	public function getMinLiveSpotterData($filter = array())
192 192
 	{
193 193
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
 	}
225 225
 
226 226
 	/**
227
-	* Gets Minimal Live Spotter data since xx seconds
228
-	*
229
-	* @return Array the spotter information
230
-	*
231
-	*/
227
+	 * Gets Minimal Live Spotter data since xx seconds
228
+	 *
229
+	 * @return Array the spotter information
230
+	 *
231
+	 */
232 232
 	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false, $id = '')
233 233
 	{
234 234
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
 	}
321 321
 
322 322
 	/**
323
-	* Gets number of latest data entry
324
-	*
325
-	* @return String number of entry
326
-	*
327
-	*/
323
+	 * Gets number of latest data entry
324
+	 *
325
+	 * @return String number of entry
326
+	 *
327
+	 */
328 328
 	public function getLiveSpotterCount($filter = array())
329 329
 	{
330 330
 		global $globalDBdriver, $globalLiveInterval;
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 	}
352 352
 
353 353
 	/**
354
-	* Gets all the spotter information based on the latest data entry and coord
355
-	*
356
-	* @return Array the spotter information
357
-	*
358
-	*/
354
+	 * Gets all the spotter information based on the latest data entry and coord
355
+	 *
356
+	 * @return Array the spotter information
357
+	 *
358
+	 */
359 359
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
360 360
 	{
361 361
 		global $globalDBdriver, $globalLiveInterval;
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
 	}
381 381
 
382 382
 	/**
383
-	* Gets all the spotter information based on the latest data entry and coord
384
-	*
385
-	* @return Array the spotter information
386
-	*
387
-	*/
383
+	 * Gets all the spotter information based on the latest data entry and coord
384
+	 *
385
+	 * @return Array the spotter information
386
+	 *
387
+	 */
388 388
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
389 389
 	{
390 390
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
 	}
450 450
 
451 451
 	/**
452
-	* Gets all the spotter information based on a user's latitude and longitude
453
-	*
454
-	* @return Array the spotter information
455
-	*
456
-	*/
452
+	 * Gets all the spotter information based on a user's latitude and longitude
453
+	 *
454
+	 * @return Array the spotter information
455
+	 *
456
+	 */
457 457
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
458 458
 	{
459 459
 		$Spotter = new Spotter($this->db);
@@ -463,98 +463,98 @@  discard block
 block discarded – undo
463 463
 				return false;
464 464
 			}
465 465
 		}
466
-        if ($lng != '')
467
-                {
468
-                        if (!is_numeric($lng))
469
-                        {
470
-                                return false;
471
-                        }
472
-                }
473
-
474
-                if ($radius != '')
475
-                {
476
-                        if (!is_numeric($radius))
477
-                        {
478
-                                return false;
479
-                        }
480
-                }
466
+		if ($lng != '')
467
+				{
468
+						if (!is_numeric($lng))
469
+						{
470
+								return false;
471
+						}
472
+				}
473
+
474
+				if ($radius != '')
475
+				{
476
+						if (!is_numeric($radius))
477
+						{
478
+								return false;
479
+						}
480
+				}
481 481
 		$additional_query = '';
482
-        if ($interval != '')
483
-                {
484
-                        if (!is_string($interval))
485
-                        {
486
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
487
-			        return false;
488
-                        } else {
489
-                if ($interval == '1m')
490
-                {
491
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
492
-                } else if ($interval == '15m'){
493
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
494
-                } 
495
-            }
496
-                } else {
497
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
498
-        }
499
-
500
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
482
+		if ($interval != '')
483
+				{
484
+						if (!is_string($interval))
485
+						{
486
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
487
+					return false;
488
+						} else {
489
+				if ($interval == '1m')
490
+				{
491
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
492
+				} else if ($interval == '15m'){
493
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
494
+				} 
495
+			}
496
+				} else {
497
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
498
+		}
499
+
500
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
501 501
                    WHERE spotter_live.latitude <> '' 
502 502
                                    AND spotter_live.longitude <> '' 
503 503
                    ".$additional_query."
504 504
                    HAVING distance < :radius  
505 505
                                    ORDER BY distance";
506 506
 
507
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
507
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
508 508
 
509
-                return $spotter_array;
510
-        }
509
+				return $spotter_array;
510
+		}
511 511
 
512 512
     
513
-        /**
514
-	* Gets all the spotter information based on a particular callsign
515
-	*
516
-	* @return Array the spotter information
517
-	*
518
-	*/
513
+		/**
514
+		 * Gets all the spotter information based on a particular callsign
515
+		 *
516
+		 * @return Array the spotter information
517
+		 *
518
+		 */
519 519
 	public function getLastLiveSpotterDataByIdent($ident)
520 520
 	{
521 521
 		$Spotter = new Spotter($this->db);
522 522
 		date_default_timezone_set('UTC');
523 523
 
524 524
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
525
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
525
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526 526
 
527 527
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
528 528
 
529 529
 		return $spotter_array;
530 530
 	}
531 531
 
532
-        /**
533
-	* Gets all the spotter information based on a particular callsign
534
-	*
535
-	* @return Array the spotter information
536
-	*
537
-	*/
532
+		/**
533
+		 * Gets all the spotter information based on a particular callsign
534
+		 *
535
+		 * @return Array the spotter information
536
+		 *
537
+		 */
538 538
 	public function getDateLiveSpotterDataByIdent($ident,$date)
539 539
 	{
540 540
 		$Spotter = new Spotter($this->db);
541 541
 		date_default_timezone_set('UTC');
542 542
 
543 543
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
544
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
544
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
545 545
 
546
-                $date = date('c',$date);
546
+				$date = date('c',$date);
547 547
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
548 548
 
549 549
 		return $spotter_array;
550 550
 	}
551 551
 
552
-        /**
553
-	* Gets last spotter information based on a particular callsign
554
-	*
555
-	* @return Array the spotter information
556
-	*
557
-	*/
552
+		/**
553
+		 * Gets last spotter information based on a particular callsign
554
+		 *
555
+		 * @return Array the spotter information
556
+		 *
557
+		 */
558 558
 	public function getLastLiveSpotterDataById($id)
559 559
 	{
560 560
 		$Spotter = new Spotter($this->db);
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
 		return $spotter_array;
566 566
 	}
567 567
 
568
-        /**
569
-	* Gets last spotter information based on a particular callsign
570
-	*
571
-	* @return Array the spotter information
572
-	*
573
-	*/
568
+		/**
569
+		 * Gets last spotter information based on a particular callsign
570
+		 *
571
+		 * @return Array the spotter information
572
+		 *
573
+		 */
574 574
 	public function getDateLiveSpotterDataById($id,$date)
575 575
 	{
576 576
 		$Spotter = new Spotter($this->db);
@@ -583,21 +583,21 @@  discard block
 block discarded – undo
583 583
 		return $spotter_array;
584 584
 	}
585 585
 
586
-        /**
587
-	* Gets altitude information based on a particular callsign
588
-	*
589
-	* @return Array the spotter information
590
-	*
591
-	*/
586
+		/**
587
+		 * Gets altitude information based on a particular callsign
588
+		 *
589
+		 * @return Array the spotter information
590
+		 *
591
+		 */
592 592
 	public function getAltitudeLiveSpotterDataByIdent($ident)
593 593
 	{
594 594
 
595 595
 		date_default_timezone_set('UTC');
596 596
 
597 597
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
598
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
598
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
599 599
 
600
-    		try {
600
+			try {
601 601
 			
602 602
 			$sth = $this->db->prepare($query);
603 603
 			$sth->execute(array(':ident' => $ident));
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
 		return $spotter_array;
611 611
 	}
612 612
 
613
-        /**
614
-	* Gets all the spotter information based on a particular id
615
-	*
616
-	* @return Array the spotter information
617
-	*
618
-	*/
613
+		/**
614
+		 * Gets all the spotter information based on a particular id
615
+		 *
616
+		 * @return Array the spotter information
617
+		 *
618
+		 */
619 619
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
620 620
 	{
621 621
 		global $globalDBdriver, $globalLiveInterval;
@@ -643,18 +643,18 @@  discard block
 block discarded – undo
643 643
 		return $spotter_array;
644 644
 	}
645 645
 
646
-        /**
647
-	* Gets all the spotter information based on a particular ident
648
-	*
649
-	* @return Array the spotter information
650
-	*
651
-	*/
646
+		/**
647
+		 * Gets all the spotter information based on a particular ident
648
+		 *
649
+		 * @return Array the spotter information
650
+		 *
651
+		 */
652 652
 	public function getAllLiveSpotterDataByIdent($ident)
653 653
 	{
654 654
 		date_default_timezone_set('UTC');
655 655
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
656 656
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
657
-    		try {
657
+			try {
658 658
 			
659 659
 			$sth = $this->db->prepare($query);
660 660
 			$sth->execute(array(':ident' => $ident));
@@ -668,23 +668,23 @@  discard block
 block discarded – undo
668 668
 
669 669
 
670 670
 	/**
671
-	* Deletes all info in the table
672
-	*
673
-	* @return String success or false
674
-	*
675
-	*/
671
+	 * Deletes all info in the table
672
+	 *
673
+	 * @return String success or false
674
+	 *
675
+	 */
676 676
 	public function deleteLiveSpotterData()
677 677
 	{
678 678
 		global $globalDBdriver;
679 679
 		if ($globalDBdriver == 'mysql') {
680 680
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
681 681
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
682
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
682
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
683 683
 		} else {
684 684
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
685 685
 		}
686 686
         
687
-    		try {
687
+			try {
688 688
 			
689 689
 			$sth = $this->db->prepare($query);
690 690
 			$sth->execute();
@@ -696,18 +696,18 @@  discard block
 block discarded – undo
696 696
 	}
697 697
 
698 698
 	/**
699
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
700
-	*
701
-	* @return String success or false
702
-	*
703
-	*/
699
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
700
+	 *
701
+	 * @return String success or false
702
+	 *
703
+	 */
704 704
 	public function deleteLiveSpotterDataNotUpdated()
705 705
 	{
706 706
 		global $globalDBdriver, $globalDebug;
707 707
 		if ($globalDBdriver == 'mysql') {
708 708
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
709
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
710
-    			try {
709
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
710
+				try {
711 711
 				
712 712
 				$sth = $this->db->prepare($query);
713 713
 				$sth->execute();
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 				return "error";
716 716
 			}
717 717
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
718
-                        $i = 0;
719
-                        $j =0;
718
+						$i = 0;
719
+						$j =0;
720 720
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
721 721
 			foreach($all as $row)
722 722
 			{
@@ -724,20 +724,20 @@  discard block
 block discarded – undo
724 724
 				$j++;
725 725
 				if ($j == 30) {
726 726
 					if ($globalDebug) echo ".";
727
-				    	try {
727
+						try {
728 728
 						
729 729
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
730 730
 						$sth->execute();
731 731
 					} catch(PDOException $e) {
732 732
 						return "error";
733 733
 					}
734
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
735
-                                	$j = 0;
734
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
735
+									$j = 0;
736 736
 				}
737 737
 				$query_delete .= "'".$row['flightaware_id']."',";
738 738
 			}
739 739
 			if ($i > 0) {
740
-    				try {
740
+					try {
741 741
 					
742 742
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
743 743
 					$sth->execute();
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
 			return "success";
749 749
 		} elseif ($globalDBdriver == 'pgsql') {
750 750
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
751
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
752
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
753
-    			try {
751
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
752
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
753
+				try {
754 754
 				
755 755
 				$sth = $this->db->prepare($query);
756 756
 				$sth->execute();
@@ -794,17 +794,17 @@  discard block
 block discarded – undo
794 794
 	}
795 795
 
796 796
 	/**
797
-	* Deletes all info in the table for an ident
798
-	*
799
-	* @return String success or false
800
-	*
801
-	*/
797
+	 * Deletes all info in the table for an ident
798
+	 *
799
+	 * @return String success or false
800
+	 *
801
+	 */
802 802
 	public function deleteLiveSpotterDataByIdent($ident)
803 803
 	{
804 804
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
805 805
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
806 806
         
807
-    		try {
807
+			try {
808 808
 			
809 809
 			$sth = $this->db->prepare($query);
810 810
 			$sth->execute(array(':ident' => $ident));
@@ -816,17 +816,17 @@  discard block
 block discarded – undo
816 816
 	}
817 817
 
818 818
 	/**
819
-	* Deletes all info in the table for an id
820
-	*
821
-	* @return String success or false
822
-	*
823
-	*/
819
+	 * Deletes all info in the table for an id
820
+	 *
821
+	 * @return String success or false
822
+	 *
823
+	 */
824 824
 	public function deleteLiveSpotterDataById($id)
825 825
 	{
826 826
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
827 827
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
828 828
         
829
-    		try {
829
+			try {
830 830
 			
831 831
 			$sth = $this->db->prepare($query);
832 832
 			$sth->execute(array(':id' => $id));
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
 
840 840
 
841 841
 	/**
842
-	* Gets the aircraft ident within the last hour
843
-	*
844
-	* @return String the ident
845
-	*
846
-	*/
842
+	 * Gets the aircraft ident within the last hour
843
+	 *
844
+	 * @return String the ident
845
+	 *
846
+	 */
847 847
 	public function getIdentFromLastHour($ident)
848 848
 	{
849 849
 		global $globalDBdriver, $globalTimezone;
@@ -869,14 +869,14 @@  discard block
 block discarded – undo
869 869
 			$ident_result = $row['ident'];
870 870
 		}
871 871
 		return $ident_result;
872
-        }
872
+		}
873 873
 
874 874
 	/**
875
-	* Check recent aircraft
876
-	*
877
-	* @return String the ident
878
-	*
879
-	*/
875
+	 * Check recent aircraft
876
+	 *
877
+	 * @return String the ident
878
+	 *
879
+	 */
880 880
 	public function checkIdentRecent($ident)
881 881
 	{
882 882
 		global $globalDBdriver, $globalTimezone;
@@ -902,14 +902,14 @@  discard block
 block discarded – undo
902 902
 			$ident_result = $row['flightaware_id'];
903 903
 		}
904 904
 		return $ident_result;
905
-        }
905
+		}
906 906
 
907 907
 	/**
908
-	* Check recent aircraft by id
909
-	*
910
-	* @return String the ident
911
-	*
912
-	*/
908
+	 * Check recent aircraft by id
909
+	 *
910
+	 * @return String the ident
911
+	 *
912
+	 */
913 913
 	public function checkIdRecent($id)
914 914
 	{
915 915
 		global $globalDBdriver, $globalTimezone;
@@ -935,14 +935,14 @@  discard block
 block discarded – undo
935 935
 			$ident_result = $row['flightaware_id'];
936 936
 		}
937 937
 		return $ident_result;
938
-        }
938
+		}
939 939
 
940 940
 	/**
941
-	* Check recent aircraft by ModeS
942
-	*
943
-	* @return String the ModeS
944
-	*
945
-	*/
941
+	 * Check recent aircraft by ModeS
942
+	 *
943
+	 * @return String the ModeS
944
+	 *
945
+	 */
946 946
 	public function checkModeSRecent($modes)
947 947
 	{
948 948
 		global $globalDBdriver, $globalTimezone;
@@ -972,11 +972,11 @@  discard block
 block discarded – undo
972 972
 	}
973 973
 
974 974
 	/**
975
-	* Gets the aircraft data from the last 20 seconds
976
-	*
977
-	* @return Array the spotter data
978
-	*
979
-	*/
975
+	 * Gets the aircraft data from the last 20 seconds
976
+	 *
977
+	 * @return Array the spotter data
978
+	 *
979
+	 */
980 980
 	public function getRealTimeData($q = '')
981 981
 	{
982 982
 		global $globalDBdriver;
@@ -1018,16 +1018,16 @@  discard block
 block discarded – undo
1018 1018
 	}
1019 1019
 
1020 1020
 	/**
1021
-	* Adds a new spotter data
1022
-	*
1023
-	* @param String $flightaware_id the ID from flightaware
1024
-	* @param String $ident the flight ident
1025
-	* @param String $aircraft_icao the aircraft type
1026
-	* @param String $departure_airport_icao the departure airport
1027
-	* @param String $arrival_airport_icao the arrival airport
1028
-	* @return String success or false
1029
-	*
1030
-	*/
1021
+	 * Adds a new spotter data
1022
+	 *
1023
+	 * @param String $flightaware_id the ID from flightaware
1024
+	 * @param String $ident the flight ident
1025
+	 * @param String $aircraft_icao the aircraft type
1026
+	 * @param String $departure_airport_icao the departure airport
1027
+	 * @param String $arrival_airport_icao the arrival airport
1028
+	 * @return String success or false
1029
+	 *
1030
+	 */
1031 1031
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1032 1032
 	{
1033 1033
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1170,10 +1170,10 @@  discard block
 block discarded – undo
1170 1170
 		$arrival_airport_country = '';
1171 1171
 		
1172 1172
             	
1173
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1174
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1175
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1176
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1173
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1174
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1175
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1176
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1177 1177
 		
1178 1178
 		$query = '';
1179 1179
 		if ($globalArchive) {
@@ -1194,10 +1194,10 @@  discard block
 block discarded – undo
1194 1194
 			return "error : ".$e->getMessage();
1195 1195
 		}
1196 1196
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1197
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1198
-		    $SpotterArchive = new SpotterArchive($this->db);
1199
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1200
-		    if ($globalDebug) echo $result.')';
1197
+			if ($globalDebug) echo '(Add to SBS archive : ';
1198
+			$SpotterArchive = new SpotterArchive($this->db);
1199
+			$result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1200
+			if ($globalDebug) echo $result.')';
1201 1201
 		} elseif ($globalDebug && $putinarchive !== true) {
1202 1202
 			echo '(Not adding to archive)';
1203 1203
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
airspace-geojson.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 $Connection = new Connection();
12 12
 
13 13
 if (!$Connection->tableExists('airspace')) {
14
-    die;
14
+	die;
15 15
 }
16 16
 
17 17
 if (isset($_GET['coord'])) 
18 18
 {
19 19
 	$coords = explode(',',$_GET['coord']);
20
-        if ($globalDBdriver == 'mysql') {
20
+		if ($globalDBdriver == 'mysql') {
21 21
 		$query = "SELECT *, ST_AsWKB(SHAPE) AS wkb FROM airspace WHERE ST_Intersects(SHAPE, ST_Envelope(linestring(point(:minlon,:minlat), point(:maxlon,:maxlat))))";
22 22
 		try {
23 23
 			$sth = $Connection->db->prepare($query);
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		}
38 38
 	}
39 39
 } else {
40
-        if ($globalDBdriver == 'mysql') {
40
+		if ($globalDBdriver == 'mysql') {
41 41
 		$query = "SELECT *, ST_AsWKB(SHAPE) AS wkb FROM airspace";
42 42
 	} else {
43 43
 		$query = "SELECT *, ST_AsBinary(wkb_geometry,'NDR') AS wkb FROM airspace";
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 }
52 52
 
53 53
 $geojson = array(
54
-    'type' => 'FeatureCollection',
55
-    'features' => array()
54
+	'type' => 'FeatureCollection',
55
+	'features' => array()
56 56
 );
57 57
 
58 58
 while ($row = $sth->fetch(PDO::FETCH_ASSOC))
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		}
116 116
 		if (isset($properties['type']) && $properties['type'] != '') {
117 117
 			$feature = array(
118
-			    'type' => 'Feature',
119
-			    'geometry' => json_decode($geom->out('json')),
120
-			    'properties' => $properties
118
+				'type' => 'Feature',
119
+				'geometry' => json_decode($geom->out('json')),
120
+				'properties' => $properties
121 121
 			);
122 122
 			array_push($geojson['features'], $feature);
123 123
 		}
Please login to merge, or discard this patch.
header.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40 40
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
41
+		return strpos($key,'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
@@ -404,34 +404,34 @@  discard block
 block discarded – undo
404 404
 
405 405
       <ul class="nav navbar-nav">
406 406
 <?php
407
-    if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
407
+	if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
408 408
 ?>
409 409
     <li><a href="<?php print $globalURL; ?>/news"><?php echo _("News"); ?></a></li>
410 410
 <?php
411
-    }
411
+	}
412 412
 ?>
413 413
 
414 414
 <?php 
415
-    $sub = false;
416
-    if (
415
+	$sub = false;
416
+	if (
417 417
 	(
418
-	    (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
418
+		(!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
419 419
 	) || 
420 420
 	(
421
-	    isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
421
+		isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
422 422
 	) || 
423 423
 	(
424
-	    isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
424
+		isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
425 425
 	) || 
426 426
 	(
427
-	    isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
427
+		isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
428 428
 	)
429
-    ) {
429
+	) {
430 430
 	$sub = true;
431
-    }
431
+	}
432 432
 ?>
433 433
 <?php
434
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
434
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
435 435
 ?>
436 436
     <li class="dropdown">
437 437
 <?php
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	<ul class="dropdown-menu multi-level">
443 443
       	<li class="dropdown-submenu">
444 444
 <?php
445
-        }
445
+		}
446 446
 ?>
447 447
 <?php
448 448
 	if (isset($globalNewsFeeds['aircraft']) && !empty($globalNewsFeeds['aircraft'])) {
@@ -457,25 +457,25 @@  discard block
 block discarded – undo
457 457
           <ul class="dropdown-menu">
458 458
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircraft Types"); ?></a></li>
459 459
 <?php
460
-    if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
460
+	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
461 461
 ?>
462 462
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
463 463
 <?php
464
-    }
464
+	}
465 465
 ?>
466 466
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
467 467
 <?php
468
-    if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
468
+	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
469 469
 ?>
470 470
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
471 471
 <?php
472
-    } 
473
-    if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
472
+	} 
473
+	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
474 474
 
475 475
 ?>
476 476
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
477 477
 <?php
478
-    }
478
+	}
479 479
 ?>
480 480
 			<li><hr /></li>
481 481
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -483,43 +483,43 @@  discard block
 block discarded – undo
483 483
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
484 484
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
485 485
             <?php
486
-        	if ($globalACARS) {
487
-        	    if (isset($globalDemo) && $globalDemo) {
488
-    	    ?>
486
+			if ($globalACARS) {
487
+				if (isset($globalDemo) && $globalDemo) {
488
+			?>
489 489
             <li><hr /></li>
490 490
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
491 491
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
492 492
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
493 493
             <?php
494
-        	    } else {
495
-    	    ?>
494
+				} else {
495
+			?>
496 496
             <li><hr /></li>
497 497
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
498 498
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
499 499
             <?php
500
-        	    }
501
-        	}
502
-    	    ?>
500
+				}
501
+			}
502
+			?>
503 503
     	    <?php
504
-    	        if (isset($globalAccidents) && $globalAccidents) {
505
-    	    ?>
504
+				if (isset($globalAccidents) && $globalAccidents) {
505
+			?>
506 506
             <li><hr /></li>
507 507
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
508 508
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
509 509
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
510 510
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
511 511
             <?php
512
-        	}
513
-    	    ?>
512
+			}
513
+			?>
514 514
             <li><hr /></li>
515 515
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
516 516
             <?php
517 517
 		if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) {
518
-	    ?>
518
+		?>
519 519
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
520 520
 	    <?php
521 521
 		}
522
-	    ?>
522
+		?>
523 523
           </ul>
524 524
         </li>
525 525
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
     </ul>
547 547
 <?php
548 548
 	}
549
-    }
549
+	}
550 550
 ?>
551 551
 <?php
552
-    if (isset($globalMarine) && $globalMarine) {
552
+	if (isset($globalMarine) && $globalMarine) {
553 553
 ?>
554 554
     <li class="dropdown">
555 555
 <?php
556
-        if ($sub) {
556
+		if ($sub) {
557 557
 ?>
558 558
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Marines"); ?> <b class="caret"></b></a>
559 559
 	<ul class="dropdown-menu multi-level">
@@ -587,14 +587,14 @@  discard block
 block discarded – undo
587 587
 	}
588 588
 ?>
589 589
 <?php
590
-    }
590
+	}
591 591
 ?>
592 592
 <?php
593
-    if (isset($globalTracker) && $globalTracker) {
593
+	if (isset($globalTracker) && $globalTracker) {
594 594
 ?>
595 595
     <li class="dropdown">
596 596
 <?php
597
-        if ($sub) {
597
+		if ($sub) {
598 598
 ?>
599 599
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a>
600 600
 	<ul class="dropdown-menu multi-level">
@@ -628,14 +628,14 @@  discard block
 block discarded – undo
628 628
 	}
629 629
 ?>
630 630
 <?php
631
-    }
631
+	}
632 632
 ?>
633 633
 <?php
634
-    if (isset($globalSatellite) && $globalSatellite) {
634
+	if (isset($globalSatellite) && $globalSatellite) {
635 635
 ?>
636 636
     <li class="dropdown">
637 637
 <?php
638
-        if ($sub) {
638
+		if ($sub) {
639 639
 ?>
640 640
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Satellites"); ?> <b class="caret"></b></a>
641 641
 	<ul class="dropdown-menu multi-level">
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	}
672 672
 ?>
673 673
 <?php
674
-    }
674
+	}
675 675
 ?>
676 676
 
677 677
         <li class="dropdown">
@@ -680,12 +680,12 @@  discard block
 block discarded – undo
680 680
           	<li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li>
681 681
           	<li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li>
682 682
 <?php
683
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
683
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
684 684
 ?>
685 685
 		<li><hr /></li>
686 686
 		<li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li>
687 687
 <?php
688
-    }
688
+	}
689 689
 ?>
690 690
 	    <?php if (isset($globalContribute) && $globalContribute) { ?>
691 691
                 <li><hr /></li>
@@ -709,13 +709,13 @@  discard block
 block discarded – undo
709 709
   	    <form>
710 710
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
711 711
   		    <?php
712
-  		        foreach ($alllang as $key => $lang) {
713
-  		            print '<option value="'.$key.'"';
714
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
715
-  		            if ($lang[0] == 'Deutsch') print '>'.$lang[0].' (&beta;eta)</option>';
716
-  		            else print '>'.$lang[0].'</option>';
717
-  		        }
718
-  		    ?>
712
+  				foreach ($alllang as $key => $lang) {
713
+  					print '<option value="'.$key.'"';
714
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
715
+  					if ($lang[0] == 'Deutsch') print '>'.$lang[0].' (&beta;eta)</option>';
716
+  					else print '>'.$lang[0].'</option>';
717
+  				}
718
+  			?>
719 719
   		</select>
720 720
   	    </form>
721 721
   	</div>
@@ -748,18 +748,18 @@  discard block
 block discarded – undo
748 748
 ?>
749 749
     <div class="top-header clear" role="main">
750 750
 <?php
751
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
751
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
752 752
 ?>
753 753
     <div id="archive-map"></div>
754 754
 <?php
755
-    }
755
+	}
756 756
 ?>
757 757
     </div>
758 758
 <?php
759 759
 }
760 760
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
761 761
 {
762
-    ?>
762
+	?>
763 763
     <div class="top-header clear" role="main">
764 764
         <div id="map"></div>
765 765
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -770,15 +770,15 @@  discard block
 block discarded – undo
770 770
         var zoom = 13;
771 771
 //create the map
772 772
 <?php
773
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
773
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
774 774
 ?>
775 775
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
776 776
 <?php
777
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
777
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
778 778
 ?>
779 779
   map = L.map('map', { zoomControl:true });
780 780
 <?php
781
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
781
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
782 782
 ?>
783 783
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
784 784
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -786,22 +786,22 @@  discard block
 block discarded – undo
786 786
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
787 787
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
788 788
 <?php
789
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
789
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
790 790
 ?>
791 791
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
792 792
 <?php
793
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
793
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
794 794
 ?>
795 795
   map = L.map('map', { zoomControl:true });
796 796
 <?php
797
-    }
797
+	}
798 798
 ?>
799 799
   //initialize the layer group for the aircrft markers
800 800
   var layer_data = L.layerGroup();
801 801
 
802 802
   //a few title layers
803 803
 <?php
804
-    if ($globalMapProvider == 'Mapbox') {
804
+	if ($globalMapProvider == 'Mapbox') {
805 805
 ?>
806 806
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
807 807
     maxZoom: 18,
@@ -812,14 +812,14 @@  discard block
 block discarded – undo
812 812
     token : '<?php print $globalMapboxToken; ?>'
813 813
   }).addTo(map);
814 814
 <?php
815
-    } elseif ($globalMapProvider == 'Mapbox-GL') {
815
+	} elseif ($globalMapProvider == 'Mapbox-GL') {
816 816
 ?>
817 817
     L.mapboxGL({
818 818
 	accessToken: '<?php print $globalMapboxToken; ?>',
819 819
 	style: 'mapbox://styles/mapbox/bright-v8'
820 820
   }).addTo(map);
821 821
 <?php
822
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
822
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
823 823
 ?>
824 824
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
825 825
     maxZoom: 18,
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
829 829
   }).addTo(map);
830 830
 <?php
831
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
831
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
832 832
 ?>
833 833
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
834 834
     maxZoom: 18,
@@ -837,27 +837,27 @@  discard block
 block discarded – undo
837 837
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
838 838
   }).addTo(map);
839 839
 <?php
840
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
840
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
841 841
 ?>
842 842
     var googleLayer = new L.Google('ROADMAP');
843 843
     map.addLayer(googleLayer);
844 844
 <?php
845
-    } elseif ($globalMapProvider == 'Google-Satellite') {
845
+	} elseif ($globalMapProvider == 'Google-Satellite') {
846 846
 ?>
847 847
     var googleLayer = new L.Google('SATELLITE');
848 848
     map.addLayer(googleLayer);
849 849
 <?php
850
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
850
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
851 851
 ?>
852 852
     var googleLayer = new L.Google('HYBRID');
853 853
     map.addLayer(googleLayer);
854 854
 <?php
855
-    } elseif ($globalMapProvider == 'Google-Terrain') {
855
+	} elseif ($globalMapProvider == 'Google-Terrain') {
856 856
 ?>
857 857
     var googleLayer = new L.Google('Terrain');
858 858
     map.addLayer(googleLayer);
859 859
 <?php
860
-    } elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
860
+	} elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
861 861
 	$customid = $globalMapProvider;
862 862
 ?>
863 863
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
868 868
     }).addTo(map);
869 869
 <?php
870
-    } elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
870
+	} elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
871 871
 ?>
872 872
     var center = map.getCenter();
873 873
     map.options.crs = L.CRS.EPSG4326;
@@ -882,8 +882,8 @@  discard block
 block discarded – undo
882 882
         attribution: 'Natural Earth'
883 883
     }).addTo(map);
884 884
 <?php
885
-    //} elseif ($globalMapProvider == 'OpenStreetMap') {
886
-    } else {
885
+	//} elseif ($globalMapProvider == 'OpenStreetMap') {
886
+	} else {
887 887
 ?>
888 888
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
889 889
     maxZoom: 18,
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
   }).addTo(map);
893 893
 
894 894
 <?php
895
-    }
895
+	}
896 896
 ?>
897 897
         </script>
898 898
     </div>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +1091 added lines, -1091 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
182
-        	//$formats[$id] = 'planefinderclient';
183
-        	$globalSources[$id]['format'] = 'planefinderclient';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
187
-        	//$formats[$id] = 'aircraftlistjson';
188
-        	$globalSources[$id]['format'] = 'opensky';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
+			} else if (preg_match('/aircraft$/i',$host)) {
182
+			//$formats[$id] = 'planefinderclient';
183
+			$globalSources[$id]['format'] = 'planefinderclient';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
+			} else if (preg_match('/opensky/i',$host)) {
187
+			//$formats[$id] = 'aircraftlistjson';
188
+			$globalSources[$id]['format'] = 'opensky';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
+			/*
192 192
     	    // Disabled for now, site change source format
193 193
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
194 194
         	//$formats[$id] = 'radarvirtueljson';
@@ -200,127 +200,127 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
-        	//$formats[$id] = 'planeupdatefaa';
205
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
206
-        	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'phpvmacars';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vaos';
220
-        	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
227
-        	//$formats[$id] = 'whazzup';
228
-        	$globalSources[$id]['format'] = 'whazzup';
229
-        	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
232
-        	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
235
-        	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
238
-        	//$formats[$id] = 'pirepsjson';
239
-        	$globalSources[$id]['format'] = 'pirepsjson';
240
-        	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
-        	//$formats[$id] = 'fr24json';
244
-        	$globalSources[$id]['format'] = 'fr24json';
245
-        	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
-        	    exit(0);
250
-        	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'myshiptracking';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
-        	//$formats[$id] = 'tsv';
263
-        	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
-            }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
-    		    if ($idf !== false) {
270
-    			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
274
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275
-	    $hostport = explode(':',$host);
276
-	    if (isset($hostport[1])) {
203
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
+			//$formats[$id] = 'planeupdatefaa';
205
+			$globalSources[$id]['format'] = 'planeupdatefaa';
206
+			//$last_exec['planeupdatefaa'] = 0;
207
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'phpvmacars';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vaos';
220
+			//$last_exec['phpvmacars'] = 0;
221
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'vam';
225
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
+			} else if (preg_match('/whazzup/i',$host)) {
227
+			//$formats[$id] = 'whazzup';
228
+			$globalSources[$id]['format'] = 'whazzup';
229
+			//$last_exec['whazzup'] = 0;
230
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
+			} else if (preg_match('/blitzortung/i',$host)) {
232
+			$globalSources[$id]['format'] = 'blitzortung';
233
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
+			} else if (preg_match('/airwhere/i',$host)) {
235
+			$globalSources[$id]['format'] = 'airwhere';
236
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+			} else if (preg_match('/recentpireps/i',$host)) {
238
+			//$formats[$id] = 'pirepsjson';
239
+			$globalSources[$id]['format'] = 'pirepsjson';
240
+			//$last_exec['pirepsjson'] = 0;
241
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
+			//$formats[$id] = 'fr24json';
244
+			$globalSources[$id]['format'] = 'fr24json';
245
+			//$last_exec['fr24json'] = 0;
246
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
+				exit(0);
250
+			}
251
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'myshiptracking';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			//} else if (preg_match('/10001/',$host)) {
261
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
+			//$formats[$id] = 'tsv';
263
+			$globalSources[$id]['format'] = 'tsv';
264
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
+			}
266
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
+				if ($idf !== false) {
270
+				$httpfeeds[$id] = $idf;
271
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
274
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275
+		$hostport = explode(':',$host);
276
+		if (isset($hostport[1])) {
277 277
 		$port = $hostport[1];
278 278
 		$hostn = $hostport[0];
279
-	    } else {
279
+		} else {
280 280
 		$port = $globalSources[$id]['port'];
281 281
 		$hostn = $globalSources[$id]['host'];
282
-	    }
283
-	    $Common = new Common();
284
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
285
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
-    	    } else {
287
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
-	    }
289
-	    if ($s) {
290
-    	        $sockets[$id] = $s;
291
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
292
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
282
+		}
283
+		$Common = new Common();
284
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
285
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
+			} else {
287
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
+		}
289
+		if ($s) {
290
+				$sockets[$id] = $s;
291
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
292
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293 293
 			//$formats[$id] = 'aprs';
294 294
 			$globalSources[$id]['format'] = 'aprs';
295 295
 			//$aprs_connect = 0;
296 296
 			//$use_aprs = true;
297
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
297
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298 298
 			$globalSources[$id]['format'] = 'vrstcp';
299
-    		    } elseif ($port == '10001') {
300
-        		//$formats[$id] = 'tsv';
301
-        		$globalSources[$id]['format'] = 'tsv';
302
-		    } elseif ($port == '30002') {
303
-        		//$formats[$id] = 'raw';
304
-        		$globalSources[$id]['format'] = 'raw';
305
-		    } elseif ($port == '5001') {
306
-        		//$formats[$id] = 'raw';
307
-        		$globalSources[$id]['format'] = 'flightgearmp';
308
-		    } elseif ($port == '30005') {
299
+				} elseif ($port == '10001') {
300
+				//$formats[$id] = 'tsv';
301
+				$globalSources[$id]['format'] = 'tsv';
302
+			} elseif ($port == '30002') {
303
+				//$formats[$id] = 'raw';
304
+				$globalSources[$id]['format'] = 'raw';
305
+			} elseif ($port == '5001') {
306
+				//$formats[$id] = 'raw';
307
+				$globalSources[$id]['format'] = 'flightgearmp';
308
+			} elseif ($port == '30005') {
309 309
 			// Not yet supported
310
-        		//$formats[$id] = 'beast';
311
-        		$globalSources[$id]['format'] = 'beast';
312
-		    //} else $formats[$id] = 'sbs';
313
-		    } else $globalSources[$id]['format'] = 'sbs';
314
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
310
+				//$formats[$id] = 'beast';
311
+				$globalSources[$id]['format'] = 'beast';
312
+			//} else $formats[$id] = 'sbs';
313
+			} else $globalSources[$id]['format'] = 'sbs';
314
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
315 315
 		}
316 316
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
317
-            } else {
317
+			} else {
318 318
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
319 319
 		sleep(10);
320 320
 		connect_all($hosts);
321
-    	    }
322
-        }
323
-    }
321
+			}
322
+		}
323
+	}
324 324
 }
325 325
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
326 326
 
@@ -343,9 +343,9 @@  discard block
 block discarded – undo
343 343
 //connect_all($globalSources);
344 344
 
345 345
 if (isset($globalProxy) && $globalProxy) {
346
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
346
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347 347
 } else {
348
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
348
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
349 349
 }
350 350
 
351 351
 // APRS Configuration
@@ -354,21 +354,21 @@  discard block
 block discarded – undo
354 354
 	die;
355 355
 }
356 356
 foreach ($globalSources as $key => $source) {
357
-    if (!isset($source['format'])) {
358
-        $globalSources[$key]['format'] = 'auto';
359
-    }
360
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
361
-        unset($globalSources[$key]);
362
-    }
357
+	if (!isset($source['format'])) {
358
+		$globalSources[$key]['format'] = 'auto';
359
+	}
360
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
361
+		unset($globalSources[$key]);
362
+	}
363 363
 }
364 364
 connect_all($globalSources);
365 365
 foreach ($globalSources as $key => $source) {
366
-    if (isset($source['format']) && $source['format'] == 'aprs') {
366
+	if (isset($source['format']) && $source['format'] == 'aprs') {
367 367
 	$aprs_connect = 0;
368 368
 	$use_aprs = true;
369 369
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
370 370
 	break;
371
-    }
371
+	}
372 372
 }
373 373
 
374 374
 if ($use_aprs) {
@@ -409,133 +409,133 @@  discard block
 block discarded – undo
409 409
 
410 410
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
411 411
 while ($i > 0) {
412
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
412
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413 413
 
414
-    if (!$globalDaemon) $i = $endtime-time();
415
-    // Delete old ATC
416
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
414
+	if (!$globalDaemon) $i = $endtime-time();
415
+	// Delete old ATC
416
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417 417
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
418
-        $ATC->deleteOldATC();
419
-    }
418
+		$ATC->deleteOldATC();
419
+	}
420 420
     
421
-    if (count($last_exec) == count($globalSources)) {
421
+	if (count($last_exec) == count($globalSources)) {
422 422
 	$max = $globalMinFetch;
423 423
 	foreach ($last_exec as $last) {
424
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
424
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
425 425
 	}
426 426
 	if ($max < $globalMinFetch) {
427
-	    if ($globalDebug) echo 'Sleeping...'."\n";
428
-	    sleep($globalMinFetch-$max+2);
427
+		if ($globalDebug) echo 'Sleeping...'."\n";
428
+		sleep($globalMinFetch-$max+2);
429
+	}
429 430
 	}
430
-    }
431 431
 
432 432
     
433
-    //foreach ($formats as $id => $value) {
434
-    foreach ($globalSources as $id => $value) {
433
+	//foreach ($formats as $id => $value) {
434
+	foreach ($globalSources as $id => $value) {
435 435
 	date_default_timezone_set('UTC');
436 436
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
437 437
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
438 438
 	if ($value['format'] === 'deltadbtxt' && 
439
-	    (
439
+		(
440 440
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
441 441
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
442
-	    )
442
+		)
443 443
 	) {
444
-	    //$buffer = $Common->getData($hosts[$id]);
445
-	    $buffer = $Common->getData($value['host']);
446
-	    if ($buffer != '') $reset = 0;
447
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448
-	    $buffer = explode('\n',$buffer);
449
-	    foreach ($buffer as $line) {
450
-    		if ($line != '' && count($line) > 7) {
451
-    		    $line = explode(',', $line);
452
-	            $data = array();
453
-	            $data['hex'] = $line[1]; // hex
454
-	            $data['ident'] = $line[2]; // ident
455
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
460
-	            $data['verticalrate'] = ''; // vertical rate
461
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462
-	            $data['emergency'] = ''; // emergency
463
-		    $data['datetime'] = date('Y-m-d H:i:s');
464
-		    $data['format_source'] = 'deltadbtxt';
465
-    		    $data['id_source'] = $id_source;
466
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
469
-    		    $SI->add($data);
470
-		    unset($data);
471
-    		}
472
-    	    }
473
-    	    $last_exec[$id]['last'] = time();
444
+		//$buffer = $Common->getData($hosts[$id]);
445
+		$buffer = $Common->getData($value['host']);
446
+		if ($buffer != '') $reset = 0;
447
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448
+		$buffer = explode('\n',$buffer);
449
+		foreach ($buffer as $line) {
450
+			if ($line != '' && count($line) > 7) {
451
+				$line = explode(',', $line);
452
+				$data = array();
453
+				$data['hex'] = $line[1]; // hex
454
+				$data['ident'] = $line[2]; // ident
455
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
460
+				$data['verticalrate'] = ''; // vertical rate
461
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462
+				$data['emergency'] = ''; // emergency
463
+			$data['datetime'] = date('Y-m-d H:i:s');
464
+			$data['format_source'] = 'deltadbtxt';
465
+				$data['id_source'] = $id_source;
466
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
469
+				$SI->add($data);
470
+			unset($data);
471
+			}
472
+			}
473
+			$last_exec[$id]['last'] = time();
474 474
 	} elseif ($value['format'] === 'aisnmeatxt' && 
475
-	    (
475
+		(
476 476
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
477 477
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
478
-	    )
478
+		)
479 479
 	) {
480
-	    date_default_timezone_set('CET');
481
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
-	    date_default_timezone_set('UTC');
483
-	    if ($buffer != '') $reset = 0;
484
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485
-	    $buffer = explode('\n',$buffer);
486
-	    foreach ($buffer as $line) {
480
+		date_default_timezone_set('CET');
481
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
+		date_default_timezone_set('UTC');
483
+		if ($buffer != '') $reset = 0;
484
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485
+		$buffer = explode('\n',$buffer);
486
+		foreach ($buffer as $line) {
487 487
 		if ($line != '') {
488
-		    //echo "'".$line."'\n";
489
-		    $add = false;
490
-		    $ais_data = $AIS->parse_line(trim($line));
491
-		    $data = array();
492
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
504
-		    if (isset($ais_data['timestamp'])) {
488
+			//echo "'".$line."'\n";
489
+			$add = false;
490
+			$ais_data = $AIS->parse_line(trim($line));
491
+			$data = array();
492
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
504
+			if (isset($ais_data['timestamp'])) {
505 505
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506 506
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
507
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
508
-			    $add = true;
507
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
508
+				$add = true;
509 509
 			}
510
-		    } else {
510
+			} else {
511 511
 			$data['datetime'] = date('Y-m-d H:i:s');
512 512
 			$add = true;
513
-		    }
514
-		    $data['format_source'] = 'aisnmeatxt';
515
-    		    $data['id_source'] = $id_source;
516
-		    //print_r($data);
517
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
519
-		    unset($data);
513
+			}
514
+			$data['format_source'] = 'aisnmeatxt';
515
+				$data['id_source'] = $id_source;
516
+			//print_r($data);
517
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
519
+			unset($data);
520 520
 		}
521
-    	    }
522
-    	    $last_exec[$id]['last'] = time();
521
+			}
522
+			$last_exec[$id]['last'] = time();
523 523
 	} elseif ($value['format'] === 'aisnmeahttp') {
524
-	    $arr = $httpfeeds;
525
-	    $w = $e = null;
524
+		$arr = $httpfeeds;
525
+		$w = $e = null;
526 526
 	    
527
-	    if (isset($arr[$id])) {
527
+		if (isset($arr[$id])) {
528 528
 		$nn = stream_select($arr,$w,$e,$timeout);
529 529
 		if ($nn > 0) {
530
-		    foreach ($httpfeeds as $feed) {
530
+			foreach ($httpfeeds as $feed) {
531 531
 			$buffer = stream_get_line($feed,2000,"\n");
532 532
 			if ($buffer === FALSE) {
533
-			    connect_all($globalSources);
533
+				connect_all($globalSources);
534 534
 			}
535 535
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
536 536
 			$buffer = explode('\n',$buffer);
537 537
 			foreach ($buffer as $line) {
538
-			    if ($line != '') {
538
+				if ($line != '') {
539 539
 				$ais_data = $AIS->parse_line(trim($line));
540 540
 				$data = array();
541 541
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -553,117 +553,117 @@  discard block
 block discarded – undo
553 553
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
554 554
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
555 555
 				if (isset($ais_data['timestamp'])) {
556
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
556
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557 557
 				} else {
558
-				    $data['datetime'] = date('Y-m-d H:i:s');
558
+					$data['datetime'] = date('Y-m-d H:i:s');
559 559
 				}
560 560
 				$data['format_source'] = 'aisnmeahttp';
561 561
 				$data['id_source'] = $id_source;
562 562
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
563 563
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
564 564
 				unset($data);
565
-			    }
565
+				}
566
+			}
566 567
 			}
567
-		    }
568 568
 		} else {
569
-		    $format = $value['format'];
570
-		    if (isset($tt[$format])) $tt[$format]++;
571
-		    else $tt[$format] = 0;
572
-		    if ($tt[$format] > 30) {
569
+			$format = $value['format'];
570
+			if (isset($tt[$format])) $tt[$format]++;
571
+			else $tt[$format] = 0;
572
+			if ($tt[$format] > 30) {
573 573
 			if ($globalDebug) echo 'Reconnect...'."\n";
574 574
 			sleep(2);
575 575
 			//$sourceeen[] = $value;
576 576
 			//connect_all($sourceeen);
577 577
 			//$sourceeen = array();
578 578
 			connect_all($globalSources);
579
-		    }
579
+			}
580
+		}
580 581
 		}
581
-	    }
582 582
 	} elseif ($value['format'] === 'myshiptracking' && 
583
-	    (
583
+		(
584 584
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
585 585
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
586
-	    )
586
+		)
587 587
 	) {
588
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
589
-	    if ($buffer != '') {
588
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
589
+		if ($buffer != '') {
590 590
 		//echo $buffer;
591 591
 		$all_data = json_decode($buffer,true);
592 592
 		//print_r($all_data);
593 593
 		if (isset($all_data[0]['DATA'])) {
594
-		    foreach ($all_data[0]['DATA'] as $line) {
594
+			foreach ($all_data[0]['DATA'] as $line) {
595 595
 			if ($line != '') {
596
-			    $data = array();
597
-			    $data['ident'] = $line['NAME'];
598
-			    $data['mmsi'] = $line['MMSI'];
599
-			    if (strlen($data['mmsi']) > 9) {
596
+				$data = array();
597
+				$data['ident'] = $line['NAME'];
598
+				$data['mmsi'] = $line['MMSI'];
599
+				if (strlen($data['mmsi']) > 9) {
600 600
 				$data['mmsi'] = substr($data['mmsi'],-9);
601
-			    }
602
-			    $data['speed'] = $line['SOG'];
603
-			    $data['heading'] = $line['COG'];
604
-			    $data['latitude'] = $line['LAT'];
605
-			    $data['longitude'] = $line['LNG'];
606
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607
-			    //$data['type_id'] = $line['TYPE'];
608
-			    $data['imo'] = $line['IMO'];
609
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
611
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612
-			    $data['format_source'] = 'myshiptracking';
613
-			    $data['id_source'] = $id_source;
614
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
615
-			    $MI->add($data);
616
-			    unset($data);
601
+				}
602
+				$data['speed'] = $line['SOG'];
603
+				$data['heading'] = $line['COG'];
604
+				$data['latitude'] = $line['LAT'];
605
+				$data['longitude'] = $line['LNG'];
606
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607
+				//$data['type_id'] = $line['TYPE'];
608
+				$data['imo'] = $line['IMO'];
609
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
611
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612
+				$data['format_source'] = 'myshiptracking';
613
+				$data['id_source'] = $id_source;
614
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
615
+				$MI->add($data);
616
+				unset($data);
617 617
 			}
618
-		    }
618
+			}
619
+		}
619 620
 		}
620
-	    }
621
-	    $last_exec[$id]['last'] = time();
621
+		$last_exec[$id]['last'] = time();
622 622
 	} elseif ($value['format'] === 'boatbeaconapp' && 
623
-	    (
623
+		(
624 624
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
625 625
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
626
-	    )
626
+		)
627 627
 	) {
628
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
-	    if ($buffer != '') {
628
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
+		if ($buffer != '') {
630 630
 		$all_data = json_decode($buffer,true);
631 631
 		if (isset($all_data[0]['mmsi'])) {
632
-		    foreach ($all_data as $line) {
632
+			foreach ($all_data as $line) {
633 633
 			if ($line != '') {
634
-			    $data = array();
635
-			    $data['ident'] = $line['shipname'];
636
-			    $data['callsign'] = $line['callsign'];
637
-			    $data['mmsi'] = substr($line['mmsi'],-9);
638
-			    $data['speed'] = $line['sog'];
639
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
640
-			    $data['latitude'] = $line['latitude'];
641
-			    $data['longitude'] = $line['longitude'];
642
-			    $data['type_id'] = $line['shiptype'];
643
-			    $data['arrival_code'] = $line['destination'];
644
-			    $data['datetime'] = $line['time'];
645
-			    $data['format_source'] = 'boatbeaconapp';
646
-			    $data['id_source'] = $id_source;
647
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
648
-			    $MI->add($data);
649
-			    unset($data);
634
+				$data = array();
635
+				$data['ident'] = $line['shipname'];
636
+				$data['callsign'] = $line['callsign'];
637
+				$data['mmsi'] = substr($line['mmsi'],-9);
638
+				$data['speed'] = $line['sog'];
639
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
640
+				$data['latitude'] = $line['latitude'];
641
+				$data['longitude'] = $line['longitude'];
642
+				$data['type_id'] = $line['shiptype'];
643
+				$data['arrival_code'] = $line['destination'];
644
+				$data['datetime'] = $line['time'];
645
+				$data['format_source'] = 'boatbeaconapp';
646
+				$data['id_source'] = $id_source;
647
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
648
+				$MI->add($data);
649
+				unset($data);
650
+			}
650 651
 			}
651
-		    }
652 652
 		}
653 653
 		
654
-	    }
655
-    	    $last_exec[$id]['last'] = time();
654
+		}
655
+			$last_exec[$id]['last'] = time();
656 656
 	} elseif ($value['format'] === 'boatnerd' && 
657
-	    (
657
+		(
658 658
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
659 659
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
660
-	    )
660
+		)
661 661
 	) {
662
-	    $buffer = $Common->getData($value['host']);
663
-	    if ($buffer != '') {
662
+		$buffer = $Common->getData($value['host']);
663
+		if ($buffer != '') {
664 664
 		$all_data = json_decode($buffer,true);
665 665
 		if (isset($all_data['features'][0]['id'])) {
666
-		    foreach ($all_data['features'] as $line) {
666
+			foreach ($all_data['features'] as $line) {
667 667
 			print_r($line);
668 668
 			$data = array();
669 669
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -683,80 +683,80 @@  discard block
 block discarded – undo
683 683
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684 684
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
685 685
 			unset($data);
686
-		    }
686
+			}
687 687
 		}
688 688
 		
689
-	    }
690
-    	    $last_exec[$id]['last'] = time();
689
+		}
690
+			$last_exec[$id]['last'] = time();
691 691
 	} elseif ($value['format'] === 'shipplotter' && 
692
-	    (
692
+		(
693 693
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
694 694
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
695
-	    )
695
+		)
696 696
 	) {
697
-	    echo 'download...';
698
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
-	    echo 'done !'."\n";
700
-	    // FIXME: Need more work
701
-	    if ($buffer != '') $reset = 0;
702
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703
-	    $buffer = explode('\n',$buffer);
704
-	    foreach ($buffer as $line) {
697
+		echo 'download...';
698
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
+		echo 'done !'."\n";
700
+		// FIXME: Need more work
701
+		if ($buffer != '') $reset = 0;
702
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703
+		$buffer = explode('\n',$buffer);
704
+		foreach ($buffer as $line) {
705 705
 		if ($line != '') {
706
-		    $data = array();
707
-		    echo $line."\n";
708
-		    $data['mmsi'] = (int)substr($line,0,9);
709
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
710
-		    $data['status_id'] = substr($line,21,2);
711
-		    $data['type_id'] = substr($line,24,3);
712
-		    $data['latitude'] = substr($line,29,9);
713
-		    $data['longitude'] = substr($line,41,9);
714
-		    $data['speed'] = round(substr($line,51,5));
715
-		    //$data['course'] = substr($line,57,5);
716
-		    $data['heading'] = round(substr($line,63,3));
717
-		    //$data['draft'] = substr($line,67,4);
718
-		    //$data['length'] = substr($line,72,3);
719
-		    //$data['beam'] = substr($line,76,2);
720
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
-		    //$data['callsign'] = trim(substr($line,100,7);
722
-		    $data['arrival_code'] = substr($line,108,20);
723
-		    //$data['etaDate'] = substr($line,129,5);
724
-		    //$data['etaTime'] = substr($line,135,5);
725
-		    $data['format_source'] = 'shipplotter';
726
-    		    $data['id_source'] = $id_source;
727
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
728
-		    //print_r($data);
729
-		    echo 'Add...'."\n";
730
-		    $MI->add($data);
731
-		    unset($data);
706
+			$data = array();
707
+			echo $line."\n";
708
+			$data['mmsi'] = (int)substr($line,0,9);
709
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
710
+			$data['status_id'] = substr($line,21,2);
711
+			$data['type_id'] = substr($line,24,3);
712
+			$data['latitude'] = substr($line,29,9);
713
+			$data['longitude'] = substr($line,41,9);
714
+			$data['speed'] = round(substr($line,51,5));
715
+			//$data['course'] = substr($line,57,5);
716
+			$data['heading'] = round(substr($line,63,3));
717
+			//$data['draft'] = substr($line,67,4);
718
+			//$data['length'] = substr($line,72,3);
719
+			//$data['beam'] = substr($line,76,2);
720
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
+			//$data['callsign'] = trim(substr($line,100,7);
722
+			$data['arrival_code'] = substr($line,108,20);
723
+			//$data['etaDate'] = substr($line,129,5);
724
+			//$data['etaTime'] = substr($line,135,5);
725
+			$data['format_source'] = 'shipplotter';
726
+				$data['id_source'] = $id_source;
727
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
728
+			//print_r($data);
729
+			echo 'Add...'."\n";
730
+			$MI->add($data);
731
+			unset($data);
732 732
 		}
733
-    	    }
734
-    	    $last_exec[$id]['last'] = time();
733
+			}
734
+			$last_exec[$id]['last'] = time();
735 735
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
736 736
 	} elseif (
737
-	    (
737
+		(
738 738
 		$value['format'] === 'whazzup' && 
739 739
 		(
740
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
741
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
740
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
741
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
742 742
 		)
743
-	    ) || (
743
+		) || (
744 744
 		$value['format'] === 'vatsimtxt' && 
745 745
 		(
746
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
746
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
748
+		)
748 749
 		)
749
-	    )
750 750
 	) {
751
-	    //$buffer = $Common->getData($hosts[$id]);
752
-	    $buffer = $Common->getData($value['host']);
753
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
754
-	    $buffer = explode('\n',$buffer);
755
-	    $reset = 0;
756
-	    foreach ($buffer as $line) {
757
-    		if ($line != '') {
758
-    		    $line = explode(':', $line);
759
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
751
+		//$buffer = $Common->getData($hosts[$id]);
752
+		$buffer = $Common->getData($value['host']);
753
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
754
+		$buffer = explode('\n',$buffer);
755
+		$reset = 0;
756
+		foreach ($buffer as $line) {
757
+			if ($line != '') {
758
+				$line = explode(':', $line);
759
+				if (count($line) > 30 && $line[0] != 'callsign') {
760 760
 			$data = array();
761 761
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
762 762
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -769,37 +769,37 @@  discard block
 block discarded – undo
769 769
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
770 770
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
771 771
 			$data['latitude'] = $line[5]; // lat
772
-	        	$data['longitude'] = $line[6]; // long
773
-	        	$data['verticalrate'] = ''; // vertical rate
774
-	        	$data['squawk'] = ''; // squawk
775
-	        	$data['emergency'] = ''; // emergency
776
-	        	$data['waypoints'] = $line[30];
772
+				$data['longitude'] = $line[6]; // long
773
+				$data['verticalrate'] = ''; // vertical rate
774
+				$data['squawk'] = ''; // squawk
775
+				$data['emergency'] = ''; // emergency
776
+				$data['waypoints'] = $line[30];
777 777
 			$data['datetime'] = date('Y-m-d H:i:s');
778 778
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
779 779
 			//if (isset($line[37])) $data['last_update'] = $line[37];
780
-		        $data['departure_airport_icao'] = $line[11];
781
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
782
-		        $data['arrival_airport_icao'] = $line[13];
780
+				$data['departure_airport_icao'] = $line[11];
781
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
782
+				$data['arrival_airport_icao'] = $line[13];
783 783
 			$data['frequency'] = $line[4];
784 784
 			$data['type'] = $line[18];
785 785
 			$data['range'] = $line[19];
786 786
 			if (isset($line[35])) $data['info'] = $line[35];
787
-    			$data['id_source'] = $id_source;
788
-	    		//$data['arrival_airport_time'] = ;
789
-	    		if ($line[9] != '') {
790
-	    		    $aircraft_data = explode('/',$line[9]);
791
-	    		    if (isset($aircraft_data[1])) {
792
-	    			$data['aircraft_icao'] = $aircraft_data[1];
793
-	    		    }
794
-        		}
795
-	    		/*
787
+				$data['id_source'] = $id_source;
788
+				//$data['arrival_airport_time'] = ;
789
+				if ($line[9] != '') {
790
+					$aircraft_data = explode('/',$line[9]);
791
+					if (isset($aircraft_data[1])) {
792
+					$data['aircraft_icao'] = $aircraft_data[1];
793
+					}
794
+				}
795
+				/*
796 796
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
797 797
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
798 798
 	    		*/
799
-	    		$data['format_source'] = $value['format'];
799
+				$data['format_source'] = $value['format'];
800 800
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
801 801
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
802
-    			if ($line[3] === 'PILOT') $SI->add($data);
802
+				if ($line[3] === 'PILOT') $SI->add($data);
803 803
 			elseif ($line[3] === 'ATC') {
804 804
 				//print_r($data);
805 805
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -820,21 +820,21 @@  discard block
 block discarded – undo
820 820
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
821 821
 				}
822 822
 			}
823
-    			unset($data);
824
-    		    }
825
-    		}
826
-    	    }
827
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
828
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
829
-    	    $last_exec[$id]['last'] = time();
830
-    	} elseif ($value['format'] === 'airwhere' && 
831
-    	    (
832
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
833
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
834
-    	    )
835
-    	) {
836
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
837
-	    if ($buffer != '') {
823
+				unset($data);
824
+				}
825
+			}
826
+			}
827
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
828
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
829
+			$last_exec[$id]['last'] = time();
830
+		} elseif ($value['format'] === 'airwhere' && 
831
+			(
832
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
833
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
834
+			)
835
+		) {
836
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
837
+		if ($buffer != '') {
838 838
 		$all_data = simplexml_load_string($buffer);
839 839
 		foreach($all_data->children() as $childdata) {
840 840
 			$data = array();
@@ -856,10 +856,10 @@  discard block
 block discarded – undo
856 856
 			$SI->add($data);
857 857
 			unset($data);
858 858
 		}
859
-	    }
860
-	    $Source->deleteOldLocationByType('gs');
861
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
862
-	    if ($buffer != '') {
859
+		}
860
+		$Source->deleteOldLocationByType('gs');
861
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
862
+		if ($buffer != '') {
863 863
 		$all_data = simplexml_load_string($buffer);
864 864
 		foreach($all_data->children() as $childdata) {
865 865
 			$data = array();
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 			}
878 878
 			unset($data);
879 879
 		}
880
-	    }
881
-	    $last_exec[$id]['last'] = time();
880
+		}
881
+		$last_exec[$id]['last'] = time();
882 882
 	/*
883 883
 	} if ($value['format'] === 'aircraftlistjson') {
884 884
 	    print_r($globalSources);
@@ -886,17 +886,17 @@  discard block
 block discarded – undo
886 886
 	    echo $globalMinFetch;
887 887
 	*/
888 888
 	} elseif ($value['format'] === 'aircraftlistjson' && 
889
-	    (
889
+		(
890 890
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
891 891
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
892
-	    )
892
+		)
893 893
 	) {
894
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
895
-	    if ($buffer != '') {
896
-	        $all_data = json_decode($buffer,true);
894
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
895
+		if ($buffer != '') {
896
+			$all_data = json_decode($buffer,true);
897 897
 		if (isset($all_data['acList'])) {
898
-		    $reset = 0;
899
-		    foreach ($all_data['acList'] as $line) {
898
+			$reset = 0;
899
+			foreach ($all_data['acList'] as $line) {
900 900
 			$data = array();
901 901
 			$data['hex'] = $line['Icao']; // hex
902 902
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
920 920
 			if (isset($data['latitude'])) $SI->add($data);
921 921
 			unset($data);
922
-		    }
922
+			}
923 923
 		} elseif (is_array($all_data)) {
924
-		    $reset = 0;
925
-		    foreach ($all_data as $line) {
924
+			$reset = 0;
925
+			foreach ($all_data as $line) {
926 926
 			$data = array();
927 927
 			$data['hex'] = $line['hex']; // hex
928 928
 			$data['ident'] = $line['flight']; // ident
@@ -942,291 +942,291 @@  discard block
 block discarded – undo
942 942
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
943 943
 			$SI->add($data);
944 944
 			unset($data);
945
-		    }
945
+			}
946 946
 		}
947
-	    } elseif ($globalDebug) echo 'No data'."\n";
948
-    	    //$last_exec['aircraftlistjson'] = time();
949
-    	    $last_exec[$id]['last'] = time();
950
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
951
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
952
-    	    (
953
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
954
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
955
-    	    )
956
-    	) {
957
-	    $buffer = $Common->getData($value['host']);
958
-	    $all_data = json_decode($buffer,true);
959
-	    if (isset($all_data['planes'])) {
947
+		} elseif ($globalDebug) echo 'No data'."\n";
948
+			//$last_exec['aircraftlistjson'] = time();
949
+			$last_exec[$id]['last'] = time();
950
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
951
+		} elseif ($value['format'] === 'planeupdatefaa' && 
952
+			(
953
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
954
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
955
+			)
956
+		) {
957
+		$buffer = $Common->getData($value['host']);
958
+		$all_data = json_decode($buffer,true);
959
+		if (isset($all_data['planes'])) {
960 960
 		$reset = 0;
961 961
 		foreach ($all_data['planes'] as $key => $line) {
962
-		    $data = array();
963
-		    $data['hex'] = $key; // hex
964
-		    $data['ident'] = $line[3]; // ident
965
-		    $data['altitude'] = $line[6]; // altitude
966
-		    $data['speed'] = $line[8]; // speed
967
-		    $data['heading'] = $line[7]; // heading
968
-		    $data['latitude'] = $line[4]; // lat
969
-		    $data['longitude'] = $line[5]; // long
970
-		    //$data['verticalrate'] = $line[]; // verticale rate
971
-		    $data['squawk'] = $line[10]; // squawk
972
-		    $data['emergency'] = ''; // emergency
973
-		    $data['registration'] = $line[2];
974
-		    $data['aircraft_icao'] = $line[0];
975
-		    $deparr = explode('-',$line[1]);
976
-		    if (count($deparr) === 2) {
962
+			$data = array();
963
+			$data['hex'] = $key; // hex
964
+			$data['ident'] = $line[3]; // ident
965
+			$data['altitude'] = $line[6]; // altitude
966
+			$data['speed'] = $line[8]; // speed
967
+			$data['heading'] = $line[7]; // heading
968
+			$data['latitude'] = $line[4]; // lat
969
+			$data['longitude'] = $line[5]; // long
970
+			//$data['verticalrate'] = $line[]; // verticale rate
971
+			$data['squawk'] = $line[10]; // squawk
972
+			$data['emergency'] = ''; // emergency
973
+			$data['registration'] = $line[2];
974
+			$data['aircraft_icao'] = $line[0];
975
+			$deparr = explode('-',$line[1]);
976
+			if (count($deparr) === 2) {
977 977
 			$data['departure_airport_icao'] = $deparr[0];
978 978
 			$data['arrival_airport_icao'] = $deparr[1];
979
-		    }
980
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981
-	    	    $data['format_source'] = 'planeupdatefaa';
982
-    		    $data['id_source'] = $id_source;
983
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
985
-		    $SI->add($data);
986
-		    unset($data);
979
+			}
980
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981
+				$data['format_source'] = 'planeupdatefaa';
982
+				$data['id_source'] = $id_source;
983
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
985
+			$SI->add($data);
986
+			unset($data);
987 987
 		}
988
-	    }
989
-	    //$last_exec['planeupdatefaa'] = time();
990
-	    $last_exec[$id]['last'] = time();
988
+		}
989
+		//$last_exec['planeupdatefaa'] = time();
990
+		$last_exec[$id]['last'] = time();
991 991
 	} elseif ($value['format'] === 'opensky' && 
992
-	    (
992
+		(
993 993
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
994 994
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
995
-	    )
995
+		)
996 996
 	) {
997
-	    $buffer = $Common->getData($value['host']);
998
-	    $all_data = json_decode($buffer,true);
999
-	    if (isset($all_data['states'])) {
997
+		$buffer = $Common->getData($value['host']);
998
+		$all_data = json_decode($buffer,true);
999
+		if (isset($all_data['states'])) {
1000 1000
 		$reset = 0;
1001 1001
 		foreach ($all_data['states'] as $key => $line) {
1002
-		    $data = array();
1003
-		    $data['hex'] = $line[0]; // hex
1004
-		    $data['ident'] = trim($line[1]); // ident
1005
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1006
-		    $data['speed'] = round($line[9]*1.94384); // speed
1007
-		    $data['heading'] = round($line[10]); // heading
1008
-		    $data['latitude'] = $line[6]; // lat
1009
-		    $data['longitude'] = $line[5]; // long
1010
-		    $data['verticalrate'] = $line[11]; // verticale rate
1011
-		    //$data['squawk'] = $line[10]; // squawk
1012
-		    //$data['emergency'] = ''; // emergency
1013
-		    //$data['registration'] = $line[2];
1014
-		    //$data['aircraft_icao'] = $line[0];
1015
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016
-		    $data['format_source'] = 'opensky';
1017
-		    $data['id_source'] = $id_source;
1018
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1019
-		    $SI->add($data);
1020
-		    unset($data);
1002
+			$data = array();
1003
+			$data['hex'] = $line[0]; // hex
1004
+			$data['ident'] = trim($line[1]); // ident
1005
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1006
+			$data['speed'] = round($line[9]*1.94384); // speed
1007
+			$data['heading'] = round($line[10]); // heading
1008
+			$data['latitude'] = $line[6]; // lat
1009
+			$data['longitude'] = $line[5]; // long
1010
+			$data['verticalrate'] = $line[11]; // verticale rate
1011
+			//$data['squawk'] = $line[10]; // squawk
1012
+			//$data['emergency'] = ''; // emergency
1013
+			//$data['registration'] = $line[2];
1014
+			//$data['aircraft_icao'] = $line[0];
1015
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016
+			$data['format_source'] = 'opensky';
1017
+			$data['id_source'] = $id_source;
1018
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1019
+			$SI->add($data);
1020
+			unset($data);
1021
+		}
1021 1022
 		}
1022
-	    }
1023
-	    //$last_exec['planeupdatefaa'] = time();
1024
-	    $last_exec[$id]['last'] = time();
1023
+		//$last_exec['planeupdatefaa'] = time();
1024
+		$last_exec[$id]['last'] = time();
1025 1025
 	} elseif ($value['format'] === 'aircraftjson' && 
1026
-	    (
1026
+		(
1027 1027
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1028 1028
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1029
-	    )
1029
+		)
1030 1030
 	) {
1031
-	    $buffer = $Common->getData($value['host']);
1032
-	    $all_data = json_decode($buffer,true);
1033
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1031
+		$buffer = $Common->getData($value['host']);
1032
+		$all_data = json_decode($buffer,true);
1033
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1034 1034
 		$reset = 0;
1035 1035
 		foreach ($all_data['aircraft'] as $key => $line) {
1036
-		    $data = array();
1037
-		    // add support for ground vehicule with ~ in front of hex
1038
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1047
-		    //$data['emergency'] = ''; // emergency
1048
-		    //$data['registration'] = $line[2];
1049
-		    //$data['aircraft_icao'] = $line[0];
1050
-		    $data['datetime'] = date('Y-m-d H:i:s');
1051
-		    $data['format_source'] = 'aircraftjson';
1052
-		    $data['id_source'] = $id_source;
1053
-		    if (isset($value['name']) && $value['name'] != '') {
1054
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
-			    else $data['source_name'] = $value['name'];
1056
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
-		    $SI->add($data);
1059
-		    unset($data);
1036
+			$data = array();
1037
+			// add support for ground vehicule with ~ in front of hex
1038
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1047
+			//$data['emergency'] = ''; // emergency
1048
+			//$data['registration'] = $line[2];
1049
+			//$data['aircraft_icao'] = $line[0];
1050
+			$data['datetime'] = date('Y-m-d H:i:s');
1051
+			$data['format_source'] = 'aircraftjson';
1052
+			$data['id_source'] = $id_source;
1053
+			if (isset($value['name']) && $value['name'] != '') {
1054
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
+				else $data['source_name'] = $value['name'];
1056
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
+			$SI->add($data);
1059
+			unset($data);
1060 1060
 		}
1061
-	    }
1062
-	    //$last_exec['planeupdatefaa'] = time();
1063
-	    $last_exec[$id]['last'] = time();
1061
+		}
1062
+		//$last_exec['planeupdatefaa'] = time();
1063
+		$last_exec[$id]['last'] = time();
1064 1064
 	} elseif ($value['format'] === 'planefinderclient' && 
1065
-	    (
1065
+		(
1066 1066
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1067 1067
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1068
-	    )
1068
+		)
1069 1069
 	) {
1070
-	    $buffer = $Common->getData($value['host']);
1071
-	    $all_data = json_decode($buffer,true);
1072
-	    if (isset($all_data['aircraft'])) {
1070
+		$buffer = $Common->getData($value['host']);
1071
+		$all_data = json_decode($buffer,true);
1072
+		if (isset($all_data['aircraft'])) {
1073 1073
 		$reset = 0;
1074 1074
 		foreach ($all_data['aircraft'] as $key => $line) {
1075
-		    $data = array();
1076
-		    $data['hex'] = $key; // hex
1077
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1085
-		    //$data['emergency'] = ''; // emergency
1086
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1088
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089
-		    $data['format_source'] = 'planefinderclient';
1090
-		    $data['id_source'] = $id_source;
1091
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1093
-		    $SI->add($data);
1094
-		    unset($data);
1075
+			$data = array();
1076
+			$data['hex'] = $key; // hex
1077
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1085
+			//$data['emergency'] = ''; // emergency
1086
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1088
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089
+			$data['format_source'] = 'planefinderclient';
1090
+			$data['id_source'] = $id_source;
1091
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1093
+			$SI->add($data);
1094
+			unset($data);
1095 1095
 		}
1096
-	    }
1097
-	    $last_exec[$id]['last'] = time();
1096
+		}
1097
+		$last_exec[$id]['last'] = time();
1098 1098
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1099 1099
 	} elseif ($value['format'] === 'fr24json' && 
1100
-	    (
1100
+		(
1101 1101
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1102 1102
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1103
-	    )
1103
+		)
1104 1104
 	) {
1105
-	    //$buffer = $Common->getData($hosts[$id]);
1106
-	    $buffer = $Common->getData($value['host']);
1107
-	    $all_data = json_decode($buffer,true);
1108
-	    if (!empty($all_data)) $reset = 0;
1109
-	    foreach ($all_data as $key => $line) {
1105
+		//$buffer = $Common->getData($hosts[$id]);
1106
+		$buffer = $Common->getData($value['host']);
1107
+		$all_data = json_decode($buffer,true);
1108
+		if (!empty($all_data)) $reset = 0;
1109
+		foreach ($all_data as $key => $line) {
1110 1110
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1111
-		    $data = array();
1112
-		    $data['hex'] = $line[0];
1113
-		    $data['ident'] = $line[16]; //$line[13]
1114
-	    	    $data['altitude'] = $line[4]; // altitude
1115
-	    	    $data['speed'] = $line[5]; // speed
1116
-	    	    $data['heading'] = $line[3]; // heading
1117
-	    	    $data['latitude'] = $line[1]; // lat
1118
-	    	    $data['longitude'] = $line[2]; // long
1119
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1120
-	    	    $data['squawk'] = $line[6]; // squawk
1121
-	    	    $data['aircraft_icao'] = $line[8];
1122
-	    	    $data['registration'] = $line[9];
1123
-		    $data['departure_airport_iata'] = $line[11];
1124
-		    $data['arrival_airport_iata'] = $line[12];
1125
-	    	    $data['emergency'] = ''; // emergency
1126
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127
-	    	    $data['format_source'] = 'fr24json';
1128
-    		    $data['id_source'] = $id_source;
1129
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131
-		    $SI->add($data);
1132
-		    unset($data);
1111
+			$data = array();
1112
+			$data['hex'] = $line[0];
1113
+			$data['ident'] = $line[16]; //$line[13]
1114
+				$data['altitude'] = $line[4]; // altitude
1115
+				$data['speed'] = $line[5]; // speed
1116
+				$data['heading'] = $line[3]; // heading
1117
+				$data['latitude'] = $line[1]; // lat
1118
+				$data['longitude'] = $line[2]; // long
1119
+				$data['verticalrate'] = $line[15]; // verticale rate
1120
+				$data['squawk'] = $line[6]; // squawk
1121
+				$data['aircraft_icao'] = $line[8];
1122
+				$data['registration'] = $line[9];
1123
+			$data['departure_airport_iata'] = $line[11];
1124
+			$data['arrival_airport_iata'] = $line[12];
1125
+				$data['emergency'] = ''; // emergency
1126
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127
+				$data['format_source'] = 'fr24json';
1128
+				$data['id_source'] = $id_source;
1129
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131
+			$SI->add($data);
1132
+			unset($data);
1133
+		}
1133 1134
 		}
1134
-	    }
1135
-	    //$last_exec['fr24json'] = time();
1136
-	    $last_exec[$id]['last'] = time();
1135
+		//$last_exec['fr24json'] = time();
1136
+		$last_exec[$id]['last'] = time();
1137 1137
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1138 1138
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1139
-	    (
1139
+		(
1140 1140
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1141 1141
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1142
-	    )
1142
+		)
1143 1143
 	) {
1144
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1145
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1146
-	    //echo $buffer;
1147
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1148
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1149
-	    $all_data = json_decode($buffer,true);
1150
-	    if (json_last_error() != JSON_ERROR_NONE) {
1144
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1145
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1146
+		//echo $buffer;
1147
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1148
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1149
+		$all_data = json_decode($buffer,true);
1150
+		if (json_last_error() != JSON_ERROR_NONE) {
1151 1151
 		die(json_last_error_msg());
1152
-	    }
1153
-	    if (isset($all_data['mrkrs'])) {
1152
+		}
1153
+		if (isset($all_data['mrkrs'])) {
1154 1154
 		$reset = 0;
1155 1155
 		foreach ($all_data['mrkrs'] as $key => $line) {
1156
-		    if (isset($line['inf'])) {
1156
+			if (isset($line['inf'])) {
1157 1157
 			$data = array();
1158 1158
 			$data['hex'] = $line['inf']['ia'];
1159 1159
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1160
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1163
-	    		$data['latitude'] = $line['pt'][0]; // lat
1164
-	    		$data['longitude'] = $line['pt'][1]; // long
1165
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1167
-	    		//$data['aircraft_icao'] = $line[8];
1168
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1160
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1163
+				$data['latitude'] = $line['pt'][0]; // lat
1164
+				$data['longitude'] = $line['pt'][1]; // long
1165
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1167
+				//$data['aircraft_icao'] = $line[8];
1168
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1169 1169
 			//$data['departure_airport_iata'] = $line[11];
1170 1170
 			//$data['arrival_airport_iata'] = $line[12];
1171
-	    		//$data['emergency'] = ''; // emergency
1171
+				//$data['emergency'] = ''; // emergency
1172 1172
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1173
-	    		$data['format_source'] = 'radarvirtueljson';
1174
-    			$data['id_source'] = $id_source;
1173
+				$data['format_source'] = 'radarvirtueljson';
1174
+				$data['id_source'] = $id_source;
1175 1175
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176 1176
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1177 1177
 			$SI->add($data);
1178 1178
 			unset($data);
1179
-		    }
1179
+			}
1180 1180
 		}
1181
-	    }
1182
-	    //$last_exec['radarvirtueljson'] = time();
1183
-	    $last_exec[$id]['last'] = time();
1181
+		}
1182
+		//$last_exec['radarvirtueljson'] = time();
1183
+		$last_exec[$id]['last'] = time();
1184 1184
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1185 1185
 	} elseif ($value['format'] === 'pirepsjson' && 
1186
-	    (
1186
+		(
1187 1187
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1188 1188
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1189
-	    )
1189
+		)
1190 1190
 	) {
1191
-	    //$buffer = $Common->getData($hosts[$id]);
1192
-	    $buffer = $Common->getData($value['host'].'?'.time());
1193
-	    $all_data = json_decode(utf8_encode($buffer),true);
1191
+		//$buffer = $Common->getData($hosts[$id]);
1192
+		$buffer = $Common->getData($value['host'].'?'.time());
1193
+		$all_data = json_decode(utf8_encode($buffer),true);
1194 1194
 	    
1195
-	    if (isset($all_data['pireps'])) {
1195
+		if (isset($all_data['pireps'])) {
1196 1196
 		$reset = 0;
1197
-	        foreach ($all_data['pireps'] as $line) {
1198
-		    $data = array();
1199
-		    $data['id'] = $line['id'];
1200
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201
-		    $data['ident'] = $line['callsign']; // ident
1202
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1208
-		    $data['latitude'] = $line['lat']; // lat
1209
-		    $data['longitude'] = $line['lon']; // long
1210
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1211
-		    //$data['squawk'] = $line['squawk']; // squawk
1212
-		    //$data['emergency'] = ''; // emergency
1213
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1216
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1217
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
-		    else $data['info'] = '';
1221
-		    $data['format_source'] = 'pireps';
1222
-    		    $data['id_source'] = $id_source;
1223
-		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226
-		    if ($line['icon'] === 'plane') {
1197
+			foreach ($all_data['pireps'] as $line) {
1198
+			$data = array();
1199
+			$data['id'] = $line['id'];
1200
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201
+			$data['ident'] = $line['callsign']; // ident
1202
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1208
+			$data['latitude'] = $line['lat']; // lat
1209
+			$data['longitude'] = $line['lon']; // long
1210
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1211
+			//$data['squawk'] = $line['squawk']; // squawk
1212
+			//$data['emergency'] = ''; // emergency
1213
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1216
+			//$data['arrival_airport_time'] = $line['arrtime'];
1217
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
+			else $data['info'] = '';
1221
+			$data['format_source'] = 'pireps';
1222
+				$data['id_source'] = $id_source;
1223
+			$data['datetime'] = date('Y-m-d H:i:s');
1224
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226
+			if ($line['icon'] === 'plane') {
1227 1227
 			$SI->add($data);
1228
-		    //    print_r($data);
1229
-    		    } elseif ($line['icon'] === 'ct') {
1228
+			//    print_r($data);
1229
+				} elseif ($line['icon'] === 'ct') {
1230 1230
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1231 1231
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1232 1232
 			$typec = substr($data['ident'],-3);
@@ -1241,209 +1241,209 @@  discard block
 block discarded – undo
1241 1241
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1242 1242
 			else $data['type'] = 'Observer';
1243 1243
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1244
-		    }
1245
-		    unset($data);
1244
+			}
1245
+			unset($data);
1246 1246
 		}
1247
-	    }
1248
-	    //$last_exec['pirepsjson'] = time();
1249
-	    $last_exec[$id]['last'] = time();
1247
+		}
1248
+		//$last_exec['pirepsjson'] = time();
1249
+		$last_exec[$id]['last'] = time();
1250 1250
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1251 1251
 	} elseif ($value['format'] === 'phpvmacars' && 
1252
-	    (
1252
+		(
1253 1253
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1254 1254
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1255
-	    )
1255
+		)
1256 1256
 	) {
1257
-	    //$buffer = $Common->getData($hosts[$id]);
1258
-	    if ($globalDebug) echo 'Get Data...'."\n";
1259
-	    $buffer = $Common->getData($value['host']);
1260
-	    $all_data = json_decode($buffer,true);
1261
-	    if ($buffer != '' && is_array($all_data)) {
1257
+		//$buffer = $Common->getData($hosts[$id]);
1258
+		if ($globalDebug) echo 'Get Data...'."\n";
1259
+		$buffer = $Common->getData($value['host']);
1260
+		$all_data = json_decode($buffer,true);
1261
+		if ($buffer != '' && is_array($all_data)) {
1262 1262
 		$reset = 0;
1263 1263
 		foreach ($all_data as $line) {
1264
-	    	    $data = array();
1265
-	    	    //$data['id'] = $line['id']; // id not usable
1266
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1267
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1270
-	    	    $data['ident'] = $line['flightnum']; // ident
1271
-	    	    $data['altitude'] = $line['alt']; // altitude
1272
-	    	    $data['speed'] = $line['gs']; // speed
1273
-	    	    $data['heading'] = $line['heading']; // heading
1274
-	    	    $data['latitude'] = $line['lat']; // lat
1275
-	    	    $data['longitude'] = $line['lng']; // long
1276
-	    	    $data['verticalrate'] = ''; // verticale rate
1277
-	    	    $data['squawk'] = ''; // squawk
1278
-	    	    $data['emergency'] = ''; // emergency
1279
-	    	    //$data['datetime'] = $line['lastupdate'];
1280
-	    	    //$data['last_update'] = $line['lastupdate'];
1281
-	    	    if (isset($value['timezone'])) {
1282
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1284
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1286
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1287
-	    	    $data['departure_airport_time'] = $line['deptime'];
1288
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1289
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1290
-    		    if (isset($line['registration'])) {
1291
-    			$data['registration'] = $line['registration'];
1292
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
-    		    } else $data['registration'] = $line['aircraft'];
1294
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1296
-		    if (isset($line['aircraftname'])) {
1264
+				$data = array();
1265
+				//$data['id'] = $line['id']; // id not usable
1266
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1267
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1270
+				$data['ident'] = $line['flightnum']; // ident
1271
+				$data['altitude'] = $line['alt']; // altitude
1272
+				$data['speed'] = $line['gs']; // speed
1273
+				$data['heading'] = $line['heading']; // heading
1274
+				$data['latitude'] = $line['lat']; // lat
1275
+				$data['longitude'] = $line['lng']; // long
1276
+				$data['verticalrate'] = ''; // verticale rate
1277
+				$data['squawk'] = ''; // squawk
1278
+				$data['emergency'] = ''; // emergency
1279
+				//$data['datetime'] = $line['lastupdate'];
1280
+				//$data['last_update'] = $line['lastupdate'];
1281
+				if (isset($value['timezone'])) {
1282
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1284
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1286
+				$data['departure_airport_icao'] = $line['depicao'];
1287
+				$data['departure_airport_time'] = $line['deptime'];
1288
+				$data['arrival_airport_icao'] = $line['arricao'];
1289
+				$data['arrival_airport_time'] = $line['arrtime'];
1290
+				if (isset($line['registration'])) {
1291
+				$data['registration'] = $line['registration'];
1292
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
+				} else $data['registration'] = $line['aircraft'];
1294
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1296
+			if (isset($line['aircraftname'])) {
1297 1297
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1298 1298
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1299
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1300
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
-	    		else {
1303
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1304
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1306
-	    		}
1307
-	    	    }
1308
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1309
-    		    $data['id_source'] = $id_source;
1310
-	    	    $data['format_source'] = 'phpvmacars';
1311
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1312
-		    $SI->add($data);
1313
-		    unset($data);
1299
+				$aircraft_data = explode('-',$line['aircraftname']);
1300
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
+				else {
1303
+					$aircraft_data = explode(' ',$line['aircraftname']);
1304
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1306
+				}
1307
+				}
1308
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1309
+				$data['id_source'] = $id_source;
1310
+				$data['format_source'] = 'phpvmacars';
1311
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1312
+			$SI->add($data);
1313
+			unset($data);
1314 1314
 		}
1315 1315
 		if ($globalDebug) echo 'No more data...'."\n";
1316 1316
 		unset($buffer);
1317 1317
 		unset($all_data);
1318
-	    }
1319
-	    //$last_exec['phpvmacars'] = time();
1320
-	    $last_exec[$id]['last'] = time();
1318
+		}
1319
+		//$last_exec['phpvmacars'] = time();
1320
+		$last_exec[$id]['last'] = time();
1321 1321
 	} elseif ($value['format'] === 'vaos' && 
1322
-	    (
1322
+		(
1323 1323
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1324 1324
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1325
-	    )
1325
+		)
1326 1326
 	) {
1327
-	    //$buffer = $Common->getData($hosts[$id]);
1328
-	    if ($globalDebug) echo 'Get Data...'."\n";
1329
-	    $buffer = $Common->getData($value['host']);
1330
-	    $all_data = json_decode($buffer,true);
1331
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1327
+		//$buffer = $Common->getData($hosts[$id]);
1328
+		if ($globalDebug) echo 'Get Data...'."\n";
1329
+		$buffer = $Common->getData($value['host']);
1330
+		$all_data = json_decode($buffer,true);
1331
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1332 1332
 		$reset = 0;
1333 1333
 		foreach ($all_data['ACARSData'] as $line) {
1334
-		    //print_r($line);
1335
-	    	    $data = array();
1336
-	    	    //$data['id'] = $line['id']; // id not usable
1337
-	    	    $data['id'] = $line['id'];
1338
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1341
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1343
-	    	    $data['altitude'] = $line['altitude']; // altitude
1344
-	    	    $data['speed'] = $line['groundspeed']; // speed
1345
-	    	    $data['heading'] = $line['heading']; // heading
1346
-	    	    $data['latitude'] = $line['lat']; // lat
1347
-	    	    $data['longitude'] = $line['lon']; // long
1348
-	    	    //$data['verticalrate'] = ''; // verticale rate
1349
-	    	    //$data['squawk'] = ''; // squawk
1350
-	    	    //$data['emergency'] = ''; // emergency
1351
-	    	    if (isset($value['timezone'])) {
1352
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1354
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1334
+			//print_r($line);
1335
+				$data = array();
1336
+				//$data['id'] = $line['id']; // id not usable
1337
+				$data['id'] = $line['id'];
1338
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1341
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1343
+				$data['altitude'] = $line['altitude']; // altitude
1344
+				$data['speed'] = $line['groundspeed']; // speed
1345
+				$data['heading'] = $line['heading']; // heading
1346
+				$data['latitude'] = $line['lat']; // lat
1347
+				$data['longitude'] = $line['lon']; // long
1348
+				//$data['verticalrate'] = ''; // verticale rate
1349
+				//$data['squawk'] = ''; // squawk
1350
+				//$data['emergency'] = ''; // emergency
1351
+				if (isset($value['timezone'])) {
1352
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1354
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1356 1356
 	    	    
1357
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1359
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1360
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1361
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1357
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1359
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1360
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1361
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1362 1362
 
1363
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1365
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1363
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1365
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1366 1366
 
1367
-    		    $data['id_source'] = $id_source;
1368
-	    	    $data['format_source'] = 'vaos';
1369
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1370
-		    $SI->add($data);
1371
-		    unset($data);
1367
+				$data['id_source'] = $id_source;
1368
+				$data['format_source'] = 'vaos';
1369
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1370
+			$SI->add($data);
1371
+			unset($data);
1372 1372
 		}
1373 1373
 		if ($globalDebug) echo 'No more data...'."\n";
1374 1374
 		unset($buffer);
1375 1375
 		unset($all_data);
1376
-	    }
1377
-	    //$last_exec['phpvmacars'] = time();
1378
-	    $last_exec[$id]['last'] = time();
1376
+		}
1377
+		//$last_exec['phpvmacars'] = time();
1378
+		$last_exec[$id]['last'] = time();
1379 1379
 	} elseif ($value['format'] === 'vam' && 
1380
-	    (
1380
+		(
1381 1381
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1382 1382
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1383
-	    )
1383
+		)
1384 1384
 	) {
1385
-	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1387
-	    $buffer = $Common->getData($value['host']);
1388
-	    $all_data = json_decode($buffer,true);
1389
-	    if ($buffer != '' && is_array($all_data)) {
1385
+		//$buffer = $Common->getData($hosts[$id]);
1386
+		if ($globalDebug) echo 'Get Data...'."\n";
1387
+		$buffer = $Common->getData($value['host']);
1388
+		$all_data = json_decode($buffer,true);
1389
+		if ($buffer != '' && is_array($all_data)) {
1390 1390
 		$reset = 0;
1391 1391
 		foreach ($all_data as $line) {
1392
-	    	    $data = array();
1393
-	    	    //$data['id'] = $line['id']; // id not usable
1394
-	    	    $data['id'] = trim($line['flight_id']);
1395
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
-	    	    $data['pilot_name'] = $line['pilot_name'];
1397
-	    	    $data['pilot_id'] = $line['pilot_id'];
1398
-	    	    $data['ident'] = trim($line['callsign']); // ident
1399
-	    	    $data['altitude'] = $line['altitude']; // altitude
1400
-	    	    $data['speed'] = $line['gs']; // speed
1401
-	    	    $data['heading'] = $line['heading']; // heading
1402
-	    	    $data['latitude'] = $line['latitude']; // lat
1403
-	    	    $data['longitude'] = $line['longitude']; // long
1404
-	    	    $data['verticalrate'] = ''; // verticale rate
1405
-	    	    $data['squawk'] = ''; // squawk
1406
-	    	    $data['emergency'] = ''; // emergency
1407
-	    	    //$data['datetime'] = $line['lastupdate'];
1408
-	    	    $data['last_update'] = $line['last_update'];
1409
-		    $data['datetime'] = date('Y-m-d H:i:s');
1410
-	    	    $data['departure_airport_icao'] = $line['departure'];
1411
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1412
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1413
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1414
-    		    //$data['registration'] = $line['aircraft'];
1415
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1416
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1417
-    		    $data['id_source'] = $id_source;
1418
-	    	    $data['format_source'] = 'vam';
1419
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1421
-		    $SI->add($data);
1422
-		    unset($data);
1392
+				$data = array();
1393
+				//$data['id'] = $line['id']; // id not usable
1394
+				$data['id'] = trim($line['flight_id']);
1395
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
+				$data['pilot_name'] = $line['pilot_name'];
1397
+				$data['pilot_id'] = $line['pilot_id'];
1398
+				$data['ident'] = trim($line['callsign']); // ident
1399
+				$data['altitude'] = $line['altitude']; // altitude
1400
+				$data['speed'] = $line['gs']; // speed
1401
+				$data['heading'] = $line['heading']; // heading
1402
+				$data['latitude'] = $line['latitude']; // lat
1403
+				$data['longitude'] = $line['longitude']; // long
1404
+				$data['verticalrate'] = ''; // verticale rate
1405
+				$data['squawk'] = ''; // squawk
1406
+				$data['emergency'] = ''; // emergency
1407
+				//$data['datetime'] = $line['lastupdate'];
1408
+				$data['last_update'] = $line['last_update'];
1409
+			$data['datetime'] = date('Y-m-d H:i:s');
1410
+				$data['departure_airport_icao'] = $line['departure'];
1411
+				//$data['departure_airport_time'] = $line['departure_time'];
1412
+				$data['arrival_airport_icao'] = $line['arrival'];
1413
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1414
+				//$data['registration'] = $line['aircraft'];
1415
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1416
+				$data['aircraft_icao'] = $line['plane_type'];
1417
+				$data['id_source'] = $id_source;
1418
+				$data['format_source'] = 'vam';
1419
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1421
+			$SI->add($data);
1422
+			unset($data);
1423 1423
 		}
1424 1424
 		if ($globalDebug) echo 'No more data...'."\n";
1425 1425
 		unset($buffer);
1426 1426
 		unset($all_data);
1427
-	    }
1428
-	    //$last_exec['phpvmacars'] = time();
1429
-	    $last_exec[$id]['last'] = time();
1427
+		}
1428
+		//$last_exec['phpvmacars'] = time();
1429
+		$last_exec[$id]['last'] = time();
1430 1430
 	} elseif ($value['format'] === 'blitzortung' && 
1431
-	    (
1431
+		(
1432 1432
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1433 1433
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1434
-	    )
1434
+		)
1435 1435
 	) {
1436
-	    //$buffer = $Common->getData($hosts[$id]);
1437
-	    if ($globalDebug) echo 'Get Data...'."\n";
1438
-	    $buffer = $Common->getData($value['host']);
1439
-	    $all_data = json_decode($buffer,true);
1440
-	    if ($buffer != '') {
1436
+		//$buffer = $Common->getData($hosts[$id]);
1437
+		if ($globalDebug) echo 'Get Data...'."\n";
1438
+		$buffer = $Common->getData($value['host']);
1439
+		$all_data = json_decode($buffer,true);
1440
+		if ($buffer != '') {
1441 1441
 		$Source->deleteLocationBySource('blitzortung');
1442 1442
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1443 1443
 		$buffer = explode('\n',$buffer);
1444 1444
 		foreach ($buffer as $buffer_line) {
1445
-		    $line = json_decode($buffer_line,true);
1446
-		    if (isset($line['time'])) {
1445
+			$line = json_decode($buffer_line,true);
1446
+			if (isset($line['time'])) {
1447 1447
 			$data = array();
1448 1448
 			$data['altitude'] = $line['alt']; // altitude
1449 1449
 			$data['latitude'] = $line['lat']; // lat
@@ -1455,94 +1455,94 @@  discard block
 block discarded – undo
1455 1455
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1456 1456
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1457 1457
 			unset($data);
1458
-		    }
1458
+			}
1459 1459
 		}
1460 1460
 		if ($globalDebug) echo 'No more data...'."\n";
1461 1461
 		unset($buffer);
1462
-	    }
1463
-	    $last_exec[$id]['last'] = time();
1462
+		}
1463
+		$last_exec[$id]['last'] = time();
1464 1464
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1465 1465
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1466
-	    //$last_exec[$id]['last'] = time();
1467
-	    //$read = array( $sockets[$id] );
1468
-	    $read = $sockets;
1469
-	    $write = NULL;
1470
-	    $e = NULL;
1471
-	    $n = socket_select($read, $write, $e, $timeout);
1472
-	    if ($e != NULL) var_dump($e);
1473
-	    if ($n > 0) {
1466
+		//$last_exec[$id]['last'] = time();
1467
+		//$read = array( $sockets[$id] );
1468
+		$read = $sockets;
1469
+		$write = NULL;
1470
+		$e = NULL;
1471
+		$n = socket_select($read, $write, $e, $timeout);
1472
+		if ($e != NULL) var_dump($e);
1473
+		if ($n > 0) {
1474 1474
 		$reset = 0;
1475 1475
 		foreach ($read as $nb => $r) {
1476
-		    //$value = $formats[$nb];
1477
-		    $format = $globalSources[$nb]['format'];
1478
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1476
+			//$value = $formats[$nb];
1477
+			$format = $globalSources[$nb]['format'];
1478
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1479 1479
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1480
-		    } elseif ($format === 'vrstcp') {
1480
+			} elseif ($format === 'vrstcp') {
1481 1481
 			$buffer = @socket_read($r, 6000);
1482
-		    } else {
1482
+			} else {
1483 1483
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1484
-		    }
1485
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1486
-		    //echo $buffer."\n";
1487
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1488
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1489
-		    $error = false;
1490
-		    //$SI::del();
1491
-		    if ($buffer !== FALSE) {
1484
+			}
1485
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1486
+			//echo $buffer."\n";
1487
+			// lets play nice and handle signals such as ctrl-c/kill properly
1488
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1489
+			$error = false;
1490
+			//$SI::del();
1491
+			if ($buffer !== FALSE) {
1492 1492
 			if ($format === 'vrstcp') {
1493
-			    $buffer = explode('},{',$buffer);
1493
+				$buffer = explode('},{',$buffer);
1494 1494
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1495
-		    }
1496
-		    // SBS format is CSV format
1497
-		    if ($buffer !== FALSE && $buffer !== '') {
1495
+			}
1496
+			// SBS format is CSV format
1497
+			if ($buffer !== FALSE && $buffer !== '') {
1498 1498
 			$tt[$format] = 0;
1499 1499
 			if ($format === 'acarssbs3') {
1500
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1501
-			    $ACARS->add(trim($buffer));
1502
-			    $ACARS->deleteLiveAcarsData();
1500
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1501
+				$ACARS->add(trim($buffer));
1502
+				$ACARS->deleteLiveAcarsData();
1503 1503
 			} elseif ($format === 'raw') {
1504
-			    // AVR format
1505
-			    $data = $SBS->parse($buffer);
1506
-			    if (is_array($data)) {
1504
+				// AVR format
1505
+				$data = $SBS->parse($buffer);
1506
+				if (is_array($data)) {
1507 1507
 				$data['datetime'] = date('Y-m-d H:i:s');
1508 1508
 				$data['format_source'] = 'raw';
1509 1509
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1510 1510
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1511 1511
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1512 1512
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1513
-			    }
1513
+				}
1514 1514
 			} elseif ($format === 'ais') {
1515
-			    $ais_data = $AIS->parse_line(trim($buffer));
1516
-			    $data = array();
1517
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1515
+				$ais_data = $AIS->parse_line(trim($buffer));
1516
+				$data = array();
1517
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1533 1533
 
1534
-			    if (isset($ais_data['timestamp'])) {
1534
+				if (isset($ais_data['timestamp'])) {
1535 1535
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1536
-			    } else {
1536
+				} else {
1537 1537
 				$data['datetime'] = date('Y-m-d H:i:s');
1538
-			    }
1539
-			    $data['format_source'] = 'aisnmea';
1540
-    			    $data['id_source'] = $id_source;
1541
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1542
-			    unset($data);
1543
-                        } elseif ($format === 'flightgearsp') {
1544
-                    	    //echo $buffer."\n";
1545
-                    	    if (strlen($buffer) > 5) {
1538
+				}
1539
+				$data['format_source'] = 'aisnmea';
1540
+					$data['id_source'] = $id_source;
1541
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1542
+				unset($data);
1543
+						} elseif ($format === 'flightgearsp') {
1544
+							//echo $buffer."\n";
1545
+							if (strlen($buffer) > 5) {
1546 1546
 				$line = explode(',',$buffer);
1547 1547
 				$data = array();
1548 1548
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1559,38 +1559,38 @@  discard block
 block discarded – undo
1559 1559
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1560 1560
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1561 1561
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1562
-			    }
1563
-                        } elseif ($format === 'acars') {
1564
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1565
-			    $ACARS->add(trim($buffer));
1566
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567
-			    $ACARS->deleteLiveAcarsData();
1562
+				}
1563
+						} elseif ($format === 'acars') {
1564
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1565
+				$ACARS->add(trim($buffer));
1566
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567
+				$ACARS->deleteLiveAcarsData();
1568 1568
 			} elseif ($format === 'flightgearmp') {
1569
-			    if (substr($buffer,0,1) != '#') {
1569
+				if (substr($buffer,0,1) != '#') {
1570 1570
 				$data = array();
1571 1571
 				//echo $buffer."\n";
1572 1572
 				$line = explode(' ',$buffer);
1573 1573
 				if (count($line) === 11) {
1574
-				    $userserver = explode('@',$line[0]);
1575
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1576
-				    $data['ident'] = $userserver[0];
1577
-				    $data['registration'] = $userserver[0];
1578
-				    $data['latitude'] = $line[4];
1579
-				    $data['longitude'] = $line[5];
1580
-				    $data['altitude'] = $line[6];
1581
-				    $data['datetime'] = date('Y-m-d H:i:s');
1582
-				    $aircraft_type = $line[10];
1583
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1584
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1574
+					$userserver = explode('@',$line[0]);
1575
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1576
+					$data['ident'] = $userserver[0];
1577
+					$data['registration'] = $userserver[0];
1578
+					$data['latitude'] = $line[4];
1579
+					$data['longitude'] = $line[5];
1580
+					$data['altitude'] = $line[6];
1581
+					$data['datetime'] = date('Y-m-d H:i:s');
1582
+					$aircraft_type = $line[10];
1583
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1584
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1587
+				}
1587 1588
 				}
1588
-			    }
1589 1589
 			} elseif ($format === 'beast') {
1590
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1591
-			    die;
1590
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1591
+				die;
1592 1592
 			} elseif ($format === 'vrstcp') {
1593
-			    foreach($buffer as $all_data) {
1593
+				foreach($buffer as $all_data) {
1594 1594
 				$line = json_decode('{'.$all_data.'}',true);
1595 1595
 				$data = array();
1596 1596
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1610,153 +1610,153 @@  discard block
 block discarded – undo
1610 1610
 				*/
1611 1611
 				$data['datetime'] = date('Y-m-d H:i:s');
1612 1612
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1613
-		    		$data['format_source'] = 'vrstcp';
1613
+					$data['format_source'] = 'vrstcp';
1614 1614
 				$data['id_source'] = $id_source;
1615 1615
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1616 1616
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1617 1617
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1618 1618
 				unset($data);
1619
-			    }
1619
+				}
1620 1620
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1621
-			    $line = explode("\t", $buffer);
1622
-			    for($k = 0; $k < count($line); $k=$k+2) {
1621
+				$line = explode("\t", $buffer);
1622
+				for($k = 0; $k < count($line); $k=$k+2) {
1623 1623
 				$key = $line[$k];
1624
-			        $lined[$key] = $line[$k+1];
1625
-			    }
1626
-    			    if (count($lined) > 3) {
1627
-    				$data['hex'] = $lined['hexid'];
1628
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1630
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1637
-    				$data['id_source'] = $id_source;
1638
-    				$data['format_source'] = 'tsv';
1639
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1624
+					$lined[$key] = $line[$k+1];
1625
+				}
1626
+					if (count($lined) > 3) {
1627
+					$data['hex'] = $lined['hexid'];
1628
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629
+					$data['datetime'] = date('Y-m-d H:i:s');;
1630
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1637
+					$data['id_source'] = $id_source;
1638
+					$data['format_source'] = 'tsv';
1639
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1641 1641
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1642
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1643
-    				unset($lined);
1644
-    				unset($data);
1645
-    			    } else $error = true;
1642
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1643
+					unset($lined);
1644
+					unset($data);
1645
+					} else $error = true;
1646 1646
 			} elseif ($format === 'aprs' && $use_aprs) {
1647
-			    if ($aprs_connect === 0) {
1647
+				if ($aprs_connect === 0) {
1648 1648
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1649 1649
 				$aprs_connect = 1;
1650
-			    }
1650
+				}
1651 1651
 			    
1652
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1652
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1653 1653
 				$aprs_last_tx = time();
1654 1654
 				$data_aprs = "# Keep alive";
1655 1655
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1656
-			    }
1656
+				}
1657 1657
 			    
1658
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1659
-			    //echo 'APRS data : '.$buffer."\n";
1660
-			    $buffer = str_replace('APRS <- ','',$buffer);
1661
-			    $buffer = str_replace('APRS -> ','',$buffer);
1662
-			    //echo $buffer."\n";
1663
-			    date_default_timezone_set('UTC');
1664
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1658
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1659
+				//echo 'APRS data : '.$buffer."\n";
1660
+				$buffer = str_replace('APRS <- ','',$buffer);
1661
+				$buffer = str_replace('APRS -> ','',$buffer);
1662
+				//echo $buffer."\n";
1663
+				date_default_timezone_set('UTC');
1664
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1665 1665
 				$line = $APRS->parse($buffer);
1666 1666
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1667 1667
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1668
-				    $aprs_last_tx = time();
1669
-				    $data = array();
1670
-				    //print_r($line);
1671
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1672
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1681
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1682
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1683
-				    $data['latitude'] = $line['latitude'];
1684
-				    $data['longitude'] = $line['longitude'];
1685
-				    //$data['verticalrate'] = $line[16];
1686
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1687
-				    //else $data['speed'] = 0;
1688
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1691
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1668
+					$aprs_last_tx = time();
1669
+					$data = array();
1670
+					//print_r($line);
1671
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1672
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
+					else $data['datetime'] = date('Y-m-d H:i:s');
1681
+					//$data['datetime'] = date('Y-m-d H:i:s');
1682
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1683
+					$data['latitude'] = $line['latitude'];
1684
+					$data['longitude'] = $line['longitude'];
1685
+					//$data['verticalrate'] = $line[16];
1686
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1687
+					//else $data['speed'] = 0;
1688
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1691
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1692 1692
 				    
1693
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1694
-				    //else echo 'No heading...'."\n";
1695
-				    //else $data['heading'] = 0;
1696
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1697
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1702
-    				    $data['id_source'] = $id_source;
1703
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
-				    else $data['format_source'] = 'aprs';
1705
-				    $data['source_name'] = $line['source'];
1706
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
-				    else $data['source_type'] = 'flarm';
1708
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1709
-				    $currentdate = date('Y-m-d H:i:s');
1710
-				    $aprsdate = strtotime($data['datetime']);
1711
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1712
-				    // Accept data if time <= system time + 20s
1713
-				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1714
-				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1693
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1694
+					//else echo 'No heading...'."\n";
1695
+					//else $data['heading'] = 0;
1696
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1697
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1702
+						$data['id_source'] = $id_source;
1703
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
+					else $data['format_source'] = 'aprs';
1705
+					$data['source_name'] = $line['source'];
1706
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
+					else $data['source_type'] = 'flarm';
1708
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1709
+					$currentdate = date('Y-m-d H:i:s');
1710
+					$aprsdate = strtotime($data['datetime']);
1711
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1712
+					// Accept data if time <= system time + 20s
1713
+					//if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1714
+					if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1715 1715
 					$send = $SI->add($data);
1716
-				    } elseif ($data['source_type'] === 'ais') {
1716
+					} elseif ($data['source_type'] === 'ais') {
1717 1717
 					$data['type'] = '';
1718 1718
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1719
-				    } elseif (isset($line['stealth'])) {
1719
+					} elseif (isset($line['stealth'])) {
1720 1720
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1721 1721
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1722
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723
-					    //$line['symbol'] === 'Balloon' ||
1724
-					    $line['symbol'] === 'Glider' || 
1725
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1728
-					    $send = $SI->add($data);
1729
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730
-					    $line['symbol'] === 'Yacht (Sail)' || 
1731
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1732
-					    $send = $MI->add($data);
1733
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1734
-					    $line['symbol'] === 'Car' || 
1735
-					    $line['symbol'] === 'Ambulance' || 
1736
-					    $line['symbol'] === 'Van' || 
1737
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1738
-					    $line['symbol'] === 'Motorcycle' || 
1739
-					    $line['symbol'] === 'Tractor' || 
1740
-					    $line['symbol'] === 'Police' || 
1741
-					    $line['symbol'] === 'Bike' || 
1742
-					    $line['symbol'] === 'Jogger' || 
1743
-					    $line['symbol'] === 'Horse' || 
1744
-					    $line['symbol'] === 'Bus' || 
1745
-					    $line['symbol'] === 'Jeep' || 
1746
-					    $line['symbol'] === 'Recreational Vehicle' || 
1747
-					    $line['symbol'] === 'Yacht (Sail)' || 
1748
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1749
-					    $line['symbol'] === 'Firetruck' || 
1750
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1751
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1752
-					    $line['symbol'] === 'SUV' ||
1753
-					    $line['symbol'] === 'Snowmobile' ||
1754
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1755
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1722
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723
+						//$line['symbol'] === 'Balloon' ||
1724
+						$line['symbol'] === 'Glider' || 
1725
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1728
+						$send = $SI->add($data);
1729
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730
+						$line['symbol'] === 'Yacht (Sail)' || 
1731
+						$line['symbol'] === 'Ship (Power Boat)')) {
1732
+						$send = $MI->add($data);
1733
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1734
+						$line['symbol'] === 'Car' || 
1735
+						$line['symbol'] === 'Ambulance' || 
1736
+						$line['symbol'] === 'Van' || 
1737
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1738
+						$line['symbol'] === 'Motorcycle' || 
1739
+						$line['symbol'] === 'Tractor' || 
1740
+						$line['symbol'] === 'Police' || 
1741
+						$line['symbol'] === 'Bike' || 
1742
+						$line['symbol'] === 'Jogger' || 
1743
+						$line['symbol'] === 'Horse' || 
1744
+						$line['symbol'] === 'Bus' || 
1745
+						$line['symbol'] === 'Jeep' || 
1746
+						$line['symbol'] === 'Recreational Vehicle' || 
1747
+						$line['symbol'] === 'Yacht (Sail)' || 
1748
+						$line['symbol'] === 'Ship (Power Boat)' || 
1749
+						$line['symbol'] === 'Firetruck' || 
1750
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1751
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1752
+						$line['symbol'] === 'SUV' ||
1753
+						$line['symbol'] === 'Snowmobile' ||
1754
+						$line['symbol'] === 'Mobile Satellite Station')) {
1755
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1756 1756
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1757 1757
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1758 1758
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1759
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1759
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1760 1760
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1761 1761
 					$Source->deleteOldLocationByType('gs');
1762 1762
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
 					} else {
1765 1765
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1766 1766
 					}
1767
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1767
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1768 1768
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1769 1769
 					if ($globalDebug) echo '# Weather Station added'."\n";
1770 1770
 					$Source->deleteOldLocationByType('wx');
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 					} else {
1775 1775
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1776 1776
 					}
1777
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1777
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1778 1778
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1779 1779
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1780 1780
 					$Source->deleteOldLocationByType('lightning');
@@ -1783,11 +1783,11 @@  discard block
 block discarded – undo
1783 1783
 					} else {
1784 1784
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1785 1785
 					}
1786
-				    } elseif ($globalDebug) {
1787
-				    	echo '/!\ Not added: '.$buffer."\n";
1788
-				    	print_r($line);
1789
-				    }
1790
-				    unset($data);
1786
+					} elseif ($globalDebug) {
1787
+						echo '/!\ Not added: '.$buffer."\n";
1788
+						print_r($line);
1789
+					}
1790
+					unset($data);
1791 1791
 				}
1792 1792
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1793 1793
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1806,12 +1806,12 @@  discard block
 block discarded – undo
1806 1806
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1807 1807
 					$globalSources[$nb]['last_weather_clean'] = time();
1808 1808
 				}
1809
-			    }
1809
+				}
1810 1810
 			} else {
1811
-			    $line = explode(',', $buffer);
1812
-    			    if (count($line) > 20) {
1813
-    			    	$data['hex'] = $line[4];
1814
-    				/*
1811
+				$line = explode(',', $buffer);
1812
+					if (count($line) > 20) {
1813
+						$data['hex'] = $line[4];
1814
+					/*
1815 1815
     				$data['datetime'] = $line[6].' '.$line[7];
1816 1816
     					date_default_timezone_set($globalTimezone);
1817 1817
     					$datetime = new DateTime($data['datetime']);
@@ -1819,31 +1819,31 @@  discard block
 block discarded – undo
1819 1819
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1820 1820
     					date_default_timezone_set('UTC');
1821 1821
     				*/
1822
-    				// Force datetime to current UTC datetime
1823
-    				date_default_timezone_set('UTC');
1824
-    				$data['datetime'] = date('Y-m-d H:i:s');
1825
-    				$data['ident'] = trim($line[10]);
1826
-    				$data['latitude'] = $line[14];
1827
-    				$data['longitude'] = $line[15];
1828
-    				$data['verticalrate'] = $line[16];
1829
-    				$data['emergency'] = $line[20];
1830
-    				$data['speed'] = $line[12];
1831
-    				$data['squawk'] = $line[17];
1832
-    				$data['altitude'] = $line[11];
1833
-    				$data['heading'] = $line[13];
1834
-    				$data['ground'] = $line[21];
1835
-    				$data['emergency'] = $line[19];
1836
-    				$data['format_source'] = 'sbs';
1822
+					// Force datetime to current UTC datetime
1823
+					date_default_timezone_set('UTC');
1824
+					$data['datetime'] = date('Y-m-d H:i:s');
1825
+					$data['ident'] = trim($line[10]);
1826
+					$data['latitude'] = $line[14];
1827
+					$data['longitude'] = $line[15];
1828
+					$data['verticalrate'] = $line[16];
1829
+					$data['emergency'] = $line[20];
1830
+					$data['speed'] = $line[12];
1831
+					$data['squawk'] = $line[17];
1832
+					$data['altitude'] = $line[11];
1833
+					$data['heading'] = $line[13];
1834
+					$data['ground'] = $line[21];
1835
+					$data['emergency'] = $line[19];
1836
+					$data['format_source'] = 'sbs';
1837 1837
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1838 1838
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1839
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1839
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1840 1840
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1841
-    				$data['id_source'] = $id_source;
1842
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1843
-    				else $error = true;
1844
-    				unset($data);
1845
-    			    } else $error = true;
1846
-			    if ($error) {
1841
+					$data['id_source'] = $id_source;
1842
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1843
+					else $error = true;
1844
+					unset($data);
1845
+					} else $error = true;
1846
+				if ($error) {
1847 1847
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1848 1848
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1849 1849
 				} else {
@@ -1859,13 +1859,13 @@  discard block
 block discarded – undo
1859 1859
 					connect_all($sourceer);
1860 1860
 					$sourceer = array();
1861 1861
 				}
1862
-			    }
1862
+				}
1863 1863
 			}
1864 1864
 			// Sleep for xxx microseconds
1865 1865
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1866
-		    } else {
1866
+			} else {
1867 1867
 			if ($format === 'flightgearmp') {
1868
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1868
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1869 1869
 				//@socket_close($r);
1870 1870
 				sleep($globalMinFetch);
1871 1871
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1874,9 +1874,9 @@  discard block
 block discarded – undo
1874 1874
 				break;
1875 1875
 				
1876 1876
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1877
-			    if (isset($tt[$format])) $tt[$format]++;
1878
-			    else $tt[$format] = 0;
1879
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1877
+				if (isset($tt[$format])) $tt[$format]++;
1878
+				else $tt[$format] = 0;
1879
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1880 1880
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1881 1881
 				//@socket_close($r);
1882 1882
 				sleep(2);
@@ -1887,24 +1887,24 @@  discard block
 block discarded – undo
1887 1887
 				//connect_all($globalSources);
1888 1888
 				$tt[$format]=0;
1889 1889
 				break;
1890
-			    } 
1891
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1890
+				} 
1891
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1892
+			}
1892 1893
 			}
1893
-		    }
1894 1894
 		}
1895
-	    } else {
1895
+		} else {
1896 1896
 		$error = socket_strerror(socket_last_error());
1897 1897
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1898 1898
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1899 1899
 			if (isset($globalDebug)) echo "Restarting...\n";
1900 1900
 			// Restart the script if possible
1901 1901
 			if (is_array($sockets)) {
1902
-			    if ($globalDebug) echo "Shutdown all sockets...";
1902
+				if ($globalDebug) echo "Shutdown all sockets...";
1903 1903
 			    
1904
-			    foreach ($sockets as $sock) {
1904
+				foreach ($sockets as $sock) {
1905 1905
 				@socket_shutdown($sock,2);
1906 1906
 				@socket_close($sock);
1907
-			    }
1907
+				}
1908 1908
 			    
1909 1909
 			}
1910 1910
 			if ($globalDebug) echo "Waiting...";
@@ -1919,15 +1919,15 @@  discard block
 block discarded – undo
1919 1919
 			if ($globalDebug) echo "Restart all connections...";
1920 1920
 			connect_all($globalSources);
1921 1921
 		}
1922
-	    }
1922
+		}
1923 1923
 	}
1924 1924
 	if ($globalDaemon === false) {
1925
-	    if ($globalDebug) echo 'Check all...'."\n";
1926
-	    if (isset($SI)) $SI->checkAll();
1927
-	    if (isset($TI)) $TI->checkAll();
1928
-	    if (isset($MI)) $MI->checkAll();
1925
+		if ($globalDebug) echo 'Check all...'."\n";
1926
+		if (isset($SI)) $SI->checkAll();
1927
+		if (isset($TI)) $TI->checkAll();
1928
+		if (isset($MI)) $MI->checkAll();
1929
+	}
1929 1930
 	}
1930
-    }
1931 1931
 }
1932 1932
 
1933 1933
 ?>
Please login to merge, or discard this patch.
live-czml.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -50,30 +50,30 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
 function quaternionrotate($heading, $attitude = 0, $bank = 0) {
53
-    // Assuming the angles are in radians.
54
-    $c1 = cos($heading/2);
55
-    $s1 = sin($heading/2);
56
-    $c2 = cos($attitude/2);
57
-    $s2 = sin($attitude/2);
58
-    $c3 = cos($bank/2);
59
-    $s3 = sin($bank/2);
60
-    $c1c2 = $c1*$c2;
61
-    $s1s2 = $s1*$s2;
62
-    $w =$c1c2*$c3 - $s1s2*$s3;
63
-    $x =$c1c2*$s3 + $s1s2*$c3;
64
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
65
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
66
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
53
+	// Assuming the angles are in radians.
54
+	$c1 = cos($heading/2);
55
+	$s1 = sin($heading/2);
56
+	$c2 = cos($attitude/2);
57
+	$s2 = sin($attitude/2);
58
+	$c3 = cos($bank/2);
59
+	$s3 = sin($bank/2);
60
+	$c1c2 = $c1*$c2;
61
+	$s1s2 = $s1*$s2;
62
+	$w =$c1c2*$c3 - $s1s2*$s3;
63
+	$x =$c1c2*$s3 + $s1s2*$c3;
64
+	$y =$s1*$c2*$c3 + $c1*$s2*$s3;
65
+	$z =$c1*$s2*$c3 - $s1*$c2*$s3;
66
+	return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
67 67
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
68 68
 
69 69
 }
70 70
 
71 71
 
72 72
 if (isset($_GET['download'])) {
73
-    if ($_GET['download'] == "true")
74
-    {
73
+	if ($_GET['download'] == "true")
74
+	{
75 75
 	header('Content-disposition: attachment; filename="flightairmap.json"');
76
-    }
76
+	}
77 77
 }
78 78
 header('Content-Type: text/javascript');
79 79
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	if (isset($_GET['coord']) && $_GET['coord'] != '') {
173 173
 		$coord = explode(',',$_GET['coord']);
174 174
 		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
175
-		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
175
+			&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
176 176
 			$coord = array();
177 177
 		}
178 178
 	}
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	if (isset($_GET['coord']) && $_GET['coord'] != '') {
183 183
 		$coord = explode(',',$_GET['coord']);
184 184
 		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
185
-		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
185
+			&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
186 186
 			$coord = array();
187 187
 		}
188 188
 	}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') {
193 193
 		$coord = explode(',',$_GET['coord']);
194 194
 		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
195
-		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
195
+			&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
196 196
 			$coord = array();
197 197
 		}
198 198
 	}
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
 			$image = "images/placeholder_thumb.png";
302 302
 		}
303 303
 
304
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
305
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
306
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
307
-                if ($prev_flightaware_id != $id) {
304
+				if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
305
+				elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
306
+				elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
307
+				if ($prev_flightaware_id != $id) {
308 308
 			if ($prev_flightaware_id != '') {
309 309
 				/*
310 310
 				if ($nblatlong == 1) {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
385 385
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
386 386
 						} else $aircraft_shadow = '';
387
-	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
387
+							$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
388 388
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true' && isset($_COOKIE['IconColor'])) {
389 389
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
390 390
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
416 416
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
417 417
 						}
418
-    						$output .= '},';
418
+							$output .= '},';
419 419
 					} elseif (isset($modelsdb[$aircraft_icao]) && $aircraft_icao != '') {
420 420
 						$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_icao].'","scale" : '.$scale.',"minimumPixelSize": '.$minimumpixelsize.'';
421 421
 						$output .= ',"heightReference": "'.$heightrelative.'"';
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
424 424
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
425 425
 						}
426
-    						$output .= '},';
426
+							$output .= '},';
427 427
 					} elseif ($aircraft_icao != '') {
428 428
 						$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
429 429
 						if (isset($aircraft_info[0]['engine_type'])) {
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/class.GeoidHeight.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 SpotterImport {
16
-    private $all_flights = 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_flights = 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, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
27 27
 	if (!(isset($globalNoDB) && $globalNoDB)) {
28 28
 		$Connection = new Connection($dbc);
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
38
-		    	$type = $srcst['stats_type'];
37
+			foreach($sourcestat as $srcst) {
38
+				$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40
-			    $source = $srcst['source_name'];
41
-			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
-	    		}
44
-		    }
40
+				$source = $srcst['source_name'];
41
+				$data = $srcst['source_data'];
42
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
+				}
44
+			}
45 45
 		}
46 46
 	}
47 47
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59
-    }
59
+	}
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+	public function get_Schedule($id,$ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -78,43 +78,43 @@  discard block
 block discarded – undo
78 78
 	$operator = $Spotter->getOperator($ident);
79 79
 	$scheduleexist = false;
80 80
 	if ($Schedule->checkSchedule($operator) == 0) {
81
-	    $operator = $Translation->checkTranslation($ident);
82
-	    if ($Schedule->checkSchedule($operator) == 0) {
81
+		$operator = $Translation->checkTranslation($ident);
82
+		if ($Schedule->checkSchedule($operator) == 0) {
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
-		    // Should also check if route schedule = route from DB
89
-		    if ($schedule['DepartureAirportIATA'] != '') {
85
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
+			// Should also check if route schedule = route from DB
89
+			if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
91
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
-			    if (trim($airport_icao) != '') {
91
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
+				if (trim($airport_icao) != '') {
93 93
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94 94
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
95
-			    }
95
+				}
96
+			}
96 97
 			}
97
-		    }
98
-		    if ($schedule['ArrivalAirportIATA'] != '') {
98
+			if ($schedule['ArrivalAirportIATA'] != '') {
99 99
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
100
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
-			    if (trim($airport_icao) != '') {
100
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
+				if (trim($airport_icao) != '') {
102 102
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103 103
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
104
-			    }
104
+				}
105 105
 			}
106
-		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
106
+			}
107
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 108
 		}
109
-	    } else $scheduleexist = true;
109
+		} else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
111 111
 	// close connection, at least one way will work ?
112
-       if ($scheduleexist) {
112
+	   if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114
-    		$sch = $Schedule->getSchedule($operator);
114
+			$sch = $Schedule->getSchedule($operator);
115 115
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116 116
 		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
117
-       }
117
+	   }
118 118
 	$Spotter->db = null;
119 119
 	$Schedule->db = null;
120 120
 	$Translation->db = null;
@@ -129,78 +129,78 @@  discard block
 block discarded – undo
129 129
 	}
130 130
 	  */
131 131
 	}
132
-    }
132
+	}
133 133
 
134
-    public function checkAll() {
134
+	public function checkAll() {
135 135
 	global $globalDebug, $globalNoImport;
136 136
 	if ($globalDebug) echo "Update last seen flights data...\n";
137 137
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138
-	    foreach ($this->all_flights as $key => $flight) {
138
+		foreach ($this->all_flights as $key => $flight) {
139 139
 		if (isset($this->all_flights[$key]['id'])) {
140
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141
-    		    $Spotter = new Spotter($this->db);
142
-        	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
144
-        	}
145
-	    }
140
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141
+				$Spotter = new Spotter($this->db);
142
+				$real_arrival = $this->arrival($key);
143
+				if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
144
+			}
145
+		}
146
+	}
146 147
 	}
147
-    }
148 148
 
149
-    public function arrival($key) {
149
+	public function arrival($key) {
150 150
 	global $globalClosestMinDist, $globalDebug;
151 151
 	if ($globalDebug) echo 'Update arrival...'."\n";
152 152
 	$Spotter = new Spotter($this->db);
153
-        $airport_icao = '';
154
-        $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
153
+		$airport_icao = '';
154
+		$airport_time = '';
155
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
156 156
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158
-    	    if (isset($closestAirports[0])) {
159
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160
-        	    $airport_icao = $closestAirports[0]['icao'];
161
-        	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164
-        	    foreach ($closestAirports as $airport) {
165
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166
-        		    $airport_icao = $airport['icao'];
167
-        		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
-        		    break;
170
-        		}
171
-        	    }
172
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
173
-        		$airport_icao = $closestAirports[0]['icao'];
174
-        		$airport_time = $this->all_flights[$key]['datetime'];
175
-        	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
177
-        	}
178
-    	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
180
-    	    }
157
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158
+			if (isset($closestAirports[0])) {
159
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160
+				$airport_icao = $closestAirports[0]['icao'];
161
+				$airport_time = $this->all_flights[$key]['datetime'];
162
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164
+				foreach ($closestAirports as $airport) {
165
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166
+					$airport_icao = $airport['icao'];
167
+					$airport_time = $this->all_flights[$key]['datetime'];
168
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+					break;
170
+				}
171
+				}
172
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
173
+				$airport_icao = $closestAirports[0]['icao'];
174
+				$airport_time = $this->all_flights[$key]['datetime'];
175
+			} else {
176
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
177
+			}
178
+			} else {
179
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
180
+			}
181 181
 
182
-        } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184
-        }
185
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186
-    }
182
+		} else {
183
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184
+		}
185
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186
+	}
187 187
 
188 188
 
189 189
 
190
-    public function del() {
190
+	public function del() {
191 191
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 192
 	// Delete old infos
193 193
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
194 194
 	foreach ($this->all_flights as $key => $flight) {
195
-	    if (isset($flight['lastupdate'])) {
195
+		if (isset($flight['lastupdate'])) {
196 196
 		if ($flight['lastupdate'] < (time()-1800)) {
197
-		    $this->delKey($key);
197
+			$this->delKey($key);
198
+		}
198 199
 		}
199
-	    }
200 200
 	}
201
-    }
201
+	}
202 202
 
203
-    public function delKey($key) {
203
+	public function delKey($key) {
204 204
 	global $globalDebug, $globalNoImport, $globalNoDB;
205 205
 	// Delete old infos
206 206
 	if (isset($this->all_flights[$key]['id'])) {
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 	}
223 223
 	unset($this->all_flights[$key]);
224
-    }
224
+	}
225 225
 
226
-    public function add($line) {
226
+	public function add($line) {
227 227
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
228 228
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
229 229
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
@@ -249,20 +249,20 @@  discard block
 block discarded – undo
249 249
 	
250 250
 	// SBS format is CSV format
251 251
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
252
-	    //print_r($line);
253
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
254
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
252
+		//print_r($line);
253
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
254
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
255 255
 
256 256
 		// Increment message number
257 257
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
258
-		    $current_date = date('Y-m-d');
259
-		    if (isset($line['source_name'])) $source = $line['source_name'];
260
-		    else $source = '';
261
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
262
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
263
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
264
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
265
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
258
+			$current_date = date('Y-m-d');
259
+			if (isset($line['source_name'])) $source = $line['source_name'];
260
+			else $source = '';
261
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
262
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
263
+				$this->stats[$current_date][$source]['msg']['date'] = time();
264
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
265
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
266 266
 		}
267 267
 		
268 268
 		/*
@@ -278,54 +278,54 @@  discard block
 block discarded – undo
278 278
 		//$this->db = $dbc;
279 279
 
280 280
 		//$hex = trim($line['hex']);
281
-	        if (!isset($line['id'])) $id = trim($line['hex']);
282
-	        else $id = trim($line['id']);
281
+			if (!isset($line['id'])) $id = trim($line['hex']);
282
+			else $id = trim($line['id']);
283 283
 		
284 284
 		if (!isset($this->all_flights[$id])) {
285
-		    if ($globalDebug) echo 'New flight...'."\n";
286
-		    $this->all_flights[$id] = array();
287
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
288
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
289
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
290
-		    if (!isset($line['id'])) {
285
+			if ($globalDebug) echo 'New flight...'."\n";
286
+			$this->all_flights[$id] = array();
287
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
288
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
289
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
290
+			if (!isset($line['id'])) {
291 291
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
292 292
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
293 293
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
294 294
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
295
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
296
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
297
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
295
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
296
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
297
+			if ($globalAllFlights !== FALSE) $dataFound = true;
298 298
 		}
299 299
 		if (isset($line['source_type']) && $line['source_type'] != '') {
300
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
300
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
301 301
 		}
302 302
 		
303 303
 		//print_r($this->all_flights);
304 304
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
305
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
306
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
305
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
306
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
307 307
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
308
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
309
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
308
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
309
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
310 310
 			$timeelapsed = microtime(true);
311 311
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
312
-			    $Spotter = new Spotter($this->db);
313
-			    if (isset($this->all_flights[$id]['source_type'])) {
312
+				$Spotter = new Spotter($this->db);
313
+				if (isset($this->all_flights[$id]['source_type'])) {
314 314
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
315
-			    } else {
315
+				} else {
316 316
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
317
-			    }
318
-			    $Spotter->db = null;
319
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
320
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
317
+				}
318
+				$Spotter->db = null;
319
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
320
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
321
+			}
321 322
 			}
322
-		    }
323
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
324
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
323
+			if ($globalAllFlights !== FALSE) $dataFound = true;
324
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
325 325
 		}
326
-	        if (isset($line['id']) && !isset($line['hex'])) {
327
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
328
-	        }
326
+			if (isset($line['id']) && !isset($line['hex'])) {
327
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
328
+			}
329 329
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
330 330
 			$icao = $line['aircraft_icao'];
331 331
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 		}
356 356
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
357 357
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
358
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
358
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
359 359
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
360
-		    } else {
360
+			} else {
361 361
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
362 362
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
363 363
 				/*
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 				print_r($line);
367 367
 				*/
368 368
 				return '';
369
-		    }
369
+			}
370 370
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
371 371
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
372 372
 			return '';
@@ -382,21 +382,21 @@  discard block
 block discarded – undo
382 382
 		}
383 383
 
384 384
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
385
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
385
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
386 386
 		}
387 387
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
388
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
388
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
389 389
 		}
390 390
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
391
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
391
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
392 392
 		}
393 393
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
394
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
394
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
395 395
 		}
396 396
  
397 397
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
398 398
 
399
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
399
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
400 400
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
401 401
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
402 402
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -405,23 +405,23 @@  discard block
 block discarded – undo
405 405
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
406 406
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
407 407
 			} else {
408
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
409
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
408
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
409
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
410 410
 				$timeelapsed = microtime(true);
411
-            			$Spotter = new Spotter($this->db);
412
-            			$fromsource = NULL;
413
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
414
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
411
+						$Spotter = new Spotter($this->db);
412
+						$fromsource = NULL;
413
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
414
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
415 415
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
416 416
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
417 417
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
418
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
418
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
419 419
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
420 420
 				$Spotter->db = null;
421 421
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
422
-			    }
422
+				}
423 423
 			}
424
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
424
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
425 425
 		    
426 426
 /*
427 427
 		    if (!isset($line['id'])) {
@@ -431,63 +431,63 @@  discard block
 block discarded – undo
431 431
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
432 432
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
433 433
   */
434
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
435 435
 
436
-		    //$putinarchive = true;
437
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
436
+			//$putinarchive = true;
437
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
438 438
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
439
-		    }
440
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
439
+			}
440
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
441 441
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
442
-		    }
443
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
444
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
445
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
442
+			}
443
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
444
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
445
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
446 446
 			$timeelapsed = microtime(true);
447 447
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
448 448
 				$Spotter = new Spotter($this->db);
449 449
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
450 450
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
451
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
451
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
452 452
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
-                        }
454
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
453
+						}
454
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
455 455
 			$timeelapsed = microtime(true);
456 456
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
457
-			    $Spotter = new Spotter($this->db);
458
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
459
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
457
+				$Spotter = new Spotter($this->db);
458
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
459
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
460 460
 				$Translation = new Translation($this->db);
461 461
 				$ident = $Translation->checkTranslation(trim($line['ident']));
462 462
 				$route = $Spotter->getRouteInfo($ident);
463 463
 				$Translation->db = null;
464
-			    }
465
-			    $Spotter->db = null;
466
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
467
-                    	}
464
+				}
465
+				$Spotter->db = null;
466
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
467
+						}
468 468
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
469
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
470
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
469
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
470
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
471 471
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
472
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
473
-		    	    }
472
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
473
+					}
474 474
 			}
475 475
 			if (!isset($globalFork)) $globalFork = TRUE;
476 476
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
477 477
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
478 478
 			}
479
-		    }
479
+			}
480 480
 		}
481 481
 
482 482
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
483 483
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
484
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
485
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
486
-		    //$dataFound = true;
484
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
485
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
486
+			//$dataFound = true;
487 487
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
488
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
489
-		    if ($distance > 1000 && $distance < 10000) {
490
-		    // use datetime
488
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
489
+			if ($distance > 1000 && $distance < 10000) {
490
+			// use datetime
491 491
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
492 492
 			$speed = $speed*3.6;
493 493
 			if ($speed < 1000) {
@@ -496,49 +496,49 @@  discard block
 block discarded – undo
496 496
 	  		} else {
497 497
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
498 498
 	  		}
499
-		    }
499
+			}
500 500
 		}
501 501
 
502 502
 
503 503
 
504
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
505
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
506
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
507
-	    	    	return false;
508
-	    	    }
509
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
510
-	    	    else unset($timediff);
511
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
512
-	    	    else unset($timediff_archive);
513
-	    	    if ($this->tmd > 5
514
-	    	        || (isset($line['format_source']) 
515
-	    	    	    && $line['format_source'] == 'airwhere' 
516
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
517
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
518
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
519
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
520
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
521
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
522
-	    	    		)
523
-	    	    	    )
524
-	    	    	)
525
-	    		|| (isset($globalVA) && $globalVA) 
526
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
527
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
528
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
529
-	    	    	|| (isset($globalVAM) && $globalVAM)
530
-	    	    	|| !isset($timediff)
531
-	    	    	|| $timediff > $globalLiveInterval
532
-	    	    	|| $globalArchive
533
-	    	    	|| ($timediff > 30 
534
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
535
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
536
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
537
-	    	    	    )
538
-	    	    	) {
504
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
505
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
506
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
507
+					return false;
508
+				}
509
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
510
+				else unset($timediff);
511
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
512
+				else unset($timediff_archive);
513
+				if ($this->tmd > 5
514
+					|| (isset($line['format_source']) 
515
+						&& $line['format_source'] == 'airwhere' 
516
+						&& ((!isset($this->all_flights[$id]['latitude']) 
517
+						|| !isset($this->all_flights[$id]['longitude'])) 
518
+						|| (isset($this->all_flights[$id]['latitude']) 
519
+							&& isset($this->all_flights[$id]['longitude']) 
520
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
521
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
522
+						)
523
+						)
524
+					)
525
+				|| (isset($globalVA) && $globalVA) 
526
+					|| (isset($globalIVAO) && $globalIVAO)
527
+					|| (isset($globalVATSIM) && $globalVATSIM)
528
+					|| (isset($globalphpVMS) && $globalphpVMS)
529
+					|| (isset($globalVAM) && $globalVAM)
530
+					|| !isset($timediff)
531
+					|| $timediff > $globalLiveInterval
532
+					|| $globalArchive
533
+					|| ($timediff > 30 
534
+						&& isset($this->all_flights[$id]['latitude']) 
535
+						&& isset($this->all_flights[$id]['longitude']) 
536
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
537
+						)
538
+					) {
539 539
 
540 540
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
541
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
541
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
542 542
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
543 543
 				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
544 544
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 				$this->all_flights[$id]['putinarchive'] = true;
547 547
 				$this->tmd = 0;
548 548
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
549
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
550
-				    $timeelapsed = microtime(true);
551
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
549
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
550
+					$timeelapsed = microtime(true);
551
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
552 552
 					$Spotter = new Spotter($this->db);
553 553
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
554 554
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
 					$Spotter->db = null;
557 557
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
558 558
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
559
-				    }
559
+					}
560 560
 				}
561 561
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
562
-			    } 
563
-			    /*
562
+				} 
563
+				/*
564 564
 			    else {
565 565
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
566 566
 				else {
@@ -574,16 +574,16 @@  discard block
 block discarded – undo
574 574
 			}
575 575
 
576 576
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
577
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
577
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
578 578
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
579 579
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
580 580
 					$this->all_flights[$id]['time_last_coord'] = time();
581 581
 				}
582 582
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
583 583
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
584
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
585
-				    $dataFound = true;
586
-				    $this->all_flights[$id]['time_last_coord'] = time();
584
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
585
+					$dataFound = true;
586
+					$this->all_flights[$id]['time_last_coord'] = time();
587 587
 				}
588 588
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
589 589
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -594,24 +594,24 @@  discard block
 block discarded – undo
594 594
 				    //$putinarchive = true;
595 595
 				}
596 596
 				*/
597
-			    /*
597
+				/*
598 598
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
599 599
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
600 600
 			    }
601 601
 			    */
602 602
 			}
603 603
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
604
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
605
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
604
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
605
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
606 606
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
607 607
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
608 608
 					$this->all_flights[$id]['time_last_coord'] = time();
609 609
 				}
610 610
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
611 611
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
612
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
613
-				    $dataFound = true;
614
-				    $this->all_flights[$id]['time_last_coord'] = time();
612
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
613
+					$dataFound = true;
614
+					$this->all_flights[$id]['time_last_coord'] = time();
615 615
 				}
616 616
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
617 617
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -629,67 +629,67 @@  discard block
 block discarded – undo
629 629
 			    */
630 630
 			}
631 631
 
632
-		    } else if ($globalDebug && $timediff > 30) {
632
+			} else if ($globalDebug && $timediff > 30) {
633 633
 			$this->tmd = $this->tmd + 1;
634 634
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
635 635
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
636 636
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
637 637
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
638
-		    }
638
+			}
639 639
 		}
640 640
 		if (isset($line['last_update']) && $line['last_update'] != '') {
641
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
642
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
641
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
642
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
643 643
 		}
644 644
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
645
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
646
-		    //$dataFound = true;
645
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
646
+			//$dataFound = true;
647 647
 		}
648 648
 		if (isset($line['format_source']) && $line['format_source'] != '') {
649
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
649
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
650 650
 		}
651 651
 		if (isset($line['source_name']) && $line['source_name'] != '') {
652
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
652
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
653 653
 		}
654 654
 		if (isset($line['emergency']) && $line['emergency'] != '') {
655
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
656
-		    //$dataFound = true;
655
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
656
+			//$dataFound = true;
657 657
 		}
658 658
 		if (isset($line['ground']) && $line['ground'] != '') {
659
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
659
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
660 660
 			// Here we force archive of flight because after ground it's a new one (or should be)
661 661
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
662 662
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
663 663
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
664
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
664
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
665 665
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
666
-		    }
667
-		    if ($line['ground'] != 1) $line['ground'] = 0;
668
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
669
-		    //$dataFound = true;
666
+			}
667
+			if ($line['ground'] != 1) $line['ground'] = 0;
668
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
669
+			//$dataFound = true;
670 670
 		}
671 671
 		if (isset($line['squawk']) && $line['squawk'] != '') {
672
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
673
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
674
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
675
-			    $highlight = '';
676
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
677
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
678
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
679
-			    if ($highlight != '') {
672
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
673
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
674
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
675
+				$highlight = '';
676
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
677
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
678
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
679
+				if ($highlight != '') {
680 680
 				$timeelapsed = microtime(true);
681 681
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
682
-				    $Spotter = new Spotter($this->db);
683
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
684
-				    $Spotter->db = null;
685
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
682
+					$Spotter = new Spotter($this->db);
683
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
684
+					$Spotter->db = null;
685
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
686 686
 				}
687 687
 				//$putinarchive = true;
688 688
 				//$highlight = '';
689
-			    }
689
+				}
690 690
 			    
691
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
692
-		    //$dataFound = true;
691
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
692
+			//$dataFound = true;
693 693
 		}
694 694
 
695 695
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -700,13 +700,13 @@  discard block
 block discarded – undo
700 700
 					$line['altitude'] = $line['altitude'] - $geoid;
701 701
 				}
702 702
 			}
703
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
703
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
704 704
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
705 705
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
706 706
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
707 707
 			//$dataFound = true;
708
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
709
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
708
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
709
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
710 710
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
711 711
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
712 712
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -715,27 +715,27 @@  discard block
 block discarded – undo
715 715
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
716 716
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
717 717
 			}
718
-		    }
719
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
718
+			}
719
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
720 720
 		}
721 721
 
722 722
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
723
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
723
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
724 724
 		}
725 725
 		
726 726
 		if (isset($line['heading']) && $line['heading'] != '') {
727
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
728
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
729
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
730
-		    //$dataFound = true;
727
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
728
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
729
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
730
+			//$dataFound = true;
731 731
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
732
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
733
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
734
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
735
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
732
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
733
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
734
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
735
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
736 736
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
737
-  		    // If not enough messages and ACARS set heading to 0
738
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
737
+  			// If not enough messages and ACARS set heading to 0
738
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
739 739
   		}
740 740
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
741 741
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -748,133 +748,133 @@  discard block
 block discarded – undo
748 748
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
749 749
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
750 750
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
751
-		    $this->all_flights[$id]['lastupdate'] = time();
752
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
753
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
754
-			    //print_r($this->all_flights);
755
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
756
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
757
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
751
+			$this->all_flights[$id]['lastupdate'] = time();
752
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
753
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
754
+				//print_r($this->all_flights);
755
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
756
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
757
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
758 758
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
759
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
760
-				    $timeelapsed = microtime(true);
761
-				    $SpotterLive = new SpotterLive($this->db);
762
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
759
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
760
+					$timeelapsed = microtime(true);
761
+					$SpotterLive = new SpotterLive($this->db);
762
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
763 763
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
764 764
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
765
-				    } elseif (isset($line['id'])) {
765
+					} elseif (isset($line['id'])) {
766 766
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
767 767
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
768
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
768
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
769 769
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
770 770
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
771
-				    } else $recent_ident = '';
772
-				    $SpotterLive->db=null;
773
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
774
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
771
+					} else $recent_ident = '';
772
+					$SpotterLive->db=null;
773
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
774
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
775 775
 				} else $recent_ident = '';
776
-			    } else {
776
+				} else {
777 777
 				$recent_ident = '';
778 778
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
779
-			    }
780
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
781
-			    if($recent_ident == "")
782
-			    {
779
+				}
780
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
781
+				if($recent_ident == "")
782
+				{
783 783
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
784 784
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
785 785
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
786 786
 				//adds the spotter data for the archive
787 787
 				$ignoreImport = false;
788 788
 				foreach($globalAirportIgnore as $airportIgnore) {
789
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
789
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
790 790
 					$ignoreImport = true;
791
-				    }
791
+					}
792 792
 				}
793 793
 				if (count($globalAirportAccept) > 0) {
794
-				    $ignoreImport = true;
795
-				    foreach($globalAirportIgnore as $airportIgnore) {
794
+					$ignoreImport = true;
795
+					foreach($globalAirportIgnore as $airportIgnore) {
796 796
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
797
-					    $ignoreImport = false;
797
+						$ignoreImport = false;
798
+					}
798 799
 					}
799
-				    }
800 800
 				}
801 801
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
802
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
802
+					foreach($globalAirlineIgnore as $airlineIgnore) {
803 803
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
804
-					    $ignoreImport = true;
804
+						$ignoreImport = true;
805
+					}
805 806
 					}
806
-				    }
807 807
 				}
808 808
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
809
-				    $ignoreImport = true;
810
-				    foreach($globalAirlineAccept as $airlineAccept) {
809
+					$ignoreImport = true;
810
+					foreach($globalAirlineAccept as $airlineAccept) {
811 811
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
812
-					    $ignoreImport = false;
812
+						$ignoreImport = false;
813
+					}
813 814
 					}
814
-				    }
815 815
 				}
816 816
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
817
-				    $ignoreImport = true;
818
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
817
+					$ignoreImport = true;
818
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
819 819
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
820
-					    $ignoreImport = false;
820
+						$ignoreImport = false;
821
+					}
821 822
 					}
822
-				    }
823 823
 				}
824 824
 				
825 825
 				if (!$ignoreImport) {
826
-				    $highlight = '';
827
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
828
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
829
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
830
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
831
-				    $timeelapsed = microtime(true);
832
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
826
+					$highlight = '';
827
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
828
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
829
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
830
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
831
+					$timeelapsed = microtime(true);
832
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
833 833
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
834
-					    $Spotter = new Spotter($this->db);
835
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
836
-					    $Spotter->db = null;
837
-					    if ($globalDebug) {
834
+						$Spotter = new Spotter($this->db);
835
+						$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
836
+						$Spotter->db = null;
837
+						if ($globalDebug) {
838 838
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
839 839
 						else echo 'Success';
840
-					    }
841
-					    if (count($result) > 1) {
842
-					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
840
+						}
841
+						if (count($result) > 1) {
842
+						// ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
843 843
 						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
844 844
 						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
845
-					    }
845
+						}
846 846
 					}
847
-				    }
848
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
849
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
847
+					}
848
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
849
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
850 850
 
851
-				    // Add source stat in DB
852
-				    $Stats = new Stats($this->db);
853
-				    if (!empty($this->stats)) {
851
+					// Add source stat in DB
852
+					$Stats = new Stats($this->db);
853
+					if (!empty($this->stats)) {
854 854
 					if ($globalDebug) echo 'Add source stats : ';
855
-				        foreach($this->stats as $date => $data) {
856
-					    foreach($data as $source => $sourced) {
857
-					        //print_r($sourced);
858
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
859
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
860
-				    		if (isset($sourced['msg'])) {
861
-				    		    if (time() - $sourced['msg']['date'] > 10) {
862
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
863
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
864
-			    			        unset($this->stats[$date][$source]['msg']);
865
-			    			    }
866
-			    			}
867
-			    		    }
868
-			    		    if ($date != date('Y-m-d')) {
869
-			    			unset($this->stats[$date]);
870
-			    		    }
871
-				    	}
872
-				    	if ($globalDebug) echo 'Done'."\n";
855
+						foreach($this->stats as $date => $data) {
856
+						foreach($data as $source => $sourced) {
857
+							//print_r($sourced);
858
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
859
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
860
+							if (isset($sourced['msg'])) {
861
+								if (time() - $sourced['msg']['date'] > 10) {
862
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
863
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
864
+									unset($this->stats[$date][$source]['msg']);
865
+								}
866
+							}
867
+							}
868
+							if ($date != date('Y-m-d')) {
869
+							unset($this->stats[$date]);
870
+							}
871
+						}
872
+						if ($globalDebug) echo 'Done'."\n";
873 873
 
874
-				    }
875
-				    $Stats->db = null;
876
-				    }
877
-				    $this->del();
874
+					}
875
+					$Stats->db = null;
876
+					}
877
+					$this->del();
878 878
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
879 879
 				//$ignoreImport = false;
880 880
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -892,41 +892,41 @@  discard block
 block discarded – undo
892 892
 			*/
893 893
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
894 894
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
895
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
896
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
897
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
895
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
896
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
897
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
898 898
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
899
-					    $SpotterLive = new SpotterLive($this->db);
900
-					    $SpotterLive->deleteLiveSpotterData();
901
-					    $SpotterLive->db=null;
899
+						$SpotterLive = new SpotterLive($this->db);
900
+						$SpotterLive->deleteLiveSpotterData();
901
+						$SpotterLive->db=null;
902 902
 					}
903
-				    }
904
-				    if ($globalDebug) echo " Done\n";
905
-				    $this->last_delete = time();
903
+					}
904
+					if ($globalDebug) echo " Done\n";
905
+					$this->last_delete = time();
906 906
 				}
907
-			    } else {
907
+				} else {
908 908
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
909
-				    $this->all_flights[$id]['id'] = $recent_ident;
910
-				    $this->all_flights[$id]['addedSpotter'] = 1;
909
+					$this->all_flights[$id]['id'] = $recent_ident;
910
+					$this->all_flights[$id]['addedSpotter'] = 1;
911 911
 				}
912 912
 				if (isset($globalDaemon) && !$globalDaemon) {
913
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
913
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
914 914
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
915
-					    $Spotter = new Spotter($this->db);
916
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
917
-					    $Spotter->db = null;
915
+						$Spotter = new Spotter($this->db);
916
+						$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
917
+						$Spotter->db = null;
918
+					}
918 919
 					}
919
-				    }
920 920
 				}
921 921
 				
922
-			    }
922
+				}
923 923
 			}
924
-		    }
925
-		    //adds the spotter LIVE data
926
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
927
-		    //echo "\nAdd in Live !! \n";
928
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
929
-		    if ($globalDebug) {
924
+			}
925
+			//adds the spotter LIVE data
926
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
927
+			//echo "\nAdd in Live !! \n";
928
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
929
+			if ($globalDebug) {
930 930
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
931 931
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
932 932
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -934,60 +934,60 @@  discard block
 block discarded – undo
934 934
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
935 935
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
936 936
 			}
937
-		    }
938
-		    $ignoreImport = false;
939
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
940
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
937
+			}
938
+			$ignoreImport = false;
939
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
940
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
941 941
 
942
-		    foreach($globalAirportIgnore as $airportIgnore) {
943
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
944
-			    $ignoreImport = true;
942
+			foreach($globalAirportIgnore as $airportIgnore) {
943
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
944
+				$ignoreImport = true;
945
+			}
945 946
 			}
946
-		    }
947
-		    if (count($globalAirportAccept) > 0) {
948
-		        $ignoreImport = true;
949
-		        foreach($globalAirportIgnore as $airportIgnore) {
950
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
947
+			if (count($globalAirportAccept) > 0) {
948
+				$ignoreImport = true;
949
+				foreach($globalAirportIgnore as $airportIgnore) {
950
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
951 951
 				$ignoreImport = false;
952
-			    }
952
+				}
953 953
 			}
954
-		    }
955
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
954
+			}
955
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
956 956
 			foreach($globalAirlineIgnore as $airlineIgnore) {
957
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
957
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
958 958
 				$ignoreImport = true;
959
-			    }
959
+				}
960 960
 			}
961
-		    }
962
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
961
+			}
962
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
963 963
 			$ignoreImport = true;
964 964
 			foreach($globalAirlineAccept as $airlineAccept) {
965
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
965
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
966 966
 				$ignoreImport = false;
967
-			    }
967
+				}
968
+			}
968 969
 			}
969
-		    }
970
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
970
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
971 971
 			$ignoreImport = true;
972 972
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
973
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
974
-			        $ignoreImport = false;
975
-			    }
973
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
974
+					$ignoreImport = false;
975
+				}
976
+			}
976 977
 			}
977
-		    }
978 978
 
979
-		    if (!$ignoreImport) {
979
+			if (!$ignoreImport) {
980 980
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
981 981
 				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
982 982
 				$timeelapsed = microtime(true);
983 983
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
984
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
984
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
985 985
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
986 986
 					$SpotterLive = new SpotterLive($this->db);
987 987
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
988 988
 					$SpotterLive->db = null;
989 989
 					if ($globalDebug) echo $result."\n";
990
-				    }
990
+					}
991 991
 				}
992 992
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
993 993
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 				//if ($line['format_source'] != 'aprs') {
1000 1000
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
1001 1001
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1002
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1002
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1003 1003
 					$source = $this->all_flights[$id]['source_name'];
1004 1004
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1005 1005
 					if (!isset($this->source_location[$source])) {
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 					if ($stats_heading == 16) $stats_heading = 0;
1026 1026
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1027 1027
 						for ($i=0;$i<=15;$i++) {
1028
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1028
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1029 1029
 						}
1030 1030
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1031 1031
 					} else {
@@ -1038,17 +1038,17 @@  discard block
 block discarded – undo
1038 1038
 					//var_dump($this->stats);
1039 1039
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1040 1040
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1041
-						    end($this->stats[$current_date][$source]['hist']);
1042
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1041
+							end($this->stats[$current_date][$source]['hist']);
1042
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1043 1043
 						} else $mini = 0;
1044 1044
 						for ($i=$mini;$i<=$distance;$i+=10) {
1045
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1045
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1046 1046
 						}
1047 1047
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1048 1048
 					} else {
1049 1049
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1050 1050
 					}
1051
-				    }
1051
+					}
1052 1052
 				}
1053 1053
 
1054 1054
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 			//$this->del();
1059 1059
 			
1060 1060
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1061
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1061
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1062 1062
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1063 1063
 				$SpotterLive = new SpotterLive($this->db);
1064 1064
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1066,19 +1066,19 @@  discard block
 block discarded – undo
1066 1066
 				//SpotterLive->deleteLiveSpotterData();
1067 1067
 				if ($globalDebug) echo " Done\n";
1068 1068
 				$this->last_delete_hourly = time();
1069
-			    } else {
1069
+				} else {
1070 1070
 				$this->del();
1071 1071
 				$this->last_delete_hourly = time();
1072
-			    }
1072
+				}
1073 1073
 			}
1074 1074
 			
1075
-		    }
1076
-		    //$ignoreImport = false;
1075
+			}
1076
+			//$ignoreImport = false;
1077 1077
 		}
1078 1078
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1079 1079
 		if ($send) return $this->all_flights[$id];
1080
-	    }
1080
+		}
1081
+	}
1081 1082
 	}
1082
-    }
1083 1083
 }
1084 1084
 ?>
Please login to merge, or discard this patch.
js/map-tracker.2d.js.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 			}
576 576
                     }
577 577
 		    <?php
578
-            		} else {
579
-            	    ?>
578
+					} else {
579
+					?>
580 580
 		    if (map.getZoom() > 7) {
581 581
                 	var style = {
582 582
                     	    "color": "#1a3151",
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                 	layer_tracker_data.addLayer(layer);
596 596
 		    }
597 597
 <?php
598
-            		}
598
+					}
599 599
 ?>
600 600
 				}
601 601
 			    }
@@ -740,11 +740,11 @@  discard block
 block discarded – undo
740 740
 $( document ).ready(function() {
741 741
 	map.on('moveend', function() {
742 742
 <?php
743
-    if (isset($globalMapUseBbox) && $globalMapUseBbox && (!isset($archive) || $archive === false)) {
743
+	if (isset($globalMapUseBbox) && $globalMapUseBbox && (!isset($archive) || $archive === false)) {
744 744
 ?>
745 745
 		getLiveTrackerData(1);
746 746
 <?php
747
-    }
747
+	}
748 748
 ?>
749 749
 	});
750 750
 
Please login to merge, or discard this patch.
js/map-tracker.3d.js.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -98,21 +98,21 @@  discard block
 block discarded – undo
98 98
 			var entityid = entity.id;
99 99
 			var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value;
100 100
 			<?php 
101
-			    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
101
+				if (isset($globalMapUseBbox) && $globalMapUseBbox) {
102 102
 			?>
103 103
 			if (lastupdateentity != lastupdatetracker) {
104 104
 				viewer.dataSources.get(dsn).entities.remove(entity);
105 105
 				czmldstracker.entities.removeById(entityid);
106 106
 			}
107 107
 			<?php
108
-			    } else {
108
+				} else {
109 109
 			?>
110 110
 			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
111 111
 				viewer.dataSources.get(dsn).entities.remove(entity);
112 112
 				czmldstracker.entities.removeById(entityid);
113 113
 			}
114 114
 			<?php
115
-			    }
115
+				}
116 116
 			?>
117 117
 		}
118 118
 	}
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 function updateTrackerData() {
146 146
 	lastupdatetracker = Date.now();
147 147
 <?php
148
-    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
148
+	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
149 149
 ?>
150 150
 	var livetrackerdata = czmldstracker.process('<?php print $globalURL; ?>/live-czml.php?tracker&coord='+bbox()+'&update=' + lastupdatetracker);
151 151
 <?php
152
-    } else {
152
+	} else {
153 153
 ?>
154 154
 	var livetrackerdata = czmldstracker.process('<?php print $globalURL; ?>/live-czml.php?tracker&update=' + lastupdatetracker);
155 155
 <?php
156
-    }
156
+	}
157 157
 ?>  
158 158
 	livetrackerdata.then(function (data) { 
159 159
 		displayTrackerData(data);
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
210 210
 camera.moveEnd.addEventListener(function() {
211 211
 <?php
212
-    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
212
+	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
213 213
 ?>
214 214
 	if (typeof archive == 'undefined' || archive == false) {
215 215
 		updateTrackerData();
216 216
 	}
217 217
 <?php
218
-    }
218
+	}
219 219
 ?>
220 220
 });
221 221
 
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 			var entityid = entity.id;
290 290
 			var lastupdateentity = entity.properties.lastupdate;
291 291
 			<?php 
292
-			    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
293
-			    // Remove flights not in latest CZML
292
+				if (isset($globalMapUseBbox) && $globalMapUseBbox) {
293
+				// Remove flights not in latest CZML
294 294
 			?>
295 295
 			if (lastupdateentity != lastupdate) {
296 296
 				console.log('Remove...');
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 				czmlds.entities.removeById(entityid);
299 299
 			}
300 300
 			<?php
301
-			    } else {
301
+				} else {
302 302
 			?>
303 303
 			if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
304 304
 				viewer.dataSources.get(dsn).entities.remove(entity);
305 305
 				czmlds.entities.removeById(entityid);
306 306
 			}
307 307
 			<?php
308
-			    }
308
+				}
309 309
 			?>
310 310
 		}
311 311
 	}
@@ -762,12 +762,12 @@  discard block
 block discarded – undo
762 762
 }
763 763
 
764 764
 <?php
765
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
765
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
766 766
 ?>
767 767
 update_atcLayer();
768 768
 setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
769 769
 <?php
770
-    }
770
+	}
771 771
 ?>
772 772
 
773 773
 function iconColor(color) {
Please login to merge, or discard this patch.