Completed
Push — master ( 6ff122...47c470 )
by Yannick
45:08
created
require/class.SpotterLive.php 1 patch
Indentation   +265 added lines, -265 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 string the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param array $filter the filter
18
+	 * @return string 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();
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 		return $filter_query;
139 139
 	}
140 140
 
141
-    /**
142
-     * Gets all the spotter information based on the latest data entry
143
-     *
144
-     * @param string $limit
145
-     * @param string $sort
146
-     * @param array $filter
147
-     * @return array the spotter information
148
-     */
141
+	/**
142
+	 * Gets all the spotter information based on the latest data entry
143
+	 *
144
+	 * @param string $limit
145
+	 * @param string $sort
146
+	 * @param array $filter
147
+	 * @return array the spotter information
148
+	 */
149 149
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
150 150
 	{
151 151
 		global $globalDBdriver, $globalLiveInterval;
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 		return $spotter_array;
188 188
 	}
189 189
 
190
-    /**
191
-     * Gets Minimal Live Spotter data
192
-     *
193
-     * @param int $limit
194
-     * @param array $filter
195
-     * @return array the spotter information
196
-     */
190
+	/**
191
+	 * Gets Minimal Live Spotter data
192
+	 *
193
+	 * @param int $limit
194
+	 * @param array $filter
195
+	 * @return array the spotter information
196
+	 */
197 197
 	public function getMinLiveSpotterData($limit = 0,$filter = array())
198 198
 	{
199 199
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 		return $spotter_array;
245 245
 	}
246 246
 
247
-    /**
248
-     * Gets Minimal Live Spotter data since xx seconds
249
-     *
250
-     * @param array $coord
251
-     * @param array $filter
252
-     * @param int $limit
253
-     * @param string $id
254
-     * @return array the spotter information
255
-     */
247
+	/**
248
+	 * Gets Minimal Live Spotter data since xx seconds
249
+	 *
250
+	 * @param array $coord
251
+	 * @param array $filter
252
+	 * @param int $limit
253
+	 * @param string $id
254
+	 * @return array the spotter information
255
+	 */
256 256
 	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '')
257 257
 	{
258 258
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 		return $spotter_array;
355 355
 	}
356 356
 
357
-    /**
358
-     * Gets Minimal Live Spotter data since xx seconds
359
-     *
360
-     * @param string $id
361
-     * @param array $filter
362
-     * @param int $limit
363
-     * @return array the spotter information
364
-     */
357
+	/**
358
+	 * Gets Minimal Live Spotter data since xx seconds
359
+	 *
360
+	 * @param string $id
361
+	 * @param array $filter
362
+	 * @param int $limit
363
+	 * @return array the spotter information
364
+	 */
365 365
 	public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0)
366 366
 	{
367 367
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
 		return $spotter_array;
427 427
 	}
428 428
 
429
-    /**
430
-     * Gets number of latest data entry
431
-     *
432
-     * @param array $filter
433
-     * @return String number of entry
434
-     */
429
+	/**
430
+	 * Gets number of latest data entry
431
+	 *
432
+	 * @param array $filter
433
+	 * @return String number of entry
434
+	 */
435 435
 	public function getLiveSpotterCount($filter = array())
436 436
 	{
437 437
 		global $globalDBdriver, $globalLiveInterval;
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 		return $result['nb'];
458 458
 	}
459 459
 
460
-    /**
461
-     * Gets all the spotter information based on the latest data entry and coord
462
-     *
463
-     * @param $coord
464
-     * @param array $filter
465
-     * @return array the spotter information
466
-     */
460
+	/**
461
+	 * Gets all the spotter information based on the latest data entry and coord
462
+	 *
463
+	 * @param $coord
464
+	 * @param array $filter
465
+	 * @return array the spotter information
466
+	 */
467 467
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
468 468
 	{
469 469
 		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
 		return $spotter_array;
491 491
 	}
492 492
 
493
-    /**
494
-     * Gets all the spotter information based on the latest data entry and coord
495
-     *
496
-     * @param $coord
497
-     * @param int $limit
498
-     * @param array $filter
499
-     * @return array the spotter information
500
-     */
493
+	/**
494
+	 * Gets all the spotter information based on the latest data entry and coord
495
+	 *
496
+	 * @param $coord
497
+	 * @param int $limit
498
+	 * @param array $filter
499
+	 * @return array the spotter information
500
+	 */
501 501
 	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
502 502
 	{
503 503
 		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 		return $spotter_array;
588 588
 	}
589 589
 
590
-    /**
591
-     * Gets all the spotter information based on a user's latitude and longitude
592
-     *
593
-     * @param $lat
594
-     * @param $lng
595
-     * @param $radius
596
-     * @param $interval
597
-     * @return array the spotter information
598
-     */
590
+	/**
591
+	 * Gets all the spotter information based on a user's latitude and longitude
592
+	 *
593
+	 * @param $lat
594
+	 * @param $lng
595
+	 * @param $radius
596
+	 * @param $interval
597
+	 * @return array the spotter information
598
+	 */
599 599
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
600 600
 	{
601 601
 		$Spotter = new Spotter($this->db);
@@ -605,95 +605,95 @@  discard block
 block discarded – undo
605 605
 				return array();
606 606
 			}
607 607
 		}
608
-        if ($lng != '')
609
-        {
610
-        	if (!is_numeric($lng))
611
-            {
612
-            	return array();
613
-            }
614
-        }
615
-        if ($radius != '')
616
-        {
617
-        	if (!is_numeric($radius))
618
-        	{
619
-        		return array();
620
-        	}
621
-        }
608
+		if ($lng != '')
609
+		{
610
+			if (!is_numeric($lng))
611
+			{
612
+				return array();
613
+			}
614
+		}
615
+		if ($radius != '')
616
+		{
617
+			if (!is_numeric($radius))
618
+			{
619
+				return array();
620
+			}
621
+		}
622 622
 		$additional_query = '';
623
-        if ($interval != '')
624
-        {
625
-        	if (!is_string($interval))
626
-        	{
627
-        		return array();
628
-        	} else {
629
-                if ($interval == '1m')
630
-                {
631
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
632
-                } else if ($interval == '15m'){
633
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
634
-                } 
635
-            }
636
-        } else {
637
-        	$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
638
-        }
639
-	        $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 
623
+		if ($interval != '')
624
+		{
625
+			if (!is_string($interval))
626
+			{
627
+				return array();
628
+			} else {
629
+				if ($interval == '1m')
630
+				{
631
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
632
+				} else if ($interval == '15m'){
633
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
634
+				} 
635
+			}
636
+		} else {
637
+			$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
638
+		}
639
+			$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 
640 640
                    WHERE spotter_live.latitude <> '' 
641 641
                    AND spotter_live.longitude <> '' 
642 642
                   ".$additional_query."
643 643
                    HAVING distance < :radius  
644 644
                    ORDER BY distance";
645 645
 
646
-            $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
647
-            return $spotter_array;
648
-        }
646
+			$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
647
+			return $spotter_array;
648
+		}
649 649
 
650 650
 
651
-    /**
652
-     * Gets all the spotter information based on a particular callsign
653
-     *
654
-     * @param $ident
655
-     * @return array the spotter information
656
-     */
651
+	/**
652
+	 * Gets all the spotter information based on a particular callsign
653
+	 *
654
+	 * @param $ident
655
+	 * @return array the spotter information
656
+	 */
657 657
 	public function getLastLiveSpotterDataByIdent($ident)
658 658
 	{
659 659
 		$Spotter = new Spotter($this->db);
660 660
 		date_default_timezone_set('UTC');
661 661
 
662 662
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
663
-                $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';
663
+				$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';
664 664
 
665 665
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
666 666
 
667 667
 		return $spotter_array;
668 668
 	}
669 669
 
670
-    /**
671
-     * Gets all the spotter information based on a particular callsign
672
-     *
673
-     * @param $ident
674
-     * @param $date
675
-     * @return array the spotter information
676
-     */
670
+	/**
671
+	 * Gets all the spotter information based on a particular callsign
672
+	 *
673
+	 * @param $ident
674
+	 * @param $date
675
+	 * @return array the spotter information
676
+	 */
677 677
 	public function getDateLiveSpotterDataByIdent($ident,$date)
678 678
 	{
679 679
 		$Spotter = new Spotter($this->db);
680 680
 		date_default_timezone_set('UTC');
681 681
 
682 682
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
683
-                $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';
683
+				$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';
684 684
 
685
-                $date = date('c',$date);
685
+				$date = date('c',$date);
686 686
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
687 687
 
688 688
 		return $spotter_array;
689 689
 	}
690 690
 
691
-    /**
692
-     * Gets last spotter information based on a particular callsign
693
-     *
694
-     * @param $id
695
-     * @return array the spotter information
696
-     */
691
+	/**
692
+	 * Gets last spotter information based on a particular callsign
693
+	 *
694
+	 * @param $id
695
+	 * @return array the spotter information
696
+	 */
697 697
 	public function getLastLiveSpotterDataById($id)
698 698
 	{
699 699
 		$Spotter = new Spotter($this->db);
@@ -704,13 +704,13 @@  discard block
 block discarded – undo
704 704
 		return $spotter_array;
705 705
 	}
706 706
 
707
-    /**
708
-     * Gets last spotter information based on a particular callsign
709
-     *
710
-     * @param $id
711
-     * @param $date
712
-     * @return array the spotter information
713
-     */
707
+	/**
708
+	 * Gets last spotter information based on a particular callsign
709
+	 *
710
+	 * @param $id
711
+	 * @param $date
712
+	 * @return array the spotter information
713
+	 */
714 714
 	public function getDateLiveSpotterDataById($id,$date)
715 715
 	{
716 716
 		$Spotter = new Spotter($this->db);
@@ -723,21 +723,21 @@  discard block
 block discarded – undo
723 723
 		return $spotter_array;
724 724
 	}
725 725
 
726
-    /**
727
-     * Gets altitude information based on a particular callsign
728
-     *
729
-     * @param $ident
730
-     * @return array the spotter information
731
-     */
726
+	/**
727
+	 * Gets altitude information based on a particular callsign
728
+	 *
729
+	 * @param $ident
730
+	 * @return array the spotter information
731
+	 */
732 732
 	public function getAltitudeLiveSpotterDataByIdent($ident)
