Completed
Push — master ( 39c0a3...691470 )
by Yannick
28:40
created
require/class.SpotterLive.php 1 patch
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	/**
136
-	* Gets all the spotter information based on the latest data entry
137
-	*
138
-	* @return Array the spotter information
139
-	*
140
-	*/
136
+	 * Gets all the spotter information based on the latest data entry
137
+	 *
138
+	 * @return Array the spotter information
139
+	 *
140
+	 */
141 141
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
142 142
 	{
143 143
 		global $globalDBdriver, $globalLiveInterval;
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	/**
183
-	* Gets Minimal Live Spotter data
184
-	*
185
-	* @return Array the spotter information
186
-	*
187
-	*/
183
+	 * Gets Minimal Live Spotter data
184
+	 *
185
+	 * @return Array the spotter information
186
+	 *
187
+	 */
188 188
 	public function getMinLiveSpotterData($filter = array())
189 189
 	{
190 190
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	/**
224
-	* Gets Minimal Live Spotter data since xx seconds
225
-	*
226
-	* @return Array the spotter information
227
-	*
228
-	*/
224
+	 * Gets Minimal Live Spotter data since xx seconds
225
+	 *
226
+	 * @return Array the spotter information
227
+	 *
228
+	 */
229 229
 	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false)
230 230
 	{
231 231
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 	}
309 309
 
310 310
 	/**
311
-	* Gets number of latest data entry
312
-	*
313
-	* @return String number of entry
314
-	*
315
-	*/
311
+	 * Gets number of latest data entry
312
+	 *
313
+	 * @return String number of entry
314
+	 *
315
+	 */
316 316
 	public function getLiveSpotterCount($filter = array())
317 317
 	{
318 318
 		global $globalDBdriver, $globalLiveInterval;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	}
340 340
 
341 341
 	/**
342
-	* Gets all the spotter information based on the latest data entry and coord
343
-	*
344
-	* @return Array the spotter information
345
-	*
346
-	*/
342
+	 * Gets all the spotter information based on the latest data entry and coord
343
+	 *
344
+	 * @return Array the spotter information
345
+	 *
346
+	 */
347 347
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
348 348
 	{
349 349
 		global $globalDBdriver, $globalLiveInterval;
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Gets all the spotter information based on the latest data entry and coord
372
-	*
373
-	* @return Array the spotter information
374
-	*
375
-	*/
371
+	 * Gets all the spotter information based on the latest data entry and coord
372
+	 *
373
+	 * @return Array the spotter information
374
+	 *
375
+	 */
376 376
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
377 377
 	{
378 378
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	}
438 438
 
439 439
 	/**
440
-	* Gets all the spotter information based on a user's latitude and longitude
441
-	*
442
-	* @return Array the spotter information
443
-	*
444
-	*/
440
+	 * Gets all the spotter information based on a user's latitude and longitude
441
+	 *
442
+	 * @return Array the spotter information
443
+	 *
444
+	 */
445 445
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
446 446
 	{
447 447
 		$Spotter = new Spotter($this->db);
@@ -451,98 +451,98 @@  discard block
 block discarded – undo
451 451
 				return false;
452 452
 			}
453 453
 		}
454
-        if ($lng != '')
455
-                {
456
-                        if (!is_numeric($lng))
457
-                        {
458
-                                return false;
459
-                        }
460
-                }
461
-
462
-                if ($radius != '')
463
-                {
464
-                        if (!is_numeric($radius))
465
-                        {
466
-                                return false;
467
-                        }
468
-                }
454
+		if ($lng != '')
455
+				{
456
+						if (!is_numeric($lng))
457
+						{
458
+								return false;
459
+						}
460
+				}
461
+
462
+				if ($radius != '')
463
+				{
464
+						if (!is_numeric($radius))
465
+						{
466
+								return false;
467
+						}
468
+				}
469 469
 		$additional_query = '';
470
-        if ($interval != '')
471
-                {
472
-                        if (!is_string($interval))
473
-                        {
474
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
475
-			        return false;
476
-                        } else {
477
-                if ($interval == '1m')
478
-                {
479
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
480
-                } else if ($interval == '15m'){
481
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
482
-                } 
483
-            }
484
-                } else {
485
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
486
-        }
487
-
488
-                $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 
470
+		if ($interval != '')
471
+				{
472
+						if (!is_string($interval))
473
+						{
474
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
475
+					return false;
476
+						} else {
477
+				if ($interval == '1m')
478
+				{
479
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
480
+				} else if ($interval == '15m'){
481
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
482
+				} 
483
+			}
484
+				} else {
485
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
486
+		}
487
+
488
+				$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 
489 489
                    WHERE spotter_live.latitude <> '' 
490 490
                                    AND spotter_live.longitude <> '' 
491 491
                    ".$additional_query."
492 492
                    HAVING distance < :radius  
493 493
                                    ORDER BY distance";
494 494
 
495
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
495
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
496 496
 
497
-                return $spotter_array;
498
-        }
497
+				return $spotter_array;
498
+		}
499 499
 
