Completed
Push — master ( 072036...f3a36a )
by Yannick
29:27
created
require/class.SpotterLive.php 1 patch
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	}
137 137
 
138 138
 	/**
139
-	* Gets all the spotter information based on the latest data entry
140
-	*
141
-	* @return Array the spotter information
142
-	*
143
-	*/
139
+	 * Gets all the spotter information based on the latest data entry
140
+	 *
141
+	 * @return Array the spotter information
142
+	 *
143
+	 */
144 144
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
145 145
 	{
146 146
 		global $globalDBdriver, $globalLiveInterval;
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	}
184 184
 
185 185
 	/**
186
-	* Gets Minimal Live Spotter data
187
-	*
188
-	* @return Array the spotter information
189
-	*
190
-	*/
186
+	 * Gets Minimal Live Spotter data
187
+	 *
188
+	 * @return Array the spotter information
189
+	 *
190
+	 */
191 191
 	public function getMinLiveSpotterData($filter = array())
192 192
 	{
193 193
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
 	}
225 225
 
226 226
 	/**
227
-	* Gets Minimal Live Spotter data since xx seconds
228
-	*
229
-	* @return Array the spotter information
230
-	*
231
-	*/
227
+	 * Gets Minimal Live Spotter data since xx seconds
228
+	 *
229
+	 * @return Array the spotter information
230
+	 *
231
+	 */
232 232
 	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false, $id = '')
233 233
 	{
234 234
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	}
326 326
 
327 327
 	/**
328
-	* Gets Minimal Live Spotter data since xx seconds
329
-	*
330
-	* @return Array the spotter information
331
-	*
332
-	*/
328
+	 * Gets Minimal Live Spotter data since xx seconds
329
+	 *
330
+	 * @return Array the spotter information
331
+	 *
332
+	 */
333 333
 	public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = false)
334 334
 	{
335 335
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 	}
395 395
 
396 396
 	/**
397
-	* Gets number of latest data entry
398
-	*
399
-	* @return String number of entry
400
-	*
401
-	*/
397
+	 * Gets number of latest data entry
398
+	 *
399
+	 * @return String number of entry
400
+	 *
401
+	 */
402 402
 	public function getLiveSpotterCount($filter = array())
403 403
 	{
404 404
 		global $globalDBdriver, $globalLiveInterval;
@@ -425,11 +425,11 @@  discard block
 block discarded – undo
425 425
 	}
426 426
 
427 427
 	/**
428
-	* Gets all the spotter information based on the latest data entry and coord
429
-	*
430
-	* @return Array the spotter information
431
-	*
432
-	*/
428
+	 * Gets all the spotter information based on the latest data entry and coord
429
+	 *
430
+	 * @return Array the spotter information
431
+	 *
432
+	 */
433 433
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
434 434
 	{
435 435
 		global $globalDBdriver, $globalLiveInterval;
@@ -454,11 +454,11 @@  discard block
 block discarded – undo
454 454
 	}
455 455
 
456 456
 	/**
457
-	* Gets all the spotter information based on the latest data entry and coord
458
-	*
459
-	* @return Array the spotter information
460
-	*
461
-	*/
457
+	 * Gets all the spotter information based on the latest data entry and coord
458
+	 *
459
+	 * @return Array the spotter information
460
+	 *
461
+	 */
462 462
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
463 463
 	{
464 464
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
 	}
524 524
 
525 525
 	/**
526
-	* Gets all the spotter information based on a user's latitude and longitude
527
-	*
528
-	* @return Array the spotter information
529
-	*
530
-	*/
526
+	 * Gets all the spotter information based on a user's latitude and longitude
527
+	 *
528
+	 * @return Array the spotter information
529
+	 *
530
+	 */
531 531
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
532 532
 	{
533 533
 		$Spotter = new Spotter($this->db);
@@ -537,98 +537,98 @@  discard block
 block discarded – undo
537 537
 				return false;
538 538
 			}
539 539
 		}