733 733
 	{
734 734
 
735 735
 		date_default_timezone_set('UTC');
736 736
 
737 737
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
738
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
738
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
739 739
 
740
-    		try {
740
+			try {
741 741
 			
742 742
 			$sth = $this->db->prepare($query);
743 743
 			$sth->execute(array(':ident' => $ident));
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 		return $spotter_array;
751 751
 	}
752 752
 
753
-    /**
754
-     * Gets all the spotter information based on a particular id
755
-     *
756
-     * @param $id
757
-     * @param bool $liveinterval
758
-     * @return array the spotter information
759
-     */
753
+	/**
754
+	 * Gets all the spotter information based on a particular id
755
+	 *
756
+	 * @param $id
757
+	 * @param bool $liveinterval
758
+	 * @return array the spotter information
759
+	 */
760 760
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
761 761
 	{
762 762
 		global $globalDBdriver, $globalLiveInterval;
@@ -784,18 +784,18 @@  discard block
 block discarded – undo
784 784
 		return $spotter_array;
785 785
 	}
786 786
 
787
-    /**
788
-     * Gets all the spotter information based on a particular ident
789
-     *
790
-     * @param $ident
791
-     * @return array the spotter information
792
-     */
787
+	/**
788
+	 * Gets all the spotter information based on a particular ident
789
+	 *
790
+	 * @param $ident
791
+	 * @return array the spotter information
792
+	 */
793 793
 	public function getAllLiveSpotterDataByIdent($ident)
794 794
 	{
795 795
 		date_default_timezone_set('UTC');
796 796
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
797 797
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
798
-    		try {
798
+			try {
799 799
 			
800 800
 			$sth = $this->db->prepare($query);
801 801
 			$sth->execute(array(':ident' => $ident));
@@ -809,23 +809,23 @@  discard block
 block discarded – undo
809 809
 
810 810
 
811 811
 	/**
812
-	* Deletes all info in the table
813
-	*
814
-	* @return String success or false
815
-	*
816
-	*/
812
+	 * Deletes all info in the table
813
+	 *
814
+	 * @return String success or false
815
+	 *
816
+	 */
817 817
 	public function deleteLiveSpotterData()
818 818
 	{
819 819
 		global $globalDBdriver;
820 820
 		if ($globalDBdriver == 'mysql') {
821 821
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
822 822
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
823
-            		//$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)";
823
+					//$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)";
824 824
 		} else {
825 825
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
826 826
 		}
827 827
         
828
-    		try {
828
+			try {
829 829
 			
830 830
 			$sth = $this->db->prepare($query);
831 831
 			$sth->execute();
@@ -837,18 +837,18 @@  discard block
 block discarded – undo
837 837
 	}
838 838
 
839 839
 	/**
840
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
841
-	*
842
-	* @return String success or false
843
-	*
844
-	*/
840
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
841
+	 *
842
+	 * @return String success or false
843
+	 *
844
+	 */
845 845
 	public function deleteLiveSpotterDataNotUpdated()
846 846
 	{
847 847
 		global $globalDBdriver, $globalDebug;
848 848
 		if ($globalDBdriver == 'mysql') {
849 849
 			//$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';
850
-    			$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";
851
-    			try {
850
+				$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";
851
+				try {
852 852
 				
853 853
 				$sth = $this->db->prepare($query);
854 854
 				$sth->execute();
@@ -856,8 +856,8 @@  discard block
 block discarded – undo
856 856
 				return "error";
857 857
 			}
858 858
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
859
-                        $i = 0;
860
-                        $j =0;
859
+						$i = 0;
860
+						$j =0;
861 861
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
862 862
 			foreach($all as $row)
863 863
 			{
@@ -865,20 +865,20 @@  discard block
 block discarded – undo
865 865
 				$j++;
866 866
 				if ($j == 30) {
867 867
 					if ($globalDebug) echo ".";
868
-				    	try {
868
+						try {
869 869
 						
870 870
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
871 871
 						$sth->execute();
872 872
 					} catch(PDOException $e) {
873 873
 						return "error";
874 874
 					}
875
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
876
-                                	$j = 0;
875
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
876
+									$j = 0;
877 877
 				}
878 878
 				$query_delete .= "'".$row['flightaware_id']."',";
879 879
 			}
880 880
 			if ($i > 0) {
881
-    				try {
881
+					try {
882 882
 					
883 883
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
884 884
 					$sth->execute();
@@ -889,9 +889,9 @@  discard block
 block discarded – undo
889 889
 			return "success";
890 890
 		} elseif ($globalDBdriver == 'pgsql') {
891 891
 			//$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";
892
-    			//$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";
893
-    			$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)";
894
-    			try {
892
+				//$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";
893
+				$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)";
894
+				try {
895 895
 				
896 896
 				$sth = $this->db->prepare($query);
897 897
 				$sth->execute();
@@ -934,18 +934,18 @@  discard block
 block discarded – undo
934 934
 		}
935 935
 	}
936 936
 
937
-    /**
938
-     * Deletes all info in the table for an ident
939
-     *
940
-     * @param $ident
941
-     * @return String success or false
942
-     */
937
+	/**
938
+	 * Deletes all info in the table for an ident
939
+	 *
940
+	 * @param $ident
941
+	 * @return String success or false
942
+	 */
943 943
 	public function deleteLiveSpotterDataByIdent($ident)
944 944
 	{
945 945
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
946 946
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
947 947
         
948
-    		try {
948
+			try {
949 949
 			
950 950
 			$sth = $this->db->prepare($query);
951 951
 			$sth->execute(array(':ident' => $ident));
@@ -956,18 +956,18 @@  discard block
 block discarded – undo
956 956
 		return "success";
957 957
 	}
958 958
 
959
-    /**
960
-     * Deletes all info in the table for an id
961
-     *
962
-     * @param $id
963
-     * @return String success or false
964
-     */
959
+	/**
960
+	 * Deletes all info in the table for an id
961
+	 *
962
+	 * @param $id
963
+	 * @return String success or false
964
+	 */
965 965
 	public function deleteLiveSpotterDataById($id)
966 966
 	{
967 967
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
968 968
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
969 969
         
970
-    		try {
970
+			try {
971 971
 			
972 972
 			$sth = $this->db->prepare($query);
973 973
 			$sth->execute(array(':id' => $id));
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
 	}
980 980
 
981 981
 
982
-    /**
983
-     * Gets the aircraft ident within the last hour
984
-     *
985
-     * @param $ident
986
-     * @return String the ident
987
-     */
982
+	/**
983
+	 * Gets the aircraft ident within the last hour
984
+	 *
985
+	 * @param $ident
986
+	 * @return String the ident
987
+	 */
988 988
 	public function getIdentFromLastHour($ident)
989 989
 	{
990 990
 		global $globalDBdriver, $globalTimezone;
@@ -1010,14 +1010,14 @@  discard block
 block discarded – undo
1010 1010
 			$ident_result = $row['ident'];
1011 1011
 		}
1012 1012
 		return $ident_result;
1013
-        }
1014
-
1015
-    /**
1016
-     * Check recent aircraft
1017
-     *
1018
-     * @param $ident
1019
-     * @return String the ident
1020
-     */
1013
+		}
1014
+
1015
+	/**
1016
+	 * Check recent aircraft
1017
+	 *
1018
+	 * @param $ident
1019
+	 * @return String the ident
1020
+	 */
1021 1021
 	public function checkIdentRecent($ident)
1022 1022
 	{
1023 1023
 		global $globalDBdriver, $globalTimezone;
@@ -1043,14 +1043,14 @@  discard block
 block discarded – undo
1043 1043
 			$ident_result = $row['flightaware_id'];
1044 1044
 		}
1045 1045
 		return $ident_result;
1046
-        }
1047
-
1048
-    /**
1049
-     * Check recent aircraft by id
1050
-     *
1051
-     * @param $id
1052
-     * @return String the ident
1053
-     */
1046
+		}
1047
+
1048
+	/**
1049
+	 * Check recent aircraft by id
1050
+	 *
1051
+	 * @param $id
1052
+	 * @return String the ident
1053
+	 */
1054 1054
 	public function checkIdRecent($id)
1055 1055
 	{
1056 1056
 		global $globalDBdriver, $globalTimezone;
@@ -1076,14 +1076,14 @@  discard block
 block discarded – undo
1076 1076
 			$ident_result = $row['flightaware_id'];
1077 1077
 		}
1078 1078
 		return $ident_result;
1079
-        }
1080
-
1081
-    /**
1082
-     * Check recent aircraft by ModeS
1083
-     *
1084
-     * @param $modes
1085
-     * @return String the ModeS
1086
-     */
1079
+		}
1080
+
1081
+	/**
1082
+	 * Check recent aircraft by ModeS
1083
+	 *
1084
+	 * @param $modes
1085
+	 * @return String the ModeS
1086
+	 */
1087 1087
 	public function checkModeSRecent($modes)
1088 1088
 	{
1089 1089
 		global $globalDBdriver, $globalTimezone;
@@ -1112,12 +1112,12 @@  discard block
 block discarded – undo
1112 1112
 		return $ident_result;
1113 1113
 	}
1114 1114
 
1115
-    /**
1116
-     * Gets the aircraft data from the last 20 seconds
1117
-     *
1118
-     * @param string $q
1119
-     * @return array the spotter data
1120
-     */
1115
+	/**
1116
+	 * Gets the aircraft data from the last 20 seconds
1117
+	 *
1118
+	 * @param string $q
1119
+	 * @return array the spotter data
1120
+	 */
1121 1121
 	public function getRealTimeData($q = '')
1122 1122
 	{
1123 1123
 		global $globalDBdriver;
@@ -1158,39 +1158,39 @@  discard block
 block discarded – undo
1158 1158
 		return $spotter_array;
1159 1159
 	}
1160 1160
 
1161
-    /**
1162
-     * Adds a new spotter data
1163
-     *
1164
-     * @param String $flightaware_id the ID from flightaware
1165
-     * @param String $ident the flight ident
1166
-     * @param String $aircraft_icao the aircraft type
1167
-     * @param String $departure_airport_icao the departure airport
1168
-     * @param String $arrival_airport_icao the arrival airport
1169
-     * @param string $latitude
1170
-     * @param string $longitude
1171
-     * @param string $waypoints
1172
-     * @param string $altitude
1173
-     * @param string $altitude_real
1174
-     * @param string $heading
1175
-     * @param string $groundspeed
1176
-     * @param string $date
1177
-     * @param string $departure_airport_time
1178
-     * @param string $arrival_airport_time
1179
-     * @param string $squawk
1180
-     * @param string $route_stop
1181
-     * @param string $ModeS
1182
-     * @param bool $putinarchive
1183
-     * @param string $registration
1184
-     * @param string $pilot_id
1185
-     * @param string $pilot_name
1186
-     * @param string $verticalrate
1187
-     * @param bool $noarchive
1188
-     * @param bool $ground
1189
-     * @param string $format_source
1190
-     * @param string $source_name
1191
-     * @param string $over_country
1192
-     * @return String success or false
1193
-     */
1161
+	/**
1162
+	 * Adds a new spotter data
1163
+	 *
1164
+	 * @param String $flightaware_id the ID from flightaware
1165
+	 * @param String $ident the flight ident
1166
+	 * @param String $aircraft_icao the aircraft type
1167
+	 * @param String $departure_airport_icao the departure airport
1168
+	 * @param String $arrival_airport_icao the arrival airport
1169
+	 * @param string $latitude
1170
+	 * @param string $longitude
1171
+	 * @param string $waypoints
1172
+	 * @param string $altitude
1173
+	 * @param string $altitude_real
1174
+	 * @param string $heading
1175
+	 * @param string $groundspeed
1176
+	 * @param string $date
1177
+	 * @param string $departure_airport_time
1178
+	 * @param string $arrival_airport_time
1179
+	 * @param string $squawk
1180
+	 * @param string $route_stop
1181
+	 * @param string $ModeS
1182
+	 * @param bool $putinarchive
1183
+	 * @param string $registration
1184
+	 * @param string $pilot_id
1185
+	 * @param string $pilot_name
1186
+	 * @param string $verticalrate
1187
+	 * @param bool $noarchive
1188
+	 * @param bool $ground
1189
+	 * @param string $format_source
1190
+	 * @param string $source_name
1191
+	 * @param string $over_country
1192
+	 * @return String success or false
1193
+	 */
1194 1194
 	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 = '')
1195 1195
 	{
1196 1196
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1333,10 +1333,10 @@  discard block
 block discarded – undo
1333 1333
 		$arrival_airport_country = '';
1334 1334
 		
1335 1335
             	
1336
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1337
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1338
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1339
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1336
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1337
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1338
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1339
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1340 1340
 		
1341 1341
 		$query = '';
1342 1342
 		if ($globalArchive) {
@@ -1357,10 +1357,10 @@  discard block
 block discarded – undo
1357 1357
 			return "error : ".$e->getMessage();
1358 1358
 		}
1359 1359
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1360
-		    if ($globalDebug) echo '(Add to Spotter archive : ';
1361
-		    $SpotterArchive = new SpotterArchive($this->db);
1362
-		    $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);
1363
-		    if ($globalDebug) echo $result.')';
1360
+			if ($globalDebug) echo '(Add to Spotter archive : ';
1361
+			$SpotterArchive = new SpotterArchive($this->db);
1362
+			$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);
1363
+			if ($globalDebug) echo $result.')';
1364 1364
 		} elseif ($globalDebug && $putinarchive !== true) {
1365 1365
 			echo '(Not adding to archive)';
1366 1366
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
 		if ($this->db === null) die('Error: No DB connection. (SpotterArchive)');
10 10
 	}
11 11
 
12
-    /**
13
-     * Get SQL query part for filter used
14
-     * @param array $filter the filter
15
-     * @param bool $where
16
-     * @param bool $and
17
-     * @return string the SQL part
18
-     */
12
+	/**
13
+	 * Get SQL query part for filter used
14
+	 * @param array $filter the filter
15
+	 * @param bool $where
16
+	 * @param bool $and
17
+	 * @return string the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 
163
-    /**
164
-     * Gets all the spotter information based on a particular callsign
165
-     *
166
-     * @param $ident
167
-     * @return array the spotter information
168
-     */
163
+	/**
164
+	 * Gets all the spotter information based on a particular callsign
165
+	 *
166
+	 * @param $ident
167
+	 * @return array the spotter information
168
+	 */
169 169
 	public function getLastArchiveSpotterDataByIdent($ident) {
170 170
 		$Spotter = new Spotter($this->db);
171 171
 		date_default_timezone_set('UTC');
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 
183
-    /**
184
-     * Gets last the spotter information based on a particular id
185
-     *
186
-     * @param $id
187
-     * @return array the spotter information
188
-     */
183
+	/**
184
+	 * Gets last the spotter information based on a particular id
185
+	 *
186
+	 * @param $id
187
+	 * @return array the spotter information
188
+	 */
189 189
 	public function getLastArchiveSpotterDataById($id) {
190 190
 		$Spotter = new Spotter($this->db);
191 191
 		date_default_timezone_set('UTC');
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
 		return $spotter_array;
211 211
 	}
212 212
 
213
-    /**
214
-     * Gets all the spotter information based on a particular id
215
-     *
216
-     * @param $id
217
-     * @return array the spotter information
218
-     */
213
+	/**
214
+	 * Gets all the spotter information based on a particular id
215
+	 *
216
+	 * @param $id
217
+	 * @return array the spotter information
218
+	 */
219 219
 	public function getAllArchiveSpotterDataById($id) {
220 220
 		date_default_timezone_set('UTC');
221 221
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 		return $spotter_array;
236 236
 	}
237 237
 
238
-    /**
239
-     * Gets coordinate & time spotter information based on a particular id
240
-     *
241
-     * @param $id
242
-     * @return array the spotter information
243
-     */
238
+	/**
239
+	 * Gets coordinate & time spotter information based on a particular id
240
+	 *
241
+	 * @param $id
242
+	 * @return array the spotter information
243
+	 */
244 244
 	public function getCoordArchiveSpotterDataById($id) {
245 245
 		date_default_timezone_set('UTC');
246 246
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 		return $spotter_array;
257 257
 	}
258 258
 
259
-    /**
260
-     * Gets coordinate & time spotter information based on a particular id
261
-     *
262
-     * @param $id
263
-     * @param $begindate
264
-     * @param $enddate
265
-     * @return array the spotter information
266
-     */
259
+	/**
260
+	 * Gets coordinate & time spotter information based on a particular id
261
+	 *
262
+	 * @param $id
263
+	 * @param $begindate
264
+	 * @param $enddate
265
+	 * @return array the spotter information
266
+	 */
267 267
 	public function getCoordArchiveSpotterDataByIdDate($id,$begindate,$enddate) {
268 268
 		date_default_timezone_set('UTC');
269 269
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 	}
281 281
 
282 282
 
283
-    /**
284
-     * Gets altitude information based on a particular callsign
285
-     *
286
-     * @param $ident
287
-     * @return array the spotter information
288
-     */
283
+	/**
284
+	 * Gets altitude information based on a particular callsign
285
+	 *
286
+	 * @param $ident
287
+	 * @return array the spotter information
288
+	 */
289 289
 	public function getAltitudeArchiveSpotterDataByIdent($ident) {
290 290
 
291 291
 		date_default_timezone_set('UTC');
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 		return $spotter_array;
306 306
 	}
307 307
 
308
-    /**
309
-     * Gets altitude information based on a particular id
310
-     *
311
-     * @param $id
312
-     * @return array the spotter information
313
-     */
308
+	/**
309
+	 * Gets altitude information based on a particular id
310
+	 *
311
+	 * @param $id
312
+	 * @return array the spotter information
313
+	 */
314 314
 	public function getAltitudeArchiveSpotterDataById($id) {
315 315
 
316 316
 		date_default_timezone_set('UTC');
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 		return $spotter_array;
331 331
 	}
332 332
 
333
-    /**
334
-     * Gets altitude & speed information based on a particular id
335
-     *
336
-     * @param $id
337
-     * @return array the spotter information
338
-     */
333
+	/**
334
+	 * Gets altitude & speed information based on a particular id
335
+	 *
336
+	 * @param $id
337
+	 * @return array the spotter information
338
+	 */
339 339
 	public function getAltitudeSpeedArchiveSpotterDataById($id) {
340 340
 		date_default_timezone_set('UTC');
341 341
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 		return $spotter_array;
352 352
 	}
353 353
 
354
-    /**
355
-     * Gets altitude information based on a particular callsign
356
-     *
357
-     * @param $ident
358
-     * @return array the spotter information
359
-     */
354
+	/**
355
+	 * Gets altitude information based on a particular callsign
356
+	 *
357
+	 * @param $ident
358
+	 * @return array the spotter information
359
+	 */
360 360
 	public function getLastAltitudeArchiveSpotterDataByIdent($ident) {
361 361
 		date_default_timezone_set('UTC');
362 362
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -374,14 +374,14 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 
376 376
 
377
-    /**
378
-     * Gets all the archive spotter information
379
-     *
380
-     * @param $ident
381
-     * @param $flightaware_id
382
-     * @param $date
383
-     * @return array the spotter information
384
-     */
377
+	/**
378
+	 * Gets all the archive spotter information
379
+	 *
380
+	 * @param $ident
381
+	 * @param $flightaware_id
382
+	 * @param $date
383
+	 * @return array the spotter information
384
+	 */
385 385
 	public function getSpotterArchiveData($ident,$flightaware_id,$date) {
386 386
 		$Spotter = new Spotter($this->db);
387 387
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
 		}
407 407
 	}
408 408
 
409
-    /**
410
-     * Delete row in spotter_archive table based on flightaware_id
411
-     * @param $id flightaware_id
412
-     */
413
-    public function deleteSpotterArchiveTrackDataByID($id) {
409
+	/**
410
+	 * Delete row in spotter_archive table based on flightaware_id
411
+	 * @param $id flightaware_id
412
+	 */
413
+	public function deleteSpotterArchiveTrackDataByID($id) {
414 414
 		global $globalArchiveKeepTrackMonths, $globalDBdriver;
415 415
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.flightaware_id = :id';
416 416
 		try {
@@ -422,15 +422,15 @@  discard block
 block discarded – undo
422 422
 		}
423 423
 	}
424 424
 
425
-    /**
426
-     * Gets Minimal Live Spotter data
427
-     *
428
-     * @param $begindate
429
-     * @param $enddate
430
-     * @param array $filter
431
-     * @param int $part
432
-     * @return array the spotter information
433
-     */
425
+	/**
426
+	 * Gets Minimal Live Spotter data
427
+	 *
428
+	 * @param $begindate
429
+	 * @param $enddate
430
+	 * @param array $filter
431
+	 * @param int $part
432
+	 * @return array the spotter information
433
+	 */
434 434
 	public function getMinLiveSpotterData($begindate,$enddate,$filter = array(),$part = 0) {
435 435
 		global $globalDBdriver;
436 436
 		date_default_timezone_set('UTC');
@@ -481,14 +481,14 @@  discard block
 block discarded – undo
481 481
 		return $spotter_array;
482 482
 	}
483 483
 
484
-    /**
485
-     * Gets Minimal Live Spotter data
486
-     *
487
-     * @param $begindate
488
-     * @param $enddate
489
-     * @param array $filter
490
-     * @return array the spotter information
491
-     */
484
+	/**
485
+	 * Gets Minimal Live Spotter data
486
+	 *
487
+	 * @param $begindate
488
+	 * @param $enddate
489
+	 * @param array $filter
490
+	 * @return array the spotter information
491
+	 */
492 492
 	public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) {
493 493
 		global $globalDBdriver;
494 494
 		date_default_timezone_set('UTC');
@@ -554,14 +554,14 @@  discard block
 block discarded – undo
554 554
 		return $spotter_array;
555 555
 	}
556 556
 
557
-    /**
558
-     * Gets count Live Spotter data
559
-     *
560
-     * @param $begindate
561
-     * @param $enddate
562
-     * @param array $filter
563
-     * @return array the spotter information
564
-     */
557
+	/**
558
+	 * Gets count Live Spotter data
559
+	 *
560
+	 * @param $begindate
561
+	 * @param $enddate
562
+	 * @param array $filter
563
+	 * @return array the spotter information
564
+	 */
565 565
 	public function getLiveSpotterCount($begindate,$enddate,$filter = array()) {
566 566
 		global $globalDBdriver, $globalLiveInterval;
567 567
 		date_default_timezone_set('UTC');
@@ -606,36 +606,36 @@  discard block
 block discarded – undo
606 606
 
607 607
 	// Spotter_Archive_output
608 608
 
609
-    /**
610
-     * Gets all the spotter information
611
-     *
612
-     * @param string $q
613
-     * @param string $registration
614
-     * @param string $aircraft_icao
615
-     * @param string $aircraft_manufacturer
616
-     * @param string $highlights
617
-     * @param string $airline_icao
618
-     * @param string $airline_country
619
-     * @param string $airline_type
620
-     * @param string $airport
621
-     * @param string $airport_country
622
-     * @param string $callsign
623
-     * @param string $departure_airport_route
624
-     * @param string $arrival_airport_route
625
-     * @param string $owner
626
-     * @param string $pilot_id
627
-     * @param string $pilot_name
628
-     * @param string $altitude
629
-     * @param string $date_posted
630
-     * @param string $limit
631
-     * @param string $sort
632
-     * @param string $includegeodata
633
-     * @param string $origLat
634
-     * @param string $origLon
635
-     * @param string $dist
636
-     * @param array $filters
637
-     * @return array the spotter information
638
-     */
609
+	/**
610
+	 * Gets all the spotter information
611
+	 *
612
+	 * @param string $q
613
+	 * @param string $registration
614
+	 * @param string $aircraft_icao
615
+	 * @param string $aircraft_manufacturer
616
+	 * @param string $highlights
617
+	 * @param string $airline_icao
618
+	 * @param string $airline_country
619
+	 * @param string $airline_type
620
+	 * @param string $airport
621
+	 * @param string $airport_country
622
+	 * @param string $callsign
623
+	 * @param string $departure_airport_route
624
+	 * @param string $arrival_airport_route
625
+	 * @param string $owner
626
+	 * @param string $pilot_id
627
+	 * @param string $pilot_name
628
+	 * @param string $altitude
629
+	 * @param string $date_posted
630
+	 * @param string $limit
631
+	 * @param string $sort
632
+	 * @param string $includegeodata
633
+	 * @param string $origLat
634
+	 * @param string $origLon
635
+	 * @param string $dist
636
+	 * @param array $filters
637
+	 * @return array the spotter information
638
+	 */
639 639
 	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) {
640 640
 		global $globalTimezone, $globalDBdriver;
641 641
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -927,14 +927,14 @@  discard block
 block discarded – undo
927 927
 		}
928 928
 	}
929 929
 
930
-    /**
931
-     * Gets all the spotter information based on the callsign
932
-     *
933
-     * @param string $ident
934
-     * @param string $limit
935
-     * @param string $sort
936
-     * @return array the spotter information
937
-     */
930
+	/**
931
+	 * Gets all the spotter information based on the callsign
932
+	 *
933
+	 * @param string $ident
934
+	 * @param string $limit
935
+	 * @param string $sort
936
+	 * @return array the spotter information
937
+	 */
938 938
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') {
939 939
 		$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
940 940
 
@@ -981,15 +981,15 @@  discard block
 block discarded – undo
981 981
 	}
982 982
 
983 983
 
984
-    /**
985
-     * Gets all the spotter information based on the owner
986
-     *
987
-     * @param string $owner
988
-     * @param string $limit
989
-     * @param string $sort
990
-     * @param array $filter
991
-     * @return array the spotter information
992
-     */
984
+	/**
985
+	 * Gets all the spotter information based on the owner
986
+	 *
987
+	 * @param string $owner
988
+	 * @param string $limit
989
+	 * @param string $sort
990
+	 * @param array $filter
991
+	 * @return array the spotter information
992
+	 */
993 993
 	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) {
994 994
 		$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
995 995
 
@@ -1036,15 +1036,15 @@  discard block
 block discarded – undo
1036 1036
 		return $spotter_array;
1037 1037
 	}
1038 1038
 
1039
-    /**
1040
-     * Gets all the spotter information based on the pilot
1041
-     *
1042
-     * @param string $pilot
1043
-     * @param string $limit
1044
-     * @param string $sort
1045
-     * @param array $filter
1046
-     * @return array the spotter information
1047
-     */
1039
+	/**
1040
+	 * Gets all the spotter information based on the pilot
1041
+	 *
1042
+	 * @param string $pilot
1043
+	 * @param string $limit
1044
+	 * @param string $sort
1045
+	 * @param array $filter
1046
+	 * @return array the spotter information
1047
+	 */
1048 1048
 	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) {
1049 1049
 		$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1050 1050
 
@@ -1087,14 +1087,14 @@  discard block
 block discarded – undo
1087 1087
 		return $spotter_array;
1088 1088
 	}
1089 1089
 
1090
-    /**
1091
-     * Gets all number of flight over countries
1092
-     *
1093
-     * @param bool $limit
1094
-     * @param int $olderthanmonths
1095
-     * @param string $sincedate
1096
-     * @return array the airline country list
1097
-     */
1090
+	/**
1091
+	 * Gets all number of flight over countries
1092
+	 *
1093
+	 * @param bool $limit
1094
+	 * @param int $olderthanmonths
1095
+	 * @param string $sincedate
1096
+	 * @return array the airline country list
1097
+	 */
1098 1098
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') {
1099 1099
 		global $globalDBdriver;
1100 1100
 		/*
@@ -1133,14 +1133,14 @@  discard block
 block discarded – undo
1133 1133
 		return $flight_array;
1134 1134
 	}
1135 1135
 
1136
-    /**
1137
-     * Gets all number of flight over countries
1138
-     *
1139
-     * @param bool $limit
1140
-     * @param int $olderthanmonths
1141
-     * @param string $sincedate
1142
-     * @return array the airline country list
1143
-     */
1136
+	/**
1137
+	 * Gets all number of flight over countries
1138
+	 *
1139
+	 * @param bool $limit
1140
+	 * @param int $olderthanmonths
1141
+	 * @param string $sincedate
1142
+	 * @return array the airline country list
1143
+	 */
1144 1144
 	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') {
1145 1145
 		global $globalDBdriver;
1146 1146
 		/*
@@ -1180,13 +1180,13 @@  discard block
 block discarded – undo
1180 1180
 		return $flight_array;
1181 1181
 	}
1182 1182
 
1183
-    /**
1184
-     * Gets all aircraft types that have flown over by owner
1185
-     *
1186
-     * @param $owner
1187
-     * @param array $filters
1188
-     * @return array the aircraft list
1189
-     */
1183
+	/**
1184
+	 * Gets all aircraft types that have flown over by owner
1185
+	 *
1186
+	 * @param $owner
1187
+	 * @param array $filters
1188
+	 * @return array the aircraft list
1189
+	 */
1190 1190
 	public function countAllAircraftTypesByOwner($owner,$filters = array())
1191 1191
 	{
1192 1192
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1202,13 +1202,13 @@  discard block
 block discarded – undo
1202 1202
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
1203 1203
 	}
1204 1204
 
1205
-    /**
1206
-     * Gets all airlines by owner
1207
-     *
1208
-     * @param $owner
1209
-     * @param array $filters
1210
-     * @return array the airline list
1211
-     */
1205
+	/**
1206
+	 * Gets all airlines by owner
1207
+	 *
1208
+	 * @param $owner
1209
+	 * @param array $filters
1210
+	 * @return array the airline list
1211
+	 */
1212 1212
 	public function countAllAirlinesByOwner($owner,$filters = array())
1213 1213
 	{
1214 1214
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -1223,13 +1223,13 @@  discard block
 block discarded – undo
1223 1223
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
1224 1224
 	}
1225 1225
 
1226
-    /**
1227
-     * Gets all arrival airports by country of the airplanes that have flown over based on a owner
1228
-     *
1229
-     * @param $owner
1230
-     * @param array $filters
1231
-     * @return array the airport list
1232
-     */
1226
+	/**
1227
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a owner
1228
+	 *
1229
+	 * @param $owner
1230
+	 * @param array $filters
1231
+	 * @return array the airport list
1232
+	 */
1233 1233
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
1234 1234
 	{
1235 1235
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1243,13 +1243,13 @@  discard block
 block discarded – undo
1243 1243
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
1244 1244
 	}
1245 1245
 
1246
-    /**
1247
-     * Gets all arrival airports of the airplanes that have flown over based on a owner
1248
-     *
1249
-     * @param $owner
1250
-     * @param array $filters
1251
-     * @return array the airport list
1252
-     */
1246
+	/**
1247
+	 * Gets all arrival airports of the airplanes that have flown over based on a owner
1248
+	 *
1249
+	 * @param $owner
1250
+	 * @param array $filters
1251
+	 * @return array the airport list
1252
+	 */
1253 1253
 	public function countAllArrivalAirportsByOwner($owner,$filters = array())
1254 1254
 	{
1255 1255
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1274,13 +1274,13 @@  discard block
 block discarded – undo
1274 1274
 		return $airport_array;
1275 1275
 	}
1276 1276
 
1277
-    /**
1278
-     * Gets all departure airports by country of the airplanes that have flown over based on owner
1279
-     *
1280
-     * @param $owner
1281
-     * @param array $filters
1282
-     * @return array the airport list
1283
-     */
1277
+	/**
1278
+	 * Gets all departure airports by country of the airplanes that have flown over based on owner
1279
+	 *
1280
+	 * @param $owner
1281
+	 * @param array $filters
1282
+	 * @return array the airport list
1283
+	 */
1284 1284
 	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
1285 1285
 	{
1286 1286
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1294,13 +1294,13 @@  discard block
 block discarded – undo
1294 1294
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
1295 1295
 	}
1296 1296
 
1297
-    /**
1298
-     * Gets all departure airports of the airplanes that have flown over based on a owner
1299
-     *
1300
-     * @param $owner
1301
-     * @param array $filters
1302
-     * @return array the airport list
1303
-     */
1297
+	/**
1298
+	 * Gets all departure airports of the airplanes that have flown over based on a owner
1299
+	 *
1300
+	 * @param $owner
1301
+	 * @param array $filters
1302
+	 * @return array the airport list
1303
+	 */
1304 1304
 	public function countAllDepartureAirportsByOwner($owner,$filters = array())
1305 1305
 	{
1306 1306
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1327,13 +1327,13 @@  discard block
 block discarded – undo
1327 1327
 		return $airport_array;
1328 1328
 	}
1329 1329
 
1330
-    /**
1331
-     * Gets all aircraft manufacturer that have flown over by owner
1332
-     *
1333
-     * @param $owner
1334
-     * @param array $filters
1335
-     * @return array the aircraft manufacturer list
1336
-     */
1330
+	/**
1331
+	 * Gets all aircraft manufacturer that have flown over by owner
1332
+	 *
1333
+	 * @param $owner
1334
+	 * @param array $filters
1335
+	 * @return array the aircraft manufacturer list
1336
+	 */
1337 1337
 	public function countAllAircraftManufacturerByOwner($owner,$filters = array())
1338 1338
 	{
1339 1339
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1349,13 +1349,13 @@  discard block
 block discarded – undo
1349 1349
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
1350 1350
 	}
1351 1351
 
1352
-    /**
1353
-     * Gets all aircraft registration that have flown over by owner
1354
-     *
1355
-     * @param $owner
1356
-     * @param array $filters
1357
-     * @return array the aircraft list
1358
-     */
1352
+	/**
1353
+	 * Gets all aircraft registration that have flown over by owner
1354
+	 *
1355
+	 * @param $owner
1356
+	 * @param array $filters
1357
+	 * @return array the aircraft list
1358
+	 */
1359 1359
 	public function countAllAircraftRegistrationByOwner($owner,$filters = array())
1360 1360
 	{
1361 1361
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1391,13 +1391,13 @@  discard block
 block discarded – undo
1391 1391
 		return $aircraft_array;
1392 1392
 	}
1393 1393
 
1394
-    /**
1395
-     * Gets all route combinations based on an owner
1396
-     *
1397
-     * @param $owner
1398
-     * @param array $filters
1399
-     * @return array the route list
1400
-     */
1394
+	/**
1395
+	 * Gets all route combinations based on an owner
1396
+	 *
1397
+	 * @param $owner
1398
+	 * @param array $filters
1399
+	 * @return array the route list
1400
+	 */
1401 1401
 	public function countAllRoutesByOwner($owner,$filters = array())
1402 1402
 	{
1403 1403
 		$filter_query = $this->getFilter($filters,true,true);
@@ -1426,13 +1426,13 @@  discard block
 block discarded – undo
1426 1426
 		return $routes_array;
1427 1427
 	}
1428 1428
 
1429
-    /**
1430
-     * Counts all hours by a owner
1431
-     *
1432
-     * @param $owner
1433
-     * @param array $filters
1434
-     * @return array the hour list
1435
-     */
1429
+	/**
1430
+	 * Counts all hours by a owner
1431
+	 *
1432
+	 * @param $owner
1433
+	 * @param array $filters
1434
+	 * @return array the hour list
1435
+	 */
1436 1436
 	public function countAllHoursByOwner($owner, $filters = array())
1437 1437
 	{
1438 1438
 		global $globalTimezone, $globalDBdriver;
@@ -1467,13 +1467,13 @@  discard block
 block discarded – undo
1467 1467
 		return $hour_array;
1468 1468
 	}
1469 1469
 
1470
-    /**
1471
-     * Gets last spotter information based on a particular callsign
1472
-     *
1473
-     * @param $id
1474
-     * @param $date
1475
-     * @return array the spotter information
1476
-     */
1470
+	/**
1471
+	 * Gets last spotter information based on a particular callsign
1472
+	 *
1473
+	 * @param $id
1474
+	 * @param $date
1475
+	 * @return array the spotter information
1476
+	 */
1477 1477
 	public function getDateArchiveSpotterDataById($id,$date) {
1478 1478
 		$Spotter = new Spotter($this->db);
1479 1479
 		date_default_timezone_set('UTC');
@@ -1484,13 +1484,13 @@  discard block
 block discarded – undo
1484 1484
 		return $spotter_array;
1485 1485
 	}
1486 1486
 
1487
-    /**
1488
-     * Gets all the spotter information based on a particular callsign
1489
-     *
1490
-     * @param $ident
1491
-     * @param $date
1492
-     * @return array the spotter information
1493
-     */
1487
+	/**
1488
+	 * Gets all the spotter information based on a particular callsign
1489
+	 *
1490
+	 * @param $ident
1491
+	 * @param $date
1492
+	 * @return array the spotter information
1493
+	 */
1494 1494
 	public function getDateArchiveSpotterDataByIdent($ident,$date) {
1495 1495
 		$Spotter = new Spotter($this->db);
1496 1496
 		date_default_timezone_set('UTC');
@@ -1501,15 +1501,15 @@  discard block
 block discarded – undo
1501 1501
 		return $spotter_array;
1502 1502
 	}
1503 1503
 
1504
-    /**
1505
-     * Gets all the spotter information based on the airport
1506
-     *
1507
-     * @param string $airport
1508
-     * @param string $limit
1509
-     * @param string $sort
1510
-     * @param array $filters
1511
-     * @return array the spotter information
1512
-     */
1504
+	/**
1505
+	 * Gets all the spotter information based on the airport
1506
+	 *
1507
+	 * @param string $airport
1508
+	 * @param string $limit
1509
+	 * @param string $sort
1510
+	 * @param array $filters
1511
+	 * @return array the spotter information
1512
+	 */
1513 1513
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) {
1514 1514
 		global $global_query;
1515 1515
 		$Spotter = new Spotter($this->db);
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	//protected $cookies = array();
15 15
 	
16 16
 	/**
17
-	* Get data from form result
18
-	* @param String $url form URL
19
-	* @param String $type type of submit form method (get or post)
20
-	* @param String|array $data values form post method
21
-	* @param array $headers header to submit with the form
22
-	* @return String the result
23
-	*/
17
+	 * Get data from form result
18
+	 * @param String $url form URL
19
+	 * @param String $type type of submit form method (get or post)
20
+	 * @param String|array $data values form post method
21
+	 * @param array $headers header to submit with the form
22
+	 * @return String the result
23
+	 */
24 24
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) {
25 25
 		global $globalProxy, $globalForceIPv4;
26 26
 		$ch = curl_init();
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	}
176 176
 
177 177
 	/**
178
-	* Convert a HTML table to an array
179
-	* @param String $data HTML page
180
-	* @return array array of the tables in HTML page
181
-	*/
178
+	 * Convert a HTML table to an array
179
+	 * @param String $data HTML page
180
+	 * @return array array of the tables in HTML page
181
+	 */
182 182
 	public function table2array($data) {
183 183
 		if (!is_string($data)) return array();
184 184
 		if ($data == '') return array();
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	}
213 213
 	
214 214
 	/**
215
-	* Convert <p> part of a HTML page to an array
216
-	* @param String $data HTML page
217
-	* @return array array of the <p> in HTML page
218
-	*/
215
+	 * Convert <p> part of a HTML page to an array
216
+	 * @param String $data HTML page
217
+	 * @return array array of the <p> in HTML page
218
+	 */
219 219
 	public function text2array($data) {
220 220
 		$html = str_get_html($data);
221 221
 		if ($html === false) return array();
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	/**
233
-	* Give distance between 2 coordonnates
234
-	* @param Float $lat latitude of first point
235
-	* @param Float $lon longitude of first point
236
-	* @param Float $latc latitude of second point
237
-	* @param Float $lonc longitude of second point
238
-	* @param String $unit km else no unit used
239
-	* @return Float Distance in $unit
240
-	*/
233
+	 * Give distance between 2 coordonnates
234
+	 * @param Float $lat latitude of first point
235
+	 * @param Float $lon longitude of first point
236
+	 * @param Float $latc latitude of second point
237
+	 * @param Float $lonc longitude of second point
238
+	 * @param String $unit km else no unit used
239
+	 * @return Float Distance in $unit
240
+	 */
241 241
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
242 242
 		if ($lat == $latc && $lon == $lonc) return 0;
243 243
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
 	}
256 256
 
257 257
 	/**
258
-	* Give plunge between 2 altitudes and distance
259
-	* @param Float $initial_altitude altitude of first point in m
260
-	* @param Float $final_altitude altitude of second point in m
261
-	* @param String $distance distance between two points in m
262
-	* @return Float plunge
263
-	*/
258
+	 * Give plunge between 2 altitudes and distance
259
+	 * @param Float $initial_altitude altitude of first point in m
260
+	 * @param Float $final_altitude altitude of second point in m
261
+	 * @param String $distance distance between two points in m
262
+	 * @return Float plunge
263
+	 */
264 264
 	public function plunge($initial_altitude,$final_altitude,$distance) {
265 265
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
266 266
 		/*
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 
276 276
 	/**
277
-	* Give azimuth between 2 coordonnates
278
-	* @param Float $lat latitude of first point
279
-	* @param Float $lon longitude of first point
280
-	* @param Float $latc latitude of second point
281
-	* @param Float $lonc longitude of second point
282
-	* @return Float Azimuth
283
-	*/
277
+	 * Give azimuth between 2 coordonnates
278
+	 * @param Float $lat latitude of first point
279
+	 * @param Float $lon longitude of first point
280
+	 * @param Float $latc latitude of second point
281
+	 * @param Float $lonc longitude of second point
282
+	 * @return Float Azimuth
283
+	 */
284 284
 	public function azimuth($lat, $lon, $latc, $lonc) {
285 285
 		$dX = $latc - $lat;
286 286
 		$dY = $lonc - $lon;
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 	
292 292
 	
293 293
 	/**
294
-	* Check is distance realistic
295
-	* @param int $timeDifference the time between the reception of both messages
296
-	* @param float $distance distance covered
297
-	* @return bool whether distance is realistic
298
-	*/
294
+	 * Check is distance realistic
295
+	 * @param int $timeDifference the time between the reception of both messages
296
+	 * @param float $distance distance covered
297
+	 * @return bool whether distance is realistic
298
+	 */
299 299
 	public function withinThreshold ($timeDifference, $distance) {
300 300
 		$x = abs($timeDifference);
301 301
 		$d = abs($distance);
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	}
384 384
 	
385 385
 	/**
386
-	* Copy folder contents
387
-	* @param       string   $source    Source path
388
-	* @param       string   $dest      Destination path
389
-	* @return      bool     Returns true on success, false on failure
390
-	*/
386
+	 * Copy folder contents
387
+	 * @param       string   $source    Source path
388
+	 * @param       string   $dest      Destination path
389
+	 * @return      bool     Returns true on success, false on failure
390
+	 */
391 391
 	public function xcopy($source, $dest)
392 392
 	{
393 393
 		$files = glob($source.'*.*');
@@ -399,20 +399,20 @@  discard block
 block discarded – undo
399 399
 	}
400 400
 	
401 401
 	/**
402
-	* Check if an url exist
403
-	* @param	String $url url to check
404
-	* @return	bool Return true on succes false on failure
405
-	*/
402
+	 * Check if an url exist
403
+	 * @param	String $url url to check
404
+	 * @return	bool Return true on succes false on failure
405
+	 */
406 406
 	public function urlexist($url){
407 407
 		$headers=get_headers($url);
408 408
 		return stripos($headers[0],"200 OK")?true:false;
409 409
 	}
410 410
 	
411 411
 	/**
412
-	* Convert hexa to string
413
-	* @param	String $hex data in hexa
414
-	* @return	String Return result
415
-	*/
412
+	 * Convert hexa to string
413
+	 * @param	String $hex data in hexa
414
+	 * @return	String Return result
415
+	 */
416 416
 	public function hex2str($hex) {
417 417
 		$str = '';
418 418
 		$hexln = strlen($hex);
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 	}
422 422
 	
423 423
 	/**
424
-	* Convert hexa color to rgb
425
-	* @param	String $hex data in hexa
426
-	* @return	String Return result
427
-	*/
424
+	 * Convert hexa color to rgb
425
+	 * @param	String $hex data in hexa
426
+	 * @return	String Return result
427
+	 */
428 428
 	public function hex2rgb($hex) {
429 429
 		$hex = str_replace('#','',$hex);
430 430
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 	}
503 503
 	
504 504
 	/**
505
-	* Returns list of available locales
506
-	*
507
-	* @return array
505
+	 * Returns list of available locales
506
+	 *
507
+	 * @return array
508 508
 	 */
509 509
 	public function listLocaleDir()
510 510
 	{
@@ -603,100 +603,100 @@  discard block
 block discarded – undo
603 603
 	public function remove_accents($string) {
604 604
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
605 605
 		$chars = array(
606
-		    // Decompositions for Latin-1 Supplement
607
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
608
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
609
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
610
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
611
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
612
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
613
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
614
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
615
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
616
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
617
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
618
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
619
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
620
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
621
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
622
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
623
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
624
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
625
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
626
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
627
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
628
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
629
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
630
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
631
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
632
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
633
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
634
-		    chr(195).chr(191) => 'y',
635
-		    // Decompositions for Latin Extended-A
636
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
637
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
638
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
639
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
640
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
641
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
642
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
643
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
644
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
645
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
646
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
647
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
648
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
649
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
650
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
651
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
652
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
653
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
654
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
655
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
656
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
657
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
658
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
659
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
660
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
661
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
662
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
663
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
664
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
665
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
666
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
667
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
668
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
669
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
670
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
671
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
672
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
673
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
674
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
675
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
676
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
677
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
678
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
679
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
680
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
681
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
682
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
683
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
684
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
685
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
686
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
687
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
688
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
689
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
690
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
691
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
692
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
693
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
694
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
695
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
696
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
697
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
698
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
699
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
606
+			// Decompositions for Latin-1 Supplement
607
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
608
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
609
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
610
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
611
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
612
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
613
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
614
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
615
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
616
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
617
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
618
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
619
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
620
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
621
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
622
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
623
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
624
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
625
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
626
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
627
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
628
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
629
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
630
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
631
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
632
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
633
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
634
+			chr(195).chr(191) => 'y',
635
+			// Decompositions for Latin Extended-A
636
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
637
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
638
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
639
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
640
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
641
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
642
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
643
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
644
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
645
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
646
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
647
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
648
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
649
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
650
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
651
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
652
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
653
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
654
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
655
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
656
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
657
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
658
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
659
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
660
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
661
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
662
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
663
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
664
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
665
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
666
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
667
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
668
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
669
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
670
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
671
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
672
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
673
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
674
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
675
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
676
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
677
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
678
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
679
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
680
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
681
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
682
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
683
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
684
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
685
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
686
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
687
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
688
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
689
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
690
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
691
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
692
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
693
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
694
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
695
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
696
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
697
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
698
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
699
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
700 700
 		);
701 701
 		$string = strtr($string, $chars);
702 702
 		return $string;
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 			$dfX = $first_pass[$j][0];
838 838
 			$dfDiffLong = abs($dfX - $dfPrevX);
839 839
 			if ($dfDiffLong > $dfDiffSpace &&
840
-			    (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
840
+				(($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
841 841
 			{
842 842
 				$bHasBigDiff = true;
843 843
 			} else if ($dfDiffLong > $dfMaxSmallDiffLong) {
@@ -857,8 +857,8 @@  discard block
 block discarded – undo
857 857
 					$dfX2 = floatval($first_pass[$k][0]);
858 858
 					$dfY2 = floatval($first_pass[$k][1]);
859 859
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
860
-					    $k+1 < count($first_pass) &&
861
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
860
+						$k+1 < count($first_pass) &&
861
+						$first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
862 862
 					{
863 863
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
864 864
 						$k++;
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
867 867
 						continue;
868 868
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
869
-					    $k+1 < $first_pass_ln &&
870
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
869
+						$k+1 < $first_pass_ln &&
870
+						$first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
871 871
 					{
872 872
 						$poNewLS[] = array(180, $first_pass[$k][1]);
873 873
 						$k++;
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 		if ($this->db === null) die('Error: No DB connection. (ATC)');
22 22
 	}
23 23
 
24
-    /**
25
-     * Get SQL query part for filter used
26
-     * @param array $filter the filter
27
-     * @param bool $where
28
-     * @param bool $and
29
-     * @return String the SQL part
30
-     */
24
+	/**
25
+	 * Get SQL query part for filter used
26
+	 * @param array $filter the filter
27
+	 * @param bool $where
28
+	 * @param bool $and
29
+	 * @return String the SQL part
30
+	 */
31 31
 	public function getFilter($filter = array(),$where = false,$and = false) {
32 32
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
33 33
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * Get all ATC from atc table
56 56
 	 * @return array Return all ATC
57 57
      */
58
-    public function getAll() {
58
+	public function getAll() {
59 59
 		$filter_query = $this->getFilter(array());
60 60
 		$query = "SELECT * FROM atc".$filter_query;
61 61
 		$query_values = array();
Please login to merge, or discard this patch.
require/class.MarineArchive.php 1 patch
Indentation   +927 added lines, -927 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 		if ($this->db === null) die('Error: No DB connection. (MarineArchive)');
17 17
 	}
18 18
 
19
-    /**
20
-     * Get SQL query part for filter used
21
-     * @param array $filter the filter
22
-     * @param bool $where
23
-     * @param bool $and
24
-     * @return string the SQL part
25
-     */
19
+	/**
20
+	 * Get SQL query part for filter used
21
+	 * @param array $filter the filter
22
+	 * @param bool $where
23
+	 * @param bool $and
24
+	 * @return string the SQL part
25
+	 */
26 26
 	public function getFilter($filter = array(),$where = false,$and = false) {
27 27
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
28 28
 		$filters = array();
@@ -91,40 +91,40 @@  discard block
 block discarded – undo
91 91
 		return $filter_query;
92 92
 	}
93 93
 
94
-    /**
95
-     * Add to Mariche archive
96
-     *
97
-     * @param string $fammarine_id
98
-     * @param string $ident
99
-     * @param string $latitude
100
-     * @param string $longitude
101
-     * @param string $heading
102
-     * @param string $groundspeed
103
-     * @param string $date
104
-     * @param bool $putinarchive
105
-     * @param string $mmsi
106
-     * @param string $type
107
-     * @param string $typeid
108
-     * @param string $imo
109
-     * @param string $callsign
110
-     * @param string $arrival_code
111
-     * @param string $arrival_date
112
-     * @param string $status
113
-     * @param string $statusid
114
-     * @param bool $noarchive
115
-     * @param string $format_source
116
-     * @param string $source_name
117
-     * @param string $over_country
118
-     * @param string $captain_id
119
-     * @param string $captain_name
120
-     * @param string $race_id
121
-     * @param string $race_name
122
-     * @param string $distance
123
-     * @param string $race_rank
124
-     * @param string $race_time
125
-     * @return string
126
-     */
127
-    public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') {
94
+	/**
95
+	 * Add to Mariche archive
96
+	 *
97
+	 * @param string $fammarine_id
98
+	 * @param string $ident
99
+	 * @param string $latitude
100
+	 * @param string $longitude
101
+	 * @param string $heading
102
+	 * @param string $groundspeed
103
+	 * @param string $date
104
+	 * @param bool $putinarchive
105
+	 * @param string $mmsi
106
+	 * @param string $type
107
+	 * @param string $typeid
108
+	 * @param string $imo
109
+	 * @param string $callsign
110
+	 * @param string $arrival_code
111
+	 * @param string $arrival_date
112
+	 * @param string $status
113
+	 * @param string $statusid
114
+	 * @param bool $noarchive
115
+	 * @param string $format_source
116
+	 * @param string $source_name
117
+	 * @param string $over_country
118
+	 * @param string $captain_id
119
+	 * @param string $captain_name
120
+	 * @param string $race_id
121
+	 * @param string $race_name
122
+	 * @param string $distance
123
+	 * @param string $race_rank
124
+	 * @param string $race_time
125
+	 * @return string
126
+	 */
127
+	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') {
128 128
 		require_once(dirname(__FILE__).'/class.Marine.php');
129 129
 		if ($over_country == '') {
130 130
 			$Marine = new Marine($this->db);
@@ -149,42 +149,42 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 
152
-    /**
153
-     * Gets all the spotter information based on a particular callsign
154
-     *
155
-     * @param $ident
156
-     * @return array the spotter information
157
-     */
158
-    public function getLastArchiveMarineDataByIdent($ident)
159
-    {
160
-	    $Marine = new Marine($this->db);
161
-        date_default_timezone_set('UTC');
162
-
163
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
164
-        //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
165
-        $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
-        $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
167
-        return $spotter_array;
168
-    }
169
-
170
-
171
-    /**
172
-     * Gets last the spotter information based on a particular id
173
-     *
174
-     * @param $id
175
-     * @return array the spotter information
176
-     */
177
-    public function getLastArchiveMarineDataById($id)
178
-    {
179
-        $Marine = new Marine($this->db);
180
-        date_default_timezone_set('UTC');
181
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
182
-        //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
183
-        //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
184
-        $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
152
+	/**
153
+	 * Gets all the spotter information based on a particular callsign
154
+	 *
155
+	 * @param $ident
156
+	 * @return array the spotter information
157
+	 */
158
+	public function getLastArchiveMarineDataByIdent($ident)
159
+	{
160
+		$Marine = new Marine($this->db);
161
+		date_default_timezone_set('UTC');
162
+
163
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
164
+		//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
165
+		$query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
+		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
167
+		return $spotter_array;
168
+	}
169
+
170
+
171
+	/**
172
+	 * Gets last the spotter information based on a particular id
173
+	 *
174
+	 * @param $id
175
+	 * @return array the spotter information
176
+	 */
177
+	public function getLastArchiveMarineDataById($id)
178
+	{
179
+		$Marine = new Marine($this->db);
180
+		date_default_timezone_set('UTC');
181
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
182
+		//$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
183
+		//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
184
+		$query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
185 185
 
186 186
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
187
-                  /*
187
+				  /*
188 188
                 try {
189 189
                         $Connection = new Connection();
190 190
                         $sth = Connection->$db->prepare($query);
@@ -194,196 +194,196 @@  discard block
 block discarded – undo
194 194
                 }
195 195
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
196 196
                 */
197
-        $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
198
-        return $spotter_array;
199
-    }
200
-
201
-    /**
202
-     * Gets all the spotter information based on a particular id
203
-     *
204
-     * @param $id
205
-     * @return array the spotter information
206
-     */
207
-    public function getAllArchiveMarineDataById($id)
197
+		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
198
+		return $spotter_array;
199
+	}
200
+
201
+	/**
202
+	 * Gets all the spotter information based on a particular id
203
+	 *
204
+	 * @param $id
205
+	 * @return array the spotter information
206
+	 */
207
+	public function getAllArchiveMarineDataById($id)
208 208
 	{
209
-        date_default_timezone_set('UTC');
210
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
211
-        $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
209
+		date_default_timezone_set('UTC');
210
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
211
+		$query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
212 212
 
213 213
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
214 214
 
215
-        try {
216
-            $sth = $this->db->prepare($query);
217
-            $sth->execute(array(':id' => $id));
218
-        } catch(PDOException $e) {
219
-            echo $e->getMessage();
220
-            die;
221
-        }
222
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
223
-        return $spotter_array;
215
+		try {
216
+			$sth = $this->db->prepare($query);
217
+			$sth->execute(array(':id' => $id));
218
+		} catch(PDOException $e) {
219
+			echo $e->getMessage();
220
+			die;
221
+		}
222
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
223
+		return $spotter_array;
224 224
 	}
225 225
 
226
-    /**
227
-     * Gets coordinate & time spotter information based on a particular id
228
-     *
229
-     * @param $id
230
-     * @return array the spotter information
231
-     */
232
-    public function getCoordArchiveMarineDataById($id)
233
-    {
234
-        date_default_timezone_set('UTC');
235
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
236
-        $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
226
+	/**
227
+	 * Gets coordinate & time spotter information based on a particular id
228
+	 *
229
+	 * @param $id
230
+	 * @return array the spotter information
231
+	 */
232
+	public function getCoordArchiveMarineDataById($id)
233
+	{
234
+		date_default_timezone_set('UTC');
235
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
236
+		$query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
237 237
 
238 238
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
239 239
 
240
-        try {
241
-            $sth = $this->db->prepare($query);
242
-            $sth->execute(array(':id' => $id));
243
-        } catch(PDOException $e) {
244
-            echo $e->getMessage();
245
-            die;
246
-        }
247
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
248
-
249
-        return $spotter_array;
250
-    }
251
-
252
-
253
-    /**
254
-     * Gets altitude information based on a particular callsign
255
-     *
256
-     * @param $ident
257
-     * @return array the spotter information
258
-     */
259
-    public function getAltitudeArchiveMarineDataByIdent($ident)
260
-    {
261
-
262
-        date_default_timezone_set('UTC');
263
-
264
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
265
-        $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
266
-
267
-        try {
268
-            $sth = $this->db->prepare($query);
269
-            $sth->execute(array(':ident' => $ident));
270
-        } catch(PDOException $e) {
271
-            echo $e->getMessage();
272
-            die;
273
-        }
274
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
275
-
276
-        return $spotter_array;
277
-    }
278
-
279
-    /**
280
-     * Gets altitude information based on a particular id
281
-     *
282
-     * @return array the spotter information
283
-     *
284
-     */
285
-    public function getAltitudeArchiveMarineDataById($id)
286
-    {
287
-
288
-        date_default_timezone_set('UTC');
289
-
290
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
291
-        $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
292
-
293
-        try {
294
-            $sth = $this->db->prepare($query);
295
-            $sth->execute(array(':id' => $id));
296
-        } catch(PDOException $e) {
297
-            echo $e->getMessage();
298
-            die;
299
-        }
300
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
301
-
302
-        return $spotter_array;
303
-    }
304
-
305
-    /**
306
-     * Gets altitude & speed information based on a particular id
307
-     *
308
-     * @param $id
309
-     * @return array the spotter information
310
-     */
311
-    public function getAltitudeSpeedArchiveMarineDataById($id)
312
-    {
313
-        date_default_timezone_set('UTC');
314
-
315
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
316
-        $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
317
-
318
-        try {
319
-            $sth = $this->db->prepare($query);
320
-            $sth->execute(array(':id' => $id));
321
-        } catch(PDOException $e) {
322
-            echo $e->getMessage();
323
-            die;
324
-        }
325
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
326
-
327
-        return $spotter_array;
328
-    }
329
-
330
-
331
-    /**
332
-     * Gets altitude information based on a particular callsign
333
-     *
334
-     * @param $ident
335
-     * @return array the spotter information
336
-     */
337
-    public function getLastAltitudeArchiveMarineDataByIdent($ident)
338
-    {
339
-
340
-        date_default_timezone_set('UTC');
341
-
342
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
343
-        $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
240
+		try {
241
+			$sth = $this->db->prepare($query);
242
+			$sth->execute(array(':id' => $id));
243
+		} catch(PDOException $e) {
244
+			echo $e->getMessage();
245
+			die;
246
+		}
247
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
248
+
249
+		return $spotter_array;
250
+	}
251
+
252
+
253
+	/**
254
+	 * Gets altitude information based on a particular callsign
255
+	 *
256
+	 * @param $ident
257
+	 * @return array the spotter information
258
+	 */
259
+	public function getAltitudeArchiveMarineDataByIdent($ident)
260
+	{
261
+
262
+		date_default_timezone_set('UTC');
263
+
264
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
265
+		$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
266
+
267
+		try {
268
+			$sth = $this->db->prepare($query);
269
+			$sth->execute(array(':ident' => $ident));
270
+		} catch(PDOException $e) {
271
+			echo $e->getMessage();
272
+			die;
273
+		}
274
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
275
+
276
+		return $spotter_array;
277
+	}
278
+
279
+	/**
280
+	 * Gets altitude information based on a particular id
281
+	 *
282
+	 * @return array the spotter information
283
+	 *
284
+	 */
285
+	public function getAltitudeArchiveMarineDataById($id)
286
+	{
287
+
288
+		date_default_timezone_set('UTC');
289
+
290
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
291
+		$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
292
+
293
+		try {
294
+			$sth = $this->db->prepare($query);
295
+			$sth->execute(array(':id' => $id));
296
+		} catch(PDOException $e) {
297
+			echo $e->getMessage();
298
+			die;
299
+		}
300
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
301
+
302
+		return $spotter_array;
303
+	}
304
+
305
+	/**
306
+	 * Gets altitude & speed information based on a particular id
307
+	 *
308
+	 * @param $id
309
+	 * @return array the spotter information
310
+	 */
311
+	public function getAltitudeSpeedArchiveMarineDataById($id)
312
+	{
313
+		date_default_timezone_set('UTC');
314
+
315
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
316
+		$query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
317
+
318
+		try {
319
+			$sth = $this->db->prepare($query);
320
+			$sth->execute(array(':id' => $id));
321
+		} catch(PDOException $e) {
322
+			echo $e->getMessage();
323
+			die;
324
+		}
325
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
326
+
327
+		return $spotter_array;
328
+	}
329
+
330
+
331
+	/**
332
+	 * Gets altitude information based on a particular callsign
333
+	 *
334
+	 * @param $ident
335
+	 * @return array the spotter information
336
+	 */
337
+	public function getLastAltitudeArchiveMarineDataByIdent($ident)
338
+	{
339
+
340
+		date_default_timezone_set('UTC');
341
+
342
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
343
+		$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
344 344
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
345 345
 
346
-        try {
347
-            $sth = $this->db->prepare($query);
348
-            $sth->execute(array(':ident' => $ident));
349
-        } catch(PDOException $e) {
350
-            echo $e->getMessage();
351
-            die;
352
-        }
353
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
354
-
355
-        return $spotter_array;
356
-    }
357
-
358
-
359
-    /**
360
-     * Gets all the archive spotter information
361
-     *
362
-     * @param $ident
363
-     * @param $fammarine_id
364
-     * @param $date
365
-     * @return array the spotter information
366
-     */
367
-    public function getMarineArchiveData($ident,$fammarine_id,$date)
368
-    {
369
-        $Marine = new Marine($this->db);
370
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
371
-        $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
372
-        $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
373
-        return $spotter_array;
374
-    }
375
-
376
-    /**
377
-     * Delete all tracking data
378
-     *
379
-     */
380
-    public function deleteMarineArchiveTrackData()
381
-    {
382
-        global $globalArchiveKeepTrackMonths, $globalDBdriver;
383
-        if ($globalDBdriver == 'mysql') {
384
-            $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
385
-        } else {
386
-            $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
346
+		try {
347
+			$sth = $this->db->prepare($query);
348
+			$sth->execute(array(':ident' => $ident));
349
+		} catch(PDOException $e) {
350
+			echo $e->getMessage();
351
+			die;
352
+		}
353
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
354
+
355
+		return $spotter_array;
356
+	}
357
+
358
+
359
+	/**
360
+	 * Gets all the archive spotter information
361
+	 *
362
+	 * @param $ident
363
+	 * @param $fammarine_id
364
+	 * @param $date
365
+	 * @return array the spotter information
366
+	 */
367
+	public function getMarineArchiveData($ident,$fammarine_id,$date)
368
+	{
369
+		$Marine = new Marine($this->db);
370
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
371
+		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
372
+		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
373
+		return $spotter_array;
374
+	}
375
+
376
+	/**
377
+	 * Delete all tracking data
378
+	 *
379
+	 */
380
+	public function deleteMarineArchiveTrackData()
381
+	{
382
+		global $globalArchiveKeepTrackMonths, $globalDBdriver;
383
+		if ($globalDBdriver == 'mysql') {
384
+			$query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
385
+		} else {
386
+			$query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
387 387
 		}
388 388
 		try {
389 389
 			$sth = $this->db->prepare($query);
@@ -394,42 +394,42 @@  discard block
 block discarded – undo
394 394
 		}
395 395
 	}
396 396
 
397
-    /**
398
-     * Gets Minimal Live Marine data
399
-     *
400
-     * @param $begindate
401
-     * @param $enddate
402
-     * @param array $filter
403
-     * @return array the spotter information
404
-     */
405
-    public function getMinLiveMarineData($begindate,$enddate,$filter = array())
406
-    {
407
-        global $globalDBdriver, $globalLiveInterval;
408
-        date_default_timezone_set('UTC');
409
-
410
-        $filter_query = '';
411
-        if (isset($filter['source']) && !empty($filter['source'])) {
412
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
-        }
414
-        // Use spotter_output also ?
415
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
417
-        }
418
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
420
-        }
421
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
-        }
424
-
425
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
-        if ($globalDBdriver == 'mysql') {
427
-            /*
397
+	/**
398
+	 * Gets Minimal Live Marine data
399
+	 *
400
+	 * @param $begindate
401
+	 * @param $enddate
402
+	 * @param array $filter
403
+	 * @return array the spotter information
404
+	 */
405
+	public function getMinLiveMarineData($begindate,$enddate,$filter = array())
406
+	{
407
+		global $globalDBdriver, $globalLiveInterval;
408
+		date_default_timezone_set('UTC');
409
+
410
+		$filter_query = '';
411
+		if (isset($filter['source']) && !empty($filter['source'])) {
412
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
+		}
414
+		// Use spotter_output also ?
415
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
+			$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
417
+		}
418
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
+			$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
420
+		}
421
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
+		}
424
+
425
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
+		if ($globalDBdriver == 'mysql') {
427
+			/*
428 428
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
429 429
                     		    FROM marine_archive 
430 430
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
431 431
 			*/
432
-            /*
432
+			/*
433 433
 			$query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
434 434
 				    FROM marine_archive 
435 435
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
@@ -438,540 +438,540 @@  discard block
 block discarded – undo
438 438
 						GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id 
439 439
 				    AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
440 440
 */
441
-            $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
441
+			$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
442 442
 				    FROM marine_archive 
443 443
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
444 444
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
445 445
                         	    '.$filter_query.' ORDER BY fammarine_id';
446
-        } else {
447
-            //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
448
-            $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
446
+		} else {
447
+			//$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
448
+			$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
449 449
                         	    FROM marine_archive 
450 450
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
451 451
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
452 452
                         	    '.$filter_query.' ORDER BY fammarine_id';
453
-        }
454
-        //echo $query;
455
-        try {
456
-            $sth = $this->db->prepare($query);
457
-            $sth->execute();
458
-        } catch(PDOException $e) {
459
-            echo $e->getMessage();
460
-            die;
461
-        }
462
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
463
-
464
-        return $spotter_array;
465
-    }
466
-
467
-    /**
468
-     * Gets Minimal Live Marine data
469
-     *
470
-     * @param $begindate
471
-     * @param $enddate
472
-     * @param array $filter
473
-     * @return array the spotter information
474
-     */
475
-    public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
476
-    {
477
-        global $globalDBdriver, $globalLiveInterval;
478
-        date_default_timezone_set('UTC');
479
-
480
-        $filter_query = '';
481
-        if (isset($filter['source']) && !empty($filter['source'])) {
482
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
483
-        }
484
-        // Should use spotter_output also ?
485
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
486
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
487
-        }
488
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
489
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
490
-        }
491
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
492
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
493
-        }
494
-
495
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
496
-        if ($globalDBdriver == 'mysql') {
497
-            /*
453
+		}
454
+		//echo $query;
455
+		try {
456
+			$sth = $this->db->prepare($query);
457
+			$sth->execute();
458
+		} catch(PDOException $e) {
459
+			echo $e->getMessage();
460
+			die;
461
+		}
462
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
463
+
464
+		return $spotter_array;
465
+	}
466
+
467
+	/**
468
+	 * Gets Minimal Live Marine data
469
+	 *
470
+	 * @param $begindate
471
+	 * @param $enddate
472
+	 * @param array $filter
473
+	 * @return array the spotter information
474
+	 */
475
+	public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
476
+	{
477
+		global $globalDBdriver, $globalLiveInterval;
478
+		date_default_timezone_set('UTC');
479
+
480
+		$filter_query = '';
481
+		if (isset($filter['source']) && !empty($filter['source'])) {
482
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
483
+		}
484
+		// Should use spotter_output also ?
485
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
486
+			$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
487
+		}
488
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
489
+			$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
490
+		}
491
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
492
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
493
+		}
494
+
495
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
496
+		if ($globalDBdriver == 'mysql') {
497
+			/*
498 498
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
499 499
                     		    FROM marine_archive 
500 500
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
501 501
 			*/
502
-            $query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
502
+			$query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
503 503
 				    FROM marine_archive_output 
504 504
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao 
505 505
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
506 506
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
507 507
 
508
-        } else {
509
-            //$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
510
-            /*
508
+		} else {
509
+			//$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
510
+			/*
511 511
                         $query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
512 512
                         	    FROM marine_archive_output 
513 513
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
514 514
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
515 515
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
516 516
                         */
517
-            $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
517
+			$query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
518 518
                         	    FROM marine_archive_output 
519 519
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
520 520
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
521 521
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
522 522
 //                        	    .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
523 523
                         	    
524
-        }
525
-        //echo $query;
526
-        try {
527
-            $sth = $this->db->prepare($query);
528
-            $sth->execute();
529
-        } catch(PDOException $e) {
530
-            echo $e->getMessage();
531
-            die;
532
-        }
533
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
534
-
535
-        return $spotter_array;
536
-    }
537
-
538
-    /**
539
-     * Gets count Live Marine data
540
-     *
541
-     * @param $begindate
542
-     * @param $enddate
543
-     * @param array $filter
544
-     * @return array the spotter information
545
-     */
546
-    public function getLiveMarineCount($begindate,$enddate,$filter = array())
547
-    {
548
-        global $globalDBdriver, $globalLiveInterval;
549
-        date_default_timezone_set('UTC');
550
-
551
-        $filter_query = '';
552
-        if (isset($filter['source']) && !empty($filter['source'])) {
553
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
554
-        }
555
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
556
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
557
-        }
558
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
559
-            $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
560
-        }
561
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
562
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
563
-        }
564
-
565
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
566
-        if ($globalDBdriver == 'mysql') {
567
-            $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
524
+		}
525
+		//echo $query;
526
+		try {
527
+			$sth = $this->db->prepare($query);
528
+			$sth->execute();
529
+		} catch(PDOException $e) {
530
+			echo $e->getMessage();
531
+			die;
532
+		}
533
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
534
+
535
+		return $spotter_array;
536
+	}
537
+
538
+	/**
539
+	 * Gets count Live Marine data
540
+	 *
541
+	 * @param $begindate
542
+	 * @param $enddate
543
+	 * @param array $filter
544
+	 * @return array the spotter information
545
+	 */
546
+	public function getLiveMarineCount($begindate,$enddate,$filter = array())
547
+	{
548
+		global $globalDBdriver, $globalLiveInterval;
549
+		date_default_timezone_set('UTC');
550
+
551
+		$filter_query = '';
552
+		if (isset($filter['source']) && !empty($filter['source'])) {
553
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
554
+		}
555
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
556
+			$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
557
+		}
558
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
559
+			$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
560
+		}
561
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
562
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
563
+		}
564
+
565
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
566
+		if ($globalDBdriver == 'mysql') {
567
+			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
568 568
 			FROM marine_archive l 
569 569
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
570
-        } else {
571
-            $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
572
-        }
573
-        //echo $query;
574
-        try {
575
-            $sth = $this->db->prepare($query);
576
-            $sth->execute();
577
-        } catch(PDOException $e) {
578
-            echo $e->getMessage();
579
-            die;
580
-        }
581
-        $result = $sth->fetch(PDO::FETCH_ASSOC);
582
-        $sth->closeCursor();
583
-        return $result['nb'];
584
-    }
570
+		} else {
571
+			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
572
+		}
573
+		//echo $query;
574
+		try {
575
+			$sth = $this->db->prepare($query);
576
+			$sth->execute();
577
+		} catch(PDOException $e) {
578
+			echo $e->getMessage();
579
+			die;
580
+		}
581
+		$result = $sth->fetch(PDO::FETCH_ASSOC);
582
+		$sth->closeCursor();
583
+		return $result['nb'];
584
+	}
585 585
 
586 586
 
587 587
 
588 588
 	// marine_archive_output
589 589
 
590
-    /**
591
-     * Gets all the spotter information
592
-     *
593
-     * @param string $q
594
-     * @param string $registration
595
-     * @param string $aircraft_icao
596
-     * @param string $aircraft_manufacturer
597
-     * @param string $highlights
598
-     * @param string $airline_icao
599
-     * @param string $airline_country
600
-     * @param string $airline_type
601
-     * @param string $airport
602
-     * @param string $airport_country
603
-     * @param string $callsign
604
-     * @param string $departure_airport_route
605
-     * @param string $arrival_airport_route
606
-     * @param string $owner
607
-     * @param string $pilot_id
608
-     * @param string $pilot_name
609
-     * @param string $altitude
610
-     * @param string $date_posted
611
-     * @param string $limit
612
-     * @param string $sort
613
-     * @param string $includegeodata
614
-     * @param string $origLat
615
-     * @param string $origLon
616
-     * @param string $dist
617
-     * @param array $filters
618
-     * @return array the spotter information
619
-     */
620
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
621
-    {
622
-        global $globalTimezone, $globalDBdriver;
623
-        require_once(dirname(__FILE__).'/class.Translation.php');
624
-        $Translation = new Translation($this->db);
625
-        $Marine = new Marine($this->db);
626
-
627
-        date_default_timezone_set('UTC');
590
+	/**
591
+	 * Gets all the spotter information
592
+	 *
593
+	 * @param string $q
594
+	 * @param string $registration
595
+	 * @param string $aircraft_icao
596
+	 * @param string $aircraft_manufacturer
597
+	 * @param string $highlights
598
+	 * @param string $airline_icao
599
+	 * @param string $airline_country
600
+	 * @param string $airline_type
601
+	 * @param string $airport
602
+	 * @param string $airport_country
603
+	 * @param string $callsign
604
+	 * @param string $departure_airport_route
605
+	 * @param string $arrival_airport_route
606
+	 * @param string $owner
607
+	 * @param string $pilot_id
608
+	 * @param string $pilot_name
609
+	 * @param string $altitude
610
+	 * @param string $date_posted
611
+	 * @param string $limit
612
+	 * @param string $sort
613
+	 * @param string $includegeodata
614
+	 * @param string $origLat
615
+	 * @param string $origLon
616
+	 * @param string $dist
617
+	 * @param array $filters
618
+	 * @return array the spotter information
619
+	 */
620
+	public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
621
+	{
622
+		global $globalTimezone, $globalDBdriver;
623
+		require_once(dirname(__FILE__).'/class.Translation.php');
624
+		$Translation = new Translation($this->db);
625
+		$Marine = new Marine($this->db);
626
+
627
+		date_default_timezone_set('UTC');
628 628
 	
629
-        $query_values = array();
630
-        $additional_query = '';
631
-        $limit_query = '';
632
-        $filter_query = $this->getFilter($filters);
633
-        if ($q != "")
634
-        {
635
-            if (!is_string($q))
636
-            {
637
-                return array();
638
-            } else {
639
-                $q_array = explode(" ", $q);
629
+		$query_values = array();
630
+		$additional_query = '';
631
+		$limit_query = '';
632
+		$filter_query = $this->getFilter($filters);
633
+		if ($q != "")
634
+		{
635
+			if (!is_string($q))
636
+			{
637
+				return array();
638
+			} else {
639
+				$q_array = explode(" ", $q);
640 640
 		
641
-                foreach ($q_array as $q_item){
642
-                    $additional_query .= " AND (";
643
-                    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
644
-                    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
645
-                    $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
646
-                    $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
647
-                    $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
648
-                    $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
649
-                    $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
650
-                    $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
651
-                    $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
652
-                    $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
653
-                    $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
654
-                    $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
655
-                    $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
656
-                    $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
657
-                    $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
658
-                    $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
659
-                    $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
660
-                    $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
661
-                    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
662
-                    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
663
-                    $translate = $Translation->ident2icao($q_item);
664
-                    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
665
-                    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
666
-                    $additional_query .= ")";
667
-                }
668
-            }
669
-        }
641
+				foreach ($q_array as $q_item){
642
+					$additional_query .= " AND (";
643
+					$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
644
+					$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
645
+					$additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
646
+					$additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
647
+					$additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
648
+					$additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
649
+					$additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
650
+					$additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
651
+					$additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
652
+					$additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
653
+					$additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
654
+					$additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
655
+					$additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
656
+					$additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
657
+					$additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
658
+					$additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
659
+					$additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
660
+					$additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
661
+					$additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
662
+					$additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
663
+					$translate = $Translation->ident2icao($q_item);
664
+					if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
665
+					$additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
666
+					$additional_query .= ")";
667
+				}
668
+			}
669
+		}
670 670
 	
671
-        if ($registration != "")
672
-        {
673
-            $registration = filter_var($registration,FILTER_SANITIZE_STRING);
674
-            if (!is_string($registration))
675
-            {
676
-                return array();
677
-            } else {
678
-                $additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
679
-            }
680
-        }
671
+		if ($registration != "")
672
+		{
673
+			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
674
+			if (!is_string($registration))
675
+			{
676
+				return array();
677
+			} else {
678
+				$additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
679
+			}
680
+		}
681 681
 	
682
-        if ($aircraft_icao != "")
683
-        {
684
-            $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
685
-            if (!is_string($aircraft_icao))
686
-            {
687
-                return array();
688
-            } else {
689
-                $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
690
-            }
691
-        }
682
+		if ($aircraft_icao != "")
683
+		{
684
+			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
685
+			if (!is_string($aircraft_icao))
686
+			{
687
+				return array();
688
+			} else {
689
+				$additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
690
+			}
691
+		}
692 692
 	
693
-        if ($aircraft_manufacturer != "")
694
-        {
695
-            $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
696
-            if (!is_string($aircraft_manufacturer))
697
-            {
698
-                return array();
699
-	    } else {
700
-                $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
701
-            }
702
-        }
693
+		if ($aircraft_manufacturer != "")
694
+		{
695
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
696
+			if (!is_string($aircraft_manufacturer))
697
+			{
698
+				return array();
699
+		} else {
700
+				$additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
701
+			}
702
+		}
703 703
 	
704
-        if ($highlights == "true")
705
-        {
706
-            if (!is_string($highlights))
707
-            {
708
-                return array();
709
-            } else {
710
-                $additional_query .= " AND (marine_archive_output.highlight <> '')";
711
-            }
712
-        }
704
+		if ($highlights == "true")
705
+		{
706
+			if (!is_string($highlights))
707
+			{
708
+				return array();
709
+			} else {
710
+				$additional_query .= " AND (marine_archive_output.highlight <> '')";
711
+			}
712
+		}
713 713
 	
714
-        if ($airline_icao != "")
715
-        {
716
-            $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
717
-            if (!is_string($airline_icao))
718
-            {
719
-                return array();
720
-            } else {
721
-                $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
722
-            }
723
-        }
714
+		if ($airline_icao != "")
715
+		{
716
+			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
717
+			if (!is_string($airline_icao))
718
+			{
719
+				return array();
720
+			} else {
721
+				$additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
722
+			}
723
+		}
724 724
 	
725
-        if ($airline_country != "")
726
-        {
727
-            $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
728
-            if (!is_string($airline_country))
729
-            {
730
-                return array();
731
-            } else {
732
-                $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
733
-            }
734
-        }
725
+		if ($airline_country != "")
726
+		{
727
+			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
728
+			if (!is_string($airline_country))
729
+			{
730
+				return array();
731
+			} else {
732
+				$additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
733
+			}
734
+		}
735 735
 	
736
-        if ($airline_type != "")
737
-        {
738
-            $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
739
-            if (!is_string($airline_type))
740
-            {
741
-                return array();
742
-            } else {
743
-                if ($airline_type == "passenger")
744
-                {
745
-                    $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
746
-                }
747
-                if ($airline_type == "cargo")
748
-                {
749
-                    $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
750
-                }
751
-                if ($airline_type == "military")
752
-                {
753
-                    $additional_query .= " AND (marine_archive_output.airline_type = 'military')";
754
-                }
755
-            }
756
-        }
736
+		if ($airline_type != "")
737
+		{
738
+			$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
739
+			if (!is_string($airline_type))
740
+			{
741
+				return array();
742
+			} else {
743
+				if ($airline_type == "passenger")
744
+				{
745
+					$additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
746
+				}
747
+				if ($airline_type == "cargo")
748
+				{
749
+					$additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
750
+				}
751
+				if ($airline_type == "military")
752
+				{
753
+					$additional_query .= " AND (marine_archive_output.airline_type = 'military')";
754
+				}
755
+			}
756
+		}
757 757
 	
758
-        if ($airport != "")
759
-        {
760
-            $airport = filter_var($airport,FILTER_SANITIZE_STRING);
761
-            if (!is_string($airport))
762
-            {
763
-                return array();
764
-            } else {
765
-                $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
766
-            }
767
-        }
758
+		if ($airport != "")
759
+		{
760
+			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
761
+			if (!is_string($airport))
762
+			{
763
+				return array();
764
+			} else {
765
+				$additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
766
+			}
767
+		}
768 768
 	
769
-        if ($airport_country != "")
770
-        {
771
-            $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
772
-            if (!is_string($airport_country))
773
-            {
774
-                return array();
775
-            } else {
776
-                $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
777
-            }
778
-        }
769
+		if ($airport_country != "")
770
+		{
771
+			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
772
+			if (!is_string($airport_country))
773
+			{
774
+				return array();
775
+			} else {
776
+				$additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
777
+			}
778
+		}
779 779
     
780
-        if ($callsign != "")
781
-        {
782
-            $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
783
-            if (!is_string($callsign))
784
-            {
785
-                return array();
786
-            } else {
787
-                $translate = $Translation->ident2icao($callsign);
788
-                if ($translate != $callsign) {
789
-                    $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
790
-                    $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
791
-                } else {
792
-                    $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
793
-                }
794
-            }
795
-        }
796
-
797
-        if ($owner != "")
798
-        {
799
-            $owner = filter_var($owner,FILTER_SANITIZE_STRING);
800
-            if (!is_string($owner))
801
-            {
802
-                return array();
803
-            } else {
804
-                $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
805
-            }
806
-        }
807
-
808
-        if ($pilot_name != "")
809
-        {
810
-            $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
811
-            if (!is_string($pilot_name))
812
-            {
813
-                return array();
814
-            } else {
815
-                $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
816
-            }
817
-        }
780
+		if ($callsign != "")
781
+		{
782
+			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
783
+			if (!is_string($callsign))
784
+			{
785
+				return array();
786
+			} else {
787
+				$translate = $Translation->ident2icao($callsign);
788
+				if ($translate != $callsign) {
789
+					$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
790
+					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
791
+				} else {
792
+					$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
793
+				}
794
+			}
795
+		}
796
+
797
+		if ($owner != "")
798
+		{
799
+			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
800
+			if (!is_string($owner))
801
+			{
802
+				return array();
803
+			} else {
804
+				$additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
805
+			}
806
+		}
807
+
808
+		if ($pilot_name != "")
809
+		{
810
+			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
811
+			if (!is_string($pilot_name))
812
+			{
813
+				return array();
814
+			} else {
815
+				$additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
816
+			}
817
+		}
818 818
 	
819
-        if ($pilot_id != "")
820
-        {
821
-            $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
822
-            if (!is_string($pilot_id))
823
-            {
824
-                return array();
825
-            } else {
826
-                $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
827
-            }
828
-        }
819
+		if ($pilot_id != "")
820
+		{
821
+			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
822
+			if (!is_string($pilot_id))
823
+			{
824
+				return array();
825
+			} else {
826
+				$additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
827
+			}
828
+		}
829 829
 	
830
-        if ($departure_airport_route != "")
831
-        {
832
-            $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
833
-            if (!is_string($departure_airport_route))
834
-            {
835
-                return array();
836
-            } else {
837
-                $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
838
-            }
839
-        }
830
+		if ($departure_airport_route != "")
831
+		{
832
+			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
833
+			if (!is_string($departure_airport_route))
834
+			{
835
+				return array();
836
+			} else {
837
+				$additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
838
+			}
839
+		}
840 840
 	
841
-        if ($arrival_airport_route != "")
842
-        {
843
-            $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
844
-            if (!is_string($arrival_airport_route))
845
-            {
846
-                return array();
847
-            } else {
848
-                $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
849
-            }
850
-        }
841
+		if ($arrival_airport_route != "")
842
+		{
843
+			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
844
+			if (!is_string($arrival_airport_route))
845
+			{
846
+				return array();
847
+			} else {
848
+				$additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
849
+			}
850
+		}
851 851
 	
852
-        if ($altitude != "")
853
-        {
854
-            $altitude_array = explode(",", $altitude);
852
+		if ($altitude != "")
853
+		{
854
+			$altitude_array = explode(",", $altitude);
855 855
 	    
856
-            $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
857
-            $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
856
+			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
857
+			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
858 858
 	    
859 859
 
860
-            if ($altitude_array[1] != "")
861
-            {
862
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
863
-                $altitude_array[1] = substr($altitude_array[1], 0, -2);
864
-                $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
865
-            } else {
866
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
867
-                $additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
868
-            }
869
-        }
860
+			if ($altitude_array[1] != "")
861
+			{
862
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
863
+				$altitude_array[1] = substr($altitude_array[1], 0, -2);
864
+				$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
865
+			} else {
866
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
867
+				$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
868
+			}
869
+		}
870 870
 	
871
-        if ($date_posted != "")
872
-        {
873
-            $date_array = explode(",", $date_posted);
871
+		if ($date_posted != "")
872
+		{
873
+			$date_array = explode(",", $date_posted);
874 874
 	    
875
-            $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
876
-            $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
875
+			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
876
+			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
877 877
 	    
878
-            if ($globalTimezone != '') {
879
-                date_default_timezone_set($globalTimezone);
880
-                $datetime = new DateTime();
881
-                $offset = $datetime->format('P');
882
-            } else $offset = '+00:00';
883
-
884
-
885
-            if ($date_array[1] != "")
886
-            {
887
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
888
-                $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
889
-                if ($globalDBdriver == 'mysql') {
890
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
891
-                } else {
892
-                    $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
893
-                }
894
-            } else {
895
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
896
-                if ($globalDBdriver == 'mysql') {
897
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
898
-                } else {
899
-                    $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
900
-                }
901
-            }
902
-        }
878
+			if ($globalTimezone != '') {
879
+				date_default_timezone_set($globalTimezone);
880
+				$datetime = new DateTime();
881
+				$offset = $datetime->format('P');
882
+			} else $offset = '+00:00';
883
+
884
+
885
+			if ($date_array[1] != "")
886
+			{
887
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
888
+				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
889
+				if ($globalDBdriver == 'mysql') {
890
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
891
+				} else {
892
+					$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
893
+				}
894
+			} else {
895
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
896
+				if ($globalDBdriver == 'mysql') {
897
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
898
+				} else {
899
+					$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
900
+				}
901
+			}
902
+		}
903 903
 	
904
-        if ($limit != "")
905
-        {
906
-            $limit_array = explode(",", $limit);
904
+		if ($limit != "")
905
+		{
906
+			$limit_array = explode(",", $limit);
907 907
 	    
908
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
909
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
908
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
909
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
910 910
 	    
911
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
912
-            {
913
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
914
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
915
-            }
916
-        }
911
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
912
+			{
913
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
914
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
915
+			}
916
+		}
917 917
 	
918 918
 
919
-        if ($origLat != "" && $origLon != "" && $dist != "") {
920
-            $dist = number_format($dist*0.621371,2,'.','');
921
-            $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
919
+		if ($origLat != "" && $origLon != "" && $dist != "") {
920
+			$dist = number_format($dist*0.621371,2,'.','');
921
+			$query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
922 922
                           FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
923 923
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
924
-        } else {
925
-            if ($sort != "")
926
-            {
927
-                $search_orderby_array = $Marine->getOrderBy();
928
-                $orderby_query = $search_orderby_array[$sort]['sql'];
929
-            } else {
930
-                $orderby_query = " ORDER BY marine_archive_output.date DESC";
931
-            }
924
+		} else {
925
+			if ($sort != "")
926
+			{
927
+				$search_orderby_array = $Marine->getOrderBy();
928
+				$orderby_query = $search_orderby_array[$sort]['sql'];
929
+			} else {
930
+				$orderby_query = " ORDER BY marine_archive_output.date DESC";
931
+			}
932 932
 	
933
-            if ($includegeodata == "true")
934
-            {
935
-                $additional_query .= " AND (marine_archive_output.waypoints <> '')";
936
-            }
933
+			if ($includegeodata == "true")
934
+			{
935
+				$additional_query .= " AND (marine_archive_output.waypoints <> '')";
936
+			}
937 937
 
938
-            $query  = "SELECT marine_archive_output.* FROM marine_archive_output 
938
+			$query  = "SELECT marine_archive_output.* FROM marine_archive_output 
939 939
 		    WHERE marine_archive_output.ident <> '' 
940 940
 		    ".$additional_query."
941 941
 		    ".$filter_query.$orderby_query;
942
-        }
943
-        $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
944
-
945
-        return $spotter_array;
946
-    }
947
-
948
-    public function deleteMarineArchiveData()
949
-    {
950
-        global $globalArchiveKeepMonths, $globalDBdriver;
951
-        date_default_timezone_set('UTC');
952
-        if ($globalDBdriver == 'mysql') {
953
-            $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
954
-        } else {
955
-            $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
956
-        }
957
-        try {
958
-            $sth = $this->db->prepare($query);
959
-            $sth->execute();
960
-        } catch(PDOException $e) {
961
-            return "error";
962
-        }
963
-    }
964
-
965
-    /**
966
-     * Gets all the spotter information based on the callsign
967
-     *
968
-     * @param string $ident
969
-     * @param string $limit
970
-     * @param string $sort
971
-     * @return array the spotter information
972
-     */
973
-    public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
974
-    {
942
+		}
943
+		$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
944
+
945
+		return $spotter_array;
946
+	}
947
+
948
+	public function deleteMarineArchiveData()
949
+	{
950
+		global $globalArchiveKeepMonths, $globalDBdriver;
951
+		date_default_timezone_set('UTC');
952
+		if ($globalDBdriver == 'mysql') {
953
+			$query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
954
+		} else {
955
+			$query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
956
+		}
957
+		try {
958
+			$sth = $this->db->prepare($query);
959
+			$sth->execute();
960
+		} catch(PDOException $e) {
961
+			return "error";
962
+		}
963
+	}
964
+
965
+	/**
966
+	 * Gets all the spotter information based on the callsign
967
+	 *
968
+	 * @param string $ident
969
+	 * @param string $limit
970
+	 * @param string $sort
971
+	 * @return array the spotter information
972
+	 */
973
+	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
974
+	{
975 975
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
976 976
 	
977 977
 	date_default_timezone_set('UTC');
@@ -983,35 +983,35 @@  discard block
 block discarded – undo
983 983
 	
984 984
 	if ($ident != "")
985 985
 	{
986
-	    if (!is_string($ident))
987
-	    {
986
+		if (!is_string($ident))
987
+		{
988 988
 		return false;
989
-	    } else {
989
+		} else {
990 990
 		$additional_query = " AND (marine_archive_output.ident = :ident)";
991 991
 		$query_values = array(':ident' => $ident);
992
-	    }
992
+		}
993 993
 	}
994 994
 	
995 995
 	if ($limit != "")
996 996
 	{
997
-	    $limit_array = explode(",", $limit);
997
+		$limit_array = explode(",", $limit);
998 998
 	    
999
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1000
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
999
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1000
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1001 1001
 	    
1002
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1003
-	    {
1002
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1003
+		{
1004 1004
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1005 1005
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1006
-	    }
1006
+		}
1007 1007
 	}
1008 1008
 
1009 1009
 	if ($sort != "")
1010 1010
 	{
1011
-	    $search_orderby_array = $Marine->getOrderBy();
1012
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1011
+		$search_orderby_array = $Marine->getOrderBy();
1012
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1013 1013
 	} else {
1014
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1014
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1015 1015
 	}
1016 1016
 
1017 1017
 	$query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -1019,20 +1019,20 @@  discard block
 block discarded – undo
1019 1019
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1020 1020
 
1021 1021
 	return $spotter_array;
1022
-    }
1023
-
1024
-
1025
-    /**
1026
-     * Gets all the spotter information based on the owner
1027
-     *
1028
-     * @param string $owner
1029
-     * @param string $limit
1030
-     * @param string $sort
1031
-     * @param array $filter
1032
-     * @return array the spotter information
1033
-     */
1034
-    public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1035
-    {
1022
+	}
1023
+
1024
+
1025
+	/**
1026
+	 * Gets all the spotter information based on the owner
1027
+	 *
1028
+	 * @param string $owner
1029
+	 * @param string $limit
1030
+	 * @param string $sort
1031
+	 * @param array $filter
1032
+	 * @return array the spotter information
1033
+	 */
1034
+	public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1035
+	{
1036 1036
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1037 1037
 	
1038 1038
 	date_default_timezone_set('UTC');
@@ -1045,35 +1045,35 @@  discard block
 block discarded – undo
1045 1045
 	
1046 1046
 	if ($owner != "")
1047 1047
 	{
1048
-	    if (!is_string($owner))
1049
-	    {
1048
+		if (!is_string($owner))
1049
+		{
1050 1050
 		return array();
1051
-	    } else {
1051
+		} else {
1052 1052
 		$additional_query = " AND (marine_archive_output.owner_name = :owner)";
1053 1053
 		$query_values = array(':owner' => $owner);
1054
-	    }
1054
+		}
1055 1055
 	}
1056 1056
 	
1057 1057
 	if ($limit != "")
1058 1058
 	{
1059
-	    $limit_array = explode(",", $limit);
1059
+		$limit_array = explode(",", $limit);
1060 1060
 	    
1061
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1062
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1061
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1062
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1063 1063
 	    
1064
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1065
-	    {
1064
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1065
+		{
1066 1066
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1067 1067
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1068
-	    }
1068
+		}
1069 1069
 	}
1070 1070
 
1071 1071
 	if ($sort != "")
1072 1072
 	{
1073
-	    $search_orderby_array = $Marine->getOrderBy();
1074
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1073
+		$search_orderby_array = $Marine->getOrderBy();
1074
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1075 1075
 	} else {
1076
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1076
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1077 1077
 	}
1078 1078
 
1079 1079
 	$query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1081,19 +1081,19 @@  discard block
 block discarded – undo
1081 1081
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1082 1082
 
1083 1083
 	return $spotter_array;
1084
-    }
1085
-
1086
-    /**
1087
-     * Gets all the spotter information based on the pilot
1088
-     *
1089
-     * @param string $pilot
1090
-     * @param string $limit
1091
-     * @param string $sort
1092
-     * @param array $filter
1093
-     * @return array the spotter information
1094
-     */
1095
-    public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1096
-    {
1084
+	}
1085
+
1086
+	/**
1087
+	 * Gets all the spotter information based on the pilot
1088
+	 *
1089
+	 * @param string $pilot
1090
+	 * @param string $limit
1091
+	 * @param string $sort
1092
+	 * @param array $filter
1093
+	 * @return array the spotter information
1094
+	 */
1095
+	public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1096
+	{
1097 1097
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1098 1098
 	
1099 1099
 	date_default_timezone_set('UTC');
@@ -1112,24 +1112,24 @@  discard block
 block discarded – undo
1112 1112
 	
1113 1113
 	if ($limit != "")
1114 1114
 	{
1115
-	    $limit_array = explode(",", $limit);
1115
+		$limit_array = explode(",", $limit);
1116 1116
 	    
1117
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1118
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1117
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1118
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1119 1119
 	    
1120
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1121
-	    {
1120
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1121
+		{
1122 1122
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1123 1123
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1124
-	    }
1124
+		}
1125 1125
 	}
1126 1126
 
1127 1127
 	if ($sort != "")
1128 1128
 	{
1129
-	    $search_orderby_array = $Marine->getOrderBy();
1130
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1129
+		$search_orderby_array = $Marine->getOrderBy();
1130
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1131 1131
 	} else {
1132
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1132
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1133 1133
 	}
1134 1134
 
1135 1135
 	$query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1137,18 +1137,18 @@  discard block
 block discarded – undo
1137 1137
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1138 1138
 
1139 1139
 	return $spotter_array;
1140
-    }
1141
-
1142
-    /**
1143
-     * Gets all number of flight over countries
1144
-     *
1145
-     * @param bool $limit
1146
-     * @param int $olderthanmonths
1147
-     * @param string $sincedate
1148
-     * @return array the airline country list
1149
-     */
1150
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1151
-    {
1140
+	}
1141
+
1142
+	/**
1143
+	 * Gets all number of flight over countries
1144
+	 *
1145
+	 * @param bool $limit
1146
+	 * @param int $olderthanmonths
1147
+	 * @param string $sincedate
1148
+	 * @return array the airline country list
1149
+	 */
1150
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1151
+	{
1152 1152
 	global $globalDBdriver;
1153 1153
 	/*
1154 1154
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1158,14 +1158,14 @@  discard block
 block discarded – undo
1158 1158
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1159 1159
 		    FROM countries c, marine_archive s
1160 1160
 		    WHERE c.iso2 = s.over_country ";
1161
-                if ($olderthanmonths > 0) {
1162
-            		if ($globalDBdriver == 'mysql') {
1161
+				if ($olderthanmonths > 0) {
1162
+					if ($globalDBdriver == 'mysql') {
1163 1163
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1164 1164
 			} else {
1165 1165
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1166 1166
 			}
1167 1167
 		}
1168
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1168
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1169 1169
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1170 1170
 	if ($limit) $query .= " LIMIT 0,10";
1171 1171
       
@@ -1178,25 +1178,25 @@  discard block
 block discarded – undo
1178 1178
         
1179 1179
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1180 1180
 	{
1181
-	    $temp_array['flight_count'] = $row['nb'];
1182
-	    $temp_array['flight_country'] = $row['name'];
1183
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1184
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1185
-	    $flight_array[] = $temp_array;
1181
+		$temp_array['flight_count'] = $row['nb'];
1182
+		$temp_array['flight_country'] = $row['name'];
1183
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1184
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1185
+		$flight_array[] = $temp_array;
1186 1186
 	}
1187 1187
 	return $flight_array;
1188
-    }
1189
-
1190
-    /**
1191
-     * Gets all number of flight over countries
1192
-     *
1193
-     * @param bool $limit
1194
-     * @param int $olderthanmonths
1195
-     * @param string $sincedate
1196
-     * @return array the airline country list
1197
-     */
1198
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1199
-    {
1188
+	}
1189
+
1190
+	/**
1191
+	 * Gets all number of flight over countries
1192
+	 *
1193
+	 * @param bool $limit
1194
+	 * @param int $olderthanmonths
1195
+	 * @param string $sincedate
1196
+	 * @return array the airline country list
1197
+	 */
1198
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1199
+	{
1200 1200
 	global $globalDBdriver;
1201 1201
 	/*
1202 1202
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1206,14 +1206,14 @@  discard block
 block discarded – undo
1206 1206
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1207 1207
 		    FROM countries c, marine_archive s, spotter_output o
1208 1208
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";
1209
-                if ($olderthanmonths > 0) {
1210
-            		if ($globalDBdriver == 'mysql') {
1209
+				if ($olderthanmonths > 0) {
1210
+					if ($globalDBdriver == 'mysql') {
1211 1211
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1212 1212
 			} else {
1213 1213
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1214 1214
 			}
1215 1215
 		}
1216
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1216
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1217 1217
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1218 1218
 	if ($limit) $query .= " LIMIT 0,10";
1219 1219
       
@@ -1226,25 +1226,25 @@  discard block
 block discarded – undo
1226 1226
         
1227 1227
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1228 1228
 	{
1229
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1230
-	    $temp_array['flight_count'] = $row['nb'];
1231
-	    $temp_array['flight_country'] = $row['name'];
1232
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1233
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1234
-	    $flight_array[] = $temp_array;
1229
+		$temp_array['airline_icao'] = $row['airline_icao'];
1230
+		$temp_array['flight_count'] = $row['nb'];
1231
+		$temp_array['flight_country'] = $row['name'];
1232
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1233
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1234
+		$flight_array[] = $temp_array;
1235 1235
 	}
1236 1236
 	return $flight_array;
1237
-    }
1238
-
1239
-    /**
1240
-     * Gets last spotter information based on a particular callsign
1241
-     *
1242
-     * @param $id
1243
-     * @param $date
1244
-     * @return array the spotter information
1245
-     */
1246
-    public function getDateArchiveMarineDataById($id,$date)
1247
-    {
1237
+	}
1238
+
1239
+	/**
1240
+	 * Gets last spotter information based on a particular callsign
1241
+	 *
1242
+	 * @param $id
1243
+	 * @param $date
1244
+	 * @return array the spotter information
1245
+	 */
1246
+	public function getDateArchiveMarineDataById($id,$date)
1247
+	{
1248 1248
 	$Marine = new Marine($this->db);
1249 1249
 	date_default_timezone_set('UTC');
1250 1250
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1252,17 +1252,17 @@  discard block
 block discarded – undo
1252 1252
 	$date = date('c',$date);
1253 1253
 	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1254 1254
 	return $spotter_array;
1255
-    }
1256
-
1257
-    /**
1258
-     * Gets all the spotter information based on a particular callsign
1259
-     *
1260
-     * @param $ident
1261
-     * @param $date
1262
-     * @return array the spotter information
1263
-     */
1264
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1265
-    {
1255
+	}
1256
+
1257
+	/**
1258
+	 * Gets all the spotter information based on a particular callsign
1259
+	 *
1260
+	 * @param $ident
1261
+	 * @param $date
1262
+	 * @return array the spotter information
1263
+	 */
1264
+	public function getDateArchiveMarineDataByIdent($ident,$date)
1265
+	{
1266 1266
 	$Marine = new Marine($this->db);
1267 1267
 	date_default_timezone_set('UTC');
1268 1268
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1270,65 +1270,65 @@  discard block
 block discarded – undo
1270 1270
 	$date = date('c',$date);
1271 1271
 	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1272 1272
 	return $spotter_array;
1273
-    }
1274
-
1275
-    /**
1276
-     * Gets all the spotter information based on the airport
1277
-     *
1278
-     * @param string $airport
1279
-     * @param string $limit
1280
-     * @param string $sort
1281
-     * @param array $filters
1282
-     * @return array the spotter information
1283
-     */
1284
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1285
-    {
1286
-        global $global_query;
1287
-        $Marine = new Marine($this->db);
1288
-        date_default_timezone_set('UTC');
1289
-        $query_values = array();
1290
-        $limit_query = '';
1291
-        $additional_query = '';
1292
-        $filter_query = $this->getFilter($filters,true,true);
1273
+	}
1274
+
1275
+	/**
1276
+	 * Gets all the spotter information based on the airport
1277
+	 *
1278
+	 * @param string $airport
1279
+	 * @param string $limit
1280
+	 * @param string $sort
1281
+	 * @param array $filters
1282
+	 * @return array the spotter information
1283
+	 */
1284
+	public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1285
+	{
1286
+		global $global_query;
1287
+		$Marine = new Marine($this->db);
1288
+		date_default_timezone_set('UTC');
1289
+		$query_values = array();
1290
+		$limit_query = '';
1291
+		$additional_query = '';
1292
+		$filter_query = $this->getFilter($filters,true,true);
1293 1293
 	
1294
-        if ($airport != "")
1295
-        {
1296
-            if (!is_string($airport))
1297
-            {
1298
-                return array();
1299
-            } else {
1300
-                $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1301
-                $query_values = array(':airport' => $airport);
1302
-            }
1303
-        }
1294
+		if ($airport != "")
1295
+		{
1296
+			if (!is_string($airport))
1297
+			{
1298
+				return array();
1299
+			} else {
1300
+				$additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1301
+				$query_values = array(':airport' => $airport);
1302
+			}
1303
+		}
1304 1304
 	
1305
-        if ($limit != "")
1306
-        {
1307
-            $limit_array = explode(",", $limit);
1305
+		if ($limit != "")
1306
+		{
1307
+			$limit_array = explode(",", $limit);
1308 1308
 	    
1309
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1310
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1309
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1310
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1311 1311
 	    
1312
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1313
-            {
1314
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1315
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1316
-            }
1317
-        }
1312
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1313
+			{
1314
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1315
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1316
+			}
1317
+		}
1318 1318
 	
1319
-        if ($sort != "")
1320
-        {
1321
-            $search_orderby_array = $Marine->getOrderBy();
1322
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1323
-        } else {
1324
-            $orderby_query = " ORDER BY marine_archive_output.date DESC";
1325
-        }
1319
+		if ($sort != "")
1320
+		{
1321
+			$search_orderby_array = $Marine->getOrderBy();
1322
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1323
+		} else {
1324
+			$orderby_query = " ORDER BY marine_archive_output.date DESC";
1325
+		}
1326 1326
 
1327
-        $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
1327
+		$query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
1328 1328
 
1329
-        $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1329
+		$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1330 1330
 
1331
-        return $spotter_array;
1332
-    }
1331
+		return $spotter_array;
1332
+	}
1333 1333
 }
1334 1334
 ?>
1335 1335
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.Source.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@
 block discarded – undo
60 60
 		return $all;
61 61
 	}
62 62
 
63
-    /**
64
-     * @param $name
65
-     * @return array
66
-     */
67
-    public function getLocationInfobySourceName($name) {
63
+	/**
64
+	 * @param $name
65
+	 * @return array
66
+	 */
67
+	public function getLocationInfobySourceName($name) {
68 68
 		$query = "SELECT * FROM source_location WHERE source = :name";
69 69
 		$query_values = array(':name' => $name);
70 70
 		try {
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -16,20 +16,20 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/class.Source.php');
17 17
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
18 18
 if (isset($globalServerAPRS) && $globalServerAPRS) {
19
-    require_once(dirname(__FILE__).'/class.APRS.php');
19
+	require_once(dirname(__FILE__).'/class.APRS.php');
20 20
 }
21 21
 
22 22
 class SpotterImport {
23
-    private $all_flights = array();
24
-    private $last_delete_hourly = 0;
25
-    private $last_delete = 0;
26
-    private $stats = array();
27
-    private $tmd = 0;
28
-    private $source_location = array();
29
-    public $db = null;
30
-    public $nb = 0;
23
+	private $all_flights = array();
24
+	private $last_delete_hourly = 0;
25
+	private $last_delete = 0;
26
+	private $stats = array();
27
+	private $tmd = 0;
28
+	private $source_location = array();
29
+	public $db = null;
30
+	public $nb = 0;
31 31
 
32
-    public function __construct($dbc = null) {
32
+	public function __construct($dbc = null) {
33 33
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
34 34
 	if (!(isset($globalNoDB) && $globalNoDB)) {
35 35
 		$Connection = new Connection($dbc);
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 		$currentdate = date('Y-m-d');
42 42
 		$sourcestat = $Stats->getStatsSource($currentdate);
43 43
 		if (!empty($sourcestat)) {
44
-		    foreach($sourcestat as $srcst) {
45
-		    	$type = $srcst['stats_type'];
44
+			foreach($sourcestat as $srcst) {
45
+				$type = $srcst['stats_type'];
46 46
 			if ($type == 'polar' || $type == 'hist') {
47
-			    $source = $srcst['source_name'];
48
-			    $data = $srcst['source_data'];
49
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
50
-	    		}
51
-		    }
47
+				$source = $srcst['source_name'];
48
+				$data = $srcst['source_data'];
49
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
50
+				}
51
+			}
52 52
 		}
53 53
 	}
54 54
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 			$GeoidClass = FALSE;
64 64
 		}
65 65
 	}
66
-    }
66
+	}
67 67
 
68
-    public function get_Schedule($id,$ident) {
68
+	public function get_Schedule($id,$ident) {
69 69
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
70 70
 	// Get schedule here, so it's done only one time
71 71
 	
@@ -85,43 +85,43 @@  discard block
 block discarded – undo
85 85
 	$operator = $Spotter->getOperator($ident);
86 86
 	$scheduleexist = false;
87 87
 	if ($Schedule->checkSchedule($operator) == 0) {
88
-	    $operator = $Translation->checkTranslation($ident);
89
-	    if ($Schedule->checkSchedule($operator) == 0) {
88
+		$operator = $Translation->checkTranslation($ident);
89
+		if ($Schedule->checkSchedule($operator) == 0) {
90 90
 		$schedule = $Schedule->fetchSchedule($operator);
91 91
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
92
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
93
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
94
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
95
-		    // Should also check if route schedule = route from DB
96
-		    if ($schedule['DepartureAirportIATA'] != '') {
92
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
93
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
94
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
95
+			// Should also check if route schedule = route from DB
96
+			if ($schedule['DepartureAirportIATA'] != '') {
97 97
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
98
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
99
-			    if (trim($airport_icao) != '') {
98
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
99
+				if (trim($airport_icao) != '') {
100 100
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
101 101
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
-			    }
102
+				}
103
+			}
103 104
 			}
104
-		    }
105
-		    if ($schedule['ArrivalAirportIATA'] != '') {
105
+			if ($schedule['ArrivalAirportIATA'] != '') {
106 106
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
107
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
108
-			    if (trim($airport_icao) != '') {
107
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
108
+				if (trim($airport_icao) != '') {
109 109
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
110 110
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
-			    }
111
+				}
112 112
 			}
113
-		    }
114
-		    $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']);
113
+			}
114
+			$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']);
115 115
 		}
116
-	    } else $scheduleexist = true;
116
+		} else $scheduleexist = true;
117 117
 	} else $scheduleexist = true;
118 118
 	// close connection, at least one way will work ?
119
-       if ($scheduleexist) {
119
+	   if ($scheduleexist) {
120 120
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
121
-    		$sch = $Schedule->getSchedule($operator);
121
+			$sch = $Schedule->getSchedule($operator);
122 122
 		$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']));
123 123
 		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']);
124
-       }
124
+	   }
125 125
 	$Spotter->db = null;
126 126
 	$Schedule->db = null;
127 127
 	$Translation->db = null;
@@ -136,65 +136,65 @@  discard block
 block discarded – undo
136 136
 	}
137 137
 	  */
138 138
 	}