500 500
     
501
-        /**
502
-	* Gets all the spotter information based on a particular callsign
503
-	*
504
-	* @return Array the spotter information
505
-	*
506
-	*/
501
+		/**
502
+		 * Gets all the spotter information based on a particular callsign
503
+		 *
504
+		 * @return Array the spotter information
505
+		 *
506
+		 */
507 507
 	public function getLastLiveSpotterDataByIdent($ident)
508 508
 	{
509 509
 		$Spotter = new Spotter($this->db);
510 510
 		date_default_timezone_set('UTC');
511 511
 
512 512
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
513
-                $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';
513
+				$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';
514 514
 
515 515
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
516 516
 
517 517
 		return $spotter_array;
518 518
 	}
519 519
 
520
-        /**
521
-	* Gets all the spotter information based on a particular callsign
522
-	*
523
-	* @return Array the spotter information
524
-	*
525
-	*/
520
+		/**
521
+		 * Gets all the spotter information based on a particular callsign
522
+		 *
523
+		 * @return Array the spotter information
524
+		 *
525
+		 */
526 526
 	public function getDateLiveSpotterDataByIdent($ident,$date)
527 527
 	{
528 528
 		$Spotter = new Spotter($this->db);
529 529
 		date_default_timezone_set('UTC');
530 530
 
531 531
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
532
-                $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';
532
+				$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';
533 533
 
534
-                $date = date('c',$date);
534
+				$date = date('c',$date);
535 535
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
536 536
 
537 537
 		return $spotter_array;
538 538
 	}
539 539
 
540
-        /**
541
-	* Gets last spotter information based on a particular callsign
542
-	*
543
-	* @return Array the spotter information
544
-	*
545
-	*/
540
+		/**
541
+		 * Gets last spotter information based on a particular callsign
542
+		 *
543
+		 * @return Array the spotter information
544
+		 *
545
+		 */
546 546
 	public function getLastLiveSpotterDataById($id)
547 547
 	{
548 548
 		$Spotter = new Spotter($this->db);
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
 		return $spotter_array;
554 554
 	}
555 555
 
556
-        /**
557
-	* Gets last spotter information based on a particular callsign
558
-	*
559
-	* @return Array the spotter information
560
-	*
561
-	*/
556
+		/**
557
+		 * Gets last spotter information based on a particular callsign
558
+		 *
559
+		 * @return Array the spotter information
560
+		 *
561
+		 */
562 562
 	public function getDateLiveSpotterDataById($id,$date)
563 563
 	{
564 564
 		$Spotter = new Spotter($this->db);
@@ -571,21 +571,21 @@  discard block
 block discarded – undo
571 571
 		return $spotter_array;
572 572
 	}
573 573
 
574
-        /**
575
-	* Gets altitude information based on a particular callsign
576
-	*
577
-	* @return Array the spotter information
578
-	*
579
-	*/
574
+		/**
575
+		 * Gets altitude information based on a particular callsign
576
+		 *
577
+		 * @return Array the spotter information
578
+		 *
579
+		 */
580 580
 	public function getAltitudeLiveSpotterDataByIdent($ident)
