Completed
Push — master ( ab6cc4...df2e86 )
by Yannick
39:41 queued 07:08
created
require/class.MarineLive.php 1 patch
Indentation   +196 added lines, -196 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();
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	/**
99
-	* Gets all the spotter information based on the latest data entry
100
-	*
101
-	* @return Array the spotter information
102
-	*
103
-	*/
99
+	 * Gets all the spotter information based on the latest data entry
100
+	 *
101
+	 * @return Array the spotter information
102
+	 *
103
+	 */
104 104
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
105 105
 	{
106 106
 		global $globalDBdriver, $globalLiveInterval;
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 	}
144 144
 
145 145
 	/**
146
-	* Gets Minimal Live Spotter data
147
-	*
148
-	* @return Array the spotter information
149
-	*
150
-	*/
146
+	 * Gets Minimal Live Spotter data
147
+	 *
148
+	 * @return Array the spotter information
149
+	 *
150
+	 */
151 151
 	public function getMinLiveMarineData($filter = array())
152 152
 	{
153 153
 		global $globalDBdriver, $globalLiveInterval;
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	}
178 178
 
179 179
 	/**
180
-	* Gets Minimal Live Spotter data since xx seconds
181
-	*
182
-	* @return Array the spotter information
183
-	*
184
-	*/
180
+	 * Gets Minimal Live Spotter data since xx seconds
181
+	 *
182
+	 * @return Array the spotter information
183
+	 *
184
+	 */
185 185
 	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
186 186
 	{
187 187
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
 	}
262 262
 
263 263
 	/**
264
-	* Gets number of latest data entry
265
-	*
266
-	* @return String number of entry
267
-	*
268
-	*/
264
+	 * Gets number of latest data entry
265
+	 *
266
+	 * @return String number of entry
267
+	 *
268
+	 */
269 269
 	public function getLiveMarineCount($filter = array())
270 270
 	{
271 271
 		global $globalDBdriver, $globalLiveInterval;
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	}
291 291
 
292 292
 	/**
293
-	* Gets all the spotter information based on the latest data entry and coord
294
-	*
295
-	* @return Array the spotter information
296
-	*
297
-	*/
293
+	 * Gets all the spotter information based on the latest data entry and coord
294
+	 *
295
+	 * @return Array the spotter information
296
+	 *
297
+	 */
298 298
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
299 299
 	{
300 300
 		global $globalDBdriver, $globalLiveInterval;
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 	}
319 319
 
320 320
 	/**
321
-	* Gets all the spotter information based on the latest data entry and coord
322
-	*
323
-	* @return Array the spotter information
324
-	*
325
-	*/
321
+	 * Gets all the spotter information based on the latest data entry and coord
322
+	 *
323
+	 * @return Array the spotter information
324
+	 *
325
+	 */
326 326
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
327 327
 	{
328 328
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	/**
394
-	* Gets all the spotter information based on a user's latitude and longitude
395
-	*
396
-	* @return Array the spotter information
397
-	*
398
-	*/
394
+	 * Gets all the spotter information based on a user's latitude and longitude
395
+	 *
396
+	 * @return Array the spotter information
397
+	 *
398
+	 */
399 399
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
400 400
 	{
401 401
 		$Marine = new Marine($this->db);
@@ -408,75 +408,75 @@  discard block
 block discarded – undo
408 408
 		if ($lng != '')
409 409
 		{
410 410
 			if (!is_numeric($lng))
411
-                        {
412
-                                return false;
413
-                        }
414
-                }
415
-
416
-                if ($radius != '')
417
-                {
418
-                        if (!is_numeric($radius))
419
-                        {
420
-                                return false;
421
-                        }
422
-                }
411
+						{
412
+								return false;
413
+						}
414
+				}
415
+
416
+				if ($radius != '')
417
+				{
418
+						if (!is_numeric($radius))
419
+						{
420
+								return false;
421
+						}
422
+				}
423 423
 		$additional_query = '';
424 424
 		if ($interval != '')
425
-                {
426
-                        if (!is_string($interval))
427
-                        {
428
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
429
-			        return false;
430
-                        } else {
431
-                if ($interval == '1m')
432
-                {
433
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
434
-                } else if ($interval == '15m'){
435
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
436
-                } 
437
-            }
438
-                } else {
439
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
440
-        }
441
-
442
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
425
+				{
426
+						if (!is_string($interval))
427
+						{
428
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
429
+					return false;
430
+						} else {
431
+				if ($interval == '1m')
432
+				{
433
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
434
+				} else if ($interval == '15m'){
435
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
436
+				} 
437
+			}
438
+				} else {
439
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
440
+		}
441
+
442
+				$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
443 443
                    WHERE marine_live.latitude <> '' 
444 444
                                    AND marine_live.longitude <> '' 
445 445
                    ".$additional_query."
446 446
                    HAVING distance < :radius  
447 447
                                    ORDER BY distance";
448 448
 
449
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
450 450
 
451
-                return $spotter_array;
452
-        }
451
+				return $spotter_array;
452
+		}
453 453
 
454 454
     
455
-        /**
456
-	* Gets all the spotter information based on a particular callsign
457
-	*
458
-	* @return Array the spotter information
459
-	*
460
-	*/
455
+		/**
456
+		 * Gets all the spotter information based on a particular callsign
457
+		 *
458
+		 * @return Array the spotter information
459
+		 *
460
+		 */
461 461
 	public function getLastLiveMarineDataByIdent($ident)