139
-    }
139
+	}
140 140
 
141
-    public function checkAll() {
141
+	public function checkAll() {
142 142
 	global $globalDebug, $globalNoImport;
143 143
 	if ($globalDebug) echo "Update last seen flights data...\n";
144 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
145
-	    foreach ($this->all_flights as $key => $flight) {
145
+		foreach ($this->all_flights as $key => $flight) {
146 146
 		if (isset($this->all_flights[$key]['id'])) {
147
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
148
-    		    $Spotter = new Spotter($this->db);
149
-        	    $real_arrival = $this->arrival($key);
150
-        	    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']);
151
-        	}
152
-	    }
147
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
148
+				$Spotter = new Spotter($this->db);
149
+				$real_arrival = $this->arrival($key);
150
+				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']);
151
+			}
152
+		}
153
+	}
153 154
 	}
154
-    }
155 155
 
156
-    public function arrival($key) {
156
+	public function arrival($key) {
157 157
 	global $globalClosestMinDist, $globalDebug;
158 158
 	if ($globalDebug) echo 'Update arrival...'."\n";
159 159
 	$Spotter = new Spotter($this->db);
160
-        $airport_icao = '';
161
-        $airport_time = '';
162
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
160
+		$airport_icao = '';
161
+		$airport_time = '';
162
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
163 163
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
164
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
165
-    	    if (isset($closestAirports[0])) {
166
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
167
-        	    $airport_icao = $closestAirports[0]['icao'];
168
-        	    $airport_time = $this->all_flights[$key]['datetime'];
169
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
170
-        	} elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
171
-        	    foreach ($closestAirports as $airport) {
172
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
173
-        		    $airport_icao = $airport['icao'];
174
-        		    $airport_time = $this->all_flights[$key]['datetime'];
175
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
176
-        		    break;
177
-        		}
178
-        	    }
179
-        	} 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))) {
180
-        		$airport_icao = $closestAirports[0]['icao'];
181
-        		$airport_time = $this->all_flights[$key]['datetime'];
182
-        	} else {
183
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
184
-        	}
185
-    	    } else {
186
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
187
-    	    }
164
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
165
+			if (isset($closestAirports[0])) {
166
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
167
+				$airport_icao = $closestAirports[0]['icao'];
168
+				$airport_time = $this->all_flights[$key]['datetime'];
169
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
170
+			} elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
171
+				foreach ($closestAirports as $airport) {
172
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
173
+					$airport_icao = $airport['icao'];
174
+					$airport_time = $this->all_flights[$key]['datetime'];
175
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
176
+					break;
177
+				}
178
+				}
179
+			} 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))) {
180
+				$airport_icao = $closestAirports[0]['icao'];
181
+				$airport_time = $this->all_flights[$key]['datetime'];
182
+			} else {
183
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
184
+			}
185
+			} else {
186
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
187
+			}
188 188
 