581 581
 	{
582 582
 
583 583
 		date_default_timezone_set('UTC');
584 584
 
585 585
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
586
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
586
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
587 587
 
588
-    		try {
588
+			try {
589 589
 			
590 590
 			$sth = $this->db->prepare($query);
591 591
 			$sth->execute(array(':ident' => $ident));
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
 		return $spotter_array;
599 599
 	}
600 600
 
601
-        /**
602
-	* Gets all the spotter information based on a particular id
603
-	*
604
-	* @return Array the spotter information
605
-	*
606
-	*/
601
+		/**
602
+		 * Gets all the spotter information based on a particular id
603
+		 *
604
+		 * @return Array the spotter information
605
+		 *
606
+		 */
607 607
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
608 608
 	{
609 609
 		global $globalDBdriver, $globalLiveInterval;
@@ -631,18 +631,18 @@  discard block
 block discarded – undo
631 631
 		return $spotter_array;
632 632
 	}
633 633
 
634
-        /**
635
-	* Gets all the spotter information based on a particular ident
636
-	*
637
-	* @return Array the spotter information
638
-	*
639
-	*/
634
+		/**
635
+		 * Gets all the spotter information based on a particular ident
636
+		 *
637
+		 * @return Array the spotter information
638
+		 *
639
+		 */
640 640
 	public function getAllLiveSpotterDataByIdent($ident)
641 641
 	{
642 642
 		date_default_timezone_set('UTC');
643 643
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
644 644
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
645
-    		try {
645
+			try {
646 646
 			
647 647
 			$sth = $this->db->prepare($query);
648 648
 			$sth->execute(array(':ident' => $ident));
@@ -656,23 +656,23 @@  discard block
 block discarded – undo
656 656
 
657 657
 
658 658
 	/**
659
-	* Deletes all info in the table
660
-	*
661
-	* @return String success or false
662
-	*
663
-	*/
659
+	 * Deletes all info in the table
660
+	 *
661
+	 * @return String success or false
662
+	 *
663
+	 */
664 664
 	public function deleteLiveSpotterData()
665 665
 	{
666 666
 		global $globalDBdriver;
667 667
 		if ($globalDBdriver == 'mysql') {
668 668
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
669 669
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
670
-            		//$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)";
670
+					//$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)";
671 671
 		} else {
672 672
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
673 673
 		}
674 674
         
675
-    		try {
675
+			try {
676 676
 			
677 677
 			$sth = $this->db->prepare($query);
678 678
 			$sth->execute();
@@ -684,18 +684,18 @@  discard block
 block discarded – undo
684 684
 	}
685 685
 
686 686
 	/**
687
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
688
-	*
689
-	* @return String success or false
690
-	*
691
-	*/
687
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
688
+	 *
689
+	 * @return String success or false
690
+	 *
691
+	 */
692 692
 	public function deleteLiveSpotterDataNotUpdated()
693 693
 	{
694 694
 		global $globalDBdriver, $globalDebug;
695 695
 		if ($globalDBdriver == 'mysql') {
696 696
 			//$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';
697
-    			$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";
698
-    			try {
697
+				$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";
698
+				try {
699 699
 				
700 700
 				$sth = $this->db->prepare($query);
701 701
 				$sth->execute();
@@ -703,8 +703,8 @@  discard block
 block discarded – undo
703 703
 				return "error";
704 704
 			}
705 705
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
706
-                        $i = 0;
707
-                        $j =0;
706
+						$i = 0;
707
+						$j =0;
708 708
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
709 709
 			foreach($all as $row)
710 710
 			{
@@ -712,20 +712,20 @@  discard block
 block discarded – undo
712 712
 				$j++;
713 713
 				if ($j == 30) {
714 714
 					if ($globalDebug) echo ".";
715
-				    	try {
715
+						try {
716 716
 						
717 717
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
718 718
 						$sth->execute();
719 719
 					} catch(PDOException $e) {
720 720
 						return "error";
721 721
 					}
722
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
723
-                                	$j = 0;
722
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
723
+									$j = 0;
724 724
 				}
725 725
 				$query_delete .= "'".$row['flightaware_id']."',";
726 726
 			}
727 727
 			if ($i > 0) {
728
-    				try {
728
+					try {
729 729
 					
730 730
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
731 731
 					$sth->execute();
@@ -736,9 +736,9 @@  discard block
 block discarded – undo
736 736
 			return "success";
737 737
 		} elseif ($globalDBdriver == 'pgsql') {
738 738
 			//$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";
739
-    			//$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";
740
-    			$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)";
741
-    			try {
739
+				//$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";
740
+				$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)";
741
+				try {
742 742
 				
743 743
 				$sth = $this->db->prepare($query);
744 744
 				$sth->execute();
@@ -782,17 +782,17 @@  discard block
 block discarded – undo
782 782
 	}
783 783
 
784 784
 	/**
785
-	* Deletes all info in the table for an ident
786
-	*
787
-	* @return String success or false
788
-	*
789
-	*/
785
+	 * Deletes all info in the table for an ident
786
+	 *
787
+	 * @return String success or false
788
+	 *
789
+	 */
790 790
 	public function deleteLiveSpotterDataByIdent($ident)
791 791
 	{
792 792
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
793 793
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
794 794
         
795
-    		try {
795
+			try {
796 796
 			
797 797
 			$sth = $this->db->prepare($query);
798 798
 			$sth->execute(array(':ident' => $ident));
@@ -804,17 +804,17 @@  discard block
 block discarded – undo
804 804
 	}
805 805
 
806 806
 	/**
807
-	* Deletes all info in the table for an id
808
-	*
809
-	* @return String success or false
810
-	*
811
-	*/
807
+	 * Deletes all info in the table for an id
808
+	 *
809
+	 * @return String success or false
810
+	 *
811
+	 */
812 812
 	public function deleteLiveSpotterDataById($id)
813 813
 	{
814 814
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
815 815
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
816 816
         
817
-    		try {
817
+			try {
818 818
 			
819 819
 			$sth = $this->db->prepare($query);
820 820
 			$sth->execute(array(':id' => $id));
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 
828 828
 
829 829
 	/**
830
-	* Gets the aircraft ident within the last hour
831
-	*
832
-	* @return String the ident
833
-	*
834
-	*/
830
+	 * Gets the aircraft ident within the last hour
831
+	 *
832
+	 * @return String the ident
833
+	 *
834
+	 */
835 835
 	public function getIdentFromLastHour($ident)
836 836
 	{
837 837
 		global $globalDBdriver, $globalTimezone;
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
 			$ident_result = $row['ident'];
858 858
 		}
859 859
 		return $ident_result;
860
-        }
860
+		}
861 861
 
862 862
 	/**
863
-	* Check recent aircraft
864
-	*
865
-	* @return String the ident
866
-	*
867
-	*/
863
+	 * Check recent aircraft
864
+	 *
865
+	 * @return String the ident
866
+	 *
867
+	 */
868 868
 	public function checkIdentRecent($ident)
869 869
 	{
870 870
 		global $globalDBdriver, $globalTimezone;
@@ -890,14 +890,14 @@  discard block
 block discarded – undo
890 890
 			$ident_result = $row['flightaware_id'];
891 891
 		}
892 892
 		return $ident_result;
893
-        }
893
+		}
894 894
 
895 895
 	/**
896
-	* Check recent aircraft by id
897
-	*
898
-	* @return String the ident
899
-	*
900
-	*/
896
+	 * Check recent aircraft by id
897
+	 *
898
+	 * @return String the ident
899
+	 *
900
+	 */
901 901
 	public function checkIdRecent($id)
902 902
 	{
903 903
 		global $globalDBdriver, $globalTimezone;
@@ -923,14 +923,14 @@  discard block
 block discarded – undo
923 923
 			$ident_result = $row['flightaware_id'];
924 924
 		}
925 925
 		return $ident_result;
926
-        }
926
+		}
927 927
 
928 928
 	/**
929
-	* Check recent aircraft by ModeS
930
-	*
931
-	* @return String the ModeS
932
-	*
933
-	*/
929
+	 * Check recent aircraft by ModeS
930
+	 *
931
+	 * @return String the ModeS
932
+	 *
933
+	 */
934 934
 	public function checkModeSRecent($modes)
935 935
 	{
936 936
 		global $globalDBdriver, $globalTimezone;
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 	}
961 961
 
962 962
 	/**
963
-	* Gets the aircraft data from the last 20 seconds
964
-	*
965
-	* @return Array the spotter data
966
-	*
967
-	*/
963
+	 * Gets the aircraft data from the last 20 seconds
964
+	 *
965
+	 * @return Array the spotter data
966
+	 *
967
+	 */
968 968
 	public function getRealTimeData($q = '')
969 969
 	{
970 970
 		global $globalDBdriver;
@@ -1006,16 +1006,16 @@  discard block
 block discarded – undo
1006 1006
 	}
1007 1007
 
1008 1008
 	/**
1009
-	* Adds a new spotter data
1010
-	*
1011
-	* @param String $flightaware_id the ID from flightaware
1012
-	* @param String $ident the flight ident
1013
-	* @param String $aircraft_icao the aircraft type
1014
-	* @param String $departure_airport_icao the departure airport
1015
-	* @param String $arrival_airport_icao the arrival airport
1016
-	* @return String success or false
1017
-	*
1018
-	*/
1009
+	 * Adds a new spotter data
1010
+	 *
1011
+	 * @param String $flightaware_id the ID from flightaware
1012
+	 * @param String $ident the flight ident
1013
+	 * @param String $aircraft_icao the aircraft type
1014
+	 * @param String $departure_airport_icao the departure airport
1015
+	 * @param String $arrival_airport_icao the arrival airport
1016
+	 * @return String success or false
1017
+	 *
1018
+	 */
1019 1019
 	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 = '')
1020 1020
 	{
1021 1021
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1158,10 +1158,10 @@  discard block
 block discarded – undo
1158 1158
 		$arrival_airport_country = '';
1159 1159
 		
1160 1160
             	
1161
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1162
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1163
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1164
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1161
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1162
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1163
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1164
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1165 1165
 		
1166 1166
 		$query = '';
1167 1167
 		if ($globalArchive) {
@@ -1182,10 +1182,10 @@  discard block
 block discarded – undo
1182 1182
 			return "error : ".$e->getMessage();
1183 1183
 		}
1184 1184
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1185
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1186
-		    $SpotterArchive = new SpotterArchive($this->db);
1187
-		    $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);
1188
-		    if ($globalDebug) echo $result.')';
1185
+			if ($globalDebug) echo '(Add to SBS archive : ';
1186
+			$SpotterArchive = new SpotterArchive($this->db);
1187
+			$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);
1188
+			if ($globalDebug) echo $result.')';
1189 1189
 		} elseif ($globalDebug && $putinarchive !== true) {
1190 1190
 			echo '(Not adding to archive)';
1191 1191
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.