462 462
 	{
463 463
 		$Marine = new Marine($this->db);
464 464
 		date_default_timezone_set('UTC');
465 465
 
466 466
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
467
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
467
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
468 468
 
469 469
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
470 470
 
471 471
 		return $spotter_array;
472 472
 	}
473 473
 
474
-        /**
475
-	* Gets all the spotter information based on a particular callsign
476
-	*
477
-	* @return Array the spotter information
478
-	*
479
-	*/
474
+		/**
475
+		 * Gets all the spotter information based on a particular callsign
476
+		 *
477
+		 * @return Array the spotter information
478
+		 *
479
+		 */
480 480
 	public function getDateLiveMarineDataByIdent($ident,$date)
481 481
 	{
482 482
 		$Marine = new Marine($this->db);
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 	}
490 490
 
491 491
 	/**
492
-	* Gets all the spotter information based on a particular MMSI
493
-	*
494
-	* @return Array the spotter information
495
-	*
496
-	*/
492
+	 * Gets all the spotter information based on a particular MMSI
493
+	 *
494
+	 * @return Array the spotter information
495
+	 *
496
+	 */
497 497
 	public function getDateLiveMarineDataByMMSI($mmsi,$date)
498 498
 	{
499 499
 		$Marine = new Marine($this->db);
@@ -505,51 +505,51 @@  discard block
 block discarded – undo
505 505
 		return $spotter_array;
506 506
 	}
507 507
 
508
-        /**
509
-	* Gets last spotter information based on a particular callsign
510
-	*
511
-	* @return Array the spotter information
512
-	*
513
-	*/
508
+		/**
509
+		 * Gets last spotter information based on a particular callsign
510
+		 *
511
+		 * @return Array the spotter information
512
+		 *
513
+		 */
514 514
 	public function getLastLiveMarineDataById($id)
515 515
 	{
516 516
 		$Marine = new Marine($this->db);
517 517
 		date_default_timezone_set('UTC');
518 518
 
519 519
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
520
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
520
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
521 521
 
522 522
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
523 523
 
524 524
 		return $spotter_array;
525 525
 	}
526 526
 
527
-        /**
528
-	* Gets last spotter information based on a particular callsign
529
-	*
530
-	* @return Array the spotter information
531
-	*
532
-	*/
527
+		/**
528
+		 * Gets last spotter information based on a particular callsign
529
+		 *
530
+		 * @return Array the spotter information
531
+		 *
532
+		 */
533 533
 	public function getDateLiveMarineDataById($id,$date)
534 534
 	{
535 535
 		$Marine = new Marine($this->db);
536 536
 		date_default_timezone_set('UTC');
537 537
 
538 538
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
539
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
540
-                $date = date('c',$date);
539
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
540
+				$date = date('c',$date);
541 541
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
542 542
 
543 543
 		return $spotter_array;
544 544
 	}
545 545
 
546 546
 
547
-        /**
548
-	* Gets all the spotter information based on a particular id
549
-	*
550
-	* @return Array the spotter information
551
-	*
552
-	*/
547
+		/**
548
+		 * Gets all the spotter information based on a particular id
549
+		 *
550
+		 * @return Array the spotter information
551
+		 *
552
+		 */
553 553
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
554 554
 	{
555 555
 		global $globalDBdriver, $globalLiveInterval;
@@ -577,18 +577,18 @@  discard block
 block discarded – undo
577 577
 		return $spotter_array;
578 578
 	}
579 579
 
580
-        /**
581
-	* Gets all the spotter information based on a particular ident
582
-	*
583
-	* @return Array the spotter information
584
-	*
585
-	*/
580
+		/**
581
+		 * Gets all the spotter information based on a particular ident
582
+		 *
583
+		 * @return Array the spotter information
584
+		 *
585
+		 */
586 586
 	public function getAllLiveMarineDataByIdent($ident)