189
-        } else {
190
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
191
-        }
192
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
193
-    }
189
+		} else {
190
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
191
+		}
192
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
193
+	}
194 194
 
195 195
 
196 196
 
197
-    public function del() {
197
+	public function del() {
198 198
 	global $globalDebug, $globalNoImport, $globalNoDB;
199 199
 	// Delete old infos
200 200
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 			}
207 207
 		}
208 208
 	}
209
-    }
209
+	}
210 210
 
211
-    public function delKey($key) {
211
+	public function delKey($key) {
212 212
 	global $globalDebug, $globalNoImport, $globalNoDB;
213 213
 	// Delete old infos
214 214
 	if (isset($this->all_flights[$key]['id'])) {
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 		if ($globalDebug) echo "\n";
231 231
 	}
232 232
 	unset($this->all_flights[$key]);
233
-    }
233
+	}
234 234
 
235
-    public function add($line) {
235
+	public function add($line) {
236 236
 	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;
237 237
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
238 238
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
@@ -258,20 +258,20 @@  discard block
 block discarded – undo
258 258
 	
259 259
 	// SBS format is CSV format
260 260
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
261
-	    //print_r($line);
262
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
263
-  	    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)) {
261
+		//print_r($line);
262
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
263
+  		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)) {
264 264
 
265 265
 		// Increment message number
266 266
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
267
-		    $current_date = date('Y-m-d');
268
-		    if (isset($line['source_name'])) $source = $line['source_name'];
269
-		    else $source = '';
270
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
271
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
272
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
273
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
274
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
267
+			$current_date = date('Y-m-d');
268
+			if (isset($line['source_name'])) $source = $line['source_name'];
269
+			else $source = '';
270
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
271
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
272
+				$this->stats[$current_date][$source]['msg']['date'] = time();
273
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
274
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
275 275
 		}