540
-        if ($lng != '')
541
-                {
542
-                        if (!is_numeric($lng))
543
-                        {
544
-                                return false;
545
-                        }
546
-                }
547
-
548
-                if ($radius != '')
549
-                {
550
-                        if (!is_numeric($radius))
551
-                        {
552
-                                return false;
553
-                        }
554
-                }
540
+		if ($lng != '')
541
+				{
542
+						if (!is_numeric($lng))
543
+						{
544
+								return false;
545
+						}
546
+				}
547
+
548
+				if ($radius != '')
549
+				{
550
+						if (!is_numeric($radius))
551
+						{
552
+								return false;
553
+						}
554
+				}
555 555
 		$additional_query = '';
556
-        if ($interval != '')
557
-                {
558
-                        if (!is_string($interval))
559
-                        {
560
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
561
-			        return false;
562
-                        } else {
563
-                if ($interval == '1m')
564
-                {
565
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
566
-                } else if ($interval == '15m'){
567
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
568
-                } 
569
-            }
570
-                } else {
571
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
572
-        }
573
-
574
-                $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 
556
+		if ($interval != '')
557
+				{
558
+						if (!is_string($interval))
559
+						{
560
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
561
+					return false;
562
+						} else {
563
+				if ($interval == '1m')
564
+				{
565
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
566
+				} else if ($interval == '15m'){
567
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
568
+				} 
569
+			}
570
+				} else {
571
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
572
+		}
573
+
574
+				$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 
575 575
                    WHERE spotter_live.latitude <> '' 
576 576
                                    AND spotter_live.longitude <> '' 
577 577
                    ".$additional_query."
578 578
                    HAVING distance < :radius  
579 579
                                    ORDER BY distance";
580 580
 
581
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
581
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
582 582
 
583
-                return $spotter_array;
584
-        }
583
+				return $spotter_array;
584
+		}
585 585
 
586 586
     
587
-        /**
588
-	* Gets all the spotter information based on a particular callsign
589
-	*
590
-	* @return Array the spotter information
591
-	*
592
-	*/
587
+		/**
588
+		 * Gets all the spotter information based on a particular callsign
589
+		 *
590
+		 * @return Array the spotter information
591
+		 *
592
+		 */
593 593
 	public function getLastLiveSpotterDataByIdent($ident)
594 594
 	{
595 595
 		$Spotter = new Spotter($this->db);
596 596
 		date_default_timezone_set('UTC');
597 597
 
598 598
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
599
-                $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';
599
+				$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';
600 600
 
601 601
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
602 602
 
603 603
 		return $spotter_array;
604 604
 	}
605 605
 
606
-        /**
607
-	* Gets all the spotter information based on a particular callsign
608
-	*
609
-	* @return Array the spotter information
610
-	*
611
-	*/
606
+		/**
607
+		 * Gets all the spotter information based on a particular callsign
608
+		 *
609
+		 * @return Array the spotter information
610
+		 *
611
+		 */
612 612
 	public function getDateLiveSpotterDataByIdent($ident,$date)
613 613
 	{
614 614
 		$Spotter = new Spotter($this->db);
615 615
 		date_default_timezone_set('UTC');
616 616
 
617 617
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
618
-                $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';
618
+				$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';
619 619
 
620
-                $date = date('c',$date);
620
+				$date = date('c',$date);
621 621
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
622 622
 
623 623
 		return $spotter_array;
624 624
 	}
625 625
 
626
-        /**
627
-	* Gets last spotter information based on a particular callsign
628
-	*
629
-	* @return Array the spotter information
630
-	*
631
-	*/
626
+		/**
627
+		 * Gets last spotter information based on a particular callsign
628
+		 *
629
+		 * @return Array the spotter information
630
+		 *
631
+		 */
632 632
 	public function getLastLiveSpotterDataById($id)
633 633
 	{
634 634
 		$Spotter = new Spotter($this->db);
@@ -639,12 +639,12 @@  discard block
 block discarded – undo
639 639
 		return $spotter_array;
640 640
 	}
641 641
 