587 587
 	{
588 588
 		date_default_timezone_set('UTC');
589 589
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
590 590
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
591
-    		try {
591
+			try {
592 592
 			
593 593
 			$sth = $this->db->prepare($query);
594 594
 			$sth->execute(array(':ident' => $ident));
@@ -602,23 +602,23 @@  discard block
 block discarded – undo
602 602
 
603 603
 
604 604
 	/**
605
-	* Deletes all info in the table
606
-	*
607
-	* @return String success or false
608
-	*
609
-	*/
605
+	 * Deletes all info in the table
606
+	 *
607
+	 * @return String success or false
608
+	 *
609
+	 */
610 610
 	public function deleteLiveMarineData()
611 611
 	{
612 612
 		global $globalDBdriver;
613 613
 		if ($globalDBdriver == 'mysql') {
614 614
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
615 615
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
616
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
616
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
617 617
 		} else {
618 618
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
619 619
 		}
620 620
         
621
-    		try {
621
+			try {
622 622
 			
623 623
 			$sth = $this->db->prepare($query);
624 624
 			$sth->execute();
@@ -630,18 +630,18 @@  discard block
 block discarded – undo
630 630
 	}
631 631
 
632 632
 	/**
633
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
634
-	*
635
-	* @return String success or false
636
-	*
637
-	*/
633
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
634
+	 *
635
+	 * @return String success or false
636
+	 *
637
+	 */
638 638
 	public function deleteLiveMarineDataNotUpdated()
639 639
 	{
640 640
 		global $globalDBdriver, $globalDebug;
641 641
 		if ($globalDBdriver == 'mysql') {
642 642
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
643
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
644
-    			try {
643
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
644
+				try {
645 645
 				
646 646
 				$sth = $this->db->prepare($query);
647 647
 				$sth->execute();
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
 				return "error";
650 650
 			}
651 651
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
652
-                        $i = 0;
653
-                        $j =0;
652
+						$i = 0;
653
+						$j =0;
654 654
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655 655
 			foreach($all as $row)
656 656
 			{
@@ -658,20 +658,20 @@  discard block
 block discarded – undo
658 658
 				$j++;
659 659
 				if ($j == 30) {
660 660
 					if ($globalDebug) echo ".";
661
-				    	try {
661
+						try {
662 662
 						
663 663
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
664 664
 						$sth->execute();
665 665
 					} catch(PDOException $e) {
666 666
 						return "error";
667 667
 					}
668
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
669
-                                	$j = 0;
668
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
669
+									$j = 0;
670 670
 				}
671 671
 				$query_delete .= "'".$row['fammarine_id']."',";
672 672
 			}
673 673
 			if ($i > 0) {
674
-    				try {
674
+					try {
675 675
 					
676 676
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
677 677
 					$sth->execute();
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
 			return "success";
683 683
 		} elseif ($globalDBdriver == 'pgsql') {
684 684
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
685
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
686
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
687
-    			try {
685
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
686
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
687
+				try {
688 688
 				
689 689
 				$sth = $this->db->prepare($query);
690 690
 				$sth->execute();
@@ -728,17 +728,17 @@  discard block
 block discarded – undo
728 728
 	}
729 729
 
730 730
 	/**
731
-	* Deletes all info in the table for an ident
732
-	*
733
-	* @return String success or false
734
-	*
735
-	*/
731
+	 * Deletes all info in the table for an ident
732
+	 *
733
+	 * @return String success or false
734
+	 *
735
+	 */
736 736
 	public function deleteLiveMarineDataByIdent($ident)
737 737
 	{
738 738
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
739 739
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
740 740
         
741
-    		try {
741
+			try {
742 742
 			
743 743
 			$sth = $this->db->prepare($query);
744 744
 			$sth->execute(array(':ident' => $ident));
@@ -750,17 +750,17 @@  discard block
 block discarded – undo
750 750
 	}
751 751
 
752 752
 	/**
753
-	* Deletes all info in the table for an id
754
-	*
755
-	* @return String success or false
756
-	*
757
-	*/
753
+	 * Deletes all info in the table for an id
754
+	 *
755
+	 * @return String success or false
756
+	 *
757
+	 */
758 758
 	public function deleteLiveMarineDataById($id)
759 759
 	{
760 760
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
761 761
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
762 762
         
763
-    		try {
763
+			try {
764 764
 			
765 765
 			$sth = $this->db->prepare($query);
766 766
 			$sth->execute(array(':id' => $id));
@@ -773,11 +773,11 @@  discard block
 block discarded – undo
773 773
 
774 774
 
775 775
 	/**
776
-	* Gets the marine races
777
-	*
778
-	* @return Array all races
779
-	*
780
-	*/
776
+	 * Gets the marine races
777
+	 *
778
+	 * @return Array all races
779
+	 *
780
+	 */
781 781
 	public function getAllRaces()
782 782
 	{
783 783
 		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
@@ -787,11 +787,11 @@  discard block
 block discarded – undo
787 787
 	}
788 788
 
789 789
 	/**
790
-	* Gets the aircraft ident within the last hour
791
-	*
792
-	* @return String the ident
793
-	*
794
-	*/
790
+	 * Gets the aircraft ident within the last hour
791
+	 *
792
+	 * @return String the ident
793
+	 *
794
+	 */
795 795
 	public function getIdentFromLastHour($ident)
796 796
 	{
797 797
 		global $globalDBdriver, $globalTimezone;
@@ -817,14 +817,14 @@  discard block
 block discarded – undo
817 817
 			$ident_result = $row['ident'];
818 818
 		}
819 819
 		return $ident_result;
820
-        }
820
+		}
821 821
 
822 822
 	/**
823
-	* Check recent aircraft
824
-	*
825
-	* @return String the ident
826
-	*
827
-	*/
823
+	 * Check recent aircraft
824
+	 *
825
+	 * @return String the ident
826
+	 *
827
+	 */
828 828
 	public function checkIdentRecent($ident)
829 829
 	{
830 830
 		global $globalDBdriver, $globalTimezone;
@@ -850,14 +850,14 @@  discard block
 block discarded – undo
850 850
 			$ident_result = $row['fammarine_id'];
851 851
 		}
852 852
 		return $ident_result;
853
-        }
853
+		}
854 854
 
855 855
 	/**
856
-	* Check recent aircraft by id
857
-	*
858
-	* @return String the ident
859
-	*
860
-	*/
856
+	 * Check recent aircraft by id
857
+	 *
858
+	 * @return String the ident
859
+	 *
860
+	 */
861 861
 	public function checkIdRecent($id)
862 862
 	{
863 863
 		global $globalDBdriver, $globalTimezone;
@@ -883,14 +883,14 @@  discard block
 block discarded – undo
883 883
 			$ident_result = $row['fammarine_id'];
884 884
 		}
885 885
 		return $ident_result;
886
-        }
886
+		}
887 887
 
888 888
 	/**
889
-	* Check recent aircraft by mmsi
890
-	*
891
-	* @return String the ident
892
-	*
893
-	*/
889
+	 * Check recent aircraft by mmsi
890
+	 *
891
+	 * @return String the ident
892
+	 *
893
+	 */
894 894
 	public function checkMMSIRecent($mmsi)
895 895
 	{
896 896
 		global $globalDBdriver, $globalTimezone;
@@ -916,19 +916,19 @@  discard block
 block discarded – undo
916 916
 			$ident_result = $row['fammarine_id'];
917 917
 		}
918 918
 		return $ident_result;
919
-        }
919
+		}
920 920
 
921 921
 	/**
922
-	* Adds a new spotter data
923
-	*
924
-	* @param String $fammarine_id the ID from flightaware
925
-	* @param String $ident the flight ident
926
-	* @param String $aircraft_icao the aircraft type
927
-	* @param String $departure_airport_icao the departure airport
928
-	* @param String $arrival_airport_icao the arrival airport
929
-	* @return String success or false
930
-	*
931
-	*/
922
+	 * Adds a new spotter data
923
+	 *
924
+	 * @param String $fammarine_id the ID from flightaware
925
+	 * @param String $ident the flight ident
926
+	 * @param String $aircraft_icao the aircraft type
927
+	 * @param String $departure_airport_icao the departure airport
928
+	 * @param String $arrival_airport_icao the arrival airport
929
+	 * @return String success or false
930
+	 *
931
+	 */
932 932
 	public function addLiveMarineData($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 = '')
933 933
 	{
934 934
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1006,10 +1006,10 @@  discard block
 block discarded – undo
1006 1006
 		if ($typeid == '') $typeid = NULL;
1007 1007
 		if ($statusid == '') $statusid = NULL;
1008 1008
 
1009
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1010
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1011
-            	if ($arrival_date == '') $arrival_date = NULL;
1012
-            	$query = '';
1009
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1010
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1011
+				if ($arrival_date == '') $arrival_date = NULL;
1012
+				$query = '';
1013 1013
 		if ($globalArchive) {
1014 1014
 			if ($globalDebug) echo '-- Delete previous data -- ';
1015 1015
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Stats.php');
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class MarineImport {
16
-    private $all_tracked = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_tracked = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
27 27
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
28
-	    $Connection = new Connection($dbc);
29
-	    $this->db = $Connection->db();
30
-	    date_default_timezone_set('UTC');
28
+		$Connection = new Connection($dbc);
29
+		$this->db = $Connection->db();
30
+		date_default_timezone_set('UTC');
31 31
 	}
32 32
 	// Get previous source stats
33 33
 	/*
@@ -46,57 +46,57 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	*/
48 48
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
49
-	    $APRSMarine = new APRSMarine();
50
-	    //$APRSSpotter->connect();
49
+		$APRSMarine = new APRSMarine();
50
+		//$APRSSpotter->connect();
51
+	}
51 52
 	}
52
-    }
53 53
 
54
-    public function checkAll() {
54
+	public function checkAll() {
55 55
 	global $globalDebug, $globalNoDB;
56 56
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
57
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
58
-	    foreach ($this->all_tracked as $key => $flight) {
57
+		if ($globalDebug) echo "Update last seen tracked data...\n";
58
+		foreach ($this->all_tracked as $key => $flight) {
59 59
 		if (isset($this->all_tracked[$key]['id'])) {
60
-		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61
-    		    $Marine = new Marine($this->db);
62
-    		    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
60
+			//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61
+				$Marine = new Marine($this->db);
62
+				$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
63
+		}
63 64
 		}
64
-	    }
65 65
 	}
66
-    }
66
+	}
67 67
 
68
-    public function del() {
68
+	public function del() {
69 69
 	global $globalDebug, $globalNoDB, $globalNoImport;
70 70
 	// Delete old infos
71 71
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
72 72
 	foreach ($this->all_tracked as $key => $flight) {
73
-    	    if (isset($flight['lastupdate'])) {
74
-        	if ($flight['lastupdate'] < (time()-3000)) {
75
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76
-            		if (isset($this->all_tracked[$key]['id'])) {
77
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
78
-			    /*
73
+			if (isset($flight['lastupdate'])) {
74
+			if ($flight['lastupdate'] < (time()-3000)) {
75
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76
+					if (isset($this->all_tracked[$key]['id'])) {
77
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
78
+				/*
79 79
 			    $MarineLive = new MarineLive();
80 80
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
81 81
 			    $MarineLive->db = null;
82 82
 			    */
83
-            		    //$real_arrival = $this->arrival($key);
84
-            		    $Marine = new Marine($this->db);
85
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
83
+						//$real_arrival = $this->arrival($key);
84
+						$Marine = new Marine($this->db);
85
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
86 86
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
87 87
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
88
-			    }
89
-			    // Put in archive
88
+				}
89
+				// Put in archive
90 90
 //				$Marine->db = null;
91 91
 			}
92
-            	    }
93
-            	    unset($this->all_tracked[$key]);
94
-    	        }
95
-	    }
96
-        }
97
-    }
92
+					}
93
+					unset($this->all_tracked[$key]);
94
+				}
95
+		}
96
+		}
97
+	}
98 98
 
99
-    public function add($line) {
99
+	public function add($line) {
100 100
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval;
101 101
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
102 102
 	date_default_timezone_set('UTC');
@@ -105,104 +105,104 @@  discard block
 block discarded – undo
105 105
 	
106 106
 	// SBS format is CSV format
107 107
 	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
108
-	    //print_r($line);
109
-  	    if (isset($line['mmsi']) || isset($line['id'])) {
108
+		//print_r($line);
109
+  		if (isset($line['mmsi']) || isset($line['id'])) {
110 110
 
111 111
 		
112 112
 		// Increment message number
113 113
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
114
-		    $current_date = date('Y-m-d');
115
-		    if (isset($line['source_name'])) $source = $line['source_name'];
116
-		    else $source = '';
117
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
118
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
119
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
120
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
114
+			$current_date = date('Y-m-d');
115
+			if (isset($line['source_name'])) $source = $line['source_name'];
116
+			else $source = '';
117
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
118
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
119
+				$this->stats[$current_date][$source]['msg']['date'] = time();
120
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
122 122
 		}
123 123
 		
124 124
 		
125 125
 		$Common = new Common();
126 126
 		$AIS = new AIS();
127
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
128
-	        else $id = trim($line['id']);
127
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
128
+			else $id = trim($line['id']);
129 129
 		
130 130
 		if (!isset($this->all_tracked[$id])) {
131
-		    $this->all_tracked[$id] = array();
132
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
133
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => ''));
134
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135
-		    if (!isset($line['id'])) {
131
+			$this->all_tracked[$id] = array();
132
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
133
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => ''));
134
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135
+			if (!isset($line['id'])) {
136 136
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
137 137
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
138
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
139
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
138
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
139
+			if ($globalAllTracked !== FALSE) $dataFound = true;
140 140
 		}
141 141
 		
142 142
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
143
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
144
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
143
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
144
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
145 145
 			$Marine = new Marine($this->db);
146 146
 			$identity = $Marine->getIdentity($line['mmsi']);
147 147
 			if (!empty($identity)) {
148
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
-			    $this->all_tracked[$id]['type'] = $identity['type'];
150
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
148
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
+				$this->all_tracked[$id]['type'] = $identity['type'];
150
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
151 151
 			}
152 152
 			//print_r($identity);
153 153
 			unset($Marine);
154 154
 			//$dataFound = true;
155
-		    }
155
+			}
156 156
 		}