276 276
 		
277 277
 		/*
@@ -287,54 +287,54 @@  discard block
 block discarded – undo
287 287
 		//$this->db = $dbc;
288 288
 
289 289
 		//$hex = trim($line['hex']);
290
-	        if (!isset($line['id'])) $id = trim($line['hex']);
291
-	        else $id = trim($line['id']);
290
+			if (!isset($line['id'])) $id = trim($line['hex']);
291
+			else $id = trim($line['id']);
292 292
 		
293 293
 		if (!isset($this->all_flights[$id])) {
294
-		    if ($globalDebug) echo 'New flight...'."\n";
295
-		    $this->all_flights[$id] = array();
296
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
297
-		    $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' => '','coordinates' => 0));
298
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
299
-		    if (!isset($line['id'])) {
294
+			if ($globalDebug) echo 'New flight...'."\n";
295
+			$this->all_flights[$id] = array();
296
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
297
+			$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' => '','coordinates' => 0));
298
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
299
+			if (!isset($line['id'])) {
300 300
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
301 301
 //			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')));
302 302
 //			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')));
303 303
 			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')));
304
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
305
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
306
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
304
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
305
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
306
+			if ($globalAllFlights !== FALSE) $dataFound = true;
307 307
 		}
308 308
 		if (isset($line['source_type']) && $line['source_type'] != '') {
309
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
309
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
310 310
 		}
311 311
 		
312 312
 		//print_r($this->all_flights);
313 313
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
314
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
315
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
314
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
315
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
316 316
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
317
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
318
-		    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') {
317
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
318
+			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') {
319 319
 			$timeelapsed = microtime(true);
320 320
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
321
-			    $Spotter = new Spotter($this->db);
322
-			    if (isset($this->all_flights[$id]['source_type'])) {
321
+				$Spotter = new Spotter($this->db);
322
+				if (isset($this->all_flights[$id]['source_type'])) {
323 323
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
324
-			    } else {
324
+				} else {
325 325
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
326
-			    }
327
-			    $Spotter->db = null;
328
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
329
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
326
+				}
327
+				$Spotter->db = null;
328
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
329
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
330 330
 			}
331
-		    }
332
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
333
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
331
+			}
332
+			if ($globalAllFlights !== FALSE) $dataFound = true;
333
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
334 334
 		}
335
-	        if (isset($line['id']) && !isset($line['hex'])) {
336
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
337
-	        }
335
+			if (isset($line['id']) && !isset($line['hex'])) {
336
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
337
+			}
338 338
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
339 339
 			$icao = $line['aircraft_icao'];
340 340
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 		}
365 365
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
366 366
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
367
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
367
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
368 368
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
369
-		    } else {
369
+			} else {
370 370
 				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";
371 371
 				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";
372 372
 				/*
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 				print_r($line);
376 376
 				*/