642
-        /**
643
-	* Gets last spotter information based on a particular callsign
644
-	*
645
-	* @return Array the spotter information
646
-	*
647
-	*/
642
+		/**
643
+		 * Gets last spotter information based on a particular callsign
644
+		 *
645
+		 * @return Array the spotter information
646
+		 *
647
+		 */
648 648
 	public function getDateLiveSpotterDataById($id,$date)
649 649
 	{
650 650
 		$Spotter = new Spotter($this->db);
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
 		return $spotter_array;
658 658
 	}
659 659
 
660
-        /**
661
-	* Gets altitude information based on a particular callsign
662
-	*
663
-	* @return Array the spotter information
664
-	*
665
-	*/
660
+		/**
661
+		 * Gets altitude information based on a particular callsign
662
+		 *
663
+		 * @return Array the spotter information
664
+		 *
665
+		 */
666 666
 	public function getAltitudeLiveSpotterDataByIdent($ident)
667 667
 	{
668 668
 
669 669
 		date_default_timezone_set('UTC');
670 670
 
671 671
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
672
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
672
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
673 673
 
674
-    		try {
674
+			try {
675 675
 			
676 676
 			$sth = $this->db->prepare($query);
677 677
 			$sth->execute(array(':ident' => $ident));
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
 		return $spotter_array;
685 685
 	}
686 686
 
687
-        /**
688
-	* Gets all the spotter information based on a particular id
689
-	*
690
-	* @return Array the spotter information
691
-	*
692
-	*/
687
+		/**
688
+		 * Gets all the spotter information based on a particular id
689
+		 *
690
+		 * @return Array the spotter information
691
+		 *
692
+		 */
693 693
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
694 694
 	{
695 695
 		global $globalDBdriver, $globalLiveInterval;
@@ -717,18 +717,18 @@  discard block
 block discarded – undo
717 717
 		return $spotter_array;
718 718
 	}
719 719
 
720
-        /**
721
-	* Gets all the spotter information based on a particular ident
722
-	*
723
-	* @return Array the spotter information
724
-	*
725
-	*/
720
+		/**
721
+		 * Gets all the spotter information based on a particular ident
722
+		 *
723
+		 * @return Array the spotter information
724
+		 *
725
+		 */
726 726
 	public function getAllLiveSpotterDataByIdent($ident)
727 727
 	{
728 728
 		date_default_timezone_set('UTC');
729 729
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
730 730
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
731
-    		try {
731
+			try {
732 732
 			
733 733
 			$sth = $this->db->prepare($query);
734 734
 			$sth->execute(array(':ident' => $ident));
@@ -742,23 +742,23 @@  discard block
 block discarded – undo
742 742
 
743 743
 
744 744
 	/**
745
-	* Deletes all info in the table
746
-	*
747
-	* @return String success or false
748
-	*
749
-	*/
745
+	 * Deletes all info in the table
746
+	 *
747
+	 * @return String success or false
748
+	 *
749
+	 */
750 750
 	public function deleteLiveSpotterData()
751 751
 	{
752 752
 		global $globalDBdriver;
753 753
 		if ($globalDBdriver == 'mysql') {
754 754
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
755 755
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
756
-            		//$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)";
756
+					//$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)";
757 757
 		} else {
758 758
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
759 759
 		}
760 760
         
761
-    		try {
761
+			try {
762 762
 			
763 763
 			$sth = $this->db->prepare($query);
764 764
 			$sth->execute();
@@ -770,18 +770,18 @@  discard block
 block discarded – undo
770 770
 	}
771 771
 
772 772
 	/**
773
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
774
-	*
775
-	* @return String success or false
776
-	*
777
-	*/
773
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
774
+	 *
775
+	 * @return String success or false
776
+	 *
777
+	 */
778 778
 	public function deleteLiveSpotterDataNotUpdated()
779 779
 	{
780 780
 		global $globalDBdriver, $globalDebug;
781 781
 		if ($globalDBdriver == 'mysql') {
782 782
 			//$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';
783
-    			$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";
784
-    			try {
783
+				$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";
784
+				try {
785 785
 				
786 786
 				$sth = $this->db->prepare($query);
787 787
 				$sth->execute();
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
 				return "error";
790 790
 			}
791 791
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
792
-                        $i = 0;
793
-                        $j =0;
792
+						$i = 0;
793
+						$j =0;
794 794
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
795 795
 			foreach($all as $row)
796 796
 			{
@@ -798,20 +798,20 @@  discard block
 block discarded – undo
798 798
 				$j++;
799 799
 				if ($j == 30) {
800 800
 					if ($globalDebug) echo ".";
801
-				    	try {
801
+						try {
802 802
 						
803 803
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
804 804
 						$sth->execute();
805 805
 					} catch(PDOException $e) {
806 806
 						return "error";
807 807
 					}
808
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
809
-                                	$j = 0;
808
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
809
+									$j = 0;
810 810
 				}
811 811
 				$query_delete .= "'".$row['flightaware_id']."',";
812 812
 			}
813 813
 			if ($i > 0) {
814
-    				try {
814
+					try {
815 815
 					
816 816
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
817 817
 					$sth->execute();
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 			return "success";
823 823
 		} elseif ($globalDBdriver == 'pgsql') {
824 824
 			//$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";
825
-    			//$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";
826
-    			$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)";
827
-    			try {
825
+				//$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";
826
+				$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)";
827
+				try {
828 828
 				
829 829
 				$sth = $this->db->prepare($query);
830 830
 				$sth->execute();
@@ -868,17 +868,17 @@  discard block
 block discarded – undo
868 868
 	}
869 869
 
870 870
 	/**
871
-	* Deletes all info in the table for an ident
872
-	*
873
-	* @return String success or false
874
-	*
875
-	*/
871
+	 * Deletes all info in the table for an ident
872
+	 *
873
+	 * @return String success or false
874
+	 *
875
+	 */
876 876
 	public function deleteLiveSpotterDataByIdent($ident)
877 877
 	{
878 878
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
879 879
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
880 880
         
881
-    		try {
881
+			try {
882 882
 			
883 883
 			$sth = $this->db->prepare($query);
884 884
 			$sth->execute(array(':ident' => $ident));
@@ -890,17 +890,17 @@  discard block
 block discarded – undo
890 890
 	}
891 891
 
892 892
 	/**
893
-	* Deletes all info in the table for an id
894
-	*
895
-	* @return String success or false
896
-	*
897
-	*/
893
+	 * Deletes all info in the table for an id
894
+	 *
895
+	 * @return String success or false
896
+	 *
897
+	 */
898 898
 	public function deleteLiveSpotterDataById($id)
899 899
 	{
900 900
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
901 901
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
902 902
         
903
-    		try {
903
+			try {
904 904
 			
905 905
 			$sth = $this->db->prepare($query);
906 906
 			$sth->execute(array(':id' => $id));
@@ -913,11 +913,11 @@  discard block
 block discarded – undo
913 913
 
914 914
 
915 915
 	/**
916
-	* Gets the aircraft ident within the last hour
917
-	*
918
-	* @return String the ident
919
-	*
920
-	*/
916
+	 * Gets the aircraft ident within the last hour
917
+	 *
918
+	 * @return String the ident
919
+	 *
920
+	 */
921 921
 	public function getIdentFromLastHour($ident)
922 922
 	{
923 923
 		global $globalDBdriver, $globalTimezone;
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 			$ident_result = $row['ident'];
944 944
 		}
945 945
 		return $ident_result;
946
-        }
946
+		}
947 947
 
948 948
 	/**
949
-	* Check recent aircraft
950
-	*
951
-	* @return String the ident
952
-	*
953
-	*/
949
+	 * Check recent aircraft
950
+	 *
951
+	 * @return String the ident
952
+	 *
953
+	 */
954 954
 	public function checkIdentRecent($ident)
955 955
 	{
956 956
 		global $globalDBdriver, $globalTimezone;
@@ -976,14 +976,14 @@  discard block
 block discarded – undo
976 976
 			$ident_result = $row['flightaware_id'];
977 977
 		}
978 978
 		return $ident_result;
979
-        }
979
+		}
980 980
 
981 981
 	/**
982
-	* Check recent aircraft by id
983
-	*
984
-	* @return String the ident
985
-	*
986
-	*/
982
+	 * Check recent aircraft by id
983
+	 *
984
+	 * @return String the ident
985
+	 *
986
+	 */
987 987
 	public function checkIdRecent($id)
988 988
 	{
989 989
 		global $globalDBdriver, $globalTimezone;
@@ -1009,14 +1009,14 @@  discard block
 block discarded – undo
1009 1009
 			$ident_result = $row['flightaware_id'];
1010 1010
 		}
1011 1011
 		return $ident_result;
1012
-        }
1012
+		}
1013 1013
 
1014 1014
 	/**
1015
-	* Check recent aircraft by ModeS
1016
-	*
1017
-	* @return String the ModeS
1018
-	*
1019
-	*/
1015
+	 * Check recent aircraft by ModeS
1016
+	 *
1017
+	 * @return String the ModeS
1018
+	 *
1019
+	 */
1020 1020
 	public function checkModeSRecent($modes)
1021 1021
 	{
1022 1022
 		global $globalDBdriver, $globalTimezone;
@@ -1046,11 +1046,11 @@  discard block
 block discarded – undo
1046 1046
 	}
1047 1047
 
1048 1048
 	/**
1049
-	* Gets the aircraft data from the last 20 seconds
1050
-	*
1051
-	* @return Array the spotter data
1052
-	*
1053
-	*/
1049
+	 * Gets the aircraft data from the last 20 seconds
1050
+	 *
1051
+	 * @return Array the spotter data
1052
+	 *
1053
+	 */
1054 1054
 	public function getRealTimeData($q = '')
1055 1055
 	{
1056 1056
 		global $globalDBdriver;
@@ -1092,16 +1092,16 @@  discard block
 block discarded – undo
1092 1092
 	}
1093 1093
 
1094 1094
 	/**
1095
-	* Adds a new spotter data
1096
-	*
1097
-	* @param String $flightaware_id the ID from flightaware
1098
-	* @param String $ident the flight ident
1099
-	* @param String $aircraft_icao the aircraft type
1100
-	* @param String $departure_airport_icao the departure airport
1101
-	* @param String $arrival_airport_icao the arrival airport
1102
-	* @return String success or false
1103
-	*
1104
-	*/
1095
+	 * Adds a new spotter data
1096
+	 *
1097
+	 * @param String $flightaware_id the ID from flightaware
1098
+	 * @param String $ident the flight ident
1099
+	 * @param String $aircraft_icao the aircraft type
1100
+	 * @param String $departure_airport_icao the departure airport
1101
+	 * @param String $arrival_airport_icao the arrival airport
1102
+	 * @return String success or false
1103
+	 *
1104
+	 */
1105 1105
 	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 = '')
1106 1106
 	{
1107 1107
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1244,10 +1244,10 @@  discard block
 block discarded – undo
1244 1244
 		$arrival_airport_country = '';
1245 1245
 		
1246 1246
             	
1247
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1248
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1249
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1250
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1247
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1248
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1249
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1250
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1251 1251
 		
1252 1252
 		$query = '';
1253 1253
 		if ($globalArchive) {
@@ -1268,10 +1268,10 @@  discard block
 block discarded – undo
1268 1268
 			return "error : ".$e->getMessage();
1269 1269
 		}
1270 1270
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1271
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1272
-		    $SpotterArchive = new SpotterArchive($this->db);
1273
-		    $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);
1274
-		    if ($globalDebug) echo $result.')';
1271
+			if ($globalDebug) echo '(Add to SBS archive : ';
1272
+			$SpotterArchive = new SpotterArchive($this->db);
1273
+			$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);
1274
+			if ($globalDebug) echo $result.')';
1275 1275
 		} elseif ($globalDebug && $putinarchive !== true) {
1276 1276
 			echo '(Not adding to archive)';
1277 1277
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.