157 157
 		if (isset($line['type_id'])) {
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
159
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
159
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
160 160
 		}
161 161
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
162
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
164 164
 		}
165 165
 		if (isset($line['status']) && $line['status'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
167 167
 		}
168 168
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
170
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
169
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
170
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
171 171
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
172
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
173 173
 				$Marine = new Marine($this->db);
174 174
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
175 175
 				unset($Marine);
176
-			    }
176
+				}
177
+			}
177 178
 			}
178
-		    }
179 179
 		}
180 180
 
181 181
 
182 182
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
183
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
183
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
184 184
 		}
185 185
 		if (isset($line['imo']) && $line['imo'] != '') {
186
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
186
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
187 187
 		}
188 188
 		if (isset($line['callsign']) && $line['callsign'] != '') {
189
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
189
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
190 190
 		}
191 191
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
192
-		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
192
+			if (!isset($this->all_tracked[$id]['arrival_code'])) {
193 193
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
194 194
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
195 195
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
196
-			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
196
+				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
197 197
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
198
-				    $Marine = new Marine($this->db);
199
-				    $fromsource = NULL;
200
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
201
-				    $Marine->db = null;
198
+					$Marine = new Marine($this->db);
199
+					$fromsource = NULL;
200
+					$Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
201
+					$Marine->db = null;
202
+				}
202 203
 				}