377 377
 				return '';
378
-		    }
378
+			}
379 379
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
380 380
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
381 381
 			return '';
@@ -391,21 +391,21 @@  discard block
 block discarded – undo
391 391
 		}
392 392
 
393 393
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
394
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
394
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
395 395
 		}
396 396
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
397
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
397
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
398 398
 		}
399 399
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
400
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
400
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
401 401
 		}
402 402
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
403
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
403
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
404 404
 		}
405 405
  
406 406
 		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'])) {
407 407
 
408
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
408
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
409 409
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
410 410
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
411 411
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -414,23 +414,23 @@  discard block
 block discarded – undo
414 414
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
415 415
 				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']));
416 416
 			} else {
417
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
417
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
419 419
 				$timeelapsed = microtime(true);
420
-            			$Spotter = new Spotter($this->db);
421
-            			$fromsource = NULL;
422
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
423
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
420
+						$Spotter = new Spotter($this->db);
421
+						$fromsource = NULL;
422
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
423
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
424 424
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
425 425
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
426 426
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
427
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
427
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
428 428
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
429 429
 				$Spotter->db = null;
430 430
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
431
-			    }
431
+				}
432 432
 			}
433
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
433
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
434 434
 		    
435 435
 /*
436 436
 		    if (!isset($line['id'])) {
@@ -440,63 +440,63 @@  discard block
 block discarded – undo
440 440
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
441 441
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
442 442
   */
443
-		    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']));
443
+			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']));
444 444
 
445
-		    //$putinarchive = true;
446
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
445
+			//$putinarchive = true;
446
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
447 447
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
448
-		    }
449
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
448
+			}
449
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
450 450
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
451
-		    }
452
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
453
-		    		$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' => ''));
454
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
451
+			}
452
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
453
+					$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' => ''));
454
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
455 455
 			$timeelapsed = microtime(true);
456 456
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
457 457
 				$Spotter = new Spotter($this->db);
458 458
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
459 459
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
460
-		    		$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' => ''));
460
+					$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' => ''));
461 461
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
462
-                        }
463
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
462
+						}
463
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
464 464
 			$timeelapsed = microtime(true);
465 465
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
466
-			    $Spotter = new Spotter($this->db);
467
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
468
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
466
+				$Spotter = new Spotter($this->db);
467
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
468
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
469 469
 				$Translation = new Translation($this->db);
470 470
 				$ident = $Translation->checkTranslation(trim($line['ident']));
471 471
 				$route = $Spotter->getRouteInfo($ident);
472 472
 				$Translation->db = null;
473
-			    }
474
-			    $Spotter->db = null;
475
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
476
-                    	}
473
+				}
474
+				$Spotter->db = null;
475
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
476
+						}
477 477
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
478
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
479
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
478
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
479
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
480 480
 				//    $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']));
481
-		    		$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']));
482
-		    	    }
481
+					$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']));
482
+					}
483 483
 			}
484 484
 			if (!isset($globalFork)) $globalFork = TRUE;
485 485
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
486 486
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
487 487
 			}
488
-		    }
488
+			}
489 489
 		}
490 490
 
491 491
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
492 492
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
493
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
494
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
495
-		    //$dataFound = true;
493
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
494
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
495
+			//$dataFound = true;
496 496
 		} 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'])) {
497
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
498
-		    if ($distance > 1000 && $distance < 10000) {
499
-		    // use datetime
497
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
498
+			if ($distance > 1000 && $distance < 10000) {
499
+			// use datetime
500 500
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
501 501
 			$speed = $speed*3.6;
502 502
 			if ($speed < 1000) {
@@ -505,49 +505,49 @@  discard block
 block discarded – undo
505 505
 	  		} else {
506 506
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
507 507
 	  		}
508
-		    }
508
+			}
509 509
 		}
510 510
 
511 511
 
512 512
 
513
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
514
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
515
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
516
-	    	    	return false;
517
-	    	    }
518
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
519
-	    	    else unset($timediff);
520
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
521
-	    	    else unset($timediff_archive);
522
-	    	    if ($this->tmd > 5
523
-	    	        || (isset($line['format_source']) 
524
-	    	    	    && $line['format_source'] == 'airwhere' 
525
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
526
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
527
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
528
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
529
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
530
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
531
-	    	    		)
532
-	    	    	    )
533
-	    	    	)
534
-	    		|| (isset($globalVA) && $globalVA) 
535
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
536
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
537
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
538
-	    	    	|| (isset($globalVAM) && $globalVAM)
539
-	    	    	|| !isset($timediff)
540
-	    	    	|| (isset($timediff) && $timediff > $globalLiveInterval)
541
-	    	    	|| $globalArchive
542
-	    	    	|| (isset($timediff) && $timediff > 30
543
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
544
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
545
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
546
-	    	    	    )
547
-	    	    	) {
513
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
514
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
515
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
516
+					return false;
517
+				}
518
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
519
+				else unset($timediff);
520
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
521
+				else unset($timediff_archive);
522
+				if ($this->tmd > 5
523
+					|| (isset($line['format_source']) 
524
+						&& $line['format_source'] == 'airwhere' 
525
+						&& ((!isset($this->all_flights[$id]['latitude']) 
526
+						|| !isset($this->all_flights[$id]['longitude'])) 
527
+						|| (isset($this->all_flights[$id]['latitude']) 
528
+							&& isset($this->all_flights[$id]['longitude']) 
529
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
530
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
531
+						)
532
+						)
533
+					)
534
+				|| (isset($globalVA) && $globalVA) 
535
+					|| (isset($globalIVAO) && $globalIVAO)
536
+					|| (isset($globalVATSIM) && $globalVATSIM)
537
+					|| (isset($globalphpVMS) && $globalphpVMS)
538
+					|| (isset($globalVAM) && $globalVAM)
539
+					|| !isset($timediff)
540
+					|| (isset($timediff) && $timediff > $globalLiveInterval)
541
+					|| $globalArchive
542
+					|| (isset($timediff) && $timediff > 30
543
+						&& isset($this->all_flights[$id]['latitude']) 
544
+						&& isset($this->all_flights[$id]['longitude']) 
545
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
546
+						)
547
+					) {
548 548
 
549 549
 			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']))) {
550
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
550
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
551 551
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
552 552
 				|| !$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'])) {
553 553
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 				}
560 560
 				$this->tmd = 0;
561 561
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
562
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
563
-				    $timeelapsed = microtime(true);
564
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
562
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
563
+					$timeelapsed = microtime(true);
564
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
565 565
 					$Spotter = new Spotter($this->db);
566 566
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
567 567
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -569,11 +569,11 @@  discard block
 block discarded – undo
569 569
 					$Spotter->db = null;
570 570
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
571 571
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
572
-				    }
572
+					}
573 573
 				}
574 574
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
575
-			    } 
576
-			    /*
575
+				} 
576
+				/*
577 577
 			    else {
578 578
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
579 579
 				else {
@@ -587,16 +587,16 @@  discard block
 block discarded – undo
587 587
 			}
588 588
 
589 589
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
590
-			    //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) {
590
+				//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) {
591 591
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
592 592
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
593 593
 					$this->all_flights[$id]['time_last_coord'] = time();
594 594
 				}
595 595
 				//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)) {
596 596
 				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)) {
597
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
598
-				    $dataFound = true;
599
-				    $this->all_flights[$id]['time_last_coord'] = time();
597
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
598
+					$dataFound = true;
599
+					$this->all_flights[$id]['time_last_coord'] = time();
600 600
 				}
601 601
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
602 602
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -607,25 +607,25 @@  discard block
 block discarded – undo
607 607
 				    //$putinarchive = true;
608 608
 				}
609 609
 				*/
610
-			    /*
610
+				/*
611 611
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
612 612
 				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";
613 613
 			    }
614 614
 			    */
615 615
 			}
616 616
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
617
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
618
-			    //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) {
617
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
618
+				//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) {
619 619
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
620 620
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
621 621
 					$this->all_flights[$id]['time_last_coord'] = time();
622 622
 				}
623 623
 				//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)) {
624 624
 				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)) {
625
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
626
-				    $dataFound = true;
627
-				    $this->all_flights[$id]['coordinates'] += 1;
628
-				    $this->all_flights[$id]['time_last_coord'] = time();
625
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
626
+					$dataFound = true;
627
+					$this->all_flights[$id]['coordinates'] += 1;
628
+					$this->all_flights[$id]['time_last_coord'] = time();
629 629
 				}
630 630
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
631 631
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -643,76 +643,76 @@  discard block
 block discarded – undo
643 643
 			    */
644 644
 			}
645 645
 			if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) {
646
-			    if ($globalDebug) echo "\n".'>>> Update initial data !'."\n";
647
-			    unset($updateinitial);
648
-			    $SpotterArchive = new SpotterArchive();
649
-			    $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']);
650
-			    $SpotterArchive->db = null;
651
-			    $Spotter = new Spotter();
652
-			    $Spotter->updateInitialSpotterData($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']);
653
-			    $Spotter->db = null;
646
+				if ($globalDebug) echo "\n".'>>> Update initial data !'."\n";
647
+				unset($updateinitial);
648
+				$SpotterArchive = new SpotterArchive();
649
+				$SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']);
650
+				$SpotterArchive->db = null;
651
+				$Spotter = new Spotter();
652
+				$Spotter->updateInitialSpotterData($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']);
653
+				$Spotter->db = null;
654 654
 			}
655
-		    } else if ($globalDebug && $timediff > 30) {
655
+			} else if ($globalDebug && $timediff > 30) {
656 656
 			$this->tmd = $this->tmd + 1;
657 657
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
658 658
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
659 659
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
660 660
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
661
-		    }
661
+			}
662 662
 		}
663 663
 		if (isset($line['last_update']) && $line['last_update'] != '') {
664
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
665
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
664
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
665
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
666 666
 		}
667 667
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
668
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
669
-		    //$dataFound = true;
668
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
669
+			//$dataFound = true;
670 670
 		}
671 671
 		if (isset($line['format_source']) && $line['format_source'] != '') {
672
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
672
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
673 673
 		}
674 674
 		if (isset($line['source_name']) && $line['source_name'] != '') {
675
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
675
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
676 676
 		}
677 677
 		if (isset($line['emergency']) && $line['emergency'] != '') {
678
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
679
-		    //$dataFound = true;
678
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
679
+			//$dataFound = true;
680 680
 		}
681 681
 		if (isset($line['ground']) && $line['ground'] != '') {
682
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
682
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
683 683
 			// Here we force archive of flight because after ground it's a new one (or should be)
684 684
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
685 685
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
686 686
 			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')));
687
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
687
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
688 688
 			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']));
689
-		    }
690
-		    if ($line['ground'] != 1) $line['ground'] = 0;
691
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
692
-		    //$dataFound = true;
689
+			}
690
+			if ($line['ground'] != 1) $line['ground'] = 0;
691
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
692
+			//$dataFound = true;
693 693
 		}
694 694
 		if (isset($line['squawk']) && $line['squawk'] != '') {
695
-		    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'])) {
696
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
697
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
698
-			    $highlight = '';
699
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
700
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
701
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
702
-			    if ($highlight != '') {
695
+			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'])) {
696
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
697
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
698
+				$highlight = '';
699
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
700
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
701
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
702
+				if ($highlight != '') {
703 703
 				$timeelapsed = microtime(true);
704 704
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
705
-				    $Spotter = new Spotter($this->db);
706
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
707
-				    $Spotter->db = null;
708
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
705
+					$Spotter = new Spotter($this->db);
706
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
707
+					$Spotter->db = null;
708
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
709 709
 				}
710 710
 				//$putinarchive = true;
711 711
 				//$highlight = '';
712
-			    }
712
+				}
713 713
 			    
714
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
715
-		    //$dataFound = true;
714
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
715
+			//$dataFound = true;
716 716
 		}
717 717
 
718 718
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
 					$line['altitude'] = $line['altitude'] - $geoid;
724 724
 				}
725 725
 			}
726
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
726
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
727 727
 			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;
728 728
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
729 729
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
730 730
 			//$dataFound = true;
731
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
732
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
731
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
732
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
733 733
 			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) {
734 734
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
735 735
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -738,27 +738,27 @@  discard block
 block discarded – undo
738 738
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
739 739
 				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']));
740 740
 			}
741
-		    }
742
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
741
+			}
742
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
743 743
 		}
744 744
 
745 745
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
746
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
746
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
747 747
 		}
748 748
 		
749 749
 		if (isset($line['heading']) && $line['heading'] != '') {
750
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
752
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
753
-		    //$dataFound = true;
750
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
752
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
753
+			//$dataFound = true;
754 754
   		} 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']) {
755
-  		    $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']);
756
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
757
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
758
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
755
+  			$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']);
756
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
757
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
758
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
759 759
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
760
-  		    // If not enough messages and ACARS set heading to 0
761
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
760
+  			// If not enough messages and ACARS set heading to 0
761
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
762 762
   		}
763 763
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
764 764
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -771,133 +771,133 @@  discard block
 block discarded – undo
771 771
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
772 772
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
773 773
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
774
-		    $this->all_flights[$id]['lastupdate'] = time();
775
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
776
-		        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'])) {
777
-			    //print_r($this->all_flights);
778
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
779
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
780
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
774
+			$this->all_flights[$id]['lastupdate'] = time();
775
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
776
+				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'])) {
777
+				//print_r($this->all_flights);
778
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
779
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
780
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
781 781
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
782
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
783
-				    $timeelapsed = microtime(true);
784
-				    $SpotterLive = new SpotterLive($this->db);
785
-				    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')) {
782
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
783
+					$timeelapsed = microtime(true);
784
+					$SpotterLive = new SpotterLive($this->db);
785
+					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')) {
786 786
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
787 787
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
788
-				    } elseif (isset($line['id'])) {
788
+					} elseif (isset($line['id'])) {
789 789
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
790 790
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
791
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
791
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
792 792
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
793 793
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
794
-				    } else $recent_ident = '';
795
-				    $SpotterLive->db=null;
796
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
797
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
794
+					} else $recent_ident = '';
795
+					$SpotterLive->db=null;
796
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
797
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
798 798
 				} else $recent_ident = '';
799
-			    } else {
799
+				} else {
800 800
 				$recent_ident = '';
801 801
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
802
-			    }
803
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
804
-			    if($recent_ident == "")
805
-			    {
802
+				}
803
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
804
+				if($recent_ident == "")
805
+				{
806 806
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
807 807
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808 808
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 809
 				//adds the spotter data for the archive
810 810
 				$ignoreImport = false;
811 811
 				foreach($globalAirportIgnore as $airportIgnore) {
812
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
813 813
 					$ignoreImport = true;
814
-				    }
814
+					}
815 815
 				}
816 816
 				if (count($globalAirportAccept) > 0) {
817
-				    $ignoreImport = true;
818
-				    foreach($globalAirportIgnore as $airportIgnore) {
817
+					$ignoreImport = true;
818
+					foreach($globalAirportIgnore as $airportIgnore) {
819 819
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
820
-					    $ignoreImport = false;
820
+						$ignoreImport = false;
821
+					}
821 822
 					}
822
-				    }
823 823
 				}
824 824
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
825
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
825
+					foreach($globalAirlineIgnore as $airlineIgnore) {
826 826
 					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)) {
827
-					    $ignoreImport = true;
827
+						$ignoreImport = true;
828
+					}
828 829
 					}
829
-				    }
830 830
 				}
831 831
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
832
-				    $ignoreImport = true;
833
-				    foreach($globalAirlineAccept as $airlineAccept) {
832
+					$ignoreImport = true;
833
+					foreach($globalAirlineAccept as $airlineAccept) {
834 834
 					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)) {
835
-					    $ignoreImport = false;
835
+						$ignoreImport = false;
836
+					}
836 837
 					}
837
-				    }
838 838
 				}
839 839
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
840
-				    $ignoreImport = true;
841
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
840
+					$ignoreImport = true;
841
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
842 842
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
843
-					    $ignoreImport = false;
843
+						$ignoreImport = false;
844
+					}
844 845
 					}
845
-				    }
846 846
 				}
847 847
 				
848 848
 				if (!$ignoreImport) {
849
-				    $highlight = '';
850
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
851
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
853
-				    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')));
854
-				    $timeelapsed = microtime(true);
855
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
849
+					$highlight = '';
850
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
851
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
853
+					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')));
854
+					$timeelapsed = microtime(true);
855
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 856
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
857
-					    $Spotter = new Spotter($this->db);
858
-					    $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']);
859
-					    $Spotter->db = null;
860
-					    if ($globalDebug) {
857
+						$Spotter = new Spotter($this->db);
858
+						$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']);
859
+						$Spotter->db = null;
860
+						if ($globalDebug) {
861 861
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
862 862
 						else echo 'Success';
863
-					    }
864
-					    if (count($result) > 1) {
865
-					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
863
+						}
864
+						if (count($result) > 1) {
865
+						// ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
866 866
 						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
867 867
 						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
868
-					    }
868
+						}
869 869
 					}
870
-				    }
871
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
872
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
870
+					}
871
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
872
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
873 873
 
874
-				    // Add source stat in DB
875
-				    $Stats = new Stats($this->db);
876
-				    if (!empty($this->stats)) {
874
+					// Add source stat in DB
875
+					$Stats = new Stats($this->db);
876
+					if (!empty($this->stats)) {
877 877
 					if ($globalDebug) echo 'Add source stats : ';
878
-				        foreach($this->stats as $date => $data) {
879
-					    foreach($data as $source => $sourced) {
880
-					        //print_r($sourced);
881
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
883
-				    		if (isset($sourced['msg'])) {
884
-				    		    if (time() - $sourced['msg']['date'] > 10) {
885
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
886
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
887
-			    			        unset($this->stats[$date][$source]['msg']);
888
-			    			    }
889
-			    			}
890
-			    		    }
891
-			    		    if ($date != date('Y-m-d')) {
892
-			    			unset($this->stats[$date]);
893
-			    		    }
894
-				    	}
895
-				    	if ($globalDebug) echo 'Done'."\n";
878
+						foreach($this->stats as $date => $data) {
879
+						foreach($data as $source => $sourced) {
880
+							//print_r($sourced);
881
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
883
+							if (isset($sourced['msg'])) {
884
+								if (time() - $sourced['msg']['date'] > 10) {
885
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
886
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
887
+									unset($this->stats[$date][$source]['msg']);
888
+								}
889
+							}
890
+							}
891
+							if ($date != date('Y-m-d')) {
892
+							unset($this->stats[$date]);
893
+							}
894
+						}
895
+						if ($globalDebug) echo 'Done'."\n";
896 896
 
897
-				    }
898
-				    $Stats->db = null;
899
-				    }
900
-				    $this->del();
897
+					}
898
+					$Stats->db = null;
899
+					}
900
+					$this->del();
901 901
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
902 902
 				//$ignoreImport = false;
903 903
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -915,41 +915,41 @@  discard block
 block discarded – undo
915 915
 			*/
916 916
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
917 917
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
918
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
919
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
920
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
918
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
919
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
920
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
921 921
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
922
-					    $SpotterLive = new SpotterLive($this->db);
923
-					    $SpotterLive->deleteLiveSpotterData();
924
-					    $SpotterLive->db=null;
922
+						$SpotterLive = new SpotterLive($this->db);
923
+						$SpotterLive->deleteLiveSpotterData();
924
+						$SpotterLive->db=null;
925 925
 					}
926
-				    }
927
-				    if ($globalDebug) echo " Done\n";
928
-				    $this->last_delete = time();
926
+					}
927
+					if ($globalDebug) echo " Done\n";
928
+					$this->last_delete = time();
929 929
 				}
930
-			    } else {
930
+				} else {
931 931
 				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')) {
932
-				    $this->all_flights[$id]['id'] = $recent_ident;
933
-				    $this->all_flights[$id]['addedSpotter'] = 1;
932
+					$this->all_flights[$id]['id'] = $recent_ident;
933
+					$this->all_flights[$id]['addedSpotter'] = 1;
934 934
 				}
935 935
 				if (isset($globalDaemon) && !$globalDaemon) {
936
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
936
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
937 937
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
938
-					    $Spotter = new Spotter($this->db);
939
-					    $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']);
940
-					    $Spotter->db = null;
938
+						$Spotter = new Spotter($this->db);
939
+						$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']);
940
+						$Spotter->db = null;
941
+					}
941 942
 					}
942
-				    }
943 943
 				}
944 944
 				