203
-			    }
204 204
 			}
205
-		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
205
+			} elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
206 206
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
207 207
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
208 208
 			if (!isset($line['id'])) {
@@ -210,38 +210,38 @@  discard block
 block discarded – undo
210 210
 				$this->all_tracked[$id]['forcenew'] = 1;
211 211
 				$this->all_tracked[$id]['addedMarine'] = 0;
212 212
 			}
213
-		    }
213
+			}
214 214
 		}
215 215
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
216
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
216
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
217 217
 		}
218 218
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
219
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
219
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
220 220
 		}
221 221
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
222
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
222
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
223 223
 		}
224 224
 		if (isset($line['race_id']) && $line['race_id'] != '') {
225
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
225
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
226 226
 		}
227 227
 		if (isset($line['race_name']) && $line['race_name'] != '') {
228
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
228
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
229 229
 		}
230 230
 
231 231
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
232 232
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
233
-		    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
233
+			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
234 234
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
235
-			    $timeelapsed = microtime(true);
236
-			    $Marine = new Marine($this->db);
237
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
238
-			    $Marine->db = null;
235
+				$timeelapsed = microtime(true);
236
+				$Marine = new Marine($this->db);
237
+				$Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
238
+				$Marine->db = null;
239
+			}
239 240
 			}
240
-		    }
241
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
242
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
241
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
242
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
243 243
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
244
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
244
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
245 245
 				$timeelapsed = microtime(true);
246 246
 				$Marine = new Marine($this->db);
247 247
 				$fromsource = NULL;
@@ -249,20 +249,20 @@  discard block
 block discarded – undo
249 249
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
250 250
 				$Marine->db = null;
251 251
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
252
-			    }
252
+				}
253
+			}
253 254
 			}
254
-		    }
255
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
255
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
256 256
 		}
257 257
 
258 258
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
259
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
259
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
260 260
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
261
-		    } else {
261
+			} else {
262 262
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
263 263
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
264 264
 				return '';
265
-		    }
265
+			}
266 266
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
267 267
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
268 268
 			return '';
@@ -279,33 +279,33 @@  discard block
 block discarded – undo
279 279
 
280 280
 
281 281
 		if (isset($line['speed'])) {
282
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
283
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
282
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
283
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
284 284
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
285
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
286
-		    if ($distance > 1000 && $distance < 10000) {
285
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
286
+			if ($distance > 1000 && $distance < 10000) {
287 287
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
288 288
 			$speed = $speed*3.6;
289 289
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
290 290
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
291
-		    }
291
+			}
292 292
 		}
293 293
 
294
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
295
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
296
-	    	    else unset($timediff);
297
-	    	    if ($this->tmd > 5 ||
298
-	    		!isset($timediff) ||
299
-	    		$timediff > $globalLiveInterval ||
300
-	    		(
301
-	    		    $timediff > 30 && 
302
-	    		    isset($this->all_tracked[$id]['latitude']) &&
303
-	    		    isset($this->all_tracked[$id]['longitude']) &&
304
-	    		    $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
305
-	    		)
306
-	    		) {
294
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
295
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
296
+				else unset($timediff);
297
+				if ($this->tmd > 5 ||
298
+				!isset($timediff) ||
299
+				$timediff > $globalLiveInterval ||
300
+				(
301
+					$timediff > 30 && 
302
+					isset($this->all_tracked[$id]['latitude']) &&
303
+					isset($this->all_tracked[$id]['longitude']) &&
304
+					$Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
305
+				)
306
+				) {
307 307
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
308
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
308
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
309 309
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
310 310
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
311 311
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -313,192 +313,192 @@  discard block
 block discarded – undo
313 313
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
314 314
 				$timeelapsed = microtime(true);
315 315
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
316
-				    $Marine = new Marine($this->db);
317
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
318
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
319
-				    $Marine->db = null;
320
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
316
+					$Marine = new Marine($this->db);
317
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
318
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
319
+					$Marine->db = null;
320
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
321 321
 				}
322 322
 				$this->tmd = 0;
323 323
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
324
-			    }
324
+				}
325 325
 			}
326 326
 
327 327
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
328 328
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
329 329
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
330
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
331
-				    $dataFound = true;
332
-				    $this->all_tracked[$id]['time_last_coord'] = time();
330
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
331
+					$dataFound = true;
332
+					$this->all_tracked[$id]['time_last_coord'] = time();
333 333
 				}
334 334
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
335 335
 			}
336 336
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
337
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
337
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
338 338
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
339 339
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
340
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
341
-				    $dataFound = true;
342
-				    $this->all_tracked[$id]['time_last_coord'] = time();
340
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
341
+					$dataFound = true;
342
+					$this->all_tracked[$id]['time_last_coord'] = time();
343 343
 				}
344 344
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
345 345
 			}
346 346
 
347
-		    } else if ($globalDebug && $timediff > 20) {
347
+			} else if ($globalDebug && $timediff > 20) {
348 348
 			$this->tmd = $this->tmd + 1;
349 349
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
350 350
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
351 351
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
352 352
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
353
-		    }
353
+			}
354 354
 		}
355 355
 		if (isset($line['last_update']) && $line['last_update'] != '') {
356
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
357
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
356
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
357
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
358 358
 		}
359 359
 		if (isset($line['format_source']) && $line['format_source'] != '') {
360
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
360
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
361 361
 		}
362 362
 		if (isset($line['source_name']) && $line['source_name'] != '') {
363
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
363
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
364 364
 		}
365 365
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
366
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
366
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
367 367
 		}
368 368
 		
369 369
 		if (isset($line['heading']) && $line['heading'] != '') {
370
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
371
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
372
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
373
-		    //$dataFound = true;
370
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
371
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
372
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
373
+			//$dataFound = true;
374 374
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
375
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
376
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
377
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
378
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
375
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
376
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
377
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
378
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
379 379
   		}
380 380
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
381 381
 
382 382
 
383 383
 
384 384
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
385
-		    $this->all_tracked[$id]['lastupdate'] = time();
386
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
387
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
388
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
385
+			$this->all_tracked[$id]['lastupdate'] = time();
386
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
387
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
388
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
389 389
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
390
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
391
-				    $timeelapsed = microtime(true);
392
-				    $MarineLive = new MarineLive($this->db);
393
-				    if (isset($line['id'])) {
390
+					if ($globalDebug) echo "Check if vessel is already in DB...";
391
+					$timeelapsed = microtime(true);
392
+					$MarineLive = new MarineLive($this->db);
393
+					if (isset($line['id'])) {
394 394
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
395 395
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
396
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
396
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
397 397
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
398 398
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
399
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
400 400
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
401 401
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
402
-				    } else $recent_ident = '';
403
-				    $MarineLive->db=null;
404
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
405
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
402
+					} else $recent_ident = '';
403
+					$MarineLive->db=null;
404
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
405
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
406 406
 				} else $recent_ident = '';