945
-			    }
945
+				}
946 946
 			}
947
-		    }
948
-		    //adds the spotter LIVE data
949
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
950
-		    //echo "\nAdd in Live !! \n";
951
-		    //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";
952
-		    if ($globalDebug) {
947
+			}
948
+			//adds the spotter LIVE data
949
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
950
+			//echo "\nAdd in Live !! \n";
951
+			//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";
952
+			if ($globalDebug) {
953 953
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
954 954
 				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";
955 955
 				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";
@@ -957,61 +957,61 @@  discard block
 block discarded – undo
957 957
 				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";
958 958
 				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";
959 959
 			}
960
-		    }
961
-		    $ignoreImport = false;
962
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
963
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
960
+			}
961
+			$ignoreImport = false;
962
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
963
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
964 964
 
965
-		    foreach($globalAirportIgnore as $airportIgnore) {
966
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
967
-			    $ignoreImport = true;
965
+			foreach($globalAirportIgnore as $airportIgnore) {
966
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
967
+				$ignoreImport = true;
968
+			}
968 969
 			}
969
-		    }
970
-		    if (count($globalAirportAccept) > 0) {
971
-		        $ignoreImport = true;
972
-		        foreach($globalAirportIgnore as $airportIgnore) {
973
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
970
+			if (count($globalAirportAccept) > 0) {
971
+				$ignoreImport = true;
972
+				foreach($globalAirportIgnore as $airportIgnore) {
973
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
974 974
 				$ignoreImport = false;
975
-			    }
975
+				}
976 976
 			}
977
-		    }
978
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
977
+			}
978
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
979 979
 			foreach($globalAirlineIgnore as $airlineIgnore) {
980
-			    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)) {
980
+				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)) {
981 981
 				$ignoreImport = true;
982
-			    }
982
+				}
983 983
 			}
984
-		    }
985
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
984
+			}
985
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
986 986
 			$ignoreImport = true;
987 987
 			foreach($globalAirlineAccept as $airlineAccept) {
988
-			    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)) {
988
+				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)) {
989 989
 				$ignoreImport = false;
990
-			    }
990
+				}
991
+			}
991 992
 			}
992
-		    }
993
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
993
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
994 994
 			$ignoreImport = true;
995 995
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
996
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
997
-			        $ignoreImport = false;
998
-			    }
996
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
997
+					$ignoreImport = false;
998
+				}
999
+			}
999 1000
 			}
1000
-		    }
1001 1001
 
1002
-		    if (!$ignoreImport) {
1002
+			if (!$ignoreImport) {
1003 1003
 			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'])) {
1004 1004
 				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')));
1005 1005
 				$timeelapsed = microtime(true);
1006 1006
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
1007
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1007
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1008 1008
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1009 1009
 					$SpotterLive = new SpotterLive($this->db);
1010 1010
 					//var_dump($this->all_flights[$id]);
1011 1011
 					$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']);
1012 1012
 					$SpotterLive->db = null;
1013 1013
 					if ($globalDebug) echo $result."\n";
1014
-				    }
1014
+					}
1015 1015
 				}
1016 1016
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
1017 1017
 					$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']);
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 				//if ($line['format_source'] != 'aprs') {
1024 1024
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
1025 1025
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1026
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1026
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1027 1027
 					$source = $this->all_flights[$id]['source_name'];
1028 1028
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1029 1029
 					if (!isset($this->source_location[$source])) {
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 					if ($stats_heading == 16) $stats_heading = 0;
1050 1050
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1051 1051
 						for ($i=0;$i<=15;$i++) {
1052
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1052
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1053 1053
 						}
1054 1054
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1055 1055
 					} else {
@@ -1062,17 +1062,17 @@  discard block
 block discarded – undo
1062 1062
 					//var_dump($this->stats);
1063 1063
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1064 1064
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1065
-						    end($this->stats[$current_date][$source]['hist']);
1066
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1065
+							end($this->stats[$current_date][$source]['hist']);
1066
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1067 1067
 						} else $mini = 0;
1068 1068
 						for ($i=$mini;$i<=$distance;$i+=10) {
1069
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1069
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1070 1070
 						}
1071 1071
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1072 1072
 					} else {
1073 1073
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1074 1074
 					}
1075
-				    }
1075
+					}
1076 1076
 				}
1077 1077
 
1078 1078
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 			//$this->del();
1083 1083
 			
1084 1084
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1085
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1085
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1086 1086
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1087 1087
 				$SpotterLive = new SpotterLive($this->db);
1088 1088
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1090,19 +1090,19 @@  discard block
 block discarded – undo
1090 1090
 				//SpotterLive->deleteLiveSpotterData();
1091 1091
 				if ($globalDebug) echo " Done\n";
1092 1092
 				$this->last_delete_hourly = time();
1093
-			    } else {
1093
+				} else {
1094 1094
 				$this->del();
1095 1095
 				$this->last_delete_hourly = time();
1096
-			    }
1096
+				}
1097 1097
 			}
1098 1098
 			
1099
-		    }
1100
-		    //$ignoreImport = false;
1099
+			}
1100
+			//$ignoreImport = false;
1101 1101
 		}
1102 1102
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1103 1103
 		if ($send) return $this->all_flights[$id];
1104
-	    }
1104
+		}
1105
+	}
1105 1106
 	}
1106
-    }
1107 1107
 }
1108 1108
 ?>
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Get Accidents data from DB
40
-	* @param String $limit Limit
41
-	* @param String $type Set type accident or incident
42
-	* @param String $date get data for a date
43
-	* @return Array Return Accidents data in array
44
-	*/
39
+	 * Get Accidents data from DB
40
+	 * @param String $limit Limit
41
+	 * @param String $type Set type accident or incident
42
+	 * @param String $date get data for a date
43
+	 * @return Array Return Accidents data in array
44
+	 */
45 45
 	public function getAccidentData($limit = '',$type = '',$date = '') {
46 46
 		global $globalURL, $globalDBdriver;
47 47
 		$Image = new Image($this->db);
@@ -381,11 +381,11 @@  discard block
 block discarded – undo
381 381
 		return $row['nb'];
382 382
 	}
383 383
 
384
-    /**
385
-     * Check if lastest accident update date is older than 1 day
386
-     * @return bool|string
387
-     */
388
-    public static function check_last_accidents_update() {
384
+	/**
385
+	 * Check if lastest accident update date is older than 1 day
386
+	 * @return bool|string
387
+	 */
388
+	public static function check_last_accidents_update() {
389 389
 		global $globalDBdriver;
390 390
 		if ($globalDBdriver == 'mysql') {
391 391
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_accident_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)";
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
 		else return true;
405 405
 	}
406 406
 
407
-    /**
408
-     * Insert accident update date
409
-     * @return string
410
-     */
411
-    public static function insert_last_accidents_update() {
407
+	/**
408
+	 * Insert accident update date
409
+	 * @return string
410
+	 */
411
+	public static function insert_last_accidents_update() {
412 412
 		$query = "DELETE FROM config WHERE name = 'last_update_accident_db';
413 413
 		    INSERT INTO config (name,value) VALUES ('last_update_accident_db',NOW());";
414 414
 		try {
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Indentation   +460 added lines, -460 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 		if ($this->db === null) die('Error: No DB connection. (Marine)');
19 19
 	}
20 20
 
21
-    /**
22
-     * Get SQL query part for filter used
23
-     * @param array $filter the filter
24
-     * @param bool $where
25
-     * @param bool $and
26
-     * @return string the SQL part
27
-     */
21
+	/**
22
+	 * Get SQL query part for filter used
23
+	 * @param array $filter the filter
24
+	 * @param bool $where
25
+	 * @param bool $and
26
+	 * @return string the SQL part
27
+	 */
28 28
 	public function getFilter($filter = array(),$where = false,$and = false) {
29 29
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
30 30
 		$filters = array();
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	/**
99
-	* Executes the SQL statements to get the spotter information
100
-	*
101
-	* @param String $query the SQL query
102
-	* @param array $params parameter of the query
103
-	* @param String $limitQuery the limit query
104
-	* @return array the spotter information
105
-	*
106
-	*/
99
+	 * Executes the SQL statements to get the spotter information
100
+	 *
101
+	 * @param String $query the SQL query
102
+	 * @param array $params parameter of the query
103
+	 * @param String $limitQuery the limit query
104
+	 * @return array the spotter information
105
+	 *
106
+	 */
107 107
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
108 108
 	{
109 109
 		global $globalVM;
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 	}
254 254
 
255 255
 
256
-    /**
257
-     * Gets all the spotter information based on the latest data entry
258
-     *
259
-     * @param string $limit
260
-     * @param string $sort
261
-     * @param array $filter
262
-     * @return array the spotter information
263
-     */
256
+	/**
257
+	 * Gets all the spotter information based on the latest data entry
258
+	 *
259
+	 * @param string $limit
260
+	 * @param string $sort
261
+	 * @param array $filter
262
+	 * @return array the spotter information
263
+	 */
264 264
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
265 265
 	{
266 266
 		global $global_marine_query;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      * @param string $id
296 296
      * @return array the spotter information
297 297
      */
298
-    public function getMarineDataByID($id = '')
298
+	public function getMarineDataByID($id = '')
299 299
 	{
300 300
 		global $global_marine_query;
301 301
 		
@@ -308,15 +308,15 @@  discard block
 block discarded – undo
308 308
 		return $spotter_array;
309 309
 	}
310 310
 
311
-    /**
312
-     * Gets all the spotter information based on the callsign
313
-     *
314
-     * @param string $ident
315
-     * @param string $limit
316
-     * @param string $sort
317
-     * @param array $filter
318
-     * @return array the spotter information
319
-     */
311
+	/**
312
+	 * Gets all the spotter information based on the callsign
313
+	 *
314
+	 * @param string $ident
315
+	 * @param string $limit
316
+	 * @param string $sort
317
+	 * @param array $filter
318
+	 * @return array the spotter information
319
+	 */
320 320
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
321 321
 	{
322 322
 		global $global_marine_query;
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 		return $spotter_array;
368 368
 	}
369 369
 
370
-    /**
371
-     * Gets all the marine information based on the type
372
-     *
373
-     * @param string $type
374
-     * @param string $limit
375
-     * @param string $sort
376
-     * @param array $filter
377
-     * @return array the marine information
378
-     */
370
+	/**
371
+	 * Gets all the marine information based on the type
372
+	 *
373
+	 * @param string $type
374
+	 * @param string $limit
375
+	 * @param string $sort
376
+	 * @param array $filter
377
+	 * @return array the marine information
378
+	 */
379 379
 	public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array())
380 380
 	{
381 381
 		global $global_marine_query;
@@ -423,14 +423,14 @@  discard block
 block discarded – undo
423 423
 		return $spotter_array;
424 424
 	}
425 425
 
426
-    /**
427
-     * @param string $date
428
-     * @param string $limit
429
-     * @param string $sort
430
-     * @param array $filter
431
-     * @return array
432
-     */
433
-    public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
426
+	/**
427
+	 * @param string $date
428
+	 * @param string $limit
429
+	 * @param string $sort
430
+	 * @param array $filter
431
+	 * @return array
432
+	 */
433
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
434 434
 	{
435 435
 		global $global_marine_query, $globalTimezone, $globalDBdriver;
436 436
 		
@@ -487,15 +487,15 @@  discard block
 block discarded – undo
487 487
 		return $spotter_array;
488 488
 	}
489 489
 
490
-    /**
491
-     * Gets all the marine information based on the captain
492
-     *
493
-     * @param string $captain
494
-     * @param string $limit
495
-     * @param string $sort
496
-     * @param array $filter
497
-     * @return array the marine information
498
-     */
490
+	/**
491
+	 * Gets all the marine information based on the captain
492
+	 *
493
+	 * @param string $captain
494
+	 * @param string $limit
495
+	 * @param string $sort
496
+	 * @param array $filter
497
+	 * @return array the marine information
498
+	 */
499 499
 	public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array())
500 500
 	{
501 501
 		global $global_marine_query;
@@ -533,15 +533,15 @@  discard block
 block discarded – undo
533 533
 		return $spotter_array;
534 534
 	}
535 535
 
536
-    /**
537
-     * Gets all the marine information based on the race
538
-     *
539
-     * @param string $race
540
-     * @param string $limit
541
-     * @param string $sort
542
-     * @param array $filter
543
-     * @return array the marine information
544
-     */
536
+	/**
537
+	 * Gets all the marine information based on the race
538
+	 *
539
+	 * @param string $race
540
+	 * @param string $limit
541
+	 * @param string $sort
542
+	 * @param array $filter
543
+	 * @return array the marine information
544
+	 */
545 545
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
546 546
 	{
547 547
 		global $global_marine_query,$globalDBdriver;
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 		return $spotter_array;
584 584
 	}
585 585
 
586
-    /**
587
-     * Count races by captain
588
-     *
589
-     * @param $captain
590
-     * @param array $filters
591
-     * @return Integer number of race for a captain
592
-     */
586
+	/**
587
+	 * Count races by captain
588
+	 *
589
+	 * @param $captain
590
+	 * @param array $filters
591
+	 * @return Integer number of race for a captain
592
+	 */
593 593
 	public function countRacesByCaptain($captain,$filters = array())
594 594
 	{
595 595
 		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
 		return $result[0]['nb'];
605 605
 	}
606 606
 
607
-    /**
608
-     * Count captains by race
609
-     *
610
-     * @param $race
611
-     * @param array $filters
612
-     * @return String Duration of all races
613
-     */
607
+	/**
608
+	 * Count captains by race
609
+	 *
610
+	 * @param $race
611
+	 * @param array $filters
612
+	 * @return String Duration of all races
613
+	 */
614 614
 	public function countCaptainsByRace($race,$filters = array())
615 615
 	{
616 616
 		$race = filter_var($race,FILTER_SANITIZE_STRING);
@@ -625,16 +625,16 @@  discard block
 block discarded – undo
625 625
 		return $result[0]['nb'];
626 626
 	}
627 627
 
628
-    /**
629
-     * Gets all boat types that have been used by a captain
630
-     *
631
-     * @param $captain
632
-     * @param array $filters
633
-     * @param string $year
634
-     * @param string $month
635
-     * @param string $day
636
-     * @return array the boat list
637
-     */
628
+	/**
629
+	 * Gets all boat types that have been used by a captain
630
+	 *
631
+	 * @param $captain
632
+	 * @param array $filters
633
+	 * @param string $year
634
+	 * @param string $month
635
+	 * @param string $day
636
+	 * @return array the boat list
637
+	 */
638 638
 	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
639 639
 	{
640 640
 		global $globalDBdriver;
@@ -678,16 +678,16 @@  discard block
 block discarded – undo
678 678
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
679 679
 	}
680 680
 
681
-    /**
682
-     * Gets all boat types that have been used on a race
683
-     *
684
-     * @param $race
685
-     * @param array $filters
686
-     * @param string $year
687
-     * @param string $month
688
-     * @param string $day
689
-     * @return array the boat list
690
-     */
681
+	/**
682
+	 * Gets all boat types that have been used on a race
683
+	 *
684
+	 * @param $race
685
+	 * @param array $filters
686
+	 * @param string $year
687
+	 * @param string $month
688
+	 * @param string $day
689
+	 * @return array the boat list
690
+	 */
691 691
 	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
692 692
 	{
693 693
 		global $globalDBdriver;
@@ -731,16 +731,16 @@  discard block
 block discarded – undo
731 731
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
732 732
 	}
733 733
 
734
-    /**
735
-     * Gets race duration by captain
736
-     *
737
-     * @param $captain
738
-     * @param array $filters
739
-     * @param string $year
740
-     * @param string $month
741
-     * @param string $day
742
-     * @return String Duration of all race
743
-     */
734
+	/**
735
+	 * Gets race duration by captain
736
+	 *
737
+	 * @param $captain
738
+	 * @param array $filters
739
+	 * @param string $year
740
+	 * @param string $month
741
+	 * @param string $day
742
+	 * @return String Duration of all race
743
+	 */
744 744
 	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
745 745
 	{
746 746
 		global $globalDBdriver;
@@ -785,16 +785,16 @@  discard block
 block discarded – undo
785 785
 		else return $result[0]['duration'];
786 786
 	}
787 787
 
788
-    /**
789
-     * Gets race duration by captains
790
-     *
791
-     * @param bool $limit
792
-     * @param array $filters
793
-     * @param string $year
794
-     * @param string $month
795
-     * @param string $day
796
-     * @return array Duration of all race
797
-     */
788
+	/**
789
+	 * Gets race duration by captains
790
+	 *
791
+	 * @param bool $limit
792
+	 * @param array $filters
793
+	 * @param string $year
794
+	 * @param string $month
795
+	 * @param string $day
796
+	 * @return array Duration of all race
797
+	 */
798 798
 	public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '')
799 799
 	{
800 800
 		global $globalDBdriver;
@@ -852,12 +852,12 @@  discard block
 block discarded – undo
852 852
 
853 853
 	}
854 854
 
855
-    /**
856
-     * Gets a list of all captain names and captain ids
857
-     *
858
-     * @param array $filters
859
-     * @return array list of captain names and captain ids
860
-     */
855
+	/**
856
+	 * Gets a list of all captain names and captain ids
857
+	 *
858
+	 * @param array $filters
859
+	 * @return array list of captain names and captain ids
860
+	 */
861 861
 	public function getAllCaptainNames($filters = array())
862 862
 	{
863 863
 		$filter_query = $this->getFilter($filters,true,true);
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
871 871
 	}
872 872
 
873
-    /**
874
-     * Gets a list of all race names and race ids
875
-     *
876
-     * @param array $filters
877
-     * @return array list of race names and race ids
878
-     */
873
+	/**
874
+	 * Gets a list of all race names and race ids
875
+	 *
876
+	 * @param array $filters
877
+	 * @return array list of race names and race ids
878
+	 */
879 879
 	public function getAllRaceNames($filters = array())
880 880
 	{
881 881
 		$filter_query = $this->getFilter($filters,true,true);
@@ -889,13 +889,13 @@  discard block
 block discarded – undo
889 889
 	}
890 890
 
891 891
 
892
-    /**
893
-     * Gets all source name
894
-     *
895
-     * @param String type format of source
896
-     * @param array $filters
897
-     * @return array list of source name
898
-     */
892
+	/**
893
+	 * Gets all source name
894
+	 *
895
+	 * @param String type format of source
896
+	 * @param array $filters
897
+	 * @return array list of source name
898
+	 */
899 899
 	public function getAllSourceName($type = '',$filters = array())
900 900
 	{
901 901
 		$filter_query = $this->getFilter($filters,true,true);
@@ -924,12 +924,12 @@  discard block
 block discarded – undo
924 924
 	}
925 925
 
926 926
 
927
-    /**
928
-     * Gets a list of all idents/callsigns
929
-     *
930
-     * @param array $filters
931
-     * @return array list of ident/callsign names
932
-     */
927
+	/**
928
+	 * Gets a list of all idents/callsigns
929
+	 *
930
+	 * @param array $filters
931
+	 * @return array list of ident/callsign names
932
+	 */
933 933
 	public function getAllIdents($filters = array())
934 934
 	{
935 935
 		$filter_query = $this->getFilter($filters,true,true);
@@ -952,12 +952,12 @@  discard block
 block discarded – undo
952 952
 		return $ident_array;
953 953
 	}
954 954
 
955
-    /**
956
-     * Gets all info from a mmsi
957
-     *
958
-     * @param $mmsi
959
-     * @return array ident
960
-     */
955
+	/**
956
+	 * Gets all info from a mmsi
957
+	 *
958
+	 * @param $mmsi
959
+	 * @return array ident
960
+	 */
961 961
 	public function getIdentity($mmsi)
962 962
 	{
963 963
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -969,14 +969,14 @@  discard block
 block discarded – undo
969 969
 		else return array();
970 970
 	}
971 971
 
972
-    /**
973
-     * Add identity
974
-     * @param $mmsi
975
-     * @param $imo
976
-     * @param $ident
977
-     * @param $callsign
978
-     * @param $type
979
-     */
972
+	/**
973
+	 * Add identity
974
+	 * @param $mmsi
975
+	 * @param $imo
976
+	 * @param $ident
977
+	 * @param $callsign
978
+	 * @param $type
979
+	 */
980 980
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
981 981
 	{
982 982
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
 	}
1043 1043
 
1044 1044
 	/**
1045
-	* Update ident tracker data
1046
-	*
1047
-	* @param String $fammarine_id the ID
1048
-	* @param String $ident the marine ident
1049
-	* @return String success or false
1050
-	*
1051
-	*/
1045
+	 * Update ident tracker data
1046
+	 *
1047
+	 * @param String $fammarine_id the ID
1048
+	 * @param String $ident the marine ident
1049
+	 * @return String success or false
1050
+	 *
1051
+	 */
1052 1052
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
1053 1053
 	{
1054 1054
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -1063,13 +1063,13 @@  discard block
 block discarded – undo
1063 1063
 	}
1064 1064
 
1065 1065
 	/**
1066
-	* Update arrival marine data
1067
-	*
1068
-	* @param String $fammarine_id the ID
1069
-	* @param String $arrival_code the marine ident
1070
-	* @return String success or false
1071
-	*
1072
-	*/
1066
+	 * Update arrival marine data
1067
+	 *
1068
+	 * @param String $fammarine_id the ID
1069
+	 * @param String $arrival_code the marine ident
1070
+	 * @return String success or false
1071
+	 *
1072
+	 */
1073 1073
 	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
1074 1074
 	{
1075 1075
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
@@ -1084,19 +1084,19 @@  discard block
 block discarded – undo
1084 1084
 	}
1085 1085
 
1086 1086
 	/**
1087
-	* Update Status data
1088
-	*
1089
-	* @param String $fammarine_id the ID
1090
-	* @param String $status_id the marine status id
1091
-	* @param String $status the marine status
1092
-	* @return String success or false
1093
-	*
1094
-	*/
1087
+	 * Update Status data
1088
+	 *
1089
+	 * @param String $fammarine_id the ID
1090
+	 * @param String $status_id the marine status id
1091
+	 * @param String $status the marine status
1092
+	 * @return String success or false
1093
+	 *
1094
+	 */
1095 1095
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
1096 1096
 	{
1097 1097
 
1098 1098
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
1099
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1099
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1100 1100
 
1101 1101
 		try {
1102 1102
 			$sth = $this->db->prepare($query);
@@ -1109,22 +1109,22 @@  discard block
 block discarded – undo
1109 1109
 
1110 1110
 	}
1111 1111
 
1112
-    /**
1113
-     * Update latest marine data
1114
-     *
1115
-     * @param String $fammarine_id the ID
1116
-     * @param String $ident the marine ident
1117
-     * @param string $latitude
1118
-     * @param string $longitude
1119
-     * @param float $groundspeed
1120
-     * @param string $date
1121
-     * @param float $distance
1122
-     * @param integer $race_rank
1123
-     * @param integer $race_time
1124
-     * @param string $status
1125
-     * @param string $race_begin
1126
-     * @return String success or false
1127
-     */
1112
+	/**
1113
+	 * Update latest marine data
1114
+	 *
1115
+	 * @param String $fammarine_id the ID
1116
+	 * @param String $ident the marine ident
1117
+	 * @param string $latitude
1118
+	 * @param string $longitude
1119
+	 * @param float $groundspeed
1120
+	 * @param string $date
1121
+	 * @param float $distance
1122
+	 * @param integer $race_rank
1123
+	 * @param integer $race_time
1124
+	 * @param string $status
1125
+	 * @param string $race_begin
1126
+	 * @return String success or false
1127
+	 */
1128 1128
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1129 1129
 	{
1130 1130
 		if ($latitude == '') $latitude = NULL;
@@ -1149,36 +1149,36 @@  discard block
 block discarded – undo
1149 1149
 
1150 1150
 	}
1151 1151
 
1152
-    /**
1153
-     * Adds a new marine data
1154
-     *
1155
-     * @param String $fammarine_id the ID
1156
-     * @param String $ident the marine ident
1157
-     * @param String $latitude latitude of flight
1158
-     * @param String $longitude latitude of flight
1159
-     * @param String $heading heading of flight
1160
-     * @param String $groundspeed speed of flight
1161
-     * @param String $date date of flight
1162
-     * @param string $mmsi
1163
-     * @param string $type
1164
-     * @param string $typeid
1165
-     * @param string $imo
1166
-     * @param string $callsign
1167
-     * @param string $arrival_code
1168
-     * @param string $arrival_date
1169
-     * @param string $status
1170
-     * @param string $statusid
1171
-     * @param string $format_source
1172
-     * @param string $source_name
1173
-     * @param string $captain_id
1174
-     * @param string $captain_name
1175
-     * @param string $race_id
1176
-     * @param string $race_name
1177
-     * @param string $distance
1178
-     * @param string $race_rank
1179
-     * @param string $race_time
1180
-     * @return String success or false
1181
-     */
1152
+	/**
1153
+	 * Adds a new marine data
1154
+	 *
1155
+	 * @param String $fammarine_id the ID
1156
+	 * @param String $ident the marine ident
1157
+	 * @param String $latitude latitude of flight
1158
+	 * @param String $longitude latitude of flight
1159
+	 * @param String $heading heading of flight
1160
+	 * @param String $groundspeed speed of flight
1161
+	 * @param String $date date of flight
1162
+	 * @param string $mmsi
1163
+	 * @param string $type
1164
+	 * @param string $typeid
1165
+	 * @param string $imo
1166
+	 * @param string $callsign
1167
+	 * @param string $arrival_code
1168
+	 * @param string $arrival_date
1169
+	 * @param string $status
1170
+	 * @param string $statusid
1171
+	 * @param string $format_source
1172
+	 * @param string $source_name
1173
+	 * @param string $captain_id
1174
+	 * @param string $captain_name
1175
+	 * @param string $race_id
1176
+	 * @param string $race_name
1177
+	 * @param string $distance
1178
+	 * @param string $race_rank
1179
+	 * @param string $race_time
1180
+	 * @return String success or false
1181
+	 */
1182 1182
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '')
1183 1183
 	{
1184 1184
 		global $globalURL, $globalMarineImageFetch;
@@ -1311,12 +1311,12 @@  discard block
 block discarded – undo
1311 1311
 	}
1312 1312
 
1313 1313
 
1314
-    /**
1315
-     * Gets the aircraft ident within the last hour
1316
-     *
1317
-     * @param $ident
1318
-     * @return String the ident
1319
-     */
1314
+	/**
1315
+	 * Gets the aircraft ident within the last hour
1316
+	 *
1317
+	 * @param $ident
1318
+	 * @return String the ident
1319
+	 */
1320 1320
 	public function getIdentFromLastHour($ident)
1321 1321
 	{
1322 1322
 		global $globalDBdriver, $globalTimezone;
@@ -1332,11 +1332,11 @@  discard block
 block discarded – undo
1332 1332
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1333 1333
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
1334 1334
 			$query_data = array(':ident' => $ident);
1335
-    		}
1335
+			}
1336 1336
 		
1337 1337
 		$sth = $this->db->prepare($query);
1338 1338
 		$sth->execute($query_data);
1339
-    		$ident_result='';
1339
+			$ident_result='';
1340 1340
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1341 1341
 		{
1342 1342
 			$ident_result = $row['ident'];
@@ -1346,12 +1346,12 @@  discard block
 block discarded – undo
1346 1346
 	}
1347 1347
 
1348 1348
 
1349
-    /**
1350
-     * Gets the aircraft data from the last 20 seconds
1351
-     *
1352
-     * @param string $q
1353
-     * @return array the marine data
1354
-     */
1349
+	/**
1350
+	 * Gets the aircraft data from the last 20 seconds
1351
+	 *
1352
+	 * @param string $q
1353
+	 * @return array the marine data
1354
+	 */
1355 1355
 	public function getRealTimeData($q = '')
1356 1356
 	{
1357 1357
 		global $globalDBdriver;
@@ -1386,15 +1386,15 @@  discard block
 block discarded – undo
1386 1386
 	}
1387 1387
 
1388 1388
 
1389
-    /**
1390
-     * Gets all number of flight over countries
1391
-     *
1392
-     * @param bool $limit
1393
-     * @param int $olderthanmonths
1394
-     * @param string $sincedate
1395
-     * @param array $filters
1396
-     * @return array the airline country list
1397
-     */
1389
+	/**
1390
+	 * Gets all number of flight over countries
1391
+	 *
1392
+	 * @param bool $limit
1393
+	 * @param int $olderthanmonths
1394
+	 * @param string $sincedate
1395
+	 * @param array $filters
1396
+	 * @return array the airline country list
1397
+	 */
1398 1398
 
1399 1399
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1400 1400
 	{
@@ -1465,18 +1465,18 @@  discard block
 block discarded – undo
1465 1465
 	}
1466 1466
 
1467 1467
 
1468
-    /**
1469
-     * Gets all callsigns that have flown over
1470
-     *
1471
-     * @param bool $limit
1472
-     * @param int $olderthanmonths
1473
-     * @param string $sincedate
1474
-     * @param array $filters
1475
-     * @param string $year
1476
-     * @param string $month
1477
-     * @param string $day
1478
-     * @return array the callsign list
1479
-     */
1468
+	/**
1469
+	 * Gets all callsigns that have flown over
1470
+	 *
1471
+	 * @param bool $limit
1472
+	 * @param int $olderthanmonths
1473
+	 * @param string $sincedate
1474
+	 * @param array $filters
1475
+	 * @param string $year
1476
+	 * @param string $month
1477
+	 * @param string $day
1478
+	 * @return array the callsign list
1479
+	 */
1480 1480
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1481 1481
 	{
1482 1482
 		global $globalDBdriver;
@@ -1542,12 +1542,12 @@  discard block
 block discarded – undo
1542 1542
 	}
1543 1543
 
1544 1544
 
1545
-    /**
1546
-     * Counts all dates
1547
-     *
1548
-     * @param array $filters
1549
-     * @return array the date list
1550
-     */
1545
+	/**
1546
+	 * Counts all dates
1547
+	 *
1548
+	 * @param array $filters
1549
+	 * @return array the date list
1550
+	 */
1551 1551
 	public function countAllDates($filters = array())
1552 1552
 	{
1553 1553
 		global $globalTimezone, $globalDBdriver;
@@ -1592,12 +1592,12 @@  discard block
 block discarded – undo
1592 1592
 	}
1593 1593
 
1594 1594
 
1595
-    /**
1596
-     * Counts all dates during the last 7 days
1597
-     *
1598
-     * @param array $filters
1599
-     * @return array the date list
1600
-     */
1595
+	/**
1596
+	 * Counts all dates during the last 7 days
1597
+	 *
1598
+	 * @param array $filters
1599
+	 * @return array the date list
1600
+	 */
1601 1601
 	public function countAllDatesLast7Days($filters = array())
1602 1602
 	{
1603 1603
 		global $globalTimezone, $globalDBdriver;
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 			$query .= " GROUP BY date_name 
1620 1620
 								ORDER BY date_name ASC";
1621 1621
 			$query_data = array(':offset' => $offset);
1622
-    		}
1622
+			}
1623 1623
 		