407
-			    } else {
407
+				} else {
408 408
 				$recent_ident = '';
409 409
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
410
-			    }
411
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
412
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
413
-			    {
410
+				}
411
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
412
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
413
+				{
414 414
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
415 415
 				//adds the spotter data for the archive
416
-				    $highlight = '';
417
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
418
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
416
+					$highlight = '';
417
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
418
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
419 419
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
420
-					    $timeelapsed = microtime(true);
421
-					    $Marine = new Marine($this->db);
422
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
423
-					    $Marine->db = null;
424
-					    if ($globalDebug && isset($result)) echo $result."\n";
425
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
420
+						$timeelapsed = microtime(true);
421
+						$Marine = new Marine($this->db);
422
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
423
+						$Marine->db = null;
424
+						if ($globalDebug && isset($result)) echo $result."\n";
425
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426
+					}
426 427
 					}
427
-				    }
428
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
428
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
429 429
 					// Add source stat in DB
430 430
 					$Stats = new Stats($this->db);
431 431
 					if (!empty($this->stats)) {
432
-					    if ($globalDebug) echo 'Add source stats : ';
433
-				    	    foreach($this->stats as $date => $data) {
432
+						if ($globalDebug) echo 'Add source stats : ';
433
+							foreach($this->stats as $date => $data) {
434 434
 						foreach($data as $source => $sourced) {
435
-					    	    //print_r($sourced);
436
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
437
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
438
-				    		    if (isset($sourced['msg'])) {
439
-				    			if (time() - $sourced['msg']['date'] > 10) {
440
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
441
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
442
-			    			    	    unset($this->stats[$date][$source]['msg']);
443
-			    				}
444
-			    			    }
445
-			    			}
446
-			    			if ($date != date('Y-m-d')) {
447
-			    			    unset($this->stats[$date]);
448
-			    			}
449
-				    	    }
450
-				    	    if ($globalDebug) echo 'Done'."\n";
435
+								//print_r($sourced);
436
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
437
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
438
+								if (isset($sourced['msg'])) {
439
+								if (time() - $sourced['msg']['date'] > 10) {
440
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
441
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
442
+										unset($this->stats[$date][$source]['msg']);
443
+								}
444
+								}
445
+							}
446
+							if ($date != date('Y-m-d')) {
447
+								unset($this->stats[$date]);
448
+							}
449
+							}
450
+							if ($globalDebug) echo 'Done'."\n";
451 451
 					}
452 452
 					$Stats->db = null;
453
-				    }
453
+					}
454 454
 				    
455
-				    $this->del();
455
+					$this->del();
456 456
 				//$ignoreImport = false;
457 457
 				$this->all_tracked[$id]['addedMarine'] = 1;
458 458
 				//print_r($this->all_tracked[$id]);
459 459
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
460
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
461
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
462
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
460
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
461
+					//MarineLive->deleteLiveMarineDataNotUpdated();
462
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
463 463
 					$MarineLive = new MarineLive($this->db);
464 464
 					$MarineLive->deleteLiveMarineData();
465 465
 					$MarineLive->db=null;
466 466
 					if ($globalDebug) echo " Done\n";
467
-				    }
468
-				    $this->last_delete = time();
467
+					}
468
+					$this->last_delete = time();
469 469
 				}
470
-			    } elseif ($recent_ident != '') {
470
+				} elseif ($recent_ident != '') {
471 471
 				$this->all_tracked[$id]['id'] = $recent_ident;
472 472
 				$this->all_tracked[$id]['addedMarine'] = 1;
473 473
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
474
-				    if (isset($globalDaemon) && !$globalDaemon) {
474
+					if (isset($globalDaemon) && !$globalDaemon) {
475 475
 					$Marine = new Marine($this->db);
476 476
 					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
477 477
 					$Marine->db = null;
478
-				    }
478
+					}
479 479
 				}
480 480
 				
481
-			    }
481
+				}
482 482
 			}
483
-		    }
484
-		    //adds the spotter LIVE data
485
-		    if ($globalDebug) {
483
+			}
484
+			//adds the spotter LIVE data
485
+			if ($globalDebug) {
486 486
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
487
-		    }
488
-		    $ignoreImport = false;
487
+			}
488
+			$ignoreImport = false;
489 489
 
490
-		    if (!$ignoreImport) {
490
+			if (!$ignoreImport) {
491 491
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
492 492
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
493 493
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
494
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
494
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
495 495
 					$timeelapsed = microtime(true);
496 496
 					$MarineLive = new MarineLive($this->db);
497 497
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
498 498
 					$MarineLive->db = null;
499 499
 					if ($globalDebug) echo $result."\n";
500 500
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
501
-				    }
501
+					}
502 502
 				}
503 503
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
504 504
 					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 					if ($stats_heading == 16) $stats_heading = 0;
534 534
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
535 535
 						for ($i=0;$i<=15;$i++) {
536
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
536
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
537 537
 						}
538 538
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
539 539
 					} else {
@@ -546,11 +546,11 @@  discard block
 block discarded – undo
546 546
 					//var_dump($this->stats);
547 547
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
548 548
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
549
-						    end($this->stats[$current_date][$source]['hist']);
550
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
549
+							end($this->stats[$current_date][$source]['hist']);
550
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
551 551
 						} else $mini = 0;