1624 1624
 		$sth = $this->db->prepare($query);
1625 1625
 		$sth->execute($query_data);
@@ -1638,12 +1638,12 @@  discard block
 block discarded – undo
1638 1638
 		return $date_array;
1639 1639
 	}
1640 1640
 
1641
-    /**
1642
-     * Counts all dates during the last month
1643
-     *
1644
-     * @param array $filters
1645
-     * @return array the date list
1646
-     */
1641
+	/**
1642
+	 * Counts all dates during the last month
1643
+	 *
1644
+	 * @param array $filters
1645
+	 * @return array the date list
1646
+	 */
1647 1647
 	public function countAllDatesLastMonth($filters = array())
1648 1648
 	{
1649 1649
 		global $globalTimezone, $globalDBdriver;
@@ -1665,7 +1665,7 @@  discard block
 block discarded – undo
1665 1665
 			$query .= " GROUP BY date_name 
1666 1666
 								ORDER BY date_name ASC";
1667 1667
 			$query_data = array(':offset' => $offset);
1668
-    		}
1668
+			}
1669 1669
 		
1670 1670
 		$sth = $this->db->prepare($query);
1671 1671
 		$sth->execute($query_data);
@@ -1687,11 +1687,11 @@  discard block
 block discarded – undo
1687 1687
 
1688 1688
 
1689 1689
 	/**
1690
-	* Counts all month
1691
-	*
1692
-	* @return array the month list
1693
-	*
1694
-	*/
1690
+	 * Counts all month
1691
+	 *
1692
+	 * @return array the month list
1693
+	 *
1694
+	 */
1695 1695
 	public function countAllMonths($filters = array())
1696 1696
 	{
1697 1697
 		global $globalTimezone, $globalDBdriver;
@@ -1733,12 +1733,12 @@  discard block
 block discarded – undo
1733 1733
 	}
1734 1734
 
1735 1735
 
1736
-    /**
1737
-     * Counts all dates during the last year
1738
-     *
1739
-     * @param $filters
1740
-     * @return array the date list
1741
-     */
1736
+	/**
1737
+	 * Counts all dates during the last year
1738
+	 *
1739
+	 * @param $filters
1740
+	 * @return array the date list
1741
+	 */
1742 1742
 	public function countAllMonthsLastYear($filters)
1743 1743
 	{
1744 1744
 		global $globalTimezone, $globalDBdriver;
@@ -1760,7 +1760,7 @@  discard block
 block discarded – undo
1760 1760
 			$query .= " GROUP BY year_name, month_name
1761 1761
 								ORDER BY year_name, month_name ASC";
1762 1762
 			$query_data = array(':offset' => $offset);
1763
-    		}
1763
+			}
1764 1764
 		
1765 1765
 		$sth = $this->db->prepare($query);
1766 1766
 		$sth->execute($query_data);
@@ -1781,13 +1781,13 @@  discard block
 block discarded – undo
1781 1781
 	}
1782 1782
 
1783 1783
 
1784
-    /**
1785
-     * Counts all hours
1786
-     *
1787
-     * @param $orderby
1788
-     * @param array $filters
1789
-     * @return array the hour list
1790
-     */
1784
+	/**
1785
+	 * Counts all hours
1786
+	 *
1787
+	 * @param $orderby
1788
+	 * @param array $filters
1789
+	 * @return array the hour list
1790
+	 */
1791 1791
 	public function countAllHours($orderby,$filters = array())
1792 1792
 	{
1793 1793
 		global $globalTimezone, $globalDBdriver;
@@ -1848,13 +1848,13 @@  discard block
 block discarded – undo
1848 1848
 	}
1849 1849
 
1850 1850
 
1851
-    /**
1852
-     * Counts all hours by date
1853
-     *
1854
-     * @param $date
1855
-     * @param array $filters
1856
-     * @return array the hour list
1857
-     */
1851
+	/**
1852
+	 * Counts all hours by date
1853
+	 *
1854
+	 * @param $date
1855
+	 * @param array $filters
1856
+	 * @return array the hour list
1857
+	 */
1858 1858
 	public function countAllHoursByDate($date, $filters = array())
1859 1859
 	{
1860 1860
 		global $globalTimezone, $globalDBdriver;
@@ -1896,13 +1896,13 @@  discard block
 block discarded – undo
1896 1896
 	}
1897 1897
 
1898 1898
 
1899
-    /**
1900
-     * Counts all hours by a ident/callsign
1901
-     *
1902
-     * @param $ident
1903
-     * @param array $filters
1904
-     * @return array the hour list
1905
-     */
1899
+	/**
1900
+	 * Counts all hours by a ident/callsign
1901
+	 *
1902
+	 * @param $ident
1903
+	 * @param array $filters
1904
+	 * @return array the hour list
1905
+	 */
1906 1906
 	public function countAllHoursByIdent($ident, $filters = array())
1907 1907
 	{
1908 1908
 		global $globalTimezone, $globalDBdriver;
@@ -1944,15 +1944,15 @@  discard block
 block discarded – undo
1944 1944
 		return $hour_array;
1945 1945
 	}
1946 1946
 
1947
-    /**
1948
-     * Gets all aircraft registrations that have flown over
1949
-     *
1950
-     * @param bool $limit
1951
-     * @param int $olderthanmonths
1952
-     * @param string $sincedate
1953
-     * @param array $filters
1954
-     * @return array the aircraft list
1955
-     */
1947
+	/**
1948
+	 * Gets all aircraft registrations that have flown over
1949
+	 *
1950
+	 * @param bool $limit
1951
+	 * @param int $olderthanmonths
1952
+	 * @param string $sincedate
1953
+	 * @param array $filters
1954
+	 * @return array the aircraft list
1955
+	 */
1956 1956
 	public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1957 1957
 	{
1958 1958
 		global $globalDBdriver;
@@ -1990,14 +1990,14 @@  discard block
 block discarded – undo
1990 1990
 		return $marine_array;
1991 1991
 	}
1992 1992
 
1993
-    /**
1994
-     * Counts all vessels
1995
-     *
1996
-     * @param array $filters
1997
-     * @param string $year
1998
-     * @param string $month
1999
-     * @return Integer the number of vessels
2000
-     */
1993
+	/**
1994
+	 * Counts all vessels
1995
+	 *
1996
+	 * @param array $filters
1997
+	 * @param string $year
1998
+	 * @param string $month
1999
+	 * @return Integer the number of vessels
2000
+	 */
2001 2001
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
2002 2002
 	{
2003 2003
 		global $globalDBdriver;
@@ -2031,14 +2031,14 @@  discard block
 block discarded – undo
2031 2031
 		return $sth->fetchColumn();
2032 2032
 	}
2033 2033
 
2034
-    /**
2035
-     * Counts all vessel type
2036
-     *
2037
-     * @param array $filters
2038
-     * @param string $year
2039
-     * @param string $month
2040
-     * @return Integer the number of vessels
2041
-     */
2034
+	/**
2035
+	 * Counts all vessel type
2036
+	 *
2037
+	 * @param array $filters
2038
+	 * @param string $year
2039
+	 * @param string $month
2040
+	 * @return Integer the number of vessels
2041
+	 */
2042 2042
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
2043 2043
 	{
2044 2044
 		global $globalDBdriver;
@@ -2071,14 +2071,14 @@  discard block
 block discarded – undo
2071 2071
 		return $sth->fetchColumn();
2072 2072
 	}
2073 2073
 
2074
-    /**
2075
-     * Gets a number of all race
2076
-     *
2077
-     * @param array $filters
2078
-     * @param string $year
2079
-     * @param string $month
2080
-     * @return Integer number of races
2081
-     */
2074
+	/**
2075
+	 * Gets a number of all race
2076
+	 *
2077
+	 * @param array $filters
2078
+	 * @param string $year
2079
+	 * @param string $month
2080
+	 * @return Integer number of races
2081
+	 */
2082 2082
 	public function countOverallMarineRaces($filters = array(),$year = '',$month = '')
2083 2083
 	{
2084 2084
 		global $globalDBdriver;
@@ -2111,14 +2111,14 @@  discard block
 block discarded – undo
2111 2111
 		return $sth->fetchColumn();
2112 2112
 	}
2113 2113
 
2114
-    /**
2115
-     * Gets a number of all captain
2116
-     *
2117
-     * @param array $filters
2118
-     * @param string $year
2119
-     * @param string $month
2120
-     * @return Integer number of captain
2121
-     */
2114
+	/**
2115
+	 * Gets a number of all captain
2116
+	 *
2117
+	 * @param array $filters
2118
+	 * @param string $year
2119
+	 * @param string $month
2120
+	 * @return Integer number of captain
2121
+	 */
2122 2122
 	public function countOverallMarineCaptains($filters = array(),$year = '',$month = '')
2123 2123
 	{
2124 2124
 		global $globalDBdriver;
@@ -2151,12 +2151,12 @@  discard block
 block discarded – undo
2151 2151
 		return $sth->fetchColumn();
2152 2152
 	}
2153 2153
 
2154
-    /**
2155
-     * Counts all hours of today
2156
-     *
2157
-     * @param array $filters
2158
-     * @return array the hour list
2159
-     */
2154
+	/**
2155
+	 * Counts all hours of today
2156
+	 *
2157
+	 * @param array $filters
2158
+	 * @return array the hour list
2159
+	 */
2160 2160
 	public function countAllHoursFromToday($filters = array())
2161 2161
 	{
2162 2162
 		global $globalTimezone, $globalDBdriver;
@@ -2196,12 +2196,12 @@  discard block
 block discarded – undo
2196 2196
 	}
2197 2197
     
2198 2198
     
2199
-     /**
2200
-	* Gets the Barrie Spotter ID based on the FlightAware ID
2201
-	*
2202
-	* @return Integer the Barrie Spotter ID
2199
+	 /**
2200
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
2201
+	  *
2202
+	  * @return Integer the Barrie Spotter ID
2203 2203
 q	*
2204
-	*/
2204
+	  */
2205 2205
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
2206 2206
 	{
2207 2207
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -2222,13 +2222,13 @@  discard block
 block discarded – undo
2222 2222
   
2223 2223
  
2224 2224
 	/**
2225
-	* Parses a date string
2226
-	*
2227
-	* @param String $dateString the date string
2228
-	* @param String $timezone the timezone of a user
2229
-	* @return array the time information
2230
-	*
2231
-	*/
2225
+	 * Parses a date string
2226
+	 *
2227
+	 * @param String $dateString the date string
2228
+	 * @param String $timezone the timezone of a user
2229
+	 * @return array the time information
2230
+	 *
2231
+	 */
2232 2232
 	public function parseDateString($dateString, $timezone = '')
2233 2233
 	{
2234 2234
 		$time_array = array();
@@ -2261,12 +2261,12 @@  discard block
 block discarded – undo
2261 2261
 	}
2262 2262
 	
2263 2263
 	/**
2264
-	* Parses the direction degrees to working
2265
-	*
2266
-	* @param Float $direction the direction in degrees
2267
-	* @return array the direction information
2268
-	*
2269
-	*/
2264
+	 * Parses the direction degrees to working
2265
+	 *
2266
+	 * @param Float $direction the direction in degrees
2267
+	 * @return array the direction information
2268
+	 *
2269
+	 */
2270 2270
 	public function parseDirection($direction = 0)
2271 2271
 	{
2272 2272
 		if ($direction == '') $direction = 0;
@@ -2345,12 +2345,12 @@  discard block
 block discarded – undo
2345 2345
 	
2346 2346
 	
2347 2347
 	/**
2348
-	* Gets Country from latitude/longitude
2349
-	*
2350
-	* @param Float $latitude latitute of the flight
2351
-	* @param Float $longitude longitute of the flight
2352
-	* @return String the countries
2353
-	*/
2348
+	 * Gets Country from latitude/longitude
2349
+	 *
2350
+	 * @param Float $latitude latitute of the flight
2351
+	 * @param Float $longitude longitute of the flight
2352
+	 * @return String the countries
2353
+	 */
2354 2354
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2355 2355
 	{
2356 2356
 		global $globalDBdriver, $globalDebug;
@@ -2387,11 +2387,11 @@  discard block
 block discarded – undo
2387 2387
 	}
2388 2388
 
2389 2389
 	/**
2390
-	* Gets Country from iso2
2391
-	*
2392
-	* @param String $iso2 ISO2 country code
2393
-	* @return String the countries
2394
-	*/
2390
+	 * Gets Country from iso2
2391
+	 *
2392
+	 * @param String $iso2 ISO2 country code
2393
+	 * @return String the countries
2394
+	 */
2395 2395
 	public function getCountryFromISO2($iso2)
2396 2396
 	{
2397 2397
 		global $globalDBdriver, $globalDebug;
@@ -2420,12 +2420,12 @@  discard block
 block discarded – undo
2420 2420
 
2421 2421
 	
2422 2422
 	/**
2423
-	* Gets the short url from bit.ly
2424
-	*
2425
-	* @param String $url the full url
2426
-	* @return String the bit.ly url
2427
-	*
2428
-	*/
2423
+	 * Gets the short url from bit.ly
2424
+	 *
2425
+	 * @param String $url the full url
2426
+	 * @return String the bit.ly url
2427
+	 *
2428
+	 */
2429 2429
 	public function getBitlyURL($url)
2430 2430
 	{
2431 2431
 		global $globalBitlyAccessToken;
@@ -2451,18 +2451,18 @@  discard block
 block discarded – undo
2451 2451
 	}
2452 2452
 
2453 2453
 
2454
-    /**
2455
-     * Gets all vessels types that have flown over
2456
-     *
2457
-     * @param bool $limit
2458
-     * @param int $olderthanmonths
2459
-     * @param string $sincedate
2460
-     * @param array $filters
2461
-     * @param string $year
2462
-     * @param string $month
2463
-     * @param string $day
2464
-     * @return array the vessel type list
2465
-     */
2454
+	/**
2455
+	 * Gets all vessels types that have flown over
2456
+	 *
2457
+	 * @param bool $limit
2458
+	 * @param int $olderthanmonths
2459
+	 * @param string $sincedate
2460
+	 * @param array $filters
2461
+	 * @param string $year
2462
+	 * @param string $month
2463
+	 * @param string $day
2464
+	 * @return array the vessel type list
2465
+	 */
2466 2466
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2467 2467
 	{
2468 2468
 		global $globalDBdriver;
@@ -2527,27 +2527,27 @@  discard block
 block discarded – undo
2527 2527
 		return $marine_array;
2528 2528
 	}
2529 2529
 
2530
-    /**
2531
-     * Gets all the tracker information
2532
-     *
2533
-     * @param string $q
2534
-     * @param string $callsign
2535
-     * @param string $mmsi
2536
-     * @param string $imo
2537
-     * @param string $date_posted
2538
-     * @param string $limit
2539
-     * @param string $sort
2540
-     * @param string $includegeodata
2541
-     * @param string $origLat
2542
-     * @param string $origLon
2543
-     * @param string $dist
2544
-     * @param string $captain_id
2545
-     * @param string $captain_name
2546
-     * @param string $race_id
2547
-     * @param string $race_name
2548
-     * @param array $filters
2549
-     * @return array the tracker information
2550
-     */
2530
+	/**
2531
+	 * Gets all the tracker information
2532
+	 *
2533
+	 * @param string $q
2534
+	 * @param string $callsign
2535
+	 * @param string $mmsi
2536
+	 * @param string $imo
2537
+	 * @param string $date_posted
2538
+	 * @param string $limit
2539
+	 * @param string $sort
2540
+	 * @param string $includegeodata
2541
+	 * @param string $origLat
2542
+	 * @param string $origLon
2543
+	 * @param string $dist
2544
+	 * @param string $captain_id
2545
+	 * @param string $captain_name
2546
+	 * @param string $race_id
2547
+	 * @param string $race_name
2548
+	 * @param array $filters
2549
+	 * @return array the tracker information
2550
+	 */
2551 2551
 	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array())
2552 2552
 	{
2553 2553
 		global $globalTimezone, $globalDBdriver;
@@ -2723,12 +2723,12 @@  discard block
 block discarded – undo
2723 2723
 		return $marine_array;
2724 2724
 	}
2725 2725
 
2726
-    /**
2727
-     * Check marine by id
2728
-     *
2729
-     * @param $id
2730
-     * @return String the ident
2731
-     */
2726
+	/**
2727
+	 * Check marine by id
2728
+	 *
2729
+	 * @param $id
2730
+	 * @return String the ident
2731
+	 */
2732 2732
 	public function checkId($id)
2733 2733
 	{
2734 2734
 		global $globalDBdriver, $globalTimezone;
@@ -2744,12 +2744,12 @@  discard block
 block discarded – undo
2744 2744
 		return $ident_result;
2745 2745
 	}
2746 2746
 
2747
-    /**
2748
-     * Gets all info from a race
2749
-     *
2750
-     * @param $race_name
2751
-     * @return array race
2752
-     */
2747
+	/**
2748
+	 * Gets all info from a race
2749
+	 *
2750
+	 * @param $race_name
2751
+	 * @return array race
2752
+	 */
2753 2753
 	public function getRaceByName($race_name)
2754 2754
 	{
2755 2755
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
@@ -2761,12 +2761,12 @@  discard block
 block discarded – undo
2761 2761
 		else return array();
2762 2762
 	}
2763 2763
 
2764
-    /**
2765
-     * Gets all info from a race
2766
-     *
2767
-     * @param $race_id
2768
-     * @return array race
2769
-     */
2764
+	/**
2765
+	 * Gets all info from a race
2766
+	 *
2767
+	 * @param $race_id
2768
+	 * @return array race
2769
+	 */
2770 2770
 	public function getRace($race_id)
2771 2771
 	{
2772 2772
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
@@ -2778,15 +2778,15 @@  discard block
 block discarded – undo
2778 2778
 		else return array();
2779 2779
 	}
2780 2780
 
2781
-    /**
2782
-     * Add race
2783
-     * @param $race_id
2784
-     * @param $race_name
2785
-     * @param $race_creator
2786
-     * @param $race_desc
2787
-     * @param $race_startdate
2788
-     * @param $race_markers
2789
-     */
2781
+	/**
2782
+	 * Add race
2783
+	 * @param $race_id
2784
+	 * @param $race_name
2785
+	 * @param $race_creator
2786
+	 * @param $race_desc
2787
+	 * @param $race_startdate
2788
+	 * @param $race_markers
2789
+	 */
2790 2790
 	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2791 2791
 	{
2792 2792
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.