552 552
 						for ($i=$mini;$i<=$distance;$i+=10) {
553
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
553
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
554 554
 						}
555 555
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
556 556
 					} else {
@@ -566,24 +566,24 @@  discard block
 block discarded – undo
566 566
 			
567 567
 			
568 568
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
569
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
569
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
570 570
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
571 571
 				$MarineLive = new MarineLive($this->db);
572 572
 				$MarineLive->deleteLiveMarineDataNotUpdated();
573 573
 				$MarineLive->db = null;
574 574
 				//MarineLive->deleteLiveMarineData();
575 575
 				if ($globalDebug) echo " Done\n";
576
-			    }
577
-			    $this->last_delete_hourly = time();
576
+				}
577
+				$this->last_delete_hourly = time();
578 578
 			}
579 579
 			
580
-		    }
581
-		    //$ignoreImport = false;
580
+			}
581
+			//$ignoreImport = false;
582 582
 		}
583 583
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
584 584
 		if ($send) return $this->all_tracked[$id];
585
-	    }
585
+		}
586
+	}
586 587
 	}
587
-    }
588 588
 }
589 589
 ?>
Please login to merge, or discard this patch.
live-czml.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -50,30 +50,30 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
 function quaternionrotate($heading, $attitude = 0, $bank = 0) {
53
-    // Assuming the angles are in radians.
54
-    $c1 = cos($heading/2);
55
-    $s1 = sin($heading/2);
56
-    $c2 = cos($attitude/2);
57
-    $s2 = sin($attitude/2);
58
-    $c3 = cos($bank/2);
59
-    $s3 = sin($bank/2);
60
-    $c1c2 = $c1*$c2;
61
-    $s1s2 = $s1*$s2;
62
-    $w =$c1c2*$c3 - $s1s2*$s3;
63
-    $x =$c1c2*$s3 + $s1s2*$c3;
64
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
65
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
66
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
53
+	// Assuming the angles are in radians.
54
+	$c1 = cos($heading/2);
55
+	$s1 = sin($heading/2);
56
+	$c2 = cos($attitude/2);
57
+	$s2 = sin($attitude/2);
58
+	$c3 = cos($bank/2);
59
+	$s3 = sin($bank/2);
60
+	$c1c2 = $c1*$c2;
61
+	$s1s2 = $s1*$s2;
62
+	$w =$c1c2*$c3 - $s1s2*$s3;
63
+	$x =$c1c2*$s3 + $s1s2*$c3;
64
+	$y =$s1*$c2*$c3 + $c1*$s2*$s3;
65
+	$z =$c1*$s2*$c3 - $s1*$c2*$s3;
66
+	return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
67 67
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
68 68
 
69 69
 }
70 70
 
71 71
 
72 72
 if (isset($_GET['download'])) {
73
-    if ($_GET['download'] == "true")
74
-    {
73
+	if ($_GET['download'] == "true")
74
+	{
75 75
 	header('Content-disposition: attachment; filename="flightairmap.json"');
76
-    }
76
+	}
77 77
 }
78 78
 header('Content-Type: text/javascript');
79 79
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if (isset($_GET['coord']) && $_GET['coord'] != '') {
185 185
 		$coord = explode(',',$_GET['coord']);
186 186
 		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
187
-		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
187
+			&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
188 188
 			$coord = array();
189 189
 		}
190 190
 	}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') {
209 209
 		$coord = explode(',',$_GET['coord']);
210 210
 		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
211
-		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
211
+			&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
212 212
 			$coord = array();
213 213
 		}
214 214
 	}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') {
230 230
 		$coord = explode(',',$_GET['coord']);
231 231
 		if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
232
-		    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
232
+			&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) {
233 233
 			$coord = array();
234 234
 		}
235 235
 	}
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
 			$image = "images/placeholder_thumb.png";
351 351
 		}
352 352
 
353
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
354
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
355
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
356
-                if ($prev_flightaware_id != $id) {
353
+				if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
354
+				elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
355
+				elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
356
+				if ($prev_flightaware_id != $id) {
357 357
 			if ($prev_flightaware_id != '') {
358 358
 				/*
359 359
 				if ($nblatlong == 1) {
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
450 450
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
451 451
 						} else $aircraft_shadow = '';
452
-	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
452
+							$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
453 453
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true' && isset($_COOKIE['IconColor'])) {
454 454
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
455 455
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
481 481
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
482 482
 						}
483
-    						$output .= '},';
483
+							$output .= '},';
484 484
 					} elseif (isset($modelsdb[$aircraft_icao]) && $aircraft_icao != '') {
485 485
 						$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_icao].'","scale" : '.$scale.',"minimumPixelSize": '.$minimumpixelsize.'';
486 486
 						$output .= ',"heightReference": "'.$heightrelative.'"';
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
489 489
 							$output .= ',"color": {"rgba" : ['.$rgb[0].','.$rgb[1].','.$rgb[2].',255]}';
490 490
 						}
491
-    						$output .= '},';
491
+							$output .= '},';
492 492
 					} elseif ($aircraft_icao != '') {
493 493
 						$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
494 494
 						if (isset($aircraft_info[0]['engine_type'])) {
Please login to merge, or discard this patch.